Skip to contentSkip to conversation

support a new type of PMIC,including two chips(rk817 and rk809)

PATCH In review Tony Xie 3 participants 12 messages Jun 21, 2019 – Jun 27, 2019

Subsystems (6)
lore
Share & tools
lore

Tony Xie

author
#0 lore raw

v10 cover support a new type of PMIC,including two chips(rk817 and rk809)

Most of functions and registers of the rk817 and rk808 are the same, so they can share allmost all codes.

Their specifications are as follows:
1) The RK809 and RK809 consist of 5 DCDCs, 9 LDOs and have the same
registers
for these components except dcdc5.
2) The dcdc5 is a boost dcdc for RK817 and is a buck for RK809.
3) The RK817 has one switch but The Rk809 has two.

Changes in V2:
1. initialize the pm_pwroff_fn to NULL.
2. use EXPORT_SYMBOL_GPL to export pm_power_off_prepare.
3. change patch 2/3/4/5 subjects.

Changes in V3
1. change patch 4 subjects
2. replace pr_ with dev_ for printing in patch 2
3. modify switch1 and switch2 configs in patch 2
4. explain gpio information for rk809 and rk817 in patch 4

Changes in V4:
1. modify some codes for patch 2 and patch 5 according to comments
2. add reviewer mail lists for patch 3 and 4

Changes in V5:
modify some codes for patch 1 according to reveiw comments for v3.
1) remove the pm_power_off_prepare() and replace with shutdown
call-back from syscore
2) move the macro REGMAP_IRQ_M into the regmap.h and rename it
REGMAP_IRQ_LINE
3) make some dev_warn() log clear

Changes in V6:
modify some codes according to reveiw comments for v5.

Changes in V7:
modify some codes for patch 2 according to reveiw comments.

Changes in V8:
For helping me promote this work, Heiko send the V8

Changes in V9:
1.base on the V8
2.modify some codes according to reveiw comments for V8 from Mark Brown

Changes in V10:
And Ack from Mark Brown <[email protected]> for parch 3

Tony Xie (6):
mfd: rk808: remove the id_table
mfd: rk808: Add RK817 and RK809 support
regulator: rk808: add RK809 and RK817 support.
dt-bindings: mfd: rk808: Add binding information for RK809 and RK817.
rtc: rk808: add RK809 and RK817 support.
clk: RK808: add RK809 and RK817 support.

 .../devicetree/bindings/mfd/rk808.txt         |  44 ++
 drivers/clk/Kconfig                           |   9 +-
 drivers/clk/clk-rk808.c                       |  64 +-
 drivers/mfd/Kconfig                           |   6 +-
 drivers/mfd/rk808.c                           | 199 +++++-
 drivers/regulator/Kconfig                     |   4 +-
 drivers/regulator/rk808-regulator.c           | 646 +++++++++++++++++-
 drivers/rtc/Kconfig                           |   4 +-
 drivers/rtc/rtc-rk808.c                       |  68 +-
 include/linux/mfd/rk808.h                     | 175 +++++
 10 files changed, 1155 insertions(+), 64 deletions(-)
Signature · 1 line
2.17.1
author
#1 lore raw

PATCH v10 1/6 mfd: rk808: remove the id_table

Remove the id_table because it's not used.

---
 drivers/mfd/rk808.c | 9 ---------
 1 file changed, 9 deletions(-)
drivers/mfd/rk808.c +0 -9
index 216fbf6adec9..94377782d208 100644
@@ -568,14 +568,6 @@ static int rk808_remove(struct i2c_client *client)
 	return 0;
 }
 
-static const struct i2c_device_id rk808_ids[] = {
-	{ "rk805" },
-	{ "rk808" },
-	{ "rk818" },
-	{ },
-};
-MODULE_DEVICE_TABLE(i2c, rk808_ids);
-
 static struct i2c_driver rk808_i2c_driver = {
 	.driver = {
 		.name = "rk808",
@@ -583,7 +575,6 @@ static struct i2c_driver rk808_i2c_driver = {
 	},
 	.probe    = rk808_probe,
 	.remove   = rk808_remove,
-	.id_table = rk808_ids,
 };
 
 module_i2c_driver(rk808_i2c_driver);
Signature · 1 line
2.17.1
#2 lore raw

Re: [PATCH v10 1/6] mfd: rk808: remove the id_table

Quoted 6 lines · Tony Xie

Remove the id_table because it's not used.

---
 drivers/mfd/rk808.c | 9 ---------
 1 file changed, 9 deletions(-)

Also, this patch already appears to be applied.

Once patches are taken from the set, you should avoid resending them.

Quoted 27 lines
drivers/mfd/rk808.c +0 -9
index 216fbf6adec9..94377782d208 100644
@@ -568,14 +568,6 @@ static int rk808_remove(struct i2c_client *client)
 	return 0;
 }
 
