Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[ARM] 3490/1: i.MX: move uart resources to board files

Patch from Sascha Hauer

This patch moves the i.MX uart resources and the gpio pin setup to the
board files. This allows the boards to decide how many internal uarts
are connected to the outside world and whether they use rts/cts or
not.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>

authored by

Sascha Hauer and committed by
Russell King
5b802344 b2556da5

+100 -76
-52
arch/arm/mach-imx/generic.c
··· 195 195 } 196 196 EXPORT_SYMBOL(imx_set_mmc_info); 197 197 198 - static struct resource imx_uart1_resources[] = { 199 - [0] = { 200 - .start = 0x00206000, 201 - .end = 0x002060FF, 202 - .flags = IORESOURCE_MEM, 203 - }, 204 - [1] = { 205 - .start = (UART1_MINT_RX), 206 - .end = (UART1_MINT_RX), 207 - .flags = IORESOURCE_IRQ, 208 - }, 209 - [2] = { 210 - .start = (UART1_MINT_TX), 211 - .end = (UART1_MINT_TX), 212 - .flags = IORESOURCE_IRQ, 213 - }, 214 - }; 215 - 216 - static struct platform_device imx_uart1_device = { 217 - .name = "imx-uart", 218 - .id = 0, 219 - .num_resources = ARRAY_SIZE(imx_uart1_resources), 220 - .resource = imx_uart1_resources, 221 - }; 222 - 223 - static struct resource imx_uart2_resources[] = { 224 - [0] = { 225 - .start = 0x00207000, 226 - .end = 0x002070FF, 227 - .flags = IORESOURCE_MEM, 228 - }, 229 - [1] = { 230 - .start = (UART2_MINT_RX), 231 - .end = (UART2_MINT_RX), 232 - .flags = IORESOURCE_IRQ, 233 - }, 234 - [2] = { 235 - .start = (UART2_MINT_TX), 236 - .end = (UART2_MINT_TX), 237 - .flags = IORESOURCE_IRQ, 238 - }, 239 - }; 240 - 241 - static struct platform_device imx_uart2_device = { 242 - .name = "imx-uart", 243 - .id = 1, 244 - .num_resources = ARRAY_SIZE(imx_uart2_resources), 245 - .resource = imx_uart2_resources, 246 - }; 247 - 248 198 static struct imxfb_mach_info imx_fb_info; 249 199 250 200 void __init set_imx_fb_info(struct imxfb_mach_info *hard_imx_fb_info) ··· 233 283 static struct platform_device *devices[] __initdata = { 234 284 &imx_mmc_device, 235 285 &imxfb_device, 236 - &imx_uart1_device, 237 - &imx_uart2_device, 238 286 }; 239 287 240 288 static struct map_desc imx_io_desc[] __initdata = {
+74
arch/arm/mach-imx/mx1ads.c
··· 26 26 27 27 #include <asm/mach/arch.h> 28 28 #include <asm/arch/mmc.h> 29 + #include <asm/arch/imx-uart.h> 29 30 #include <linux/interrupt.h> 30 31 #include "generic.h" 31 32 ··· 49 48 .resource = cs89x0_resources, 50 49 }; 51 50 51 + static struct imxuart_platform_data uart_pdata = { 52 + .flags = IMXUART_HAVE_RTSCTS, 53 + }; 54 + 55 + static struct resource imx_uart1_resources[] = { 56 + [0] = { 57 + .start = 0x00206000, 58 + .end = 0x002060FF, 59 + .flags = IORESOURCE_MEM, 60 + }, 61 + [1] = { 62 + .start = (UART1_MINT_RX), 63 + .end = (UART1_MINT_RX), 64 + .flags = IORESOURCE_IRQ, 65 + }, 66 + [2] = { 67 + .start = (UART1_MINT_TX), 68 + .end = (UART1_MINT_TX), 69 + .flags = IORESOURCE_IRQ, 70 + }, 71 + }; 72 + 73 + static struct platform_device imx_uart1_device = { 74 + .name = "imx-uart", 75 + .id = 0, 76 + .num_resources = ARRAY_SIZE(imx_uart1_resources), 77 + .resource = imx_uart1_resources, 78 + .dev = { 79 + .platform_data = &uart_pdata, 80 + } 81 + }; 82 + 83 + static struct resource imx_uart2_resources[] = { 84 + [0] = { 85 + .start = 0x00207000, 86 + .end = 0x002070FF, 87 + .flags = IORESOURCE_MEM, 88 + }, 89 + [1] = { 90 + .start = (UART2_MINT_RX), 91 + .end = (UART2_MINT_RX), 92 + .flags = IORESOURCE_IRQ, 93 + }, 94 + [2] = { 95 + .start = (UART2_MINT_TX), 96 + .end = (UART2_MINT_TX), 97 + .flags = IORESOURCE_IRQ, 98 + }, 99 + }; 100 + 101 + static struct platform_device imx_uart2_device = { 102 + .name = "imx-uart", 103 + .id = 1, 104 + .num_resources = ARRAY_SIZE(imx_uart2_resources), 105 + .resource = imx_uart2_resources, 106 + .dev = { 107 + .platform_data = &uart_pdata, 108 + } 109 + }; 110 + 52 111 static struct platform_device *devices[] __initdata = { 53 112 &cs89x0_device, 113 + &imx_uart1_device, 114 + &imx_uart2_device, 54 115 }; 55 116 56 117 #ifdef CONFIG_MMC_IMX ··· 138 75 imx_gpio_mode(GPIO_PORTB | GPIO_GIUS | GPIO_IN | 20); 139 76 imx_set_mmc_info(&mx1ads_mmc_info); 140 77 #endif 78 + 79 + imx_gpio_mode(PC9_PF_UART1_CTS); 80 + imx_gpio_mode(PC10_PF_UART1_RTS); 81 + imx_gpio_mode(PC11_PF_UART1_TXD); 82 + imx_gpio_mode(PC12_PF_UART1_RXD); 83 + 84 + imx_gpio_mode(PB28_PF_UART2_CTS); 85 + imx_gpio_mode(PB29_PF_UART2_RTS); 86 + imx_gpio_mode(PB30_PF_UART2_TXD); 87 + imx_gpio_mode(PB31_PF_UART2_RXD); 88 + 141 89 platform_add_devices(devices, ARRAY_SIZE(devices)); 142 90 } 143 91
+16 -24
drivers/serial/imx.c
··· 45 45 #include <asm/io.h> 46 46 #include <asm/irq.h> 47 47 #include <asm/hardware.h> 48 + #include <asm/arch/imx-uart.h> 48 49 49 50 /* We've been assigned a range on the "Low-density serial ports" major */ 50 51 #define SERIAL_IMX_MAJOR 204 ··· 74 73 struct uart_port port; 75 74 struct timer_list timer; 76 75 unsigned int old_status; 77 - int txirq,rxirq,rtsirq; 76 + int txirq,rxirq,rtsirq; 77 + int have_rtscts:1; 78 78 }; 79 79 80 80 /* ··· 493 491 ucr2 = UCR2_SRST | UCR2_IRTS; 494 492 495 493 if (termios->c_cflag & CRTSCTS) { 496 - ucr2 &= ~UCR2_IRTS; 497 - ucr2 |= UCR2_CTSC; 494 + if( sport->have_rtscts ) { 495 + ucr2 &= ~UCR2_IRTS; 496 + ucr2 |= UCR2_CTSC; 497 + } else { 498 + termios->c_cflag &= ~CRTSCTS; 499 + } 498 500 } 499 501 500 502 if (termios->c_cflag & CSTOPB) ··· 725 719 imx_ports[i].timer.function = imx_timeout; 726 720 imx_ports[i].timer.data = (unsigned long)&imx_ports[i]; 727 721 } 728 - 729 - imx_gpio_mode(PC9_PF_UART1_CTS); 730 - imx_gpio_mode(PC10_PF_UART1_RTS); 731 - imx_gpio_mode(PC11_PF_UART1_TXD); 732 - imx_gpio_mode(PC12_PF_UART1_RXD); 733 - imx_gpio_mode(PB28_PF_UART2_CTS); 734 - imx_gpio_mode(PB29_PF_UART2_RTS); 735 - 736 - imx_gpio_mode(PB30_PF_UART2_TXD); 737 - imx_gpio_mode(PB31_PF_UART2_RXD); 738 - 739 - #if 0 /* We don't need these, on the mx1 the _modem_ side of the uart 740 - * is implemented. 741 - */ 742 - imx_gpio_mode(PD7_AF_UART2_DTR); 743 - imx_gpio_mode(PD8_AF_UART2_DCD); 744 - imx_gpio_mode(PD9_AF_UART2_RI); 745 - imx_gpio_mode(PD10_AF_UART2_DSR); 746 - #endif 747 - 748 - 749 722 } 750 723 751 724 #ifdef CONFIG_SERIAL_IMX_CONSOLE ··· 917 932 918 933 static int serial_imx_probe(struct platform_device *dev) 919 934 { 935 + struct imxuart_platform_data *pdata; 936 + 920 937 imx_ports[dev->id].port.dev = &dev->dev; 938 + 939 + pdata = (struct imxuart_platform_data *)dev->dev.platform_data; 940 + if(pdata && (pdata->flags & IMXUART_HAVE_RTSCTS)) 941 + imx_ports[dev->id].have_rtscts = 1; 942 + 921 943 uart_add_one_port(&imx_reg, &imx_ports[dev->id].port); 922 944 platform_set_drvdata(dev, &imx_ports[dev->id]); 923 945 return 0;
+10
include/asm-arm/arch-imx/imx-uart.h
··· 1 + #ifndef ASMARM_ARCH_UART_H 2 + #define ASMARM_ARCH_UART_H 3 + 4 + #define IMXUART_HAVE_RTSCTS (1<<0) 5 + 6 + struct imxuart_platform_data { 7 + unsigned int flags; 8 + }; 9 + 10 + #endif