[adm5120] experimental gpiodev support (closes #3613)
authorjuhosg <juhosg@3c298f89-4303-0410-b956-a3cf2f4a3e73>
Tue, 5 Aug 2008 11:16:46 +0000 (11:16 +0000)
committerjuhosg <juhosg@3c298f89-4303-0410-b956-a3cf2f4a3e73>
Tue, 5 Aug 2008 11:16:46 +0000 (11:16 +0000)
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@12134 3c298f89-4303-0410-b956-a3cf2f4a3e73

target/linux/adm5120/files/arch/mips/adm5120/board.c
target/linux/adm5120/files/arch/mips/adm5120/boards/cellvision.c
target/linux/adm5120/files/arch/mips/adm5120/boards/compex.c
target/linux/adm5120/files/arch/mips/adm5120/boards/infineon.c
target/linux/adm5120/files/arch/mips/adm5120/boards/mikrotik.c
target/linux/adm5120/files/arch/mips/adm5120/boards/zyxel.c
target/linux/adm5120/files/arch/mips/adm5120/platform.c
target/linux/adm5120/files/include/asm-mips/mach-adm5120/adm5120_platform.h

index 8f383da403e82535e1b6830612ec205ecec4011b..2cbc8f2cc4b70eab206f49de589d9019196022aa 100644 (file)
@@ -93,6 +93,11 @@ static int __init adm5120_board_setup(void)
        /* register built-in ethernet switch */
        platform_device_register(&adm5120_switch_device);
 
+       if (adm5120_package_pqfp())
+               adm5120_gpiodev_resource.start &= ~0xf0;
+
+       platform_device_register(&adm5120_gpiodev_device);
+
        /* setup PCI irq map */
        adm5120_pci_set_irq_map(board->pci_nr_irqs, board->pci_irq_map);
 
index 3e68fa52abdb885bceb9ae812b048b57f15d230b..d3e7c7dbe42ac51323f7540899978dba8c280297 100644 (file)
 #include <adm5120_platform.h>
 #include <adm5120_irq.h>
 
+#define CAS6XX_GPIO_DEV_MASK   (1 << ADM5120_GPIO_PIN5)
+#define CAS7XX_GPIO_DEV_MASK   (1 << ADM5120_GPIO_PIN5)
+#define NFS_GPIO_DEV_MASK      (1 << ADM5120_GPIO_PIN5)
+
 static void switch_bank_gpio5(unsigned bank)
 {
        switch (bank) {
@@ -104,6 +108,8 @@ static void __init cas6xx_setup(void)
        adm5120_flash0_data.nr_parts = ARRAY_SIZE(cas6xx_partitions);
        adm5120_flash0_data.parts = cas6xx_partitions;
 
+       adm5120_gpiodev_resource.start &= ~CAS6XX_GPIO_DEV_MASK;
+
        /* TODO: setup mac address */
 }
 
@@ -117,6 +123,8 @@ static void __init cas7xx_setup(void)
        adm5120_flash0_data.nr_parts = ARRAY_SIZE(cas7xx_partitions);
        adm5120_flash0_data.parts = cas7xx_partitions;
 
+       adm5120_gpiodev_resource.start &= ~CAS7XX_GPIO_DEV_MASK;
+
        /* TODO: setup mac address */
 }
 
@@ -130,6 +138,8 @@ static void __init nfs_setup(void)
        adm5120_flash0_data.nr_parts = ARRAY_SIZE(cas6xx_partitions);
        adm5120_flash0_data.parts = cas6xx_partitions;
 
+       adm5120_gpiodev_resource.start &= ~NFS_GPIO_DEV_MASK;
+
        /* TODO: setup mac address */
 }
 
index 1af0eb2d4bd9b4308dff8cf46555e5a393870d71..5cf858c294a9a90a09e2f537fcad25311307a511 100644 (file)
 #include <adm5120_platform.h>
 #include <adm5120_irq.h>
 
