Commit 9f24ff6f4236f117729bdb2fe8b0c202ce86098f

Authored by Linus Torvalds

Merge tag 'mfd-for-linus-3.4' of git://git.kernel.org/pub/scm/linux/kernel/git/sameo/mfd-2.6

Pull MFD fixes from Samuel Ortiz:
 "We have 3 build fixes, a OMAP USB host PHY reset fix and the twl6040
  conversion to an i2c driver.  The latter may not sound like a fix but
  the twl6040 MFD driver won't probe without it, triggering an OMAP4
  audio regression."

* tag 'mfd-for-linus-3.4' of git://git.kernel.org/pub/scm/linux/kernel/git/sameo/mfd-2.6:
  mfd: Fix modular builds of rc5t583 regulator support
  mfd: Fix asic3_gpio_to_irq
  ARM: OMAP3: USB: Fix the EHCI ULPI PHY reset issue
  mfd: Convert twl6040 to i2c driver, and separate it from twl core
  mfd : Fix dbx500 compilation error

Showing 20 changed files Side-by-side Diff

arch/arm/mach-omap2/board-4430sdp.c
... ... @@ -20,6 +20,7 @@
20 20 #include <linux/usb/otg.h>
21 21 #include <linux/spi/spi.h>
22 22 #include <linux/i2c/twl.h>
  23 +#include <linux/mfd/twl6040.h>
