Skip to content

Commit e6beda5

Browse files
committed
mfd/pinctrl/regulator: Add RK806 Support
Merge series from Sebastian Reichel <sebastian.reichel@collabora.com>: All existing boards using RK3588/RK3588s use RK806 PMICs. This series is now the main blocker for full upstream support of those boards and it would be good to have it merged for 6.5 :) The patches have been tested on multiple different platforms and are mainly missing an Ack from Mark or Liam for the rk808-regulator changes. Merging must happen through a single tree, since the pinctrl and regulator drivers rely on the register definitions from the include file added by the MFD patch. My suggested merge strategy is that Lee creates an immutable branch for the regulator/pinctrl tree once all Acks have been collected.
2 parents 15a1cd2 + f991a22 commit e6beda5

19 files changed

Lines changed: 1876 additions & 293 deletions

File tree

Documentation/devicetree/bindings/mfd/rockchip,rk806.yaml

Lines changed: 406 additions & 0 deletions
Large diffs are not rendered by default.

drivers/clk/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ config COMMON_CLK_MAX9485
8282

8383
config COMMON_CLK_RK808
8484
tristate "Clock driver for RK805/RK808/RK809/RK817/RK818"
85-
depends on MFD_RK808
85+
depends on MFD_RK8XX
8686
help
8787
This driver supports RK805, RK809 and RK817, RK808 and RK818 crystal oscillator clock.
8888
These multi-function devices have two fixed-rate oscillators, clocked at 32KHz each.

drivers/clk/clk-rk808.c

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@
1212
#include <linux/slab.h>
1313
#include <linux/platform_device.h>
1414
#include <linux/mfd/rk808.h>
15-
#include <linux/i2c.h>
1615

1716
struct rk808_clkout {
18-
struct rk808 *rk808;
17+
struct regmap *regmap;
1918
struct clk_hw clkout1_hw;
2019
struct clk_hw clkout2_hw;
2120
};
@@ -31,9 +30,8 @@ static int rk808_clkout2_enable(struct clk_hw *hw, bool enable)
3130
struct rk808_clkout *rk808_clkout = container_of(hw,
3231
struct rk808_clkout,
3332
clkout2_hw);
34-
struct rk808 *rk808 = rk808_clkout->rk808;
3533

36-
return regmap_update_bits(rk808->regmap, RK808_CLK32OUT_REG,
34+
return regmap_update_bits(rk808_clkout->regmap, RK808_CLK32OUT_REG,
3735
CLK32KOUT2_EN, enable ? CLK32KOUT2_EN : 0);
3836
}
3937

@@ -52,10 +50,9 @@ static int rk808_clkout2_is_prepared(struct clk_hw *hw)
5250
struct rk808_clkout *rk808_clkout = container_of(hw,
5351
struct rk808_clkout,
5452
clkout2_hw);
55-
struct rk808 *rk808 = rk808_clkout->rk808;
5653
uint32_t val;
5754

58-
int ret = regmap_read(rk808->regmap, RK808_CLK32OUT_REG, &val);
55+
int ret = regmap_read(rk808_clkout->regmap, RK808_CLK32OUT_REG, &val);
5956

6057
if (ret < 0)
6158
return ret;
@@ -93,9 +90,8 @@ static int rk817_clkout2_enable(struct clk_hw *hw, bool enable)
9390
struct rk808_clkout *rk808_clkout = container_of(hw,
9491
struct rk808_clkout,
9592
clkout2_hw);
96-
struct rk808 *rk808 = rk808_clkout->rk808;
9793

98-
return regmap_update_bits(rk808->regmap, RK817_SYS_CFG(1),
94+
return regmap_update_bits(rk808_clkout->regmap, RK817_SYS_CFG(1),
9995
RK817_CLK32KOUT2_EN,
10096
enable ? RK817_CLK32KOUT2_EN : 0);
10197
}
@@ -115,10 +111,9 @@ static int rk817_clkout2_is_prepared(struct clk_hw *hw)
115111
struct rk808_clkout *rk808_clkout = container_of(hw,
116112
struct rk808_clkout,
117113
clkout2_hw);
118-
struct rk808 *rk808 = rk808_clkout->rk808;
119114
unsigned int val;
120115

121-
int ret = regmap_read(rk808->regmap, RK817_SYS_CFG(1), &val);
116+
int ret = regmap_read(rk808_clkout->regmap, RK817_SYS_CFG(1), &val);
122117

