1 #ifndef __SWITCH_GPIO_H
2 #define __SWITCH_GPIO_H
3 #include <linux/interrupt.h>
6 #include <linux/ssb/ssb_embedded.h>
8 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25)
9 #define ssb ssb_bcm47xx
12 extern struct ssb_bus ssb;
15 static inline u32 gpio_in(void)
17 return ssb_gpio_in(&ssb, ~0);
20 static inline u32 gpio_out(u32 mask, u32 value)
22 return ssb_gpio_out(&ssb, mask, value);
25 static inline u32 gpio_outen(u32 mask, u32 value)
27 return ssb_gpio_outen(&ssb, mask, value);
30 static inline u32 gpio_control(u32 mask, u32 value)
32 return ssb_gpio_control(&ssb, mask, value);
35 static inline u32 gpio_intmask(u32 mask, u32 value)
37 return ssb_gpio_intmask(&ssb, mask, value);
40 static inline u32 gpio_intpolarity(u32 mask, u32 value)
42 return ssb_gpio_polarity(&ssb, mask, value);
53 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
59 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
60 #define sbh bcm947xx_sbh
61 #define sbh_lock bcm947xx_sbh_lock
65 extern spinlock_t sbh_lock;
67 #define gpio_in() sb_gpioin(sbh)
68 #define gpio_out(mask, value) sb_gpioout(sbh, mask, ((value) & (mask)), GPIO_DRV_PRIORITY)
69 #define gpio_outen(mask, value) sb_gpioouten(sbh, mask, value, GPIO_DRV_PRIORITY)
70 #define gpio_control(mask, value) sb_gpiocontrol(sbh, mask, value, GPIO_DRV_PRIORITY)
71 #define gpio_intmask(mask, value) sb_gpiointmask(sbh, mask, value, GPIO_DRV_PRIORITY)
72 #define gpio_intpolarity(mask, value) sb_gpiointpolarity(sbh, mask, value, GPIO_DRV_PRIORITY)
74 #endif /* BCMDRIVER */
75 #endif /* __SWITCH_GPIO_H */