ARM: imx: dynamically register imx-fb devices
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Thu, 4 Nov 2010 16:07:48 +0000 (17:07 +0100)
committerUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Wed, 17 Nov 2010 09:01:27 +0000 (10:01 +0100)
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
16 files changed:
arch/arm/mach-imx/Kconfig
arch/arm/mach-imx/devices-imx21.h
arch/arm/mach-imx/devices-imx27.h
arch/arm/mach-imx/devices.c
arch/arm/mach-imx/devices.h
arch/arm/mach-imx/eukrea_mbimx27-baseboard.c
arch/arm/mach-imx/mach-mx21ads.c
arch/arm/mach-imx/mach-mx27ads.c
arch/arm/mach-imx/mach-mxt_td60.c
arch/arm/mach-imx/mach-pca100.c
arch/arm/mach-imx/pcm970-baseboard.c
arch/arm/plat-mxc/devices/Kconfig
arch/arm/plat-mxc/devices/Makefile
arch/arm/plat-mxc/devices/platform-imx-fb.c [new file with mode: 0644]
arch/arm/plat-mxc/include/mach/devices-common.h
arch/arm/plat-mxc/include/mach/imxfb.h

index 6b1662c55a5d13ec43f4413fb16fa68c4b38753b..d3e983e575942691607bd091d5c289074f661071 100644 (file)
@@ -71,6 +71,7 @@ comment "MX21 platforms:"
 
 config MACH_MX21ADS
        bool "MX21ADS platform"
+       select IMX_HAVE_PLATFORM_IMX_FB
        select IMX_HAVE_PLATFORM_IMX_UART
        select IMX_HAVE_PLATFORM_MXC_NAND
        help
@@ -85,6 +86,7 @@ comment "MX27 platforms:"
 
 config MACH_MX27ADS
        bool "MX27ADS platform"
+       select IMX_HAVE_PLATFORM_IMX_FB
        select IMX_HAVE_PLATFORM_IMX_I2C
        select IMX_HAVE_PLATFORM_IMX_UART
        select IMX_HAVE_PLATFORM_MXC_NAND
@@ -112,8 +114,8 @@ choice
        default MACH_PCM970_BASEBOARD
 
 config MACH_PCM970_BASEBOARD
-       prompt "PHYTEC PCM970 development board"
-       bool
+       bool "PHYTEC PCM970 development board"
+       select IMX_HAVE_PLATFORM_IMX_FB
        help
          This adds board specific devices that can be found on Phytec's
          PCM970 evaluation board.
@@ -153,6 +155,7 @@ choice
 
 config MACH_EUKREA_MBIMX27_BASEBOARD
        bool "Eukrea MBIMX27 development board"
+       select IMX_HAVE_PLATFORM_IMX_FB
        select IMX_HAVE_PLATFORM_IMX_SSI
        select IMX_HAVE_PLATFORM_IMX_UART
        select IMX_HAVE_PLATFORM_SPI_IMX
@@ -188,6 +191,7 @@ config MACH_IMX27LITE
 config MACH_PCA100
        bool "Phytec phyCARD-s (pca100)"
        select IMX_HAVE_PLATFORM_IMX2_WDT
+       select IMX_HAVE_PLATFORM_IMX_FB
        select IMX_HAVE_PLATFORM_IMX_I2C
        select IMX_HAVE_PLATFORM_IMX_SSI
        select IMX_HAVE_PLATFORM_IMX_UART
@@ -201,6 +205,7 @@ config MACH_PCA100
 
 config MACH_MXT_TD60
        bool "Maxtrack i-MXT TD60"
+       select IMX_HAVE_PLATFORM_IMX_FB
        select IMX_HAVE_PLATFORM_IMX_I2C
        select IMX_HAVE_PLATFORM_IMX_UART
        select IMX_HAVE_PLATFORM_MXC_NAND
index 738dbba6032e94af7edaaccf81c98a2ae9e7cb5a..0f782b6fcf880c3d63ce0ad7de6ca22476fc76ff 100644 (file)
@@ -13,6 +13,10 @@ extern const struct imx_imx2_wdt_data imx21_imx2_wdt_data __initconst;
 #define imx21_add_imx2_wdt(pdata)      \
        imx_add_imx2_wdt(&imx21_imx2_wdt_data)
 
