diff options
27 files changed, 3161 insertions, 150 deletions
diff --git a/Documentation/power/regulator/machine.txt b/Documentation/power/regulator/machine.txt index bdec39b9bd75..b42419b52e44 100644 --- a/Documentation/power/regulator/machine.txt +++ b/Documentation/power/regulator/machine.txt | |||
@@ -53,11 +53,11 @@ static struct regulator_init_data regulator1_data = { | |||
53 | 53 | ||
54 | Regulator-1 supplies power to Regulator-2. This relationship must be registered | 54 | Regulator-1 supplies power to Regulator-2. This relationship must be registered |
55 | with the core so that Regulator-1 is also enabled when Consumer A enables its | 55 | with the core so that Regulator-1 is also enabled when Consumer A enables its |
56 | supply (Regulator-2). The supply regulator is set by the supply_regulator_dev | 56 | supply (Regulator-2). The supply regulator is set by the supply_regulator |
57 | field below:- | 57 | field below:- |
58 | 58 | ||
59 | static struct regulator_init_data regulator2_data = { | 59 | static struct regulator_init_data regulator2_data = { |
60 | .supply_regulator_dev = &platform_regulator1_device.dev, | 60 | .supply_regulator = "regulator_name", |
61 | .constraints = { | 61 | .constraints = { |
62 | .min_uV = 1800000, | 62 | .min_uV = 1800000, |
63 | .max_uV = 2000000, | 63 | .max_uV = 2000000, |
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index b57ec09af891..d21364603755 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig | |||
@@ -424,4 +424,11 @@ config AB8500_GPIO | |||
424 | depends on AB8500_CORE && BROKEN | 424 | depends on AB8500_CORE && BROKEN |
425 | help | 425 | help |
426 | Select this to enable the AB8500 IC GPIO driver | 426 | Select this to enable the AB8500 IC GPIO driver |
427 | |||
428 | config GPIO_TPS65910 | ||
429 | bool "TPS65910 GPIO" | ||
430 | depends on MFD_TPS65910 | ||
431 | help | ||
432 | Select this option to enable GPIO driver for the TPS65910 | ||
433 | chip family. | ||
427 | endif | 434 | endif |
diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile index d92ce3a62ae5..6a3387acc0e5 100644 --- a/drivers/gpio/Makefile +++ b/drivers/gpio/Makefile | |||
@@ -40,3 +40,4 @@ obj-$(CONFIG_GPIO_SX150X) += sx150x.o | |||
40 | obj-$(CONFIG_GPIO_VX855) += vx855_gpio.o | 40 | obj-$(CONFIG_GPIO_VX855) += vx855_gpio.o |
41 | obj-$(CONFIG_GPIO_ML_IOH) += ml_ioh_gpio.o | 41 | obj-$(CONFIG_GPIO_ML_IOH) += ml_ioh_gpio.o |
42 | obj-$(CONFIG_AB8500_GPIO) += ab8500-gpio.o | 42 | obj-$(CONFIG_AB8500_GPIO) += ab8500-gpio.o |
43 | obj-$(CONFIG_GPIO_TPS65910) += tps65910-gpio.o | ||
diff --git a/drivers/gpio/tps65910-gpio.c b/drivers/gpio/tps65910-gpio.c new file mode 100644 index 000000000000..8d1ddfdd63eb --- /dev/null +++ b/drivers/gpio/tps65910-gpio.c | |||
@@ -0,0 +1,100 @@ | |||
1 | /* | ||
2 | * tps65910-gpio.c -- TI TPS6591x | ||
3 | * | ||
4 | * Copyright 2010 Texas Instruments Inc. | ||
5 | * | ||
6 | * Author: Graeme Gregory <gg@slimlogic.co.uk> | ||
7 | * Author: Jorge Eduardo Candelaria jedu@slimlogic.co.uk> | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify it | ||
10 | * under the terms of the GNU General Public License as published by the | ||
11 | * Free Software Foundation; either version 2 of the License, or (at your | ||
12 | * option) any later version. | ||
13 | * | ||
14 | */ | ||
15 | |||
16 | #include <linux/kernel.h> | ||
17 | #include <linux/module.h> | ||
18 | #include <linux/errno.h> | ||
19 | #include <linux/gpio.h> | ||
20 | #include <linux/i2c.h> | ||
21 | #include <linux/mfd/tps65910.h> | ||
22 | |||
23 | static int tps65910_gpio_get(struct gpio_chip *gc, unsigned offset) | ||
24 | { | ||
25 | struct tps65910 *tps65910 = container_of(gc, struct tps65910, gpio); | ||
26 | uint8_t val; | ||
27 | |||
28 | tps65910->read(tps65910, TPS65910_GPIO0 + offset, 1, &val); | ||
29 | |||
30 | if (val & GPIO_STS_MASK) | ||
31 | return 1; | ||
32 | |||
33 | return 0; | ||
34 | } | ||
35 | |||
36 | static void tps65910_gpio_set(struct gpio_chip *gc, unsigned offset, | ||
37 | int value) | ||
38 | { | ||
39 | struct tps65910 *tps65910 = container_of(gc, struct tps65910, gpio); | ||
40 | |||
41 | if (value) | ||
42 | tps65910_set_bits(tps65910, TPS65910_GPIO0 + offset, | ||
43 | GPIO_SET_MASK); | ||
44 | else | ||
45 | tps65910_clear_bits(tps65910, TPS65910_GPIO0 + offset, | ||
46 | GPIO_SET_MASK); | ||
47 | } | ||
48 | |||
49 | static int tps65910_gpio_output(struct gpio_chip *gc, unsigned offset, | ||
50 | int value) | ||
51 | { | ||
52 | struct tps65910 *tps65910 = container_of(gc, struct tps65910, gpio); | ||
53 | |||
54 | /* Set the initial value */ | ||
55 | tps65910_gpio_set(gc, 0, value); | ||
56 | |||
57 | return tps65910_set_bits(tps65910, TPS65910_GPIO0 + offset, | ||
58 | GPIO_CFG_MASK); | ||
59 | } | ||
60 | |||
61 | static int tps65910_gpio_input(struct gpio_chip *gc, unsigned offset) | ||
62 | { | ||
63 | struct tps65910 *tps65910 = container_of(gc, struct tps65910, gpio); | ||
64 | |||
65 | return tps65910_clear_bits(tps65910, TPS65910_GPIO0 + offset, | ||
66 | GPIO_CFG_MASK); | ||
67 | } | ||
68 | |||
69 | void tps65910_gpio_init(struct tps65910 *tps65910, int gpio_base) | ||
70 | { | ||
71 | int ret; | ||
72 | |||
73 | if (!gpio_base) | ||
74 | return; | ||
75 | |||
76 | tps65910->gpio.owner = THIS_MODULE; | ||
77 | tps65910->gpio.label = tps65910->i2c_client->name; | ||
78 | tps65910->gpio.dev = tps65910->dev; | ||
79 | tps65910->gpio.base = gpio_base; | ||
80 | |||
81 | switch(tps65910_chip_id(tps65910)) { | ||
82 | case TPS65910: | ||
83 | tps65910->gpio.ngpio = 6; | ||
84 | case TPS65911: | ||
85 | tps65910->gpio.ngpio = 9; | ||
86 | default: | ||
87 | return; | ||
88 | } | ||
89 | tps65910->gpio.can_sleep = 1; | ||
90 | |||
91 | tps65910->gpio.direction_input = tps65910_gpio_input; | ||
92 | tps65910->gpio.direction_output = tps65910_gpio_output; | ||
93 | tps65910->gpio.set = tps65910_gpio_set; | ||
94 | tps65910->gpio.get = tps65910_gpio_get; | ||
95 | |||
96 | ret = gpiochip_add(&tps65910->gpio); | ||
97 | |||
98 | if (ret) | ||
99 | dev_warn(tps65910->dev, "GPIO registration failed: %d\n", ret); | ||
100 | } | ||
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index 8344fc0ab858..b6c267724e14 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig | |||
@@ -719,6 +719,15 @@ config MFD_PM8XXX_IRQ | |||
719 | This is required to use certain other PM 8xxx features, such as GPIO | 719 | This is required to use certain other PM 8xxx features, such as GPIO |
720 | and MPP. | 720 | and MPP. |
721 | 721 | ||
722 | config MFD_TPS65910 | ||
723 | bool "TPS65910 Power Management chip" | ||
724 | depends on I2C=y | ||
725 | select MFD_CORE | ||
726 | select GPIO_TPS65910 | ||
727 | help | ||
728 | if you say yes here you get support for the TPS65910 series of | ||
729 | Power Management chips. | ||
730 | |||
722 | endif # MFD_SUPPORT | 731 | endif # MFD_SUPPORT |
723 | 732 | ||
724 | menu "Multimedia Capabilities Port drivers" | 733 | menu "Multimedia Capabilities Port drivers" |
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile index 1acb8f29a96c..efe3cc33ed92 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile | |||
@@ -93,3 +93,4 @@ obj-$(CONFIG_MFD_CS5535) += cs5535-mfd.o | |||
93 | obj-$(CONFIG_MFD_OMAP_USB_HOST) += omap-usb-host.o | 93 | obj-$(CONFIG_MFD_OMAP_USB_HOST) += omap-usb-host.o |
94 | obj-$(CONFIG_MFD_PM8921_CORE) += pm8921-core.o | 94 | obj-$(CONFIG_MFD_PM8921_CORE) += pm8921-core.o |
95 | obj-$(CONFIG_MFD_PM8XXX_IRQ) += pm8xxx-irq.o | 95 | obj-$(CONFIG_MFD_PM8XXX_IRQ) += pm8xxx-irq.o |
96 | obj-$(CONFIG_MFD_TPS65910) += tps65910.o tps65910-irq.o | ||
diff --git a/drivers/mfd/tps65910-irq.c b/drivers/mfd/tps65910-irq.c new file mode 100644 index 000000000000..2bfad5c86cc7 --- /dev/null +++ b/drivers/mfd/tps65910-irq.c | |||
@@ -0,0 +1,218 @@ | |||
1 | /* | ||
2 | * tps65910-irq.c -- TI TPS6591x | ||
3 | * | ||
4 | * Copyright 2010 Texas Instruments Inc. | ||
5 | * | ||
6 | * Author: Graeme Gregory <gg@slimlogic.co.uk> | ||
7 | * Author: Jorge Eduardo Candelaria <jedu@slimlogic.co.uk> | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify it | ||
10 | * under the terms of the GNU General Public License as published by the | ||
11 | * Free Software Foundation; either version 2 of the License, or (at your | ||
12 | * option) any later version. | ||
13 | * | ||
14 | */ | ||
15 | |||
16 | #include <linux/kernel.h> | ||
17 | #include <linux/module.h> | ||
18 | #include <linux/init.h> | ||
19 | #include <linux/bug.h> | ||
20 | #include <linux/device.h> | ||
21 | #include <linux/interrupt.h> | ||
22 | #include <linux/irq.h> | ||
23 | #include <linux/gpio.h> | ||
24 | #include <linux/mfd/tps65910.h> | ||
25 | |||
26 | static inline int irq_to_tps65910_irq(struct tps65910 *tps65910, | ||
27 | int irq) | ||
28 | { | ||
29 | return (irq - tps65910->irq_base); | ||
30 | } | ||
31 | |||
32 | /* | ||
33 | * This is a threaded IRQ handler so can access I2C/SPI. Since all | ||
34 | * interrupts are clear on read the IRQ line will be reasserted and | ||
35 | * the physical IRQ will be handled again if another interrupt is | ||
36 | * asserted while we run - in the normal course of events this is a | ||
37 | * rare occurrence so we save I2C/SPI reads. We're also assuming that | ||
38 | * it's rare to get lots of interrupts firing simultaneously so try to | ||
39 | * minimise I/O. | ||
40 | */ | ||
41 | static irqreturn_t tps65910_irq(int irq, void *irq_data) | ||
42 | { | ||
43 | struct tps65910 *tps65910 = irq_data; | ||
44 | u32 irq_sts; | ||
45 | u32 irq_mask; | ||
46 | u8 reg; | ||
47 | int i; | ||
48 | |||
49 | tps65910->read(tps65910, TPS65910_INT_STS, 1, ®); | ||
50 | irq_sts = reg; | ||
51 | tps65910->read(tps65910, TPS65910_INT_STS2, 1, ®); | ||
52 | irq_sts |= reg << 8; | ||
53 | switch (tps65910_chip_id(tps65910)) { | ||
54 | case TPS65911: | ||
55 | tps65910->read(tps65910, TPS65910_INT_STS3, 1, ®); | ||
56 | irq_sts |= reg << 16; | ||
57 | } | ||
58 | |||
59 | tps65910->read(tps65910, TPS65910_INT_MSK, 1, ®); | ||
60 | irq_mask = reg; | ||
61 | tps65910->read(tps65910, TPS65910_INT_MSK2, 1, ®); | ||
62 | irq_mask |= reg << 8; | ||
63 | switch (tps65910_chip_id(tps65910)) { | ||
64 | case TPS65911: | ||
65 | tps65910->read(tps65910, TPS65910_INT_MSK3, 1, ®); | ||
66 | irq_mask |= reg << 16; | ||
67 | } | ||
68 | |||
69 | irq_sts &= ~irq_mask; | ||
70 | |||
71 | if (!irq_sts) | ||
72 | return IRQ_NONE; | ||
73 | |||
74 | for (i = 0; i < tps65910->irq_num; i++) { | ||
75 | |||
76 | if (!(irq_sts & (1 << i))) | ||
77 | continue; | ||
78 | |||
79 | handle_nested_irq(tps65910->irq_base + i); | ||
80 | } | ||
81 | |||
82 | /* Write the STS register back to clear IRQs we handled */ | ||
83 | reg = irq_sts & 0xFF; | ||
84 | irq_sts >>= 8; | ||
85 | tps65910->write(tps65910, TPS65910_INT_STS, 1, ®); | ||
86 | reg = irq_sts & 0xFF; | ||
87 | tps65910->write(tps65910, TPS65910_INT_STS2, 1, ®); | ||
88 | switch (tps65910_chip_id(tps65910)) { | ||
89 | case TPS65911: | ||
90 | reg = irq_sts >> 8; | ||
91 | tps65910->write(tps65910, TPS65910_INT_STS3, 1, ®); | ||
92 | } | ||
93 | |||
94 | return IRQ_HANDLED; | ||
95 | } | ||
96 | |||
97 | static void tps65910_irq_lock(struct irq_data *data) | ||
98 | { | ||
99 | struct tps65910 *tps65910 = irq_data_get_irq_chip_data(data); | ||
100 | |||
101 | mutex_lock(&tps65910->irq_lock); | ||
102 | } | ||
103 | |||
104 | static void tps65910_irq_sync_unlock(struct irq_data *data) | ||
105 | { | ||
106 | struct tps65910 *tps65910 = irq_data_get_irq_chip_data(data); | ||
107 | u32 reg_mask; | ||
108 | u8 reg; | ||
109 | |||
110 | tps65910->read(tps65910, TPS65910_INT_MSK, 1, ®); | ||
111 | reg_mask = reg; | ||
112 | tps65910->read(tps65910, TPS65910_INT_MSK2, 1, ®); | ||
113 | reg_mask |= reg << 8; | ||
114 | switch (tps65910_chip_id(tps65910)) { | ||
115 | case TPS65911: | ||
116 | tps65910->read(tps65910, TPS65910_INT_MSK3, 1, ®); | ||
117 | reg_mask |= reg << 16; | ||
118 | } | ||
119 | |||
120 | if (tps65910->irq_mask != reg_mask) { | ||
121 | reg = tps65910->irq_mask & 0xFF; | ||
122 | tps65910->write(tps65910, TPS65910_INT_MSK, 1, ®); | ||
123 | reg = tps65910->irq_mask >> 8 & 0xFF; | ||
124 | tps65910->write(tps65910, TPS65910_INT_MSK2, 1, ®); | ||
125 | switch (tps65910_chip_id(tps65910)) { | ||
126 | case TPS65911: | ||
127 | reg = tps65910->irq_mask >> 16; | ||
128 | tps65910->write(tps65910, TPS65910_INT_MSK3, 1, ®); | ||
129 | } | ||
130 | } | ||
131 | mutex_unlock(&tps65910->irq_lock); | ||
132 | } | ||
133 | |||
134 | static void tps65910_irq_enable(struct irq_data *data) | ||
135 | { | ||
136 | struct tps65910 *tps65910 = irq_data_get_irq_chip_data(data); | ||
137 | |||
138 | tps65910->irq_mask &= ~( 1 << irq_to_tps65910_irq(tps65910, data->irq)); | ||
139 | } | ||
140 | |||
141 | static void tps65910_irq_disable(struct irq_data *data) | ||
142 | { | ||
143 | struct tps65910 *tps65910 = irq_data_get_irq_chip_data(data); | ||
144 | |||
145 | tps65910->irq_mask |= ( 1 << irq_to_tps65910_irq(tps65910, data->irq)); | ||
146 | } | ||
147 | |||
148 | static struct irq_chip tps65910_irq_chip = { | ||
149 | .name = "tps65910", | ||
150 | .irq_bus_lock = tps65910_irq_lock, | ||
151 | .irq_bus_sync_unlock = tps65910_irq_sync_unlock, | ||
152 | .irq_disable = tps65910_irq_disable, | ||
153 | .irq_enable = tps65910_irq_enable, | ||
154 | }; | ||
155 | |||
156 | int tps65910_irq_init(struct tps65910 *tps65910, int irq, | ||
157 | struct tps65910_platform_data *pdata) | ||
158 | { | ||
159 | int ret, cur_irq; | ||
160 | int flags = IRQF_ONESHOT; | ||
161 | |||
162 | if (!irq) { | ||
163 | dev_warn(tps65910->dev, "No interrupt support, no core IRQ\n"); | ||
164 | return -EINVAL; | ||
165 | } | ||
166 | |||
167 | if (!pdata || !pdata->irq_base) { | ||
168 | dev_warn(tps65910->dev, "No interrupt support, no IRQ base\n"); | ||
169 | return -EINVAL; | ||
170 | } | ||
171 | |||
172 | tps65910->irq_mask = 0xFFFFFF; | ||
173 | |||
174 | mutex_init(&tps65910->irq_lock); | ||
175 | tps65910->chip_irq = irq; | ||
176 | tps65910->irq_base = pdata->irq_base; | ||
177 | |||
178 | switch (tps65910_chip_id(tps65910)) { | ||
179 | case TPS65910: | ||
180 | tps65910->irq_num = TPS65910_NUM_IRQ; | ||
181 | case TPS65911: | ||
182 | tps65910->irq_num = TPS65911_NUM_IRQ; | ||
183 | } | ||
184 | |||
185 | /* Register with genirq */ | ||
186 | for (cur_irq = tps65910->irq_base; | ||
187 | cur_irq < tps65910->irq_num + tps65910->irq_base; | ||
188 | cur_irq++) { | ||
189 | irq_set_chip_data(cur_irq, tps65910); | ||
190 | irq_set_chip_and_handler(cur_irq, &tps65910_irq_chip, | ||
191 | handle_edge_irq); | ||
192 | irq_set_nested_thread(cur_irq, 1); | ||
193 | |||
194 | /* ARM needs us to explicitly flag the IRQ as valid | ||
195 | * and will set them noprobe when we do so. */ | ||
196 | #ifdef CONFIG_ARM | ||
197 | set_irq_flags(cur_irq, IRQF_VALID); | ||
198 | #else | ||
199 | irq_set_noprobe(cur_irq); | ||
200 | #endif | ||
201 | } | ||
202 | |||
203 | ret = request_threaded_irq(irq, NULL, tps65910_irq, flags, | ||
204 | "tps65910", tps65910); | ||
205 | |||
206 | irq_set_irq_type(irq, IRQ_TYPE_LEVEL_LOW); | ||
207 | |||
208 | if (ret != 0) | ||
209 | dev_err(tps65910->dev, "Failed to request IRQ: %d\n", ret); | ||
210 | |||
211 | return ret; | ||
212 | } | ||
213 | |||
214 | int tps65910_irq_exit(struct tps65910 *tps65910) | ||
215 | { | ||
216 | free_irq(tps65910->chip_irq, tps65910); | ||
217 | return 0; | ||
218 | } | ||
diff --git a/drivers/mfd/tps65910.c b/drivers/mfd/tps65910.c new file mode 100644 index 000000000000..2229e66d80db --- /dev/null +++ b/drivers/mfd/tps65910.c | |||
@@ -0,0 +1,229 @@ | |||
1 | /* | ||
2 | * tps65910.c -- TI TPS6591x | ||
3 | * | ||
4 | * Copyright 2010 Texas Instruments Inc. | ||
5 | * | ||
6 | * Author: Graeme Gregory <gg@slimlogic.co.uk> | ||
7 | * Author: Jorge Eduardo Candelaria <jedu@slimlogic.co.uk> | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify it | ||
10 | * under the terms of the GNU General Public License as published by the | ||
11 | * Free Software Foundation; either version 2 of the License, or (at your | ||
12 | * option) any later version. | ||
13 | * | ||
14 | */ | ||
15 | |||
16 | #include <linux/module.h> | ||
17 | #include <linux/moduleparam.h> | ||
18 | #include <linux/init.h> | ||
19 | #include <linux/slab.h> | ||
20 | #include <linux/i2c.h> | ||
21 | #include <linux/gpio.h> | ||
22 | #include <linux/mfd/core.h> | ||
23 | #include <linux/mfd/tps65910.h> | ||
24 | |||
25 | static struct mfd_cell tps65910s[] = { | ||
26 | { | ||
27 | .name = "tps65910-pmic", | ||
28 | }, | ||
29 | { | ||
30 | .name = "tps65910-rtc", | ||
31 | }, | ||
32 | { | ||
33 | .name = "tps65910-power", | ||
34 | }, | ||
35 | }; | ||
36 | |||
37 | |||
38 | static int tps65910_i2c_read(struct tps65910 *tps65910, u8 reg, | ||
39 | int bytes, void *dest) | ||
40 | { | ||
41 | struct i2c_client *i2c = tps65910->i2c_client; | ||
42 | struct i2c_msg xfer[2]; | ||
43 | int ret; | ||
44 | |||
45 | /* Write register */ | ||
46 | xfer[0].addr = i2c->addr; | ||
47 | xfer[0].flags = 0; | ||
48 | xfer[0].len = 1; | ||
49 | xfer[0].buf = ® | ||
50 | |||
51 | /* Read data */ | ||
52 | xfer[1].addr = i2c->addr; | ||
53 | xfer[1].flags = I2C_M_RD; | ||
54 | xfer[1].len = bytes; | ||
55 | xfer[1].buf = dest; | ||
56 | |||
57 | ret = i2c_transfer(i2c->adapter, xfer, 2); | ||
58 | if (ret == 2) | ||
59 | ret = 0; | ||
60 | else if (ret >= 0) | ||
61 | ret = -EIO; | ||
62 | |||
63 | return ret; | ||
64 | } | ||
65 | |||
66 | static int tps65910_i2c_write(struct tps65910 *tps65910, u8 reg, | ||
67 | int bytes, void *src) | ||
68 | { | ||
69 | struct i2c_client *i2c = tps65910->i2c_client; | ||
70 | /* we add 1 byte for device register */ | ||
71 | u8 msg[TPS65910_MAX_REGISTER + 1]; | ||
72 | int ret; | ||
73 | |||
74 | if (bytes > TPS65910_MAX_REGISTER) | ||
75 | return -EINVAL; | ||
76 | |||
77 | msg[0] = reg; | ||
78 | memcpy(&msg[1], src, bytes); | ||
79 | |||
80 | ret = i2c_master_send(i2c, msg, bytes + 1); | ||
81 | if (ret < 0) | ||
82 | return ret; | ||
83 | if (ret != bytes + 1) | ||
84 | return -EIO; | ||
85 | return 0; | ||
86 | } | ||
87 | |||
88 | int tps65910_set_bits(struct tps65910 *tps65910, u8 reg, u8 mask) | ||
89 | { | ||
90 | u8 data; | ||
91 | int err; | ||
92 | |||
93 | mutex_lock(&tps65910->io_mutex); | ||
94 | err = tps65910_i2c_read(tps65910, reg, 1, &data); | ||
95 | if (err) { | ||
96 | dev_err(tps65910->dev, "read from reg %x failed\n", reg); | ||
97 | goto out; | ||
98 | } | ||
99 | |||
100 | data |= mask; | ||
101 | err = tps65910_i2c_write(tps65910, reg, 1, &data); | ||
102 | if (err) | ||
103 | dev_err(tps65910->dev, "write to reg %x failed\n", reg); | ||
104 | |||
105 | out: | ||
106 | mutex_unlock(&tps65910->io_mutex); | ||
107 | return err; | ||
108 | } | ||
109 | EXPORT_SYMBOL_GPL(tps65910_set_bits); | ||
110 | |||
111 | int tps65910_clear_bits(struct tps65910 *tps65910, u8 reg, u8 mask) | ||
112 | { | ||
113 | u8 data; | ||
114 | int err; | ||
115 | |||
116 | mutex_lock(&tps65910->io_mutex); | ||
117 | err = tps65910_i2c_read(tps65910, reg, 1, &data); | ||
118 | if (err) { | ||
119 | dev_err(tps65910->dev, "read from reg %x failed\n", reg); | ||
120 | goto out; | ||
121 | } | ||
122 | |||
123 | data &= mask; | ||
124 | err = tps65910_i2c_write(tps65910, reg, 1, &data); | ||
125 | if (err) | ||
126 | dev_err(tps65910->dev, "write to reg %x failed\n", reg); | ||
127 | |||
128 | out: | ||
129 | mutex_unlock(&tps65910->io_mutex); | ||
130 | return err; | ||
131 | } | ||
132 | EXPORT_SYMBOL_GPL(tps65910_clear_bits); | ||
133 | |||
134 | static int tps65910_i2c_probe(struct i2c_client *i2c, | ||
135 | const struct i2c_device_id *id) | ||
136 | { | ||
137 | struct tps65910 *tps65910; | ||
138 | struct tps65910_board *pmic_plat_data; | ||
139 | struct tps65910_platform_data *init_data; | ||
140 | int ret = 0; | ||
141 | |||
142 | pmic_plat_data = dev_get_platdata(&i2c->dev); | ||
143 | if (!pmic_plat_data) | ||
144 | return -EINVAL; | ||
145 | |||
146 | init_data = kzalloc(sizeof(struct tps65910_platform_data), GFP_KERNEL); | ||
147 | if (init_data == NULL) | ||
148 | return -ENOMEM; | ||
149 | |||
150 | init_data->irq = pmic_plat_data->irq; | ||
151 | init_data->irq_base = pmic_plat_data->irq; | ||
152 | |||
153 | tps65910 = kzalloc(sizeof(struct tps65910), GFP_KERNEL); | ||
154 | if (tps65910 == NULL) | ||
155 | return -ENOMEM; | ||
156 | |||
157 | i2c_set_clientdata(i2c, tps65910); | ||
158 | tps65910->dev = &i2c->dev; | ||
159 | tps65910->i2c_client = i2c; | ||
160 | tps65910->id = id->driver_data; | ||
161 | tps65910->read = tps65910_i2c_read; | ||
162 | tps65910->write = tps65910_i2c_write; | ||
163 | mutex_init(&tps65910->io_mutex); | ||
164 | |||
165 | ret = mfd_add_devices(tps65910->dev, -1, | ||
166 | tps65910s, ARRAY_SIZE(tps65910s), | ||
167 | NULL, 0); | ||
168 | if (ret < 0) | ||
169 | goto err; | ||
170 | |||
171 | tps65910_gpio_init(tps65910, pmic_plat_data->gpio_base); | ||
172 | |||
173 | ret = tps65910_irq_init(tps65910, init_data->irq, init_data); | ||
174 | if (ret < 0) | ||
175 | goto err; | ||
176 | |||
177 | return ret; | ||
178 | |||
179 | err: | ||
180 | mfd_remove_devices(tps65910->dev); | ||
181 | kfree(tps65910); | ||
182 | return ret; | ||
183 | } | ||
184 | |||
185 | static int tps65910_i2c_remove(struct i2c_client *i2c) | ||
186 | { | ||
187 | struct tps65910 *tps65910 = i2c_get_clientdata(i2c); | ||
188 | |||
189 | mfd_remove_devices(tps65910->dev); | ||
190 | kfree(tps65910); | ||
191 | |||
192 | return 0; | ||
193 | } | ||
194 | |||
195 | static const struct i2c_device_id tps65910_i2c_id[] = { | ||
196 | { "tps65910", TPS65910 }, | ||
197 | { "tps65911", TPS65911 }, | ||
198 | { } | ||
199 | }; | ||
200 | MODULE_DEVICE_TABLE(i2c, tps65910_i2c_id); | ||
201 | |||
202 | |||
203 | static struct i2c_driver tps65910_i2c_driver = { | ||
204 | .driver = { | ||
205 | .name = "tps65910", | ||
206 | .owner = THIS_MODULE, | ||
207 | }, | ||
208 | .probe = tps65910_i2c_probe, | ||
209 | .remove = tps65910_i2c_remove, | ||
210 | .id_table = tps65910_i2c_id, | ||
211 | }; | ||
212 | |||
213 | static int __init tps65910_i2c_init(void) | ||
214 | { | ||
215 | return i2c_add_driver(&tps65910_i2c_driver); | ||
216 | } | ||
217 | /* init early so consumer devices can complete system boot */ | ||
218 | subsys_initcall(tps65910_i2c_init); | ||
219 | |||
220 | static void __exit tps65910_i2c_exit(void) | ||
221 | { | ||
222 | i2c_del_driver(&tps65910_i2c_driver); | ||
223 | } | ||
224 | module_exit(tps65910_i2c_exit); | ||
225 | |||
226 | MODULE_AUTHOR("Graeme Gregory <gg@slimlogic.co.uk>"); | ||
227 | MODULE_AUTHOR("Jorge Eduardo Candelaria <jedu@slimlogic.co.uk>"); | ||
228 | MODULE_DESCRIPTION("TPS6591x chip family multi-function driver"); | ||
229 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/mfd/tps65911-comparator.c b/drivers/mfd/tps65911-comparator.c new file mode 100644 index 000000000000..3d2dc56a3d40 --- /dev/null +++ b/drivers/mfd/tps65911-comparator.c | |||
@@ -0,0 +1,188 @@ | |||
1 | /* | ||
2 | * tps65910.c -- TI TPS6591x | ||
3 | * | ||
4 | * Copyright 2010 Texas Instruments Inc. | ||
5 | * | ||
6 | * Author: Jorge Eduardo Candelaria <jedu@slimlogic.co.uk> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify it | ||
9 | * under the terms of the GNU General Public License as published by the | ||
10 | * Free Software Foundation; either version 2 of the License, or (at your | ||
11 | * option) any later version. | ||
12 | * | ||
13 | */ | ||
14 | |||
15 | #include <linux/kernel.h> | ||
16 | #include <linux/module.h> | ||
17 | #include <linux/init.h> | ||
18 | #include <linux/slab.h> | ||
19 | #include <linux/err.h> | ||
20 | #include <linux/platform_device.h> | ||
21 | #include <linux/debugfs.h> | ||
22 | #include <linux/gpio.h> | ||
23 | #include <linux/mfd/tps65910.h> | ||
24 | |||
25 | #define COMP 0 | ||
26 | #define COMP1 1 | ||
27 | #define COMP2 2 | ||
28 | |||
29 | /* Comparator 1 voltage selection table in milivolts */ | ||
30 | static const u16 COMP_VSEL_TABLE[] = { | ||
31 | 0, 2500, 2500, 2500, 2500, 2550, 2600, 2650, | ||
32 | 2700, 2750, 2800, 2850, 2900, 2950, 3000, 3050, | ||
33 | 3100, 3150, 3200, 3250, 3300, 3350, 3400, 3450, | ||
34 | 3500, | ||
35 | }; | ||
36 | |||
37 | struct comparator { | ||
38 | const char *name; | ||
39 | int reg; | ||
40 | int uV_max; | ||
41 | const u16 *vsel_table; | ||
42 | }; | ||
43 | |||
44 | static struct comparator tps_comparators[] = { | ||
45 | { | ||
46 | .name = "COMP1", | ||
47 | .reg = TPS65911_VMBCH, | ||
48 | .uV_max = 3500, | ||
49 | .vsel_table = COMP_VSEL_TABLE, | ||
50 | }, | ||
51 | { | ||
52 | .name = "COMP2", | ||
53 | .reg = TPS65911_VMBCH2, | ||
54 | .uV_max = 3500, | ||
55 | .vsel_table = COMP_VSEL_TABLE, | ||
56 | }, | ||
57 | }; | ||
58 | |||
59 | static int comp_threshold_set(struct tps65910 *tps65910, int id, int voltage) | ||
60 | { | ||
61 | struct comparator tps_comp = tps_comparators[id]; | ||
62 | int curr_voltage = 0; | ||
63 | int ret; | ||
64 | u8 index = 0, val; | ||
65 | |||
66 | if (id == COMP) | ||
67 | return 0; | ||
68 | |||
69 | while (curr_voltage < tps_comp.uV_max) { | ||
70 | curr_voltage = tps_comp.vsel_table[index]; | ||
71 | if (curr_voltage >= voltage) | ||
72 | break; | ||
73 | else if (curr_voltage < voltage) | ||
74 | index ++; | ||
75 | } | ||
76 | |||
77 | if (curr_voltage > tps_comp.uV_max) | ||
78 | return -EINVAL; | ||
79 | |||
80 | val = index << 1; | ||
81 | ret = tps65910->write(tps65910, tps_comp.reg, 1, &val); | ||
82 | |||
83 | return ret; | ||
84 | } | ||
85 | |||
86 | static int comp_threshold_get(struct tps65910 *tps65910, int id) | ||
87 | { | ||
88 | struct comparator tps_comp = tps_comparators[id]; | ||
89 | int ret; | ||
90 | u8 val; | ||
91 | |||
92 | if (id == COMP) | ||
93 | return 0; | ||
94 | |||
95 | ret = tps65910->read(tps65910, tps_comp.reg, 1, &val); | ||
96 | if (ret < 0) | ||
97 | return ret; | ||
98 | |||
99 | val >>= 1; | ||
100 | return tps_comp.vsel_table[val]; | ||
101 | } | ||
102 | |||
103 | static ssize_t comp_threshold_show(struct device *dev, | ||
104 | struct device_attribute *attr, char *buf) | ||
105 | { | ||
106 | struct tps65910 *tps65910 = dev_get_drvdata(dev->parent); | ||
107 | struct attribute comp_attr = attr->attr; | ||
108 | int id, uVolt; | ||
109 | |||
110 | if (!strcmp(comp_attr.name, "comp1_threshold")) | ||
111 | id = COMP1; | ||
112 | else if (!strcmp(comp_attr.name, "comp2_threshold")) | ||
113 | id = COMP2; | ||
114 | else | ||
115 | return -EINVAL; | ||
116 | |||
117 | uVolt = comp_threshold_get(tps65910, id); | ||
118 | |||
119 | return sprintf(buf, "%d\n", uVolt); | ||
120 | } | ||
121 | |||
122 | static DEVICE_ATTR(comp1_threshold, S_IRUGO, comp_threshold_show, NULL); | ||
123 | static DEVICE_ATTR(comp2_threshold, S_IRUGO, comp_threshold_show, NULL); | ||
124 | |||
125 | static __devinit int tps65911_comparator_probe(struct platform_device *pdev) | ||
126 | { | ||
127 | struct tps65910 *tps65910 = dev_get_drvdata(pdev->dev.parent); | ||
128 | struct tps65910_platform_data *pdata = dev_get_platdata(tps65910->dev); | ||
129 | int ret; | ||
130 | |||
131 | ret = comp_threshold_set(tps65910, COMP1, pdata->vmbch_threshold); | ||
132 | if (ret < 0) { | ||
133 | dev_err(&pdev->dev, "cannot set COMP1 threshold\n"); | ||
134 | return ret; | ||
135 | } | ||
136 | |||
137 | ret = comp_threshold_set(tps65910, COMP2, pdata->vmbch2_threshold); | ||
138 | if (ret < 0) { | ||
139 | dev_err(&pdev->dev, "cannot set COMP2 theshold\n"); | ||
140 | return ret; | ||
141 | } | ||
142 | |||
143 | /* Create sysfs entry */ | ||
144 | ret = device_create_file(&pdev->dev, &dev_attr_comp1_threshold); | ||
145 | if (ret < 0) | ||
146 | dev_err(&pdev->dev, "failed to add COMP1 sysfs file\n"); | ||
147 | |||
148 | ret = device_create_file(&pdev->dev, &dev_attr_comp2_threshold); | ||
149 | if (ret < 0) | ||
150 | dev_err(&pdev->dev, "failed to add COMP2 sysfs file\n"); | ||
151 | |||
152 | return ret; | ||
153 | } | ||
154 | |||
155 | static __devexit int tps65911_comparator_remove(struct platform_device *pdev) | ||
156 | { | ||
157 | struct tps65910 *tps65910; | ||
158 | |||
159 | tps65910 = dev_get_drvdata(pdev->dev.parent); | ||
160 | |||
161 | return 0; | ||
162 | } | ||
163 | |||
164 | static struct platform_driver tps65911_comparator_driver = { | ||
165 | .driver = { | ||
166 | .name = "tps65911-comparator", | ||
167 | .owner = THIS_MODULE, | ||
168 | }, | ||
169 | .probe = tps65911_comparator_probe, | ||
170 | .remove = __devexit_p(tps65911_comparator_remove), | ||
171 | }; | ||
172 | |||
173 | static int __init tps65911_comparator_init(void) | ||
174 | { | ||
175 | return platform_driver_register(&tps65911_comparator_driver); | ||
176 | } | ||
177 | subsys_initcall(tps65911_comparator_init); | ||
178 | |||
179 | static void __exit tps65911_comparator_exit(void) | ||
180 | { | ||
181 | platform_driver_unregister(&tps65911_comparator_driver); | ||
182 | } | ||
183 | module_exit(tps65911_comparator_exit); | ||
184 | |||
185 | MODULE_AUTHOR("Jorge Eduardo Candelaria <jedu@slimlogic.co.uk>"); | ||
186 | MODULE_DESCRIPTION("TPS65911 comparator driver"); | ||
187 | MODULE_LICENSE("GPL v2"); | ||
188 | MODULE_ALIAS("platform:tps65911-comparator"); | ||
diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig index f0b13a0d1851..d7ed20f293d7 100644 --- a/drivers/regulator/Kconfig +++ b/drivers/regulator/Kconfig | |||
@@ -297,5 +297,11 @@ config REGULATOR_TPS6524X | |||
297 | serial interface currently supported on the sequencer serial | 297 | serial interface currently supported on the sequencer serial |
298 | port controller. | 298 | port controller. |
299 | 299 | ||
300 | config REGULATOR_TPS65910 | ||
301 | tristate "TI TPS65910 Power Regulator" | ||
302 | depends on MFD_TPS65910 | ||
303 | help | ||
304 | This driver supports TPS65910 voltage regulator chips. | ||
305 | |||
300 | endif | 306 | endif |
301 | 307 | ||
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile index 165ff5371e9e..3932d2ec38f3 100644 --- a/drivers/regulator/Makefile +++ b/drivers/regulator/Makefile | |||
@@ -42,5 +42,6 @@ obj-$(CONFIG_REGULATOR_88PM8607) += 88pm8607.o | |||
42 | obj-$(CONFIG_REGULATOR_ISL6271A) += isl6271a-regulator.o | 42 | obj-$(CONFIG_REGULATOR_ISL6271A) += isl6271a-regulator.o |
43 | obj-$(CONFIG_REGULATOR_AB8500) += ab8500.o | 43 | obj-$(CONFIG_REGULATOR_AB8500) += ab8500.o |
44 | obj-$(CONFIG_REGULATOR_DB8500_PRCMU) += db8500-prcmu.o | 44 | obj-$(CONFIG_REGULATOR_DB8500_PRCMU) += db8500-prcmu.o |
45 | obj-$(CONFIG_REGULATOR_TPS65910) += tps65910-regulator.o | ||
45 | 46 | ||
46 | ccflags-$(CONFIG_REGULATOR_DEBUG) += -DDEBUG | 47 | ccflags-$(CONFIG_REGULATOR_DEBUG) += -DDEBUG |
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 0fae51c4845a..d3e38790906e 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c | |||
@@ -158,6 +158,13 @@ static int regulator_check_consumers(struct regulator_dev *rdev, | |||
158 | struct regulator *regulator; | 158 | struct regulator *regulator; |
159 | 159 | ||
160 | list_for_each_entry(regulator, &rdev->consumer_list, list) { | 160 | list_for_each_entry(regulator, &rdev->consumer_list, list) { |
161 | /* | ||
162 | * Assume consumers that didn't say anything are OK | ||
163 | * with anything in the constraint range. | ||
164 | */ | ||
165 | if (!regulator->min_uV && !regulator->max_uV) | ||
166 | continue; | ||
167 | |||
161 | if (*max_uV > regulator->max_uV) | 168 | if (*max_uV > regulator->max_uV) |
162 | *max_uV = regulator->max_uV; | 169 | *max_uV = regulator->max_uV; |
163 | if (*min_uV < regulator->min_uV) | 170 | if (*min_uV < regulator->min_uV) |
@@ -197,9 +204,9 @@ static int regulator_check_current_limit(struct regulator_dev *rdev, | |||
197 | } | 204 | } |
198 | 205 | ||
199 | /* operating mode constraint check */ | 206 | /* operating mode constraint check */ |
200 | static int regulator_check_mode(struct regulator_dev *rdev, int mode) | 207 | static int regulator_mode_constrain(struct regulator_dev *rdev, int *mode) |
201 | { | 208 | { |
202 | switch (mode) { | 209 | switch (*mode) { |
203 | case REGULATOR_MODE_FAST: | 210 | case REGULATOR_MODE_FAST: |
204 | case REGULATOR_MODE_NORMAL: | 211 | case REGULATOR_MODE_NORMAL: |
205 | case REGULATOR_MODE_IDLE: | 212 | case REGULATOR_MODE_IDLE: |
@@ -217,11 +224,17 @@ static int regulator_check_mode(struct regulator_dev *rdev, int mode) | |||
217 | rdev_err(rdev, "operation not allowed\n"); | 224 | rdev_err(rdev, "operation not allowed\n"); |
218 | return -EPERM; | 225 | return -EPERM; |
219 | } | 226 | } |
220 | if (!(rdev->constraints->valid_modes_mask & mode)) { | 227 | |
221 | rdev_err(rdev, "invalid mode %x\n", mode); | 228 | /* The modes are bitmasks, the most power hungry modes having |
222 | return -EINVAL; | 229 | * the lowest values. If the requested mode isn't supported |
230 | * try higher modes. */ | ||
231 | while (*mode) { | ||
232 | if (rdev->constraints->valid_modes_mask & *mode) | ||
233 | return 0; | ||
234 | *mode /= 2; | ||
223 | } | 235 | } |
224 | return 0; | 236 | |
237 | return -EINVAL; | ||
225 | } | 238 | } |
226 | 239 | ||
227 | /* dynamic regulator mode switching constraint check */ | 240 | /* dynamic regulator mode switching constraint check */ |
@@ -612,7 +625,7 @@ static void drms_uA_update(struct regulator_dev *rdev) | |||
612 | output_uV, current_uA); | 625 | output_uV, current_uA); |
613 | 626 | ||
614 | /* check the new mode is allowed */ | 627 | /* check the new mode is allowed */ |
615 | err = regulator_check_mode(rdev, mode); | 628 | err = regulator_mode_constrain(rdev, &mode); |
616 | if (err == 0) | 629 | if (err == 0) |
617 | rdev->desc->ops->set_mode(rdev, mode); | 630 | rdev->desc->ops->set_mode(rdev, mode); |
618 | } | 631 | } |
@@ -718,6 +731,10 @@ static void print_constraints(struct regulator_dev *rdev) | |||
718 | count += sprintf(buf + count, "at %d mV ", ret / 1000); | 731 | count += sprintf(buf + count, "at %d mV ", ret / 1000); |
719 | } | 732 | } |
720 | 733 | ||
734 | if (constraints->uV_offset) | ||
735 | count += sprintf(buf, "%dmV offset ", | ||
736 | constraints->uV_offset / 1000); | ||
737 | |||
721 | if (constraints->min_uA && constraints->max_uA) { | 738 | if (constraints->min_uA && constraints->max_uA) { |
722 | if (constraints->min_uA == constraints->max_uA) | 739 | if (constraints->min_uA == constraints->max_uA) |
723 | count += sprintf(buf + count, "%d mA ", | 740 | count += sprintf(buf + count, "%d mA ", |
@@ -1498,13 +1515,14 @@ static int _regulator_force_disable(struct regulator_dev *rdev, | |||
1498 | */ | 1515 | */ |
1499 | int regulator_force_disable(struct regulator *regulator) | 1516 | int regulator_force_disable(struct regulator *regulator) |
1500 | { | 1517 | { |
1518 | struct regulator_dev *rdev = regulator->rdev; | ||
1501 | struct regulator_dev *supply_rdev = NULL; | 1519 | struct regulator_dev *supply_rdev = NULL; |
1502 | int ret; | 1520 | int ret; |
1503 | 1521 | ||
1504 | mutex_lock(®ulator->rdev->mutex); | 1522 | mutex_lock(&rdev->mutex); |
1505 | regulator->uA_load = 0; | 1523 | regulator->uA_load = 0; |
1506 | ret = _regulator_force_disable(regulator->rdev, &supply_rdev); | 1524 | ret = _regulator_force_disable(rdev, &supply_rdev); |
1507 | mutex_unlock(®ulator->rdev->mutex); | 1525 | mutex_unlock(&rdev->mutex); |
1508 | 1526 | ||
1509 | if (supply_rdev) | 1527 | if (supply_rdev) |
1510 | regulator_disable(get_device_regulator(rdev_get_dev(supply_rdev))); | 1528 | regulator_disable(get_device_regulator(rdev_get_dev(supply_rdev))); |
@@ -1634,6 +1652,9 @@ static int _regulator_do_set_voltage(struct regulator_dev *rdev, | |||
1634 | 1652 | ||
1635 | trace_regulator_set_voltage(rdev_get_name(rdev), min_uV, max_uV); | 1653 | trace_regulator_set_voltage(rdev_get_name(rdev), min_uV, max_uV); |
1636 | 1654 | ||
1655 | min_uV += rdev->constraints->uV_offset; | ||
1656 | max_uV += rdev->constraints->uV_offset; | ||
1657 | |||
1637 | if (rdev->desc->ops->set_voltage) { | 1658 | if (rdev->desc->ops->set_voltage) { |
1638 | ret = rdev->desc->ops->set_voltage(rdev, min_uV, max_uV, | 1659 | ret = rdev->desc->ops->set_voltage(rdev, min_uV, max_uV, |
1639 | &selector); | 1660 | &selector); |
@@ -1858,18 +1879,22 @@ EXPORT_SYMBOL_GPL(regulator_sync_voltage); | |||
1858 | 1879 | ||
1859 | static int _regulator_get_voltage(struct regulator_dev *rdev) | 1880 | static int _regulator_get_voltage(struct regulator_dev *rdev) |
1860 | { | 1881 | { |
1861 | int sel; | 1882 | int sel, ret; |
1862 | 1883 | ||
1863 | if (rdev->desc->ops->get_voltage_sel) { | 1884 | if (rdev->desc->ops->get_voltage_sel) { |
1864 | sel = rdev->desc->ops->get_voltage_sel(rdev); | 1885 | sel = rdev->desc->ops->get_voltage_sel(rdev); |
1865 | if (sel < 0) | 1886 | if (sel < 0) |
1866 | return sel; | 1887 | return sel; |
1867 | return rdev->desc->ops->list_voltage(rdev, sel); | 1888 | ret = rdev->desc->ops->list_voltage(rdev, sel); |
1868 | } | 1889 | } else if (rdev->desc->ops->get_voltage) { |
1869 | if (rdev->desc->ops->get_voltage) | 1890 | ret = rdev->desc->ops->get_voltage(rdev); |
1870 | return rdev->desc->ops->get_voltage(rdev); | 1891 | } else { |
1871 | else | ||
1872 | return -EINVAL; | 1892 | return -EINVAL; |
1893 | } | ||
1894 | |||
1895 | if (ret < 0) | ||
1896 | return ret; | ||
1897 | return ret - rdev->constraints->uV_offset; | ||
1873 | } | 1898 | } |
1874 | 1899 | ||
1875 | /** | 1900 | /** |
@@ -2005,7 +2030,7 @@ int regulator_set_mode(struct regulator *regulator, unsigned int mode) | |||
2005 | } | 2030 | } |
2006 | 2031 | ||
2007 | /* constraints check */ | 2032 | /* constraints check */ |
2008 | ret = regulator_check_mode(rdev, mode); | 2033 | ret = regulator_mode_constrain(rdev, &mode); |
2009 | if (ret < 0) | 2034 | if (ret < 0) |
2010 | goto out; | 2035 | goto out; |
2011 | 2036 | ||
@@ -2081,16 +2106,26 @@ int regulator_set_optimum_mode(struct regulator *regulator, int uA_load) | |||
2081 | 2106 | ||
2082 | mutex_lock(&rdev->mutex); | 2107 | mutex_lock(&rdev->mutex); |
2083 | 2108 | ||
2109 | /* | ||
2110 | * first check to see if we can set modes at all, otherwise just | ||
2111 | * tell the consumer everything is OK. | ||
2112 | */ | ||
2084 | regulator->uA_load = uA_load; | 2113 | regulator->uA_load = uA_load; |
2085 | ret = regulator_check_drms(rdev); | 2114 | ret = regulator_check_drms(rdev); |
2086 | if (ret < 0) | 2115 | if (ret < 0) { |
2116 | ret = 0; | ||
2087 | goto out; | 2117 | goto out; |
2088 | ret = -EINVAL; | 2118 | } |
2089 | 2119 | ||
2090 | /* sanity check */ | ||
2091 | if (!rdev->desc->ops->get_optimum_mode) | 2120 | if (!rdev->desc->ops->get_optimum_mode) |
2092 | goto out; | 2121 | goto out; |
2093 | 2122 | ||
2123 | /* | ||
2124 | * we can actually do this so any errors are indicators of | ||
2125 | * potential real failure. | ||
2126 | */ | ||
2127 | ret = -EINVAL; | ||
2128 | |||
2094 | /* get output voltage */ | 2129 | /* get output voltage */ |
2095 | output_uV = _regulator_get_voltage(rdev); | 2130 | output_uV = _regulator_get_voltage(rdev); |
2096 | if (output_uV <= 0) { | 2131 | if (output_uV <= 0) { |
@@ -2116,7 +2151,7 @@ int regulator_set_optimum_mode(struct regulator *regulator, int uA_load) | |||
2116 | mode = rdev->desc->ops->get_optimum_mode(rdev, | 2151 | mode = rdev->desc->ops->get_optimum_mode(rdev, |
2117 | input_uV, output_uV, | 2152 | input_uV, output_uV, |
2118 | total_uA_load); | 2153 | total_uA_load); |
2119 | ret = regulator_check_mode(rdev, mode); | 2154 | ret = regulator_mode_constrain(rdev, &mode); |
2120 | if (ret < 0) { | 2155 | if (ret < 0) { |
2121 | rdev_err(rdev, "failed to get optimum mode @ %d uA %d -> %d uV\n", | 2156 | rdev_err(rdev, "failed to get optimum mode @ %d uA %d -> %d uV\n", |
2122 | total_uA_load, input_uV, output_uV); | 2157 | total_uA_load, input_uV, output_uV); |
@@ -2589,14 +2624,6 @@ struct regulator_dev *regulator_register(struct regulator_desc *regulator_desc, | |||
2589 | if (ret < 0) | 2624 | if (ret < 0) |
2590 | goto scrub; | 2625 | goto scrub; |
2591 | 2626 | ||
2592 | /* set supply regulator if it exists */ | ||
2593 | if (init_data->supply_regulator && init_data->supply_regulator_dev) { | ||
2594 | dev_err(dev, | ||
2595 | "Supply regulator specified by both name and dev\n"); | ||
2596 | ret = -EINVAL; | ||
2597 | goto scrub; | ||
2598 | } | ||
2599 | |||
2600 | if (init_data->supply_regulator) { | 2627 | if (init_data->supply_regulator) { |
2601 | struct regulator_dev *r; | 2628 | struct regulator_dev *r; |
2602 | int found = 0; | 2629 | int found = 0; |
@@ -2621,14 +2648,6 @@ struct regulator_dev *regulator_register(struct regulator_desc *regulator_desc, | |||
2621 | goto scrub; | 2648 | goto scrub; |
2622 | } | 2649 | } |
2623 | 2650 | ||
2624 | if (init_data->supply_regulator_dev) { | ||
2625 | dev_warn(dev, "Uses supply_regulator_dev instead of regulator_supply\n"); | ||
2626 | ret = set_supply(rdev, | ||
2627 | dev_get_drvdata(init_data->supply_regulator_dev)); | ||
2628 | if (ret < 0) | ||
2629 | goto scrub; | ||
2630 | } | ||
2631 | |||
2632 | /* add consumers devices */ | 2651 | /* add consumers devices */ |
2633 | for (i = 0; i < init_data->num_consumer_supplies; i++) { | 2652 | for (i = 0; i < init_data->num_consumer_supplies; i++) { |
2634 | ret = set_consumer_device_supply(rdev, | 2653 | ret = set_consumer_device_supply(rdev, |
diff --git a/drivers/regulator/max8997.c b/drivers/regulator/max8997.c index 77e0cfb30b23..10d5a1d9768e 100644 --- a/drivers/regulator/max8997.c +++ b/drivers/regulator/max8997.c | |||
@@ -267,7 +267,6 @@ static int max8997_get_enable_register(struct regulator_dev *rdev, | |||
267 | default: | 267 | default: |
268 | /* Not controllable or not exists */ | 268 | /* Not controllable or not exists */ |
269 | return -EINVAL; | 269 | return -EINVAL; |
270 | break; | ||
271 | } | 270 | } |
272 | 271 | ||
273 | return 0; | 272 | return 0; |
@@ -1033,11 +1032,11 @@ static __devinit int max8997_pmic_probe(struct platform_device *pdev) | |||
1033 | 1032 | ||
1034 | /* For the safety, set max voltage before setting up */ | 1033 | /* For the safety, set max voltage before setting up */ |
1035 | for (i = 0; i < 8; i++) { | 1034 | for (i = 0; i < 8; i++) { |
1036 | max8997_update_reg(i2c, MAX8997_REG_BUCK1DVS(i + 1), | 1035 | max8997_update_reg(i2c, MAX8997_REG_BUCK1DVS1 + i, |
1037 | max_buck1, 0x3f); | 1036 | max_buck1, 0x3f); |
1038 | max8997_update_reg(i2c, MAX8997_REG_BUCK2DVS(i + 1), | 1037 | max8997_update_reg(i2c, MAX8997_REG_BUCK2DVS1 + i, |
1039 | max_buck2, 0x3f); | 1038 | max_buck2, 0x3f); |
1040 | max8997_update_reg(i2c, MAX8997_REG_BUCK5DVS(i + 1), | 1039 | max8997_update_reg(i2c, MAX8997_REG_BUCK5DVS1 + i, |
1041 | max_buck5, 0x3f); | 1040 | max_buck5, 0x3f); |
1042 | } | 1041 | } |
1043 | 1042 | ||
@@ -1114,13 +1113,13 @@ static __devinit int max8997_pmic_probe(struct platform_device *pdev) | |||
1114 | 1113 | ||
1115 | /* Initialize all the DVS related BUCK registers */ | 1114 | /* Initialize all the DVS related BUCK registers */ |
1116 | for (i = 0; i < 8; i++) { | 1115 | for (i = 0; i < 8; i++) { |
1117 | max8997_update_reg(i2c, MAX8997_REG_BUCK1DVS(i + 1), | 1116 | max8997_update_reg(i2c, MAX8997_REG_BUCK1DVS1 + i, |
1118 | max8997->buck1_vol[i], | 1117 | max8997->buck1_vol[i], |
1119 | 0x3f); | 1118 | 0x3f); |
1120 | max8997_update_reg(i2c, MAX8997_REG_BUCK2DVS(i + 1), | 1119 | max8997_update_reg(i2c, MAX8997_REG_BUCK2DVS1 + i, |
1121 | max8997->buck2_vol[i], | 1120 | max8997->buck2_vol[i], |
1122 | 0x3f); | 1121 | 0x3f); |
1123 | max8997_update_reg(i2c, MAX8997_REG_BUCK5DVS(i + 1), | 1122 | max8997_update_reg(i2c, MAX8997_REG_BUCK5DVS1 + i, |
1124 | max8997->buck5_vol[i], | 1123 | max8997->buck5_vol[i], |
1125 | 0x3f); | 1124 | 0x3f); |
1126 | } | 1125 | } |
diff --git a/drivers/regulator/max8998.c b/drivers/regulator/max8998.c index f57e9c42fdb4..41a1495eec2b 100644 --- a/drivers/regulator/max8998.c +++ b/drivers/regulator/max8998.c | |||
@@ -732,13 +732,15 @@ static __devinit int max8998_pmic_probe(struct platform_device *pdev) | |||
732 | if (!pdata->buck1_set1) { | 732 | if (!pdata->buck1_set1) { |
733 | printk(KERN_ERR "MAX8998 SET1 GPIO defined as 0 !\n"); | 733 | printk(KERN_ERR "MAX8998 SET1 GPIO defined as 0 !\n"); |
734 | WARN_ON(!pdata->buck1_set1); | 734 | WARN_ON(!pdata->buck1_set1); |
735 | return -EIO; | 735 | ret = -EIO; |
736 | goto err_free_mem; | ||
736 | } | 737 | } |
737 | /* Check if SET2 is not equal to 0 */ | 738 | /* Check if SET2 is not equal to 0 */ |
738 | if (!pdata->buck1_set2) { | 739 | if (!pdata->buck1_set2) { |
739 | printk(KERN_ERR "MAX8998 SET2 GPIO defined as 0 !\n"); | 740 | printk(KERN_ERR "MAX8998 SET2 GPIO defined as 0 !\n"); |
740 | WARN_ON(!pdata->buck1_set2); | 741 | WARN_ON(!pdata->buck1_set2); |
741 | return -EIO; | 742 | ret = -EIO; |
743 | goto err_free_mem; | ||
742 | } | 744 | } |
743 | 745 | ||
744 | gpio_request(pdata->buck1_set1, "MAX8998 BUCK1_SET1"); | 746 | gpio_request(pdata->buck1_set1, "MAX8998 BUCK1_SET1"); |
@@ -758,7 +760,7 @@ static __devinit int max8998_pmic_probe(struct platform_device *pdev) | |||
758 | max8998->buck1_vol[0] = i; | 760 | max8998->buck1_vol[0] = i; |
759 | ret = max8998_write_reg(i2c, MAX8998_REG_BUCK1_VOLTAGE1, i); | 761 | ret = max8998_write_reg(i2c, MAX8998_REG_BUCK1_VOLTAGE1, i); |
760 | if (ret) | 762 | if (ret) |
761 | return ret; | 763 | goto err_free_mem; |
762 | 764 | ||
763 | /* Set predefined value for BUCK1 register 2 */ | 765 | /* Set predefined value for BUCK1 register 2 */ |
764 | i = 0; | 766 | i = 0; |
@@ -770,7 +772,7 @@ static __devinit int max8998_pmic_probe(struct platform_device *pdev) | |||
770 | max8998->buck1_vol[1] = i; | 772 | max8998->buck1_vol[1] = i; |
771 | ret = max8998_write_reg(i2c, MAX8998_REG_BUCK1_VOLTAGE2, i); | 773 | ret = max8998_write_reg(i2c, MAX8998_REG_BUCK1_VOLTAGE2, i); |
772 | if (ret) | 774 | if (ret) |
773 | return ret; | 775 | goto err_free_mem; |
774 | 776 | ||
775 | /* Set predefined value for BUCK1 register 3 */ | 777 | /* Set predefined value for BUCK1 register 3 */ |
776 | i = 0; | 778 | i = 0; |
@@ -782,7 +784,7 @@ static __devinit int max8998_pmic_probe(struct platform_device *pdev) | |||
782 | max8998->buck1_vol[2] = i; | 784 | max8998->buck1_vol[2] = i; |
783 | ret = max8998_write_reg(i2c, MAX8998_REG_BUCK1_VOLTAGE3, i); | 785 | ret = max8998_write_reg(i2c, MAX8998_REG_BUCK1_VOLTAGE3, i); |
784 | if (ret) | 786 | if (ret) |
785 | return ret; | 787 | goto err_free_mem; |
786 | 788 | ||
787 | /* Set predefined value for BUCK1 register 4 */ | 789 | /* Set predefined value for BUCK1 register 4 */ |
788 | i = 0; | 790 | i = 0; |
@@ -794,7 +796,7 @@ static __devinit int max8998_pmic_probe(struct platform_device *pdev) | |||
794 | max8998->buck1_vol[3] = i; | 796 | max8998->buck1_vol[3] = i; |
795 | ret = max8998_write_reg(i2c, MAX8998_REG_BUCK1_VOLTAGE4, i); | 797 | ret = max8998_write_reg(i2c, MAX8998_REG_BUCK1_VOLTAGE4, i); |
796 | if (ret) | 798 | if (ret) |
797 | return ret; | 799 | goto err_free_mem; |
798 | 800 | ||
799 | } | 801 | } |
800 | 802 | ||
@@ -803,7 +805,8 @@ static __devinit int max8998_pmic_probe(struct platform_device *pdev) | |||
803 | if (!pdata->buck2_set3) { | 805 | if (!pdata->buck2_set3) { |
804 | printk(KERN_ERR "MAX8998 SET3 GPIO defined as 0 !\n"); | 806 | printk(KERN_ERR "MAX8998 SET3 GPIO defined as 0 !\n"); |
805 | WARN_ON(!pdata->buck2_set3); | 807 | WARN_ON(!pdata->buck2_set3); |
806 | return -EIO; | 808 | ret = -EIO; |
809 | goto err_free_mem; | ||
807 | } | 810 | } |
808 | gpio_request(pdata->buck2_set3, "MAX8998 BUCK2_SET3"); | 811 | gpio_request(pdata->buck2_set3, "MAX8998 BUCK2_SET3"); |
809 | gpio_direction_output(pdata->buck2_set3, | 812 | gpio_direction_output(pdata->buck2_set3, |
@@ -818,7 +821,7 @@ static __devinit int max8998_pmic_probe(struct platform_device *pdev) | |||
818 | max8998->buck2_vol[0] = i; | 821 | max8998->buck2_vol[0] = i; |
819 | ret = max8998_write_reg(i2c, MAX8998_REG_BUCK2_VOLTAGE1, i); | 822 | ret = max8998_write_reg(i2c, MAX8998_REG_BUCK2_VOLTAGE1, i); |
820 | if (ret) | 823 | if (ret) |
821 | return ret; | 824 | goto err_free_mem; |
822 | 825 | ||
823 | /* BUCK2 register 2 */ | 826 | /* BUCK2 register 2 */ |
824 | i = 0; | 827 | i = 0; |
@@ -830,7 +833,7 @@ static __devinit int max8998_pmic_probe(struct platform_device *pdev) | |||
830 | max8998->buck2_vol[1] = i; | 833 | max8998->buck2_vol[1] = i; |
831 | ret = max8998_write_reg(i2c, MAX8998_REG_BUCK2_VOLTAGE2, i); | 834 | ret = max8998_write_reg(i2c, MAX8998_REG_BUCK2_VOLTAGE2, i); |
832 | if (ret) | 835 | if (ret) |
833 | return ret; | 836 | goto err_free_mem; |
834 | } | 837 | } |
835 | 838 | ||
836 | for (i = 0; i < pdata->num_regulators; i++) { | 839 | for (i = 0; i < pdata->num_regulators; i++) { |
@@ -860,6 +863,7 @@ err: | |||
860 | if (rdev[i]) | 863 | if (rdev[i]) |
861 | regulator_unregister(rdev[i]); | 864 | regulator_unregister(rdev[i]); |
862 | 865 | ||
866 | err_free_mem: | ||
863 | kfree(max8998->rdev); | 867 | kfree(max8998->rdev); |
864 | kfree(max8998); | 868 | kfree(max8998); |
865 | 869 | ||
diff --git a/drivers/regulator/mc13892-regulator.c b/drivers/regulator/mc13892-regulator.c index 1b8f7398a4a8..3285d41842f2 100644 --- a/drivers/regulator/mc13892-regulator.c +++ b/drivers/regulator/mc13892-regulator.c | |||
@@ -431,7 +431,8 @@ static int mc13892_sw_regulator_set_voltage(struct regulator_dev *rdev, | |||
431 | int min_uV, int max_uV, unsigned *selector) | 431 | int min_uV, int max_uV, unsigned *selector) |
432 | { | 432 | { |
433 | struct mc13xxx_regulator_priv *priv = rdev_get_drvdata(rdev); | 433 | struct mc13xxx_regulator_priv *priv = rdev_get_drvdata(rdev); |
434 | int hi, value, val, mask, id = rdev_get_id(rdev); | 434 | int hi, value, mask, id = rdev_get_id(rdev); |
435 | u32 valread; | ||
435 | int ret; | 436 | int ret; |
436 | 437 | ||
437 | dev_dbg(rdev_get_dev(rdev), "%s id: %d min_uV: %d max_uV: %d\n", | 438 | dev_dbg(rdev_get_dev(rdev), "%s id: %d min_uV: %d max_uV: %d\n", |
@@ -447,15 +448,16 @@ static int mc13892_sw_regulator_set_voltage(struct regulator_dev *rdev, | |||
447 | 448 | ||
448 | mc13xxx_lock(priv->mc13xxx); | 449 | mc13xxx_lock(priv->mc13xxx); |
449 | ret = mc13xxx_reg_read(priv->mc13xxx, | 450 | ret = mc13xxx_reg_read(priv->mc13xxx, |
450 | mc13892_regulators[id].vsel_reg, &val); | 451 | mc13892_regulators[id].vsel_reg, &valread); |
451 | if (ret) | 452 | if (ret) |
452 | goto err; | 453 | goto err; |
453 | 454 | ||
454 | hi = val & MC13892_SWITCHERS0_SWxHI; | 455 | if (value > 1375000) |
455 | if (value > 1375) | ||
456 | hi = 1; | 456 | hi = 1; |
457 | if (value < 1100) | 457 | else if (value < 1100000) |
458 | hi = 0; | 458 | hi = 0; |
459 | else | ||
460 | hi = valread & MC13892_SWITCHERS0_SWxHI; | ||
459 | 461 | ||
460 | if (hi) { | 462 | if (hi) { |
461 | value = (value - 1100000) / 25000; | 463 | value = (value - 1100000) / 25000; |
@@ -464,8 +466,10 @@ static int mc13892_sw_regulator_set_voltage(struct regulator_dev *rdev, | |||
464 | value = (value - 600000) / 25000; | 466 | value = (value - 600000) / 25000; |
465 | 467 | ||
466 | mask = mc13892_regulators[id].vsel_mask | MC13892_SWITCHERS0_SWxHI; | 468 | mask = mc13892_regulators[id].vsel_mask | MC13892_SWITCHERS0_SWxHI; |
467 | ret = mc13xxx_reg_rmw(priv->mc13xxx, mc13892_regulators[id].vsel_reg, | 469 | valread = (valread & ~mask) | |
468 | mask, value << mc13892_regulators[id].vsel_shift); | 470 | (value << mc13892_regulators[id].vsel_shift); |
471 | ret = mc13xxx_reg_write(priv->mc13xxx, mc13892_regulators[id].vsel_reg, | ||
472 | valread); | ||
469 | err: | 473 | err: |
470 | mc13xxx_unlock(priv->mc13xxx); | 474 | mc13xxx_unlock(priv->mc13xxx); |
471 | 475 | ||
diff --git a/drivers/regulator/mc13xxx-regulator-core.c b/drivers/regulator/mc13xxx-regulator-core.c index 2bb5de1f2421..bc27ab136378 100644 --- a/drivers/regulator/mc13xxx-regulator-core.c +++ b/drivers/regulator/mc13xxx-regulator-core.c | |||
@@ -174,7 +174,7 @@ static int mc13xxx_regulator_get_voltage(struct regulator_dev *rdev) | |||
174 | 174 | ||
175 | dev_dbg(rdev_get_dev(rdev), "%s id: %d val: %d\n", __func__, id, val); | 175 | dev_dbg(rdev_get_dev(rdev), "%s id: %d val: %d\n", __func__, id, val); |
176 | 176 | ||
177 | BUG_ON(val > mc13xxx_regulators[id].desc.n_voltages); | 177 | BUG_ON(val >= mc13xxx_regulators[id].desc.n_voltages); |
178 | 178 | ||
179 | return mc13xxx_regulators[id].voltages[val]; | 179 | return mc13xxx_regulators[id].voltages[val]; |
180 | } | 180 | } |
diff --git a/drivers/regulator/tps6105x-regulator.c b/drivers/regulator/tps6105x-regulator.c index a4d7f4540c18..1011873896dc 100644 --- a/drivers/regulator/tps6105x-regulator.c +++ b/drivers/regulator/tps6105x-regulator.c | |||
@@ -158,6 +158,7 @@ static int __devinit tps6105x_regulator_probe(struct platform_device *pdev) | |||
158 | "failed to register regulator\n"); | 158 | "failed to register regulator\n"); |
159 | return ret; | 159 | return ret; |
160 | } | 160 | } |
161 | platform_set_drvdata(pdev, tps6105x); | ||
161 | 162 | ||
162 | return 0; | 163 | return 0; |
163 | } | 164 | } |
diff --git a/drivers/regulator/tps65023-regulator.c b/drivers/regulator/tps65023-regulator.c index 60a7ca5409e9..fbddc15e1811 100644 --- a/drivers/regulator/tps65023-regulator.c +++ b/drivers/regulator/tps65023-regulator.c | |||
@@ -466,7 +466,6 @@ static struct regulator_ops tps65023_ldo_ops = { | |||
466 | static int __devinit tps_65023_probe(struct i2c_client *client, | 466 | static int __devinit tps_65023_probe(struct i2c_client *client, |
467 | const struct i2c_device_id *id) | 467 | const struct i2c_device_id *id) |
468 | { | 468 | { |
469 | static int desc_id; | ||
470 | const struct tps_info *info = (void *)id->driver_data; | 469 | const struct tps_info *info = (void *)id->driver_data; |
471 | struct regulator_init_data *init_data; | 470 | struct regulator_init_data *init_data; |
472 | struct regulator_dev *rdev; | 471 | struct regulator_dev *rdev; |
@@ -499,7 +498,7 @@ static int __devinit tps_65023_probe(struct i2c_client *client, | |||
499 | tps->info[i] = info; | 498 | tps->info[i] = info; |
500 | 499 | ||
501 | tps->desc[i].name = info->name; | 500 | tps->desc[i].name = info->name; |
502 | tps->desc[i].id = desc_id++; | 501 | tps->desc[i].id = i; |
503 | tps->desc[i].n_voltages = num_voltages[i]; | 502 | tps->desc[i].n_voltages = num_voltages[i]; |
504 | tps->desc[i].ops = (i > TPS65023_DCDC_3 ? | 503 | tps->desc[i].ops = (i > TPS65023_DCDC_3 ? |
505 | &tps65023_ldo_ops : &tps65023_dcdc_ops); | 504 | &tps65023_ldo_ops : &tps65023_dcdc_ops); |
diff --git a/drivers/regulator/tps6507x-regulator.c b/drivers/regulator/tps6507x-regulator.c index 064755290599..bfffabc21eda 100644 --- a/drivers/regulator/tps6507x-regulator.c +++ b/drivers/regulator/tps6507x-regulator.c | |||
@@ -553,7 +553,6 @@ static __devinit | |||
553 | int tps6507x_pmic_probe(struct platform_device *pdev) | 553 | int tps6507x_pmic_probe(struct platform_device *pdev) |
554 | { | 554 | { |
555 | struct tps6507x_dev *tps6507x_dev = dev_get_drvdata(pdev->dev.parent); | 555 | struct tps6507x_dev *tps6507x_dev = dev_get_drvdata(pdev->dev.parent); |
556 | static int desc_id; | ||
557 | struct tps_info *info = &tps6507x_pmic_regs[0]; | 556 | struct tps_info *info = &tps6507x_pmic_regs[0]; |
558 | struct regulator_init_data *init_data; | 557 | struct regulator_init_data *init_data; |
559 | struct regulator_dev *rdev; | 558 | struct regulator_dev *rdev; |
@@ -598,7 +597,7 @@ int tps6507x_pmic_probe(struct platform_device *pdev) | |||
598 | } | 597 | } |
599 | 598 | ||
600 | tps->desc[i].name = info->name; | 599 | tps->desc[i].name = info->name; |
601 | tps->desc[i].id = desc_id++; | 600 | tps->desc[i].id = i; |
602 | tps->desc[i].n_voltages = num_voltages[i]; | 601 | tps->desc[i].n_voltages = num_voltages[i]; |
603 | tps->desc[i].ops = (i > TPS6507X_DCDC_3 ? | 602 | tps->desc[i].ops = (i > TPS6507X_DCDC_3 ? |
604 | &tps6507x_pmic_ldo_ops : &tps6507x_pmic_dcdc_ops); | 603 | &tps6507x_pmic_ldo_ops : &tps6507x_pmic_dcdc_ops); |
diff --git a/drivers/regulator/tps65910-regulator.c b/drivers/regulator/tps65910-regulator.c new file mode 100644 index 000000000000..55dd4e6650db --- /dev/null +++ b/drivers/regulator/tps65910-regulator.c | |||
@@ -0,0 +1,993 @@ | |||
1 | /* | ||
2 | * tps65910.c -- TI tps65910 | ||
3 | * | ||
4 | * Copyright 2010 Texas Instruments Inc. | ||
5 | * | ||
6 | * Author: Graeme Gregory <gg@slimlogic.co.uk> | ||
7 | * Author: Jorge Eduardo Candelaria <jedu@slimlogic.co.uk> | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify it | ||
10 | * under the terms of the GNU General Public License as published by the | ||
11 | * Free Software Foundation; either version 2 of the License, or (at your | ||
12 | * option) any later version. | ||
13 | * | ||
14 | */ | ||
15 | |||
16 | #include <linux/kernel.h> | ||
17 | #include <linux/module.h> | ||
18 | #include <linux/init.h> | ||
19 | #include <linux/err.h> | ||
20 | #include <linux/platform_device.h> | ||
21 | #include <linux/regulator/driver.h> | ||
22 | #include <linux/regulator/machine.h> | ||
23 | #include <linux/delay.h> | ||
24 | #include <linux/slab.h> | ||
25 | #include <linux/gpio.h> | ||
26 | #include <linux/mfd/tps65910.h> | ||
27 | |||
28 | #define TPS65910_REG_VRTC 0 | ||
29 | #define TPS65910_REG_VIO 1 | ||
30 | #define TPS65910_REG_VDD1 2 | ||
31 | #define TPS65910_REG_VDD2 3 | ||
32 | #define TPS65910_REG_VDD3 4 | ||
33 | #define TPS65910_REG_VDIG1 5 | ||
34 | #define TPS65910_REG_VDIG2 6 | ||
35 | #define TPS65910_REG_VPLL 7 | ||
36 | #define TPS65910_REG_VDAC 8 | ||
37 | #define TPS65910_REG_VAUX1 9 | ||
38 | #define TPS65910_REG_VAUX2 10 | ||
39 | #define TPS65910_REG_VAUX33 11 | ||
40 | #define TPS65910_REG_VMMC 12 | ||
41 | |||
42 | #define TPS65911_REG_VDDCTRL 4 | ||
43 | #define TPS65911_REG_LDO1 5 | ||
44 | #define TPS65911_REG_LDO2 6 | ||
45 | #define TPS65911_REG_LDO3 7 | ||
46 | #define TPS65911_REG_LDO4 8 | ||
47 | #define TPS65911_REG_LDO5 9 | ||
48 | #define TPS65911_REG_LDO6 10 | ||
49 | #define TPS65911_REG_LDO7 11 | ||
50 | #define TPS65911_REG_LDO8 12 | ||
51 | |||
52 | #define TPS65910_NUM_REGULATOR 13 | ||
53 | #define TPS65910_SUPPLY_STATE_ENABLED 0x1 | ||
54 | |||
55 | /* supported VIO voltages in milivolts */ | ||
56 | static const u16 VIO_VSEL_table[] = { | ||
57 | 1500, 1800, 2500, 3300, | ||
58 | }; | ||
59 | |||
60 | /* VSEL tables for TPS65910 specific LDOs and dcdc's */ | ||
61 | |||
62 | /* supported VDD3 voltages in milivolts */ | ||
63 | static const u16 VDD3_VSEL_table[] = { | ||
64 | 5000, | ||
65 | }; | ||
66 | |||
67 | /* supported VDIG1 voltages in milivolts */ | ||
68 | static const u16 VDIG1_VSEL_table[] = { | ||
69 | 1200, 1500, 1800, 2700, | ||
70 | }; | ||
71 | |||
72 | /* supported VDIG2 voltages in milivolts */ | ||
73 | static const u16 VDIG2_VSEL_table[] = { | ||
74 | 1000, 1100, 1200, 1800, | ||
75 | }; | ||
76 | |||
77 | /* supported VPLL voltages in milivolts */ | ||
78 | static const u16 VPLL_VSEL_table[] = { | ||
79 | 1000, 1100, 1800, 2500, | ||
80 | }; | ||
81 | |||
82 | /* supported VDAC voltages in milivolts */ | ||
83 | static const u16 VDAC_VSEL_table[] = { | ||
84 | 1800, 2600, 2800, 2850, | ||
85 | }; | ||
86 | |||
87 | /* supported VAUX1 voltages in milivolts */ | ||
88 | static const u16 VAUX1_VSEL_table[] = { | ||
89 | 1800, 2500, 2800, 2850, | ||
90 | }; | ||
91 | |||
92 | /* supported VAUX2 voltages in milivolts */ | ||
93 | static const u16 VAUX2_VSEL_table[] = { | ||
94 | 1800, 2800, 2900, 3300, | ||
95 | }; | ||
96 | |||
97 | /* supported VAUX33 voltages in milivolts */ | ||
98 | static const u16 VAUX33_VSEL_table[] = { | ||
99 | 1800, 2000, 2800, 3300, | ||
100 | }; | ||
101 | |||
102 | /* supported VMMC voltages in milivolts */ | ||
103 | static const u16 VMMC_VSEL_table[] = { | ||
104 | 1800, 2800, 3000, 3300, | ||
105 | }; | ||
106 | |||
107 | struct tps_info { | ||
108 | const char *name; | ||
109 | unsigned min_uV; | ||
110 | unsigned max_uV; | ||
111 | u8 table_len; | ||
112 | const u16 *table; | ||
113 | }; | ||
114 | |||
115 | static struct tps_info tps65910_regs[] = { | ||
116 | { | ||
117 | .name = "VRTC", | ||
118 | }, | ||
119 | { | ||
120 | .name = "VIO", | ||
121 | .min_uV = 1500000, | ||
122 | .max_uV = 3300000, | ||
123 | .table_len = ARRAY_SIZE(VIO_VSEL_table), | ||
124 | .table = VIO_VSEL_table, | ||
125 | }, | ||
126 | { | ||
127 | .name = "VDD1", | ||
128 | .min_uV = 600000, | ||
129 | .max_uV = 4500000, | ||
130 | }, | ||
131 | { | ||
132 | .name = "VDD2", | ||
133 | .min_uV = 600000, | ||
134 | .max_uV = 4500000, | ||
135 | }, | ||
136 | { | ||
137 | .name = "VDD3", | ||
138 | .min_uV = 5000000, | ||
139 | .max_uV = 5000000, | ||
140 | .table_len = ARRAY_SIZE(VDD3_VSEL_table), | ||
141 | .table = VDD3_VSEL_table, | ||
142 | }, | ||
143 | { | ||
144 | .name = "VDIG1", | ||
145 | .min_uV = 1200000, | ||
146 | .max_uV = 2700000, | ||
147 | .table_len = ARRAY_SIZE(VDIG1_VSEL_table), | ||
148 | .table = VDIG1_VSEL_table, | ||
149 | }, | ||
150 | { | ||
151 | .name = "VDIG2", | ||
152 | .min_uV = 1000000, | ||
153 | .max_uV = 1800000, | ||
154 | .table_len = ARRAY_SIZE(VDIG2_VSEL_table), | ||
155 | .table = VDIG2_VSEL_table, | ||
156 | }, | ||
157 | { | ||
158 | .name = "VPLL", | ||
159 | .min_uV = 1000000, | ||
160 | .max_uV = 2500000, | ||
161 | .table_len = ARRAY_SIZE(VPLL_VSEL_table), | ||
162 | .table = VPLL_VSEL_table, | ||
163 | }, | ||
164 | { | ||
165 | .name = "VDAC", | ||
166 | .min_uV = 1800000, | ||
167 | .max_uV = 2850000, | ||
168 | .table_len = ARRAY_SIZE(VDAC_VSEL_table), | ||
169 | .table = VDAC_VSEL_table, | ||
170 | }, | ||
171 | { | ||
172 | .name = "VAUX1", | ||
173 | .min_uV = 1800000, | ||
174 | .max_uV = 2850000, | ||
175 | .table_len = ARRAY_SIZE(VAUX1_VSEL_table), | ||
176 | .table = VAUX1_VSEL_table, | ||
177 | }, | ||
178 | { | ||
179 | .name = "VAUX2", | ||
180 | .min_uV = 1800000, | ||
181 | .max_uV = 3300000, | ||
182 | .table_len = ARRAY_SIZE(VAUX2_VSEL_table), | ||
183 | .table = VAUX2_VSEL_table, | ||
184 | }, | ||
185 | { | ||
186 | .name = "VAUX33", | ||
187 | .min_uV = 1800000, | ||
188 | .max_uV = 3300000, | ||
189 | .table_len = ARRAY_SIZE(VAUX33_VSEL_table), | ||
190 | .table = VAUX33_VSEL_table, | ||
191 | }, | ||
192 | { | ||
193 | .name = "VMMC", | ||
194 | .min_uV = 1800000, | ||
195 | .max_uV = 3300000, | ||
196 | .table_len = ARRAY_SIZE(VMMC_VSEL_table), | ||
197 | .table = VMMC_VSEL_table, | ||
198 | }, | ||
199 | }; | ||
200 | |||
201 | static struct tps_info tps65911_regs[] = { | ||
202 | { | ||
203 | .name = "VIO", | ||
204 | .min_uV = 1500000, | ||
205 | .max_uV = 3300000, | ||
206 | .table_len = ARRAY_SIZE(VIO_VSEL_table), | ||
207 | .table = VIO_VSEL_table, | ||
208 | }, | ||
209 | { | ||
210 | .name = "VDD1", | ||
211 | .min_uV = 600000, | ||
212 | .max_uV = 4500000, | ||
213 | }, | ||
214 | { | ||
215 | .name = "VDD2", | ||
216 | .min_uV = 600000, | ||
217 | .max_uV = 4500000, | ||
218 | }, | ||
219 | { | ||
220 | .name = "VDDCTRL", | ||
221 | .min_uV = 600000, | ||
222 | .max_uV = 1400000, | ||
223 | }, | ||
224 | { | ||
225 | .name = "LDO1", | ||
226 | .min_uV = 1000000, | ||
227 | .max_uV = 3300000, | ||
228 | }, | ||
229 | { | ||
230 | .name = "LDO2", | ||
231 | .min_uV = 1000000, | ||
232 | .max_uV = 3300000, | ||
233 | }, | ||
234 | { | ||
235 | .name = "LDO3", | ||
236 | .min_uV = 1000000, | ||
237 | .max_uV = 3300000, | ||
238 | }, | ||
239 | { | ||
240 | .name = "LDO4", | ||
241 | .min_uV = 1000000, | ||
242 | .max_uV = 3300000, | ||
243 | }, | ||
244 | { | ||
245 | .name = "LDO5", | ||
246 | .min_uV = 1000000, | ||
247 | .max_uV = 3300000, | ||
248 | }, | ||
249 | { | ||
250 | .name = "LDO6", | ||
251 | .min_uV = 1000000, | ||
252 | .max_uV = 3300000, | ||
253 | }, | ||
254 | { | ||
255 | .name = "LDO7", | ||
256 | .min_uV = 1000000, | ||
257 | .max_uV = 3300000, | ||
258 | }, | ||
259 | { | ||
260 | .name = "LDO8", | ||
261 | .min_uV = 1000000, | ||
262 | .max_uV = 3300000, | ||
263 | }, | ||
264 | }; | ||
265 | |||
266 | struct tps65910_reg { | ||
267 | struct regulator_desc desc[TPS65910_NUM_REGULATOR]; | ||
268 | struct tps65910 *mfd; | ||
269 | struct regulator_dev *rdev[TPS65910_NUM_REGULATOR]; | ||
270 | struct tps_info *info[TPS65910_NUM_REGULATOR]; | ||
271 | struct mutex mutex; | ||
272 | int mode; | ||
273 | int (*get_ctrl_reg)(int); | ||
274 | }; | ||
275 | |||
276 | static inline int tps65910_read(struct tps65910_reg *pmic, u8 reg) | ||
277 | { | ||
278 | u8 val; | ||
279 | int err; | ||
280 | |||
281 | err = pmic->mfd->read(pmic->mfd, reg, 1, &val); | ||
282 | if (err) | ||
283 | return err; | ||
284 | |||
285 | return val; | ||
286 | } | ||
287 | |||
288 | static inline int tps65910_write(struct tps65910_reg *pmic, u8 reg, u8 val) | ||
289 | { | ||
290 | return pmic->mfd->write(pmic->mfd, reg, 1, &val); | ||
291 | } | ||
292 | |||
293 | static int tps65910_modify_bits(struct tps65910_reg *pmic, u8 reg, | ||
294 | u8 set_mask, u8 clear_mask) | ||
295 | { | ||
296 | int err, data; | ||
297 | |||
298 | mutex_lock(&pmic->mutex); | ||
299 | |||
300 | data = tps65910_read(pmic, reg); | ||
301 | if (data < 0) { | ||
302 | dev_err(pmic->mfd->dev, "Read from reg 0x%x failed\n", reg); | ||
303 | err = data; | ||
304 | goto out; | ||
305 | } | ||
306 | |||
307 | data &= ~clear_mask; | ||
308 | data |= set_mask; | ||
309 | err = tps65910_write(pmic, reg, data); | ||
310 | if (err) | ||
311 | dev_err(pmic->mfd->dev, "Write for reg 0x%x failed\n", reg); | ||
312 | |||
313 | out: | ||
314 | mutex_unlock(&pmic->mutex); | ||
315 | return err; | ||
316 | } | ||
317 | |||
318 | static int tps65910_reg_read(struct tps65910_reg *pmic, u8 reg) | ||
319 | { | ||
320 | int data; | ||
321 | |||
322 | mutex_lock(&pmic->mutex); | ||
323 | |||
324 | data = tps65910_read(pmic, reg); | ||
325 | if (data < 0) | ||
326 | dev_err(pmic->mfd->dev, "Read from reg 0x%x failed\n", reg); | ||
327 | |||
328 | mutex_unlock(&pmic->mutex); | ||
329 | return data; | ||
330 | } | ||
331 | |||
332 | static int tps65910_reg_write(struct tps65910_reg *pmic, u8 reg, u8 val) | ||
333 | { | ||
334 | int err; | ||
335 | |||
336 | mutex_lock(&pmic->mutex); | ||
337 | |||
338 | err = tps65910_write(pmic, reg, val); | ||
339 | if (err < 0) | ||
340 | dev_err(pmic->mfd->dev, "Write for reg 0x%x failed\n", reg); | ||
341 | |||
342 | mutex_unlock(&pmic->mutex); | ||
343 | return err; | ||
344 | } | ||
345 | |||
346 | static int tps65910_get_ctrl_register(int id) | ||
347 | { | ||
348 | switch (id) { | ||
349 | case TPS65910_REG_VRTC: | ||
350 | return TPS65910_VRTC; | ||
351 | case TPS65910_REG_VIO: | ||
352 | return TPS65910_VIO; | ||
353 | case TPS65910_REG_VDD1: | ||
354 | return TPS65910_VDD1; | ||
355 | case TPS65910_REG_VDD2: | ||
356 | return TPS65910_VDD2; | ||
357 | case TPS65910_REG_VDD3: | ||
358 | return TPS65910_VDD3; | ||
359 | case TPS65910_REG_VDIG1: | ||
360 | return TPS65910_VDIG1; | ||
361 | case TPS65910_REG_VDIG2: | ||
362 | return TPS65910_VDIG2; | ||
363 | case TPS65910_REG_VPLL: | ||
364 | return TPS65910_VPLL; | ||
365 | case TPS65910_REG_VDAC: | ||
366 | return TPS65910_VDAC; | ||
367 | case TPS65910_REG_VAUX1: | ||
368 | return TPS65910_VAUX1; | ||
369 | case TPS65910_REG_VAUX2: | ||
370 | return TPS65910_VAUX2; | ||
371 | case TPS65910_REG_VAUX33: | ||
372 | return TPS65910_VAUX33; | ||
373 | case TPS65910_REG_VMMC: | ||
374 | return TPS65910_VMMC; | ||
375 | default: | ||
376 | return -EINVAL; | ||
377 | } | ||
378 | } | ||
379 | |||
380 | static int tps65911_get_ctrl_register(int id) | ||
381 | { | ||
382 | switch (id) { | ||
383 | case TPS65910_REG_VRTC: | ||
384 | return TPS65910_VRTC; | ||
385 | case TPS65910_REG_VIO: | ||
386 | return TPS65910_VIO; | ||
387 | case TPS65910_REG_VDD1: | ||
388 | return TPS65910_VDD1; | ||
389 | case TPS65910_REG_VDD2: | ||
390 | return TPS65910_VDD2; | ||
391 | case TPS65911_REG_VDDCTRL: | ||
392 | return TPS65911_VDDCTRL; | ||
393 | case TPS65911_REG_LDO1: | ||
394 | return TPS65911_LDO1; | ||
395 | case TPS65911_REG_LDO2: | ||
396 | return TPS65911_LDO2; | ||
397 | case TPS65911_REG_LDO3: | ||
398 | return TPS65911_LDO3; | ||
399 | case TPS65911_REG_LDO4: | ||
400 | return TPS65911_LDO4; | ||
401 | case TPS65911_REG_LDO5: | ||
402 | return TPS65911_LDO5; | ||
403 | case TPS65911_REG_LDO6: | ||
404 | return TPS65911_LDO6; | ||
405 | case TPS65911_REG_LDO7: | ||
406 | return TPS65911_LDO7; | ||
407 | case TPS65911_REG_LDO8: | ||
408 | return TPS65911_LDO8; | ||
409 | default: | ||
410 | return -EINVAL; | ||
411 | } | ||
412 | } | ||
413 | |||
414 | static int tps65910_is_enabled(struct regulator_dev *dev) | ||
415 | { | ||
416 | struct tps65910_reg *pmic = rdev_get_drvdata(dev); | ||
417 | int reg, value, id = rdev_get_id(dev); | ||
418 | |||
419 | reg = pmic->get_ctrl_reg(id); | ||
420 | if (reg < 0) | ||
421 | return reg; | ||
422 | |||
423 | value = tps65910_reg_read(pmic, reg); | ||
424 | if (value < 0) | ||
425 | return value; | ||
426 | |||
427 | return value & TPS65910_SUPPLY_STATE_ENABLED; | ||
428 | } | ||
429 | |||
430 | static int tps65910_enable(struct regulator_dev *dev) | ||
431 | { | ||
432 | struct tps65910_reg *pmic = rdev_get_drvdata(dev); | ||
433 | struct tps65910 *mfd = pmic->mfd; | ||
434 | int reg, id = rdev_get_id(dev); | ||
435 | |||
436 | reg = pmic->get_ctrl_reg(id); | ||
437 | if (reg < 0) | ||
438 | return reg; | ||
439 | |||
440 | return tps65910_set_bits(mfd, reg, TPS65910_SUPPLY_STATE_ENABLED); | ||
441 | } | ||
442 | |||
443 | static int tps65910_disable(struct regulator_dev *dev) | ||
444 | { | ||
445 | struct tps65910_reg *pmic = rdev_get_drvdata(dev); | ||
446 | struct tps65910 *mfd = pmic->mfd; | ||
447 | int reg, id = rdev_get_id(dev); | ||
448 | |||
449 | reg = pmic->get_ctrl_reg(id); | ||
450 | if (reg < 0) | ||
451 | return reg; | ||
452 | |||
453 | return tps65910_clear_bits(mfd, reg, TPS65910_SUPPLY_STATE_ENABLED); | ||
454 | } | ||
455 | |||
456 | |||
457 | static int tps65910_set_mode(struct regulator_dev *dev, unsigned int mode) | ||
458 | { | ||
459 | struct tps65910_reg *pmic = rdev_get_drvdata(dev); | ||
460 | struct tps65910 *mfd = pmic->mfd; | ||
461 | int reg, value, id = rdev_get_id(dev); | ||
462 | |||
463 | reg = pmic->get_ctrl_reg(id); | ||
464 | if (reg < 0) | ||
465 | return reg; | ||
466 | |||
467 | switch (mode) { | ||
468 | case REGULATOR_MODE_NORMAL: | ||
469 | return tps65910_modify_bits(pmic, reg, LDO_ST_ON_BIT, | ||
470 | LDO_ST_MODE_BIT); | ||
471 | case REGULATOR_MODE_IDLE: | ||
472 | value = LDO_ST_ON_BIT | LDO_ST_MODE_BIT; | ||
473 | return tps65910_set_bits(mfd, reg, value); | ||
474 | case REGULATOR_MODE_STANDBY: | ||
475 | return tps65910_clear_bits(mfd, reg, LDO_ST_ON_BIT); | ||
476 | } | ||
477 | |||
478 | return -EINVAL; | ||
479 | } | ||
480 | |||
481 | static unsigned int tps65910_get_mode(struct regulator_dev *dev) | ||
482 | { | ||
483 | struct tps65910_reg *pmic = rdev_get_drvdata(dev); | ||
484 | int reg, value, id = rdev_get_id(dev); | ||
485 | |||
486 | reg = pmic->get_ctrl_reg(id); | ||
487 | if (reg < 0) | ||
488 | return reg; | ||
489 | |||
490 | value = tps65910_reg_read(pmic, reg); | ||
491 | if (value < 0) | ||
492 | return value; | ||
493 | |||
494 | if (value & LDO_ST_ON_BIT) | ||
495 | return REGULATOR_MODE_STANDBY; | ||
496 | else if (value & LDO_ST_MODE_BIT) | ||
497 | return REGULATOR_MODE_IDLE; | ||
498 | else | ||
499 | return REGULATOR_MODE_NORMAL; | ||
500 | } | ||
501 | |||
502 | static int tps65910_get_voltage_dcdc(struct regulator_dev *dev) | ||
503 | { | ||
504 | struct tps65910_reg *pmic = rdev_get_drvdata(dev); | ||
505 | int id = rdev_get_id(dev), voltage = 0; | ||
506 | int opvsel = 0, srvsel = 0, vselmax = 0, mult = 0, sr = 0; | ||
507 | |||
508 | switch (id) { | ||
509 | case TPS65910_REG_VDD1: | ||
510 | opvsel = tps65910_reg_read(pmic, TPS65910_VDD1_OP); | ||
511 | mult = tps65910_reg_read(pmic, TPS65910_VDD1); | ||
512 | mult = (mult & VDD1_VGAIN_SEL_MASK) >> VDD1_VGAIN_SEL_SHIFT; | ||
513 | srvsel = tps65910_reg_read(pmic, TPS65910_VDD1_SR); | ||
514 | sr = opvsel & VDD1_OP_CMD_MASK; | ||
515 | opvsel &= VDD1_OP_SEL_MASK; | ||
516 | srvsel &= VDD1_SR_SEL_MASK; | ||
517 | vselmax = 75; | ||
518 | break; | ||
519 | case TPS65910_REG_VDD2: | ||
520 | opvsel = tps65910_reg_read(pmic, TPS65910_VDD2_OP); | ||
521 | mult = tps65910_reg_read(pmic, TPS65910_VDD2); | ||
522 | mult = (mult & VDD2_VGAIN_SEL_MASK) >> VDD2_VGAIN_SEL_SHIFT; | ||
523 | srvsel = tps65910_reg_read(pmic, TPS65910_VDD2_SR); | ||
524 | sr = opvsel & VDD2_OP_CMD_MASK; | ||
525 | opvsel &= VDD2_OP_SEL_MASK; | ||
526 | srvsel &= VDD2_SR_SEL_MASK; | ||
527 | vselmax = 75; | ||
528 | break; | ||
529 | case TPS65911_REG_VDDCTRL: | ||
530 | opvsel = tps65910_reg_read(pmic, TPS65911_VDDCTRL_OP); | ||
531 | srvsel = tps65910_reg_read(pmic, TPS65911_VDDCTRL_SR); | ||
532 | sr = opvsel & VDDCTRL_OP_CMD_MASK; | ||
533 | opvsel &= VDDCTRL_OP_SEL_MASK; | ||
534 | srvsel &= VDDCTRL_SR_SEL_MASK; | ||
535 | vselmax = 64; | ||
536 | break; | ||
537 | } | ||
538 | |||
539 | /* multiplier 0 == 1 but 2,3 normal */ | ||
540 | if (!mult) | ||
541 | mult=1; | ||
542 | |||
543 | if (sr) { | ||
544 | /* normalise to valid range */ | ||
545 | if (srvsel < 3) | ||
546 | srvsel = 3; | ||
547 | if (srvsel > vselmax) | ||
548 | srvsel = vselmax; | ||
549 | srvsel -= 3; | ||
550 | |||
551 | voltage = (srvsel * VDD1_2_OFFSET + VDD1_2_MIN_VOLT) * 100; | ||
552 | } else { | ||
553 | |||
554 | /* normalise to valid range*/ | ||
555 | if (opvsel < 3) | ||
556 | opvsel = 3; | ||
557 | if (opvsel > vselmax) | ||
558 | opvsel = vselmax; | ||
559 | opvsel -= 3; | ||
560 | |||
561 | voltage = (opvsel * VDD1_2_OFFSET + VDD1_2_MIN_VOLT) * 100; | ||
562 | } | ||
563 | |||
564 | voltage *= mult; | ||
565 | |||
566 | return voltage; | ||
567 | } | ||
568 | |||
569 | static int tps65910_get_voltage(struct regulator_dev *dev) | ||
570 | { | ||
571 | struct tps65910_reg *pmic = rdev_get_drvdata(dev); | ||
572 | int reg, value, id = rdev_get_id(dev), voltage = 0; | ||
573 | |||
574 | reg = pmic->get_ctrl_reg(id); | ||
575 | if (reg < 0) | ||
576 | return reg; | ||
577 | |||
578 | value = tps65910_reg_read(pmic, reg); | ||
579 | if (value < 0) | ||
580 | return value; | ||
581 | |||
582 | switch (id) { | ||
583 | case TPS65910_REG_VIO: | ||
584 | case TPS65910_REG_VDIG1: | ||
585 | case TPS65910_REG_VDIG2: | ||
586 | case TPS65910_REG_VPLL: | ||
587 | case TPS65910_REG_VDAC: | ||
588 | case TPS65910_REG_VAUX1: | ||
589 | case TPS65910_REG_VAUX2: | ||
590 | case TPS65910_REG_VAUX33: | ||
591 | case TPS65910_REG_VMMC: | ||
592 | value &= LDO_SEL_MASK; | ||
593 | value >>= LDO_SEL_SHIFT; | ||
594 | break; | ||
595 | default: | ||
596 | return -EINVAL; | ||
597 | } | ||
598 | |||
599 | voltage = pmic->info[id]->table[value] * 1000; | ||
600 | |||
601 | return voltage; | ||
602 | } | ||
603 | |||
604 | static int tps65910_get_voltage_vdd3(struct regulator_dev *dev) | ||
605 | { | ||
606 | return 5 * 1000 * 1000; | ||
607 | } | ||
608 | |||
609 | static int tps65911_get_voltage(struct regulator_dev *dev) | ||
610 | { | ||
611 | struct tps65910_reg *pmic = rdev_get_drvdata(dev); | ||
612 | int step_mv, id = rdev_get_id(dev); | ||
613 | u8 value, reg; | ||
614 | |||
615 | reg = pmic->get_ctrl_reg(id); | ||
616 | |||
617 | value = tps65910_reg_read(pmic, reg); | ||
618 | |||
619 | switch (id) { | ||
620 | case TPS65911_REG_LDO1: | ||
621 | case TPS65911_REG_LDO2: | ||
622 | case TPS65911_REG_LDO4: | ||
623 | value &= LDO1_SEL_MASK; | ||
624 | value >>= LDO_SEL_SHIFT; | ||
625 | /* The first 5 values of the selector correspond to 1V */ | ||
626 | if (value < 5) | ||
627 | value = 0; | ||
628 | else | ||
629 | value -= 4; | ||
630 | |||
631 | step_mv = 50; | ||
632 | break; | ||
633 | case TPS65911_REG_LDO3: | ||
634 | case TPS65911_REG_LDO5: | ||
635 | case TPS65911_REG_LDO6: | ||
636 | case TPS65911_REG_LDO7: | ||
637 | case TPS65911_REG_LDO8: | ||
638 | value &= LDO3_SEL_MASK; | ||
639 | value >>= LDO_SEL_SHIFT; | ||
640 | /* The first 3 values of the selector correspond to 1V */ | ||
641 | if (value < 3) | ||
642 | value = 0; | ||
643 | else | ||
644 | value -= 2; | ||
645 | |||
646 | step_mv = 100; | ||
647 | break; | ||
648 | case TPS65910_REG_VIO: | ||
649 | return pmic->info[id]->table[value] * 1000; | ||
650 | break; | ||
651 | default: | ||
652 | return -EINVAL; | ||
653 | } | ||
654 | |||
655 | return (LDO_MIN_VOLT + value * step_mv) * 1000; | ||
656 | } | ||
657 | |||
658 | static int tps65910_set_voltage_dcdc(struct regulator_dev *dev, | ||
659 | unsigned selector) | ||
660 | { | ||
661 | struct tps65910_reg *pmic = rdev_get_drvdata(dev); | ||
662 | int id = rdev_get_id(dev), vsel; | ||
663 | int dcdc_mult = 0; | ||
664 | |||
665 | switch (id) { | ||
666 | case TPS65910_REG_VDD1: | ||
667 | dcdc_mult = (selector / VDD1_2_NUM_VOLTS) + 1; | ||
668 | if (dcdc_mult == 1) | ||
669 | dcdc_mult--; | ||
670 | vsel = (selector % VDD1_2_NUM_VOLTS) + 3; | ||
671 | |||
672 | tps65910_modify_bits(pmic, TPS65910_VDD1, | ||
673 | (dcdc_mult << VDD1_VGAIN_SEL_SHIFT), | ||
674 | VDD1_VGAIN_SEL_MASK); | ||
675 | tps65910_reg_write(pmic, TPS65910_VDD1_OP, vsel); | ||
676 | break; | ||
677 | case TPS65910_REG_VDD2: | ||
678 | dcdc_mult = (selector / VDD1_2_NUM_VOLTS) + 1; | ||
679 | if (dcdc_mult == 1) | ||
680 | dcdc_mult--; | ||
681 | vsel = (selector % VDD1_2_NUM_VOLTS) + 3; | ||
682 | |||
683 | tps65910_modify_bits(pmic, TPS65910_VDD2, | ||
684 | (dcdc_mult << VDD2_VGAIN_SEL_SHIFT), | ||
685 | VDD1_VGAIN_SEL_MASK); | ||
686 | tps65910_reg_write(pmic, TPS65910_VDD2_OP, vsel); | ||
687 | break; | ||
688 | case TPS65911_REG_VDDCTRL: | ||
689 | vsel = selector; | ||
690 | tps65910_reg_write(pmic, TPS65911_VDDCTRL_OP, vsel); | ||
691 | } | ||
692 | |||
693 | return 0; | ||
694 | } | ||
695 | |||
696 | static int tps65910_set_voltage(struct regulator_dev *dev, unsigned selector) | ||
697 | { | ||
698 | struct tps65910_reg *pmic = rdev_get_drvdata(dev); | ||
699 | int reg, id = rdev_get_id(dev); | ||
700 | |||
701 | reg = pmic->get_ctrl_reg(id); | ||
702 | if (reg < 0) | ||
703 | return reg; | ||
704 | |||
705 | switch (id) { | ||
706 | case TPS65910_REG_VIO: | ||
707 | case TPS65910_REG_VDIG1: | ||
708 | case TPS65910_REG_VDIG2: | ||
709 | case TPS65910_REG_VPLL: | ||
710 | case TPS65910_REG_VDAC: | ||
711 | case TPS65910_REG_VAUX1: | ||
712 | case TPS65910_REG_VAUX2: | ||
713 | case TPS65910_REG_VAUX33: | ||
714 | case TPS65910_REG_VMMC: | ||
715 | return tps65910_modify_bits(pmic, reg, | ||
716 | (selector << LDO_SEL_SHIFT), LDO_SEL_MASK); | ||
717 | } | ||
718 | |||
719 | return -EINVAL; | ||
720 | } | ||
721 | |||
722 | static int tps65911_set_voltage(struct regulator_dev *dev, unsigned selector) | ||
723 | { | ||
724 | struct tps65910_reg *pmic = rdev_get_drvdata(dev); | ||
725 | int reg, id = rdev_get_id(dev); | ||
726 | |||
727 | reg = pmic->get_ctrl_reg(id); | ||
728 | if (reg < 0) | ||
729 | return reg; | ||
730 | |||
731 | switch (id) { | ||
732 | case TPS65911_REG_LDO1: | ||
733 | case TPS65911_REG_LDO2: | ||
734 | case TPS65911_REG_LDO4: | ||
735 | return tps65910_modify_bits(pmic, reg, | ||
736 | (selector << LDO_SEL_SHIFT), LDO1_SEL_MASK); | ||
737 | case TPS65911_REG_LDO3: | ||
738 | case TPS65911_REG_LDO5: | ||
739 | case TPS65911_REG_LDO6: | ||
740 | case TPS65911_REG_LDO7: | ||
741 | case TPS65911_REG_LDO8: | ||
742 | case TPS65910_REG_VIO: | ||
743 | return tps65910_modify_bits(pmic, reg, | ||
744 | (selector << LDO_SEL_SHIFT), LDO3_SEL_MASK); | ||
745 | } | ||
746 | |||
747 | return -EINVAL; | ||
748 | } | ||
749 | |||
750 | |||
751 | static int tps65910_list_voltage_dcdc(struct regulator_dev *dev, | ||
752 | unsigned selector) | ||
753 | { | ||
754 | int volt, mult = 1, id = rdev_get_id(dev); | ||
755 | |||
756 | switch (id) { | ||
757 | case TPS65910_REG_VDD1: | ||
758 | case TPS65910_REG_VDD2: | ||
759 | mult = (selector / VDD1_2_NUM_VOLTS) + 1; | ||
760 | volt = VDD1_2_MIN_VOLT + | ||
761 | (selector % VDD1_2_NUM_VOLTS) * VDD1_2_OFFSET; | ||
762 | case TPS65911_REG_VDDCTRL: | ||
763 | volt = VDDCTRL_MIN_VOLT + (selector * VDDCTRL_OFFSET); | ||
764 | } | ||
765 | |||
766 | return volt * 100 * mult; | ||
767 | } | ||
768 | |||
769 | static int tps65910_list_voltage(struct regulator_dev *dev, | ||
770 | unsigned selector) | ||
771 | { | ||
772 | struct tps65910_reg *pmic = rdev_get_drvdata(dev); | ||
773 | int id = rdev_get_id(dev), voltage; | ||
774 | |||
775 | if (id < TPS65910_REG_VIO || id > TPS65910_REG_VMMC) | ||
776 | return -EINVAL; | ||
777 | |||
778 | if (selector >= pmic->info[id]->table_len) | ||
779 | return -EINVAL; | ||
780 | else | ||
781 | voltage = pmic->info[id]->table[selector] * 1000; | ||
782 | |||
783 | return voltage; | ||
784 | } | ||
785 | |||
786 | static int tps65911_list_voltage(struct regulator_dev *dev, unsigned selector) | ||
787 | { | ||
788 | struct tps65910_reg *pmic = rdev_get_drvdata(dev); | ||
789 | int step_mv = 0, id = rdev_get_id(dev); | ||
790 | |||
791 | switch(id) { | ||
792 | case TPS65911_REG_LDO1: | ||
793 | case TPS65911_REG_LDO2: | ||
794 | case TPS65911_REG_LDO4: | ||
795 | /* The first 5 values of the selector correspond to 1V */ | ||
796 | if (selector < 5) | ||
797 | selector = 0; | ||
798 | else | ||
799 | selector -= 4; | ||
800 | |||
801 | step_mv = 50; | ||
802 | break; | ||
803 | case TPS65911_REG_LDO3: | ||
804 | case TPS65911_REG_LDO5: | ||
805 | case TPS65911_REG_LDO6: | ||
806 | case TPS65911_REG_LDO7: | ||
807 | case TPS65911_REG_LDO8: | ||
808 | /* The first 3 values of the selector correspond to 1V */ | ||
809 | if (selector < 3) | ||
810 | selector = 0; | ||
811 | else | ||
812 | selector -= 2; | ||
813 | |||
814 | step_mv = 100; | ||
815 | break; | ||
816 | case TPS65910_REG_VIO: | ||
817 | return pmic->info[id]->table[selector] * 1000; | ||
818 | default: | ||
819 | return -EINVAL; | ||
820 | } | ||
821 | |||
822 | return (LDO_MIN_VOLT + selector * step_mv) * 1000; | ||
823 | } | ||
824 | |||
825 | /* Regulator ops (except VRTC) */ | ||
826 | static struct regulator_ops tps65910_ops_dcdc = { | ||
827 | .is_enabled = tps65910_is_enabled, | ||
828 | .enable = tps65910_enable, | ||
829 | .disable = tps65910_disable, | ||
830 | .set_mode = tps65910_set_mode, | ||
831 | .get_mode = tps65910_get_mode, | ||
832 | .get_voltage = tps65910_get_voltage_dcdc, | ||
833 | .set_voltage_sel = tps65910_set_voltage_dcdc, | ||
834 | .list_voltage = tps65910_list_voltage_dcdc, | ||
835 | }; | ||
836 | |||
837 | static struct regulator_ops tps65910_ops_vdd3 = { | ||
838 | .is_enabled = tps65910_is_enabled, | ||
839 | .enable = tps65910_enable, | ||
840 | .disable = tps65910_disable, | ||
841 | .set_mode = tps65910_set_mode, | ||
842 | .get_mode = tps65910_get_mode, | ||
843 | .get_voltage = tps65910_get_voltage_vdd3, | ||
844 | .list_voltage = tps65910_list_voltage, | ||
845 | }; | ||
846 | |||
847 | static struct regulator_ops tps65910_ops = { | ||
848 | .is_enabled = tps65910_is_enabled, | ||
849 | .enable = tps65910_enable, | ||
850 | .disable = tps65910_disable, | ||
851 | .set_mode = tps65910_set_mode, | ||
852 | .get_mode = tps65910_get_mode, | ||
853 | .get_voltage = tps65910_get_voltage, | ||
854 | .set_voltage_sel = tps65910_set_voltage, | ||
855 | .list_voltage = tps65910_list_voltage, | ||
856 | }; | ||
857 | |||
858 | static struct regulator_ops tps65911_ops = { | ||
859 | .is_enabled = tps65910_is_enabled, | ||
860 | .enable = tps65910_enable, | ||
861 | .disable = tps65910_disable, | ||
862 | .set_mode = tps65910_set_mode, | ||
863 | .get_mode = tps65910_get_mode, | ||
864 | .get_voltage = tps65911_get_voltage, | ||
865 | .set_voltage_sel = tps65911_set_voltage, | ||
866 | .list_voltage = tps65911_list_voltage, | ||
867 | }; | ||
868 | |||
869 | static __devinit int tps65910_probe(struct platform_device *pdev) | ||
870 | { | ||
871 | struct tps65910 *tps65910 = dev_get_drvdata(pdev->dev.parent); | ||
872 | struct tps_info *info; | ||
873 | struct regulator_init_data *reg_data; | ||
874 | struct regulator_dev *rdev; | ||
875 | struct tps65910_reg *pmic; | ||
876 | struct tps65910_board *pmic_plat_data; | ||
877 | int i, err; | ||
878 | |||
879 | pmic_plat_data = dev_get_platdata(tps65910->dev); | ||
880 | if (!pmic_plat_data) | ||
881 | return -EINVAL; | ||
882 | |||
883 | reg_data = pmic_plat_data->tps65910_pmic_init_data; | ||
884 | |||
885 | pmic = kzalloc(sizeof(*pmic), GFP_KERNEL); | ||
886 | if (!pmic) | ||
887 | return -ENOMEM; | ||
888 | |||
889 | mutex_init(&pmic->mutex); | ||
890 | pmic->mfd = tps65910; | ||
891 | platform_set_drvdata(pdev, pmic); | ||
892 | |||
893 | /* Give control of all register to control port */ | ||
894 | tps65910_set_bits(pmic->mfd, TPS65910_DEVCTRL, | ||
895 | DEVCTRL_SR_CTL_I2C_SEL_MASK); | ||
896 | |||
897 | switch(tps65910_chip_id(tps65910)) { | ||
898 | case TPS65910: | ||
899 | pmic->get_ctrl_reg = &tps65910_get_ctrl_register; | ||
900 | info = tps65910_regs; | ||
901 | case TPS65911: | ||
902 | pmic->get_ctrl_reg = &tps65911_get_ctrl_register; | ||
903 | info = tps65911_regs; | ||
904 | default: | ||
905 | pr_err("Invalid tps chip version\n"); | ||
906 | return -ENODEV; | ||
907 | } | ||
908 | |||
909 | for (i = 0; i < TPS65910_NUM_REGULATOR; i++, info++, reg_data++) { | ||
910 | /* Register the regulators */ | ||
911 | pmic->info[i] = info; | ||
912 | |||
913 | pmic->desc[i].name = info->name; | ||
914 | pmic->desc[i].id = i; | ||
915 | pmic->desc[i].n_voltages = info->table_len; | ||
916 | |||
917 | if (i == TPS65910_REG_VDD1 || i == TPS65910_REG_VDD2) { | ||
918 | pmic->desc[i].ops = &tps65910_ops_dcdc; | ||
919 | } else if (i == TPS65910_REG_VDD3) { | ||
920 | if (tps65910_chip_id(tps65910) == TPS65910) | ||
921 | pmic->desc[i].ops = &tps65910_ops_vdd3; | ||
922 | else | ||
923 | pmic->desc[i].ops = &tps65910_ops_dcdc; | ||
924 | } else { | ||
925 | if (tps65910_chip_id(tps65910) == TPS65910) | ||
926 | pmic->desc[i].ops = &tps65910_ops; | ||
927 | else | ||
928 | pmic->desc[i].ops = &tps65911_ops; | ||
929 | } | ||
930 | |||
931 | pmic->desc[i].type = REGULATOR_VOLTAGE; | ||
932 | pmic->desc[i].owner = THIS_MODULE; | ||
933 | |||
934 | rdev = regulator_register(&pmic->desc[i], | ||
935 | tps65910->dev, reg_data, pmic); | ||
936 | if (IS_ERR(rdev)) { | ||
937 | dev_err(tps65910->dev, | ||
938 | "failed to register %s regulator\n", | ||
939 | pdev->name); | ||
940 | err = PTR_ERR(rdev); | ||
941 | goto err; | ||
942 | } | ||
943 | |||
944 | /* Save regulator for cleanup */ | ||
945 | pmic->rdev[i] = rdev; | ||
946 | } | ||
947 | return 0; | ||
948 | |||
949 | err: | ||
950 | while (--i >= 0) | ||
951 | regulator_unregister(pmic->rdev[i]); | ||
952 | |||
953 | kfree(pmic); | ||
954 | return err; | ||
955 | } | ||
956 | |||
957 | static int __devexit tps65910_remove(struct platform_device *pdev) | ||
958 | { | ||
959 | struct tps65910_reg *tps65910_reg = platform_get_drvdata(pdev); | ||
960 | int i; | ||
961 | |||
962 | for (i = 0; i < TPS65910_NUM_REGULATOR; i++) | ||
963 | regulator_unregister(tps65910_reg->rdev[i]); | ||
964 | |||
965 | kfree(tps65910_reg); | ||
966 | return 0; | ||
967 | } | ||
968 | |||
969 | static struct platform_driver tps65910_driver = { | ||
970 | .driver = { | ||
971 | .name = "tps65910-pmic", | ||
972 | .owner = THIS_MODULE, | ||
973 | }, | ||
974 | .probe = tps65910_probe, | ||
975 | .remove = __devexit_p(tps65910_remove), | ||
976 | }; | ||
977 | |||
978 | static int __init tps65910_init(void) | ||
979 | { | ||
980 | return platform_driver_register(&tps65910_driver); | ||
981 | } | ||
982 | subsys_initcall(tps65910_init); | ||
983 | |||
984 | static void __exit tps65910_cleanup(void) | ||
985 | { | ||
986 | platform_driver_unregister(&tps65910_driver); | ||
987 | } | ||
988 | module_exit(tps65910_cleanup); | ||
989 | |||
990 | MODULE_AUTHOR("Graeme Gregory <gg@slimlogic.co.uk>"); | ||
991 | MODULE_DESCRIPTION("TPS6507x voltage regulator driver"); | ||
992 | MODULE_LICENSE("GPL v2"); | ||
993 | MODULE_ALIAS("platform:tps65910-pmic"); | ||
diff --git a/drivers/regulator/twl-regulator.c b/drivers/regulator/twl-regulator.c index 6a292852a358..87fe0f75a56e 100644 --- a/drivers/regulator/twl-regulator.c +++ b/drivers/regulator/twl-regulator.c | |||
@@ -51,8 +51,13 @@ struct twlreg_info { | |||
51 | u16 min_mV; | 51 | u16 min_mV; |
52 | u16 max_mV; | 52 | u16 max_mV; |
53 | 53 | ||
54 | u8 flags; | ||
55 | |||
54 | /* used by regulator core */ | 56 | /* used by regulator core */ |
55 | struct regulator_desc desc; | 57 | struct regulator_desc desc; |
58 | |||
59 | /* chip specific features */ | ||
60 | unsigned long features; | ||
56 | }; | 61 | }; |
57 | 62 | ||
58 | 63 | ||
@@ -70,12 +75,35 @@ struct twlreg_info { | |||
70 | #define VREG_TRANS 1 | 75 | #define VREG_TRANS 1 |
71 | #define VREG_STATE 2 | 76 | #define VREG_STATE 2 |
72 | #define VREG_VOLTAGE 3 | 77 | #define VREG_VOLTAGE 3 |
78 | #define VREG_VOLTAGE_SMPS 4 | ||
73 | /* TWL6030 Misc register offsets */ | 79 | /* TWL6030 Misc register offsets */ |
74 | #define VREG_BC_ALL 1 | 80 | #define VREG_BC_ALL 1 |
75 | #define VREG_BC_REF 2 | 81 | #define VREG_BC_REF 2 |
76 | #define VREG_BC_PROC 3 | 82 | #define VREG_BC_PROC 3 |
77 | #define VREG_BC_CLK_RST 4 | 83 | #define VREG_BC_CLK_RST 4 |
78 | 84 | ||
85 | /* TWL6030 LDO register values for CFG_STATE */ | ||
86 | #define TWL6030_CFG_STATE_OFF 0x00 | ||
87 | #define TWL6030_CFG_STATE_ON 0x01 | ||
88 | #define TWL6030_CFG_STATE_OFF2 0x02 | ||
89 | #define TWL6030_CFG_STATE_SLEEP 0x03 | ||
90 | #define TWL6030_CFG_STATE_GRP_SHIFT 5 | ||
91 | #define TWL6030_CFG_STATE_APP_SHIFT 2 | ||
92 | #define TWL6030_CFG_STATE_APP_MASK (0x03 << TWL6030_CFG_STATE_APP_SHIFT) | ||
93 | #define TWL6030_CFG_STATE_APP(v) (((v) & TWL6030_CFG_STATE_APP_MASK) >>\ | ||
94 | TWL6030_CFG_STATE_APP_SHIFT) | ||
95 | |||
96 | /* Flags for SMPS Voltage reading */ | ||
97 | #define SMPS_OFFSET_EN BIT(0) | ||
98 | #define SMPS_EXTENDED_EN BIT(1) | ||
99 | |||
100 | /* twl6025 SMPS EPROM values */ | ||
101 | #define TWL6030_SMPS_OFFSET 0xB0 | ||
102 | #define TWL6030_SMPS_MULT 0xB3 | ||
103 | #define SMPS_MULTOFFSET_SMPS4 BIT(0) | ||
104 | #define SMPS_MULTOFFSET_VIO BIT(1) | ||
105 | #define SMPS_MULTOFFSET_SMPS3 BIT(6) | ||
106 | |||
79 | static inline int | 107 | static inline int |
80 | twlreg_read(struct twlreg_info *info, unsigned slave_subgp, unsigned offset) | 108 | twlreg_read(struct twlreg_info *info, unsigned slave_subgp, unsigned offset) |
81 | { | 109 | { |
@@ -118,21 +146,38 @@ static int twlreg_grp(struct regulator_dev *rdev) | |||
118 | #define P2_GRP_6030 BIT(1) /* "peripherals" */ | 146 | #define P2_GRP_6030 BIT(1) /* "peripherals" */ |
119 | #define P1_GRP_6030 BIT(0) /* CPU/Linux */ | 147 | #define P1_GRP_6030 BIT(0) /* CPU/Linux */ |
120 | 148 | ||
121 | static int twlreg_is_enabled(struct regulator_dev *rdev) | 149 | static int twl4030reg_is_enabled(struct regulator_dev *rdev) |
122 | { | 150 | { |
123 | int state = twlreg_grp(rdev); | 151 | int state = twlreg_grp(rdev); |
124 | 152 | ||
125 | if (state < 0) | 153 | if (state < 0) |
126 | return state; | 154 | return state; |
127 | 155 | ||
128 | if (twl_class_is_4030()) | 156 | return state & P1_GRP_4030; |
129 | state &= P1_GRP_4030; | 157 | } |
158 | |||
159 | static int twl6030reg_is_enabled(struct regulator_dev *rdev) | ||
160 | { | ||
161 | struct twlreg_info *info = rdev_get_drvdata(rdev); | ||
162 | int grp = 0, val; | ||
163 | |||
164 | if (!(twl_class_is_6030() && (info->features & TWL6025_SUBCLASS))) | ||
165 | grp = twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_GRP); | ||
166 | if (grp < 0) | ||
167 | return grp; | ||
168 | |||
169 | if (!(twl_class_is_6030() && (info->features & TWL6025_SUBCLASS))) | ||
170 | grp &= P1_GRP_6030; | ||
130 | else | 171 | else |
131 | state &= P1_GRP_6030; | 172 | grp = 1; |
132 | return state; | 173 | |
174 | val = twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_STATE); | ||
175 | val = TWL6030_CFG_STATE_APP(val); | ||
176 | |||
177 | return grp && (val == TWL6030_CFG_STATE_ON); | ||
133 | } | 178 | } |
134 | 179 | ||
135 | static int twlreg_enable(struct regulator_dev *rdev) | 180 | static int twl4030reg_enable(struct regulator_dev *rdev) |
136 | { | 181 | { |
137 | struct twlreg_info *info = rdev_get_drvdata(rdev); | 182 | struct twlreg_info *info = rdev_get_drvdata(rdev); |
138 | int grp; | 183 | int grp; |
@@ -142,10 +187,7 @@ static int twlreg_enable(struct regulator_dev *rdev) | |||
142 | if (grp < 0) | 187 | if (grp < 0) |
143 | return grp; | 188 | return grp; |
144 | 189 | ||
145 | if (twl_class_is_4030()) | 190 | grp |= P1_GRP_4030; |
146 | grp |= P1_GRP_4030; | ||
147 | else | ||
148 | grp |= P1_GRP_6030; | ||
149 | 191 | ||
150 | ret = twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_GRP, grp); | 192 | ret = twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_GRP, grp); |
151 | 193 | ||
@@ -154,29 +196,63 @@ static int twlreg_enable(struct regulator_dev *rdev) | |||
154 | return ret; | 196 | return ret; |
155 | } | 197 | } |
156 | 198 | ||
157 | static int twlreg_disable(struct regulator_dev *rdev) | 199 | static int twl6030reg_enable(struct regulator_dev *rdev) |
200 | { | ||
201 | struct twlreg_info *info = rdev_get_drvdata(rdev); | ||
202 | int grp = 0; | ||
203 | int ret; | ||
204 | |||
205 | if (!(twl_class_is_6030() && (info->features & TWL6025_SUBCLASS))) | ||
206 | grp = twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_GRP); | ||
207 | if (grp < 0) | ||
208 | return grp; | ||
209 | |||
210 | ret = twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_STATE, | ||
211 | grp << TWL6030_CFG_STATE_GRP_SHIFT | | ||
212 | TWL6030_CFG_STATE_ON); | ||
213 | |||
214 | udelay(info->delay); | ||
215 | |||
216 | return ret; | ||
217 | } | ||
218 | |||
219 | static int twl4030reg_disable(struct regulator_dev *rdev) | ||
158 | { | 220 | { |
159 | struct twlreg_info *info = rdev_get_drvdata(rdev); | 221 | struct twlreg_info *info = rdev_get_drvdata(rdev); |
160 | int grp; | 222 | int grp; |
223 | int ret; | ||
161 | 224 | ||
162 | grp = twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_GRP); | 225 | grp = twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_GRP); |
163 | if (grp < 0) | 226 | if (grp < 0) |
164 | return grp; | 227 | return grp; |
165 | 228 | ||
166 | if (twl_class_is_4030()) | 229 | grp &= ~(P1_GRP_4030 | P2_GRP_4030 | P3_GRP_4030); |
167 | grp &= ~(P1_GRP_4030 | P2_GRP_4030 | P3_GRP_4030); | ||
168 | else | ||
169 | grp &= ~(P1_GRP_6030 | P2_GRP_6030 | P3_GRP_6030); | ||
170 | 230 | ||
171 | return twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_GRP, grp); | 231 | ret = twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_GRP, grp); |
232 | |||
233 | return ret; | ||
172 | } | 234 | } |
173 | 235 | ||
174 | static int twlreg_get_status(struct regulator_dev *rdev) | 236 | static int twl6030reg_disable(struct regulator_dev *rdev) |
175 | { | 237 | { |
176 | int state = twlreg_grp(rdev); | 238 | struct twlreg_info *info = rdev_get_drvdata(rdev); |
239 | int grp = 0; | ||
240 | int ret; | ||
241 | |||
242 | if (!(twl_class_is_6030() && (info->features & TWL6025_SUBCLASS))) | ||
243 | grp = P1_GRP_6030 | P2_GRP_6030 | P3_GRP_6030; | ||
244 | |||
245 | /* For 6030, set the off state for all grps enabled */ | ||
246 | ret = twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_STATE, | ||
247 | (grp) << TWL6030_CFG_STATE_GRP_SHIFT | | ||
248 | TWL6030_CFG_STATE_OFF); | ||
249 | |||
250 | return ret; | ||
251 | } | ||
177 | 252 | ||
178 | if (twl_class_is_6030()) | 253 | static int twl4030reg_get_status(struct regulator_dev *rdev) |
179 | return 0; /* FIXME return for 6030 regulator */ | 254 | { |
255 | int state = twlreg_grp(rdev); | ||
180 | 256 | ||
181 | if (state < 0) | 257 | if (state < 0) |
182 | return state; | 258 | return state; |
@@ -190,15 +266,39 @@ static int twlreg_get_status(struct regulator_dev *rdev) | |||
190 | : REGULATOR_STATUS_STANDBY; | 266 | : REGULATOR_STATUS_STANDBY; |
191 | } | 267 | } |
192 | 268 | ||
193 | static int twlreg_set_mode(struct regulator_dev *rdev, unsigned mode) | 269 | static int twl6030reg_get_status(struct regulator_dev *rdev) |
270 | { | ||
271 | struct twlreg_info *info = rdev_get_drvdata(rdev); | ||
272 | int val; | ||
273 | |||
274 | val = twlreg_grp(rdev); | ||
275 | if (val < 0) | ||
276 | return val; | ||
277 | |||
278 | val = twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_STATE); | ||
279 | |||
280 | switch (TWL6030_CFG_STATE_APP(val)) { | ||
281 | case TWL6030_CFG_STATE_ON: | ||
282 | return REGULATOR_STATUS_NORMAL; | ||
283 | |||
284 | case TWL6030_CFG_STATE_SLEEP: | ||
285 | return REGULATOR_STATUS_STANDBY; | ||
286 | |||
287 | case TWL6030_CFG_STATE_OFF: | ||
288 | case TWL6030_CFG_STATE_OFF2: | ||
289 | default: | ||
290 | break; | ||
291 | } | ||
292 | |||
293 | return REGULATOR_STATUS_OFF; | ||
294 | } | ||
295 | |||
296 | static int twl4030reg_set_mode(struct regulator_dev *rdev, unsigned mode) | ||
194 | { | 297 | { |
195 | struct twlreg_info *info = rdev_get_drvdata(rdev); | 298 | struct twlreg_info *info = rdev_get_drvdata(rdev); |
196 | unsigned message; | 299 | unsigned message; |
197 | int status; | 300 | int status; |
198 | 301 | ||
199 | if (twl_class_is_6030()) | ||
200 | return 0; /* FIXME return for 6030 regulator */ | ||
201 | |||
202 | /* We can only set the mode through state machine commands... */ | 302 | /* We can only set the mode through state machine commands... */ |
203 | switch (mode) { | 303 | switch (mode) { |
204 | case REGULATOR_MODE_NORMAL: | 304 | case REGULATOR_MODE_NORMAL: |
@@ -227,6 +327,36 @@ static int twlreg_set_mode(struct regulator_dev *rdev, unsigned mode) | |||
227 | message & 0xff, TWL4030_PM_MASTER_PB_WORD_LSB); | 327 | message & 0xff, TWL4030_PM_MASTER_PB_WORD_LSB); |
228 | } | 328 | } |
229 | 329 | ||
330 | static int twl6030reg_set_mode(struct regulator_dev *rdev, unsigned mode) | ||
331 | { | ||
332 | struct twlreg_info *info = rdev_get_drvdata(rdev); | ||
333 | int grp = 0; | ||
334 | int val; | ||
335 | |||
336 | if (!(twl_class_is_6030() && (info->features & TWL6025_SUBCLASS))) | ||
337 | grp = twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_GRP); | ||
338 | |||
339 | if (grp < 0) | ||
340 | return grp; | ||
341 | |||
342 | /* Compose the state register settings */ | ||
343 | val = grp << TWL6030_CFG_STATE_GRP_SHIFT; | ||
344 | /* We can only set the mode through state machine commands... */ | ||
345 | switch (mode) { | ||
346 | case REGULATOR_MODE_NORMAL: | ||
347 | val |= TWL6030_CFG_STATE_ON; | ||
348 | break; | ||
349 | case REGULATOR_MODE_STANDBY: | ||
350 | val |= TWL6030_CFG_STATE_SLEEP; | ||
351 | break; | ||
352 | |||
353 | default: | ||
354 | return -EINVAL; | ||
355 | } | ||
356 | |||
357 | return twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_STATE, val); | ||
358 | } | ||
359 | |||
230 | /*----------------------------------------------------------------------*/ | 360 | /*----------------------------------------------------------------------*/ |
231 | 361 | ||
232 | /* | 362 | /* |
@@ -375,13 +505,13 @@ static struct regulator_ops twl4030ldo_ops = { | |||
375 | .set_voltage = twl4030ldo_set_voltage, | 505 | .set_voltage = twl4030ldo_set_voltage, |
376 | .get_voltage = twl4030ldo_get_voltage, | 506 | .get_voltage = twl4030ldo_get_voltage, |
377 | 507 | ||
378 | .enable = twlreg_enable, | 508 | .enable = twl4030reg_enable, |
379 | .disable = twlreg_disable, | 509 | .disable = twl4030reg_disable, |
380 | .is_enabled = twlreg_is_enabled, | 510 | .is_enabled = twl4030reg_is_enabled, |
381 | 511 | ||
382 | .set_mode = twlreg_set_mode, | 512 | .set_mode = twl4030reg_set_mode, |
383 | 513 | ||
384 | .get_status = twlreg_get_status, | 514 | .get_status = twl4030reg_get_status, |
385 | }; | 515 | }; |
386 | 516 | ||
387 | static int twl6030ldo_list_voltage(struct regulator_dev *rdev, unsigned index) | 517 | static int twl6030ldo_list_voltage(struct regulator_dev *rdev, unsigned index) |
@@ -433,13 +563,13 @@ static struct regulator_ops twl6030ldo_ops = { | |||
433 | .set_voltage = twl6030ldo_set_voltage, | 563 | .set_voltage = twl6030ldo_set_voltage, |
434 | .get_voltage = twl6030ldo_get_voltage, | 564 | .get_voltage = twl6030ldo_get_voltage, |
435 | 565 | ||
436 | .enable = twlreg_enable, | 566 | .enable = twl6030reg_enable, |
437 | .disable = twlreg_disable, | 567 | .disable = twl6030reg_disable, |
438 | .is_enabled = twlreg_is_enabled, | 568 | .is_enabled = twl6030reg_is_enabled, |
439 | 569 | ||
440 | .set_mode = twlreg_set_mode, | 570 | .set_mode = twl6030reg_set_mode, |
441 | 571 | ||
442 | .get_status = twlreg_get_status, | 572 | .get_status = twl6030reg_get_status, |
443 | }; | 573 | }; |
444 | 574 | ||
445 | /*----------------------------------------------------------------------*/ | 575 | /*----------------------------------------------------------------------*/ |
@@ -461,25 +591,242 @@ static int twlfixed_get_voltage(struct regulator_dev *rdev) | |||
461 | return info->min_mV * 1000; | 591 | return info->min_mV * 1000; |
462 | } | 592 | } |
463 | 593 | ||
464 | static struct regulator_ops twlfixed_ops = { | 594 | static struct regulator_ops twl4030fixed_ops = { |
595 | .list_voltage = twlfixed_list_voltage, | ||
596 | |||
597 | .get_voltage = twlfixed_get_voltage, | ||
598 | |||
599 | .enable = twl4030reg_enable, | ||
600 | .disable = twl4030reg_disable, | ||
601 | .is_enabled = twl4030reg_is_enabled, | ||
602 | |||
603 | .set_mode = twl4030reg_set_mode, | ||
604 | |||
605 | .get_status = twl4030reg_get_status, | ||
606 | }; | ||
607 | |||
608 | static struct regulator_ops twl6030fixed_ops = { | ||
465 | .list_voltage = twlfixed_list_voltage, | 609 | .list_voltage = twlfixed_list_voltage, |
466 | 610 | ||
467 | .get_voltage = twlfixed_get_voltage, | 611 | .get_voltage = twlfixed_get_voltage, |
468 | 612 | ||
469 | .enable = twlreg_enable, | 613 | .enable = twl6030reg_enable, |
470 | .disable = twlreg_disable, | 614 | .disable = twl6030reg_disable, |
471 | .is_enabled = twlreg_is_enabled, | 615 | .is_enabled = twl6030reg_is_enabled, |
472 | 616 | ||
473 | .set_mode = twlreg_set_mode, | 617 | .set_mode = twl6030reg_set_mode, |
474 | 618 | ||
475 | .get_status = twlreg_get_status, | 619 | .get_status = twl6030reg_get_status, |
476 | }; | 620 | }; |
477 | 621 | ||
478 | static struct regulator_ops twl6030_fixed_resource = { | 622 | static struct regulator_ops twl6030_fixed_resource = { |
479 | .enable = twlreg_enable, | 623 | .enable = twl6030reg_enable, |
480 | .disable = twlreg_disable, | 624 | .disable = twl6030reg_disable, |
481 | .is_enabled = twlreg_is_enabled, | 625 | .is_enabled = twl6030reg_is_enabled, |
482 | .get_status = twlreg_get_status, | 626 | .get_status = twl6030reg_get_status, |
627 | }; | ||
628 | |||
629 | /* | ||
630 | * SMPS status and control | ||
631 | */ | ||
632 | |||
633 | static int twl6030smps_list_voltage(struct regulator_dev *rdev, unsigned index) | ||
634 | { | ||
635 | struct twlreg_info *info = rdev_get_drvdata(rdev); | ||
636 | |||
637 | int voltage = 0; | ||
638 | |||
639 | switch (info->flags) { | ||
640 | case SMPS_OFFSET_EN: | ||
641 | voltage = 100000; | ||
642 | /* fall through */ | ||
643 | case 0: | ||
644 | switch (index) { | ||
645 | case 0: | ||
646 | voltage = 0; | ||
647 | break; | ||
648 | case 58: | ||
649 | voltage = 1350 * 1000; | ||
650 | break; | ||
651 | case 59: | ||
652 | voltage = 1500 * 1000; | ||
653 | break; | ||
654 | case 60: | ||
655 | voltage = 1800 * 1000; | ||
656 | break; | ||
657 | case 61: | ||
658 | voltage = 1900 * 1000; | ||
659 | break; | ||
660 | case 62: | ||
661 | voltage = 2100 * 1000; | ||
662 | break; | ||
663 | default: | ||
664 | voltage += (600000 + (12500 * (index - 1))); | ||
665 | } | ||
666 | break; | ||
667 | case SMPS_EXTENDED_EN: | ||
668 | switch (index) { | ||
669 | case 0: | ||
670 | voltage = 0; | ||
671 | break; | ||
672 | case 58: | ||
673 | voltage = 2084 * 1000; | ||
674 | break; | ||
675 | case 59: | ||
676 | voltage = 2315 * 1000; | ||
677 | break; | ||
678 | case 60: | ||
679 | voltage = 2778 * 1000; | ||
680 | break; | ||
681 | case 61: | ||
682 | voltage = 2932 * 1000; | ||
683 | break; | ||
684 | case 62: | ||
685 | voltage = 3241 * 1000; | ||
686 | break; | ||
687 | default: | ||
688 | voltage = (1852000 + (38600 * (index - 1))); | ||
689 | } | ||
690 | break; | ||
691 | case SMPS_OFFSET_EN | SMPS_EXTENDED_EN: | ||
692 | switch (index) { | ||
693 | case 0: | ||
694 | voltage = 0; | ||
695 | break; | ||
696 | case 58: | ||
697 | voltage = 4167 * 1000; | ||
698 | break; | ||
699 | case 59: | ||
700 | voltage = 2315 * 1000; | ||
701 | break; | ||
702 | case 60: | ||
703 | voltage = 2778 * 1000; | ||
704 | break; | ||
705 | case 61: | ||
706 | voltage = 2932 * 1000; | ||
707 | break; | ||
708 | case 62: | ||
709 | voltage = 3241 * 1000; | ||
710 | break; | ||
711 | default: | ||
712 | voltage = (2161000 + (38600 * (index - 1))); | ||
713 | } | ||
714 | break; | ||
715 | } | ||
716 | |||
717 | return voltage; | ||
718 | } | ||
719 | |||
720 | static int | ||
721 | twl6030smps_set_voltage(struct regulator_dev *rdev, int min_uV, int max_uV, | ||
722 | unsigned int *selector) | ||
723 | { | ||
724 | struct twlreg_info *info = rdev_get_drvdata(rdev); | ||
725 | int vsel = 0; | ||
726 | |||
727 | switch (info->flags) { | ||
728 | case 0: | ||
729 | if (min_uV == 0) | ||
730 | vsel = 0; | ||
731 | else if ((min_uV >= 600000) && (max_uV <= 1300000)) { | ||
732 | vsel = (min_uV - 600000) / 125; | ||
733 | if (vsel % 100) | ||
734 | vsel += 100; | ||
735 | vsel /= 100; | ||
736 | vsel++; | ||
737 | } | ||
738 | /* Values 1..57 for vsel are linear and can be calculated | ||
739 | * values 58..62 are non linear. | ||
740 | */ | ||
741 | else if ((min_uV > 1900000) && (max_uV >= 2100000)) | ||
742 | vsel = 62; | ||
743 | else if ((min_uV > 1800000) && (max_uV >= 1900000)) | ||
744 | vsel = 61; | ||
745 | else if ((min_uV > 1500000) && (max_uV >= 1800000)) | ||
746 | vsel = 60; | ||
747 | else if ((min_uV > 1350000) && (max_uV >= 1500000)) | ||
748 | vsel = 59; | ||
749 | else if ((min_uV > 1300000) && (max_uV >= 1350000)) | ||
750 | vsel = 58; | ||
751 | else | ||
752 | return -EINVAL; | ||
753 | break; | ||
754 | case SMPS_OFFSET_EN: | ||
755 | if (min_uV == 0) | ||
756 | vsel = 0; | ||
757 | else if ((min_uV >= 700000) && (max_uV <= 1420000)) { | ||
758 | vsel = (min_uV - 700000) / 125; | ||
759 | if (vsel % 100) | ||
760 | vsel += 100; | ||
761 | vsel /= 100; | ||
762 | vsel++; | ||
763 | } | ||
764 | /* Values 1..57 for vsel are linear and can be calculated | ||
765 | * values 58..62 are non linear. | ||
766 | */ | ||
767 | else if ((min_uV > 1900000) && (max_uV >= 2100000)) | ||
768 | vsel = 62; | ||
769 | else if ((min_uV > 1800000) && (max_uV >= 1900000)) | ||
770 | vsel = 61; | ||
771 | else if ((min_uV > 1350000) && (max_uV >= 1800000)) | ||
772 | vsel = 60; | ||
773 | else if ((min_uV > 1350000) && (max_uV >= 1500000)) | ||
774 | vsel = 59; | ||
775 | else if ((min_uV > 1300000) && (max_uV >= 1350000)) | ||
776 | vsel = 58; | ||
777 | else | ||
778 | return -EINVAL; | ||
779 | break; | ||
780 | case SMPS_EXTENDED_EN: | ||
781 | if (min_uV == 0) | ||
782 | vsel = 0; | ||
783 | else if ((min_uV >= 1852000) && (max_uV <= 4013600)) { | ||
784 | vsel = (min_uV - 1852000) / 386; | ||
785 | if (vsel % 100) | ||
786 | vsel += 100; | ||
787 | vsel /= 100; | ||
788 | vsel++; | ||
789 | } | ||
790 | break; | ||
791 | case SMPS_OFFSET_EN|SMPS_EXTENDED_EN: | ||
792 | if (min_uV == 0) | ||
793 | vsel = 0; | ||
794 | else if ((min_uV >= 2161000) && (max_uV <= 4321000)) { | ||
795 | vsel = (min_uV - 1852000) / 386; | ||
796 | if (vsel % 100) | ||
797 | vsel += 100; | ||
798 | vsel /= 100; | ||
799 | vsel++; | ||
800 | } | ||
801 | break; | ||
802 | } | ||
803 | |||
804 | *selector = vsel; | ||
805 | |||
806 | return twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_VOLTAGE_SMPS, | ||
807 | vsel); | ||
808 | } | ||
809 | |||
810 | static int twl6030smps_get_voltage_sel(struct regulator_dev *rdev) | ||
811 | { | ||
812 | struct twlreg_info *info = rdev_get_drvdata(rdev); | ||
813 | |||
814 | return twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_VOLTAGE_SMPS); | ||
815 | } | ||
816 | |||
817 | static struct regulator_ops twlsmps_ops = { | ||
818 | .list_voltage = twl6030smps_list_voltage, | ||
819 | |||
820 | .set_voltage = twl6030smps_set_voltage, | ||
821 | .get_voltage_sel = twl6030smps_get_voltage_sel, | ||
822 | |||
823 | .enable = twl6030reg_enable, | ||
824 | .disable = twl6030reg_disable, | ||
825 | .is_enabled = twl6030reg_is_enabled, | ||
826 | |||
827 | .set_mode = twl6030reg_set_mode, | ||
828 | |||
829 | .get_status = twl6030reg_get_status, | ||
483 | }; | 830 | }; |
484 | 831 | ||
485 | /*----------------------------------------------------------------------*/ | 832 | /*----------------------------------------------------------------------*/ |
@@ -487,11 +834,10 @@ static struct regulator_ops twl6030_fixed_resource = { | |||
487 | #define TWL4030_FIXED_LDO(label, offset, mVolts, num, turnon_delay, \ | 834 | #define TWL4030_FIXED_LDO(label, offset, mVolts, num, turnon_delay, \ |
488 | remap_conf) \ | 835 | remap_conf) \ |
489 | TWL_FIXED_LDO(label, offset, mVolts, num, turnon_delay, \ | 836 | TWL_FIXED_LDO(label, offset, mVolts, num, turnon_delay, \ |
490 | remap_conf, TWL4030) | 837 | remap_conf, TWL4030, twl4030fixed_ops) |
491 | #define TWL6030_FIXED_LDO(label, offset, mVolts, num, turnon_delay, \ | 838 | #define TWL6030_FIXED_LDO(label, offset, mVolts, num, turnon_delay) \ |
492 | remap_conf) \ | ||
493 | TWL_FIXED_LDO(label, offset, mVolts, num, turnon_delay, \ | 839 | TWL_FIXED_LDO(label, offset, mVolts, num, turnon_delay, \ |
494 | remap_conf, TWL6030) | 840 | 0x0, TWL6030, twl6030fixed_ops) |
495 | 841 | ||
496 | #define TWL4030_ADJUSTABLE_LDO(label, offset, num, turnon_delay, remap_conf) { \ | 842 | #define TWL4030_ADJUSTABLE_LDO(label, offset, num, turnon_delay, remap_conf) { \ |
497 | .base = offset, \ | 843 | .base = offset, \ |
@@ -510,13 +856,11 @@ static struct regulator_ops twl6030_fixed_resource = { | |||
510 | }, \ | 856 | }, \ |
511 | } | 857 | } |
512 | 858 | ||
513 | #define TWL6030_ADJUSTABLE_LDO(label, offset, min_mVolts, max_mVolts, num, \ | 859 | #define TWL6030_ADJUSTABLE_LDO(label, offset, min_mVolts, max_mVolts, num) { \ |
514 | remap_conf) { \ | ||
515 | .base = offset, \ | 860 | .base = offset, \ |
516 | .id = num, \ | 861 | .id = num, \ |
517 | .min_mV = min_mVolts, \ | 862 | .min_mV = min_mVolts, \ |
518 | .max_mV = max_mVolts, \ | 863 | .max_mV = max_mVolts, \ |
519 | .remap = remap_conf, \ | ||
520 | .desc = { \ | 864 | .desc = { \ |
521 | .name = #label, \ | 865 | .name = #label, \ |
522 | .id = TWL6030_REG_##label, \ | 866 | .id = TWL6030_REG_##label, \ |
@@ -527,9 +871,23 @@ static struct regulator_ops twl6030_fixed_resource = { | |||
527 | }, \ | 871 | }, \ |
528 | } | 872 | } |
529 | 873 | ||
874 | #define TWL6025_ADJUSTABLE_LDO(label, offset, min_mVolts, max_mVolts, num) { \ | ||
875 | .base = offset, \ | ||
876 | .id = num, \ | ||
877 | .min_mV = min_mVolts, \ | ||
878 | .max_mV = max_mVolts, \ | ||
879 | .desc = { \ | ||
880 | .name = #label, \ | ||
881 | .id = TWL6025_REG_##label, \ | ||
882 | .n_voltages = ((max_mVolts - min_mVolts)/100) + 1, \ | ||
883 | .ops = &twl6030ldo_ops, \ | ||
884 | .type = REGULATOR_VOLTAGE, \ | ||
885 | .owner = THIS_MODULE, \ | ||
886 | }, \ | ||
887 | } | ||
530 | 888 | ||
531 | #define TWL_FIXED_LDO(label, offset, mVolts, num, turnon_delay, remap_conf, \ | 889 | #define TWL_FIXED_LDO(label, offset, mVolts, num, turnon_delay, remap_conf, \ |
532 | family) { \ | 890 | family, operations) { \ |
533 | .base = offset, \ | 891 | .base = offset, \ |
534 | .id = num, \ | 892 | .id = num, \ |
535 | .min_mV = mVolts, \ | 893 | .min_mV = mVolts, \ |
@@ -539,17 +897,16 @@ static struct regulator_ops twl6030_fixed_resource = { | |||
539 | .name = #label, \ | 897 | .name = #label, \ |
540 | .id = family##_REG_##label, \ | 898 | .id = family##_REG_##label, \ |
541 | .n_voltages = 1, \ | 899 | .n_voltages = 1, \ |
542 | .ops = &twlfixed_ops, \ | 900 | .ops = &operations, \ |
543 | .type = REGULATOR_VOLTAGE, \ | 901 | .type = REGULATOR_VOLTAGE, \ |
544 | .owner = THIS_MODULE, \ | 902 | .owner = THIS_MODULE, \ |
545 | }, \ | 903 | }, \ |
546 | } | 904 | } |
547 | 905 | ||
548 | #define TWL6030_FIXED_RESOURCE(label, offset, num, turnon_delay, remap_conf) { \ | 906 | #define TWL6030_FIXED_RESOURCE(label, offset, num, turnon_delay) { \ |
549 | .base = offset, \ | 907 | .base = offset, \ |
550 | .id = num, \ | 908 | .id = num, \ |
551 | .delay = turnon_delay, \ | 909 | .delay = turnon_delay, \ |
552 | .remap = remap_conf, \ | ||
553 | .desc = { \ | 910 | .desc = { \ |
554 | .name = #label, \ | 911 | .name = #label, \ |
555 | .id = TWL6030_REG_##label, \ | 912 | .id = TWL6030_REG_##label, \ |
@@ -559,6 +916,21 @@ static struct regulator_ops twl6030_fixed_resource = { | |||
559 | }, \ | 916 | }, \ |
560 | } | 917 | } |
561 | 918 | ||
919 | #define TWL6025_ADJUSTABLE_SMPS(label, offset, num) { \ | ||
920 | .base = offset, \ | ||
921 | .id = num, \ | ||
922 | .min_mV = 600, \ | ||
923 | .max_mV = 2100, \ | ||
924 | .desc = { \ | ||
925 | .name = #label, \ | ||
926 | .id = TWL6025_REG_##label, \ | ||
927 | .n_voltages = 63, \ | ||
928 | .ops = &twlsmps_ops, \ | ||
929 | .type = REGULATOR_VOLTAGE, \ | ||
930 | .owner = THIS_MODULE, \ | ||
931 | }, \ | ||
932 | } | ||
933 | |||
562 | /* | 934 | /* |
563 | * We list regulators here if systems need some level of | 935 | * We list regulators here if systems need some level of |
564 | * software control over them after boot. | 936 | * software control over them after boot. |
@@ -589,19 +961,52 @@ static struct twlreg_info twl_regs[] = { | |||
589 | /* 6030 REG with base as PMC Slave Misc : 0x0030 */ | 961 | /* 6030 REG with base as PMC Slave Misc : 0x0030 */ |
590 | /* Turnon-delay and remap configuration values for 6030 are not | 962 | /* Turnon-delay and remap configuration values for 6030 are not |
591 | verified since the specification is not public */ | 963 | verified since the specification is not public */ |
592 | TWL6030_ADJUSTABLE_LDO(VAUX1_6030, 0x54, 1000, 3300, 1, 0x21), | 964 | TWL6030_ADJUSTABLE_LDO(VAUX1_6030, 0x54, 1000, 3300, 1), |
593 | TWL6030_ADJUSTABLE_LDO(VAUX2_6030, 0x58, 1000, 3300, 2, 0x21), | 965 | TWL6030_ADJUSTABLE_LDO(VAUX2_6030, 0x58, 1000, 3300, 2), |
594 | TWL6030_ADJUSTABLE_LDO(VAUX3_6030, 0x5c, 1000, 3300, 3, 0x21), | 966 | TWL6030_ADJUSTABLE_LDO(VAUX3_6030, 0x5c, 1000, 3300, 3), |
595 | TWL6030_ADJUSTABLE_LDO(VMMC, 0x68, 1000, 3300, 4, 0x21), | 967 | TWL6030_ADJUSTABLE_LDO(VMMC, 0x68, 1000, 3300, 4), |
596 | TWL6030_ADJUSTABLE_LDO(VPP, 0x6c, 1000, 3300, 5, 0x21), | 968 | TWL6030_ADJUSTABLE_LDO(VPP, 0x6c, 1000, 3300, 5), |
597 | TWL6030_ADJUSTABLE_LDO(VUSIM, 0x74, 1000, 3300, 7, 0x21), | 969 | TWL6030_ADJUSTABLE_LDO(VUSIM, 0x74, 1000, 3300, 7), |
598 | TWL6030_FIXED_LDO(VANA, 0x50, 2100, 15, 0, 0x21), | 970 | TWL6030_FIXED_LDO(VANA, 0x50, 2100, 15, 0), |
599 | TWL6030_FIXED_LDO(VCXIO, 0x60, 1800, 16, 0, 0x21), | 971 | TWL6030_FIXED_LDO(VCXIO, 0x60, 1800, 16, 0), |
600 | TWL6030_FIXED_LDO(VDAC, 0x64, 1800, 17, 0, 0x21), | 972 | TWL6030_FIXED_LDO(VDAC, 0x64, 1800, 17, 0), |
601 | TWL6030_FIXED_LDO(VUSB, 0x70, 3300, 18, 0, 0x21), | 973 | TWL6030_FIXED_LDO(VUSB, 0x70, 3300, 18, 0), |
602 | TWL6030_FIXED_RESOURCE(CLK32KG, 0x8C, 48, 0, 0x21), | 974 | TWL6030_FIXED_RESOURCE(CLK32KG, 0x8C, 48, 0), |
975 | |||
976 | /* 6025 are renamed compared to 6030 versions */ | ||
977 | TWL6025_ADJUSTABLE_LDO(LDO2, 0x54, 1000, 3300, 1), | ||
978 | TWL6025_ADJUSTABLE_LDO(LDO4, 0x58, 1000, 3300, 2), | ||
979 | TWL6025_ADJUSTABLE_LDO(LDO3, 0x5c, 1000, 3300, 3), | ||
980 | TWL6025_ADJUSTABLE_LDO(LDO5, 0x68, 1000, 3300, 4), | ||
981 | TWL6025_ADJUSTABLE_LDO(LDO1, 0x6c, 1000, 3300, 5), | ||
982 | TWL6025_ADJUSTABLE_LDO(LDO7, 0x74, 1000, 3300, 7), | ||
983 | TWL6025_ADJUSTABLE_LDO(LDO6, 0x60, 1000, 3300, 16), | ||
984 | TWL6025_ADJUSTABLE_LDO(LDOLN, 0x64, 1000, 3300, 17), | ||
985 | TWL6025_ADJUSTABLE_LDO(LDOUSB, 0x70, 1000, 3300, 18), | ||
986 | |||
987 | TWL6025_ADJUSTABLE_SMPS(SMPS3, 0x34, 1), | ||
988 | TWL6025_ADJUSTABLE_SMPS(SMPS4, 0x10, 2), | ||
989 | TWL6025_ADJUSTABLE_SMPS(VIO, 0x16, 3), | ||
603 | }; | 990 | }; |
604 | 991 | ||
992 | static u8 twl_get_smps_offset(void) | ||
993 | { | ||
994 | u8 value; | ||
995 | |||
996 | twl_i2c_read_u8(TWL_MODULE_PM_RECEIVER, &value, | ||
997 | TWL6030_SMPS_OFFSET); | ||
998 | return value; | ||
999 | } | ||
1000 | |||
1001 | static u8 twl_get_smps_mult(void) | ||
1002 | { | ||
1003 | u8 value; | ||
1004 | |||
1005 | twl_i2c_read_u8(TWL_MODULE_PM_RECEIVER, &value, | ||
1006 | TWL6030_SMPS_MULT); | ||
1007 | return value; | ||
1008 | } | ||
1009 | |||
605 | static int __devinit twlreg_probe(struct platform_device *pdev) | 1010 | static int __devinit twlreg_probe(struct platform_device *pdev) |
606 | { | 1011 | { |
607 | int i; | 1012 | int i; |
@@ -623,6 +1028,9 @@ static int __devinit twlreg_probe(struct platform_device *pdev) | |||
623 | if (!initdata) | 1028 | if (!initdata) |
624 | return -EINVAL; | 1029 | return -EINVAL; |
625 | 1030 | ||
1031 | /* copy the features into regulator data */ | ||
1032 | info->features = (unsigned long)initdata->driver_data; | ||
1033 | |||
626 | /* Constrain board-specific capabilities according to what | 1034 | /* Constrain board-specific capabilities according to what |
627 | * this driver and the chip itself can actually do. | 1035 | * this driver and the chip itself can actually do. |
628 | */ | 1036 | */ |
@@ -645,6 +1053,27 @@ static int __devinit twlreg_probe(struct platform_device *pdev) | |||
645 | break; | 1053 | break; |
646 | } | 1054 | } |
647 | 1055 | ||
1056 | switch (pdev->id) { | ||
1057 | case TWL6025_REG_SMPS3: | ||
1058 | if (twl_get_smps_mult() & SMPS_MULTOFFSET_SMPS3) | ||
1059 | info->flags |= SMPS_EXTENDED_EN; | ||
1060 | if (twl_get_smps_offset() & SMPS_MULTOFFSET_SMPS3) | ||
1061 | info->flags |= SMPS_OFFSET_EN; | ||
1062 | break; | ||
1063 | case TWL6025_REG_SMPS4: | ||
1064 | if (twl_get_smps_mult() & SMPS_MULTOFFSET_SMPS4) | ||
1065 | info->flags |= SMPS_EXTENDED_EN; | ||
1066 | if (twl_get_smps_offset() & SMPS_MULTOFFSET_SMPS4) | ||
1067 | info->flags |= SMPS_OFFSET_EN; | ||
1068 | break; | ||
1069 | case TWL6025_REG_VIO: | ||
1070 | if (twl_get_smps_mult() & SMPS_MULTOFFSET_VIO) | ||
1071 | info->flags |= SMPS_EXTENDED_EN; | ||
1072 | if (twl_get_smps_offset() & SMPS_MULTOFFSET_VIO) | ||
1073 | info->flags |= SMPS_OFFSET_EN; | ||
1074 | break; | ||
1075 | } | ||
1076 | |||
648 | rdev = regulator_register(&info->desc, &pdev->dev, initdata, info); | 1077 | rdev = regulator_register(&info->desc, &pdev->dev, initdata, info); |
649 | if (IS_ERR(rdev)) { | 1078 | if (IS_ERR(rdev)) { |
650 | dev_err(&pdev->dev, "can't register %s, %ld\n", | 1079 | dev_err(&pdev->dev, "can't register %s, %ld\n", |
@@ -653,7 +1082,8 @@ static int __devinit twlreg_probe(struct platform_device *pdev) | |||
653 | } | 1082 | } |
654 | platform_set_drvdata(pdev, rdev); | 1083 | platform_set_drvdata(pdev, rdev); |
655 | 1084 | ||
656 | twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_REMAP, | 1085 | if (twl_class_is_4030()) |
1086 | twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_REMAP, | ||
657 | info->remap); | 1087 | info->remap); |
658 | 1088 | ||
659 | /* NOTE: many regulators support short-circuit IRQs (presentable | 1089 | /* NOTE: many regulators support short-circuit IRQs (presentable |
diff --git a/drivers/regulator/wm831x-dcdc.c b/drivers/regulator/wm831x-dcdc.c index e93453b1b978..a0982e809851 100644 --- a/drivers/regulator/wm831x-dcdc.c +++ b/drivers/regulator/wm831x-dcdc.c | |||
@@ -600,7 +600,6 @@ err: | |||
600 | static __devexit int wm831x_buckv_remove(struct platform_device *pdev) | 600 | static __devexit int wm831x_buckv_remove(struct platform_device *pdev) |
601 | { | 601 | { |
602 | struct wm831x_dcdc *dcdc = platform_get_drvdata(pdev); | 602 | struct wm831x_dcdc *dcdc = platform_get_drvdata(pdev); |
603 | struct wm831x *wm831x = dcdc->wm831x; | ||
604 | 603 | ||
605 | platform_set_drvdata(pdev, NULL); | 604 | platform_set_drvdata(pdev, NULL); |
606 | 605 | ||
@@ -776,7 +775,6 @@ err: | |||
776 | static __devexit int wm831x_buckp_remove(struct platform_device *pdev) | 775 | static __devexit int wm831x_buckp_remove(struct platform_device *pdev) |
777 | { | 776 | { |
778 | struct wm831x_dcdc *dcdc = platform_get_drvdata(pdev); | 777 | struct wm831x_dcdc *dcdc = platform_get_drvdata(pdev); |
779 | struct wm831x *wm831x = dcdc->wm831x; | ||
780 | 778 | ||
781 | platform_set_drvdata(pdev, NULL); | 779 | platform_set_drvdata(pdev, NULL); |
782 | 780 | ||
diff --git a/drivers/regulator/wm8400-regulator.c b/drivers/regulator/wm8400-regulator.c index b42d01cef35a..0f12c70bebc9 100644 --- a/drivers/regulator/wm8400-regulator.c +++ b/drivers/regulator/wm8400-regulator.c | |||
@@ -55,7 +55,7 @@ static int wm8400_ldo_list_voltage(struct regulator_dev *dev, | |||
55 | return 1600000 + ((selector - 14) * 100000); | 55 | return 1600000 + ((selector - 14) * 100000); |
56 | } | 56 | } |
57 | 57 | ||
58 | static int wm8400_ldo_get_voltage(struct regulator_dev *dev) | 58 | static int wm8400_ldo_get_voltage_sel(struct regulator_dev *dev) |
59 | { | 59 | { |
60 | struct wm8400 *wm8400 = rdev_get_drvdata(dev); | 60 | struct wm8400 *wm8400 = rdev_get_drvdata(dev); |
61 | u16 val; | 61 | u16 val; |
@@ -63,7 +63,7 @@ static int wm8400_ldo_get_voltage(struct regulator_dev *dev) | |||
63 | val = wm8400_reg_read(wm8400, WM8400_LDO1_CONTROL + rdev_get_id(dev)); | 63 | val = wm8400_reg_read(wm8400, WM8400_LDO1_CONTROL + rdev_get_id(dev)); |
64 | val &= WM8400_LDO1_VSEL_MASK; | 64 | val &= WM8400_LDO1_VSEL_MASK; |
65 | 65 | ||
66 | return wm8400_ldo_list_voltage(dev, val); | 66 | return val; |
67 | } | 67 | } |
68 | 68 | ||
69 | static int wm8400_ldo_set_voltage(struct regulator_dev *dev, | 69 | static int wm8400_ldo_set_voltage(struct regulator_dev *dev, |
@@ -104,7 +104,7 @@ static struct regulator_ops wm8400_ldo_ops = { | |||
104 | .enable = wm8400_ldo_enable, | 104 | .enable = wm8400_ldo_enable, |
105 | .disable = wm8400_ldo_disable, | 105 | .disable = wm8400_ldo_disable, |
106 | .list_voltage = wm8400_ldo_list_voltage, | 106 | .list_voltage = wm8400_ldo_list_voltage, |
107 | .get_voltage = wm8400_ldo_get_voltage, | 107 | .get_voltage_sel = wm8400_ldo_get_voltage_sel, |
108 | .set_voltage = wm8400_ldo_set_voltage, | 108 | .set_voltage = wm8400_ldo_set_voltage, |
109 | }; | 109 | }; |
110 | 110 | ||
@@ -145,7 +145,7 @@ static int wm8400_dcdc_list_voltage(struct regulator_dev *dev, | |||
145 | return 850000 + (selector * 25000); | 145 | return 850000 + (selector * 25000); |
146 | } | 146 | } |
147 | 147 | ||
148 | static int wm8400_dcdc_get_voltage(struct regulator_dev *dev) | 148 | static int wm8400_dcdc_get_voltage_sel(struct regulator_dev *dev) |
149 | { | 149 | { |
150 | struct wm8400 *wm8400 = rdev_get_drvdata(dev); | 150 | struct wm8400 *wm8400 = rdev_get_drvdata(dev); |
151 | u16 val; | 151 | u16 val; |
@@ -154,7 +154,7 @@ static int wm8400_dcdc_get_voltage(struct regulator_dev *dev) | |||
154 | val = wm8400_reg_read(wm8400, WM8400_DCDC1_CONTROL_1 + offset); | 154 | val = wm8400_reg_read(wm8400, WM8400_DCDC1_CONTROL_1 + offset); |
155 | val &= WM8400_DC1_VSEL_MASK; | 155 | val &= WM8400_DC1_VSEL_MASK; |
156 | 156 | ||
157 | return 850000 + (25000 * val); | 157 | return val; |
158 | } | 158 | } |
159 | 159 | ||
160 | static int wm8400_dcdc_set_voltage(struct regulator_dev *dev, | 160 | static int wm8400_dcdc_set_voltage(struct regulator_dev *dev, |
@@ -261,7 +261,7 @@ static struct regulator_ops wm8400_dcdc_ops = { | |||
261 | .enable = wm8400_dcdc_enable, | 261 | .enable = wm8400_dcdc_enable, |
262 | .disable = wm8400_dcdc_disable, | 262 | .disable = wm8400_dcdc_disable, |
263 | .list_voltage = wm8400_dcdc_list_voltage, | 263 | .list_voltage = wm8400_dcdc_list_voltage, |
264 | .get_voltage = wm8400_dcdc_get_voltage, | 264 | .get_voltage_sel = wm8400_dcdc_get_voltage_sel, |
265 | .set_voltage = wm8400_dcdc_set_voltage, | 265 | .set_voltage = wm8400_dcdc_set_voltage, |
266 | .get_mode = wm8400_dcdc_get_mode, | 266 | .get_mode = wm8400_dcdc_get_mode, |
267 | .set_mode = wm8400_dcdc_set_mode, | 267 | .set_mode = wm8400_dcdc_set_mode, |
diff --git a/drivers/usb/otg/twl6030-usb.c b/drivers/usb/otg/twl6030-usb.c index 3f2e07011a48..cfb5aa72b196 100644 --- a/drivers/usb/otg/twl6030-usb.c +++ b/drivers/usb/otg/twl6030-usb.c | |||
@@ -100,6 +100,7 @@ struct twl6030_usb { | |||
100 | u8 linkstat; | 100 | u8 linkstat; |
101 | u8 asleep; | 101 | u8 asleep; |
102 | bool irq_enabled; | 102 | bool irq_enabled; |
103 | unsigned long features; | ||
103 | }; | 104 | }; |
104 | 105 | ||
105 | #define xceiv_to_twl(x) container_of((x), struct twl6030_usb, otg) | 106 | #define xceiv_to_twl(x) container_of((x), struct twl6030_usb, otg) |
@@ -204,6 +205,12 @@ static int twl6030_start_srp(struct otg_transceiver *x) | |||
204 | 205 | ||
205 | static int twl6030_usb_ldo_init(struct twl6030_usb *twl) | 206 | static int twl6030_usb_ldo_init(struct twl6030_usb *twl) |
206 | { | 207 | { |
208 | char *regulator_name; | ||
209 | |||
210 | if (twl->features & TWL6025_SUBCLASS) | ||
211 | regulator_name = "ldousb"; | ||
212 | else | ||
213 | regulator_name = "vusb"; | ||
207 | 214 | ||
208 | /* Set to OTG_REV 1.3 and turn on the ID_WAKEUP_COMP */ | 215 | /* Set to OTG_REV 1.3 and turn on the ID_WAKEUP_COMP */ |
209 | twl6030_writeb(twl, TWL6030_MODULE_ID0 , 0x1, TWL6030_BACKUP_REG); | 216 | twl6030_writeb(twl, TWL6030_MODULE_ID0 , 0x1, TWL6030_BACKUP_REG); |
@@ -214,7 +221,7 @@ static int twl6030_usb_ldo_init(struct twl6030_usb *twl) | |||
214 | /* Program MISC2 register and set bit VUSB_IN_VBAT */ | 221 | /* Program MISC2 register and set bit VUSB_IN_VBAT */ |
215 | twl6030_writeb(twl, TWL6030_MODULE_ID0 , 0x10, TWL6030_MISC2); | 222 | twl6030_writeb(twl, TWL6030_MODULE_ID0 , 0x10, TWL6030_MISC2); |
216 | 223 | ||
217 | twl->usb3v3 = regulator_get(twl->dev, "vusb"); | 224 | twl->usb3v3 = regulator_get(twl->dev, regulator_name); |
218 | if (IS_ERR(twl->usb3v3)) | 225 | if (IS_ERR(twl->usb3v3)) |
219 | return -ENODEV; | 226 | return -ENODEV; |
220 | 227 | ||
@@ -409,6 +416,7 @@ static int __devinit twl6030_usb_probe(struct platform_device *pdev) | |||
409 | twl->dev = &pdev->dev; | 416 | twl->dev = &pdev->dev; |
410 | twl->irq1 = platform_get_irq(pdev, 0); | 417 | twl->irq1 = platform_get_irq(pdev, 0); |
411 | twl->irq2 = platform_get_irq(pdev, 1); | 418 | twl->irq2 = platform_get_irq(pdev, 1); |
419 | twl->features = pdata->features; | ||
412 | twl->otg.dev = twl->dev; | 420 | twl->otg.dev = twl->dev; |
413 | twl->otg.label = "twl6030"; | 421 | twl->otg.label = "twl6030"; |
414 | twl->otg.set_host = twl6030_set_host; | 422 | twl->otg.set_host = twl6030_set_host; |
diff --git a/include/linux/mfd/max8997-private.h b/include/linux/mfd/max8997-private.h index 69d1010e2e51..5ff2400ad46c 100644 --- a/include/linux/mfd/max8997-private.h +++ b/include/linux/mfd/max8997-private.h | |||
@@ -311,10 +311,6 @@ enum max8997_irq { | |||
311 | MAX8997_IRQ_NR, | 311 | MAX8997_IRQ_NR, |
312 | }; | 312 | }; |
313 | 313 | ||
314 | #define MAX8997_REG_BUCK1DVS(x) (MAX8997_REG_BUCK1DVS1 + (x) - 1) | ||
315 | #define MAX8997_REG_BUCK2DVS(x) (MAX8997_REG_BUCK2DVS1 + (x) - 1) | ||
316 | #define MAX8997_REG_BUCK5DVS(x) (MAX8997_REG_BUCK5DVS1 + (x) - 1) | ||
317 | |||
318 | #define MAX8997_NUM_GPIO 12 | 314 | #define MAX8997_NUM_GPIO 12 |
319 | struct max8997_dev { | 315 | struct max8997_dev { |
320 | struct device *dev; | 316 | struct device *dev; |
diff --git a/include/linux/mfd/tps65910.h b/include/linux/mfd/tps65910.h new file mode 100644 index 000000000000..8bb85b930c07 --- /dev/null +++ b/include/linux/mfd/tps65910.h | |||
@@ -0,0 +1,800 @@ | |||
1 | /* | ||
2 | * tps65910.h -- TI TPS6591x | ||
3 | * | ||
4 | * Copyright 2010-2011 Texas Instruments Inc. | ||
5 | * | ||
6 | * Author: Graeme Gregory <gg@slimlogic.co.uk> | ||
7 | * Author: Jorge Eduardo Candelaria <jedu@slimlogic.co.uk> | ||
8 | * Author: Arnaud Deconinck <a-deconinck@ti.com> | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify it | ||
11 | * under the terms of the GNU General Public License as published by the | ||
12 | * Free Software Foundation; either version 2 of the License, or (at your | ||
13 | * option) any later version. | ||
14 | * | ||
15 | */ | ||
16 | |||
17 | #ifndef __LINUX_MFD_TPS65910_H | ||
18 | #define __LINUX_MFD_TPS65910_H | ||
19 | |||
20 | /* TPS chip id list */ | ||
21 | #define TPS65910 0 | ||
22 | #define TPS65911 1 | ||
23 | |||
24 | /* TPS regulator type list */ | ||
25 | #define REGULATOR_LDO 0 | ||
26 | #define REGULATOR_DCDC 1 | ||
27 | |||
28 | /* | ||
29 | * List of registers for component TPS65910 | ||
30 | * | ||
31 | */ | ||
32 | |||
33 | #define TPS65910_SECONDS 0x0 | ||
34 | #define TPS65910_MINUTES 0x1 | ||
35 | #define TPS65910_HOURS 0x2 | ||
36 | #define TPS65910_DAYS 0x3 | ||
37 | #define TPS65910_MONTHS 0x4 | ||
38 | #define TPS65910_YEARS 0x5 | ||
39 | #define TPS65910_WEEKS 0x6 | ||
40 | #define TPS65910_ALARM_SECONDS 0x8 | ||
41 | #define TPS65910_ALARM_MINUTES 0x9 | ||
42 | #define TPS65910_ALARM_HOURS 0xA | ||
43 | #define TPS65910_ALARM_DAYS 0xB | ||
44 | #define TPS65910_ALARM_MONTHS 0xC | ||
45 | #define TPS65910_ALARM_YEARS 0xD | ||
46 | #define TPS65910_RTC_CTRL 0x10 | ||
47 | #define TPS65910_RTC_STATUS 0x11 | ||
48 | #define TPS65910_RTC_INTERRUPTS 0x12 | ||
49 | #define TPS65910_RTC_COMP_LSB 0x13 | ||
50 | #define TPS65910_RTC_COMP_MSB 0x14 | ||
51 | #define TPS65910_RTC_RES_PROG 0x15 | ||
52 | #define TPS65910_RTC_RESET_STATUS 0x16 | ||
53 | #define TPS65910_BCK1 0x17 | ||
54 | #define TPS65910_BCK2 0x18 | ||
55 | #define TPS65910_BCK3 0x19 | ||
56 | #define TPS65910_BCK4 0x1A | ||
57 | #define TPS65910_BCK5 0x1B | ||
58 | #define TPS65910_PUADEN 0x1C | ||
59 | #define TPS65910_REF 0x1D | ||
60 | #define TPS65910_VRTC 0x1E | ||
61 | #define TPS65910_VIO 0x20 | ||
62 | #define TPS65910_VDD1 0x21 | ||
63 | #define TPS65910_VDD1_OP 0x22 | ||
64 | #define TPS65910_VDD1_SR 0x23 | ||
65 | #define TPS65910_VDD2 0x24 | ||
66 | #define TPS65910_VDD2_OP 0x25 | ||
67 | #define TPS65910_VDD2_SR 0x26 | ||
68 | #define TPS65910_VDD3 0x27 | ||
69 | #define TPS65910_VDIG1 0x30 | ||
70 | #define TPS65910_VDIG2 0x31 | ||
71 | #define TPS65910_VAUX1 0x32 | ||
72 | #define TPS65910_VAUX2 0x33 | ||
73 | #define TPS65910_VAUX33 0x34 | ||
74 | #define TPS65910_VMMC 0x35 | ||
75 | #define TPS65910_VPLL 0x36 | ||
76 | #define TPS65910_VDAC 0x37 | ||
77 | #define TPS65910_THERM 0x38 | ||
78 | #define TPS65910_BBCH 0x39 | ||
79 | #define TPS65910_DCDCCTRL 0x3E | ||
80 | #define TPS65910_DEVCTRL 0x3F | ||
81 | #define TPS65910_DEVCTRL2 0x40 | ||
82 | #define TPS65910_SLEEP_KEEP_LDO_ON 0x41 | ||
83 | #define TPS65910_SLEEP_KEEP_RES_ON 0x42 | ||
84 | #define TPS65910_SLEEP_SET_LDO_OFF 0x43 | ||
85 | #define TPS65910_SLEEP_SET_RES_OFF 0x44 | ||
86 | #define TPS65910_EN1_LDO_ASS 0x45 | ||
87 | #define TPS65910_EN1_SMPS_ASS 0x46 | ||
88 | #define TPS65910_EN2_LDO_ASS 0x47 | ||
89 | #define TPS65910_EN2_SMPS_ASS 0x48 | ||
90 | #define TPS65910_EN3_LDO_ASS 0x49 | ||
91 | #define TPS65910_SPARE 0x4A | ||
92 | #define TPS65910_INT_STS 0x50 | ||
93 | #define TPS65910_INT_MSK 0x51 | ||
94 | #define TPS65910_INT_STS2 0x52 | ||
95 | #define TPS65910_INT_MSK2 0x53 | ||
96 | #define TPS65910_INT_STS3 0x54 | ||
97 | #define TPS65910_INT_MSK3 0x55 | ||
98 | #define TPS65910_GPIO0 0x60 | ||
99 | #define TPS65910_GPIO1 0x61 | ||
100 | #define TPS65910_GPIO2 0x62 | ||
101 | #define TPS65910_GPIO3 0x63 | ||
102 | #define TPS65910_GPIO4 0x64 | ||
103 | #define TPS65910_GPIO5 0x65 | ||
104 | #define TPS65910_GPIO6 0x66 | ||
105 | #define TPS65910_GPIO7 0x67 | ||
106 | #define TPS65910_GPIO8 0x68 | ||
107 | #define TPS65910_JTAGVERNUM 0x80 | ||
108 | #define TPS65910_MAX_REGISTER 0x80 | ||
109 | |||
110 | /* | ||
111 | * List of registers specific to TPS65911 | ||
112 | */ | ||
113 | #define TPS65911_VDDCTRL 0x27 | ||
114 | #define TPS65911_VDDCTRL_OP 0x28 | ||
115 | #define TPS65911_VDDCTRL_SR 0x29 | ||
116 | #define TPS65911_LDO1 0x30 | ||
117 | #define TPS65911_LDO2 0x31 | ||
118 | #define TPS65911_LDO5 0x32 | ||
119 | #define TPS65911_LDO8 0x33 | ||
120 | #define TPS65911_LDO7 0x34 | ||
121 | #define TPS65911_LDO6 0x35 | ||
122 | #define TPS65911_LDO4 0x36 | ||
123 | #define TPS65911_LDO3 0x37 | ||
124 | #define TPS65911_VMBCH 0x6A | ||
125 | #define TPS65911_VMBCH2 0x6B | ||
126 | |||
127 | /* | ||
128 | * List of register bitfields for component TPS65910 | ||
129 | * | ||
130 | */ | ||
131 | |||
132 | |||
133 | /*Register BCK1 (0x80) register.RegisterDescription */ | ||
134 | #define BCK1_BCKUP_MASK 0xFF | ||
135 | #define BCK1_BCKUP_SHIFT 0 | ||
136 | |||
137 | |||
138 | /*Register BCK2 (0x80) register.RegisterDescription */ | ||
139 | #define BCK2_BCKUP_MASK 0xFF | ||
140 | #define BCK2_BCKUP_SHIFT 0 | ||
141 | |||
142 | |||
143 | /*Register BCK3 (0x80) register.RegisterDescription */ | ||
144 | #define BCK3_BCKUP_MASK 0xFF | ||
145 | #define BCK3_BCKUP_SHIFT 0 | ||
146 | |||
147 | |||
148 | /*Register BCK4 (0x80) register.RegisterDescription */ | ||
149 | #define BCK4_BCKUP_MASK 0xFF | ||
150 | #define BCK4_BCKUP_SHIFT 0 | ||
151 | |||
152 | |||
153 | /*Register BCK5 (0x80) register.RegisterDescription */ | ||
154 | #define BCK5_BCKUP_MASK 0xFF | ||
155 | #define BCK5_BCKUP_SHIFT 0 | ||
156 | |||
157 | |||
158 | /*Register PUADEN (0x80) register.RegisterDescription */ | ||
159 | #define PUADEN_EN3P_MASK 0x80 | ||
160 | #define PUADEN_EN3P_SHIFT 7 | ||
161 | #define PUADEN_I2CCTLP_MASK 0x40 | ||
162 | #define PUADEN_I2CCTLP_SHIFT 6 | ||
163 | #define PUADEN_I2CSRP_MASK 0x20 | ||
164 | #define PUADEN_I2CSRP_SHIFT 5 | ||
165 | #define PUADEN_PWRONP_MASK 0x10 | ||
166 | #define PUADEN_PWRONP_SHIFT 4 | ||
167 | #define PUADEN_SLEEPP_MASK 0x08 | ||
168 | #define PUADEN_SLEEPP_SHIFT 3 | ||
169 | #define PUADEN_PWRHOLDP_MASK 0x04 | ||
170 | #define PUADEN_PWRHOLDP_SHIFT 2 | ||
171 | #define PUADEN_BOOT1P_MASK 0x02 | ||
172 | #define PUADEN_BOOT1P_SHIFT 1 | ||
173 | #define PUADEN_BOOT0P_MASK 0x01 | ||
174 | #define PUADEN_BOOT0P_SHIFT 0 | ||
175 | |||
176 | |||
177 | /*Register REF (0x80) register.RegisterDescription */ | ||
178 | #define REF_VMBCH_SEL_MASK 0x0C | ||
179 | #define REF_VMBCH_SEL_SHIFT 2 | ||
180 | #define REF_ST_MASK 0x03 | ||
181 | #define REF_ST_SHIFT 0 | ||
182 | |||
183 | |||
184 | /*Register VRTC (0x80) register.RegisterDescription */ | ||
185 | #define VRTC_VRTC_OFFMASK_MASK 0x08 | ||
186 | #define VRTC_VRTC_OFFMASK_SHIFT 3 | ||
187 | #define VRTC_ST_MASK 0x03 | ||
188 | #define VRTC_ST_SHIFT 0 | ||
189 | |||
190 | |||
191 | /*Register VIO (0x80) register.RegisterDescription */ | ||
192 | #define VIO_ILMAX_MASK 0xC0 | ||
193 | #define VIO_ILMAX_SHIFT 6 | ||
194 | #define VIO_SEL_MASK 0x0C | ||
195 | #define VIO_SEL_SHIFT 2 | ||
196 | #define VIO_ST_MASK 0x03 | ||
197 | #define VIO_ST_SHIFT 0 | ||
198 | |||
199 | |||
200 | /*Register VDD1 (0x80) register.RegisterDescription */ | ||
201 | #define VDD1_VGAIN_SEL_MASK 0xC0 | ||
202 | #define VDD1_VGAIN_SEL_SHIFT 6 | ||
203 | #define VDD1_ILMAX_MASK 0x20 | ||
204 | #define VDD1_ILMAX_SHIFT 5 | ||
205 | #define VDD1_TSTEP_MASK 0x1C | ||
206 | #define VDD1_TSTEP_SHIFT 2 | ||
207 | #define VDD1_ST_MASK 0x03 | ||
208 | #define VDD1_ST_SHIFT 0 | ||
209 | |||
210 | |||
211 | /*Register VDD1_OP (0x80) register.RegisterDescription */ | ||
212 | #define VDD1_OP_CMD_MASK 0x80 | ||
213 | #define VDD1_OP_CMD_SHIFT 7 | ||
214 | #define VDD1_OP_SEL_MASK 0x7F | ||
215 | #define VDD1_OP_SEL_SHIFT 0 | ||
216 | |||
217 | |||
218 | /*Register VDD1_SR (0x80) register.RegisterDescription */ | ||
219 | #define VDD1_SR_SEL_MASK 0x7F | ||
220 | #define VDD1_SR_SEL_SHIFT 0 | ||
221 | |||
222 | |||
223 | /*Register VDD2 (0x80) register.RegisterDescription */ | ||
224 | #define VDD2_VGAIN_SEL_MASK 0xC0 | ||
225 | #define VDD2_VGAIN_SEL_SHIFT 6 | ||
226 | #define VDD2_ILMAX_MASK 0x20 | ||
227 | #define VDD2_ILMAX_SHIFT 5 | ||
228 | #define VDD2_TSTEP_MASK 0x1C | ||
229 | #define VDD2_TSTEP_SHIFT 2 | ||
230 | #define VDD2_ST_MASK 0x03 | ||
231 | #define VDD2_ST_SHIFT 0 | ||
232 | |||
233 | |||
234 | /*Register VDD2_OP (0x80) register.RegisterDescription */ | ||
235 | #define VDD2_OP_CMD_MASK 0x80 | ||
236 | #define VDD2_OP_CMD_SHIFT 7 | ||
237 | #define VDD2_OP_SEL_MASK 0x7F | ||
238 | #define VDD2_OP_SEL_SHIFT 0 | ||
239 | |||
240 | /*Register VDD2_SR (0x80) register.RegisterDescription */ | ||
241 | #define VDD2_SR_SEL_MASK 0x7F | ||
242 | #define VDD2_SR_SEL_SHIFT 0 | ||
243 | |||
244 | |||
245 | /*Registers VDD1, VDD2 voltage values definitions */ | ||
246 | #define VDD1_2_NUM_VOLTS 73 | ||
247 | #define VDD1_2_MIN_VOLT 6000 | ||
248 | #define VDD1_2_OFFSET 125 | ||
249 | |||
250 | |||
251 | /*Register VDD3 (0x80) register.RegisterDescription */ | ||
252 | #define VDD3_CKINEN_MASK 0x04 | ||
253 | #define VDD3_CKINEN_SHIFT 2 | ||
254 | #define VDD3_ST_MASK 0x03 | ||
255 | #define VDD3_ST_SHIFT 0 | ||
256 | #define VDDCTRL_MIN_VOLT 6000 | ||
257 | #define VDDCTRL_OFFSET 125 | ||
258 | |||
259 | /*Registers VDIG (0x80) to VDAC register.RegisterDescription */ | ||
260 | #define LDO_SEL_MASK 0x0C | ||
261 | #define LDO_SEL_SHIFT 2 | ||
262 | #define LDO_ST_MASK 0x03 | ||
263 | #define LDO_ST_SHIFT 0 | ||
264 | #define LDO_ST_ON_BIT 0x01 | ||
265 | #define LDO_ST_MODE_BIT 0x02 | ||
266 | |||
267 | |||
268 | /* Registers LDO1 to LDO8 in tps65910 */ | ||
269 | #define LDO1_SEL_MASK 0xFC | ||
270 | #define LDO3_SEL_MASK 0x7C | ||
271 | #define LDO_MIN_VOLT 1000 | ||
272 | #define LDO_MAX_VOLT 3300; | ||
273 | |||
274 | |||
275 | /*Register VDIG1 (0x80) register.RegisterDescription */ | ||
276 | #define VDIG1_SEL_MASK 0x0C | ||
277 | #define VDIG1_SEL_SHIFT 2 | ||
278 | #define VDIG1_ST_MASK 0x03 | ||
279 | #define VDIG1_ST_SHIFT 0 | ||
280 | |||
281 | |||
282 | /*Register VDIG2 (0x80) register.RegisterDescription */ | ||
283 | #define VDIG2_SEL_MASK 0x0C | ||
284 | #define VDIG2_SEL_SHIFT 2 | ||
285 | #define VDIG2_ST_MASK 0x03 | ||
286 | #define VDIG2_ST_SHIFT 0 | ||
287 | |||
288 | |||
289 | /*Register VAUX1 (0x80) register.RegisterDescription */ | ||
290 | #define VAUX1_SEL_MASK 0x0C | ||
291 | #define VAUX1_SEL_SHIFT 2 | ||
292 | #define VAUX1_ST_MASK 0x03 | ||
293 | #define VAUX1_ST_SHIFT 0 | ||
294 | |||
295 | |||
296 | /*Register VAUX2 (0x80) register.RegisterDescription */ | ||
297 | #define VAUX2_SEL_MASK 0x0C | ||
298 | #define VAUX2_SEL_SHIFT 2 | ||
299 | #define VAUX2_ST_MASK 0x03 | ||
300 | #define VAUX2_ST_SHIFT 0 | ||
301 | |||
302 | |||
303 | /*Register VAUX33 (0x80) register.RegisterDescription */ | ||
304 | #define VAUX33_SEL_MASK 0x0C | ||
305 | #define VAUX33_SEL_SHIFT 2 | ||
306 | #define VAUX33_ST_MASK 0x03 | ||
307 | #define VAUX33_ST_SHIFT 0 | ||
308 | |||
309 | |||
310 | /*Register VMMC (0x80) register.RegisterDescription */ | ||
311 | #define VMMC_SEL_MASK 0x0C | ||
312 | #define VMMC_SEL_SHIFT 2 | ||
313 | #define VMMC_ST_MASK 0x03 | ||
314 | #define VMMC_ST_SHIFT 0 | ||
315 | |||
316 | |||
317 | /*Register VPLL (0x80) register.RegisterDescription */ | ||
318 | #define VPLL_SEL_MASK 0x0C | ||
319 | #define VPLL_SEL_SHIFT 2 | ||
320 | #define VPLL_ST_MASK 0x03 | ||
321 | #define VPLL_ST_SHIFT 0 | ||
322 | |||
323 | |||
324 | /*Register VDAC (0x80) register.RegisterDescription */ | ||
325 | #define VDAC_SEL_MASK 0x0C | ||
326 | #define VDAC_SEL_SHIFT 2 | ||
327 | #define VDAC_ST_MASK 0x03 | ||
328 | #define VDAC_ST_SHIFT 0 | ||
329 | |||
330 | |||
331 | /*Register THERM (0x80) register.RegisterDescription */ | ||
332 | #define THERM_THERM_HD_MASK 0x20 | ||
333 | #define THERM_THERM_HD_SHIFT 5 | ||
334 | #define THERM_THERM_TS_MASK 0x10 | ||
335 | #define THERM_THERM_TS_SHIFT 4 | ||
336 | #define THERM_THERM_HDSEL_MASK 0x0C | ||
337 | #define THERM_THERM_HDSEL_SHIFT 2 | ||
338 | #define THERM_RSVD1_MASK 0x02 | ||
339 | #define THERM_RSVD1_SHIFT 1 | ||
340 | #define THERM_THERM_STATE_MASK 0x01 | ||
341 | #define THERM_THERM_STATE_SHIFT 0 | ||
342 | |||
343 | |||
344 | /*Register BBCH (0x80) register.RegisterDescription */ | ||
345 | #define BBCH_BBSEL_MASK 0x06 | ||
346 | #define BBCH_BBSEL_SHIFT 1 | ||
347 | #define BBCH_BBCHEN_MASK 0x01 | ||
348 | #define BBCH_BBCHEN_SHIFT 0 | ||
349 | |||
350 | |||
351 | /*Register DCDCCTRL (0x80) register.RegisterDescription */ | ||
352 | #define DCDCCTRL_VDD2_PSKIP_MASK 0x20 | ||
353 | #define DCDCCTRL_VDD2_PSKIP_SHIFT 5 | ||
354 | #define DCDCCTRL_VDD1_PSKIP_MASK 0x10 | ||
355 | #define DCDCCTRL_VDD1_PSKIP_SHIFT 4 | ||
356 | #define DCDCCTRL_VIO_PSKIP_MASK 0x08 | ||
357 | #define DCDCCTRL_VIO_PSKIP_SHIFT 3 | ||
358 | #define DCDCCTRL_DCDCCKEXT_MASK 0x04 | ||
359 | #define DCDCCTRL_DCDCCKEXT_SHIFT 2 | ||
360 | #define DCDCCTRL_DCDCCKSYNC_MASK 0x03 | ||
361 | #define DCDCCTRL_DCDCCKSYNC_SHIFT 0 | ||
362 | |||
363 | |||
364 | /*Register DEVCTRL (0x80) register.RegisterDescription */ | ||
365 | #define DEVCTRL_RTC_PWDN_MASK 0x40 | ||
366 | #define DEVCTRL_RTC_PWDN_SHIFT 6 | ||
367 | #define DEVCTRL_CK32K_CTRL_MASK 0x20 | ||
368 | #define DEVCTRL_CK32K_CTRL_SHIFT 5 | ||
369 | #define DEVCTRL_SR_CTL_I2C_SEL_MASK 0x10 | ||
370 | #define DEVCTRL_SR_CTL_I2C_SEL_SHIFT 4 | ||
371 | #define DEVCTRL_DEV_OFF_RST_MASK 0x08 | ||
372 | #define DEVCTRL_DEV_OFF_RST_SHIFT 3 | ||
373 | #define DEVCTRL_DEV_ON_MASK 0x04 | ||
374 | #define DEVCTRL_DEV_ON_SHIFT 2 | ||
375 | #define DEVCTRL_DEV_SLP_MASK 0x02 | ||
376 | #define DEVCTRL_DEV_SLP_SHIFT 1 | ||
377 | #define DEVCTRL_DEV_OFF_MASK 0x01 | ||
378 | #define DEVCTRL_DEV_OFF_SHIFT 0 | ||
379 | |||
380 | |||
381 | /*Register DEVCTRL2 (0x80) register.RegisterDescription */ | ||
382 | #define DEVCTRL2_TSLOT_LENGTH_MASK 0x30 | ||
383 | #define DEVCTRL2_TSLOT_LENGTH_SHIFT 4 | ||
384 | #define DEVCTRL2_SLEEPSIG_POL_MASK 0x08 | ||
385 | #define DEVCTRL2_SLEEPSIG_POL_SHIFT 3 | ||
386 | #define DEVCTRL2_PWON_LP_OFF_MASK 0x04 | ||
387 | #define DEVCTRL2_PWON_LP_OFF_SHIFT 2 | ||
388 | #define DEVCTRL2_PWON_LP_RST_MASK 0x02 | ||
389 | #define DEVCTRL2_PWON_LP_RST_SHIFT 1 | ||
390 | #define DEVCTRL2_IT_POL_MASK 0x01 | ||
391 | #define DEVCTRL2_IT_POL_SHIFT 0 | ||
392 | |||
393 | |||
394 | /*Register SLEEP_KEEP_LDO_ON (0x80) register.RegisterDescription */ | ||
395 | #define SLEEP_KEEP_LDO_ON_VDAC_KEEPON_MASK 0x80 | ||
396 | #define SLEEP_KEEP_LDO_ON_VDAC_KEEPON_SHIFT 7 | ||
397 | #define SLEEP_KEEP_LDO_ON_VPLL_KEEPON_MASK 0x40 | ||
398 | #define SLEEP_KEEP_LDO_ON_VPLL_KEEPON_SHIFT 6 | ||
399 | #define SLEEP_KEEP_LDO_ON_VAUX33_KEEPON_MASK 0x20 | ||
400 | #define SLEEP_KEEP_LDO_ON_VAUX33_KEEPON_SHIFT 5 | ||
401 | #define SLEEP_KEEP_LDO_ON_VAUX2_KEEPON_MASK 0x10 | ||
402 | #define SLEEP_KEEP_LDO_ON_VAUX2_KEEPON_SHIFT 4 | ||
403 | #define SLEEP_KEEP_LDO_ON_VAUX1_KEEPON_MASK 0x08 | ||
404 | #define SLEEP_KEEP_LDO_ON_VAUX1_KEEPON_SHIFT 3 | ||
405 | #define SLEEP_KEEP_LDO_ON_VDIG2_KEEPON_MASK 0x04 | ||
406 | #define SLEEP_KEEP_LDO_ON_VDIG2_KEEPON_SHIFT 2 | ||
407 | #define SLEEP_KEEP_LDO_ON_VDIG1_KEEPON_MASK 0x02 | ||
408 | #define SLEEP_KEEP_LDO_ON_VDIG1_KEEPON_SHIFT 1 | ||
409 | #define SLEEP_KEEP_LDO_ON_VMMC_KEEPON_MASK 0x01 | ||
410 | #define SLEEP_KEEP_LDO_ON_VMMC_KEEPON_SHIFT 0 | ||
411 | |||
412 | |||
413 | /*Register SLEEP_KEEP_RES_ON (0x80) register.RegisterDescription */ | ||
414 | #define SLEEP_KEEP_RES_ON_THERM_KEEPON_MASK 0x80 | ||
415 | #define SLEEP_KEEP_RES_ON_THERM_KEEPON_SHIFT 7 | ||
416 | #define SLEEP_KEEP_RES_ON_CLKOUT32K_KEEPON_MASK 0x40 | ||
417 | #define SLEEP_KEEP_RES_ON_CLKOUT32K_KEEPON_SHIFT 6 | ||
418 | #define SLEEP_KEEP_RES_ON_VRTC_KEEPON_MASK 0x20 | ||
419 | #define SLEEP_KEEP_RES_ON_VRTC_KEEPON_SHIFT 5 | ||
420 | #define SLEEP_KEEP_RES_ON_I2CHS_KEEPON_MASK 0x10 | ||
421 | #define SLEEP_KEEP_RES_ON_I2CHS_KEEPON_SHIFT 4 | ||
422 | #define SLEEP_KEEP_RES_ON_VDD3_KEEPON_MASK 0x08 | ||
423 | #define SLEEP_KEEP_RES_ON_VDD3_KEEPON_SHIFT 3 | ||
424 | #define SLEEP_KEEP_RES_ON_VDD2_KEEPON_MASK 0x04 | ||
425 | #define SLEEP_KEEP_RES_ON_VDD2_KEEPON_SHIFT 2 | ||
426 | #define SLEEP_KEEP_RES_ON_VDD1_KEEPON_MASK 0x02 | ||
427 | #define SLEEP_KEEP_RES_ON_VDD1_KEEPON_SHIFT 1 | ||
428 | #define SLEEP_KEEP_RES_ON_VIO_KEEPON_MASK 0x01 | ||
429 | #define SLEEP_KEEP_RES_ON_VIO_KEEPON_SHIFT 0 | ||
430 | |||
431 | |||
432 | /*Register SLEEP_SET_LDO_OFF (0x80) register.RegisterDescription */ | ||
433 | #define SLEEP_SET_LDO_OFF_VDAC_SETOFF_MASK 0x80 | ||
434 | #define SLEEP_SET_LDO_OFF_VDAC_SETOFF_SHIFT 7 | ||
435 | #define SLEEP_SET_LDO_OFF_VPLL_SETOFF_MASK 0x40 | ||
436 | #define SLEEP_SET_LDO_OFF_VPLL_SETOFF_SHIFT 6 | ||
437 | #define SLEEP_SET_LDO_OFF_VAUX33_SETOFF_MASK 0x20 | ||
438 | #define SLEEP_SET_LDO_OFF_VAUX33_SETOFF_SHIFT 5 | ||
439 | #define SLEEP_SET_LDO_OFF_VAUX2_SETOFF_MASK 0x10 | ||
440 | #define SLEEP_SET_LDO_OFF_VAUX2_SETOFF_SHIFT 4 | ||
441 | #define SLEEP_SET_LDO_OFF_VAUX1_SETOFF_MASK 0x08 | ||
442 | #define SLEEP_SET_LDO_OFF_VAUX1_SETOFF_SHIFT 3 | ||
443 | #define SLEEP_SET_LDO_OFF_VDIG2_SETOFF_MASK 0x04 | ||
444 | #define SLEEP_SET_LDO_OFF_VDIG2_SETOFF_SHIFT 2 | ||
445 | #define SLEEP_SET_LDO_OFF_VDIG1_SETOFF_MASK 0x02 | ||
446 | #define SLEEP_SET_LDO_OFF_VDIG1_SETOFF_SHIFT 1 | ||
447 | #define SLEEP_SET_LDO_OFF_VMMC_SETOFF_MASK 0x01 | ||
448 | #define SLEEP_SET_LDO_OFF_VMMC_SETOFF_SHIFT 0 | ||
449 | |||
450 | |||
451 | /*Register SLEEP_SET_RES_OFF (0x80) register.RegisterDescription */ | ||
452 | #define SLEEP_SET_RES_OFF_DEFAULT_VOLT_MASK 0x80 | ||
453 | #define SLEEP_SET_RES_OFF_DEFAULT_VOLT_SHIFT 7 | ||
454 | #define SLEEP_SET_RES_OFF_RSVD_MASK 0x60 | ||
455 | #define SLEEP_SET_RES_OFF_RSVD_SHIFT 5 | ||
456 | #define SLEEP_SET_RES_OFF_SPARE_SETOFF_MASK 0x10 | ||
457 | #define SLEEP_SET_RES_OFF_SPARE_SETOFF_SHIFT 4 | ||
458 | #define SLEEP_SET_RES_OFF_VDD3_SETOFF_MASK 0x08 | ||
459 | #define SLEEP_SET_RES_OFF_VDD3_SETOFF_SHIFT 3 | ||
460 | #define SLEEP_SET_RES_OFF_VDD2_SETOFF_MASK 0x04 | ||
461 | #define SLEEP_SET_RES_OFF_VDD2_SETOFF_SHIFT 2 | ||
462 | #define SLEEP_SET_RES_OFF_VDD1_SETOFF_MASK 0x02 | ||
463 | #define SLEEP_SET_RES_OFF_VDD1_SETOFF_SHIFT 1 | ||
464 | #define SLEEP_SET_RES_OFF_VIO_SETOFF_MASK 0x01 | ||
465 | #define SLEEP_SET_RES_OFF_VIO_SETOFF_SHIFT 0 | ||
466 | |||
467 | |||
468 | /*Register EN1_LDO_ASS (0x80) register.RegisterDescription */ | ||
469 | #define EN1_LDO_ASS_VDAC_EN1_MASK 0x80 | ||
470 | #define EN1_LDO_ASS_VDAC_EN1_SHIFT 7 | ||
471 | #define EN1_LDO_ASS_VPLL_EN1_MASK 0x40 | ||
472 | #define EN1_LDO_ASS_VPLL_EN1_SHIFT 6 | ||
473 | #define EN1_LDO_ASS_VAUX33_EN1_MASK 0x20 | ||
474 | #define EN1_LDO_ASS_VAUX33_EN1_SHIFT 5 | ||
475 | #define EN1_LDO_ASS_VAUX2_EN1_MASK 0x10 | ||
476 | #define EN1_LDO_ASS_VAUX2_EN1_SHIFT 4 | ||
477 | #define EN1_LDO_ASS_VAUX1_EN1_MASK 0x08 | ||
478 | #define EN1_LDO_ASS_VAUX1_EN1_SHIFT 3 | ||
479 | #define EN1_LDO_ASS_VDIG2_EN1_MASK 0x04 | ||
480 | #define EN1_LDO_ASS_VDIG2_EN1_SHIFT 2 | ||
481 | #define EN1_LDO_ASS_VDIG1_EN1_MASK 0x02 | ||
482 | #define EN1_LDO_ASS_VDIG1_EN1_SHIFT 1 | ||
483 | #define EN1_LDO_ASS_VMMC_EN1_MASK 0x01 | ||
484 | #define EN1_LDO_ASS_VMMC_EN1_SHIFT 0 | ||
485 | |||
486 | |||
487 | /*Register EN1_SMPS_ASS (0x80) register.RegisterDescription */ | ||
488 | #define EN1_SMPS_ASS_RSVD_MASK 0xE0 | ||
489 | #define EN1_SMPS_ASS_RSVD_SHIFT 5 | ||
490 | #define EN1_SMPS_ASS_SPARE_EN1_MASK 0x10 | ||
491 | #define EN1_SMPS_ASS_SPARE_EN1_SHIFT 4 | ||
492 | #define EN1_SMPS_ASS_VDD3_EN1_MASK 0x08 | ||
493 | #define EN1_SMPS_ASS_VDD3_EN1_SHIFT 3 | ||
494 | #define EN1_SMPS_ASS_VDD2_EN1_MASK 0x04 | ||
495 | #define EN1_SMPS_ASS_VDD2_EN1_SHIFT 2 | ||
496 | #define EN1_SMPS_ASS_VDD1_EN1_MASK 0x02 | ||
497 | #define EN1_SMPS_ASS_VDD1_EN1_SHIFT 1 | ||
498 | #define EN1_SMPS_ASS_VIO_EN1_MASK 0x01 | ||
499 | #define EN1_SMPS_ASS_VIO_EN1_SHIFT 0 | ||
500 | |||
501 | |||
502 | /*Register EN2_LDO_ASS (0x80) register.RegisterDescription */ | ||
503 | #define EN2_LDO_ASS_VDAC_EN2_MASK 0x80 | ||
504 | #define EN2_LDO_ASS_VDAC_EN2_SHIFT 7 | ||
505 | #define EN2_LDO_ASS_VPLL_EN2_MASK 0x40 | ||
506 | #define EN2_LDO_ASS_VPLL_EN2_SHIFT 6 | ||
507 | #define EN2_LDO_ASS_VAUX33_EN2_MASK 0x20 | ||
508 | #define EN2_LDO_ASS_VAUX33_EN2_SHIFT 5 | ||
509 | #define EN2_LDO_ASS_VAUX2_EN2_MASK 0x10 | ||
510 | #define EN2_LDO_ASS_VAUX2_EN2_SHIFT 4 | ||
511 | #define EN2_LDO_ASS_VAUX1_EN2_MASK 0x08 | ||
512 | #define EN2_LDO_ASS_VAUX1_EN2_SHIFT 3 | ||
513 | #define EN2_LDO_ASS_VDIG2_EN2_MASK 0x04 | ||
514 | #define EN2_LDO_ASS_VDIG2_EN2_SHIFT 2 | ||
515 | #define EN2_LDO_ASS_VDIG1_EN2_MASK 0x02 | ||
516 | #define EN2_LDO_ASS_VDIG1_EN2_SHIFT 1 | ||
517 | #define EN2_LDO_ASS_VMMC_EN2_MASK 0x01 | ||
518 | #define EN2_LDO_ASS_VMMC_EN2_SHIFT 0 | ||
519 | |||
520 | |||
521 | /*Register EN2_SMPS_ASS (0x80) register.RegisterDescription */ | ||
522 | #define EN2_SMPS_ASS_RSVD_MASK 0xE0 | ||
523 | #define EN2_SMPS_ASS_RSVD_SHIFT 5 | ||
524 | #define EN2_SMPS_ASS_SPARE_EN2_MASK 0x10 | ||
525 | #define EN2_SMPS_ASS_SPARE_EN2_SHIFT 4 | ||
526 | #define EN2_SMPS_ASS_VDD3_EN2_MASK 0x08 | ||
527 | #define EN2_SMPS_ASS_VDD3_EN2_SHIFT 3 | ||
528 | #define EN2_SMPS_ASS_VDD2_EN2_MASK 0x04 | ||
529 | #define EN2_SMPS_ASS_VDD2_EN2_SHIFT 2 | ||
530 | #define EN2_SMPS_ASS_VDD1_EN2_MASK 0x02 | ||
531 | #define EN2_SMPS_ASS_VDD1_EN2_SHIFT 1 | ||
532 | #define EN2_SMPS_ASS_VIO_EN2_MASK 0x01 | ||
533 | #define EN2_SMPS_ASS_VIO_EN2_SHIFT 0 | ||
534 | |||
535 | |||
536 | /*Register EN3_LDO_ASS (0x80) register.RegisterDescription */ | ||
537 | #define EN3_LDO_ASS_VDAC_EN3_MASK 0x80 | ||
538 | #define EN3_LDO_ASS_VDAC_EN3_SHIFT 7 | ||
539 | #define EN3_LDO_ASS_VPLL_EN3_MASK 0x40 | ||
540 | #define EN3_LDO_ASS_VPLL_EN3_SHIFT 6 | ||
541 | #define EN3_LDO_ASS_VAUX33_EN3_MASK 0x20 | ||
542 | #define EN3_LDO_ASS_VAUX33_EN3_SHIFT 5 | ||
543 | #define EN3_LDO_ASS_VAUX2_EN3_MASK 0x10 | ||
544 | #define EN3_LDO_ASS_VAUX2_EN3_SHIFT 4 | ||
545 | #define EN3_LDO_ASS_VAUX1_EN3_MASK 0x08 | ||
546 | #define EN3_LDO_ASS_VAUX1_EN3_SHIFT 3 | ||
547 | #define EN3_LDO_ASS_VDIG2_EN3_MASK 0x04 | ||
548 | #define EN3_LDO_ASS_VDIG2_EN3_SHIFT 2 | ||
549 | #define EN3_LDO_ASS_VDIG1_EN3_MASK 0x02 | ||
550 | #define EN3_LDO_ASS_VDIG1_EN3_SHIFT 1 | ||
551 | #define EN3_LDO_ASS_VMMC_EN3_MASK 0x01 | ||
552 | #define EN3_LDO_ASS_VMMC_EN3_SHIFT 0 | ||
553 | |||
554 | |||
555 | /*Register SPARE (0x80) register.RegisterDescription */ | ||
556 | #define SPARE_SPARE_MASK 0xFF | ||
557 | #define SPARE_SPARE_SHIFT 0 | ||
558 | |||
559 | |||
560 | /*Register INT_STS (0x80) register.RegisterDescription */ | ||
561 | #define INT_STS_RTC_PERIOD_IT_MASK 0x80 | ||
562 | #define INT_STS_RTC_PERIOD_IT_SHIFT 7 | ||
563 | #define INT_STS_RTC_ALARM_IT_MASK 0x40 | ||
564 | #define INT_STS_RTC_ALARM_IT_SHIFT 6 | ||
565 | #define INT_STS_HOTDIE_IT_MASK 0x20 | ||
566 | #define INT_STS_HOTDIE_IT_SHIFT 5 | ||
567 | #define INT_STS_PWRHOLD_IT_MASK 0x10 | ||
568 | #define INT_STS_PWRHOLD_IT_SHIFT 4 | ||
569 | #define INT_STS_PWRON_LP_IT_MASK 0x08 | ||
570 | #define INT_STS_PWRON_LP_IT_SHIFT 3 | ||
571 | #define INT_STS_PWRON_IT_MASK 0x04 | ||
572 | #define INT_STS_PWRON_IT_SHIFT 2 | ||
573 | #define INT_STS_VMBHI_IT_MASK 0x02 | ||
574 | #define INT_STS_VMBHI_IT_SHIFT 1 | ||
575 | #define INT_STS_VMBDCH_IT_MASK 0x01 | ||
576 | #define INT_STS_VMBDCH_IT_SHIFT 0 | ||
577 | |||
578 | |||
579 | /*Register INT_MSK (0x80) register.RegisterDescription */ | ||
580 | #define INT_MSK_RTC_PERIOD_IT_MSK_MASK 0x80 | ||
581 | #define INT_MSK_RTC_PERIOD_IT_MSK_SHIFT 7 | ||
582 | #define INT_MSK_RTC_ALARM_IT_MSK_MASK 0x40 | ||
583 | #define INT_MSK_RTC_ALARM_IT_MSK_SHIFT 6 | ||
584 | #define INT_MSK_HOTDIE_IT_MSK_MASK 0x20 | ||
585 | #define INT_MSK_HOTDIE_IT_MSK_SHIFT 5 | ||
586 | #define INT_MSK_PWRHOLD_IT_MSK_MASK 0x10 | ||
587 | #define INT_MSK_PWRHOLD_IT_MSK_SHIFT 4 | ||
588 | #define INT_MSK_PWRON_LP_IT_MSK_MASK 0x08 | ||
589 | #define INT_MSK_PWRON_LP_IT_MSK_SHIFT 3 | ||
590 | #define INT_MSK_PWRON_IT_MSK_MASK 0x04 | ||
591 | #define INT_MSK_PWRON_IT_MSK_SHIFT 2 | ||
592 | #define INT_MSK_VMBHI_IT_MSK_MASK 0x02 | ||
593 | #define INT_MSK_VMBHI_IT_MSK_SHIFT 1 | ||
594 | #define INT_MSK_VMBDCH_IT_MSK_MASK 0x01 | ||
595 | #define INT_MSK_VMBDCH_IT_MSK_SHIFT 0 | ||
596 | |||
597 | |||
598 | /*Register INT_STS2 (0x80) register.RegisterDescription */ | ||
599 | #define INT_STS2_GPIO3_F_IT_MASK 0x80 | ||
600 | #define INT_STS2_GPIO3_F_IT_SHIFT 7 | ||
601 | #define INT_STS2_GPIO3_R_IT_MASK 0x40 | ||
602 | #define INT_STS2_GPIO3_R_IT_SHIFT 6 | ||
603 | #define INT_STS2_GPIO2_F_IT_MASK 0x20 | ||
604 | #define INT_STS2_GPIO2_F_IT_SHIFT 5 | ||
605 | #define INT_STS2_GPIO2_R_IT_MASK 0x10 | ||
606 | #define INT_STS2_GPIO2_R_IT_SHIFT 4 | ||
607 | #define INT_STS2_GPIO1_F_IT_MASK 0x08 | ||
608 | #define INT_STS2_GPIO1_F_IT_SHIFT 3 | ||
609 | #define INT_STS2_GPIO1_R_IT_MASK 0x04 | ||
610 | #define INT_STS2_GPIO1_R_IT_SHIFT 2 | ||
611 | #define INT_STS2_GPIO0_F_IT_MASK 0x02 | ||
612 | #define INT_STS2_GPIO0_F_IT_SHIFT 1 | ||
613 | #define INT_STS2_GPIO0_R_IT_MASK 0x01 | ||
614 | #define INT_STS2_GPIO0_R_IT_SHIFT 0 | ||
615 | |||
616 | |||
617 | /*Register INT_MSK2 (0x80) register.RegisterDescription */ | ||
618 | #define INT_MSK2_GPIO3_F_IT_MSK_MASK 0x80 | ||
619 | #define INT_MSK2_GPIO3_F_IT_MSK_SHIFT 7 | ||
620 | #define INT_MSK2_GPIO3_R_IT_MSK_MASK 0x40 | ||
621 | #define INT_MSK2_GPIO3_R_IT_MSK_SHIFT 6 | ||
622 | #define INT_MSK2_GPIO2_F_IT_MSK_MASK 0x20 | ||
623 | #define INT_MSK2_GPIO2_F_IT_MSK_SHIFT 5 | ||
624 | #define INT_MSK2_GPIO2_R_IT_MSK_MASK 0x10 | ||
625 | #define INT_MSK2_GPIO2_R_IT_MSK_SHIFT 4 | ||
626 | #define INT_MSK2_GPIO1_F_IT_MSK_MASK 0x08 | ||
627 | #define INT_MSK2_GPIO1_F_IT_MSK_SHIFT 3 | ||
628 | #define INT_MSK2_GPIO1_R_IT_MSK_MASK 0x04 | ||
629 | #define INT_MSK2_GPIO1_R_IT_MSK_SHIFT 2 | ||
630 | #define INT_MSK2_GPIO0_F_IT_MSK_MASK 0x02 | ||
631 | #define INT_MSK2_GPIO0_F_IT_MSK_SHIFT 1 | ||
632 | #define INT_MSK2_GPIO0_R_IT_MSK_MASK 0x01 | ||
633 | #define INT_MSK2_GPIO0_R_IT_MSK_SHIFT 0 | ||
634 | |||
635 | |||
636 | /*Register INT_STS3 (0x80) register.RegisterDescription */ | ||
637 | #define INT_STS3_GPIO5_F_IT_MASK 0x08 | ||
638 | #define INT_STS3_GPIO5_F_IT_SHIFT 3 | ||
639 | #define INT_STS3_GPIO5_R_IT_MASK 0x04 | ||
640 | #define INT_STS3_GPIO5_R_IT_SHIFT 2 | ||
641 | #define INT_STS3_GPIO4_F_IT_MASK 0x02 | ||
642 | #define INT_STS3_GPIO4_F_IT_SHIFT 1 | ||
643 | #define INT_STS3_GPIO4_R_IT_MASK 0x01 | ||
644 | #define INT_STS3_GPIO4_R_IT_SHIFT 0 | ||
645 | |||
646 | |||
647 | /*Register INT_MSK3 (0x80) register.RegisterDescription */ | ||
648 | #define INT_MSK3_GPIO5_F_IT_MSK_MASK 0x08 | ||
649 | #define INT_MSK3_GPIO5_F_IT_MSK_SHIFT 3 | ||
650 | #define INT_MSK3_GPIO5_R_IT_MSK_MASK 0x04 | ||
651 | #define INT_MSK3_GPIO5_R_IT_MSK_SHIFT 2 | ||
652 | #define INT_MSK3_GPIO4_F_IT_MSK_MASK 0x02 | ||
653 | #define INT_MSK3_GPIO4_F_IT_MSK_SHIFT 1 | ||
654 | #define INT_MSK3_GPIO4_R_IT_MSK_MASK 0x01 | ||
655 | #define INT_MSK3_GPIO4_R_IT_MSK_SHIFT 0 | ||
656 | |||
657 | |||
658 | /*Register GPIO (0x80) register.RegisterDescription */ | ||
659 | #define GPIO_DEB_MASK 0x10 | ||
660 | #define GPIO_DEB_SHIFT 4 | ||
661 | #define GPIO_PUEN_MASK 0x08 | ||
662 | #define GPIO_PUEN_SHIFT 3 | ||
663 | #define GPIO_CFG_MASK 0x04 | ||
664 | #define GPIO_CFG_SHIFT 2 | ||
665 | #define GPIO_STS_MASK 0x02 | ||
666 | #define GPIO_STS_SHIFT 1 | ||
667 | #define GPIO_SET_MASK 0x01 | ||
668 | #define GPIO_SET_SHIFT 0 | ||
669 | |||
670 | |||
671 | /*Register JTAGVERNUM (0x80) register.RegisterDescription */ | ||
672 | #define JTAGVERNUM_VERNUM_MASK 0x0F | ||
673 | #define JTAGVERNUM_VERNUM_SHIFT 0 | ||
674 | |||
675 | |||
676 | /* Register VDDCTRL (0x27) bit definitions */ | ||
677 | #define VDDCTRL_ST_MASK 0x03 | ||
678 | #define VDDCTRL_ST_SHIFT 0 | ||
679 | |||
680 | |||
681 | /*Register VDDCTRL_OP (0x28) bit definitios */ | ||
682 | #define VDDCTRL_OP_CMD_MASK 0x80 | ||
683 | #define VDDCTRL_OP_CMD_SHIFT 7 | ||
684 | #define VDDCTRL_OP_SEL_MASK 0x7F | ||
685 | #define VDDCTRL_OP_SEL_SHIFT 0 | ||
686 | |||
687 | |||
688 | /*Register VDDCTRL_SR (0x29) bit definitions */ | ||
689 | #define VDDCTRL_SR_SEL_MASK 0x7F | ||
690 | #define VDDCTRL_SR_SEL_SHIFT 0 | ||
691 | |||
692 | |||
693 | /* IRQ Definitions */ | ||
694 | #define TPS65910_IRQ_VBAT_VMBDCH 0 | ||
695 | #define TPS65910_IRQ_VBAT_VMHI 1 | ||
696 | #define TPS65910_IRQ_PWRON 2 | ||
697 | #define TPS65910_IRQ_PWRON_LP 3 | ||
698 | #define TPS65910_IRQ_PWRHOLD 4 | ||
699 | #define TPS65910_IRQ_HOTDIE 5 | ||
700 | #define TPS65910_IRQ_RTC_ALARM 6 | ||
701 | #define TPS65910_IRQ_RTC_PERIOD 7 | ||
702 | #define TPS65910_IRQ_GPIO_R 8 | ||
703 | #define TPS65910_IRQ_GPIO_F 9 | ||
704 | #define TPS65910_NUM_IRQ 10 | ||
705 | |||
706 | #define TPS65911_IRQ_VBAT_VMBDCH 0 | ||
707 | #define TPS65911_IRQ_VBAT_VMBDCH2L 1 | ||
708 | #define TPS65911_IRQ_VBAT_VMBDCH2H 2 | ||
709 | #define TPS65911_IRQ_VBAT_VMHI 3 | ||
710 | #define TPS65911_IRQ_PWRON 4 | ||
711 | #define TPS65911_IRQ_PWRON_LP 5 | ||
712 | #define TPS65911_IRQ_PWRHOLD_F 6 | ||
713 | #define TPS65911_IRQ_PWRHOLD_R 7 | ||
714 | #define TPS65911_IRQ_HOTDIE 8 | ||
715 | #define TPS65911_IRQ_RTC_ALARM 9 | ||
716 | #define TPS65911_IRQ_RTC_PERIOD 10 | ||
717 | #define TPS65911_IRQ_GPIO0_R 11 | ||
718 | #define TPS65911_IRQ_GPIO0_F 12 | ||
719 | #define TPS65911_IRQ_GPIO1_R 13 | ||
720 | #define TPS65911_IRQ_GPIO1_F 14 | ||
721 | #define TPS65911_IRQ_GPIO2_R 15 | ||
722 | #define TPS65911_IRQ_GPIO2_F 16 | ||
723 | #define TPS65911_IRQ_GPIO3_R 17 | ||
724 | #define TPS65911_IRQ_GPIO3_F 18 | ||
725 | #define TPS65911_IRQ_GPIO4_R 19 | ||
726 | #define TPS65911_IRQ_GPIO4_F 20 | ||
727 | #define TPS65911_IRQ_GPIO5_R 21 | ||
728 | #define TPS65911_IRQ_GPIO5_F 22 | ||
729 | #define TPS65911_IRQ_WTCHDG 23 | ||
730 | #define TPS65911_IRQ_PWRDN 24 | ||
731 | |||
732 | #define TPS65911_NUM_IRQ 25 | ||
733 | |||
734 | |||
735 | /* GPIO Register Definitions */ | ||
736 | #define TPS65910_GPIO_DEB BIT(2) | ||
737 | #define TPS65910_GPIO_PUEN BIT(3) | ||
738 | #define TPS65910_GPIO_CFG BIT(2) | ||
739 | #define TPS65910_GPIO_STS BIT(1) | ||
740 | #define TPS65910_GPIO_SET BIT(0) | ||
741 | |||
742 | /** | ||
743 | * struct tps65910_board | ||
744 | * Board platform data may be used to initialize regulators. | ||
745 | */ | ||
746 | |||
747 | struct tps65910_board { | ||
748 | int gpio_base; | ||
749 | int irq; | ||
750 | int irq_base; | ||
751 | int vmbch_threshold; | ||
752 | int vmbch2_threshold; | ||
753 | struct regulator_init_data *tps65910_pmic_init_data; | ||
754 | }; | ||
755 | |||
756 | /** | ||
757 | * struct tps65910 - tps65910 sub-driver chip access routines | ||
758 | */ | ||
759 | |||
760 | struct tps65910 { | ||
761 | struct device *dev; | ||
762 | struct i2c_client *i2c_client; | ||
763 | struct mutex io_mutex; | ||
764 | unsigned int id; | ||
765 | int (*read)(struct tps65910 *tps65910, u8 reg, int size, void *dest); | ||
766 | int (*write)(struct tps65910 *tps65910, u8 reg, int size, void *src); | ||
767 | |||
768 | /* Client devices */ | ||
769 | struct tps65910_pmic *pmic; | ||
770 | struct tps65910_rtc *rtc; | ||
771 | struct tps65910_power *power; | ||
772 | |||
773 | /* GPIO Handling */ | ||
774 | struct gpio_chip gpio; | ||
775 | |||
776 | /* IRQ Handling */ | ||
777 | struct mutex irq_lock; | ||
778 | int chip_irq; | ||
779 | int irq_base; | ||
780 | int irq_num; | ||
781 | u32 irq_mask; | ||
782 | }; | ||
783 | |||
784 | struct tps65910_platform_data { | ||
785 | int irq; | ||
786 | int irq_base; | ||
787 | }; | ||
788 | |||
789 | int tps65910_set_bits(struct tps65910 *tps65910, u8 reg, u8 mask); | ||
790 | int tps65910_clear_bits(struct tps65910 *tps65910, u8 reg, u8 mask); | ||
791 | void tps65910_gpio_init(struct tps65910 *tps65910, int gpio_base); | ||
792 | int tps65910_irq_init(struct tps65910 *tps65910, int irq, | ||
793 | struct tps65910_platform_data *pdata); | ||
794 | |||
795 | static inline int tps65910_chip_id(struct tps65910 *tps65910) | ||
796 | { | ||
797 | return tps65910->id; | ||
798 | } | ||
799 | |||
800 | #endif /* __LINUX_MFD_TPS65910_H */ | ||
diff --git a/include/linux/regulator/machine.h b/include/linux/regulator/machine.h index c4c4fc45f856..ce3127a75c88 100644 --- a/include/linux/regulator/machine.h +++ b/include/linux/regulator/machine.h | |||
@@ -68,6 +68,8 @@ struct regulator_state { | |||
68 | * | 68 | * |
69 | * @min_uV: Smallest voltage consumers may set. | 69 | * @min_uV: Smallest voltage consumers may set. |
70 | * @max_uV: Largest voltage consumers may set. | 70 | * @max_uV: Largest voltage consumers may set. |
71 | * @uV_offset: Offset applied to voltages from consumer to compensate for | ||
72 | * voltage drops. | ||
71 | * | 73 | * |
72 | * @min_uA: Smallest consumers consumers may set. | 74 | * @min_uA: Smallest consumers consumers may set. |
73 | * @max_uA: Largest current consumers may set. | 75 | * @max_uA: Largest current consumers may set. |
@@ -99,6 +101,8 @@ struct regulation_constraints { | |||
99 | int min_uV; | 101 | int min_uV; |
100 | int max_uV; | 102 | int max_uV; |
101 | 103 | ||
104 | int uV_offset; | ||
105 | |||
102 | /* current output range (inclusive) - for current control */ | 106 | /* current output range (inclusive) - for current control */ |
103 | int min_uA; | 107 | int min_uA; |
104 | int max_uA; | 108 | int max_uA; |
@@ -160,8 +164,6 @@ struct regulator_consumer_supply { | |||
160 | * @supply_regulator: Parent regulator. Specified using the regulator name | 164 | * @supply_regulator: Parent regulator. Specified using the regulator name |
161 | * as it appears in the name field in sysfs, which can | 165 | * as it appears in the name field in sysfs, which can |
162 | * be explicitly set using the constraints field 'name'. | 166 | * be explicitly set using the constraints field 'name'. |
163 | * @supply_regulator_dev: Parent regulator (if any) - DEPRECATED in favour | ||
164 | * of supply_regulator. | ||
165 | * | 167 | * |
166 | * @constraints: Constraints. These must be specified for the regulator to | 168 | * @constraints: Constraints. These must be specified for the regulator to |
167 | * be usable. | 169 | * be usable. |
@@ -173,7 +175,6 @@ struct regulator_consumer_supply { | |||
173 | */ | 175 | */ |
174 | struct regulator_init_data { | 176 | struct regulator_init_data { |
175 | const char *supply_regulator; /* or NULL for system supply */ | 177 | const char *supply_regulator; /* or NULL for system supply */ |
176 | struct device *supply_regulator_dev; /* or NULL for system supply */ | ||
177 | 178 | ||
178 | struct regulation_constraints constraints; | 179 | struct regulation_constraints constraints; |
179 | 180 | ||