-static const struct i2c_device_id rk808_ids[] = {
-	{ "rk805" },
-	{ "rk808" },
-	{ "rk818" },
-	{ },
-};
-MODULE_DEVICE_TABLE(i2c, rk808_ids);
-
 static struct i2c_driver rk808_i2c_driver = {
 	.driver = {
 		.name = "rk808",
@@ -583,7 +575,6 @@ static struct i2c_driver rk808_i2c_driver = {
 	},
 	.probe    = rk808_probe,
 	.remove   = rk808_remove,
-	.id_table = rk808_ids,
 };
 
 module_i2c_driver(rk808_i2c_driver);
Signature · 4 lines
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
author
#3 lore raw

PATCH v10 2/6 mfd: rk808: Add RK817 and RK809 support

In reply to Tony Xie

The RK809 and RK817 are a Power Management IC (PMIC) for multimedia and handheld devices. They contains the following components:
- Regulators
- RTC
- Clocking

Both RK809 and RK817 chips are using a similar register map, so we can reuse the RTC and Clocking functionality. Most of regulators have a some implementation also.

---
 drivers/mfd/Kconfig       |   6 +-
 drivers/mfd/rk808.c       | 192 +++++++++++++++++++++++++++++++++++++-
 include/linux/mfd/rk808.h | 172 ++++++++++++++++++++++++++++++++++
 3 files changed, 364 insertions(+), 6 deletions(-)
drivers/mfd/Kconfig +3 -3
index 8c5dfdce4326..a8a2833407b1 100644
@@ -1006,14 +1006,14 @@ config MFD_RC5T583
 	  different functionality of the device.
 
 config MFD_RK808
-	tristate "Rockchip RK805/RK808/RK818 Power Management Chip"
+	tristate "Rockchip RK805/RK808/RK809/RK817/RK818 Power Management Chip"
 	depends on I2C && OF
 	select MFD_CORE
 	select REGMAP_I2C
 	select REGMAP_IRQ
 	help
-	  If you say yes here you get support for the RK805, RK808 and RK818
-	  Power Management chips.
+	  If you say yes here you get support for the RK805, RK808, RK809,
+	  RK817 and RK818 Power Management chips.
 	  This driver provides common support for accessing the device
 	  through I2C interface. The device supports multiple sub-devices
 	  including interrupts, RTC, LDO & DCDC regulators, and onkey.
drivers/mfd/rk808.c +189 -3

293 lines not on this page · raw message

include/linux/mfd/rk808.h +172 -0

190 lines not on this page · raw message

Signature · 1 line
2.17.1
author
#4 lore raw

PATCH v10 3/6 regulator: rk808: add RK809 and RK817 support.

In reply to Tony Xie

Add support for the rk809 and rk817 regulator driver. Their specifications are as follows:
1. The RK809 and RK809 consist of 5 DCDCs, 9 LDOs
and have the same registers for these components except dcdc5.
2. The dcdc5 is a boost dcdc for RK817 and is a buck for RK809.
3. The RK817 has one switch but The Rk809 has two.

The output voltages are configurable and are meant to supply power to the main processor and other components.

---
 drivers/regulator/Kconfig           |   4 +-
 drivers/regulator/rk808-regulator.c | 646 ++++++++++++++++++++++++++--
 include/linux/mfd/rk808.h           |   3 +
 3 files changed, 625 insertions(+), 28 deletions(-)
drivers/regulator/Kconfig +2 -2
index ee60a222f5eb..3bfd820afcdd 100644
@@ -742,11 +742,11 @@ config REGULATOR_RC5T583
 	  outputs which can be controlled by i2c communication.
 
 config REGULATOR_RK808
-	tristate "Rockchip RK805/RK808/RK818 Power regulators"
+	tristate "Rockchip RK805/RK808/RK809/RK817/RK818 Power regulators"
 	depends on MFD_RK808
 	help
 	  Select this option to enable the power regulator of ROCKCHIP
-	  PMIC RK805,RK808 and RK818.
+	  PMIC RK805,RK809&RK817,RK808 and RK818.
 	  This driver supports the control of different power rails of device
 	  through regulator interface. The device supports multiple DCDC/LDO
 	  outputs which can be controlled by i2c communication.
drivers/regulator/rk808-regulator.c +620 -26

726 lines not on this page · raw message

include/linux/mfd/rk808.h +3 -0
index 0fd9eedf3c20..2a9cd01691b2 100644
@@ -396,7 +396,10 @@ enum rk805_reg {
 #define SHUTDOWN_FUN			(0x2 << 2)
 #define SLEEP_FUN			(0x1 << 2)
 #define RK8XX_ID_MSK			0xfff0
+#define PWM_MODE_MSK			BIT(7)
 #define FPWM_MODE			BIT(7)
+#define AUTO_PWM_MODE			0
+
 enum rk817_reg_id {
 	RK817_ID_DCDC1 = 0,
 	RK817_ID_DCDC2,
Signature · 1 line
2.17.1
maintainer
#5 lore raw

PATCH 3/6 regulator: rk808: add RK809 and RK817 support.

Add support for the rk809 and rk817 regulator driver. Their specifications are as follows:
1. The RK809 and RK809 consist of 5 DCDCs, 9 LDOs
and have the same registers for these components except dcdc5.
2. The dcdc5 is a boost dcdc for RK817 and is a buck for RK809.
3. The RK817 has one switch but The Rk809 has two.

The output voltages are configurable and are meant to supply power to the main processor and other components.

---
Hi Lee,

to maybe help that along as Tony is probably asleep right now, I just did the rebase of this patch on top of 5.2-rc1 .

The other patches seemed to apply fine.

 drivers/regulator/Kconfig           |   4 +-
 drivers/regulator/rk808-regulator.c | 646 ++++++++++++++++++++++++++--
 include/linux/mfd/rk808.h           |   3 +
 3 files changed, 625 insertions(+), 28 deletions(-)
drivers/regulator/Kconfig +2 -2
index 6c37f0df9323..214a958ff3e5 100644
@@ -762,11 +762,11 @@ config REGULATOR_RC5T583
 	  outputs which can be controlled by i2c communication.
 
 config REGULATOR_RK808
-	tristate "Rockchip RK805/RK808/RK818 Power regulators"
+	tristate "Rockchip RK805/RK808/RK809/RK817/RK818 Power regulators"
 	depends on MFD_RK808
 	help
 	  Select this option to enable the power regulator of ROCKCHIP
-	  PMIC RK805,RK808 and RK818.
+	  PMIC RK805,RK809&RK817,RK808 and RK818.
 	  This driver supports the control of different power rails of device
 	  through regulator interface. The device supports multiple DCDC/LDO
 	  outputs which can be controlled by i2c communication.
drivers/regulator/rk808-regulator.c +620 -26

726 lines not on this page · raw message

include/linux/mfd/rk808.h +3 -0
index 0fd9eedf3c20..2a9cd01691b2 100644
@@ -396,7 +396,10 @@ enum rk805_reg {
 #define SHUTDOWN_FUN			(0x2 << 2)
 #define SLEEP_FUN			(0x1 << 2)
 #define RK8XX_ID_MSK			0xfff0
+#define PWM_MODE_MSK			BIT(7)
 #define FPWM_MODE			BIT(7)
+#define AUTO_PWM_MODE			0
+
 enum rk817_reg_id {
 	RK817_ID_DCDC1 = 0,
 	RK817_ID_DCDC2,
Signature · 1 line
2.20.1
author
#6 lore raw

PATCH v10 4/6 dt-bindings: mfd: rk808: Add binding information for RK809 and RK817.

In reply to Tony Xie

Add device tree bindings documentation for Rockchip's RK809 & RK817 PMIC.

---
 .../devicetree/bindings/mfd/rk808.txt         | 44 +++++++++++++++++++
 1 file changed, 44 insertions(+)
Documentation/devicetree/bindings/mfd/rk808.txt +44 -0
index 1683ec3245bc..04df07f6f793 100644
@@ -3,11 +3,15 @@ RK8XX Power Management Integrated Circuit
 The rk8xx family current members:
 rk805
 rk808
+rk809
+rk817
 rk818
 
 Required properties:
 - compatible: "rockchip,rk805"
 - compatible: "rockchip,rk808"
+- compatible: "rockchip,rk809"
+- compatible: "rockchip,rk817"
 - compatible: "rockchip,rk818"
 - reg: I2C slave address
 - interrupts: the interrupt outputs of the controller.
@@ -45,6 +49,23 @@ Optional RK808 properties:
   the gpio controller. If DVS GPIOs aren't present, voltage changes will happen
   very quickly with no slow ramp time.
 
+Optional shared RK809 and RK817 properties:
+- vcc1-supply:  The input supply for DCDC_REG1
+- vcc2-supply:  The input supply for DCDC_REG2
+- vcc3-supply:  The input supply for DCDC_REG3
+- vcc4-supply:  The input supply for DCDC_REG4
+- vcc5-supply:  The input supply for LDO_REG1, LDO_REG2, LDO_REG3
+- vcc6-supply:  The input supply for LDO_REG4, LDO_REG5, LDO_REG6
+- vcc7-supply:  The input supply for LDO_REG7, LDO_REG8, LDO_REG9
+
+Optional RK809 properties:
+- vcc8-supply:  The input supply for SWITCH_REG1
+- vcc9-supply:  The input supply for DCDC_REG5, SWITCH_REG2
+
+Optional RK817 properties:
+- vcc8-supply:  The input supply for BOOST
+- vcc9-supply:  The input supply for OTG_SWITCH
+
 Optional RK818 properties:
 - vcc1-supply:  The input supply for DCDC_REG1
 - vcc2-supply:  The input supply for DCDC_REG2
@@ -86,6 +107,21 @@ number as described in RK808 datasheet.
 	- SWITCH_REGn
 		- valid values for n are 1 to 2
 
+Following regulators of the RK809 and RK817 PMIC blocks are supported. Note that
+the 'n' in regulator name, as in DCDC_REGn or LDOn, represents the DCDC or LDO
+number as described in RK809 and RK817 datasheets.
+
+	- DCDC_REGn
+		- valid values for n are 1 to 5 for RK809.
+		- valid values for n are 1 to 4 for RK817.
+	- LDO_REGn
+		- valid values for n are 1 to 9 for RK809.
+		- valid values for n are 1 to 9 for RK817.
+	- SWITCH_REGn
+		- valid values for n are 1 to 2 for RK809.
+	- BOOST for RK817
+	- OTG_SWITCH for RK817
+
 Following regulators of the RK818 PMIC block are supported. Note that
 the 'n' in regulator name, as in DCDC_REGn or LDOn, represents the DCDC or LDO
 number as described in RK818 datasheet.
@@ -98,6 +134,14 @@ number as described in RK818 datasheet.
 	- HDMI_SWITCH
 	- OTG_SWITCH
 
+It is necessary to configure three pins for both the RK809 and RK817, the three
+pins are "gpio_ts" "gpio_gt" "gpio_slp".
+	The gpio_gt and gpio_ts pins support the gpio function.
+	The gpio_slp pin is for controlling the pmic states, as below:
+		- reset
+		- power down
+		- sleep
+
 Standard regulator bindings are used inside regulator subnodes. Check
   Documentation/devicetree/bindings/regulator/regulator.txt
 for more details
Signature · 1 line
2.17.1
author
#7 lore raw

PATCH v10 5/6 rtc: rk808: add RK809 and RK817 support.

In reply to Tony Xie

RK809 and RK817 are power management IC chips for multimedia products. Most of their functions and registers are same, including the rtc.

---
 drivers/rtc/Kconfig     |  4 +--
 drivers/rtc/rtc-rk808.c | 68 ++++++++++++++++++++++++++++++++---------
 2 files changed, 56 insertions(+), 16 deletions(-)
drivers/rtc/Kconfig +2 -2
index a819ef07b7ec..8c34f7ec0a59 100644
@@ -363,11 +363,11 @@ config RTC_DRV_MAX77686
 	  will be called rtc-max77686.
 
 config RTC_DRV_RK808
-	tristate "Rockchip RK805/RK808/RK818 RTC"
+	tristate "Rockchip RK805/RK808/RK809/RK817/RK818 RTC"
 	depends on MFD_RK808
 	help
 	  If you say yes here you will get support for the
-	  RTC of RK805, RK808 and RK818 PMIC.
+	  RTC of RK805, RK809 and RK817, RK808 and RK818 PMIC.
 
 	  This driver can also be built as a module. If so, the module
 	  will be called rk808-rtc.
drivers/rtc/rtc-rk808.c +54 -14

172 lines not on this page · raw message

Signature · 1 line
2.17.1
author
#8 lore raw

PATCH v10 6/6 clk: RK808: add RK809 and RK817 support.

In reply to Tony Xie

RK809 and RK817 are power management IC chips for multimedia products. most of their functions and registers are same, including the clkout funciton.

---
 drivers/clk/Kconfig     |  9 +++---
 drivers/clk/clk-rk808.c | 64 ++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 67 insertions(+), 6 deletions(-)
drivers/clk/Kconfig +4 -5
index e5b2fe80eab4..532ab112fa8a 100644
@@ -52,13 +52,12 @@ config COMMON_CLK_MAX9485
 	  This driver supports Maxim 9485 Programmable Audio Clock Generator
 
 config COMMON_CLK_RK808
-	tristate "Clock driver for RK805/RK808/RK818"
+	tristate "Clock driver for RK805/RK808/RK809/RK817/RK818"
 	depends on MFD_RK808
 	---help---
-	  This driver supports RK805, RK808 and RK818 crystal oscillator clock. These
-	  multi-function devices have two fixed-rate oscillators,
-	  clocked at 32KHz each. Clkout1 is always on, Clkout2 can off
-	  by control register.
+	  This driver supports RK805, RK809 and RK817, RK808 and RK818 crystal oscillator clock.
+	  These multi-function devices have two fixed-rate oscillators, clocked at 32KHz each.
+	  Clkout1 is always on, Clkout2 can off by control register.
 
 config COMMON_CLK_HI655X
 	tristate "Clock driver for Hi655x" if EXPERT
drivers/clk/clk-rk808.c +63 -1

76 lines not on this page · raw message

Signature · 1 line
2.17.1
#9 lore raw
In reply to Tony Xie
Quoted 9 lines · Tony Xie

Most of functions and registers of the rk817 and rk808 are the same, so they can share allmost all codes.

Their specifications are as follows:
1) The RK809 and RK809 consist of 5 DCDCs, 9 LDOs and have the same
registers
for these components except dcdc5.
2) The dcdc5 is a boost dcdc for RK817 and is a buck for RK809.
3) The RK817 has one switch but The Rk809 has two.

Just tried to apply this set to a v5.2-rc1 base, but it doesn't seem to do so cleanly. Would you be able to rebase and resend please?

Signature · 4 lines
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
maintainer
#10 lore raw

Hi Lee,

Am Mittwoch, 26. Juni 2019, 13:52:51 CEST schrieb Lee Jones:

Quoted 12 lines · Tony Xie
Quoted 10 lines

Most of functions and registers of the rk817 and rk808 are the same, so they can share allmost all codes.

Their specifications are as follows:
1) The RK809 and RK809 consist of 5 DCDCs, 9 LDOs and have the same
registers
for these components except dcdc5.
2) The dcdc5 is a boost dcdc for RK817 and is a buck for RK809.
3) The RK817 has one switch but The Rk809 has two.

