samsung.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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. dma_filter_fn fn;
  40. void *rx_param;
  41. void *tx_param;
  42. unsigned int rx_chan_id;
  43. unsigned int tx_chan_id;
  44. struct dma_slave_config rx_conf;
  45. struct dma_slave_config tx_conf;
  46. struct dma_chan *rx_chan;
  47. struct dma_chan *tx_chan;
  48. dma_addr_t rx_addr;
  49. dma_addr_t tx_addr;
  50. dma_cookie_t rx_cookie;
  51. dma_cookie_t tx_cookie;
  52. char *rx_buf;
  53. dma_addr_t tx_transfer_addr;
  54. size_t rx_size;
  55. size_t tx_size;
  56. struct dma_async_tx_descriptor *tx_desc;
  57. struct dma_async_tx_descriptor *rx_desc;
  58. int tx_bytes_requested;
  59. int rx_bytes_requested;
  60. };
  61. struct s3c24xx_uart_port {
  62. unsigned char rx_claimed;
  63. unsigned char tx_claimed;
  64. unsigned int pm_level;
  65. unsigned long baudclk_rate;
  66. unsigned int min_dma_size;
  67. unsigned int rx_irq;
  68. unsigned int tx_irq;
  69. unsigned int tx_in_progress;
  70. unsigned int tx_mode;
  71. unsigned int rx_mode;
  72. struct s3c24xx_uart_info *info;
  73. struct clk *clk;
  74. struct clk *baudclk;
  75. struct uart_port port;
  76. struct s3c24xx_serial_drv_data *drv_data;
  77. /* reference to platform data */
  78. struct s3c2410_uartcfg *cfg;
  79. struct s3c24xx_uart_dma *dma;
  80. #ifdef CONFIG_ARM_S3C24XX_CPUFREQ
  81. struct notifier_block freq_transition;
  82. #endif
  83. };
  84. /* conversion functions */
  85. #define s3c24xx_dev_to_port(__dev) dev_get_drvdata(__dev)
  86. /* register access controls */
  87. #define portaddr(port, reg) ((port)->membase + (reg))
  88. #define portaddrl(port, reg) \
  89. ((unsigned long *)(unsigned long)((port)->membase + (reg)))
  90. #define rd_regb(port, reg) (readb_relaxed(portaddr(port, reg)))
  91. #define rd_regl(port, reg) (readl_relaxed(portaddr(port, reg)))
  92. #define wr_regb(port, reg, val) writeb_relaxed(val, portaddr(port, reg))
  93. #define wr_regl(port, reg, val) writel_relaxed(val, portaddr(port, reg))
  94. /* Byte-order aware bit setting/clearing functions. */
  95. static inline void s3c24xx_set_bit(struct uart_port *port, int idx,
  96. unsigned int reg)
  97. {
  98. unsigned long flags;
  99. u32 val;
  100. local_irq_save(flags);
  101. val = rd_regl(port, reg);
  102. val |= (1 << idx);
  103. wr_regl(port, reg, val);
  104. local_irq_restore(flags);
  105. }
  106. static inline void s3c24xx_clear_bit(struct uart_port *port, int idx,
  107. unsigned int reg)
  108. {
  109. unsigned long flags;
  110. u32 val;
  111. local_irq_save(flags);
  112. val = rd_regl(port, reg);
  113. val &= ~(1 << idx);
  114. wr_regl(port, reg, val);
  115. local_irq_restore(flags);
  116. }
  117. #endif