23 24 #include <linux/gpio_keys.h>
24 25 #include <linux/regulator/machine.h>
25 26 #include <linux/regulator/fixed.h>
... ... @@ -560,7 +561,7 @@
560 561 },
561 562 };
562 563  
563   -static struct twl4030_codec_data twl6040_codec = {
  564 +static struct twl6040_codec_data twl6040_codec = {
564 565 /* single-step ramp for headset and handsfree */
565 566 .hs_left_step = 0x0f,
566 567 .hs_right_step = 0x0f,
... ... @@ -568,7 +569,7 @@
568 569 .hf_right_step = 0x1d,
569 570 };
570 571  
571   -static struct twl4030_vibra_data twl6040_vibra = {
  572 +static struct twl6040_vibra_data twl6040_vibra = {
572 573 .vibldrv_res = 8,
573 574 .vibrdrv_res = 3,
574 575 .viblmotor_res = 10,
575 576  
576 577  
... ... @@ -577,16 +578,14 @@
577 578 .vddvibr_uV = 0, /* fixed volt supply - VBAT */
578 579 };
579 580  
580   -static struct twl4030_audio_data twl6040_audio = {
  581 +static struct twl6040_platform_data twl6040_data = {
581 582 .codec = &twl6040_codec,
582 583 .vibra = &twl6040_vibra,
583 584 .audpwron_gpio = 127,
584   - .naudint_irq = OMAP44XX_IRQ_SYS_2N,
585 585 .irq_base = TWL6040_CODEC_IRQ_BASE,
586 586 };
587 587  
588 588 static struct twl4030_platform_data sdp4430_twldata = {
589   - .audio = &twl6040_audio,
590 589 /* Regulators */
591 590 .vusim = &sdp4430_vusim,
592 591 .vaux1 = &sdp4430_vaux1,
... ... @@ -617,7 +616,8 @@
617 616 TWL_COMMON_REGULATOR_VCXIO |
618 617 TWL_COMMON_REGULATOR_VUSB |
619 618 TWL_COMMON_REGULATOR_CLK32KG);
620   - omap4_pmic_init("twl6030", &sdp4430_twldata);
  619 + omap4_pmic_init("twl6030", &sdp4430_twldata,
  620 + &twl6040_data, OMAP44XX_IRQ_SYS_2N);
621 621 omap_register_i2c_bus(2, 400, NULL, 0);
622 622 omap_register_i2c_bus(3, 400, sdp4430_i2c_3_boardinfo,
623 623 ARRAY_SIZE(sdp4430_i2c_3_boardinfo));
arch/arm/mach-omap2/board-generic.c
... ... @@ -137,7 +137,7 @@
137 137  
138 138 static void __init omap4_i2c_init(void)
139 139 {
140   - omap4_pmic_init("twl6030", &sdp4430_twldata);
  140 + omap4_pmic_init("twl6030", &sdp4430_twldata, NULL, 0);
141 141 }
142 142  
143 143 static void __init omap4_init(void)
arch/arm/mach-omap2/board-omap4panda.c
... ... @@ -25,6 +25,7 @@
25 25 #include <linux/gpio.h>
26 26 #include <linux/usb/otg.h>
27 27 #include <linux/i2c/twl.h>
  28 +#include <linux/mfd/twl6040.h>
28 29 #include <linux/regulator/machine.h>
29 30 #include <linux/regulator/fixed.h>
30 31 #include <linux/wl12xx.h>
... ... @@ -284,7 +285,7 @@
284 285 return 0;
285 286 }
286 287  
287   -static struct twl4030_codec_data twl6040_codec = {
  288 +static struct twl6040_codec_data twl6040_codec = {
288 289 /* single-step ramp for headset and handsfree */
289 290 .hs_left_step = 0x0f,
290 291 .hs_right_step = 0x0f,
291 292  
292 293  
... ... @@ -292,17 +293,14 @@
292 293 .hf_right_step = 0x1d,
293 294 };
294 295  
295   -static struct twl4030_audio_data twl6040_audio = {
  296 +static struct twl6040_platform_data twl6040_data = {
296 297 .codec = &twl6040_codec,
297 298 .audpwron_gpio = 127,
298   - .naudint_irq = OMAP44XX_IRQ_SYS_2N,
299 299 .irq_base = TWL6040_CODEC_IRQ_BASE,
300 300 };
301 301  
302 302 /* Panda board uses the common PMIC configuration */
303   -static struct twl4030_platform_data omap4_panda_twldata = {
304   - .audio = &twl6040_audio,
305   -};
  303 +static struct twl4030_platform_data omap4_panda_twldata;
306 304  
307 305 /*
308 306 * Display monitor features are burnt in their EEPROM as EDID data. The EEPROM
... ... @@ -326,7 +324,8 @@
326 324 TWL_COMMON_REGULATOR_VCXIO |
327 325 TWL_COMMON_REGULATOR_VUSB |
328 326 TWL_COMMON_REGULATOR_CLK32KG);
329   - omap4_pmic_init("twl6030", &omap4_panda_twldata);
  327 + omap4_pmic_init("twl6030", &omap4_panda_twldata,
  328 + &twl6040_data, OMAP44XX_IRQ_SYS_2N);
330 329 omap_register_i2c_bus(2, 400, NULL, 0);
331 330 /*
332 331 * Bus 3 is attached to the DVI port where devices like the pico DLP
arch/arm/mach-omap2/twl-common.c
... ... @@ -37,6 +37,16 @@
37 37 .flags = I2C_CLIENT_WAKE,
38 38 };
39 39  
  40 +static struct i2c_board_info __initdata omap4_i2c1_board_info[] = {
  41 + {
  42 + .addr = 0x48,
  43 + .flags = I2C_CLIENT_WAKE,
  44 + },
  45 + {
  46 + I2C_BOARD_INFO("twl6040", 0x4b),
  47 + },
  48 +};
  49 +
40 50 void __init omap_pmic_init(int bus, u32 clkrate,
41 51 const char *pmic_type, int pmic_irq,
42 52 struct twl4030_platform_data *pmic_data)
43 53  
... ... @@ -49,14 +59,31 @@
49 59 omap_register_i2c_bus(bus, clkrate, &pmic_i2c_board_info, 1);
50 60 }
51 61  
  62 +void __init omap4_pmic_init(const char *pmic_type,
  63 + struct twl4030_platform_data *pmic_data,
  64 + struct twl6040_platform_data *twl6040_data, int twl6040_irq)
  65 +{
  66 + /* PMIC part*/
  67 + strncpy(omap4_i2c1_board_info[0].type, pmic_type,
  68 + sizeof(omap4_i2c1_board_info[0].type));
  69 + omap4_i2c1_board_info[0].irq = OMAP44XX_IRQ_SYS_1N;
  70 + omap4_i2c1_board_info[0].platform_data = pmic_data;
  71 +
  72 + /* TWL6040 audio IC part */
  73 + omap4_i2c1_board_info[1].irq = twl6040_irq;
  74 + omap4_i2c1_board_info[1].platform_data = twl6040_data;
  75 +
  76 + omap_register_i2c_bus(1, 400, omap4_i2c1_board_info, 2);
  77 +
  78 +}
  79 +
52 80 void __init omap_pmic_late_init(void)
53 81 {
54 82 /* Init the OMAP TWL parameters (if PMIC has been registerd) */
55   - if (!pmic_i2c_board_info.irq)
56   - return;
57   -
58   - omap3_twl_init();
59   - omap4_twl_init();
  83 + if (pmic_i2c_board_info.irq)
  84 + omap3_twl_init();
  85 + if (omap4_i2c1_board_info[0].irq)
  86 + omap4_twl_init();
60 87 }
61 88  
62 89 #if defined(CONFIG_ARCH_OMAP3)
arch/arm/mach-omap2/twl-common.h
... ... @@ -29,6 +29,7 @@
29 29  
30 30  
31 31 struct twl4030_platform_data;
  32 +struct twl6040_platform_data;
32 33  
33 34 void omap_pmic_init(int bus, u32 clkrate, const char *pmic_type, int pmic_irq,
34 35 struct twl4030_platform_data *pmic_data);
... ... @@ -46,12 +47,9 @@
46 47 omap_pmic_init(1, 2600, pmic_type, INT_34XX_SYS_NIRQ, pmic_data);
47 48 }
48 49  
49   -static inline void omap4_pmic_init(const char *pmic_type,
50   - struct twl4030_platform_data *pmic_data)
51   -{
52   - /* Phoenix Audio IC needs I2C1 to start with 400 KHz or less */
53   - omap_pmic_init(1, 400, pmic_type, OMAP44XX_IRQ_SYS_1N, pmic_data);
54   -}
  50 +void omap4_pmic_init(const char *pmic_type,
  51 + struct twl4030_platform_data *pmic_data,
  52 + struct twl6040_platform_data *audio_data, int twl6040_irq);
55 53  
56 54 void omap3_pmic_get_config(struct twl4030_platform_data *pmic_data,
57 55 u32 pdata_flags, u32 regulators_flags);
drivers/input/misc/Kconfig
... ... @@ -380,8 +380,7 @@
380 380  
381 381 config INPUT_TWL6040_VIBRA
382 382 tristate "Support for TWL6040 Vibrator"
383   - depends on TWL4030_CORE
384   - select TWL6040_CORE
  383 + depends on TWL6040_CORE
385 384 select INPUT_FF_MEMLESS
386 385 help
387 386 This option enables support for TWL6040 Vibrator Driver.
drivers/input/misc/twl6040-vibra.c
... ... @@ -28,7 +28,7 @@
28 28 #include <linux/module.h>
29 29 #include <linux/platform_device.h>
30 30 #include <linux/workqueue.h>
31   -#include <linux/i2c/twl.h>
  31 +#include <linux/input.h>
32 32 #include <linux/mfd/twl6040.h>
33 33 #include <linux/slab.h>
34 34 #include <linux/delay.h>
... ... @@ -257,7 +257,7 @@
257 257  
258 258 static int __devinit twl6040_vibra_probe(struct platform_device *pdev)
259 259 {
260   - struct twl4030_vibra_data *pdata = pdev->dev.platform_data;
  260 + struct twl6040_vibra_data *pdata = pdev->dev.platform_data;
261 261 struct vibra_info *info;
262 262 int ret;
263 263  
... ... @@ -268,10 +268,17 @@
268 268 This is used to control charging LED brightness.
269 269  
270 270 config TWL6040_CORE
271   - bool
272   - depends on TWL4030_CORE && GENERIC_HARDIRQS
  271 + bool "Support for TWL6040 audio codec"
  272 + depends on I2C=y && GENERIC_HARDIRQS
273 273 select MFD_CORE
  274 + select REGMAP_I2C
274 275 default n
  276 + help
  277 + Say yes here if you want support for Texas Instruments TWL6040 audio
  278 + codec.
  279 + This driver provides common support for accessing the device,
  280 + additional drivers must be enabled in order to use the
  281 + functionality of the device (audio, vibra).
275 282  
276 283 config MFD_STMPE
277 284 bool "Support STMicroelectronics STMPE"
... ... @@ -527,7 +527,9 @@
527 527  
528 528 static int asic3_gpio_to_irq(struct gpio_chip *chip, unsigned offset)
529 529 {
530   - return (offset < ASIC3_NUM_GPIOS) ? IRQ_BOARD_START + offset : -ENXIO;
  530 + struct asic3 *asic = container_of(chip, struct asic3, gpio);
  531 +
  532 + return (offset < ASIC3_NUM_GPIOS) ? asic->irq_base + offset : -ENXIO;
531 533 }
532 534  
533 535 static __init int asic3_gpio_probe(struct platform_device *pdev,
drivers/mfd/omap-usb-host.c
... ... @@ -25,7 +25,6 @@
25 25 #include <linux/clk.h>
26 26 #include <linux/dma-mapping.h>
27 27 #include <linux/spinlock.h>
28   -#include <linux/gpio.h>
29 28 #include <plat/usb.h>
30 29 #include <linux/pm_runtime.h>
31 30  
... ... @@ -502,19 +501,6 @@
502 501 pm_runtime_get_sync(dev);
503 502 spin_lock_irqsave(&omap->lock, flags);
504 503  
505   - if (pdata->ehci_data->phy_reset) {
506   - if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[0]))
507   - gpio_request_one(pdata->ehci_data->reset_gpio_port[0],
508   - GPIOF_OUT_INIT_LOW, "USB1 PHY reset");
509   -
510   - if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[1]))
511   - gpio_request_one(pdata->ehci_data->reset_gpio_port[1],
512   - GPIOF_OUT_INIT_LOW, "USB2 PHY reset");
513   -
514   - /* Hold the PHY in RESET for enough time till DIR is high */
515   - udelay(10);
516   - }
517   -
518 504 omap->usbhs_rev = usbhs_read(omap->uhh_base, OMAP_UHH_REVISION);
519 505 dev_dbg(dev, "OMAP UHH_REVISION 0x%x\n", omap->usbhs_rev);
520 506  
521 507  
522 508  
... ... @@ -593,40 +579,11 @@
593 579 usbhs_omap_tll_init(dev, OMAP_TLL_CHANNEL_COUNT);
594 580 }
595 581  
596   - if (pdata->ehci_data->phy_reset) {
597   - /* Hold the PHY in RESET for enough time till
598   - * PHY is settled and ready
599   - */
600   - udelay(10);
601   -
602   - if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[0]))
603   - gpio_set_value
604   - (pdata->ehci_data->reset_gpio_port[0], 1);
605   -
606   - if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[1]))
607   - gpio_set_value
608   - (pdata->ehci_data->reset_gpio_port[1], 1);
609   - }
610   -
611 582 spin_unlock_irqrestore(&omap->lock, flags);
612 583 pm_runtime_put_sync(dev);
613 584 }
614 585  
615   -static void omap_usbhs_deinit(struct device *dev)
616   -{
617   - struct usbhs_hcd_omap *omap = dev_get_drvdata(dev);
618   - struct usbhs_omap_platform_data *pdata = &omap->platdata;
619 586  
620   - if (pdata->ehci_data->phy_reset) {
621   - if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[0]))
622   - gpio_free(pdata->ehci_data->reset_gpio_port[0]);
623   -
624   - if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[1]))
625   - gpio_free(pdata->ehci_data->reset_gpio_port[1]);
626   - }
627   -}
628   -
629   -
630 587 /**
631 588 * usbhs_omap_probe - initialize TI-based HCDs
632 589 *
... ... @@ -860,7 +817,6 @@
860 817 {
861 818 struct usbhs_hcd_omap *omap = platform_get_drvdata(pdev);
862 819  
863   - omap_usbhs_deinit(&pdev->dev);
864 820 iounmap(omap->tll_base);
865 821 iounmap(omap->uhh_base);
866 822 clk_put(omap->init_60m_fclk);
drivers/mfd/rc5t583.c
... ... @@ -80,44 +80,6 @@
80 80 {.name = "rc5t583-key", }
81 81 };
82 82  
83   -int rc5t583_write(struct device *dev, uint8_t reg, uint8_t val)
84   -{
85   - struct rc5t583 *rc5t583 = dev_get_drvdata(dev);
86   - return regmap_write(rc5t583->regmap, reg, val);
87   -}
88   -
89   -int rc5t583_read(struct device *dev, uint8_t reg, uint8_t *val)
90   -{
91   - struct rc5t583 *rc5t583 = dev_get_drvdata(dev);
92   - unsigned int ival;
93   - int ret;
94   - ret = regmap_read(rc5t583->regmap, reg, &ival);
95   - if (!ret)
96   - *val = (uint8_t)ival;
97   - return ret;
98   -}
99   -
100   -int rc5t583_set_bits(struct device *dev, unsigned int reg,
101   - unsigned int bit_mask)
102   -{
103   - struct rc5t583 *rc5t583 = dev_get_drvdata(dev);
104   - return regmap_update_bits(rc5t583->regmap, reg, bit_mask, bit_mask);
105   -}
106   -
107   -int rc5t583_clear_bits(struct device *dev, unsigned int reg,
108   - unsigned int bit_mask)
109   -{
110   - struct rc5t583 *rc5t583 = dev_get_drvdata(dev);
111   - return regmap_update_bits(rc5t583->regmap, reg, bit_mask, 0);
112   -}
113   -
114   -int rc5t583_update(struct device *dev, unsigned int reg,
115   - unsigned int val, unsigned int mask)
116   -{
117   - struct rc5t583 *rc5t583 = dev_get_drvdata(dev);
118   - return regmap_update_bits(rc5t583->regmap, reg, mask, val);
119   -}
120   -
121 83 static int __rc5t583_set_ext_pwrreq1_control(struct device *dev,
122 84 int id, int ext_pwr, int slots)
123 85 {
... ... @@ -197,6 +159,7 @@
197 159 ds_id, ext_pwr_req);
198 160 return 0;
199 161 }
  162 +EXPORT_SYMBOL(rc5t583_ext_power_req_config);
200 163  
201 164 static int rc5t583_clear_ext_power_req(struct rc5t583 *rc5t583,
202 165 struct rc5t583_platform_data *pdata)
drivers/mfd/twl6040-core.c
... ... @@ -30,7 +30,9 @@
30 30 #include <linux/platform_device.h>
31 31 #include <linux/gpio.h>
32 32 #include <linux/delay.h>
33   -#include <linux/i2c/twl.h>
  33 +#include <linux/i2c.h>
  34 +#include <linux/regmap.h>
  35 +#include <linux/err.h>
34 36 #include <linux/mfd/core.h>
35 37 #include <linux/mfd/twl6040.h>
36 38  
... ... @@ -39,7 +41,7 @@
39 41 int twl6040_reg_read(struct twl6040 *twl6040, unsigned int reg)
40 42 {
41 43 int ret;
42   - u8 val = 0;
  44 + unsigned int val;
43 45  
44 46 mutex_lock(&twl6040->io_mutex);
45 47 /* Vibra control registers from cache */
... ... @@ -47,7 +49,7 @@
47 49 reg == TWL6040_REG_VIBCTLR)) {
48 50 val = twl6040->vibra_ctrl_cache[VIBRACTRL_MEMBER(reg)];
49 51 } else {
50   - ret = twl_i2c_read_u8(TWL_MODULE_AUDIO_VOICE, &val, reg);
  52 + ret = regmap_read(twl6040->regmap, reg, &val);
51 53 if (ret < 0) {
52 54 mutex_unlock(&twl6040->io_mutex);
53 55 return ret;
... ... @@ -64,7 +66,7 @@
64 66 int ret;
65 67  
66 68 mutex_lock(&twl6040->io_mutex);
67   - ret = twl_i2c_write_u8(TWL_MODULE_AUDIO_VOICE, val, reg);
  69 + ret = regmap_write(twl6040->regmap, reg, val);
68 70 /* Cache the vibra control registers */
69 71 if (reg == TWL6040_REG_VIBCTLL || reg == TWL6040_REG_VIBCTLR)
70 72 twl6040->vibra_ctrl_cache[VIBRACTRL_MEMBER(reg)] = val;
71 73  
... ... @@ -77,16 +79,9 @@
77 79 int twl6040_set_bits(struct twl6040 *twl6040, unsigned int reg, u8 mask)
78 80 {
79 81 int ret;
80   - u8 val;
81 82  
82 83 mutex_lock(&twl6040->io_mutex);
83   - ret = twl_i2c_read_u8(TWL_MODULE_AUDIO_VOICE, &val, reg);
84   - if (ret)
85   - goto out;
86   -
87   - val |= mask;
88   - ret = twl_i2c_write_u8(TWL_MODULE_AUDIO_VOICE, val, reg);
89   -out:
  84 + ret = regmap_update_bits(twl6040->regmap, reg, mask, mask);
90 85 mutex_unlock(&twl6040->io_mutex);
91 86 return ret;
92 87 }
93 88  
... ... @@ -95,16 +90,9 @@
95 90 int twl6040_clear_bits(struct twl6040 *twl6040, unsigned int reg, u8 mask)
96 91 {
97 92 int ret;
98   - u8 val;
99 93  
100 94 mutex_lock(&twl6040->io_mutex);
101   - ret = twl_i2c_read_u8(TWL_MODULE_AUDIO_VOICE, &val, reg);
102   - if (ret)
103   - goto out;
104   -
105   - val &= ~mask;
106   - ret = twl_i2c_write_u8(TWL_MODULE_AUDIO_VOICE, val, reg);
107   -out:
  95 + ret = regmap_update_bits(twl6040->regmap, reg, mask, 0);
108 96 mutex_unlock(&twl6040->io_mutex);
109 97 return ret;
110 98 }
111 99  
112 100  
113 101  
114 102  
115 103  
116 104  
... ... @@ -494,32 +482,58 @@
494 482 },
495 483 };
496 484  
497   -static int __devinit twl6040_probe(struct platform_device *pdev)
  485 +static bool twl6040_readable_reg(struct device *dev, unsigned int reg)
