spi-topcliff-pch: Fix issue for transmitting over 4KByte
[zen-stable.git] / include / linux / scx200_gpio.h
blobece4e553e9ac26d61ce77eb31bc4e4a1b6874be3
1 u32 scx200_gpio_configure(unsigned index, u32 set, u32 clear);
3 extern unsigned scx200_gpio_base;
4 extern unsigned long scx200_gpio_shadow[2];
5 extern struct nsc_gpio_ops scx200_gpio_ops;
7 #define scx200_gpio_present() (scx200_gpio_base!=0)
9 /* Definitions to make sure I do the same thing in all functions */
10 #define __SCx200_GPIO_BANK unsigned bank = index>>5
11 #define __SCx200_GPIO_IOADDR unsigned short ioaddr = scx200_gpio_base+0x10*bank
12 #define __SCx200_GPIO_SHADOW unsigned long *shadow = scx200_gpio_shadow+bank
13 #define __SCx200_GPIO_INDEX index &= 31
15 #define __SCx200_GPIO_OUT __asm__ __volatile__("outsl":"=mS" (shadow):"d" (ioaddr), "0" (shadow))
17 /* returns the value of the GPIO pin */
19 static inline int scx200_gpio_get(unsigned index) {
20 __SCx200_GPIO_BANK;
21 __SCx200_GPIO_IOADDR + 0x04;
22 __SCx200_GPIO_INDEX;
24 return (inl(ioaddr) & (1<<index)) ? 1 : 0;
27 /* return the value driven on the GPIO signal (the value that will be
28 driven if the GPIO is configured as an output, it might not be the
29 state of the GPIO right now if the GPIO is configured as an input) */
31 static inline int scx200_gpio_current(unsigned index) {
32 __SCx200_GPIO_BANK;
33 __SCx200_GPIO_INDEX;
35 return (scx200_gpio_shadow[bank] & (1<<index)) ? 1 : 0;
38 /* drive the GPIO signal high */
40 static inline void scx200_gpio_set_high(unsigned index) {
41 __SCx200_GPIO_BANK;
42 __SCx200_GPIO_IOADDR;
43 __SCx200_GPIO_SHADOW;
44 __SCx200_GPIO_INDEX;
45 set_bit(index, shadow); /* __set_bit()? */
46 __SCx200_GPIO_OUT;
49 /* drive the GPIO signal low */
51 static inline void scx200_gpio_set_low(unsigned index) {
52 __SCx200_GPIO_BANK;
53 __SCx200_GPIO_IOADDR;
54 __SCx200_GPIO_SHADOW;
55 __SCx200_GPIO_INDEX;
56 clear_bit(index, shadow); /* __clear_bit()? */
57 __SCx200_GPIO_OUT;
60 /* drive the GPIO signal to state */
62 static inline void scx200_gpio_set(unsigned index, int state) {
63 __SCx200_GPIO_BANK;
64 __SCx200_GPIO_IOADDR;
65 __SCx200_GPIO_SHADOW;
66 __SCx200_GPIO_INDEX;
67 if (state)
68 set_bit(index, shadow);
69 else
70 clear_bit(index, shadow);
71 __SCx200_GPIO_OUT;
74 /* toggle the GPIO signal */
75 static inline void scx200_gpio_change(unsigned index) {
76 __SCx200_GPIO_BANK;
77 __SCx200_GPIO_IOADDR;
78 __SCx200_GPIO_SHADOW;
79 __SCx200_GPIO_INDEX;
80 change_bit(index, shadow);
81 __SCx200_GPIO_OUT;
84 #undef __SCx200_GPIO_BANK
85 #undef __SCx200_GPIO_IOADDR
86 #undef __SCx200_GPIO_SHADOW
87 #undef __SCx200_GPIO_INDEX
88 #undef __SCx200_GPIO_OUT