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

IMX UART: remove statically initialized tables

This patch removes the statically initialized tables from the i.MX serial
driver and makes the driver fully dependent on the information provided by
the platform_device.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>

authored by

Sascha Hauer and committed by
Robert Schwebel
dbff4e9e 2582d8c1

+64 -75
+10
arch/arm/mach-imx/mx1ads.c
··· 69 69 .end = (UART1_MINT_TX), 70 70 .flags = IORESOURCE_IRQ, 71 71 }, 72 + [3] = { 73 + .start = UART1_MINT_RTS, 74 + .end = UART1_MINT_RTS, 75 + .flags = IORESOURCE_IRQ, 76 + }, 72 77 }; 73 78 74 79 static struct platform_device imx_uart1_device = { ··· 100 95 [2] = { 101 96 .start = (UART2_MINT_TX), 102 97 .end = (UART2_MINT_TX), 98 + .flags = IORESOURCE_IRQ, 99 + }, 100 + [3] = { 101 + .start = UART2_MINT_RTS, 102 + .end = UART2_MINT_RTS, 103 103 .flags = IORESOURCE_IRQ, 104 104 }, 105 105 };
+54 -75
drivers/serial/imx.c
··· 176 176 177 177 #define DRIVER_NAME "IMX-uart" 178 178 179 + #define UART_NR 8 180 + 179 181 struct imx_port { 180 182 struct uart_port port; 181 183 struct timer_list timer; ··· 831 829 .verify_port = imx_verify_port, 832 830 }; 833 831 834 - static struct imx_port imx_ports[] = { 835 - { 836 - .txirq = UART1_MINT_TX, 837 - .rxirq = UART1_MINT_RX, 838 - .rtsirq = UART1_MINT_RTS, 839 - .port = { 840 - .type = PORT_IMX, 841 - .iotype = UPIO_MEM, 842 - .membase = (void *)IMX_UART1_BASE, 843 - .mapbase = 0x00206000, 844 - .irq = UART1_MINT_RX, 845 - .fifosize = 32, 846 - .flags = UPF_BOOT_AUTOCONF, 847 - .ops = &imx_pops, 848 - .line = 0, 849 - }, 850 - }, { 851 - .txirq = UART2_MINT_TX, 852 - .rxirq = UART2_MINT_RX, 853 - .rtsirq = UART2_MINT_RTS, 854 - .port = { 855 - .type = PORT_IMX, 856 - .iotype = UPIO_MEM, 857 - .membase = (void *)IMX_UART2_BASE, 858 - .mapbase = 0x00207000, 859 - .irq = UART2_MINT_RX, 860 - .fifosize = 32, 861 - .flags = UPF_BOOT_AUTOCONF, 862 - .ops = &imx_pops, 863 - .line = 1, 864 - }, 865 - } 866 - }; 867 - 868 - /* 869 - * Setup the IMX serial ports. 870 - * Note also that we support "console=ttySMXx" where "x" is either 0 or 1. 871 - * Which serial port this ends up being depends on the machine you're 872 - * running this kernel on. I'm not convinced that this is a good idea, 873 - * but that's the way it traditionally works. 874 - * 875 - */ 876 - static void __init imx_init_ports(void) 877 - { 878 - static int first = 1; 879 - int i; 880 - 881 - if (!first) 882 - return; 883 - first = 0; 884 - 885 - for (i = 0; i < ARRAY_SIZE(imx_ports); i++) { 886 - init_timer(&imx_ports[i].timer); 887 - imx_ports[i].timer.function = imx_timeout; 888 - imx_ports[i].timer.data = (unsigned long)&imx_ports[i]; 889 - 890 - imx_ports[i].port.uartclk = imx_get_perclk1(); 891 - } 892 - } 832 + static struct imx_port *imx_ports[UART_NR]; 893 833 894 834 #ifdef CONFIG_SERIAL_IMX_CONSOLE 895 835 static void imx_console_putchar(struct uart_port *port, int ch) ··· 850 906 static void 851 907 imx_console_write(struct console *co, const char *s, unsigned int count) 852 908 { 853 - struct imx_port *sport = &imx_ports[co->index]; 909 + struct imx_port *sport = imx_ports[co->index]; 854 910 unsigned int old_ucr1, old_ucr2; 855 911 856 912 /* ··· 956 1012 */ 957 1013 if (co->index == -1 || co->index >= ARRAY_SIZE(imx_ports)) 958 1014 co->index = 0; 959 - sport = &imx_ports[co->index]; 1015 + sport = imx_ports[co->index]; 960 1016 961 1017 if (options) 962 1018 uart_parse_options(options, &baud, &parity, &bits, &flow); ··· 978 1034 .index = -1, 979 1035 .data = &imx_reg, 980 1036 }; 981 - 982 - static int __init imx_rs_console_init(void) 983 - { 984 - imx_init_ports(); 985 - register_console(&imx_console); 986 - return 0; 987 - } 988 - console_initcall(imx_rs_console_init); 989 1037 990 1038 #define IMX_CONSOLE &imx_console 991 1039 #else ··· 1016 1080 1017 1081 static int serial_imx_probe(struct platform_device *pdev) 1018 1082 { 1083 + struct imx_port *sport; 1019 1084 struct imxuart_platform_data *pdata; 1085 + void __iomem *base; 1086 + int ret = 0; 1087 + struct resource *res; 1020 1088 1021 - imx_ports[pdev->id].port.dev = &pdev->dev; 1089 + sport = kzalloc(sizeof(*sport), GFP_KERNEL); 1090 + if (!sport) 1091 + return -ENOMEM; 1092 + 1093 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1094 + if (!res) { 1095 + ret = -ENODEV; 1096 + goto free; 1097 + } 1098 + 1099 + base = ioremap(res->start, PAGE_SIZE); 1100 + if (!base) { 1101 + ret = -ENOMEM; 1102 + goto free; 1103 + } 1104 + 1105 + sport->port.dev = &pdev->dev; 1106 + sport->port.mapbase = res->start; 1107 + sport->port.membase = base; 1108 + sport->port.type = PORT_IMX, 1109 + sport->port.iotype = UPIO_MEM; 1110 + sport->port.irq = platform_get_irq(pdev, 0); 1111 + sport->rxirq = platform_get_irq(pdev, 0); 1112 + sport->txirq = platform_get_irq(pdev, 1); 1113 + sport->rtsirq = platform_get_irq(pdev, 2); 1114 + sport->port.fifosize = 32; 1115 + sport->port.ops = &imx_pops; 1116 + sport->port.flags = UPF_BOOT_AUTOCONF; 1117 + sport->port.line = pdev->id; 1118 + init_timer(&sport->timer); 1119 + sport->timer.function = imx_timeout; 1120 + sport->timer.data = (unsigned long)sport; 1121 + sport->port.uartclk = imx_get_perclk1(); 1122 + 1123 + imx_ports[pdev->id] = sport; 1022 1124 1023 1125 pdata = pdev->dev.platform_data; 1024 1126 if(pdata && (pdata->flags & IMXUART_HAVE_RTSCTS)) 1025 - imx_ports[pdev->id].have_rtscts = 1; 1127 + sport->have_rtscts = 1; 1026 1128 1027 1129 if (pdata->init) 1028 1130 pdata->init(pdev); 1029 1131 1030 - uart_add_one_port(&imx_reg, &imx_ports[pdev->id].port); 1031 - platform_set_drvdata(pdev, &imx_ports[pdev->id]); 1132 + uart_add_one_port(&imx_reg, &sport->port); 1133 + platform_set_drvdata(pdev, &sport->port); 1032 1134 1033 1135 return 0; 1136 + free: 1137 + kfree(sport); 1138 + 1139 + return ret; 1034 1140 } 1035 1141 1036 1142 static int serial_imx_remove(struct platform_device *pdev) ··· 1089 1111 1090 1112 if (pdata->exit) 1091 1113 pdata->exit(pdev); 1114 + 1115 + iounmap(sport->port.membase); 1116 + kfree(sport); 1092 1117 1093 1118 return 0; 1094 1119 } ··· 1113 1132 int ret; 1114 1133 1115 1134 printk(KERN_INFO "Serial: IMX driver\n"); 1116 - 1117 - imx_init_ports(); 1118 1135 1119 1136 ret = uart_register_driver(&imx_reg); 1120 1137 if (ret)