samsung.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. // SPDX-License-Identifier: GPL-2.0
  2. #ifndef __SAMSUNG_H
  3. #define __SAMSUNG_H
  4. /*
  5. * Driver for Samsung SoC onboard UARTs.
  6. *
  7. * Ben Dooks, Copyright (c) 2003-2008 Simtec Electronics
  8. * http://armlinux.simtec.co.uk/
  9. */
  10. #include <linux/dmaengine.h>
  11. struct s3c24xx_uart_info {
  12. char *name;
  13. unsigned int type;
  14. unsigned int fifosize;
  15. unsigned long rx_fifomask;
  16. unsigned long rx_fifoshift;
  17. unsigned long rx_fifofull;
  18. unsigned long tx_fifomask;
  19. unsigned long tx_fifoshift;
  20. unsigned long tx_fifofull;
  21. unsigned int def_clk_sel;
  22. unsigned long num_clks;
  23. unsigned long clksel_mask;
  24. unsigned long clksel_shift;
  25. /* uart port features */
  26. unsigned int has_divslot:1;
  27. /* uart controls */
  28. int (*reset_port)(struct uart_port *, struct s3c2410_uartcfg *);
  29. };
  30. struct s3c24xx_serial_drv_data {
  31. struct s3c24xx_uart_info *info;
  32. struct s3c2410_uartcfg *def_cfg;
  33. unsigned int fifosize[CONFIG_SERIAL_SAMSUNG_UARTS];
  34. };
  35. struct s3c24xx_uart_dma {
  36. unsigned int rx_chan_id;
  37. unsigned int tx_chan_id;
  38. struct dma_slave_config rx_conf;
  39. struct dma_slave_config tx_conf;
  40. struct dma_chan *rx_chan;
  41. struct dma_chan *tx_chan;
  42. dma_addr_t rx_addr;
  43. dma_addr_t tx_addr;
  44. dma_cookie_t rx_cookie;
  45. dma_cookie_t tx_cookie;
  46. char *rx_buf;
  47. dma_addr_t tx_transfer_addr;
  48. size_t rx_size;
  49. size_t tx_size;
  50. struct dma_async_tx_descriptor *tx_desc;
  51. struct dma_async_tx_descriptor *rx_desc;
  52. int tx_bytes_requested;
  53. int rx_bytes_requested;
  54. };
  55. struct s3c24xx_uart_port {
  56. unsigned char rx_claimed;
  57. unsigned char tx_claimed;
  58. unsigned int pm_level;
  59. unsigned long baudclk_rate;
  60. unsigned int min_dma_size;
  61. unsigned int rx_irq;
  62. unsigned int tx_irq;
  63. unsigned int tx_in_progress;
  64. unsigned int tx_mode;
  65. unsigned int rx_mode;
  66. struct s3c24xx_uart_info *info;
  67. struct clk *clk;
  68. struct clk *baudclk;
  69. struct uart_port port;
  70. struct s3c24xx_serial_drv_data *drv_data;
  71. /* reference to platform data */
  72. struct s3c2410_uartcfg *cfg;
  73. struct s3c24xx_uart_dma *dma;
  74. #ifdef CONFIG_ARM_S3C24XX_CPUFREQ
  75. struct notifier_block freq_transition;
  76. #endif
  77. };
  78. /* conversion functions */
  79. #define s3c24xx_dev_to_port(__dev) dev_get_drvdata(__dev)
  80. /* register access controls */
  81. #define portaddr(port, reg) ((port)->membase + (reg))
  82. #define portaddrl(port, reg) \
  83. ((unsigned long *)(unsigned long)((port)->membase + (reg)))
  84. #define rd_regb(port, reg) (readb_relaxed(portaddr(port, reg)))
  85. #define rd_regl(port, reg) (readl_relaxed(portaddr(port, reg)))
  86. #define wr_regb(port, reg, val) writeb_relaxed(val, portaddr(port, reg))
  87. #define wr_regl(port, reg, val) writel_relaxed(val, portaddr(port, reg))
  88. /* Byte-order aware bit setting/clearing functions. */
  89. static inline void s3c24xx_set_bit(struct uart_port *port, int idx,
  90. unsigned int reg)
  91. {
  92. unsigned long flags;
  93. u32 val;
  94. local_irq_save(flags);
  95. val = rd_regl(port, reg);
  96. val |= (1 << idx);
  97. wr_regl(port, reg, val);
  98. local_irq_restore(flags);
  99. }
  100. static inline void s3c24xx_clear_bit(struct uart_port *port, int idx,
  101. unsigned int reg)
  102. {
  103. unsigned long flags;
  104. u32 val;
  105. local_irq_save(flags);
  106. val = rd_regl(port, reg);
  107. val &= ~(1 << idx);
  108. wr_regl(port, reg, val);
  109. local_irq_restore(flags);
  110. }
  111. #endif