498 486 {
499   - struct twl4030_audio_data *pdata = pdev->dev.platform_data;
  487 + /* Register 0 is not readable */
  488 + if (!reg)
  489 + return false;
  490 + return true;
  491 +}
  492 +
  493 +static struct regmap_config twl6040_regmap_config = {
  494 + .reg_bits = 8,
  495 + .val_bits = 8,
  496 + .max_register = TWL6040_REG_STATUS, /* 0x2e */
  497 +
  498 + .readable_reg = twl6040_readable_reg,
  499 +};
  500 +
  501 +static int __devinit twl6040_probe(struct i2c_client *client,
  502 + const struct i2c_device_id *id)
  503 +{
  504 + struct twl6040_platform_data *pdata = client->dev.platform_data;
500 505 struct twl6040 *twl6040;
501 506 struct mfd_cell *cell = NULL;
502 507 int ret, children = 0;
503 508  
504 509 if (!pdata) {
505   - dev_err(&pdev->dev, "Platform data is missing\n");
  510 + dev_err(&client->dev, "Platform data is missing\n");
506 511 return -EINVAL;
507 512 }
508 513  
509 514 /* In order to operate correctly we need valid interrupt config */
510   - if (!pdata->naudint_irq || !pdata->irq_base) {
511   - dev_err(&pdev->dev, "Invalid IRQ configuration\n");
  515 + if (!client->irq || !pdata->irq_base) {
  516 + dev_err(&client->dev, "Invalid IRQ configuration\n");
512 517 return -EINVAL;
513 518 }
514 519  
515   - twl6040 = kzalloc(sizeof(struct twl6040), GFP_KERNEL);
516   - if (!twl6040)
517   - return -ENOMEM;
  520 + twl6040 = devm_kzalloc(&client->dev, sizeof(struct twl6040),
  521 + GFP_KERNEL);
  522 + if (!twl6040) {
  523 + ret = -ENOMEM;
  524 + goto err;
  525 + }
518 526  
519   - platform_set_drvdata(pdev, twl6040);
  527 + twl6040->regmap = regmap_init_i2c(client, &twl6040_regmap_config);
  528 + if (IS_ERR(twl6040->regmap)) {
  529 + ret = PTR_ERR(twl6040->regmap);
  530 + goto err;
  531 + }
520 532  
521   - twl6040->dev = &pdev->dev;
522   - twl6040->irq = pdata->naudint_irq;
  533 + i2c_set_clientdata(client, twl6040);
  534 +
  535 + twl6040->dev = &client->dev;
  536 + twl6040->irq = client->irq;
523 537 twl6040->irq_base = pdata->irq_base;
524 538  
525 539 mutex_init(&twl6040->mutex);
526 540  
... ... @@ -588,12 +602,12 @@
588 602 }
589 603  
590 604 if (children) {
591   - ret = mfd_add_devices(&pdev->dev, pdev->id, twl6040->cells,
  605 + ret = mfd_add_devices(&client->dev, -1, twl6040->cells,
592 606 children, NULL, 0);
593 607 if (ret)
594 608 goto mfd_err;
595 609 } else {
596   - dev_err(&pdev->dev, "No platform data found for children\n");
  610 + dev_err(&client->dev, "No platform data found for children\n");
597 611 ret = -ENODEV;
598 612 goto mfd_err;
599 613 }
600 614  
601 615  
... ... @@ -608,14 +622,15 @@
608 622 if (gpio_is_valid(twl6040->audpwron))
609 623 gpio_free(twl6040->audpwron);
610 624 gpio1_err:
611   - platform_set_drvdata(pdev, NULL);
612   - kfree(twl6040);
  625 + i2c_set_clientdata(client, NULL);
  626 + regmap_exit(twl6040->regmap);
  627 +err:
613 628 return ret;
614 629 }
615 630  
616   -static int __devexit twl6040_remove(struct platform_device *pdev)
  631 +static int __devexit twl6040_remove(struct i2c_client *client)
617 632 {
618   - struct twl6040 *twl6040 = platform_get_drvdata(pdev);
  633 + struct twl6040 *twl6040 = i2c_get_clientdata(client);
619 634  
620 635 if (twl6040->power_count)
621 636 twl6040_power(twl6040, 0);
622 637  
623 638  
624 639  
... ... @@ -626,23 +641,30 @@
626 641 free_irq(twl6040->irq_base + TWL6040_IRQ_READY, twl6040);
627 642 twl6040_irq_exit(twl6040);
628 643  
629   - mfd_remove_devices(&pdev->dev);
630   - platform_set_drvdata(pdev, NULL);
631   - kfree(twl6040);
  644 + mfd_remove_devices(&client->dev);
  645 + i2c_set_clientdata(client, NULL);
  646 + regmap_exit(twl6040->regmap);
632 647  
633 648 return 0;
634 649 }
635 650  
636   -static struct platform_driver twl6040_driver = {
  651 +static const struct i2c_device_id twl6040_i2c_id[] = {
  652 + { "twl6040", 0, },
  653 + { },
  654 +};
  655 +MODULE_DEVICE_TABLE(i2c, twl6040_i2c_id);
  656 +
  657 +static struct i2c_driver twl6040_driver = {
  658 + .driver = {
  659 + .name = "twl6040",
  660 + .owner = THIS_MODULE,
  661 + },
637 662 .probe = twl6040_probe,
638 663 .remove = __devexit_p(twl6040_remove),
639   - .driver = {
640   - .owner = THIS_MODULE,
641   - .name = "twl6040",
642   - },
  664 + .id_table = twl6040_i2c_id,
643 665 };
644 666  
645   -module_platform_driver(twl6040_driver);
  667 +module_i2c_driver(twl6040_driver);
646 668  
647 669 MODULE_DESCRIPTION("TWL6040 MFD");
648 670 MODULE_AUTHOR("Misael Lopez Cruz <misael.lopez@ti.com>");
drivers/usb/host/ehci-omap.c
... ... @@ -42,6 +42,7 @@
42 42 #include <plat/usb.h>
43 43 #include <linux/regulator/consumer.h>
44 44 #include <linux/pm_runtime.h>
  45 +#include <linux/gpio.h>
45 46  
46 47 /* EHCI Register Set */
47 48 #define EHCI_INSNREG04 (0xA0)
... ... @@ -191,6 +192,19 @@
191 192 }
192 193 }
193 194  
  195 + if (pdata->phy_reset) {
  196 + if (gpio_is_valid(pdata->reset_gpio_port[0]))
  197 + gpio_request_one(pdata->reset_gpio_port[0],
  198 + GPIOF_OUT_INIT_LOW, "USB1 PHY reset");
  199 +
  200 + if (gpio_is_valid(pdata->reset_gpio_port[1]))
  201 + gpio_request_one(pdata->reset_gpio_port[1],
  202 + GPIOF_OUT_INIT_LOW, "USB2 PHY reset");
  203 +
  204 + /* Hold the PHY in RESET for enough time till DIR is high */
  205 + udelay(10);
  206 + }
  207 +