+#define NP27G_GPIO_DEV_MASK    (1 << ADM5120_GPIO_PIN5)
+#define NP28G_GPIO_DEV_MASK    ( 1 << ADM5120_GPIO_PIN5 \
+                               | 1 << ADM5120_GPIO_PIN4)
+
+#define WP54_GPIO_DEV_MASK     ( 1 << ADM5120_GPIO_PIN5 \
+                               | 1 << ADM5120_GPIO_PIN3)
+
 static struct adm5120_pci_irq wp54_pci_irqs[] __initdata = {
        PCIIRQ(2, 0, 1, ADM5120_IRQ_PCI0),
 };
@@ -104,6 +111,7 @@ static void __init np27g_setup(void)
 
        /* setup data for flash0 device */
        adm5120_flash0_data.switch_bank = switch_bank_gpio5;
+       adm5120_gpiodev_resource.start &= ~NP27G_GPIO_DEV_MASK;
 
        /* TODO: setup mac address */
 }
@@ -119,6 +127,8 @@ static void __init np28g_setup(void)
        /* setup data for flash0 device */
        adm5120_flash0_data.switch_bank = switch_bank_gpio5;
 
+       adm5120_gpiodev_resource.start &= ~NP28G_GPIO_DEV_MASK;
+
        /* TODO: setup mac address */
 }
 
@@ -137,6 +147,8 @@ static void __init wp54_setup(void)
        adm5120_buttons[0].desc = "reset button";
        adm5120_buttons[0].gpio = ADM5120_GPIO_PIN2;
 
+       adm5120_gpiodev_resource.start &= ~WP54_GPIO_DEV_MASK;
+
        /* TODO: setup mac address */
 }
 
index 8ef01e6e68c66189d20664c597b57b814da8f99b..c8680d6c4aada984f82466f83ae3be35f7f41baa 100644 (file)
@@ -24,6 +24,9 @@
 #include <adm5120_platform.h>
 #include <adm5120_info.h>
 
+#define EASY_PQFP_GPIO_DEV_MASK        (1 << ADM5120_GPIO_PIN3)
+#define EASY_BGA_GPIO_DEV_MASK (1 << ADM5120_GPIO_PIN5)
+
 static void switch_bank_gpio3(unsigned bank)
 {
        switch (bank) {
@@ -99,6 +102,8 @@ static void __init easy_setup_pqfp(void)
        adm5120_flash0_data.nr_parts = ARRAY_SIZE(easy_partitions);
        adm5120_flash0_data.parts = easy_partitions;
 
+       adm5120_gpiodev_resource.start &= ~EASY_PQFP_GPIO_DEV_MASK;
+
        /* TODO: setup mac addresses */
 }
 
@@ -112,6 +117,8 @@ static void __init easy_setup_bga(void)
        adm5120_flash0_data.nr_parts = ARRAY_SIZE(easy_partitions);
        adm5120_flash0_data.parts = easy_partitions;
 
+       adm5120_gpiodev_resource.start &= ~EASY_BGA_GPIO_DEV_MASK;
+
        /* TODO: setup mac addresses */
 }
 
index 54fb8c03b7917dabeaac18f4b78056f852e3d856..9595e815f77b9a05a5a9c339987e4e9f3b1db36f 100644 (file)
 #define RB150_GPIO_NAND_NCE    ADM5120_GPIO_PIN1
 #define RB150_GPIO_NAND_CLE    ADM5120_GPIO_P2L2
 #define RB150_GPIO_NAND_ALE    ADM5120_GPIO_P3L2
+#define RB150_GPIO_DEV_MASK    ( 1 << RB150_GPIO_NAND_READY    \
+                               | 1 << RB150_GPIO_NAND_NCE      \
+                               | 1 << RB150_GPIO_NAND_CLE      \
+                               | 1 << RB150_GPIO_NAND_ALE)
 
 #define RB150_NAND_DELAY       100
 
 #define RB150_NAND_WRITE(v) \
        writeb((v), (void __iomem *)KSEG1ADDR(RB150_NAND_BASE))
 
