| Graff Yang | d510fe7 | 2009-05-12 13:47:54 -0700 | [diff] [blame] | 1 | /* | 
|  | 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 Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 19 | #include <linux/slab.h> | 
| Graff Yang | d510fe7 | 2009-05-12 13:47:54 -0700 | [diff] [blame] | 20 |  | 
|  | 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 Frysinger | 709465d | 2010-10-28 15:43:50 -0400 | [diff] [blame] | 29 | #undef DRIVER_NAME | 
| Graff Yang | d510fe7 | 2009-05-12 13:47:54 -0700 | [diff] [blame] | 30 |  | 
|  | 31 | #ifdef CONFIG_SIR_BFIN_DMA | 
|  | 32 | struct dma_rx_buf { | 
|  | 33 | char *buf; | 
|  | 34 | int head; | 
|  | 35 | int tail; | 
|  | 36 | }; | 
|  | 37 | #endif | 
|  | 38 |  | 
|  | 39 | struct 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 |  | 
|  | 55 | struct 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 |  | 
|  | 62 | struct 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 Frysinger | 229de61 | 2011-05-23 12:17:09 +0000 | [diff] [blame] | 85 | #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 Yang | d510fe7 | 2009-05-12 13:47:54 -0700 | [diff] [blame] | 89 |  | 
|  | 90 | static 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 | }; |