2 * Copyright (C) 2007, OpenWrt.org, Florian Fainelli <florian@openwrt.org>
3 * RDC321x architecture specific GPIO support
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version.
11 #include <linux/autoconf.h>
12 #include <linux/init.h>
14 #include <linux/types.h>
15 #include <linux/module.h>
16 #include <linux/delay.h>
18 #define RDC3210_CFGREG_ADDR 0x0CF8
19 #define RDC3210_CFGREG_DATA 0x0CFC
21 static unsigned int rdc_gpio_read(unsigned gpio)
25 val = 0x80000000 | (7 << 11) | ((0x48));
26 outl(val, RDC3210_CFGREG_ADDR);
28 val = inl(RDC3210_CFGREG_DATA);
30 outl(val, RDC3210_CFGREG_DATA);
32 val = 0x80000000 | (7 << 11) | ((0x4C));
33 outl(val, RDC3210_CFGREG_ADDR);
35 val = inl(RDC3210_CFGREG_DATA);
40 void rdc_gpio_write(unsigned int val)
43 outl(val, RDC3210_CFGREG_DATA);
48 int rdc_gpio_get_value(unsigned gpio)
50 return ((int)rdc_gpio_read(gpio));
52 EXPORT_SYMBOL(rdc_gpio_get_value);
54 void rdc_gpio_set_value(unsigned gpio, int value)
58 val = rdc_gpio_read(gpio);
61 val &= ~(0x1 << gpio);
67 EXPORT_SYMBOL(rdc_gpio_set_value);
69 int rdc_gpio_direction_input(unsigned gpio)
73 EXPORT_SYMBOL(rdc_gpio_direction_input);
75 int rdc_gpio_direction_output(unsigned gpio, int value)
79 EXPORT_SYMBOL(rdc_gpio_direction_output);