Merge branch 'move-drivers' of git://git.kernel.org/pub/scm/linux/kernel/git/davej...
[linux-2.6/next.git] / drivers / tty / serial / s3c24a0.c
blobfad6083ca42716af9e1ad615862928dc2d767e10
1 /* linux/drivers/serial/s3c24a0.c
3 * Driver for Samsung S3C24A0 SoC onboard UARTs.
5 * Based on drivers/serial/s3c2410.c
7 * Author: Sandeep Patil <sandeep.patil@azingo.com>
9 * Ben Dooks, Copyright (c) 2003-2008 Simtec Electronics
10 * http://armlinux.simtec.co.uk/
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License version 2 as
14 * published by the Free Software Foundation.
17 #include <linux/module.h>
18 #include <linux/ioport.h>
19 #include <linux/platform_device.h>
20 #include <linux/init.h>
21 #include <linux/serial_core.h>
22 #include <linux/serial.h>
23 #include <linux/io.h>
24 #include <linux/irq.h>
26 #include <mach/hardware.h>
28 #include <plat/regs-serial.h>
29 #include <mach/regs-gpio.h>
31 #include "samsung.h"
33 static int s3c24a0_serial_setsource(struct uart_port *port,
34 struct s3c24xx_uart_clksrc *clk)
36 unsigned long ucon = rd_regl(port, S3C2410_UCON);
38 if (strcmp(clk->name, "uclk") == 0)
39 ucon |= S3C2410_UCON_UCLK;
40 else
41 ucon &= ~S3C2410_UCON_UCLK;
43 wr_regl(port, S3C2410_UCON, ucon);
44 return 0;
47 static int s3c24a0_serial_getsource(struct uart_port *port,
48 struct s3c24xx_uart_clksrc *clk)
50 unsigned long ucon = rd_regl(port, S3C2410_UCON);
52 clk->divisor = 1;
53 clk->name = (ucon & S3C2410_UCON_UCLK) ? "uclk" : "pclk";
55 return 0;
58 static int s3c24a0_serial_resetport(struct uart_port *port,
59 struct s3c2410_uartcfg *cfg)
61 dbg("s3c24a0_serial_resetport: port=%p (%08lx), cfg=%p\n",
62 port, port->mapbase, cfg);
64 wr_regl(port, S3C2410_UCON, cfg->ucon);
65 wr_regl(port, S3C2410_ULCON, cfg->ulcon);
67 /* reset both fifos */
69 wr_regl(port, S3C2410_UFCON, cfg->ufcon | S3C2410_UFCON_RESETBOTH);
70 wr_regl(port, S3C2410_UFCON, cfg->ufcon);
72 return 0;
75 static struct s3c24xx_uart_info s3c24a0_uart_inf = {
76 .name = "Samsung S3C24A0 UART",
77 .type = PORT_S3C2410,
78 .fifosize = 16,
79 .rx_fifomask = S3C24A0_UFSTAT_RXMASK,
80 .rx_fifoshift = S3C24A0_UFSTAT_RXSHIFT,
81 .rx_fifofull = S3C24A0_UFSTAT_RXFULL,
82 .tx_fifofull = S3C24A0_UFSTAT_TXFULL,
83 .tx_fifomask = S3C24A0_UFSTAT_TXMASK,
84 .tx_fifoshift = S3C24A0_UFSTAT_TXSHIFT,
85 .get_clksrc = s3c24a0_serial_getsource,
86 .set_clksrc = s3c24a0_serial_setsource,
87 .reset_port = s3c24a0_serial_resetport,
90 static int s3c24a0_serial_probe(struct platform_device *dev)
92 return s3c24xx_serial_probe(dev, &s3c24a0_uart_inf);
95 static struct platform_driver s3c24a0_serial_driver = {
96 .probe = s3c24a0_serial_probe,
97 .remove = __devexit_p(s3c24xx_serial_remove),
98 .driver = {
99 .name = "s3c24a0-uart",
100 .owner = THIS_MODULE,
104 s3c24xx_console_init(&s3c24a0_serial_driver, &s3c24a0_uart_inf);
106 static int __init s3c24a0_serial_init(void)
108 return s3c24xx_serial_init(&s3c24a0_serial_driver, &s3c24a0_uart_inf);
111 static void __exit s3c24a0_serial_exit(void)
113 platform_driver_unregister(&s3c24a0_serial_driver);
116 module_init(s3c24a0_serial_init);
117 module_exit(s3c24a0_serial_exit);