From 2decd8745e8768e975100914edb2828417e69155 Mon Sep 17 00:00:00 2001 From: Matthieu Crapet Date: Sun, 17 Jan 2010 17:52:13 +0100 Subject: [PATCH 06/16] ts72xx_ts_ser1 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Signed-off-by: Petr Štetiar --- 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 + * 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 +#include +#include +#include +#include +#include +#include +#include + + +#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 "); +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 9ff47db..c9afa26 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 5548fe7..1c655ad 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.3.3