ARM: ux500: Register the AB8500 from DB8500 MFD
authorLee Jones <lee.jones@linaro.org>
Fri, 6 Jul 2012 10:46:23 +0000 (12:46 +0200)
committerSamuel Ortiz <sameo@linux.intel.com>
Sun, 8 Jul 2012 22:16:14 +0000 (00:16 +0200)
As the AB8500 is a subordinate MFD device to the DB8500-PRCMU,
for consistency and a better 1:1 depiction of how the hardware
is laid out, it is a good idea to register it in the same way
as we do for the other MFD child devices. In order for us to do
this successfully we have to pass AB8500's platform data when
registering the DB8500-PRCMU from platform code.

Also solves this issue:
WARNING: at fs/sysfs/dir.c:526 sysfs_add_one+0x88/0xb0()
sysfs: cannot create duplicate filename '/bus/platform/devices/ab8500-core.0'

Reported-by: Linus Walleij <linus.walleij@linaro.org>
Suggested-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
arch/arm/mach-ux500/board-mop500.c
arch/arm/mach-ux500/cpu-db8500.c
arch/arm/mach-ux500/include/mach/setup.h
drivers/mfd/db8500-prcmu.c

index 6224400a9d47c658a5e062169bcf49a6380ed36b..833903e428a8a8d424cacb2dc004a7ec74cb1126 100644 (file)
@@ -197,24 +197,6 @@ static struct ab8500_platform_data ab8500_platdata = {
        .gpio           = &ab8500_gpio_pdata,
 };
 
-static struct resource ab8500_resources[] = {
-       [0] = {
-               .start  = IRQ_DB8500_AB8500,
-               .end    = IRQ_DB8500_AB8500,
-               .flags  = IORESOURCE_IRQ
-       }
-};
-
-struct platform_device ab8500_device = {
-       .name = "ab8500-core",
-       .id = 0,
-       .dev = {
-               .platform_data = &ab8500_platdata,
-       },
-       .num_resources = 1,
-       .resource = ab8500_resources,
-};
-
 /*
  * TPS61052
  */
