1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
|
From eb753556815cde046e35d206880a507eb052ac4e Mon Sep 17 00:00:00 2001
From: Matthieu Crapet <mcrapet@gmail.com>
Date: Sun, 17 Jan 2010 17:52:13 +0100
Subject: [PATCH] ts72xx_ts_ser1
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Petr Štetiar <ynezz@true.cz>
---
drivers/serial/8250_ts_ser1.c | 150 +++++++++++++++++++++++++++++++++++++++++
drivers/serial/Kconfig | 17 +++++
drivers/serial/Makefile | 1 +
3 files changed, 168 insertions(+), 0 deletions(-)
create mode 100644 drivers/serial/8250_ts_ser1.c
diff --git a/drivers/serial/8250_ts_ser1.c b/drivers/serial/8250_ts_ser1.c
new file mode 100644
index 0000000..a3c95d4
--- /dev/null
+++ b/drivers/serial/8250_ts_ser1.c
@@ -0,0 +1,150 @@
+/*
+ * linux/drivers/serial/8250_ts_ser1.c
+ * Technologic Systems TS-SER1 support.
+ *
+ * (c) Copyright 2006-2008 Matthieu Crapet <mcrapet@gmail.com>
+ * Data taken from include/asm-i386/serial.h
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * Pin Number:
+ * 1 DCD
+ * 2 Receive data
+ * 3 Trasmit data
+ * 4 DTR
+ * 5 Signal Ground
+ * 6 DSR
+ * 7 RTS
+ * 8 CTS
+ * 9 RI
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/serial_8250.h>
+#include <linux/irq.h>
+#include <linux/io.h>
+#include <mach/hardware.h>
+#include <mach/ts72xx.h>
+#include <mach/gpio.h>
+
+
+#define TS72XX_SER1_IO_PHYS_BASE (TS72XX_PC104_8BIT_IO_PHYS_BASE)
+#define TS72XX_SER1_IO_SIZE (TS72XX_PC104_8BIT_IO_SIZE)
+
+#define TS_SER1_PORT_COM3 0x3E8
+#define TS_SER1_PORT_COM4 0x2E8
+#define TS_SER1_PORT_COM5 0x3A8
+
+/* Value to write in 16550A scratch register */
+#define MARKER_BYTE 0xAA /* or 0x55 */
+
+#define PORT(_base,_irq) \
+ { \
+ .iobase = _base, \
+ .membase = (void __iomem *)0, \
+ .irq = _irq, \
+ .uartclk = 1843200, \
+ .iotype = UPIO_PORT, \
+ .flags = UPF_BOOT_AUTOCONF, \
+ }
+// Note: IRQ can be shared (see CONFIG_SERIAL_8250_SHARE_IRQ)
+
+
+static struct plat_serial8250_port ts72xx_ser1_data_com3[] = {
+ PORT(TS_SER1_PORT_COM3, 0),
+ { },
+};
+
+static struct plat_serial8250_port ts72xx_ser1_data_com4[] = {
+ PORT(TS_SER1_PORT_COM4, 0),
+ { },
+};
+
+static struct plat_serial8250_port ts72xx_ser1_data_com5[] = {
+ PORT(TS_SER1_PORT_COM5, 0),
+ { },
+};
+
+static struct platform_device ts72xx_ser1_device = {
+ .name = "serial8250",
+ .id = 0,
+ .dev = {
+ .platform_data = ts72xx_ser1_data_com3,
+ },
+};
+
+static void __iomem *iomem;
+
+
+static int __init ts_ser1_init(void)
+{
+ static struct plat_serial8250_port *comX = NULL;
+ int n = 0; // COM number as printed on TS-SER1 pcb
+
+ iomem = ioremap(TS72XX_SER1_IO_PHYS_BASE, TS72XX_SER1_IO_SIZE);
+
+ if (iomem != NULL) {
+ __raw_writeb(MARKER_BYTE, iomem + TS_SER1_PORT_COM3 + 7);
+ if (__raw_readb(iomem + TS_SER1_PORT_COM3 + 7) == MARKER_BYTE) {
+ comX = ts72xx_ser1_data_com3;
+ n = 3;
+ } else {
+ __raw_writeb(MARKER_BYTE, iomem + TS_SER1_PORT_COM4 + 7);
+ if (__raw_readb(iomem + TS_SER1_PORT_COM4 + 7) == MARKER_BYTE) {
+ comX = ts72xx_ser1_data_com4;
+ n = 4;
+ } else {
+ __raw_writeb(MARKER_BYTE, iomem + TS_SER1_PORT_COM5 + 7);
+ if (__raw_readb(iomem + TS_SER1_PORT_COM5 + 7) == MARKER_BYTE) {
+ comX = ts72xx_ser1_data_com5;
+ n = 5;
+ }
+ }
+ }
+
+ if (comX) {
+ #if CONFIG_SERIAL_8250_TS_SER1_IRQ == 5
+ gpio_direction_input(EP93XX_GPIO_LINE_F(3));
+ comX->irq = gpio_to_irq(EP93XX_GPIO_LINE_F(3)); // 83
+ set_irq_type(comX->irq, IRQ_TYPE_EDGE_RISING);
+ #elif CONFIG_SERIAL_8250_TS_SER1_IRQ == 6
+ comX->irq = IRQ_EP93XX_EXT1;
+ #elif CONFIG_SERIAL_8250_TS_SER1_IRQ == 7
+ comX->irq = IRQ_EP93XX_EXT3;
+ #else
+ comX->irq = IRQ_EP93XX_EXT3;
+ #endif
+
+ comX->iobase += (unsigned long)iomem; // virtual address
+ }
+
+ ts72xx_ser1_device.id = n;
+ ts72xx_ser1_device.dev.platform_data = comX;
+ }
+
+ return ((comX == NULL) ? -ENODEV :
+ platform_device_register(&ts72xx_ser1_device));
+}
+
+static void __exit ts_ser1_exit(void)
+{
+ iounmap(iomem);
+ platform_device_unregister(&ts72xx_ser1_device);
+}
+
+module_init(ts_ser1_init);
+module_exit(ts_ser1_exit);
+
+MODULE_AUTHOR("Matthieu Crapet <mcrapet@gmail.com>");
+MODULE_DESCRIPTION("8250 serial probe module for TS-SER1 (TS-72xx)");
+MODULE_LICENSE("GPL");
+MODULE_VERSION("0.3");
diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index e522572..0eeca06 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -275,6 +275,23 @@ config SERIAL_8250_RM9K
port hardware found on MIPS RM9122 and similar processors.
If unsure, say N.
+config SERIAL_8250_TS_SER1
+ tristate "Support TS-SER1 (for TS-72XX SBC)"
+ depends on SERIAL_8250 != n && MACH_TS72XX
+ help
+ Say Y here if you have a TS-SER1 PC/104 peripheral.
+ COM number will be configured automaticaly.
+
+ To compile this driver as a module, choose M here: the module
+ will be called 8250_ts_ser1.
+
+config SERIAL_8250_TS_SER1_IRQ
+ int "Selected IRQ (5, 6 or 7)"
+ depends on SERIAL_8250_TS_SER1
+ default "5"
+ help
+ Enter jumper IRQ configuration
+
comment "Non-8250 serial port support"
config SERIAL_AMBA_PL010
diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile
index d21d5dd..f8fdb4f 100644
--- a/drivers/serial/Makefile
+++ b/drivers/serial/Makefile
@@ -28,6 +28,7 @@ obj-$(CONFIG_SERIAL_8250_BOCA) += 8250_boca.o
obj-$(CONFIG_SERIAL_8250_EXAR_ST16C554) += 8250_exar_st16c554.o
obj-$(CONFIG_SERIAL_8250_HUB6) += 8250_hub6.o
obj-$(CONFIG_SERIAL_8250_MCA) += 8250_mca.o
+obj-$(CONFIG_SERIAL_8250_TS_SER1) += 8250_ts_ser1.o
obj-$(CONFIG_SERIAL_AMBA_PL010) += amba-pl010.o
obj-$(CONFIG_SERIAL_AMBA_PL011) += amba-pl011.o
obj-$(CONFIG_SERIAL_CLPS711X) += clps711x.o
--
1.6.0.4
|