Quoted 2 lines

Just tried to apply this set to a v5.2-rc1 base, but it doesn't seem to do so cleanly. Would you be able to rebase and resend please?

I took the liberty of rebasing patch 3 accordingly and sent it as reply to the original patch3 as (v10.1). The other patches did apply cleanly after that.

Heiko

#11 lore raw

[GIT PULL] Immutable branch between MFD, Clk, Regulator and RTC due for the v5.3 merge window

In reply to Tony Xie

Enjoy!

The following changes since commit a188339ca5a396acc588e5851ed7e19f66b0ebd9:

Linux 5.2-rc1 (2019-05-19 15:47:09 -0700)

are available in the Git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd.git ib-mfd-clk-regulator-rtc-v5.3

for you to fetch changes up to 8ed14401974830f316a419b073e58ef75a473a63:

clk: RK808: Add RK809 and RK817 support. (2019-06-27 14:57:59 +0100)

----------------------------------------------------------------
Immutable branch between MFD, Clk, Regulator and RTC due for the v5.3 merge window

----------------------------------------------------------------
Heiko Stuebner (1):

      regulator: rk808: Add RK809 and RK817 support.

Tony Xie (4):

      mfd: rk808: Add RK817 and RK809 support
      dt-bindings: mfd: rk808: Add binding information for RK809 and RK817.
      rtc: rk808: Add RK809 and RK817 support.
      clk: RK808: Add RK809 and RK817 support.
 Documentation/devicetree/bindings/mfd/rk808.txt |  44 ++
 drivers/clk/Kconfig                             |   9 +-
 drivers/clk/clk-rk808.c                         |  64 ++-
 drivers/mfd/Kconfig                             |   6 +-
 drivers/mfd/rk808.c                             | 192 ++++++-
 drivers/regulator/Kconfig                       |   4 +-
 drivers/regulator/rk808-regulator.c             | 646 +++++++++++++++++++++++-
 drivers/rtc/Kconfig                             |   4 +-
 drivers/rtc/rtc-rk808.c                         |  68 ++-
 include/linux/mfd/rk808.h                       | 175 +++++++
 10 files changed, 1156 insertions(+), 56 deletions(-)
Signature · 4 lines
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog