s3c24a0.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /* linux/drivers/serial/s3c24a0.c
  2. *
  3. * Driver for Samsung S3C24A0 SoC onboard UARTs.
  4. *
  5. * Based on drivers/serial/s3c2410.c
  6. *
  7. * Author: Sandeep Patil <sandeep.patil@azingo.com>
  8. *
  9. * Ben Dooks, Copyright (c) 2003-2005,2008 Simtec Electronics
  10. * http://armlinux.simtec.co.uk/
  11. *
  12. * This program is free software; you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License version 2 as
  14. * published by the Free Software Foundation.
  15. */
  16. #include <linux/module.h>
  17. #include <linux/ioport.h>
  18. #include <linux/platform_device.h>
  19. #include <linux/init.h>
  20. #include <linux/serial_core.h>
  21. #include <linux/serial.h>
  22. #include <linux/io.h>
  23. #include <linux/irq.h>
  24. #include <mach/hardware.h>
  25. #include <plat/regs-serial.h>
  26. #include <mach/regs-gpio.h>
  27. #include "samsung.h"
  28. static int s3c24a0_serial_setsource(struct uart_port *port,
  29. struct s3c24xx_uart_clksrc *clk)
  30. {
  31. unsigned long ucon = rd_regl(port, S3C2410_UCON);
  32. if (strcmp(clk->name, "uclk") == 0)
  33. ucon |= S3C2410_UCON_UCLK;
  34. else
  35. ucon &= ~S3C2410_UCON_UCLK;
  36. wr_regl(port, S3C2410_UCON, ucon);
  37. return 0;
  38. }
  39. static int s3c24a0_serial_getsource(struct uart_port *port,
  40. struct s3c24xx_uart_clksrc *clk)
  41. {
  42. unsigned long ucon = rd_regl(port, S3C2410_UCON);
  43. clk->divisor = 1;
  44. clk->name = (ucon & S3C2410_UCON_UCLK) ? "uclk" : "pclk";
  45. return 0;
  46. }
  47. static int s3c24a0_serial_resetport(struct uart_port *port,
  48. struct s3c2410_uartcfg *cfg)
  49. {
  50. dbg("s3c24a0_serial_resetport: port=%p (%08lx), cfg=%p\n",
  51. port, port->mapbase, cfg);
  52. wr_regl(port, S3C2410_UCON, cfg->ucon);
  53. wr_regl(port, S3C2410_ULCON, cfg->ulcon);
  54. /* reset both fifos */
  55. wr_regl(port, S3C2410_UFCON, cfg->ufcon | S3C2410_UFCON_RESETBOTH);
  56. wr_regl(port, S3C2410_UFCON, cfg->ufcon);
  57. return 0;
  58. }
  59. static struct s3c24xx_uart_info s3c24a0_uart_inf = {
  60. .name = "Samsung S3C24A0 UART",
  61. .type = PORT_S3C2410,
  62. .fifosize = 16,
  63. .rx_fifomask = S3C24A0_UFSTAT_RXMASK,
  64. .rx_fifoshift = S3C24A0_UFSTAT_RXSHIFT,
  65. .rx_fifofull = S3C24A0_UFSTAT_RXFULL,
  66. .tx_fifofull = S3C24A0_UFSTAT_TXFULL,
  67. .tx_fifomask = S3C24A0_UFSTAT_TXMASK,
  68. .tx_fifoshift = S3C24A0_UFSTAT_TXSHIFT,
  69. .get_clksrc = s3c24a0_serial_getsource,
  70. .set_clksrc = s3c24a0_serial_setsource,
  71. .reset_port = s3c24a0_serial_resetport,
  72. };
  73. static int s3c24a0_serial_probe(struct platform_device *dev)
  74. {
  75. return s3c24xx_serial_probe(dev, &s3c24a0_uart_inf);
  76. }
  77. static struct platform_driver s3c24a0_serial_drv = {
  78. .probe = s3c24a0_serial_probe,
  79. .remove = __devexit_p(s3c24xx_serial_remove),
  80. .driver = {
  81. .name = "s3c24a0-uart",
  82. .owner = THIS_MODULE,
  83. },
  84. };
  85. s3c24xx_console_init(&s3c24a0_serial_drv, &s3c24a0_uart_inf);
  86. static int __init s3c24a0_serial_init(void)
  87. {
  88. return s3c24xx_serial_init(&s3c24a0_serial_drv, &s3c24a0_uart_inf);
  89. }
  90. static void __exit s3c24a0_serial_exit(void)
  91. {
  92. platform_driver_unregister(&s3c24a0_serial_drv);
  93. }
  94. module_init(s3c24a0_serial_init);
  95. module_exit(s3c24a0_serial_exit);