cpm_uart.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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. */
  9. #ifndef CPM_UART_H
  10. #define CPM_UART_H
  11. #include <linux/config.h>
  12. #include <linux/platform_device.h>
  13. #include <linux/fs_uart_pd.h>
  14. #if defined(CONFIG_CPM2)
  15. #include "cpm_uart_cpm2.h"
  16. #elif defined(CONFIG_8xx)
  17. #include "cpm_uart_cpm1.h"
  18. #endif
  19. #define SERIAL_CPM_MAJOR 204
  20. #define SERIAL_CPM_MINOR 46
  21. #define IS_SMC(pinfo) (pinfo->flags & FLAG_SMC)
  22. #define IS_DISCARDING(pinfo) (pinfo->flags & FLAG_DISCARDING)
  23. #define FLAG_DISCARDING 0x00000004 /* when set, don't discard */
  24. #define FLAG_SMC 0x00000002
  25. #define FLAG_CONSOLE 0x00000001
  26. #define UART_SMC1 fsid_smc1_uart
  27. #define UART_SMC2 fsid_smc2_uart
  28. #define UART_SCC1 fsid_scc1_uart
  29. #define UART_SCC2 fsid_scc2_uart
  30. #define UART_SCC3 fsid_scc3_uart
  31. #define UART_SCC4 fsid_scc4_uart
  32. #define UART_NR fs_uart_nr
  33. #define RX_NUM_FIFO 4
  34. #define RX_BUF_SIZE 32
  35. #define TX_NUM_FIFO 4
  36. #define TX_BUF_SIZE 32
  37. #define SCC_WAIT_CLOSING 100
  38. struct uart_cpm_port {
  39. struct uart_port port;
  40. u16 rx_nrfifos;
  41. u16 rx_fifosize;
  42. u16 tx_nrfifos;
  43. u16 tx_fifosize;
  44. smc_t *smcp;
  45. smc_uart_t *smcup;
  46. scc_t *sccp;
  47. scc_uart_t *sccup;
  48. volatile cbd_t *rx_bd_base;
  49. volatile cbd_t *rx_cur;
  50. volatile cbd_t *tx_bd_base;
  51. volatile cbd_t *tx_cur;
  52. unsigned char *tx_buf;
  53. unsigned char *rx_buf;
  54. u32 flags;
  55. void (*set_lineif)(struct uart_cpm_port *);
  56. u8 brg;
  57. uint dp_addr;
  58. void *mem_addr;
  59. dma_addr_t dma_addr;
  60. u32 mem_size;
  61. /* helpers */
  62. int baud;
  63. int bits;
  64. /* Keep track of 'odd' SMC2 wirings */
  65. int is_portb;
  66. /* wait on close if needed */
  67. int wait_closing;
  68. };
  69. extern int cpm_uart_port_map[UART_NR];
  70. extern int cpm_uart_nr;
  71. extern struct uart_cpm_port cpm_uart_ports[UART_NR];
  72. /* these are located in their respective files */
  73. void cpm_line_cr_cmd(int line, int cmd);
  74. int cpm_uart_init_portdesc(void);
  75. int cpm_uart_allocbuf(struct uart_cpm_port *pinfo, unsigned int is_con);
  76. void cpm_uart_freebuf(struct uart_cpm_port *pinfo);
  77. void smc1_lineif(struct uart_cpm_port *pinfo);
  78. void smc2_lineif(struct uart_cpm_port *pinfo);
  79. void scc1_lineif(struct uart_cpm_port *pinfo);
  80. void scc2_lineif(struct uart_cpm_port *pinfo);
  81. void scc3_lineif(struct uart_cpm_port *pinfo);
  82. void scc4_lineif(struct uart_cpm_port *pinfo);
  83. /*
  84. virtual to phys transtalion
  85. */
  86. static inline unsigned long cpu2cpm_addr(void* addr, struct uart_cpm_port *pinfo)
  87. {
  88. int offset;
  89. u32 val = (u32)addr;
  90. /* sane check */
  91. if ((val >= (u32)pinfo->mem_addr) &&
  92. (val<((u32)pinfo->mem_addr + pinfo->mem_size))) {
  93. offset = val - (u32)pinfo->mem_addr;
  94. return pinfo->dma_addr+offset;
  95. }
  96. printk("%s(): address %x to translate out of range!\n", __FUNCTION__, val);
  97. return 0;
  98. }
  99. static inline void *cpm2cpu_addr(unsigned long addr, struct uart_cpm_port *pinfo)
  100. {
  101. int offset;
  102. u32 val = addr;
  103. /* sane check */
  104. if ((val >= pinfo->dma_addr) &&
  105. (val<(pinfo->dma_addr + pinfo->mem_size))) {
  106. offset = val - (u32)pinfo->dma_addr;
  107. return (void*)(pinfo->mem_addr+offset);
  108. }
  109. printk("%s(): address %x to translate out of range!\n", __FUNCTION__, val);
  110. return 0;
  111. }
  112. #endif /* CPM_UART_H */