194 208 pm_runtime_enable(dev);
195 209 pm_runtime_get_sync(dev);
196 210  
... ... @@ -237,6 +251,19 @@
237 251 /* root ports should always stay powered */
238 252 ehci_port_power(omap_ehci, 1);
239 253  
  254 + if (pdata->phy_reset) {
  255 + /* Hold the PHY in RESET for enough time till
  256 + * PHY is settled and ready
  257 + */
  258 + udelay(10);
  259 +
  260 + if (gpio_is_valid(pdata->reset_gpio_port[0]))
  261 + gpio_set_value(pdata->reset_gpio_port[0], 1);
  262 +
  263 + if (gpio_is_valid(pdata->reset_gpio_port[1]))
  264 + gpio_set_value(pdata->reset_gpio_port[1], 1);
  265 + }
  266 +
240 267 return 0;
241 268  
242 269 err_add_hcd:
... ... @@ -259,8 +286,9 @@
259 286 */
260 287 static int ehci_hcd_omap_remove(struct platform_device *pdev)
261 288 {
262   - struct device *dev = &pdev->dev;
263   - struct usb_hcd *hcd = dev_get_drvdata(dev);
  289 + struct device *dev = &pdev->dev;
  290 + struct usb_hcd *hcd = dev_get_drvdata(dev);
  291 + struct ehci_hcd_omap_platform_data *pdata = dev->platform_data;
264 292  
265 293 usb_remove_hcd(hcd);
266 294 disable_put_regulator(dev->platform_data);
... ... @@ -269,6 +297,13 @@
269 297 pm_runtime_put_sync(dev);
270 298 pm_runtime_disable(dev);
271 299  
  300 + if (pdata->phy_reset) {
  301 + if (gpio_is_valid(pdata->reset_gpio_port[0]))
  302 + gpio_free(pdata->reset_gpio_port[0]);
  303 +
  304 + if (gpio_is_valid(pdata->reset_gpio_port[1]))
  305 + gpio_free(pdata->reset_gpio_port[1]);
  306 + }
272 307 return 0;
273 308 }
274 309  
include/linux/i2c/twl.h
... ... @@ -666,23 +666,11 @@
666 666 unsigned int check_defaults:1;
667 667 unsigned int reset_registers:1;
668 668 unsigned int hs_extmute:1;
669   - u16 hs_left_step;
670   - u16 hs_right_step;
671   - u16 hf_left_step;
672   - u16 hf_right_step;
673 669 void (*set_hs_extmute)(int mute);
674 670 };
675 671  
676 672 struct twl4030_vibra_data {
677 673 unsigned int coexist;
678   -
679   - /* twl6040 */
680   - unsigned int vibldrv_res; /* left driver resistance */
681   - unsigned int vibrdrv_res; /* right driver resistance */
682   - unsigned int viblmotor_res; /* left motor resistance */
683   - unsigned int vibrmotor_res; /* right motor resistance */
684   - int vddvibl_uV; /* VDDVIBL volt, set 0 for fixed reg */
685   - int vddvibr_uV; /* VDDVIBR volt, set 0 for fixed reg */
686 674 };
687 675  
688 676 struct twl4030_audio_data {
include/linux/mfd/db5500-prcmu.h
... ... @@ -8,41 +8,14 @@
8 8 #ifndef __MFD_DB5500_PRCMU_H
9 9 #define __MFD_DB5500_PRCMU_H
10 10  
11   -#ifdef CONFIG_MFD_DB5500_PRCMU
12   -
13   -void db5500_prcmu_early_init(void);
14   -int db5500_prcmu_set_epod(u16 epod_id, u8 epod_state);
15   -int db5500_prcmu_set_display_clocks(void);
16   -int db5500_prcmu_disable_dsipll(void);
17   -int db5500_prcmu_enable_dsipll(void);
18   -int db5500_prcmu_abb_read(u8 slave, u8 reg, u8 *value, u8 size);
19   -int db5500_prcmu_abb_write(u8 slave, u8 reg, u8 *value, u8 size);
20   -void db5500_prcmu_enable_wakeups(u32 wakeups);
21   -int db5500_prcmu_request_clock(u8 clock, bool enable);
22   -void db5500_prcmu_config_abb_event_readout(u32 abb_events);
23   -void db5500_prcmu_get_abb_event_buffer(void __iomem **buf);
24   -int prcmu_resetout(u8 resoutn, u8 state);
25   -int db5500_prcmu_set_power_state(u8 state, bool keep_ulp_clk,
26   - bool keep_ap_pll);
27   -int db5500_prcmu_config_esram0_deep_sleep(u8 state);
28   -void db5500_prcmu_system_reset(u16 reset_code);
29   -u16 db5500_prcmu_get_reset_code(void);
30   -bool db5500_prcmu_is_ac_wake_requested(void);
31   -int db5500_prcmu_set_arm_opp(u8 opp);
32   -int db5500_prcmu_get_arm_opp(void);
33   -
34   -#else /* !CONFIG_UX500_SOC_DB5500 */
35   -
36   -static inline void db5500_prcmu_early_init(void) {}
37   -
38   -static inline int db5500_prcmu_abb_read(u8 slave, u8 reg, u8 *value, u8 size)
  11 +static inline int prcmu_resetout(u8 resoutn, u8 state)
39 12 {
40   - return -ENOSYS;
  13 + return 0;
41 14 }
42 15  
43   -static inline int db5500_prcmu_abb_write(u8 slave, u8 reg, u8 *value, u8 size)
  16 +static inline int db5500_prcmu_set_epod(u16 epod_id, u8 epod_state)
44 17 {
45   - return -ENOSYS;
  18 + return 0;
46 19 }
47 20  
48 21 static inline int db5500_prcmu_request_clock(u8 clock, bool enable)
49 22  
50 23  
51 24  
52 25  
53 26  
54 27  
55 28  
56 29  
57 30  
58 31  
59 32  
60 33  
61 34  
62 35  
... ... @@ -50,69 +23,82 @@
50 23 return 0;
51 24 }
52 25  
53   -static inline int db5500_prcmu_set_display_clocks(void)
  26 +static inline int db5500_prcmu_set_power_state(u8 state, bool keep_ulp_clk,
  27 + bool keep_ap_pll)