+extern const struct imx_imx_fb_data imx21_imx_fb_data __initconst;
+#define imx21_add_imx_fb(pdata)        \
+       imx_add_imx_fb(&imx21_imx_fb_data, pdata)
+
 extern const struct imx_imx_i2c_data imx21_imx_i2c_data __initconst;
 #define imx21_add_imx_i2c(pdata)       \
        imx_add_imx_i2c(&imx21_imx_i2c_data, pdata)
index b2d4c513635482abb9ca206e6bb80c594a4dd736..6e11bef297d0d9f83f7a3a32f90c59c30d11e89e 100644 (file)
@@ -17,6 +17,10 @@ extern const struct imx_imx2_wdt_data imx27_imx2_wdt_data __initconst;
 #define imx27_add_imx2_wdt(pdata)      \
        imx_add_imx2_wdt(&imx27_imx2_wdt_data)
 
+extern const struct imx_imx_fb_data imx27_imx_fb_data __initconst;
+#define imx27_add_imx_fb(pdata)        \
+       imx_add_imx_fb(&imx27_imx_fb_data, pdata)
+
 extern const struct imx_imx_i2c_data imx27_imx_i2c_data[] __initconst;
 #define imx27_add_imx_i2c(id, pdata)   \
        imx_add_imx_i2c(&imx27_imx_i2c_data[id], pdata)
index 20655fb10a57cf8ef1717cc621785d856dc62805..d78456411f3f7a6a9f8bb7c3f622beedbaeb9376 100644 (file)
@@ -77,35 +77,6 @@ int __init imx1_register_gpios(void)
 #endif
 
 #if defined(CONFIG_MACH_MX21) || defined(CONFIG_MACH_MX27)
