blob: 87c182ef71b8662e4e6de1772cb2ada44b96b235 [file] [log] [blame]
Ben Dooks05a78962008-05-22 16:36:45 +01001/* linux/drivers/serial/s3c2410.c
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 *
Ben Dooksb4975492008-07-03 12:32:51 +01003 * Driver for Samsung S3C2410 SoC onboard UARTs.
Linus Torvalds1da177e2005-04-16 15:20:36 -07004 *
Ben Dooksb4975492008-07-03 12:32:51 +01005 * Ben Dooks, Copyright (c) 2003-2005,2008 Simtec Electronics
Ben Dooks05a78962008-05-22 16:36:45 +01006 * http://armlinux.simtec.co.uk/
Ben Dooks8fe059d2008-05-23 11:48:00 +01007 *
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.
Linus Torvalds1da177e2005-04-16 15:20:36 -070011*/
12
Linus Torvalds1da177e2005-04-16 15:20:36 -070013#include <linux/module.h>
14#include <linux/ioport.h>
Ben Dooksb4975492008-07-03 12:32:51 +010015#include <linux/io.h>
Russell Kingd052d1b2005-10-29 19:07:23 +010016#include <linux/platform_device.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070017#include <linux/init.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070018#include <linux/serial_core.h>
19#include <linux/serial.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070020
Linus Torvalds1da177e2005-04-16 15:20:36 -070021#include <asm/irq.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010022#include <mach/hardware.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070023
Ben Dooksa2b7ba92008-10-07 22:26:09 +010024#include <plat/regs-serial.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010025#include <mach/regs-gpio.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070026
Ben Dooksb4975492008-07-03 12:32:51 +010027#include "samsung.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070028
29static int s3c2410_serial_setsource(struct uart_port *port,
30 struct s3c24xx_uart_clksrc *clk)
31{
32 unsigned long ucon = rd_regl(port, S3C2410_UCON);
33
34 if (strcmp(clk->name, "uclk") == 0)
35 ucon |= S3C2410_UCON_UCLK;
36 else
37 ucon &= ~S3C2410_UCON_UCLK;
38
39 wr_regl(port, S3C2410_UCON, ucon);
40 return 0;
41}
42
43static int s3c2410_serial_getsource(struct uart_port *port,
44 struct s3c24xx_uart_clksrc *clk)
45{
46 unsigned long ucon = rd_regl(port, S3C2410_UCON);
47
48 clk->divisor = 1;
49 clk->name = (ucon & S3C2410_UCON_UCLK) ? "uclk" : "pclk";
50
51 return 0;
52}
53
54static int s3c2410_serial_resetport(struct uart_port *port,
55 struct s3c2410_uartcfg *cfg)
56{
57 dbg("s3c2410_serial_resetport: port=%p (%08lx), cfg=%p\n",
58 port, port->mapbase, cfg);
59
60 wr_regl(port, S3C2410_UCON, cfg->ucon);
61 wr_regl(port, S3C2410_ULCON, cfg->ulcon);
62
63 /* reset both fifos */
64
65 wr_regl(port, S3C2410_UFCON, cfg->ufcon | S3C2410_UFCON_RESETBOTH);
66 wr_regl(port, S3C2410_UFCON, cfg->ufcon);
67
68 return 0;
69}
70
71static struct s3c24xx_uart_info s3c2410_uart_inf = {
72 .name = "Samsung S3C2410 UART",
73 .type = PORT_S3C2410,
74 .fifosize = 16,
75 .rx_fifomask = S3C2410_UFSTAT_RXMASK,
76 .rx_fifoshift = S3C2410_UFSTAT_RXSHIFT,
77 .rx_fifofull = S3C2410_UFSTAT_RXFULL,
78 .tx_fifofull = S3C2410_UFSTAT_TXFULL,
79 .tx_fifomask = S3C2410_UFSTAT_TXMASK,
80 .tx_fifoshift = S3C2410_UFSTAT_TXSHIFT,
81 .get_clksrc = s3c2410_serial_getsource,
82 .set_clksrc = s3c2410_serial_setsource,
83 .reset_port = s3c2410_serial_resetport,
84};
85
Russell King3ae5eae2005-11-09 22:32:44 +000086static int s3c2410_serial_probe(struct platform_device *dev)
Linus Torvalds1da177e2005-04-16 15:20:36 -070087{
88 return s3c24xx_serial_probe(dev, &s3c2410_uart_inf);
89}
90
Russell King3ae5eae2005-11-09 22:32:44 +000091static struct platform_driver s3c2410_serial_drv = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070092 .probe = s3c2410_serial_probe,
93 .remove = s3c24xx_serial_remove,
Russell King3ae5eae2005-11-09 22:32:44 +000094 .driver = {
95 .name = "s3c2410-uart",
96 .owner = THIS_MODULE,
97 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070098};
99
Ben Dooksb4975492008-07-03 12:32:51 +0100100s3c24xx_console_init(&s3c2410_serial_drv, &s3c2410_uart_inf);
101
102static int __init s3c2410_serial_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103{
104 return s3c24xx_serial_init(&s3c2410_serial_drv, &s3c2410_uart_inf);
105}
106
Ben Dooksb4975492008-07-03 12:32:51 +0100107static void __exit s3c2410_serial_exit(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108{
Russell King3ae5eae2005-11-09 22:32:44 +0000109 platform_driver_unregister(&s3c2410_serial_drv);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110}
111
Ben Dooksb4975492008-07-03 12:32:51 +0100112module_init(s3c2410_serial_init);
113module_exit(s3c2410_serial_exit);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700114
Ben Dooks8fe059d2008-05-23 11:48:00 +0100115MODULE_LICENSE("GPL v2");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116MODULE_AUTHOR("Ben Dooks <ben@simtec.co.uk>");
Ben Dooksb4975492008-07-03 12:32:51 +0100117MODULE_DESCRIPTION("Samsung S3C2410 SoC Serial port driver");
Kay Sieverse169c132008-04-15 14:34:35 -0700118MODULE_ALIAS("platform:s3c2410-uart");