diff options
Diffstat (limited to 'drivers/serial')
32 files changed, 416 insertions, 2787 deletions
diff --git a/drivers/serial/21285.c b/drivers/serial/21285.c index 6558a4037806..f31c6698419c 100644 --- a/drivers/serial/21285.c +++ b/drivers/serial/21285.c | |||
@@ -19,7 +19,7 @@ | |||
19 | #include <asm/irq.h> | 19 | #include <asm/irq.h> |
20 | #include <asm/mach-types.h> | 20 | #include <asm/mach-types.h> |
21 | #include <asm/hardware/dec21285.h> | 21 | #include <asm/hardware/dec21285.h> |
22 | #include <asm/hardware.h> | 22 | #include <mach/hardware.h> |
23 | 23 | ||
24 | #define BAUD_BASE (mem_fclk_21285/64) | 24 | #define BAUD_BASE (mem_fclk_21285/64) |
25 | 25 | ||
diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c index a97f1ae11f78..d4104a3bbe87 100644 --- a/drivers/serial/8250.c +++ b/drivers/serial/8250.c | |||
@@ -44,6 +44,10 @@ | |||
44 | 44 | ||
45 | #include "8250.h" | 45 | #include "8250.h" |
46 | 46 | ||
47 | #ifdef CONFIG_SPARC | ||
48 | #include "suncore.h" | ||
49 | #endif | ||
50 | |||
47 | /* | 51 | /* |
48 | * Configuration: | 52 | * Configuration: |
49 | * share_irqs - whether we pass IRQF_SHARED to request_irq(). This option | 53 | * share_irqs - whether we pass IRQF_SHARED to request_irq(). This option |
@@ -53,6 +57,13 @@ static unsigned int share_irqs = SERIAL8250_SHARE_IRQS; | |||
53 | 57 | ||
54 | static unsigned int nr_uarts = CONFIG_SERIAL_8250_RUNTIME_UARTS; | 58 | static unsigned int nr_uarts = CONFIG_SERIAL_8250_RUNTIME_UARTS; |
55 | 59 | ||
60 | static struct uart_driver serial8250_reg; | ||
61 | |||
62 | static int serial_index(struct uart_port *port) | ||
63 | { | ||
64 | return (serial8250_reg.minor - 64) + port->line; | ||
65 | } | ||
66 | |||
56 | /* | 67 | /* |
57 | * Debugging. | 68 | * Debugging. |
58 | */ | 69 | */ |
@@ -536,7 +547,7 @@ static unsigned int serial_icr_read(struct uart_8250_port *up, int offset) | |||
536 | /* | 547 | /* |
537 | * FIFO support. | 548 | * FIFO support. |
538 | */ | 549 | */ |
539 | static inline void serial8250_clear_fifos(struct uart_8250_port *p) | 550 | static void serial8250_clear_fifos(struct uart_8250_port *p) |
540 | { | 551 | { |
541 | if (p->capabilities & UART_CAP_FIFO) { | 552 | if (p->capabilities & UART_CAP_FIFO) { |
542 | serial_outp(p, UART_FCR, UART_FCR_ENABLE_FIFO); | 553 | serial_outp(p, UART_FCR, UART_FCR_ENABLE_FIFO); |
@@ -551,7 +562,7 @@ static inline void serial8250_clear_fifos(struct uart_8250_port *p) | |||
551 | * capability" bit enabled. Note that on XR16C850s, we need to | 562 | * capability" bit enabled. Note that on XR16C850s, we need to |
552 | * reset LCR to write to IER. | 563 | * reset LCR to write to IER. |
553 | */ | 564 | */ |
554 | static inline void serial8250_set_sleep(struct uart_8250_port *p, int sleep) | 565 | static void serial8250_set_sleep(struct uart_8250_port *p, int sleep) |
555 | { | 566 | { |
556 | if (p->capabilities & UART_CAP_SLEEP) { | 567 | if (p->capabilities & UART_CAP_SLEEP) { |
557 | if (p->capabilities & UART_CAP_EFR) { | 568 | if (p->capabilities & UART_CAP_EFR) { |
@@ -993,7 +1004,7 @@ static void autoconfig(struct uart_8250_port *up, unsigned int probeflags) | |||
993 | return; | 1004 | return; |
994 | 1005 | ||
995 | DEBUG_AUTOCONF("ttyS%d: autoconf (0x%04x, 0x%p): ", | 1006 | DEBUG_AUTOCONF("ttyS%d: autoconf (0x%04x, 0x%p): ", |
996 | up->port.line, up->port.iobase, up->port.membase); | 1007 | serial_index(&up->port), up->port.iobase, up->port.membase); |
997 | 1008 | ||
998 | /* | 1009 | /* |
999 | * We really do need global IRQs disabled here - we're going to | 1010 | * We really do need global IRQs disabled here - we're going to |
@@ -1128,8 +1139,8 @@ static void autoconfig(struct uart_8250_port *up, unsigned int probeflags) | |||
1128 | if (up->capabilities != uart_config[up->port.type].flags) { | 1139 | if (up->capabilities != uart_config[up->port.type].flags) { |
1129 | printk(KERN_WARNING | 1140 | printk(KERN_WARNING |
1130 | "ttyS%d: detected caps %08x should be %08x\n", | 1141 | "ttyS%d: detected caps %08x should be %08x\n", |
1131 | up->port.line, up->capabilities, | 1142 | serial_index(&up->port), up->capabilities, |
1132 | uart_config[up->port.type].flags); | 1143 | uart_config[up->port.type].flags); |
1133 | } | 1144 | } |
1134 | 1145 | ||
1135 | up->port.fifosize = uart_config[up->port.type].fifo_size; | 1146 | up->port.fifosize = uart_config[up->port.type].fifo_size; |
@@ -1424,8 +1435,7 @@ static unsigned int check_modem_status(struct uart_8250_port *up) | |||
1424 | /* | 1435 | /* |
1425 | * This handles the interrupt from one port. | 1436 | * This handles the interrupt from one port. |
1426 | */ | 1437 | */ |
1427 | static inline void | 1438 | static void serial8250_handle_port(struct uart_8250_port *up) |
1428 | serial8250_handle_port(struct uart_8250_port *up) | ||
1429 | { | 1439 | { |
1430 | unsigned int status; | 1440 | unsigned int status; |
1431 | unsigned long flags; | 1441 | unsigned long flags; |
@@ -1719,7 +1729,7 @@ static void serial8250_break_ctl(struct uart_port *port, int break_state) | |||
1719 | /* | 1729 | /* |
1720 | * Wait for transmitter & holding register to empty | 1730 | * Wait for transmitter & holding register to empty |
1721 | */ | 1731 | */ |
1722 | static inline void wait_for_xmitr(struct uart_8250_port *up, int bits) | 1732 | static void wait_for_xmitr(struct uart_8250_port *up, int bits) |
1723 | { | 1733 | { |
1724 | unsigned int status, tmout = 10000; | 1734 | unsigned int status, tmout = 10000; |
1725 | 1735 | ||
@@ -1854,7 +1864,8 @@ static int serial8250_startup(struct uart_port *port) | |||
1854 | */ | 1864 | */ |
1855 | if (!(up->port.flags & UPF_BUGGY_UART) && | 1865 | if (!(up->port.flags & UPF_BUGGY_UART) && |
1856 | (serial_inp(up, UART_LSR) == 0xff)) { | 1866 | (serial_inp(up, UART_LSR) == 0xff)) { |
1857 | printk("ttyS%d: LSR safety check engaged!\n", up->port.line); | 1867 | printk(KERN_INFO "ttyS%d: LSR safety check engaged!\n", |
1868 | serial_index(&up->port)); | ||
1858 | return -ENODEV; | 1869 | return -ENODEV; |
1859 | } | 1870 | } |
1860 | 1871 | ||
@@ -1885,7 +1896,7 @@ static int serial8250_startup(struct uart_port *port) | |||
1885 | * the interrupt is enabled. Delays are necessary to | 1896 | * the interrupt is enabled. Delays are necessary to |
1886 | * allow register changes to become visible. | 1897 | * allow register changes to become visible. |
1887 | */ | 1898 | */ |
1888 | spin_lock(&up->port.lock); | 1899 | spin_lock_irqsave(&up->port.lock, flags); |
1889 | if (up->port.flags & UPF_SHARE_IRQ) | 1900 | if (up->port.flags & UPF_SHARE_IRQ) |
1890 | disable_irq_nosync(up->port.irq); | 1901 | disable_irq_nosync(up->port.irq); |
1891 | 1902 | ||
@@ -1901,22 +1912,31 @@ static int serial8250_startup(struct uart_port *port) | |||
1901 | 1912 | ||
1902 | if (up->port.flags & UPF_SHARE_IRQ) | 1913 | if (up->port.flags & UPF_SHARE_IRQ) |
1903 | enable_irq(up->port.irq); | 1914 | enable_irq(up->port.irq); |
1904 | spin_unlock(&up->port.lock); | 1915 | spin_unlock_irqrestore(&up->port.lock, flags); |
1905 | 1916 | ||
1906 | /* | 1917 | /* |
1907 | * If the interrupt is not reasserted, setup a timer to | 1918 | * If the interrupt is not reasserted, setup a timer to |
1908 | * kick the UART on a regular basis. | 1919 | * kick the UART on a regular basis. |
1909 | */ | 1920 | */ |
1910 | if (!(iir1 & UART_IIR_NO_INT) && (iir & UART_IIR_NO_INT)) { | 1921 | if (!(iir1 & UART_IIR_NO_INT) && (iir & UART_IIR_NO_INT)) { |
1911 | pr_debug("ttyS%d - using backup timer\n", port->line); | 1922 | up->bugs |= UART_BUG_THRE; |
1912 | up->timer.function = serial8250_backup_timeout; | 1923 | pr_debug("ttyS%d - using backup timer\n", |
1913 | up->timer.data = (unsigned long)up; | 1924 | serial_index(port)); |
1914 | mod_timer(&up->timer, jiffies + | ||
1915 | poll_timeout(up->port.timeout) + HZ / 5); | ||
1916 | } | 1925 | } |
1917 | } | 1926 | } |
1918 | 1927 | ||
1919 | /* | 1928 | /* |
1929 | * The above check will only give an accurate result the first time | ||
1930 | * the port is opened so this value needs to be preserved. | ||
1931 | */ | ||
1932 | if (up->bugs & UART_BUG_THRE) { | ||
1933 | up->timer.function = serial8250_backup_timeout; | ||
1934 | up->timer.data = (unsigned long)up; | ||
1935 | mod_timer(&up->timer, jiffies + | ||
1936 | poll_timeout(up->port.timeout) + HZ / 5); | ||
1937 | } | ||
1938 | |||
1939 | /* | ||
1920 | * If the "interrupt" for this port doesn't correspond with any | 1940 | * If the "interrupt" for this port doesn't correspond with any |
1921 | * hardware interrupt, we use a timer-based system. The original | 1941 | * hardware interrupt, we use a timer-based system. The original |
1922 | * driver used to do this with IRQ0. | 1942 | * driver used to do this with IRQ0. |
@@ -1961,7 +1981,7 @@ static int serial8250_startup(struct uart_port *port) | |||
1961 | if (!(up->bugs & UART_BUG_TXEN)) { | 1981 | if (!(up->bugs & UART_BUG_TXEN)) { |
1962 | up->bugs |= UART_BUG_TXEN; | 1982 | up->bugs |= UART_BUG_TXEN; |
1963 | pr_debug("ttyS%d - enabling bad tx status workarounds\n", | 1983 | pr_debug("ttyS%d - enabling bad tx status workarounds\n", |
1964 | port->line); | 1984 | serial_index(port)); |
1965 | } | 1985 | } |
1966 | } else { | 1986 | } else { |
1967 | up->bugs &= ~UART_BUG_TXEN; | 1987 | up->bugs &= ~UART_BUG_TXEN; |
@@ -2622,7 +2642,6 @@ static int serial8250_console_early_setup(void) | |||
2622 | return serial8250_find_port_for_earlycon(); | 2642 | return serial8250_find_port_for_earlycon(); |
2623 | } | 2643 | } |
2624 | 2644 | ||
2625 | static struct uart_driver serial8250_reg; | ||
2626 | static struct console serial8250_console = { | 2645 | static struct console serial8250_console = { |
2627 | .name = "ttyS", | 2646 | .name = "ttyS", |
2628 | .write = serial8250_console_write, | 2647 | .write = serial8250_console_write, |
@@ -2669,7 +2688,6 @@ static struct uart_driver serial8250_reg = { | |||
2669 | .dev_name = "ttyS", | 2688 | .dev_name = "ttyS", |
2670 | .major = TTY_MAJOR, | 2689 | .major = TTY_MAJOR, |
2671 | .minor = 64, | 2690 | .minor = 64, |
2672 | .nr = UART_NR, | ||
2673 | .cons = SERIAL8250_CONSOLE, | 2691 | .cons = SERIAL8250_CONSOLE, |
2674 | }; | 2692 | }; |
2675 | 2693 | ||
@@ -2951,10 +2969,12 @@ static int __init serial8250_init(void) | |||
2951 | "%d ports, IRQ sharing %sabled\n", nr_uarts, | 2969 | "%d ports, IRQ sharing %sabled\n", nr_uarts, |
2952 | share_irqs ? "en" : "dis"); | 2970 | share_irqs ? "en" : "dis"); |
2953 | 2971 | ||
2954 | for (i = 0; i < NR_IRQS; i++) | 2972 | #ifdef CONFIG_SPARC |
2955 | spin_lock_init(&irq_lists[i].lock); | 2973 | ret = sunserial_register_minors(&serial8250_reg, UART_NR); |
2956 | 2974 | #else | |
2975 | serial8250_reg.nr = UART_NR; | ||
2957 | ret = uart_register_driver(&serial8250_reg); | 2976 | ret = uart_register_driver(&serial8250_reg); |
2977 | #endif | ||
2958 | if (ret) | 2978 | if (ret) |
2959 | goto out; | 2979 | goto out; |
2960 | 2980 | ||
@@ -2979,7 +2999,11 @@ static int __init serial8250_init(void) | |||
2979 | put_dev: | 2999 | put_dev: |
2980 | platform_device_put(serial8250_isa_devs); | 3000 | platform_device_put(serial8250_isa_devs); |
2981 | unreg_uart_drv: | 3001 | unreg_uart_drv: |
3002 | #ifdef CONFIG_SPARC | ||
3003 | sunserial_unregister_minors(&serial8250_reg, UART_NR); | ||
3004 | #else | ||
2982 | uart_unregister_driver(&serial8250_reg); | 3005 | uart_unregister_driver(&serial8250_reg); |
3006 | #endif | ||
2983 | out: | 3007 | out: |
2984 | return ret; | 3008 | return ret; |
2985 | } | 3009 | } |
@@ -2998,7 +3022,11 @@ static void __exit serial8250_exit(void) | |||
2998 | platform_driver_unregister(&serial8250_isa_driver); | 3022 | platform_driver_unregister(&serial8250_isa_driver); |
2999 | platform_device_unregister(isa_dev); | 3023 | platform_device_unregister(isa_dev); |
3000 | 3024 | ||
3025 | #ifdef CONFIG_SPARC | ||
3026 | sunserial_unregister_minors(&serial8250_reg, UART_NR); | ||
3027 | #else | ||
3001 | uart_unregister_driver(&serial8250_reg); | 3028 | uart_unregister_driver(&serial8250_reg); |
3029 | #endif | ||
3002 | } | 3030 | } |
3003 | 3031 | ||
3004 | module_init(serial8250_init); | 3032 | module_init(serial8250_init); |
diff --git a/drivers/serial/8250.h b/drivers/serial/8250.h index 78c00162b04e..520260326f3d 100644 --- a/drivers/serial/8250.h +++ b/drivers/serial/8250.h | |||
@@ -47,6 +47,7 @@ struct serial8250_config { | |||
47 | #define UART_BUG_QUOT (1 << 0) /* UART has buggy quot LSB */ | 47 | #define UART_BUG_QUOT (1 << 0) /* UART has buggy quot LSB */ |
48 | #define UART_BUG_TXEN (1 << 1) /* UART has buggy TX IIR status */ | 48 | #define UART_BUG_TXEN (1 << 1) /* UART has buggy TX IIR status */ |
49 | #define UART_BUG_NOMSR (1 << 2) /* UART has buggy MSR status bits (Au1x00) */ | 49 | #define UART_BUG_NOMSR (1 << 2) /* UART has buggy MSR status bits (Au1x00) */ |
50 | #define UART_BUG_THRE (1 << 3) /* UART has buggy THRE reassertion */ | ||
50 | 51 | ||
51 | #define PROBE_RSA (1 << 0) | 52 | #define PROBE_RSA (1 << 0) |
52 | #define PROBE_ANY (~0) | 53 | #define PROBE_ANY (~0) |
diff --git a/drivers/serial/8250_pci.c b/drivers/serial/8250_pci.c index c2f23933155b..c014ffb110e9 100644 --- a/drivers/serial/8250_pci.c +++ b/drivers/serial/8250_pci.c | |||
@@ -2041,9 +2041,9 @@ static int pciserial_resume_one(struct pci_dev *dev) | |||
2041 | * The device may have been disabled. Re-enable it. | 2041 | * The device may have been disabled. Re-enable it. |
2042 | */ | 2042 | */ |
2043 | err = pci_enable_device(dev); | 2043 | err = pci_enable_device(dev); |
2044 | /* FIXME: We cannot simply error out here */ | ||
2044 | if (err) | 2045 | if (err) |
2045 | return err; | 2046 | printk(KERN_ERR "pciserial: Unable to re-enable ports, trying to continue.\n"); |
2046 | |||
2047 | pciserial_resume_ports(priv); | 2047 | pciserial_resume_ports(priv); |
2048 | } | 2048 | } |
2049 | return 0; | 2049 | return 0; |
diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig index 3b4a14e355c1..31786b3b0a68 100644 --- a/drivers/serial/Kconfig +++ b/drivers/serial/Kconfig | |||
@@ -9,7 +9,6 @@ menu "Serial drivers" | |||
9 | # The new 8250/16550 serial drivers | 9 | # The new 8250/16550 serial drivers |
10 | config SERIAL_8250 | 10 | config SERIAL_8250 |
11 | tristate "8250/16550 and compatible serial support" | 11 | tristate "8250/16550 and compatible serial support" |
12 | depends on (BROKEN || !SPARC) | ||
13 | select SERIAL_CORE | 12 | select SERIAL_CORE |
14 | ---help--- | 13 | ---help--- |
15 | This selects whether you want to include the driver for the standard | 14 | This selects whether you want to include the driver for the standard |
@@ -449,6 +448,7 @@ config SERIAL_CLPS711X_CONSOLE | |||
449 | config SERIAL_SAMSUNG | 448 | config SERIAL_SAMSUNG |
450 | tristate "Samsung SoC serial support" | 449 | tristate "Samsung SoC serial support" |
451 | depends on ARM && PLAT_S3C24XX | 450 | depends on ARM && PLAT_S3C24XX |
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, |
454 | providing /dev/ttySAC0, 1 and 2 (note, some machines may not | 454 | providing /dev/ttySAC0, 1 and 2 (note, some machines may not |
@@ -993,24 +993,12 @@ config SERIAL_68328_RTS_CTS | |||
993 | bool "Support RTS/CTS on 68328 serial port" | 993 | bool "Support RTS/CTS on 68328 serial port" |
994 | depends on SERIAL_68328 | 994 | depends on SERIAL_68328 |
995 | 995 | ||
996 | config SERIAL_COLDFIRE | ||
997 | bool "ColdFire serial support (DEPRECATED)" | ||
998 | depends on COLDFIRE | ||
999 | help | ||
1000 | This driver supports the built-in serial ports of the Motorola ColdFire | ||
1001 | family of CPUs. | ||
1002 | This driver is deprecated because it supports only the old interface | ||
1003 | for serial drivers and features like magic keys are not working. | ||
1004 | Please switch to the new style driver because this driver will be | ||
1005 | removed soon. | ||
1006 | |||
1007 | config SERIAL_MCF | 996 | config SERIAL_MCF |
1008 | bool "Coldfire serial support (new style driver)" | 997 | bool "Coldfire serial support" |
1009 | depends on COLDFIRE | 998 | depends on COLDFIRE |
1010 | select SERIAL_CORE | 999 | select SERIAL_CORE |
1011 | help | 1000 | help |
1012 | This new serial driver supports the Freescale Coldfire serial ports | 1001 | This serial driver supports the Freescale Coldfire serial ports. |
1013 | using the new serial driver subsystem. | ||
1014 | 1002 | ||
1015 | config SERIAL_MCF_BAUDRATE | 1003 | config SERIAL_MCF_BAUDRATE |
1016 | int "Default baudrate for Coldfire serial ports" | 1004 | int "Default baudrate for Coldfire serial ports" |
diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile index 3a0bbbe17aa3..0c17c8ddb19d 100644 --- a/drivers/serial/Makefile +++ b/drivers/serial/Makefile | |||
@@ -4,6 +4,16 @@ | |||
4 | 4 | ||
5 | obj-$(CONFIG_SERIAL_CORE) += serial_core.o | 5 | obj-$(CONFIG_SERIAL_CORE) += serial_core.o |
6 | obj-$(CONFIG_SERIAL_21285) += 21285.o | 6 | obj-$(CONFIG_SERIAL_21285) += 21285.o |
7 | |||
8 | # These Sparc drivers have to appear before others such as 8250 | ||
9 | # which share ttySx minor node space. Otherwise console device | ||
10 | # names change and other unplesantries. | ||
11 | obj-$(CONFIG_SERIAL_SUNCORE) += suncore.o | ||
12 | obj-$(CONFIG_SERIAL_SUNHV) += sunhv.o | ||
13 | obj-$(CONFIG_SERIAL_SUNZILOG) += sunzilog.o | ||
14 | obj-$(CONFIG_SERIAL_SUNSU) += sunsu.o | ||
15 | obj-$(CONFIG_SERIAL_SUNSAB) += sunsab.o | ||
16 | |||
7 | obj-$(CONFIG_SERIAL_8250) += 8250.o | 17 | obj-$(CONFIG_SERIAL_8250) += 8250.o |
8 | obj-$(CONFIG_SERIAL_8250_PNP) += 8250_pnp.o | 18 | obj-$(CONFIG_SERIAL_8250_PNP) += 8250_pnp.o |
9 | obj-$(CONFIG_SERIAL_8250_GSC) += 8250_gsc.o | 19 | obj-$(CONFIG_SERIAL_8250_GSC) += 8250_gsc.o |
@@ -31,18 +41,11 @@ obj-$(CONFIG_SERIAL_S3C2400) += s3c2400.o | |||
31 | obj-$(CONFIG_SERIAL_S3C2410) += s3c2410.o | 41 | obj-$(CONFIG_SERIAL_S3C2410) += s3c2410.o |
32 | obj-$(CONFIG_SERIAL_S3C2412) += s3c2412.o | 42 | obj-$(CONFIG_SERIAL_S3C2412) += s3c2412.o |
33 | obj-$(CONFIG_SERIAL_S3C2440) += s3c2440.o | 43 | obj-$(CONFIG_SERIAL_S3C2440) += s3c2440.o |
34 | obj-$(CONFIG_SERIAL_SUNCORE) += suncore.o | ||
35 | obj-$(CONFIG_SERIAL_SUNHV) += sunhv.o | ||
36 | obj-$(CONFIG_SERIAL_SUNZILOG) += sunzilog.o | ||
37 | obj-$(CONFIG_SERIAL_IP22_ZILOG) += ip22zilog.o | 44 | obj-$(CONFIG_SERIAL_IP22_ZILOG) += ip22zilog.o |
38 | obj-$(CONFIG_SERIAL_SUNSU) += sunsu.o | ||
39 | obj-$(CONFIG_SERIAL_SUNSAB) += sunsab.o | ||
40 | obj-$(CONFIG_SERIAL_MUX) += mux.o | 45 | obj-$(CONFIG_SERIAL_MUX) += mux.o |
41 | obj-$(CONFIG_SERIAL_68328) += 68328serial.o | 46 | obj-$(CONFIG_SERIAL_68328) += 68328serial.o |
42 | obj-$(CONFIG_SERIAL_68360) += 68360serial.o | 47 | obj-$(CONFIG_SERIAL_68360) += 68360serial.o |
43 | obj-$(CONFIG_SERIAL_COLDFIRE) += mcfserial.o | ||
44 | obj-$(CONFIG_SERIAL_MCF) += mcf.o | 48 | obj-$(CONFIG_SERIAL_MCF) += mcf.o |
45 | obj-$(CONFIG_V850E_UART) += v850e_uart.o | ||
46 | obj-$(CONFIG_SERIAL_PMACZILOG) += pmac_zilog.o | 49 | obj-$(CONFIG_SERIAL_PMACZILOG) += pmac_zilog.o |
47 | obj-$(CONFIG_SERIAL_LH7A40X) += serial_lh7a40x.o | 50 | obj-$(CONFIG_SERIAL_LH7A40X) += serial_lh7a40x.o |
48 | obj-$(CONFIG_SERIAL_DZ) += dz.o | 51 | obj-$(CONFIG_SERIAL_DZ) += dz.o |
diff --git a/drivers/serial/atmel_serial.c b/drivers/serial/atmel_serial.c index 1fee12c1f4f8..61fb8b6d19af 100644 --- a/drivers/serial/atmel_serial.c +++ b/drivers/serial/atmel_serial.c | |||
@@ -42,11 +42,11 @@ | |||
42 | #include <asm/io.h> | 42 | #include <asm/io.h> |
43 | 43 | ||
44 | #include <asm/mach/serial_at91.h> | 44 | #include <asm/mach/serial_at91.h> |
45 | #include <asm/arch/board.h> | 45 | #include <mach/board.h> |
46 | 46 | ||
47 | #ifdef CONFIG_ARM | 47 | #ifdef CONFIG_ARM |
48 | #include <asm/arch/cpu.h> | 48 | #include <mach/cpu.h> |
49 | #include <asm/arch/gpio.h> | 49 | #include <mach/gpio.h> |
50 | #endif | 50 | #endif |
51 | 51 | ||
52 | #define PDC_BUFFER_SIZE 512 | 52 | #define PDC_BUFFER_SIZE 512 |
@@ -131,7 +131,8 @@ struct atmel_uart_char { | |||
131 | struct atmel_uart_port { | 131 | struct atmel_uart_port { |
132 | struct uart_port uart; /* uart */ | 132 | struct uart_port uart; /* uart */ |
133 | struct clk *clk; /* uart clock */ | 133 | struct clk *clk; /* uart clock */ |
134 | unsigned short suspended; /* is port suspended? */ | 134 | int may_wakeup; /* cached value of device_may_wakeup for times we need to disable it */ |
135 | u32 backup_imr; /* IMR saved during suspend */ | ||
135 | int break_active; /* break being received */ | 136 | int break_active; /* break being received */ |
136 | 137 | ||
137 | short use_dma_rx; /* enable PDC receiver */ | 138 | short use_dma_rx; /* enable PDC receiver */ |
@@ -984,8 +985,15 @@ static void atmel_serial_pm(struct uart_port *port, unsigned int state, | |||
984 | * This is called on uart_open() or a resume event. | 985 | * This is called on uart_open() or a resume event. |
985 | */ | 986 | */ |
986 | clk_enable(atmel_port->clk); | 987 | clk_enable(atmel_port->clk); |
988 | |||
989 | /* re-enable interrupts if we disabled some on suspend */ | ||
990 | UART_PUT_IER(port, atmel_port->backup_imr); | ||
987 | break; | 991 | break; |
988 | case 3: | 992 | case 3: |
993 | /* Back up the interrupt mask and disable all interrupts */ | ||
994 | atmel_port->backup_imr = UART_GET_IMR(port); | ||
995 | UART_PUT_IDR(port, -1); | ||
996 | |||
989 | /* | 997 | /* |
990 | * Disable the peripheral clock for this serial port. | 998 | * Disable the peripheral clock for this serial port. |
991 | * This is called on uart_close() or a suspend event. | 999 | * This is called on uart_close() or a suspend event. |
@@ -1475,13 +1483,12 @@ static int atmel_serial_suspend(struct platform_device *pdev, | |||
1475 | cpu_relax(); | 1483 | cpu_relax(); |
1476 | } | 1484 | } |
1477 | 1485 | ||
1478 | if (device_may_wakeup(&pdev->dev) | 1486 | /* we can not wake up if we're running on slow clock */ |
1479 | && !atmel_serial_clk_will_stop()) | 1487 | atmel_port->may_wakeup = device_may_wakeup(&pdev->dev); |
1480 | enable_irq_wake(port->irq); | 1488 | if (atmel_serial_clk_will_stop()) |
1481 | else { | 1489 | device_set_wakeup_enable(&pdev->dev, 0); |
1482 | uart_suspend_port(&atmel_uart, port); | 1490 | |
1483 | atmel_port->suspended = 1; | 1491 | uart_suspend_port(&atmel_uart, port); |
1484 | } | ||
1485 | 1492 | ||
1486 | return 0; | 1493 | return 0; |
1487 | } | 1494 | } |
@@ -1491,11 +1498,8 @@ static int atmel_serial_resume(struct platform_device *pdev) | |||
1491 | struct uart_port *port = platform_get_drvdata(pdev); | 1498 | struct uart_port *port = platform_get_drvdata(pdev); |
1492 | struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); | 1499 | struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); |
1493 | 1500 | ||
1494 | if (atmel_port->suspended) { | 1501 | uart_resume_port(&atmel_uart, port); |
1495 | uart_resume_port(&atmel_uart, port); | 1502 | device_set_wakeup_enable(&pdev->dev, atmel_port->may_wakeup); |
1496 | atmel_port->suspended = 0; | ||
1497 | } else | ||
1498 | disable_irq_wake(port->irq); | ||
1499 | 1503 | ||
1500 | return 0; | 1504 | return 0; |
1501 | } | 1505 | } |
@@ -1513,6 +1517,8 @@ static int __devinit atmel_serial_probe(struct platform_device *pdev) | |||
1513 | BUILD_BUG_ON(!is_power_of_2(ATMEL_SERIAL_RINGSIZE)); | 1517 | BUILD_BUG_ON(!is_power_of_2(ATMEL_SERIAL_RINGSIZE)); |
1514 | 1518 | ||
1515 | port = &atmel_ports[pdev->id]; | 1519 | port = &atmel_ports[pdev->id]; |
1520 | port->backup_imr = 0; | ||
1521 | |||
1516 | atmel_init_port(port, pdev); | 1522 | atmel_init_port(port, pdev); |
1517 | 1523 | ||
1518 | if (!atmel_use_dma_rx(&port->uart)) { | 1524 | if (!atmel_use_dma_rx(&port->uart)) { |
diff --git a/drivers/serial/bfin_5xx.c b/drivers/serial/bfin_5xx.c index 9d8543762a30..569f0e2476c6 100644 --- a/drivers/serial/bfin_5xx.c +++ b/drivers/serial/bfin_5xx.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Blackfin On-Chip Serial Driver | 2 | * Blackfin On-Chip Serial Driver |
3 | * | 3 | * |
4 | * Copyright 2006-2007 Analog Devices Inc. | 4 | * Copyright 2006-2008 Analog Devices Inc. |
5 | * | 5 | * |
6 | * Enter bugs at http://blackfin.uclinux.org/ | 6 | * Enter bugs at http://blackfin.uclinux.org/ |
7 | * | 7 | * |
@@ -28,7 +28,7 @@ | |||
28 | #endif | 28 | #endif |
29 | 29 | ||
30 | #include <asm/gpio.h> | 30 | #include <asm/gpio.h> |
31 | #include <asm/mach/bfin_serial_5xx.h> | 31 | #include <mach/bfin_serial_5xx.h> |
32 | 32 | ||
33 | #ifdef CONFIG_SERIAL_BFIN_DMA | 33 | #ifdef CONFIG_SERIAL_BFIN_DMA |
34 | #include <linux/dma-mapping.h> | 34 | #include <linux/dma-mapping.h> |
@@ -42,6 +42,9 @@ | |||
42 | #define BFIN_SERIAL_MAJOR 204 | 42 | #define BFIN_SERIAL_MAJOR 204 |
43 | #define BFIN_SERIAL_MINOR 64 | 43 | #define BFIN_SERIAL_MINOR 64 |
44 | 44 | ||
45 | static struct bfin_serial_port bfin_serial_ports[BFIN_UART_NR_PORTS]; | ||
46 | static int nr_active_ports = ARRAY_SIZE(bfin_serial_resource); | ||
47 | |||
45 | /* | 48 | /* |
46 | * Setup for console. Argument comes from the menuconfig | 49 | * Setup for console. Argument comes from the menuconfig |
47 | */ | 50 | */ |
@@ -126,13 +129,13 @@ static int kgdb_entry_state; | |||
126 | void kgdb_put_debug_char(int chr) | 129 | void kgdb_put_debug_char(int chr) |
127 | { | 130 | { |
128 | struct bfin_serial_port *uart; | 131 | struct bfin_serial_port *uart; |
129 | 132 | ||
130 | if (CONFIG_KGDB_UART_PORT < 0 | 133 | if (CONFIG_KGDB_UART_PORT < 0 |
131 | || CONFIG_KGDB_UART_PORT >= BFIN_UART_NR_PORTS) | 134 | || CONFIG_KGDB_UART_PORT >= BFIN_UART_NR_PORTS) |
132 | uart = &bfin_serial_ports[0]; | 135 | uart = &bfin_serial_ports[0]; |
133 | else | 136 | else |
134 | uart = &bfin_serial_ports[CONFIG_KGDB_UART_PORT]; | 137 | uart = &bfin_serial_ports[CONFIG_KGDB_UART_PORT]; |
135 | 138 | ||
136 | while (!(UART_GET_LSR(uart) & THRE)) { | 139 | while (!(UART_GET_LSR(uart) & THRE)) { |
137 | SSYNC(); | 140 | SSYNC(); |
138 | } | 141 | } |
@@ -152,7 +155,7 @@ int kgdb_get_debug_char(void) | |||
152 | uart = &bfin_serial_ports[0]; | 155 | uart = &bfin_serial_ports[0]; |
153 | else | 156 | else |
154 | uart = &bfin_serial_ports[CONFIG_KGDB_UART_PORT]; | 157 | uart = &bfin_serial_ports[CONFIG_KGDB_UART_PORT]; |
155 | 158 | ||
156 | while(!(UART_GET_LSR(uart) & DR)) { | 159 | while(!(UART_GET_LSR(uart) & DR)) { |
157 | SSYNC(); | 160 | SSYNC(); |
158 | } | 161 | } |
@@ -298,7 +301,11 @@ static void bfin_serial_tx_chars(struct bfin_serial_port *uart) | |||
298 | bfin_serial_mctrl_check(uart); | 301 | bfin_serial_mctrl_check(uart); |
299 | 302 | ||
300 | if (uart_circ_empty(xmit) || uart_tx_stopped(&uart->port)) { | 303 | if (uart_circ_empty(xmit) || uart_tx_stopped(&uart->port)) { |
301 | bfin_serial_stop_tx(&uart->port); | 304 | #ifdef CONFIG_BF54x |
305 | /* Clear TFI bit */ | ||
306 | UART_PUT_LSR(uart, TFI); | ||
307 | #endif | ||
308 | UART_CLEAR_IER(uart, ETBEI); | ||
302 | return; | 309 | return; |
303 | } | 310 | } |
304 | 311 | ||
@@ -317,9 +324,6 @@ static void bfin_serial_tx_chars(struct bfin_serial_port *uart) | |||
317 | 324 | ||
318 | if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) | 325 | if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) |
319 | uart_write_wakeup(&uart->port); | 326 | uart_write_wakeup(&uart->port); |
320 | |||
321 | if (uart_circ_empty(xmit)) | ||
322 | bfin_serial_stop_tx(&uart->port); | ||
323 | } | 327 | } |
324 | 328 | ||
325 | static irqreturn_t bfin_serial_rx_int(int irq, void *dev_id) | 329 | static irqreturn_t bfin_serial_rx_int(int irq, void *dev_id) |
@@ -645,6 +649,42 @@ static int bfin_serial_startup(struct uart_port *port) | |||
645 | free_irq(uart->port.irq, uart); | 649 | free_irq(uart->port.irq, uart); |
646 | return -EBUSY; | 650 | return -EBUSY; |
647 | } | 651 | } |
652 | |||
653 | # ifdef CONFIG_BF54x | ||
654 | { | ||
655 | unsigned uart_dma_ch_rx, uart_dma_ch_tx; | ||
656 | |||
657 | switch (uart->port.irq) { | ||
658 | case IRQ_UART3_RX: | ||
659 | uart_dma_ch_rx = CH_UART3_RX; | ||
660 | uart_dma_ch_tx = CH_UART3_TX; | ||
661 | break; | ||
662 | case IRQ_UART2_RX: | ||
663 | uart_dma_ch_rx = CH_UART2_RX; | ||
664 | uart_dma_ch_tx = CH_UART2_TX; | ||
665 | break; | ||
666 | default: | ||
667 | uart_dma_ch_rx = uart_dma_ch_tx = 0; | ||
668 | break; | ||
669 | }; | ||
670 | |||
671 | if (uart_dma_ch_rx && | ||
672 | request_dma(uart_dma_ch_rx, "BFIN_UART_RX") < 0) { | ||
673 | printk(KERN_NOTICE"Fail to attach UART interrupt\n"); | ||
674 | free_irq(uart->port.irq, uart); | ||
675 | free_irq(uart->port.irq + 1, uart); | ||
676 | return -EBUSY; | ||
677 | } | ||
678 | if (uart_dma_ch_tx && | ||
679 | request_dma(uart_dma_ch_tx, "BFIN_UART_TX") < 0) { | ||
680 | printk(KERN_NOTICE "Fail to attach UART interrupt\n"); | ||
681 | free_dma(uart_dma_ch_rx); | ||
682 | free_irq(uart->port.irq, uart); | ||
683 | free_irq(uart->port.irq + 1, uart); | ||
684 | return -EBUSY; | ||
685 | } | ||
686 | } | ||
687 | # endif | ||
648 | #endif | 688 | #endif |
649 | UART_SET_IER(uart, ERBFI); | 689 | UART_SET_IER(uart, ERBFI); |
650 | return 0; | 690 | return 0; |
@@ -662,6 +702,20 @@ static void bfin_serial_shutdown(struct uart_port *port) | |||
662 | del_timer(&(uart->rx_dma_timer)); | 702 | del_timer(&(uart->rx_dma_timer)); |
663 | dma_free_coherent(NULL, PAGE_SIZE, uart->rx_dma_buf.buf, 0); | 703 | dma_free_coherent(NULL, PAGE_SIZE, uart->rx_dma_buf.buf, 0); |
664 | #else | 704 | #else |
705 | #ifdef CONFIG_BF54x | ||
706 | switch (uart->port.irq) { | ||
707 | case IRQ_UART3_RX: | ||
708 | free_dma(CH_UART3_RX); | ||
709 | free_dma(CH_UART3_TX); | ||
710 | break; | ||
711 | case IRQ_UART2_RX: | ||
712 | free_dma(CH_UART2_RX); | ||
713 | free_dma(CH_UART2_TX); | ||
714 | break; | ||
715 | default: | ||
716 | break; | ||
717 | }; | ||
718 | #endif | ||
665 | #ifdef CONFIG_KGDB_UART | 719 | #ifdef CONFIG_KGDB_UART |
666 | if (uart->port.line != CONFIG_KGDB_UART_PORT) | 720 | if (uart->port.line != CONFIG_KGDB_UART_PORT) |
667 | #endif | 721 | #endif |
@@ -757,6 +811,9 @@ bfin_serial_set_termios(struct uart_port *port, struct ktermios *termios, | |||
757 | val |= UCEN; | 811 | val |= UCEN; |
758 | UART_PUT_GCTL(uart, val); | 812 | UART_PUT_GCTL(uart, val); |
759 | 813 | ||
814 | /* Port speed changed, update the per-port timeout. */ | ||
815 | uart_update_timeout(port, termios->c_cflag, baud); | ||
816 | |||
760 | spin_unlock_irqrestore(&uart->port.lock, flags); | 817 | spin_unlock_irqrestore(&uart->port.lock, flags); |
761 | } | 818 | } |
762 | 819 | ||
@@ -817,7 +874,7 @@ static void bfin_serial_set_ldisc(struct uart_port *port) | |||
817 | if (line >= port->info->port.tty->driver->num) | 874 | if (line >= port->info->port.tty->driver->num) |
818 | return; | 875 | return; |
819 | 876 | ||
820 | switch (port->info->port.tty->ldisc.num) { | 877 | switch (port->info->port.tty->termios->c_line) { |
821 | case N_IRDA: | 878 | case N_IRDA: |
822 | val = UART_GET_GCTL(&bfin_serial_ports[line]); | 879 | val = UART_GET_GCTL(&bfin_serial_ports[line]); |
823 | val |= (IREN | RPOLC); | 880 | val |= (IREN | RPOLC); |
@@ -859,8 +916,9 @@ static void __init bfin_serial_init_ports(void) | |||
859 | return; | 916 | return; |
860 | first = 0; | 917 | first = 0; |
861 | 918 | ||
862 | for (i = 0; i < nr_ports; i++) { | 919 | for (i = 0; i < nr_active_ports; i++) { |
863 | bfin_serial_ports[i].port.uartclk = get_sclk(); | 920 | bfin_serial_ports[i].port.uartclk = get_sclk(); |
921 | bfin_serial_ports[i].port.fifosize = BFIN_UART_TX_FIFO_SIZE; | ||
864 | bfin_serial_ports[i].port.ops = &bfin_serial_pops; | 922 | bfin_serial_ports[i].port.ops = &bfin_serial_pops; |
865 | bfin_serial_ports[i].port.line = i; | 923 | bfin_serial_ports[i].port.line = i; |
866 | bfin_serial_ports[i].port.iotype = UPIO_MEM; | 924 | bfin_serial_ports[i].port.iotype = UPIO_MEM; |
@@ -961,7 +1019,7 @@ bfin_serial_console_setup(struct console *co, char *options) | |||
961 | * if so, search for the first available port that does have | 1019 | * if so, search for the first available port that does have |
962 | * console support. | 1020 | * console support. |
963 | */ | 1021 | */ |
964 | if (co->index == -1 || co->index >= nr_ports) | 1022 | if (co->index == -1 || co->index >= nr_active_ports) |
965 | co->index = 0; | 1023 | co->index = 0; |
966 | uart = &bfin_serial_ports[co->index]; | 1024 | uart = &bfin_serial_ports[co->index]; |
967 | 1025 | ||
@@ -1056,7 +1114,7 @@ static __init void early_serial_write(struct console *con, const char *s, | |||
1056 | } | 1114 | } |
1057 | } | 1115 | } |
1058 | 1116 | ||
1059 | static struct __init console bfin_early_serial_console = { | 1117 | static struct __initdata console bfin_early_serial_console = { |
1060 | .name = "early_BFuart", | 1118 | .name = "early_BFuart", |
1061 | .write = early_serial_write, | 1119 | .write = early_serial_write, |
1062 | .device = uart_console_device, | 1120 | .device = uart_console_device, |
@@ -1072,7 +1130,7 @@ struct console __init *bfin_earlyserial_init(unsigned int port, | |||
1072 | struct bfin_serial_port *uart; | 1130 | struct bfin_serial_port *uart; |
1073 | struct ktermios t; | 1131 | struct ktermios t; |
1074 | 1132 | ||
1075 | if (port == -1 || port >= nr_ports) | 1133 | if (port == -1 || port >= nr_active_ports) |
1076 | port = 0; | 1134 | port = 0; |
1077 | bfin_serial_init_ports(); | 1135 | bfin_serial_init_ports(); |
1078 | bfin_early_serial_console.index = port; | 1136 | bfin_early_serial_console.index = port; |
@@ -1100,20 +1158,26 @@ static struct uart_driver bfin_serial_reg = { | |||
1100 | 1158 | ||
1101 | static int bfin_serial_suspend(struct platform_device *dev, pm_message_t state) | 1159 | static int bfin_serial_suspend(struct platform_device *dev, pm_message_t state) |
1102 | { | 1160 | { |
1103 | struct bfin_serial_port *uart = platform_get_drvdata(dev); | 1161 | int i; |
1104 | 1162 | ||
1105 | if (uart) | 1163 | for (i = 0; i < nr_active_ports; i++) { |
1106 | uart_suspend_port(&bfin_serial_reg, &uart->port); | 1164 | if (bfin_serial_ports[i].port.dev != &dev->dev) |
1165 | continue; | ||
1166 | uart_suspend_port(&bfin_serial_reg, &bfin_serial_ports[i].port); | ||
1167 | } | ||
1107 | 1168 | ||
1108 | return 0; | 1169 | return 0; |
1109 | } | 1170 | } |
1110 | 1171 | ||
1111 | static int bfin_serial_resume(struct platform_device *dev) | 1172 | static int bfin_serial_resume(struct platform_device *dev) |
1112 | { | 1173 | { |
1113 | struct bfin_serial_port *uart = platform_get_drvdata(dev); | 1174 | int i; |
1114 | 1175 | ||
1115 | if (uart) | 1176 | for (i = 0; i < nr_active_ports; i++) { |
1116 | uart_resume_port(&bfin_serial_reg, &uart->port); | 1177 | if (bfin_serial_ports[i].port.dev != &dev->dev) |
1178 | continue; | ||
1179 | uart_resume_port(&bfin_serial_reg, &bfin_serial_ports[i].port); | ||
1180 | } | ||
1117 | 1181 | ||
1118 | return 0; | 1182 | return 0; |
1119 | } | 1183 | } |
@@ -1128,32 +1192,31 @@ static int bfin_serial_probe(struct platform_device *dev) | |||
1128 | break; | 1192 | break; |
1129 | 1193 | ||
1130 | if (i < dev->num_resources) { | 1194 | if (i < dev->num_resources) { |
1131 | for (i = 0; i < nr_ports; i++, res++) { | 1195 | for (i = 0; i < nr_active_ports; i++, res++) { |
1132 | if (bfin_serial_ports[i].port.mapbase != res->start) | 1196 | if (bfin_serial_ports[i].port.mapbase != res->start) |
1133 | continue; | 1197 | continue; |
1134 | bfin_serial_ports[i].port.dev = &dev->dev; | 1198 | bfin_serial_ports[i].port.dev = &dev->dev; |
1135 | uart_add_one_port(&bfin_serial_reg, &bfin_serial_ports[i].port); | 1199 | uart_add_one_port(&bfin_serial_reg, &bfin_serial_ports[i].port); |
1136 | platform_set_drvdata(dev, &bfin_serial_ports[i]); | ||
1137 | } | 1200 | } |
1138 | } | 1201 | } |
1139 | 1202 | ||
1140 | return 0; | 1203 | return 0; |
1141 | } | 1204 | } |
1142 | 1205 | ||
1143 | static int bfin_serial_remove(struct platform_device *pdev) | 1206 | static int bfin_serial_remove(struct platform_device *dev) |
1144 | { | 1207 | { |
1145 | struct bfin_serial_port *uart = platform_get_drvdata(pdev); | 1208 | int i; |
1146 | |||
1147 | 1209 | ||
1210 | for (i = 0; i < nr_active_ports; i++) { | ||
1211 | if (bfin_serial_ports[i].port.dev != &dev->dev) | ||
1212 | continue; | ||
1213 | uart_remove_one_port(&bfin_serial_reg, &bfin_serial_ports[i].port); | ||
1214 | bfin_serial_ports[i].port.dev = NULL; | ||
1148 | #ifdef CONFIG_SERIAL_BFIN_CTSRTS | 1215 | #ifdef CONFIG_SERIAL_BFIN_CTSRTS |
1149 | gpio_free(uart->cts_pin); | 1216 | gpio_free(bfin_serial_ports[i].cts_pin); |
1150 | gpio_free(uart->rts_pin); | 1217 | gpio_free(bfin_serial_ports[i].rts_pin); |
1151 | #endif | 1218 | #endif |
1152 | 1219 | } | |
1153 | platform_set_drvdata(pdev, NULL); | ||
1154 | |||
1155 | if (uart) | ||
1156 | uart_remove_one_port(&bfin_serial_reg, &uart->port); | ||
1157 | 1220 | ||
1158 | return 0; | 1221 | return 0; |
1159 | } | 1222 | } |
diff --git a/drivers/serial/clps711x.c b/drivers/serial/clps711x.c index fc1fa9267c59..459f3420a429 100644 --- a/drivers/serial/clps711x.c +++ b/drivers/serial/clps711x.c | |||
@@ -39,7 +39,7 @@ | |||
39 | #include <linux/serial_core.h> | 39 | #include <linux/serial_core.h> |
40 | #include <linux/serial.h> | 40 | #include <linux/serial.h> |
41 | 41 | ||
42 | #include <asm/hardware.h> | 42 | #include <mach/hardware.h> |
43 | #include <asm/io.h> | 43 | #include <asm/io.h> |
44 | #include <asm/irq.h> | 44 | #include <asm/irq.h> |
45 | #include <asm/hardware/clps7111.h> | 45 | #include <asm/hardware/clps7111.h> |
diff --git a/drivers/serial/cpm_uart/cpm_uart.h b/drivers/serial/cpm_uart/cpm_uart.h index 5c76e0ae0582..7274b527a3c1 100644 --- a/drivers/serial/cpm_uart/cpm_uart.h +++ b/drivers/serial/cpm_uart/cpm_uart.h | |||
@@ -50,6 +50,15 @@ | |||
50 | 50 | ||
51 | #define SCC_WAIT_CLOSING 100 | 51 | #define SCC_WAIT_CLOSING 100 |
52 | 52 | ||
53 | #define GPIO_CTS 0 | ||
54 | #define GPIO_RTS 1 | ||
55 | #define GPIO_DCD 2 | ||
56 | #define GPIO_DSR 3 | ||
57 | #define GPIO_DTR 4 | ||
58 | #define GPIO_RI 5 | ||
59 | |||
60 | #define NUM_GPIOS (GPIO_RI+1) | ||
61 | |||
53 | struct uart_cpm_port { | 62 | struct uart_cpm_port { |
54 | struct uart_port port; | 63 | struct uart_port port; |
55 | u16 rx_nrfifos; | 64 | u16 rx_nrfifos; |
@@ -68,6 +77,7 @@ struct uart_cpm_port { | |||
68 | unsigned char *rx_buf; | 77 | unsigned char *rx_buf; |
69 | u32 flags; | 78 | u32 flags; |
70 | void (*set_lineif)(struct uart_cpm_port *); | 79 | void (*set_lineif)(struct uart_cpm_port *); |
80 | struct clk *clk; | ||
71 | u8 brg; | 81 | u8 brg; |
72 | uint dp_addr; | 82 | uint dp_addr; |
73 | void *mem_addr; | 83 | void *mem_addr; |
@@ -82,6 +92,7 @@ struct uart_cpm_port { | |||
82 | int wait_closing; | 92 | int wait_closing; |
83 | /* value to combine with opcode to form cpm command */ | 93 | /* value to combine with opcode to form cpm command */ |
84 | u32 command; | 94 | u32 command; |
95 | int gpios[NUM_GPIOS]; | ||
85 | }; | 96 | }; |
86 | 97 | ||
87 | extern int cpm_uart_nr; | 98 | extern int cpm_uart_nr; |
diff --git a/drivers/serial/cpm_uart/cpm_uart_core.c b/drivers/serial/cpm_uart/cpm_uart_core.c index a4f86927a74b..25efca5a7a1f 100644 --- a/drivers/serial/cpm_uart/cpm_uart_core.c +++ b/drivers/serial/cpm_uart/cpm_uart_core.c | |||
@@ -43,6 +43,9 @@ | |||
43 | #include <linux/dma-mapping.h> | 43 | #include <linux/dma-mapping.h> |
44 | #include <linux/fs_uart_pd.h> | 44 | #include <linux/fs_uart_pd.h> |
45 | #include <linux/of_platform.h> | 45 | #include <linux/of_platform.h> |
46 | #include <linux/gpio.h> | ||
47 | #include <linux/of_gpio.h> | ||
48 | #include <linux/clk.h> | ||
46 | 49 | ||
47 | #include <asm/io.h> | 50 | #include <asm/io.h> |
48 | #include <asm/irq.h> | 51 | #include <asm/irq.h> |
@@ -96,13 +99,41 @@ static unsigned int cpm_uart_tx_empty(struct uart_port *port) | |||
96 | 99 | ||
97 | static void cpm_uart_set_mctrl(struct uart_port *port, unsigned int mctrl) | 100 | static void cpm_uart_set_mctrl(struct uart_port *port, unsigned int mctrl) |
98 | { | 101 | { |
99 | /* Whee. Do nothing. */ | 102 | struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port; |
103 | |||
104 | if (pinfo->gpios[GPIO_RTS] >= 0) | ||
105 | gpio_set_value(pinfo->gpios[GPIO_RTS], !(mctrl & TIOCM_RTS)); | ||
106 | |||
107 | if (pinfo->gpios[GPIO_DTR] >= 0) | ||
108 | gpio_set_value(pinfo->gpios[GPIO_DTR], !(mctrl & TIOCM_DTR)); | ||
100 | } | 109 | } |
101 | 110 | ||
102 | static unsigned int cpm_uart_get_mctrl(struct uart_port *port) | 111 | static unsigned int cpm_uart_get_mctrl(struct uart_port *port) |
103 | { | 112 | { |
104 | /* Whee. Do nothing. */ | 113 | struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port; |
105 | return TIOCM_CAR | TIOCM_DSR | TIOCM_CTS; | 114 | unsigned int mctrl = TIOCM_CTS | TIOCM_DSR | TIOCM_CAR; |
115 | |||
116 | if (pinfo->gpios[GPIO_CTS] >= 0) { | ||
117 | if (gpio_get_value(pinfo->gpios[GPIO_CTS])) | ||
118 | mctrl &= ~TIOCM_CTS; | ||
119 | } | ||
120 | |||
121 | if (pinfo->gpios[GPIO_DSR] >= 0) { | ||
122 | if (gpio_get_value(pinfo->gpios[GPIO_DSR])) | ||
123 | mctrl &= ~TIOCM_DSR; | ||
124 | } | ||
125 | |||
126 | if (pinfo->gpios[GPIO_DCD] >= 0) { | ||
127 | if (gpio_get_value(pinfo->gpios[GPIO_DCD])) | ||
128 | mctrl &= ~TIOCM_CAR; | ||
129 | } | ||
130 | |||
131 | if (pinfo->gpios[GPIO_RI] >= 0) { | ||
132 | if (!gpio_get_value(pinfo->gpios[GPIO_RI])) | ||
133 | mctrl |= TIOCM_RNG; | ||
134 | } | ||
135 | |||
136 | return mctrl; | ||
106 | } | 137 | } |
107 | 138 | ||
108 | /* | 139 | /* |
@@ -566,7 +597,10 @@ static void cpm_uart_set_termios(struct uart_port *port, | |||
566 | out_be16(&sccp->scc_psmr, (sbits << 12) | scval); | 597 | out_be16(&sccp->scc_psmr, (sbits << 12) | scval); |
567 | } | 598 | } |
568 | 599 | ||
569 | cpm_set_brg(pinfo->brg - 1, baud); | 600 | if (pinfo->clk) |
601 | clk_set_rate(pinfo->clk, baud); | ||
602 | else | ||
603 | cpm_set_brg(pinfo->brg - 1, baud); | ||
570 | spin_unlock_irqrestore(&port->lock, flags); | 604 | spin_unlock_irqrestore(&port->lock, flags); |
571 | } | 605 | } |
572 | 606 | ||
@@ -991,14 +1025,23 @@ static int cpm_uart_init_port(struct device_node *np, | |||
991 | void __iomem *mem, *pram; | 1025 | void __iomem *mem, *pram; |
992 | int len; | 1026 | int len; |
993 | int ret; | 1027 | int ret; |
1028 | int i; | ||
994 | 1029 | ||
995 | data = of_get_property(np, "fsl,cpm-brg", &len); | 1030 | data = of_get_property(np, "clock", NULL); |
996 | if (!data || len != 4) { | 1031 | if (data) { |
997 | printk(KERN_ERR "CPM UART %s has no/invalid " | 1032 | struct clk *clk = clk_get(NULL, (const char*)data); |
998 | "fsl,cpm-brg property.\n", np->name); | 1033 | if (!IS_ERR(clk)) |
999 | return -EINVAL; | 1034 | pinfo->clk = clk; |
1035 | } | ||
1036 | if (!pinfo->clk) { | ||
1037 | data = of_get_property(np, "fsl,cpm-brg", &len); | ||
1038 | if (!data || len != 4) { | ||
1039 | printk(KERN_ERR "CPM UART %s has no/invalid " | ||
1040 | "fsl,cpm-brg property.\n", np->name); | ||
1041 | return -EINVAL; | ||
1042 | } | ||
1043 | pinfo->brg = *data; | ||
1000 | } | 1044 | } |
1001 | pinfo->brg = *data; | ||
1002 | 1045 | ||
1003 | data = of_get_property(np, "fsl,cpm-command", &len); | 1046 | data = of_get_property(np, "fsl,cpm-command", &len); |
1004 | if (!data || len != 4) { | 1047 | if (!data || len != 4) { |
@@ -1050,6 +1093,9 @@ static int cpm_uart_init_port(struct device_node *np, | |||
1050 | goto out_pram; | 1093 | goto out_pram; |
1051 | } | 1094 | } |
1052 | 1095 | ||
1096 | for (i = 0; i < NUM_GPIOS; i++) | ||
1097 | pinfo->gpios[i] = of_get_gpio(np, i); | ||
1098 | |||
1053 | return cpm_uart_request_port(&pinfo->port); | 1099 | return cpm_uart_request_port(&pinfo->port); |
1054 | 1100 | ||
1055 | out_pram: | 1101 | out_pram: |
diff --git a/drivers/serial/crisv10.c b/drivers/serial/crisv10.c index 8249ac490559..211c21797ce0 100644 --- a/drivers/serial/crisv10.c +++ b/drivers/serial/crisv10.c | |||
@@ -234,7 +234,7 @@ unsigned long r_alt_ser_baudrate_shadow = 0; | |||
234 | 234 | ||
235 | static struct e100_serial rs_table[] = { | 235 | static struct e100_serial rs_table[] = { |
236 | { .baud = DEF_BAUD, | 236 | { .baud = DEF_BAUD, |
237 | .port = (unsigned char *)R_SERIAL0_CTRL, | 237 | .ioport = (unsigned char *)R_SERIAL0_CTRL, |
238 | .irq = 1U << 12, /* uses DMA 6 and 7 */ | 238 | .irq = 1U << 12, /* uses DMA 6 and 7 */ |
239 | .oclrintradr = R_DMA_CH6_CLR_INTR, | 239 | .oclrintradr = R_DMA_CH6_CLR_INTR, |
240 | .ofirstadr = R_DMA_CH6_FIRST, | 240 | .ofirstadr = R_DMA_CH6_FIRST, |
@@ -288,7 +288,7 @@ static struct e100_serial rs_table[] = { | |||
288 | }, /* ttyS0 */ | 288 | }, /* ttyS0 */ |
289 | #ifndef CONFIG_SVINTO_SIM | 289 | #ifndef CONFIG_SVINTO_SIM |
290 | { .baud = DEF_BAUD, | 290 | { .baud = DEF_BAUD, |
291 | .port = (unsigned char *)R_SERIAL1_CTRL, | 291 | .ioport = (unsigned char *)R_SERIAL1_CTRL, |
292 | .irq = 1U << 16, /* uses DMA 8 and 9 */ | 292 | .irq = 1U << 16, /* uses DMA 8 and 9 */ |
293 | .oclrintradr = R_DMA_CH8_CLR_INTR, | 293 | .oclrintradr = R_DMA_CH8_CLR_INTR, |
294 | .ofirstadr = R_DMA_CH8_FIRST, | 294 | .ofirstadr = R_DMA_CH8_FIRST, |
@@ -344,7 +344,7 @@ static struct e100_serial rs_table[] = { | |||
344 | }, /* ttyS1 */ | 344 | }, /* ttyS1 */ |
345 | 345 | ||
346 | { .baud = DEF_BAUD, | 346 | { .baud = DEF_BAUD, |
347 | .port = (unsigned char *)R_SERIAL2_CTRL, | 347 | .ioport = (unsigned char *)R_SERIAL2_CTRL, |
348 | .irq = 1U << 4, /* uses DMA 2 and 3 */ | 348 | .irq = 1U << 4, /* uses DMA 2 and 3 */ |
349 | .oclrintradr = R_DMA_CH2_CLR_INTR, | 349 | .oclrintradr = R_DMA_CH2_CLR_INTR, |
350 | .ofirstadr = R_DMA_CH2_FIRST, | 350 | .ofirstadr = R_DMA_CH2_FIRST, |
@@ -398,7 +398,7 @@ static struct e100_serial rs_table[] = { | |||
398 | }, /* ttyS2 */ | 398 | }, /* ttyS2 */ |
399 | 399 | ||
400 | { .baud = DEF_BAUD, | 400 | { .baud = DEF_BAUD, |
401 | .port = (unsigned char *)R_SERIAL3_CTRL, | 401 | .ioport = (unsigned char *)R_SERIAL3_CTRL, |
402 | .irq = 1U << 8, /* uses DMA 4 and 5 */ | 402 | .irq = 1U << 8, /* uses DMA 4 and 5 */ |
403 | .oclrintradr = R_DMA_CH4_CLR_INTR, | 403 | .oclrintradr = R_DMA_CH4_CLR_INTR, |
404 | .ofirstadr = R_DMA_CH4_FIRST, | 404 | .ofirstadr = R_DMA_CH4_FIRST, |
@@ -457,7 +457,6 @@ static struct e100_serial rs_table[] = { | |||
457 | #define NR_PORTS (sizeof(rs_table)/sizeof(struct e100_serial)) | 457 | #define NR_PORTS (sizeof(rs_table)/sizeof(struct e100_serial)) |
458 | 458 | ||
459 | static struct ktermios *serial_termios[NR_PORTS]; | 459 | static struct ktermios *serial_termios[NR_PORTS]; |
460 | static struct ktermios *serial_termios_locked[NR_PORTS]; | ||
461 | #ifdef CONFIG_ETRAX_SERIAL_FAST_TIMER | 460 | #ifdef CONFIG_ETRAX_SERIAL_FAST_TIMER |
462 | static struct fast_timer fast_timers[NR_PORTS]; | 461 | static struct fast_timer fast_timers[NR_PORTS]; |
463 | #endif | 462 | #endif |
@@ -939,7 +938,7 @@ static const struct control_pins e100_modem_pins[NR_PORTS] = | |||
939 | /* Output */ | 938 | /* Output */ |
940 | #define E100_RTS_GET(info) ((info)->rx_ctrl & E100_RTS_MASK) | 939 | #define E100_RTS_GET(info) ((info)->rx_ctrl & E100_RTS_MASK) |
941 | /* Input */ | 940 | /* Input */ |
942 | #define E100_CTS_GET(info) ((info)->port[REG_STATUS] & E100_CTS_MASK) | 941 | #define E100_CTS_GET(info) ((info)->ioport[REG_STATUS] & E100_CTS_MASK) |
943 | 942 | ||
944 | /* These are typically PA or PB and 0 means 0V, 1 means 3.3V */ | 943 | /* These are typically PA or PB and 0 means 0V, 1 means 3.3V */ |
945 | /* Is an output */ | 944 | /* Is an output */ |
@@ -1092,7 +1091,7 @@ e100_rts(struct e100_serial *info, int set) | |||
1092 | local_irq_save(flags); | 1091 | local_irq_save(flags); |
1093 | info->rx_ctrl &= ~E100_RTS_MASK; | 1092 | info->rx_ctrl &= ~E100_RTS_MASK; |
1094 | info->rx_ctrl |= (set ? 0 : E100_RTS_MASK); /* RTS is active low */ | 1093 | info->rx_ctrl |= (set ? 0 : E100_RTS_MASK); /* RTS is active low */ |
1095 | info->port[REG_REC_CTRL] = info->rx_ctrl; | 1094 | info->ioport[REG_REC_CTRL] = info->rx_ctrl; |
1096 | local_irq_restore(flags); | 1095 | local_irq_restore(flags); |
1097 | #ifdef SERIAL_DEBUG_IO | 1096 | #ifdef SERIAL_DEBUG_IO |
1098 | printk("ser%i rts %i\n", info->line, set); | 1097 | printk("ser%i rts %i\n", info->line, set); |
@@ -1142,7 +1141,7 @@ e100_disable_rx(struct e100_serial *info) | |||
1142 | { | 1141 | { |
1143 | #ifndef CONFIG_SVINTO_SIM | 1142 | #ifndef CONFIG_SVINTO_SIM |
1144 | /* disable the receiver */ | 1143 | /* disable the receiver */ |
1145 | info->port[REG_REC_CTRL] = | 1144 | info->ioport[REG_REC_CTRL] = |
1146 | (info->rx_ctrl &= ~IO_MASK(R_SERIAL0_REC_CTRL, rec_enable)); | 1145 | (info->rx_ctrl &= ~IO_MASK(R_SERIAL0_REC_CTRL, rec_enable)); |
1147 | #endif | 1146 | #endif |
1148 | } | 1147 | } |
@@ -1152,7 +1151,7 @@ e100_enable_rx(struct e100_serial *info) | |||
1152 | { | 1151 | { |
1153 | #ifndef CONFIG_SVINTO_SIM | 1152 | #ifndef CONFIG_SVINTO_SIM |
1154 | /* enable the receiver */ | 1153 | /* enable the receiver */ |
1155 | info->port[REG_REC_CTRL] = | 1154 | info->ioport[REG_REC_CTRL] = |
1156 | (info->rx_ctrl |= IO_MASK(R_SERIAL0_REC_CTRL, rec_enable)); | 1155 | (info->rx_ctrl |= IO_MASK(R_SERIAL0_REC_CTRL, rec_enable)); |
1157 | #endif | 1156 | #endif |
1158 | } | 1157 | } |
@@ -1490,7 +1489,7 @@ rs_stop(struct tty_struct *tty) | |||
1490 | xoff |= IO_STATE(R_SERIAL0_XOFF, auto_xoff, enable); | 1489 | xoff |= IO_STATE(R_SERIAL0_XOFF, auto_xoff, enable); |
1491 | } | 1490 | } |
1492 | 1491 | ||
1493 | *((unsigned long *)&info->port[REG_XOFF]) = xoff; | 1492 | *((unsigned long *)&info->ioport[REG_XOFF]) = xoff; |
1494 | local_irq_restore(flags); | 1493 | local_irq_restore(flags); |
1495 | } | 1494 | } |
1496 | } | 1495 | } |
@@ -1513,7 +1512,7 @@ rs_start(struct tty_struct *tty) | |||
1513 | xoff |= IO_STATE(R_SERIAL0_XOFF, auto_xoff, enable); | 1512 | xoff |= IO_STATE(R_SERIAL0_XOFF, auto_xoff, enable); |
1514 | } | 1513 | } |
1515 | 1514 | ||
1516 | *((unsigned long *)&info->port[REG_XOFF]) = xoff; | 1515 | *((unsigned long *)&info->ioport[REG_XOFF]) = xoff; |
1517 | if (!info->uses_dma_out && | 1516 | if (!info->uses_dma_out && |
1518 | info->xmit.head != info->xmit.tail && info->xmit.buf) | 1517 | info->xmit.head != info->xmit.tail && info->xmit.buf) |
1519 | e100_enable_serial_tx_ready_irq(info); | 1518 | e100_enable_serial_tx_ready_irq(info); |
@@ -1888,7 +1887,7 @@ static void receive_chars_dma(struct e100_serial *info) | |||
1888 | handle_all_descr_data(info); | 1887 | handle_all_descr_data(info); |
1889 | 1888 | ||
1890 | /* Read the status register to detect errors */ | 1889 | /* Read the status register to detect errors */ |
1891 | rstat = info->port[REG_STATUS]; | 1890 | rstat = info->ioport[REG_STATUS]; |
1892 | if (rstat & IO_MASK(R_SERIAL0_STATUS, xoff_detect) ) { | 1891 | if (rstat & IO_MASK(R_SERIAL0_STATUS, xoff_detect) ) { |
1893 | DFLOW(DEBUG_LOG(info->line, "XOFF detect stat %x\n", rstat)); | 1892 | DFLOW(DEBUG_LOG(info->line, "XOFF detect stat %x\n", rstat)); |
1894 | } | 1893 | } |
@@ -1897,7 +1896,7 @@ static void receive_chars_dma(struct e100_serial *info) | |||
1897 | /* If we got an error, we must reset it by reading the | 1896 | /* If we got an error, we must reset it by reading the |
1898 | * data_in field | 1897 | * data_in field |
1899 | */ | 1898 | */ |
1900 | unsigned char data = info->port[REG_DATA]; | 1899 | unsigned char data = info->ioport[REG_DATA]; |
1901 | 1900 | ||
1902 | PROCSTAT(ser_stat[info->line].errors_cnt++); | 1901 | PROCSTAT(ser_stat[info->line].errors_cnt++); |
1903 | DEBUG_LOG(info->line, "#dERR: s d 0x%04X\n", | 1902 | DEBUG_LOG(info->line, "#dERR: s d 0x%04X\n", |
@@ -2077,7 +2076,7 @@ static int force_eop_if_needed(struct e100_serial *info) | |||
2077 | /* We check data_avail bit to determine if data has | 2076 | /* We check data_avail bit to determine if data has |
2078 | * arrived since last time | 2077 | * arrived since last time |
2079 | */ | 2078 | */ |
2080 | unsigned char rstat = info->port[REG_STATUS]; | 2079 | unsigned char rstat = info->ioport[REG_STATUS]; |
2081 | 2080 | ||
2082 | /* error or datavail? */ | 2081 | /* error or datavail? */ |
2083 | if (rstat & SER_ERROR_MASK) { | 2082 | if (rstat & SER_ERROR_MASK) { |
@@ -2096,7 +2095,7 @@ static int force_eop_if_needed(struct e100_serial *info) | |||
2096 | TIMERD(DEBUG_LOG(info->line, "timeout: rstat 0x%03X\n", | 2095 | TIMERD(DEBUG_LOG(info->line, "timeout: rstat 0x%03X\n", |
2097 | rstat | (info->line << 8))); | 2096 | rstat | (info->line << 8))); |
2098 | /* Read data to clear status flags */ | 2097 | /* Read data to clear status flags */ |
2099 | (void)info->port[REG_DATA]; | 2098 | (void)info->ioport[REG_DATA]; |
2100 | 2099 | ||
2101 | info->forced_eop = 0; | 2100 | info->forced_eop = 0; |
2102 | START_FLUSH_FAST_TIMER(info, "magic"); | 2101 | START_FLUSH_FAST_TIMER(info, "magic"); |
@@ -2296,7 +2295,7 @@ struct e100_serial * handle_ser_rx_interrupt_no_dma(struct e100_serial *info) | |||
2296 | } | 2295 | } |
2297 | 2296 | ||
2298 | /* Read data and status at the same time */ | 2297 | /* Read data and status at the same time */ |
2299 | data_read = *((unsigned long *)&info->port[REG_DATA_STATUS32]); | 2298 | data_read = *((unsigned long *)&info->ioport[REG_DATA_STATUS32]); |
2300 | more_data: | 2299 | more_data: |
2301 | if (data_read & IO_MASK(R_SERIAL0_READ, xoff_detect) ) { | 2300 | if (data_read & IO_MASK(R_SERIAL0_READ, xoff_detect) ) { |
2302 | DFLOW(DEBUG_LOG(info->line, "XOFF detect\n", 0)); | 2301 | DFLOW(DEBUG_LOG(info->line, "XOFF detect\n", 0)); |
@@ -2391,7 +2390,7 @@ more_data: | |||
2391 | 2390 | ||
2392 | 2391 | ||
2393 | info->icount.rx++; | 2392 | info->icount.rx++; |
2394 | data_read = *((unsigned long *)&info->port[REG_DATA_STATUS32]); | 2393 | data_read = *((unsigned long *)&info->ioport[REG_DATA_STATUS32]); |
2395 | if (data_read & IO_MASK(R_SERIAL0_READ, data_avail)) { | 2394 | if (data_read & IO_MASK(R_SERIAL0_READ, data_avail)) { |
2396 | DEBUG_LOG(info->line, "ser_rx %c in loop\n", IO_EXTRACT(R_SERIAL0_READ, data_in, data_read)); | 2395 | DEBUG_LOG(info->line, "ser_rx %c in loop\n", IO_EXTRACT(R_SERIAL0_READ, data_in, data_read)); |
2397 | goto more_data; | 2396 | goto more_data; |
@@ -2413,7 +2412,7 @@ static struct e100_serial* handle_ser_rx_interrupt(struct e100_serial *info) | |||
2413 | return handle_ser_rx_interrupt_no_dma(info); | 2412 | return handle_ser_rx_interrupt_no_dma(info); |
2414 | } | 2413 | } |
2415 | /* DMA is used */ | 2414 | /* DMA is used */ |
2416 | rstat = info->port[REG_STATUS]; | 2415 | rstat = info->ioport[REG_STATUS]; |
2417 | if (rstat & IO_MASK(R_SERIAL0_STATUS, xoff_detect) ) { | 2416 | if (rstat & IO_MASK(R_SERIAL0_STATUS, xoff_detect) ) { |
2418 | DFLOW(DEBUG_LOG(info->line, "XOFF detect\n", 0)); | 2417 | DFLOW(DEBUG_LOG(info->line, "XOFF detect\n", 0)); |
2419 | } | 2418 | } |
@@ -2426,7 +2425,7 @@ static struct e100_serial* handle_ser_rx_interrupt(struct e100_serial *info) | |||
2426 | /* If we got an error, we must reset it by reading the | 2425 | /* If we got an error, we must reset it by reading the |
2427 | * data_in field | 2426 | * data_in field |
2428 | */ | 2427 | */ |
2429 | data = info->port[REG_DATA]; | 2428 | data = info->ioport[REG_DATA]; |
2430 | DINTR1(DEBUG_LOG(info->line, "ser_rx! %c\n", data)); | 2429 | DINTR1(DEBUG_LOG(info->line, "ser_rx! %c\n", data)); |
2431 | DINTR1(DEBUG_LOG(info->line, "ser_rx err stat %02X\n", rstat)); | 2430 | DINTR1(DEBUG_LOG(info->line, "ser_rx err stat %02X\n", rstat)); |
2432 | if (!data && (rstat & SER_FRAMING_ERR_MASK)) { | 2431 | if (!data && (rstat & SER_FRAMING_ERR_MASK)) { |
@@ -2528,10 +2527,10 @@ static void handle_ser_tx_interrupt(struct e100_serial *info) | |||
2528 | unsigned char rstat; | 2527 | unsigned char rstat; |
2529 | DFLOW(DEBUG_LOG(info->line, "tx_int: xchar 0x%02X\n", info->x_char)); | 2528 | DFLOW(DEBUG_LOG(info->line, "tx_int: xchar 0x%02X\n", info->x_char)); |
2530 | local_irq_save(flags); | 2529 | local_irq_save(flags); |
2531 | rstat = info->port[REG_STATUS]; | 2530 | rstat = info->ioport[REG_STATUS]; |
2532 | DFLOW(DEBUG_LOG(info->line, "stat %x\n", rstat)); | 2531 | DFLOW(DEBUG_LOG(info->line, "stat %x\n", rstat)); |
2533 | 2532 | ||
2534 | info->port[REG_TR_DATA] = info->x_char; | 2533 | info->ioport[REG_TR_DATA] = info->x_char; |
2535 | info->icount.tx++; | 2534 | info->icount.tx++; |
2536 | info->x_char = 0; | 2535 | info->x_char = 0; |
2537 | /* We must enable since it is disabled in ser_interrupt */ | 2536 | /* We must enable since it is disabled in ser_interrupt */ |
@@ -2545,7 +2544,7 @@ static void handle_ser_tx_interrupt(struct e100_serial *info) | |||
2545 | /* We only use normal tx interrupt when sending x_char */ | 2544 | /* We only use normal tx interrupt when sending x_char */ |
2546 | DFLOW(DEBUG_LOG(info->line, "tx_int: xchar sent\n", 0)); | 2545 | DFLOW(DEBUG_LOG(info->line, "tx_int: xchar sent\n", 0)); |
2547 | local_irq_save(flags); | 2546 | local_irq_save(flags); |
2548 | rstat = info->port[REG_STATUS]; | 2547 | rstat = info->ioport[REG_STATUS]; |
2549 | DFLOW(DEBUG_LOG(info->line, "stat %x\n", rstat)); | 2548 | DFLOW(DEBUG_LOG(info->line, "stat %x\n", rstat)); |
2550 | e100_disable_serial_tx_ready_irq(info); | 2549 | e100_disable_serial_tx_ready_irq(info); |
2551 | if (info->port.tty->stopped) | 2550 | if (info->port.tty->stopped) |
@@ -2573,7 +2572,7 @@ static void handle_ser_tx_interrupt(struct e100_serial *info) | |||
2573 | DINTR2(DEBUG_LOG(info->line, "tx_int %c\n", info->xmit.buf[info->xmit.tail])); | 2572 | DINTR2(DEBUG_LOG(info->line, "tx_int %c\n", info->xmit.buf[info->xmit.tail])); |
2574 | /* Send a byte, rs485 timing is critical so turn of ints */ | 2573 | /* Send a byte, rs485 timing is critical so turn of ints */ |
2575 | local_irq_save(flags); | 2574 | local_irq_save(flags); |
2576 | info->port[REG_TR_DATA] = info->xmit.buf[info->xmit.tail]; | 2575 | info->ioport[REG_TR_DATA] = info->xmit.buf[info->xmit.tail]; |
2577 | info->xmit.tail = (info->xmit.tail + 1) & (SERIAL_XMIT_SIZE-1); | 2576 | info->xmit.tail = (info->xmit.tail + 1) & (SERIAL_XMIT_SIZE-1); |
2578 | info->icount.tx++; | 2577 | info->icount.tx++; |
2579 | if (info->xmit.head == info->xmit.tail) { | 2578 | if (info->xmit.head == info->xmit.tail) { |
@@ -2848,7 +2847,7 @@ startup(struct e100_serial * info) | |||
2848 | 2847 | ||
2849 | /* dummy read to reset any serial errors */ | 2848 | /* dummy read to reset any serial errors */ |
2850 | 2849 | ||
2851 | (void)info->port[REG_DATA]; | 2850 | (void)info->ioport[REG_DATA]; |
2852 | 2851 | ||
2853 | /* enable the interrupts */ | 2852 | /* enable the interrupts */ |
2854 | if (info->uses_dma_out) | 2853 | if (info->uses_dma_out) |
@@ -2897,7 +2896,7 @@ shutdown(struct e100_serial * info) | |||
2897 | /* shut down the transmitter and receiver */ | 2896 | /* shut down the transmitter and receiver */ |
2898 | DFLOW(DEBUG_LOG(info->line, "shutdown %i\n", info->line)); | 2897 | DFLOW(DEBUG_LOG(info->line, "shutdown %i\n", info->line)); |
2899 | e100_disable_rx(info); | 2898 | e100_disable_rx(info); |
2900 | info->port[REG_TR_CTRL] = (info->tx_ctrl &= ~0x40); | 2899 | info->ioport[REG_TR_CTRL] = (info->tx_ctrl &= ~0x40); |
2901 | 2900 | ||
2902 | /* disable interrupts, reset dma channels */ | 2901 | /* disable interrupts, reset dma channels */ |
2903 | if (info->uses_dma_in) { | 2902 | if (info->uses_dma_in) { |
@@ -2968,7 +2967,7 @@ change_speed(struct e100_serial *info) | |||
2968 | 2967 | ||
2969 | if (!info->port.tty || !info->port.tty->termios) | 2968 | if (!info->port.tty || !info->port.tty->termios) |
2970 | return; | 2969 | return; |
2971 | if (!info->port) | 2970 | if (!info->ioport) |
2972 | return; | 2971 | return; |
2973 | 2972 | ||
2974 | cflag = info->port.tty->termios->c_cflag; | 2973 | cflag = info->port.tty->termios->c_cflag; |
@@ -3037,7 +3036,7 @@ change_speed(struct e100_serial *info) | |||
3037 | 3036 | ||
3038 | info->baud = cflag_to_baud(cflag); | 3037 | info->baud = cflag_to_baud(cflag); |
3039 | #ifndef CONFIG_SVINTO_SIM | 3038 | #ifndef CONFIG_SVINTO_SIM |
3040 | info->port[REG_BAUD] = cflag_to_etrax_baud(cflag); | 3039 | info->ioport[REG_BAUD] = cflag_to_etrax_baud(cflag); |
3041 | #endif /* CONFIG_SVINTO_SIM */ | 3040 | #endif /* CONFIG_SVINTO_SIM */ |
3042 | } | 3041 | } |
3043 | 3042 | ||
@@ -3097,8 +3096,8 @@ change_speed(struct e100_serial *info) | |||
3097 | 3096 | ||
3098 | /* actually write the control regs to the hardware */ | 3097 | /* actually write the control regs to the hardware */ |
3099 | 3098 | ||
3100 | info->port[REG_TR_CTRL] = info->tx_ctrl; | 3099 | info->ioport[REG_TR_CTRL] = info->tx_ctrl; |
3101 | info->port[REG_REC_CTRL] = info->rx_ctrl; | 3100 | info->ioport[REG_REC_CTRL] = info->rx_ctrl; |
3102 | xoff = IO_FIELD(R_SERIAL0_XOFF, xoff_char, STOP_CHAR(info->port.tty)); | 3101 | xoff = IO_FIELD(R_SERIAL0_XOFF, xoff_char, STOP_CHAR(info->port.tty)); |
3103 | xoff |= IO_STATE(R_SERIAL0_XOFF, tx_stop, enable); | 3102 | xoff |= IO_STATE(R_SERIAL0_XOFF, tx_stop, enable); |
3104 | if (info->port.tty->termios->c_iflag & IXON ) { | 3103 | if (info->port.tty->termios->c_iflag & IXON ) { |
@@ -3107,7 +3106,7 @@ change_speed(struct e100_serial *info) | |||
3107 | xoff |= IO_STATE(R_SERIAL0_XOFF, auto_xoff, enable); | 3106 | xoff |= IO_STATE(R_SERIAL0_XOFF, auto_xoff, enable); |
3108 | } | 3107 | } |
3109 | 3108 | ||
3110 | *((unsigned long *)&info->port[REG_XOFF]) = xoff; | 3109 | *((unsigned long *)&info->ioport[REG_XOFF]) = xoff; |
3111 | local_irq_restore(flags); | 3110 | local_irq_restore(flags); |
3112 | #endif /* !CONFIG_SVINTO_SIM */ | 3111 | #endif /* !CONFIG_SVINTO_SIM */ |
3113 | 3112 | ||
@@ -3156,7 +3155,7 @@ static int rs_raw_write(struct tty_struct *tty, | |||
3156 | #ifdef SERIAL_DEBUG_DATA | 3155 | #ifdef SERIAL_DEBUG_DATA |
3157 | if (info->line == SERIAL_DEBUG_LINE) | 3156 | if (info->line == SERIAL_DEBUG_LINE) |
3158 | printk("rs_raw_write (%d), status %d\n", | 3157 | printk("rs_raw_write (%d), status %d\n", |
3159 | count, info->port[REG_STATUS]); | 3158 | count, info->ioport[REG_STATUS]); |
3160 | #endif | 3159 | #endif |
3161 | 3160 | ||
3162 | #ifdef CONFIG_SVINTO_SIM | 3161 | #ifdef CONFIG_SVINTO_SIM |
@@ -3427,7 +3426,7 @@ get_serial_info(struct e100_serial * info, | |||
3427 | memset(&tmp, 0, sizeof(tmp)); | 3426 | memset(&tmp, 0, sizeof(tmp)); |
3428 | tmp.type = info->type; | 3427 | tmp.type = info->type; |
3429 | tmp.line = info->line; | 3428 | tmp.line = info->line; |
3430 | tmp.port = (int)info->port; | 3429 | tmp.port = (int)info->ioport; |
3431 | tmp.irq = info->irq; | 3430 | tmp.irq = info->irq; |
3432 | tmp.flags = info->flags; | 3431 | tmp.flags = info->flags; |
3433 | tmp.baud_base = info->baud_base; | 3432 | tmp.baud_base = info->baud_base; |
@@ -3557,14 +3556,14 @@ char *get_control_state_str(int MLines, char *s) | |||
3557 | } | 3556 | } |
3558 | #endif | 3557 | #endif |
3559 | 3558 | ||
3560 | static void | 3559 | static int |
3561 | rs_break(struct tty_struct *tty, int break_state) | 3560 | rs_break(struct tty_struct *tty, int break_state) |
3562 | { | 3561 | { |
3563 | struct e100_serial *info = (struct e100_serial *)tty->driver_data; | 3562 | struct e100_serial *info = (struct e100_serial *)tty->driver_data; |
3564 | unsigned long flags; | 3563 | unsigned long flags; |
3565 | 3564 | ||
3566 | if (!info->port) | 3565 | if (!info->ioport) |
3567 | return; | 3566 | return -EIO; |
3568 | 3567 | ||
3569 | local_irq_save(flags); | 3568 | local_irq_save(flags); |
3570 | if (break_state == -1) { | 3569 | if (break_state == -1) { |
@@ -3575,8 +3574,9 @@ rs_break(struct tty_struct *tty, int break_state) | |||
3575 | /* Set bit 7 (txd) and 6 (tr_enable) */ | 3574 | /* Set bit 7 (txd) and 6 (tr_enable) */ |
3576 | info->tx_ctrl |= (0x80 | 0x40); | 3575 | info->tx_ctrl |= (0x80 | 0x40); |
3577 | } | 3576 | } |
3578 | info->port[REG_TR_CTRL] = info->tx_ctrl; | 3577 | info->ioport[REG_TR_CTRL] = info->tx_ctrl; |
3579 | local_irq_restore(flags); | 3578 | local_irq_restore(flags); |
3579 | return 0; | ||
3580 | } | 3580 | } |
3581 | 3581 | ||
3582 | static int | 3582 | static int |
@@ -4231,9 +4231,9 @@ static int line_info(char *buf, struct e100_serial *info) | |||
4231 | unsigned long tmp; | 4231 | unsigned long tmp; |
4232 | 4232 | ||
4233 | ret = sprintf(buf, "%d: uart:E100 port:%lX irq:%d", | 4233 | ret = sprintf(buf, "%d: uart:E100 port:%lX irq:%d", |
4234 | info->line, (unsigned long)info->port, info->irq); | 4234 | info->line, (unsigned long)info->ioport, info->irq); |
4235 | 4235 | ||
4236 | if (!info->port || (info->type == PORT_UNKNOWN)) { | 4236 | if (!info->ioport || (info->type == PORT_UNKNOWN)) { |
4237 | ret += sprintf(buf+ret, "\n"); | 4237 | ret += sprintf(buf+ret, "\n"); |
4238 | return ret; | 4238 | return ret; |
4239 | } | 4239 | } |
@@ -4281,7 +4281,7 @@ static int line_info(char *buf, struct e100_serial *info) | |||
4281 | } | 4281 | } |
4282 | 4282 | ||
4283 | { | 4283 | { |
4284 | unsigned char rstat = info->port[REG_STATUS]; | 4284 | unsigned char rstat = info->ioport[REG_STATUS]; |
4285 | if (rstat & IO_MASK(R_SERIAL0_STATUS, xoff_detect) ) | 4285 | if (rstat & IO_MASK(R_SERIAL0_STATUS, xoff_detect) ) |
4286 | ret += sprintf(buf+ret, " xoff_detect:1"); | 4286 | ret += sprintf(buf+ret, " xoff_detect:1"); |
4287 | } | 4287 | } |
@@ -4418,6 +4418,7 @@ rs_init(void) | |||
4418 | rs485_pa_bit)) { | 4418 | rs485_pa_bit)) { |
4419 | printk(KERN_CRIT "ETRAX100LX serial: Could not allocate " | 4419 | printk(KERN_CRIT "ETRAX100LX serial: Could not allocate " |
4420 | "RS485 pin\n"); | 4420 | "RS485 pin\n"); |
4421 | put_tty_driver(driver); | ||
4421 | return -EBUSY; | 4422 | return -EBUSY; |
4422 | } | 4423 | } |
4423 | #endif | 4424 | #endif |
@@ -4426,6 +4427,7 @@ rs_init(void) | |||
4426 | rs485_port_g_bit)) { | 4427 | rs485_port_g_bit)) { |
4427 | printk(KERN_CRIT "ETRAX100LX serial: Could not allocate " | 4428 | printk(KERN_CRIT "ETRAX100LX serial: Could not allocate " |
4428 | "RS485 pin\n"); | 4429 | "RS485 pin\n"); |
4430 | put_tty_driver(driver); | ||
4429 | return -EBUSY; | 4431 | return -EBUSY; |
4430 | } | 4432 | } |
4431 | #endif | 4433 | #endif |
@@ -4445,8 +4447,6 @@ rs_init(void) | |||
4445 | driver->init_termios.c_ispeed = 115200; | 4447 | driver->init_termios.c_ispeed = 115200; |
4446 | driver->init_termios.c_ospeed = 115200; | 4448 | driver->init_termios.c_ospeed = 115200; |
4447 | driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV; | 4449 | driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV; |
4448 | driver->termios = serial_termios; | ||
4449 | driver->termios_locked = serial_termios_locked; | ||
4450 | 4450 | ||
4451 | tty_set_operations(driver, &rs_ops); | 4451 | tty_set_operations(driver, &rs_ops); |
4452 | serial_driver = driver; | 4452 | serial_driver = driver; |
@@ -4502,7 +4502,7 @@ rs_init(void) | |||
4502 | 4502 | ||
4503 | if (info->enabled) { | 4503 | if (info->enabled) { |
4504 | printk(KERN_INFO "%s%d at 0x%x is a builtin UART with DMA\n", | 4504 | printk(KERN_INFO "%s%d at 0x%x is a builtin UART with DMA\n", |
4505 | serial_driver->name, info->line, (unsigned int)info->port); | 4505 | serial_driver->name, info->line, (unsigned int)info->ioport); |
4506 | } | 4506 | } |
4507 | } | 4507 | } |
4508 | #ifdef CONFIG_ETRAX_FAST_TIMER | 4508 | #ifdef CONFIG_ETRAX_FAST_TIMER |
diff --git a/drivers/serial/crisv10.h b/drivers/serial/crisv10.h index ccd0f32b7372..e3c5c8c3c09b 100644 --- a/drivers/serial/crisv10.h +++ b/drivers/serial/crisv10.h | |||
@@ -36,8 +36,9 @@ struct etrax_recv_buffer { | |||
36 | }; | 36 | }; |
37 | 37 | ||
38 | struct e100_serial { | 38 | struct e100_serial { |
39 | struct tty_port port; | ||
39 | int baud; | 40 | int baud; |
40 | volatile u8 *port; /* R_SERIALx_CTRL */ | 41 | volatile u8 *ioport; /* R_SERIALx_CTRL */ |
41 | u32 irq; /* bitnr in R_IRQ_MASK2 for dmaX_descr */ | 42 | u32 irq; /* bitnr in R_IRQ_MASK2 for dmaX_descr */ |
42 | 43 | ||
43 | /* Output registers */ | 44 | /* Output registers */ |
diff --git a/drivers/serial/imx.c b/drivers/serial/imx.c index e0da4dc7bbf6..3f90f1bbbbcd 100644 --- a/drivers/serial/imx.c +++ b/drivers/serial/imx.c | |||
@@ -44,8 +44,8 @@ | |||
44 | 44 | ||
45 | #include <asm/io.h> | 45 | #include <asm/io.h> |
46 | #include <asm/irq.h> | 46 | #include <asm/irq.h> |
47 | #include <asm/hardware.h> | 47 | #include <mach/hardware.h> |
48 | #include <asm/arch/imx-uart.h> | 48 | #include <mach/imx-uart.h> |
49 | 49 | ||
50 | /* Register definitions */ | 50 | /* Register definitions */ |
51 | #define URXD0 0x0 /* Receiver Register */ | 51 | #define URXD0 0x0 /* Receiver Register */ |
@@ -127,8 +127,13 @@ | |||
127 | #define UCR3_RXDSEN (1<<6) /* Receive status interrupt enable */ | 127 | #define UCR3_RXDSEN (1<<6) /* Receive status interrupt enable */ |
128 | #define UCR3_AIRINTEN (1<<5) /* Async IR wake interrupt enable */ | 128 | #define UCR3_AIRINTEN (1<<5) /* Async IR wake interrupt enable */ |
129 | #define UCR3_AWAKEN (1<<4) /* Async wake interrupt enable */ | 129 | #define UCR3_AWAKEN (1<<4) /* Async wake interrupt enable */ |
130 | #define UCR3_REF25 (1<<3) /* Ref freq 25 MHz */ | 130 | #ifdef CONFIG_ARCH_IMX |
131 | #define UCR3_REF30 (1<<2) /* Ref Freq 30 MHz */ | 131 | #define UCR3_REF25 (1<<3) /* Ref freq 25 MHz, only on mx1 */ |
132 | #define UCR3_REF30 (1<<2) /* Ref Freq 30 MHz, only on mx1 */ | ||
133 | #endif | ||
134 | #if defined CONFIG_ARCH_MX2 || defined CONFIG_ARCH_MX3 | ||
135 | #define UCR3_RXDMUXSEL (1<<2) /* RXD Muxed Input Select, on mx2/mx3 */ | ||
136 | #endif | ||
132 | #define UCR3_INVT (1<<1) /* Inverted Infrared transmission */ | 137 | #define UCR3_INVT (1<<1) /* Inverted Infrared transmission */ |
133 | #define UCR3_BPEN (1<<0) /* Preset registers enable */ | 138 | #define UCR3_BPEN (1<<0) /* Preset registers enable */ |
134 | #define UCR4_CTSTL_32 (32<<10) /* CTS trigger level (32 chars) */ | 139 | #define UCR4_CTSTL_32 (32<<10) /* CTS trigger level (32 chars) */ |
@@ -445,7 +450,7 @@ static irqreturn_t imx_int(int irq, void *dev_id) | |||
445 | readl(sport->port.membase + UCR1) & UCR1_TXMPTYEN) | 450 | readl(sport->port.membase + UCR1) & UCR1_TXMPTYEN) |
446 | imx_txint(irq, dev_id); | 451 | imx_txint(irq, dev_id); |
447 | 452 | ||
448 | if (sts & USR1_RTSS) | 453 | if (sts & USR1_RTSD) |
449 | imx_rtsint(irq, dev_id); | 454 | imx_rtsint(irq, dev_id); |
450 | 455 | ||
451 | return IRQ_HANDLED; | 456 | return IRQ_HANDLED; |
@@ -598,6 +603,12 @@ static int imx_startup(struct uart_port *port) | |||
598 | temp |= (UCR2_RXEN | UCR2_TXEN); | 603 | temp |= (UCR2_RXEN | UCR2_TXEN); |
599 | writel(temp, sport->port.membase + UCR2); | 604 | writel(temp, sport->port.membase + UCR2); |
600 | 605 | ||
606 | #if defined CONFIG_ARCH_MX2 || defined CONFIG_ARCH_MX3 | ||
607 | temp = readl(sport->port.membase + UCR3); | ||
608 | temp |= UCR3_RXDMUXSEL; | ||
609 | writel(temp, sport->port.membase + UCR3); | ||
610 | #endif | ||
611 | |||
601 | /* | 612 | /* |
602 | * Enable modem status interrupts | 613 | * Enable modem status interrupts |
603 | */ | 614 | */ |
@@ -1133,13 +1144,19 @@ static int serial_imx_probe(struct platform_device *pdev) | |||
1133 | if(pdata && (pdata->flags & IMXUART_HAVE_RTSCTS)) | 1144 | if(pdata && (pdata->flags & IMXUART_HAVE_RTSCTS)) |
1134 | sport->have_rtscts = 1; | 1145 | sport->have_rtscts = 1; |
1135 | 1146 | ||
1136 | if (pdata->init) | 1147 | if (pdata->init) { |
1137 | pdata->init(pdev); | 1148 | ret = pdata->init(pdev); |
1149 | if (ret) | ||
1150 | goto clkput; | ||
1151 | } | ||
1138 | 1152 | ||
1139 | uart_add_one_port(&imx_reg, &sport->port); | 1153 | uart_add_one_port(&imx_reg, &sport->port); |
1140 | platform_set_drvdata(pdev, &sport->port); | 1154 | platform_set_drvdata(pdev, &sport->port); |
1141 | 1155 | ||
1142 | return 0; | 1156 | return 0; |
1157 | clkput: | ||
1158 | clk_put(sport->clk); | ||
1159 | clk_disable(sport->clk); | ||
1143 | unmap: | 1160 | unmap: |
1144 | iounmap(sport->port.membase); | 1161 | iounmap(sport->port.membase); |
1145 | free: | 1162 | free: |
diff --git a/drivers/serial/mcfserial.c b/drivers/serial/mcfserial.c deleted file mode 100644 index fbe3835f6b77..000000000000 --- a/drivers/serial/mcfserial.c +++ /dev/null | |||
@@ -1,1965 +0,0 @@ | |||
1 | #warning This driver is deprecated. Check Kconfig for details. | ||
2 | /* | ||
3 | * mcfserial.c -- serial driver for ColdFire internal UARTS. | ||
4 | * | ||
5 | * Copyright (C) 1999-2003 Greg Ungerer <gerg@snapgear.com> | ||
6 | * Copyright (c) 2000-2001 Lineo, Inc. <www.lineo.com> | ||
7 | * Copyright (C) 2001-2002 SnapGear Inc. <www.snapgear.com> | ||
8 | * | ||
9 | * Based on code from 68332serial.c which was: | ||
10 | * | ||
11 | * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu) | ||
12 | * Copyright (C) 1998 TSHG | ||
13 | * Copyright (c) 1999 Rt-Control Inc. <jeff@uclinux.org> | ||
14 | * | ||
15 | * Changes: | ||
16 | * 08/07/2003 Daniele Bellucci <bellucda@tiscali.it> | ||
17 | * some cleanups in mcfrs_write. | ||
18 | * | ||
19 | */ | ||
20 | |||
21 | #include <linux/module.h> | ||
22 | #include <linux/errno.h> | ||
23 | #include <linux/signal.h> | ||
24 | #include <linux/sched.h> | ||
25 | #include <linux/timer.h> | ||
26 | #include <linux/wait.h> | ||
27 | #include <linux/interrupt.h> | ||
28 | #include <linux/tty.h> | ||
29 | #include <linux/tty_flip.h> | ||
30 | #include <linux/string.h> | ||
31 | #include <linux/fcntl.h> | ||
32 | #include <linux/mm.h> | ||
33 | #include <linux/kernel.h> | ||
34 | #include <linux/serial.h> | ||
35 | #include <linux/serialP.h> | ||
36 | #include <linux/console.h> | ||
37 | #include <linux/init.h> | ||
38 | #include <linux/bitops.h> | ||
39 | #include <linux/delay.h> | ||
40 | |||
41 | #include <asm/io.h> | ||
42 | #include <asm/irq.h> | ||
43 | #include <asm/system.h> | ||
44 | #include <asm/delay.h> | ||
45 | #include <asm/coldfire.h> | ||
46 | #include <asm/mcfsim.h> | ||
47 | #include <asm/mcfuart.h> | ||
48 | #include <asm/nettel.h> | ||
49 | #include <asm/uaccess.h> | ||
50 | #include "mcfserial.h" | ||
51 | |||
52 | struct timer_list mcfrs_timer_struct; | ||
53 | |||
54 | /* | ||
55 | * Default console baud rate, we use this as the default | ||
56 | * for all ports so init can just open /dev/console and | ||
57 | * keep going. Perhaps one day the cflag settings for the | ||
58 | * console can be used instead. | ||
59 | */ | ||
60 | #if defined(CONFIG_HW_FEITH) | ||
61 | #define CONSOLE_BAUD_RATE 38400 | ||
62 | #define DEFAULT_CBAUD B38400 | ||
63 | #elif defined(CONFIG_MOD5272) || defined(CONFIG_M5208EVB) || \ | ||
64 | defined(CONFIG_M5329EVB) || defined(CONFIG_GILBARCO) | ||
65 | #define CONSOLE_BAUD_RATE 115200 | ||
66 | #define DEFAULT_CBAUD B115200 | ||
67 | #elif defined(CONFIG_ARNEWSH) || defined(CONFIG_FREESCALE) || \ | ||
68 | defined(CONFIG_senTec) || defined(CONFIG_SNEHA) || defined(CONFIG_AVNET) | ||
69 | #define CONSOLE_BAUD_RATE 19200 | ||
70 | #define DEFAULT_CBAUD B19200 | ||
71 | #endif | ||
72 | |||
73 | #ifndef CONSOLE_BAUD_RATE | ||
74 | #define CONSOLE_BAUD_RATE 9600 | ||
75 | #define DEFAULT_CBAUD B9600 | ||
76 | #endif | ||
77 | |||
78 | int mcfrs_console_inited = 0; | ||
79 | int mcfrs_console_port = -1; | ||
80 | int mcfrs_console_baud = CONSOLE_BAUD_RATE; | ||
81 | int mcfrs_console_cbaud = DEFAULT_CBAUD; | ||
82 | |||
83 | /* | ||
84 | * Driver data structures. | ||
85 | */ | ||
86 | static struct tty_driver *mcfrs_serial_driver; | ||
87 | |||
88 | /* number of characters left in xmit buffer before we ask for more */ | ||
89 | #define WAKEUP_CHARS 256 | ||
90 | |||
91 | /* Debugging... | ||
92 | */ | ||
93 | #undef SERIAL_DEBUG_OPEN | ||
94 | #undef SERIAL_DEBUG_FLOW | ||
95 | |||
96 | #if defined(CONFIG_M523x) || defined(CONFIG_M527x) || defined(CONFIG_M528x) || \ | ||
97 | defined(CONFIG_M520x) || defined(CONFIG_M532x) | ||
98 | #define IRQBASE (MCFINT_VECBASE+MCFINT_UART0) | ||
99 | #else | ||
100 | #define IRQBASE 73 | ||
101 | #endif | ||
102 | |||
103 | /* | ||
104 | * Configuration table, UARTs to look for at startup. | ||
105 | */ | ||
106 | static struct mcf_serial mcfrs_table[] = { | ||
107 | { /* ttyS0 */ | ||
108 | .magic = 0, | ||
109 | .addr = (volatile unsigned char *) (MCF_MBAR+MCFUART_BASE1), | ||
110 | .irq = IRQBASE, | ||
111 | .flags = ASYNC_BOOT_AUTOCONF, | ||
112 | }, | ||
113 | #ifdef MCFUART_BASE2 | ||
114 | { /* ttyS1 */ | ||
115 | .magic = 0, | ||
116 | .addr = (volatile unsigned char *) (MCF_MBAR+MCFUART_BASE2), | ||
117 | .irq = IRQBASE+1, | ||
118 | .flags = ASYNC_BOOT_AUTOCONF, | ||
119 | }, | ||
120 | #endif | ||
121 | #ifdef MCFUART_BASE3 | ||
122 | { /* ttyS2 */ | ||
123 | .magic = 0, | ||
124 | .addr = (volatile unsigned char *) (MCF_MBAR+MCFUART_BASE3), | ||
125 | .irq = IRQBASE+2, | ||
126 | .flags = ASYNC_BOOT_AUTOCONF, | ||
127 | }, | ||
128 | #endif | ||
129 | #ifdef MCFUART_BASE4 | ||
130 | { /* ttyS3 */ | ||
131 | .magic = 0, | ||
132 | .addr = (volatile unsigned char *) (MCF_MBAR+MCFUART_BASE4), | ||
133 | .irq = IRQBASE+3, | ||
134 | .flags = ASYNC_BOOT_AUTOCONF, | ||
135 | }, | ||
136 | #endif | ||
137 | }; | ||
138 | |||
139 | |||
140 | #define NR_PORTS (sizeof(mcfrs_table) / sizeof(struct mcf_serial)) | ||
141 | |||
142 | /* | ||
143 | * This is used to figure out the divisor speeds and the timeouts. | ||
144 | */ | ||
145 | static int mcfrs_baud_table[] = { | ||
146 | 0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800, | ||
147 | 9600, 19200, 38400, 57600, 115200, 230400, 460800, 0 | ||
148 | }; | ||
149 | #define MCFRS_BAUD_TABLE_SIZE \ | ||
150 | (sizeof(mcfrs_baud_table)/sizeof(mcfrs_baud_table[0])) | ||
151 | |||
152 | |||
153 | #ifdef CONFIG_MAGIC_SYSRQ | ||
154 | /* | ||
155 | * Magic system request keys. Used for debugging... | ||
156 | */ | ||
157 | extern int magic_sysrq_key(int ch); | ||
158 | #endif | ||
159 | |||
160 | |||
161 | /* | ||
162 | * Forware declarations... | ||
163 | */ | ||
164 | static void mcfrs_change_speed(struct mcf_serial *info); | ||
165 | static void mcfrs_wait_until_sent(struct tty_struct *tty, int timeout); | ||
166 | |||
167 | |||
168 | static inline int serial_paranoia_check(struct mcf_serial *info, | ||
169 | char *name, const char *routine) | ||
170 | { | ||
171 | #ifdef SERIAL_PARANOIA_CHECK | ||
172 | static const char badmagic[] = | ||
173 | "MCFRS(warning): bad magic number for serial struct %s in %s\n"; | ||
174 | static const char badinfo[] = | ||
175 | "MCFRS(warning): null mcf_serial for %s in %s\n"; | ||
176 | |||
177 | if (!info) { | ||
178 | printk(badinfo, name, routine); | ||
179 | return 1; | ||
180 | } | ||
181 | if (info->magic != SERIAL_MAGIC) { | ||
182 | printk(badmagic, name, routine); | ||
183 | return 1; | ||
184 | } | ||
185 | #endif | ||
186 | return 0; | ||
187 | } | ||
188 | |||
189 | /* | ||
190 | * Sets or clears DTR and RTS on the requested line. | ||
191 | */ | ||
192 | static void mcfrs_setsignals(struct mcf_serial *info, int dtr, int rts) | ||
193 | { | ||
194 | volatile unsigned char *uartp; | ||
195 | unsigned long flags; | ||
196 | |||
197 | #if 0 | ||
198 | printk("%s(%d): mcfrs_setsignals(info=%x,dtr=%d,rts=%d)\n", | ||
199 | __FILE__, __LINE__, info, dtr, rts); | ||
200 | #endif | ||
201 | |||
202 | local_irq_save(flags); | ||
203 | if (dtr >= 0) { | ||
204 | #ifdef MCFPP_DTR0 | ||
205 | if (info->line) | ||
206 | mcf_setppdata(MCFPP_DTR1, (dtr ? 0 : MCFPP_DTR1)); | ||
207 | else | ||
208 | mcf_setppdata(MCFPP_DTR0, (dtr ? 0 : MCFPP_DTR0)); | ||
209 | #endif | ||
210 | } | ||
211 | if (rts >= 0) { | ||
212 | uartp = info->addr; | ||
213 | if (rts) { | ||
214 | info->sigs |= TIOCM_RTS; | ||
215 | uartp[MCFUART_UOP1] = MCFUART_UOP_RTS; | ||
216 | } else { | ||
217 | info->sigs &= ~TIOCM_RTS; | ||
218 | uartp[MCFUART_UOP0] = MCFUART_UOP_RTS; | ||
219 | } | ||
220 | } | ||
221 | local_irq_restore(flags); | ||
222 | return; | ||
223 | } | ||
224 | |||
225 | /* | ||
226 | * Gets values of serial signals. | ||
227 | */ | ||
228 | static int mcfrs_getsignals(struct mcf_serial *info) | ||
229 | { | ||
230 | volatile unsigned char *uartp; | ||
231 | unsigned long flags; | ||
232 | int sigs; | ||
233 | #if defined(CONFIG_NETtel) && defined(CONFIG_M5307) | ||
234 | unsigned short ppdata; | ||
235 | #endif | ||
236 | |||
237 | #if 0 | ||
238 | printk("%s(%d): mcfrs_getsignals(info=%x)\n", __FILE__, __LINE__); | ||
239 | #endif | ||
240 | |||
241 | local_irq_save(flags); | ||
242 | uartp = info->addr; | ||
243 | sigs = (uartp[MCFUART_UIPR] & MCFUART_UIPR_CTS) ? 0 : TIOCM_CTS; | ||
244 | sigs |= (info->sigs & TIOCM_RTS); | ||
245 | |||
246 | #ifdef MCFPP_DCD0 | ||
247 | { | ||
248 | unsigned int ppdata; | ||
249 | ppdata = mcf_getppdata(); | ||
250 | if (info->line == 0) { | ||
251 | sigs |= (ppdata & MCFPP_DCD0) ? 0 : TIOCM_CD; | ||
252 | sigs |= (ppdata & MCFPP_DTR0) ? 0 : TIOCM_DTR; | ||
253 | } else if (info->line == 1) { | ||
254 | sigs |= (ppdata & MCFPP_DCD1) ? 0 : TIOCM_CD; | ||
255 | sigs |= (ppdata & MCFPP_DTR1) ? 0 : TIOCM_DTR; | ||
256 | } | ||
257 | } | ||
258 | #endif | ||
259 | |||
260 | local_irq_restore(flags); | ||
261 | return(sigs); | ||
262 | } | ||
263 | |||
264 | /* | ||
265 | * ------------------------------------------------------------ | ||
266 | * mcfrs_stop() and mcfrs_start() | ||
267 | * | ||
268 | * This routines are called before setting or resetting tty->stopped. | ||
269 | * They enable or disable transmitter interrupts, as necessary. | ||
270 | * ------------------------------------------------------------ | ||
271 | */ | ||
272 | static void mcfrs_stop(struct tty_struct *tty) | ||
273 | { | ||
274 | volatile unsigned char *uartp; | ||
275 | struct mcf_serial *info = (struct mcf_serial *)tty->driver_data; | ||
276 | unsigned long flags; | ||
277 | |||
278 | if (serial_paranoia_check(info, tty->name, "mcfrs_stop")) | ||
279 | return; | ||
280 | |||
281 | local_irq_save(flags); | ||
282 | uartp = info->addr; | ||
283 | info->imr &= ~MCFUART_UIR_TXREADY; | ||
284 | uartp[MCFUART_UIMR] = info->imr; | ||
285 | local_irq_restore(flags); | ||
286 | } | ||
287 | |||
288 | static void mcfrs_start(struct tty_struct *tty) | ||
289 | { | ||
290 | volatile unsigned char *uartp; | ||
291 | struct mcf_serial *info = (struct mcf_serial *)tty->driver_data; | ||
292 | unsigned long flags; | ||
293 | |||
294 | if (serial_paranoia_check(info, tty->name, "mcfrs_start")) | ||
295 | return; | ||
296 | |||
297 | local_irq_save(flags); | ||
298 | if (info->xmit_cnt && info->xmit_buf) { | ||
299 | uartp = info->addr; | ||
300 | info->imr |= MCFUART_UIR_TXREADY; | ||
301 | uartp[MCFUART_UIMR] = info->imr; | ||
302 | } | ||
303 | local_irq_restore(flags); | ||
304 | } | ||
305 | |||
306 | /* | ||
307 | * ---------------------------------------------------------------------- | ||
308 | * | ||
309 | * Here starts the interrupt handling routines. All of the following | ||
310 | * subroutines are declared as inline and are folded into | ||
311 | * mcfrs_interrupt(). They were separated out for readability's sake. | ||
312 | * | ||
313 | * Note: mcfrs_interrupt() is a "fast" interrupt, which means that it | ||
314 | * runs with interrupts turned off. People who may want to modify | ||
315 | * mcfrs_interrupt() should try to keep the interrupt handler as fast as | ||
316 | * possible. After you are done making modifications, it is not a bad | ||
317 | * idea to do: | ||
318 | * | ||
319 | * gcc -S -DKERNEL -Wall -Wstrict-prototypes -O6 -fomit-frame-pointer serial.c | ||
320 | * | ||
321 | * and look at the resulting assemble code in serial.s. | ||
322 | * | ||
323 | * - Ted Ts'o (tytso@mit.edu), 7-Mar-93 | ||
324 | * ----------------------------------------------------------------------- | ||
325 | */ | ||
326 | |||
327 | static inline void receive_chars(struct mcf_serial *info) | ||
328 | { | ||
329 | volatile unsigned char *uartp; | ||
330 | struct tty_struct *tty = info->port.tty; | ||
331 | unsigned char status, ch, flag; | ||
332 | |||
333 | if (!tty) | ||
334 | return; | ||
335 | |||
336 | uartp = info->addr; | ||
337 | |||
338 | while ((status = uartp[MCFUART_USR]) & MCFUART_USR_RXREADY) { | ||
339 | ch = uartp[MCFUART_URB]; | ||
340 | info->stats.rx++; | ||
341 | |||
342 | #ifdef CONFIG_MAGIC_SYSRQ | ||
343 | if (mcfrs_console_inited && (info->line == mcfrs_console_port)) { | ||
344 | if (magic_sysrq_key(ch)) | ||
345 | continue; | ||
346 | } | ||
347 | #endif | ||
348 | |||
349 | flag = TTY_NORMAL; | ||
350 | if (status & MCFUART_USR_RXERR) { | ||
351 | uartp[MCFUART_UCR] = MCFUART_UCR_CMDRESETERR; | ||
352 | if (status & MCFUART_USR_RXBREAK) { | ||
353 | info->stats.rxbreak++; | ||
354 | flag = TTY_BREAK; | ||
355 | } else if (status & MCFUART_USR_RXPARITY) { | ||
356 | info->stats.rxparity++; | ||
357 | flag = TTY_PARITY; | ||
358 | } else if (status & MCFUART_USR_RXOVERRUN) { | ||
359 | info->stats.rxoverrun++; | ||
360 | flag = TTY_OVERRUN; | ||
361 | } else if (status & MCFUART_USR_RXFRAMING) { | ||
362 | info->stats.rxframing++; | ||
363 | flag = TTY_FRAME; | ||
364 | } | ||
365 | } | ||
366 | tty_insert_flip_char(tty, ch, flag); | ||
367 | } | ||
368 | tty_schedule_flip(tty); | ||
369 | return; | ||
370 | } | ||
371 | |||
372 | static inline void transmit_chars(struct mcf_serial *info) | ||
373 | { | ||
374 | volatile unsigned char *uartp; | ||
375 | |||
376 | uartp = info->addr; | ||
377 | |||
378 | if (info->x_char) { | ||
379 | /* Send special char - probably flow control */ | ||
380 | uartp[MCFUART_UTB] = info->x_char; | ||
381 | info->x_char = 0; | ||
382 | info->stats.tx++; | ||
383 | } | ||
384 | |||
385 | if ((info->xmit_cnt <= 0) || info->port.tty->stopped) { | ||
386 | info->imr &= ~MCFUART_UIR_TXREADY; | ||
387 | uartp[MCFUART_UIMR] = info->imr; | ||
388 | return; | ||
389 | } | ||
390 | |||
391 | while (uartp[MCFUART_USR] & MCFUART_USR_TXREADY) { | ||
392 | uartp[MCFUART_UTB] = info->xmit_buf[info->xmit_tail++]; | ||
393 | info->xmit_tail = info->xmit_tail & (SERIAL_XMIT_SIZE-1); | ||
394 | info->stats.tx++; | ||
395 | if (--info->xmit_cnt <= 0) | ||
396 | break; | ||
397 | } | ||
398 | |||
399 | if (info->xmit_cnt < WAKEUP_CHARS) | ||
400 | schedule_work(&info->tqueue); | ||
401 | return; | ||
402 | } | ||
403 | |||
404 | /* | ||
405 | * This is the serial driver's generic interrupt routine | ||
406 | */ | ||
407 | irqreturn_t mcfrs_interrupt(int irq, void *dev_id) | ||
408 | { | ||
409 | struct mcf_serial *info; | ||
410 | unsigned char isr; | ||
411 | |||
412 | info = &mcfrs_table[(irq - IRQBASE)]; | ||
413 | isr = info->addr[MCFUART_UISR] & info->imr; | ||
414 | |||
415 | if (isr & MCFUART_UIR_RXREADY) | ||
416 | receive_chars(info); | ||
417 | if (isr & MCFUART_UIR_TXREADY) | ||
418 | transmit_chars(info); | ||
419 | return IRQ_HANDLED; | ||
420 | } | ||
421 | |||
422 | /* | ||
423 | * ------------------------------------------------------------------- | ||
424 | * Here ends the serial interrupt routines. | ||
425 | * ------------------------------------------------------------------- | ||
426 | */ | ||
427 | |||
428 | static void mcfrs_offintr(struct work_struct *work) | ||
429 | { | ||
430 | struct mcf_serial *info = container_of(work, struct mcf_serial, tqueue); | ||
431 | struct tty_struct *tty = info->port.tty; | ||
432 | |||
433 | if (tty) | ||
434 | tty_wakeup(tty); | ||
435 | } | ||
436 | |||
437 | |||
438 | /* | ||
439 | * Change of state on a DCD line. | ||
440 | */ | ||
441 | void mcfrs_modem_change(struct mcf_serial *info, int dcd) | ||
442 | { | ||
443 | if (info->count == 0) | ||
444 | return; | ||
445 | |||
446 | if (info->flags & ASYNC_CHECK_CD) { | ||
447 | if (dcd) | ||
448 | wake_up_interruptible(&info->open_wait); | ||
449 | else | ||
450 | schedule_work(&info->tqueue_hangup); | ||
451 | } | ||
452 | } | ||
453 | |||
454 | |||
455 | #ifdef MCFPP_DCD0 | ||
456 | |||
457 | unsigned short mcfrs_ppstatus; | ||
458 | |||
459 | /* | ||
460 | * This subroutine is called when the RS_TIMER goes off. It is used | ||
461 | * to monitor the state of the DCD lines - since they have no edge | ||
462 | * sensors and interrupt generators. | ||
463 | */ | ||
464 | static void mcfrs_timer(void) | ||
465 | { | ||
466 | unsigned int ppstatus, dcdval, i; | ||
467 | |||
468 | ppstatus = mcf_getppdata() & (MCFPP_DCD0 | MCFPP_DCD1); | ||
469 | |||
470 | if (ppstatus != mcfrs_ppstatus) { | ||
471 | for (i = 0; (i < 2); i++) { | ||
472 | dcdval = (i ? MCFPP_DCD1 : MCFPP_DCD0); | ||
473 | if ((ppstatus & dcdval) != (mcfrs_ppstatus & dcdval)) { | ||
474 | mcfrs_modem_change(&mcfrs_table[i], | ||
475 | ((ppstatus & dcdval) ? 0 : 1)); | ||
476 | } | ||
477 | } | ||
478 | } | ||
479 | mcfrs_ppstatus = ppstatus; | ||
480 | |||
481 | /* Re-arm timer */ | ||
482 | mcfrs_timer_struct.expires = jiffies + HZ/25; | ||
483 | add_timer(&mcfrs_timer_struct); | ||
484 | } | ||
485 | |||
486 | #endif /* MCFPP_DCD0 */ | ||
487 | |||
488 | |||
489 | /* | ||
490 | * This routine is called from the scheduler tqueue when the interrupt | ||
491 | * routine has signalled that a hangup has occurred. The path of | ||
492 | * hangup processing is: | ||
493 | * | ||
494 | * serial interrupt routine -> (scheduler tqueue) -> | ||
495 | * do_serial_hangup() -> tty->hangup() -> mcfrs_hangup() | ||
496 | * | ||
497 | */ | ||
498 | static void do_serial_hangup(struct work_struct *work) | ||
499 | { | ||
500 | struct mcf_serial *info = container_of(work, struct mcf_serial, tqueue_hangup); | ||
501 | struct tty_struct *tty = info->port.tty; | ||
502 | |||
503 | if (tty) | ||
504 | tty_hangup(tty); | ||
505 | } | ||
506 | |||
507 | static int startup(struct mcf_serial * info) | ||
508 | { | ||
509 | volatile unsigned char *uartp; | ||
510 | unsigned long flags; | ||
511 | |||
512 | if (info->flags & ASYNC_INITIALIZED) | ||
513 | return 0; | ||
514 | |||
515 | if (!info->xmit_buf) { | ||
516 | info->xmit_buf = (unsigned char *) __get_free_page(GFP_KERNEL); | ||
517 | if (!info->xmit_buf) | ||
518 | return -ENOMEM; | ||
519 | } | ||
520 | |||
521 | local_irq_save(flags); | ||
522 | |||
523 | #ifdef SERIAL_DEBUG_OPEN | ||
524 | printk("starting up ttyS%d (irq %d)...\n", info->line, info->irq); | ||
525 | #endif | ||
526 | |||
527 | /* | ||
528 | * Reset UART, get it into known state... | ||
529 | */ | ||
530 | uartp = info->addr; | ||
531 | uartp[MCFUART_UCR] = MCFUART_UCR_CMDRESETRX; /* reset RX */ | ||
532 | uartp[MCFUART_UCR] = MCFUART_UCR_CMDRESETTX; /* reset TX */ | ||
533 | mcfrs_setsignals(info, 1, 1); | ||
534 | |||
535 | if (info->port.tty) | ||
536 | clear_bit(TTY_IO_ERROR, &info->port.tty->flags); | ||
537 | info->xmit_cnt = info->xmit_head = info->xmit_tail = 0; | ||
538 | |||
539 | /* | ||
540 | * and set the speed of the serial port | ||
541 | */ | ||
542 | mcfrs_change_speed(info); | ||
543 | |||
544 | /* | ||
545 | * Lastly enable the UART transmitter and receiver, and | ||
546 | * interrupt enables. | ||
547 | */ | ||
548 | info->imr = MCFUART_UIR_RXREADY; | ||
549 | uartp[MCFUART_UCR] = MCFUART_UCR_RXENABLE | MCFUART_UCR_TXENABLE; | ||
550 | uartp[MCFUART_UIMR] = info->imr; | ||
551 | |||
552 | info->flags |= ASYNC_INITIALIZED; | ||
553 | local_irq_restore(flags); | ||
554 | return 0; | ||
555 | } | ||
556 | |||
557 | /* | ||
558 | * This routine will shutdown a serial port; interrupts are disabled, and | ||
559 | * DTR is dropped if the hangup on close termio flag is on. | ||
560 | */ | ||
561 | static void shutdown(struct mcf_serial * info) | ||
562 | { | ||
563 | volatile unsigned char *uartp; | ||
564 | unsigned long flags; | ||
565 | |||
566 | if (!(info->flags & ASYNC_INITIALIZED)) | ||
567 | return; | ||
568 | |||
569 | #ifdef SERIAL_DEBUG_OPEN | ||
570 | printk("Shutting down serial port %d (irq %d)....\n", info->line, | ||
571 | info->irq); | ||
572 | #endif | ||
573 | |||
574 | local_irq_save(flags); | ||
575 | |||
576 | uartp = info->addr; | ||
577 | uartp[MCFUART_UIMR] = 0; /* mask all interrupts */ | ||
578 | uartp[MCFUART_UCR] = MCFUART_UCR_CMDRESETRX; /* reset RX */ | ||
579 | uartp[MCFUART_UCR] = MCFUART_UCR_CMDRESETTX; /* reset TX */ | ||
580 | |||
581 | if (!info->port.tty || (info->port.tty->termios->c_cflag & HUPCL)) | ||
582 | mcfrs_setsignals(info, 0, 0); | ||
583 | |||
584 | if (info->xmit_buf) { | ||
585 | free_page((unsigned long) info->xmit_buf); | ||
586 | info->xmit_buf = 0; | ||
587 | } | ||
588 | |||
589 | if (info->port.tty) | ||
590 | set_bit(TTY_IO_ERROR, &info->port.tty->flags); | ||
591 | |||
592 | info->flags &= ~ASYNC_INITIALIZED; | ||
593 | local_irq_restore(flags); | ||
594 | } | ||
595 | |||
596 | |||
597 | /* | ||
598 | * This routine is called to set the UART divisor registers to match | ||
599 | * the specified baud rate for a serial port. | ||
600 | */ | ||
601 | static void mcfrs_change_speed(struct mcf_serial *info) | ||
602 | { | ||
603 | volatile unsigned char *uartp; | ||
604 | unsigned int baudclk, cflag; | ||
605 | unsigned long flags; | ||
606 | unsigned char mr1, mr2; | ||
607 | int i; | ||
608 | #ifdef CONFIG_M5272 | ||
609 | unsigned int fraction; | ||
610 | #endif | ||
611 | |||
612 | if (!info->port.tty || !info->port.tty->termios) | ||
613 | return; | ||
614 | cflag = info->port.tty->termios->c_cflag; | ||
615 | if (info->addr == 0) | ||
616 | return; | ||
617 | |||
618 | #if 0 | ||
619 | printk("%s(%d): mcfrs_change_speed()\n", __FILE__, __LINE__); | ||
620 | #endif | ||
621 | |||
622 | i = cflag & CBAUD; | ||
623 | if (i & CBAUDEX) { | ||
624 | i &= ~CBAUDEX; | ||
625 | if (i < 1 || i > 4) | ||
626 | info->port.tty->termios->c_cflag &= ~CBAUDEX; | ||
627 | else | ||
628 | i += 15; | ||
629 | } | ||
630 | if (i == 0) { | ||
631 | mcfrs_setsignals(info, 0, -1); | ||
632 | return; | ||
633 | } | ||
634 | |||
635 | /* compute the baudrate clock */ | ||
636 | #ifdef CONFIG_M5272 | ||
637 | /* | ||
638 | * For the MCF5272, also compute the baudrate fraction. | ||
639 | */ | ||
640 | baudclk = (MCF_BUSCLK / mcfrs_baud_table[i]) / 32; | ||
641 | fraction = MCF_BUSCLK - (baudclk * 32 * mcfrs_baud_table[i]); | ||
642 | fraction *= 16; | ||
643 | fraction /= (32 * mcfrs_baud_table[i]); | ||
644 | #else | ||
645 | baudclk = ((MCF_BUSCLK / mcfrs_baud_table[i]) + 16) / 32; | ||
646 | #endif | ||
647 | |||
648 | info->baud = mcfrs_baud_table[i]; | ||
649 | |||
650 | mr1 = MCFUART_MR1_RXIRQRDY | MCFUART_MR1_RXERRCHAR; | ||
651 | mr2 = 0; | ||
652 | |||
653 | switch (cflag & CSIZE) { | ||
654 | case CS5: mr1 |= MCFUART_MR1_CS5; break; | ||
655 | case CS6: mr1 |= MCFUART_MR1_CS6; break; | ||
656 | case CS7: mr1 |= MCFUART_MR1_CS7; break; | ||
657 | case CS8: | ||
658 | default: mr1 |= MCFUART_MR1_CS8; break; | ||
659 | } | ||
660 | |||
661 | if (cflag & PARENB) { | ||
662 | if (cflag & CMSPAR) { | ||
663 | if (cflag & PARODD) | ||
664 | mr1 |= MCFUART_MR1_PARITYMARK; | ||
665 | else | ||
666 | mr1 |= MCFUART_MR1_PARITYSPACE; | ||
667 | } else { | ||
668 | if (cflag & PARODD) | ||
669 | mr1 |= MCFUART_MR1_PARITYODD; | ||
670 | else | ||
671 | mr1 |= MCFUART_MR1_PARITYEVEN; | ||
672 | } | ||
673 | } else { | ||
674 | mr1 |= MCFUART_MR1_PARITYNONE; | ||
675 | } | ||
676 | |||
677 | if (cflag & CSTOPB) | ||
678 | mr2 |= MCFUART_MR2_STOP2; | ||
679 | else | ||
680 | mr2 |= MCFUART_MR2_STOP1; | ||
681 | |||
682 | if (cflag & CRTSCTS) { | ||
683 | mr1 |= MCFUART_MR1_RXRTS; | ||
684 | mr2 |= MCFUART_MR2_TXCTS; | ||
685 | } | ||
686 | |||
687 | if (cflag & CLOCAL) | ||
688 | info->flags &= ~ASYNC_CHECK_CD; | ||
689 | else | ||
690 | info->flags |= ASYNC_CHECK_CD; | ||
691 | |||
692 | uartp = info->addr; | ||
693 | |||
694 | local_irq_save(flags); | ||
695 | #if 0 | ||
696 | printk("%s(%d): mr1=%x mr2=%x baudclk=%x\n", __FILE__, __LINE__, | ||
697 | mr1, mr2, baudclk); | ||
698 | #endif | ||
699 | /* | ||
700 | Note: pg 12-16 of MCF5206e User's Manual states that a | ||
701 | software reset should be performed prior to changing | ||
702 | UMR1,2, UCSR, UACR, bit 7 | ||
703 | */ | ||
704 | uartp[MCFUART_UCR] = MCFUART_UCR_CMDRESETRX; /* reset RX */ | ||
705 | uartp[MCFUART_UCR] = MCFUART_UCR_CMDRESETTX; /* reset TX */ | ||
706 | uartp[MCFUART_UCR] = MCFUART_UCR_CMDRESETMRPTR; /* reset MR pointer */ | ||
707 | uartp[MCFUART_UMR] = mr1; | ||
708 | uartp[MCFUART_UMR] = mr2; | ||
709 | uartp[MCFUART_UBG1] = (baudclk & 0xff00) >> 8; /* set msb byte */ | ||
710 | uartp[MCFUART_UBG2] = (baudclk & 0xff); /* set lsb byte */ | ||
711 | #ifdef CONFIG_M5272 | ||
712 | uartp[MCFUART_UFPD] = (fraction & 0xf); /* set fraction */ | ||
713 | #endif | ||
714 | uartp[MCFUART_UCSR] = MCFUART_UCSR_RXCLKTIMER | MCFUART_UCSR_TXCLKTIMER; | ||
715 | uartp[MCFUART_UCR] = MCFUART_UCR_RXENABLE | MCFUART_UCR_TXENABLE; | ||
716 | mcfrs_setsignals(info, 1, -1); | ||
717 | local_irq_restore(flags); | ||
718 | return; | ||
719 | } | ||
720 | |||
721 | static void mcfrs_flush_chars(struct tty_struct *tty) | ||
722 | { | ||
723 | volatile unsigned char *uartp; | ||
724 | struct mcf_serial *info = (struct mcf_serial *)tty->driver_data; | ||
725 | unsigned long flags; | ||
726 | |||
727 | if (serial_paranoia_check(info, tty->name, "mcfrs_flush_chars")) | ||
728 | return; | ||
729 | |||
730 | uartp = (volatile unsigned char *) info->addr; | ||
731 | |||
732 | /* | ||
733 | * re-enable receiver interrupt | ||
734 | */ | ||
735 | local_irq_save(flags); | ||
736 | if ((!(info->imr & MCFUART_UIR_RXREADY)) && | ||
737 | (info->flags & ASYNC_INITIALIZED) ) { | ||
738 | info->imr |= MCFUART_UIR_RXREADY; | ||
739 | uartp[MCFUART_UIMR] = info->imr; | ||
740 | } | ||
741 | local_irq_restore(flags); | ||
742 | |||
743 | if (info->xmit_cnt <= 0 || tty->stopped || tty->hw_stopped || | ||
744 | !info->xmit_buf) | ||
745 | return; | ||
746 | |||
747 | /* Enable transmitter */ | ||
748 | local_irq_save(flags); | ||
749 | info->imr |= MCFUART_UIR_TXREADY; | ||
750 | uartp[MCFUART_UIMR] = info->imr; | ||
751 | local_irq_restore(flags); | ||
752 | } | ||
753 | |||
754 | static int mcfrs_write(struct tty_struct * tty, | ||
755 | const unsigned char *buf, int count) | ||
756 | { | ||
757 | volatile unsigned char *uartp; | ||
758 | struct mcf_serial *info = (struct mcf_serial *)tty->driver_data; | ||
759 | unsigned long flags; | ||
760 | int c, total = 0; | ||
761 | |||
762 | #if 0 | ||
763 | printk("%s(%d): mcfrs_write(tty=%x,buf=%x,count=%d)\n", | ||
764 | __FILE__, __LINE__, (int)tty, (int)buf, count); | ||
765 | #endif | ||
766 | |||
767 | if (serial_paranoia_check(info, tty->name, "mcfrs_write")) | ||
768 | return 0; | ||
769 | |||
770 | if (!tty || !info->xmit_buf) | ||
771 | return 0; | ||
772 | |||
773 | local_save_flags(flags); | ||
774 | while (1) { | ||
775 | local_irq_disable(); | ||
776 | c = min(count, (int) min(((int)SERIAL_XMIT_SIZE) - info->xmit_cnt - 1, | ||
777 | ((int)SERIAL_XMIT_SIZE) - info->xmit_head)); | ||
778 | local_irq_restore(flags); | ||
779 | |||
780 | if (c <= 0) | ||
781 | break; | ||
782 | |||
783 | memcpy(info->xmit_buf + info->xmit_head, buf, c); | ||
784 | |||
785 | local_irq_disable(); | ||
786 | info->xmit_head = (info->xmit_head + c) & (SERIAL_XMIT_SIZE-1); | ||
787 | info->xmit_cnt += c; | ||
788 | local_irq_restore(flags); | ||
789 | |||
790 | buf += c; | ||
791 | count -= c; | ||
792 | total += c; | ||
793 | } | ||
794 | |||
795 | local_irq_disable(); | ||
796 | uartp = info->addr; | ||
797 | info->imr |= MCFUART_UIR_TXREADY; | ||
798 | uartp[MCFUART_UIMR] = info->imr; | ||
799 | local_irq_restore(flags); | ||
800 | |||
801 | return total; | ||
802 | } | ||
803 | |||
804 | static int mcfrs_write_room(struct tty_struct *tty) | ||
805 | { | ||
806 | struct mcf_serial *info = (struct mcf_serial *)tty->driver_data; | ||
807 | int ret; | ||
808 | |||
809 | if (serial_paranoia_check(info, tty->name, "mcfrs_write_room")) | ||
810 | return 0; | ||
811 | ret = SERIAL_XMIT_SIZE - info->xmit_cnt - 1; | ||
812 | if (ret < 0) | ||
813 | ret = 0; | ||
814 | return ret; | ||
815 | } | ||
816 | |||
817 | static int mcfrs_chars_in_buffer(struct tty_struct *tty) | ||
818 | { | ||
819 | struct mcf_serial *info = (struct mcf_serial *)tty->driver_data; | ||
820 | |||
821 | if (serial_paranoia_check(info, tty->name, "mcfrs_chars_in_buffer")) | ||
822 | return 0; | ||
823 | return info->xmit_cnt; | ||
824 | } | ||
825 | |||
826 | static void mcfrs_flush_buffer(struct tty_struct *tty) | ||
827 | { | ||
828 | struct mcf_serial *info = (struct mcf_serial *)tty->driver_data; | ||
829 | unsigned long flags; | ||
830 | |||
831 | if (serial_paranoia_check(info, tty->name, "mcfrs_flush_buffer")) | ||
832 | return; | ||
833 | |||
834 | local_irq_save(flags); | ||
835 | info->xmit_cnt = info->xmit_head = info->xmit_tail = 0; | ||
836 | local_irq_restore(flags); | ||
837 | |||
838 | tty_wakeup(tty); | ||
839 | } | ||
840 | |||
841 | /* | ||
842 | * ------------------------------------------------------------ | ||
843 | * mcfrs_throttle() | ||
844 | * | ||
845 | * This routine is called by the upper-layer tty layer to signal that | ||
846 | * incoming characters should be throttled. | ||
847 | * ------------------------------------------------------------ | ||
848 | */ | ||
849 | static void mcfrs_throttle(struct tty_struct * tty) | ||
850 | { | ||
851 | struct mcf_serial *info = (struct mcf_serial *)tty->driver_data; | ||
852 | #ifdef SERIAL_DEBUG_THROTTLE | ||
853 | char buf[64]; | ||
854 | |||
855 | printk("throttle %s: %d....\n", tty_name(tty, buf), | ||
856 | tty->ldisc.chars_in_buffer(tty)); | ||
857 | #endif | ||
858 | |||
859 | if (serial_paranoia_check(info, tty->name, "mcfrs_throttle")) | ||
860 | return; | ||
861 | |||
862 | if (I_IXOFF(tty)) | ||
863 | info->x_char = STOP_CHAR(tty); | ||
864 | |||
865 | /* Turn off RTS line (do this atomic) */ | ||
866 | } | ||
867 | |||
868 | static void mcfrs_unthrottle(struct tty_struct * tty) | ||
869 | { | ||
870 | struct mcf_serial *info = (struct mcf_serial *)tty->driver_data; | ||
871 | #ifdef SERIAL_DEBUG_THROTTLE | ||
872 | char buf[64]; | ||
873 | |||
874 | printk("unthrottle %s: %d....\n", tty_name(tty, buf), | ||
875 | tty->ldisc.chars_in_buffer(tty)); | ||
876 | #endif | ||
877 | |||
878 | if (serial_paranoia_check(info, tty->name, "mcfrs_unthrottle")) | ||
879 | return; | ||
880 | |||
881 | if (I_IXOFF(tty)) { | ||
882 | if (info->x_char) | ||
883 | info->x_char = 0; | ||
884 | else | ||
885 | info->x_char = START_CHAR(tty); | ||
886 | } | ||
887 | |||
888 | /* Assert RTS line (do this atomic) */ | ||
889 | } | ||
890 | |||
891 | /* | ||
892 | * ------------------------------------------------------------ | ||
893 | * mcfrs_ioctl() and friends | ||
894 | * ------------------------------------------------------------ | ||
895 | */ | ||
896 | |||
897 | static int get_serial_info(struct mcf_serial * info, | ||
898 | struct serial_struct * retinfo) | ||
899 | { | ||
900 | struct serial_struct tmp; | ||
901 | |||
902 | if (!retinfo) | ||
903 | return -EFAULT; | ||
904 | memset(&tmp, 0, sizeof(tmp)); | ||
905 | tmp.type = info->type; | ||
906 | tmp.line = info->line; | ||
907 | tmp.port = (unsigned int) info->addr; | ||
908 | tmp.irq = info->irq; | ||
909 | tmp.flags = info->flags; | ||
910 | tmp.baud_base = info->baud_base; | ||
911 | tmp.close_delay = info->close_delay; | ||
912 | tmp.closing_wait = info->closing_wait; | ||
913 | tmp.custom_divisor = info->custom_divisor; | ||
914 | return copy_to_user(retinfo,&tmp,sizeof(*retinfo)) ? -EFAULT : 0; | ||
915 | } | ||
916 | |||
917 | static int set_serial_info(struct mcf_serial * info, | ||
918 | struct serial_struct * new_info) | ||
919 | { | ||
920 | struct serial_struct new_serial; | ||
921 | struct mcf_serial old_info; | ||
922 | int retval = 0; | ||
923 | |||
924 | if (!new_info) | ||
925 | return -EFAULT; | ||
926 | if (copy_from_user(&new_serial,new_info,sizeof(new_serial))) | ||
927 | return -EFAULT; | ||
928 | old_info = *info; | ||
929 | |||
930 | if (!capable(CAP_SYS_ADMIN)) { | ||
931 | if ((new_serial.baud_base != info->baud_base) || | ||
932 | (new_serial.type != info->type) || | ||
933 | (new_serial.close_delay != info->close_delay) || | ||
934 | ((new_serial.flags & ~ASYNC_USR_MASK) != | ||
935 | (info->flags & ~ASYNC_USR_MASK))) | ||
936 | return -EPERM; | ||
937 | info->flags = ((info->flags & ~ASYNC_USR_MASK) | | ||
938 | (new_serial.flags & ASYNC_USR_MASK)); | ||
939 | info->custom_divisor = new_serial.custom_divisor; | ||
940 | goto check_and_exit; | ||
941 | } | ||
942 | |||
943 | if (info->count > 1) | ||
944 | return -EBUSY; | ||
945 | |||
946 | /* | ||
947 | * OK, past this point, all the error checking has been done. | ||
948 | * At this point, we start making changes..... | ||
949 | */ | ||
950 | |||
951 | info->baud_base = new_serial.baud_base; | ||
952 | info->flags = ((info->flags & ~ASYNC_FLAGS) | | ||
953 | (new_serial.flags & ASYNC_FLAGS)); | ||
954 | info->type = new_serial.type; | ||
955 | info->close_delay = new_serial.close_delay; | ||
956 | info->closing_wait = new_serial.closing_wait; | ||
957 | |||
958 | check_and_exit: | ||
959 | retval = startup(info); | ||
960 | return retval; | ||
961 | } | ||
962 | |||
963 | /* | ||
964 | * get_lsr_info - get line status register info | ||
965 | * | ||
966 | * Purpose: Let user call ioctl() to get info when the UART physically | ||
967 | * is emptied. On bus types like RS485, the transmitter must | ||
968 | * release the bus after transmitting. This must be done when | ||
969 | * the transmit shift register is empty, not be done when the | ||
970 | * transmit holding register is empty. This functionality | ||
971 | * allows an RS485 driver to be written in user space. | ||
972 | */ | ||
973 | static int get_lsr_info(struct mcf_serial * info, unsigned int *value) | ||
974 | { | ||
975 | volatile unsigned char *uartp; | ||
976 | unsigned long flags; | ||
977 | unsigned char status; | ||
978 | |||
979 | local_irq_save(flags); | ||
980 | uartp = info->addr; | ||
981 | status = (uartp[MCFUART_USR] & MCFUART_USR_TXEMPTY) ? TIOCSER_TEMT : 0; | ||
982 | local_irq_restore(flags); | ||
983 | |||
984 | return put_user(status,value); | ||
985 | } | ||
986 | |||
987 | /* | ||
988 | * This routine sends a break character out the serial port. | ||
989 | */ | ||
990 | static void send_break( struct mcf_serial * info, int duration) | ||
991 | { | ||
992 | volatile unsigned char *uartp; | ||
993 | unsigned long flags; | ||
994 | |||
995 | if (!info->addr) | ||
996 | return; | ||
997 | set_current_state(TASK_INTERRUPTIBLE); | ||
998 | uartp = info->addr; | ||
999 | |||
1000 | local_irq_save(flags); | ||
1001 | uartp[MCFUART_UCR] = MCFUART_UCR_CMDBREAKSTART; | ||
1002 | schedule_timeout(duration); | ||
1003 | uartp[MCFUART_UCR] = MCFUART_UCR_CMDBREAKSTOP; | ||
1004 | local_irq_restore(flags); | ||
1005 | } | ||
1006 | |||
1007 | static int mcfrs_tiocmget(struct tty_struct *tty, struct file *file) | ||
1008 | { | ||
1009 | struct mcf_serial * info = (struct mcf_serial *)tty->driver_data; | ||
1010 | |||
1011 | if (serial_paranoia_check(info, tty->name, "mcfrs_ioctl")) | ||
1012 | return -ENODEV; | ||
1013 | if (tty->flags & (1 << TTY_IO_ERROR)) | ||
1014 | return -EIO; | ||
1015 | |||
1016 | return mcfrs_getsignals(info); | ||
1017 | } | ||
1018 | |||
1019 | static int mcfrs_tiocmset(struct tty_struct *tty, struct file *file, | ||
1020 | unsigned int set, unsigned int clear) | ||
1021 | { | ||
1022 | struct mcf_serial * info = (struct mcf_serial *)tty->driver_data; | ||
1023 | int rts = -1, dtr = -1; | ||
1024 | |||
1025 | if (serial_paranoia_check(info, tty->name, "mcfrs_ioctl")) | ||
1026 | return -ENODEV; | ||
1027 | if (tty->flags & (1 << TTY_IO_ERROR)) | ||
1028 | return -EIO; | ||
1029 | |||
1030 | if (set & TIOCM_RTS) | ||
1031 | rts = 1; | ||
1032 | if (set & TIOCM_DTR) | ||
1033 | dtr = 1; | ||
1034 | if (clear & TIOCM_RTS) | ||
1035 | rts = 0; | ||
1036 | if (clear & TIOCM_DTR) | ||
1037 | dtr = 0; | ||
1038 | |||
1039 | mcfrs_setsignals(info, dtr, rts); | ||
1040 | |||
1041 | return 0; | ||
1042 | } | ||
1043 | |||
1044 | static int mcfrs_ioctl(struct tty_struct *tty, struct file * file, | ||
1045 | unsigned int cmd, unsigned long arg) | ||
1046 | { | ||
1047 | struct mcf_serial * info = (struct mcf_serial *)tty->driver_data; | ||
1048 | int retval, error; | ||
1049 | |||
1050 | if (serial_paranoia_check(info, tty->name, "mcfrs_ioctl")) | ||
1051 | return -ENODEV; | ||
1052 | |||
1053 | if ((cmd != TIOCGSERIAL) && (cmd != TIOCSSERIAL) && | ||
1054 | (cmd != TIOCSERCONFIG) && (cmd != TIOCSERGWILD) && | ||
1055 | (cmd != TIOCSERSWILD) && (cmd != TIOCSERGSTRUCT)) { | ||
1056 | if (tty->flags & (1 << TTY_IO_ERROR)) | ||
1057 | return -EIO; | ||
1058 | } | ||
1059 | |||
1060 | switch (cmd) { | ||
1061 | case TCSBRK: /* SVID version: non-zero arg --> no break */ | ||
1062 | retval = tty_check_change(tty); | ||
1063 | if (retval) | ||
1064 | return retval; | ||
1065 | tty_wait_until_sent(tty, 0); | ||
1066 | if (!arg) | ||
1067 | send_break(info, HZ/4); /* 1/4 second */ | ||
1068 | return 0; | ||
1069 | case TCSBRKP: /* support for POSIX tcsendbreak() */ | ||
1070 | retval = tty_check_change(tty); | ||
1071 | if (retval) | ||
1072 | return retval; | ||
1073 | tty_wait_until_sent(tty, 0); | ||
1074 | send_break(info, arg ? arg*(HZ/10) : HZ/4); | ||
1075 | return 0; | ||
1076 | case TIOCGSERIAL: | ||
1077 | if (access_ok(VERIFY_WRITE, (void *) arg, | ||
1078 | sizeof(struct serial_struct))) | ||
1079 | return get_serial_info(info, | ||
1080 | (struct serial_struct *) arg); | ||
1081 | return -EFAULT; | ||
1082 | case TIOCSSERIAL: | ||
1083 | return set_serial_info(info, | ||
1084 | (struct serial_struct *) arg); | ||
1085 | case TIOCSERGETLSR: /* Get line status register */ | ||
1086 | if (access_ok(VERIFY_WRITE, (void *) arg, | ||
1087 | sizeof(unsigned int))) | ||
1088 | return get_lsr_info(info, (unsigned int *) arg); | ||
1089 | return -EFAULT; | ||
1090 | case TIOCSERGSTRUCT: | ||
1091 | error = copy_to_user((struct mcf_serial *) arg, | ||
1092 | info, sizeof(struct mcf_serial)); | ||
1093 | if (error) | ||
1094 | return -EFAULT; | ||
1095 | return 0; | ||
1096 | |||
1097 | #ifdef TIOCSET422 | ||
1098 | case TIOCSET422: { | ||
1099 | unsigned int val; | ||
1100 | get_user(val, (unsigned int *) arg); | ||
1101 | mcf_setpa(MCFPP_PA11, (val ? 0 : MCFPP_PA11)); | ||
1102 | break; | ||
1103 | } | ||
1104 | case TIOCGET422: { | ||
1105 | unsigned int val; | ||
1106 | val = (mcf_getpa() & MCFPP_PA11) ? 0 : 1; | ||
1107 | put_user(val, (unsigned int *) arg); | ||
1108 | break; | ||
1109 | } | ||
1110 | #endif | ||
1111 | |||
1112 | default: | ||
1113 | return -ENOIOCTLCMD; | ||
1114 | } | ||
1115 | return 0; | ||
1116 | } | ||
1117 | |||
1118 | static void mcfrs_set_termios(struct tty_struct *tty, struct ktermios *old_termios) | ||
1119 | { | ||
1120 | struct mcf_serial *info = (struct mcf_serial *)tty->driver_data; | ||
1121 | |||
1122 | if (tty->termios->c_cflag == old_termios->c_cflag) | ||
1123 | return; | ||
1124 | |||
1125 | mcfrs_change_speed(info); | ||
1126 | |||
1127 | if ((old_termios->c_cflag & CRTSCTS) && | ||
1128 | !(tty->termios->c_cflag & CRTSCTS)) { | ||
1129 | tty->hw_stopped = 0; | ||
1130 | mcfrs_setsignals(info, -1, 1); | ||
1131 | #if 0 | ||
1132 | mcfrs_start(tty); | ||
1133 | #endif | ||
1134 | } | ||
1135 | } | ||
1136 | |||
1137 | /* | ||
1138 | * ------------------------------------------------------------ | ||
1139 | * mcfrs_close() | ||
1140 | * | ||
1141 | * This routine is called when the serial port gets closed. First, we | ||
1142 | * wait for the last remaining data to be sent. Then, we unlink its | ||
1143 | * S structure from the interrupt chain if necessary, and we free | ||
1144 | * that IRQ if nothing is left in the chain. | ||
1145 | * ------------------------------------------------------------ | ||
1146 | */ | ||
1147 | static void mcfrs_close(struct tty_struct *tty, struct file * filp) | ||
1148 | { | ||
1149 | volatile unsigned char *uartp; | ||
1150 | struct mcf_serial *info = (struct mcf_serial *)tty->driver_data; | ||
1151 | unsigned long flags; | ||
1152 | |||
1153 | if (!info || serial_paranoia_check(info, tty->name, "mcfrs_close")) | ||
1154 | return; | ||
1155 | |||
1156 | local_irq_save(flags); | ||
1157 | |||
1158 | if (tty_hung_up_p(filp)) { | ||
1159 | local_irq_restore(flags); | ||
1160 | return; | ||
1161 | } | ||
1162 | |||
1163 | #ifdef SERIAL_DEBUG_OPEN | ||
1164 | printk("mcfrs_close ttyS%d, count = %d\n", info->line, info->count); | ||
1165 | #endif | ||
1166 | if ((tty->count == 1) && (info->count != 1)) { | ||
1167 | /* | ||
1168 | * Uh, oh. tty->count is 1, which means that the tty | ||
1169 | * structure will be freed. Info->count should always | ||
1170 | * be one in these conditions. If it's greater than | ||
1171 | * one, we've got real problems, since it means the | ||
1172 | * serial port won't be shutdown. | ||
1173 | */ | ||
1174 | printk("MCFRS: bad serial port count; tty->count is 1, " | ||
1175 | "info->count is %d\n", info->count); | ||
1176 | info->count = 1; | ||
1177 | } | ||
1178 | if (--info->count < 0) { | ||
1179 | printk("MCFRS: bad serial port count for ttyS%d: %d\n", | ||
1180 | info->line, info->count); | ||
1181 | info->count = 0; | ||
1182 | } | ||
1183 | if (info->count) { | ||
1184 | local_irq_restore(flags); | ||
1185 | return; | ||
1186 | } | ||
1187 | info->flags |= ASYNC_CLOSING; | ||
1188 | |||
1189 | /* | ||
1190 | * Now we wait for the transmit buffer to clear; and we notify | ||
1191 | * the line discipline to only process XON/XOFF characters. | ||
1192 | */ | ||
1193 | tty->closing = 1; | ||
1194 | if (info->closing_wait != ASYNC_CLOSING_WAIT_NONE) | ||
1195 | tty_wait_until_sent(tty, info->closing_wait); | ||
1196 | |||
1197 | /* | ||
1198 | * At this point we stop accepting input. To do this, we | ||
1199 | * disable the receive line status interrupts, and tell the | ||
1200 | * interrupt driver to stop checking the data ready bit in the | ||
1201 | * line status register. | ||
1202 | */ | ||
1203 | info->imr &= ~MCFUART_UIR_RXREADY; | ||
1204 | uartp = info->addr; | ||
1205 | uartp[MCFUART_UIMR] = info->imr; | ||
1206 | |||
1207 | #if 0 | ||
1208 | /* FIXME: do we need to keep this enabled for console?? */ | ||
1209 | if (mcfrs_console_inited && (mcfrs_console_port == info->line)) { | ||
1210 | /* Do not disable the UART */ ; | ||
1211 | } else | ||
1212 | #endif | ||
1213 | shutdown(info); | ||
1214 | mcfrs_flush_buffer(tty); | ||
1215 | tty_ldisc_flush(tty); | ||
1216 | |||
1217 | tty->closing = 0; | ||
1218 | info->event = 0; | ||
1219 | info->port.tty = NULL; | ||
1220 | #if 0 | ||
1221 | if (tty->ldisc.num != ldiscs[N_TTY].num) { | ||
1222 | if (tty->ldisc.close) | ||
1223 | (tty->ldisc.close)(tty); | ||
1224 | tty->ldisc = ldiscs[N_TTY]; | ||
1225 | tty->termios->c_line = N_TTY; | ||
1226 | if (tty->ldisc.open) | ||
1227 | (tty->ldisc.open)(tty); | ||
1228 | } | ||
1229 | #endif | ||
1230 | if (info->blocked_open) { | ||
1231 | if (info->close_delay) { | ||
1232 | msleep_interruptible(jiffies_to_msecs(info->close_delay)); | ||
1233 | } | ||
1234 | wake_up_interruptible(&info->open_wait); | ||
1235 | } | ||
1236 | info->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING); | ||
1237 | wake_up_interruptible(&info->close_wait); | ||
1238 | local_irq_restore(flags); | ||
1239 | } | ||
1240 | |||
1241 | /* | ||
1242 | * mcfrs_wait_until_sent() --- wait until the transmitter is empty | ||
1243 | */ | ||
1244 | static void | ||
1245 | mcfrs_wait_until_sent(struct tty_struct *tty, int timeout) | ||
1246 | { | ||
1247 | #ifdef CONFIG_M5272 | ||
1248 | #define MCF5272_FIFO_SIZE 25 /* fifo size + shift reg */ | ||
1249 | |||
1250 | struct mcf_serial * info = (struct mcf_serial *)tty->driver_data; | ||
1251 | volatile unsigned char *uartp; | ||
1252 | unsigned long orig_jiffies, fifo_time, char_time, fifo_cnt; | ||
1253 | |||
1254 | if (serial_paranoia_check(info, tty->name, "mcfrs_wait_until_sent")) | ||
1255 | return; | ||
1256 | |||
1257 | orig_jiffies = jiffies; | ||
1258 | |||
1259 | /* | ||
1260 | * Set the check interval to be 1/5 of the approximate time | ||
1261 | * to send the entire fifo, and make it at least 1. The check | ||
1262 | * interval should also be less than the timeout. | ||
1263 | * | ||
1264 | * Note: we have to use pretty tight timings here to satisfy | ||
1265 | * the NIST-PCTS. | ||
1266 | */ | ||
1267 | lock_kernel(); | ||
1268 | |||
1269 | fifo_time = (MCF5272_FIFO_SIZE * HZ * 10) / info->baud; | ||
1270 | char_time = fifo_time / 5; | ||
1271 | if (char_time == 0) | ||
1272 | char_time = 1; | ||
1273 | if (timeout && timeout < char_time) | ||
1274 | char_time = timeout; | ||
1275 | |||
1276 | /* | ||
1277 | * Clamp the timeout period at 2 * the time to empty the | ||
1278 | * fifo. Just to be safe, set the minimum at .5 seconds. | ||
1279 | */ | ||
1280 | fifo_time *= 2; | ||
1281 | if (fifo_time < (HZ/2)) | ||
1282 | fifo_time = HZ/2; | ||
1283 | if (!timeout || timeout > fifo_time) | ||
1284 | timeout = fifo_time; | ||
1285 | |||
1286 | /* | ||
1287 | * Account for the number of bytes in the UART | ||
1288 | * transmitter FIFO plus any byte being shifted out. | ||
1289 | */ | ||
1290 | uartp = (volatile unsigned char *) info->addr; | ||
1291 | for (;;) { | ||
1292 | fifo_cnt = (uartp[MCFUART_UTF] & MCFUART_UTF_TXB); | ||
1293 | if ((uartp[MCFUART_USR] & (MCFUART_USR_TXREADY| | ||
1294 | MCFUART_USR_TXEMPTY)) == | ||
1295 | MCFUART_USR_TXREADY) | ||
1296 | fifo_cnt++; | ||
1297 | if (fifo_cnt == 0) | ||
1298 | break; | ||
1299 | msleep_interruptible(jiffies_to_msecs(char_time)); | ||
1300 | if (signal_pending(current)) | ||
1301 | break; | ||
1302 | if (timeout && time_after(jiffies, orig_jiffies + timeout)) | ||
1303 | break; | ||
1304 | } | ||
1305 | unlock_kernel(); | ||
1306 | #else | ||
1307 | /* | ||
1308 | * For the other coldfire models, assume all data has been sent | ||
1309 | */ | ||
1310 | #endif | ||
1311 | } | ||
1312 | |||
1313 | /* | ||
1314 | * mcfrs_hangup() --- called by tty_hangup() when a hangup is signaled. | ||
1315 | */ | ||
1316 | void mcfrs_hangup(struct tty_struct *tty) | ||
1317 | { | ||
1318 | struct mcf_serial * info = (struct mcf_serial *)tty->driver_data; | ||
1319 | |||
1320 | if (serial_paranoia_check(info, tty->name, "mcfrs_hangup")) | ||
1321 | return; | ||
1322 | |||
1323 | mcfrs_flush_buffer(tty); | ||
1324 | shutdown(info); | ||
1325 | info->event = 0; | ||
1326 | info->count = 0; | ||
1327 | info->flags &= ~ASYNC_NORMAL_ACTIVE; | ||
1328 | info->port.tty = NULL; | ||
1329 | wake_up_interruptible(&info->open_wait); | ||
1330 | } | ||
1331 | |||
1332 | /* | ||
1333 | * ------------------------------------------------------------ | ||
1334 | * mcfrs_open() and friends | ||
1335 | * ------------------------------------------------------------ | ||
1336 | */ | ||
1337 | static int block_til_ready(struct tty_struct *tty, struct file * filp, | ||
1338 | struct mcf_serial *info) | ||
1339 | { | ||
1340 | DECLARE_WAITQUEUE(wait, current); | ||
1341 | int retval; | ||
1342 | int do_clocal = 0; | ||
1343 | |||
1344 | /* | ||
1345 | * If the device is in the middle of being closed, then block | ||
1346 | * until it's done, and then try again. | ||
1347 | */ | ||
1348 | if (info->flags & ASYNC_CLOSING) { | ||
1349 | interruptible_sleep_on(&info->close_wait); | ||
1350 | #ifdef SERIAL_DO_RESTART | ||
1351 | if (info->flags & ASYNC_HUP_NOTIFY) | ||
1352 | return -EAGAIN; | ||
1353 | else | ||
1354 | return -ERESTARTSYS; | ||
1355 | #else | ||
1356 | return -EAGAIN; | ||
1357 | #endif | ||
1358 | } | ||
1359 | |||
1360 | /* | ||
1361 | * If non-blocking mode is set, or the port is not enabled, | ||
1362 | * then make the check up front and then exit. | ||
1363 | */ | ||
1364 | if ((filp->f_flags & O_NONBLOCK) || | ||
1365 | (tty->flags & (1 << TTY_IO_ERROR))) { | ||
1366 | info->flags |= ASYNC_NORMAL_ACTIVE; | ||
1367 | return 0; | ||
1368 | } | ||
1369 | |||
1370 | if (tty->termios->c_cflag & CLOCAL) | ||
1371 | do_clocal = 1; | ||
1372 | |||
1373 | /* | ||
1374 | * Block waiting for the carrier detect and the line to become | ||
1375 | * free (i.e., not in use by the callout). While we are in | ||
1376 | * this loop, info->count is dropped by one, so that | ||
1377 | * mcfrs_close() knows when to free things. We restore it upon | ||
1378 | * exit, either normal or abnormal. | ||
1379 | */ | ||
1380 | retval = 0; | ||
1381 | add_wait_queue(&info->open_wait, &wait); | ||
1382 | #ifdef SERIAL_DEBUG_OPEN | ||
1383 | printk("block_til_ready before block: ttyS%d, count = %d\n", | ||
1384 | info->line, info->count); | ||
1385 | #endif | ||
1386 | info->count--; | ||
1387 | info->blocked_open++; | ||
1388 | while (1) { | ||
1389 | local_irq_disable(); | ||
1390 | mcfrs_setsignals(info, 1, 1); | ||
1391 | local_irq_enable(); | ||
1392 | current->state = TASK_INTERRUPTIBLE; | ||
1393 | if (tty_hung_up_p(filp) || | ||
1394 | !(info->flags & ASYNC_INITIALIZED)) { | ||
1395 | #ifdef SERIAL_DO_RESTART | ||
1396 | if (info->flags & ASYNC_HUP_NOTIFY) | ||
1397 | retval = -EAGAIN; | ||
1398 | else | ||
1399 | retval = -ERESTARTSYS; | ||
1400 | #else | ||
1401 | retval = -EAGAIN; | ||
1402 | #endif | ||
1403 | break; | ||
1404 | } | ||
1405 | if (!(info->flags & ASYNC_CLOSING) && | ||
1406 | (do_clocal || (mcfrs_getsignals(info) & TIOCM_CD))) | ||
1407 | break; | ||
1408 | if (signal_pending(current)) { | ||
1409 | retval = -ERESTARTSYS; | ||
1410 | break; | ||
1411 | } | ||
1412 | #ifdef SERIAL_DEBUG_OPEN | ||
1413 | printk("block_til_ready blocking: ttyS%d, count = %d\n", | ||
1414 | info->line, info->count); | ||
1415 | #endif | ||
1416 | schedule(); | ||
1417 | } | ||
1418 | current->state = TASK_RUNNING; | ||
1419 | remove_wait_queue(&info->open_wait, &wait); | ||
1420 | if (!tty_hung_up_p(filp)) | ||
1421 | info->count++; | ||
1422 | info->blocked_open--; | ||
1423 | #ifdef SERIAL_DEBUG_OPEN | ||
1424 | printk("block_til_ready after blocking: ttyS%d, count = %d\n", | ||
1425 | info->line, info->count); | ||
1426 | #endif | ||
1427 | if (retval) | ||
1428 | return retval; | ||
1429 | info->flags |= ASYNC_NORMAL_ACTIVE; | ||
1430 | return 0; | ||
1431 | } | ||
1432 | |||
1433 | /* | ||
1434 | * This routine is called whenever a serial port is opened. It | ||
1435 | * enables interrupts for a serial port, linking in its structure into | ||
1436 | * the IRQ chain. It also performs the serial-specific | ||
1437 | * initialization for the tty structure. | ||
1438 | */ | ||
1439 | int mcfrs_open(struct tty_struct *tty, struct file * filp) | ||
1440 | { | ||
1441 | struct mcf_serial *info; | ||
1442 | int retval, line; | ||
1443 | |||
1444 | line = tty->index; | ||
1445 | if ((line < 0) || (line >= NR_PORTS)) | ||
1446 | return -ENODEV; | ||
1447 | info = mcfrs_table + line; | ||
1448 | if (serial_paranoia_check(info, tty->name, "mcfrs_open")) | ||
1449 | return -ENODEV; | ||
1450 | #ifdef SERIAL_DEBUG_OPEN | ||
1451 | printk("mcfrs_open %s, count = %d\n", tty->name, info->count); | ||
1452 | #endif | ||
1453 | info->count++; | ||
1454 | tty->driver_data = info; | ||
1455 | info->port.tty = tty; | ||
1456 | |||
1457 | /* | ||
1458 | * Start up serial port | ||
1459 | */ | ||
1460 | retval = startup(info); | ||
1461 | if (retval) | ||
1462 | return retval; | ||
1463 | |||
1464 | retval = block_til_ready(tty, filp, info); | ||
1465 | if (retval) { | ||
1466 | #ifdef SERIAL_DEBUG_OPEN | ||
1467 | printk("mcfrs_open returning after block_til_ready with %d\n", | ||
1468 | retval); | ||
1469 | #endif | ||
1470 | return retval; | ||
1471 | } | ||
1472 | |||
1473 | #ifdef SERIAL_DEBUG_OPEN | ||
1474 | printk("mcfrs_open %s successful...\n", tty->name); | ||
1475 | #endif | ||
1476 | return 0; | ||
1477 | } | ||
1478 | |||
1479 | /* | ||
1480 | * Based on the line number set up the internal interrupt stuff. | ||
1481 | */ | ||
1482 | static void mcfrs_irqinit(struct mcf_serial *info) | ||
1483 | { | ||
1484 | #if defined(CONFIG_M5272) | ||
1485 | volatile unsigned long *icrp; | ||
1486 | volatile unsigned long *portp; | ||
1487 | volatile unsigned char *uartp; | ||
1488 | |||
1489 | uartp = info->addr; | ||
1490 | icrp = (volatile unsigned long *) (MCF_MBAR + MCFSIM_ICR2); | ||
1491 | |||
1492 | switch (info->line) { | ||
1493 | case 0: | ||
1494 | *icrp = 0xe0000000; | ||
1495 | break; | ||
1496 | case 1: | ||
1497 | *icrp = 0x0e000000; | ||
1498 | break; | ||
1499 | default: | ||
1500 | printk("MCFRS: don't know how to handle UART %d interrupt?\n", | ||
1501 | info->line); | ||
1502 | return; | ||
1503 | } | ||
1504 | |||
1505 | /* Enable the output lines for the serial ports */ | ||
1506 | portp = (volatile unsigned long *) (MCF_MBAR + MCFSIM_PBCNT); | ||
1507 | *portp = (*portp & ~0x000000ff) | 0x00000055; | ||
1508 | portp = (volatile unsigned long *) (MCF_MBAR + MCFSIM_PDCNT); | ||
1509 | *portp = (*portp & ~0x000003fc) | 0x000002a8; | ||
1510 | #elif defined(CONFIG_M523x) || defined(CONFIG_M527x) || defined(CONFIG_M528x) | ||
1511 | volatile unsigned char *icrp, *uartp; | ||
1512 | volatile unsigned long *imrp; | ||
1513 | |||
1514 | uartp = info->addr; | ||
1515 | |||
1516 | icrp = (volatile unsigned char *) (MCF_MBAR + MCFICM_INTC0 + | ||
1517 | MCFINTC_ICR0 + MCFINT_UART0 + info->line); | ||
1518 | *icrp = 0x30 + info->line; /* level 6, line based priority */ | ||
1519 | |||
1520 | imrp = (volatile unsigned long *) (MCF_MBAR + MCFICM_INTC0 + | ||
1521 | MCFINTC_IMRL); | ||
1522 | *imrp &= ~((1 << (info->irq - MCFINT_VECBASE)) | 1); | ||
1523 | #if defined(CONFIG_M527x) | ||
1524 | { | ||
1525 | /* | ||
1526 | * External Pin Mask Setting & Enable External Pin for Interface | ||
1527 | * mrcbis@aliceposta.it | ||
1528 | */ | ||
1529 | u16 *serpin_enable_mask; | ||
1530 | serpin_enable_mask = (u16 *) (MCF_IPSBAR + MCF_GPIO_PAR_UART); | ||
1531 | if (info->line == 0) | ||
1532 | *serpin_enable_mask |= UART0_ENABLE_MASK; | ||
1533 | else if (info->line == 1) | ||
1534 | *serpin_enable_mask |= UART1_ENABLE_MASK; | ||
1535 | else if (info->line == 2) | ||
1536 | *serpin_enable_mask |= UART2_ENABLE_MASK; | ||
1537 | } | ||
1538 | #endif | ||
1539 | #if defined(CONFIG_M528x) | ||
1540 | /* make sure PUAPAR is set for UART0 and UART1 */ | ||
1541 | if (info->line < 2) { | ||
1542 | volatile unsigned char *portp = (volatile unsigned char *) (MCF_MBAR + MCF5282_GPIO_PUAPAR); | ||
1543 | *portp |= (0x03 << (info->line * 2)); | ||
1544 | } | ||
1545 | #endif | ||
1546 | #elif defined(CONFIG_M520x) | ||
1547 | volatile unsigned char *icrp, *uartp; | ||
1548 | volatile unsigned long *imrp; | ||
1549 | |||
1550 | uartp = info->addr; | ||
1551 | |||
1552 | icrp = (volatile unsigned char *) (MCF_MBAR + MCFICM_INTC0 + | ||
1553 | MCFINTC_ICR0 + MCFINT_UART0 + info->line); | ||
1554 | *icrp = 0x03; | ||
1555 | |||
1556 | imrp = (volatile unsigned long *) (MCF_MBAR + MCFICM_INTC0 + | ||
1557 | MCFINTC_IMRL); | ||
1558 | *imrp &= ~((1 << (info->irq - MCFINT_VECBASE)) | 1); | ||
1559 | if (info->line < 2) { | ||
1560 | unsigned short *uart_par; | ||
1561 | uart_par = (unsigned short *)(MCF_IPSBAR + MCF_GPIO_PAR_UART); | ||
1562 | if (info->line == 0) | ||
1563 | *uart_par |= MCF_GPIO_PAR_UART_PAR_UTXD0 | ||
1564 | | MCF_GPIO_PAR_UART_PAR_URXD0; | ||
1565 | else if (info->line == 1) | ||
1566 | *uart_par |= MCF_GPIO_PAR_UART_PAR_UTXD1 | ||
1567 | | MCF_GPIO_PAR_UART_PAR_URXD1; | ||
1568 | } else if (info->line == 2) { | ||
1569 | unsigned char *feci2c_par; | ||
1570 | feci2c_par = (unsigned char *)(MCF_IPSBAR + MCF_GPIO_PAR_FECI2C); | ||
1571 | *feci2c_par &= ~0x0F; | ||
1572 | *feci2c_par |= MCF_GPIO_PAR_FECI2C_PAR_SCL_UTXD2 | ||
1573 | | MCF_GPIO_PAR_FECI2C_PAR_SDA_URXD2; | ||
1574 | } | ||
1575 | #elif defined(CONFIG_M532x) | ||
1576 | volatile unsigned char *uartp; | ||
1577 | uartp = info->addr; | ||
1578 | switch (info->line) { | ||
1579 | case 0: | ||
1580 | MCF_INTC0_ICR26 = 0x3; | ||
1581 | MCF_INTC0_CIMR = 26; | ||
1582 | /* GPIO initialization */ | ||
1583 | MCF_GPIO_PAR_UART |= 0x000F; | ||
1584 | break; | ||
1585 | case 1: | ||
1586 | MCF_INTC0_ICR27 = 0x3; | ||
1587 | MCF_INTC0_CIMR = 27; | ||
1588 | /* GPIO initialization */ | ||
1589 | MCF_GPIO_PAR_UART |= 0x0FF0; | ||
1590 | break; | ||
1591 | case 2: | ||
1592 | MCF_INTC0_ICR28 = 0x3; | ||
1593 | MCF_INTC0_CIMR = 28; | ||
1594 | /* GPIOs also must be initalized, depends on board */ | ||
1595 | break; | ||
1596 | } | ||
1597 | #else | ||
1598 | volatile unsigned char *icrp, *uartp; | ||
1599 | |||
1600 | switch (info->line) { | ||
1601 | case 0: | ||
1602 | icrp = (volatile unsigned char *) (MCF_MBAR + MCFSIM_UART1ICR); | ||
1603 | *icrp = /*MCFSIM_ICR_AUTOVEC |*/ MCFSIM_ICR_LEVEL6 | | ||
1604 | MCFSIM_ICR_PRI1; | ||
1605 | mcf_setimr(mcf_getimr() & ~MCFSIM_IMR_UART1); | ||
1606 | break; | ||
1607 | case 1: | ||
1608 | icrp = (volatile unsigned char *) (MCF_MBAR + MCFSIM_UART2ICR); | ||
1609 | *icrp = /*MCFSIM_ICR_AUTOVEC |*/ MCFSIM_ICR_LEVEL6 | | ||
1610 | MCFSIM_ICR_PRI2; | ||
1611 | mcf_setimr(mcf_getimr() & ~MCFSIM_IMR_UART2); | ||
1612 | break; | ||
1613 | default: | ||
1614 | printk("MCFRS: don't know how to handle UART %d interrupt?\n", | ||
1615 | info->line); | ||
1616 | return; | ||
1617 | } | ||
1618 | |||
1619 | uartp = info->addr; | ||
1620 | uartp[MCFUART_UIVR] = info->irq; | ||
1621 | #endif | ||
1622 | |||
1623 | /* Clear mask, so no surprise interrupts. */ | ||
1624 | uartp[MCFUART_UIMR] = 0; | ||
1625 | |||
1626 | if (request_irq(info->irq, mcfrs_interrupt, IRQF_DISABLED, | ||
1627 | "ColdFire UART", NULL)) { | ||
1628 | printk("MCFRS: Unable to attach ColdFire UART %d interrupt " | ||
1629 | "vector=%d\n", info->line, info->irq); | ||
1630 | } | ||
1631 | |||
1632 | return; | ||
1633 | } | ||
1634 | |||
1635 | |||
1636 | char *mcfrs_drivername = "ColdFire internal UART serial driver version 1.00\n"; | ||
1637 | |||
1638 | |||
1639 | /* | ||
1640 | * Serial stats reporting... | ||
1641 | */ | ||
1642 | int mcfrs_readproc(char *page, char **start, off_t off, int count, | ||
1643 | int *eof, void *data) | ||
1644 | { | ||
1645 | struct mcf_serial *info; | ||
1646 | char str[20]; | ||
1647 | int len, sigs, i; | ||
1648 | |||
1649 | len = sprintf(page, mcfrs_drivername); | ||
1650 | for (i = 0; (i < NR_PORTS); i++) { | ||
1651 | info = &mcfrs_table[i]; | ||
1652 | len += sprintf((page + len), "%d: port:%x irq=%d baud:%d ", | ||
1653 | i, (unsigned int) info->addr, info->irq, info->baud); | ||
1654 | if (info->stats.rx || info->stats.tx) | ||
1655 | len += sprintf((page + len), "tx:%d rx:%d ", | ||
1656 | info->stats.tx, info->stats.rx); | ||
1657 | if (info->stats.rxframing) | ||
1658 | len += sprintf((page + len), "fe:%d ", | ||
1659 | info->stats.rxframing); | ||
1660 | if (info->stats.rxparity) | ||
1661 | len += sprintf((page + len), "pe:%d ", | ||
1662 | info->stats.rxparity); | ||
1663 | if (info->stats.rxbreak) | ||
1664 | len += sprintf((page + len), "brk:%d ", | ||
1665 | info->stats.rxbreak); | ||
1666 | if (info->stats.rxoverrun) | ||
1667 | len += sprintf((page + len), "oe:%d ", | ||
1668 | info->stats.rxoverrun); | ||
1669 | |||
1670 | str[0] = str[1] = 0; | ||
1671 | if ((sigs = mcfrs_getsignals(info))) { | ||
1672 | if (sigs & TIOCM_RTS) | ||
1673 | strcat(str, "|RTS"); | ||
1674 | if (sigs & TIOCM_CTS) | ||
1675 | strcat(str, "|CTS"); | ||
1676 | if (sigs & TIOCM_DTR) | ||
1677 | strcat(str, "|DTR"); | ||
1678 | if (sigs & TIOCM_CD) | ||
1679 | strcat(str, "|CD"); | ||
1680 | } | ||
1681 | |||
1682 | len += sprintf((page + len), "%s\n", &str[1]); | ||
1683 | } | ||
1684 | |||
1685 | return(len); | ||
1686 | } | ||
1687 | |||
1688 | |||
1689 | /* Finally, routines used to initialize the serial driver. */ | ||
1690 | |||
1691 | static void show_serial_version(void) | ||
1692 | { | ||
1693 | printk(mcfrs_drivername); | ||
1694 | } | ||
1695 | |||
1696 | static const struct tty_operations mcfrs_ops = { | ||
1697 | .open = mcfrs_open, | ||
1698 | .close = mcfrs_close, | ||
1699 | .write = mcfrs_write, | ||
1700 | .flush_chars = mcfrs_flush_chars, | ||
1701 | .write_room = mcfrs_write_room, | ||
1702 | .chars_in_buffer = mcfrs_chars_in_buffer, | ||
1703 | .flush_buffer = mcfrs_flush_buffer, | ||
1704 | .ioctl = mcfrs_ioctl, | ||
1705 | .throttle = mcfrs_throttle, | ||
1706 | .unthrottle = mcfrs_unthrottle, | ||
1707 | .set_termios = mcfrs_set_termios, | ||
1708 | .stop = mcfrs_stop, | ||
1709 | .start = mcfrs_start, | ||
1710 | .hangup = mcfrs_hangup, | ||
1711 | .read_proc = mcfrs_readproc, | ||
1712 | .wait_until_sent = mcfrs_wait_until_sent, | ||
1713 | .tiocmget = mcfrs_tiocmget, | ||
1714 | .tiocmset = mcfrs_tiocmset, | ||
1715 | }; | ||
1716 | |||
1717 | /* mcfrs_init inits the driver */ | ||
1718 | static int __init | ||
1719 | mcfrs_init(void) | ||
1720 | { | ||
1721 | struct mcf_serial *info; | ||
1722 | unsigned long flags; | ||
1723 | int i; | ||
1724 | |||
1725 | /* Setup base handler, and timer table. */ | ||
1726 | #ifdef MCFPP_DCD0 | ||
1727 | init_timer(&mcfrs_timer_struct); | ||
1728 | mcfrs_timer_struct.function = mcfrs_timer; | ||
1729 | mcfrs_timer_struct.data = 0; | ||
1730 | mcfrs_timer_struct.expires = jiffies + HZ/25; | ||
1731 | add_timer(&mcfrs_timer_struct); | ||
1732 | mcfrs_ppstatus = mcf_getppdata() & (MCFPP_DCD0 | MCFPP_DCD1); | ||
1733 | #endif | ||
1734 | mcfrs_serial_driver = alloc_tty_driver(NR_PORTS); | ||
1735 | if (!mcfrs_serial_driver) | ||
1736 | return -ENOMEM; | ||
1737 | |||
1738 | show_serial_version(); | ||
1739 | |||
1740 | /* Initialize the tty_driver structure */ | ||
1741 | mcfrs_serial_driver->owner = THIS_MODULE; | ||
1742 | mcfrs_serial_driver->name = "ttyS"; | ||
1743 | mcfrs_serial_driver->driver_name = "mcfserial"; | ||
1744 | mcfrs_serial_driver->major = TTY_MAJOR; | ||
1745 | mcfrs_serial_driver->minor_start = 64; | ||
1746 | mcfrs_serial_driver->type = TTY_DRIVER_TYPE_SERIAL; | ||
1747 | mcfrs_serial_driver->subtype = SERIAL_TYPE_NORMAL; | ||
1748 | mcfrs_serial_driver->init_termios = tty_std_termios; | ||
1749 | |||
1750 | mcfrs_serial_driver->init_termios.c_cflag = | ||
1751 | mcfrs_console_cbaud | CS8 | CREAD | HUPCL | CLOCAL; | ||
1752 | mcfrs_serial_driver->flags = TTY_DRIVER_REAL_RAW; | ||
1753 | |||
1754 | tty_set_operations(mcfrs_serial_driver, &mcfrs_ops); | ||
1755 | |||
1756 | if (tty_register_driver(mcfrs_serial_driver)) { | ||
1757 | printk("MCFRS: Couldn't register serial driver\n"); | ||
1758 | put_tty_driver(mcfrs_serial_driver); | ||
1759 | return(-EBUSY); | ||
1760 | } | ||
1761 | |||
1762 | local_irq_save(flags); | ||
1763 | |||
1764 | /* | ||
1765 | * Configure all the attached serial ports. | ||
1766 | */ | ||
1767 | for (i = 0, info = mcfrs_table; (i < NR_PORTS); i++, info++) { | ||
1768 | info->magic = SERIAL_MAGIC; | ||
1769 | info->line = i; | ||
1770 | info->port.tty = NULL; | ||
1771 | info->custom_divisor = 16; | ||
1772 | info->close_delay = 50; | ||
1773 | info->closing_wait = 3000; | ||
1774 | info->x_char = 0; | ||
1775 | info->event = 0; | ||
1776 | info->count = 0; | ||
1777 | info->blocked_open = 0; | ||
1778 | INIT_WORK(&info->tqueue, mcfrs_offintr); | ||
1779 | INIT_WORK(&info->tqueue_hangup, do_serial_hangup); | ||
1780 | init_waitqueue_head(&info->open_wait); | ||
1781 | init_waitqueue_head(&info->close_wait); | ||
1782 | |||
1783 | info->imr = 0; | ||
1784 | mcfrs_setsignals(info, 0, 0); | ||
1785 | mcfrs_irqinit(info); | ||
1786 | |||
1787 | printk("ttyS%d at 0x%04x (irq = %d)", info->line, | ||
1788 | (unsigned int) info->addr, info->irq); | ||
1789 | printk(" is a builtin ColdFire UART\n"); | ||
1790 | } | ||
1791 | |||
1792 | local_irq_restore(flags); | ||
1793 | return 0; | ||
1794 | } | ||
1795 | |||
1796 | module_init(mcfrs_init); | ||
1797 | |||
1798 | /****************************************************************************/ | ||
1799 | /* Serial Console */ | ||
1800 | /****************************************************************************/ | ||
1801 | |||
1802 | /* | ||
1803 | * Quick and dirty UART initialization, for console output. | ||
1804 | */ | ||
1805 | |||
1806 | void mcfrs_init_console(void) | ||
1807 | { | ||
1808 | volatile unsigned char *uartp; | ||
1809 | unsigned int clk; | ||
1810 | |||
1811 | /* | ||
1812 | * Reset UART, get it into known state... | ||
1813 | */ | ||
1814 | uartp = (volatile unsigned char *) (MCF_MBAR + | ||
1815 | (mcfrs_console_port ? MCFUART_BASE2 : MCFUART_BASE1)); | ||
1816 | |||
1817 | uartp[MCFUART_UCR] = MCFUART_UCR_CMDRESETRX; /* reset RX */ | ||
1818 | uartp[MCFUART_UCR] = MCFUART_UCR_CMDRESETTX; /* reset TX */ | ||
1819 | uartp[MCFUART_UCR] = MCFUART_UCR_CMDRESETMRPTR; /* reset MR pointer */ | ||
1820 | |||
1821 | /* | ||
1822 | * Set port for defined baud , 8 data bits, 1 stop bit, no parity. | ||
1823 | */ | ||
1824 | uartp[MCFUART_UMR] = MCFUART_MR1_PARITYNONE | MCFUART_MR1_CS8; | ||
1825 | uartp[MCFUART_UMR] = MCFUART_MR2_STOP1; | ||
1826 | |||
1827 | #ifdef CONFIG_M5272 | ||
1828 | { | ||
1829 | /* | ||
1830 | * For the MCF5272, also compute the baudrate fraction. | ||
1831 | */ | ||
1832 | int fraction = MCF_BUSCLK - (clk * 32 * mcfrs_console_baud); | ||
1833 | fraction *= 16; | ||
1834 | fraction /= (32 * mcfrs_console_baud); | ||
1835 | uartp[MCFUART_UFPD] = (fraction & 0xf); /* set fraction */ | ||
1836 | clk = (MCF_BUSCLK / mcfrs_console_baud) / 32; | ||
1837 | } | ||
1838 | #else | ||
1839 | clk = ((MCF_BUSCLK / mcfrs_console_baud) + 16) / 32; /* set baud */ | ||
1840 | #endif | ||
1841 | |||
1842 | uartp[MCFUART_UBG1] = (clk & 0xff00) >> 8; /* set msb baud */ | ||
1843 | uartp[MCFUART_UBG2] = (clk & 0xff); /* set lsb baud */ | ||
1844 | uartp[MCFUART_UCSR] = MCFUART_UCSR_RXCLKTIMER | MCFUART_UCSR_TXCLKTIMER; | ||
1845 | uartp[MCFUART_UCR] = MCFUART_UCR_RXENABLE | MCFUART_UCR_TXENABLE; | ||
1846 | |||
1847 | mcfrs_console_inited++; | ||
1848 | return; | ||
1849 | } | ||
1850 | |||
1851 | |||
1852 | /* | ||
1853 | * Setup for console. Argument comes from the boot command line. | ||
1854 | */ | ||
1855 | |||
1856 | int mcfrs_console_setup(struct console *cp, char *arg) | ||
1857 | { | ||
1858 | int i, n = CONSOLE_BAUD_RATE; | ||
1859 | |||
1860 | if (!cp) | ||
1861 | return(-1); | ||
1862 | |||
1863 | if (!strncmp(cp->name, "ttyS", 4)) | ||
1864 | mcfrs_console_port = cp->index; | ||
1865 | else if (!strncmp(cp->name, "cua", 3)) | ||
1866 | mcfrs_console_port = cp->index; | ||
1867 | else | ||
1868 | return(-1); | ||
1869 | |||
1870 | if (arg) | ||
1871 | n = simple_strtoul(arg,NULL,0); | ||
1872 | for (i = 0; i < MCFRS_BAUD_TABLE_SIZE; i++) | ||
1873 | if (mcfrs_baud_table[i] == n) | ||
1874 | break; | ||
1875 | if (i < MCFRS_BAUD_TABLE_SIZE) { | ||
1876 | mcfrs_console_baud = n; | ||
1877 | mcfrs_console_cbaud = 0; | ||
1878 | if (i > 15) { | ||
1879 | mcfrs_console_cbaud |= CBAUDEX; | ||
1880 | i -= 15; | ||
1881 | } | ||
1882 | mcfrs_console_cbaud |= i; | ||
1883 | } | ||
1884 | mcfrs_init_console(); /* make sure baud rate changes */ | ||
1885 | return(0); | ||
1886 | } | ||
1887 | |||
1888 | |||
1889 | static struct tty_driver *mcfrs_console_device(struct console *c, int *index) | ||
1890 | { | ||
1891 | *index = c->index; | ||
1892 | return mcfrs_serial_driver; | ||
1893 | } | ||
1894 | |||
1895 | |||
1896 | /* | ||
1897 | * Output a single character, using UART polled mode. | ||
1898 | * This is used for console output. | ||
1899 | */ | ||
1900 | |||
1901 | int mcfrs_put_char(char ch) | ||
1902 | { | ||
1903 | volatile unsigned char *uartp; | ||
1904 | unsigned long flags; | ||
1905 | int i; | ||
1906 | |||
1907 | uartp = (volatile unsigned char *) (MCF_MBAR + | ||
1908 | (mcfrs_console_port ? MCFUART_BASE2 : MCFUART_BASE1)); | ||
1909 | |||
1910 | local_irq_save(flags); | ||
1911 | for (i = 0; (i < 0x10000); i++) { | ||
1912 | if (uartp[MCFUART_USR] & MCFUART_USR_TXREADY) | ||
1913 | break; | ||
1914 | } | ||
1915 | if (i < 0x10000) { | ||
1916 | uartp[MCFUART_UTB] = ch; | ||
1917 | for (i = 0; (i < 0x10000); i++) | ||
1918 | if (uartp[MCFUART_USR] & MCFUART_USR_TXEMPTY) | ||
1919 | break; | ||
1920 | } | ||
1921 | if (i >= 0x10000) | ||
1922 | mcfrs_init_console(); /* try and get it back */ | ||
1923 | local_irq_restore(flags); | ||
1924 | |||
1925 | return 1; | ||
1926 | } | ||
1927 | |||
1928 | |||
1929 | /* | ||
1930 | * rs_console_write is registered for printk output. | ||
1931 | */ | ||
1932 | |||
1933 | void mcfrs_console_write(struct console *cp, const char *p, unsigned len) | ||
1934 | { | ||
1935 | if (!mcfrs_console_inited) | ||
1936 | mcfrs_init_console(); | ||
1937 | while (len-- > 0) { | ||
1938 | if (*p == '\n') | ||
1939 | mcfrs_put_char('\r'); | ||
1940 | mcfrs_put_char(*p++); | ||
1941 | } | ||
1942 | } | ||
1943 | |||
1944 | /* | ||
1945 | * declare our consoles | ||
1946 | */ | ||
1947 | |||
1948 | struct console mcfrs_console = { | ||
1949 | .name = "ttyS", | ||
1950 | .write = mcfrs_console_write, | ||
1951 | .device = mcfrs_console_device, | ||
1952 | .setup = mcfrs_console_setup, | ||
1953 | .flags = CON_PRINTBUFFER, | ||
1954 | .index = -1, | ||
1955 | }; | ||
1956 | |||
1957 | static int __init mcfrs_console_init(void) | ||
1958 | { | ||
1959 | register_console(&mcfrs_console); | ||
1960 | return 0; | ||
1961 | } | ||
1962 | |||
1963 | console_initcall(mcfrs_console_init); | ||
1964 | |||
1965 | /****************************************************************************/ | ||
diff --git a/drivers/serial/mcfserial.h b/drivers/serial/mcfserial.h deleted file mode 100644 index 56420e2cb110..000000000000 --- a/drivers/serial/mcfserial.h +++ /dev/null | |||
@@ -1,74 +0,0 @@ | |||
1 | /* | ||
2 | * mcfserial.c -- serial driver for ColdFire internal UARTS. | ||
3 | * | ||
4 | * Copyright (c) 1999 Greg Ungerer <gerg@snapgear.com> | ||
5 | * Copyright (c) 2000-2001 Lineo, Inc. <www.lineo.com> | ||
6 | * Copyright (c) 2002 SnapGear Inc., <www.snapgear.com> | ||
7 | * | ||
8 | * Based on code from 68332serial.c which was: | ||
9 | * | ||
10 | * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu) | ||
11 | * Copyright (C) 1998 TSHG | ||
12 | * Copyright (c) 1999 Rt-Control Inc. <jeff@uclinux.org> | ||
13 | */ | ||
14 | #ifndef _MCF_SERIAL_H | ||
15 | #define _MCF_SERIAL_H | ||
16 | |||
17 | #include <linux/serial.h> | ||
18 | |||
19 | #ifdef __KERNEL__ | ||
20 | |||
21 | /* | ||
22 | * Define a local serial stats structure. | ||
23 | */ | ||
24 | |||
25 | struct mcf_stats { | ||
26 | unsigned int rx; | ||
27 | unsigned int tx; | ||
28 | unsigned int rxbreak; | ||
29 | unsigned int rxframing; | ||
30 | unsigned int rxparity; | ||
31 | unsigned int rxoverrun; | ||
32 | }; | ||
33 | |||
34 | |||
35 | /* | ||
36 | * This is our internal structure for each serial port's state. | ||
37 | * Each serial port has one of these structures associated with it. | ||
38 | */ | ||
39 | |||
40 | struct mcf_serial { | ||
41 | int magic; | ||
42 | volatile unsigned char *addr; /* UART memory address */ | ||
43 | int irq; | ||
44 | int flags; /* defined in tty.h */ | ||
45 | int type; /* UART type */ | ||
46 | struct tty_struct *tty; | ||
47 | unsigned char imr; /* Software imr register */ | ||
48 | unsigned int baud; | ||
49 | int sigs; | ||
50 | int custom_divisor; | ||
51 | int x_char; /* xon/xoff character */ | ||
52 | int baud_base; | ||
53 | int close_delay; | ||
54 | unsigned short closing_wait; | ||
55 | unsigned short closing_wait2; | ||
56 | unsigned long event; | ||
57 | int line; | ||
58 | int count; /* # of fd on device */ | ||
59 | int blocked_open; /* # of blocked opens */ | ||
60 | unsigned char *xmit_buf; | ||
61 | int xmit_head; | ||
62 | int xmit_tail; | ||
63 | int xmit_cnt; | ||
64 | struct mcf_stats stats; | ||
65 | struct work_struct tqueue; | ||
66 | struct work_struct tqueue_hangup; | ||
67 | wait_queue_head_t open_wait; | ||
68 | wait_queue_head_t close_wait; | ||
69 | |||
70 | }; | ||
71 | |||
72 | #endif /* __KERNEL__ */ | ||
73 | |||
74 | #endif /* _MCF_SERIAL_H */ | ||
diff --git a/drivers/serial/netx-serial.c b/drivers/serial/netx-serial.c index 9f8ccb735c19..3f489329e8d3 100644 --- a/drivers/serial/netx-serial.c +++ b/drivers/serial/netx-serial.c | |||
@@ -35,8 +35,8 @@ | |||
35 | 35 | ||
36 | #include <asm/io.h> | 36 | #include <asm/io.h> |
37 | #include <asm/irq.h> | 37 | #include <asm/irq.h> |
38 | #include <asm/hardware.h> | 38 | #include <mach/hardware.h> |
39 | #include <asm/arch/netx-regs.h> | 39 | #include <mach/netx-regs.h> |
40 | 40 | ||
41 | /* We've been assigned a range on the "Low-density serial ports" major */ | 41 | /* We've been assigned a range on the "Low-density serial ports" major */ |
42 | #define SERIAL_NX_MAJOR 204 | 42 | #define SERIAL_NX_MAJOR 204 |
diff --git a/drivers/serial/pxa.c b/drivers/serial/pxa.c index b9a93f326fb8..abc00be55433 100644 --- a/drivers/serial/pxa.c +++ b/drivers/serial/pxa.c | |||
@@ -45,9 +45,9 @@ | |||
45 | #include <linux/clk.h> | 45 | #include <linux/clk.h> |
46 | 46 | ||
47 | #include <asm/io.h> | 47 | #include <asm/io.h> |
48 | #include <asm/hardware.h> | 48 | #include <mach/hardware.h> |
49 | #include <asm/irq.h> | 49 | #include <asm/irq.h> |
50 | #include <asm/arch/pxa-regs.h> | 50 | #include <mach/pxa-regs.h> |
51 | 51 | ||
52 | 52 | ||
53 | struct uart_pxa_port { | 53 | struct uart_pxa_port { |
@@ -534,6 +534,11 @@ serial_pxa_set_termios(struct uart_port *port, struct ktermios *termios, | |||
534 | 534 | ||
535 | serial_out(up, UART_IER, up->ier); | 535 | serial_out(up, UART_IER, up->ier); |
536 | 536 | ||
537 | if (termios->c_cflag & CRTSCTS) | ||
538 | up->mcr |= UART_MCR_AFE; | ||
539 | else | ||
540 | up->mcr &= ~UART_MCR_AFE; | ||
541 | |||
537 | serial_out(up, UART_LCR, cval | UART_LCR_DLAB);/* set DLAB */ | 542 | serial_out(up, UART_LCR, cval | UART_LCR_DLAB);/* set DLAB */ |
538 | serial_out(up, UART_DLL, quot & 0xff); /* LS of divisor */ | 543 | serial_out(up, UART_DLL, quot & 0xff); /* LS of divisor */ |
539 | serial_out(up, UART_DLM, quot >> 8); /* MS of divisor */ | 544 | serial_out(up, UART_DLM, quot >> 8); /* MS of divisor */ |
diff --git a/drivers/serial/s3c2400.c b/drivers/serial/s3c2400.c index a1102053e553..c8b4266ac35f 100644 --- a/drivers/serial/s3c2400.c +++ b/drivers/serial/s3c2400.c | |||
@@ -17,10 +17,10 @@ | |||
17 | 17 | ||
18 | #include <asm/irq.h> | 18 | #include <asm/irq.h> |
19 | 19 | ||
20 | #include <asm/hardware.h> | 20 | #include <mach/hardware.h> |
21 | 21 | ||
22 | #include <asm/plat-s3c/regs-serial.h> | 22 | #include <asm/plat-s3c/regs-serial.h> |
23 | #include <asm/arch/regs-gpio.h> | 23 | #include <mach/regs-gpio.h> |
24 | 24 | ||
25 | #include "samsung.h" | 25 | #include "samsung.h" |
26 | 26 | ||
diff --git a/drivers/serial/s3c2410.c b/drivers/serial/s3c2410.c index c5f03f41686f..40a2531b5541 100644 --- a/drivers/serial/s3c2410.c +++ b/drivers/serial/s3c2410.c | |||
@@ -19,10 +19,10 @@ | |||
19 | #include <linux/serial.h> | 19 | #include <linux/serial.h> |
20 | 20 | ||
21 | #include <asm/irq.h> | 21 | #include <asm/irq.h> |
22 | #include <asm/hardware.h> | 22 | #include <mach/hardware.h> |
23 | 23 | ||
24 | #include <asm/plat-s3c/regs-serial.h> | 24 | #include <asm/plat-s3c/regs-serial.h> |
25 | #include <asm/arch/regs-gpio.h> | 25 | #include <mach/regs-gpio.h> |
26 | 26 | ||
27 | #include "samsung.h" | 27 | #include "samsung.h" |
28 | 28 | ||
diff --git a/drivers/serial/s3c2412.c b/drivers/serial/s3c2412.c index ce0c220e3e92..d0170319c729 100644 --- a/drivers/serial/s3c2412.c +++ b/drivers/serial/s3c2412.c | |||
@@ -19,10 +19,10 @@ | |||
19 | #include <linux/serial.h> | 19 | #include <linux/serial.h> |
20 | 20 | ||
21 | #include <asm/irq.h> | 21 | #include <asm/irq.h> |
22 | #include <asm/hardware.h> | 22 | #include <mach/hardware.h> |
23 | 23 | ||
24 | #include <asm/plat-s3c/regs-serial.h> | 24 | #include <asm/plat-s3c/regs-serial.h> |
25 | #include <asm/arch/regs-gpio.h> | 25 | #include <mach/regs-gpio.h> |
26 | 26 | ||
27 | #include "samsung.h" | 27 | #include "samsung.h" |
28 | 28 | ||
diff --git a/drivers/serial/s3c2440.c b/drivers/serial/s3c2440.c index 38f954bd39c6..d4a2b17b2498 100644 --- a/drivers/serial/s3c2440.c +++ b/drivers/serial/s3c2440.c | |||
@@ -19,10 +19,10 @@ | |||
19 | #include <linux/serial.h> | 19 | #include <linux/serial.h> |
20 | 20 | ||
21 | #include <asm/irq.h> | 21 | #include <asm/irq.h> |
22 | #include <asm/hardware.h> | 22 | #include <mach/hardware.h> |
23 | 23 | ||
24 | #include <asm/plat-s3c/regs-serial.h> | 24 | #include <asm/plat-s3c/regs-serial.h> |
25 | #include <asm/arch/regs-gpio.h> | 25 | #include <mach/regs-gpio.h> |
26 | 26 | ||
27 | #include "samsung.h" | 27 | #include "samsung.h" |
28 | 28 | ||
diff --git a/drivers/serial/sa1100.c b/drivers/serial/sa1100.c index a5e76cc18073..b24a25ea6bc5 100644 --- a/drivers/serial/sa1100.c +++ b/drivers/serial/sa1100.c | |||
@@ -39,7 +39,7 @@ | |||
39 | 39 | ||
40 | #include <asm/io.h> | 40 | #include <asm/io.h> |
41 | #include <asm/irq.h> | 41 | #include <asm/irq.h> |
42 | #include <asm/hardware.h> | 42 | #include <mach/hardware.h> |
43 | #include <asm/mach/serial_sa1100.h> | 43 | #include <asm/mach/serial_sa1100.h> |
44 | 44 | ||
45 | /* We've been assigned a range on the "Low-density serial ports" major */ | 45 | /* We've been assigned a range on the "Low-density serial ports" major */ |
diff --git a/drivers/serial/samsung.c b/drivers/serial/samsung.c index d852f83f8900..5a88b3f9fe9b 100644 --- a/drivers/serial/samsung.c +++ b/drivers/serial/samsung.c | |||
@@ -45,10 +45,10 @@ | |||
45 | 45 | ||
46 | #include <asm/irq.h> | 46 | #include <asm/irq.h> |
47 | 47 | ||
48 | #include <asm/hardware.h> | 48 | #include <mach/hardware.h> |
49 | 49 | ||
50 | #include <asm/plat-s3c/regs-serial.h> | 50 | #include <asm/plat-s3c/regs-serial.h> |
51 | #include <asm/arch/regs-gpio.h> | 51 | #include <mach/regs-gpio.h> |
52 | 52 | ||
53 | #include "samsung.h" | 53 | #include "samsung.h" |
54 | 54 | ||
diff --git a/drivers/serial/serial_core.c b/drivers/serial/serial_core.c index f977c98cfa95..6bdf3362e3b1 100644 --- a/drivers/serial/serial_core.c +++ b/drivers/serial/serial_core.c | |||
@@ -2051,7 +2051,8 @@ int uart_suspend_port(struct uart_driver *drv, struct uart_port *port) | |||
2051 | "transmitter\n", | 2051 | "transmitter\n", |
2052 | port->dev ? port->dev->bus_id : "", | 2052 | port->dev ? port->dev->bus_id : "", |
2053 | port->dev ? ": " : "", | 2053 | port->dev ? ": " : "", |
2054 | drv->dev_name, port->line); | 2054 | drv->dev_name, |
2055 | drv->tty_driver->name_base + port->line); | ||
2055 | 2056 | ||
2056 | ops->shutdown(port); | 2057 | ops->shutdown(port); |
2057 | } | 2058 | } |
@@ -2154,12 +2155,11 @@ uart_report_port(struct uart_driver *drv, struct uart_port *port) | |||
2154 | 2155 | ||
2155 | switch (port->iotype) { | 2156 | switch (port->iotype) { |
2156 | case UPIO_PORT: | 2157 | case UPIO_PORT: |
2157 | snprintf(address, sizeof(address), | 2158 | snprintf(address, sizeof(address), "I/O 0x%lx", port->iobase); |
2158 | "I/O 0x%x", port->iobase); | ||
2159 | break; | 2159 | break; |
2160 | case UPIO_HUB6: | 2160 | case UPIO_HUB6: |
2161 | snprintf(address, sizeof(address), | 2161 | snprintf(address, sizeof(address), |
2162 | "I/O 0x%x offset 0x%x", port->iobase, port->hub6); | 2162 | "I/O 0x%lx offset 0x%x", port->iobase, port->hub6); |
2163 | break; | 2163 | break; |
2164 | case UPIO_MEM: | 2164 | case UPIO_MEM: |
2165 | case UPIO_MEM32: | 2165 | case UPIO_MEM32: |
@@ -2177,7 +2177,9 @@ uart_report_port(struct uart_driver *drv, struct uart_port *port) | |||
2177 | printk(KERN_INFO "%s%s%s%d at %s (irq = %d) is a %s\n", | 2177 | printk(KERN_INFO "%s%s%s%d at %s (irq = %d) is a %s\n", |
2178 | port->dev ? port->dev->bus_id : "", | 2178 | port->dev ? port->dev->bus_id : "", |
2179 | port->dev ? ": " : "", | 2179 | port->dev ? ": " : "", |
2180 | drv->dev_name, port->line, address, port->irq, uart_type(port)); | 2180 | drv->dev_name, |
2181 | drv->tty_driver->name_base + port->line, | ||
2182 | address, port->irq, uart_type(port)); | ||
2181 | } | 2183 | } |
2182 | 2184 | ||
2183 | static void | 2185 | static void |
diff --git a/drivers/serial/serial_ks8695.c b/drivers/serial/serial_ks8695.c index 0edbc5dd378b..998e89dc5aaf 100644 --- a/drivers/serial/serial_ks8695.c +++ b/drivers/serial/serial_ks8695.c | |||
@@ -26,8 +26,8 @@ | |||
26 | #include <asm/irq.h> | 26 | #include <asm/irq.h> |
27 | #include <asm/mach/irq.h> | 27 | #include <asm/mach/irq.h> |
28 | 28 | ||
29 | #include <asm/arch/regs-uart.h> | 29 | #include <mach/regs-uart.h> |
30 | #include <asm/arch/regs-irq.h> | 30 | #include <mach/regs-irq.h> |
31 | 31 | ||
32 | #if defined(CONFIG_SERIAL_KS8695_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) | 32 | #if defined(CONFIG_SERIAL_KS8695_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) |
33 | #define SUPPORT_SYSRQ | 33 | #define SUPPORT_SYSRQ |
@@ -63,8 +63,44 @@ | |||
63 | #define UART_DUMMY_LSR_RX 0x100 | 63 | #define UART_DUMMY_LSR_RX 0x100 |
64 | #define UART_PORT_SIZE (KS8695_USR - KS8695_URRB + 4) | 64 | #define UART_PORT_SIZE (KS8695_USR - KS8695_URRB + 4) |
65 | 65 | ||
66 | #define tx_enabled(port) ((port)->unused[0]) | 66 | static inline int tx_enabled(struct uart_port *port) |
67 | #define rx_enabled(port) ((port)->unused[1]) | 67 | { |
68 | return port->unused[0] & 1; | ||
69 | } | ||
70 | |||
71 | static inline int rx_enabled(struct uart_port *port) | ||
72 | { | ||
73 | return port->unused[0] & 2; | ||
74 | } | ||
75 | |||
76 | static inline int ms_enabled(struct uart_port *port) | ||
77 | { | ||
78 | return port->unused[0] & 4; | ||
79 | } | ||
80 | |||
81 | static inline void ms_enable(struct uart_port *port, int enabled) | ||
82 | { | ||
83 | if(enabled) | ||
84 | port->unused[0] |= 4; | ||
85 | else | ||
86 | port->unused[0] &= ~4; | ||
87 | } | ||
88 | |||
89 | static inline void rx_enable(struct uart_port *port, int enabled) | ||
90 | { | ||
91 | if(enabled) | ||
92 | port->unused[0] |= 2; | ||
93 | else | ||
94 | port->unused[0] &= ~2; | ||
95 | } | ||
96 | |||
97 | static inline void tx_enable(struct uart_port *port, int enabled) | ||
98 | { | ||
99 | if(enabled) | ||
100 | port->unused[0] |= 1; | ||
101 | else | ||
102 | port->unused[0] &= ~1; | ||
103 | } | ||
68 | 104 | ||
69 | 105 | ||
70 | #ifdef SUPPORT_SYSRQ | 106 | #ifdef SUPPORT_SYSRQ |
@@ -75,7 +111,7 @@ static void ks8695uart_stop_tx(struct uart_port *port) | |||
75 | { | 111 | { |
76 | if (tx_enabled(port)) { | 112 | if (tx_enabled(port)) { |
77 | disable_irq(KS8695_IRQ_UART_TX); | 113 | disable_irq(KS8695_IRQ_UART_TX); |
78 | tx_enabled(port) = 0; | 114 | tx_enable(port, 0); |
79 | } | 115 | } |
80 | } | 116 | } |
81 | 117 | ||
@@ -83,7 +119,7 @@ static void ks8695uart_start_tx(struct uart_port *port) | |||
83 | { | 119 | { |
84 | if (!tx_enabled(port)) { | 120 | if (!tx_enabled(port)) { |
85 | enable_irq(KS8695_IRQ_UART_TX); | 121 | enable_irq(KS8695_IRQ_UART_TX); |
86 | tx_enabled(port) = 1; | 122 | tx_enable(port, 1); |
87 | } | 123 | } |
88 | } | 124 | } |
89 | 125 | ||
@@ -91,18 +127,24 @@ static void ks8695uart_stop_rx(struct uart_port *port) | |||
91 | { | 127 | { |
92 | if (rx_enabled(port)) { | 128 | if (rx_enabled(port)) { |
93 | disable_irq(KS8695_IRQ_UART_RX); | 129 | disable_irq(KS8695_IRQ_UART_RX); |
94 | rx_enabled(port) = 0; | 130 | rx_enable(port, 0); |
95 | } | 131 | } |
96 | } | 132 | } |
97 | 133 | ||
98 | static void ks8695uart_enable_ms(struct uart_port *port) | 134 | static void ks8695uart_enable_ms(struct uart_port *port) |
99 | { | 135 | { |
100 | enable_irq(KS8695_IRQ_UART_MODEM_STATUS); | 136 | if (!ms_enabled(port)) { |
137 | enable_irq(KS8695_IRQ_UART_MODEM_STATUS); | ||
138 | ms_enable(port,1); | ||
139 | } | ||
101 | } | 140 | } |
102 | 141 | ||
103 | static void ks8695uart_disable_ms(struct uart_port *port) | 142 | static void ks8695uart_disable_ms(struct uart_port *port) |
104 | { | 143 | { |
105 | disable_irq(KS8695_IRQ_UART_MODEM_STATUS); | 144 | if (ms_enabled(port)) { |
145 | disable_irq(KS8695_IRQ_UART_MODEM_STATUS); | ||
146 | ms_enable(port,0); | ||
147 | } | ||
106 | } | 148 | } |
107 | 149 | ||
108 | static irqreturn_t ks8695uart_rx_chars(int irq, void *dev_id) | 150 | static irqreturn_t ks8695uart_rx_chars(int irq, void *dev_id) |
@@ -285,8 +327,9 @@ static int ks8695uart_startup(struct uart_port *port) | |||
285 | int retval; | 327 | int retval; |
286 | 328 | ||
287 | set_irq_flags(KS8695_IRQ_UART_TX, IRQF_VALID | IRQF_NOAUTOEN); | 329 | set_irq_flags(KS8695_IRQ_UART_TX, IRQF_VALID | IRQF_NOAUTOEN); |
288 | tx_enabled(port) = 0; | 330 | tx_enable(port, 0); |
289 | rx_enabled(port) = 1; | 331 | rx_enable(port, 1); |
332 | ms_enable(port, 1); | ||
290 | 333 | ||
291 | /* | 334 | /* |
292 | * Allocate the IRQ | 335 | * Allocate the IRQ |
diff --git a/drivers/serial/sh-sci.h b/drivers/serial/sh-sci.h index cd728df6a01a..8a0749e34ca3 100644 --- a/drivers/serial/sh-sci.h +++ b/drivers/serial/sh-sci.h | |||
@@ -451,19 +451,21 @@ SCIx_FNS(SCxSR, 0x08, 8, 0x10, 8, 0x08, 16, 0x10, 16, 0x04, 8) | |||
451 | SCIx_FNS(SCxRDR, 0x0a, 8, 0x14, 8, 0x0A, 8, 0x14, 8, 0x05, 8) | 451 | SCIx_FNS(SCxRDR, 0x0a, 8, 0x14, 8, 0x0A, 8, 0x14, 8, 0x05, 8) |
452 | SCIF_FNS(SCFCR, 0x0c, 8, 0x18, 16) | 452 | SCIF_FNS(SCFCR, 0x0c, 8, 0x18, 16) |
453 | #if defined(CONFIG_CPU_SUBTYPE_SH7760) || \ | 453 | #if defined(CONFIG_CPU_SUBTYPE_SH7760) || \ |
454 | defined(CONFIG_CPU_SUBTYPE_SH7763) || \ | ||
455 | defined(CONFIG_CPU_SUBTYPE_SH7780) || \ | 454 | defined(CONFIG_CPU_SUBTYPE_SH7780) || \ |
456 | defined(CONFIG_CPU_SUBTYPE_SH7785) | 455 | defined(CONFIG_CPU_SUBTYPE_SH7785) |
456 | SCIF_FNS(SCFDR, 0x0e, 16, 0x1C, 16) | ||
457 | SCIF_FNS(SCTFDR, 0x0e, 16, 0x1C, 16) | 457 | SCIF_FNS(SCTFDR, 0x0e, 16, 0x1C, 16) |
458 | SCIF_FNS(SCRFDR, 0x0e, 16, 0x20, 16) | 458 | SCIF_FNS(SCRFDR, 0x0e, 16, 0x20, 16) |
459 | SCIF_FNS(SCSPTR, 0, 0, 0x24, 16) | 459 | SCIF_FNS(SCSPTR, 0, 0, 0x24, 16) |
460 | SCIF_FNS(SCLSR, 0, 0, 0x28, 16) | 460 | SCIF_FNS(SCLSR, 0, 0, 0x28, 16) |
461 | #if defined(CONFIG_CPU_SUBTYPE_SH7763) | 461 | #elif defined(CONFIG_CPU_SUBTYPE_SH7763) |
462 | /* SH7763 SCIF2 */ | ||
463 | SCIF_FNS(SCFDR, 0, 0, 0x1C, 16) | 462 | SCIF_FNS(SCFDR, 0, 0, 0x1C, 16) |
464 | SCIF_FNS(SCSPTR2, 0, 0, 0x20, 16) | 463 | SCIF_FNS(SCSPTR2, 0, 0, 0x20, 16) |
465 | SCIF_FNS(SCLSR2, 0, 0, 0x24, 16) | 464 | SCIF_FNS(SCLSR2, 0, 0, 0x24, 16) |
466 | #endif /* CONFIG_CPU_SUBTYPE_SH7763 */ | 465 | SCIF_FNS(SCTFDR, 0x0e, 16, 0x1C, 16) |
466 | SCIF_FNS(SCRFDR, 0x0e, 16, 0x20, 16) | ||
467 | SCIF_FNS(SCSPTR, 0, 0, 0x24, 16) | ||
468 | SCIF_FNS(SCLSR, 0, 0, 0x28, 16) | ||
467 | #else | 469 | #else |
468 | SCIF_FNS(SCFDR, 0x0e, 16, 0x1C, 16) | 470 | SCIF_FNS(SCFDR, 0x0e, 16, 0x1C, 16) |
469 | #if defined(CONFIG_CPU_SUBTYPE_SH7722) | 471 | #if defined(CONFIG_CPU_SUBTYPE_SH7722) |
diff --git a/drivers/serial/sunhv.c b/drivers/serial/sunhv.c index aeeec5588afd..a94a2ab4b571 100644 --- a/drivers/serial/sunhv.c +++ b/drivers/serial/sunhv.c | |||
@@ -17,11 +17,11 @@ | |||
17 | #include <linux/slab.h> | 17 | #include <linux/slab.h> |
18 | #include <linux/delay.h> | 18 | #include <linux/delay.h> |
19 | #include <linux/init.h> | 19 | #include <linux/init.h> |
20 | #include <linux/of_device.h> | ||
20 | 21 | ||
21 | #include <asm/hypervisor.h> | 22 | #include <asm/hypervisor.h> |
22 | #include <asm/spitfire.h> | 23 | #include <asm/spitfire.h> |
23 | #include <asm/prom.h> | 24 | #include <asm/prom.h> |
24 | #include <asm/of_device.h> | ||
25 | #include <asm/irq.h> | 25 | #include <asm/irq.h> |
26 | 26 | ||
27 | #if defined(CONFIG_MAGIC_SYSRQ) | 27 | #if defined(CONFIG_MAGIC_SYSRQ) |
@@ -616,7 +616,7 @@ static int __devexit hv_remove(struct of_device *dev) | |||
616 | return 0; | 616 | return 0; |
617 | } | 617 | } |
618 | 618 | ||
619 | static struct of_device_id hv_match[] = { | 619 | static const struct of_device_id hv_match[] = { |
620 | { | 620 | { |
621 | .name = "console", | 621 | .name = "console", |
622 | .compatible = "qcn", | 622 | .compatible = "qcn", |
diff --git a/drivers/serial/sunsab.c b/drivers/serial/sunsab.c index 15ee497e1c78..0355efe115d9 100644 --- a/drivers/serial/sunsab.c +++ b/drivers/serial/sunsab.c | |||
@@ -32,11 +32,11 @@ | |||
32 | #include <linux/slab.h> | 32 | #include <linux/slab.h> |
33 | #include <linux/delay.h> | 33 | #include <linux/delay.h> |
34 | #include <linux/init.h> | 34 | #include <linux/init.h> |
35 | #include <linux/of_device.h> | ||
35 | 36 | ||
36 | #include <asm/io.h> | 37 | #include <asm/io.h> |
37 | #include <asm/irq.h> | 38 | #include <asm/irq.h> |
38 | #include <asm/prom.h> | 39 | #include <asm/prom.h> |
39 | #include <asm/of_device.h> | ||
40 | 40 | ||
41 | #if defined(CONFIG_SERIAL_SUNSAB_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) | 41 | #if defined(CONFIG_SERIAL_SUNSAB_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) |
42 | #define SUPPORT_SYSRQ | 42 | #define SUPPORT_SYSRQ |
@@ -1078,7 +1078,7 @@ static int __devexit sab_remove(struct of_device *op) | |||
1078 | return 0; | 1078 | return 0; |
1079 | } | 1079 | } |
1080 | 1080 | ||
1081 | static struct of_device_id sab_match[] = { | 1081 | static const struct of_device_id sab_match[] = { |
1082 | { | 1082 | { |
1083 | .name = "se", | 1083 | .name = "se", |
1084 | }, | 1084 | }, |
diff --git a/drivers/serial/sunsu.c b/drivers/serial/sunsu.c index e24e68235088..a4dc79b1d7ab 100644 --- a/drivers/serial/sunsu.c +++ b/drivers/serial/sunsu.c | |||
@@ -35,11 +35,11 @@ | |||
35 | #include <linux/serial_reg.h> | 35 | #include <linux/serial_reg.h> |
36 | #include <linux/init.h> | 36 | #include <linux/init.h> |
37 | #include <linux/delay.h> | 37 | #include <linux/delay.h> |
38 | #include <linux/of_device.h> | ||
38 | 39 | ||
39 | #include <asm/io.h> | 40 | #include <asm/io.h> |
40 | #include <asm/irq.h> | 41 | #include <asm/irq.h> |
41 | #include <asm/prom.h> | 42 | #include <asm/prom.h> |
42 | #include <asm/of_device.h> | ||
43 | 43 | ||
44 | #if defined(CONFIG_SERIAL_SUNSU_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) | 44 | #if defined(CONFIG_SERIAL_SUNSU_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) |
45 | #define SUPPORT_SYSRQ | 45 | #define SUPPORT_SYSRQ |
@@ -1506,7 +1506,7 @@ static int __devexit su_remove(struct of_device *op) | |||
1506 | return 0; | 1506 | return 0; |
1507 | } | 1507 | } |
1508 | 1508 | ||
1509 | static struct of_device_id su_match[] = { | 1509 | static const struct of_device_id su_match[] = { |
1510 | { | 1510 | { |
1511 | .name = "su", | 1511 | .name = "su", |
1512 | }, | 1512 | }, |
diff --git a/drivers/serial/sunzilog.c b/drivers/serial/sunzilog.c index 0f3d69b86d67..45a299f35617 100644 --- a/drivers/serial/sunzilog.c +++ b/drivers/serial/sunzilog.c | |||
@@ -32,11 +32,11 @@ | |||
32 | #include <linux/serio.h> | 32 | #include <linux/serio.h> |
33 | #endif | 33 | #endif |
34 | #include <linux/init.h> | 34 | #include <linux/init.h> |
35 | #include <linux/of_device.h> | ||
35 | 36 | ||
36 | #include <asm/io.h> | 37 | #include <asm/io.h> |
37 | #include <asm/irq.h> | 38 | #include <asm/irq.h> |
38 | #include <asm/prom.h> | 39 | #include <asm/prom.h> |
39 | #include <asm/of_device.h> | ||
40 | 40 | ||
41 | #if defined(CONFIG_SERIAL_SUNZILOG_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) | 41 | #if defined(CONFIG_SERIAL_SUNZILOG_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) |
42 | #define SUPPORT_SYSRQ | 42 | #define SUPPORT_SYSRQ |
@@ -1480,7 +1480,7 @@ static int __devexit zs_remove(struct of_device *op) | |||
1480 | return 0; | 1480 | return 0; |
1481 | } | 1481 | } |
1482 | 1482 | ||
1483 | static struct of_device_id zs_match[] = { | 1483 | static const struct of_device_id zs_match[] = { |
1484 | { | 1484 | { |
1485 | .name = "zs", | 1485 | .name = "zs", |
1486 | }, | 1486 | }, |
diff --git a/drivers/serial/v850e_uart.c b/drivers/serial/v850e_uart.c deleted file mode 100644 index 5acf061b6cd2..000000000000 --- a/drivers/serial/v850e_uart.c +++ /dev/null | |||
@@ -1,548 +0,0 @@ | |||
1 | /* | ||
2 | * drivers/serial/v850e_uart.c -- Serial I/O using V850E on-chip UART or UARTB | ||
3 | * | ||
4 | * Copyright (C) 2001,02,03 NEC Electronics Corporation | ||
5 | * Copyright (C) 2001,02,03 Miles Bader <miles@gnu.org> | ||
6 | * | ||
7 | * This file is subject to the terms and conditions of the GNU General | ||
8 | * Public License. See the file COPYING in the main directory of this | ||
9 | * archive for more details. | ||
10 | * | ||
11 | * Written by Miles Bader <miles@gnu.org> | ||
12 | */ | ||
13 | |||
14 | /* This driver supports both the original V850E UART interface (called | ||
15 | merely `UART' in the docs) and the newer `UARTB' interface, which is | ||
16 | roughly a superset of the first one. The selection is made at | ||
17 | configure time -- if CONFIG_V850E_UARTB is defined, then UARTB is | ||
18 | presumed, otherwise the old UART -- as these are on-CPU UARTS, a system | ||
19 | can never have both. | ||
20 | |||
21 | The UARTB interface also has a 16-entry FIFO mode, which is not | ||
22 | yet supported by this driver. */ | ||
23 | |||
24 | #include <linux/kernel.h> | ||
25 | #include <linux/init.h> | ||
26 | #include <linux/module.h> | ||
27 | #include <linux/console.h> | ||
28 | #include <linux/tty.h> | ||
29 | #include <linux/tty_flip.h> | ||
30 | #include <linux/serial.h> | ||
31 | #include <linux/serial_core.h> | ||
32 | |||
33 | #include <asm/v850e_uart.h> | ||
34 | |||
35 | /* Initial UART state. This may be overridden by machine-dependent headers. */ | ||
36 | #ifndef V850E_UART_INIT_BAUD | ||
37 | #define V850E_UART_INIT_BAUD 115200 | ||
38 | #endif | ||
39 | #ifndef V850E_UART_INIT_CFLAGS | ||
40 | #define V850E_UART_INIT_CFLAGS (B115200 | CS8 | CREAD) | ||
41 | #endif | ||
42 | |||
43 | /* A string used for prefixing printed descriptions; since the same UART | ||
44 | macro is actually used on other chips than the V850E. This must be a | ||
45 | constant string. */ | ||
46 | #ifndef V850E_UART_CHIP_NAME | ||
47 | #define V850E_UART_CHIP_NAME "V850E" | ||
48 | #endif | ||
49 | |||
50 | #define V850E_UART_MINOR_BASE 64 /* First tty minor number */ | ||
51 | |||
52 | |||
53 | /* Low-level UART functions. */ | ||
54 | |||
55 | /* Configure and turn on uart channel CHAN, using the termios `control | ||
56 | modes' bits in CFLAGS, and a baud-rate of BAUD. */ | ||
57 | void v850e_uart_configure (unsigned chan, unsigned cflags, unsigned baud) | ||
58 | { | ||
59 | int flags; | ||
60 | v850e_uart_speed_t old_speed; | ||
61 | v850e_uart_config_t old_config; | ||
62 | v850e_uart_speed_t new_speed = v850e_uart_calc_speed (baud); | ||
63 | v850e_uart_config_t new_config = v850e_uart_calc_config (cflags); | ||
64 | |||
65 | /* Disable interrupts while we're twiddling the hardware. */ | ||
66 | local_irq_save (flags); | ||
67 | |||
68 | #ifdef V850E_UART_PRE_CONFIGURE | ||
69 | V850E_UART_PRE_CONFIGURE (chan, cflags, baud); | ||
70 | #endif | ||
71 | |||
72 | old_config = V850E_UART_CONFIG (chan); | ||
73 | old_speed = v850e_uart_speed (chan); | ||
74 | |||
75 | if (! v850e_uart_speed_eq (old_speed, new_speed)) { | ||
76 | /* The baud rate has changed. First, disable the UART. */ | ||
77 | V850E_UART_CONFIG (chan) = V850E_UART_CONFIG_FINI; | ||
78 | old_config = 0; /* Force the uart to be re-initialized. */ | ||
79 | |||
80 | /* Reprogram the baud-rate generator. */ | ||
81 | v850e_uart_set_speed (chan, new_speed); | ||
82 | } | ||
83 | |||
84 | if (! (old_config & V850E_UART_CONFIG_ENABLED)) { | ||
85 | /* If we are using the uart for the first time, start by | ||
86 | enabling it, which must be done before turning on any | ||
87 | other bits. */ | ||
88 | V850E_UART_CONFIG (chan) = V850E_UART_CONFIG_INIT; | ||
89 | /* See the initial state. */ | ||
90 | old_config = V850E_UART_CONFIG (chan); | ||
91 | } | ||
92 | |||
93 | if (new_config != old_config) { | ||
94 | /* Which of the TXE/RXE bits we'll temporarily turn off | ||
95 | before changing other control bits. */ | ||
96 | unsigned temp_disable = 0; | ||
97 | /* Which of the TXE/RXE bits will be enabled. */ | ||
98 | unsigned enable = 0; | ||
99 | unsigned changed_bits = new_config ^ old_config; | ||
100 | |||
101 | /* Which of RX/TX will be enabled in the new configuration. */ | ||
102 | if (new_config & V850E_UART_CONFIG_RX_BITS) | ||
103 | enable |= (new_config & V850E_UART_CONFIG_RX_ENABLE); | ||
104 | if (new_config & V850E_UART_CONFIG_TX_BITS) | ||
105 | enable |= (new_config & V850E_UART_CONFIG_TX_ENABLE); | ||
106 | |||
107 | /* Figure out which of RX/TX needs to be disabled; note | ||
108 | that this will only happen if they're not already | ||
109 | disabled. */ | ||
110 | if (changed_bits & V850E_UART_CONFIG_RX_BITS) | ||
111 | temp_disable | ||
112 | |= (old_config & V850E_UART_CONFIG_RX_ENABLE); | ||
113 | if (changed_bits & V850E_UART_CONFIG_TX_BITS) | ||
114 | temp_disable | ||
115 | |= (old_config & V850E_UART_CONFIG_TX_ENABLE); | ||
116 | |||
117 | /* We have to turn off RX and/or TX mode before changing | ||
118 | any associated control bits. */ | ||
119 | if (temp_disable) | ||
120 | V850E_UART_CONFIG (chan) = old_config & ~temp_disable; | ||
121 | |||
122 | /* Write the new control bits, while RX/TX are disabled. */ | ||
123 | if (changed_bits & ~enable) | ||
124 | V850E_UART_CONFIG (chan) = new_config & ~enable; | ||
125 | |||
126 | v850e_uart_config_delay (new_config, new_speed); | ||
127 | |||
128 | /* Write the final version, with enable bits turned on. */ | ||
129 | V850E_UART_CONFIG (chan) = new_config; | ||
130 | } | ||
131 | |||
132 | local_irq_restore (flags); | ||
133 | } | ||
134 | |||
135 | |||
136 | /* Low-level console. */ | ||
137 | |||
138 | #ifdef CONFIG_V850E_UART_CONSOLE | ||
139 | |||
140 | static void v850e_uart_cons_write (struct console *co, | ||
141 | const char *s, unsigned count) | ||
142 | { | ||
143 | if (count > 0) { | ||
144 | unsigned chan = co->index; | ||
145 | unsigned irq = V850E_UART_TX_IRQ (chan); | ||
146 | int irq_was_enabled, irq_was_pending, flags; | ||
147 | |||
148 | /* We don't want to get `transmission completed' | ||
149 | interrupts, since we're busy-waiting, so we disable them | ||
150 | while sending (we don't disable interrupts entirely | ||
151 | because sending over a serial line is really slow). We | ||
152 | save the status of the tx interrupt and restore it when | ||
153 | we're done so that using printk doesn't interfere with | ||
154 | normal serial transmission (other than interleaving the | ||
155 | output, of course!). This should work correctly even if | ||
156 | this function is interrupted and the interrupt printks | ||
157 | something. */ | ||
158 | |||
159 | /* Disable interrupts while fiddling with tx interrupt. */ | ||
160 | local_irq_save (flags); | ||
161 | /* Get current tx interrupt status. */ | ||
162 | irq_was_enabled = v850e_intc_irq_enabled (irq); | ||
163 | irq_was_pending = v850e_intc_irq_pending (irq); | ||
164 | /* Disable tx interrupt if necessary. */ | ||
165 | if (irq_was_enabled) | ||
166 | v850e_intc_disable_irq (irq); | ||
167 | /* Turn interrupts back on. */ | ||
168 | local_irq_restore (flags); | ||
169 | |||
170 | /* Send characters. */ | ||
171 | while (count > 0) { | ||
172 | int ch = *s++; | ||
173 | |||
174 | if (ch == '\n') { | ||
175 | /* We don't have the benefit of a tty | ||
176 | driver, so translate NL into CR LF. */ | ||
177 | v850e_uart_wait_for_xmit_ok (chan); | ||
178 | v850e_uart_putc (chan, '\r'); | ||
179 | } | ||
180 | |||
181 | v850e_uart_wait_for_xmit_ok (chan); | ||
182 | v850e_uart_putc (chan, ch); | ||
183 | |||
184 | count--; | ||
185 | } | ||
186 | |||
187 | /* Restore saved tx interrupt status. */ | ||
188 | if (irq_was_enabled) { | ||
189 | /* Wait for the last character we sent to be | ||
190 | completely transmitted (as we'll get an | ||
191 | interrupt interrupt at that point). */ | ||
192 | v850e_uart_wait_for_xmit_done (chan); | ||
193 | /* Clear pending interrupts received due | ||
194 | to our transmission, unless there was already | ||
195 | one pending, in which case we want the | ||
196 | handler to be called. */ | ||
197 | if (! irq_was_pending) | ||
198 | v850e_intc_clear_pending_irq (irq); | ||
199 | /* ... and then turn back on handling. */ | ||
200 | v850e_intc_enable_irq (irq); | ||
201 | } | ||
202 | } | ||
203 | } | ||
204 | |||
205 | extern struct uart_driver v850e_uart_driver; | ||
206 | static struct console v850e_uart_cons = | ||
207 | { | ||
208 | .name = "ttyS", | ||
209 | .write = v850e_uart_cons_write, | ||
210 | .device = uart_console_device, | ||
211 | .flags = CON_PRINTBUFFER, | ||
212 | .cflag = V850E_UART_INIT_CFLAGS, | ||
213 | .index = -1, | ||
214 | .data = &v850e_uart_driver, | ||
215 | }; | ||
216 | |||
217 | void v850e_uart_cons_init (unsigned chan) | ||
218 | { | ||
219 | v850e_uart_configure (chan, V850E_UART_INIT_CFLAGS, | ||
220 | V850E_UART_INIT_BAUD); | ||
221 | v850e_uart_cons.index = chan; | ||
222 | register_console (&v850e_uart_cons); | ||
223 | printk ("Console: %s on-chip UART channel %d\n", | ||
224 | V850E_UART_CHIP_NAME, chan); | ||
225 | } | ||
226 | |||
227 | /* This is what the init code actually calls. */ | ||
228 | static int v850e_uart_console_init (void) | ||
229 | { | ||
230 | v850e_uart_cons_init (V850E_UART_CONSOLE_CHANNEL); | ||
231 | return 0; | ||
232 | } | ||
233 | console_initcall(v850e_uart_console_init); | ||
234 | |||
235 | #define V850E_UART_CONSOLE &v850e_uart_cons | ||
236 | |||
237 | #else /* !CONFIG_V850E_UART_CONSOLE */ | ||
238 | #define V850E_UART_CONSOLE 0 | ||
239 | #endif /* CONFIG_V850E_UART_CONSOLE */ | ||
240 | |||
241 | /* TX/RX interrupt handlers. */ | ||
242 | |||
243 | static void v850e_uart_stop_tx (struct uart_port *port); | ||
244 | |||
245 | void v850e_uart_tx (struct uart_port *port) | ||
246 | { | ||
247 | struct circ_buf *xmit = &port->info->xmit; | ||
248 | int stopped = uart_tx_stopped (port); | ||
249 | |||
250 | if (v850e_uart_xmit_ok (port->line)) { | ||
251 | int tx_ch; | ||
252 | |||
253 | if (port->x_char) { | ||
254 | tx_ch = port->x_char; | ||
255 | port->x_char = 0; | ||
256 | } else if (!uart_circ_empty (xmit) && !stopped) { | ||
257 | tx_ch = xmit->buf[xmit->tail]; | ||
258 | xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1); | ||
259 | } else | ||
260 | goto no_xmit; | ||
261 | |||
262 | v850e_uart_putc (port->line, tx_ch); | ||
263 | port->icount.tx++; | ||
264 | |||
265 | if (uart_circ_chars_pending (xmit) < WAKEUP_CHARS) | ||
266 | uart_write_wakeup (port); | ||
267 | } | ||
268 | |||
269 | no_xmit: | ||
270 | if (uart_circ_empty (xmit) || stopped) | ||
271 | v850e_uart_stop_tx (port, stopped); | ||
272 | } | ||
273 | |||
274 | static irqreturn_t v850e_uart_tx_irq(int irq, void *data) | ||
275 | { | ||
276 | struct uart_port *port = data; | ||
277 | v850e_uart_tx (port); | ||
278 | return IRQ_HANDLED; | ||
279 | } | ||
280 | |||
281 | static irqreturn_t v850e_uart_rx_irq(int irq, void *data) | ||
282 | { | ||
283 | struct uart_port *port = data; | ||
284 | unsigned ch_stat = TTY_NORMAL; | ||
285 | unsigned ch = v850e_uart_getc (port->line); | ||
286 | unsigned err = v850e_uart_err (port->line); | ||
287 | |||
288 | if (err) { | ||
289 | if (err & V850E_UART_ERR_OVERRUN) { | ||
290 | ch_stat = TTY_OVERRUN; | ||
291 | port->icount.overrun++; | ||
292 | } else if (err & V850E_UART_ERR_FRAME) { | ||
293 | ch_stat = TTY_FRAME; | ||
294 | port->icount.frame++; | ||
295 | } else if (err & V850E_UART_ERR_PARITY) { | ||
296 | ch_stat = TTY_PARITY; | ||
297 | port->icount.parity++; | ||
298 | } | ||
299 | } | ||
300 | |||
301 | port->icount.rx++; | ||
302 | |||
303 | tty_insert_flip_char (port->info->port.tty, ch, ch_stat); | ||
304 | tty_schedule_flip (port->info->port.tty); | ||
305 | |||
306 | return IRQ_HANDLED; | ||
307 | } | ||
308 | |||
309 | |||
310 | /* Control functions for the serial framework. */ | ||
311 | |||
312 | static void v850e_uart_nop (struct uart_port *port) { } | ||
313 | static int v850e_uart_success (struct uart_port *port) { return 0; } | ||
314 | |||
315 | static unsigned v850e_uart_tx_empty (struct uart_port *port) | ||
316 | { | ||
317 | return TIOCSER_TEMT; /* Can't detect. */ | ||
318 | } | ||
319 | |||
320 | static void v850e_uart_set_mctrl (struct uart_port *port, unsigned mctrl) | ||
321 | { | ||
322 | #ifdef V850E_UART_SET_RTS | ||
323 | V850E_UART_SET_RTS (port->line, (mctrl & TIOCM_RTS)); | ||
324 | #endif | ||
325 | } | ||
326 | |||
327 | static unsigned v850e_uart_get_mctrl (struct uart_port *port) | ||
328 | { | ||
329 | /* We don't support DCD or DSR, so consider them permanently active. */ | ||
330 | int mctrl = TIOCM_CAR | TIOCM_DSR; | ||
331 | |||
332 | /* We may support CTS. */ | ||
333 | #ifdef V850E_UART_CTS | ||
334 | mctrl |= V850E_UART_CTS(port->line) ? TIOCM_CTS : 0; | ||
335 | #else | ||
336 | mctrl |= TIOCM_CTS; | ||
337 | #endif | ||
338 | |||
339 | return mctrl; | ||
340 | } | ||
341 | |||
342 | static void v850e_uart_start_tx (struct uart_port *port) | ||
343 | { | ||
344 | v850e_intc_disable_irq (V850E_UART_TX_IRQ (port->line)); | ||
345 | v850e_uart_tx (port); | ||
346 | v850e_intc_enable_irq (V850E_UART_TX_IRQ (port->line)); | ||
347 | } | ||
348 | |||
349 | static void v850e_uart_stop_tx (struct uart_port *port) | ||
350 | { | ||
351 | v850e_intc_disable_irq (V850E_UART_TX_IRQ (port->line)); | ||
352 | } | ||
353 | |||
354 | static void v850e_uart_start_rx (struct uart_port *port) | ||
355 | { | ||
356 | v850e_intc_enable_irq (V850E_UART_RX_IRQ (port->line)); | ||
357 | } | ||
358 | |||
359 | static void v850e_uart_stop_rx (struct uart_port *port) | ||
360 | { | ||
361 | v850e_intc_disable_irq (V850E_UART_RX_IRQ (port->line)); | ||
362 | } | ||
363 | |||
364 | static void v850e_uart_break_ctl (struct uart_port *port, int break_ctl) | ||
365 | { | ||
366 | /* Umm, do this later. */ | ||
367 | } | ||
368 | |||
369 | static int v850e_uart_startup (struct uart_port *port) | ||
370 | { | ||
371 | int err; | ||
372 | |||
373 | /* Alloc RX irq. */ | ||
374 | err = request_irq (V850E_UART_RX_IRQ (port->line), v850e_uart_rx_irq, | ||
375 | IRQF_DISABLED, "v850e_uart", port); | ||
376 | if (err) | ||
377 | return err; | ||
378 | |||
379 | /* Alloc TX irq. */ | ||
380 | err = request_irq (V850E_UART_TX_IRQ (port->line), v850e_uart_tx_irq, | ||
381 | IRQF_DISABLED, "v850e_uart", port); | ||
382 | if (err) { | ||
383 | free_irq (V850E_UART_RX_IRQ (port->line), port); | ||
384 | return err; | ||
385 | } | ||
386 | |||
387 | v850e_uart_start_rx (port); | ||
388 | |||
389 | return 0; | ||
390 | } | ||
391 | |||
392 | static void v850e_uart_shutdown (struct uart_port *port) | ||
393 | { | ||
394 | /* Disable port interrupts. */ | ||
395 | free_irq (V850E_UART_TX_IRQ (port->line), port); | ||
396 | free_irq (V850E_UART_RX_IRQ (port->line), port); | ||
397 | |||
398 | /* Turn off xmit/recv enable bits. */ | ||
399 | V850E_UART_CONFIG (port->line) | ||
400 | &= ~(V850E_UART_CONFIG_TX_ENABLE | ||
401 | | V850E_UART_CONFIG_RX_ENABLE); | ||
402 | /* Then reset the channel. */ | ||
403 | V850E_UART_CONFIG (port->line) = 0; | ||
404 | } | ||
405 | |||
406 | static void | ||
407 | v850e_uart_set_termios (struct uart_port *port, struct ktermios *termios, | ||
408 | struct ktermios *old) | ||
409 | { | ||
410 | unsigned cflags = termios->c_cflag; | ||
411 | |||
412 | /* Restrict flags to legal values. */ | ||
413 | if ((cflags & CSIZE) != CS7 && (cflags & CSIZE) != CS8) | ||
414 | /* The new value of CSIZE is invalid, use the old value. */ | ||
415 | cflags = (cflags & ~CSIZE) | ||
416 | | (old ? (old->c_cflag & CSIZE) : CS8); | ||
417 | |||
418 | termios->c_cflag = cflags; | ||
419 | |||
420 | v850e_uart_configure (port->line, cflags, | ||
421 | uart_get_baud_rate (port, termios, old, | ||
422 | v850e_uart_min_baud(), | ||
423 | v850e_uart_max_baud())); | ||
424 | } | ||
425 | |||
426 | static const char *v850e_uart_type (struct uart_port *port) | ||
427 | { | ||
428 | return port->type == PORT_V850E_UART ? "v850e_uart" : 0; | ||
429 | } | ||
430 | |||
431 | static void v850e_uart_config_port (struct uart_port *port, int flags) | ||
432 | { | ||
433 | if (flags & UART_CONFIG_TYPE) | ||
434 | port->type = PORT_V850E_UART; | ||
435 | } | ||
436 | |||
437 | static int | ||
438 | v850e_uart_verify_port (struct uart_port *port, struct serial_struct *ser) | ||
439 | { | ||
440 | if (ser->type != PORT_UNKNOWN && ser->type != PORT_V850E_UART) | ||
441 | return -EINVAL; | ||
442 | if (ser->irq != V850E_UART_TX_IRQ (port->line)) | ||
443 | return -EINVAL; | ||
444 | return 0; | ||
445 | } | ||
446 | |||
447 | static struct uart_ops v850e_uart_ops = { | ||
448 | .tx_empty = v850e_uart_tx_empty, | ||
449 | .get_mctrl = v850e_uart_get_mctrl, | ||
450 | .set_mctrl = v850e_uart_set_mctrl, | ||
451 | .start_tx = v850e_uart_start_tx, | ||
452 | .stop_tx = v850e_uart_stop_tx, | ||
453 | .stop_rx = v850e_uart_stop_rx, | ||
454 | .enable_ms = v850e_uart_nop, | ||
455 | .break_ctl = v850e_uart_break_ctl, | ||
456 | .startup = v850e_uart_startup, | ||
457 | .shutdown = v850e_uart_shutdown, | ||
458 | .set_termios = v850e_uart_set_termios, | ||
459 | .type = v850e_uart_type, | ||
460 | .release_port = v850e_uart_nop, | ||
461 | .request_port = v850e_uart_success, | ||
462 | .config_port = v850e_uart_config_port, | ||
463 | .verify_port = v850e_uart_verify_port, | ||
464 | }; | ||
465 | |||
466 | /* Initialization and cleanup. */ | ||
467 | |||
468 | static struct uart_driver v850e_uart_driver = { | ||
469 | .owner = THIS_MODULE, | ||
470 | .driver_name = "v850e_uart", | ||
471 | .dev_name = "ttyS", | ||
472 | .major = TTY_MAJOR, | ||
473 | .minor = V850E_UART_MINOR_BASE, | ||
474 | .nr = V850E_UART_NUM_CHANNELS, | ||
475 | .cons = V850E_UART_CONSOLE, | ||
476 | }; | ||
477 | |||
478 | |||
479 | static struct uart_port v850e_uart_ports[V850E_UART_NUM_CHANNELS]; | ||
480 | |||
481 | static int __init v850e_uart_init (void) | ||
482 | { | ||
483 | int rval; | ||
484 | |||
485 | printk (KERN_INFO "%s on-chip UART\n", V850E_UART_CHIP_NAME); | ||
486 | |||
487 | rval = uart_register_driver (&v850e_uart_driver); | ||
488 | if (rval == 0) { | ||
489 | unsigned chan; | ||
490 | |||
491 | for (chan = 0; chan < V850E_UART_NUM_CHANNELS; chan++) { | ||
492 | struct uart_port *port = &v850e_uart_ports[chan]; | ||
493 | |||
494 | memset (port, 0, sizeof *port); | ||
495 | |||
496 | port->ops = &v850e_uart_ops; | ||
497 | port->line = chan; | ||
498 | port->iotype = UPIO_MEM; | ||
499 | port->flags = UPF_BOOT_AUTOCONF; | ||
500 | |||
501 | /* We actually use multiple IRQs, but the serial | ||
502 | framework seems to mainly use this for | ||
503 | informational purposes anyway. Here we use the TX | ||
504 | irq. */ | ||
505 | port->irq = V850E_UART_TX_IRQ (chan); | ||
506 | |||
507 | /* The serial framework doesn't really use these | ||
508 | membase/mapbase fields for anything useful, but | ||
509 | it requires that they be something non-zero to | ||
510 | consider the port `valid', and also uses them | ||
511 | for informational purposes. */ | ||
512 | port->membase = (void *)V850E_UART_BASE_ADDR (chan); | ||
513 | port->mapbase = V850E_UART_BASE_ADDR (chan); | ||
514 | |||
515 | /* The framework insists on knowing the uart's master | ||
516 | clock freq, though it doesn't seem to do anything | ||
517 | useful for us with it. We must make it at least | ||
518 | higher than (the maximum baud rate * 16), otherwise | ||
519 | the framework will puke during its internal | ||
520 | calculations, and force the baud rate to be 9600. | ||
521 | To be accurate though, just repeat the calculation | ||
522 | we use when actually setting the speed. */ | ||
523 | port->uartclk = v850e_uart_max_clock() * 16; | ||
524 | |||
525 | uart_add_one_port (&v850e_uart_driver, port); | ||
526 | } | ||
527 | } | ||
528 | |||
529 | return rval; | ||
530 | } | ||
531 | |||
532 | static void __exit v850e_uart_exit (void) | ||
533 | { | ||
534 | unsigned chan; | ||
535 | |||
536 | for (chan = 0; chan < V850E_UART_NUM_CHANNELS; chan++) | ||
537 | uart_remove_one_port (&v850e_uart_driver, | ||
538 | &v850e_uart_ports[chan]); | ||
539 | |||
540 | uart_unregister_driver (&v850e_uart_driver); | ||
541 | } | ||
542 | |||
543 | module_init (v850e_uart_init); | ||
544 | module_exit (v850e_uart_exit); | ||
545 | |||
546 | MODULE_AUTHOR ("Miles Bader"); | ||
547 | MODULE_DESCRIPTION ("NEC " V850E_UART_CHIP_NAME " on-chip UART"); | ||
548 | MODULE_LICENSE ("GPL"); | ||