3 #include <linux/interrupt.h>
6 #include <linux/ssb/ssb_embedded.h>
8 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25)
9 #include <linux/gpio.h>
10 #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 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)
36 static inline u32
gpio_intmask(u32 mask
, u32 value
)
38 return ssb_gpio_intmask(&ssb
, mask
, value
);
42 static inline u32
gpio_intpolarity(u32 mask
, u32 value
)
44 return ssb_gpio_polarity(&ssb
, mask
, value
);
47 static inline u32
__ssb_write32_masked(struct ssb_device
*dev
, u16 offset
,
51 value
|= ssb_read32(dev
, offset
) & ~mask
;
52 ssb_write32(dev
, offset
, value
);
56 static void gpio_set_irqenable(int enabled
, irqreturn_t (*handler
)(int, void *))
60 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25)
62 if (irq
== -EINVAL
) return;
65 irq
= ssb_mips_irq(ssb
.chipco
.dev
) + 2;
66 else if (ssb
.extif
.dev
)
67 irq
= ssb_mips_irq(ssb
.extif
.dev
) + 2;
72 if (request_irq(irq
, handler
, IRQF_SHARED
| IRQF_SAMPLE_RANDOM
, "gpio", handler
))
75 free_irq(irq
, handler
);
79 __ssb_write32_masked(ssb
.chipco
.dev
, SSB_CHIPCO_IRQMASK
, SSB_CHIPCO_IRQ_GPIO
, (enabled
? SSB_CHIPCO_IRQ_GPIO
: 0));
90 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
96 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
97 #define sbh bcm947xx_sbh
98 #define sbh_lock bcm947xx_sbh_lock
102 extern spinlock_t sbh_lock
;
104 #define gpio_in() sb_gpioin(sbh)
105 #define gpio_out(mask, value) sb_gpioout(sbh, mask, ((value) & (mask)), GPIO_DRV_PRIORITY)
106 #define gpio_outen(mask, value) sb_gpioouten(sbh, mask, value, GPIO_DRV_PRIORITY)
107 #define gpio_control(mask, value) sb_gpiocontrol(sbh, mask, value, GPIO_DRV_PRIORITY)
108 #define gpio_intmask(mask, value) sb_gpiointmask(sbh, mask, value, GPIO_DRV_PRIORITY)
109 #define gpio_intpolarity(mask, value) sb_gpiointpolarity(sbh, mask, value, GPIO_DRV_PRIORITY)
111 static void gpio_set_irqenable(int enabled
, irqreturn_t (*handler
)(int, void *, struct pt_regs
*))
113 unsigned int coreidx
;
118 spin_lock_irqsave(sbh_lock
, flags
);
119 coreidx
= sb_coreidx(sbh
);
121 irq
= sb_irq(sbh
) + 2;
123 request_irq(irq
, handler
, SA_SHIRQ
| SA_SAMPLE_RANDOM
, "gpio", handler
);
125 free_irq(irq
, handler
);
127 if ((cc
= sb_setcore(sbh
, SB_CC
, 0))) {
130 intmask
= readl(&cc
->intmask
);
135 writel(intmask
, &cc
->intmask
);
137 sb_setcoreidx(sbh
, coreidx
);
138 spin_unlock_irqrestore(sbh_lock
, flags
);
141 #endif /* BCMDRIVER */
143 #define EXTIF_ADDR 0x1f000000
144 #define EXTIF_UART (EXTIF_ADDR + 0x00800000)
146 #define GPIO_TYPE_NORMAL (0x0 << 24)
147 #define GPIO_TYPE_EXTIF (0x1 << 24)
148 #define GPIO_TYPE_MASK (0xf << 24)
150 static inline void gpio_set_extif(int gpio
, int value
)
152 volatile u8
*addr
= (volatile u8
*) KSEG1ADDR(EXTIF_UART
) + (gpio
& ~GPIO_TYPE_MASK
);
159 #endif /* __DIAG_GPIO_H */
This page took 0.050521 seconds and 5 git commands to generate.