-/*
- * lcdc:
- * - i.MX1: the basic controller
- * - i.MX21: to be checked
- * - i.MX27: like i.MX1, with slightly variations
- */
-static struct resource mxc_fb[] = {
-       {
-               .start = MX2x_LCDC_BASE_ADDR,
-               .end = MX2x_LCDC_BASE_ADDR + SZ_4K - 1,
-               .flags = IORESOURCE_MEM,
-       }, {
-               .start = MX2x_INT_LCDC,
-               .end = MX2x_INT_LCDC,
-               .flags = IORESOURCE_IRQ,
-       }
-};
-
-/* mxc lcd driver */
-struct platform_device mxc_fb_device = {
-       .name = "imx-fb",
-       .id = 0,
-       .num_resources = ARRAY_SIZE(mxc_fb),
-       .resource = mxc_fb,
-       .dev = {
-               .coherent_dma_mask = DMA_BIT_MASK(32),
-       },
-};
-
 static struct resource mxc_pwm_resources[] = {
        {
                .start = MX2x_PWM_BASE_ADDR,
index f441b0256b934fc9ed48d7f0573befd43cf933c8..407e90aa0bc4085c82d7e53f123d35e55e6f91f8 100644 (file)
@@ -1,5 +1,4 @@
 #if defined(CONFIG_MACH_MX21) || defined(CONFIG_MACH_MX27)
-extern struct platform_device mxc_fb_device;
 extern struct platform_device mxc_pwm_device;
 extern struct platform_device mxc_sdhc_device0;
 extern struct platform_device mxc_sdhc_device1;
index 026263c665cae060cfca17ca86ad2fb36c8c2cad..a226e2540ebdb169ee993e64f3b164926b55fa52 100644 (file)
@@ -32,7 +32,6 @@
 
 #include <mach/common.h>
 #include <mach/iomux-mx27.h>
-#include <mach/imxfb.h>
 #include <mach/hardware.h>
 #include <mach/mmc.h>
 #include <mach/spi.h>
@@ -196,7 +195,7 @@ static struct imx_fb_videomode eukrea_mbimx27_modes[] = {
        },
 };
 
-static struct imx_fb_platform_data eukrea_mbimx27_fb_data = {
+static const struct imx_fb_platform_data eukrea_mbimx27_fb_data __initconst = {
        .mode = eukrea_mbimx27_modes,
        .num_modes = ARRAY_SIZE(eukrea_mbimx27_modes),
 
@@ -351,7 +350,7 @@ void __init eukrea_mbimx27_baseboard_init(void)
        imx27_add_imx_uart3(&uart_pdata);
 #endif
 
-       mxc_register_device(&mxc_fb_device, &eukrea_mbimx27_fb_data);
+       imx27_add_imx_fb(&eukrea_mbimx27_fb_data);
        mxc_register_device(&mxc_sdhc_device0, &sdhc_pdata);
 
        i2c_register_board_info(0, eukrea_mbimx27_i2c_devices,
index e1282e9f50ffe38f5861c48209a92b241686d324..4820a67b8abbda15d37e3997ae08c39e93aac5ac 100644 (file)
@@ -24,7 +24,6 @@
 #include <asm/mach/arch.h>
 #include <asm/mach/time.h>
 #include <asm/mach/map.h>
-#include <mach/imxfb.h>
 #include <mach/iomux-mx21.h>
 #include <mach/mxc_nand.h>
 #include <mach/mmc.h>
@@ -213,7 +212,7 @@ static struct imx_fb_videomode mx21ads_modes[] = {
        },
 };
 
-static struct imx_fb_platform_data mx21ads_fb_data = {
+static const struct imx_fb_platform_data mx21ads_fb_data __initconst = {
        .mode = mx21ads_modes,
        .num_modes = ARRAY_SIZE(mx21ads_modes),
 
@@ -296,7 +295,7 @@ static void __init mx21ads_board_init(void)
        imx21_add_imx_uart0(&uart_pdata_rts);
        imx21_add_imx_uart2(&uart_pdata_norts);
        imx21_add_imx_uart3(&uart_pdata_rts);
-       mxc_register_device(&mxc_fb_device, &mx21ads_fb_data);
+       imx21_add_imx_fb(&mx21ads_fb_data);
        mxc_register_device(&mxc_sdhc_device0, &mx21ads_sdhc_pdata);
        imx21_add_mxc_nand(&mx21ads_nand_board_info);
 
index 219899a5c8ab0ed6fc19602e07fa4e6d6b6f2d33..d97b25bffe7b282f80434c49b87ffe4f083e540b 100644 (file)
@@ -30,7 +30,6 @@
 #include <mach/gpio.h>
 #include <mach/iomux-mx27.h>
 #include <mach/mxc_nand.h>
-#include <mach/imxfb.h>
 #include <mach/mmc.h>
 
 #include "devices-imx27.h"
@@ -228,7 +227,7 @@ static struct imx_fb_videomode mx27ads_modes[] = {
        },
 };
 
-static struct imx_fb_platform_data mx27ads_fb_data = {
+static const struct imx_fb_platform_data mx27ads_fb_data __initconst = {
        .mode = mx27ads_modes,
        .num_modes = ARRAY_SIZE(mx27ads_modes),
 
@@ -307,7 +306,7 @@ static void __init mx27ads_board_init(void)
        i2c_register_board_info(1, mx27ads_i2c_devices,
                                ARRAY_SIZE(mx27ads_i2c_devices));
        imx27_add_imx_i2c(1, &mx27ads_i2c1_data);
-       mxc_register_device(&mxc_fb_device, &mx27ads_fb_data);
+       imx27_add_imx_fb(&mx27ads_fb_data);
        mxc_register_device(&mxc_sdhc_device0, &sdhc1_pdata);
        mxc_register_device(&mxc_sdhc_device1, &sdhc2_pdata);
 
index 38d3a4ae17c765f2a4779e67f2ac9967cd130f12..0c944858e88460c1c72a224ddc11c94392b8e053 100644 (file)
@@ -31,7 +31,6 @@
 #include <mach/iomux-mx27.h>
 #include <mach/mxc_nand.h>
 #include <linux/i2c/pca953x.h>
-#include <mach/imxfb.h>
 #include <mach/mmc.h>
 
 #include "devices-imx27.h"
@@ -196,7 +195,7 @@ static struct imx_fb_videomode mxt_td60_modes[] = {
        },
 };
 
-static struct imx_fb_platform_data mxt_td60_fb_data = {
+static const struct imx_fb_platform_data mxt_td60_fb_data __initconst = {
        .mode = mxt_td60_modes,
        .num_modes = ARRAY_SIZE(mxt_td60_modes),
 
@@ -253,7 +252,7 @@ static void __init mxt_td60_board_init(void)
 
        imx27_add_imx_i2c(0, &mxt_td60_i2c0_data);
        imx27_add_imx_i2c(1, &mxt_td60_i2c1_data);
-       mxc_register_device(&mxc_fb_device, &mxt_td60_fb_data);
+       imx27_add_imx_fb(&mxt_td60_fb_data);
        mxc_register_device(&mxc_sdhc_device0, &sdhc1_pdata);
        imx27_add_fec(NULL);
 }
index 11da9c226e9055d18961c34dd9cb847e4eebb229..30490c37190e86d75225109d972447c0110061c2 100644 (file)
@@ -43,7 +43,6 @@
 #include <mach/mmc.h>
 #include <mach/mxc_ehci.h>
 #include <mach/ulpi.h>
-#include <mach/imxfb.h>
 
 #include "devices-imx27.h"
 #include "devices.h"
@@ -350,7 +349,7 @@ static struct imx_fb_videomode pca100_fb_modes[] = {
        },
 };
 
-static struct imx_fb_platform_data pca100_fb_data = {
+static const struct imx_fb_platform_data pca100_fb_data __initconst = {
        .mode = pca100_fb_modes,
        .num_modes = ARRAY_SIZE(pca100_fb_modes),
 
@@ -425,7 +424,7 @@ static void __init pca100_init(void)
                mxc_register_device(&mxc_otg_udc_device, &otg_device_pdata);
        }
 
-       mxc_register_device(&mxc_fb_device, &pca100_fb_data);
+       imx27_add_imx_fb(&pca100_fb_data);
 
        imx27_add_fec(NULL);
        imx27_add_imx2_wdt(NULL);
index 9110d9cca7a2dc4b66adc85950541b5a9a7bc81b..9cf94607034e791c9e0d488d3a91a826315c56a6 100644 (file)
 
 #include <mach/common.h>
 #include <mach/iomux-mx27.h>
-#include <mach/imxfb.h>
 #include <mach/hardware.h>
 #include <mach/mmc.h>
 
+#include "devices-imx27.h"
 #include "devices.h"
 
 static const int pcm970_pins[] __initconst = {
@@ -179,7 +179,7 @@ static struct imx_fb_videomode pcm970_modes[] = {
        },
 };
 
-static struct imx_fb_platform_data pcm038_fb_data = {
+static const struct imx_fb_platform_data pcm038_fb_data __initconst = {
        .mode = pcm970_modes,
        .num_modes = ARRAY_SIZE(pcm970_modes),
 
@@ -226,7 +226,7 @@ void __init pcm970_baseboard_init(void)
        mxc_gpio_setup_multiple_pins(pcm970_pins, ARRAY_SIZE(pcm970_pins),
                        "PCM970");
 
-       mxc_register_device(&mxc_fb_device, &pcm038_fb_data);
+       imx27_add_imx_fb(&pcm038_fb_data);
        mxc_gpio_mode(GPIO_PORTC | 28 | GPIO_GPIO | GPIO_IN);
        mxc_register_device(&mxc_sdhc_device1, &sdhc_pdata);
        platform_device_register(&pcm970_sja1000);
index 01b0d0cdf8669d8b8c05fa1e143b6bb4fdd5ce83..25423713b49843ed61e0bf06589a0f257670c88a 100644 (file)
@@ -16,6 +16,9 @@ config IMX_HAVE_PLATFORM_GPIO_KEYS
 config IMX_HAVE_PLATFORM_IMX2_WDT
        bool
 
+config IMX_HAVE_PLATFORM_IMX_FB
+       bool
+
 config IMX_HAVE_PLATFORM_IMX_I2C
        bool
 
index 224f6655c75fd45c625a6affbbdff2aec09f976d..d3f845eea1cade78e5e38f6736031aa6f388ce93 100644 (file)
@@ -4,6 +4,7 @@ obj-$(CONFIG_IMX_HAVE_PLATFORM_FLEXCAN) += platform-flexcan.o
 obj-$(CONFIG_IMX_HAVE_PLATFORM_GPIO_KEYS) += platform-gpio_keys.o
 obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX2_WDT) += platform-imx2-wdt.o
 obj-y += platform-imx-dma.o
+obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_FB) += platform-imx-fb.o
 obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_I2C) += platform-imx-i2c.o
 obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_SSI) += platform-imx-ssi.o
 obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_UART) += platform-imx-uart.o
diff --git a/arch/arm/plat-mxc/devices/platform-imx-fb.c b/arch/arm/plat-mxc/devices/platform-imx-fb.c
new file mode 100644 (file)
index 0000000..42ed3be
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2010 Pengutronix
+ * Uwe Kleine-Koenig <u.kleine-koenig@pengutronix.de>
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License version 2 as published by the
+ * Free Software Foundation.
+ */
+#include <mach/hardware.h>
+#include <mach/devices-common.h>
+
+#define imx_imx_fb_data_entry_single(soc)                              \
+       {                                                               \
+               .iobase = soc ## _LCDC_BASE_ADDR,                       \
+               .irq = soc ## _INT_LCDC,                                \
+       }
+
+#ifdef CONFIG_SOC_IMX21
+const struct imx_imx_fb_data imx21_imx_fb_data __initconst =
+       imx_imx_fb_data_entry_single(MX21);
+#endif /* ifdef CONFIG_SOC_IMX21 */
+
+#ifdef CONFIG_SOC_IMX27
+const struct imx_imx_fb_data imx27_imx_fb_data __initconst =
+       imx_imx_fb_data_entry_single(MX27);
+#endif /* ifdef CONFIG_SOC_IMX27 */
+
+struct platform_device *__init imx_add_imx_fb(
+               const struct imx_imx_fb_data *data,
+               const struct imx_fb_platform_data *pdata)
+{
+       struct resource res[] = {
+               {
+                       .start = data->iobase,
+                       .end = data->iobase + SZ_4K - 1,
+                       .flags = IORESOURCE_MEM,
+               }, {
+                       .start = data->irq,
+                       .end = data->irq,
+                       .flags = IORESOURCE_IRQ,
+               },
+       };
+       return imx_add_platform_device_dmamask("imx-fb", 0,
+                       res, ARRAY_SIZE(res),
+                       pdata, sizeof(*pdata), DMA_BIT_MASK(32));
+}
index 830369ea80d0667902730411b1f81df25a6077f6..b1d765634860d197ba5ce3ec94d8b36abd07cf68 100644 (file)
@@ -54,6 +54,15 @@ struct imx_imx2_wdt_data {
 struct platform_device *__init imx_add_imx2_wdt(
                const struct imx_imx2_wdt_data *data);
 
+#include <mach/imxfb.h>
+struct imx_imx_fb_data {
+       resource_size_t iobase;
+       resource_size_t irq;
+};
+struct platform_device *__init imx_add_imx_fb(
+               const struct imx_imx_fb_data *data,
+               const struct imx_fb_platform_data *pdata);
+
 #include <mach/i2c.h>
 struct imx_imx_i2c_data {
        int id;
index 5263506b7ddff1d4e75171651af5c6155a4a3e53..9de8f062ad5de01d77aed0641be39509db093ca9 100644 (file)
@@ -1,6 +1,8 @@
 /*
  * This structure describes the machine which we are running on.
  */
+#ifndef __MACH_IMXFB_H__
+#define __MACH_IMXFB_H__
 
 #include <linux/fb.h>
 
@@ -79,3 +81,4 @@ struct imx_fb_platform_data {
 };
 
 void set_imx_fb_info(struct imx_fb_platform_data *);
+#endif /* ifndef __MACH_IMXFB_H__ */