2 * Blackfin Infra-red Driver
4 * Copyright 2006-2008 Analog Devices Inc.
6 * Enter bugs at http://blackfin.uclinux.org/
8 * Licensed under the GPL-2 or later.
12 #include <linux/serial.h>
14 #include <asm/portmux.h>
16 #define SIR_UART_GET_CHAR(port) bfin_read16((port)->membase + OFFSET_RBR)
17 #define SIR_UART_GET_DLL(port) bfin_read16((port)->membase + OFFSET_DLL)
18 #define SIR_UART_GET_IER(port) bfin_read16((port)->membase + OFFSET_IER_SET)
19 #define SIR_UART_GET_DLH(port) bfin_read16((port)->membase + OFFSET_DLH)
20 #define SIR_UART_GET_LCR(port) bfin_read16((port)->membase + OFFSET_LCR)
21 #define SIR_UART_GET_LSR(port) bfin_read16((port)->membase + OFFSET_LSR)
22 #define SIR_UART_GET_GCTL(port) bfin_read16((port)->membase + OFFSET_GCTL)
24 #define SIR_UART_PUT_CHAR(port, v) bfin_write16(((port)->membase + OFFSET_THR), v)
25 #define SIR_UART_PUT_DLL(port, v) bfin_write16(((port)->membase + OFFSET_DLL), v)
26 #define SIR_UART_SET_IER(port, v) bfin_write16(((port)->membase + OFFSET_IER_SET), v)
27 #define SIR_UART_CLEAR_IER(port, v) bfin_write16(((port)->membase + OFFSET_IER_CLEAR), v)
28 #define SIR_UART_PUT_DLH(port, v) bfin_write16(((port)->membase + OFFSET_DLH), v)
29 #define SIR_UART_PUT_LSR(port, v) bfin_write16(((port)->membase + OFFSET_LSR), v)
30 #define SIR_UART_PUT_LCR(port, v) bfin_write16(((port)->membase + OFFSET_LCR), v)
31 #define SIR_UART_CLEAR_LSR(port) bfin_write16(((port)->membase + OFFSET_LSR), -1)
32 #define SIR_UART_PUT_GCTL(port, v) bfin_write16(((port)->membase + OFFSET_GCTL), v)
34 #ifdef CONFIG_SIR_BFIN_DMA
40 #endif /* CONFIG_SIR_BFIN_DMA */
42 struct bfin_sir_port
{
43 unsigned char __iomem
*membase
;
47 struct net_device
*dev
;
48 #ifdef CONFIG_SIR_BFIN_DMA
50 struct dma_rx_buf rx_dma_buf
;
51 struct timer_list rx_dma_timer
;
53 #endif /* CONFIG_SIR_BFIN_DMA */
54 unsigned int tx_dma_channel
;
55 unsigned int rx_dma_channel
;
58 struct bfin_sir_port sir_ports
[BFIN_UART_NR_PORTS
];
60 struct bfin_sir_port_res
{
61 unsigned long base_addr
;
63 unsigned int rx_dma_channel
;
64 unsigned int tx_dma_channel
;
67 struct bfin_sir_port_res bfin_sir_port_resource
[] = {
68 #ifdef CONFIG_BFIN_SIR0
76 #ifdef CONFIG_BFIN_SIR1
84 #ifdef CONFIG_BFIN_SIR2
92 #ifdef CONFIG_BFIN_SIR3
102 int nr_sirs
= ARRAY_SIZE(bfin_sir_port_resource
);
104 struct bfin_sir_self
{
105 struct bfin_sir_port
*sir_port
;
111 struct sk_buff
*txskb
;
112 struct sk_buff
*rxskb
;
113 struct net_device_stats stats
;
115 struct irlap_cb
*irlap
;
121 struct work_struct work
;
125 #define DRIVER_NAME "bfin_sir"
127 static int bfin_sir_hw_init(void)
130 #ifdef CONFIG_BFIN_SIR0
131 ret
= peripheral_request(P_UART0_TX
, DRIVER_NAME
);
134 ret
= peripheral_request(P_UART0_RX
, DRIVER_NAME
);
139 #ifdef CONFIG_BFIN_SIR1
140 ret
= peripheral_request(P_UART1_TX
, DRIVER_NAME
);
143 ret
= peripheral_request(P_UART1_RX
, DRIVER_NAME
);
148 #ifdef CONFIG_BFIN_SIR2
149 ret
= peripheral_request(P_UART2_TX
, DRIVER_NAME
);
152 ret
= peripheral_request(P_UART2_RX
, DRIVER_NAME
);
157 #ifdef CONFIG_BFIN_SIR3
158 ret
= peripheral_request(P_UART3_TX
, DRIVER_NAME
);
161 ret
= peripheral_request(P_UART3_RX
, DRIVER_NAME
);