Commit 2a4febfd919303e6af49b170b5acf163696e85c1
1 parent
61101e0583
Exists in
v2017.01-smarct4x
and in
30 other branches
power: Add base support for the RK808 PMIC
This Rockchip PMIC provides features suitable for battery-powered applications. It is commonly used with Rockchip SoCs. Add a driver which provides register access. The regulator driver will use this. Signed-off-by: Simon Glass <sjg@chromium.org>
Showing 4 changed files with 183 additions and 0 deletions Side-by-side Diff
drivers/power/pmic/Kconfig
... | ... | @@ -33,6 +33,15 @@ |
33 | 33 | This config enables implementation of driver-model pmic uclass features |
34 | 34 | for PMIC MAX77686. The driver implements read/write operations. |
35 | 35 | |
36 | +config PMIC_RK808 | |
37 | + bool "Enable support for Rockchip PMIC RK808" | |
38 | + depends on DM_PMIC | |
39 | + ---help--- | |
40 | + The Rockchip RK808 PMIC provides four buck DC-DC convertors, 8 LDOs, | |
41 | + an RTC and two low Rds (resistance (drain to source)) switches. It is | |
42 | + accessed via an I2C interface. The device is used with Rockchip SoCs. | |
43 | + This driver implements register read/write operations. | |
44 | + | |
36 | 45 | config PMIC_S2MPS11 |
37 | 46 | bool "Enable Driver Model for PMIC Samsung S2MPS11" |
38 | 47 | depends on DM_PMIC |
drivers/power/pmic/Makefile
... | ... | @@ -11,6 +11,7 @@ |
11 | 11 | obj-$(CONFIG_PMIC_S2MPS11) += s2mps11.o |
12 | 12 | obj-$(CONFIG_DM_PMIC_SANDBOX) += sandbox.o i2c_pmic_emul.o |
13 | 13 | obj-$(CONFIG_PMIC_ACT8846) += act8846.o |
14 | +obj-$(CONFIG_PMIC_RK808) += rk808.o | |
14 | 15 | obj-$(CONFIG_PMIC_TPS65090) += tps65090.o |
15 | 16 | obj-$(CONFIG_PMIC_S5M8767) += s5m8767.o |
16 | 17 |
drivers/power/pmic/rk808.c
1 | +/* | |
2 | + * Copyright (C) 2015 Google, Inc | |
3 | + * Written by Simon Glass <sjg@chromium.org> | |
4 | + * | |
5 | + * SPDX-License-Identifier: GPL-2.0+ | |
6 | + */ | |
7 | + | |
8 | +#include <common.h> | |
9 | +#include <dm.h> | |
10 | +#include <errno.h> | |
11 | +#include <fdtdec.h> | |
12 | +#include <libfdt.h> | |
13 | +#include <power/rk808_pmic.h> | |
14 | +#include <power/pmic.h> | |
15 | + | |
16 | +DECLARE_GLOBAL_DATA_PTR; | |
17 | + | |
18 | +static const struct pmic_child_info pmic_children_info[] = { | |
19 | + { .prefix = "DCDC_REG", .driver = "rk808_buck"}, | |
20 | + { .prefix = "LDO_REG", .driver = "rk808_ldo"}, | |
21 | + { .prefix = "SWITCH_REG", .driver = "rk808_switch"}, | |
22 | + { }, | |
23 | +}; | |
24 | + | |
25 | +static int rk808_reg_count(struct udevice *dev) | |
26 | +{ | |
27 | + return RK808_NUM_OF_REGS; | |
28 | +} | |
29 | + | |
30 | +static int rk808_write(struct udevice *dev, uint reg, const uint8_t *buff, | |
31 | + int len) | |
32 | +{ | |
33 | + if (dm_i2c_write(dev, reg, buff, len)) { | |
34 | + debug("write error to device: %p register: %#x!", dev, reg); | |
35 | + return -EIO; | |
36 | + } | |
37 | + | |
38 | + return 0; | |
39 | +} | |
40 | + | |
41 | +static int rk808_read(struct udevice *dev, uint reg, uint8_t *buff, int len) | |
42 | +{ | |
43 | + if (dm_i2c_read(dev, reg, buff, len)) { | |
44 | + debug("read error from device: %p register: %#x!", dev, reg); | |
45 | + return -EIO; | |
46 | + } | |
47 | + | |
48 | + return 0; | |
49 | +} | |
50 | + | |
51 | +#if CONFIG_IS_ENABLED(PMIC_CHILDREN) | |
52 | +static int rk808_bind(struct udevice *dev) | |
53 | +{ | |
54 | + const void *blob = gd->fdt_blob; | |
55 | + int regulators_node; | |
56 | + int children; | |
57 | + | |
58 | + regulators_node = fdt_subnode_offset(blob, dev->of_offset, | |
59 | + "regulators"); | |
60 | + if (regulators_node <= 0) { | |
61 | + debug("%s: %s regulators subnode not found!", __func__, | |
62 | + dev->name); | |
63 | + return -ENXIO; | |
64 | + } | |
65 | + | |
66 | + debug("%s: '%s' - found regulators subnode\n", __func__, dev->name); | |
67 | + | |
68 | + children = pmic_bind_children(dev, regulators_node, pmic_children_info); | |
69 | + if (!children) | |
70 | + debug("%s: %s - no child found\n", __func__, dev->name); | |
71 | + | |
72 | + /* Always return success for this device */ | |
73 | + return 0; | |
74 | +} | |
75 | +#endif | |
76 | + | |
77 | +static struct dm_pmic_ops rk808_ops = { | |
78 | + .reg_count = rk808_reg_count, | |
79 | + .read = rk808_read, | |
80 | + .write = rk808_write, | |
81 | +}; | |
82 | + | |
83 | +static const struct udevice_id rk808_ids[] = { | |
84 | + { .compatible = "rockchip,rk808" }, | |
85 | + { } | |
86 | +}; | |
87 | + | |
88 | +U_BOOT_DRIVER(pmic_rk808) = { | |
89 | + .name = "rk808 pmic", | |
90 | + .id = UCLASS_PMIC, | |
91 | + .of_match = rk808_ids, | |
92 | +#if CONFIG_IS_ENABLED(PMIC_CHILDREN) | |
93 | + .bind = rk808_bind, | |
94 | +#endif | |
95 | + .ops = &rk808_ops, | |
96 | +}; |
include/power/rk808_pmic.h
1 | +/* | |
2 | + * Copyright (C) 2015 Google, Inc | |
3 | + * Written by Simon Glass <sjg@chromium.org> | |
4 | + * | |
5 | + * SPDX-License-Identifier: GPL-2.0+ | |
6 | + */ | |
7 | + | |
8 | +#ifndef _PMIC_RK808_H_ | |
9 | +#define _PMIC_RK808_H_ | |
10 | + | |
11 | +enum { | |
12 | + REG_DCDC_EN = 0x23, | |
13 | + REG_LDO_EN, | |
14 | + REG_SLEEP_SET_OFF1, | |
15 | + REG_SLEEP_SET_OFF2, | |
16 | + REG_DCDC_UV_STS, | |
17 | + | |
18 | + REG_DCDC_UV_ACT, | |
19 | + REG_LDO_UV_STS, | |
20 | + REG_LDO_UV_ACT, | |
21 | + REG_DCDC_PG, | |
22 | + REG_LDO_PG, | |
23 | + REG_VOUT_MON_TDB, | |
24 | + REG_BUCK1_CONFIG, | |
25 | + REG_BUCK1_ON_VSEL, | |
26 | + | |
27 | + REG_BUCK1_SLP_VSEL, | |
28 | + REG_BUCK1_DVS_VSEL, | |
29 | + REG_BUCK2_CONFIG, | |
30 | + REG_BUCK2_ON_VSEL, | |
31 | + REG_BUCK2_SLP_VSEL, | |
32 | + REG_BUCK2_DVS_VSEL, | |
33 | + REG_BUCK3_CONFIG, | |
34 | + REG_BUCK4_CONFIG, | |
35 | + | |
36 | + REG_BUCK4_ON_VSEL, | |
37 | + REG_BUCK4_SLP_VSEL, | |
38 | + LDO1_ON_VSEL = 0x3b, | |
39 | + LDO1_SLP_VSEL, | |
40 | + LDO2_ON_VSEL, | |
41 | + LDO2_SLP_VSEL, | |
42 | + LDO3_ON_VSEL, | |
43 | + | |
44 | + LDO3_SLP_VSEL, | |
45 | + LDO4_ON_VSEL, | |
46 | + LDO4_SLP_VSEL, | |
47 | + LDO5_ON_VSEL, | |
48 | + LDO5_SLP_VSEL, | |
49 | + LDO6_ON_VSEL, | |
50 | + LDO6_SLP_VSEL, | |
51 | + LDO7_ON_VSEL, | |
52 | + | |
53 | + LDO7_SLP_VSEL, | |
54 | + LDO8_ON_VSEL, | |
55 | + LDO8_SLP_VSEL, | |
56 | + DEVCTRL, | |
57 | + INT_STS1, | |
58 | + INT_STS_MSK1, | |
59 | + INT_STS2, | |
60 | + INT_STS_MSK2, | |
61 | + IO_POL, | |
62 | + | |
63 | + /* Not sure what this does */ | |
64 | + DCDC_ILMAX = 0x90, | |
65 | + | |
66 | + RK808_NUM_OF_REGS, | |
67 | +}; | |
68 | + | |
69 | +struct rk808_reg_table { | |
70 | + char *name; | |
71 | + u8 reg_ctl; | |
72 | + u8 reg_vol; | |
73 | +}; | |
74 | + | |
75 | +int rk808_spl_configure_buck(struct udevice *pmic, int buck, int uvolt); | |
76 | + | |
77 | +#endif |