From 33bca57f0148859dbe70c197643903fbe92cfaec Mon Sep 17 00:00:00 2001 From: juhosg Date: Tue, 5 Aug 2008 11:16:46 +0000 Subject: [PATCH] [adm5120] experimental gpiodev support (closes #3613) git-svn-id: svn://svn.openwrt.org/openwrt/trunk@12134 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- target/linux/adm5120/files/arch/mips/adm5120/board.c | 5 +++++ .../files/arch/mips/adm5120/boards/cellvision.c | 10 ++++++++++ .../adm5120/files/arch/mips/adm5120/boards/compex.c | 12 ++++++++++++ .../files/arch/mips/adm5120/boards/infineon.c | 7 +++++++ .../files/arch/mips/adm5120/boards/mikrotik.c | 12 ++++++++++++ .../adm5120/files/arch/mips/adm5120/boards/zyxel.c | 3 +++ .../linux/adm5120/files/arch/mips/adm5120/platform.c | 12 ++++++++++++ .../include/asm-mips/mach-adm5120/adm5120_platform.h | 3 +++ 8 files changed, 64 insertions(+) diff --git a/target/linux/adm5120/files/arch/mips/adm5120/board.c b/target/linux/adm5120/files/arch/mips/adm5120/board.c index 8f383da40..2cbc8f2cc 100644 --- a/target/linux/adm5120/files/arch/mips/adm5120/board.c +++ b/target/linux/adm5120/files/arch/mips/adm5120/board.c @@ -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); diff --git a/target/linux/adm5120/files/arch/mips/adm5120/boards/cellvision.c b/target/linux/adm5120/files/arch/mips/adm5120/boards/cellvision.c index 3e68fa52a..d3e7c7dbe 100644 --- a/target/linux/adm5120/files/arch/mips/adm5120/boards/cellvision.c +++ b/target/linux/adm5120/files/arch/mips/adm5120/boards/cellvision.c @@ -22,6 +22,10 @@ #include #include +#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 */ } diff --git a/target/linux/adm5120/files/arch/mips/adm5120/boards/compex.c b/target/linux/adm5120/files/arch/mips/adm5120/boards/compex.c index 1af0eb2d4..5cf858c29 100644 --- a/target/linux/adm5120/files/arch/mips/adm5120/boards/compex.c +++ b/target/linux/adm5120/files/arch/mips/adm5120/boards/compex.c @@ -22,6 +22,13 @@ #include #include +#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 */ } diff --git a/target/linux/adm5120/files/arch/mips/adm5120/boards/infineon.c b/target/linux/adm5120/files/arch/mips/adm5120/boards/infineon.c index 8ef01e6e6..c8680d6c4 100644 --- a/target/linux/adm5120/files/arch/mips/adm5120/boards/infineon.c +++ b/target/linux/adm5120/files/arch/mips/adm5120/boards/infineon.c @@ -24,6 +24,9 @@ #include #include +#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 */ } diff --git a/target/linux/adm5120/files/arch/mips/adm5120/boards/mikrotik.c b/target/linux/adm5120/files/arch/mips/adm5120/boards/mikrotik.c index 54fb8c03b..9595e815f 100644 --- a/target/linux/adm5120/files/arch/mips/adm5120/boards/mikrotik.c +++ b/target/linux/adm5120/files/arch/mips/adm5120/boards/mikrotik.c @@ -44,12 +44,20 @@ #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; } /*--------------------------------------------------------------------------*/ diff --git a/target/linux/adm5120/files/arch/mips/adm5120/boards/zyxel.c b/target/linux/adm5120/files/arch/mips/adm5120/boards/zyxel.c index 075661a8d..717c0733a 100644 --- a/target/linux/adm5120/files/arch/mips/adm5120/boards/zyxel.c +++ b/target/linux/adm5120/files/arch/mips/adm5120/boards/zyxel.c @@ -22,6 +22,8 @@ #include #include +#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 */ } diff --git a/target/linux/adm5120/files/arch/mips/adm5120/platform.c b/target/linux/adm5120/files/arch/mips/adm5120/platform.c index d61e7c65d..26de8f0c6 100644 --- a/target/linux/adm5120/files/arch/mips/adm5120/platform.c +++ b/target/linux/adm5120/files/arch/mips/adm5120/platform.c @@ -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) { diff --git a/target/linux/adm5120/files/include/asm-mips/mach-adm5120/adm5120_platform.h b/target/linux/adm5120/files/include/asm-mips/mach-adm5120/adm5120_platform.h index 470ef254d..d3b2213d3 100644 --- a/target/linux/adm5120/files/include/asm-mips/mach-adm5120/adm5120_platform.h +++ b/target/linux/adm5120/files/include/asm-mips/mach-adm5120/adm5120_platform.h @@ -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;