eadb15235e8e076437b5b835592e0d78c1e64596
[openwrt/svn-archive/archive.git] / target / linux / rdc-2.6 / files / arch / i386 / mach-rdc / gpio.c
1 /*
2 * Copyright (C) 2007, OpenWrt.org, Florian Fainelli <florian@openwrt.org>
3 * RDC321x architecture specific GPIO support
4 *
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.
9 */
10
11 #include <linux/autoconf.h>
12 #include <linux/init.h>
13 #include <linux/io.h>
14 #include <linux/types.h>
15 #include <linux/module.h>
16 #include <linux/delay.h>
17
18 #define RDC3210_CFGREG_ADDR 0x0CF8
19 #define RDC3210_CFGREG_DATA 0x0CFC
20
21 static unsigned int rdc_gpio_read(unsigned gpio)
22 {
23 unsigned int val;
24
25 val = 0x80000000 | (7 << 11) | ((0x48));
26 outl(val, RDC3210_CFGREG_ADDR);
27 udelay(10);
28 val = inl(RDC3210_CFGREG_DATA);
29 val |= (0x1 << gpio);
30 outl(val, RDC3210_CFGREG_DATA);
31 udelay(10);
32 val = 0x80000000 | (7 << 11) | ((0x4C));
33 outl(val, RDC3210_CFGREG_ADDR);
34 udelay(10);
35 val = inl(RDC3210_CFGREG_DATA);
36
37 return val;
38 }
39
40 void rdc_gpio_write(unsigned int val)
41 {
42 if (val) {
43 outl(val, RDC3210_CFGREG_DATA);
44 udelay(10);
45 }
46 }
47
48 int rdc_gpio_get_value(unsigned gpio)
49 {
50 return ((int)rdc_gpio_read(gpio));
51 }
52 EXPORT_SYMBOL(rdc_gpio_get_value);
53
54 void rdc_gpio_set_value(unsigned gpio, int value)
55 {
56 unsigned int val;
57
58 val = rdc_gpio_read(gpio);
59
60 if (value)
61 val &= ~(0x1 << gpio);
62 else
63 val |= (0x1 << gpio);
64
65 rdc_gpio_write(val);
66 }
67 EXPORT_SYMBOL(rdc_gpio_set_value);
68
69 int rdc_gpio_direction_input(unsigned gpio)
70 {
71 return 0;
72 }
73 EXPORT_SYMBOL(rdc_gpio_direction_input);
74
75 int rdc_gpio_direction_output(unsigned gpio, int value)
76 {
77 return 0;
78 }
79 EXPORT_SYMBOL(rdc_gpio_direction_output);
80
81