1 #include <linux/spinlock.h>
3 u32
scx200_gpio_configure(unsigned index
, u32 set
, u32 clear
);
5 extern unsigned scx200_gpio_base
;
6 extern long scx200_gpio_shadow
[2];
8 #define scx200_gpio_present() (scx200_gpio_base!=0)
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
16 #define __SCx200_GPIO_OUT __asm__ __volatile__("outsl":"=mS" (shadow):"d" (ioaddr), "0" (shadow))
18 /* returns the value of the GPIO pin */
20 static inline int scx200_gpio_get(unsigned index
) {
22 __SCx200_GPIO_IOADDR
+ 0x04;
25 return (inl(ioaddr
) & (1<<index
)) ? 1 : 0;
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) */
32 static inline int scx200_gpio_current(unsigned index
) {
36 return (scx200_gpio_shadow
[bank
] & (1<<index
)) ? 1 : 0;
39 /* drive the GPIO signal high */
41 static inline void scx200_gpio_set_high(unsigned index
) {
46 set_bit(index
, shadow
);
50 /* drive the GPIO signal low */
52 static inline void scx200_gpio_set_low(unsigned index
) {
57 clear_bit(index
, shadow
);
61 /* drive the GPIO signal to state */
63 static inline void scx200_gpio_set(unsigned index
, int state
) {
69 set_bit(index
, shadow
);
71 clear_bit(index
, shadow
);
75 /* toggle the GPIO signal */
76 static inline void scx200_gpio_change(unsigned index
) {
81 change_bit(index
, shadow
);
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