diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2014-01-21 13:58:17 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-01-21 13:58:17 -0500 |
commit | ac26663572db5b64522b92f3941a58678a832a36 (patch) | |
tree | 3a8d27153de37cb3f3fb0ff6843a1e727c961005 /drivers | |
parent | d4371f94bc003e912d4825f5c4bdf57959857073 (diff) | |
parent | 02915661dbb91b25b621ab3f387ab55311bded7f (diff) |
Merge tag 'mfd-3.14-1' of git://git.linaro.org/people/ljones/mfd
Pull MFD changes from Lee Jones:
"New drivers
- Samsung Maxim 14577; Micro USB, Regulator, IRQ Controller and
Battery Charger
- TI/National Semiconductor LP3943 I2C GPIO Expander and PWM
Generator
Existing driver adaptions
- Expansion of Wolfson Arizona DSP and High-Pass filter controls
- TI TWL6040 default Regmap support and Regcache addition/bypass
- Some nice Smatch catch fixes
- Conversion of TI OMAP-USB and TI TWL6030 to endian neutralness
- ChromeOS EC timing (delay) adaptions and added dependency on OF
- Many constifications of 'struct {mfd_cell,regmap_irq,et.al}'
- Watchdog support added for NVIDIA AS3722
- Convert functions to static in TI AM335x
- Realigned previously defeated functionality in TI AM335x
- IIO ADC-TSC concurrency dead-lock/timeout resolution
- Addition of Power Management and Clock support for Samsung core
- DEFINE_PCI_DEVICE_TABLE macro removal from MFD Subsystem
- Greater use of irqdomain functionality in ST-E AB8500
- Removal of 'include/linux/mfd/abx500/ab8500-gpio.h'
- Wolfson WM831x PMIC Power Management changes s/poweroff/shutdown/
- Device Tree documentation added for TI/Nat Semi LP3943
- Version detection and voltage tables for TI TPS6586x PMIC devices
- Simplification of Freescale MC13XXX (de-)initialisation routines
- Clean-up and simplification of the Realtek parent driver
- Added support for RTL8402 Realtek PCI-Express card reader
- Resource leak fix for Maxim 77686
- Possible suspend BUG() fix in OMAP USB TLL
- Support for new Wolfson WM5110 Revision (D)
- Testing of automatic assignment of of_node in mfd_add_device()
- Reversion of the above when it started to cause issues
- Remove legacy Platform Data from;
TI TWL Core, Qualcomm SSBI and ST-E ABx500 Pinctrl
- Clean-ups; tabbing issues, function name changes, 'drvdata = NULL'
removal, unused uninitialised warning mitigation, error
message clarity, removal of redundant/duplicate checks,
licensing (GPL -> GPL2), coding consistency, duplicate
function declaration, ret checks, commit corrections,
redundant of_match_ptr() helper removal, spelling,
#if-deffery removal and header guards name changes"
* tag 'mfd-3.14-1' of git://git.linaro.org/people/ljones/mfd: (78 commits)
mfd: wm5110: Add register patch for rev D chip
mfd: omap-usb-tll: Don't hold lock during pm_runtime_get/put_sync()
gpio: lp3943: Remove redundant of_match_ptr helper
mfd: sta2x11-mfd: Use named constants for pci_power_t values
Documentation: mfd: Fix LDO index in s2mps11.txt
mfd: Cleanup mfd-mcp-sa11x0.h header
mfd: max8997: Use "IS_ENABLED(CONFIG_OF)" for DT code.
mfd: twl6030: Fix endianness problem in IRQ handler
mfd: sec-core: Add cells for S5M8767-clocks
mfd: max14577: Remove redundant of_match_ptr helper
mfd: twl6040: Fix sparse non static symbol warning
mfd: Revert "mfd: Always assign of_node in mfd_add_device()"
mfd: rtsx: Fix sparse non static symbol warning
mfd: max77693: Set proper maximum register for MUIC regmap
mfd: max77686: Fix regmap resource leak on driver remove
mfd: Represent correct filenames in file headers
mfd: rtsx: Add support for card reader rtl8402
mfd: rtsx: Add set pull control macro and simplify rtl8411
mfd: max8997: Enforce mfd_add_devices() return value check
mfd: mc13xxx: Simplify probe() & remove()
...
Diffstat (limited to 'drivers')
86 files changed, 1669 insertions, 586 deletions
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index 25ce03eff6ab..50cc557abe41 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig | |||
@@ -406,6 +406,14 @@ config GPIO_ARIZONA | |||
406 | help | 406 | help |
407 | Support for GPIOs on Wolfson Arizona class devices. | 407 | Support for GPIOs on Wolfson Arizona class devices. |
408 | 408 | ||
409 | config GPIO_LP3943 | ||
410 | tristate "TI/National Semiconductor LP3943 GPIO expander" | ||
411 | depends on MFD_LP3943 | ||
412 | help | ||
413 | GPIO driver for LP3943 MFD. | ||
414 | LP3943 can be used as a GPIO expander which provides up to 16 GPIOs. | ||
415 | Open drain outputs are required for this usage. | ||
416 | |||
409 | config GPIO_MAX7300 | 417 | config GPIO_MAX7300 |
410 | tristate "Maxim MAX7300 GPIO expander" | 418 | tristate "Maxim MAX7300 GPIO expander" |
411 | depends on I2C | 419 | depends on I2C |
diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile index c44fffac9519..0248471402e4 100644 --- a/drivers/gpio/Makefile +++ b/drivers/gpio/Makefile | |||
@@ -35,6 +35,7 @@ obj-$(CONFIG_GPIO_JANZ_TTL) += gpio-janz-ttl.o | |||
35 | obj-$(CONFIG_GPIO_KEMPLD) += gpio-kempld.o | 35 | obj-$(CONFIG_GPIO_KEMPLD) += gpio-kempld.o |
36 | obj-$(CONFIG_ARCH_KS8695) += gpio-ks8695.o | 36 | obj-$(CONFIG_ARCH_KS8695) += gpio-ks8695.o |
37 | obj-$(CONFIG_GPIO_INTEL_MID) += gpio-intel-mid.o | 37 | obj-$(CONFIG_GPIO_INTEL_MID) += gpio-intel-mid.o |
38 | obj-$(CONFIG_GPIO_LP3943) += gpio-lp3943.o | ||
38 | obj-$(CONFIG_ARCH_LPC32XX) += gpio-lpc32xx.o | 39 | obj-$(CONFIG_ARCH_LPC32XX) += gpio-lpc32xx.o |
39 | obj-$(CONFIG_GPIO_LYNXPOINT) += gpio-lynxpoint.o | 40 | obj-$(CONFIG_GPIO_LYNXPOINT) += gpio-lynxpoint.o |
40 | obj-$(CONFIG_GPIO_MAX730X) += gpio-max730x.o | 41 | obj-$(CONFIG_GPIO_MAX730X) += gpio-max730x.o |
diff --git a/drivers/gpio/gpio-lp3943.c b/drivers/gpio/gpio-lp3943.c new file mode 100644 index 000000000000..a0341c92bcb4 --- /dev/null +++ b/drivers/gpio/gpio-lp3943.c | |||
@@ -0,0 +1,242 @@ | |||
1 | /* | ||
2 | * TI/National Semiconductor LP3943 GPIO driver | ||
3 | * | ||
4 | * Copyright 2013 Texas Instruments | ||
5 | * | ||
6 | * Author: Milo Kim <milo.kim@ti.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation; version 2. | ||
11 | */ | ||
12 | |||
13 | #include <linux/bitops.h> | ||
14 | #include <linux/err.h> | ||
15 | #include <linux/gpio.h> | ||
16 | #include <linux/i2c.h> | ||
17 | #include <linux/mfd/lp3943.h> | ||
18 | #include <linux/module.h> | ||
19 | #include <linux/platform_device.h> | ||
20 | #include <linux/slab.h> | ||
21 | |||
22 | enum lp3943_gpios { | ||
23 | LP3943_GPIO1, | ||
24 | LP3943_GPIO2, | ||
25 | LP3943_GPIO3, | ||
26 | LP3943_GPIO4, | ||
27 | LP3943_GPIO5, | ||
28 | LP3943_GPIO6, | ||
29 | LP3943_GPIO7, | ||
30 | LP3943_GPIO8, | ||
31 | LP3943_GPIO9, | ||
32 | LP3943_GPIO10, | ||
33 | LP3943_GPIO11, | ||
34 | LP3943_GPIO12, | ||
35 | LP3943_GPIO13, | ||
36 | LP3943_GPIO14, | ||
37 | LP3943_GPIO15, | ||
38 | LP3943_GPIO16, | ||
39 | LP3943_MAX_GPIO, | ||
40 | }; | ||
41 | |||
42 | struct lp3943_gpio { | ||
43 | struct gpio_chip chip; | ||
44 | struct lp3943 *lp3943; | ||
45 | u16 input_mask; /* 1 = GPIO is input direction, 0 = output */ | ||
46 | }; | ||
47 | |||
48 | static inline struct lp3943_gpio *to_lp3943_gpio(struct gpio_chip *_chip) | ||
49 | { | ||
50 | return container_of(_chip, struct lp3943_gpio, chip); | ||
51 | } | ||
52 | |||
53 | static int lp3943_gpio_request(struct gpio_chip *chip, unsigned offset) | ||
54 | { | ||
55 | struct lp3943_gpio *lp3943_gpio = to_lp3943_gpio(chip); | ||
56 | struct lp3943 *lp3943 = lp3943_gpio->lp3943; | ||
57 | |||
58 | /* Return an error if the pin is already assigned */ | ||
59 | if (test_and_set_bit(offset, &lp3943->pin_used)) | ||
60 | return -EBUSY; | ||
61 | |||
62 | return 0; | ||
63 | } | ||
64 | |||
65 | static void lp3943_gpio_free(struct gpio_chip *chip, unsigned offset) | ||
66 | { | ||
67 | struct lp3943_gpio *lp3943_gpio = to_lp3943_gpio(chip); | ||
68 | struct lp3943 *lp3943 = lp3943_gpio->lp3943; | ||
69 | |||
70 | clear_bit(offset, &lp3943->pin_used); | ||
71 | } | ||
72 | |||
73 | static int lp3943_gpio_set_mode(struct lp3943_gpio *lp3943_gpio, u8 offset, | ||
74 | u8 val) | ||
75 | { | ||
76 | struct lp3943 *lp3943 = lp3943_gpio->lp3943; | ||
77 | const struct lp3943_reg_cfg *mux = lp3943->mux_cfg; | ||
78 | |||
79 | return lp3943_update_bits(lp3943, mux[offset].reg, mux[offset].mask, | ||
80 | val << mux[offset].shift); | ||
81 | } | ||
82 | |||
83 | static int lp3943_gpio_direction_input(struct gpio_chip *chip, unsigned offset) | ||
84 | { | ||
85 | struct lp3943_gpio *lp3943_gpio = to_lp3943_gpio(chip); | ||
86 | |||
87 | lp3943_gpio->input_mask |= BIT(offset); | ||
88 | |||
89 | return lp3943_gpio_set_mode(lp3943_gpio, offset, LP3943_GPIO_IN); | ||
90 | } | ||
91 | |||
92 | static int lp3943_get_gpio_in_status(struct lp3943_gpio *lp3943_gpio, | ||
93 | struct gpio_chip *chip, unsigned offset) | ||
94 | { | ||
95 | u8 addr, read; | ||
96 | int err; | ||
97 | |||
98 | switch (offset) { | ||
99 | case LP3943_GPIO1 ... LP3943_GPIO8: | ||
100 | addr = LP3943_REG_GPIO_A; | ||
101 | break; | ||
102 | case LP3943_GPIO9 ... LP3943_GPIO16: | ||
103 | addr = LP3943_REG_GPIO_B; | ||
104 | offset = offset - 8; | ||
105 | break; | ||
106 | default: | ||
107 | return -EINVAL; | ||
108 | } | ||
109 | |||
110 | err = lp3943_read_byte(lp3943_gpio->lp3943, addr, &read); | ||
111 | if (err) | ||
112 | return err; | ||
113 | |||
114 | return !!(read & BIT(offset)); | ||
115 | } | ||
116 | |||
117 | static int lp3943_get_gpio_out_status(struct lp3943_gpio *lp3943_gpio, | ||
118 | struct gpio_chip *chip, unsigned offset) | ||
119 | { | ||
120 | struct lp3943 *lp3943 = lp3943_gpio->lp3943; | ||
121 | const struct lp3943_reg_cfg *mux = lp3943->mux_cfg; | ||
122 | u8 read; | ||
123 | int err; | ||
124 | |||
125 | err = lp3943_read_byte(lp3943, mux[offset].reg, &read); | ||
126 | if (err) | ||
127 | return err; | ||
128 | |||
129 | read = (read & mux[offset].mask) >> mux[offset].shift; | ||
130 | |||
131 | if (read == LP3943_GPIO_OUT_HIGH) | ||
132 | return 1; | ||
133 | else if (read == LP3943_GPIO_OUT_LOW) | ||
134 | return 0; | ||
135 | else | ||
136 | return -EINVAL; | ||
137 | } | ||
138 | |||
139 | static int lp3943_gpio_get(struct gpio_chip *chip, unsigned offset) | ||
140 | { | ||
141 | struct lp3943_gpio *lp3943_gpio = to_lp3943_gpio(chip); | ||
142 | |||
143 | /* | ||
144 | * Limitation: | ||
145 | * LP3943 doesn't have the GPIO direction register. It provides | ||
146 | * only input and output status registers. | ||
147 | * So, direction info is required to handle the 'get' operation. | ||
148 | * This variable is updated whenever the direction is changed and | ||
149 | * it is used here. | ||
150 | */ | ||
151 | |||
152 | if (lp3943_gpio->input_mask & BIT(offset)) | ||
153 | return lp3943_get_gpio_in_status(lp3943_gpio, chip, offset); | ||
154 | else | ||
155 | return lp3943_get_gpio_out_status(lp3943_gpio, chip, offset); | ||
156 | } | ||
157 | |||
158 | static void lp3943_gpio_set(struct gpio_chip *chip, unsigned offset, int value) | ||
159 | { | ||
160 | struct lp3943_gpio *lp3943_gpio = to_lp3943_gpio(chip); | ||
161 | u8 data; | ||
162 | |||
163 | if (value) | ||
164 | data = LP3943_GPIO_OUT_HIGH; | ||
165 | else | ||
166 | data = LP3943_GPIO_OUT_LOW; | ||
167 | |||
168 | lp3943_gpio_set_mode(lp3943_gpio, offset, data); | ||
169 | } | ||
170 | |||
171 | static int lp3943_gpio_direction_output(struct gpio_chip *chip, unsigned offset, | ||
172 | int value) | ||
173 | { | ||
174 | struct lp3943_gpio *lp3943_gpio = to_lp3943_gpio(chip); | ||
175 | |||
176 | lp3943_gpio_set(chip, offset, value); | ||
177 | lp3943_gpio->input_mask &= ~BIT(offset); | ||
178 | |||
179 | return 0; | ||
180 | } | ||
181 | |||
182 | static const struct gpio_chip lp3943_gpio_chip = { | ||
183 | .label = "lp3943", | ||
184 | .owner = THIS_MODULE, | ||
185 | .request = lp3943_gpio_request, | ||
186 | .free = lp3943_gpio_free, | ||
187 | .direction_input = lp3943_gpio_direction_input, | ||
188 | .get = lp3943_gpio_get, | ||
189 | .direction_output = lp3943_gpio_direction_output, | ||
190 | .set = lp3943_gpio_set, | ||
191 | .base = -1, | ||
192 | .ngpio = LP3943_MAX_GPIO, | ||
193 | .can_sleep = 1, | ||
194 | }; | ||
195 | |||
196 | static int lp3943_gpio_probe(struct platform_device *pdev) | ||
197 | { | ||
198 | struct lp3943 *lp3943 = dev_get_drvdata(pdev->dev.parent); | ||
199 | struct lp3943_gpio *lp3943_gpio; | ||
200 | |||
201 | lp3943_gpio = devm_kzalloc(&pdev->dev, sizeof(*lp3943_gpio), | ||
202 | GFP_KERNEL); | ||
203 | if (!lp3943_gpio) | ||
204 | return -ENOMEM; | ||
205 | |||
206 | lp3943_gpio->lp3943 = lp3943; | ||
207 | lp3943_gpio->chip = lp3943_gpio_chip; | ||
208 | lp3943_gpio->chip.dev = &pdev->dev; | ||
209 | |||
210 | platform_set_drvdata(pdev, lp3943_gpio); | ||
211 | |||
212 | return gpiochip_add(&lp3943_gpio->chip); | ||
213 | } | ||
214 | |||
215 | static int lp3943_gpio_remove(struct platform_device *pdev) | ||
216 | { | ||
217 | struct lp3943_gpio *lp3943_gpio = platform_get_drvdata(pdev); | ||
218 | |||
219 | return gpiochip_remove(&lp3943_gpio->chip); | ||
220 | } | ||
221 | |||
222 | static const struct of_device_id lp3943_gpio_of_match[] = { | ||
223 | { .compatible = "ti,lp3943-gpio", }, | ||
224 | { } | ||
225 | }; | ||
226 | MODULE_DEVICE_TABLE(of, lp3943_gpio_of_match); | ||
227 | |||
228 | static struct platform_driver lp3943_gpio_driver = { | ||
229 | .probe = lp3943_gpio_probe, | ||
230 | .remove = lp3943_gpio_remove, | ||
231 | .driver = { | ||
232 | .name = "lp3943-gpio", | ||
233 | .owner = THIS_MODULE, | ||
234 | .of_match_table = lp3943_gpio_of_match, | ||
235 | }, | ||
236 | }; | ||
237 | module_platform_driver(lp3943_gpio_driver); | ||
238 | |||
239 | MODULE_DESCRIPTION("LP3943 GPIO driver"); | ||
240 | MODULE_ALIAS("platform:lp3943-gpio"); | ||
241 | MODULE_AUTHOR("Milo Kim"); | ||
242 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c index d4d748214e4b..31e786e3999b 100644 --- a/drivers/iio/adc/ti_am335x_adc.c +++ b/drivers/iio/adc/ti_am335x_adc.c | |||
@@ -60,6 +60,24 @@ static u32 get_adc_step_mask(struct tiadc_device *adc_dev) | |||
60 | return step_en; | 60 | return step_en; |
61 | } | 61 | } |
62 | 62 | ||
63 | static u32 get_adc_chan_step_mask(struct tiadc_device *adc_dev, | ||
64 | struct iio_chan_spec const *chan) | ||
65 | { | ||
66 | int i; | ||
67 | |||
68 | for (i = 0; i < ARRAY_SIZE(adc_dev->channel_step); i++) { | ||
69 | if (chan->channel == adc_dev->channel_line[i]) { | ||
70 | u32 step; | ||
71 | |||
72 | step = adc_dev->channel_step[i]; | ||
73 | /* +1 for the charger */ | ||
74 | return 1 << (step + 1); | ||
75 | } | ||
76 | } | ||
77 | WARN_ON(1); | ||
78 | return 0; | ||
79 | } | ||
80 | |||
63 | static u32 get_adc_step_bit(struct tiadc_device *adc_dev, int chan) | 81 | static u32 get_adc_step_bit(struct tiadc_device *adc_dev, int chan) |
64 | { | 82 | { |
65 | return 1 << adc_dev->channel_step[chan]; | 83 | return 1 << adc_dev->channel_step[chan]; |
@@ -181,7 +199,7 @@ static int tiadc_buffer_postenable(struct iio_dev *indio_dev) | |||
181 | enb |= (get_adc_step_bit(adc_dev, bit) << 1); | 199 | enb |= (get_adc_step_bit(adc_dev, bit) << 1); |
182 | adc_dev->buffer_en_ch_steps = enb; | 200 | adc_dev->buffer_en_ch_steps = enb; |
183 | 201 | ||
184 | am335x_tsc_se_set(adc_dev->mfd_tscadc, enb); | 202 | am335x_tsc_se_set_cache(adc_dev->mfd_tscadc, enb); |
185 | 203 | ||
186 | tiadc_writel(adc_dev, REG_IRQSTATUS, IRQENB_FIFO1THRES | 204 | tiadc_writel(adc_dev, REG_IRQSTATUS, IRQENB_FIFO1THRES |
187 | | IRQENB_FIFO1OVRRUN | IRQENB_FIFO1UNDRFLW); | 205 | | IRQENB_FIFO1OVRRUN | IRQENB_FIFO1UNDRFLW); |
@@ -199,6 +217,7 @@ static int tiadc_buffer_predisable(struct iio_dev *indio_dev) | |||
199 | tiadc_writel(adc_dev, REG_IRQCLR, (IRQENB_FIFO1THRES | | 217 | tiadc_writel(adc_dev, REG_IRQCLR, (IRQENB_FIFO1THRES | |
200 | IRQENB_FIFO1OVRRUN | IRQENB_FIFO1UNDRFLW)); | 218 | IRQENB_FIFO1OVRRUN | IRQENB_FIFO1UNDRFLW)); |
201 | am335x_tsc_se_clr(adc_dev->mfd_tscadc, adc_dev->buffer_en_ch_steps); | 219 | am335x_tsc_se_clr(adc_dev->mfd_tscadc, adc_dev->buffer_en_ch_steps); |
220 | adc_dev->buffer_en_ch_steps = 0; | ||
202 | 221 | ||
203 | /* Flush FIFO of leftover data in the time it takes to disable adc */ | 222 | /* Flush FIFO of leftover data in the time it takes to disable adc */ |
204 | fifo1count = tiadc_readl(adc_dev, REG_FIFO1CNT); | 223 | fifo1count = tiadc_readl(adc_dev, REG_FIFO1CNT); |
@@ -328,34 +347,43 @@ static int tiadc_read_raw(struct iio_dev *indio_dev, | |||
328 | unsigned int fifo1count, read, stepid; | 347 | unsigned int fifo1count, read, stepid; |
329 | bool found = false; | 348 | bool found = false; |
330 | u32 step_en; | 349 | u32 step_en; |
331 | unsigned long timeout = jiffies + usecs_to_jiffies | 350 | unsigned long timeout; |
332 | (IDLE_TIMEOUT * adc_dev->channels); | ||
333 | 351 | ||
334 | if (iio_buffer_enabled(indio_dev)) | 352 | if (iio_buffer_enabled(indio_dev)) |
335 | return -EBUSY; | 353 | return -EBUSY; |
336 | 354 | ||
337 | step_en = get_adc_step_mask(adc_dev); | 355 | step_en = get_adc_chan_step_mask(adc_dev, chan); |
338 | am335x_tsc_se_set(adc_dev->mfd_tscadc, step_en); | 356 | if (!step_en) |
357 | return -EINVAL; | ||
358 | |||
359 | fifo1count = tiadc_readl(adc_dev, REG_FIFO1CNT); | ||
360 | while (fifo1count--) | ||
361 | tiadc_readl(adc_dev, REG_FIFO1); | ||
362 | |||
363 | am335x_tsc_se_set_once(adc_dev->mfd_tscadc, step_en); | ||
339 | 364 | ||
340 | /* Wait for ADC sequencer to complete sampling */ | 365 | timeout = jiffies + usecs_to_jiffies |
341 | while (tiadc_readl(adc_dev, REG_ADCFSM) & SEQ_STATUS) { | 366 | (IDLE_TIMEOUT * adc_dev->channels); |
342 | if (time_after(jiffies, timeout)) | 367 | /* Wait for Fifo threshold interrupt */ |
368 | while (1) { | ||
369 | fifo1count = tiadc_readl(adc_dev, REG_FIFO1CNT); | ||
370 | if (fifo1count) | ||
371 | break; | ||
372 | |||
373 | if (time_after(jiffies, timeout)) { | ||
374 | am335x_tsc_se_adc_done(adc_dev->mfd_tscadc); | ||
343 | return -EAGAIN; | 375 | return -EAGAIN; |
344 | } | 376 | } |
377 | } | ||
345 | map_val = chan->channel + TOTAL_CHANNELS; | 378 | map_val = chan->channel + TOTAL_CHANNELS; |
346 | 379 | ||
347 | /* | 380 | /* |
348 | * When the sub-system is first enabled, | 381 | * We check the complete FIFO. We programmed just one entry but in case |
349 | * the sequencer will always start with the | 382 | * something went wrong we left empty handed (-EAGAIN previously) and |
350 | * lowest step (1) and continue until step (16). | 383 | * then the value apeared somehow in the FIFO we would have two entries. |
351 | * For ex: If we have enabled 4 ADC channels and | 384 | * Therefore we read every item and keep only the latest version of the |
352 | * currently use only 1 out of them, the | 385 | * requested channel. |
353 | * sequencer still configures all the 4 steps, | ||
354 | * leading to 3 unwanted data. | ||
355 | * Hence we need to flush out this data. | ||
356 | */ | 386 | */ |
357 | |||
358 | fifo1count = tiadc_readl(adc_dev, REG_FIFO1CNT); | ||
359 | for (i = 0; i < fifo1count; i++) { | 387 | for (i = 0; i < fifo1count; i++) { |
360 | read = tiadc_readl(adc_dev, REG_FIFO1); | 388 | read = tiadc_readl(adc_dev, REG_FIFO1); |
361 | stepid = read & FIFOREAD_CHNLID_MASK; | 389 | stepid = read & FIFOREAD_CHNLID_MASK; |
@@ -367,6 +395,7 @@ static int tiadc_read_raw(struct iio_dev *indio_dev, | |||
367 | *val = (u16) read; | 395 | *val = (u16) read; |
368 | } | 396 | } |
369 | } | 397 | } |
398 | am335x_tsc_se_adc_done(adc_dev->mfd_tscadc); | ||
370 | 399 | ||
371 | if (found == false) | 400 | if (found == false) |
372 | return -EBUSY; | 401 | return -EBUSY; |
@@ -494,7 +523,8 @@ static int tiadc_resume(struct device *dev) | |||
494 | tiadc_writel(adc_dev, REG_CTRL, restore); | 523 | tiadc_writel(adc_dev, REG_CTRL, restore); |
495 | 524 | ||
496 | tiadc_step_config(indio_dev); | 525 | tiadc_step_config(indio_dev); |
497 | 526 | am335x_tsc_se_set_cache(adc_dev->mfd_tscadc, | |
527 | adc_dev->buffer_en_ch_steps); | ||
498 | return 0; | 528 | return 0; |
499 | } | 529 | } |
500 | 530 | ||
diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig index 5f4967d01bc3..e2413acbbb16 100644 --- a/drivers/input/misc/Kconfig +++ b/drivers/input/misc/Kconfig | |||
@@ -168,7 +168,7 @@ config INPUT_MAX8997_HAPTIC | |||
168 | 168 | ||
169 | config INPUT_MC13783_PWRBUTTON | 169 | config INPUT_MC13783_PWRBUTTON |
170 | tristate "MC13783 ON buttons" | 170 | tristate "MC13783 ON buttons" |
171 | depends on MFD_MC13783 | 171 | depends on MFD_MC13XXX |
172 | help | 172 | help |
173 | Support the ON buttons of MC13783 PMIC as an input device | 173 | Support the ON buttons of MC13783 PMIC as an input device |
174 | reporting power button status. | 174 | reporting power button status. |
diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig index 961d58d32647..07e9e82029d1 100644 --- a/drivers/input/touchscreen/Kconfig +++ b/drivers/input/touchscreen/Kconfig | |||
@@ -717,7 +717,7 @@ config TOUCHSCREEN_USB_COMPOSITE | |||
717 | 717 | ||
718 | config TOUCHSCREEN_MC13783 | 718 | config TOUCHSCREEN_MC13783 |
719 | tristate "Freescale MC13783 touchscreen input driver" | 719 | tristate "Freescale MC13783 touchscreen input driver" |
720 | depends on MFD_MC13783 | 720 | depends on MFD_MC13XXX |
721 | help | 721 | help |
722 | Say Y here if you have an Freescale MC13783 PMIC on your | 722 | Say Y here if you have an Freescale MC13783 PMIC on your |
723 | board and want to use its touchscreen | 723 | board and want to use its touchscreen |
diff --git a/drivers/input/touchscreen/ti_am335x_tsc.c b/drivers/input/touchscreen/ti_am335x_tsc.c index 68beadaabceb..2ca5a7bee04e 100644 --- a/drivers/input/touchscreen/ti_am335x_tsc.c +++ b/drivers/input/touchscreen/ti_am335x_tsc.c | |||
@@ -198,7 +198,7 @@ static void titsc_step_config(struct titsc *ts_dev) | |||
198 | /* The steps1 … end and bit 0 for TS_Charge */ | 198 | /* The steps1 … end and bit 0 for TS_Charge */ |
199 | stepenable = (1 << (end_step + 2)) - 1; | 199 | stepenable = (1 << (end_step + 2)) - 1; |
200 | ts_dev->step_mask = stepenable; | 200 | ts_dev->step_mask = stepenable; |
201 | am335x_tsc_se_set(ts_dev->mfd_tscadc, ts_dev->step_mask); | 201 | am335x_tsc_se_set_cache(ts_dev->mfd_tscadc, ts_dev->step_mask); |
202 | } | 202 | } |
203 | 203 | ||
204 | static void titsc_read_coordinates(struct titsc *ts_dev, | 204 | static void titsc_read_coordinates(struct titsc *ts_dev, |
@@ -322,7 +322,7 @@ static irqreturn_t titsc_irq(int irq, void *dev) | |||
322 | 322 | ||
323 | if (irqclr) { | 323 | if (irqclr) { |
324 | titsc_writel(ts_dev, REG_IRQSTATUS, irqclr); | 324 | titsc_writel(ts_dev, REG_IRQSTATUS, irqclr); |
325 | am335x_tsc_se_set(ts_dev->mfd_tscadc, ts_dev->step_mask); | 325 | am335x_tsc_se_set_cache(ts_dev->mfd_tscadc, ts_dev->step_mask); |
326 | return IRQ_HANDLED; | 326 | return IRQ_HANDLED; |
327 | } | 327 | } |
328 | return IRQ_NONE; | 328 | return IRQ_NONE; |
diff --git a/drivers/mfd/88pm800.c b/drivers/mfd/88pm800.c index a65447d65605..7dca1e640970 100644 --- a/drivers/mfd/88pm800.c +++ b/drivers/mfd/88pm800.c | |||
@@ -148,7 +148,7 @@ static struct resource onkey_resources[] = { | |||
148 | }, | 148 | }, |
149 | }; | 149 | }; |
150 | 150 | ||
151 | static struct mfd_cell onkey_devs[] = { | 151 | static const struct mfd_cell onkey_devs[] = { |
152 | { | 152 | { |
153 | .name = "88pm80x-onkey", | 153 | .name = "88pm80x-onkey", |
154 | .num_resources = 1, | 154 | .num_resources = 1, |
@@ -157,7 +157,7 @@ static struct mfd_cell onkey_devs[] = { | |||
157 | }, | 157 | }, |
158 | }; | 158 | }; |
159 | 159 | ||
160 | static struct mfd_cell regulator_devs[] = { | 160 | static const struct mfd_cell regulator_devs[] = { |
161 | { | 161 | { |
162 | .name = "88pm80x-regulator", | 162 | .name = "88pm80x-regulator", |
163 | .id = -1, | 163 | .id = -1, |
diff --git a/drivers/mfd/88pm805.c b/drivers/mfd/88pm805.c index 8a5b6ffb5afb..64751c2a1ace 100644 --- a/drivers/mfd/88pm805.c +++ b/drivers/mfd/88pm805.c | |||
@@ -77,7 +77,7 @@ static struct resource codec_resources[] = { | |||
77 | }, | 77 | }, |
78 | }; | 78 | }; |
79 | 79 | ||
80 | static struct mfd_cell codec_devs[] = { | 80 | static const struct mfd_cell codec_devs[] = { |
81 | { | 81 | { |
82 | .name = "88pm80x-codec", | 82 | .name = "88pm80x-codec", |
83 | .num_resources = ARRAY_SIZE(codec_resources), | 83 | .num_resources = ARRAY_SIZE(codec_resources), |
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index dd671582c9a1..49bb445d846a 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig | |||
@@ -80,7 +80,7 @@ config MFD_CROS_EC_I2C | |||
80 | 80 | ||
81 | config MFD_CROS_EC_SPI | 81 | config MFD_CROS_EC_SPI |
82 | tristate "ChromeOS Embedded Controller (SPI)" | 82 | tristate "ChromeOS Embedded Controller (SPI)" |
83 | depends on MFD_CROS_EC && SPI | 83 | depends on MFD_CROS_EC && SPI && OF |
84 | 84 | ||
85 | ---help--- | 85 | ---help--- |
86 | If you say Y here, you get support for talking to the ChromeOS EC | 86 | If you say Y here, you get support for talking to the ChromeOS EC |
@@ -163,14 +163,10 @@ config MFD_DA9063 | |||
163 | Additional drivers must be enabled in order to use the functionality | 163 | Additional drivers must be enabled in order to use the functionality |
164 | of the device. | 164 | of the device. |
165 | 165 | ||
166 | config MFD_MC13783 | ||
167 | tristate | ||
168 | |||
169 | config MFD_MC13XXX | 166 | config MFD_MC13XXX |
170 | tristate | 167 | tristate |
171 | depends on (SPI_MASTER || I2C) | 168 | depends on (SPI_MASTER || I2C) |
172 | select MFD_CORE | 169 | select MFD_CORE |
173 | select MFD_MC13783 | ||
174 | help | 170 | help |
175 | Enable support for the Freescale MC13783 and MC13892 PMICs. | 171 | Enable support for the Freescale MC13783 and MC13892 PMICs. |
176 | This driver provides common support for accessing the device, | 172 | This driver provides common support for accessing the device, |
@@ -321,6 +317,19 @@ config MFD_88PM860X | |||
321 | select individual components like voltage regulators, RTC and | 317 | select individual components like voltage regulators, RTC and |
322 | battery-charger under the corresponding menus. | 318 | battery-charger under the corresponding menus. |
323 | 319 | ||
320 | config MFD_MAX14577 | ||
321 | bool "Maxim Semiconductor MAX14577 MUIC + Charger Support" | ||
322 | depends on I2C=y | ||
323 | select MFD_CORE | ||
324 | select REGMAP_I2C | ||
325 | select IRQ_DOMAIN | ||
326 | help | ||
327 | Say yes here to support for Maxim Semiconductor MAX14577. | ||
328 | This is a Micro-USB IC with Charger controls on chip. | ||
329 | This driver provides common support for accessing the device; | ||
330 | additional drivers must be enabled in order to use the functionality | ||
331 | of the device. | ||
332 | |||
324 | config MFD_MAX77686 | 333 | config MFD_MAX77686 |
325 | bool "Maxim Semiconductor MAX77686 PMIC Support" | 334 | bool "Maxim Semiconductor MAX77686 PMIC Support" |
326 | depends on I2C=y | 335 | depends on I2C=y |
@@ -725,6 +734,17 @@ config MFD_DM355EVM_MSP | |||
725 | boards. MSP430 firmware manages resets and power sequencing, | 734 | boards. MSP430 firmware manages resets and power sequencing, |
726 | inputs from buttons and the IR remote, LEDs, an RTC, and more. | 735 | inputs from buttons and the IR remote, LEDs, an RTC, and more. |
727 | 736 | ||
737 | config MFD_LP3943 | ||
738 | tristate "TI/National Semiconductor LP3943 MFD Driver" | ||
739 | depends on I2C | ||
740 | select MFD_CORE | ||
741 | select REGMAP_I2C | ||
742 | help | ||
743 | Support for the TI/National Semiconductor LP3943. | ||
744 | This driver consists of GPIO and PWM drivers. | ||
745 | With these functionalities, it can be used for LED string control or | ||
746 | general usage such like a GPIO controller and a PWM controller. | ||
747 | |||
728 | config MFD_LP8788 | 748 | config MFD_LP8788 |
729 | bool "TI LP8788 Power Management Unit Driver" | 749 | bool "TI LP8788 Power Management Unit Driver" |
730 | depends on I2C=y | 750 | depends on I2C=y |
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile index 8a28dc90fe78..5aea5ef0a62f 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile | |||
@@ -102,6 +102,7 @@ obj-$(CONFIG_PMIC_DA9052) += da9052-core.o | |||
102 | obj-$(CONFIG_MFD_DA9052_SPI) += da9052-spi.o | 102 | obj-$(CONFIG_MFD_DA9052_SPI) += da9052-spi.o |
103 | obj-$(CONFIG_MFD_DA9052_I2C) += da9052-i2c.o | 103 | obj-$(CONFIG_MFD_DA9052_I2C) += da9052-i2c.o |
104 | 104 | ||
105 | obj-$(CONFIG_MFD_LP3943) += lp3943.o | ||
105 | obj-$(CONFIG_MFD_LP8788) += lp8788.o lp8788-irq.o | 106 | obj-$(CONFIG_MFD_LP8788) += lp8788.o lp8788-irq.o |
106 | 107 | ||
107 | da9055-objs := da9055-core.o da9055-i2c.o | 108 | da9055-objs := da9055-core.o da9055-i2c.o |
@@ -110,6 +111,7 @@ obj-$(CONFIG_MFD_DA9055) += da9055.o | |||
110 | da9063-objs := da9063-core.o da9063-irq.o da9063-i2c.o | 111 | da9063-objs := da9063-core.o da9063-irq.o da9063-i2c.o |
111 | obj-$(CONFIG_MFD_DA9063) += da9063.o | 112 | obj-$(CONFIG_MFD_DA9063) += da9063.o |
112 | 113 | ||
114 | obj-$(CONFIG_MFD_MAX14577) += max14577.o | ||
113 | obj-$(CONFIG_MFD_MAX77686) += max77686.o max77686-irq.o | 115 | obj-$(CONFIG_MFD_MAX77686) += max77686.o max77686-irq.o |
114 | obj-$(CONFIG_MFD_MAX77693) += max77693.o max77693-irq.o | 116 | obj-$(CONFIG_MFD_MAX77693) += max77693.o max77693-irq.o |
115 | obj-$(CONFIG_MFD_MAX8907) += max8907.o | 117 | obj-$(CONFIG_MFD_MAX8907) += max8907.o |
diff --git a/drivers/mfd/ab8500-core.c b/drivers/mfd/ab8500-core.c index b6c2cdc76091..aaff683cd37d 100644 --- a/drivers/mfd/ab8500-core.c +++ b/drivers/mfd/ab8500-core.c | |||
@@ -491,7 +491,7 @@ static int ab8500_handle_hierarchical_line(struct ab8500 *ab8500, | |||
491 | if (line == AB8540_INT_GPIO43F || line == AB8540_INT_GPIO44F) | 491 | if (line == AB8540_INT_GPIO43F || line == AB8540_INT_GPIO44F) |
492 | line += 1; | 492 | line += 1; |
493 | 493 | ||
494 | handle_nested_irq(ab8500->irq_base + line); | 494 | handle_nested_irq(irq_create_mapping(ab8500->domain, line)); |
495 | } | 495 | } |
496 | 496 | ||
497 | return 0; | 497 | return 0; |
@@ -1017,7 +1017,7 @@ static struct resource ab8500_temp_resources[] = { | |||
1017 | }, | 1017 | }, |
1018 | }; | 1018 | }; |
1019 | 1019 | ||
1020 | static struct mfd_cell ab8500_bm_devs[] = { | 1020 | static const struct mfd_cell ab8500_bm_devs[] = { |
1021 | { | 1021 | { |
1022 | .name = "ab8500-charger", | 1022 | .name = "ab8500-charger", |
1023 | .of_compatible = "stericsson,ab8500-charger", | 1023 | .of_compatible = "stericsson,ab8500-charger", |
@@ -1052,7 +1052,7 @@ static struct mfd_cell ab8500_bm_devs[] = { | |||
1052 | }, | 1052 | }, |
1053 | }; | 1053 | }; |
1054 | 1054 | ||
1055 | static struct mfd_cell ab8500_devs[] = { | 1055 | static const struct mfd_cell ab8500_devs[] = { |
1056 | #ifdef CONFIG_DEBUG_FS | 1056 | #ifdef CONFIG_DEBUG_FS |
1057 | { | 1057 | { |
1058 | .name = "ab8500-debug", | 1058 | .name = "ab8500-debug", |
@@ -1143,7 +1143,7 @@ static struct mfd_cell ab8500_devs[] = { | |||
1143 | }, | 1143 | }, |
1144 | }; | 1144 | }; |
1145 | 1145 | ||
1146 | static struct mfd_cell ab9540_devs[] = { | 1146 | static const struct mfd_cell ab9540_devs[] = { |
1147 | #ifdef CONFIG_DEBUG_FS | 1147 | #ifdef CONFIG_DEBUG_FS |
1148 | { | 1148 | { |
1149 | .name = "ab8500-debug", | 1149 | .name = "ab8500-debug", |
@@ -1214,7 +1214,7 @@ static struct mfd_cell ab9540_devs[] = { | |||
1214 | }; | 1214 | }; |
1215 | 1215 | ||
1216 | /* Device list for ab8505 */ | 1216 | /* Device list for ab8505 */ |
1217 | static struct mfd_cell ab8505_devs[] = { | 1217 | static const struct mfd_cell ab8505_devs[] = { |
1218 | #ifdef CONFIG_DEBUG_FS | 1218 | #ifdef CONFIG_DEBUG_FS |
1219 | { | 1219 | { |
1220 | .name = "ab8500-debug", | 1220 | .name = "ab8500-debug", |
@@ -1275,7 +1275,7 @@ static struct mfd_cell ab8505_devs[] = { | |||
1275 | }, | 1275 | }, |
1276 | }; | 1276 | }; |
1277 | 1277 | ||
1278 | static struct mfd_cell ab8540_devs[] = { | 1278 | static const struct mfd_cell ab8540_devs[] = { |
1279 | #ifdef CONFIG_DEBUG_FS | 1279 | #ifdef CONFIG_DEBUG_FS |
1280 | { | 1280 | { |
1281 | .name = "ab8500-debug", | 1281 | .name = "ab8500-debug", |
@@ -1339,7 +1339,7 @@ static struct mfd_cell ab8540_devs[] = { | |||
1339 | }, | 1339 | }, |
1340 | }; | 1340 | }; |
1341 | 1341 | ||
1342 | static struct mfd_cell ab8540_cut1_devs[] = { | 1342 | static const struct mfd_cell ab8540_cut1_devs[] = { |
1343 | { | 1343 | { |
1344 | .name = "ab8500-rtc", | 1344 | .name = "ab8500-rtc", |
1345 | .of_compatible = "stericsson,ab8500-rtc", | 1345 | .of_compatible = "stericsson,ab8500-rtc", |
@@ -1348,7 +1348,7 @@ static struct mfd_cell ab8540_cut1_devs[] = { | |||
1348 | }, | 1348 | }, |
1349 | }; | 1349 | }; |
1350 | 1350 | ||
1351 | static struct mfd_cell ab8540_cut2_devs[] = { | 1351 | static const struct mfd_cell ab8540_cut2_devs[] = { |
1352 | { | 1352 | { |
1353 | .name = "ab8540-rtc", | 1353 | .name = "ab8540-rtc", |
1354 | .of_compatible = "stericsson,ab8540-rtc", | 1354 | .of_compatible = "stericsson,ab8540-rtc", |
diff --git a/drivers/mfd/ab8500-debugfs.c b/drivers/mfd/ab8500-debugfs.c index e33e385af0a2..d1a22aae2df5 100644 --- a/drivers/mfd/ab8500-debugfs.c +++ b/drivers/mfd/ab8500-debugfs.c | |||
@@ -1600,7 +1600,6 @@ static int ab8500_interrupts_print(struct seq_file *s, void *p) | |||
1600 | 1600 | ||
1601 | for (line = 0; line < num_interrupt_lines; line++) { | 1601 | for (line = 0; line < num_interrupt_lines; line++) { |
1602 | struct irq_desc *desc = irq_to_desc(line + irq_first); | 1602 | struct irq_desc *desc = irq_to_desc(line + irq_first); |
1603 | struct irqaction *action = desc->action; | ||
1604 | 1603 | ||
1605 | seq_printf(s, "%3i: %6i %4i", line, | 1604 | seq_printf(s, "%3i: %6i %4i", line, |
1606 | num_interrupts[line], | 1605 | num_interrupts[line], |
@@ -1608,7 +1607,9 @@ static int ab8500_interrupts_print(struct seq_file *s, void *p) | |||
1608 | 1607 | ||
1609 | if (desc && desc->name) | 1608 | if (desc && desc->name) |
1610 | seq_printf(s, "-%-8s", desc->name); | 1609 | seq_printf(s, "-%-8s", desc->name); |
1611 | if (action) { | 1610 | if (desc && desc->action) { |
1611 | struct irqaction *action = desc->action; | ||
1612 | |||
1612 | seq_printf(s, " %s", action->name); | 1613 | seq_printf(s, " %s", action->name); |
1613 | while ((action = action->next) != NULL) | 1614 | while ((action = action->next) != NULL) |
1614 | seq_printf(s, ", %s", action->name); | 1615 | seq_printf(s, ", %s", action->name); |
diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c index 75e180ceecf3..a45aab9f6bb1 100644 --- a/drivers/mfd/arizona-core.c +++ b/drivers/mfd/arizona-core.c | |||
@@ -565,7 +565,7 @@ static inline int arizona_of_get_core_pdata(struct arizona *arizona) | |||
565 | } | 565 | } |
566 | #endif | 566 | #endif |
567 | 567 | ||
568 | static struct mfd_cell early_devs[] = { | 568 | static const struct mfd_cell early_devs[] = { |
569 | { .name = "arizona-ldo1" }, | 569 | { .name = "arizona-ldo1" }, |
570 | }; | 570 | }; |
571 | 571 | ||
@@ -577,7 +577,7 @@ static const char *wm5102_supplies[] = { | |||
577 | "SPKVDDR", | 577 | "SPKVDDR", |
578 | }; | 578 | }; |
579 | 579 | ||
580 | static struct mfd_cell wm5102_devs[] = { | 580 | static const struct mfd_cell wm5102_devs[] = { |
581 | { .name = "arizona-micsupp" }, | 581 | { .name = "arizona-micsupp" }, |
582 | { .name = "arizona-extcon" }, | 582 | { .name = "arizona-extcon" }, |
583 | { .name = "arizona-gpio" }, | 583 | { .name = "arizona-gpio" }, |
@@ -590,7 +590,7 @@ static struct mfd_cell wm5102_devs[] = { | |||
590 | }, | 590 | }, |
591 | }; | 591 | }; |
592 | 592 | ||
593 | static struct mfd_cell wm5110_devs[] = { | 593 | static const struct mfd_cell wm5110_devs[] = { |
594 | { .name = "arizona-micsupp" }, | 594 | { .name = "arizona-micsupp" }, |
595 | { .name = "arizona-extcon" }, | 595 | { .name = "arizona-extcon" }, |
596 | { .name = "arizona-gpio" }, | 596 | { .name = "arizona-gpio" }, |
@@ -609,7 +609,7 @@ static const char *wm8997_supplies[] = { | |||
609 | "SPKVDD", | 609 | "SPKVDD", |
610 | }; | 610 | }; |
611 | 611 | ||
612 | static struct mfd_cell wm8997_devs[] = { | 612 | static const struct mfd_cell wm8997_devs[] = { |
613 | { .name = "arizona-micsupp" }, | 613 | { .name = "arizona-micsupp" }, |
614 | { .name = "arizona-extcon" }, | 614 | { .name = "arizona-extcon" }, |
615 | { .name = "arizona-gpio" }, | 615 | { .name = "arizona-gpio" }, |
diff --git a/drivers/mfd/as3722.c b/drivers/mfd/as3722.c index f161f2e00df7..c71ff0af1547 100644 --- a/drivers/mfd/as3722.c +++ b/drivers/mfd/as3722.c | |||
@@ -54,7 +54,7 @@ static const struct resource as3722_adc_resource[] = { | |||
54 | }, | 54 | }, |
55 | }; | 55 | }; |
56 | 56 | ||
57 | static struct mfd_cell as3722_devs[] = { | 57 | static const struct mfd_cell as3722_devs[] = { |
58 | { | 58 | { |
59 | .name = "as3722-pinctrl", | 59 | .name = "as3722-pinctrl", |
60 | }, | 60 | }, |
@@ -74,6 +74,9 @@ static struct mfd_cell as3722_devs[] = { | |||
74 | { | 74 | { |
75 | .name = "as3722-power-off", | 75 | .name = "as3722-power-off", |
76 | }, | 76 | }, |
77 | { | ||
78 | .name = "as3722-wdt", | ||
79 | }, | ||
77 | }; | 80 | }; |
78 | 81 | ||
79 | static const struct regmap_irq as3722_irqs[] = { | 82 | static const struct regmap_irq as3722_irqs[] = { |
diff --git a/drivers/mfd/asic3.c b/drivers/mfd/asic3.c index fa22154c84e4..9f6294f2a070 100644 --- a/drivers/mfd/asic3.c +++ b/drivers/mfd/asic3.c | |||
@@ -695,7 +695,7 @@ static int ds1wm_disable(struct platform_device *pdev) | |||
695 | return 0; | 695 | return 0; |
696 | } | 696 | } |
697 | 697 | ||
698 | static struct mfd_cell asic3_cell_ds1wm = { | 698 | static const struct mfd_cell asic3_cell_ds1wm = { |
699 | .name = "ds1wm", | 699 | .name = "ds1wm", |
700 | .enable = ds1wm_enable, | 700 | .enable = ds1wm_enable, |
701 | .disable = ds1wm_disable, | 701 | .disable = ds1wm_disable, |
@@ -797,7 +797,7 @@ static int asic3_mmc_disable(struct platform_device *pdev) | |||
797 | return 0; | 797 | return 0; |
798 | } | 798 | } |
799 | 799 | ||
800 | static struct mfd_cell asic3_cell_mmc = { | 800 | static const struct mfd_cell asic3_cell_mmc = { |
801 | .name = "tmio-mmc", | 801 | .name = "tmio-mmc", |
802 | .enable = asic3_mmc_enable, | 802 | .enable = asic3_mmc_enable, |
803 | .disable = asic3_mmc_disable, | 803 | .disable = asic3_mmc_disable, |
diff --git a/drivers/mfd/cros_ec.c b/drivers/mfd/cros_ec.c index 1f36885d674b..783fe2e73e1e 100644 --- a/drivers/mfd/cros_ec.c +++ b/drivers/mfd/cros_ec.c | |||
@@ -84,7 +84,7 @@ static irqreturn_t ec_irq_thread(int irq, void *data) | |||
84 | return IRQ_HANDLED; | 84 | return IRQ_HANDLED; |
85 | } | 85 | } |
86 | 86 | ||
87 | static struct mfd_cell cros_devs[] = { | 87 | static const struct mfd_cell cros_devs[] = { |
88 | { | 88 | { |
89 | .name = "cros-ec-keyb", | 89 | .name = "cros-ec-keyb", |
90 | .id = 1, | 90 | .id = 1, |
diff --git a/drivers/mfd/cros_ec_i2c.c b/drivers/mfd/cros_ec_i2c.c index 123044608b63..4f71be99a183 100644 --- a/drivers/mfd/cros_ec_i2c.c +++ b/drivers/mfd/cros_ec_i2c.c | |||
@@ -120,7 +120,7 @@ static int cros_ec_command_xfer(struct cros_ec_device *ec_dev, | |||
120 | return ret; | 120 | return ret; |
121 | } | 121 | } |
122 | 122 | ||
123 | static int cros_ec_probe_i2c(struct i2c_client *client, | 123 | static int cros_ec_i2c_probe(struct i2c_client *client, |
124 | const struct i2c_device_id *dev_id) | 124 | const struct i2c_device_id *dev_id) |
125 | { | 125 | { |
126 | struct device *dev = &client->dev; | 126 | struct device *dev = &client->dev; |
@@ -150,7 +150,7 @@ static int cros_ec_probe_i2c(struct i2c_client *client, | |||
150 | return 0; | 150 | return 0; |
151 | } | 151 | } |
152 | 152 | ||
153 | static int cros_ec_remove_i2c(struct i2c_client *client) | 153 | static int cros_ec_i2c_remove(struct i2c_client *client) |
154 | { | 154 | { |
155 | struct cros_ec_device *ec_dev = i2c_get_clientdata(client); | 155 | struct cros_ec_device *ec_dev = i2c_get_clientdata(client); |
156 | 156 | ||
@@ -190,8 +190,8 @@ static struct i2c_driver cros_ec_driver = { | |||
190 | .owner = THIS_MODULE, | 190 | .owner = THIS_MODULE, |
191 | .pm = &cros_ec_i2c_pm_ops, | 191 | .pm = &cros_ec_i2c_pm_ops, |
192 | }, | 192 | }, |
193 | .probe = cros_ec_probe_i2c, | 193 | .probe = cros_ec_i2c_probe, |
194 | .remove = cros_ec_remove_i2c, | 194 | .remove = cros_ec_i2c_remove, |
195 | .id_table = cros_ec_i2c_id, | 195 | .id_table = cros_ec_i2c_id, |
196 | }; | 196 | }; |
197 | 197 | ||
diff --git a/drivers/mfd/cros_ec_spi.c b/drivers/mfd/cros_ec_spi.c index 367ccb58ecb1..84af8d7a4295 100644 --- a/drivers/mfd/cros_ec_spi.c +++ b/drivers/mfd/cros_ec_spi.c | |||
@@ -18,6 +18,7 @@ | |||
18 | #include <linux/module.h> | 18 | #include <linux/module.h> |
19 | #include <linux/mfd/cros_ec.h> | 19 | #include <linux/mfd/cros_ec.h> |
20 | #include <linux/mfd/cros_ec_commands.h> | 20 | #include <linux/mfd/cros_ec_commands.h> |
21 | #include <linux/of.h> | ||
21 | #include <linux/platform_device.h> | 22 | #include <linux/platform_device.h> |
22 | #include <linux/slab.h> | 23 | #include <linux/slab.h> |
23 | #include <linux/spi/spi.h> | 24 | #include <linux/spi/spi.h> |
@@ -50,10 +51,11 @@ | |||
50 | /* | 51 | /* |
51 | * Time between raising the SPI chip select (for the end of a | 52 | * Time between raising the SPI chip select (for the end of a |
52 | * transaction) and dropping it again (for the next transaction). | 53 | * transaction) and dropping it again (for the next transaction). |
53 | * If we go too fast, the EC will miss the transaction. It seems | 54 | * If we go too fast, the EC will miss the transaction. We know that we |
54 | * that 50us is enough with the 16MHz STM32 EC. | 55 | * need at least 70 us with the 16 MHz STM32 EC, so go with 200 us to be |
56 | * safe. | ||
55 | */ | 57 | */ |
56 | #define EC_SPI_RECOVERY_TIME_NS (50 * 1000) | 58 | #define EC_SPI_RECOVERY_TIME_NS (200 * 1000) |
57 | 59 | ||
58 | /** | 60 | /** |
59 | * struct cros_ec_spi - information about a SPI-connected EC | 61 | * struct cros_ec_spi - information about a SPI-connected EC |
@@ -61,10 +63,13 @@ | |||
61 | * @spi: SPI device we are connected to | 63 | * @spi: SPI device we are connected to |
62 | * @last_transfer_ns: time that we last finished a transfer, or 0 if there | 64 | * @last_transfer_ns: time that we last finished a transfer, or 0 if there |
63 | * if no record | 65 | * if no record |
66 | * @end_of_msg_delay: used to set the delay_usecs on the spi_transfer that | ||
67 | * is sent when we want to turn off CS at the end of a transaction. | ||
64 | */ | 68 | */ |
65 | struct cros_ec_spi { | 69 | struct cros_ec_spi { |
66 | struct spi_device *spi; | 70 | struct spi_device *spi; |
67 | s64 last_transfer_ns; | 71 | s64 last_transfer_ns; |
72 | unsigned int end_of_msg_delay; | ||
68 | }; | 73 | }; |
69 | 74 | ||
70 | static void debug_packet(struct device *dev, const char *name, u8 *ptr, | 75 | static void debug_packet(struct device *dev, const char *name, u8 *ptr, |
@@ -75,7 +80,9 @@ static void debug_packet(struct device *dev, const char *name, u8 *ptr, | |||
75 | 80 | ||
76 | dev_dbg(dev, "%s: ", name); | 81 | dev_dbg(dev, "%s: ", name); |
77 | for (i = 0; i < len; i++) | 82 | for (i = 0; i < len; i++) |
78 | dev_cont(dev, " %02x", ptr[i]); | 83 | pr_cont(" %02x", ptr[i]); |
84 | |||
85 | pr_cont("\n"); | ||
79 | #endif | 86 | #endif |
80 | } | 87 | } |
81 | 88 | ||
@@ -105,7 +112,7 @@ static int cros_ec_spi_receive_response(struct cros_ec_device *ec_dev, | |||
105 | /* Receive data until we see the header byte */ | 112 | /* Receive data until we see the header byte */ |
106 | deadline = jiffies + msecs_to_jiffies(EC_MSG_DEADLINE_MS); | 113 | deadline = jiffies + msecs_to_jiffies(EC_MSG_DEADLINE_MS); |
107 | do { | 114 | do { |
108 | memset(&trans, '\0', sizeof(trans)); | 115 | memset(&trans, 0, sizeof(trans)); |
109 | trans.cs_change = 1; | 116 | trans.cs_change = 1; |
110 | trans.rx_buf = ptr = ec_dev->din; | 117 | trans.rx_buf = ptr = ec_dev->din; |
111 | trans.len = EC_MSG_PREAMBLE_COUNT; | 118 | trans.len = EC_MSG_PREAMBLE_COUNT; |
@@ -157,7 +164,7 @@ static int cros_ec_spi_receive_response(struct cros_ec_device *ec_dev, | |||
157 | dev_dbg(ec_dev->dev, "loop, todo=%d, need_len=%d, ptr=%zd\n", | 164 | dev_dbg(ec_dev->dev, "loop, todo=%d, need_len=%d, ptr=%zd\n", |
158 | todo, need_len, ptr - ec_dev->din); | 165 | todo, need_len, ptr - ec_dev->din); |
159 | 166 | ||
160 | memset(&trans, '\0', sizeof(trans)); | 167 | memset(&trans, 0, sizeof(trans)); |
161 | trans.cs_change = 1; | 168 | trans.cs_change = 1; |
162 | trans.rx_buf = ptr; | 169 | trans.rx_buf = ptr; |
163 | trans.len = todo; | 170 | trans.len = todo; |
@@ -217,7 +224,7 @@ static int cros_ec_command_spi_xfer(struct cros_ec_device *ec_dev, | |||
217 | 224 | ||
218 | /* Transmit phase - send our message */ | 225 | /* Transmit phase - send our message */ |
219 | debug_packet(ec_dev->dev, "out", ec_dev->dout, len); | 226 | debug_packet(ec_dev->dev, "out", ec_dev->dout, len); |
220 | memset(&trans, '\0', sizeof(trans)); | 227 | memset(&trans, 0, sizeof(trans)); |
221 | trans.tx_buf = ec_dev->dout; | 228 | trans.tx_buf = ec_dev->dout; |
222 | trans.len = len; | 229 | trans.len = len; |
223 | trans.cs_change = 1; | 230 | trans.cs_change = 1; |
@@ -235,6 +242,17 @@ static int cros_ec_command_spi_xfer(struct cros_ec_device *ec_dev, | |||
235 | 242 | ||
236 | /* turn off CS */ | 243 | /* turn off CS */ |
237 | spi_message_init(&msg); | 244 | spi_message_init(&msg); |
245 | |||
246 | if (ec_spi->end_of_msg_delay) { | ||
247 | /* | ||
248 | * Add delay for last transaction, to ensure the rising edge | ||
249 | * doesn't come too soon after the end of the data. | ||
250 | */ | ||
251 | memset(&trans, 0, sizeof(trans)); | ||
252 | trans.delay_usecs = ec_spi->end_of_msg_delay; | ||
253 | spi_message_add_tail(&trans, &msg); | ||
254 | } | ||
255 | |||
238 | final_ret = spi_sync(ec_spi->spi, &msg); | 256 | final_ret = spi_sync(ec_spi->spi, &msg); |
239 | ktime_get_ts(&ts); | 257 | ktime_get_ts(&ts); |
240 | ec_spi->last_transfer_ns = timespec_to_ns(&ts); | 258 | ec_spi->last_transfer_ns = timespec_to_ns(&ts); |
@@ -281,7 +299,18 @@ static int cros_ec_command_spi_xfer(struct cros_ec_device *ec_dev, | |||
281 | return 0; | 299 | return 0; |
282 | } | 300 | } |
283 | 301 | ||
284 | static int cros_ec_probe_spi(struct spi_device *spi) | 302 | static void cros_ec_spi_dt_probe(struct cros_ec_spi *ec_spi, struct device *dev) |
303 | { | ||
304 | struct device_node *np = dev->of_node; | ||
305 | u32 val; | ||
306 | int ret; | ||
307 | |||
308 | ret = of_property_read_u32(np, "google,cros-ec-spi-msg-delay", &val); | ||
309 | if (!ret) | ||
310 | ec_spi->end_of_msg_delay = val; | ||
311 | } | ||
312 | |||
313 | static int cros_ec_spi_probe(struct spi_device *spi) | ||
285 | { | 314 | { |
286 | struct device *dev = &spi->dev; | 315 | struct device *dev = &spi->dev; |
287 | struct cros_ec_device *ec_dev; | 316 | struct cros_ec_device *ec_dev; |
@@ -302,6 +331,9 @@ static int cros_ec_probe_spi(struct spi_device *spi) | |||
302 | if (!ec_dev) | 331 | if (!ec_dev) |
303 | return -ENOMEM; | 332 | return -ENOMEM; |
304 | 333 | ||
334 | /* Check for any DT properties */ | ||
335 | cros_ec_spi_dt_probe(ec_spi, dev); | ||
336 | |||
305 | spi_set_drvdata(spi, ec_dev); | 337 | spi_set_drvdata(spi, ec_dev); |
306 | ec_dev->name = "SPI"; | 338 | ec_dev->name = "SPI"; |
307 | ec_dev->dev = dev; | 339 | ec_dev->dev = dev; |
@@ -323,7 +355,7 @@ static int cros_ec_probe_spi(struct spi_device *spi) | |||
323 | return 0; | 355 | return 0; |
324 | } | 356 | } |
325 | 357 | ||
326 | static int cros_ec_remove_spi(struct spi_device *spi) | 358 | static int cros_ec_spi_remove(struct spi_device *spi) |
327 | { | 359 | { |
328 | struct cros_ec_device *ec_dev; | 360 | struct cros_ec_device *ec_dev; |
329 | 361 | ||
@@ -364,12 +396,12 @@ static struct spi_driver cros_ec_driver_spi = { | |||
364 | .owner = THIS_MODULE, | 396 | .owner = THIS_MODULE, |
365 | .pm = &cros_ec_spi_pm_ops, | 397 | .pm = &cros_ec_spi_pm_ops, |
366 | }, | 398 | }, |
367 | .probe = cros_ec_probe_spi, | 399 | .probe = cros_ec_spi_probe, |
368 | .remove = cros_ec_remove_spi, | 400 | .remove = cros_ec_spi_remove, |
369 | .id_table = cros_ec_spi_id, | 401 | .id_table = cros_ec_spi_id, |
370 | }; | 402 | }; |
371 | 403 | ||
372 | module_spi_driver(cros_ec_driver_spi); | 404 | module_spi_driver(cros_ec_driver_spi); |
373 | 405 | ||
374 | MODULE_LICENSE("GPL"); | 406 | MODULE_LICENSE("GPL v2"); |
375 | MODULE_DESCRIPTION("ChromeOS EC multi function device (SPI)"); | 407 | MODULE_DESCRIPTION("ChromeOS EC multi function device (SPI)"); |
diff --git a/drivers/mfd/cs5535-mfd.c b/drivers/mfd/cs5535-mfd.c index 2e4752a9220a..17c13012686a 100644 --- a/drivers/mfd/cs5535-mfd.c +++ b/drivers/mfd/cs5535-mfd.c | |||
@@ -172,7 +172,7 @@ static void cs5535_mfd_remove(struct pci_dev *pdev) | |||
172 | pci_disable_device(pdev); | 172 | pci_disable_device(pdev); |
173 | } | 173 | } |
174 | 174 | ||
175 | static DEFINE_PCI_DEVICE_TABLE(cs5535_mfd_pci_tbl) = { | 175 | static const struct pci_device_id cs5535_mfd_pci_tbl[] = { |
176 | { PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_CS5535_ISA) }, | 176 | { PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_CS5535_ISA) }, |
177 | { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_ISA) }, | 177 | { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_ISA) }, |
178 | { 0, } | 178 | { 0, } |
diff --git a/drivers/mfd/da9052-core.c b/drivers/mfd/da9052-core.c index ea28a33576e4..25838f10b35b 100644 --- a/drivers/mfd/da9052-core.c +++ b/drivers/mfd/da9052-core.c | |||
@@ -427,7 +427,7 @@ int da9052_adc_read_temp(struct da9052 *da9052) | |||
427 | } | 427 | } |
428 | EXPORT_SYMBOL_GPL(da9052_adc_read_temp); | 428 | EXPORT_SYMBOL_GPL(da9052_adc_read_temp); |
429 | 429 | ||
430 | static struct mfd_cell da9052_subdev_info[] = { | 430 | static const struct mfd_cell da9052_subdev_info[] = { |
431 | { | 431 | { |
432 | .name = "da9052-regulator", | 432 | .name = "da9052-regulator", |
433 | .id = 1, | 433 | .id = 1, |
diff --git a/drivers/mfd/da9055-core.c b/drivers/mfd/da9055-core.c index d3670cd3c3c6..caf8dcffd0ad 100644 --- a/drivers/mfd/da9055-core.c +++ b/drivers/mfd/da9055-core.c | |||
@@ -294,7 +294,7 @@ static struct resource da9055_ld05_6_resource = { | |||
294 | .flags = IORESOURCE_IRQ, | 294 | .flags = IORESOURCE_IRQ, |
295 | }; | 295 | }; |
296 | 296 | ||
297 | static struct mfd_cell da9055_devs[] = { | 297 | static const struct mfd_cell da9055_devs[] = { |
298 | { | 298 | { |
299 | .of_compatible = "dialog,da9055-gpio", | 299 | .of_compatible = "dialog,da9055-gpio", |
300 | .name = "da9055-gpio", | 300 | .name = "da9055-gpio", |
diff --git a/drivers/mfd/da9063-core.c b/drivers/mfd/da9063-core.c index c9cf8d988406..26937cd01071 100644 --- a/drivers/mfd/da9063-core.c +++ b/drivers/mfd/da9063-core.c | |||
@@ -75,7 +75,7 @@ static struct resource da9063_hwmon_resources[] = { | |||
75 | }; | 75 | }; |
76 | 76 | ||
77 | 77 | ||
78 | static struct mfd_cell da9063_devs[] = { | 78 | static const struct mfd_cell da9063_devs[] = { |
79 | { | 79 | { |
80 | .name = DA9063_DRVNAME_REGULATORS, | 80 | .name = DA9063_DRVNAME_REGULATORS, |
81 | .num_resources = ARRAY_SIZE(da9063_regulators_resources), | 81 | .num_resources = ARRAY_SIZE(da9063_regulators_resources), |
diff --git a/drivers/mfd/db8500-prcmu.c b/drivers/mfd/db8500-prcmu.c index b9ce60c301de..e43e6e821117 100644 --- a/drivers/mfd/db8500-prcmu.c +++ b/drivers/mfd/db8500-prcmu.c | |||
@@ -3070,7 +3070,7 @@ static struct db8500_thsens_platform_data db8500_thsens_data = { | |||
3070 | .num_trips = 4, | 3070 | .num_trips = 4, |
3071 | }; | 3071 | }; |
3072 | 3072 | ||
3073 | static struct mfd_cell common_prcmu_devs[] = { | 3073 | static const struct mfd_cell common_prcmu_devs[] = { |
3074 | { | 3074 | { |
3075 | .name = "ux500_wdt", | 3075 | .name = "ux500_wdt", |
3076 | .platform_data = &db8500_wdt_pdata, | 3076 | .platform_data = &db8500_wdt_pdata, |
@@ -3079,7 +3079,7 @@ static struct mfd_cell common_prcmu_devs[] = { | |||
3079 | }, | 3079 | }, |
3080 | }; | 3080 | }; |
3081 | 3081 | ||
3082 | static struct mfd_cell db8500_prcmu_devs[] = { | 3082 | static const struct mfd_cell db8500_prcmu_devs[] = { |
3083 | { | 3083 | { |
3084 | .name = "db8500-prcmu-regulators", | 3084 | .name = "db8500-prcmu-regulators", |
3085 | .of_compatible = "stericsson,db8500-prcmu-regulator", | 3085 | .of_compatible = "stericsson,db8500-prcmu-regulator", |
diff --git a/drivers/mfd/htc-pasic3.c b/drivers/mfd/htc-pasic3.c index 6bf92a507b95..e88d4f6fef4c 100644 --- a/drivers/mfd/htc-pasic3.c +++ b/drivers/mfd/htc-pasic3.c | |||
@@ -114,7 +114,7 @@ static struct resource ds1wm_resources[] __initdata = { | |||
114 | }, | 114 | }, |
115 | }; | 115 | }; |
116 | 116 | ||
117 | static struct mfd_cell ds1wm_cell __initdata = { | 117 | static const struct mfd_cell ds1wm_cell __initconst = { |
118 | .name = "ds1wm", | 118 | .name = "ds1wm", |
119 | .enable = ds1wm_enable, | 119 | .enable = ds1wm_enable, |
120 | .disable = ds1wm_disable, | 120 | .disable = ds1wm_disable, |
diff --git a/drivers/mfd/intel_msic.c b/drivers/mfd/intel_msic.c index 9203d47cdbb1..049fd23af54a 100644 --- a/drivers/mfd/intel_msic.c +++ b/drivers/mfd/intel_msic.c | |||
@@ -178,7 +178,7 @@ static struct mfd_cell msic_devs[] = { | |||
178 | * These devices appear only after the MSIC driver itself is initialized so | 178 | * These devices appear only after the MSIC driver itself is initialized so |
179 | * we can guarantee that the SCU IPC interface is ready. | 179 | * we can guarantee that the SCU IPC interface is ready. |
180 | */ | 180 | */ |
181 | static struct mfd_cell msic_other_devs[] = { | 181 | static const struct mfd_cell msic_other_devs[] = { |
182 | /* Audio codec in the MSIC */ | 182 | /* Audio codec in the MSIC */ |
183 | { | 183 | { |
184 | .id = -1, | 184 | .id = -1, |
diff --git a/drivers/mfd/janz-cmodio.c b/drivers/mfd/janz-cmodio.c index fcbb2e9dfd37..81b7d88af313 100644 --- a/drivers/mfd/janz-cmodio.c +++ b/drivers/mfd/janz-cmodio.c | |||
@@ -265,7 +265,7 @@ static void cmodio_pci_remove(struct pci_dev *dev) | |||
265 | #define PCI_VENDOR_ID_JANZ 0x13c3 | 265 | #define PCI_VENDOR_ID_JANZ 0x13c3 |
266 | 266 | ||
267 | /* The list of devices that this module will support */ | 267 | /* The list of devices that this module will support */ |
268 | static DEFINE_PCI_DEVICE_TABLE(cmodio_pci_ids) = { | 268 | static const struct pci_device_id cmodio_pci_ids[] = { |
269 | { PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9030, PCI_VENDOR_ID_JANZ, 0x0101 }, | 269 | { PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9030, PCI_VENDOR_ID_JANZ, 0x0101 }, |
270 | { PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9050, PCI_VENDOR_ID_JANZ, 0x0100 }, | 270 | { PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9050, PCI_VENDOR_ID_JANZ, 0x0100 }, |
271 | { 0, } | 271 | { 0, } |
diff --git a/drivers/mfd/jz4740-adc.c b/drivers/mfd/jz4740-adc.c index 3c0e8cf6916b..7a51c0d0d4f1 100644 --- a/drivers/mfd/jz4740-adc.c +++ b/drivers/mfd/jz4740-adc.c | |||
@@ -181,7 +181,7 @@ static struct resource jz4740_battery_resources[] = { | |||
181 | }, | 181 | }, |
182 | }; | 182 | }; |
183 | 183 | ||
184 | static struct mfd_cell jz4740_adc_cells[] = { | 184 | static const struct mfd_cell jz4740_adc_cells[] = { |
185 | { | 185 | { |
186 | .id = 0, | 186 | .id = 0, |
187 | .name = "jz4740-hwmon", | 187 | .name = "jz4740-hwmon", |
diff --git a/drivers/mfd/lp3943.c b/drivers/mfd/lp3943.c new file mode 100644 index 000000000000..e32226836fb4 --- /dev/null +++ b/drivers/mfd/lp3943.c | |||
@@ -0,0 +1,167 @@ | |||
1 | /* | ||
2 | * TI/National Semiconductor LP3943 MFD Core Driver | ||
3 | * | ||
4 | * Copyright 2013 Texas Instruments | ||
5 | * | ||
6 | * Author: Milo Kim <milo.kim@ti.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License version 2 as | ||
10 | * published by the Free Software Foundation. | ||
11 | * | ||
12 | * Driver structure: | ||
13 | * LP3943 is an integrated device capable of driving 16 output channels. | ||
14 | * It can be used for a GPIO expander and PWM generators. | ||
15 | * | ||
16 | * LED control General usage for a device | ||
17 | * ___________ ____________________________ | ||
18 | * | ||
19 | * LP3943 MFD ---- GPIO expander leds-gpio eg) HW enable pin | ||
20 | * | | ||
21 | * --- PWM generator leds-pwm eg) PWM input | ||
22 | * | ||
23 | * Internal two PWM channels are used for LED dimming effect. | ||
24 | * And each output pin can be used as a GPIO as well. | ||
25 | * The LED functionality can work with GPIOs or PWMs. | ||
26 | * LEDs can be controlled with legacy leds-gpio(static brightness) or | ||
27 | * leds-pwm drivers(dynamic brightness control). | ||
28 | * Alternatively, it can be used for generic GPIO and PWM controller. | ||
29 | * For example, a GPIO is HW enable pin of a device. | ||
30 | * A PWM is input pin of a backlight device. | ||
31 | */ | ||
32 | |||
33 | #include <linux/err.h> | ||
34 | #include <linux/gpio.h> | ||
35 | #include <linux/i2c.h> | ||
36 | #include <linux/mfd/core.h> | ||
37 | #include <linux/mfd/lp3943.h> | ||
38 | #include <linux/module.h> | ||
39 | #include <linux/of.h> | ||
40 | #include <linux/slab.h> | ||
41 | |||
42 | #define LP3943_MAX_REGISTERS 0x09 | ||
43 | |||
44 | /* Register configuration for pin MUX */ | ||
45 | static const struct lp3943_reg_cfg lp3943_mux_cfg[] = { | ||
46 | /* address, mask, shift */ | ||
47 | { LP3943_REG_MUX0, 0x03, 0 }, | ||
48 | { LP3943_REG_MUX0, 0x0C, 2 }, | ||
49 | { LP3943_REG_MUX0, 0x30, 4 }, | ||
50 | { LP3943_REG_MUX0, 0xC0, 6 }, | ||
51 | { LP3943_REG_MUX1, 0x03, 0 }, | ||
52 | { LP3943_REG_MUX1, 0x0C, 2 }, | ||
53 | { LP3943_REG_MUX1, 0x30, 4 }, | ||
54 | { LP3943_REG_MUX1, 0xC0, 6 }, | ||
55 | { LP3943_REG_MUX2, 0x03, 0 }, | ||
56 | { LP3943_REG_MUX2, 0x0C, 2 }, | ||
57 | { LP3943_REG_MUX2, 0x30, 4 }, | ||
58 | { LP3943_REG_MUX2, 0xC0, 6 }, | ||
59 | { LP3943_REG_MUX3, 0x03, 0 }, | ||
60 | { LP3943_REG_MUX3, 0x0C, 2 }, | ||
61 | { LP3943_REG_MUX3, 0x30, 4 }, | ||
62 | { LP3943_REG_MUX3, 0xC0, 6 }, | ||
63 | }; | ||
64 | |||
65 | static struct mfd_cell lp3943_devs[] = { | ||
66 | { | ||
67 | .name = "lp3943-pwm", | ||
68 | .of_compatible = "ti,lp3943-pwm", | ||
69 | }, | ||
70 | { | ||
71 | .name = "lp3943-gpio", | ||
72 | .of_compatible = "ti,lp3943-gpio", | ||
73 | }, | ||
74 | }; | ||
75 | |||
76 | int lp3943_read_byte(struct lp3943 *lp3943, u8 reg, u8 *read) | ||
77 | { | ||
78 | int ret; | ||
79 | unsigned int val; | ||
80 | |||
81 | ret = regmap_read(lp3943->regmap, reg, &val); | ||
82 | if (ret < 0) | ||
83 | return ret; | ||
84 | |||
85 | *read = (u8)val; | ||
86 | return 0; | ||
87 | } | ||
88 | EXPORT_SYMBOL_GPL(lp3943_read_byte); | ||
89 | |||
90 | int lp3943_write_byte(struct lp3943 *lp3943, u8 reg, u8 data) | ||
91 | { | ||
92 | return regmap_write(lp3943->regmap, reg, data); | ||
93 | } | ||
94 | EXPORT_SYMBOL_GPL(lp3943_write_byte); | ||
95 | |||
96 | int lp3943_update_bits(struct lp3943 *lp3943, u8 reg, u8 mask, u8 data) | ||
97 | { | ||
98 | return regmap_update_bits(lp3943->regmap, reg, mask, data); | ||
99 | } | ||
100 | EXPORT_SYMBOL_GPL(lp3943_update_bits); | ||
101 | |||
102 | static const struct regmap_config lp3943_regmap_config = { | ||
103 | .reg_bits = 8, | ||
104 | .val_bits = 8, | ||
105 | .max_register = LP3943_MAX_REGISTERS, | ||
106 | }; | ||
107 | |||
108 | static int lp3943_probe(struct i2c_client *cl, const struct i2c_device_id *id) | ||
109 | { | ||
110 | struct lp3943 *lp3943; | ||
111 | struct device *dev = &cl->dev; | ||
112 | |||
113 | lp3943 = devm_kzalloc(dev, sizeof(*lp3943), GFP_KERNEL); | ||
114 | if (!lp3943) | ||
115 | return -ENOMEM; | ||
116 | |||
117 | lp3943->regmap = devm_regmap_init_i2c(cl, &lp3943_regmap_config); | ||
118 | if (IS_ERR(lp3943->regmap)) | ||
119 | return PTR_ERR(lp3943->regmap); | ||
120 | |||
121 | lp3943->pdata = dev_get_platdata(dev); | ||
122 | lp3943->dev = dev; | ||
123 | lp3943->mux_cfg = lp3943_mux_cfg; | ||
124 | i2c_set_clientdata(cl, lp3943); | ||
125 | |||
126 | return mfd_add_devices(dev, -1, lp3943_devs, ARRAY_SIZE(lp3943_devs), | ||
127 | NULL, 0, NULL); | ||
128 | } | ||
129 | |||
130 | static int lp3943_remove(struct i2c_client *cl) | ||
131 | { | ||
132 | struct lp3943 *lp3943 = i2c_get_clientdata(cl); | ||
133 | |||
134 | mfd_remove_devices(lp3943->dev); | ||
135 | return 0; | ||
136 | } | ||
137 | |||
138 | static const struct i2c_device_id lp3943_ids[] = { | ||
139 | { "lp3943", 0 }, | ||
140 | { } | ||
141 | }; | ||
142 | MODULE_DEVICE_TABLE(i2c, lp3943_ids); | ||
143 | |||
144 | #ifdef CONFIG_OF | ||
145 | static const struct of_device_id lp3943_of_match[] = { | ||
146 | { .compatible = "ti,lp3943", }, | ||
147 | { } | ||
148 | }; | ||
149 | MODULE_DEVICE_TABLE(of, lp3943_of_match); | ||
150 | #endif | ||
151 | |||
152 | static struct i2c_driver lp3943_driver = { | ||
153 | .probe = lp3943_probe, | ||
154 | .remove = lp3943_remove, | ||
155 | .driver = { | ||
156 | .name = "lp3943", | ||
157 | .owner = THIS_MODULE, | ||
158 | .of_match_table = of_match_ptr(lp3943_of_match), | ||
159 | }, | ||
160 | .id_table = lp3943_ids, | ||
161 | }; | ||
162 | |||
163 | module_i2c_driver(lp3943_driver); | ||
164 | |||
165 | MODULE_DESCRIPTION("LP3943 MFD Core Driver"); | ||
166 | MODULE_AUTHOR("Milo Kim"); | ||
167 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/mfd/lp8788.c b/drivers/mfd/lp8788.c index 0f1221911018..a30bc15fe5ba 100644 --- a/drivers/mfd/lp8788.c +++ b/drivers/mfd/lp8788.c | |||
@@ -71,7 +71,7 @@ static struct resource rtc_irqs[] = { | |||
71 | }, | 71 | }, |
72 | }; | 72 | }; |
73 | 73 | ||
74 | static struct mfd_cell lp8788_devs[] = { | 74 | static const struct mfd_cell lp8788_devs[] = { |
75 | /* 4 bucks */ | 75 | /* 4 bucks */ |
76 | MFD_DEV_WITH_ID(BUCK, 1), | 76 | MFD_DEV_WITH_ID(BUCK, 1), |
77 | MFD_DEV_WITH_ID(BUCK, 2), | 77 | MFD_DEV_WITH_ID(BUCK, 2), |
diff --git a/drivers/mfd/lpc_ich.c b/drivers/mfd/lpc_ich.c index 37edf9e989b0..be93fa261ded 100644 --- a/drivers/mfd/lpc_ich.c +++ b/drivers/mfd/lpc_ich.c | |||
@@ -517,7 +517,7 @@ static struct lpc_ich_info lpc_chipset_info[] = { | |||
517 | * pci_driver, because the I/O Controller Hub has also other | 517 | * pci_driver, because the I/O Controller Hub has also other |
518 | * functions that probably will be registered by other drivers. | 518 | * functions that probably will be registered by other drivers. |
519 | */ | 519 | */ |
520 | static DEFINE_PCI_DEVICE_TABLE(lpc_ich_ids) = { | 520 | static const struct pci_device_id lpc_ich_ids[] = { |
521 | { PCI_VDEVICE(INTEL, 0x2410), LPC_ICH}, | 521 | { PCI_VDEVICE(INTEL, 0x2410), LPC_ICH}, |
522 | { PCI_VDEVICE(INTEL, 0x2420), LPC_ICH0}, | 522 | { PCI_VDEVICE(INTEL, 0x2420), LPC_ICH0}, |
523 | { PCI_VDEVICE(INTEL, 0x2440), LPC_ICH2}, | 523 | { PCI_VDEVICE(INTEL, 0x2440), LPC_ICH2}, |
diff --git a/drivers/mfd/lpc_sch.c b/drivers/mfd/lpc_sch.c index fbfbf0b7f97a..3bb05c03c68d 100644 --- a/drivers/mfd/lpc_sch.c +++ b/drivers/mfd/lpc_sch.c | |||
@@ -76,7 +76,7 @@ static struct mfd_cell wdt_sch_cell = { | |||
76 | .ignore_resource_conflicts = true, | 76 | .ignore_resource_conflicts = true, |
77 | }; | 77 | }; |
78 | 78 | ||
79 | static DEFINE_PCI_DEVICE_TABLE(lpc_sch_ids) = { | 79 | static const struct pci_device_id lpc_sch_ids[] = { |
80 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_SCH_LPC) }, | 80 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_SCH_LPC) }, |
81 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ITC_LPC) }, | 81 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ITC_LPC) }, |
82 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_CENTERTON_ILB) }, | 82 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_CENTERTON_ILB) }, |
diff --git a/drivers/mfd/max14577.c b/drivers/mfd/max14577.c new file mode 100644 index 000000000000..ac514fb2b877 --- /dev/null +++ b/drivers/mfd/max14577.c | |||
@@ -0,0 +1,245 @@ | |||
1 | /* | ||
2 | * max14577.c - mfd core driver for the Maxim 14577 | ||
3 | * | ||
4 | * Copyright (C) 2013 Samsung Electrnoics | ||
5 | * Chanwoo Choi <cw00.choi@samsung.com> | ||
6 | * Krzysztof Kozlowski <k.kozlowski@samsung.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation; either version 2 of the License, or | ||
11 | * (at your option) any later version. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | * GNU General Public License for more details. | ||
17 | * | ||
18 | * This driver is based on max8997.c | ||
19 | */ | ||
20 | |||
21 | #include <linux/module.h> | ||
22 | #include <linux/interrupt.h> | ||
23 | #include <linux/mfd/core.h> | ||
24 | #include <linux/mfd/max14577.h> | ||
25 | #include <linux/mfd/max14577-private.h> | ||
26 | |||
27 | static struct mfd_cell max14577_devs[] = { | ||
28 | { .name = "max14577-muic", }, | ||
29 | { | ||
30 | .name = "max14577-regulator", | ||
31 | .of_compatible = "maxim,max14577-regulator", | ||
32 | }, | ||
33 | { .name = "max14577-charger", }, | ||
34 | }; | ||
35 | |||
36 | static bool max14577_volatile_reg(struct device *dev, unsigned int reg) | ||
37 | { | ||
38 | switch (reg) { | ||
39 | case MAX14577_REG_INT1 ... MAX14577_REG_STATUS3: | ||
40 | return true; | ||
41 | default: | ||
42 | break; | ||
43 | } | ||
44 | return false; | ||
45 | } | ||
46 | |||
47 | static const struct regmap_config max14577_regmap_config = { | ||
48 | .reg_bits = 8, | ||
49 | .val_bits = 8, | ||
50 | .volatile_reg = max14577_volatile_reg, | ||
51 | .max_register = MAX14577_REG_END, | ||
52 | }; | ||
53 | |||
54 | static const struct regmap_irq max14577_irqs[] = { | ||
55 | /* INT1 interrupts */ | ||
56 | { .reg_offset = 0, .mask = INT1_ADC_MASK, }, | ||
57 | { .reg_offset = 0, .mask = INT1_ADCLOW_MASK, }, | ||
58 | { .reg_offset = 0, .mask = INT1_ADCERR_MASK, }, | ||
59 | /* INT2 interrupts */ | ||
60 | { .reg_offset = 1, .mask = INT2_CHGTYP_MASK, }, | ||
61 | { .reg_offset = 1, .mask = INT2_CHGDETRUN_MASK, }, | ||
62 | { .reg_offset = 1, .mask = INT2_DCDTMR_MASK, }, | ||
63 | { .reg_offset = 1, .mask = INT2_DBCHG_MASK, }, | ||
64 | { .reg_offset = 1, .mask = INT2_VBVOLT_MASK, }, | ||
65 | /* INT3 interrupts */ | ||
66 | { .reg_offset = 2, .mask = INT3_EOC_MASK, }, | ||
67 | { .reg_offset = 2, .mask = INT3_CGMBC_MASK, }, | ||
68 | { .reg_offset = 2, .mask = INT3_OVP_MASK, }, | ||
69 | { .reg_offset = 2, .mask = INT3_MBCCHGERR_MASK, }, | ||
70 | }; | ||
71 | |||
72 | static const struct regmap_irq_chip max14577_irq_chip = { | ||
73 | .name = "max14577", | ||
74 | .status_base = MAX14577_REG_INT1, | ||
75 | .mask_base = MAX14577_REG_INTMASK1, | ||
76 | .mask_invert = 1, | ||
77 | .num_regs = 3, | ||
78 | .irqs = max14577_irqs, | ||
79 | .num_irqs = ARRAY_SIZE(max14577_irqs), | ||
80 | }; | ||
81 | |||
82 | static int max14577_i2c_probe(struct i2c_client *i2c, | ||
83 | const struct i2c_device_id *id) | ||
84 | { | ||
85 | struct max14577 *max14577; | ||
86 | struct max14577_platform_data *pdata = dev_get_platdata(&i2c->dev); | ||
87 | struct device_node *np = i2c->dev.of_node; | ||
88 | u8 reg_data; | ||
89 | int ret = 0; | ||
90 | |||
91 | if (np) { | ||
92 | pdata = devm_kzalloc(&i2c->dev, sizeof(*pdata), GFP_KERNEL); | ||
93 | if (!pdata) | ||
94 | return -ENOMEM; | ||
95 | i2c->dev.platform_data = pdata; | ||
96 | } | ||
97 | |||
98 | if (!pdata) { | ||
99 | dev_err(&i2c->dev, "No platform data found.\n"); | ||
100 | return -EINVAL; | ||
101 | } | ||
102 | |||
103 | max14577 = devm_kzalloc(&i2c->dev, sizeof(*max14577), GFP_KERNEL); | ||
104 | if (!max14577) | ||
105 | return -ENOMEM; | ||
106 | |||
107 | i2c_set_clientdata(i2c, max14577); | ||
108 | max14577->dev = &i2c->dev; | ||
109 | max14577->i2c = i2c; | ||
110 | max14577->irq = i2c->irq; | ||
111 | |||
112 | max14577->regmap = devm_regmap_init_i2c(i2c, &max14577_regmap_config); | ||
113 | if (IS_ERR(max14577->regmap)) { | ||
114 | ret = PTR_ERR(max14577->regmap); | ||
115 | dev_err(max14577->dev, "Failed to allocate register map: %d\n", | ||
116 | ret); | ||
117 | return ret; | ||
118 | } | ||
119 | |||
120 | ret = max14577_read_reg(max14577->regmap, MAX14577_REG_DEVICEID, | ||
121 | ®_data); | ||
122 | if (ret) { | ||
123 | dev_err(max14577->dev, "Device not found on this channel: %d\n", | ||
124 | ret); | ||
125 | return ret; | ||
126 | } | ||
127 | max14577->vendor_id = ((reg_data & DEVID_VENDORID_MASK) >> | ||
128 | DEVID_VENDORID_SHIFT); | ||
129 | max14577->device_id = ((reg_data & DEVID_DEVICEID_MASK) >> | ||
130 | DEVID_DEVICEID_SHIFT); | ||
131 | dev_info(max14577->dev, "Device ID: 0x%x, vendor: 0x%x\n", | ||
132 | max14577->device_id, max14577->vendor_id); | ||
133 | |||
134 | ret = regmap_add_irq_chip(max14577->regmap, max14577->irq, | ||
135 | IRQF_TRIGGER_FALLING | IRQF_ONESHOT, 0, | ||
136 | &max14577_irq_chip, | ||
137 | &max14577->irq_data); | ||
138 | if (ret != 0) { | ||
139 | dev_err(&i2c->dev, "Failed to request IRQ %d: %d\n", | ||
140 | max14577->irq, ret); | ||
141 | return ret; | ||
142 | } | ||
143 | |||
144 | ret = mfd_add_devices(max14577->dev, -1, max14577_devs, | ||
145 | ARRAY_SIZE(max14577_devs), NULL, 0, | ||
146 | regmap_irq_get_domain(max14577->irq_data)); | ||
147 | if (ret < 0) | ||
148 | goto err_mfd; | ||
149 | |||
150 | device_init_wakeup(max14577->dev, 1); | ||
151 | |||
152 | return 0; | ||
153 | |||
154 | err_mfd: | ||
155 | regmap_del_irq_chip(max14577->irq, max14577->irq_data); | ||
156 | |||
157 | return ret; | ||
158 | } | ||
159 | |||
160 | static int max14577_i2c_remove(struct i2c_client *i2c) | ||
161 | { | ||
162 | struct max14577 *max14577 = i2c_get_clientdata(i2c); | ||
163 | |||
164 | mfd_remove_devices(max14577->dev); | ||
165 | regmap_del_irq_chip(max14577->irq, max14577->irq_data); | ||
166 | |||
167 | return 0; | ||
168 | } | ||
169 | |||
170 | static const struct i2c_device_id max14577_i2c_id[] = { | ||
171 | { "max14577", 0 }, | ||
172 | { } | ||
173 | }; | ||
174 | MODULE_DEVICE_TABLE(i2c, max14577_i2c_id); | ||
175 | |||
176 | static int max14577_suspend(struct device *dev) | ||
177 | { | ||
178 | struct i2c_client *i2c = container_of(dev, struct i2c_client, dev); | ||
179 | struct max14577 *max14577 = i2c_get_clientdata(i2c); | ||
180 | |||
181 | if (device_may_wakeup(dev)) { | ||
182 | enable_irq_wake(max14577->irq); | ||
183 | /* | ||
184 | * MUIC IRQ must be disabled during suspend if this is | ||
185 | * a wake up source because it will be handled before | ||
186 | * resuming I2C. | ||
187 | * | ||
188 | * When device is woken up from suspend (e.g. by ADC change), | ||
189 | * an interrupt occurs before resuming I2C bus controller. | ||
190 | * Interrupt handler tries to read registers but this read | ||
191 | * will fail because I2C is still suspended. | ||
192 | */ | ||
193 | disable_irq(max14577->irq); | ||
194 | } | ||
195 | |||
196 | return 0; | ||
197 | } | ||
198 | |||
199 | static int max14577_resume(struct device *dev) | ||
200 | { | ||
201 | struct i2c_client *i2c = container_of(dev, struct i2c_client, dev); | ||
202 | struct max14577 *max14577 = i2c_get_clientdata(i2c); | ||
203 | |||
204 | if (device_may_wakeup(dev)) { | ||
205 | disable_irq_wake(max14577->irq); | ||
206 | enable_irq(max14577->irq); | ||
207 | } | ||
208 | |||
209 | return 0; | ||
210 | } | ||
211 | |||
212 | static struct of_device_id max14577_dt_match[] = { | ||
213 | { .compatible = "maxim,max14577", }, | ||
214 | {}, | ||
215 | }; | ||
216 | |||
217 | static SIMPLE_DEV_PM_OPS(max14577_pm, max14577_suspend, max14577_resume); | ||
218 | |||
219 | static struct i2c_driver max14577_i2c_driver = { | ||
220 | .driver = { | ||
221 | .name = "max14577", | ||
222 | .owner = THIS_MODULE, | ||
223 | .pm = &max14577_pm, | ||
224 | .of_match_table = max14577_dt_match, | ||
225 | }, | ||
226 | .probe = max14577_i2c_probe, | ||
227 | .remove = max14577_i2c_remove, | ||
228 | .id_table = max14577_i2c_id, | ||
229 | }; | ||
230 | |||
231 | static int __init max14577_i2c_init(void) | ||
232 | { | ||
233 | return i2c_add_driver(&max14577_i2c_driver); | ||
234 | } | ||
235 | subsys_initcall(max14577_i2c_init); | ||
236 | |||
237 | static void __exit max14577_i2c_exit(void) | ||
238 | { | ||
239 | i2c_del_driver(&max14577_i2c_driver); | ||
240 | } | ||
241 | module_exit(max14577_i2c_exit); | ||
242 | |||
243 | MODULE_AUTHOR("Chanwoo Choi <cw00.choi@samsung.com>, Krzysztof Kozlowski <k.kozlowski@samsung.com>"); | ||
244 | MODULE_DESCRIPTION("MAXIM 14577 multi-function core driver"); | ||
245 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/mfd/max77686.c b/drivers/mfd/max77686.c index 34520cbe8afb..f53d5823a3f7 100644 --- a/drivers/mfd/max77686.c +++ b/drivers/mfd/max77686.c | |||
@@ -35,7 +35,7 @@ | |||
35 | 35 | ||
36 | #define I2C_ADDR_RTC (0x0C >> 1) | 36 | #define I2C_ADDR_RTC (0x0C >> 1) |
37 | 37 | ||
38 | static struct mfd_cell max77686_devs[] = { | 38 | static const struct mfd_cell max77686_devs[] = { |
39 | { .name = "max77686-pmic", }, | 39 | { .name = "max77686-pmic", }, |
40 | { .name = "max77686-rtc", }, | 40 | { .name = "max77686-rtc", }, |
41 | { .name = "max77686-clk", }, | 41 | { .name = "max77686-clk", }, |
@@ -104,7 +104,7 @@ static int max77686_i2c_probe(struct i2c_client *i2c, | |||
104 | max77686->irq_gpio = pdata->irq_gpio; | 104 | max77686->irq_gpio = pdata->irq_gpio; |
105 | max77686->irq = i2c->irq; | 105 | max77686->irq = i2c->irq; |
106 | 106 | ||
107 | max77686->regmap = regmap_init_i2c(i2c, &max77686_regmap_config); | 107 | max77686->regmap = devm_regmap_init_i2c(i2c, &max77686_regmap_config); |
108 | if (IS_ERR(max77686->regmap)) { | 108 | if (IS_ERR(max77686->regmap)) { |
109 | ret = PTR_ERR(max77686->regmap); | 109 | ret = PTR_ERR(max77686->regmap); |
110 | dev_err(max77686->dev, "Failed to allocate register map: %d\n", | 110 | dev_err(max77686->dev, "Failed to allocate register map: %d\n", |
diff --git a/drivers/mfd/max77693.c b/drivers/mfd/max77693.c index 9f92463f4f7e..e0859987ab6b 100644 --- a/drivers/mfd/max77693.c +++ b/drivers/mfd/max77693.c | |||
@@ -41,7 +41,7 @@ | |||
41 | #define I2C_ADDR_MUIC (0x4A >> 1) | 41 | #define I2C_ADDR_MUIC (0x4A >> 1) |
42 | #define I2C_ADDR_HAPTIC (0x90 >> 1) | 42 | #define I2C_ADDR_HAPTIC (0x90 >> 1) |
43 | 43 | ||
44 | static struct mfd_cell max77693_devs[] = { | 44 | static const struct mfd_cell max77693_devs[] = { |
45 | { .name = "max77693-pmic", }, | 45 | { .name = "max77693-pmic", }, |
46 | { .name = "max77693-charger", }, | 46 | { .name = "max77693-charger", }, |
47 | { .name = "max77693-flash", }, | 47 | { .name = "max77693-flash", }, |
@@ -107,6 +107,12 @@ static const struct regmap_config max77693_regmap_config = { | |||
107 | .max_register = MAX77693_PMIC_REG_END, | 107 | .max_register = MAX77693_PMIC_REG_END, |
108 | }; | 108 | }; |
109 | 109 | ||
110 | static const struct regmap_config max77693_regmap_muic_config = { | ||
111 | .reg_bits = 8, | ||
112 | .val_bits = 8, | ||
113 | .max_register = MAX77693_MUIC_REG_END, | ||
114 | }; | ||
115 | |||
110 | static int max77693_i2c_probe(struct i2c_client *i2c, | 116 | static int max77693_i2c_probe(struct i2c_client *i2c, |
111 | const struct i2c_device_id *id) | 117 | const struct i2c_device_id *id) |
112 | { | 118 | { |
@@ -153,7 +159,7 @@ static int max77693_i2c_probe(struct i2c_client *i2c, | |||
153 | * before call max77693-muic probe() function. | 159 | * before call max77693-muic probe() function. |
154 | */ | 160 | */ |
155 | max77693->regmap_muic = devm_regmap_init_i2c(max77693->muic, | 161 | max77693->regmap_muic = devm_regmap_init_i2c(max77693->muic, |
156 | &max77693_regmap_config); | 162 | &max77693_regmap_muic_config); |
157 | if (IS_ERR(max77693->regmap_muic)) { | 163 | if (IS_ERR(max77693->regmap_muic)) { |
158 | ret = PTR_ERR(max77693->regmap_muic); | 164 | ret = PTR_ERR(max77693->regmap_muic); |
159 | dev_err(max77693->dev, | 165 | dev_err(max77693->dev, |
diff --git a/drivers/mfd/max8907.c b/drivers/mfd/max8907.c index 3bbfedc07f41..07740314b29d 100644 --- a/drivers/mfd/max8907.c +++ b/drivers/mfd/max8907.c | |||
@@ -22,7 +22,7 @@ | |||
22 | #include <linux/regmap.h> | 22 | #include <linux/regmap.h> |
23 | #include <linux/slab.h> | 23 | #include <linux/slab.h> |
24 | 24 | ||
25 | static struct mfd_cell max8907_cells[] = { | 25 | static const struct mfd_cell max8907_cells[] = { |
26 | { .name = "max8907-regulator", }, | 26 | { .name = "max8907-regulator", }, |
27 | { .name = "max8907-rtc", }, | 27 | { .name = "max8907-rtc", }, |
28 | }; | 28 | }; |
diff --git a/drivers/mfd/max8925-core.c b/drivers/mfd/max8925-core.c index f0cc40296d8c..f3faf0c45ddd 100644 --- a/drivers/mfd/max8925-core.c +++ b/drivers/mfd/max8925-core.c | |||
@@ -45,7 +45,7 @@ static struct resource touch_resources[] = { | |||
45 | }, | 45 | }, |
46 | }; | 46 | }; |
47 | 47 | ||
48 | static struct mfd_cell touch_devs[] = { | 48 | static const struct mfd_cell touch_devs[] = { |
49 | { | 49 | { |
50 | .name = "max8925-touch", | 50 | .name = "max8925-touch", |
51 | .num_resources = 1, | 51 | .num_resources = 1, |
@@ -63,7 +63,7 @@ static struct resource power_supply_resources[] = { | |||
63 | }, | 63 | }, |
64 | }; | 64 | }; |
65 | 65 | ||
66 | static struct mfd_cell power_devs[] = { | 66 | static const struct mfd_cell power_devs[] = { |
67 | { | 67 | { |
68 | .name = "max8925-power", | 68 | .name = "max8925-power", |
69 | .num_resources = 1, | 69 | .num_resources = 1, |
@@ -81,7 +81,7 @@ static struct resource rtc_resources[] = { | |||
81 | }, | 81 | }, |
82 | }; | 82 | }; |
83 | 83 | ||
84 | static struct mfd_cell rtc_devs[] = { | 84 | static const struct mfd_cell rtc_devs[] = { |
85 | { | 85 | { |
86 | .name = "max8925-rtc", | 86 | .name = "max8925-rtc", |
87 | .num_resources = 1, | 87 | .num_resources = 1, |
@@ -104,7 +104,7 @@ static struct resource onkey_resources[] = { | |||
104 | }, | 104 | }, |
105 | }; | 105 | }; |
106 | 106 | ||
107 | static struct mfd_cell onkey_devs[] = { | 107 | static const struct mfd_cell onkey_devs[] = { |
108 | { | 108 | { |
109 | .name = "max8925-onkey", | 109 | .name = "max8925-onkey", |
110 | .num_resources = 2, | 110 | .num_resources = 2, |
diff --git a/drivers/mfd/max8997.c b/drivers/mfd/max8997.c index 791aea3e96ce..be88a3bf7b85 100644 --- a/drivers/mfd/max8997.c +++ b/drivers/mfd/max8997.c | |||
@@ -40,7 +40,7 @@ | |||
40 | #define I2C_ADDR_RTC (0x0C >> 1) | 40 | #define I2C_ADDR_RTC (0x0C >> 1) |
41 | #define I2C_ADDR_HAPTIC (0x90 >> 1) | 41 | #define I2C_ADDR_HAPTIC (0x90 >> 1) |
42 | 42 | ||
43 | static struct mfd_cell max8997_devs[] = { | 43 | static const struct mfd_cell max8997_devs[] = { |
44 | { .name = "max8997-pmic", }, | 44 | { .name = "max8997-pmic", }, |
45 | { .name = "max8997-rtc", }, | 45 | { .name = "max8997-rtc", }, |
46 | { .name = "max8997-battery", }, | 46 | { .name = "max8997-battery", }, |
@@ -133,7 +133,6 @@ int max8997_update_reg(struct i2c_client *i2c, u8 reg, u8 val, u8 mask) | |||
133 | } | 133 | } |
134 | EXPORT_SYMBOL_GPL(max8997_update_reg); | 134 | EXPORT_SYMBOL_GPL(max8997_update_reg); |
135 | 135 | ||
136 | #ifdef CONFIG_OF | ||
137 | /* | 136 | /* |
138 | * Only the common platform data elements for max8997 are parsed here from the | 137 | * Only the common platform data elements for max8997 are parsed here from the |
139 | * device tree. Other sub-modules of max8997 such as pmic, rtc and others have | 138 | * device tree. Other sub-modules of max8997 such as pmic, rtc and others have |
@@ -164,24 +163,15 @@ static struct max8997_platform_data *max8997_i2c_parse_dt_pdata( | |||
164 | 163 | ||
165 | return pd; | 164 | return pd; |
166 | } | 165 | } |
167 | #else | ||
168 | static struct max8997_platform_data *max8997_i2c_parse_dt_pdata( | ||
169 | struct device *dev) | ||
170 | { | ||
171 | return 0; | ||
172 | } | ||
173 | #endif | ||
174 | 166 | ||
175 | static inline int max8997_i2c_get_driver_data(struct i2c_client *i2c, | 167 | static inline int max8997_i2c_get_driver_data(struct i2c_client *i2c, |
176 | const struct i2c_device_id *id) | 168 | const struct i2c_device_id *id) |
177 | { | 169 | { |
178 | #ifdef CONFIG_OF | 170 | if (IS_ENABLED(CONFIG_OF) && i2c->dev.of_node) { |
179 | if (i2c->dev.of_node) { | ||
180 | const struct of_device_id *match; | 171 | const struct of_device_id *match; |
181 | match = of_match_node(max8997_pmic_dt_match, i2c->dev.of_node); | 172 | match = of_match_node(max8997_pmic_dt_match, i2c->dev.of_node); |
182 | return (int)match->data; | 173 | return (int)match->data; |
183 | } | 174 | } |
184 | #endif | ||
185 | return (int)id->driver_data; | 175 | return (int)id->driver_data; |
186 | } | 176 | } |
187 | 177 | ||
@@ -203,7 +193,7 @@ static int max8997_i2c_probe(struct i2c_client *i2c, | |||
203 | max8997->type = max8997_i2c_get_driver_data(i2c, id); | 193 | max8997->type = max8997_i2c_get_driver_data(i2c, id); |
204 | max8997->irq = i2c->irq; | 194 | max8997->irq = i2c->irq; |
205 | 195 | ||
206 | if (max8997->dev->of_node) { | 196 | if (IS_ENABLED(CONFIG_OF) && max8997->dev->of_node) { |
207 | pdata = max8997_i2c_parse_dt_pdata(max8997->dev); | 197 | pdata = max8997_i2c_parse_dt_pdata(max8997->dev); |
208 | if (IS_ERR(pdata)) | 198 | if (IS_ERR(pdata)) |
209 | return PTR_ERR(pdata); | 199 | return PTR_ERR(pdata); |
@@ -228,18 +218,19 @@ static int max8997_i2c_probe(struct i2c_client *i2c, | |||
228 | 218 | ||
229 | max8997_irq_init(max8997); | 219 | max8997_irq_init(max8997); |
230 | 220 | ||
231 | mfd_add_devices(max8997->dev, -1, max8997_devs, | 221 | ret = mfd_add_devices(max8997->dev, -1, max8997_devs, |
232 | ARRAY_SIZE(max8997_devs), | 222 | ARRAY_SIZE(max8997_devs), |
233 | NULL, 0, NULL); | 223 | NULL, 0, NULL); |
224 | if (ret < 0) { | ||
225 | dev_err(max8997->dev, "failed to add MFD devices %d\n", ret); | ||
226 | goto err_mfd; | ||
227 | } | ||
234 | 228 | ||
235 | /* | 229 | /* |
236 | * TODO: enable others (flash, muic, rtc, battery, ...) and | 230 | * TODO: enable others (flash, muic, rtc, battery, ...) and |
237 | * check the return value | 231 | * check the return value |
238 | */ | 232 | */ |
239 | 233 | ||
240 | if (ret < 0) | ||
241 | goto err_mfd; | ||
242 | |||
243 | /* MAX8997 has a power button input. */ | 234 | /* MAX8997 has a power button input. */ |
244 | device_init_wakeup(max8997->dev, pdata->wakeup); | 235 | device_init_wakeup(max8997->dev, pdata->wakeup); |
245 | 236 | ||
diff --git a/drivers/mfd/max8998.c b/drivers/mfd/max8998.c index fe6332dcabee..f47eaa70eae0 100644 --- a/drivers/mfd/max8998.c +++ b/drivers/mfd/max8998.c | |||
@@ -37,7 +37,7 @@ | |||
37 | 37 | ||
38 | #define RTC_I2C_ADDR (0x0c >> 1) | 38 | #define RTC_I2C_ADDR (0x0c >> 1) |
39 | 39 | ||
40 | static struct mfd_cell max8998_devs[] = { | 40 | static const struct mfd_cell max8998_devs[] = { |
41 | { | 41 | { |
42 | .name = "max8998-pmic", | 42 | .name = "max8998-pmic", |
43 | }, { | 43 | }, { |
@@ -47,7 +47,7 @@ static struct mfd_cell max8998_devs[] = { | |||
47 | }, | 47 | }, |
48 | }; | 48 | }; |
49 | 49 | ||
50 | static struct mfd_cell lp3974_devs[] = { | 50 | static const struct mfd_cell lp3974_devs[] = { |
51 | { | 51 | { |
52 | .name = "lp3974-pmic", | 52 | .name = "lp3974-pmic", |
53 | }, { | 53 | }, { |
diff --git a/drivers/mfd/mc13xxx-core.c b/drivers/mfd/mc13xxx-core.c index dbbf8ee3f592..06e64b6fcb89 100644 --- a/drivers/mfd/mc13xxx-core.c +++ b/drivers/mfd/mc13xxx-core.c | |||
@@ -158,9 +158,6 @@ int mc13xxx_reg_read(struct mc13xxx *mc13xxx, unsigned int offset, u32 *val) | |||
158 | { | 158 | { |
159 | int ret; | 159 | int ret; |
160 | 160 | ||
161 | if (offset > MC13XXX_NUMREGS) | ||
162 | return -EINVAL; | ||
163 | |||
164 | ret = regmap_read(mc13xxx->regmap, offset, val); | 161 | ret = regmap_read(mc13xxx->regmap, offset, val); |
165 | dev_vdbg(mc13xxx->dev, "[0x%02x] -> 0x%06x\n", offset, *val); | 162 | dev_vdbg(mc13xxx->dev, "[0x%02x] -> 0x%06x\n", offset, *val); |
166 | 163 | ||
@@ -172,7 +169,7 @@ int mc13xxx_reg_write(struct mc13xxx *mc13xxx, unsigned int offset, u32 val) | |||
172 | { | 169 | { |
173 | dev_vdbg(mc13xxx->dev, "[0x%02x] <- 0x%06x\n", offset, val); | 170 | dev_vdbg(mc13xxx->dev, "[0x%02x] <- 0x%06x\n", offset, val); |
174 | 171 | ||
175 | if (offset > MC13XXX_NUMREGS || val > 0xffffff) | 172 | if (val >= BIT(24)) |
176 | return -EINVAL; | 173 | return -EINVAL; |
177 | 174 | ||
178 | return regmap_write(mc13xxx->regmap, offset, val); | 175 | return regmap_write(mc13xxx->regmap, offset, val); |
@@ -639,42 +636,36 @@ static inline int mc13xxx_probe_flags_dt(struct mc13xxx *mc13xxx) | |||
639 | } | 636 | } |
640 | #endif | 637 | #endif |
641 | 638 | ||
642 | int mc13xxx_common_init(struct mc13xxx *mc13xxx, | 639 | int mc13xxx_common_init(struct device *dev) |
643 | struct mc13xxx_platform_data *pdata, int irq) | ||
644 | { | 640 | { |
641 | struct mc13xxx_platform_data *pdata = dev_get_platdata(dev); | ||
642 | struct mc13xxx *mc13xxx = dev_get_drvdata(dev); | ||
645 | int ret; | 643 | int ret; |
646 | u32 revision; | 644 | u32 revision; |
647 | 645 | ||
648 | mc13xxx_lock(mc13xxx); | 646 | mc13xxx->dev = dev; |
649 | 647 | ||
650 | ret = mc13xxx_reg_read(mc13xxx, MC13XXX_REVISION, &revision); | 648 | ret = mc13xxx_reg_read(mc13xxx, MC13XXX_REVISION, &revision); |
651 | if (ret) | 649 | if (ret) |
652 | goto err_revision; | 650 | return ret; |
653 | 651 | ||
654 | mc13xxx->variant->print_revision(mc13xxx, revision); | 652 | mc13xxx->variant->print_revision(mc13xxx, revision); |
655 | 653 | ||
656 | /* mask all irqs */ | 654 | /* mask all irqs */ |
657 | ret = mc13xxx_reg_write(mc13xxx, MC13XXX_IRQMASK0, 0x00ffffff); | 655 | ret = mc13xxx_reg_write(mc13xxx, MC13XXX_IRQMASK0, 0x00ffffff); |
658 | if (ret) | 656 | if (ret) |
659 | goto err_mask; | 657 | return ret; |
660 | 658 | ||
661 | ret = mc13xxx_reg_write(mc13xxx, MC13XXX_IRQMASK1, 0x00ffffff); | 659 | ret = mc13xxx_reg_write(mc13xxx, MC13XXX_IRQMASK1, 0x00ffffff); |
662 | if (ret) | 660 | if (ret) |
663 | goto err_mask; | 661 | return ret; |
664 | 662 | ||
665 | ret = request_threaded_irq(irq, NULL, mc13xxx_irq_thread, | 663 | ret = request_threaded_irq(mc13xxx->irq, NULL, mc13xxx_irq_thread, |
666 | IRQF_ONESHOT | IRQF_TRIGGER_HIGH, "mc13xxx", mc13xxx); | 664 | IRQF_ONESHOT | IRQF_TRIGGER_HIGH, "mc13xxx", mc13xxx); |
667 | 665 | if (ret) | |
668 | if (ret) { | ||
669 | err_mask: | ||
670 | err_revision: | ||
671 | mc13xxx_unlock(mc13xxx); | ||
672 | return ret; | 666 | return ret; |
673 | } | ||
674 | 667 | ||
675 | mc13xxx->irq = irq; | 668 | mutex_init(&mc13xxx->lock); |
676 | |||
677 | mc13xxx_unlock(mc13xxx); | ||
678 | 669 | ||
679 | if (mc13xxx_probe_flags_dt(mc13xxx) < 0 && pdata) | 670 | if (mc13xxx_probe_flags_dt(mc13xxx) < 0 && pdata) |
680 | mc13xxx->flags = pdata->flags; | 671 | mc13xxx->flags = pdata->flags; |
@@ -710,13 +701,17 @@ err_revision: | |||
710 | } | 701 | } |
711 | EXPORT_SYMBOL_GPL(mc13xxx_common_init); | 702 | EXPORT_SYMBOL_GPL(mc13xxx_common_init); |
712 | 703 | ||
713 | void mc13xxx_common_cleanup(struct mc13xxx *mc13xxx) | 704 | int mc13xxx_common_exit(struct device *dev) |
714 | { | 705 | { |
706 | struct mc13xxx *mc13xxx = dev_get_drvdata(dev); | ||
707 | |||
715 | free_irq(mc13xxx->irq, mc13xxx); | 708 | free_irq(mc13xxx->irq, mc13xxx); |
709 | mfd_remove_devices(dev); | ||
710 | mutex_destroy(&mc13xxx->lock); | ||
716 | 711 | ||
717 | mfd_remove_devices(mc13xxx->dev); | 712 | return 0; |
718 | } | 713 | } |
719 | EXPORT_SYMBOL_GPL(mc13xxx_common_cleanup); | 714 | EXPORT_SYMBOL_GPL(mc13xxx_common_exit); |
720 | 715 | ||
721 | MODULE_DESCRIPTION("Core driver for Freescale MC13XXX PMIC"); | 716 | MODULE_DESCRIPTION("Core driver for Freescale MC13XXX PMIC"); |
722 | MODULE_AUTHOR("Uwe Kleine-Koenig <u.kleine-koenig@pengutronix.de>"); | 717 | MODULE_AUTHOR("Uwe Kleine-Koenig <u.kleine-koenig@pengutronix.de>"); |
diff --git a/drivers/mfd/mc13xxx-i2c.c b/drivers/mfd/mc13xxx-i2c.c index 898bd335cd8e..ae3addb153a2 100644 --- a/drivers/mfd/mc13xxx-i2c.c +++ b/drivers/mfd/mc13xxx-i2c.c | |||
@@ -10,7 +10,6 @@ | |||
10 | #include <linux/slab.h> | 10 | #include <linux/slab.h> |
11 | #include <linux/module.h> | 11 | #include <linux/module.h> |
12 | #include <linux/platform_device.h> | 12 | #include <linux/platform_device.h> |
13 | #include <linux/mutex.h> | ||
14 | #include <linux/mfd/core.h> | 13 | #include <linux/mfd/core.h> |
15 | #include <linux/mfd/mc13xxx.h> | 14 | #include <linux/mfd/mc13xxx.h> |
16 | #include <linux/of.h> | 15 | #include <linux/of.h> |
@@ -60,7 +59,6 @@ static int mc13xxx_i2c_probe(struct i2c_client *client, | |||
60 | const struct i2c_device_id *id) | 59 | const struct i2c_device_id *id) |
61 | { | 60 | { |
62 | struct mc13xxx *mc13xxx; | 61 | struct mc13xxx *mc13xxx; |
63 | struct mc13xxx_platform_data *pdata = dev_get_platdata(&client->dev); | ||
64 | int ret; | 62 | int ret; |
65 | 63 | ||
66 | mc13xxx = devm_kzalloc(&client->dev, sizeof(*mc13xxx), GFP_KERNEL); | 64 | mc13xxx = devm_kzalloc(&client->dev, sizeof(*mc13xxx), GFP_KERNEL); |
@@ -69,15 +67,13 @@ static int mc13xxx_i2c_probe(struct i2c_client *client, | |||
69 | 67 | ||
70 | dev_set_drvdata(&client->dev, mc13xxx); | 68 | dev_set_drvdata(&client->dev, mc13xxx); |
71 | 69 | ||
72 | mc13xxx->dev = &client->dev; | 70 | mc13xxx->irq = client->irq; |
73 | mutex_init(&mc13xxx->lock); | ||
74 | 71 | ||
75 | mc13xxx->regmap = devm_regmap_init_i2c(client, | 72 | mc13xxx->regmap = devm_regmap_init_i2c(client, |
76 | &mc13xxx_regmap_i2c_config); | 73 | &mc13xxx_regmap_i2c_config); |
77 | if (IS_ERR(mc13xxx->regmap)) { | 74 | if (IS_ERR(mc13xxx->regmap)) { |
78 | ret = PTR_ERR(mc13xxx->regmap); | 75 | ret = PTR_ERR(mc13xxx->regmap); |
79 | dev_err(mc13xxx->dev, "Failed to initialize register map: %d\n", | 76 | dev_err(&client->dev, "Failed to initialize regmap: %d\n", ret); |
80 | ret); | ||
81 | return ret; | 77 | return ret; |
82 | } | 78 | } |
83 | 79 | ||
@@ -89,18 +85,12 @@ static int mc13xxx_i2c_probe(struct i2c_client *client, | |||
89 | mc13xxx->variant = (void *)id->driver_data; | 85 | mc13xxx->variant = (void *)id->driver_data; |
90 | } | 86 | } |
91 | 87 | ||
92 | ret = mc13xxx_common_init(mc13xxx, pdata, client->irq); | 88 | return mc13xxx_common_init(&client->dev); |
93 | |||
94 | return ret; | ||
95 | } | 89 | } |
96 | 90 | ||
97 | static int mc13xxx_i2c_remove(struct i2c_client *client) | 91 | static int mc13xxx_i2c_remove(struct i2c_client *client) |
98 | { | 92 | { |
99 | struct mc13xxx *mc13xxx = dev_get_drvdata(&client->dev); | 93 | return mc13xxx_common_exit(&client->dev); |
100 | |||
101 | mc13xxx_common_cleanup(mc13xxx); | ||
102 | |||
103 | return 0; | ||
104 | } | 94 | } |
105 | 95 | ||
106 | static struct i2c_driver mc13xxx_i2c_driver = { | 96 | static struct i2c_driver mc13xxx_i2c_driver = { |
diff --git a/drivers/mfd/mc13xxx-spi.c b/drivers/mfd/mc13xxx-spi.c index 5f14ef6693c2..38ab67829791 100644 --- a/drivers/mfd/mc13xxx-spi.c +++ b/drivers/mfd/mc13xxx-spi.c | |||
@@ -13,7 +13,6 @@ | |||
13 | #include <linux/slab.h> | 13 | #include <linux/slab.h> |
14 | #include <linux/module.h> | 14 | #include <linux/module.h> |
15 | #include <linux/platform_device.h> | 15 | #include <linux/platform_device.h> |
16 | #include <linux/mutex.h> | ||
17 | #include <linux/interrupt.h> | 16 | #include <linux/interrupt.h> |
18 | #include <linux/mfd/core.h> | 17 | #include <linux/mfd/core.h> |
19 | #include <linux/mfd/mc13xxx.h> | 18 | #include <linux/mfd/mc13xxx.h> |
@@ -129,27 +128,24 @@ static struct regmap_bus regmap_mc13xxx_bus = { | |||
129 | static int mc13xxx_spi_probe(struct spi_device *spi) | 128 | static int mc13xxx_spi_probe(struct spi_device *spi) |
130 | { | 129 | { |
131 | struct mc13xxx *mc13xxx; | 130 | struct mc13xxx *mc13xxx; |
132 | struct mc13xxx_platform_data *pdata = dev_get_platdata(&spi->dev); | ||
133 | int ret; | 131 | int ret; |
134 | 132 | ||
135 | mc13xxx = devm_kzalloc(&spi->dev, sizeof(*mc13xxx), GFP_KERNEL); | 133 | mc13xxx = devm_kzalloc(&spi->dev, sizeof(*mc13xxx), GFP_KERNEL); |
136 | if (!mc13xxx) | 134 | if (!mc13xxx) |
137 | return -ENOMEM; | 135 | return -ENOMEM; |
138 | 136 | ||
139 | spi_set_drvdata(spi, mc13xxx); | 137 | dev_set_drvdata(&spi->dev, mc13xxx); |
138 | |||
140 | spi->mode = SPI_MODE_0 | SPI_CS_HIGH; | 139 | spi->mode = SPI_MODE_0 | SPI_CS_HIGH; |
141 | 140 | ||
142 | mc13xxx->dev = &spi->dev; | 141 | mc13xxx->irq = spi->irq; |
143 | mutex_init(&mc13xxx->lock); | ||
144 | 142 | ||
145 | mc13xxx->regmap = devm_regmap_init(&spi->dev, ®map_mc13xxx_bus, | 143 | mc13xxx->regmap = devm_regmap_init(&spi->dev, ®map_mc13xxx_bus, |
146 | &spi->dev, | 144 | &spi->dev, |
147 | &mc13xxx_regmap_spi_config); | 145 | &mc13xxx_regmap_spi_config); |
148 | if (IS_ERR(mc13xxx->regmap)) { | 146 | if (IS_ERR(mc13xxx->regmap)) { |
149 | ret = PTR_ERR(mc13xxx->regmap); | 147 | ret = PTR_ERR(mc13xxx->regmap); |
150 | dev_err(mc13xxx->dev, "Failed to initialize register map: %d\n", | 148 | dev_err(&spi->dev, "Failed to initialize regmap: %d\n", ret); |
151 | ret); | ||
152 | spi_set_drvdata(spi, NULL); | ||
153 | return ret; | 149 | return ret; |
154 | } | 150 | } |
155 | 151 | ||
@@ -164,16 +160,12 @@ static int mc13xxx_spi_probe(struct spi_device *spi) | |||
164 | mc13xxx->variant = (void *)id_entry->driver_data; | 160 | mc13xxx->variant = (void *)id_entry->driver_data; |
165 | } | 161 | } |
166 | 162 | ||
167 | return mc13xxx_common_init(mc13xxx, pdata, spi->irq); | 163 | return mc13xxx_common_init(&spi->dev); |
168 | } | 164 | } |
169 | 165 | ||
170 | static int mc13xxx_spi_remove(struct spi_device *spi) | 166 | static int mc13xxx_spi_remove(struct spi_device *spi) |
171 | { | 167 | { |
172 | struct mc13xxx *mc13xxx = spi_get_drvdata(spi); | 168 | return mc13xxx_common_exit(&spi->dev); |
173 | |||
174 | mc13xxx_common_cleanup(mc13xxx); | ||
175 | |||
176 | return 0; | ||
177 | } | 169 | } |
178 | 170 | ||
179 | static struct spi_driver mc13xxx_spi_driver = { | 171 | static struct spi_driver mc13xxx_spi_driver = { |
diff --git a/drivers/mfd/mc13xxx.h b/drivers/mfd/mc13xxx.h index 460ec5c7b18c..ae7f1659f5d1 100644 --- a/drivers/mfd/mc13xxx.h +++ b/drivers/mfd/mc13xxx.h | |||
@@ -43,9 +43,7 @@ struct mc13xxx { | |||
43 | int adcflags; | 43 | int adcflags; |
44 | }; | 44 | }; |
45 | 45 | ||
46 | int mc13xxx_common_init(struct mc13xxx *mc13xxx, | 46 | int mc13xxx_common_init(struct device *dev); |
47 | struct mc13xxx_platform_data *pdata, int irq); | 47 | int mc13xxx_common_exit(struct device *dev); |
48 | |||
49 | void mc13xxx_common_cleanup(struct mc13xxx *mc13xxx); | ||
50 | 48 | ||
51 | #endif /* __DRIVERS_MFD_MC13XXX_H */ | 49 | #endif /* __DRIVERS_MFD_MC13XXX_H */ |
diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c index 142650fdc058..90b630ccc8bc 100644 --- a/drivers/mfd/omap-usb-host.c +++ b/drivers/mfd/omap-usb-host.c | |||
@@ -121,22 +121,22 @@ static u64 usbhs_dmamask = DMA_BIT_MASK(32); | |||
121 | 121 | ||
122 | static inline void usbhs_write(void __iomem *base, u32 reg, u32 val) | 122 | static inline void usbhs_write(void __iomem *base, u32 reg, u32 val) |
123 | { | 123 | { |
124 | __raw_writel(val, base + reg); | 124 | writel_relaxed(val, base + reg); |
125 | } | 125 | } |
126 | 126 | ||
127 | static inline u32 usbhs_read(void __iomem *base, u32 reg) | 127 | static inline u32 usbhs_read(void __iomem *base, u32 reg) |
128 | { | 128 | { |
129 | return __raw_readl(base + reg); | 129 | return readl_relaxed(base + reg); |
130 | } | 130 | } |
131 | 131 | ||
132 | static inline void usbhs_writeb(void __iomem *base, u8 reg, u8 val) | 132 | static inline void usbhs_writeb(void __iomem *base, u8 reg, u8 val) |
133 | { | 133 | { |
134 | __raw_writeb(val, base + reg); | 134 | writeb_relaxed(val, base + reg); |
135 | } | 135 | } |
136 | 136 | ||
137 | static inline u8 usbhs_readb(void __iomem *base, u8 reg) | 137 | static inline u8 usbhs_readb(void __iomem *base, u8 reg) |
138 | { | 138 | { |
139 | return __raw_readb(base + reg); | 139 | return readb_relaxed(base + reg); |
140 | } | 140 | } |
141 | 141 | ||
142 | /*-------------------------------------------------------------------------*/ | 142 | /*-------------------------------------------------------------------------*/ |
diff --git a/drivers/mfd/omap-usb-tll.c b/drivers/mfd/omap-usb-tll.c index 0d946ae14453..5ee50f779ef6 100644 --- a/drivers/mfd/omap-usb-tll.c +++ b/drivers/mfd/omap-usb-tll.c | |||
@@ -121,22 +121,22 @@ static DEFINE_SPINLOCK(tll_lock); /* serialize access to tll_dev */ | |||
121 | 121 | ||
122 | static inline void usbtll_write(void __iomem *base, u32 reg, u32 val) | 122 | static inline void usbtll_write(void __iomem *base, u32 reg, u32 val) |
123 | { | 123 | { |
124 | __raw_writel(val, base + reg); | 124 | writel_relaxed(val, base + reg); |
125 | } | 125 | } |
126 | 126 | ||
127 | static inline u32 usbtll_read(void __iomem *base, u32 reg) | 127 | static inline u32 usbtll_read(void __iomem *base, u32 reg) |
128 | { | 128 | { |
129 | return __raw_readl(base + reg); | 129 | return readl_relaxed(base + reg); |
130 | } | 130 | } |
131 | 131 | ||
132 | static inline void usbtll_writeb(void __iomem *base, u8 reg, u8 val) | 132 | static inline void usbtll_writeb(void __iomem *base, u8 reg, u8 val) |
133 | { | 133 | { |
134 | __raw_writeb(val, base + reg); | 134 | writeb_relaxed(val, base + reg); |
135 | } | 135 | } |
136 | 136 | ||
137 | static inline u8 usbtll_readb(void __iomem *base, u8 reg) | 137 | static inline u8 usbtll_readb(void __iomem *base, u8 reg) |
138 | { | 138 | { |
139 | return __raw_readb(base + reg); | 139 | return readb_relaxed(base + reg); |
140 | } | 140 | } |
141 | 141 | ||
142 | /*-------------------------------------------------------------------------*/ | 142 | /*-------------------------------------------------------------------------*/ |
@@ -333,21 +333,17 @@ int omap_tll_init(struct usbhs_omap_platform_data *pdata) | |||
333 | unsigned reg; | 333 | unsigned reg; |
334 | struct usbtll_omap *tll; | 334 | struct usbtll_omap *tll; |
335 | 335 | ||
336 | spin_lock(&tll_lock); | 336 | if (!tll_dev) |
337 | |||
338 | if (!tll_dev) { | ||
339 | spin_unlock(&tll_lock); | ||
340 | return -ENODEV; | 337 | return -ENODEV; |
341 | } | ||
342 | 338 | ||
343 | tll = dev_get_drvdata(tll_dev); | 339 | pm_runtime_get_sync(tll_dev); |
344 | 340 | ||
341 | spin_lock(&tll_lock); | ||
342 | tll = dev_get_drvdata(tll_dev); | ||
345 | needs_tll = false; | 343 | needs_tll = false; |
346 | for (i = 0; i < tll->nch; i++) | 344 | for (i = 0; i < tll->nch; i++) |
347 | needs_tll |= omap_usb_mode_needs_tll(pdata->port_mode[i]); | 345 | needs_tll |= omap_usb_mode_needs_tll(pdata->port_mode[i]); |
348 | 346 | ||
349 | pm_runtime_get_sync(tll_dev); | ||
350 | |||
351 | if (needs_tll) { | 347 | if (needs_tll) { |
352 | void __iomem *base = tll->base; | 348 | void __iomem *base = tll->base; |
353 | 349 | ||
@@ -398,9 +394,8 @@ int omap_tll_init(struct usbhs_omap_platform_data *pdata) | |||
398 | } | 394 | } |
399 | } | 395 | } |
400 | 396 | ||
401 | pm_runtime_put_sync(tll_dev); | ||
402 | |||
403 | spin_unlock(&tll_lock); | 397 | spin_unlock(&tll_lock); |
398 | pm_runtime_put_sync(tll_dev); | ||
404 | 399 | ||
405 | return 0; | 400 | return 0; |
406 | } | 401 | } |
@@ -411,17 +406,14 @@ int omap_tll_enable(struct usbhs_omap_platform_data *pdata) | |||
411 | int i; | 406 | int i; |
412 | struct usbtll_omap *tll; | 407 | struct usbtll_omap *tll; |
413 | 408 | ||
414 | spin_lock(&tll_lock); | 409 | if (!tll_dev) |
415 | |||
416 | if (!tll_dev) { | ||
417 | spin_unlock(&tll_lock); | ||
418 | return -ENODEV; | 410 | return -ENODEV; |
419 | } | ||
420 | |||
421 | tll = dev_get_drvdata(tll_dev); | ||
422 | 411 | ||
423 | pm_runtime_get_sync(tll_dev); | 412 | pm_runtime_get_sync(tll_dev); |
424 | 413 | ||
414 | spin_lock(&tll_lock); | ||
415 | tll = dev_get_drvdata(tll_dev); | ||
416 | |||
425 | for (i = 0; i < tll->nch; i++) { | 417 | for (i = 0; i < tll->nch; i++) { |
426 | if (omap_usb_mode_needs_tll(pdata->port_mode[i])) { | 418 | if (omap_usb_mode_needs_tll(pdata->port_mode[i])) { |
427 | int r; | 419 | int r; |
@@ -448,13 +440,10 @@ int omap_tll_disable(struct usbhs_omap_platform_data *pdata) | |||
448 | int i; | 440 | int i; |
449 | struct usbtll_omap *tll; | 441 | struct usbtll_omap *tll; |
450 | 442 | ||
451 | spin_lock(&tll_lock); | 443 | if (!tll_dev) |
452 | |||
453 | if (!tll_dev) { | ||
454 | spin_unlock(&tll_lock); | ||
455 | return -ENODEV; | 444 | return -ENODEV; |
456 | } | ||
457 | 445 | ||
446 | spin_lock(&tll_lock); | ||
458 | tll = dev_get_drvdata(tll_dev); | 447 | tll = dev_get_drvdata(tll_dev); |
459 | 448 | ||
460 | for (i = 0; i < tll->nch; i++) { | 449 | for (i = 0; i < tll->nch; i++) { |
@@ -464,9 +453,8 @@ int omap_tll_disable(struct usbhs_omap_platform_data *pdata) | |||
464 | } | 453 | } |
465 | } | 454 | } |
466 | 455 | ||
467 | pm_runtime_put_sync(tll_dev); | ||
468 | |||
469 | spin_unlock(&tll_lock); | 456 | spin_unlock(&tll_lock); |
457 | pm_runtime_put_sync(tll_dev); | ||
470 | 458 | ||
471 | return 0; | 459 | return 0; |
472 | } | 460 | } |
diff --git a/drivers/mfd/rc5t583.c b/drivers/mfd/rc5t583.c index 346330176afc..df276ad9f40b 100644 --- a/drivers/mfd/rc5t583.c +++ b/drivers/mfd/rc5t583.c | |||
@@ -74,7 +74,7 @@ static struct deepsleep_control_data deepsleep_data[] = { | |||
74 | #define EXT_PWR_REQ \ | 74 | #define EXT_PWR_REQ \ |
75 | (RC5T583_EXT_PWRREQ1_CONTROL | RC5T583_EXT_PWRREQ2_CONTROL) | 75 | (RC5T583_EXT_PWRREQ1_CONTROL | RC5T583_EXT_PWRREQ2_CONTROL) |
76 | 76 | ||
77 | static struct mfd_cell rc5t583_subdevs[] = { | 77 | static const struct mfd_cell rc5t583_subdevs[] = { |
78 | {.name = "rc5t583-gpio",}, | 78 | {.name = "rc5t583-gpio",}, |
79 | {.name = "rc5t583-regulator",}, | 79 | {.name = "rc5t583-regulator",}, |
80 | {.name = "rc5t583-rtc", }, | 80 | {.name = "rc5t583-rtc", }, |
diff --git a/drivers/mfd/rdc321x-southbridge.c b/drivers/mfd/rdc321x-southbridge.c index 21b7bef73507..d346146249a2 100644 --- a/drivers/mfd/rdc321x-southbridge.c +++ b/drivers/mfd/rdc321x-southbridge.c | |||
@@ -56,7 +56,7 @@ static struct resource rdc321x_gpio_resources[] = { | |||
56 | } | 56 | } |
57 | }; | 57 | }; |
58 | 58 | ||
59 | static struct mfd_cell rdc321x_sb_cells[] = { | 59 | static const struct mfd_cell rdc321x_sb_cells[] = { |
60 | { | 60 | { |
61 | .name = "rdc321x-wdt", | 61 | .name = "rdc321x-wdt", |
62 | .resources = rdc321x_wdt_resource, | 62 | .resources = rdc321x_wdt_resource, |
@@ -96,7 +96,7 @@ static void rdc321x_sb_remove(struct pci_dev *pdev) | |||
96 | mfd_remove_devices(&pdev->dev); | 96 | mfd_remove_devices(&pdev->dev); |
97 | } | 97 | } |
98 | 98 | ||
99 | static DEFINE_PCI_DEVICE_TABLE(rdc321x_sb_table) = { | 99 | static const struct pci_device_id rdc321x_sb_table[] = { |
100 | { PCI_DEVICE(PCI_VENDOR_ID_RDC, PCI_DEVICE_ID_RDC_R6030) }, | 100 | { PCI_DEVICE(PCI_VENDOR_ID_RDC, PCI_DEVICE_ID_RDC_R6030) }, |
101 | {} | 101 | {} |
102 | }; | 102 | }; |
diff --git a/drivers/mfd/retu-mfd.c b/drivers/mfd/retu-mfd.c index a1830986eeb7..c8f345f7e9a2 100644 --- a/drivers/mfd/retu-mfd.c +++ b/drivers/mfd/retu-mfd.c | |||
@@ -55,7 +55,7 @@ static struct resource retu_pwrbutton_res[] = { | |||
55 | }, | 55 | }, |
56 | }; | 56 | }; |
57 | 57 | ||
58 | static struct mfd_cell retu_devs[] = { | 58 | static const struct mfd_cell retu_devs[] = { |
59 | { | 59 | { |
60 | .name = "retu-wdt" | 60 | .name = "retu-wdt" |
61 | }, | 61 | }, |
@@ -94,7 +94,7 @@ static struct resource tahvo_usb_res[] = { | |||
94 | }, | 94 | }, |
95 | }; | 95 | }; |
96 | 96 | ||
97 | static struct mfd_cell tahvo_devs[] = { | 97 | static const struct mfd_cell tahvo_devs[] = { |
98 | { | 98 | { |
99 | .name = "tahvo-usb", | 99 | .name = "tahvo-usb", |
100 | .resources = tahvo_usb_res, | 100 | .resources = tahvo_usb_res, |
@@ -122,7 +122,7 @@ static const struct retu_data { | |||
122 | char *chip_name; | 122 | char *chip_name; |
123 | char *companion_name; | 123 | char *companion_name; |
124 | struct regmap_irq_chip *irq_chip; | 124 | struct regmap_irq_chip *irq_chip; |
125 | struct mfd_cell *children; | 125 | const struct mfd_cell *children; |
126 | int nchildren; | 126 | int nchildren; |
127 | } retu_data[] = { | 127 | } retu_data[] = { |
128 | [0] = { | 128 | [0] = { |
diff --git a/drivers/mfd/rtl8411.c b/drivers/mfd/rtl8411.c index 52801351864d..fdd34c883d86 100644 --- a/drivers/mfd/rtl8411.c +++ b/drivers/mfd/rtl8411.c | |||
@@ -49,8 +49,8 @@ static int rtl8411b_is_qfn48(struct rtsx_pcr *pcr) | |||
49 | 49 | ||
50 | static void rtl8411_fetch_vendor_settings(struct rtsx_pcr *pcr) | 50 | static void rtl8411_fetch_vendor_settings(struct rtsx_pcr *pcr) |
51 | { | 51 | { |
52 | u32 reg1; | 52 | u32 reg1 = 0; |
53 | u8 reg3; | 53 | u8 reg3 = 0; |
54 | 54 | ||
55 | rtsx_pci_read_config_dword(pcr, PCR_SETTING_REG1, ®1); | 55 | rtsx_pci_read_config_dword(pcr, PCR_SETTING_REG1, ®1); |
56 | dev_dbg(&(pcr->pci->dev), "Cfg 0x%x: 0x%x\n", PCR_SETTING_REG1, reg1); | 56 | dev_dbg(&(pcr->pci->dev), "Cfg 0x%x: 0x%x\n", PCR_SETTING_REG1, reg1); |
@@ -71,7 +71,7 @@ static void rtl8411_fetch_vendor_settings(struct rtsx_pcr *pcr) | |||
71 | 71 | ||
72 | static void rtl8411b_fetch_vendor_settings(struct rtsx_pcr *pcr) | 72 | static void rtl8411b_fetch_vendor_settings(struct rtsx_pcr *pcr) |
73 | { | 73 | { |
74 | u32 reg; | 74 | u32 reg = 0; |
75 | 75 | ||
76 | rtsx_pci_read_config_dword(pcr, PCR_SETTING_REG1, ®); | 76 | rtsx_pci_read_config_dword(pcr, PCR_SETTING_REG1, ®); |
77 | dev_dbg(&(pcr->pci->dev), "Cfg 0x%x: 0x%x\n", PCR_SETTING_REG1, reg); | 77 | dev_dbg(&(pcr->pci->dev), "Cfg 0x%x: 0x%x\n", PCR_SETTING_REG1, reg); |
@@ -191,24 +191,25 @@ static int rtl8411_card_power_off(struct rtsx_pcr *pcr, int card) | |||
191 | BPP_LDO_POWB, BPP_LDO_SUSPEND); | 191 | BPP_LDO_POWB, BPP_LDO_SUSPEND); |
192 | } | 192 | } |
193 | 193 | ||
194 | static int rtl8411_switch_output_voltage(struct rtsx_pcr *pcr, u8 voltage) | 194 | static int rtl8411_do_switch_output_voltage(struct rtsx_pcr *pcr, u8 voltage, |
195 | int bpp_tuned18_shift, int bpp_asic_1v8) | ||
195 | { | 196 | { |
196 | u8 mask, val; | 197 | u8 mask, val; |
197 | int err; | 198 | int err; |
198 | 199 | ||
199 | mask = (BPP_REG_TUNED18 << BPP_TUNED18_SHIFT_8411) | BPP_PAD_MASK; | 200 | mask = (BPP_REG_TUNED18 << bpp_tuned18_shift) | BPP_PAD_MASK; |
200 | if (voltage == OUTPUT_3V3) { | 201 | if (voltage == OUTPUT_3V3) { |
201 | err = rtsx_pci_write_register(pcr, | 202 | err = rtsx_pci_write_register(pcr, |
202 | SD30_DRIVE_SEL, 0x07, pcr->sd30_drive_sel_3v3); | 203 | SD30_DRIVE_SEL, 0x07, pcr->sd30_drive_sel_3v3); |
203 | if (err < 0) | 204 | if (err < 0) |
204 | return err; | 205 | return err; |
205 | val = (BPP_ASIC_3V3 << BPP_TUNED18_SHIFT_8411) | BPP_PAD_3V3; | 206 | val = (BPP_ASIC_3V3 << bpp_tuned18_shift) | BPP_PAD_3V3; |
206 | } else if (voltage == OUTPUT_1V8) { | 207 | } else if (voltage == OUTPUT_1V8) { |
207 | err = rtsx_pci_write_register(pcr, | 208 | err = rtsx_pci_write_register(pcr, |
208 | SD30_DRIVE_SEL, 0x07, pcr->sd30_drive_sel_1v8); | 209 | SD30_DRIVE_SEL, 0x07, pcr->sd30_drive_sel_1v8); |
209 | if (err < 0) | 210 | if (err < 0) |
210 | return err; | 211 | return err; |
211 | val = (BPP_ASIC_1V8 << BPP_TUNED18_SHIFT_8411) | BPP_PAD_1V8; | 212 | val = (bpp_asic_1v8 << bpp_tuned18_shift) | BPP_PAD_1V8; |
212 | } else { | 213 | } else { |
213 | return -EINVAL; | 214 | return -EINVAL; |
214 | } | 215 | } |
@@ -216,6 +217,18 @@ static int rtl8411_switch_output_voltage(struct rtsx_pcr *pcr, u8 voltage) | |||
216 | return rtsx_pci_write_register(pcr, LDO_CTL, mask, val); | 217 | return rtsx_pci_write_register(pcr, LDO_CTL, mask, val); |
217 | } | 218 | } |
218 | 219 | ||
220 | static int rtl8411_switch_output_voltage(struct rtsx_pcr *pcr, u8 voltage) | ||
221 | { | ||
222 | return rtl8411_do_switch_output_voltage(pcr, voltage, | ||
223 | BPP_TUNED18_SHIFT_8411, BPP_ASIC_1V8); | ||
224 | } | ||
225 | |||
226 | static int rtl8402_switch_output_voltage(struct rtsx_pcr *pcr, u8 voltage) | ||
227 | { | ||
228 | return rtl8411_do_switch_output_voltage(pcr, voltage, | ||
229 | BPP_TUNED18_SHIFT_8402, BPP_ASIC_2V0); | ||
230 | } | ||
231 | |||
219 | static unsigned int rtl8411_cd_deglitch(struct rtsx_pcr *pcr) | 232 | static unsigned int rtl8411_cd_deglitch(struct rtsx_pcr *pcr) |
220 | { | 233 | { |
221 | unsigned int card_exist; | 234 | unsigned int card_exist; |
@@ -295,6 +308,22 @@ static const struct pcr_ops rtl8411_pcr_ops = { | |||
295 | .force_power_down = rtl8411_force_power_down, | 308 | .force_power_down = rtl8411_force_power_down, |
296 | }; | 309 | }; |
297 | 310 | ||
311 | static const struct pcr_ops rtl8402_pcr_ops = { | ||
312 | .fetch_vendor_settings = rtl8411_fetch_vendor_settings, | ||
313 | .extra_init_hw = rtl8411_extra_init_hw, | ||
314 | .optimize_phy = NULL, | ||
315 | .turn_on_led = rtl8411_turn_on_led, | ||
316 | .turn_off_led = rtl8411_turn_off_led, | ||
317 | .enable_auto_blink = rtl8411_enable_auto_blink, | ||
318 | .disable_auto_blink = rtl8411_disable_auto_blink, | ||
319 | .card_power_on = rtl8411_card_power_on, | ||
320 | .card_power_off = rtl8411_card_power_off, | ||
321 | .switch_output_voltage = rtl8402_switch_output_voltage, | ||
322 | .cd_deglitch = rtl8411_cd_deglitch, | ||
323 | .conv_clk_and_div_n = rtl8411_conv_clk_and_div_n, | ||
324 | .force_power_down = rtl8411_force_power_down, | ||
325 | }; | ||
326 | |||
298 | static const struct pcr_ops rtl8411b_pcr_ops = { | 327 | static const struct pcr_ops rtl8411b_pcr_ops = { |
299 | .fetch_vendor_settings = rtl8411b_fetch_vendor_settings, | 328 | .fetch_vendor_settings = rtl8411b_fetch_vendor_settings, |
300 | .extra_init_hw = rtl8411b_extra_init_hw, | 329 | .extra_init_hw = rtl8411b_extra_init_hw, |
@@ -441,12 +470,10 @@ static const u32 rtl8411b_qfn48_ms_pull_ctl_disable_tbl[] = { | |||
441 | 0, | 470 | 0, |
442 | }; | 471 | }; |
443 | 472 | ||
444 | void rtl8411_init_params(struct rtsx_pcr *pcr) | 473 | static void rtl8411_init_common_params(struct rtsx_pcr *pcr) |
445 | { | 474 | { |
446 | pcr->extra_caps = EXTRA_CAPS_SD_SDR50 | EXTRA_CAPS_SD_SDR104; | 475 | pcr->extra_caps = EXTRA_CAPS_SD_SDR50 | EXTRA_CAPS_SD_SDR104; |
447 | pcr->num_slots = 2; | 476 | pcr->num_slots = 2; |
448 | pcr->ops = &rtl8411_pcr_ops; | ||
449 | |||
450 | pcr->flags = 0; | 477 | pcr->flags = 0; |
451 | pcr->card_drive_sel = RTL8411_CARD_DRIVE_DEFAULT; | 478 | pcr->card_drive_sel = RTL8411_CARD_DRIVE_DEFAULT; |
452 | pcr->sd30_drive_sel_1v8 = DRIVER_TYPE_B; | 479 | pcr->sd30_drive_sel_1v8 = DRIVER_TYPE_B; |
@@ -454,47 +481,29 @@ void rtl8411_init_params(struct rtsx_pcr *pcr) | |||
454 | pcr->aspm_en = ASPM_L1_EN; | 481 | pcr->aspm_en = ASPM_L1_EN; |
455 | pcr->tx_initial_phase = SET_CLOCK_PHASE(23, 7, 14); | 482 | pcr->tx_initial_phase = SET_CLOCK_PHASE(23, 7, 14); |
456 | pcr->rx_initial_phase = SET_CLOCK_PHASE(4, 3, 10); | 483 | pcr->rx_initial_phase = SET_CLOCK_PHASE(4, 3, 10); |
457 | |||
458 | pcr->ic_version = rtl8411_get_ic_version(pcr); | 484 | pcr->ic_version = rtl8411_get_ic_version(pcr); |
459 | pcr->sd_pull_ctl_enable_tbl = rtl8411_sd_pull_ctl_enable_tbl; | 485 | } |
460 | pcr->sd_pull_ctl_disable_tbl = rtl8411_sd_pull_ctl_disable_tbl; | 486 | |
461 | pcr->ms_pull_ctl_enable_tbl = rtl8411_ms_pull_ctl_enable_tbl; | 487 | void rtl8411_init_params(struct rtsx_pcr *pcr) |
462 | pcr->ms_pull_ctl_disable_tbl = rtl8411_ms_pull_ctl_disable_tbl; | 488 | { |
489 | rtl8411_init_common_params(pcr); | ||
490 | pcr->ops = &rtl8411_pcr_ops; | ||
491 | set_pull_ctrl_tables(pcr, rtl8411); | ||
463 | } | 492 | } |
464 | 493 | ||
465 | void rtl8411b_init_params(struct rtsx_pcr *pcr) | 494 | void rtl8411b_init_params(struct rtsx_pcr *pcr) |
466 | { | 495 | { |
467 | pcr->extra_caps = EXTRA_CAPS_SD_SDR50 | EXTRA_CAPS_SD_SDR104; | 496 | rtl8411_init_common_params(pcr); |
468 | pcr->num_slots = 2; | ||
469 | pcr->ops = &rtl8411b_pcr_ops; | 497 | pcr->ops = &rtl8411b_pcr_ops; |
498 | if (rtl8411b_is_qfn48(pcr)) | ||
499 | set_pull_ctrl_tables(pcr, rtl8411b_qfn48); | ||
500 | else | ||
501 | set_pull_ctrl_tables(pcr, rtl8411b_qfn64); | ||
502 | } | ||
470 | 503 | ||
471 | pcr->flags = 0; | 504 | void rtl8402_init_params(struct rtsx_pcr *pcr) |
472 | pcr->card_drive_sel = RTL8411_CARD_DRIVE_DEFAULT; | 505 | { |
473 | pcr->sd30_drive_sel_1v8 = DRIVER_TYPE_B; | 506 | rtl8411_init_common_params(pcr); |
474 | pcr->sd30_drive_sel_3v3 = DRIVER_TYPE_D; | 507 | pcr->ops = &rtl8402_pcr_ops; |
475 | pcr->aspm_en = ASPM_L1_EN; | 508 | set_pull_ctrl_tables(pcr, rtl8411); |
476 | pcr->tx_initial_phase = SET_CLOCK_PHASE(23, 7, 14); | ||
477 | pcr->rx_initial_phase = SET_CLOCK_PHASE(4, 3, 10); | ||
478 | |||
479 | pcr->ic_version = rtl8411_get_ic_version(pcr); | ||
480 | |||
481 | if (rtl8411b_is_qfn48(pcr)) { | ||
482 | pcr->sd_pull_ctl_enable_tbl = | ||
483 | rtl8411b_qfn48_sd_pull_ctl_enable_tbl; | ||
484 | pcr->sd_pull_ctl_disable_tbl = | ||
485 | rtl8411b_qfn48_sd_pull_ctl_disable_tbl; | ||
486 | pcr->ms_pull_ctl_enable_tbl = | ||
487 | rtl8411b_qfn48_ms_pull_ctl_enable_tbl; | ||
488 | pcr->ms_pull_ctl_disable_tbl = | ||
489 | rtl8411b_qfn48_ms_pull_ctl_disable_tbl; | ||
490 | } else { | ||
491 | pcr->sd_pull_ctl_enable_tbl = | ||
492 | rtl8411b_qfn64_sd_pull_ctl_enable_tbl; | ||
493 | pcr->sd_pull_ctl_disable_tbl = | ||
494 | rtl8411b_qfn64_sd_pull_ctl_disable_tbl; | ||
495 | pcr->ms_pull_ctl_enable_tbl = | ||
496 | rtl8411b_qfn64_ms_pull_ctl_enable_tbl; | ||
497 | pcr->ms_pull_ctl_disable_tbl = | ||
498 | rtl8411b_qfn64_ms_pull_ctl_disable_tbl; | ||
499 | } | ||
500 | } | 509 | } |
diff --git a/drivers/mfd/rtsx_pcr.c b/drivers/mfd/rtsx_pcr.c index 705698fd2c7e..1d15735f9ef9 100644 --- a/drivers/mfd/rtsx_pcr.c +++ b/drivers/mfd/rtsx_pcr.c | |||
@@ -50,13 +50,14 @@ static struct mfd_cell rtsx_pcr_cells[] = { | |||
50 | }, | 50 | }, |
51 | }; | 51 | }; |
52 | 52 | ||
53 | static DEFINE_PCI_DEVICE_TABLE(rtsx_pci_ids) = { | 53 | static const struct pci_device_id rtsx_pci_ids[] = { |
54 | { PCI_DEVICE(0x10EC, 0x5209), PCI_CLASS_OTHERS << 16, 0xFF0000 }, | 54 | { PCI_DEVICE(0x10EC, 0x5209), PCI_CLASS_OTHERS << 16, 0xFF0000 }, |
55 | { PCI_DEVICE(0x10EC, 0x5229), PCI_CLASS_OTHERS << 16, 0xFF0000 }, | 55 | { PCI_DEVICE(0x10EC, 0x5229), PCI_CLASS_OTHERS << 16, 0xFF0000 }, |
56 | { PCI_DEVICE(0x10EC, 0x5289), PCI_CLASS_OTHERS << 16, 0xFF0000 }, | 56 | { PCI_DEVICE(0x10EC, 0x5289), PCI_CLASS_OTHERS << 16, 0xFF0000 }, |
57 | { PCI_DEVICE(0x10EC, 0x5227), PCI_CLASS_OTHERS << 16, 0xFF0000 }, | 57 | { PCI_DEVICE(0x10EC, 0x5227), PCI_CLASS_OTHERS << 16, 0xFF0000 }, |
58 | { PCI_DEVICE(0x10EC, 0x5249), PCI_CLASS_OTHERS << 16, 0xFF0000 }, | 58 | { PCI_DEVICE(0x10EC, 0x5249), PCI_CLASS_OTHERS << 16, 0xFF0000 }, |
59 | { PCI_DEVICE(0x10EC, 0x5287), PCI_CLASS_OTHERS << 16, 0xFF0000 }, | 59 | { PCI_DEVICE(0x10EC, 0x5287), PCI_CLASS_OTHERS << 16, 0xFF0000 }, |
60 | { PCI_DEVICE(0x10EC, 0x5286), PCI_CLASS_OTHERS << 16, 0xFF0000 }, | ||
60 | { 0, } | 61 | { 0, } |
61 | }; | 62 | }; |
62 | 63 | ||
@@ -1061,6 +1062,10 @@ static int rtsx_pci_init_chip(struct rtsx_pcr *pcr) | |||
1061 | case 0x5287: | 1062 | case 0x5287: |
1062 | rtl8411b_init_params(pcr); | 1063 | rtl8411b_init_params(pcr); |
1063 | break; | 1064 | break; |
1065 | |||
1066 | case 0x5286: | ||
1067 | rtl8402_init_params(pcr); | ||
1068 | break; | ||
1064 | } | 1069 | } |
1065 | 1070 | ||
1066 | dev_dbg(&(pcr->pci->dev), "PID: 0x%04x, IC version: 0x%02x\n", | 1071 | dev_dbg(&(pcr->pci->dev), "PID: 0x%04x, IC version: 0x%02x\n", |
diff --git a/drivers/mfd/rtsx_pcr.h b/drivers/mfd/rtsx_pcr.h index 947e79b05ceb..07e4c2ebf05a 100644 --- a/drivers/mfd/rtsx_pcr.h +++ b/drivers/mfd/rtsx_pcr.h | |||
@@ -30,6 +30,7 @@ | |||
30 | void rts5209_init_params(struct rtsx_pcr *pcr); | 30 | void rts5209_init_params(struct rtsx_pcr *pcr); |
31 | void rts5229_init_params(struct rtsx_pcr *pcr); | 31 | void rts5229_init_params(struct rtsx_pcr *pcr); |
32 | void rtl8411_init_params(struct rtsx_pcr *pcr); | 32 | void rtl8411_init_params(struct rtsx_pcr *pcr); |
33 | void rtl8402_init_params(struct rtsx_pcr *pcr); | ||
33 | void rts5227_init_params(struct rtsx_pcr *pcr); | 34 | void rts5227_init_params(struct rtsx_pcr *pcr); |
34 | void rts5249_init_params(struct rtsx_pcr *pcr); | 35 | void rts5249_init_params(struct rtsx_pcr *pcr); |
35 | void rtl8411b_init_params(struct rtsx_pcr *pcr); | 36 | void rtl8411b_init_params(struct rtsx_pcr *pcr); |
@@ -63,4 +64,12 @@ static inline u8 map_sd_drive(int idx) | |||
63 | #define rtl8411_reg_to_sd30_drive_sel_3v3(reg) (((reg) >> 5) & 0x07) | 64 | #define rtl8411_reg_to_sd30_drive_sel_3v3(reg) (((reg) >> 5) & 0x07) |
64 | #define rtl8411b_reg_to_sd30_drive_sel_3v3(reg) ((reg) & 0x03) | 65 | #define rtl8411b_reg_to_sd30_drive_sel_3v3(reg) ((reg) & 0x03) |
65 | 66 | ||
67 | #define set_pull_ctrl_tables(pcr, __device) \ | ||
68 | do { \ | ||
69 | pcr->sd_pull_ctl_enable_tbl = __device##_sd_pull_ctl_enable_tbl; \ | ||
70 | pcr->sd_pull_ctl_disable_tbl = __device##_sd_pull_ctl_disable_tbl; \ | ||
71 | pcr->ms_pull_ctl_enable_tbl = __device##_ms_pull_ctl_enable_tbl; \ | ||
72 | pcr->ms_pull_ctl_disable_tbl = __device##_ms_pull_ctl_disable_tbl; \ | ||
73 | } while (0) | ||
74 | |||
66 | #endif | 75 | #endif |
diff --git a/drivers/mfd/sec-core.c b/drivers/mfd/sec-core.c index 54cc25546592..e4671088f075 100644 --- a/drivers/mfd/sec-core.c +++ b/drivers/mfd/sec-core.c | |||
@@ -31,7 +31,7 @@ | |||
31 | #include <linux/mfd/samsung/s5m8767.h> | 31 | #include <linux/mfd/samsung/s5m8767.h> |
32 | #include <linux/regmap.h> | 32 | #include <linux/regmap.h> |
33 | 33 | ||
34 | static struct mfd_cell s5m8751_devs[] = { | 34 | static const struct mfd_cell s5m8751_devs[] = { |
35 | { | 35 | { |
36 | .name = "s5m8751-pmic", | 36 | .name = "s5m8751-pmic", |
37 | }, { | 37 | }, { |
@@ -41,7 +41,7 @@ static struct mfd_cell s5m8751_devs[] = { | |||
41 | }, | 41 | }, |
42 | }; | 42 | }; |
43 | 43 | ||
44 | static struct mfd_cell s5m8763_devs[] = { | 44 | static const struct mfd_cell s5m8763_devs[] = { |
45 | { | 45 | { |
46 | .name = "s5m8763-pmic", | 46 | .name = "s5m8763-pmic", |
47 | }, { | 47 | }, { |
@@ -51,15 +51,17 @@ static struct mfd_cell s5m8763_devs[] = { | |||
51 | }, | 51 | }, |
52 | }; | 52 | }; |
53 | 53 | ||
54 | static struct mfd_cell s5m8767_devs[] = { | 54 | static const struct mfd_cell s5m8767_devs[] = { |
55 | { | 55 | { |
56 | .name = "s5m8767-pmic", | 56 | .name = "s5m8767-pmic", |
57 | }, { | 57 | }, { |
58 | .name = "s5m-rtc", | 58 | .name = "s5m-rtc", |
59 | }, | 59 | }, { |
60 | .name = "s5m8767-clk", | ||
61 | } | ||
60 | }; | 62 | }; |
61 | 63 | ||
62 | static struct mfd_cell s2mps11_devs[] = { | 64 | static const struct mfd_cell s2mps11_devs[] = { |
63 | { | 65 | { |
64 | .name = "s2mps11-pmic", | 66 | .name = "s2mps11-pmic", |
65 | }, { | 67 | }, { |
@@ -134,12 +136,12 @@ static bool s5m8763_volatile(struct device *dev, unsigned int reg) | |||
134 | } | 136 | } |
135 | } | 137 | } |
136 | 138 | ||
137 | static struct regmap_config sec_regmap_config = { | 139 | static const struct regmap_config sec_regmap_config = { |
138 | .reg_bits = 8, | 140 | .reg_bits = 8, |
139 | .val_bits = 8, | 141 | .val_bits = 8, |
140 | }; | 142 | }; |
141 | 143 | ||
142 | static struct regmap_config s2mps11_regmap_config = { | 144 | static const struct regmap_config s2mps11_regmap_config = { |
143 | .reg_bits = 8, | 145 | .reg_bits = 8, |
144 | .val_bits = 8, | 146 | .val_bits = 8, |
145 | 147 | ||
@@ -148,7 +150,7 @@ static struct regmap_config s2mps11_regmap_config = { | |||
148 | .cache_type = REGCACHE_FLAT, | 150 | .cache_type = REGCACHE_FLAT, |
149 | }; | 151 | }; |
150 | 152 | ||
151 | static struct regmap_config s5m8763_regmap_config = { | 153 | static const struct regmap_config s5m8763_regmap_config = { |
152 | .reg_bits = 8, | 154 | .reg_bits = 8, |
153 | .val_bits = 8, | 155 | .val_bits = 8, |
154 | 156 | ||
@@ -157,7 +159,7 @@ static struct regmap_config s5m8763_regmap_config = { | |||
157 | .cache_type = REGCACHE_FLAT, | 159 | .cache_type = REGCACHE_FLAT, |
158 | }; | 160 | }; |
159 | 161 | ||
160 | static struct regmap_config s5m8767_regmap_config = { | 162 | static const struct regmap_config s5m8767_regmap_config = { |
161 | .reg_bits = 8, | 163 | .reg_bits = 8, |
162 | .val_bits = 8, | 164 | .val_bits = 8, |
163 | 165 | ||
@@ -204,7 +206,7 @@ static struct sec_platform_data *sec_pmic_i2c_parse_dt_pdata( | |||
204 | static struct sec_platform_data *sec_pmic_i2c_parse_dt_pdata( | 206 | static struct sec_platform_data *sec_pmic_i2c_parse_dt_pdata( |
205 | struct device *dev) | 207 | struct device *dev) |
206 | { | 208 | { |
207 | return 0; | 209 | return NULL; |
208 | } | 210 | } |
209 | #endif | 211 | #endif |
210 | 212 | ||
@@ -323,6 +325,8 @@ static int sec_pmic_probe(struct i2c_client *i2c, | |||
323 | if (ret) | 325 | if (ret) |
324 | goto err; | 326 | goto err; |
325 | 327 | ||
328 | device_init_wakeup(sec_pmic->dev, sec_pmic->wakeup); | ||
329 | |||
326 | return ret; | 330 | return ret; |
327 | 331 | ||
328 | err: | 332 | err: |
@@ -341,6 +345,43 @@ static int sec_pmic_remove(struct i2c_client *i2c) | |||
341 | return 0; | 345 | return 0; |
342 | } | 346 | } |
343 | 347 | ||
348 | static int sec_pmic_suspend(struct device *dev) | ||
349 | { | ||
350 | struct i2c_client *i2c = container_of(dev, struct i2c_client, dev); | ||
351 | struct sec_pmic_dev *sec_pmic = i2c_get_clientdata(i2c); | ||
352 | |||
353 | if (device_may_wakeup(dev)) { | ||
354 | enable_irq_wake(sec_pmic->irq); | ||
355 | /* | ||
356 | * PMIC IRQ must be disabled during suspend for RTC alarm | ||
357 | * to work properly. | ||
358 | * When device is woken up from suspend by RTC Alarm, an | ||
359 | * interrupt occurs before resuming I2C bus controller. | ||
360 | * The interrupt is handled by regmap_irq_thread which tries | ||
361 | * to read RTC registers. This read fails (I2C is still | ||
362 | * suspended) and RTC Alarm interrupt is disabled. | ||
363 | */ | ||
364 | disable_irq(sec_pmic->irq); | ||
365 | } | ||
366 | |||
367 | return 0; | ||
368 | } | ||
369 | |||
370 | static int sec_pmic_resume(struct device *dev) | ||
371 | { | ||
372 | struct i2c_client *i2c = container_of(dev, struct i2c_client, dev); | ||
373 | struct sec_pmic_dev *sec_pmic = i2c_get_clientdata(i2c); | ||
374 | |||
375 | if (device_may_wakeup(dev)) { | ||
376 | disable_irq_wake(sec_pmic->irq); | ||
377 | enable_irq(sec_pmic->irq); | ||
378 | } | ||
379 | |||
380 | return 0; | ||
381 | } | ||
382 | |||
383 | static SIMPLE_DEV_PM_OPS(sec_pmic_pm_ops, sec_pmic_suspend, sec_pmic_resume); | ||
384 | |||
344 | static const struct i2c_device_id sec_pmic_id[] = { | 385 | static const struct i2c_device_id sec_pmic_id[] = { |
345 | { "sec_pmic", 0 }, | 386 | { "sec_pmic", 0 }, |
346 | { } | 387 | { } |
@@ -351,6 +392,7 @@ static struct i2c_driver sec_pmic_driver = { | |||
351 | .driver = { | 392 | .driver = { |
352 | .name = "sec_pmic", | 393 | .name = "sec_pmic", |
353 | .owner = THIS_MODULE, | 394 | .owner = THIS_MODULE, |
395 | .pm = &sec_pmic_pm_ops, | ||
354 | .of_match_table = of_match_ptr(sec_dt_match), | 396 | .of_match_table = of_match_ptr(sec_dt_match), |
355 | }, | 397 | }, |
356 | .probe = sec_pmic_probe, | 398 | .probe = sec_pmic_probe, |
diff --git a/drivers/mfd/sec-irq.c b/drivers/mfd/sec-irq.c index b441b1be27cb..4de494f51d40 100644 --- a/drivers/mfd/sec-irq.c +++ b/drivers/mfd/sec-irq.c | |||
@@ -22,7 +22,7 @@ | |||
22 | #include <linux/mfd/samsung/s5m8763.h> | 22 | #include <linux/mfd/samsung/s5m8763.h> |
23 | #include <linux/mfd/samsung/s5m8767.h> | 23 | #include <linux/mfd/samsung/s5m8767.h> |
24 | 24 | ||
25 | static struct regmap_irq s2mps11_irqs[] = { | 25 | static const struct regmap_irq s2mps11_irqs[] = { |
26 | [S2MPS11_IRQ_PWRONF] = { | 26 | [S2MPS11_IRQ_PWRONF] = { |
27 | .reg_offset = 0, | 27 | .reg_offset = 0, |
28 | .mask = S2MPS11_IRQ_PWRONF_MASK, | 28 | .mask = S2MPS11_IRQ_PWRONF_MASK, |
@@ -90,7 +90,7 @@ static struct regmap_irq s2mps11_irqs[] = { | |||
90 | }; | 90 | }; |
91 | 91 | ||
92 | 92 | ||
93 | static struct regmap_irq s5m8767_irqs[] = { | 93 | static const struct regmap_irq s5m8767_irqs[] = { |
94 | [S5M8767_IRQ_PWRR] = { | 94 | [S5M8767_IRQ_PWRR] = { |
95 | .reg_offset = 0, | 95 | .reg_offset = 0, |
96 | .mask = S5M8767_IRQ_PWRR_MASK, | 96 | .mask = S5M8767_IRQ_PWRR_MASK, |
@@ -161,7 +161,7 @@ static struct regmap_irq s5m8767_irqs[] = { | |||
161 | }, | 161 | }, |
162 | }; | 162 | }; |
163 | 163 | ||
164 | static struct regmap_irq s5m8763_irqs[] = { | 164 | static const struct regmap_irq s5m8763_irqs[] = { |
165 | [S5M8763_IRQ_DCINF] = { | 165 | [S5M8763_IRQ_DCINF] = { |
166 | .reg_offset = 0, | 166 | .reg_offset = 0, |
167 | .mask = S5M8763_IRQ_DCINF_MASK, | 167 | .mask = S5M8763_IRQ_DCINF_MASK, |
@@ -236,7 +236,7 @@ static struct regmap_irq s5m8763_irqs[] = { | |||
236 | }, | 236 | }, |
237 | }; | 237 | }; |
238 | 238 | ||
239 | static struct regmap_irq_chip s2mps11_irq_chip = { | 239 | static const struct regmap_irq_chip s2mps11_irq_chip = { |
240 | .name = "s2mps11", | 240 | .name = "s2mps11", |
241 | .irqs = s2mps11_irqs, | 241 | .irqs = s2mps11_irqs, |
242 | .num_irqs = ARRAY_SIZE(s2mps11_irqs), | 242 | .num_irqs = ARRAY_SIZE(s2mps11_irqs), |
@@ -246,7 +246,7 @@ static struct regmap_irq_chip s2mps11_irq_chip = { | |||
246 | .ack_base = S2MPS11_REG_INT1, | 246 | .ack_base = S2MPS11_REG_INT1, |
247 | }; | 247 | }; |
248 | 248 | ||
249 | static struct regmap_irq_chip s5m8767_irq_chip = { | 249 | static const struct regmap_irq_chip s5m8767_irq_chip = { |
250 | .name = "s5m8767", | 250 | .name = "s5m8767", |
251 | .irqs = s5m8767_irqs, | 251 | .irqs = s5m8767_irqs, |
252 | .num_irqs = ARRAY_SIZE(s5m8767_irqs), | 252 | .num_irqs = ARRAY_SIZE(s5m8767_irqs), |
@@ -256,7 +256,7 @@ static struct regmap_irq_chip s5m8767_irq_chip = { | |||
256 | .ack_base = S5M8767_REG_INT1, | 256 | .ack_base = S5M8767_REG_INT1, |
257 | }; | 257 | }; |
258 | 258 | ||
259 | static struct regmap_irq_chip s5m8763_irq_chip = { | 259 | static const struct regmap_irq_chip s5m8763_irq_chip = { |
260 | .name = "s5m8763", | 260 | .name = "s5m8763", |
261 | .irqs = s5m8763_irqs, | 261 | .irqs = s5m8763_irqs, |
262 | .num_irqs = ARRAY_SIZE(s5m8763_irqs), | 262 | .num_irqs = ARRAY_SIZE(s5m8763_irqs), |
diff --git a/drivers/mfd/sm501.c b/drivers/mfd/sm501.c index c2c8c91c6c7b..e7dc441a8f8a 100644 --- a/drivers/mfd/sm501.c +++ b/drivers/mfd/sm501.c | |||
@@ -1710,7 +1710,7 @@ static int sm501_plat_remove(struct platform_device *dev) | |||
1710 | return 0; | 1710 | return 0; |
1711 | } | 1711 | } |
1712 | 1712 | ||
1713 | static DEFINE_PCI_DEVICE_TABLE(sm501_pci_tbl) = { | 1713 | static const struct pci_device_id sm501_pci_tbl[] = { |
1714 | { 0x126f, 0x0501, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, | 1714 | { 0x126f, 0x0501, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, |
1715 | { 0, }, | 1715 | { 0, }, |
1716 | }; | 1716 | }; |
diff --git a/drivers/mfd/ssbi.c b/drivers/mfd/ssbi.c index 102a22844297..b78942ed4c67 100644 --- a/drivers/mfd/ssbi.c +++ b/drivers/mfd/ssbi.c | |||
@@ -65,13 +65,19 @@ | |||
65 | 65 | ||
66 | #define SSBI_TIMEOUT_US 100 | 66 | #define SSBI_TIMEOUT_US 100 |
67 | 67 | ||
68 | enum ssbi_controller_type { | ||
69 | MSM_SBI_CTRL_SSBI = 0, | ||
70 | MSM_SBI_CTRL_SSBI2, | ||
71 | MSM_SBI_CTRL_PMIC_ARBITER, | ||
72 | }; | ||
73 | |||
68 | struct ssbi { | 74 | struct ssbi { |
69 | struct device *slave; | 75 | struct device *slave; |
70 | void __iomem *base; | 76 | void __iomem *base; |
71 | spinlock_t lock; | 77 | spinlock_t lock; |
72 | enum ssbi_controller_type controller_type; | 78 | enum ssbi_controller_type controller_type; |
73 | int (*read)(struct ssbi *, u16 addr, u8 *buf, int len); | 79 | int (*read)(struct ssbi *, u16 addr, u8 *buf, int len); |
74 | int (*write)(struct ssbi *, u16 addr, u8 *buf, int len); | 80 | int (*write)(struct ssbi *, u16 addr, const u8 *buf, int len); |
75 | }; | 81 | }; |
76 | 82 | ||
77 | #define to_ssbi(dev) platform_get_drvdata(to_platform_device(dev)) | 83 | #define to_ssbi(dev) platform_get_drvdata(to_platform_device(dev)) |
@@ -140,7 +146,7 @@ err: | |||
140 | } | 146 | } |
141 | 147 | ||
142 | static int | 148 | static int |
143 | ssbi_write_bytes(struct ssbi *ssbi, u16 addr, u8 *buf, int len) | 149 | ssbi_write_bytes(struct ssbi *ssbi, u16 addr, const u8 *buf, int len) |
144 | { | 150 | { |
145 | int ret = 0; | 151 | int ret = 0; |
146 | 152 | ||
@@ -217,7 +223,7 @@ err: | |||
217 | } | 223 | } |
218 | 224 | ||
219 | static int | 225 | static int |
220 | ssbi_pa_write_bytes(struct ssbi *ssbi, u16 addr, u8 *buf, int len) | 226 | ssbi_pa_write_bytes(struct ssbi *ssbi, u16 addr, const u8 *buf, int len) |
221 | { | 227 | { |
222 | u32 cmd; | 228 | u32 cmd; |
223 | int ret = 0; | 229 | int ret = 0; |
@@ -249,7 +255,7 @@ int ssbi_read(struct device *dev, u16 addr, u8 *buf, int len) | |||
249 | } | 255 | } |
250 | EXPORT_SYMBOL_GPL(ssbi_read); | 256 | EXPORT_SYMBOL_GPL(ssbi_read); |
251 | 257 | ||
252 | int ssbi_write(struct device *dev, u16 addr, u8 *buf, int len) | 258 | int ssbi_write(struct device *dev, u16 addr, const u8 *buf, int len) |
253 | { | 259 | { |
254 | struct ssbi *ssbi = to_ssbi(dev); | 260 | struct ssbi *ssbi = to_ssbi(dev); |
255 | unsigned long flags; | 261 | unsigned long flags; |
@@ -311,7 +317,7 @@ static int ssbi_probe(struct platform_device *pdev) | |||
311 | return of_platform_populate(np, NULL, NULL, &pdev->dev); | 317 | return of_platform_populate(np, NULL, NULL, &pdev->dev); |
312 | } | 318 | } |
313 | 319 | ||
314 | static struct of_device_id ssbi_match_table[] = { | 320 | static const struct of_device_id ssbi_match_table[] = { |
315 | { .compatible = "qcom,ssbi" }, | 321 | { .compatible = "qcom,ssbi" }, |
316 | {} | 322 | {} |
317 | }; | 323 | }; |
diff --git a/drivers/mfd/sta2x11-mfd.c b/drivers/mfd/sta2x11-mfd.c index 65c6fa671acb..5b72db07d9de 100644 --- a/drivers/mfd/sta2x11-mfd.c +++ b/drivers/mfd/sta2x11-mfd.c | |||
@@ -339,7 +339,7 @@ static int sta2x11_mfd_platform_probe(struct platform_device *dev, | |||
339 | regmap_config->cache_type = REGCACHE_NONE; | 339 | regmap_config->cache_type = REGCACHE_NONE; |
340 | mfd->regmap[index] = devm_regmap_init_mmio(&dev->dev, mfd->regs[index], | 340 | mfd->regmap[index] = devm_regmap_init_mmio(&dev->dev, mfd->regs[index], |
341 | regmap_config); | 341 | regmap_config); |
342 | WARN_ON(!mfd->regmap[index]); | 342 | WARN_ON(IS_ERR(mfd->regmap[index])); |
343 | 343 | ||
344 | return 0; | 344 | return 0; |
345 | } | 345 | } |
@@ -529,7 +529,7 @@ static int sta2x11_mfd_resume(struct pci_dev *pdev) | |||
529 | { | 529 | { |
530 | int err; | 530 | int err; |
531 | 531 | ||
532 | pci_set_power_state(pdev, 0); | 532 | pci_set_power_state(pdev, PCI_D0); |
533 | err = pci_enable_device(pdev); | 533 | err = pci_enable_device(pdev); |
534 | if (err) | 534 | if (err) |
535 | return err; | 535 | return err; |
@@ -642,7 +642,7 @@ err_disable: | |||
642 | return err; | 642 | return err; |
643 | } | 643 | } |
644 | 644 | ||
645 | static DEFINE_PCI_DEVICE_TABLE(sta2x11_mfd_tbl) = { | 645 | static const struct pci_device_id sta2x11_mfd_tbl[] = { |
646 | {PCI_DEVICE(PCI_VENDOR_ID_STMICRO, PCI_DEVICE_ID_STMICRO_GPIO)}, | 646 | {PCI_DEVICE(PCI_VENDOR_ID_STMICRO, PCI_DEVICE_ID_STMICRO_GPIO)}, |
647 | {PCI_DEVICE(PCI_VENDOR_ID_STMICRO, PCI_DEVICE_ID_STMICRO_VIC)}, | 647 | {PCI_DEVICE(PCI_VENDOR_ID_STMICRO, PCI_DEVICE_ID_STMICRO_VIC)}, |
648 | {0,}, | 648 | {0,}, |
diff --git a/drivers/mfd/stmpe.c b/drivers/mfd/stmpe.c index fff63a41862c..42ccd0544513 100644 --- a/drivers/mfd/stmpe.c +++ b/drivers/mfd/stmpe.c | |||
@@ -297,14 +297,14 @@ static struct resource stmpe_gpio_resources[] = { | |||
297 | }, | 297 | }, |
298 | }; | 298 | }; |
299 | 299 | ||
300 | static struct mfd_cell stmpe_gpio_cell = { | 300 | static const struct mfd_cell stmpe_gpio_cell = { |
301 | .name = "stmpe-gpio", | 301 | .name = "stmpe-gpio", |
302 | .of_compatible = "st,stmpe-gpio", | 302 | .of_compatible = "st,stmpe-gpio", |
303 | .resources = stmpe_gpio_resources, | 303 | .resources = stmpe_gpio_resources, |
304 | .num_resources = ARRAY_SIZE(stmpe_gpio_resources), | 304 | .num_resources = ARRAY_SIZE(stmpe_gpio_resources), |
305 | }; | 305 | }; |
306 | 306 | ||
307 | static struct mfd_cell stmpe_gpio_cell_noirq = { | 307 | static const struct mfd_cell stmpe_gpio_cell_noirq = { |
308 | .name = "stmpe-gpio", | 308 | .name = "stmpe-gpio", |
309 | .of_compatible = "st,stmpe-gpio", | 309 | .of_compatible = "st,stmpe-gpio", |
310 | /* gpio cell resources consist of an irq only so no resources here */ | 310 | /* gpio cell resources consist of an irq only so no resources here */ |
@@ -325,7 +325,7 @@ static struct resource stmpe_keypad_resources[] = { | |||
325 | }, | 325 | }, |
326 | }; | 326 | }; |
327 | 327 | ||
328 | static struct mfd_cell stmpe_keypad_cell = { | 328 | static const struct mfd_cell stmpe_keypad_cell = { |
329 | .name = "stmpe-keypad", | 329 | .name = "stmpe-keypad", |
330 | .of_compatible = "st,stmpe-keypad", | 330 | .of_compatible = "st,stmpe-keypad", |
331 | .resources = stmpe_keypad_resources, | 331 | .resources = stmpe_keypad_resources, |
@@ -409,7 +409,7 @@ static struct resource stmpe_ts_resources[] = { | |||
409 | }, | 409 | }, |
410 | }; | 410 | }; |
411 | 411 | ||
412 | static struct mfd_cell stmpe_ts_cell = { | 412 | static const struct mfd_cell stmpe_ts_cell = { |
413 | .name = "stmpe-ts", | 413 | .name = "stmpe-ts", |
414 | .of_compatible = "st,stmpe-ts", | 414 | .of_compatible = "st,stmpe-ts", |
415 | .resources = stmpe_ts_resources, | 415 | .resources = stmpe_ts_resources, |
@@ -1064,7 +1064,7 @@ static int stmpe_chip_init(struct stmpe *stmpe) | |||
1064 | return stmpe_reg_write(stmpe, stmpe->regs[STMPE_IDX_ICR_LSB], icr); | 1064 | return stmpe_reg_write(stmpe, stmpe->regs[STMPE_IDX_ICR_LSB], icr); |
1065 | } | 1065 | } |
1066 | 1066 | ||
1067 | static int stmpe_add_device(struct stmpe *stmpe, struct mfd_cell *cell) | 1067 | static int stmpe_add_device(struct stmpe *stmpe, const struct mfd_cell *cell) |
1068 | { | 1068 | { |
1069 | return mfd_add_devices(stmpe->dev, stmpe->pdata->id, cell, 1, | 1069 | return mfd_add_devices(stmpe->dev, stmpe->pdata->id, cell, 1, |
1070 | NULL, stmpe->irq_base, stmpe->domain); | 1070 | NULL, stmpe->irq_base, stmpe->domain); |
diff --git a/drivers/mfd/stmpe.h b/drivers/mfd/stmpe.h index ff2b09ba8797..6639f1b0fef5 100644 --- a/drivers/mfd/stmpe.h +++ b/drivers/mfd/stmpe.h | |||
@@ -38,7 +38,7 @@ static inline void stmpe_dump_bytes(const char *str, const void *buf, | |||
38 | * enable and altfunc callbacks | 38 | * enable and altfunc callbacks |
39 | */ | 39 | */ |
40 | struct stmpe_variant_block { | 40 | struct stmpe_variant_block { |
41 | struct mfd_cell *cell; | 41 | const struct mfd_cell *cell; |
42 | int irq; | 42 | int irq; |
43 | enum stmpe_block block; | 43 | enum stmpe_block block; |
44 | }; | 44 | }; |
diff --git a/drivers/mfd/tc3589x.c b/drivers/mfd/tc3589x.c index 87ea51dc6234..2cf636c267d9 100644 --- a/drivers/mfd/tc3589x.c +++ b/drivers/mfd/tc3589x.c | |||
@@ -155,7 +155,7 @@ static struct resource keypad_resources[] = { | |||
155 | }, | 155 | }, |
156 | }; | 156 | }; |
157 | 157 | ||
158 | static struct mfd_cell tc3589x_dev_gpio[] = { | 158 | static const struct mfd_cell tc3589x_dev_gpio[] = { |
159 | { | 159 | { |
160 | .name = "tc3589x-gpio", | 160 | .name = "tc3589x-gpio", |
161 | .num_resources = ARRAY_SIZE(gpio_resources), | 161 | .num_resources = ARRAY_SIZE(gpio_resources), |
@@ -164,7 +164,7 @@ static struct mfd_cell tc3589x_dev_gpio[] = { | |||
164 | }, | 164 | }, |
165 | }; | 165 | }; |
166 | 166 | ||
167 | static struct mfd_cell tc3589x_dev_keypad[] = { | 167 | static const struct mfd_cell tc3589x_dev_keypad[] = { |
168 | { | 168 | { |
169 | .name = "tc3589x-keypad", | 169 | .name = "tc3589x-keypad", |
170 | .num_resources = ARRAY_SIZE(keypad_resources), | 170 | .num_resources = ARRAY_SIZE(keypad_resources), |
diff --git a/drivers/mfd/tc6387xb.c b/drivers/mfd/tc6387xb.c index acd0f3a41044..591a331d8d83 100644 --- a/drivers/mfd/tc6387xb.c +++ b/drivers/mfd/tc6387xb.c | |||
@@ -126,7 +126,7 @@ static struct tmio_mmc_data tc6387xb_mmc_data = { | |||
126 | 126 | ||
127 | /*--------------------------------------------------------------------------*/ | 127 | /*--------------------------------------------------------------------------*/ |
128 | 128 | ||
129 | static struct mfd_cell tc6387xb_cells[] = { | 129 | static const struct mfd_cell tc6387xb_cells[] = { |
130 | [TC6387XB_CELL_MMC] = { | 130 | [TC6387XB_CELL_MMC] = { |
131 | .name = "tmio-mmc", | 131 | .name = "tmio-mmc", |
132 | .enable = tc6387xb_mmc_enable, | 132 | .enable = tc6387xb_mmc_enable, |
diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c index 88718abfb9ba..d4e860413bb5 100644 --- a/drivers/mfd/ti_am335x_tscadc.c +++ b/drivers/mfd/ti_am335x_tscadc.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <linux/pm_runtime.h> | 24 | #include <linux/pm_runtime.h> |
25 | #include <linux/of.h> | 25 | #include <linux/of.h> |
26 | #include <linux/of_device.h> | 26 | #include <linux/of_device.h> |
27 | #include <linux/sched.h> | ||
27 | 28 | ||
28 | #include <linux/mfd/ti_am335x_tscadc.h> | 29 | #include <linux/mfd/ti_am335x_tscadc.h> |
29 | 30 | ||
@@ -48,32 +49,79 @@ static const struct regmap_config tscadc_regmap_config = { | |||
48 | .val_bits = 32, | 49 | .val_bits = 32, |
49 | }; | 50 | }; |
50 | 51 | ||
51 | void am335x_tsc_se_update(struct ti_tscadc_dev *tsadc) | 52 | void am335x_tsc_se_set_cache(struct ti_tscadc_dev *tsadc, u32 val) |
52 | { | 53 | { |
53 | tscadc_writel(tsadc, REG_SE, tsadc->reg_se_cache); | 54 | unsigned long flags; |
55 | |||
56 | spin_lock_irqsave(&tsadc->reg_lock, flags); | ||
57 | tsadc->reg_se_cache = val; | ||
58 | if (tsadc->adc_waiting) | ||
59 | wake_up(&tsadc->reg_se_wait); | ||
60 | else if (!tsadc->adc_in_use) | ||
61 | tscadc_writel(tsadc, REG_SE, val); | ||
62 | |||
63 | spin_unlock_irqrestore(&tsadc->reg_lock, flags); | ||
64 | } | ||
65 | EXPORT_SYMBOL_GPL(am335x_tsc_se_set_cache); | ||
66 | |||
67 | static void am335x_tscadc_need_adc(struct ti_tscadc_dev *tsadc) | ||
68 | { | ||
69 | DEFINE_WAIT(wait); | ||
70 | u32 reg; | ||
71 | |||
72 | /* | ||
73 | * disable TSC steps so it does not run while the ADC is using it. If | ||
74 | * write 0 while it is running (it just started or was already running) | ||
75 | * then it completes all steps that were enabled and stops then. | ||
76 | */ | ||
77 | tscadc_writel(tsadc, REG_SE, 0); | ||
78 | reg = tscadc_readl(tsadc, REG_ADCFSM); | ||
79 | if (reg & SEQ_STATUS) { | ||
80 | tsadc->adc_waiting = true; | ||
81 | prepare_to_wait(&tsadc->reg_se_wait, &wait, | ||
82 | TASK_UNINTERRUPTIBLE); | ||
83 | spin_unlock_irq(&tsadc->reg_lock); | ||
84 | |||
85 | schedule(); | ||
86 | |||
87 | spin_lock_irq(&tsadc->reg_lock); | ||
88 | finish_wait(&tsadc->reg_se_wait, &wait); | ||
89 | |||
90 | reg = tscadc_readl(tsadc, REG_ADCFSM); | ||
91 | WARN_ON(reg & SEQ_STATUS); | ||
92 | tsadc->adc_waiting = false; | ||
93 | } | ||
94 | tsadc->adc_in_use = true; | ||
95 | } | ||
96 | |||
97 | void am335x_tsc_se_set_once(struct ti_tscadc_dev *tsadc, u32 val) | ||
98 | { | ||
99 | spin_lock_irq(&tsadc->reg_lock); | ||
100 | am335x_tscadc_need_adc(tsadc); | ||
101 | |||
102 | tscadc_writel(tsadc, REG_SE, val); | ||
103 | spin_unlock_irq(&tsadc->reg_lock); | ||
54 | } | 104 | } |
55 | EXPORT_SYMBOL_GPL(am335x_tsc_se_update); | 105 | EXPORT_SYMBOL_GPL(am335x_tsc_se_set_once); |
56 | 106 | ||
57 | void am335x_tsc_se_set(struct ti_tscadc_dev *tsadc, u32 val) | 107 | void am335x_tsc_se_adc_done(struct ti_tscadc_dev *tsadc) |
58 | { | 108 | { |
59 | unsigned long flags; | 109 | unsigned long flags; |
60 | 110 | ||
61 | spin_lock_irqsave(&tsadc->reg_lock, flags); | 111 | spin_lock_irqsave(&tsadc->reg_lock, flags); |
62 | tsadc->reg_se_cache = tscadc_readl(tsadc, REG_SE); | 112 | tsadc->adc_in_use = false; |
63 | tsadc->reg_se_cache |= val; | 113 | tscadc_writel(tsadc, REG_SE, tsadc->reg_se_cache); |
64 | am335x_tsc_se_update(tsadc); | ||
65 | spin_unlock_irqrestore(&tsadc->reg_lock, flags); | 114 | spin_unlock_irqrestore(&tsadc->reg_lock, flags); |
66 | } | 115 | } |
67 | EXPORT_SYMBOL_GPL(am335x_tsc_se_set); | 116 | EXPORT_SYMBOL_GPL(am335x_tsc_se_adc_done); |
68 | 117 | ||
69 | void am335x_tsc_se_clr(struct ti_tscadc_dev *tsadc, u32 val) | 118 | void am335x_tsc_se_clr(struct ti_tscadc_dev *tsadc, u32 val) |
70 | { | 119 | { |
71 | unsigned long flags; | 120 | unsigned long flags; |
72 | 121 | ||
73 | spin_lock_irqsave(&tsadc->reg_lock, flags); | 122 | spin_lock_irqsave(&tsadc->reg_lock, flags); |
74 | tsadc->reg_se_cache = tscadc_readl(tsadc, REG_SE); | ||
75 | tsadc->reg_se_cache &= ~val; | 123 | tsadc->reg_se_cache &= ~val; |
76 | am335x_tsc_se_update(tsadc); | 124 | tscadc_writel(tsadc, REG_SE, tsadc->reg_se_cache); |
77 | spin_unlock_irqrestore(&tsadc->reg_lock, flags); | 125 | spin_unlock_irqrestore(&tsadc->reg_lock, flags); |
78 | } | 126 | } |
79 | EXPORT_SYMBOL_GPL(am335x_tsc_se_clr); | 127 | EXPORT_SYMBOL_GPL(am335x_tsc_se_clr); |
@@ -181,6 +229,8 @@ static int ti_tscadc_probe(struct platform_device *pdev) | |||
181 | } | 229 | } |
182 | 230 | ||
183 | spin_lock_init(&tscadc->reg_lock); | 231 | spin_lock_init(&tscadc->reg_lock); |
232 | init_waitqueue_head(&tscadc->reg_se_wait); | ||
233 | |||
184 | pm_runtime_enable(&pdev->dev); | 234 | pm_runtime_enable(&pdev->dev); |
185 | pm_runtime_get_sync(&pdev->dev); | 235 | pm_runtime_get_sync(&pdev->dev); |
186 | 236 | ||
@@ -302,7 +352,6 @@ static int tscadc_resume(struct device *dev) | |||
302 | 352 | ||
303 | if (tscadc_dev->tsc_cell != -1) | 353 | if (tscadc_dev->tsc_cell != -1) |
304 | tscadc_idle_config(tscadc_dev); | 354 | tscadc_idle_config(tscadc_dev); |
305 | am335x_tsc_se_update(tscadc_dev); | ||
306 | restore = tscadc_readl(tscadc_dev, REG_CTRL); | 355 | restore = tscadc_readl(tscadc_dev, REG_CTRL); |
307 | tscadc_writel(tscadc_dev, REG_CTRL, | 356 | tscadc_writel(tscadc_dev, REG_CTRL, |
308 | (restore | CNTRLREG_TSCSSENB)); | 357 | (restore | CNTRLREG_TSCSSENB)); |
diff --git a/drivers/mfd/timberdale.c b/drivers/mfd/timberdale.c index dbb34f94e5e3..2bc5cfb85204 100644 --- a/drivers/mfd/timberdale.c +++ b/drivers/mfd/timberdale.c | |||
@@ -374,7 +374,7 @@ static const struct resource timberdale_dma_resources[] = { | |||
374 | }, | 374 | }, |
375 | }; | 375 | }; |
376 | 376 | ||
377 | static struct mfd_cell timberdale_cells_bar0_cfg0[] = { | 377 | static const struct mfd_cell timberdale_cells_bar0_cfg0[] = { |
378 | { | 378 | { |
379 | .name = "timb-dma", | 379 | .name = "timb-dma", |
380 | .num_resources = ARRAY_SIZE(timberdale_dma_resources), | 380 | .num_resources = ARRAY_SIZE(timberdale_dma_resources), |
@@ -431,7 +431,7 @@ static struct mfd_cell timberdale_cells_bar0_cfg0[] = { | |||
431 | }, | 431 | }, |
432 | }; | 432 | }; |
433 | 433 | ||
434 | static struct mfd_cell timberdale_cells_bar0_cfg1[] = { | 434 | static const struct mfd_cell timberdale_cells_bar0_cfg1[] = { |
435 | { | 435 | { |
436 | .name = "timb-dma", | 436 | .name = "timb-dma", |
437 | .num_resources = ARRAY_SIZE(timberdale_dma_resources), | 437 | .num_resources = ARRAY_SIZE(timberdale_dma_resources), |
@@ -498,7 +498,7 @@ static struct mfd_cell timberdale_cells_bar0_cfg1[] = { | |||
498 | }, | 498 | }, |
499 | }; | 499 | }; |
500 | 500 | ||
501 | static struct mfd_cell timberdale_cells_bar0_cfg2[] = { | 501 | static const struct mfd_cell timberdale_cells_bar0_cfg2[] = { |
502 | { | 502 | { |
503 | .name = "timb-dma", | 503 | .name = "timb-dma", |
504 | .num_resources = ARRAY_SIZE(timberdale_dma_resources), | 504 | .num_resources = ARRAY_SIZE(timberdale_dma_resources), |
@@ -548,7 +548,7 @@ static struct mfd_cell timberdale_cells_bar0_cfg2[] = { | |||
548 | }, | 548 | }, |
549 | }; | 549 | }; |
550 | 550 | ||
551 | static struct mfd_cell timberdale_cells_bar0_cfg3[] = { | 551 | static const struct mfd_cell timberdale_cells_bar0_cfg3[] = { |
552 | { | 552 | { |
553 | .name = "timb-dma", | 553 | .name = "timb-dma", |
554 | .num_resources = ARRAY_SIZE(timberdale_dma_resources), | 554 | .num_resources = ARRAY_SIZE(timberdale_dma_resources), |
@@ -619,7 +619,7 @@ static const struct resource timberdale_sdhc_resources[] = { | |||
619 | }, | 619 | }, |
620 | }; | 620 | }; |
621 | 621 | ||
622 | static struct mfd_cell timberdale_cells_bar1[] = { | 622 | static const struct mfd_cell timberdale_cells_bar1[] = { |
623 | { | 623 | { |
624 | .name = "sdhci", | 624 | .name = "sdhci", |
625 | .num_resources = ARRAY_SIZE(timberdale_sdhc_resources), | 625 | .num_resources = ARRAY_SIZE(timberdale_sdhc_resources), |
@@ -627,7 +627,7 @@ static struct mfd_cell timberdale_cells_bar1[] = { | |||
627 | }, | 627 | }, |
628 | }; | 628 | }; |
629 | 629 | ||
630 | static struct mfd_cell timberdale_cells_bar2[] = { | 630 | static const struct mfd_cell timberdale_cells_bar2[] = { |
631 | { | 631 | { |
632 | .name = "sdhci", | 632 | .name = "sdhci", |
633 | .num_resources = ARRAY_SIZE(timberdale_sdhc_resources), | 633 | .num_resources = ARRAY_SIZE(timberdale_sdhc_resources), |
@@ -851,7 +851,7 @@ static void timb_remove(struct pci_dev *dev) | |||
851 | kfree(priv); | 851 | kfree(priv); |
852 | } | 852 | } |
853 | 853 | ||
854 | static DEFINE_PCI_DEVICE_TABLE(timberdale_pci_tbl) = { | 854 | static const struct pci_device_id timberdale_pci_tbl[] = { |
855 | { PCI_DEVICE(PCI_VENDOR_ID_TIMB, PCI_DEVICE_ID_TIMB) }, | 855 | { PCI_DEVICE(PCI_VENDOR_ID_TIMB, PCI_DEVICE_ID_TIMB) }, |
856 | { 0 } | 856 | { 0 } |
857 | }; | 857 | }; |
diff --git a/drivers/mfd/tps6507x.c b/drivers/mfd/tps6507x.c index a081b925d10b..3b27482a174f 100644 --- a/drivers/mfd/tps6507x.c +++ b/drivers/mfd/tps6507x.c | |||
@@ -24,7 +24,7 @@ | |||
24 | #include <linux/mfd/core.h> | 24 | #include <linux/mfd/core.h> |
25 | #include <linux/mfd/tps6507x.h> | 25 | #include <linux/mfd/tps6507x.h> |
26 | 26 | ||
27 | static struct mfd_cell tps6507x_devs[] = { | 27 | static const struct mfd_cell tps6507x_devs[] = { |
28 | { | 28 | { |
29 | .name = "tps6507x-pmic", | 29 | .name = "tps6507x-pmic", |
30 | }, | 30 | }, |
diff --git a/drivers/mfd/tps65090.c b/drivers/mfd/tps65090.c index e6f03a733879..ba1a25d758c1 100644 --- a/drivers/mfd/tps65090.c +++ b/drivers/mfd/tps65090.c | |||
@@ -64,7 +64,7 @@ static struct resource charger_resources[] = { | |||
64 | } | 64 | } |
65 | }; | 65 | }; |
66 | 66 | ||
67 | static struct mfd_cell tps65090s[] = { | 67 | static const struct mfd_cell tps65090s[] = { |
68 | { | 68 | { |
69 | .name = "tps65090-pmic", | 69 | .name = "tps65090-pmic", |
70 | }, | 70 | }, |
diff --git a/drivers/mfd/tps65217.c b/drivers/mfd/tps65217.c index b7be0b295575..6939ae56c2e1 100644 --- a/drivers/mfd/tps65217.c +++ b/drivers/mfd/tps65217.c | |||
@@ -30,7 +30,7 @@ | |||
30 | #include <linux/mfd/core.h> | 30 | #include <linux/mfd/core.h> |
31 | #include <linux/mfd/tps65217.h> | 31 | #include <linux/mfd/tps65217.h> |
32 | 32 | ||
33 | static struct mfd_cell tps65217s[] = { | 33 | static const struct mfd_cell tps65217s[] = { |
34 | { | 34 | { |
35 | .name = "tps65217-pmic", | 35 | .name = "tps65217-pmic", |
36 | }, | 36 | }, |
diff --git a/drivers/mfd/tps6586x.c b/drivers/mfd/tps6586x.c index ee61fd7c198d..bbd54414a75d 100644 --- a/drivers/mfd/tps6586x.c +++ b/drivers/mfd/tps6586x.c | |||
@@ -103,7 +103,7 @@ static struct resource tps6586x_rtc_resources[] = { | |||
103 | }, | 103 | }, |
104 | }; | 104 | }; |
105 | 105 | ||
106 | static struct mfd_cell tps6586x_cell[] = { | 106 | static const struct mfd_cell tps6586x_cell[] = { |
107 | { | 107 | { |
108 | .name = "tps6586x-gpio", | 108 | .name = "tps6586x-gpio", |
109 | }, | 109 | }, |
@@ -124,6 +124,7 @@ struct tps6586x { | |||
124 | struct device *dev; | 124 | struct device *dev; |
125 | struct i2c_client *client; | 125 | struct i2c_client *client; |
126 | struct regmap *regmap; | 126 | struct regmap *regmap; |
127 | int version; | ||
127 | 128 | ||
128 | int irq; | 129 | int irq; |
129 | struct irq_chip irq_chip; | 130 | struct irq_chip irq_chip; |
@@ -208,6 +209,14 @@ int tps6586x_irq_get_virq(struct device *dev, int irq) | |||
208 | } | 209 | } |
209 | EXPORT_SYMBOL_GPL(tps6586x_irq_get_virq); | 210 | EXPORT_SYMBOL_GPL(tps6586x_irq_get_virq); |
210 | 211 | ||
212 | int tps6586x_get_version(struct device *dev) | ||
213 | { | ||
214 | struct tps6586x *tps6586x = dev_get_drvdata(dev); | ||
215 | |||
216 | return tps6586x->version; | ||
217 | } | ||
218 | EXPORT_SYMBOL_GPL(tps6586x_get_version); | ||
219 | |||
211 | static int __remove_subdev(struct device *dev, void *unused) | 220 | static int __remove_subdev(struct device *dev, void *unused) |
212 | { | 221 | { |
213 | platform_device_unregister(to_platform_device(dev)); | 222 | platform_device_unregister(to_platform_device(dev)); |
@@ -472,12 +481,38 @@ static void tps6586x_power_off(void) | |||
472 | tps6586x_set_bits(tps6586x_dev, TPS6586X_SUPPLYENE, SLEEP_MODE_BIT); | 481 | tps6586x_set_bits(tps6586x_dev, TPS6586X_SUPPLYENE, SLEEP_MODE_BIT); |
473 | } | 482 | } |
474 | 483 | ||
484 | static void tps6586x_print_version(struct i2c_client *client, int version) | ||
485 | { | ||
486 | const char *name; | ||
487 | |||
488 | switch (version) { | ||
489 | case TPS658621A: | ||
490 | name = "TPS658621A"; | ||
491 | break; | ||
492 | case TPS658621CD: | ||
493 | name = "TPS658621C/D"; | ||
494 | break; | ||
495 | case TPS658623: | ||
496 | name = "TPS658623"; | ||
497 | break; | ||
498 | case TPS658643: | ||
499 | name = "TPS658643"; | ||
500 | break; | ||
501 | default: | ||
502 | name = "TPS6586X"; | ||
503 | break; | ||
504 | } | ||
505 | |||
506 | dev_info(&client->dev, "Found %s, VERSIONCRC is %02x\n", name, version); | ||
507 | } | ||
508 | |||
475 | static int tps6586x_i2c_probe(struct i2c_client *client, | 509 | static int tps6586x_i2c_probe(struct i2c_client *client, |
476 | const struct i2c_device_id *id) | 510 | const struct i2c_device_id *id) |
477 | { | 511 | { |
478 | struct tps6586x_platform_data *pdata = dev_get_platdata(&client->dev); | 512 | struct tps6586x_platform_data *pdata = dev_get_platdata(&client->dev); |
479 | struct tps6586x *tps6586x; | 513 | struct tps6586x *tps6586x; |
480 | int ret; | 514 | int ret; |
515 | int version; | ||
481 | 516 | ||
482 | if (!pdata && client->dev.of_node) | 517 | if (!pdata && client->dev.of_node) |
483 | pdata = tps6586x_parse_dt(client); | 518 | pdata = tps6586x_parse_dt(client); |
@@ -487,19 +522,18 @@ static int tps6586x_i2c_probe(struct i2c_client *client, | |||
487 | return -ENOTSUPP; | 522 | return -ENOTSUPP; |
488 | } | 523 | } |
489 | 524 | ||
490 | ret = i2c_smbus_read_byte_data(client, TPS6586X_VERSIONCRC); | 525 | version = i2c_smbus_read_byte_data(client, TPS6586X_VERSIONCRC); |
491 | if (ret < 0) { | 526 | if (version < 0) { |
492 | dev_err(&client->dev, "Chip ID read failed: %d\n", ret); | 527 | dev_err(&client->dev, "Chip ID read failed: %d\n", version); |
493 | return -EIO; | 528 | return -EIO; |
494 | } | 529 | } |
495 | 530 | ||
496 | dev_info(&client->dev, "VERSIONCRC is %02x\n", ret); | ||
497 | |||
498 | tps6586x = devm_kzalloc(&client->dev, sizeof(*tps6586x), GFP_KERNEL); | 531 | tps6586x = devm_kzalloc(&client->dev, sizeof(*tps6586x), GFP_KERNEL); |
499 | if (tps6586x == NULL) { | 532 | if (!tps6586x) |
500 | dev_err(&client->dev, "memory for tps6586x alloc failed\n"); | ||
501 | return -ENOMEM; | 533 | return -ENOMEM; |
502 | } | 534 | |
535 | tps6586x->version = version; | ||
536 | tps6586x_print_version(client, tps6586x->version); | ||
503 | 537 | ||
504 | tps6586x->client = client; | 538 | tps6586x->client = client; |
505 | tps6586x->dev = &client->dev; | 539 | tps6586x->dev = &client->dev; |
diff --git a/drivers/mfd/tps65910.c b/drivers/mfd/tps65910.c index c0f608e3ca9e..1f142d76cbbc 100644 --- a/drivers/mfd/tps65910.c +++ b/drivers/mfd/tps65910.c | |||
@@ -36,7 +36,7 @@ static struct resource rtc_resources[] = { | |||
36 | } | 36 | } |
37 | }; | 37 | }; |
38 | 38 | ||
39 | static struct mfd_cell tps65910s[] = { | 39 | static const struct mfd_cell tps65910s[] = { |
40 | { | 40 | { |
41 | .name = "tps65910-gpio", | 41 | .name = "tps65910-gpio", |
42 | }, | 42 | }, |
diff --git a/drivers/mfd/tps65912-core.c b/drivers/mfd/tps65912-core.c index 925a044cbdf6..27a518e0eec6 100644 --- a/drivers/mfd/tps65912-core.c +++ b/drivers/mfd/tps65912-core.c | |||
@@ -21,7 +21,7 @@ | |||
21 | #include <linux/mfd/core.h> | 21 | #include <linux/mfd/core.h> |
22 | #include <linux/mfd/tps65912.h> | 22 | #include <linux/mfd/tps65912.h> |
23 | 23 | ||
24 | static struct mfd_cell tps65912s[] = { | 24 | static const struct mfd_cell tps65912s[] = { |
25 | { | 25 | { |
26 | .name = "tps65912-pmic", | 26 | .name = "tps65912-pmic", |
27 | }, | 27 | }, |
diff --git a/drivers/mfd/tps80031.c b/drivers/mfd/tps80031.c index f15ee6d5cfbf..ed6c5b0956e2 100644 --- a/drivers/mfd/tps80031.c +++ b/drivers/mfd/tps80031.c | |||
@@ -44,7 +44,7 @@ static struct resource tps80031_rtc_resources[] = { | |||
44 | }; | 44 | }; |
45 | 45 | ||
46 | /* TPS80031 sub mfd devices */ | 46 | /* TPS80031 sub mfd devices */ |
47 | static struct mfd_cell tps80031_cell[] = { | 47 | static const struct mfd_cell tps80031_cell[] = { |
48 | { | 48 | { |
49 | .name = "tps80031-pmic", | 49 | .name = "tps80031-pmic", |
50 | }, | 50 | }, |
diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c index 6ef7685a4cf8..ed718328eff1 100644 --- a/drivers/mfd/twl-core.c +++ b/drivers/mfd/twl-core.c | |||
@@ -837,62 +837,6 @@ add_children(struct twl4030_platform_data *pdata, unsigned irq_base, | |||
837 | usb3v1[0].dev_name = dev_name(child); | 837 | usb3v1[0].dev_name = dev_name(child); |
838 | } | 838 | } |
839 | } | 839 | } |
840 | if (IS_ENABLED(CONFIG_TWL6030_USB) && pdata->usb && | ||
841 | twl_class_is_6030()) { | ||
842 | |||
843 | static struct regulator_consumer_supply usb3v3; | ||
844 | int regulator; | ||
845 | |||
846 | if (IS_ENABLED(CONFIG_REGULATOR_TWL4030)) { | ||
847 | /* this is a template that gets copied */ | ||
848 | struct regulator_init_data usb_fixed = { | ||
849 | .constraints.valid_modes_mask = | ||
850 | REGULATOR_MODE_NORMAL | ||
851 | | REGULATOR_MODE_STANDBY, | ||
852 | .constraints.valid_ops_mask = | ||
853 | REGULATOR_CHANGE_MODE | ||
854 | | REGULATOR_CHANGE_STATUS, | ||
855 | }; | ||
856 | |||
857 | if (features & TWL6032_SUBCLASS) { | ||
858 | usb3v3.supply = "ldousb"; | ||
859 | regulator = TWL6032_REG_LDOUSB; | ||
860 | } else { | ||
861 | usb3v3.supply = "vusb"; | ||
862 | regulator = TWL6030_REG_VUSB; | ||
863 | } | ||
864 | child = add_regulator_linked(regulator, &usb_fixed, | ||
865 | &usb3v3, 1, | ||
866 | features); | ||
867 | if (IS_ERR(child)) | ||
868 | return PTR_ERR(child); | ||
869 | } | ||
870 | |||
871 | pdata->usb->features = features; | ||
872 | |||
873 | child = add_child(TWL_MODULE_USB, "twl6030_usb", | ||
874 | pdata->usb, sizeof(*pdata->usb), true, | ||
875 | /* irq1 = VBUS_PRES, irq0 = USB ID */ | ||
876 | irq_base + USBOTG_INTR_OFFSET, | ||
877 | irq_base + USB_PRES_INTR_OFFSET); | ||
878 | |||
879 | if (IS_ERR(child)) | ||
880 | return PTR_ERR(child); | ||
881 | /* we need to connect regulators to this transceiver */ | ||
882 | if (IS_ENABLED(CONFIG_REGULATOR_TWL4030) && child) | ||
883 | usb3v3.dev_name = dev_name(child); | ||
884 | } else if (IS_ENABLED(CONFIG_REGULATOR_TWL4030) && | ||
885 | twl_class_is_6030()) { | ||
886 | if (features & TWL6032_SUBCLASS) | ||
887 | child = add_regulator(TWL6032_REG_LDOUSB, | ||
888 | pdata->ldousb, features); | ||
889 | else | ||
890 | child = add_regulator(TWL6030_REG_VUSB, | ||
891 | pdata->vusb, features); | ||
892 | |||
893 | if (IS_ERR(child)) | ||
894 | return PTR_ERR(child); | ||
895 | } | ||
896 | 840 | ||
897 | if (IS_ENABLED(CONFIG_TWL4030_WATCHDOG) && twl_class_is_4030()) { | 841 | if (IS_ENABLED(CONFIG_TWL4030_WATCHDOG) && twl_class_is_4030()) { |
898 | child = add_child(TWL_MODULE_PM_RECEIVER, "twl4030_wdt", NULL, | 842 | child = add_child(TWL_MODULE_PM_RECEIVER, "twl4030_wdt", NULL, |
@@ -1006,148 +950,6 @@ add_children(struct twl4030_platform_data *pdata, unsigned irq_base, | |||
1006 | return PTR_ERR(child); | 950 | return PTR_ERR(child); |
1007 | } | 951 | } |
1008 | 952 | ||
1009 | /* twl6030 regulators */ | ||
1010 | if (IS_ENABLED(CONFIG_REGULATOR_TWL4030) && twl_class_is_6030() && | ||
1011 | !(features & TWL6032_SUBCLASS)) { | ||
1012 | child = add_regulator(TWL6030_REG_VDD1, pdata->vdd1, | ||
1013 | features); | ||
1014 | if (IS_ERR(child)) | ||
1015 | return PTR_ERR(child); | ||
1016 | |||
1017 | child = add_regulator(TWL6030_REG_VDD2, pdata->vdd2, | ||
1018 | features); | ||
1019 | if (IS_ERR(child)) | ||
1020 | return PTR_ERR(child); | ||
1021 | |||
1022 | child = add_regulator(TWL6030_REG_VDD3, pdata->vdd3, | ||
1023 | features); | ||
1024 | if (IS_ERR(child)) | ||
1025 | return PTR_ERR(child); | ||
1026 | |||
1027 | child = add_regulator(TWL6030_REG_V1V8, pdata->v1v8, | ||
1028 | features); | ||
1029 | if (IS_ERR(child)) | ||
1030 | return PTR_ERR(child); | ||
1031 | |||
1032 | child = add_regulator(TWL6030_REG_V2V1, pdata->v2v1, | ||
1033 | features); | ||
1034 | if (IS_ERR(child)) | ||
1035 | return PTR_ERR(child); | ||
1036 | |||
1037 | child = add_regulator(TWL6030_REG_VMMC, pdata->vmmc, | ||
1038 | features); | ||
1039 | if (IS_ERR(child)) | ||
1040 | return PTR_ERR(child); | ||
1041 | |||
1042 | child = add_regulator(TWL6030_REG_VPP, pdata->vpp, | ||
1043 | features); | ||
1044 | if (IS_ERR(child)) | ||
1045 | return PTR_ERR(child); | ||
1046 | |||
1047 | child = add_regulator(TWL6030_REG_VUSIM, pdata->vusim, | ||
1048 | features); | ||
1049 | if (IS_ERR(child)) | ||
1050 | return PTR_ERR(child); | ||
1051 | |||
1052 | child = add_regulator(TWL6030_REG_VCXIO, pdata->vcxio, | ||
1053 | features); | ||
1054 | if (IS_ERR(child)) | ||
1055 | return PTR_ERR(child); | ||
1056 | |||
1057 | child = add_regulator(TWL6030_REG_VDAC, pdata->vdac, | ||
1058 | features); | ||
1059 | if (IS_ERR(child)) | ||
1060 | return PTR_ERR(child); | ||
1061 | |||
1062 | child = add_regulator(TWL6030_REG_VAUX1_6030, pdata->vaux1, | ||
1063 | features); | ||
1064 | if (IS_ERR(child)) | ||
1065 | return PTR_ERR(child); | ||
1066 | |||
1067 | child = add_regulator(TWL6030_REG_VAUX2_6030, pdata->vaux2, | ||
1068 | features); | ||
1069 | if (IS_ERR(child)) | ||
1070 | return PTR_ERR(child); | ||
1071 | |||
1072 | child = add_regulator(TWL6030_REG_VAUX3_6030, pdata->vaux3, | ||
1073 | features); | ||
1074 | if (IS_ERR(child)) | ||
1075 | return PTR_ERR(child); | ||
1076 | |||
1077 | child = add_regulator(TWL6030_REG_CLK32KG, pdata->clk32kg, | ||
1078 | features); | ||
1079 | if (IS_ERR(child)) | ||
1080 | return PTR_ERR(child); | ||
1081 | } | ||
1082 | |||
1083 | /* 6030 and 6025 share this regulator */ | ||
1084 | if (IS_ENABLED(CONFIG_REGULATOR_TWL4030) && twl_class_is_6030()) { | ||
1085 | child = add_regulator(TWL6030_REG_VANA, pdata->vana, | ||
1086 | features); | ||
1087 | if (IS_ERR(child)) | ||
1088 | return PTR_ERR(child); | ||
1089 | } | ||
1090 | |||
1091 | /* twl6032 regulators */ | ||
1092 | if (IS_ENABLED(CONFIG_REGULATOR_TWL4030) && twl_class_is_6030() && | ||
1093 | (features & TWL6032_SUBCLASS)) { | ||
1094 | child = add_regulator(TWL6032_REG_LDO5, pdata->ldo5, | ||
1095 | features); | ||
1096 | if (IS_ERR(child)) | ||
1097 | return PTR_ERR(child); | ||
1098 | |||
1099 | child = add_regulator(TWL6032_REG_LDO1, pdata->ldo1, | ||
1100 | features); | ||
1101 | if (IS_ERR(child)) | ||
1102 | return PTR_ERR(child); | ||
1103 | |||
1104 | child = add_regulator(TWL6032_REG_LDO7, pdata->ldo7, | ||
1105 | features); | ||
1106 | if (IS_ERR(child)) | ||
1107 | return PTR_ERR(child); | ||
1108 | |||
1109 | child = add_regulator(TWL6032_REG_LDO6, pdata->ldo6, | ||
1110 | features); | ||
1111 | if (IS_ERR(child)) | ||
1112 | return PTR_ERR(child); | ||
1113 | |||
1114 | child = add_regulator(TWL6032_REG_LDOLN, pdata->ldoln, | ||
1115 | features); | ||
1116 | if (IS_ERR(child)) | ||
1117 | return PTR_ERR(child); | ||
1118 | |||
1119 | child = add_regulator(TWL6032_REG_LDO2, pdata->ldo2, | ||
1120 | features); | ||
1121 | if (IS_ERR(child)) | ||
1122 | return PTR_ERR(child); | ||
1123 | |||
1124 | child = add_regulator(TWL6032_REG_LDO4, pdata->ldo4, | ||
1125 | features); | ||
1126 | if (IS_ERR(child)) | ||
1127 | return PTR_ERR(child); | ||
1128 | |||
1129 | child = add_regulator(TWL6032_REG_LDO3, pdata->ldo3, | ||
1130 | features); | ||
1131 | if (IS_ERR(child)) | ||
1132 | return PTR_ERR(child); | ||
1133 | |||
1134 | child = add_regulator(TWL6032_REG_SMPS3, pdata->smps3, | ||
1135 | features); | ||
1136 | if (IS_ERR(child)) | ||
1137 | return PTR_ERR(child); | ||
1138 | |||
1139 | child = add_regulator(TWL6032_REG_SMPS4, pdata->smps4, | ||
1140 | features); | ||
1141 | if (IS_ERR(child)) | ||
1142 | return PTR_ERR(child); | ||
1143 | |||
1144 | child = add_regulator(TWL6032_REG_VIO, pdata->vio6025, | ||
1145 | features); | ||
1146 | if (IS_ERR(child)) | ||
1147 | return PTR_ERR(child); | ||
1148 | |||
1149 | } | ||
1150 | |||
1151 | if (IS_ENABLED(CONFIG_CHARGER_TWL4030) && pdata->bci && | 953 | if (IS_ENABLED(CONFIG_CHARGER_TWL4030) && pdata->bci && |
1152 | !(features & (TPS_SUBSET | TWL5031))) { | 954 | !(features & (TPS_SUBSET | TWL5031))) { |
1153 | child = add_child(TWL_MODULE_MAIN_CHARGE, "twl4030_bci", | 955 | child = add_child(TWL_MODULE_MAIN_CHARGE, "twl4030_bci", |
@@ -1269,6 +1071,11 @@ static int twl_remove(struct i2c_client *client) | |||
1269 | return 0; | 1071 | return 0; |
1270 | } | 1072 | } |
1271 | 1073 | ||
1074 | static struct of_dev_auxdata twl_auxdata_lookup[] = { | ||
1075 | OF_DEV_AUXDATA("ti,twl4030-gpio", 0, "twl4030-gpio", NULL), | ||
1076 | { /* sentinel */ }, | ||
1077 | }; | ||
1078 | |||
1272 | /* NOTE: This driver only handles a single twl4030/tps659x0 chip */ | 1079 | /* NOTE: This driver only handles a single twl4030/tps659x0 chip */ |
1273 | static int | 1080 | static int |
1274 | twl_probe(struct i2c_client *client, const struct i2c_device_id *id) | 1081 | twl_probe(struct i2c_client *client, const struct i2c_device_id *id) |
@@ -1407,10 +1214,14 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
1407 | twl_i2c_write_u8(TWL4030_MODULE_INTBR, temp, REG_GPPUPDCTR1); | 1214 | twl_i2c_write_u8(TWL4030_MODULE_INTBR, temp, REG_GPPUPDCTR1); |
1408 | } | 1215 | } |
1409 | 1216 | ||
1410 | if (node) | 1217 | if (node) { |
1411 | status = of_platform_populate(node, NULL, NULL, &client->dev); | 1218 | if (pdata) |
1412 | else | 1219 | twl_auxdata_lookup[0].platform_data = pdata->gpio; |
1220 | status = of_platform_populate(node, NULL, twl_auxdata_lookup, | ||
1221 | &client->dev); | ||
1222 | } else { | ||
1413 | status = add_children(pdata, irq_base, id->driver_data); | 1223 | status = add_children(pdata, irq_base, id->driver_data); |
1224 | } | ||
1414 | 1225 | ||
1415 | fail: | 1226 | fail: |
1416 | if (status < 0) | 1227 | if (status < 0) |
diff --git a/drivers/mfd/twl6030-irq.c b/drivers/mfd/twl6030-irq.c index 517eda832f79..18a607e2ca06 100644 --- a/drivers/mfd/twl6030-irq.c +++ b/drivers/mfd/twl6030-irq.c | |||
@@ -176,8 +176,9 @@ static irqreturn_t twl6030_irq_thread(int irq, void *data) | |||
176 | int i, ret; | 176 | int i, ret; |
177 | union { | 177 | union { |
178 | u8 bytes[4]; | 178 | u8 bytes[4]; |
179 | u32 int_sts; | 179 | __le32 int_sts; |
180 | } sts; | 180 | } sts; |
181 | u32 int_sts; /* sts.int_sts converted to CPU endianness */ | ||
181 | struct twl6030_irq *pdata = data; | 182 | struct twl6030_irq *pdata = data; |
182 | 183 | ||
183 | /* read INT_STS_A, B and C in one shot using a burst read */ | 184 | /* read INT_STS_A, B and C in one shot using a burst read */ |
@@ -196,8 +197,9 @@ static irqreturn_t twl6030_irq_thread(int irq, void *data) | |||
196 | if (sts.bytes[2] & 0x10) | 197 | if (sts.bytes[2] & 0x10) |
197 | sts.bytes[2] |= 0x08; | 198 | sts.bytes[2] |= 0x08; |
198 | 199 | ||
199 | for (i = 0; sts.int_sts; sts.int_sts >>= 1, i++) | 200 | int_sts = le32_to_cpu(sts.int_sts); |
200 | if (sts.int_sts & 0x1) { | 201 | for (i = 0; int_sts; int_sts >>= 1, i++) |
202 | if (int_sts & 0x1) { | ||
201 | int module_irq = | 203 | int module_irq = |
202 | irq_find_mapping(pdata->irq_domain, | 204 | irq_find_mapping(pdata->irq_domain, |
203 | pdata->irq_mapping_tbl[i]); | 205 | pdata->irq_mapping_tbl[i]); |
diff --git a/drivers/mfd/twl6040.c b/drivers/mfd/twl6040.c index 51b6df1a7949..75316fb33448 100644 --- a/drivers/mfd/twl6040.c +++ b/drivers/mfd/twl6040.c | |||
@@ -86,7 +86,7 @@ static struct reg_default twl6040_defaults[] = { | |||
86 | { 0x2E, 0x00 }, /* REG_STATUS (ro) */ | 86 | { 0x2E, 0x00 }, /* REG_STATUS (ro) */ |
87 | }; | 87 | }; |
88 | 88 | ||
89 | struct reg_default twl6040_patch[] = { | 89 | static struct reg_default twl6040_patch[] = { |
90 | /* Select I2C bus access to dual access registers */ | 90 | /* Select I2C bus access to dual access registers */ |
91 | { TWL6040_REG_ACCCTL, 0x09 }, | 91 | { TWL6040_REG_ACCCTL, 0x09 }, |
92 | }; | 92 | }; |
diff --git a/drivers/mfd/viperboard.c b/drivers/mfd/viperboard.c index af2a6703f34f..e00f5340ed87 100644 --- a/drivers/mfd/viperboard.c +++ b/drivers/mfd/viperboard.c | |||
@@ -37,7 +37,7 @@ static const struct usb_device_id vprbrd_table[] = { | |||
37 | 37 | ||
38 | MODULE_DEVICE_TABLE(usb, vprbrd_table); | 38 | MODULE_DEVICE_TABLE(usb, vprbrd_table); |
39 | 39 | ||
40 | static struct mfd_cell vprbrd_devs[] = { | 40 | static const struct mfd_cell vprbrd_devs[] = { |
41 | { | 41 | { |
42 | .name = "viperboard-gpio", | 42 | .name = "viperboard-gpio", |
43 | }, | 43 | }, |
diff --git a/drivers/mfd/vx855.c b/drivers/mfd/vx855.c index 757ecc63338c..84f01da4875e 100644 --- a/drivers/mfd/vx855.c +++ b/drivers/mfd/vx855.c | |||
@@ -60,7 +60,7 @@ static struct resource vx855_gpio_resources[] = { | |||
60 | }, | 60 | }, |
61 | }; | 61 | }; |
62 | 62 | ||
63 | static struct mfd_cell vx855_cells[] = { | 63 | static const struct mfd_cell vx855_cells[] = { |
64 | { | 64 | { |
65 | .name = "vx855_gpio", | 65 | .name = "vx855_gpio", |
66 | .num_resources = ARRAY_SIZE(vx855_gpio_resources), | 66 | .num_resources = ARRAY_SIZE(vx855_gpio_resources), |
@@ -118,7 +118,7 @@ static void vx855_remove(struct pci_dev *pdev) | |||
118 | pci_disable_device(pdev); | 118 | pci_disable_device(pdev); |
119 | } | 119 | } |
120 | 120 | ||
121 | static DEFINE_PCI_DEVICE_TABLE(vx855_pci_tbl) = { | 121 | static const struct pci_device_id vx855_pci_tbl[] = { |
122 | { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_VX855) }, | 122 | { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_VX855) }, |
123 | { 0, } | 123 | { 0, } |
124 | }; | 124 | }; |
diff --git a/drivers/mfd/wm5110-tables.c b/drivers/mfd/wm5110-tables.c index 4a4432eb499c..11632f135e8c 100644 --- a/drivers/mfd/wm5110-tables.c +++ b/drivers/mfd/wm5110-tables.c | |||
@@ -224,6 +224,31 @@ static const struct reg_default wm5110_revb_patch[] = { | |||
224 | { 0x80, 0x0 }, | 224 | { 0x80, 0x0 }, |
225 | }; | 225 | }; |
226 | 226 | ||
227 | static const struct reg_default wm5110_revd_patch[] = { | ||
228 | { 0x80, 0x3 }, | ||
229 | { 0x80, 0x3 }, | ||
230 | { 0x393, 0x27 }, | ||
231 | { 0x394, 0x27 }, | ||
232 | { 0x395, 0x27 }, | ||
233 | { 0x396, 0x27 }, | ||
234 | { 0x397, 0x27 }, | ||
235 | { 0x398, 0x26 }, | ||
236 | { 0x221, 0x90 }, | ||
237 | { 0x211, 0x8 }, | ||
238 | { 0x36c, 0x1fb }, | ||
239 | { 0x26e, 0x64 }, | ||
240 | { 0x26f, 0xea }, | ||
241 | { 0x270, 0x1f16 }, | ||
242 | { 0x51b, 0x1 }, | ||
243 | { 0x55b, 0x1 }, | ||
244 | { 0x59b, 0x1 }, | ||
245 | { 0x4f0, 0x633 }, | ||
246 | { 0x441, 0xc059 }, | ||
247 | { 0x209, 0x27 }, | ||
248 | { 0x80, 0x0 }, | ||
249 | { 0x80, 0x0 }, | ||
250 | }; | ||
251 | |||
227 | /* We use a function so we can use ARRAY_SIZE() */ | 252 | /* We use a function so we can use ARRAY_SIZE() */ |
228 | int wm5110_patch(struct arizona *arizona) | 253 | int wm5110_patch(struct arizona *arizona) |
229 | { | 254 | { |
@@ -236,7 +261,10 @@ int wm5110_patch(struct arizona *arizona) | |||
236 | return regmap_register_patch(arizona->regmap, | 261 | return regmap_register_patch(arizona->regmap, |
237 | wm5110_revb_patch, | 262 | wm5110_revb_patch, |
238 | ARRAY_SIZE(wm5110_revb_patch)); | 263 | ARRAY_SIZE(wm5110_revb_patch)); |
239 | 264 | case 3: | |
265 | return regmap_register_patch(arizona->regmap, | ||
266 | wm5110_revd_patch, | ||
267 | ARRAY_SIZE(wm5110_revd_patch)); | ||
240 | default: | 268 | default: |
241 | return 0; | 269 | return 0; |
242 | } | 270 | } |
@@ -505,7 +533,7 @@ static const struct reg_default wm5110_reg_default[] = { | |||
505 | { 0x000001AA, 0x0004 }, /* R426 - FLL2 GPIO Clock */ | 533 | { 0x000001AA, 0x0004 }, /* R426 - FLL2 GPIO Clock */ |
506 | { 0x00000200, 0x0006 }, /* R512 - Mic Charge Pump 1 */ | 534 | { 0x00000200, 0x0006 }, /* R512 - Mic Charge Pump 1 */ |
507 | { 0x00000210, 0x0184 }, /* R528 - LDO1 Control 1 */ | 535 | { 0x00000210, 0x0184 }, /* R528 - LDO1 Control 1 */ |
508 | { 0x00000213, 0x0344 }, /* R531 - LDO2 Control 1 */ | 536 | { 0x00000213, 0x03E4 }, /* R531 - LDO2 Control 1 */ |
509 | { 0x00000218, 0x01A6 }, /* R536 - Mic Bias Ctrl 1 */ | 537 | { 0x00000218, 0x01A6 }, /* R536 - Mic Bias Ctrl 1 */ |
510 | { 0x00000219, 0x01A6 }, /* R537 - Mic Bias Ctrl 2 */ | 538 | { 0x00000219, 0x01A6 }, /* R537 - Mic Bias Ctrl 2 */ |
511 | { 0x0000021A, 0x01A6 }, /* R538 - Mic Bias Ctrl 3 */ | 539 | { 0x0000021A, 0x01A6 }, /* R538 - Mic Bias Ctrl 3 */ |
diff --git a/drivers/mfd/wm831x-core.c b/drivers/mfd/wm831x-core.c index 5c459f469224..28366a90e1ad 100644 --- a/drivers/mfd/wm831x-core.c +++ b/drivers/mfd/wm831x-core.c | |||
@@ -1011,7 +1011,7 @@ static struct resource wm831x_wdt_resources[] = { | |||
1011 | }, | 1011 | }, |
1012 | }; | 1012 | }; |
1013 | 1013 | ||
1014 | static struct mfd_cell wm8310_devs[] = { | 1014 | static const struct mfd_cell wm8310_devs[] = { |
1015 | { | 1015 | { |
1016 | .name = "wm831x-backup", | 1016 | .name = "wm831x-backup", |
1017 | }, | 1017 | }, |
@@ -1165,7 +1165,7 @@ static struct mfd_cell wm8310_devs[] = { | |||
1165 | }, | 1165 | }, |
1166 | }; | 1166 | }; |
1167 | 1167 | ||
1168 | static struct mfd_cell wm8311_devs[] = { | 1168 | static const struct mfd_cell wm8311_devs[] = { |
1169 | { | 1169 | { |
1170 | .name = "wm831x-backup", | 1170 | .name = "wm831x-backup", |
1171 | }, | 1171 | }, |
@@ -1295,7 +1295,7 @@ static struct mfd_cell wm8311_devs[] = { | |||
1295 | }, | 1295 | }, |
1296 | }; | 1296 | }; |
1297 | 1297 | ||
1298 | static struct mfd_cell wm8312_devs[] = { | 1298 | static const struct mfd_cell wm8312_devs[] = { |
1299 | { | 1299 | { |
1300 | .name = "wm831x-backup", | 1300 | .name = "wm831x-backup", |
1301 | }, | 1301 | }, |
@@ -1449,7 +1449,7 @@ static struct mfd_cell wm8312_devs[] = { | |||
1449 | }, | 1449 | }, |
1450 | }; | 1450 | }; |
1451 | 1451 | ||
1452 | static struct mfd_cell wm8320_devs[] = { | 1452 | static const struct mfd_cell wm8320_devs[] = { |
1453 | { | 1453 | { |
1454 | .name = "wm831x-backup", | 1454 | .name = "wm831x-backup", |
1455 | }, | 1455 | }, |
@@ -1578,7 +1578,7 @@ static struct mfd_cell wm8320_devs[] = { | |||
1578 | }, | 1578 | }, |
1579 | }; | 1579 | }; |
1580 | 1580 | ||
1581 | static struct mfd_cell touch_devs[] = { | 1581 | static const struct mfd_cell touch_devs[] = { |
1582 | { | 1582 | { |
1583 | .name = "wm831x-touch", | 1583 | .name = "wm831x-touch", |
1584 | .num_resources = ARRAY_SIZE(wm831x_touch_resources), | 1584 | .num_resources = ARRAY_SIZE(wm831x_touch_resources), |
@@ -1586,7 +1586,7 @@ static struct mfd_cell touch_devs[] = { | |||
1586 | }, | 1586 | }, |
1587 | }; | 1587 | }; |
1588 | 1588 | ||
1589 | static struct mfd_cell rtc_devs[] = { | 1589 | static const struct mfd_cell rtc_devs[] = { |
1590 | { | 1590 | { |
1591 | .name = "wm831x-rtc", | 1591 | .name = "wm831x-rtc", |
1592 | .num_resources = ARRAY_SIZE(wm831x_rtc_resources), | 1592 | .num_resources = ARRAY_SIZE(wm831x_rtc_resources), |
@@ -1594,7 +1594,7 @@ static struct mfd_cell rtc_devs[] = { | |||
1594 | }, | 1594 | }, |
1595 | }; | 1595 | }; |
1596 | 1596 | ||
1597 | static struct mfd_cell backlight_devs[] = { | 1597 | static const struct mfd_cell backlight_devs[] = { |
1598 | { | 1598 | { |
1599 | .name = "wm831x-backlight", | 1599 | .name = "wm831x-backlight", |
1600 | }, | 1600 | }, |
diff --git a/drivers/mfd/wm831x-i2c.c b/drivers/mfd/wm831x-i2c.c index 2b29caebc9cf..a4cbefe5430f 100644 --- a/drivers/mfd/wm831x-i2c.c +++ b/drivers/mfd/wm831x-i2c.c | |||
@@ -64,11 +64,13 @@ static int wm831x_i2c_suspend(struct device *dev) | |||
64 | return wm831x_device_suspend(wm831x); | 64 | return wm831x_device_suspend(wm831x); |
65 | } | 65 | } |
66 | 66 | ||
67 | static void wm831x_i2c_shutdown(struct i2c_client *i2c) | 67 | static int wm831x_i2c_poweroff(struct device *dev) |
68 | { | 68 | { |
69 | struct wm831x *wm831x = i2c_get_clientdata(i2c); | 69 | struct wm831x *wm831x = dev_get_drvdata(dev); |
70 | 70 | ||
71 | wm831x_device_shutdown(wm831x); | 71 | wm831x_device_shutdown(wm831x); |
72 | |||
73 | return 0; | ||
72 | } | 74 | } |
73 | 75 | ||
74 | static const struct i2c_device_id wm831x_i2c_id[] = { | 76 | static const struct i2c_device_id wm831x_i2c_id[] = { |
@@ -85,6 +87,7 @@ MODULE_DEVICE_TABLE(i2c, wm831x_i2c_id); | |||
85 | 87 | ||
86 | static const struct dev_pm_ops wm831x_pm_ops = { | 88 | static const struct dev_pm_ops wm831x_pm_ops = { |
87 | .suspend = wm831x_i2c_suspend, | 89 | .suspend = wm831x_i2c_suspend, |
90 | .poweroff = wm831x_i2c_poweroff, | ||
88 | }; | 91 | }; |
89 | 92 | ||
90 | static struct i2c_driver wm831x_i2c_driver = { | 93 | static struct i2c_driver wm831x_i2c_driver = { |
@@ -95,7 +98,6 @@ static struct i2c_driver wm831x_i2c_driver = { | |||
95 | }, | 98 | }, |
96 | .probe = wm831x_i2c_probe, | 99 | .probe = wm831x_i2c_probe, |
97 | .remove = wm831x_i2c_remove, | 100 | .remove = wm831x_i2c_remove, |
98 | .shutdown = wm831x_i2c_shutdown, | ||
99 | .id_table = wm831x_i2c_id, | 101 | .id_table = wm831x_i2c_id, |
100 | }; | 102 | }; |
101 | 103 | ||
diff --git a/drivers/mfd/wm831x-spi.c b/drivers/mfd/wm831x-spi.c index 07de3cc5a0d9..b8a5e3b34ec7 100644 --- a/drivers/mfd/wm831x-spi.c +++ b/drivers/mfd/wm831x-spi.c | |||
@@ -66,16 +66,19 @@ static int wm831x_spi_suspend(struct device *dev) | |||
66 | return wm831x_device_suspend(wm831x); | 66 | return wm831x_device_suspend(wm831x); |
67 | } | 67 | } |
68 | 68 | ||
69 | static void wm831x_spi_shutdown(struct spi_device *spi) | 69 | static int wm831x_spi_poweroff(struct device *dev) |
70 | { | 70 | { |
71 | struct wm831x *wm831x = spi_get_drvdata(spi); | 71 | struct wm831x *wm831x = dev_get_drvdata(dev); |
72 | 72 | ||
73 | wm831x_device_shutdown(wm831x); | 73 | wm831x_device_shutdown(wm831x); |
74 | |||
75 | return 0; | ||
74 | } | 76 | } |
75 | 77 | ||
76 | static const struct dev_pm_ops wm831x_spi_pm = { | 78 | static const struct dev_pm_ops wm831x_spi_pm = { |
77 | .freeze = wm831x_spi_suspend, | 79 | .freeze = wm831x_spi_suspend, |
78 | .suspend = wm831x_spi_suspend, | 80 | .suspend = wm831x_spi_suspend, |
81 | .poweroff = wm831x_spi_poweroff, | ||
79 | }; | 82 | }; |
80 | 83 | ||
81 | static const struct spi_device_id wm831x_spi_ids[] = { | 84 | static const struct spi_device_id wm831x_spi_ids[] = { |
@@ -99,7 +102,6 @@ static struct spi_driver wm831x_spi_driver = { | |||
99 | .id_table = wm831x_spi_ids, | 102 | .id_table = wm831x_spi_ids, |
100 | .probe = wm831x_spi_probe, | 103 | .probe = wm831x_spi_probe, |
101 | .remove = wm831x_spi_remove, | 104 | .remove = wm831x_spi_remove, |
102 | .shutdown = wm831x_spi_shutdown, | ||
103 | }; | 105 | }; |
104 | 106 | ||
105 | static int __init wm831x_spi_init(void) | 107 | static int __init wm831x_spi_init(void) |
diff --git a/drivers/mfd/wm8994-core.c b/drivers/mfd/wm8994-core.c index 030827511667..ba04f1bc70eb 100644 --- a/drivers/mfd/wm8994-core.c +++ b/drivers/mfd/wm8994-core.c | |||
@@ -33,7 +33,7 @@ | |||
33 | 33 | ||
34 | #include "wm8994.h" | 34 | #include "wm8994.h" |
35 | 35 | ||
36 | static struct mfd_cell wm8994_regulator_devs[] = { | 36 | static const struct mfd_cell wm8994_regulator_devs[] = { |
37 | { | 37 | { |
38 | .name = "wm8994-ldo", | 38 | .name = "wm8994-ldo", |
39 | .id = 1, | 39 | .id = 1, |
@@ -62,7 +62,7 @@ static struct resource wm8994_gpio_resources[] = { | |||
62 | }, | 62 | }, |
63 | }; | 63 | }; |
64 | 64 | ||
65 | static struct mfd_cell wm8994_devs[] = { | 65 | static const struct mfd_cell wm8994_devs[] = { |
66 | { | 66 | { |
67 | .name = "wm8994-codec", | 67 | .name = "wm8994-codec", |
68 | .num_resources = ARRAY_SIZE(wm8994_codec_resources), | 68 | .num_resources = ARRAY_SIZE(wm8994_codec_resources), |
diff --git a/drivers/pinctrl/pinctrl-abx500.c b/drivers/pinctrl/pinctrl-abx500.c index 5183e7bb8de3..163da9c3ea0e 100644 --- a/drivers/pinctrl/pinctrl-abx500.c +++ b/drivers/pinctrl/pinctrl-abx500.c | |||
@@ -24,7 +24,6 @@ | |||
24 | #include <linux/bitops.h> | 24 | #include <linux/bitops.h> |
25 | #include <linux/mfd/abx500.h> | 25 | #include <linux/mfd/abx500.h> |
26 | #include <linux/mfd/abx500/ab8500.h> | 26 | #include <linux/mfd/abx500/ab8500.h> |
27 | #include <linux/mfd/abx500/ab8500-gpio.h> | ||
28 | #include <linux/pinctrl/pinctrl.h> | 27 | #include <linux/pinctrl/pinctrl.h> |
29 | #include <linux/pinctrl/consumer.h> | 28 | #include <linux/pinctrl/consumer.h> |
30 | #include <linux/pinctrl/pinmux.h> | 29 | #include <linux/pinctrl/pinmux.h> |
@@ -1218,21 +1217,15 @@ static const struct of_device_id abx500_gpio_match[] = { | |||
1218 | 1217 | ||
1219 | static int abx500_gpio_probe(struct platform_device *pdev) | 1218 | static int abx500_gpio_probe(struct platform_device *pdev) |
1220 | { | 1219 | { |
1221 | struct ab8500_platform_data *abx500_pdata = | ||
1222 | dev_get_platdata(pdev->dev.parent); | ||
1223 | struct abx500_gpio_platform_data *pdata = NULL; | ||
1224 | struct device_node *np = pdev->dev.of_node; | 1220 | struct device_node *np = pdev->dev.of_node; |
1221 | const struct of_device_id *match; | ||
1225 | struct abx500_pinctrl *pct; | 1222 | struct abx500_pinctrl *pct; |
1226 | const struct platform_device_id *platid = platform_get_device_id(pdev); | ||
1227 | unsigned int id = -1; | 1223 | unsigned int id = -1; |
1228 | int ret, err; | 1224 | int ret, err; |
1229 | int i; | 1225 | int i; |
1230 | 1226 | ||
1231 | if (abx500_pdata) | 1227 | if (!np) { |
1232 | pdata = abx500_pdata->gpio; | 1228 | dev_err(&pdev->dev, "gpio dt node missing\n"); |
1233 | |||
1234 | if (!(pdata || np)) { | ||
1235 | dev_err(&pdev->dev, "gpio dt and platform data missing\n"); | ||
1236 | return -ENODEV; | 1229 | return -ENODEV; |
1237 | } | 1230 | } |
1238 | 1231 | ||
@@ -1248,17 +1241,14 @@ static int abx500_gpio_probe(struct platform_device *pdev) | |||
1248 | pct->parent = dev_get_drvdata(pdev->dev.parent); | 1241 | pct->parent = dev_get_drvdata(pdev->dev.parent); |
1249 | pct->chip = abx500gpio_chip; | 1242 | pct->chip = abx500gpio_chip; |
1250 | pct->chip.dev = &pdev->dev; | 1243 | pct->chip.dev = &pdev->dev; |
1251 | pct->chip.base = (np) ? -1 : pdata->gpio_base; | 1244 | pct->chip.base = -1; /* Dynamic allocation */ |
1252 | |||
1253 | if (platid) | ||
1254 | id = platid->driver_data; | ||
1255 | else if (np) { | ||
1256 | const struct of_device_id *match; | ||
1257 | 1245 | ||
1258 | match = of_match_device(abx500_gpio_match, &pdev->dev); | 1246 | match = of_match_device(abx500_gpio_match, &pdev->dev); |
1259 | if (match) | 1247 | if (!match) { |
1260 | id = (unsigned long)match->data; | 1248 | dev_err(&pdev->dev, "gpio dt not matching\n"); |
1249 | return -ENODEV; | ||
1261 | } | 1250 | } |
1251 | id = (unsigned long)match->data; | ||
1262 | 1252 | ||
1263 | /* Poke in other ASIC variants here */ | 1253 | /* Poke in other ASIC variants here */ |
1264 | switch (id) { | 1254 | switch (id) { |
@@ -1349,14 +1339,6 @@ static int abx500_gpio_remove(struct platform_device *pdev) | |||
1349 | return 0; | 1339 | return 0; |
1350 | } | 1340 | } |
1351 | 1341 | ||
1352 | static const struct platform_device_id abx500_pinctrl_id[] = { | ||
1353 | { "pinctrl-ab8500", PINCTRL_AB8500 }, | ||
1354 | { "pinctrl-ab8540", PINCTRL_AB8540 }, | ||
1355 | { "pinctrl-ab9540", PINCTRL_AB9540 }, | ||
1356 | { "pinctrl-ab8505", PINCTRL_AB8505 }, | ||
1357 | { }, | ||
1358 | }; | ||
1359 | |||
1360 | static struct platform_driver abx500_gpio_driver = { | 1342 | static struct platform_driver abx500_gpio_driver = { |
1361 | .driver = { | 1343 | .driver = { |
1362 | .name = "abx500-gpio", | 1344 | .name = "abx500-gpio", |
@@ -1365,7 +1347,6 @@ static struct platform_driver abx500_gpio_driver = { | |||
1365 | }, | 1347 | }, |
1366 | .probe = abx500_gpio_probe, | 1348 | .probe = abx500_gpio_probe, |
1367 | .remove = abx500_gpio_remove, | 1349 | .remove = abx500_gpio_remove, |
1368 | .id_table = abx500_pinctrl_id, | ||
1369 | }; | 1350 | }; |
1370 | 1351 | ||
1371 | static int __init abx500_gpio_init(void) | 1352 | static int __init abx500_gpio_init(void) |
diff --git a/drivers/pinctrl/pinctrl-abx500.h b/drivers/pinctrl/pinctrl-abx500.h index 82293806e842..2beef3bfe9ca 100644 --- a/drivers/pinctrl/pinctrl-abx500.h +++ b/drivers/pinctrl/pinctrl-abx500.h | |||
@@ -15,6 +15,18 @@ enum abx500_pin_func { | |||
15 | ABX500_ALT_C, | 15 | ABX500_ALT_C, |
16 | }; | 16 | }; |
17 | 17 | ||
18 | enum abx500_gpio_pull_updown { | ||
19 | ABX500_GPIO_PULL_DOWN = 0x0, | ||
20 | ABX500_GPIO_PULL_NONE = 0x1, | ||
21 | ABX500_GPIO_PULL_UP = 0x3, | ||
22 | }; | ||
23 | |||
24 | enum abx500_gpio_vinsel { | ||
25 | ABX500_GPIO_VINSEL_VBAT = 0x0, | ||
26 | ABX500_GPIO_VINSEL_VIN_1V8 = 0x1, | ||
27 | ABX500_GPIO_VINSEL_VDD_BIF = 0x2, | ||
28 | }; | ||
29 | |||
18 | /** | 30 | /** |
19 | * struct abx500_function - ABx500 pinctrl mux function | 31 | * struct abx500_function - ABx500 pinctrl mux function |
20 | * @name: The name of the function, exported to pinctrl core. | 32 | * @name: The name of the function, exported to pinctrl core. |
diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig index eece329d7872..7acab93d5a47 100644 --- a/drivers/pwm/Kconfig +++ b/drivers/pwm/Kconfig | |||
@@ -90,6 +90,16 @@ config PWM_JZ4740 | |||
90 | To compile this driver as a module, choose M here: the module | 90 | To compile this driver as a module, choose M here: the module |
91 | will be called pwm-jz4740. | 91 | will be called pwm-jz4740. |
92 | 92 | ||
93 | config PWM_LP3943 | ||
94 | tristate "TI/National Semiconductor LP3943 PWM support" | ||
95 | depends on MFD_LP3943 | ||
96 | help | ||
97 | Generic PWM framework driver for LP3943 which supports two PWM | ||
98 | channels. | ||
99 | |||
100 | To compile this driver as a module, choose M here: the module | ||
101 | will be called pwm-lp3943. | ||
102 | |||
93 | config PWM_LPC32XX | 103 | config PWM_LPC32XX |
94 | tristate "LPC32XX PWM support" | 104 | tristate "LPC32XX PWM support" |
95 | depends on ARCH_LPC32XX | 105 | depends on ARCH_LPC32XX |
diff --git a/drivers/pwm/Makefile b/drivers/pwm/Makefile index 8b754e4dba4a..4abf337dcd02 100644 --- a/drivers/pwm/Makefile +++ b/drivers/pwm/Makefile | |||
@@ -6,6 +6,7 @@ obj-$(CONFIG_PWM_BFIN) += pwm-bfin.o | |||
6 | obj-$(CONFIG_PWM_EP93XX) += pwm-ep93xx.o | 6 | obj-$(CONFIG_PWM_EP93XX) += pwm-ep93xx.o |
7 | obj-$(CONFIG_PWM_IMX) += pwm-imx.o | 7 | obj-$(CONFIG_PWM_IMX) += pwm-imx.o |
8 | obj-$(CONFIG_PWM_JZ4740) += pwm-jz4740.o | 8 | obj-$(CONFIG_PWM_JZ4740) += pwm-jz4740.o |
9 | obj-$(CONFIG_PWM_LP3943) += pwm-lp3943.o | ||
9 | obj-$(CONFIG_PWM_LPC32XX) += pwm-lpc32xx.o | 10 | obj-$(CONFIG_PWM_LPC32XX) += pwm-lpc32xx.o |
10 | obj-$(CONFIG_PWM_MXS) += pwm-mxs.o | 11 | obj-$(CONFIG_PWM_MXS) += pwm-mxs.o |
11 | obj-$(CONFIG_PWM_PCA9685) += pwm-pca9685.o | 12 | obj-$(CONFIG_PWM_PCA9685) += pwm-pca9685.o |
diff --git a/drivers/pwm/pwm-lp3943.c b/drivers/pwm/pwm-lp3943.c new file mode 100644 index 000000000000..8a843a04c224 --- /dev/null +++ b/drivers/pwm/pwm-lp3943.c | |||
@@ -0,0 +1,314 @@ | |||
1 | /* | ||
2 | * TI/National Semiconductor LP3943 PWM driver | ||
3 | * | ||
4 | * Copyright 2013 Texas Instruments | ||
5 | * | ||
6 | * Author: Milo Kim <milo.kim@ti.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation; version 2. | ||
11 | */ | ||
12 | |||
13 | #include <linux/err.h> | ||
14 | #include <linux/i2c.h> | ||
15 | #include <linux/mfd/lp3943.h> | ||
16 | #include <linux/module.h> | ||
17 | #include <linux/platform_device.h> | ||
18 | #include <linux/pwm.h> | ||
19 | #include <linux/slab.h> | ||
20 | |||
21 | #define LP3943_MAX_DUTY 255 | ||
22 | #define LP3943_MIN_PERIOD 6250 | ||
23 | #define LP3943_MAX_PERIOD 1600000 | ||
24 | |||
25 | struct lp3943_pwm { | ||
26 | struct pwm_chip chip; | ||
27 | struct lp3943 *lp3943; | ||
28 | struct lp3943_platform_data *pdata; | ||
29 | }; | ||
30 | |||
31 | static inline struct lp3943_pwm *to_lp3943_pwm(struct pwm_chip *_chip) | ||
32 | { | ||
33 | return container_of(_chip, struct lp3943_pwm, chip); | ||
34 | } | ||
35 | |||
36 | static struct lp3943_pwm_map * | ||
37 | lp3943_pwm_request_map(struct lp3943_pwm *lp3943_pwm, int hwpwm) | ||
38 | { | ||
39 | struct lp3943_platform_data *pdata = lp3943_pwm->pdata; | ||
40 | struct lp3943 *lp3943 = lp3943_pwm->lp3943; | ||
41 | struct lp3943_pwm_map *pwm_map; | ||
42 | int i, offset; | ||
43 | |||
44 | pwm_map = kzalloc(sizeof(*pwm_map), GFP_KERNEL); | ||
45 | if (!pwm_map) | ||
46 | return ERR_PTR(-ENOMEM); | ||
47 | |||
48 | pwm_map->output = pdata->pwms[hwpwm]->output; | ||
49 | pwm_map->num_outputs = pdata->pwms[hwpwm]->num_outputs; | ||
50 | |||
51 | for (i = 0; i < pwm_map->num_outputs; i++) { | ||
52 | offset = pwm_map->output[i]; | ||
53 | |||
54 | /* Return an error if the pin is already assigned */ | ||
55 | if (test_and_set_bit(offset, &lp3943->pin_used)) | ||
56 | return ERR_PTR(-EBUSY); | ||
57 | } | ||
58 | |||
59 | return pwm_map; | ||
60 | } | ||
61 | |||
62 | static int lp3943_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm) | ||
63 | { | ||
64 | struct lp3943_pwm *lp3943_pwm = to_lp3943_pwm(chip); | ||
65 | struct lp3943_pwm_map *pwm_map; | ||
66 | |||
67 | pwm_map = lp3943_pwm_request_map(lp3943_pwm, pwm->hwpwm); | ||
68 | if (IS_ERR(pwm_map)) | ||
69 | return PTR_ERR(pwm_map); | ||
70 | |||
71 | return pwm_set_chip_data(pwm, pwm_map); | ||
72 | } | ||
73 | |||
74 | static void lp3943_pwm_free_map(struct lp3943_pwm *lp3943_pwm, | ||
75 | struct lp3943_pwm_map *pwm_map) | ||
76 | { | ||
77 | struct lp3943 *lp3943 = lp3943_pwm->lp3943; | ||
78 | int i, offset; | ||
79 | |||
80 | for (i = 0; i < pwm_map->num_outputs; i++) { | ||
81 | offset = pwm_map->output[i]; | ||
82 | clear_bit(offset, &lp3943->pin_used); | ||
83 | } | ||
84 | |||
85 | kfree(pwm_map); | ||
86 | } | ||
87 | |||
88 | static void lp3943_pwm_free(struct pwm_chip *chip, struct pwm_device *pwm) | ||
89 | { | ||
90 | struct lp3943_pwm *lp3943_pwm = to_lp3943_pwm(chip); | ||
91 | struct lp3943_pwm_map *pwm_map = pwm_get_chip_data(pwm); | ||
92 | |||
93 | lp3943_pwm_free_map(lp3943_pwm, pwm_map); | ||
94 | } | ||
95 | |||
96 | static int lp3943_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, | ||
97 | int duty_ns, int period_ns) | ||
98 | { | ||
99 | struct lp3943_pwm *lp3943_pwm = to_lp3943_pwm(chip); | ||
100 | struct lp3943 *lp3943 = lp3943_pwm->lp3943; | ||
101 | u8 val, reg_duty, reg_prescale; | ||
102 | int err; | ||
103 | |||
104 | /* | ||
105 | * How to configure the LP3943 PWMs | ||
106 | * | ||
107 | * 1) Period = 6250 ~ 1600000 | ||
108 | * 2) Prescale = period / 6250 -1 | ||
109 | * 3) Duty = input duty | ||
110 | * | ||
111 | * Prescale and duty are register values | ||
112 | */ | ||
113 | |||
114 | if (pwm->hwpwm == 0) { | ||
115 | reg_prescale = LP3943_REG_PRESCALE0; | ||
116 | reg_duty = LP3943_REG_PWM0; | ||
117 | } else { | ||
118 | reg_prescale = LP3943_REG_PRESCALE1; | ||
119 | reg_duty = LP3943_REG_PWM1; | ||
120 | } | ||
121 | |||
122 | period_ns = clamp(period_ns, LP3943_MIN_PERIOD, LP3943_MAX_PERIOD); | ||
123 | val = (u8)(period_ns / LP3943_MIN_PERIOD - 1); | ||
124 | |||
125 | err = lp3943_write_byte(lp3943, reg_prescale, val); | ||
126 | if (err) | ||
127 | return err; | ||
128 | |||
129 | val = (u8)(duty_ns * LP3943_MAX_DUTY / period_ns); | ||
130 | |||
131 | return lp3943_write_byte(lp3943, reg_duty, val); | ||
132 | } | ||
133 | |||
134 | static int lp3943_pwm_set_mode(struct lp3943_pwm *lp3943_pwm, | ||
135 | struct lp3943_pwm_map *pwm_map, | ||
136 | u8 val) | ||
137 | { | ||
138 | struct lp3943 *lp3943 = lp3943_pwm->lp3943; | ||
139 | const struct lp3943_reg_cfg *mux = lp3943->mux_cfg; | ||
140 | int i, index, err; | ||
141 | |||
142 | for (i = 0; i < pwm_map->num_outputs; i++) { | ||
143 | index = pwm_map->output[i]; | ||
144 | err = lp3943_update_bits(lp3943, mux[index].reg, | ||
145 | mux[index].mask, | ||
146 | val << mux[index].shift); | ||
147 | if (err) | ||
148 | return err; | ||
149 | } | ||
150 | |||
151 | return 0; | ||
152 | } | ||
153 | |||
154 | static int lp3943_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm) | ||
155 | { | ||
156 | struct lp3943_pwm *lp3943_pwm = to_lp3943_pwm(chip); | ||
157 | struct lp3943_pwm_map *pwm_map = pwm_get_chip_data(pwm); | ||
158 | u8 val; | ||
159 | |||
160 | if (pwm->hwpwm == 0) | ||
161 | val = LP3943_DIM_PWM0; | ||
162 | else | ||
163 | val = LP3943_DIM_PWM1; | ||
164 | |||
165 | /* | ||
166 | * Each PWM generator is set to control any of outputs of LP3943. | ||
167 | * To enable/disable the PWM, these output pins should be configured. | ||
168 | */ | ||
169 | |||
170 | return lp3943_pwm_set_mode(lp3943_pwm, pwm_map, val); | ||
171 | } | ||
172 | |||
173 | static void lp3943_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm) | ||
174 | { | ||
175 | struct lp3943_pwm *lp3943_pwm = to_lp3943_pwm(chip); | ||
176 | struct lp3943_pwm_map *pwm_map = pwm_get_chip_data(pwm); | ||
177 | |||
178 | /* | ||
179 | * LP3943 outputs are open-drain, so the pin should be configured | ||
180 | * when the PWM is disabled. | ||
181 | */ | ||
182 | |||
183 | lp3943_pwm_set_mode(lp3943_pwm, pwm_map, LP3943_GPIO_OUT_HIGH); | ||
184 | } | ||
185 | |||
186 | static const struct pwm_ops lp3943_pwm_ops = { | ||
187 | .request = lp3943_pwm_request, | ||
188 | .free = lp3943_pwm_free, | ||
189 | .config = lp3943_pwm_config, | ||
190 | .enable = lp3943_pwm_enable, | ||
191 | .disable = lp3943_pwm_disable, | ||
192 | .owner = THIS_MODULE, | ||
193 | }; | ||
194 | |||
195 | static int lp3943_pwm_parse_dt(struct device *dev, | ||
196 | struct lp3943_pwm *lp3943_pwm) | ||
197 | { | ||
198 | static const char * const name[] = { "ti,pwm0", "ti,pwm1", }; | ||
199 | struct device_node *node = dev->of_node; | ||
200 | struct lp3943_platform_data *pdata; | ||
201 | struct lp3943_pwm_map *pwm_map; | ||
202 | enum lp3943_pwm_output *output; | ||
203 | int i, err, proplen, count = 0; | ||
204 | u32 num_outputs; | ||
205 | |||
206 | if (!node) | ||
207 | return -EINVAL; | ||
208 | |||
209 | pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); | ||
210 | if (!pdata) | ||
211 | return -ENOMEM; | ||
212 | |||
213 | /* | ||
214 | * Read the output map configuration from the device tree. | ||
215 | * Each of the two PWM generators can drive zero or more outputs. | ||
216 | */ | ||
217 | |||
218 | for (i = 0; i < LP3943_NUM_PWMS; i++) { | ||
219 | if (!of_get_property(node, name[i], &proplen)) | ||
220 | continue; | ||
221 | |||
222 | num_outputs = proplen / sizeof(u32); | ||
223 | if (num_outputs == 0) | ||
224 | continue; | ||
225 | |||
226 | output = devm_kzalloc(dev, sizeof(*output) * num_outputs, | ||
227 | GFP_KERNEL); | ||
228 | if (!output) | ||
229 | return -ENOMEM; | ||
230 | |||
231 | err = of_property_read_u32_array(node, name[i], output, | ||
232 | num_outputs); | ||
233 | if (err) | ||
234 | return err; | ||
235 | |||
236 | pwm_map = devm_kzalloc(dev, sizeof(*pwm_map), GFP_KERNEL); | ||
237 | if (!pwm_map) | ||
238 | return -ENOMEM; | ||
239 | |||
240 | pwm_map->output = output; | ||
241 | pwm_map->num_outputs = num_outputs; | ||
242 | pdata->pwms[i] = pwm_map; | ||
243 | |||
244 | count++; | ||
245 | } | ||
246 | |||
247 | if (count == 0) | ||
248 | return -ENODATA; | ||
249 | |||
250 | lp3943_pwm->pdata = pdata; | ||
251 | return 0; | ||
252 | } | ||
253 | |||
254 | static int lp3943_pwm_probe(struct platform_device *pdev) | ||
255 | { | ||
256 | struct lp3943 *lp3943 = dev_get_drvdata(pdev->dev.parent); | ||
257 | struct lp3943_pwm *lp3943_pwm; | ||
258 | int ret; | ||
259 | |||
260 | lp3943_pwm = devm_kzalloc(&pdev->dev, sizeof(*lp3943_pwm), GFP_KERNEL); | ||
261 | if (!lp3943_pwm) | ||
262 | return -ENOMEM; | ||
263 | |||
264 | lp3943_pwm->pdata = lp3943->pdata; | ||
265 | if (!lp3943_pwm->pdata) { | ||
266 | if (IS_ENABLED(CONFIG_OF)) | ||
267 | ret = lp3943_pwm_parse_dt(&pdev->dev, lp3943_pwm); | ||
268 | else | ||
269 | ret = -ENODEV; | ||
270 | |||
271 | if (ret) | ||
272 | return ret; | ||
273 | } | ||
274 | |||
275 | lp3943_pwm->lp3943 = lp3943; | ||
276 | lp3943_pwm->chip.dev = &pdev->dev; | ||
277 | lp3943_pwm->chip.ops = &lp3943_pwm_ops; | ||
278 | lp3943_pwm->chip.npwm = LP3943_NUM_PWMS; | ||
279 | |||
280 | platform_set_drvdata(pdev, lp3943_pwm); | ||
281 | |||
282 | return pwmchip_add(&lp3943_pwm->chip); | ||
283 | } | ||
284 | |||
285 | static int lp3943_pwm_remove(struct platform_device *pdev) | ||
286 | { | ||
287 | struct lp3943_pwm *lp3943_pwm = platform_get_drvdata(pdev); | ||
288 | |||
289 | return pwmchip_remove(&lp3943_pwm->chip); | ||
290 | } | ||
291 | |||
292 | #ifdef CONFIG_OF | ||
293 | static const struct of_device_id lp3943_pwm_of_match[] = { | ||
294 | { .compatible = "ti,lp3943-pwm", }, | ||
295 | { } | ||
296 | }; | ||
297 | MODULE_DEVICE_TABLE(of, lp3943_pwm_of_match); | ||
298 | #endif | ||
299 | |||
300 | static struct platform_driver lp3943_pwm_driver = { | ||
301 | .probe = lp3943_pwm_probe, | ||
302 | .remove = lp3943_pwm_remove, | ||
303 | .driver = { | ||
304 | .name = "lp3943-pwm", | ||
305 | .owner = THIS_MODULE, | ||
306 | .of_match_table = of_match_ptr(lp3943_pwm_of_match), | ||
307 | }, | ||
308 | }; | ||
309 | module_platform_driver(lp3943_pwm_driver); | ||
310 | |||
311 | MODULE_DESCRIPTION("LP3943 PWM driver"); | ||
312 | MODULE_ALIAS("platform:lp3943-pwm"); | ||
313 | MODULE_AUTHOR("Milo Kim"); | ||
314 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig index ce785f481281..db9ae6fa2404 100644 --- a/drivers/regulator/Kconfig +++ b/drivers/regulator/Kconfig | |||
@@ -343,7 +343,7 @@ config REGULATOR_MC13XXX_CORE | |||
343 | 343 | ||
344 | config REGULATOR_MC13783 | 344 | config REGULATOR_MC13783 |
345 | tristate "Freescale MC13783 regulator driver" | 345 | tristate "Freescale MC13783 regulator driver" |
346 | depends on MFD_MC13783 | 346 | depends on MFD_MC13XXX |
347 | select REGULATOR_MC13XXX_CORE | 347 | select REGULATOR_MC13XXX_CORE |
348 | help | 348 | help |
349 | Say y here to support the regulators found on the Freescale MC13783 | 349 | Say y here to support the regulators found on the Freescale MC13783 |
diff --git a/drivers/regulator/tps6586x-regulator.c b/drivers/regulator/tps6586x-regulator.c index e8e3a8afd3e2..0485d47f0d8a 100644 --- a/drivers/regulator/tps6586x-regulator.c +++ b/drivers/regulator/tps6586x-regulator.c | |||
@@ -93,6 +93,8 @@ static const unsigned int tps6586x_ldo4_voltages[] = { | |||
93 | 2300000, 2325000, 2350000, 2375000, 2400000, 2425000, 2450000, 2475000, | 93 | 2300000, 2325000, 2350000, 2375000, 2400000, 2425000, 2450000, 2475000, |
94 | }; | 94 | }; |
95 | 95 | ||
96 | #define tps658623_sm2_voltages tps6586x_ldo4_voltages | ||
97 | |||
96 | static const unsigned int tps6586x_ldo_voltages[] = { | 98 | static const unsigned int tps6586x_ldo_voltages[] = { |
97 | 1250000, 1500000, 1800000, 2500000, 2700000, 2850000, 3100000, 3300000, | 99 | 1250000, 1500000, 1800000, 2500000, 2700000, 2850000, 3100000, 3300000, |
98 | }; | 100 | }; |
@@ -104,6 +106,13 @@ static const unsigned int tps6586x_sm2_voltages[] = { | |||
104 | 4200000, 4250000, 4300000, 4350000, 4400000, 4450000, 4500000, 4550000, | 106 | 4200000, 4250000, 4300000, 4350000, 4400000, 4450000, 4500000, 4550000, |
105 | }; | 107 | }; |
106 | 108 | ||
109 | static const unsigned int tps658643_sm2_voltages[] = { | ||
110 | 1025000, 1050000, 1075000, 1100000, 1125000, 1150000, 1175000, 1200000, | ||
111 | 1225000, 1250000, 1275000, 1300000, 1325000, 1350000, 1375000, 1400000, | ||
112 | 1425000, 1450000, 1475000, 1500000, 1525000, 1550000, 1575000, 1600000, | ||
113 | 1625000, 1650000, 1675000, 1700000, 1725000, 1750000, 1775000, 1800000, | ||
114 | }; | ||
115 | |||
107 | static const unsigned int tps6586x_dvm_voltages[] = { | 116 | static const unsigned int tps6586x_dvm_voltages[] = { |
108 | 725000, 750000, 775000, 800000, 825000, 850000, 875000, 900000, | 117 | 725000, 750000, 775000, 800000, 825000, 850000, 875000, 900000, |
109 | 925000, 950000, 975000, 1000000, 1025000, 1050000, 1075000, 1100000, | 118 | 925000, 950000, 975000, 1000000, 1025000, 1050000, 1075000, 1100000, |
@@ -119,8 +128,8 @@ static const unsigned int tps6586x_dvm_voltages[] = { | |||
119 | .ops = &tps6586x_regulator_ops, \ | 128 | .ops = &tps6586x_regulator_ops, \ |
120 | .type = REGULATOR_VOLTAGE, \ | 129 | .type = REGULATOR_VOLTAGE, \ |
121 | .id = TPS6586X_ID_##_id, \ | 130 | .id = TPS6586X_ID_##_id, \ |
122 | .n_voltages = ARRAY_SIZE(tps6586x_##vdata##_voltages), \ | 131 | .n_voltages = ARRAY_SIZE(vdata##_voltages), \ |
123 | .volt_table = tps6586x_##vdata##_voltages, \ | 132 | .volt_table = vdata##_voltages, \ |
124 | .owner = THIS_MODULE, \ | 133 | .owner = THIS_MODULE, \ |
125 | .enable_reg = TPS6586X_SUPPLY##ereg0, \ | 134 | .enable_reg = TPS6586X_SUPPLY##ereg0, \ |
126 | .enable_mask = 1 << (ebit0), \ | 135 | .enable_mask = 1 << (ebit0), \ |
@@ -162,27 +171,47 @@ static const unsigned int tps6586x_dvm_voltages[] = { | |||
162 | 171 | ||
163 | static struct tps6586x_regulator tps6586x_regulator[] = { | 172 | static struct tps6586x_regulator tps6586x_regulator[] = { |
164 | TPS6586X_SYS_REGULATOR(), | 173 | TPS6586X_SYS_REGULATOR(), |
165 | TPS6586X_LDO(LDO_0, "vinldo01", ldo0, SUPPLYV1, 5, 3, ENC, 0, END, 0), | 174 | TPS6586X_LDO(LDO_0, "vinldo01", tps6586x_ldo0, SUPPLYV1, 5, 3, ENC, 0, |
166 | TPS6586X_LDO(LDO_3, "vinldo23", ldo, SUPPLYV4, 0, 3, ENC, 2, END, 2), | 175 | END, 0), |
167 | TPS6586X_LDO(LDO_5, "REG-SYS", ldo, SUPPLYV6, 0, 3, ENE, 6, ENE, 6), | 176 | TPS6586X_LDO(LDO_3, "vinldo23", tps6586x_ldo, SUPPLYV4, 0, 3, ENC, 2, |
168 | TPS6586X_LDO(LDO_6, "vinldo678", ldo, SUPPLYV3, 0, 3, ENC, 4, END, 4), | 177 | END, 2), |
169 | TPS6586X_LDO(LDO_7, "vinldo678", ldo, SUPPLYV3, 3, 3, ENC, 5, END, 5), | 178 | TPS6586X_LDO(LDO_5, "REG-SYS", tps6586x_ldo, SUPPLYV6, 0, 3, ENE, 6, |
170 | TPS6586X_LDO(LDO_8, "vinldo678", ldo, SUPPLYV2, 5, 3, ENC, 6, END, 6), | 179 | ENE, 6), |
171 | TPS6586X_LDO(LDO_9, "vinldo9", ldo, SUPPLYV6, 3, 3, ENE, 7, ENE, 7), | 180 | TPS6586X_LDO(LDO_6, "vinldo678", tps6586x_ldo, SUPPLYV3, 0, 3, ENC, 4, |
172 | TPS6586X_LDO(LDO_RTC, "REG-SYS", ldo, SUPPLYV4, 3, 3, V4, 7, V4, 7), | 181 | END, 4), |
173 | TPS6586X_LDO(LDO_1, "vinldo01", dvm, SUPPLYV1, 0, 5, ENC, 1, END, 1), | 182 | TPS6586X_LDO(LDO_7, "vinldo678", tps6586x_ldo, SUPPLYV3, 3, 3, ENC, 5, |
174 | TPS6586X_LDO(SM_2, "vin-sm2", sm2, SUPPLYV2, 0, 5, ENC, 7, END, 7), | 183 | END, 5), |
175 | 184 | TPS6586X_LDO(LDO_8, "vinldo678", tps6586x_ldo, SUPPLYV2, 5, 3, ENC, 6, | |
176 | TPS6586X_DVM(LDO_2, "vinldo23", dvm, LDO2BV1, 0, 5, ENA, 3, | 185 | END, 6), |
186 | TPS6586X_LDO(LDO_9, "vinldo9", tps6586x_ldo, SUPPLYV6, 3, 3, ENE, 7, | ||
187 | ENE, 7), | ||
188 | TPS6586X_LDO(LDO_RTC, "REG-SYS", tps6586x_ldo, SUPPLYV4, 3, 3, V4, 7, | ||
189 | V4, 7), | ||
190 | TPS6586X_LDO(LDO_1, "vinldo01", tps6586x_dvm, SUPPLYV1, 0, 5, ENC, 1, | ||
191 | END, 1), | ||
192 | TPS6586X_LDO(SM_2, "vin-sm2", tps6586x_sm2, SUPPLYV2, 0, 5, ENC, 7, | ||
193 | END, 7), | ||
194 | |||
195 | TPS6586X_DVM(LDO_2, "vinldo23", tps6586x_dvm, LDO2BV1, 0, 5, ENA, 3, | ||
177 | ENB, 3, TPS6586X_VCC2, BIT(6)), | 196 | ENB, 3, TPS6586X_VCC2, BIT(6)), |
178 | TPS6586X_DVM(LDO_4, "vinldo4", ldo4, LDO4V1, 0, 5, ENC, 3, | 197 | TPS6586X_DVM(LDO_4, "vinldo4", tps6586x_ldo4, LDO4V1, 0, 5, ENC, 3, |
179 | END, 3, TPS6586X_VCC1, BIT(6)), | 198 | END, 3, TPS6586X_VCC1, BIT(6)), |
180 | TPS6586X_DVM(SM_0, "vin-sm0", dvm, SM0V1, 0, 5, ENA, 1, | 199 | TPS6586X_DVM(SM_0, "vin-sm0", tps6586x_dvm, SM0V1, 0, 5, ENA, 1, |
181 | ENB, 1, TPS6586X_VCC1, BIT(2)), | 200 | ENB, 1, TPS6586X_VCC1, BIT(2)), |
182 | TPS6586X_DVM(SM_1, "vin-sm1", dvm, SM1V1, 0, 5, ENA, 0, | 201 | TPS6586X_DVM(SM_1, "vin-sm1", tps6586x_dvm, SM1V1, 0, 5, ENA, 0, |
183 | ENB, 0, TPS6586X_VCC1, BIT(0)), | 202 | ENB, 0, TPS6586X_VCC1, BIT(0)), |
184 | }; | 203 | }; |
185 | 204 | ||
205 | static struct tps6586x_regulator tps658623_regulator[] = { | ||
206 | TPS6586X_LDO(SM_2, "vin-sm2", tps658623_sm2, SUPPLYV2, 0, 5, ENC, 7, | ||
207 | END, 7), | ||
208 | }; | ||
209 | |||
210 | static struct tps6586x_regulator tps658643_regulator[] = { | ||
211 | TPS6586X_LDO(SM_2, "vin-sm2", tps658643_sm2, SUPPLYV2, 0, 5, ENC, 7, | ||
212 | END, 7), | ||
213 | }; | ||
214 | |||
186 | /* | 215 | /* |
187 | * TPS6586X has 2 enable bits that are OR'ed to determine the actual | 216 | * TPS6586X has 2 enable bits that are OR'ed to determine the actual |
188 | * regulator state. Clearing one of this bits allows switching | 217 | * regulator state. Clearing one of this bits allows switching |
@@ -254,11 +283,33 @@ static int tps6586x_regulator_set_slew_rate(struct platform_device *pdev, | |||
254 | setting->slew_rate & TPS6586X_SLEW_RATE_MASK); | 283 | setting->slew_rate & TPS6586X_SLEW_RATE_MASK); |
255 | } | 284 | } |
256 | 285 | ||
257 | static inline struct tps6586x_regulator *find_regulator_info(int id) | 286 | static struct tps6586x_regulator *find_regulator_info(int id, int version) |
258 | { | 287 | { |
259 | struct tps6586x_regulator *ri; | 288 | struct tps6586x_regulator *ri; |
289 | struct tps6586x_regulator *table = NULL; | ||
290 | int num; | ||
260 | int i; | 291 | int i; |
261 | 292 | ||
293 | switch (version) { | ||
294 | case TPS658623: | ||
295 | table = tps658623_regulator; | ||
296 | num = ARRAY_SIZE(tps658623_regulator); | ||
297 | break; | ||
298 | case TPS658643: | ||
299 | table = tps658643_regulator; | ||
300 | num = ARRAY_SIZE(tps658643_regulator); | ||
301 | break; | ||
302 | } | ||
303 | |||
304 | /* Search version specific table first */ | ||
305 | if (table) { | ||
306 | for (i = 0; i < num; i++) { | ||
307 | ri = &table[i]; | ||
308 | if (ri->desc.id == id) | ||
309 | return ri; | ||
310 | } | ||
311 | } | ||
312 | |||
262 | for (i = 0; i < ARRAY_SIZE(tps6586x_regulator); i++) { | 313 | for (i = 0; i < ARRAY_SIZE(tps6586x_regulator); i++) { |
263 | ri = &tps6586x_regulator[i]; | 314 | ri = &tps6586x_regulator[i]; |
264 | if (ri->desc.id == id) | 315 | if (ri->desc.id == id) |
@@ -351,6 +402,7 @@ static int tps6586x_regulator_probe(struct platform_device *pdev) | |||
351 | struct regulator_init_data *reg_data; | 402 | struct regulator_init_data *reg_data; |
352 | struct tps6586x_platform_data *pdata; | 403 | struct tps6586x_platform_data *pdata; |
353 | struct of_regulator_match *tps6586x_reg_matches = NULL; | 404 | struct of_regulator_match *tps6586x_reg_matches = NULL; |
405 | int version; | ||
354 | int id; | 406 | int id; |
355 | int err; | 407 | int err; |
356 | 408 | ||
@@ -373,10 +425,13 @@ static int tps6586x_regulator_probe(struct platform_device *pdev) | |||
373 | return -ENOMEM; | 425 | return -ENOMEM; |
374 | } | 426 | } |
375 | 427 | ||
428 | version = tps6586x_get_version(pdev->dev.parent); | ||
429 | |||
376 | for (id = 0; id < TPS6586X_ID_MAX_REGULATOR; ++id) { | 430 | for (id = 0; id < TPS6586X_ID_MAX_REGULATOR; ++id) { |
377 | reg_data = pdata->reg_init_data[id]; | 431 | reg_data = pdata->reg_init_data[id]; |
378 | 432 | ||
379 | ri = find_regulator_info(id); | 433 | ri = find_regulator_info(id, version); |
434 | |||
380 | if (!ri) { | 435 | if (!ri) { |
381 | dev_err(&pdev->dev, "invalid regulator ID specified\n"); | 436 | dev_err(&pdev->dev, "invalid regulator ID specified\n"); |
382 | return -EINVAL; | 437 | return -EINVAL; |