s3c2410.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /*
  2. * Driver for Samsung S3C2410 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. #include <linux/module.h>
  12. #include <linux/ioport.h>
  13. #include <linux/io.h>
  14. #include <linux/platform_device.h>
  15. #include <linux/init.h>
  16. #include <linux/serial_core.h>
  17. #include <linux/serial.h>
  18. #include <asm/irq.h>
  19. #include <mach/hardware.h>
  20. #include <plat/regs-serial.h>
  21. #include <mach/regs-gpio.h>
  22. #include "samsung.h"
  23. static int s3c2410_serial_setsource(struct uart_port *port,
  24. struct s3c24xx_uart_clksrc *clk)
  25. {
  26. unsigned long ucon = rd_regl(port, S3C2410_UCON);
  27. if (strcmp(clk->name, "uclk") == 0)
  28. ucon |= S3C2410_UCON_UCLK;
  29. else
  30. ucon &= ~S3C2410_UCON_UCLK;
  31. wr_regl(port, S3C2410_UCON, ucon);
  32. return 0;
  33. }
  34. static int s3c2410_serial_getsource(struct uart_port *port,
  35. struct s3c24xx_uart_clksrc *clk)
  36. {
  37. unsigned long ucon = rd_regl(port, S3C2410_UCON);
  38. clk->divisor = 1;
  39. clk->name = (ucon & S3C2410_UCON_UCLK) ? "uclk" : "pclk";
  40. return 0;
  41. }
  42. static int s3c2410_serial_resetport(struct uart_port *port,
  43. struct s3c2410_uartcfg *cfg)
  44. {
  45. dbg("s3c2410_serial_resetport: port=%p (%08lx), cfg=%p\n",
  46. port, port->mapbase, cfg);
  47. wr_regl(port, S3C2410_UCON, cfg->ucon);
  48. wr_regl(port, S3C2410_ULCON, cfg->ulcon);
  49. /* reset both fifos */
  50. wr_regl(port, S3C2410_UFCON, cfg->ufcon | S3C2410_UFCON_RESETBOTH);
  51. wr_regl(port, S3C2410_UFCON, cfg->ufcon);
  52. return 0;
  53. }
  54. static struct s3c24xx_uart_info s3c2410_uart_inf = {
  55. .name = "Samsung S3C2410 UART",
  56. .type = PORT_S3C2410,
  57. .fifosize = 16,
  58. .rx_fifomask = S3C2410_UFSTAT_RXMASK,
  59. .rx_fifoshift = S3C2410_UFSTAT_RXSHIFT,
  60. .rx_fifofull = S3C2410_UFSTAT_RXFULL,
  61. .tx_fifofull = S3C2410_UFSTAT_TXFULL,
  62. .tx_fifomask = S3C2410_UFSTAT_TXMASK,
  63. .tx_fifoshift = S3C2410_UFSTAT_TXSHIFT,
  64. .get_clksrc = s3c2410_serial_getsource,
  65. .set_clksrc = s3c2410_serial_setsource,
  66. .reset_port = s3c2410_serial_resetport,
  67. };
  68. static int s3c2410_serial_probe(struct platform_device *dev)
  69. {
  70. return s3c24xx_serial_probe(dev, &s3c2410_uart_inf);
  71. }
  72. static struct platform_driver s3c2410_serial_driver = {
  73. .probe = s3c2410_serial_probe,
  74. .remove = __devexit_p(s3c24xx_serial_remove),
  75. .driver = {
  76. .name = "s3c2410-uart",
  77. .owner = THIS_MODULE,
  78. },
  79. };
  80. static int __init s3c2410_serial_init(void)
  81. {
  82. return s3c24xx_serial_init(&s3c2410_serial_driver, &s3c2410_uart_inf);
  83. }
  84. static void __exit s3c2410_serial_exit(void)
  85. {
  86. platform_driver_unregister(&s3c2410_serial_driver);
  87. }
  88. module_init(s3c2410_serial_init);
  89. module_exit(s3c2410_serial_exit);
  90. MODULE_LICENSE("GPL v2");
  91. MODULE_AUTHOR("Ben Dooks <ben@simtec.co.uk>");
  92. MODULE_DESCRIPTION("Samsung S3C2410 SoC Serial port driver");
  93. MODULE_ALIAS("platform:s3c2410-uart");