54 28 {
55 29 return 0;
56 30 }
57 31  
58   -static inline int db5500_prcmu_disable_dsipll(void)
  32 +static inline int db5500_prcmu_config_esram0_deep_sleep(u8 state)
59 33 {
60 34 return 0;
61 35 }
62 36  
63   -static inline int db5500_prcmu_enable_dsipll(void)
  37 +static inline u16 db5500_prcmu_get_reset_code(void)
64 38 {
65 39 return 0;
66 40 }
67 41  
68   -static inline int db5500_prcmu_config_esram0_deep_sleep(u8 state)
  42 +static inline bool db5500_prcmu_is_ac_wake_requested(void)
69 43 {
70 44 return 0;
71 45 }
72 46  
73   -static inline void db5500_prcmu_enable_wakeups(u32 wakeups) {}
74   -
75   -static inline int prcmu_resetout(u8 resoutn, u8 state)
  47 +static inline int db5500_prcmu_set_arm_opp(u8 opp)
76 48 {
77 49 return 0;
78 50 }
79 51  
80   -static inline int db5500_prcmu_set_epod(u16 epod_id, u8 epod_state)
  52 +static inline int db5500_prcmu_get_arm_opp(void)
81 53 {
82 54 return 0;
83 55 }
84 56  
85   -static inline void db5500_prcmu_get_abb_event_buffer(void __iomem **buf) {}
86 57 static inline void db5500_prcmu_config_abb_event_readout(u32 abb_events) {}
87 58  
88   -static inline int db5500_prcmu_set_power_state(u8 state, bool keep_ulp_clk,
89   - bool keep_ap_pll)
90   -{
91   - return 0;
92   -}
  59 +static inline void db5500_prcmu_get_abb_event_buffer(void __iomem **buf) {}
