s3c2412.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. * Driver for Samsung S3C2412 and S3C2413 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 s3c2412_serial_resetport(struct uart_port *port,
  24. struct s3c2410_uartcfg *cfg)
  25. {
  26. unsigned long ucon = rd_regl(port, S3C2410_UCON);
  27. dbg("%s: port=%p (%08lx), cfg=%p\n",
  28. __func__, port, port->mapbase, cfg);
  29. /* ensure we don't change the clock settings... */
  30. ucon &= S3C2412_UCON_CLKMASK;
  31. wr_regl(port, S3C2410_UCON, ucon | cfg->ucon);
  32. wr_regl(port, S3C2410_ULCON, cfg->ulcon);
  33. /* reset both fifos */
  34. wr_regl(port, S3C2410_UFCON, cfg->ufcon | S3C2410_UFCON_RESETBOTH);
  35. wr_regl(port, S3C2410_UFCON, cfg->ufcon);
  36. return 0;
  37. }
  38. static struct s3c24xx_uart_info s3c2412_uart_inf = {
  39. .name = "Samsung S3C2412 UART",
  40. .type = PORT_S3C2412,
  41. .fifosize = 64,
  42. .has_divslot = 1,
  43. .rx_fifomask = S3C2440_UFSTAT_RXMASK,
  44. .rx_fifoshift = S3C2440_UFSTAT_RXSHIFT,
  45. .rx_fifofull = S3C2440_UFSTAT_RXFULL,
  46. .tx_fifofull = S3C2440_UFSTAT_TXFULL,
  47. .tx_fifomask = S3C2440_UFSTAT_TXMASK,
  48. .tx_fifoshift = S3C2440_UFSTAT_TXSHIFT,
  49. .def_clk_sel = S3C2410_UCON_CLKSEL2,
  50. .num_clks = 4,
  51. .clksel_mask = S3C2412_UCON_CLKMASK,
  52. .clksel_shift = S3C2412_UCON_CLKSHIFT,
  53. .reset_port = s3c2412_serial_resetport,
  54. };
  55. /* device management */
  56. static int s3c2412_serial_probe(struct platform_device *dev)
  57. {
  58. dbg("s3c2440_serial_probe: dev=%p\n", dev);
  59. return s3c24xx_serial_probe(dev, &s3c2412_uart_inf);
  60. }
  61. static struct platform_driver s3c2412_serial_driver = {
  62. .probe = s3c2412_serial_probe,
  63. .remove = __devexit_p(s3c24xx_serial_remove),
  64. .driver = {
  65. .name = "s3c2412-uart",
  66. .owner = THIS_MODULE,
  67. },
  68. };
  69. static inline int s3c2412_serial_init(void)
  70. {
  71. return s3c24xx_serial_init(&s3c2412_serial_driver, &s3c2412_uart_inf);
  72. }
  73. static inline void s3c2412_serial_exit(void)
  74. {
  75. platform_driver_unregister(&s3c2412_serial_driver);
  76. }
  77. module_init(s3c2412_serial_init);
  78. module_exit(s3c2412_serial_exit);
  79. MODULE_DESCRIPTION("Samsung S3C2412,S3C2413 SoC Serial port driver");
  80. MODULE_AUTHOR("Ben Dooks <ben@simtec.co.uk>");
  81. MODULE_LICENSE("GPL v2");
  82. MODULE_ALIAS("platform:s3c2412-uart");