···11+/*22+ * Copyright 2006-2007 Freescale Semiconductor, Inc. All Rights Reserved.33+ * Copyright 2008 Sascha Hauer, kernel@pengutronix.de44+ *55+ * This program is free software; you can redistribute it and/or66+ * modify it under the terms of the GNU General Public License77+ * as published by the Free Software Foundation; either version 288+ * of the License, or (at your option) any later version.99+ * This program is distributed in the hope that it will be useful,1010+ * but WITHOUT ANY WARRANTY; without even the implied warranty of1111+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1212+ * GNU General Public License for more details.1313+ *1414+ * You should have received a copy of the GNU General Public License1515+ * along with this program; if not, write to the Free Software1616+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,1717+ * Boston, MA 02110-1301, USA.1818+ */1919+2020+#include <linux/module.h>2121+#include <linux/platform_device.h>2222+#include <linux/serial.h>2323+#include <asm/hardware.h>2424+#include <asm/arch/imx-uart.h>2525+2626+static struct resource uart0[] = {2727+ {2828+ .start = UART1_BASE_ADDR,2929+ .end = UART1_BASE_ADDR + 0x0B5,3030+ .flags = IORESOURCE_MEM,3131+ }, {3232+ .start = MXC_INT_UART1,3333+ .end = MXC_INT_UART1,3434+ .flags = IORESOURCE_IRQ,3535+ },3636+};3737+3838+static struct platform_device mxc_uart_device0 = {3939+ .name = "imx-uart",4040+ .id = 0,4141+ .resource = uart0,4242+ .num_resources = ARRAY_SIZE(uart0),4343+};4444+4545+static struct resource uart1[] = {4646+ {4747+ .start = UART2_BASE_ADDR,4848+ .end = UART2_BASE_ADDR + 0x0B5,4949+ .flags = IORESOURCE_MEM,5050+ }, {5151+ .start = MXC_INT_UART2,5252+ .end = MXC_INT_UART2,5353+ .flags = IORESOURCE_IRQ,5454+ },5555+};5656+5757+static struct platform_device mxc_uart_device1 = {5858+ .name = "imx-uart",5959+ .id = 1,6060+ .resource = uart1,6161+ .num_resources = ARRAY_SIZE(uart1),6262+};6363+6464+static struct resource uart2[] = {6565+ {6666+ .start = UART3_BASE_ADDR,6767+ .end = UART3_BASE_ADDR + 0x0B5,6868+ .flags = IORESOURCE_MEM,6969+ }, {7070+ .start = MXC_INT_UART3,7171+ .end = MXC_INT_UART3,7272+ .flags = IORESOURCE_IRQ,7373+ },7474+};7575+7676+static struct platform_device mxc_uart_device2 = {7777+ .name = "imx-uart",7878+ .id = 2,7979+ .resource = uart2,8080+ .num_resources = ARRAY_SIZE(uart2),8181+};8282+8383+static struct resource uart3[] = {8484+ {8585+ .start = UART4_BASE_ADDR,8686+ .end = UART4_BASE_ADDR + 0x0B5,8787+ .flags = IORESOURCE_MEM,8888+ }, {8989+ .start = MXC_INT_UART4,9090+ .end = MXC_INT_UART4,9191+ .flags = IORESOURCE_IRQ,9292+ },9393+};9494+9595+static struct platform_device mxc_uart_device3 = {9696+ .name = "imx-uart",9797+ .id = 3,9898+ .resource = uart3,9999+ .num_resources = ARRAY_SIZE(uart3),100100+};101101+102102+static struct resource uart4[] = {103103+ {104104+ .start = UART5_BASE_ADDR,105105+ .end = UART5_BASE_ADDR + 0x0B5,106106+ .flags = IORESOURCE_MEM,107107+ }, {108108+ .start = MXC_INT_UART5,109109+ .end = MXC_INT_UART5,110110+ .flags = IORESOURCE_IRQ,111111+ },112112+};113113+114114+static struct platform_device mxc_uart_device4 = {115115+ .name = "imx-uart",116116+ .id = 4,117117+ .resource = uart4,118118+ .num_resources = ARRAY_SIZE(uart4),119119+};120120+121121+/*122122+ * Register only those UARTs that physically exist123123+ */124124+int __init imx_init_uart(int uart_no, struct imxuart_platform_data *pdata)125125+{126126+ switch (uart_no) {127127+ case 0:128128+ mxc_uart_device0.dev.platform_data = pdata;129129+ platform_device_register(&mxc_uart_device0);130130+ break;131131+ case 1:132132+ mxc_uart_device1.dev.platform_data = pdata;133133+ platform_device_register(&mxc_uart_device1);134134+ break;135135+ case 2:136136+ mxc_uart_device2.dev.platform_data = pdata;137137+ platform_device_register(&mxc_uart_device2);138138+ break;139139+ case 3:140140+ mxc_uart_device3.dev.platform_data = pdata;141141+ platform_device_register(&mxc_uart_device3);142142+ break;143143+ case 4:144144+ mxc_uart_device4.dev.platform_data = pdata;145145+ platform_device_register(&mxc_uart_device4);146146+ break;147147+ default:148148+ return -ENODEV;149149+ }150150+151151+ return 0;152152+}153153+
+1-1
drivers/serial/Kconfig
···753753754754config SERIAL_IMX755755 bool "IMX serial port support"756756- depends on ARM && ARCH_IMX756756+ depends on ARM && (ARCH_IMX || ARCH_MXC)757757 select SERIAL_CORE758758 help759759 If you have a machine based on a Motorola IMX CPU you
+78-18
drivers/serial/imx.c
···6262#define UBIR 0xa4 /* BRM Incremental Register */6363#define UBMR 0xa8 /* BRM Modulator Register */6464#define UBRC 0xac /* Baud Rate Count Register */6565+#ifdef CONFIG_ARCH_MX36666+#define ONEMS 0xb0 /* One Millisecond register */6767+#define UTS 0xb4 /* UART Test Register */6868+#endif6969+#ifdef CONFIG_ARCH_IMX6570#define BIPR1 0xb0 /* Incremental Preset Register 1 */6671#define BIPR2 0xb4 /* Incremental Preset Register 2 */6772#define BIPR3 0xb8 /* Incremental Preset Register 3 */···7671#define BMPR3 0xc8 /* BRM Modulator Register 3 */7772#define BMPR4 0xcc /* BRM Modulator Register 4 */7873#define UTS 0xd0 /* UART Test Register */7474+#endif79758076/* UART Control Register Bit Fields.*/8177#define URXD_CHARRDY (1<<15)···9690#define UCR1_RTSDEN (1<<5) /* RTS delta interrupt enable */9791#define UCR1_SNDBRK (1<<4) /* Send break */9892#define UCR1_TDMAEN (1<<3) /* Transmitter ready DMA enable */9393+#ifdef CONFIG_ARCH_IMX9994#define UCR1_UARTCLKEN (1<<2) /* UART clock enabled */9595+#endif9696+#ifdef CONFIG_ARCH_MX39797+#define UCR1_UARTCLKEN (0) /* not present on mx2/mx3 */9898+#endif10099#define UCR1_DOZE (1<<1) /* Doze */101100#define UCR1_UARTEN (1<<0) /* UART enabled */102101#define UCR2_ESCI (1<<15) /* Escape seq interrupt enable */···175164#define UTS_SOFTRST (1<<0) /* Software reset */176165177166/* We've been assigned a range on the "Low-density serial ports" major */167167+#ifdef CONFIG_ARCH_IMX178168#define SERIAL_IMX_MAJOR 204179169#define MINOR_START 41170170+#define DEV_NAME "ttySMX"171171+#define MAX_INTERNAL_IRQ IMX_IRQS172172+#endif173173+174174+#ifdef CONFIG_ARCH_MX3175175+#define SERIAL_IMX_MAJOR 207176176+#define MINOR_START 16177177+#define DEV_NAME "ttymxc"178178+#define MAX_INTERNAL_IRQ MXC_MAX_INT_LINES179179+#endif180180181181/*182182 * This determines how often we check the modem status signals···431409 return IRQ_HANDLED;432410}433411412412+static irqreturn_t imx_int(int irq, void *dev_id)413413+{414414+ struct imx_port *sport = dev_id;415415+ unsigned int sts;416416+417417+ sts = readl(sport->port.membase + USR1);418418+419419+ if (sts & USR1_RRDY)420420+ imx_rxint(irq, dev_id);421421+422422+ if (sts & USR1_TRDY &&423423+ readl(sport->port.membase + UCR1) & UCR1_TXMPTYEN)424424+ imx_txint(irq, dev_id);425425+426426+ if (sts & USR1_RTSS)427427+ imx_rtsint(irq, dev_id);428428+429429+ return IRQ_HANDLED;430430+}431431+434432/*435433 * Return TIOCSER_TEMT when transmitter is not busy.436434 */···556514 writel(temp & ~UCR4_DREN, sport->port.membase + UCR4);557515558516 /*559559- * Allocate the IRQ517517+ * Allocate the IRQ(s) i.MX1 has three interrupts whereas later518518+ * chips only have one interrupt.560519 */561561- retval = request_irq(sport->rxirq, imx_rxint, 0,562562- DRIVER_NAME, sport);563563- if (retval) goto error_out1;520520+ if (sport->txirq > 0) {521521+ retval = request_irq(sport->rxirq, imx_rxint, 0,522522+ DRIVER_NAME, sport);523523+ if (retval)524524+ goto error_out1;564525565565- retval = request_irq(sport->txirq, imx_txint, 0,566566- DRIVER_NAME, sport);567567- if (retval) goto error_out2;526526+ retval = request_irq(sport->txirq, imx_txint, 0,527527+ DRIVER_NAME, sport);528528+ if (retval)529529+ goto error_out2;568530569569- retval = request_irq(sport->rtsirq, imx_rtsint,570570- (sport->rtsirq < IMX_IRQS) ? 0 :531531+ retval = request_irq(sport->rtsirq, imx_rtsint,532532+ (sport->rtsirq < MAX_INTERNAL_IRQ) ? 0 :571533 IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,572572- DRIVER_NAME, sport);573573- if (retval) goto error_out3;534534+ DRIVER_NAME, sport);535535+ if (retval)536536+ goto error_out3;537537+ } else {538538+ retval = request_irq(sport->port.irq, imx_int, 0,539539+ DRIVER_NAME, sport);540540+ if (retval) {541541+ free_irq(sport->port.irq, sport);542542+ goto error_out1;543543+ }544544+ }574545575546 /*576547 * Finally, clear and enable interrupts···608553 return 0;609554610555error_out3:611611- free_irq(sport->txirq, sport);556556+ if (sport->txirq)557557+ free_irq(sport->txirq, sport);612558error_out2:613613- free_irq(sport->rxirq, sport);559559+ if (sport->rxirq)560560+ free_irq(sport->rxirq, sport);614561error_out1:615562 return retval;616563}···630573 /*631574 * Free the interrupts632575 */633633- free_irq(sport->rtsirq, sport);634634- free_irq(sport->txirq, sport);635635- free_irq(sport->rxirq, sport);576576+ if (sport->txirq > 0) {577577+ free_irq(sport->rtsirq, sport);578578+ free_irq(sport->txirq, sport);579579+ free_irq(sport->rxirq, sport);580580+ } else581581+ free_irq(sport->port.irq, sport);636582637583 /*638584 * Disable all interrupts, port and break condition.···10339731034974static struct uart_driver imx_reg;1035975static struct console imx_console = {10361036- .name = "ttySMX",976976+ .name = DEV_NAME,1037977 .write = imx_console_write,1038978 .device = uart_console_device,1039979 .setup = imx_console_setup,···1050990static struct uart_driver imx_reg = {1051991 .owner = THIS_MODULE,1052992 .driver_name = DRIVER_NAME,10531053- .dev_name = "ttySMX",993993+ .dev_name = DEV_NAME,1054994 .major = SERIAL_IMX_MAJOR,1055995 .minor = MINOR_START,1056996 .nr = ARRAY_SIZE(imx_ports),
+32
include/asm-arm/arch-mxc/imx-uart.h
···11+/*22+ * Copyright (C) 2008 by Sascha Hauer <kernel@pengutronix.de>33+ *44+ * This program is free software; you can redistribute it and/or55+ * modify it under the terms of the GNU General Public License66+ * as published by the Free Software Foundation; either version 277+ * of the License, or (at your option) any later version.88+ * This program is distributed in the hope that it will be useful,99+ * but WITHOUT ANY WARRANTY; without even the implied warranty of1010+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1111+ * GNU General Public License for more details.1212+ *1313+ * You should have received a copy of the GNU General Public License1414+ * along with this program; if not, write to the Free Software1515+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,1616+ * MA 02110-1301, USA.1717+ */1818+1919+#ifndef ASMARM_ARCH_UART_H2020+#define ASMARM_ARCH_UART_H2121+2222+#define IMXUART_HAVE_RTSCTS (1<<0)2323+2424+struct imxuart_platform_data {2525+ int (*init)(struct platform_device *pdev);2626+ int (*exit)(struct platform_device *pdev);2727+ unsigned int flags;2828+};2929+3030+int __init imx_init_uart(int uart_no, struct imxuart_platform_data *pdata);3131+3232+#endif