93 60  
94 61 static inline void db5500_prcmu_system_reset(u16 reset_code) {}
95 62  
96   -static inline u16 db5500_prcmu_get_reset_code(void)
  63 +static inline void db5500_prcmu_enable_wakeups(u32 wakeups) {}
  64 +
  65 +#ifdef CONFIG_MFD_DB5500_PRCMU
  66 +
  67 +void db5500_prcmu_early_init(void);
  68 +int db5500_prcmu_set_display_clocks(void);
  69 +int db5500_prcmu_disable_dsipll(void);
  70 +int db5500_prcmu_enable_dsipll(void);
  71 +int db5500_prcmu_abb_read(u8 slave, u8 reg, u8 *value, u8 size);
  72 +int db5500_prcmu_abb_write(u8 slave, u8 reg, u8 *value, u8 size);
  73 +
  74 +#else /* !CONFIG_UX500_SOC_DB5500 */
  75 +
  76 +static inline void db5500_prcmu_early_init(void) {}
  77 +
  78 +static inline int db5500_prcmu_abb_read(u8 slave, u8 reg, u8 *value, u8 size)
97 79 {
98   - return 0;
  80 + return -ENOSYS;
99 81 }
100 82  
101   -static inline bool db5500_prcmu_is_ac_wake_requested(void)
  83 +static inline int db5500_prcmu_abb_write(u8 slave, u8 reg, u8 *value, u8 size)
