#include <plat/mcspi.h>
-- #define OMAP2_MCSPI1_BASE 0x48098000
-- #define OMAP2_MCSPI2_BASE 0x4809a000
-- #define OMAP2_MCSPI3_BASE 0x480b8000
-- #define OMAP2_MCSPI4_BASE 0x480ba000
--
-- #define OMAP4_MCSPI1_BASE 0x48098100
-- #define OMAP4_MCSPI2_BASE 0x4809a100
-- #define OMAP4_MCSPI3_BASE 0x480b8100
-- #define OMAP4_MCSPI4_BASE 0x480ba100
--
-- static struct omap2_mcspi_platform_config omap2_mcspi1_config = {
-- .num_cs = 4,
-- };
--
-- static struct resource omap2_mcspi1_resources[] = {
-- {
-- .start = OMAP2_MCSPI1_BASE,
-- .end = OMAP2_MCSPI1_BASE + 0xff,
-- .flags = IORESOURCE_MEM,
-- },
-- };
--
-- static struct platform_device omap2_mcspi1 = {
-- .name = "omap2_mcspi",
-- .id = 1,
-- .num_resources = ARRAY_SIZE(omap2_mcspi1_resources),
-- .resource = omap2_mcspi1_resources,
-- .dev = {
-- .platform_data = &omap2_mcspi1_config,
-- },
-- };
--
-- static struct omap2_mcspi_platform_config omap2_mcspi2_config = {
-- .num_cs = 2,
-- };
--
-- static struct resource omap2_mcspi2_resources[] = {
-- {
-- .start = OMAP2_MCSPI2_BASE,
-- .end = OMAP2_MCSPI2_BASE + 0xff,
-- .flags = IORESOURCE_MEM,
-- },
-- };
--
-- static struct platform_device omap2_mcspi2 = {
-- .name = "omap2_mcspi",
-- .id = 2,
-- .num_resources = ARRAY_SIZE(omap2_mcspi2_resources),
-- .resource = omap2_mcspi2_resources,
-- .dev = {
-- .platform_data = &omap2_mcspi2_config,
-- },
-- };
--
-- #if defined(CONFIG_SOC_OMAP2430) || defined(CONFIG_ARCH_OMAP3) || \
-- defined(CONFIG_ARCH_OMAP4)
-- static struct omap2_mcspi_platform_config omap2_mcspi3_config = {
-- .num_cs = 2,
-- };
--
-- static struct resource omap2_mcspi3_resources[] = {
-- {
-- .start = OMAP2_MCSPI3_BASE,
-- .end = OMAP2_MCSPI3_BASE + 0xff,
-- .flags = IORESOURCE_MEM,
- },
- };
-
- static struct platform_device omap2_mcspi3 = {
- .name = "omap2_mcspi",
- .id = 3,
- .num_resources = ARRAY_SIZE(omap2_mcspi3_resources),
- .resource = omap2_mcspi3_resources,
- .dev = {
- .platform_data = &omap2_mcspi3_config,
- },
- };
- #endif
-
- #if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4)
- static struct omap2_mcspi_platform_config omap2_mcspi4_config = {
- .num_cs = 1,
- };
-
- static struct resource omap2_mcspi4_resources[] = {
- {
- .start = OMAP2_MCSPI4_BASE,
- .end = OMAP2_MCSPI4_BASE + 0xff,
- .flags = IORESOURCE_MEM,
- },
- };
-
- static struct platform_device omap2_mcspi4 = {
- .name = "omap2_mcspi",
- .id = 4,
- .num_resources = ARRAY_SIZE(omap2_mcspi4_resources),
- .resource = omap2_mcspi4_resources,
- .dev = {
- .platform_data = &omap2_mcspi4_config,
++ struct omap_device_pm_latency omap_mcspi_latency[] = {
++ [0] = {
++ .deactivate_func = omap_device_idle_hwmods,
++ .activate_func = omap_device_enable_hwmods,
++ .flags = OMAP_DEVICE_LATENCY_AUTO_ADJUST,
},
};
- #endif
- static struct platform_device omap2_mcspi3 = {
- .name = "omap2_mcspi",
- .id = 3,
- .num_resources = ARRAY_SIZE(omap2_mcspi3_resources),
- .resource = omap2_mcspi3_resources,
- .dev = {
- .platform_data = &omap2_mcspi3_config,
- },
- };
- #endif
-
- #if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4)
- static struct omap2_mcspi_platform_config omap2_mcspi4_config = {
- .num_cs = 1,
- };
-
- static struct resource omap2_mcspi4_resources[] = {
- {
- .start = OMAP2_MCSPI4_BASE,
- .end = OMAP2_MCSPI4_BASE + 0xff,
- .flags = IORESOURCE_MEM,
- },
- };
-
- static struct platform_device omap2_mcspi4 = {
- .name = "omap2_mcspi",
- .id = 4,
- .num_resources = ARRAY_SIZE(omap2_mcspi4_resources),
- .resource = omap2_mcspi4_resources,
- .dev = {
- .platform_data = &omap2_mcspi4_config,
- },
- };
- #endif
-
-- #ifdef CONFIG_ARCH_OMAP4
-- static inline void omap4_mcspi_fixup(void)
-- {
-- omap2_mcspi1_resources[0].start = OMAP4_MCSPI1_BASE;
-- omap2_mcspi1_resources[0].end = OMAP4_MCSPI1_BASE + 0xff;
-- omap2_mcspi2_resources[0].start = OMAP4_MCSPI2_BASE;
-- omap2_mcspi2_resources[0].end = OMAP4_MCSPI2_BASE + 0xff;
-- omap2_mcspi3_resources[0].start = OMAP4_MCSPI3_BASE;
-- omap2_mcspi3_resources[0].end = OMAP4_MCSPI3_BASE + 0xff;
-- omap2_mcspi4_resources[0].start = OMAP4_MCSPI4_BASE;
-- omap2_mcspi4_resources[0].end = OMAP4_MCSPI4_BASE + 0xff;
-- }
-- #else
-- static inline void omap4_mcspi_fixup(void)
++ static int omap_mcspi_init(struct omap_hwmod *oh, void *unused)
{
-- }
-- #endif
++ struct omap_device *od;
++ char *name = "omap2_mcspi";
++ struct omap2_mcspi_platform_config *pdata;
++ static int spi_num;
++ struct omap2_mcspi_dev_attr *mcspi_attrib = oh->dev_attr;
++
++ pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
++ if (!pdata) {
++ pr_err("Memory allocation for McSPI device failed\n");
++ return -ENOMEM;
++ }
-- #if defined(CONFIG_SOC_OMAP2430) || defined(CONFIG_ARCH_OMAP3) || \
-- defined(CONFIG_ARCH_OMAP4)
-- static inline void omap2_mcspi3_init(void)
-- {
-- platform_device_register(&omap2_mcspi3);
-- }
-- #else
-- static inline void omap2_mcspi3_init(void)
-- {
-- }
-- #endif
++ pdata->num_cs = mcspi_attrib->num_chipselect;
++ switch (oh->class->rev) {
++ case OMAP2_MCSPI_REV:
++ case OMAP3_MCSPI_REV:
++ pdata->regs_offset = 0;
++ break;
++ case OMAP4_MCSPI_REV:
++ pdata->regs_offset = OMAP4_MCSPI_REG_OFFSET;
++ break;
++ default:
++ pr_err("Invalid McSPI Revision value\n");
++ return -EINVAL;
++ }
-- #if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4)
-- static inline void omap2_mcspi4_init(void)
-- {
-- platform_device_register(&omap2_mcspi4);
-- }
-- #else
-- static inline void omap2_mcspi4_init(void)
-- {
++ spi_num++;
++ od = omap_device_build(name, spi_num, oh, pdata,
++ sizeof(*pdata), omap_mcspi_latency,
++ ARRAY_SIZE(omap_mcspi_latency), 0);
++ WARN(IS_ERR(od), "Cant build omap_device for %s:%s\n",
++ name, oh->name);
++ kfree(pdata);
++ return 0;
}
-- #endif
static void omap_init_mcspi(void)
{