diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /include/linux/scx200_gpio.h |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'include/linux/scx200_gpio.h')
-rw-r--r-- | include/linux/scx200_gpio.h | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/include/linux/scx200_gpio.h b/include/linux/scx200_gpio.h new file mode 100644 index 000000000000..30cdd648ba79 --- /dev/null +++ b/include/linux/scx200_gpio.h | |||
@@ -0,0 +1,96 @@ | |||
1 | #include <linux/spinlock.h> | ||
2 | |||
3 | u32 scx200_gpio_configure(int index, u32 set, u32 clear); | ||
4 | |||
5 | extern unsigned scx200_gpio_base; | ||
6 | extern long scx200_gpio_shadow[2]; | ||
7 | |||
8 | #define scx200_gpio_present() (scx200_gpio_base!=0) | ||
9 | |||
10 | /* Definitions to make sure I do the same thing in all functions */ | ||
11 | #define __SCx200_GPIO_BANK unsigned bank = index>>5 | ||
12 | #define __SCx200_GPIO_IOADDR unsigned short ioaddr = scx200_gpio_base+0x10*bank | ||
13 | #define __SCx200_GPIO_SHADOW long *shadow = scx200_gpio_shadow+bank | ||
14 | #define __SCx200_GPIO_INDEX index &= 31 | ||
15 | |||
16 | #define __SCx200_GPIO_OUT __asm__ __volatile__("outsl":"=mS" (shadow):"d" (ioaddr), "0" (shadow)) | ||
17 | |||
18 | /* returns the value of the GPIO pin */ | ||
19 | |||
20 | static inline int scx200_gpio_get(int index) { | ||
21 | __SCx200_GPIO_BANK; | ||
22 | __SCx200_GPIO_IOADDR + 0x04; | ||
23 | __SCx200_GPIO_INDEX; | ||
24 | |||
25 | return (inl(ioaddr) & (1<<index)) ? 1 : 0; | ||
26 | } | ||
27 | |||
28 | /* return the value driven on the GPIO signal (the value that will be | ||
29 | driven if the GPIO is configured as an output, it might not be the | ||
30 | state of the GPIO right now if the GPIO is configured as an input) */ | ||
31 | |||
32 | static inline int scx200_gpio_current(int index) { | ||
33 | __SCx200_GPIO_BANK; | ||
34 | __SCx200_GPIO_INDEX; | ||
35 | |||
36 | return (scx200_gpio_shadow[bank] & (1<<index)) ? 1 : 0; | ||
37 | } | ||
38 | |||
39 | /* drive the GPIO signal high */ | ||
40 | |||
41 | static inline void scx200_gpio_set_high(int index) { | ||
42 | __SCx200_GPIO_BANK; | ||
43 | __SCx200_GPIO_IOADDR; | ||
44 | __SCx200_GPIO_SHADOW; | ||
45 | __SCx200_GPIO_INDEX; | ||
46 | set_bit(index, shadow); | ||
47 | __SCx200_GPIO_OUT; | ||
48 | } | ||
49 | |||
50 | /* drive the GPIO signal low */ | ||
51 | |||
52 | static inline void scx200_gpio_set_low(int index) { | ||
53 | __SCx200_GPIO_BANK; | ||
54 | __SCx200_GPIO_IOADDR; | ||
55 | __SCx200_GPIO_SHADOW; | ||
56 | __SCx200_GPIO_INDEX; | ||
57 | clear_bit(index, shadow); | ||
58 | __SCx200_GPIO_OUT; | ||
59 | } | ||
60 | |||
61 | /* drive the GPIO signal to state */ | ||
62 | |||
63 | static inline void scx200_gpio_set(int index, int state) { | ||
64 | __SCx200_GPIO_BANK; | ||
65 | __SCx200_GPIO_IOADDR; | ||
66 | __SCx200_GPIO_SHADOW; | ||
67 | __SCx200_GPIO_INDEX; | ||
68 | if (state) | ||
69 | set_bit(index, shadow); | ||
70 | else | ||
71 | clear_bit(index, shadow); | ||
72 | __SCx200_GPIO_OUT; | ||
73 | } | ||
74 | |||
75 | /* toggle the GPIO signal */ | ||
76 | static inline void scx200_gpio_change(int index) { | ||
77 | __SCx200_GPIO_BANK; | ||
78 | __SCx200_GPIO_IOADDR; | ||
79 | __SCx200_GPIO_SHADOW; | ||
80 | __SCx200_GPIO_INDEX; | ||
81 | change_bit(index, shadow); | ||
82 | __SCx200_GPIO_OUT; | ||
83 | } | ||
84 | |||
85 | #undef __SCx200_GPIO_BANK | ||
86 | #undef __SCx200_GPIO_IOADDR | ||
87 | #undef __SCx200_GPIO_SHADOW | ||
88 | #undef __SCx200_GPIO_INDEX | ||
89 | #undef __SCx200_GPIO_OUT | ||
90 | |||
91 | /* | ||
92 | Local variables: | ||
93 | compile-command: "make -C ../.. bzImage modules" | ||
94 | c-basic-offset: 8 | ||
95 | End: | ||
96 | */ | ||