cpm_uart.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. /*
  2. * linux/drivers/serial/cpm_uart.h
  3. *
  4. * Driver for CPM (SCC/SMC) serial ports
  5. *
  6. * Copyright (C) 2004 Freescale Semiconductor, Inc.
  7. *
  8. * 2006 (c) MontaVista Software, Inc.
  9. * Vitaly Bordug <vbordug@ru.mvista.com>
  10. *
  11. * This file is licensed under the terms of the GNU General Public License
  12. * version 2. This program is licensed "as is" without any warranty of any
  13. * kind, whether express or implied.
  14. *
  15. */
  16. #ifndef CPM_UART_H
  17. #define CPM_UART_H
  18. #include <linux/platform_device.h>
  19. #include <linux/fs_uart_pd.h>
  20. #if defined(CONFIG_CPM2)
  21. #include "cpm_uart_cpm2.h"
  22. #elif defined(CONFIG_8xx)
  23. #include "cpm_uart_cpm1.h"
  24. #endif
  25. #define SERIAL_CPM_MAJOR 204
  26. #define SERIAL_CPM_MINOR 46
  27. #define IS_SMC(pinfo) (pinfo->flags & FLAG_SMC)
  28. #define IS_DISCARDING(pinfo) (pinfo->flags & FLAG_DISCARDING)
  29. #define FLAG_DISCARDING 0x00000004 /* when set, don't discard */
  30. #define FLAG_SMC 0x00000002
  31. #define FLAG_CONSOLE 0x00000001
  32. #define UART_SMC1 fsid_smc1_uart
  33. #define UART_SMC2 fsid_smc2_uart
  34. #define UART_SCC1 fsid_scc1_uart
  35. #define UART_SCC2 fsid_scc2_uart
  36. #define UART_SCC3 fsid_scc3_uart
  37. #define UART_SCC4 fsid_scc4_uart
  38. #define UART_NR fs_uart_nr
  39. #define RX_NUM_FIFO 4
  40. #define RX_BUF_SIZE 32
  41. #define TX_NUM_FIFO 4
  42. #define TX_BUF_SIZE 32
  43. #define SCC_WAIT_CLOSING 100
  44. struct uart_cpm_port {
  45. struct uart_port port;
  46. u16 rx_nrfifos;
  47. u16 rx_fifosize;
  48. u16 tx_nrfifos;
  49. u16 tx_fifosize;
  50. smc_t __iomem *smcp;
  51. smc_uart_t __iomem *smcup;
  52. scc_t __iomem *sccp;
  53. scc_uart_t __iomem *sccup;
  54. cbd_t __iomem *rx_bd_base;
  55. cbd_t __iomem *rx_cur;
  56. cbd_t __iomem *tx_bd_base;
  57. cbd_t __iomem *tx_cur;
  58. unsigned char *tx_buf;
  59. unsigned char *rx_buf;
  60. u32 flags;
  61. void (*set_lineif)(struct uart_cpm_port *);
  62. u8 brg;
  63. uint dp_addr;
  64. void *mem_addr;
  65. dma_addr_t dma_addr;
  66. u32 mem_size;
  67. /* helpers */
  68. int baud;
  69. int bits;
  70. /* Keep track of 'odd' SMC2 wirings */
  71. int is_portb;
  72. /* wait on close if needed */
  73. int wait_closing;
  74. /* value to combine with opcode to form cpm command */
  75. u32 command;
  76. };
  77. #ifndef CONFIG_PPC_CPM_NEW_BINDING
  78. extern int cpm_uart_port_map[UART_NR];
  79. #endif
  80. extern int cpm_uart_nr;
  81. extern struct uart_cpm_port cpm_uart_ports[UART_NR];
  82. /* these are located in their respective files */
  83. void cpm_line_cr_cmd(struct uart_cpm_port *port, int cmd);
  84. int cpm_uart_init_portdesc(void);
  85. int cpm_uart_allocbuf(struct uart_cpm_port *pinfo, unsigned int is_con);
  86. void cpm_uart_freebuf(struct uart_cpm_port *pinfo);
  87. void smc1_lineif(struct uart_cpm_port *pinfo);
  88. void smc2_lineif(struct uart_cpm_port *pinfo);
  89. void scc1_lineif(struct uart_cpm_port *pinfo);
  90. void scc2_lineif(struct uart_cpm_port *pinfo);
  91. void scc3_lineif(struct uart_cpm_port *pinfo);
  92. void scc4_lineif(struct uart_cpm_port *pinfo);
  93. /*
  94. virtual to phys transtalion
  95. */
  96. static inline unsigned long cpu2cpm_addr(void *addr,
  97. struct uart_cpm_port *pinfo)
  98. {
  99. int offset;
  100. u32 val = (u32)addr;
  101. u32 mem = (u32)pinfo->mem_addr;
  102. /* sane check */
  103. if (likely(val >= mem && val < mem + pinfo->mem_size)) {
  104. offset = val - mem;
  105. return pinfo->dma_addr + offset;
  106. }
  107. /* something nasty happened */
  108. BUG();
  109. return 0;
  110. }
  111. static inline void *cpm2cpu_addr(unsigned long addr,
  112. struct uart_cpm_port *pinfo)
  113. {
  114. int offset;
  115. u32 val = addr;
  116. u32 dma = (u32)pinfo->dma_addr;
  117. /* sane check */
  118. if (likely(val >= dma && val < dma + pinfo->mem_size)) {
  119. offset = val - dma;
  120. return pinfo->mem_addr + offset;
  121. }
  122. /* something nasty happened */
  123. BUG();
  124. return NULL;
  125. }
  126. #endif /* CPM_UART_H */