Skip to content

Commit 8eaeb93

Browse files
Peter UjfalusiSamuel Ortiz
authored andcommitted
mfd: Convert twl6040 to i2c driver, and separate it from twl core
Complete the separation of the twl6040 from the twl core since it is a separate chip, not part of the twl6030 PMIC. Make the needed Kconfig changes for the depending drivers at the same time to avoid breaking the kernel build (vibra, ASoC components). Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Reviewed-by: Mark Brown <broonie@opensource.wolfsonicro.com> Acked-by: Tony Lindgren <tony@atomide.com> Acked-by: Dmitry Torokhov <dtor@mail.ru> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
1 parent 4accdff commit 8eaeb93

14 files changed

Lines changed: 159 additions & 94 deletions

File tree

‎arch/arm/mach-omap2/board-4430sdp.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <linux/usb/otg.h>
2121
#include <linux/spi/spi.h>
2222
#include <linux/i2c/twl.h>
23+
#include <linux/mfd/twl6040.h>
2324
#include <linux/gpio_keys.h>
2425
#include <linux/regulator/machine.h>
2526
#include <linux/regulator/fixed.h>
@@ -560,15 +561,15 @@ static struct regulator_init_data sdp4430_vusim = {
560561
},
561562
};
562563

563-
static struct twl4030_codec_data twl6040_codec = {
564+
static struct twl6040_codec_data twl6040_codec = {
564565
/* single-step ramp for headset and handsfree */
565566
.hs_left_step = 0x0f,
566567
.hs_right_step = 0x0f,
567568
.hf_left_step = 0x1d,
568569
.hf_right_step = 0x1d,
569570
};
570571

571-
static struct twl4030_vibra_data twl6040_vibra = {
572+
static struct twl6040_vibra_data twl6040_vibra = {
572573
.vibldrv_res = 8,
573574
.vibrdrv_res = 3,
574575
.viblmotor_res = 10,
@@ -577,16 +578,14 @@ static struct twl4030_vibra_data twl6040_vibra = {
577578
.vddvibr_uV = 0, /* fixed volt supply - VBAT */
578579
};
579580

580-
static struct twl4030_audio_data twl6040_audio = {
581+
static struct twl6040_platform_data twl6040_data = {
581582
.codec = &twl6040_codec,
582583
.vibra = &twl6040_vibra,
583584
.audpwron_gpio = 127,
584-
.naudint_irq = OMAP44XX_IRQ_SYS_2N,
585585
.irq_base = TWL6040_CODEC_IRQ_BASE,
586586
};
587587

588588
static struct twl4030_platform_data sdp4430_twldata = {
589-
.audio = &twl6040_audio,
590589
/* Regulators */
591590
.vusim = &sdp4430_vusim,
592591
.vaux1 = &sdp4430_vaux1,
@@ -617,7 +616,8 @@ static int __init omap4_i2c_init(void)
617616
TWL_COMMON_REGULATOR_VCXIO |
618617
TWL_COMMON_REGULATOR_VUSB |
619618
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);
621621
omap_register_i2c_bus(2, 400, NULL, 0);
622622
omap_register_i2c_bus(3, 400, sdp4430_i2c_3_boardinfo,
623623
ARRAY_SIZE(sdp4430_i2c_3_boardinfo));

‎arch/arm/mach-omap2/board-generic.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ static struct twl4030_platform_data sdp4430_twldata = {
137137

138138
static void __init omap4_i2c_init(void)
139139
{
140-
omap4_pmic_init("twl6030", &sdp4430_twldata);
140+
omap4_pmic_init("twl6030", &sdp4430_twldata, NULL, 0);
141141
}
142142

143143
static void __init omap4_init(void)

‎arch/arm/mach-omap2/board-omap4panda.c‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <linux/gpio.h>
2626
#include <linux/usb/otg.h>
2727
#include <linux/i2c/twl.h>
28+
#include <linux/mfd/twl6040.h>
2829
#include <linux/regulator/machine.h>
2930
#include <linux/regulator/fixed.h>
3031
#include <linux/wl12xx.h>
@@ -284,25 +285,22 @@ static int __init omap4_twl6030_hsmmc_init(struct omap2_hsmmc_info *controllers)
284285
return 0;
285286
}
286287

287-
static struct twl4030_codec_data twl6040_codec = {
288+
static struct twl6040_codec_data twl6040_codec = {
288289
/* single-step ramp for headset and handsfree */
289290
.hs_left_step = 0x0f,
290291
.hs_right_step = 0x0f,
291292
.hf_left_step = 0x1d,
292293
.hf_right_step = 0x1d,
293294
};
294295

295-
static struct twl4030_audio_data twl6040_audio = {
296+
static struct twl6040_platform_data twl6040_data = {
296297
.codec = &twl6040_codec,
297298
.audpwron_gpio = 127,
298-
.naudint_irq = OMAP44XX_IRQ_SYS_2N,
299299
.irq_base = TWL6040_CODEC_IRQ_BASE,
300300
};
301301

302302
/* 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;
306304

307305
/*
308306
* 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)
326324
TWL_COMMON_REGULATOR_VCXIO |
327325
TWL_COMMON_REGULATOR_VUSB |
328326
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);
330329
omap_register_i2c_bus(2, 400, NULL, 0);
331330
/*
332331
* Bus 3 is attached to the DVI port where devices like the pico DLP

‎arch/arm/mach-omap2/twl-common.c‎

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,16 @@ static struct i2c_board_info __initdata pmic_i2c_board_info = {
3737
.flags = I2C_CLIENT_WAKE,
3838
};
3939

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+
4050
void __init omap_pmic_init(int bus, u32 clkrate,
4151
const char *pmic_type, int pmic_irq,
4252
struct twl4030_platform_data *pmic_data)
@@ -49,14 +59,31 @@ void __init omap_pmic_init(int bus, u32 clkrate,
4959
omap_register_i2c_bus(bus, clkrate, &pmic_i2c_board_info, 1);
5060
}
5161

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+
5280
void __init omap_pmic_late_init(void)
5381
{
5482
/* 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();
6087
}
6188

6289
#if defined(CONFIG_ARCH_OMAP3)

‎arch/arm/mach-omap2/twl-common.h‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030

3131
struct twl4030_platform_data;
32+
struct twl6040_platform_data;
3233

3334
void omap_pmic_init(int bus, u32 clkrate, const char *pmic_type, int pmic_irq,
3435
struct twl4030_platform_data *pmic_data);
@@ -46,12 +47,9 @@ static inline void omap3_pmic_init(const char *pmic_type,
4647
omap_pmic_init(1, 2600, pmic_type, INT_34XX_SYS_NIRQ, pmic_data);
4748
}
4849

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);
5553

5654
void omap3_pmic_get_config(struct twl4030_platform_data *pmic_data,
5755
u32 pdata_flags, u32 regulators_flags);

‎drivers/input/misc/Kconfig‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,8 +380,7 @@ config INPUT_TWL4030_VIBRA
380380

381381
config INPUT_TWL6040_VIBRA
382382
tristate "Support for TWL6040 Vibrator"
383-
depends on TWL4030_CORE
384-
select TWL6040_CORE
383+
depends on TWL6040_CORE
385384
select INPUT_FF_MEMLESS
386385
help
387386
This option enables support for TWL6040 Vibrator Driver.

‎drivers/input/misc/twl6040-vibra.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#include <linux/module.h>
2929
#include <linux/platform_device.h>
3030
#include <linux/workqueue.h>
31-
#include <linux/i2c/twl.h>
31+
#include <linux/input.h>
3232
#include <linux/mfd/twl6040.h>
3333
#include <linux/slab.h>
3434
#include <linux/delay.h>
@@ -257,7 +257,7 @@ static SIMPLE_DEV_PM_OPS(twl6040_vibra_pm_ops, twl6040_vibra_suspend, NULL);
257257

258258
static int __devinit twl6040_vibra_probe(struct platform_device *pdev)
259259
{
260-
struct twl4030_vibra_data *pdata = pdev->dev.platform_data;
260+
struct twl6040_vibra_data *pdata = pdev->dev.platform_data;
261261
struct vibra_info *info;
262262
int ret;
263263

‎drivers/mfd/Kconfig‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,10 +268,17 @@ config TWL6030_PWM
268268
This is used to control charging LED brightness.
269269

270270
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
273273
select MFD_CORE
274+
select REGMAP_I2C
274275
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).
275282

276283
config MFD_STMPE
277284
bool "Support STMicroelectronics STMPE"

0 commit comments

Comments
 (0)