]>
Commit | Line | Data |
---|---|---|
05a78966 | 1 | /* linux/drivers/serial/s3c2410.c |
1da177e4 | 2 | * |
b497549a | 3 | * Driver for Samsung S3C2410 SoC onboard UARTs. |
1da177e4 | 4 | * |
b497549a | 5 | * Ben Dooks, Copyright (c) 2003-2005,2008 Simtec Electronics |
05a78966 | 6 | * http://armlinux.simtec.co.uk/ |
8fe059df BD |
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. | |
1da177e4 LT |
11 | */ |
12 | ||
b497549a BD |
13 | #include <linux/module.h> |
14 | #include <linux/ioport.h> | |
15 | #include <linux/io.h> | |
16 | #include <linux/platform_device.h> | |
17 | #include <linux/init.h> | |
18 | #include <linux/serial_core.h> | |
19 | #include <linux/serial.h> | |
1da177e4 | 20 | |
b497549a BD |
21 | #include <asm/irq.h> |
22 | #include <asm/hardware.h> | |
1da177e4 | 23 | |
b497549a BD |
24 | #include <asm/plat-s3c/regs-serial.h> |
25 | #include <asm/arch/regs-gpio.h> | |
1da177e4 | 26 | |
b497549a | 27 | #include "samsung.h" |
1da177e4 LT |
28 | |
29 | static 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 | ||
43 | static 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 | ||
54 | static 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 | ||
71 | static 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 | ||
3ae5eaec | 86 | static int s3c2410_serial_probe(struct platform_device *dev) |
1da177e4 LT |
87 | { |
88 | return s3c24xx_serial_probe(dev, &s3c2410_uart_inf); | |
89 | } | |
90 | ||
3ae5eaec | 91 | static struct platform_driver s3c2410_serial_drv = { |
1da177e4 LT |
92 | .probe = s3c2410_serial_probe, |
93 | .remove = s3c24xx_serial_remove, | |
3ae5eaec RK |
94 | .driver = { |
95 | .name = "s3c2410-uart", | |
96 | .owner = THIS_MODULE, | |
97 | }, | |
1da177e4 LT |
98 | }; |
99 | ||
b497549a BD |
100 | s3c24xx_console_init(&s3c2410_serial_drv, &s3c2410_uart_inf); |
101 | ||
102 | static int __init s3c2410_serial_init(void) | |
1da177e4 LT |
103 | { |
104 | return s3c24xx_serial_init(&s3c2410_serial_drv, &s3c2410_uart_inf); | |
105 | } | |
106 | ||
b497549a | 107 | static void __exit s3c2410_serial_exit(void) |
1da177e4 | 108 | { |
3ae5eaec | 109 | platform_driver_unregister(&s3c2410_serial_drv); |
1da177e4 LT |
110 | } |
111 | ||
b497549a BD |
112 | module_init(s3c2410_serial_init); |
113 | module_exit(s3c2410_serial_exit); | |
1da177e4 | 114 | |
8fe059df | 115 | MODULE_LICENSE("GPL v2"); |
1da177e4 | 116 | MODULE_AUTHOR("Ben Dooks <ben@simtec.co.uk>"); |
b497549a | 117 | MODULE_DESCRIPTION("Samsung S3C2410 SoC Serial port driver"); |
e169c139 | 118 | MODULE_ALIAS("platform:s3c2410-uart"); |