@@ -460,7 +442,6 @@ static struct hash_platform_data u8500_hash1_platform_data = {
 /* add any platform devices here - TODO */
 static struct platform_device *mop500_platform_devs[] __initdata = {
        &mop500_gpio_keys_device,
-       &ab8500_device,
 };
 
 #ifdef CONFIG_STE_DMA40
@@ -622,7 +603,6 @@ static struct platform_device *snowball_platform_devs[] __initdata = {
        &snowball_led_dev,
        &snowball_key_dev,
        &snowball_sbnet_dev,
-       &ab8500_device,
 };
 
 static struct platform_device *snowball_of_platform_devs[] __initdata = {
@@ -639,9 +619,8 @@ static void __init mop500_init_machine(void)
        mop500_gpio_keys[0].gpio = GPIO_PROX_SENSOR;
 
        mop500_pinmaps_init();
-       parent = u8500_init_devices();
+       parent = u8500_init_devices(&ab8500_platdata);
 
-       /* FIXME: parent of ab8500 should be prcmu */
        for (i = 0; i < ARRAY_SIZE(mop500_platform_devs); i++)
                mop500_platform_devs[i]->dev.parent = parent;
 
@@ -674,7 +653,7 @@ static void __init snowball_init_machine(void)
        int i;
 
        snowball_pinmaps_init();
-       parent = u8500_init_devices();
+       parent = u8500_init_devices(&ab8500_platdata);
 
        for (i = 0; i < ARRAY_SIZE(snowball_platform_devs); i++)
                snowball_platform_devs[i]->dev.parent = parent;
@@ -706,7 +685,7 @@ static void __init hrefv60_init_machine(void)
        mop500_gpio_keys[0].gpio = HREFV60_PROX_SENSE_GPIO;
 
        hrefv60_pinmaps_init();
-       parent = u8500_init_devices();
+       parent = u8500_init_devices(&ab8500_platdata);
 
        for (i = 0; i < ARRAY_SIZE(mop500_platform_devs); i++)
                mop500_platform_devs[i]->dev.parent = parent;
index 33275eb4c6890ab7745bbf0d2b2601ecca5e413f..1fcdc2da33ba8ae6d21573e271cf1e4af1daf5cf 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/irq.h>
 #include <linux/platform_device.h>
 #include <linux/io.h>
+#include <linux/mfd/abx500/ab8500.h>
 
 #include <asm/mach/map.h>
 #include <asm/pmu.h>
@@ -115,7 +116,7 @@ static irqreturn_t db8500_pmu_handler(int irq, void *dev, irq_handler_t handler)
        return ret;
 }
 
-static struct arm_pmu_platdata db8500_pmu_platdata = {
+struct arm_pmu_platdata db8500_pmu_platdata = {
        .handle_irq             = db8500_pmu_handler,
 };
 
@@ -207,7 +208,7 @@ static struct device * __init db8500_soc_device_init(void)
 /*
  * This function is called from the board init
  */
-struct device * __init u8500_init_devices(void)
+struct device * __init u8500_init_devices(struct ab8500_platform_data *ab8500)
 {
        struct device *parent;
        int i;
@@ -224,6 +225,8 @@ struct device * __init u8500_init_devices(void)
        for (i = 0; i < ARRAY_SIZE(platform_devs); i++)
                platform_devs[i]->dev.parent = parent;
 
+       db8500_prcmu_device.dev.platform_data = ab8500;
+
        platform_add_devices(platform_devs, ARRAY_SIZE(platform_devs));
 
        return parent;
index 8b7ed82a286665961f04d548a0ab1137027fc7d8..7914e5eaa9c775a913d494adc05f8094103a5dee 100644 (file)
 
 #include <asm/mach/time.h>
 #include <linux/init.h>
+#include <linux/mfd/abx500/ab8500.h>
 
 void __init ux500_map_io(void);
 extern void __init u8500_map_io(void);
 
-extern struct device * __init u8500_init_devices(void);
+extern struct device * __init u8500_init_devices(struct ab8500_platform_data *ab8500);
 
 extern void __init ux500_init_irq(void);
 extern void __init ux500_init_late(void);
index f4adcabb2a51262c3c1d26807dde0576ad9f2172..4050a1e1872b9d146bcf82c3d525ebfb50c2bb15 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/uaccess.h>
 #include <linux/mfd/core.h>
 #include <linux/mfd/dbx500-prcmu.h>
+#include <linux/mfd/abx500/ab8500.h>
 #include <linux/regulator/db8500-prcmu.h>
 #include <linux/regulator/machine.h>
 #include <asm/hardware/gic.h>
@@ -2972,8 +2973,9 @@ static struct mfd_cell db8500_prcmu_devs[] = {
  */
 static int __devinit db8500_prcmu_probe(struct platform_device *pdev)
 {
+       struct ab8500_platform_data *ab8500_platdata = pdev->dev.platform_data;
        struct device_node *np = pdev->dev.of_node;
-       int irq = 0, err = 0;
+       int irq = 0, err = 0, i;
 
        if (ux500_is_svp())
                return -ENODEV;
@@ -2997,6 +2999,12 @@ static int __devinit db8500_prcmu_probe(struct platform_device *pdev)
                goto no_irq_return;
        }
 
+       for (i = 0; i < ARRAY_SIZE(db8500_prcmu_devs); i++) {
+               if (!strcmp(db8500_prcmu_devs[i].name, "ab8500-core")) {
+                       db8500_prcmu_devs[i].platform_data = ab8500_platdata;
+               }
+       }
+
        if (cpu_is_u8500v20_or_later())
                prcmu_config_esram0_deep_sleep(ESRAM0_DEEP_SLEEP_STATE_RET);