Skip to content

Commit 14d16c1

Browse files
power-xsfrkhuangtao
authored andcommitted
regulator: rk808: maps a hardware mode defined in a DTS to a standard mode
Change-Id: I304e0cbb3544abde112180b6ec459670d91c99ae Signed-off-by: shengfei Xu <xsf@rock-chips.com>
1 parent cfdb04d commit 14d16c1

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

Documentation/devicetree/bindings/mfd/rk816.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ Optional properties:
2525
- vcc5-supply: The input supply for LDO_REG1, LDO_REG2, LDO_REG3
2626
- vcc6-supply: The input supply for LDO_REG4, LDO_REG5, LDO_REG6
2727

28+
- regulator-initial-mode: default mode to set on startup
29+
- regulator-initial-mode is set as:
30+
REGULATOR_MODE_FAST 0x1
31+
REGULATOR_MODE_NORMAL 0x2
2832
Regulators: All the regulators of RK816 to be instantiated shall be
2933
listed in a child node named 'regulators'. Each regulator is represented
3034
by a child node of the 'regulators' node.
@@ -104,6 +108,7 @@ Example:
104108
regulator-min-microvolt = <750000>;
105109
regulator-max-microvolt = <1450000>;
106110
regulator-ramp-delay = <6001>;
111+
regulator-initial-mode = <1>;
107112
regulator-state-mem {
108113
regulator-off-in-suspend;
109114
};
@@ -115,6 +120,7 @@ Example:
115120
regulator-min-microvolt = <800000>;
116121
regulator-max-microvolt = <1250000>;
117122
regulator-ramp-delay = <6001>;
123+
regulator-initial-mode = <1>;
118124
regulator-state-mem {
119125
regulator-on-in-suspend;
120126
regulator-suspend-microvolt = <1000000>;
@@ -125,6 +131,7 @@ Example:
125131
regulator-always-on;
126132
regulator-boot-on;
127133
regulator-name = "vcc_ddr";
134+
regulator-initial-mode = <1>;
128135
regulator-state-mem {
129136
regulator-on-in-suspend;
130137
};
@@ -136,6 +143,7 @@ Example:
136143
regulator-min-microvolt = <3300000>;
137144
regulator-max-microvolt = <3300000>;
138145
regulator-name = "vcc33_io";
146+
regulator-initial-mode = <1>;
139147
regulator-state-mem {
140148
regulator-on-in-suspend;
141149
regulator-suspend-microvolt = <3300000>;

drivers/regulator/rk808-regulator.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,16 @@ static const struct regulator_linear_range rk816_buck4_voltage_ranges[] = {
156156
REGULATOR_LINEAR_RANGE(3500000, 27, 31, 0), /* 3.5v */
157157
};
158158

159+
static unsigned int rk8xx_regulator_of_map_mode(unsigned int mode)
160+
{
161+
if (mode == 1)
162+
return REGULATOR_MODE_FAST;
163+
if (mode == 2)
164+
return REGULATOR_MODE_NORMAL;
165+
166+
return -EINVAL;
167+
}
168+
159169
static int rk808_buck1_2_get_voltage_sel_regmap(struct regulator_dev *rdev)
160170
{
161171
struct rk808_regulator_data *pdata = rdev_get_drvdata(rdev);
@@ -715,6 +725,7 @@ static const struct regulator_desc rk816_reg[] = {
715725
.enable_mask = BIT(4) | BIT(0),
716726
.enable_val = BIT(4) | BIT(0),
717727
.disable_val = BIT(4),
728+
.of_map_mode = rk8xx_regulator_of_map_mode,
718729
.owner = THIS_MODULE,
719730
}, {
720731
.name = "DCDC_REG2",
@@ -733,6 +744,7 @@ static const struct regulator_desc rk816_reg[] = {
733744
.enable_mask = BIT(5) | BIT(1),
734745
.enable_val = BIT(5) | BIT(1),
735746
.disable_val = BIT(5),
747+
.of_map_mode = rk8xx_regulator_of_map_mode,
736748
.owner = THIS_MODULE,
737749
}, {
738750
.name = "DCDC_REG3",
@@ -747,6 +759,7 @@ static const struct regulator_desc rk816_reg[] = {
747759
.enable_mask = BIT(6) | BIT(2),
748760
.enable_val = BIT(6) | BIT(2),
749761
.disable_val = BIT(6),
762+
.of_map_mode = rk8xx_regulator_of_map_mode,
750763
.owner = THIS_MODULE,
751764
}, {
752765
.name = "DCDC_REG4",
@@ -765,6 +778,7 @@ static const struct regulator_desc rk816_reg[] = {
765778
.enable_mask = BIT(7) | BIT(3),
766779
.enable_val = BIT(7) | BIT(3),
767780
.disable_val = BIT(7),
781+
.of_map_mode = rk8xx_regulator_of_map_mode,
768782
.owner = THIS_MODULE,
769783
},
770784
RK816_DESC(RK816_ID_LDO1, "LDO_REG1", "vcc5", 800, 3400, 100,

0 commit comments

Comments
 (0)