Merge branch 'for-grant' of git://sources.calxeda.com/kernel/linux into devicetree...
[pandora-kernel.git] / arch / arm / mach-omap2 / devices.c
index 10adf66..68ec031 100644 (file)
@@ -8,7 +8,7 @@
  * the Free Software Foundation; either version 2 of the License, or
  * (at your option) any later version.
  */
-
+#include <linux/gpio.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/platform_device.h>
@@ -16,6 +16,7 @@
 #include <linux/clk.h>
 #include <linux/err.h>
 #include <linux/slab.h>
+#include <linux/of.h>
 
 #include <mach/hardware.h>
 #include <mach/irqs.h>
@@ -26,7 +27,6 @@
 #include <plat/tc.h>
 #include <plat/board.h>
 #include <plat/mcbsp.h>
-#include <mach/gpio.h>
 #include <plat/mmc.h>
 #include <plat/dma.h>
 #include <plat/omap_hwmod.h>
@@ -77,6 +77,10 @@ static int __init omap4_l3_init(void)
        struct platform_device *pdev;
        char oh_name[L3_MODULES_MAX_LEN];
 
+       /* If dtb is there, the devices will be created dynamically */
+       if (of_have_populated_dt())
+               return -ENODEV;
+
        /*
         * To avoid code running on other OMAPs in
         * multi-omap builds
@@ -221,14 +225,6 @@ static inline void omap_init_camera(void)
 #endif
 }
 
-struct omap_device_pm_latency omap_keyboard_latency[] = {
-       {
-               .deactivate_func = omap_device_idle_hwmods,
-               .activate_func   = omap_device_enable_hwmods,
-               .flags = OMAP_DEVICE_LATENCY_AUTO_ADJUST,
-       },
-};
-
 int __init omap4_keyboard_init(struct omap4_keypad_platform_data
                        *sdp4430_keypad_data, struct omap_board_data *bdata)
 {
@@ -248,9 +244,7 @@ int __init omap4_keyboard_init(struct omap4_keypad_platform_data
        keypad_data = sdp4430_keypad_data;
 
        pdev = omap_device_build(name, id, oh, keypad_data,
-                       sizeof(struct omap4_keypad_platform_data),
-                       omap_keyboard_latency,
-                       ARRAY_SIZE(omap_keyboard_latency), 0);
+                       sizeof(struct omap4_keypad_platform_data), NULL, 0, 0);
 
        if (IS_ERR(pdev)) {
                WARN(1, "Can't build omap_device for %s:%s.\n",
@@ -263,14 +257,6 @@ int __init omap4_keyboard_init(struct omap4_keypad_platform_data
 }
 
 #if defined(CONFIG_OMAP_MBOX_FWK) || defined(CONFIG_OMAP_MBOX_FWK_MODULE)
-static struct omap_device_pm_latency mbox_latencies[] = {
-       [0] = {
-               .activate_func = omap_device_enable_hwmods,
-               .deactivate_func = omap_device_idle_hwmods,
-               .flags = OMAP_DEVICE_LATENCY_AUTO_ADJUST,
-       },
-};
-
 static inline void omap_init_mbox(void)
 {
        struct omap_hwmod *oh;
@@ -282,8 +268,7 @@ static inline void omap_init_mbox(void)
                return;
        }
 
-       pdev = omap_device_build("omap-mailbox", -1, oh, NULL, 0,
-                               mbox_latencies, ARRAY_SIZE(mbox_latencies), 0);
+       pdev = omap_device_build("omap-mailbox", -1, oh, NULL, 0, NULL, 0, 0);
        WARN(IS_ERR(pdev), "%s: could not build device, err %ld\n",
                                                __func__, PTR_ERR(pdev));
 }
@@ -330,18 +315,42 @@ static void omap_init_audio(void)
 static inline void omap_init_audio(void) {}
 #endif
 
-#if defined(CONFIG_SPI_OMAP24XX) || defined(CONFIG_SPI_OMAP24XX_MODULE)
-
-#include <plat/mcspi.h>
+#if defined(CONFIG_SND_OMAP_SOC_MCPDM) || \
+               defined(CONFIG_SND_OMAP_SOC_MCPDM_MODULE)
 
-struct omap_device_pm_latency omap_mcspi_latency[] = {
-       [0] = {
+static struct omap_device_pm_latency omap_mcpdm_latency[] = {
+       {
                .deactivate_func = omap_device_idle_hwmods,
-               .activate_func   = omap_device_enable_hwmods,
-               .flags           = OMAP_DEVICE_LATENCY_AUTO_ADJUST,
+               .activate_func = omap_device_enable_hwmods,
+               .flags = OMAP_DEVICE_LATENCY_AUTO_ADJUST,
        },
 };
 
+static void omap_init_mcpdm(void)
+{
+       struct omap_hwmod *oh;
+       struct omap_device *od;
+
+       oh = omap_hwmod_lookup("mcpdm");
+       if (!oh) {
+               printk(KERN_ERR "Could not look up mcpdm hw_mod\n");
+               return;
+       }
+
+       od = omap_device_build("omap-mcpdm", -1, oh, NULL, 0,
+                               omap_mcpdm_latency,
+                               ARRAY_SIZE(omap_mcpdm_latency), 0);
+       if (IS_ERR(od))
+               printk(KERN_ERR "Could not build omap_device for omap-mcpdm-dai\n");
+}
+#else
+static inline void omap_init_mcpdm(void) {}
+#endif
+
+#if defined(CONFIG_SPI_OMAP24XX) || defined(CONFIG_SPI_OMAP24XX_MODULE)
+
+#include <plat/mcspi.h>
+
 static int omap_mcspi_init(struct omap_hwmod *oh, void *unused)
 {
        struct platform_device *pdev;
@@ -372,8 +381,7 @@ static int omap_mcspi_init(struct omap_hwmod *oh, void *unused)
 
        spi_num++;
        pdev = omap_device_build(name, spi_num, oh, pdata,
-                               sizeof(*pdata), omap_mcspi_latency,
-                               ARRAY_SIZE(omap_mcspi_latency), 0);
+                               sizeof(*pdata), NULL, 0, 0);
        WARN(IS_ERR(pdev), "Can't build omap_device for %s:%s\n",
                                name, oh->name);
        kfree(pdata);
@@ -683,6 +691,7 @@ static int __init omap2_init_devices(void)
         * in alphabetical order so they're easier to sort through.
         */
        omap_init_audio();
