s3c24a0.c 2.9 KB

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