arm/mx2: define seperate imx_nand devices for imx21 and imx27
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Fri, 5 Feb 2010 15:57:59 +0000 (16:57 +0100)
committerUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Mon, 15 Feb 2010 16:03:55 +0000 (17:03 +0100)
As the NFC controller has different addresses on imx21 and imx27 there
are two different devices needed if not relying on the overloaded cpp
macro NFC_BASE_ADDR.  So some cpp magic is added to minimize code
duplication.

As obviously these two defines need different names, the name of the old
device is #defined to the new one when building for only one of imx21 or
imx27.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
arch/arm/mach-mx2/devices.c
arch/arm/mach-mx2/devices.h

index 9bf49da530728cd0af1caceb9c100d9fe55f4b5b..cda4aced7a39c867566b5a26d54c035c8ad3b59e 100644 (file)
@@ -144,24 +144,33 @@ struct platform_device mxc_w1_master_device = {
        .resource = mxc_w1_master_resources,
 };
 
-static struct resource mxc_nand_resources[] = {
-       {
-               .start = NFC_BASE_ADDR,
-               .end = NFC_BASE_ADDR + SZ_4K - 1,
-               .flags = IORESOURCE_MEM,
-       }, {
-               .start = MX2x_INT_NANDFC,
-               .end = MX2x_INT_NANDFC,
-               .flags = IORESOURCE_IRQ,
-       },
-};
+#define DEFINE_MXC_NAND_DEVICE(pfx, baseaddr, irq)                     \
+       static struct resource pfx ## _nand_resources[] = {             \
+               {                                                       \
+                       .start = baseaddr,                              \
+                       .end = baseaddr + SZ_4K - 1,                    \
+                       .flags = IORESOURCE_MEM,                        \
+               }, {                                                    \
+                       .start = irq,                                   \
+                       .end = irq,                                     \
+                       .flags = IORESOURCE_IRQ,                        \
+               },                                                      \
+       };                                                              \
+                                                                       \
+       struct platform_device pfx ## _nand_device = {                  \
+               .name = "mxc_nand",                                     \
+               .id = 0,                                                \
+               .num_resources = ARRAY_SIZE(pfx ## _nand_resources),    \
+               .resource = pfx ## _nand_resources,                     \
+       }
 
-struct platform_device mxc_nand_device = {
-       .name = "mxc_nand",
-       .id = 0,
-       .num_resources = ARRAY_SIZE(mxc_nand_resources),
-       .resource = mxc_nand_resources,
-};
+#ifdef CONFIG_MACH_MX21
+DEFINE_MXC_NAND_DEVICE(imx21, MX21_NFC_BASE_ADDR, MX21_INT_NANDFC);
+#endif
+
+#ifdef CONFIG_MACH_MX27
+DEFINE_MXC_NAND_DEVICE(imx27, MX27_NFC_BASE_ADDR, MX27_INT_NANDFC);
+#endif
 
 /*
  * lcdc:
index 0dee0f5e681c4690559f05c96e9442bb5c42e18a..02e5dd203095b50ba3f0a237aac2d60a891b6452 100644 (file)
@@ -13,7 +13,16 @@ extern struct platform_device mxc_uart_device3;
 extern struct platform_device mxc_uart_device4;
 extern struct platform_device mxc_uart_device5;
 extern struct platform_device mxc_w1_master_device;
-extern struct platform_device mxc_nand_device;
+#ifdef CONFIG_MACH_MX21
+extern struct platform_device imx21_nand_device;
+#define mxc_nand_device imx21_nand_device
+#endif
+#ifdef CONFIG_MACH_MX27
+extern struct platform_device imx27_nand_device;
+#ifndef CONFIG_MACH_MX21
+#define mxc_nand_device imx27_nand_device
+#endif
+#endif
 extern struct platform_device mxc_fb_device;
 extern struct platform_device mxc_fec_device;
 extern struct platform_device mxc_pwm_device;