diff options
-rw-r--r-- | Documentation/devicetree/bindings/mfd/rn5t618.txt | 19 | ||||
-rw-r--r-- | drivers/mfd/Kconfig | 7 | ||||
-rw-r--r-- | drivers/mfd/rn5t618.c | 25 | ||||
-rw-r--r-- | include/linux/mfd/rn5t618.h | 12 |
4 files changed, 45 insertions, 18 deletions
diff --git a/Documentation/devicetree/bindings/mfd/rn5t618.txt b/Documentation/devicetree/bindings/mfd/rn5t618.txt index 937785a3eddc..9e6770b105c9 100644 --- a/Documentation/devicetree/bindings/mfd/rn5t618.txt +++ b/Documentation/devicetree/bindings/mfd/rn5t618.txt | |||
@@ -1,18 +1,21 @@ | |||
1 | * Ricoh RN5T618 PMIC | 1 | * Ricoh RN5T567/RN5T618 PMIC |
2 | 2 | ||
3 | Ricoh RN5T618 is a power management IC which integrates 3 step-down | 3 | Ricoh RN5T567/RN5T618 is a power management IC family which integrates |
4 | DCDC converters, 7 low-dropout regulators, a Li-ion battery charger, | 4 | 3 to 4 step-down DCDC converters, 7 low-dropout regulators, GPIOs and |
5 | fuel gauge, ADC, GPIOs and a watchdog timer. It can be controlled | 5 | a watchdog timer. The RN5T618 provides additionally a Li-ion battery |
6 | through a I2C interface. | 6 | charger, fuel gauge and an ADC. It can be controlled through an I2C |
7 | interface. | ||
7 | 8 | ||
8 | Required properties: | 9 | Required properties: |
9 | - compatible: should be "ricoh,rn5t618" | 10 | - compatible: must be one of |
11 | "ricoh,rn5t567" | ||
12 | "ricoh,rn5t618" | ||
10 | - reg: the I2C slave address of the device | 13 | - reg: the I2C slave address of the device |
11 | 14 | ||
12 | Sub-nodes: | 15 | Sub-nodes: |
13 | - regulators: the node is required if the regulator functionality is | 16 | - regulators: the node is required if the regulator functionality is |
14 | needed. The valid regulator names are: DCDC1, DCDC2, DCDC3, LDO1, | 17 | needed. The valid regulator names are: DCDC1, DCDC2, DCDC3, DCDC4 |
15 | LDO2, LDO3, LDO4, LDO5, LDORTC1 and LDORTC2. | 18 | (RN5T567), LDO1, LDO2, LDO3, LDO4, LDO5, LDORTC1 and LDORTC2. |
16 | The common bindings for each individual regulator can be found in: | 19 | The common bindings for each individual regulator can be found in: |
17 | Documentation/devicetree/bindings/regulator/regulator.txt | 20 | Documentation/devicetree/bindings/regulator/regulator.txt |
18 | 21 | ||
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index 1bcf601de5bc..ff031a7735a5 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig | |||
@@ -852,13 +852,14 @@ config MFD_RK808 | |||
852 | including interrupts, RTC, LDO & DCDC regulators, and onkey. | 852 | including interrupts, RTC, LDO & DCDC regulators, and onkey. |
853 | 853 | ||
854 | config MFD_RN5T618 | 854 | config MFD_RN5T618 |
855 | tristate "Ricoh RN5T5618 PMIC" | 855 | tristate "Ricoh RN5T567/618 PMIC" |
856 | depends on I2C | 856 | depends on I2C |
857 | depends on OF | ||
857 | select MFD_CORE | 858 | select MFD_CORE |
858 | select REGMAP_I2C | 859 | select REGMAP_I2C |
859 | help | 860 | help |
860 | Say yes here to add support for the Ricoh RN5T618 PMIC. This | 861 | Say yes here to add support for the Ricoh RN5T567 or R5T618 PMIC. |
861 | driver provides common support for accessing the device, | 862 | This driver provides common support for accessing the device, |
862 | additional drivers must be enabled in order to use the | 863 | additional drivers must be enabled in order to use the |
863 | functionality of the device. | 864 | functionality of the device. |
864 | 865 | ||
diff --git a/drivers/mfd/rn5t618.c b/drivers/mfd/rn5t618.c index 0ad51d792feb..c86160d3a773 100644 --- a/drivers/mfd/rn5t618.c +++ b/drivers/mfd/rn5t618.c | |||
@@ -2,6 +2,7 @@ | |||
2 | * MFD core driver for Ricoh RN5T618 PMIC | 2 | * MFD core driver for Ricoh RN5T618 PMIC |
3 | * | 3 | * |
4 | * Copyright (C) 2014 Beniamino Galvani <b.galvani@gmail.com> | 4 | * Copyright (C) 2014 Beniamino Galvani <b.galvani@gmail.com> |
5 | * Copyright (C) 2016 Toradex AG | ||
5 | * | 6 | * |
6 | * This program is free software; you can redistribute it and/or | 7 | * This program is free software; you can redistribute it and/or |
7 | * modify it under the terms of the GNU General Public License | 8 | * modify it under the terms of the GNU General Public License |
@@ -15,6 +16,7 @@ | |||
15 | #include <linux/mfd/core.h> | 16 | #include <linux/mfd/core.h> |
16 | #include <linux/mfd/rn5t618.h> | 17 | #include <linux/mfd/rn5t618.h> |
17 | #include <linux/module.h> | 18 | #include <linux/module.h> |
19 | #include <linux/of_device.h> | ||
18 | #include <linux/regmap.h> | 20 | #include <linux/regmap.h> |
19 | 21 | ||
20 | static const struct mfd_cell rn5t618_cells[] = { | 22 | static const struct mfd_cell rn5t618_cells[] = { |
@@ -59,17 +61,32 @@ static void rn5t618_power_off(void) | |||
59 | RN5T618_SLPCNT_SWPWROFF, RN5T618_SLPCNT_SWPWROFF); | 61 | RN5T618_SLPCNT_SWPWROFF, RN5T618_SLPCNT_SWPWROFF); |
60 | } | 62 | } |
61 | 63 | ||
64 | static const struct of_device_id rn5t618_of_match[] = { | ||
65 | { .compatible = "ricoh,rn5t567", .data = (void *)RN5T567 }, | ||
66 | { .compatible = "ricoh,rn5t618", .data = (void *)RN5T618 }, | ||
67 | { } | ||
68 | }; | ||
69 | MODULE_DEVICE_TABLE(of, rn5t618_of_match); | ||
70 | |||
62 | static int rn5t618_i2c_probe(struct i2c_client *i2c, | 71 | static int rn5t618_i2c_probe(struct i2c_client *i2c, |
63 | const struct i2c_device_id *id) | 72 | const struct i2c_device_id *id) |
64 | { | 73 | { |
74 | const struct of_device_id *of_id; | ||
65 | struct rn5t618 *priv; | 75 | struct rn5t618 *priv; |
66 | int ret; | 76 | int ret; |
67 | 77 | ||
78 | of_id = of_match_device(rn5t618_of_match, &i2c->dev); | ||
79 | if (!of_id) { | ||
80 | dev_err(&i2c->dev, "Failed to find matching DT ID\n"); | ||
81 | return -EINVAL; | ||
82 | } | ||
83 | |||
68 | priv = devm_kzalloc(&i2c->dev, sizeof(*priv), GFP_KERNEL); | 84 | priv = devm_kzalloc(&i2c->dev, sizeof(*priv), GFP_KERNEL); |
69 | if (!priv) | 85 | if (!priv) |
70 | return -ENOMEM; | 86 | return -ENOMEM; |
71 | 87 | ||
72 | i2c_set_clientdata(i2c, priv); | 88 | i2c_set_clientdata(i2c, priv); |
89 | priv->variant = (long)of_id->data; | ||
73 | 90 | ||
74 | priv->regmap = devm_regmap_init_i2c(i2c, &rn5t618_regmap_config); | 91 | priv->regmap = devm_regmap_init_i2c(i2c, &rn5t618_regmap_config); |
75 | if (IS_ERR(priv->regmap)) { | 92 | if (IS_ERR(priv->regmap)) { |
@@ -105,12 +122,6 @@ static int rn5t618_i2c_remove(struct i2c_client *i2c) | |||
105 | return 0; | 122 | return 0; |
106 | } | 123 | } |
107 | 124 | ||
108 | static const struct of_device_id rn5t618_of_match[] = { | ||
109 | { .compatible = "ricoh,rn5t618" }, | ||
110 | { } | ||
111 | }; | ||
112 | MODULE_DEVICE_TABLE(of, rn5t618_of_match); | ||
113 | |||
114 | static const struct i2c_device_id rn5t618_i2c_id[] = { | 125 | static const struct i2c_device_id rn5t618_i2c_id[] = { |
115 | { } | 126 | { } |
116 | }; | 127 | }; |
@@ -129,5 +140,5 @@ static struct i2c_driver rn5t618_i2c_driver = { | |||
129 | module_i2c_driver(rn5t618_i2c_driver); | 140 | module_i2c_driver(rn5t618_i2c_driver); |
130 | 141 | ||
131 | MODULE_AUTHOR("Beniamino Galvani <b.galvani@gmail.com>"); | 142 | MODULE_AUTHOR("Beniamino Galvani <b.galvani@gmail.com>"); |
132 | MODULE_DESCRIPTION("Ricoh RN5T618 MFD driver"); | 143 | MODULE_DESCRIPTION("Ricoh RN5T567/618 MFD driver"); |
133 | MODULE_LICENSE("GPL v2"); | 144 | MODULE_LICENSE("GPL v2"); |
diff --git a/include/linux/mfd/rn5t618.h b/include/linux/mfd/rn5t618.h index c72d5344f3b3..54179c2577ae 100644 --- a/include/linux/mfd/rn5t618.h +++ b/include/linux/mfd/rn5t618.h | |||
@@ -20,6 +20,7 @@ | |||
20 | #define RN5T618_OTPVER 0x01 | 20 | #define RN5T618_OTPVER 0x01 |
21 | #define RN5T618_IODAC 0x02 | 21 | #define RN5T618_IODAC 0x02 |
22 | #define RN5T618_VINDAC 0x03 | 22 | #define RN5T618_VINDAC 0x03 |
23 | #define RN5T618_OUT32KEN 0x05 | ||
23 | #define RN5T618_CPUCNT 0x06 | 24 | #define RN5T618_CPUCNT 0x06 |
24 | #define RN5T618_PSWR 0x07 | 25 | #define RN5T618_PSWR 0x07 |
25 | #define RN5T618_PONHIS 0x09 | 26 | #define RN5T618_PONHIS 0x09 |
@@ -38,6 +39,7 @@ | |||
38 | #define RN5T618_DC1_SLOT 0x16 | 39 | #define RN5T618_DC1_SLOT 0x16 |
39 | #define RN5T618_DC2_SLOT 0x17 | 40 | #define RN5T618_DC2_SLOT 0x17 |
40 | #define RN5T618_DC3_SLOT 0x18 | 41 | #define RN5T618_DC3_SLOT 0x18 |
42 | #define RN5T618_DC4_SLOT 0x19 | ||
41 | #define RN5T618_LDO1_SLOT 0x1b | 43 | #define RN5T618_LDO1_SLOT 0x1b |
42 | #define RN5T618_LDO2_SLOT 0x1c | 44 | #define RN5T618_LDO2_SLOT 0x1c |
43 | #define RN5T618_LDO3_SLOT 0x1d | 45 | #define RN5T618_LDO3_SLOT 0x1d |
@@ -54,12 +56,16 @@ | |||
54 | #define RN5T618_DC2CTL2 0x2f | 56 | #define RN5T618_DC2CTL2 0x2f |
55 | #define RN5T618_DC3CTL 0x30 | 57 | #define RN5T618_DC3CTL 0x30 |
56 | #define RN5T618_DC3CTL2 0x31 | 58 | #define RN5T618_DC3CTL2 0x31 |
59 | #define RN5T618_DC4CTL 0x32 | ||
60 | #define RN5T618_DC4CTL2 0x33 | ||
57 | #define RN5T618_DC1DAC 0x36 | 61 | #define RN5T618_DC1DAC 0x36 |
58 | #define RN5T618_DC2DAC 0x37 | 62 | #define RN5T618_DC2DAC 0x37 |
59 | #define RN5T618_DC3DAC 0x38 | 63 | #define RN5T618_DC3DAC 0x38 |
64 | #define RN5T618_DC4DAC 0x39 | ||
60 | #define RN5T618_DC1DAC_SLP 0x3b | 65 | #define RN5T618_DC1DAC_SLP 0x3b |
61 | #define RN5T618_DC2DAC_SLP 0x3c | 66 | #define RN5T618_DC2DAC_SLP 0x3c |
62 | #define RN5T618_DC3DAC_SLP 0x3d | 67 | #define RN5T618_DC3DAC_SLP 0x3d |
68 | #define RN5T618_DC4DAC_SLP 0x3e | ||
63 | #define RN5T618_DCIREN 0x40 | 69 | #define RN5T618_DCIREN 0x40 |
64 | #define RN5T618_DCIRQ 0x41 | 70 | #define RN5T618_DCIRQ 0x41 |
65 | #define RN5T618_DCIRMON 0x42 | 71 | #define RN5T618_DCIRMON 0x42 |
@@ -221,8 +227,14 @@ enum { | |||
221 | RN5T618_REG_NUM, | 227 | RN5T618_REG_NUM, |
222 | }; | 228 | }; |
223 | 229 | ||
230 | enum { | ||
231 | RN5T567 = 0, | ||
232 | RN5T618, | ||
233 | }; | ||
234 | |||
224 | struct rn5t618 { | 235 | struct rn5t618 { |
225 | struct regmap *regmap; | 236 | struct regmap *regmap; |
237 | long variant; | ||
226 | }; | 238 | }; |
227 | 239 | ||
228 | #endif /* __LINUX_MFD_RN5T618_H */ | 240 | #endif /* __LINUX_MFD_RN5T618_H */ |