Commit 07dae18e authored by David Brownell's avatar David Brownell Committed by Tony Lindgren

minor twl4030-core cleanups

Minor twl4030-core cleanups:  alphabetize the creation of the
new sub-function nodes; wrap an #if around the OMAP-only part
(to get more general build testing when this goes upstream);
remove reference to undocumented "twl3040" variant.
Signed-off-by: default avatarDavid Brownell <dbrownell@users.sourceforge.net>

Moved gpio before keypad driver due to alphabetic order.
Signed-off-by: default avatarFelipe Balbi <felipe.balbi@nokia.com>
Signed-off-by: default avatarTony Lindgren <tony@atomide.com>
parent 8c1f422c
...@@ -45,24 +45,12 @@ ...@@ -45,24 +45,12 @@
#define DRIVER_NAME "twl4030" #define DRIVER_NAME "twl4030"
#if defined(CONFIG_RTC_DRV_TWL4030) || defined(CONFIG_RTC_DRV_TWL4030_MODULE)
#define twl_has_rtc() true
#else
#define twl_has_rtc() false
#endif
#if defined(CONFIG_KEYBOARD_TWL4030) || defined(CONFIG_KEYBOARD_TWL4030_MODULE) #if defined(CONFIG_KEYBOARD_TWL4030) || defined(CONFIG_KEYBOARD_TWL4030_MODULE)
#define twl_has_keypad() true #define twl_has_keypad() true
#else #else
#define twl_has_keypad() false #define twl_has_keypad() false
#endif #endif
#if defined(CONFIG_TWL4030_USB) || defined(CONFIG_TWL4030_USB_MODULE)
#define twl_has_usb() true
#else
#define twl_has_usb() false
#endif
#ifdef CONFIG_TWL4030_GPIO #ifdef CONFIG_TWL4030_GPIO
#define twl_has_gpio() true #define twl_has_gpio() true
#else #else
...@@ -75,6 +63,18 @@ ...@@ -75,6 +63,18 @@
#define twl_has_madc() false #define twl_has_madc() false
#endif #endif
#if defined(CONFIG_RTC_DRV_TWL4030) || defined(CONFIG_RTC_DRV_TWL4030_MODULE)
#define twl_has_rtc() true
#else
#define twl_has_rtc() false
#endif
#if defined(CONFIG_TWL4030_USB) || defined(CONFIG_TWL4030_USB_MODULE)
#define twl_has_usb() true
#else
#define twl_has_usb() false
#endif
/* Primary Interrupt Handler on TWL4030 Registers */ /* Primary Interrupt Handler on TWL4030 Registers */
/* Register Definitions */ /* Register Definitions */
...@@ -706,27 +706,18 @@ static int add_children(struct twl4030_platform_data *pdata) ...@@ -706,27 +706,18 @@ static int add_children(struct twl4030_platform_data *pdata)
} }
} }
if (twl_has_rtc()) { if (twl_has_keypad() && pdata->keypad) {
pdev = platform_device_alloc("twl4030_rtc", -1); pdev = platform_device_alloc("twl4030_keypad", -1);
if (pdev) { if (pdev) {
twl = &twl4030_modules[TWL4030_SLAVENUM_NUM3]; twl = &twl4030_modules[TWL4030_SLAVENUM_NUM2];
pdev->dev.parent = &twl->client->dev; pdev->dev.parent = &twl->client->dev;
device_init_wakeup(&pdev->dev, 1); device_init_wakeup(&pdev->dev, 1);
status = platform_device_add_data(pdev, pdata->keypad,
/* sizeof(*pdata->keypad));
* FIXME add the relevant IRQ resource, and make the if (status < 0) {
* rtc driver use it instead of hard-wiring ... platform_device_put(pdev);
* goto err;
* REVISIT platform_data here currently only supports }
* setting up the "msecure" line ... which actually
* violates the "princple of least privilege", since
* it's effectively always in "high trust" mode.
*
* For now, expect equivalent treatment at board init:
* setting msecure high. Eventually, Linux might
* become more aware of those HW security concerns.
*/
status = platform_device_add(pdev); status = platform_device_add(pdev);
if (status < 0) if (status < 0)
platform_device_put(pdev); platform_device_put(pdev);
...@@ -736,14 +727,14 @@ static int add_children(struct twl4030_platform_data *pdata) ...@@ -736,14 +727,14 @@ static int add_children(struct twl4030_platform_data *pdata)
} }
} }
if (twl_has_keypad() && pdata->keypad) { if (twl_has_madc() && pdata->madc) {
pdev = platform_device_alloc("twl4030_keypad", -1); pdev = platform_device_alloc("twl4030_madc", -1);
if (pdev) { if (pdev) {
twl = &twl4030_modules[TWL4030_SLAVENUM_NUM2]; twl = &twl4030_modules[TWL4030_SLAVENUM_NUM2];
pdev->dev.parent = &twl->client->dev; pdev->dev.parent = &twl->client->dev;
device_init_wakeup(&pdev->dev, 1); device_init_wakeup(&pdev->dev, 1);
status = platform_device_add_data(pdev, pdata->keypad, status = platform_device_add_data(pdev, pdata->madc,
sizeof(*pdata->keypad)); sizeof(*pdata->madc));
if (status < 0) { if (status < 0) {
platform_device_put(pdev); platform_device_put(pdev);
goto err; goto err;
...@@ -757,18 +748,27 @@ static int add_children(struct twl4030_platform_data *pdata) ...@@ -757,18 +748,27 @@ static int add_children(struct twl4030_platform_data *pdata)
} }
} }
if (twl_has_usb() && pdata->usb) { if (twl_has_rtc()) {
pdev = platform_device_alloc("twl4030_usb", -1); pdev = platform_device_alloc("twl4030_rtc", -1);
if (pdev) { if (pdev) {
twl = &twl4030_modules[TWL4030_SLAVENUM_NUM0]; twl = &twl4030_modules[TWL4030_SLAVENUM_NUM3];
pdev->dev.parent = &twl->client->dev; pdev->dev.parent = &twl->client->dev;
device_init_wakeup(&pdev->dev, 1); device_init_wakeup(&pdev->dev, 1);
status = platform_device_add_data(pdev, pdata->usb,
sizeof(*pdata->usb)); /*
if (status < 0) { * FIXME add the relevant IRQ resource, and make the
platform_device_put(pdev); * rtc driver use it instead of hard-wiring ...
goto err; *
} * REVISIT platform_data here currently only supports
* setting up the "msecure" line ... which actually
* violates the "princple of least privilege", since
* it's effectively always in "high trust" mode.
*
* For now, expect equivalent treatment at board init:
* setting msecure high. Eventually, Linux might
* become more aware of those HW security concerns.
*/
status = platform_device_add(pdev); status = platform_device_add(pdev);
if (status < 0) if (status < 0)
platform_device_put(pdev); platform_device_put(pdev);
...@@ -778,14 +778,14 @@ static int add_children(struct twl4030_platform_data *pdata) ...@@ -778,14 +778,14 @@ static int add_children(struct twl4030_platform_data *pdata)
} }
} }
if (twl_has_madc() && pdata->madc) { if (twl_has_usb() && pdata->usb) {
pdev = platform_device_alloc("twl4030_madc", -1); pdev = platform_device_alloc("twl4030_usb", -1);
if (pdev) { if (pdev) {
twl = &twl4030_modules[TWL4030_SLAVENUM_NUM2]; twl = &twl4030_modules[TWL4030_SLAVENUM_NUM0];
pdev->dev.parent = &twl->client->dev; pdev->dev.parent = &twl->client->dev;
device_init_wakeup(&pdev->dev, 1); device_init_wakeup(&pdev->dev, 1);
status = platform_device_add_data(pdev, pdata->madc, status = platform_device_add_data(pdev, pdata->usb,
sizeof(*pdata->madc)); sizeof(*pdata->usb));
if (status < 0) { if (status < 0) {
platform_device_put(pdev); platform_device_put(pdev);
goto err; goto err;
...@@ -844,17 +844,19 @@ static int __init unprotect_pm_master(void) ...@@ -844,17 +844,19 @@ static int __init unprotect_pm_master(void)
static int __init power_companion_init(void) static int __init power_companion_init(void)
{ {
int e = 0;
#if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3)
struct clk *osc; struct clk *osc;
u32 rate; u32 rate;
u8 ctrl = HFCLK_FREQ_26_MHZ; u8 ctrl = HFCLK_FREQ_26_MHZ;
int e = 0;
if (cpu_is_omap2430()) if (cpu_is_omap2430())
osc = clk_get(NULL, "osc_ck"); osc = clk_get(NULL, "osc_ck");
else else
osc = clk_get(NULL, "osc_sys_ck"); osc = clk_get(NULL, "osc_sys_ck");
if (IS_ERR(osc)) { if (IS_ERR(osc)) {
printk(KERN_WARNING "Skipping twl3040 internal clock init and " printk(KERN_WARNING "Skipping twl4030 internal clock init and "
"using bootloader value (unknown osc rate)\n"); "using bootloader value (unknown osc rate)\n");
return 0; return 0;
} }
...@@ -879,6 +881,7 @@ static int __init power_companion_init(void) ...@@ -879,6 +881,7 @@ static int __init power_companion_init(void)
/* effect->MADC+USB ck en */ /* effect->MADC+USB ck en */
e |= twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, ctrl, R_CFG_BOOT); e |= twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, ctrl, R_CFG_BOOT);
e |= protect_pm_master(); e |= protect_pm_master();
#endif /* OMAP */
return e; return e;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment