blob: fed1a9a1ffb4e7db9aedae7ff0b498ed933e27f7 [file] [log] [blame]
Ben Dooksb4975492008-07-03 12:32:51 +01001/* linux/drivers/serial/s3c240.c
2 *
3 * Driver for Samsung SoC onboard UARTs.
4 *
5 * Ben Dooks, Copyright (c) 2003-2005 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
13#include <linux/module.h>
14#include <linux/ioport.h>
15#include <linux/io.h>
16#include <linux/platform_device.h>
17
18#include <asm/irq.h>
19
Russell Kinga09e64f2008-08-05 16:14:15 +010020#include <mach/hardware.h>
Ben Dooksb4975492008-07-03 12:32:51 +010021
Ben Dooksa2b7ba92008-10-07 22:26:09 +010022#include <plat/regs-serial.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010023#include <mach/regs-gpio.h>
Ben Dooksb4975492008-07-03 12:32:51 +010024
25#include "samsung.h"
26
27static int s3c2400_serial_getsource(struct uart_port *port,
28 struct s3c24xx_uart_clksrc *clk)
29{
30 clk->divisor = 1;
31 clk->name = "pclk";
32
33 return 0;
34}
35
36static int s3c2400_serial_setsource(struct uart_port *port,
37 struct s3c24xx_uart_clksrc *clk)
38{
39 return 0;
40}
41
42static int s3c2400_serial_resetport(struct uart_port *port,
43 struct s3c2410_uartcfg *cfg)
44{
45 dbg("s3c2400_serial_resetport: port=%p (%08lx), cfg=%p\n",
46 port, port->mapbase, cfg);
47
48 wr_regl(port, S3C2410_UCON, cfg->ucon);
49 wr_regl(port, S3C2410_ULCON, cfg->ulcon);
50
51 /* reset both fifos */
52
53 wr_regl(port, S3C2410_UFCON, cfg->ufcon | S3C2410_UFCON_RESETBOTH);
54 wr_regl(port, S3C2410_UFCON, cfg->ufcon);
55
56 return 0;
57}
58
59static struct s3c24xx_uart_info s3c2400_uart_inf = {
60 .name = "Samsung S3C2400 UART",
61 .type = PORT_S3C2400,
62 .fifosize = 16,
63 .rx_fifomask = S3C2410_UFSTAT_RXMASK,
64 .rx_fifoshift = S3C2410_UFSTAT_RXSHIFT,
65 .rx_fifofull = S3C2410_UFSTAT_RXFULL,
66 .tx_fifofull = S3C2410_UFSTAT_TXFULL,
67 .tx_fifomask = S3C2410_UFSTAT_TXMASK,
68 .tx_fifoshift = S3C2410_UFSTAT_TXSHIFT,
69 .get_clksrc = s3c2400_serial_getsource,
70 .set_clksrc = s3c2400_serial_setsource,
71 .reset_port = s3c2400_serial_resetport,
72};
73
74static int s3c2400_serial_probe(struct platform_device *dev)
75{
76 return s3c24xx_serial_probe(dev, &s3c2400_uart_inf);
77}
78
Ramax Lo8fe70a52009-07-09 16:28:33 +080079static struct platform_driver s3c2400_serial_driver = {
Ben Dooksb4975492008-07-03 12:32:51 +010080 .probe = s3c2400_serial_probe,
Peter Korsgaard90ceb9642009-06-22 18:42:49 +010081 .remove = __devexit_p(s3c24xx_serial_remove),
Ben Dooksb4975492008-07-03 12:32:51 +010082 .driver = {
83 .name = "s3c2400-uart",
84 .owner = THIS_MODULE,
85 },
86};
87
Ramax Lo8fe70a52009-07-09 16:28:33 +080088s3c24xx_console_init(&s3c2400_serial_driver, &s3c2400_uart_inf);
Ben Dooksb4975492008-07-03 12:32:51 +010089
90static inline int s3c2400_serial_init(void)
91{
Ramax Lo8fe70a52009-07-09 16:28:33 +080092 return s3c24xx_serial_init(&s3c2400_serial_driver, &s3c2400_uart_inf);
Ben Dooksb4975492008-07-03 12:32:51 +010093}
94
95static inline void s3c2400_serial_exit(void)
96{
Ramax Lo8fe70a52009-07-09 16:28:33 +080097 platform_driver_unregister(&s3c2400_serial_driver);
Ben Dooksb4975492008-07-03 12:32:51 +010098}
99
100module_init(s3c2400_serial_init);
101module_exit(s3c2400_serial_exit);
102
103MODULE_LICENSE("GPL v2");
104MODULE_AUTHOR("Ben Dooks <ben@simtec.co.uk>");
105MODULE_DESCRIPTION("Samsung S3C2400 SoC Serial port driver");
106MODULE_ALIAS("platform:s3c2400-uart");