102 84 {
103   - return 0;
  85 + return -ENOSYS;
104 86 }
105 87  
106   -static inline int db5500_prcmu_set_arm_opp(u8 opp)
  88 +static inline int db5500_prcmu_set_display_clocks(void)
107 89 {
108 90 return 0;
109 91 }
110 92  
111   -static inline int db5500_prcmu_get_arm_opp(void)
  93 +static inline int db5500_prcmu_disable_dsipll(void)
112 94 {
113 95 return 0;
114 96 }
115 97  
  98 +static inline int db5500_prcmu_enable_dsipll(void)
  99 +{
  100 + return 0;
  101 +}
116 102  
117 103 #endif /* CONFIG_MFD_DB5500_PRCMU */
118 104  
include/linux/mfd/rc5t583.h
... ... @@ -26,6 +26,7 @@
26 26  
27 27 #include <linux/mutex.h>
28 28 #include <linux/types.h>
  29 +#include <linux/regmap.h>
29 30  
30 31 #define RC5T583_MAX_REGS 0xF8
31 32  
... ... @@ -279,14 +280,44 @@
279 280 bool enable_shutdown;
280 281 };
281 282  
282   -int rc5t583_write(struct device *dev, u8 reg, uint8_t val);
283   -int rc5t583_read(struct device *dev, uint8_t reg, uint8_t *val);
284   -int rc5t583_set_bits(struct device *dev, unsigned int reg,
285   - unsigned int bit_mask);
286   -int rc5t583_clear_bits(struct device *dev, unsigned int reg,
287   - unsigned int bit_mask);
288   -int rc5t583_update(struct device *dev, unsigned int reg,
289   - unsigned int val, unsigned int mask);
  283 +static inline int rc5t583_write(struct device *dev, uint8_t reg, uint8_t val)
  284 +{
  285 + struct rc5t583 *rc5t583 = dev_get_drvdata(dev);
  286 + return regmap_write(rc5t583->regmap, reg, val);
  287 +}
  288 +
  289 +static inline int rc5t583_read(struct device *dev, uint8_t reg, uint8_t *val)
  290 +{
  291 + struct rc5t583 *rc5t583 = dev_get_drvdata(dev);
  292 + unsigned int ival;
  293 + int ret;
  294 + ret = regmap_read(rc5t583->regmap, reg, &ival);
  295 + if (!ret)
  296 + *val = (uint8_t)ival;
  297 + return ret;
  298 +}
  299 +
  300 +static inline int rc5t583_set_bits(struct device *dev, unsigned int reg,
  301 + unsigned int bit_mask)
  302 +{
  303 + struct rc5t583 *rc5t583 = dev_get_drvdata(dev);
  304 + return regmap_update_bits(rc5t583->regmap, reg, bit_mask, bit_mask);
  305 +}
  306 +
  307 +static inline int rc5t583_clear_bits(struct device *dev, unsigned int reg,
  308 + unsigned int bit_mask)
  309 +{
  310 + struct rc5t583 *rc5t583 = dev_get_drvdata(dev);
  311 + return regmap_update_bits(rc5t583->regmap, reg, bit_mask, 0);
  312 +}
  313 +
  314 +static inline int rc5t583_update(struct device *dev, unsigned int reg,
  315 + unsigned int val, unsigned int mask)
  316 +{
  317 + struct rc5t583 *rc5t583 = dev_get_drvdata(dev);
  318 + return regmap_update_bits(rc5t583->regmap, reg, mask, val);
  319 +}
  320 +
