Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound-2.6
[zen-stable.git] / drivers / tty / serial / s3c24a0.c
blob914eff22e499394f337936745a35239718d9f7c1
1 /*
2 * Driver for Samsung S3C24A0 SoC onboard UARTs.
4 * Based on drivers/serial/s3c2410.c
6 * Author: Sandeep Patil <sandeep.patil@azingo.com>
8 * Ben Dooks, Copyright (c) 2003-2008 Simtec Electronics
9 * http://armlinux.simtec.co.uk/
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
16 #include <linux/module.h>
17 #include <linux/ioport.h>
18 #include <linux/platform_device.h>
19 #include <linux/init.h>
20 #include <linux/serial_core.h>
21 #include <linux/serial.h>
22 #include <linux/io.h>
23 #include <linux/irq.h>
25 #include <mach/hardware.h>
27 #include <plat/regs-serial.h>
28 #include <mach/regs-gpio.h>
30 #include "samsung.h"
32 static int s3c24a0_serial_setsource(struct uart_port *port,
33 struct s3c24xx_uart_clksrc *clk)
35 unsigned long ucon = rd_regl(port, S3C2410_UCON);
37 if (strcmp(clk->name, "uclk") == 0)
38 ucon |= S3C2410_UCON_UCLK;
39 else
40 ucon &= ~S3C2410_UCON_UCLK;
42 wr_regl(port, S3C2410_UCON, ucon);
43 return 0;
46 static int s3c24a0_serial_getsource(struct uart_port *port,
47 struct s3c24xx_uart_clksrc *clk)
49 unsigned long ucon = rd_regl(port, S3C2410_UCON);
51 clk->divisor = 1;
52 clk->name = (ucon & S3C2410_UCON_UCLK) ? "uclk" : "pclk";
54 return 0;
57 static int s3c24a0_serial_resetport(struct uart_port *port,
58 struct s3c2410_uartcfg *cfg)
60 dbg("s3c24a0_serial_resetport: port=%p (%08lx), cfg=%p\n",
61 port, port->mapbase, cfg);
63 wr_regl(port, S3C2410_UCON, cfg->ucon);
64 wr_regl(port, S3C2410_ULCON, cfg->ulcon);
66 /* reset both fifos */
68 wr_regl(port, S3C2410_UFCON, cfg->ufcon | S3C2410_UFCON_RESETBOTH);
69 wr_regl(port, S3C2410_UFCON, cfg->ufcon);
71 return 0;
74 static struct s3c24xx_uart_info s3c24a0_uart_inf = {
75 .name = "Samsung S3C24A0 UART",
76 .type = PORT_S3C2410,
77 .fifosize = 16,
78 .rx_fifomask = S3C24A0_UFSTAT_RXMASK,
79 .rx_fifoshift = S3C24A0_UFSTAT_RXSHIFT,
80 .rx_fifofull = S3C24A0_UFSTAT_RXFULL,
81 .tx_fifofull = S3C24A0_UFSTAT_TXFULL,
82 .tx_fifomask = S3C24A0_UFSTAT_TXMASK,
83 .tx_fifoshift = S3C24A0_UFSTAT_TXSHIFT,
84 .get_clksrc = s3c24a0_serial_getsource,
85 .set_clksrc = s3c24a0_serial_setsource,
86 .reset_port = s3c24a0_serial_resetport,
89 static int s3c24a0_serial_probe(struct platform_device *dev)
91 return s3c24xx_serial_probe(dev, &s3c24a0_uart_inf);
94 static struct platform_driver s3c24a0_serial_driver = {
95 .probe = s3c24a0_serial_probe,
96 .remove = __devexit_p(s3c24xx_serial_remove),
97 .driver = {
98 .name = "s3c24a0-uart",
99 .owner = THIS_MODULE,
103 s3c24xx_console_init(&s3c24a0_serial_driver, &s3c24a0_uart_inf);
105 static int __init s3c24a0_serial_init(void)
107 return s3c24xx_serial_init(&s3c24a0_serial_driver, &s3c24a0_uart_inf);
110 static void __exit s3c24a0_serial_exit(void)
112 platform_driver_unregister(&s3c24a0_serial_driver);
115 module_init(s3c24a0_serial_init);
116 module_exit(s3c24a0_serial_exit);