+#define RB153_GPIO_DEV_MASK    ( 1 << ADM5120_GPIO_PIN0 \
+                               | 1 << ADM5120_GPIO_PIN3 \
+                               | 1 << ADM5120_GPIO_PIN4 )
+
 /*--------------------------------------------------------------------------*/
 
 static struct adm5120_pci_irq rb1xx_pci_irqs[] __initdata = {
@@ -279,6 +287,8 @@ static void __init rb150_setup(void)
        adm5120_buttons[0].desc = "reset button";
        adm5120_buttons[0].gpio = ADM5120_GPIO_PIN1; /* FIXME: valid? */
 
+       adm5120_gpiodev_resource.start &= ~RB150_GPIO_DEV_MASK;
+
        adm5120_flash0_data.window_size = 512*1024;
 
        rb1xx_flash_setup();
@@ -293,6 +303,8 @@ static void __init rb153_setup(void)
        adm5120_gpio_ew_enable();
 
        rb1xx_setup();
+
+       adm5120_gpiodev_resource.start &= ~RB153_GPIO_DEV_MASK;
 }
 
 /*--------------------------------------------------------------------------*/
index 075661a8defc040fd6d036961541f46fd45f39ae..717c0733ab233c6f932ae30384b723e526d6a911 100644 (file)
@@ -22,6 +22,8 @@
 #include <adm5120_platform.h>
 #include <adm5120_irq.h>
 
+#define P33X_GPIO_DEV_MASK     (1 << ADM5120_GPIO_PIN5)
+
 static void switch_bank_gpio5(unsigned bank)
 {
        switch (bank) {
@@ -83,6 +85,7 @@ static void __init p33x_setup(void)
        adm5120_flash0_data.nr_parts = ARRAY_SIZE(p33x_partitions);
        adm5120_flash0_data.parts = p33x_partitions;
 
+       adm5120_gpiodev_resource.start &= ~P33X_GPIO_DEV_MASK;
        /* TODO: setup mac address */
 }
 
index d61e7c65de2762f920007d57be8c09432f0db7c8..26de8f0c63724d22f813e3c3b82fa2c05cc648b2 100644 (file)
@@ -216,6 +216,18 @@ struct platform_device adm5120_buttons_device = {
        .dev.platform_data = &adm5120_buttons_data,
 };
 
+/* GPIO char device */
+struct resource adm5120_gpiodev_resource = {
+       .start  = 0x3fffff,
+};
+
+struct platform_device adm5120_gpiodev_device =        {
+       .name           = "GPIODEV",
+       .id             = -1,
+       .num_resources  = 1,
+       .resource       = &adm5120_gpiodev_resource,
+};
+
 void adm5120_uart_set_mctrl(struct amba_device *dev, void __iomem *base,
                unsigned int mctrl)
 {
index 470ef254de77596ab872e535e201848b744c1352..d3b2213d3258425deccb2f0e4437be9283dbc20f 100644 (file)
@@ -64,6 +64,8 @@ static inline void adm5120_pci_set_irq_map(unsigned int nr_irqs,
 
 #define ADM5120_NUM_BUTTONS    5
 
+extern struct resource adm5120_gpiodev_resource;
+
 extern struct adm5120_flash_platform_data adm5120_flash0_data;
 extern struct adm5120_flash_platform_data adm5120_flash1_data;
 extern struct platform_nand_data adm5120_nand_data;
@@ -79,6 +81,7 @@ extern struct platform_device adm5120_nand_device;
 extern struct platform_device adm5120_hcd_device;
 extern struct platform_device adm5120_switch_device;
 extern struct platform_device adm5120_buttons_device;
+extern struct platform_device adm5120_gpiodev_device;
 extern struct amba_device adm5120_uart0_device;
 extern struct amba_device adm5120_uart1_device;