s3c2410.c 3.0 KB

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