+       omap_init_mcpdm();
        omap_init_camera();
        omap_init_mbox();
        omap_init_mcspi();
@@ -698,14 +707,6 @@ static int __init omap2_init_devices(void)
 arch_initcall(omap2_init_devices);
 
 #if defined(CONFIG_OMAP_WATCHDOG) || defined(CONFIG_OMAP_WATCHDOG_MODULE)
-static struct omap_device_pm_latency omap_wdt_latency[] = {
-       [0] = {
-               .deactivate_func = omap_device_idle_hwmods,
-               .activate_func   = omap_device_enable_hwmods,
-               .flags           = OMAP_DEVICE_LATENCY_AUTO_ADJUST,
-       },
-};
-
 static int __init omap_init_wdt(void)
 {
        int id = -1;
@@ -723,9 +724,7 @@ static int __init omap_init_wdt(void)
                return -EINVAL;
        }
 
-       pdev = omap_device_build(dev_name, id, oh, NULL, 0,
-                               omap_wdt_latency,
-                               ARRAY_SIZE(omap_wdt_latency), 0);
+       pdev = omap_device_build(dev_name, id, oh, NULL, 0, NULL, 0, 0);
        WARN(IS_ERR(pdev), "Can't build omap_device for %s:%s.\n",
                                dev_name, oh->name);
        return 0;