Skip to content

Commit 70ef762

Browse files
committed
Merge branches 'ib-mfd-clk-gpio-power-regulator-rtc-6.20', 'ib-mfd-regulator-6.20' and 'ib-mfd-rtc-6.20' into ibs-for-mfd-merged
3 parents e39951f + 3e10bbd + b31583a commit 70ef762

11 files changed

Lines changed: 745 additions & 66 deletions

File tree

Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/mfd/rockchip,rk801.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: RK801 Power Management Integrated Circuit
8+
9+
maintainers:
10+
- Joseph Chen <chenjh@rock-chips.com>
11+
12+
description: |
13+
Rockchip RK801 series PMIC. This device consists of an i2c controlled MFD
14+
that includes multiple switchable regulators.
15+
16+
properties:
17+
compatible:
18+
enum:
19+
- rockchip,rk801
20+
21+
reg:
22+
maxItems: 1
23+
24+
interrupts:
25+
maxItems: 1
26+
27+
system-power-controller:
28+
type: boolean
29+
description:
30+
Telling whether or not this PMIC is controlling the system power.
31+
32+
wakeup-source:
33+
type: boolean
34+
description:
35+
Device can be used as a wakeup source.
36+
37+
vcc1-supply:
38+
description:
39+
The input supply for dcdc1.
40+
41+
vcc2-supply:
42+
description:
43+
The input supply for dcdc2.
44+
45+
vcc3-supply:
46+
description:
47+
The input supply for dcdc3.
48+
49+
vcc4-supply:
50+
description:
51+
The input supply for dcdc4.
52+
53+
vcc5-supply:
54+
description:
55+
The input supply for ldo1.
56+
57+
vcc6-supply:
58+
description:
59+
The input supply for ldo2.
60+
61+
vcc7-supply:
62+
description:
63+
The input supply for switch.
64+
65+
regulators:
66+
type: object
67+
patternProperties:
68+
"^(dcdc[1-4]|ldo[1-2]|switch)$":
69+
type: object
70+
$ref: /schemas/regulator/regulator.yaml#
71+
unevaluatedProperties: false
72+
additionalProperties: false
73+
74+
required:
75+
- compatible
76+
- reg
77+
- interrupts
78+
79+
additionalProperties: false
80+
81+
examples:
82+
- |
83+
#include <dt-bindings/pinctrl/rockchip.h>
84+
#include <dt-bindings/interrupt-controller/irq.h>
85+
#include <dt-bindings/gpio/gpio.h>
86+
87+
i2c {
88+
#address-cells = <1>;
89+
#size-cells = <0>;
90+
91+
rk801: pmic@27 {
92+
compatible = "rockchip,rk801";
93+
reg = <0x27>;
94+
interrupt-parent = <&gpio0>;
95+
interrupts = <RK_PC0 IRQ_TYPE_LEVEL_LOW>;
96+
pinctrl-names = "default";
97+
pinctrl-0 = <&pmic_int_l>;
98+
system-power-controller;
99+
wakeup-source;
100+
101+
vcc1-supply = <&vcc_sys>;
102+
vcc2-supply = <&vcc_sys>;
103+
vcc3-supply = <&vcc_sys>;
104+
vcc4-supply = <&vcc_sys>;
105+
vcc5-supply = <&vcc3v3_sys>;
106+
vcc6-supply = <&vcc3v3_sys>;
107+
vcc7-supply = <&vcc3v3_sys>;
108+
109+
regulators {
110+
vdd_cpu: dcdc1 {
111+
regulator-name = "vdd_cpu";
112+
regulator-min-microvolt = <500000>;
113+
regulator-max-microvolt = <1500000>;
114+
regulator-initial-mode = <0x1>;
115+
regulator-boot-on;
116+
regulator-always-on;
117+
regulator-state-mem {
118+
regulator-mode = <0x2>;
119+
regulator-off-in-suspend;
120+
regulator-suspend-microvolt = <950000>;
121+
};
122+
};
123+
124+
vcc3v3_sys: dcdc2 {
125+
regulator-name = "vcc3v3_sys";
126+
regulator-min-microvolt = <3300000>;
127+
regulator-max-microvolt = <3300000>;
128+
regulator-initial-mode = <0x1>;
129+
regulator-boot-on;
130+
regulator-always-on;
131+
regulator-state-mem {
132+
regulator-mode = <0x2>;
133+
regulator-on-in-suspend;
134+
regulator-suspend-microvolt = <3300000>;
135+
};
136+
};
137+
138+
vcc_ddr: dcdc3 {
139+
regulator-name = "vcc_ddr";
140+
regulator-boot-on;
141+
regulator-always-on;
142+
regulator-state-mem {
143+
regulator-mode = <0x2>;
144+
regulator-on-in-suspend;
145+
};
146+
};
147+
148+
vdd_logic: dcdc4 {
149+
regulator-name = "vdd_logic";
150+
regulator-min-microvolt = <500000>;
151+
regulator-max-microvolt = <1500000>;
152+
regulator-initial-mode = <0x1>;
153+
regulator-boot-on;
154+
regulator-always-on;
155+
regulator-state-mem {
156+
regulator-mode = <0x2>;
157+
regulator-off-in-suspend;
158+
regulator-suspend-microvolt = <900000>;
159+
};
160+
};
161+
162+
vdd0v9_sys: ldo1 {
163+
regulator-name = "vdd0v9_sys";
164+
regulator-min-microvolt = <900000>;
165+
regulator-max-microvolt = <900000>;
166+
regulator-boot-on;
167+
regulator-always-on;
168+
regulator-state-mem {
169+
regulator-off-in-suspend;
170+
regulator-suspend-microvolt = <900000>;
171+
};
172+
};
173+
174+
vcc_1v8: ldo2 {
175+
regulator-name = "vcc_1v8";
176+
regulator-min-microvolt = <1800000>;
177+
regulator-max-microvolt = <1800000>;
178+
regulator-boot-on;
179+
regulator-always-on;
180+
regulator-state-mem {
181+
regulator-off-in-suspend;
182+
regulator-suspend-microvolt = <1800000>;
183+
};
184+
};
185+
186+
vcc_3v3: switch {
187+
regulator-name = "vcc_3v3";
188+
regulator-boot-on;
189+
regulator-always-on;
190+
regulator-state-mem {
191+
regulator-off-in-suspend;
192+
regulator-suspend-microvolt = <3300000>;
193+
};
194+
};
195+
};
196+
};
197+
};

