diff options
author | Florian Fainelli <florian.fainelli@telecomint.eu> | 2008-01-30 07:33:36 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-01-30 07:33:36 -0500 |
commit | 5e3a77e9a9b7bfc1f69f51fe6d34aa649887980c (patch) | |
tree | 2ec08958a77752beb57ee8e823a4baac509be8dd /arch/x86/mach-rdc321x/gpio.c | |
parent | 0acf8e3447b893ff921863c2a4258e210d584452 (diff) |
x86: add support for the RDC R-321x SoC
This patch adds support for the RDC R-321x system-on-chip,
also known as R-861x-(G). It uses the generic GPIO API and
has support for the on-chip hardware watchdog.
Build-fix from: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Florian Fainelli <florian.fainelli@telecomint.eu>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'arch/x86/mach-rdc321x/gpio.c')
-rw-r--r-- | arch/x86/mach-rdc321x/gpio.c | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/arch/x86/mach-rdc321x/gpio.c b/arch/x86/mach-rdc321x/gpio.c new file mode 100644 index 000000000000..031269163bd6 --- /dev/null +++ b/arch/x86/mach-rdc321x/gpio.c | |||
@@ -0,0 +1,91 @@ | |||
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 | #include <asm/mach-rdc321x/rdc321x_defs.h> | ||
19 | |||
20 | static inline int rdc_gpio_is_valid(unsigned gpio) | ||
21 | { | ||
22 | return (gpio <= RDC_MAX_GPIO); | ||
23 | } | ||
24 | |||
25 | static unsigned int rdc_gpio_read(unsigned gpio) | ||
26 | { | ||
27 | unsigned int val; | ||
28 | |||
29 | val = 0x80000000 | (7 << 11) | ((gpio&0x20?0x84:0x48)); | ||
30 | outl(val, RDC3210_CFGREG_ADDR); | ||
31 | udelay(10); | ||
32 | val = inl(RDC3210_CFGREG_DATA); | ||
33 | val |= (0x1 << (gpio & 0x1F)); | ||
34 | outl(val, RDC3210_CFGREG_DATA); | ||
35 | udelay(10); | ||
36 | val = 0x80000000 | (7 << 11) | ((gpio&0x20?0x88:0x4C)); | ||
37 | outl(val, RDC3210_CFGREG_ADDR); | ||
38 | udelay(10); | ||
39 | val = inl(RDC3210_CFGREG_DATA); | ||
40 | |||
41 | return val; | ||
42 | } | ||
43 | |||
44 | static void rdc_gpio_write(unsigned int val) | ||
45 | { | ||
46 | if (val) { | ||
47 | outl(val, RDC3210_CFGREG_DATA); | ||
48 | udelay(10); | ||
49 | } | ||
50 | } | ||
51 | |||
52 | int rdc_gpio_get_value(unsigned gpio) | ||
53 | { | ||
54 | if (rdc_gpio_is_valid(gpio)) | ||
55 | return (int)rdc_gpio_read(gpio); | ||
56 | else | ||
57 | return -EINVAL; | ||
58 | } | ||
59 | EXPORT_SYMBOL(rdc_gpio_get_value); | ||
60 | |||
61 | void rdc_gpio_set_value(unsigned gpio, int value) | ||
62 | { | ||
63 | unsigned int val; | ||
64 | |||
65 | if (!rdc_gpio_is_valid(gpio)) | ||
66 | return; | ||
67 | |||
68 | val = rdc_gpio_read(gpio); | ||
69 | |||
70 | if (value) | ||
71 | val &= ~(0x1 << (gpio & 0x1F)); | ||
72 | else | ||
73 | val |= (0x1 << (gpio & 0x1F)); | ||
74 | |||
75 | rdc_gpio_write(val); | ||
76 | } | ||
77 | EXPORT_SYMBOL(rdc_gpio_set_value); | ||
78 | |||
79 | int rdc_gpio_direction_input(unsigned gpio) | ||
80 | { | ||
81 | return 0; | ||
82 | } | ||
83 | EXPORT_SYMBOL(rdc_gpio_direction_input); | ||
84 | |||
85 | int rdc_gpio_direction_output(unsigned gpio, int value) | ||
86 | { | ||
87 | return 0; | ||
88 | } | ||
89 | EXPORT_SYMBOL(rdc_gpio_direction_output); | ||
90 | |||
91 | |||