290 321 int rc5t583_ext_power_req_config(struct device *dev, int deepsleep_id,
291 322 int ext_pwr_req, int deepsleep_slot_nr);
292 323 int rc5t583_irq_init(struct rc5t583 *rc5t583, int irq, int irq_base);
include/linux/mfd/twl6040.h
... ... @@ -174,8 +174,35 @@
174 174 #define TWL6040_SYSCLK_SEL_LPPLL 0
175 175 #define TWL6040_SYSCLK_SEL_HPPLL 1
176 176  
  177 +struct twl6040_codec_data {
  178 + u16 hs_left_step;
  179 + u16 hs_right_step;
  180 + u16 hf_left_step;
  181 + u16 hf_right_step;
  182 +};
  183 +
  184 +struct twl6040_vibra_data {
  185 + unsigned int vibldrv_res; /* left driver resistance */
  186 + unsigned int vibrdrv_res; /* right driver resistance */
  187 + unsigned int viblmotor_res; /* left motor resistance */
  188 + unsigned int vibrmotor_res; /* right motor resistance */
  189 + int vddvibl_uV; /* VDDVIBL volt, set 0 for fixed reg */
  190 + int vddvibr_uV; /* VDDVIBR volt, set 0 for fixed reg */
  191 +};
  192 +
  193 +struct twl6040_platform_data {
  194 + int audpwron_gpio; /* audio power-on gpio */
  195 + unsigned int irq_base;
  196 +
  197 + struct twl6040_codec_data *codec;
  198 + struct twl6040_vibra_data *vibra;
  199 +};
  200 +
  201 +struct regmap;
  202 +
177 203 struct twl6040 {
178 204 struct device *dev;
  205 + struct regmap *regmap;
179 206 struct mutex mutex;
180 207 struct mutex io_mutex;
181 208 struct mutex irq_mutex;
sound/soc/codecs/Kconfig
... ... @@ -57,7 +57,7 @@
57 57 select SND_SOC_TPA6130A2 if I2C
58 58 select SND_SOC_TLV320DAC33 if I2C
59 59 select SND_SOC_TWL4030 if TWL4030_CORE
60   - select SND_SOC_TWL6040 if TWL4030_CORE
  60 + select SND_SOC_TWL6040 if TWL6040_CORE
61 61 select SND_SOC_UDA134X
62 62 select SND_SOC_UDA1380 if I2C
63 63 select SND_SOC_WL1273 if MFD_WL1273_CORE
... ... @@ -276,7 +276,6 @@
276 276 tristate
277 277  
278 278 config SND_SOC_TWL6040
279   - select TWL6040_CORE
280 279 tristate
281 280  
282 281 config SND_SOC_UDA134X
sound/soc/codecs/twl6040.c
... ... @@ -26,7 +26,6 @@
26 26 #include <linux/pm.h>
27 27 #include <linux/platform_device.h>
28 28 #include <linux/slab.h>
29   -#include <linux/i2c/twl.h>
30 29 #include <linux/mfd/twl6040.h>
31 30  
32 31 #include <sound/core.h>
... ... @@ -1528,7 +1527,7 @@
1528 1527 static int twl6040_probe(struct snd_soc_codec *codec)
1529 1528 {
1530 1529 struct twl6040_data *priv;
1531   - struct twl4030_codec_data *pdata = dev_get_platdata(codec->dev);
  1530 + struct twl6040_codec_data *pdata = dev_get_platdata(codec->dev);
1532 1531 struct platform_device *pdev = container_of(codec->dev,
1533 1532 struct platform_device, dev);
1534 1533 int ret = 0;
sound/soc/omap/Kconfig
... ... @@ -97,7 +97,7 @@
97 97  
98 98 config SND_OMAP_SOC_OMAP_ABE_TWL6040
99 99 tristate "SoC Audio support for OMAP boards using ABE and twl6040 codec"
100   - depends on TWL4030_CORE && SND_OMAP_SOC && ARCH_OMAP4
  100 + depends on TWL6040_CORE && SND_OMAP_SOC && ARCH_OMAP4
101 101 select SND_OMAP_SOC_DMIC
102 102 select SND_OMAP_SOC_MCPDM
103 103 select SND_SOC_TWL6040