bfin_sir.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /*
  2. * Blackfin Infra-red Driver
  3. *
  4. * Copyright 2006-2008 Analog Devices Inc.
  5. *
  6. * Enter bugs at http://blackfin.uclinux.org/
  7. *
  8. * Licensed under the GPL-2 or later.
  9. *
  10. */
  11. #include <linux/serial.h>
  12. #include <asm/dma.h>
  13. #include <asm/portmux.h>
  14. #define SIR_UART_GET_CHAR(port) bfin_read16((port)->membase + OFFSET_RBR)
  15. #define SIR_UART_GET_DLL(port) bfin_read16((port)->membase + OFFSET_DLL)
  16. #define SIR_UART_GET_IER(port) bfin_read16((port)->membase + OFFSET_IER_SET)
  17. #define SIR_UART_GET_DLH(port) bfin_read16((port)->membase + OFFSET_DLH)
  18. #define SIR_UART_GET_LCR(port) bfin_read16((port)->membase + OFFSET_LCR)
  19. #define SIR_UART_GET_LSR(port) bfin_read16((port)->membase + OFFSET_LSR)
  20. #define SIR_UART_GET_GCTL(port) bfin_read16((port)->membase + OFFSET_GCTL)
  21. #define SIR_UART_PUT_CHAR(port, v) bfin_write16(((port)->membase + OFFSET_THR), v)
  22. #define SIR_UART_PUT_DLL(port, v) bfin_write16(((port)->membase + OFFSET_DLL), v)
  23. #define SIR_UART_SET_IER(port, v) bfin_write16(((port)->membase + OFFSET_IER_SET), v)
  24. #define SIR_UART_CLEAR_IER(port, v) bfin_write16(((port)->membase + OFFSET_IER_CLEAR), v)
  25. #define SIR_UART_PUT_DLH(port, v) bfin_write16(((port)->membase + OFFSET_DLH), v)
  26. #define SIR_UART_PUT_LSR(port, v) bfin_write16(((port)->membase + OFFSET_LSR), v)
  27. #define SIR_UART_PUT_LCR(port, v) bfin_write16(((port)->membase + OFFSET_LCR), v)
  28. #define SIR_UART_CLEAR_LSR(port) bfin_write16(((port)->membase + OFFSET_LSR), -1)
  29. #define SIR_UART_PUT_GCTL(port, v) bfin_write16(((port)->membase + OFFSET_GCTL), v)
  30. #ifdef CONFIG_SIR_BFIN_DMA
  31. struct dma_rx_buf {
  32. char *buf;
  33. int head;
  34. int tail;
  35. };
  36. #endif /* CONFIG_SIR_BFIN_DMA */
  37. struct bfin_sir_port {
  38. unsigned char __iomem *membase;
  39. unsigned int irq;
  40. unsigned int lsr;
  41. unsigned long clk;
  42. struct net_device *dev;
  43. #ifdef CONFIG_SIR_BFIN_DMA
  44. int tx_done;
  45. struct dma_rx_buf rx_dma_buf;
  46. struct timer_list rx_dma_timer;
  47. int rx_dma_nrows;
  48. #endif /* CONFIG_SIR_BFIN_DMA */
  49. unsigned int tx_dma_channel;
  50. unsigned int rx_dma_channel;
  51. };
  52. struct bfin_sir_port sir_ports[BFIN_UART_NR_PORTS];
  53. struct bfin_sir_port_res {
  54. unsigned long base_addr;
  55. int irq;
  56. unsigned int rx_dma_channel;
  57. unsigned int tx_dma_channel;
  58. };
  59. struct bfin_sir_port_res bfin_sir_port_resource[] = {
  60. #ifdef CONFIG_BFIN_SIR0
  61. {
  62. 0xFFC00400,
  63. IRQ_UART0_RX,
  64. CH_UART0_RX,
  65. CH_UART0_TX,
  66. },
  67. #endif
  68. #ifdef CONFIG_BFIN_SIR1
  69. {
  70. 0xFFC02000,
  71. IRQ_UART1_RX,
  72. CH_UART1_RX,
  73. CH_UART1_TX,
  74. },
  75. #endif
  76. #ifdef CONFIG_BFIN_SIR2
  77. {
  78. 0xFFC02100,
  79. IRQ_UART2_RX,
  80. CH_UART2_RX,
  81. CH_UART2_TX,
  82. },
  83. #endif
  84. #ifdef CONFIG_BFIN_SIR3
  85. {
  86. 0xFFC03100,
  87. IRQ_UART3_RX,
  88. CH_UART3_RX,
  89. CH_UART3_TX,
  90. },
  91. #endif
  92. };
  93. int nr_sirs = ARRAY_SIZE(bfin_sir_port_resource);
  94. struct bfin_sir_self {
  95. struct bfin_sir_port *sir_port;
  96. spinlock_t lock;
  97. unsigned int open;
  98. int speed;
  99. int newspeed;
  100. struct sk_buff *txskb;
  101. struct sk_buff *rxskb;
  102. struct net_device_stats stats;
  103. struct device *dev;
  104. struct irlap_cb *irlap;
  105. struct qos_info qos;
  106. iobuff_t tx_buff;
  107. iobuff_t rx_buff;
  108. struct work_struct work;
  109. int mtt;
  110. };
  111. #define DRIVER_NAME "bfin_sir"
  112. static void bfin_sir_hw_init(void)
  113. {
  114. #ifdef CONFIG_BFIN_SIR0
  115. peripheral_request(P_UART0_TX, DRIVER_NAME);
  116. peripheral_request(P_UART0_RX, DRIVER_NAME);
  117. #endif
  118. #ifdef CONFIG_BFIN_SIR1
  119. peripheral_request(P_UART1_TX, DRIVER_NAME);
  120. peripheral_request(P_UART1_RX, DRIVER_NAME);
  121. #endif
  122. #ifdef CONFIG_BFIN_SIR2
  123. peripheral_request(P_UART2_TX, DRIVER_NAME);
  124. peripheral_request(P_UART2_RX, DRIVER_NAME);
  125. #endif
  126. #ifdef CONFIG_BFIN_SIR3
  127. peripheral_request(P_UART3_TX, DRIVER_NAME);
  128. peripheral_request(P_UART3_RX, DRIVER_NAME);
  129. #endif
  130. SSYNC();
  131. }