drivers/mfd/Kconfig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1371,15 +1371,15 @@ config MFD_RK8XX
13711371
select MFD_CORE
13721372

13731373
config MFD_RK8XX_I2C
1374-
tristate "Rockchip RK805/RK808/RK809/RK816/RK817/RK818 Power Management Chip"
1374+
tristate "Rockchip RK8xx Power Management Chips"
13751375
depends on I2C && OF
13761376
select MFD_CORE
13771377
select REGMAP_I2C
13781378
select REGMAP_IRQ
13791379
select MFD_RK8XX
13801380
help
1381-
If you say yes here you get support for the RK805, RK808, RK809,
1382-
RK816, RK817 and RK818 Power Management chips.
1381+
If you say yes here you get support for the RK801, RK805, RK808,
1382+
RK809, RK816, RK817 and RK818 Power Management chips.
13831383
This driver provides common support for accessing the device
13841384
through I2C interface. The device supports multiple sub-devices
13851385
including interrupts, RTC, LDO & DCDC regulators, and onkey.

drivers/mfd/rk8xx-core.c

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ static const struct resource rk817_rtc_resources[] = {
3737
DEFINE_RES_IRQ(RK817_IRQ_RTC_ALARM),
3838
};
3939

40+
static const struct resource rk801_key_resources[] = {
41+
DEFINE_RES_IRQ(RK801_IRQ_PWRON_FALL),
42+
DEFINE_RES_IRQ(RK801_IRQ_PWRON_RISE),
43+
};
44+
4045
static const struct resource rk805_key_resources[] = {
4146
DEFINE_RES_IRQ(RK805_IRQ_PWRON_RISE),
4247
DEFINE_RES_IRQ(RK805_IRQ_PWRON_FALL),
@@ -57,6 +62,14 @@ static const struct resource rk817_charger_resources[] = {
5762
DEFINE_RES_IRQ(RK817_IRQ_PLUG_OUT),
5863
};
5964

65+
static const struct mfd_cell rk801s[] = {
66+
{ .name = "rk808-regulator", },
67+
{ .name = "rk805-pwrkey",
68+
.num_resources = ARRAY_SIZE(rk801_key_resources),
69+
.resources = &rk801_key_resources[0],
70+
},
71+
};
72+
6073
static const struct mfd_cell rk805s[] = {
6174
{ .name = "rk808-clkout", },
6275
{ .name = "rk808-regulator", },
@@ -139,6 +152,15 @@ static const struct mfd_cell rk818s[] = {
139152
},
140153
};
141154

155+
static const struct rk808_reg_data rk801_pre_init_reg[] = {
156+
{ RK801_SLEEP_CFG_REG, RK801_SLEEP_FUN_MSK, RK801_NONE_FUN },
157+
{ RK801_SYS_CFG2_REG, RK801_RST_MSK, RK801_RST_RESTART_REG_RESETB },
158+
{ RK801_INT_CONFIG_REG, RK801_INT_POL_MSK, RK801_INT_ACT_L },
159+
{ RK801_POWER_FPWM_EN_REG, RK801_PLDO_HRDEC_EN, RK801_PLDO_HRDEC_EN },
160+
{ RK801_BUCK_DEBUG5_REG, MASK_ALL, 0x54 },
161+
{ RK801_CON_BACK1_REG, MASK_ALL, 0x18 },
162+
};
163+
142164
static const struct rk808_reg_data rk805_pre_init_reg[] = {
143165
{RK805_BUCK1_CONFIG_REG, RK805_BUCK1_2_ILMAX_MASK,
144166
RK805_BUCK1_2_ILMAX_4000MA},
@@ -284,6 +306,37 @@ static const struct rk808_reg_data rk818_pre_init_reg[] = {
284306
VB_LO_SEL_3500MV },
285307
};
286308

309+
static const struct regmap_irq rk801_irqs[] = {
310+
[RK801_IRQ_PWRON_FALL] = {
311+
.mask = RK801_IRQ_PWRON_FALL_MSK,
312+
.reg_offset = 0,
313+
},
314+
[RK801_IRQ_PWRON_RISE] = {
315+
.mask = RK801_IRQ_PWRON_RISE_MSK,
316+
.reg_offset = 0,
317+
},
318+
[RK801_IRQ_PWRON] = {
319+
.mask = RK801_IRQ_PWRON_MSK,
320+
.reg_offset = 0,
321+
},
322+
[RK801_IRQ_PWRON_LP] = {
323+
.mask = RK801_IRQ_PWRON_LP_MSK,
324+
.reg_offset = 0,
325+
},
326+
[RK801_IRQ_HOTDIE] = {
327+
.mask = RK801_IRQ_HOTDIE_MSK,
328+
.reg_offset = 0,
329+
},
330+
[RK801_IRQ_VDC_RISE] = {
331+
.mask = RK801_IRQ_VDC_RISE_MSK,
332+
.reg_offset = 0,
333+
},
334+
[RK801_IRQ_VDC_FALL] = {
335+
.mask = RK801_IRQ_VDC_FALL_MSK,
336+
.reg_offset = 0,
337+
},
338+
};
339+
287340
static const struct regmap_irq rk805_irqs[] = {
288341
[RK805_IRQ_PWRON_RISE] = {
289342
.mask = RK805_IRQ_PWRON_RISE_MSK,
@@ -532,6 +585,17 @@ static const struct regmap_irq rk817_irqs[RK817_IRQ_END] = {
532585
REGMAP_IRQ_REG_LINE(23, 8)
533586
};
534587

588+
static const struct regmap_irq_chip rk801_irq_chip = {
589+
.name = "rk801",
590+
.irqs = rk801_irqs,
591+
.num_irqs = ARRAY_SIZE(rk801_irqs),
592+
.num_regs = 1,
593+
.status_base = RK801_INT_STS0_REG,
594+
.mask_base = RK801_INT_MASK0_REG,
595+
.ack_base = RK801_INT_STS0_REG,
596+
.init_ack_masked = true,
597+
};
598+
535599
static const struct regmap_irq_chip rk805_irq_chip = {
536600
.name = "rk805",
537601
.irqs = rk805_irqs,
@@ -610,6 +674,10 @@ static int rk808_power_off(struct sys_off_data *data)
610674
unsigned int reg, bit;
611675

612676
switch (rk808->variant) {
677+
case RK801_ID:
678+
reg = RK801_SYS_CFG2_REG;
679+
bit = DEV_OFF;
680+
break;
613681
case RK805_ID:
614682
reg = RK805_DEV_CTRL_REG;
615683
bit = DEV_OFF;
@@ -714,6 +782,13 @@ int rk8xx_probe(struct device *dev, int variant, unsigned int irq, struct regmap
714782
dev_set_drvdata(dev, rk808);
715783

716784
switch (rk808->variant) {
785+
case RK801_ID:
786+
rk808->regmap_irq_chip = &rk801_irq_chip;
787+
pre_init_reg = rk801_pre_init_reg;
788+
nr_pre_init_regs = ARRAY_SIZE(rk801_pre_init_reg);
789+
cells = rk801s;
790+
nr_cells = ARRAY_SIZE(rk801s);
791+
break;
717792
case RK805_ID:
718793
rk808->regmap_irq_chip = &rk805_irq_chip;
719794
pre_init_reg = rk805_pre_init_reg;
@@ -831,6 +906,12 @@ int rk8xx_suspend(struct device *dev)
831906
int ret = 0;
832907

833908
switch (rk808->variant) {
909+
case RK801_ID:
910+
ret = regmap_update_bits(rk808->regmap,
911+
RK801_SLEEP_CFG_REG,
912+
RK801_SLEEP_FUN_MSK,
913+
RK801_SLEEP_FUN);
914+
break;
834915
case RK805_ID:
835916
ret = regmap_update_bits(rk808->regmap,
836917
RK805_GPIO_IO_POL_REG,

0 commit comments

Comments
 (0)