X-Git-Url: http://git.ozo.com/?a=blobdiff_plain;f=target%2Flinux%2Frdc-2.6%2Ffiles%2Farch%2Fi386%2Fmach-rdc%2Fgpio.c;fp=target%2Flinux%2Frdc-2.6%2Ffiles%2Farch%2Fi386%2Fmach-rdc%2Fgpio.c;h=eadb15235e8e076437b5b835592e0d78c1e64596;hb=47ef8de2605ee325507e867ebb99bb3aade23f22;hp=0000000000000000000000000000000000000000;hpb=94040edc4564cd2419a4d0898fdece22d0d205ea;p=openwrt-10.03%2F.git diff --git a/target/linux/rdc-2.6/files/arch/i386/mach-rdc/gpio.c b/target/linux/rdc-2.6/files/arch/i386/mach-rdc/gpio.c new file mode 100644 index 000000000..eadb15235 --- /dev/null +++ b/target/linux/rdc-2.6/files/arch/i386/mach-rdc/gpio.c @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2007, OpenWrt.org, Florian Fainelli + * RDC321x architecture specific GPIO support + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + */ + +#include +#include +#include +#include +#include +#include + +#define RDC3210_CFGREG_ADDR 0x0CF8 +#define RDC3210_CFGREG_DATA 0x0CFC + +static unsigned int rdc_gpio_read(unsigned gpio) +{ + unsigned int val; + + val = 0x80000000 | (7 << 11) | ((0x48)); + outl(val, RDC3210_CFGREG_ADDR); + udelay(10); + val = inl(RDC3210_CFGREG_DATA); + val |= (0x1 << gpio); + outl(val, RDC3210_CFGREG_DATA); + udelay(10); + val = 0x80000000 | (7 << 11) | ((0x4C)); + outl(val, RDC3210_CFGREG_ADDR); + udelay(10); + val = inl(RDC3210_CFGREG_DATA); + + return val; +} + +void rdc_gpio_write(unsigned int val) +{ + if (val) { + outl(val, RDC3210_CFGREG_DATA); + udelay(10); + } +} + +int rdc_gpio_get_value(unsigned gpio) +{ + return ((int)rdc_gpio_read(gpio)); +} +EXPORT_SYMBOL(rdc_gpio_get_value); + +void rdc_gpio_set_value(unsigned gpio, int value) +{ + unsigned int val; + + val = rdc_gpio_read(gpio); + + if (value) + val &= ~(0x1 << gpio); + else + val |= (0x1 << gpio); + + rdc_gpio_write(val); +} +EXPORT_SYMBOL(rdc_gpio_set_value); + +int rdc_gpio_direction_input(unsigned gpio) +{ + return 0; +} +EXPORT_SYMBOL(rdc_gpio_direction_input); + +int rdc_gpio_direction_output(unsigned gpio, int value) +{ + return 0; +} +EXPORT_SYMBOL(rdc_gpio_direction_output); + +