diff options
author | Ben Dooks <ben-linux@fluff.org> | 2008-10-21 09:07:03 -0400 |
---|---|---|
committer | Ben Dooks <ben-linux@fluff.org> | 2008-12-15 16:58:11 -0500 |
commit | b690ace50be7d10d77cb7a6d5ef1bd9de649852f (patch) | |
tree | 280a5f1ae30ad16669e02f664923afaf4d0d41c3 | |
parent | cf18acf0e04260ff8ffa46dc245d3d2324ed41b0 (diff) |
[ARM] S3C6400: serial support for S3C6400 and S3C6410 SoCs
Add support to the Samsung serial driver for the S3C6400
and S3C6410 serial ports.
Signed-off-by: Ben Dooks <ben-linux@fluff.org>
-rw-r--r-- | arch/arm/mach-s3c2410/include/mach/map.h | 2 | ||||
-rw-r--r-- | arch/arm/mach-s3c24a0/include/mach/map.h | 2 | ||||
-rw-r--r-- | arch/arm/plat-s3c/include/plat/regs-serial.h | 6 | ||||
-rw-r--r-- | drivers/serial/Kconfig | 10 | ||||
-rw-r--r-- | drivers/serial/Makefile | 1 | ||||
-rw-r--r-- | drivers/serial/s3c6400.c | 151 | ||||
-rw-r--r-- | drivers/serial/samsung.c | 8 | ||||
-rw-r--r-- | include/linux/serial_core.h | 2 |
8 files changed, 178 insertions, 4 deletions
diff --git a/arch/arm/mach-s3c2410/include/mach/map.h b/arch/arm/mach-s3c2410/include/mach/map.h index 6b30361a0805..918e3463297f 100644 --- a/arch/arm/mach-s3c2410/include/mach/map.h +++ b/arch/arm/mach-s3c2410/include/mach/map.h | |||
@@ -101,4 +101,6 @@ | |||
101 | #define S3C24XX_PA_SDI S3C2410_PA_SDI | 101 | #define S3C24XX_PA_SDI S3C2410_PA_SDI |
102 | #define S3C24XX_PA_NAND S3C2410_PA_NAND | 102 | #define S3C24XX_PA_NAND S3C2410_PA_NAND |
103 | 103 | ||
104 | #define S3C_PA_UART S3C24XX_PA_UART | ||
105 | |||
104 | #endif /* __ASM_ARCH_MAP_H */ | 106 | #endif /* __ASM_ARCH_MAP_H */ |
diff --git a/arch/arm/mach-s3c24a0/include/mach/map.h b/arch/arm/mach-s3c24a0/include/mach/map.h index 2ce1839de4ee..6667355a47a1 100644 --- a/arch/arm/mach-s3c24a0/include/mach/map.h +++ b/arch/arm/mach-s3c24a0/include/mach/map.h | |||
@@ -80,4 +80,6 @@ | |||
80 | #define S3C24XX_PA_SDI S3C24A0_PA_SDI | 80 | #define S3C24XX_PA_SDI S3C24A0_PA_SDI |
81 | #define S3C24XX_PA_NAND S3C24A0_PA_NAND | 81 | #define S3C24XX_PA_NAND S3C24A0_PA_NAND |
82 | 82 | ||
83 | #define S3C_PA_UART S3C24A0_PA_UART | ||
84 | |||
83 | #endif /* __ASM_ARCH_24A0_MAP_H */ | 85 | #endif /* __ASM_ARCH_24A0_MAP_H */ |
diff --git a/arch/arm/plat-s3c/include/plat/regs-serial.h b/arch/arm/plat-s3c/include/plat/regs-serial.h index 18ba31c7174c..3ca28585cf80 100644 --- a/arch/arm/plat-s3c/include/plat/regs-serial.h +++ b/arch/arm/plat-s3c/include/plat/regs-serial.h | |||
@@ -77,6 +77,12 @@ | |||
77 | #define S3C2440_UCON_FCLK (3<<10) | 77 | #define S3C2440_UCON_FCLK (3<<10) |
78 | #define S3C2443_UCON_EPLL (3<<10) | 78 | #define S3C2443_UCON_EPLL (3<<10) |
79 | 79 | ||
80 | #define S3C6400_UCON_CLKMASK (3<<10) | ||
81 | #define S3C6400_UCON_PCLK (0<<10) | ||
82 | #define S3C6400_UCON_PCLK2 (2<<10) | ||
83 | #define S3C6400_UCON_UCLK0 (1<<10) | ||
84 | #define S3C6400_UCON_UCLK1 (3<<10) | ||
85 | |||
80 | #define S3C2440_UCON2_FCLK_EN (1<<15) | 86 | #define S3C2440_UCON2_FCLK_EN (1<<15) |
81 | #define S3C2440_UCON0_DIVMASK (15 << 12) | 87 | #define S3C2440_UCON0_DIVMASK (15 << 12) |
82 | #define S3C2440_UCON1_DIVMASK (15 << 12) | 88 | #define S3C2440_UCON1_DIVMASK (15 << 12) |
diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig index f71a2e8a5f60..e4ae499e587e 100644 --- a/drivers/serial/Kconfig +++ b/drivers/serial/Kconfig | |||
@@ -447,7 +447,7 @@ config SERIAL_CLPS711X_CONSOLE | |||
447 | 447 | ||
448 | config SERIAL_SAMSUNG | 448 | config SERIAL_SAMSUNG |
449 | tristate "Samsung SoC serial support" | 449 | tristate "Samsung SoC serial support" |
450 | depends on ARM && PLAT_S3C24XX | 450 | depends on ARM && PLAT_S3C |
451 | select SERIAL_CORE | 451 | select SERIAL_CORE |
452 | help | 452 | help |
453 | Support for the on-chip UARTs on the Samsung S3C24XX series CPUs, | 453 | Support for the on-chip UARTs on the Samsung S3C24XX series CPUs, |
@@ -515,6 +515,14 @@ config SERIAL_S3C24A0 | |||
515 | help | 515 | help |
516 | Serial port support for the Samsung S3C24A0 SoC | 516 | Serial port support for the Samsung S3C24A0 SoC |
517 | 517 | ||
518 | config SERIAL_S3C6400 | ||
519 | tristate "Samsung S3C6400/S3C6410 Serial port support" | ||
520 | depends on SERIAL_SAMSUNG && (CPU_S3C600 || CPU_S3C6410) | ||
521 | default y | ||
522 | help | ||
523 | Serial port support for the Samsung S3C6400 and S3C6410 | ||
524 | SoCs | ||
525 | |||
518 | config SERIAL_DZ | 526 | config SERIAL_DZ |
519 | bool "DECstation DZ serial driver" | 527 | bool "DECstation DZ serial driver" |
520 | depends on MACH_DECSTATION && 32BIT | 528 | depends on MACH_DECSTATION && 32BIT |
diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile index 7769aece54ca..dfe775ac45b2 100644 --- a/drivers/serial/Makefile +++ b/drivers/serial/Makefile | |||
@@ -42,6 +42,7 @@ obj-$(CONFIG_SERIAL_S3C2410) += s3c2410.o | |||
42 | obj-$(CONFIG_SERIAL_S3C2412) += s3c2412.o | 42 | obj-$(CONFIG_SERIAL_S3C2412) += s3c2412.o |
43 | obj-$(CONFIG_SERIAL_S3C2440) += s3c2440.o | 43 | obj-$(CONFIG_SERIAL_S3C2440) += s3c2440.o |
44 | obj-$(CONFIG_SERIAL_S3C24A0) += s3c24a0.o | 44 | obj-$(CONFIG_SERIAL_S3C24A0) += s3c24a0.o |
45 | obj-$(CONFIG_SERIAL_S3C6400) += s3c6400.o | ||
45 | obj-$(CONFIG_SERIAL_IP22_ZILOG) += ip22zilog.o | 46 | obj-$(CONFIG_SERIAL_IP22_ZILOG) += ip22zilog.o |
46 | obj-$(CONFIG_SERIAL_MUX) += mux.o | 47 | obj-$(CONFIG_SERIAL_MUX) += mux.o |
47 | obj-$(CONFIG_SERIAL_68328) += 68328serial.o | 48 | obj-$(CONFIG_SERIAL_68328) += 68328serial.o |
diff --git a/drivers/serial/s3c6400.c b/drivers/serial/s3c6400.c new file mode 100644 index 000000000000..06936d13393f --- /dev/null +++ b/drivers/serial/s3c6400.c | |||
@@ -0,0 +1,151 @@ | |||
1 | /* linux/drivers/serial/s3c6400.c | ||
2 | * | ||
3 | * Driver for Samsung S3C6400 and S3C6410 SoC onboard UARTs. | ||
4 | * | ||
5 | * Copyright 2008 Openmoko, Inc. | ||
6 | * Copyright 2008 Simtec Electronics | ||
7 | * Ben Dooks <ben@simtec.co.uk> | ||
8 | * http://armlinux.simtec.co.uk/ | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License version 2 as | ||
12 | * published by the Free Software Foundation. | ||
13 | */ | ||
14 | |||
15 | #include <linux/module.h> | ||
16 | #include <linux/ioport.h> | ||
17 | #include <linux/io.h> | ||
18 | #include <linux/platform_device.h> | ||
19 | #include <linux/init.h> | ||
20 | #include <linux/serial_core.h> | ||
21 | #include <linux/serial.h> | ||
22 | |||
23 | #include <asm/irq.h> | ||
24 | #include <mach/hardware.h> | ||
25 | |||
26 | #include <plat/regs-serial.h> | ||
27 | |||
28 | #include "samsung.h" | ||
29 | |||
30 | static int s3c6400_serial_setsource(struct uart_port *port, | ||
31 | struct s3c24xx_uart_clksrc *clk) | ||
32 | { | ||
33 | unsigned long ucon = rd_regl(port, S3C2410_UCON); | ||
34 | |||
35 | if (strcmp(clk->name, "uclk0") == 0) { | ||
36 | ucon &= ~S3C6400_UCON_CLKMASK; | ||
37 | ucon |= S3C6400_UCON_UCLK0; | ||
38 | } else if (strcmp(clk->name, "uclk1") == 0) | ||
39 | ucon |= S3C6400_UCON_UCLK1; | ||
40 | else if (strcmp(clk->name, "pclk") == 0) { | ||
41 | /* See notes about transitioning from UCLK to PCLK */ | ||
42 | ucon &= ~S3C6400_UCON_UCLK0; | ||
43 | } else { | ||
44 | printk(KERN_ERR "unknown clock source %s\n", clk->name); | ||
45 | return -EINVAL; | ||
46 | } | ||
47 | |||
48 | wr_regl(port, S3C2410_UCON, ucon); | ||
49 | return 0; | ||
50 | } | ||
51 | |||
52 | |||
53 | static int s3c6400_serial_getsource(struct uart_port *port, | ||
54 | struct s3c24xx_uart_clksrc *clk) | ||
55 | { | ||
56 | u32 ucon = rd_regl(port, S3C2410_UCON); | ||
57 | |||
58 | clk->divisor = 1; | ||
59 | |||
60 | switch (ucon & S3C6400_UCON_CLKMASK) { | ||
61 | case S3C6400_UCON_UCLK0: | ||
62 | clk->name = "uclk0"; | ||
63 | break; | ||
64 | |||
65 | case S3C6400_UCON_UCLK1: | ||
66 | clk->name = "uclk1"; | ||
67 | break; | ||
68 | |||
69 | case S3C6400_UCON_PCLK: | ||
70 | case S3C6400_UCON_PCLK2: | ||
71 | clk->name = "pclk"; | ||
72 | break; | ||
73 | } | ||
74 | |||
75 | return 0; | ||
76 | } | ||
77 | |||
78 | static int s3c6400_serial_resetport(struct uart_port *port, | ||
79 | struct s3c2410_uartcfg *cfg) | ||
80 | { | ||
81 | unsigned long ucon = rd_regl(port, S3C2410_UCON); | ||
82 | |||
83 | dbg("s3c6400_serial_resetport: port=%p (%08lx), cfg=%p\n", | ||
84 | port, port->mapbase, cfg); | ||
85 | |||
86 | /* ensure we don't change the clock settings... */ | ||
87 | |||
88 | ucon &= S3C6400_UCON_CLKMASK; | ||
89 | |||
90 | wr_regl(port, S3C2410_UCON, ucon | cfg->ucon); | ||
91 | wr_regl(port, S3C2410_ULCON, cfg->ulcon); | ||
92 | |||
93 | /* reset both fifos */ | ||
94 | |||
95 | wr_regl(port, S3C2410_UFCON, cfg->ufcon | S3C2410_UFCON_RESETBOTH); | ||
96 | wr_regl(port, S3C2410_UFCON, cfg->ufcon); | ||
97 | |||
98 | return 0; | ||
99 | } | ||
100 | |||
101 | static struct s3c24xx_uart_info s3c6400_uart_inf = { | ||
102 | .name = "Samsung S3C6400 UART", | ||
103 | .type = PORT_S3C6400, | ||
104 | .fifosize = 64, | ||
105 | .rx_fifomask = S3C2440_UFSTAT_RXMASK, | ||
106 | .rx_fifoshift = S3C2440_UFSTAT_RXSHIFT, | ||
107 | .rx_fifofull = S3C2440_UFSTAT_RXFULL, | ||
108 | .tx_fifofull = S3C2440_UFSTAT_TXFULL, | ||
109 | .tx_fifomask = S3C2440_UFSTAT_TXMASK, | ||
110 | .tx_fifoshift = S3C2440_UFSTAT_TXSHIFT, | ||
111 | .get_clksrc = s3c6400_serial_getsource, | ||
112 | .set_clksrc = s3c6400_serial_setsource, | ||
113 | .reset_port = s3c6400_serial_resetport, | ||
114 | }; | ||
115 | |||
116 | /* device management */ | ||
117 | |||
118 | static int s3c6400_serial_probe(struct platform_device *dev) | ||
119 | { | ||
120 | dbg("s3c6400_serial_probe: dev=%p\n", dev); | ||
121 | return s3c24xx_serial_probe(dev, &s3c6400_uart_inf); | ||
122 | } | ||
123 | |||
124 | static struct platform_driver s3c6400_serial_drv = { | ||
125 | .probe = s3c6400_serial_probe, | ||
126 | .remove = s3c24xx_serial_remove, | ||
127 | .driver = { | ||
128 | .name = "s3c6400-uart", | ||
129 | .owner = THIS_MODULE, | ||
130 | }, | ||
131 | }; | ||
132 | |||
133 | s3c24xx_console_init(&s3c6400_serial_drv, &s3c6400_uart_inf); | ||
134 | |||
135 | static int __init s3c6400_serial_init(void) | ||
136 | { | ||
137 | return s3c24xx_serial_init(&s3c6400_serial_drv, &s3c6400_uart_inf); | ||
138 | } | ||
139 | |||
140 | static void __exit s3c6400_serial_exit(void) | ||
141 | { | ||
142 | platform_driver_unregister(&s3c6400_serial_drv); | ||
143 | } | ||
144 | |||
145 | module_init(s3c6400_serial_init); | ||
146 | module_exit(s3c6400_serial_exit); | ||
147 | |||
148 | MODULE_DESCRIPTION("Samsung S3C6400,S3C6410 SoC Serial port driver"); | ||
149 | MODULE_AUTHOR("Ben Dooks <ben@simtec.co.uk>"); | ||
150 | MODULE_LICENSE("GPL v2"); | ||
151 | MODULE_ALIAS("platform:s3c6400-uart"); | ||
diff --git a/drivers/serial/samsung.c b/drivers/serial/samsung.c index bb8b57aae3af..44fc38afa228 100644 --- a/drivers/serial/samsung.c +++ b/drivers/serial/samsung.c | |||
@@ -47,9 +47,9 @@ | |||
47 | #include <asm/irq.h> | 47 | #include <asm/irq.h> |
48 | 48 | ||
49 | #include <mach/hardware.h> | 49 | #include <mach/hardware.h> |
50 | #include <mach/map.h> | ||
50 | 51 | ||
51 | #include <plat/regs-serial.h> | 52 | #include <plat/regs-serial.h> |
52 | #include <mach/regs-gpio.h> | ||
53 | 53 | ||
54 | #include "samsung.h" | 54 | #include "samsung.h" |
55 | 55 | ||
@@ -756,6 +756,8 @@ static const char *s3c24xx_serial_type(struct uart_port *port) | |||
756 | return "S3C2440"; | 756 | return "S3C2440"; |
757 | case PORT_S3C2412: | 757 | case PORT_S3C2412: |
758 | return "S3C2412"; | 758 | return "S3C2412"; |
759 | case PORT_S3C6400: | ||
760 | return "S3C6400/10"; | ||
759 | default: | 761 | default: |
760 | return NULL; | 762 | return NULL; |
761 | } | 763 | } |
@@ -1034,8 +1036,8 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport, | |||
1034 | 1036 | ||
1035 | dbg("resource %p (%lx..%lx)\n", res, res->start, res->end); | 1037 | dbg("resource %p (%lx..%lx)\n", res, res->start, res->end); |
1036 | 1038 | ||
1037 | port->mapbase = res->start; | 1039 | port->mapbase = res->start; |
1038 | port->membase = S3C24XX_VA_UART + (res->start - S3C24XX_PA_UART); | 1040 | port->membase = S3C_VA_UART + res->start - (S3C_PA_UART & 0xfff00000); |
1039 | ret = platform_get_irq(platdev, 0); | 1041 | ret = platform_get_irq(platdev, 0); |
1040 | if (ret < 0) | 1042 | if (ret < 0) |
1041 | port->irq = 0; | 1043 | port->irq = 0; |
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h index 4e4f1277f3bf..feb3b939ec4b 100644 --- a/include/linux/serial_core.h +++ b/include/linux/serial_core.h | |||
@@ -158,6 +158,8 @@ | |||
158 | /* SH-SCI */ | 158 | /* SH-SCI */ |
159 | #define PORT_SCIFA 83 | 159 | #define PORT_SCIFA 83 |
160 | 160 | ||
161 | #define PORT_S3C6400 84 | ||
162 | |||
161 | #ifdef __KERNEL__ | 163 | #ifdef __KERNEL__ |
162 | 164 | ||
163 | #include <linux/compiler.h> | 165 | #include <linux/compiler.h> |