123118
if (ret < 0)
124119
return 0;
@@ -153,18 +148,21 @@ static const struct clk_ops *rkpmic_get_ops(long variant)
153148
static int rk808_clkout_probe(struct platform_device *pdev)
154149
{
155150
struct rk808 *rk808 = dev_get_drvdata(pdev->dev.parent);
156-
struct i2c_client *client = rk808->i2c;
157-
struct device_node *node = client->dev.of_node;
151+
struct device *dev = &pdev->dev;
158152
struct clk_init_data init = {};
159153
struct rk808_clkout *rk808_clkout;
160154
int ret;
161155

162-
rk808_clkout = devm_kzalloc(&client->dev,
156+
dev->of_node = pdev->dev.parent->of_node;
157+
158+
rk808_clkout = devm_kzalloc(dev,
163159
sizeof(*rk808_clkout), GFP_KERNEL);
164160
if (!rk808_clkout)
165161
return -ENOMEM;
166162

167-
rk808_clkout->rk808 = rk808;
163+
rk808_clkout->regmap = dev_get_regmap(pdev->dev.parent, NULL);
164+
if (!rk808_clkout->regmap)
165+
return -ENODEV;
168166

169167
init.parent_names = NULL;
170168
init.num_parents = 0;
@@ -173,10 +171,10 @@ static int rk808_clkout_probe(struct platform_device *pdev)
173171
rk808_clkout->clkout1_hw.init = &init;
174172

175173
/* optional override of the clockname */
176-
of_property_read_string_index(node, "clock-output-names",
174+
of_property_read_string_index(dev->of_node, "clock-output-names",
177175
0, &init.name);
178176

179-
ret = devm_clk_hw_register(&client->dev, &rk808_clkout->clkout1_hw);
177+
ret = devm_clk_hw_register(dev, &rk808_clkout->clkout1_hw);
180178
if (ret)
181179
return ret;
182180

@@ -185,10 +183,10 @@ static int rk808_clkout_probe(struct platform_device *pdev)
185183
rk808_clkout->clkout2_hw.init = &init;
186184

187185
/* optional override of the clockname */
188-
of_property_read_string_index(node, "clock-output-names",
186+
of_property_read_string_index(dev->of_node, "clock-output-names",
189187
1, &init.name);
190188

191-
ret = devm_clk_hw_register(&client->dev, &rk808_clkout->clkout2_hw);
189+
ret = devm_clk_hw_register(dev, &rk808_clkout->clkout2_hw);
192190
if (ret)
193191
return ret;
194192

drivers/input/misc/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ config INPUT_PWM_VIBRA
609609

610610
config INPUT_RK805_PWRKEY
611611
tristate "Rockchip RK805 PMIC power key support"
612-
depends on MFD_RK808
612+
depends on MFD_RK8XX
613613
help
614614
Select this option to enable power key driver for RK805.
615615

drivers/mfd/Kconfig

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1183,19 +1183,38 @@ config MFD_RC5T583
11831183
Additional drivers must be enabled in order to use the
11841184
different functionality of the device.
11851185

1186-
config MFD_RK808
1186+
config MFD_RK8XX
1187+
bool
1188+
select MFD_CORE
1189+
1190+
config MFD_RK8XX_I2C
11871191
tristate "Rockchip RK805/RK808/RK809/RK817/RK818 Power Management Chip"
11881192
depends on I2C && OF
11891193
select MFD_CORE
11901194
select REGMAP_I2C
11911195
select REGMAP_IRQ
1196+
select MFD_RK8XX
11921197
help
11931198
If you say yes here you get support for the RK805, RK808, RK809,
11941199
RK817 and RK818 Power Management chips.
11951200
This driver provides common support for accessing the device
11961201
through I2C interface. The device supports multiple sub-devices
11971202
including interrupts, RTC, LDO & DCDC regulators, and onkey.
11981203

1204+
config MFD_RK8XX_SPI
1205+
tristate "Rockchip RK806 Power Management Chip"
1206+
depends on SPI && OF
1207+
select MFD_CORE
1208+
select REGMAP_SPI
1209+
select REGMAP_IRQ
1210+
select MFD_RK8XX
1211+
help
1212+
If you say yes here you get support for the RK806 Power Management
1213+
chip.
1214+
This driver provides common support for accessing the device
1215+
through an SPI interface. The device supports multiple sub-devices
1216+
including interrupts, LDO & DCDC regulators, and power on-key.
1217+
11991218
config MFD_RN5T618
12001219
tristate "Ricoh RN5T567/618 PMIC"
12011220
depends on I2C

drivers/mfd/Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,9 @@ obj-$(CONFIG_MFD_PALMAS) += palmas.o
214214
obj-$(CONFIG_MFD_VIPERBOARD) += viperboard.o
215215
obj-$(CONFIG_MFD_NTXEC) += ntxec.o
216216
obj-$(CONFIG_MFD_RC5T583) += rc5t583.o rc5t583-irq.o
217-
obj-$(CONFIG_MFD_RK808) += rk808.o
217+
obj-$(CONFIG_MFD_RK8XX) += rk8xx-core.o
218+
obj-$(CONFIG_MFD_RK8XX_I2C) += rk8xx-i2c.o
219+
obj-$(CONFIG_MFD_RK8XX_SPI) += rk8xx-spi.o
218220
obj-$(CONFIG_MFD_RN5T618) += rn5t618.o
219221
obj-$(CONFIG_MFD_SEC_CORE) += sec-core.o sec-irq.o
220222
obj-$(CONFIG_MFD_SYSCON) += syscon.o

0 commit comments

Comments
 (0)