Skip to contentSkip to conversation

support a new rk80x pmic-variants (rk817 and rk809)

PATCH RESEND In review Heiko Stuebner 2 participants 7 messages Jun 3, 2019

Subsystems (6)
lore
Share & tools
lore

Heiko Stuebner

author maintainer
#0 lore raw

v8 cover support a new rk80x pmic-variants (rk817 and rk809)

I've picked up and rebased Tony's patch-series for rk809 and rk817. From the last iteration it looks like the regulator-portion did fall through the cracks, the other patches seem to be sufficiently reviewed/acked.

The regulator-patch could either just be picked alone to the regulator- tree or with an Ack go through the mfd tree with the other patches.

Original cover-letter + changelog follows:

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:
- [Heiko] rebase onto current mainline
- [Heiko] add some tags from Lee so that he can keep track of what he reviewed

Changes in V8 RESEND:
- none, just needs a regulator Ack

Tony Xie (5):
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                           | 192 ++++-
 drivers/regulator/Kconfig                     |   4 +-
 drivers/regulator/rk808-regulator.c           | 657 +++++++++++++++++-
 drivers/rtc/Kconfig                           |   4 +-
 drivers/rtc/rtc-rk808.c                       |  68 +-
 include/linux/mfd/rk808.h                     | 175 +++++
 10 files changed, 1165 insertions(+), 58 deletions(-)
Signature · 1 line
2.20.1
author maintainer
#1 lore raw

PATCH RESEND v8 1/5 mfd: rk808: Add RK817 and RK809 support

From: Tony Xie <[email protected]>

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 d5a8e064965f..27d43faf65b0 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.20.1
author maintainer
#2 lore raw

PATCH RESEND v8 2/5 regulator: rk808: add RK809 and RK817 support.

In reply to Heiko Stuebner

From: Tony Xie <[email protected]>

Add support for the RK809 and RK817 regulator driver. Their specifications are as follows:
1. The RK809 and RK817 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 | 657 ++++++++++++++++++++++++++--
 include/linux/mfd/rk808.h           |   3 +
 3 files changed, 634 insertions(+), 30 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 +629 -28

743 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
maintainer
#3 lore raw

Re: [PATCH v8 RESEND 2/5] regulator: rk808: add RK809 and RK817 support.

drivers/regulator/rk808-regulator.c static int rk808_set_ramp_delay(struct regulator_dev *rdev, int ramp_delay) · line 371

Quoted 6 lines · Heiko Stuebner

default:

drivers/regulator/rk808-regulator.c +3 -2
-               pr_warn("%s ramp_delay: %d not supported, setting 10000\n",
-                       rdev->desc->name, ramp_delay);
+               dev_warn(&rdev->dev,
+                        "%s ramp_delay: %d not supported, setting 10000\n",
+                        rdev->desc->name, ramp_delay);

This appears to be unrelated and should've been a separate patch.

drivers/regulator/rk808-regulator.c static int rk808_set_suspend_voltage(struct regulator_dev *rdev, int uv) · line 428

Quoted 6 lines
drivers/regulator/rk808-regulator.c +6 -0
+static int rk817_check_suspend_voltage(int id)
+{
+	if (id >= RK817_ID_DCDC1 && id <= RK817_ID_LDO9)
+		return 0;
+	return -1;
+}

Rather than have these checks in the implementation you should just not define these operations for regulators that don't have the functionality.

drivers/regulator/rk808-regulator.c static int rk808_set_suspend_disable(struct regulator_dev *rdev) · line 626

Quoted 9 lines
drivers/regulator/rk808-regulator.c +9 -0
+static unsigned int rk8xx_regulator_of_map_mode(unsigned int mode)
+{
+	if (mode == 1)
+		return REGULATOR_MODE_FAST;
+	if (mode == 2)
+		return REGULATOR_MODE_NORMAL;
+
+	return -EINVAL;
+}

This should be written as a switch statement for clarity.

author maintainer
#4 lore raw

PATCH RESEND v8 3/5 dt-bindings: mfd: rk808: Add binding information for RK809 and RK817.

In reply to Heiko Stuebner

From: Tony Xie <[email protected]>

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.20.1
author maintainer
#5 lore raw

PATCH RESEND v8 4/5 rtc: rk808: add RK809 and RK817 support.

In reply to Heiko Stuebner

From: Tony Xie <[email protected]>

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 f933c06bff4f..6a7b367be26c 100644
@@ -373,11 +373,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.20.1
author maintainer
#6 lore raw

PATCH RESEND v8 5/5 clk: RK808: add RK809 and RK817 support.

In reply to Heiko Stuebner

From: Tony Xie <[email protected]>

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 e705aab9e38b..3d3899ee64a0 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.20.1