]> err.no Git - linux-2.6/commitdiff
[ARM] 5088/3: pxa2xx: add pxa2xx_set_spi_info to register pxa2xx-spi platform devices
authorGuennadi Liakhovetski <lg@denx.de>
Fri, 13 Jun 2008 08:17:31 +0000 (09:17 +0100)
committerRussell King <rmk+kernel@arm.linux.org.uk>
Wed, 9 Jul 2008 20:31:52 +0000 (21:31 +0100)
Add a function to dynamically allocate and register pxa2xx-spi platform
devices, to be used by PXA2xx and PXA3xx based systems. Switch pcm027 and
lubbock to use it.

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@pengutronix.de>
Acked-by: Eric Miao <eric.miao@marvell.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
arch/arm/mach-pxa/Kconfig
arch/arm/mach-pxa/devices.c
arch/arm/mach-pxa/lubbock.c
arch/arm/mach-pxa/pcm027.c
include/asm-arm/arch-pxa/pxa2xx_spi.h

index 914bb33dab920e4deaff4f890916d8b3a140aee5..ef7271e378108ea95db7f545f13e6b3c063fae63 100644 (file)
@@ -139,6 +139,7 @@ config MACH_PCM027
        bool "Phytec phyCORE-PXA270 CPU module (PCM-027)"
        select PXA27x
        select IWMMXT
+       select PXA_SSP
 
 endmenu
 
index a6f2390ce662de674a520aca8bed2d5623148c0b..abc161dd083ab788bb9d26b1f750c170ab322338 100644 (file)
@@ -13,6 +13,7 @@
 #include <asm/arch/mfp-pxa27x.h>
 #include <asm/arch/ohci.h>
 #include <asm/arch/pxa27x_keypad.h>
+#include <asm/arch/pxa2xx_spi.h>
 #include <asm/arch/camera.h>
 #include <asm/arch/audio.h>
 
@@ -831,3 +832,20 @@ void __init pxa3xx_set_mci3_info(struct pxamci_platform_data *info)
 }
 
 #endif /* CONFIG_PXA3xx */
+
+/* pxa2xx-spi platform-device ID equals respective SSP platform-device ID + 1.
+ * See comment in arch/arm/mach-pxa/ssp.c::ssp_probe() */
+void __init pxa2xx_set_spi_info(unsigned id, struct pxa2xx_spi_master *info)
+{
+       struct platform_device *pd;
+
+       pd = platform_device_alloc("pxa2xx-spi", id);
+       if (pd == NULL) {
+               printk(KERN_ERR "pxa2xx-spi: failed to allocate device id %d\n",
+                      id);
+               return;
+       }
+
+       pd->dev.platform_data = info;
+       platform_device_add(pd);
+}
index a3fae4139203d42325f6ecc0f3b833e57bc804b5..e041cceab16bbb7a0c912a67e2e6f0325d507b86 100644 (file)
@@ -226,14 +226,6 @@ static struct pxa2xx_spi_master pxa_ssp_master_info = {
        .num_chipselect = 0,
 };
 
-static struct platform_device pxa_ssp = {
-       .name           = "pxa2xx-spi",
-       .id             = 1,
-       .dev = {
-               .platform_data  = &pxa_ssp_master_info,
-       },
-};
-
 static int lubbock_ads7846_pendown_state(void)
 {
        /* TS_BUSY is bit 8 in LUB_MISC_RD, but pendown is irq-only */
@@ -367,7 +359,6 @@ static struct platform_device *devices[] __initdata = {
        &smc91x_device,
        &lubbock_flash_device[0],
        &lubbock_flash_device[1],
-       &pxa_ssp,
 };
 
 static struct pxafb_mode_info sharp_lm8v31_mode = {
@@ -501,6 +492,7 @@ static void __init lubbock_init(void)
        lubbock_flash_data[flashboot].name = "boot-rom";
        (void) platform_add_devices(devices, ARRAY_SIZE(devices));
 
+       pxa2xx_set_spi_info(1, &pxa_ssp_master_info);
        spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
 }
 
index 3b945eb0aee3768a1c22b2efa12be75537b8a13a..377f3be8ce578fc5f04477cb12c9ef94532c7d41 100644 (file)
@@ -24,7 +24,9 @@
 #include <linux/platform_device.h>
 #include <linux/mtd/physmap.h>
 #include <linux/spi/spi.h>
+#include <linux/spi/max7301.h>
 #include <linux/leds.h>
+
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
 #include <asm/arch/hardware.h>
@@ -108,6 +110,32 @@ static struct platform_device smc91x_device = {
        .resource       = smc91x_resources,
 };
 
+/*
+ * SPI host and devices
+ */
+static struct pxa2xx_spi_master pxa_ssp_master_info = {
+       .num_chipselect = 1,
+};
+
+static struct max7301_platform_data max7301_info = {
+       .base = -1,
+};
+
+/* bus_num must match id in pxa2xx_set_spi_info() call */
+static struct spi_board_info spi_board_info[] __initdata = {
+       {
+               .modalias       = "max7301",
+               .platform_data  = &max7301_info,
+               .max_speed_hz   = 13000000,
+               .bus_num        = 1,
+               .chip_select    = 0,
+               .mode           = SPI_MODE_0,
+       },
+};
+
+/*
+ * NOR flash
+ */
 static struct physmap_flash_data pcm027_flash_data = {
        .width  = 4,
 };
@@ -190,6 +218,9 @@ static void __init pcm027_init(void)
 #ifdef CONFIG_MACH_PCM990_BASEBOARD
        pcm990_baseboard_init();
 #endif
+
+       pxa2xx_set_spi_info(1, &pxa_ssp_master_info);
+       spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
 }
 
 static void __init pcm027_map_io(void)
index 3459fb26ce978c2b04a129bcf036360b04fcdca2..2206cb61a9f918060d2416adea78fa83b1cfeae9 100644 (file)
@@ -41,4 +41,6 @@ struct pxa2xx_spi_chip {
        void (*cs_control)(u32 command);
 };
 
+extern void pxa2xx_set_spi_info(unsigned id, struct pxa2xx_spi_master *info);
+
 #endif /*PXA2XX_SPI_H_*/