samsung.h 3.3 KB

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