source: trunk/target/linux/ifxmips/patches-2.6.30/600-ebu-gpio.patch @ 20418

Last change on this file since 20418 was 20418, checked in by blogic, 7 years ago

[ifxmips] implement gpiolib drivers for core gpio and ebu attached latches

File size: 6.3 KB
  • drivers/gpio/Kconfig

    old new  
    176176          SPI driver for Microchip MCP23S08 I/O expander.  This provides 
    177177          a GPIO interface supporting inputs and outputs. 
    178178 
     179comment "EBU GPIO expanders:" 
     180 
     181config GPIO_IFXMIPS_EBU 
     182        boolean "IFXMIPS EBU attached I/O expander" 
     183        depends on IFXMIPS 
     184        help 
     185          This driver allows you to drive latches attached to the SoCc External Bus Unit 
     186 
    179187endif 
  • drivers/gpio/Makefile

    old new  
    1212obj-$(CONFIG_GPIO_TWL4030)      += twl4030-gpio.o 
    1313obj-$(CONFIG_GPIO_XILINX)       += xilinx_gpio.o 
    1414obj-$(CONFIG_GPIO_BT8XX)        += bt8xxgpio.o 
     15obj-$(CONFIG_GPIO_IFXMIPS_EBU)  += ifxmips_ebu_gpio.o 
  • arch/mips/ifxmips/board.c

    old new  
    111111        .name = "ifxmips_wdt", 
    112112}; 
    113113 
     114static struct platform_device ifxmips_ebu = { 
     115        .id = 0, 
     116        .name = "ifxmips_ebu", 
     117}; 
     118 
    114119static struct resource ifxmips_mtd_resource = { 
    115120        .start  = IFXMIPS_FLASH_START, 
    116121        .end    = IFXMIPS_FLASH_START + IFXMIPS_FLASH_MAX - 1, 
     
    145150static struct gpio_led arv452_gpio_leds[] = { 
    146151        { .name = "ifx:blue:power", .gpio = 3, .active_low = 1, }, 
    147152        { .name = "ifx:blue:adsl", .gpio = 4, .active_low = 1, }, 
    148         { .name = "ifx:pink:internet", .gpio = 5, .active_low = 1, }, 
     153        { .name = "ifx:blue:internet", .gpio = 5, .active_low = 1, }, 
    149154        { .name = "ifx:red:power", .gpio = 6, .active_low = 1, }, 
    150155        { .name = "ifx:yello:wps", .gpio = 7, .active_low = 1, }, 
    151156        { .name = "ifx:red:wps", .gpio = 9, .active_low = 1, }, 
     157        { .name = "ifx:blue:voip", .gpio = 32, .active_low = 1, }, 
     158        { .name = "ifx:blue:fxs1", .gpio = 33, .active_low = 1, }, 
     159        { .name = "ifx:blue:fxs2", .gpio = 34, .active_low = 1, }, 
     160        { .name = "ifx:blue:fxo", .gpio = 35, .active_low = 1, }, 
     161        { .name = "ifx:blue:voice", .gpio = 36, .active_low = 1, }, 
     162        { .name = "ifx:blue:usb", .gpio = 37, .active_low = 1, }, 
     163        { .name = "ifx:blue:wlan", .gpio = 38, .active_low = 1, }, 
     164        { .name = "ifx:red:internet", .gpio = 41, .active_low = 1, }, 
    152165}; 
    153166 
    154167static struct gpio_led_platform_data ifxmips_gpio_led_data; 
     
    205218struct platform_device *arv452_devs[] = { 
    206219        &ifxmips_gpio, &ifxmips_mii, &ifxmips_mtd, 
    207220        &ifxmips_gpio_dev, &ifxmips_wdt, &dwc_usb, 
     221        &ifxmips_ebu, 
    208222#ifdef CONFIG_LEDS_GPIO 
    209223        &ifxmips_gpio_leds, 
    210224#endif 
  • new file linux-2.6.30.10/drivers/gpio/ifxmips_ebu_gpio.c

    - +  
     1/* 
     2 *   This program is free software; you can redistribute it and/or modify 
     3 *   it under the terms of the GNU General Public License as published by 
     4 *   the Free Software Foundation; either version 2 of the License, or 
     5 *   (at your option) any later version. 
     6 * 
     7 *   This program is distributed in the hope that it will be useful, 
     8 *   but WITHOUT ANY WARRANTY; without even the implied warranty of 
     9 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     10 *   GNU General Public License for more details. 
     11 * 
     12 *   You should have received a copy of the GNU General Public License 
     13 *   along with this program; if not, write to the Free Software 
     14 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 
     15 * 
     16 *   Copyright (C) 2010 John Crispin <blogic@openwrt.org> 
     17 */ 
     18 
     19#include <linux/init.h> 
     20#include <linux/platform_device.h> 
     21#include <linux/mutex.h> 
     22#include <linux/gpio.h> 
     23#include <ifxmips.h> 
     24 
     25#define IFXMIPS_EBU_START       0x14000000 
     26#define IFXMIPS_EBU_MAX         0x00001000 
     27#define IFXMIPS_EBU_BUSCON      0x1e7ff 
     28#define IFXMIPS_EBU_WP          0x80000000 
     29 
     30static int shadow = (1 << 10) | (1 << 8); 
     31static void __iomem *virt; 
     32 
     33static int 
     34ifxmips_ebu_direction_input(struct gpio_chip *chip, unsigned offset) 
     35{ 
     36        return -EINVAL; 
     37} 
     38 
     39static int 
     40ifxmips_ebu_direction_output(struct gpio_chip *chip, unsigned offset, int value) 
     41{ 
     42        return 0; 
     43} 
     44 
     45static int 
     46ifxmips_ebu_get(struct gpio_chip *chip, unsigned offset) 
     47{ 
     48        return -EINVAL; 
     49} 
     50 
     51static void 
     52ifxmips_ebu_set(struct gpio_chip *chip, unsigned offset, int value) 
     53{ 
     54        if(value) 
     55                shadow |= (1 << offset); 
     56        else 
     57                shadow &= ~(1 << offset); 
     58        ifxmips_w32(IFXMIPS_EBU_BUSCON, IFXMIPS_EBU_BUSCON1); 
     59        *((__u16*)virt) = shadow; 
     60        ifxmips_w32(IFXMIPS_EBU_BUSCON | IFXMIPS_EBU_WP, IFXMIPS_EBU_BUSCON1); 
     61} 
     62 
     63static struct gpio_chip 
     64ifxmips_ebu_chip = 
     65{ 
     66        .label = "ifxmips_ebu", 
     67        .direction_input = ifxmips_ebu_direction_input, 
     68        .direction_output = ifxmips_ebu_direction_output, 
     69        .set = ifxmips_ebu_set, 
     70        .get = ifxmips_ebu_get, 
     71        .base = 32, 
     72        .ngpio = 16, 
     73        .can_sleep = 1, 
     74        .owner = THIS_MODULE, 
     75}; 
     76 
     77static int __devinit 
     78ifxmips_ebu_probe(struct platform_device *dev) 
     79{ 
     80        ifxmips_w32(IFXMIPS_EBU_START | 0x1, IFXMIPS_EBU_ADDRSEL1); 
     81        ifxmips_w32(IFXMIPS_EBU_BUSCON | IFXMIPS_EBU_WP, IFXMIPS_EBU_BUSCON1); 
     82        virt = ioremap_nocache(IFXMIPS_EBU_START, IFXMIPS_EBU_MAX); 
     83        if(gpiochip_add(&ifxmips_ebu_chip)) 
     84                return -EINVAL; 
     85        return 0; 
     86} 
     87 
     88static int 
     89ifxmips_ebu_remove(struct platform_device *dev) 
     90{ 
     91        return gpiochip_remove(&ifxmips_ebu_chip); 
     92} 
     93 
     94static struct platform_driver 
     95ifxmips_ebu_driver = { 
     96        .probe = ifxmips_ebu_probe, 
     97        .remove = ifxmips_ebu_remove, 
     98        .driver = { 
     99                .name = "ifxmips_ebu", 
     100                .owner = THIS_MODULE, 
     101        }, 
     102}; 
     103 
     104static int __init 
     105ifxmips_ebu_init(void) 
     106{ 
     107        return platform_driver_register(&ifxmips_ebu_driver); 
     108} 
     109 
     110static void __exit 
     111ifxmips_ebu_exit(void) 
     112{ 
     113        platform_driver_unregister(&ifxmips_ebu_driver); 
     114} 
     115 
     116module_init(ifxmips_ebu_init); 
     117module_exit(ifxmips_ebu_exit); 
     118 
     119MODULE_AUTHOR("John Crispin <blogic@openwrt.org>"); 
     120MODULE_LICENSE("GPL v2"); 
     121MODULE_DESCRIPTION("ifxmips - EBU Latch GPIO-Expander"); 
Note: See TracBrowser for help on using the repository browser.