blob: 29cbde8501ed8e09750f771204dfe9fc38503d34 [file] [log] [blame]
Graff Yangd510fe72009-05-12 13:47:54 -07001/*
2 * Blackfin Infra-red Driver
3 *
4 * Copyright 2006-2009 Analog Devices Inc.
5 *
6 * Enter bugs at http://blackfin.uclinux.org/
7 *
8 * Licensed under the GPL-2 or later.
9 *
10 */
11
12#include <linux/serial.h>
13#include <linux/module.h>
14#include <linux/netdevice.h>
15#include <linux/interrupt.h>
16#include <linux/delay.h>
17#include <linux/platform_device.h>
18#include <linux/dma-mapping.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090019#include <linux/slab.h>
Graff Yangd510fe72009-05-12 13:47:54 -070020
21#include <net/irda/irda.h>
22#include <net/irda/wrapper.h>
23#include <net/irda/irda_device.h>
24
25#include <asm/irq.h>
26#include <asm/cacheflush.h>
27#include <asm/dma.h>
28#include <asm/portmux.h>
Mike Frysinger709465d2010-10-28 15:43:50 -040029#undef DRIVER_NAME
Graff Yangd510fe72009-05-12 13:47:54 -070030
31#ifdef CONFIG_SIR_BFIN_DMA
32struct dma_rx_buf {
33 char *buf;
34 int head;
35 int tail;
36};
37#endif
38
39struct bfin_sir_port {
40 unsigned char __iomem *membase;
41 unsigned int irq;
42 unsigned int lsr;
43 unsigned long clk;
44 struct net_device *dev;
45#ifdef CONFIG_SIR_BFIN_DMA
46 int tx_done;
47 struct dma_rx_buf rx_dma_buf;
48 struct timer_list rx_dma_timer;
49 int rx_dma_nrows;
50#endif
51 unsigned int tx_dma_channel;
52 unsigned int rx_dma_channel;
53};
54
55struct bfin_sir_port_res {
56 unsigned long base_addr;
57 int irq;
58 unsigned int rx_dma_channel;
59 unsigned int tx_dma_channel;
60};
61
62struct bfin_sir_self {
63 struct bfin_sir_port *sir_port;
64 spinlock_t lock;
65 unsigned int open;
66 int speed;
67 int newspeed;
68
69 struct sk_buff *txskb;
70 struct sk_buff *rxskb;
71 struct net_device_stats stats;
72 struct device *dev;
73 struct irlap_cb *irlap;
74 struct qos_info qos;
75
76 iobuff_t tx_buff;
77 iobuff_t rx_buff;
78
79 struct work_struct work;
80 int mtt;
81};
82
83#define DRIVER_NAME "bfin_sir"
84
Mike Frysinger229de612011-05-23 12:17:09 +000085#define port_membase(port) (((struct bfin_sir_port *)(port))->membase)
86#define get_lsr_cache(port) (((struct bfin_sir_port *)(port))->lsr)
87#define put_lsr_cache(port, v) (((struct bfin_sir_port *)(port))->lsr = (v))
88#include <asm/bfin_serial.h>
Graff Yangd510fe72009-05-12 13:47:54 -070089
90static const unsigned short per[][4] = {
91 /* rx pin tx pin NULL uart_number */
92 {P_UART0_RX, P_UART0_TX, 0, 0},
93 {P_UART1_RX, P_UART1_TX, 0, 1},
94 {P_UART2_RX, P_UART2_TX, 0, 2},
95 {P_UART3_RX, P_UART3_TX, 0, 3},
96};