diff options
| -rw-r--r-- | arch/arm/mach-omap2/board-4430sdp.c | 12 | ||||
| -rw-r--r-- | arch/arm/mach-omap2/board-generic.c | 2 | ||||
| -rw-r--r-- | arch/arm/mach-omap2/board-omap4panda.c | 13 | ||||
| -rw-r--r-- | arch/arm/mach-omap2/twl-common.c | 37 | ||||
| -rw-r--r-- | arch/arm/mach-omap2/twl-common.h | 10 | ||||
| -rw-r--r-- | drivers/input/misc/Kconfig | 3 | ||||
| -rw-r--r-- | drivers/input/misc/twl6040-vibra.c | 4 | ||||
| -rw-r--r-- | drivers/mfd/Kconfig | 11 | ||||
| -rw-r--r-- | drivers/mfd/twl6040-core.c | 114 | ||||
| -rw-r--r-- | include/linux/i2c/twl.h | 12 | ||||
| -rw-r--r-- | include/linux/mfd/twl6040.h | 27 | ||||
| -rw-r--r-- | sound/soc/codecs/Kconfig | 3 | ||||
| -rw-r--r-- | sound/soc/codecs/twl6040.c | 3 | ||||
| -rw-r--r-- | sound/soc/omap/Kconfig | 2 |
14 files changed, 159 insertions, 94 deletions
diff --git a/arch/arm/mach-omap2/board-4430sdp.c b/arch/arm/mach-omap2/board-4430sdp.c index a39fc4bbd2b8..130ab00c09a2 100644 --- a/arch/arm/mach-omap2/board-4430sdp.c +++ b/arch/arm/mach-omap2/board-4430sdp.c | |||
| @@ -20,6 +20,7 @@ | |||
| 20 | #include <linux/usb/otg.h> | 20 | #include <linux/usb/otg.h> |
| 21 | #include <linux/spi/spi.h> | 21 | #include <linux/spi/spi.h> |
| 22 | #include <linux/i2c/twl.h> | 22 | #include <linux/i2c/twl.h> |
| 23 | #include <linux/mfd/twl6040.h> | ||
| 23 | #include <linux/gpio_keys.h> | 24 | #include <linux/gpio_keys.h> |
| 24 | #include <linux/regulator/machine.h> | 25 | #include <linux/regulator/machine.h> |
| 25 | #include <linux/regulator/fixed.h> | 26 | #include <linux/regulator/fixed.h> |
| @@ -560,7 +561,7 @@ static struct regulator_init_data sdp4430_vusim = { | |||
| 560 | }, | 561 | }, |
| 561 | }; | 562 | }; |
| 562 | 563 | ||
| 563 | static struct twl4030_codec_data twl6040_codec = { | 564 | static struct twl6040_codec_data twl6040_codec = { |
| 564 | /* single-step ramp for headset and handsfree */ | 565 | /* single-step ramp for headset and handsfree */ |
| 565 | .hs_left_step = 0x0f, | 566 | .hs_left_step = 0x0f, |
| 566 | .hs_right_step = 0x0f, | 567 | .hs_right_step = 0x0f, |
| @@ -568,7 +569,7 @@ static struct twl4030_codec_data twl6040_codec = { | |||
| 568 | .hf_right_step = 0x1d, | 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 | .vibldrv_res = 8, | 573 | .vibldrv_res = 8, |
| 573 | .vibrdrv_res = 3, | 574 | .vibrdrv_res = 3, |
| 574 | .viblmotor_res = 10, | 575 | .viblmotor_res = 10, |
| @@ -577,16 +578,14 @@ static struct twl4030_vibra_data twl6040_vibra = { | |||
| 577 | .vddvibr_uV = 0, /* fixed volt supply - VBAT */ | 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 | .codec = &twl6040_codec, | 582 | .codec = &twl6040_codec, |
| 582 | .vibra = &twl6040_vibra, | 583 | .vibra = &twl6040_vibra, |
| 583 | .audpwron_gpio = 127, | 584 | .audpwron_gpio = 127, |
| 584 | .naudint_irq = OMAP44XX_IRQ_SYS_2N, | ||
| 585 | .irq_base = TWL6040_CODEC_IRQ_BASE, | 585 | .irq_base = TWL6040_CODEC_IRQ_BASE, |
| 586 | }; | 586 | }; |
| 587 | 587 | ||
| 588 | static struct twl4030_platform_data sdp4430_twldata = { | 588 | static struct twl4030_platform_data sdp4430_twldata = { |
| 589 | .audio = &twl6040_audio, | ||
| 590 | /* Regulators */ | 589 | /* Regulators */ |
| 591 | .vusim = &sdp4430_vusim, | 590 | .vusim = &sdp4430_vusim, |
| 592 | .vaux1 = &sdp4430_vaux1, | 591 | .vaux1 = &sdp4430_vaux1, |
| @@ -617,7 +616,8 @@ static int __init omap4_i2c_init(void) | |||
| 617 | TWL_COMMON_REGULATOR_VCXIO | | 616 | TWL_COMMON_REGULATOR_VCXIO | |
| 618 | TWL_COMMON_REGULATOR_VUSB | | 617 | TWL_COMMON_REGULATOR_VUSB | |
| 619 | TWL_COMMON_REGULATOR_CLK32KG); | 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 | omap_register_i2c_bus(2, 400, NULL, 0); | 621 | omap_register_i2c_bus(2, 400, NULL, 0); |
| 622 | omap_register_i2c_bus(3, 400, sdp4430_i2c_3_boardinfo, | 622 | omap_register_i2c_bus(3, 400, sdp4430_i2c_3_boardinfo, |
| 623 | ARRAY_SIZE(sdp4430_i2c_3_boardinfo)); | 623 | ARRAY_SIZE(sdp4430_i2c_3_boardinfo)); |
diff --git a/arch/arm/mach-omap2/board-generic.c b/arch/arm/mach-omap2/board-generic.c index 74e1687b5170..098d183a0086 100644 --- a/arch/arm/mach-omap2/board-generic.c +++ b/arch/arm/mach-omap2/board-generic.c | |||
| @@ -137,7 +137,7 @@ static struct twl4030_platform_data sdp4430_twldata = { | |||
| 137 | 137 | ||
| 138 | static void __init omap4_i2c_init(void) | 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 | static void __init omap4_init(void) | 143 | static void __init omap4_init(void) |
diff --git a/arch/arm/mach-omap2/board-omap4panda.c b/arch/arm/mach-omap2/board-omap4panda.c index d8c0e89f0126..1b782ba53433 100644 --- a/arch/arm/mach-omap2/board-omap4panda.c +++ b/arch/arm/mach-omap2/board-omap4panda.c | |||
| @@ -25,6 +25,7 @@ | |||
| 25 | #include <linux/gpio.h> | 25 | #include <linux/gpio.h> |
| 26 | #include <linux/usb/otg.h> | 26 | #include <linux/usb/otg.h> |
| 27 | #include <linux/i2c/twl.h> | 27 | #include <linux/i2c/twl.h> |
| 28 | #include <linux/mfd/twl6040.h> | ||
| 28 | #include <linux/regulator/machine.h> | 29 | #include <linux/regulator/machine.h> |
| 29 | #include <linux/regulator/fixed.h> | 30 | #include <linux/regulator/fixed.h> |
| 30 | #include <linux/wl12xx.h> | 31 | #include <linux/wl12xx.h> |
| @@ -284,7 +285,7 @@ static int __init omap4_twl6030_hsmmc_init(struct omap2_hsmmc_info *controllers) | |||
| 284 | return 0; | 285 | return 0; |
| 285 | } | 286 | } |
| 286 | 287 | ||
| 287 | static struct twl4030_codec_data twl6040_codec = { | 288 | static struct twl6040_codec_data twl6040_codec = { |
| 288 | /* single-step ramp for headset and handsfree */ | 289 | /* single-step ramp for headset and handsfree */ |
| 289 | .hs_left_step = 0x0f, | 290 | .hs_left_step = 0x0f, |
| 290 | .hs_right_step = 0x0f, | 291 | .hs_right_step = 0x0f, |
| @@ -292,17 +293,14 @@ static struct twl4030_codec_data twl6040_codec = { | |||
| 292 | .hf_right_step = 0x1d, | 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 | .codec = &twl6040_codec, | 297 | .codec = &twl6040_codec, |
| 297 | .audpwron_gpio = 127, | 298 | .audpwron_gpio = 127, |
| 298 | .naudint_irq = OMAP44XX_IRQ_SYS_2N, | ||
| 299 | .irq_base = TWL6040_CODEC_IRQ_BASE, | 299 | .irq_base = TWL6040_CODEC_IRQ_BASE, |
| 300 | }; | 300 | }; |
| 301 | 301 | ||
| 302 | /* Panda board uses the common PMIC configuration */ | 302 | /* Panda board uses the common PMIC configuration */ |
| 303 | static struct twl4030_platform_data omap4_panda_twldata = { | 303 | static struct twl4030_platform_data omap4_panda_twldata; |
| 304 | .audio = &twl6040_audio, | ||
| 305 | }; | ||
| 306 | 304 | ||
| 307 | /* | 305 | /* |
| 308 | * Display monitor features are burnt in their EEPROM as EDID data. The EEPROM | 306 | * Display monitor features are burnt in their EEPROM as EDID data. The EEPROM |
| @@ -326,7 +324,8 @@ static int __init omap4_panda_i2c_init(void) | |||
| 326 | TWL_COMMON_REGULATOR_VCXIO | | 324 | TWL_COMMON_REGULATOR_VCXIO | |
| 327 | TWL_COMMON_REGULATOR_VUSB | | 325 | TWL_COMMON_REGULATOR_VUSB | |
| 328 | TWL_COMMON_REGULATOR_CLK32KG); | 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 | omap_register_i2c_bus(2, 400, NULL, 0); | 329 | omap_register_i2c_bus(2, 400, NULL, 0); |
| 331 | /* | 330 | /* |
| 332 | * Bus 3 is attached to the DVI port where devices like the pico DLP | 331 | * Bus 3 is attached to the DVI port where devices like the pico DLP |
diff --git a/arch/arm/mach-omap2/twl-common.c b/arch/arm/mach-omap2/twl-common.c index 4b57757bf9d1..7a7b89304c48 100644 --- a/arch/arm/mach-omap2/twl-common.c +++ b/arch/arm/mach-omap2/twl-common.c | |||
| @@ -37,6 +37,16 @@ static struct i2c_board_info __initdata pmic_i2c_board_info = { | |||
| 37 | .flags = I2C_CLIENT_WAKE, | 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 | void __init omap_pmic_init(int bus, u32 clkrate, | 50 | void __init omap_pmic_init(int bus, u32 clkrate, |
| 41 | const char *pmic_type, int pmic_irq, | 51 | const char *pmic_type, int pmic_irq, |
| 42 | struct twl4030_platform_data *pmic_data) | 52 | struct twl4030_platform_data *pmic_data) |
| @@ -49,14 +59,31 @@ void __init omap_pmic_init(int bus, u32 clkrate, | |||
| 49 | omap_register_i2c_bus(bus, clkrate, &pmic_i2c_board_info, 1); | 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 | void __init omap_pmic_late_init(void) | 80 | void __init omap_pmic_late_init(void) |
| 53 | { | 81 | { |
| 54 | /* Init the OMAP TWL parameters (if PMIC has been registerd) */ | 82 | /* Init the OMAP TWL parameters (if PMIC has been registerd) */ |
| 55 | if (!pmic_i2c_board_info.irq) | 83 | if (pmic_i2c_board_info.irq) |
| 56 | return; | 84 | omap3_twl_init(); |
| 57 | 85 | if (omap4_i2c1_board_info[0].irq) | |
| 58 | omap3_twl_init(); | 86 | omap4_twl_init(); |
| 59 | omap4_twl_init(); | ||
| 60 | } | 87 | } |
| 61 | 88 | ||
| 62 | #if defined(CONFIG_ARCH_OMAP3) | 89 | #if defined(CONFIG_ARCH_OMAP3) |
diff --git a/arch/arm/mach-omap2/twl-common.h b/arch/arm/mach-omap2/twl-common.h index 275dde8cb27a..09627483a57f 100644 --- a/arch/arm/mach-omap2/twl-common.h +++ b/arch/arm/mach-omap2/twl-common.h | |||
| @@ -29,6 +29,7 @@ | |||
| 29 | 29 | ||
| 30 | 30 | ||
| 31 | struct twl4030_platform_data; | 31 | struct twl4030_platform_data; |
| 32 | struct twl6040_platform_data; | ||
| 32 | 33 | ||
| 33 | void omap_pmic_init(int bus, u32 clkrate, const char *pmic_type, int pmic_irq, | 34 | void omap_pmic_init(int bus, u32 clkrate, const char *pmic_type, int pmic_irq, |
| 34 | struct twl4030_platform_data *pmic_data); | 35 | struct twl4030_platform_data *pmic_data); |
| @@ -46,12 +47,9 @@ static inline void omap3_pmic_init(const char *pmic_type, | |||
| 46 | omap_pmic_init(1, 2600, pmic_type, INT_34XX_SYS_NIRQ, pmic_data); | 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 | void omap4_pmic_init(const char *pmic_type, |
| 50 | struct twl4030_platform_data *pmic_data) | 51 | struct twl4030_platform_data *pmic_data, |
| 51 | { | 52 | struct twl6040_platform_data *audio_data, int twl6040_irq); |
| 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 | } | ||
| 55 | 53 | ||
| 56 | void omap3_pmic_get_config(struct twl4030_platform_data *pmic_data, | 54 | void omap3_pmic_get_config(struct twl4030_platform_data *pmic_data, |
| 57 | u32 pdata_flags, u32 regulators_flags); | 55 | u32 pdata_flags, u32 regulators_flags); |
diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig index 2d787796bf50..7faf4a7fcaa9 100644 --- a/drivers/input/misc/Kconfig +++ b/drivers/input/misc/Kconfig | |||
| @@ -380,8 +380,7 @@ config INPUT_TWL4030_VIBRA | |||
| 380 | 380 | ||
| 381 | config INPUT_TWL6040_VIBRA | 381 | config INPUT_TWL6040_VIBRA |
| 382 | tristate "Support for TWL6040 Vibrator" | 382 | tristate "Support for TWL6040 Vibrator" |
| 383 | depends on TWL4030_CORE | 383 | depends on TWL6040_CORE |
| 384 | select TWL6040_CORE | ||
| 385 | select INPUT_FF_MEMLESS | 384 | select INPUT_FF_MEMLESS |
| 386 | help | 385 | help |
| 387 | This option enables support for TWL6040 Vibrator Driver. | 386 | This option enables support for TWL6040 Vibrator Driver. |
diff --git a/drivers/input/misc/twl6040-vibra.c b/drivers/input/misc/twl6040-vibra.c index 45874fed523a..14e94f56cb7d 100644 --- a/drivers/input/misc/twl6040-vibra.c +++ b/drivers/input/misc/twl6040-vibra.c | |||
| @@ -28,7 +28,7 @@ | |||
| 28 | #include <linux/module.h> | 28 | #include <linux/module.h> |
| 29 | #include <linux/platform_device.h> | 29 | #include <linux/platform_device.h> |
| 30 | #include <linux/workqueue.h> | 30 | #include <linux/workqueue.h> |
| 31 | #include <linux/i2c/twl.h> | 31 | #include <linux/input.h> |
| 32 | #include <linux/mfd/twl6040.h> | 32 | #include <linux/mfd/twl6040.h> |
| 33 | #include <linux/slab.h> | 33 | #include <linux/slab.h> |
| 34 | #include <linux/delay.h> | 34 | #include <linux/delay.h> |
| @@ -257,7 +257,7 @@ static SIMPLE_DEV_PM_OPS(twl6040_vibra_pm_ops, twl6040_vibra_suspend, NULL); | |||
| 257 | 257 | ||
| 258 | static int __devinit twl6040_vibra_probe(struct platform_device *pdev) | 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 | struct vibra_info *info; | 261 | struct vibra_info *info; |
| 262 | int ret; | 262 | int ret; |
| 263 | 263 | ||
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index 29f463cc09cb..11e44386fa9b 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig | |||
| @@ -268,10 +268,17 @@ config TWL6030_PWM | |||
| 268 | This is used to control charging LED brightness. | 268 | This is used to control charging LED brightness. |
| 269 | 269 | ||
| 270 | config TWL6040_CORE | 270 | config TWL6040_CORE |
| 271 | bool | 271 | bool "Support for TWL6040 audio codec" |
| 272 | depends on TWL4030_CORE && GENERIC_HARDIRQS | 272 | depends on I2C=y && GENERIC_HARDIRQS |
| 273 | select MFD_CORE | 273 | select MFD_CORE |
| 274 | select REGMAP_I2C | ||
| 274 | default n | 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 | config MFD_STMPE | 283 | config MFD_STMPE |
| 277 | bool "Support STMicroelectronics STMPE" | 284 | bool "Support STMicroelectronics STMPE" |
diff --git a/drivers/mfd/twl6040-core.c b/drivers/mfd/twl6040-core.c index b2d8e512d3cb..2d6bedadca09 100644 --- a/drivers/mfd/twl6040-core.c +++ b/drivers/mfd/twl6040-core.c | |||
| @@ -30,7 +30,9 @@ | |||
| 30 | #include <linux/platform_device.h> | 30 | #include <linux/platform_device.h> |
| 31 | #include <linux/gpio.h> | 31 | #include <linux/gpio.h> |
| 32 | #include <linux/delay.h> | 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 | #include <linux/mfd/core.h> | 36 | #include <linux/mfd/core.h> |
| 35 | #include <linux/mfd/twl6040.h> | 37 | #include <linux/mfd/twl6040.h> |
| 36 | 38 | ||
| @@ -39,7 +41,7 @@ | |||
| 39 | int twl6040_reg_read(struct twl6040 *twl6040, unsigned int reg) | 41 | int twl6040_reg_read(struct twl6040 *twl6040, unsigned int reg) |
| 40 | { | 42 | { |
| 41 | int ret; | 43 | int ret; |
| 42 | u8 val = 0; | 44 | unsigned int val; |
| 43 | 45 | ||
| 44 | mutex_lock(&twl6040->io_mutex); | 46 | mutex_lock(&twl6040->io_mutex); |
| 45 | /* Vibra control registers from cache */ | 47 | /* Vibra control registers from cache */ |
| @@ -47,7 +49,7 @@ int twl6040_reg_read(struct twl6040 *twl6040, unsigned int reg) | |||
| 47 | reg == TWL6040_REG_VIBCTLR)) { | 49 | reg == TWL6040_REG_VIBCTLR)) { |
| 48 | val = twl6040->vibra_ctrl_cache[VIBRACTRL_MEMBER(reg)]; | 50 | val = twl6040->vibra_ctrl_cache[VIBRACTRL_MEMBER(reg)]; |
| 49 | } else { | 51 | } else { |
| 50 | ret = twl_i2c_read_u8(TWL_MODULE_AUDIO_VOICE, &val, reg); | 52 | ret = regmap_read(twl6040->regmap, reg, &val); |
| 51 | if (ret < 0) { | 53 | if (ret < 0) { |
| 52 | mutex_unlock(&twl6040->io_mutex); | 54 | mutex_unlock(&twl6040->io_mutex); |
| 53 | return ret; | 55 | return ret; |
| @@ -64,7 +66,7 @@ int twl6040_reg_write(struct twl6040 *twl6040, unsigned int reg, u8 val) | |||
| 64 | int ret; | 66 | int ret; |
| 65 | 67 | ||
| 66 | mutex_lock(&twl6040->io_mutex); | 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 | /* Cache the vibra control registers */ | 70 | /* Cache the vibra control registers */ |
| 69 | if (reg == TWL6040_REG_VIBCTLL || reg == TWL6040_REG_VIBCTLR) | 71 | if (reg == TWL6040_REG_VIBCTLL || reg == TWL6040_REG_VIBCTLR) |
| 70 | twl6040->vibra_ctrl_cache[VIBRACTRL_MEMBER(reg)] = val; | 72 | twl6040->vibra_ctrl_cache[VIBRACTRL_MEMBER(reg)] = val; |
| @@ -77,16 +79,9 @@ EXPORT_SYMBOL(twl6040_reg_write); | |||
| 77 | int twl6040_set_bits(struct twl6040 *twl6040, unsigned int reg, u8 mask) | 79 | int twl6040_set_bits(struct twl6040 *twl6040, unsigned int reg, u8 mask) |
| 78 | { | 80 | { |
| 79 | int ret; | 81 | int ret; |
| 80 | u8 val; | ||
| 81 | 82 | ||
| 82 | mutex_lock(&twl6040->io_mutex); | 83 | mutex_lock(&twl6040->io_mutex); |
| 83 | ret = twl_i2c_read_u8(TWL_MODULE_AUDIO_VOICE, &val, reg); | 84 | ret = regmap_update_bits(twl6040->regmap, reg, mask, mask); |
| 84 | if (ret) | ||
| 85 | goto out; | ||
| 86 | |||
| 87 | val |= mask; | ||
| 88 | ret = twl_i2c_write_u8(TWL_MODULE_AUDIO_VOICE, val, reg); | ||
| 89 | out: | ||
| 90 | mutex_unlock(&twl6040->io_mutex); | 85 | mutex_unlock(&twl6040->io_mutex); |
| 91 | return ret; | 86 | return ret; |
| 92 | } | 87 | } |
| @@ -95,16 +90,9 @@ EXPORT_SYMBOL(twl6040_set_bits); | |||
| 95 | int twl6040_clear_bits(struct twl6040 *twl6040, unsigned int reg, u8 mask) | 90 | int twl6040_clear_bits(struct twl6040 *twl6040, unsigned int reg, u8 mask) |
| 96 | { | 91 | { |
| 97 | int ret; | 92 | int ret; |
| 98 | u8 val; | ||
| 99 | 93 | ||
| 100 | mutex_lock(&twl6040->io_mutex); | 94 | mutex_lock(&twl6040->io_mutex); |
| 101 | ret = twl_i2c_read_u8(TWL_MODULE_AUDIO_VOICE, &val, reg); | 95 | ret = regmap_update_bits(twl6040->regmap, reg, mask, 0); |
| 102 | if (ret) | ||
| 103 | goto out; | ||
| 104 | |||
| 105 | val &= ~mask; | ||
| 106 | ret = twl_i2c_write_u8(TWL_MODULE_AUDIO_VOICE, val, reg); | ||
| 107 | out: | ||
| 108 | mutex_unlock(&twl6040->io_mutex); | 96 | mutex_unlock(&twl6040->io_mutex); |
| 109 | return ret; | 97 | return ret; |
| 110 | } | 98 | } |
| @@ -494,32 +482,58 @@ static struct resource twl6040_codec_rsrc[] = { | |||
| 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 | struct twl6040 *twl6040; | 505 | struct twl6040 *twl6040; |
| 501 | struct mfd_cell *cell = NULL; | 506 | struct mfd_cell *cell = NULL; |
| 502 | int ret, children = 0; | 507 | int ret, children = 0; |
| 503 | 508 | ||
| 504 | if (!pdata) { | 509 | if (!pdata) { |
| 505 | dev_err(&pdev->dev, "Platform data is missing\n"); | 510 | dev_err(&client->dev, "Platform data is missing\n"); |
| 506 | return -EINVAL; | 511 | return -EINVAL; |
| 507 | } | 512 | } |
| 508 | 513 | ||
| 509 | /* In order to operate correctly we need valid interrupt config */ | 514 | /* In order to operate correctly we need valid interrupt config */ |
| 510 | if (!pdata->naudint_irq || !pdata->irq_base) { | 515 | if (!client->irq || !pdata->irq_base) { |
| 511 | dev_err(&pdev->dev, "Invalid IRQ configuration\n"); | 516 | dev_err(&client->dev, "Invalid IRQ configuration\n"); |
| 512 | return -EINVAL; | 517 | return -EINVAL; |
| 513 | } | 518 | } |
| 514 | 519 | ||
| 515 | twl6040 = kzalloc(sizeof(struct twl6040), GFP_KERNEL); | 520 | twl6040 = devm_kzalloc(&client->dev, sizeof(struct twl6040), |
| 516 | if (!twl6040) | 521 | GFP_KERNEL); |
| 517 | return -ENOMEM; | 522 | if (!twl6040) { |
| 523 | ret = -ENOMEM; | ||
| 524 | goto err; | ||
| 525 | } | ||
| 526 | |||
| 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 | } | ||
| 518 | 532 | ||
| 519 | platform_set_drvdata(pdev, twl6040); | 533 | i2c_set_clientdata(client, twl6040); |
| 520 | 534 | ||
| 521 | twl6040->dev = &pdev->dev; | 535 | twl6040->dev = &client->dev; |
| 522 | twl6040->irq = pdata->naudint_irq; | 536 | twl6040->irq = client->irq; |
| 523 | twl6040->irq_base = pdata->irq_base; | 537 | twl6040->irq_base = pdata->irq_base; |
| 524 | 538 | ||
| 525 | mutex_init(&twl6040->mutex); | 539 | mutex_init(&twl6040->mutex); |
| @@ -588,12 +602,12 @@ static int __devinit twl6040_probe(struct platform_device *pdev) | |||
| 588 | } | 602 | } |
| 589 | 603 | ||
| 590 | if (children) { | 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 | children, NULL, 0); | 606 | children, NULL, 0); |
| 593 | if (ret) | 607 | if (ret) |
| 594 | goto mfd_err; | 608 | goto mfd_err; |
| 595 | } else { | 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 | ret = -ENODEV; | 611 | ret = -ENODEV; |
| 598 | goto mfd_err; | 612 | goto mfd_err; |
| 599 | } | 613 | } |
| @@ -608,14 +622,15 @@ gpio2_err: | |||
| 608 | if (gpio_is_valid(twl6040->audpwron)) | 622 | if (gpio_is_valid(twl6040->audpwron)) |
| 609 | gpio_free(twl6040->audpwron); | 623 | gpio_free(twl6040->audpwron); |
| 610 | gpio1_err: | 624 | gpio1_err: |
| 611 | platform_set_drvdata(pdev, NULL); | 625 | i2c_set_clientdata(client, NULL); |
| 612 | kfree(twl6040); | 626 | regmap_exit(twl6040->regmap); |
| 627 | err: | ||
| 613 | return ret; | 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 | if (twl6040->power_count) | 635 | if (twl6040->power_count) |
| 621 | twl6040_power(twl6040, 0); | 636 | twl6040_power(twl6040, 0); |
| @@ -626,23 +641,30 @@ static int __devexit twl6040_remove(struct platform_device *pdev) | |||
| 626 | free_irq(twl6040->irq_base + TWL6040_IRQ_READY, twl6040); | 641 | free_irq(twl6040->irq_base + TWL6040_IRQ_READY, twl6040); |
| 627 | twl6040_irq_exit(twl6040); | 642 | twl6040_irq_exit(twl6040); |
| 628 | 643 | ||
| 629 | mfd_remove_devices(&pdev->dev); | 644 | mfd_remove_devices(&client->dev); |
| 630 | platform_set_drvdata(pdev, NULL); | 645 | i2c_set_clientdata(client, NULL); |
| 631 | kfree(twl6040); | 646 | regmap_exit(twl6040->regmap); |
| 632 | 647 | ||
| 633 | return 0; | 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 | .probe = twl6040_probe, | 662 | .probe = twl6040_probe, |
| 638 | .remove = __devexit_p(twl6040_remove), | 663 | .remove = __devexit_p(twl6040_remove), |
| 639 | .driver = { | 664 | .id_table = twl6040_i2c_id, |
| 640 | .owner = THIS_MODULE, | ||
| 641 | .name = "twl6040", | ||
| 642 | }, | ||
| 643 | }; | 665 | }; |
| 644 | 666 | ||
| 645 | module_platform_driver(twl6040_driver); | 667 | module_i2c_driver(twl6040_driver); |
| 646 | 668 | ||
| 647 | MODULE_DESCRIPTION("TWL6040 MFD"); | 669 | MODULE_DESCRIPTION("TWL6040 MFD"); |
| 648 | MODULE_AUTHOR("Misael Lopez Cruz <misael.lopez@ti.com>"); | 670 | MODULE_AUTHOR("Misael Lopez Cruz <misael.lopez@ti.com>"); |
diff --git a/include/linux/i2c/twl.h b/include/linux/i2c/twl.h index 2463b6100333..1f90de0cfdbe 100644 --- a/include/linux/i2c/twl.h +++ b/include/linux/i2c/twl.h | |||
| @@ -666,23 +666,11 @@ struct twl4030_codec_data { | |||
| 666 | unsigned int check_defaults:1; | 666 | unsigned int check_defaults:1; |
| 667 | unsigned int reset_registers:1; | 667 | unsigned int reset_registers:1; |
| 668 | unsigned int hs_extmute:1; | 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 | void (*set_hs_extmute)(int mute); | 669 | void (*set_hs_extmute)(int mute); |
| 674 | }; | 670 | }; |
| 675 | 671 | ||
| 676 | struct twl4030_vibra_data { | 672 | struct twl4030_vibra_data { |
| 677 | unsigned int coexist; | 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 | struct twl4030_audio_data { | 676 | struct twl4030_audio_data { |
diff --git a/include/linux/mfd/twl6040.h b/include/linux/mfd/twl6040.h index 9bc9ac651dad..b15b5f03f5c4 100644 --- a/include/linux/mfd/twl6040.h +++ b/include/linux/mfd/twl6040.h | |||
| @@ -174,8 +174,35 @@ | |||
| 174 | #define TWL6040_SYSCLK_SEL_LPPLL 0 | 174 | #define TWL6040_SYSCLK_SEL_LPPLL 0 |
| 175 | #define TWL6040_SYSCLK_SEL_HPPLL 1 | 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 | struct twl6040 { | 203 | struct twl6040 { |
| 178 | struct device *dev; | 204 | struct device *dev; |
| 205 | struct regmap *regmap; | ||
| 179 | struct mutex mutex; | 206 | struct mutex mutex; |
| 180 | struct mutex io_mutex; | 207 | struct mutex io_mutex; |
| 181 | struct mutex irq_mutex; | 208 | struct mutex irq_mutex; |
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index 6508e8b790bb..59d8efaa17e9 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig | |||
| @@ -57,7 +57,7 @@ config SND_SOC_ALL_CODECS | |||
| 57 | select SND_SOC_TPA6130A2 if I2C | 57 | select SND_SOC_TPA6130A2 if I2C |
| 58 | select SND_SOC_TLV320DAC33 if I2C | 58 | select SND_SOC_TLV320DAC33 if I2C |
| 59 | select SND_SOC_TWL4030 if TWL4030_CORE | 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 | select SND_SOC_UDA134X | 61 | select SND_SOC_UDA134X |
| 62 | select SND_SOC_UDA1380 if I2C | 62 | select SND_SOC_UDA1380 if I2C |
| 63 | select SND_SOC_WL1273 if MFD_WL1273_CORE | 63 | select SND_SOC_WL1273 if MFD_WL1273_CORE |
| @@ -276,7 +276,6 @@ config SND_SOC_TWL4030 | |||
| 276 | tristate | 276 | tristate |
| 277 | 277 | ||
| 278 | config SND_SOC_TWL6040 | 278 | config SND_SOC_TWL6040 |
| 279 | select TWL6040_CORE | ||
| 280 | tristate | 279 | tristate |
| 281 | 280 | ||
| 282 | config SND_SOC_UDA134X | 281 | config SND_SOC_UDA134X |
diff --git a/sound/soc/codecs/twl6040.c b/sound/soc/codecs/twl6040.c index 2d8c6b825e57..dc7509b9d53a 100644 --- a/sound/soc/codecs/twl6040.c +++ b/sound/soc/codecs/twl6040.c | |||
| @@ -26,7 +26,6 @@ | |||
| 26 | #include <linux/pm.h> | 26 | #include <linux/pm.h> |
| 27 | #include <linux/platform_device.h> | 27 | #include <linux/platform_device.h> |
| 28 | #include <linux/slab.h> | 28 | #include <linux/slab.h> |
| 29 | #include <linux/i2c/twl.h> | ||
| 30 | #include <linux/mfd/twl6040.h> | 29 | #include <linux/mfd/twl6040.h> |
| 31 | 30 | ||
| 32 | #include <sound/core.h> | 31 | #include <sound/core.h> |
| @@ -1528,7 +1527,7 @@ static int twl6040_resume(struct snd_soc_codec *codec) | |||
| 1528 | static int twl6040_probe(struct snd_soc_codec *codec) | 1527 | static int twl6040_probe(struct snd_soc_codec *codec) |
| 1529 | { | 1528 | { |
| 1530 | struct twl6040_data *priv; | 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 | struct platform_device *pdev = container_of(codec->dev, | 1531 | struct platform_device *pdev = container_of(codec->dev, |
| 1533 | struct platform_device, dev); | 1532 | struct platform_device, dev); |
| 1534 | int ret = 0; | 1533 | int ret = 0; |
diff --git a/sound/soc/omap/Kconfig b/sound/soc/omap/Kconfig index e00dd0b1139c..deafbfaacdbf 100644 --- a/sound/soc/omap/Kconfig +++ b/sound/soc/omap/Kconfig | |||
| @@ -97,7 +97,7 @@ config SND_OMAP_SOC_SDP3430 | |||
| 97 | 97 | ||
| 98 | config SND_OMAP_SOC_OMAP_ABE_TWL6040 | 98 | config SND_OMAP_SOC_OMAP_ABE_TWL6040 |
| 99 | tristate "SoC Audio support for OMAP boards using ABE and twl6040 codec" | 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 | select SND_OMAP_SOC_DMIC | 101 | select SND_OMAP_SOC_DMIC |
| 102 | select SND_OMAP_SOC_MCPDM | 102 | select SND_OMAP_SOC_MCPDM |
| 103 | select SND_SOC_TWL6040 | 103 | select SND_SOC_TWL6040 |
