samsung.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /*
  2. * Driver for Samsung SoC onboard UARTs.
  3. *
  4. * Ben Dooks, Copyright (c) 2003-2008 Simtec Electronics
  5. * http://armlinux.simtec.co.uk/
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. */
  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. /* uart port features */
  22. unsigned int has_divslot:1;
  23. /* clock source control */
  24. int (*get_clksrc)(struct uart_port *, struct s3c24xx_uart_clksrc *clk);
  25. int (*set_clksrc)(struct uart_port *, struct s3c24xx_uart_clksrc *clk);
  26. /* uart controls */
  27. int (*reset_port)(struct uart_port *, struct s3c2410_uartcfg *);
  28. };
  29. struct s3c24xx_uart_port {
  30. unsigned char rx_claimed;
  31. unsigned char tx_claimed;
  32. unsigned int pm_level;
  33. unsigned long baudclk_rate;
  34. unsigned int rx_irq;
  35. unsigned int tx_irq;
  36. struct s3c24xx_uart_info *info;
  37. struct s3c24xx_uart_clksrc *clksrc;
  38. struct clk *clk;
  39. struct clk *baudclk;
  40. struct uart_port port;
  41. #ifdef CONFIG_CPU_FREQ
  42. struct notifier_block freq_transition;
  43. #endif
  44. };
  45. /* conversion functions */
  46. #define s3c24xx_dev_to_port(__dev) (struct uart_port *)dev_get_drvdata(__dev)
  47. #define s3c24xx_dev_to_cfg(__dev) (struct s3c2410_uartcfg *)((__dev)->platform_data)
  48. /* register access controls */
  49. #define portaddr(port, reg) ((port)->membase + (reg))
  50. #define rd_regb(port, reg) (__raw_readb(portaddr(port, reg)))
  51. #define rd_regl(port, reg) (__raw_readl(portaddr(port, reg)))
  52. #define wr_regb(port, reg, val) __raw_writeb(val, portaddr(port, reg))
  53. #define wr_regl(port, reg, val) __raw_writel(val, portaddr(port, reg))
  54. extern int s3c24xx_serial_probe(struct platform_device *dev,
  55. struct s3c24xx_uart_info *uart);
  56. extern int __devexit s3c24xx_serial_remove(struct platform_device *dev);
  57. extern int s3c24xx_serial_initconsole(struct platform_driver *drv,
  58. struct s3c24xx_uart_info **uart);
  59. extern int s3c24xx_serial_init(struct platform_driver *drv,
  60. struct s3c24xx_uart_info *info);
  61. #ifdef CONFIG_SERIAL_SAMSUNG_CONSOLE
  62. #define s3c24xx_console_init(__drv, __inf) \
  63. static int __init s3c_serial_console_init(void) \
  64. { \
  65. struct s3c24xx_uart_info *uinfo[CONFIG_SERIAL_SAMSUNG_UARTS]; \
  66. int i; \
  67. \
  68. for (i = 0; i < CONFIG_SERIAL_SAMSUNG_UARTS; i++) \
  69. uinfo[i] = __inf; \
  70. return s3c24xx_serial_initconsole(__drv, uinfo); \
  71. } \
  72. \
  73. console_initcall(s3c_serial_console_init)
  74. #else
  75. #define s3c24xx_console_init(drv, inf) extern void no_console(void)
  76. #endif
  77. #ifdef CONFIG_SERIAL_SAMSUNG_DEBUG
  78. extern void printascii(const char *);
  79. static void dbg(const char *fmt, ...)
  80. {
  81. va_list va;
  82. char buff[256];
  83. va_start(va, fmt);
  84. vsprintf(buff, fmt, va);
  85. va_end(va);
  86. printascii(buff);
  87. }
  88. #else
  89. #define dbg(x...) do { } while (0)
  90. #endif