diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/serial/cpm_uart/cpm_uart.h | 19 | ||||
-rw-r--r-- | drivers/serial/cpm_uart/cpm_uart_core.c | 37 | ||||
-rw-r--r-- | drivers/serial/cpm_uart/cpm_uart_cpm1.c | 2 | ||||
-rw-r--r-- | drivers/serial/cpm_uart/cpm_uart_cpm2.c | 2 |
4 files changed, 48 insertions, 12 deletions
diff --git a/drivers/serial/cpm_uart/cpm_uart.h b/drivers/serial/cpm_uart/cpm_uart.h index aa5eb7ddeda9..3b35cb779539 100644 --- a/drivers/serial/cpm_uart/cpm_uart.h +++ b/drivers/serial/cpm_uart/cpm_uart.h | |||
@@ -5,6 +5,13 @@ | |||
5 | * | 5 | * |
6 | * Copyright (C) 2004 Freescale Semiconductor, Inc. | 6 | * Copyright (C) 2004 Freescale Semiconductor, Inc. |
7 | * | 7 | * |
8 | * 2006 (c) MontaVista Software, Inc. | ||
9 | * Vitaly Bordug <vbordug@ru.mvista.com> | ||
10 | * | ||
11 | * This file is licensed under the terms of the GNU General Public License | ||
12 | * version 2. This program is licensed "as is" without any warranty of any | ||
13 | * kind, whether express or implied. | ||
14 | * | ||
8 | */ | 15 | */ |
9 | #ifndef CPM_UART_H | 16 | #ifndef CPM_UART_H |
10 | #define CPM_UART_H | 17 | #define CPM_UART_H |
@@ -101,12 +108,13 @@ static inline unsigned long cpu2cpm_addr(void* addr, struct uart_cpm_port *pinfo | |||
101 | int offset; | 108 | int offset; |
102 | u32 val = (u32)addr; | 109 | u32 val = (u32)addr; |
103 | /* sane check */ | 110 | /* sane check */ |
104 | if ((val >= (u32)pinfo->mem_addr) && | 111 | if (likely((val >= (u32)pinfo->mem_addr)) && |
105 | (val<((u32)pinfo->mem_addr + pinfo->mem_size))) { | 112 | (val<((u32)pinfo->mem_addr + pinfo->mem_size))) { |
106 | offset = val - (u32)pinfo->mem_addr; | 113 | offset = val - (u32)pinfo->mem_addr; |
107 | return pinfo->dma_addr+offset; | 114 | return pinfo->dma_addr+offset; |
108 | } | 115 | } |
109 | printk("%s(): address %x to translate out of range!\n", __FUNCTION__, val); | 116 | /* something nasty happened */ |
117 | BUG(); | ||
110 | return 0; | 118 | return 0; |
111 | } | 119 | } |
112 | 120 | ||
@@ -115,12 +123,13 @@ static inline void *cpm2cpu_addr(unsigned long addr, struct uart_cpm_port *pinfo | |||
115 | int offset; | 123 | int offset; |
116 | u32 val = addr; | 124 | u32 val = addr; |
117 | /* sane check */ | 125 | /* sane check */ |
118 | if ((val >= pinfo->dma_addr) && | 126 | if (likely((val >= pinfo->dma_addr) && |
119 | (val<(pinfo->dma_addr + pinfo->mem_size))) { | 127 | (val<(pinfo->dma_addr + pinfo->mem_size)))) { |
120 | offset = val - (u32)pinfo->dma_addr; | 128 | offset = val - (u32)pinfo->dma_addr; |
121 | return (void*)(pinfo->mem_addr+offset); | 129 | return (void*)(pinfo->mem_addr+offset); |
122 | } | 130 | } |
123 | printk("%s(): address %x to translate out of range!\n", __FUNCTION__, val); | 131 | /* something nasty happened */ |
132 | BUG(); | ||
124 | return 0; | 133 | return 0; |
125 | } | 134 | } |
126 | 135 | ||
diff --git a/drivers/serial/cpm_uart/cpm_uart_core.c b/drivers/serial/cpm_uart/cpm_uart_core.c index ced193bf9e1e..969f94900431 100644 --- a/drivers/serial/cpm_uart/cpm_uart_core.c +++ b/drivers/serial/cpm_uart/cpm_uart_core.c | |||
@@ -12,7 +12,8 @@ | |||
12 | * | 12 | * |
13 | * Copyright (C) 2004 Freescale Semiconductor, Inc. | 13 | * Copyright (C) 2004 Freescale Semiconductor, Inc. |
14 | * (C) 2004 Intracom, S.A. | 14 | * (C) 2004 Intracom, S.A. |
15 | * (C) 2005 MontaVista Software, Inc. by Vitaly Bordug <vbordug@ru.mvista.com> | 15 | * (C) 2005-2006 MontaVista Software, Inc. |
16 | * Vitaly Bordug <vbordug@ru.mvista.com> | ||
16 | * | 17 | * |
17 | * This program is free software; you can redistribute it and/or modify | 18 | * This program is free software; you can redistribute it and/or modify |
18 | * it under the terms of the GNU General Public License as published by | 19 | * it under the terms of the GNU General Public License as published by |
@@ -81,7 +82,7 @@ early_uart_get_pdev(int index) | |||
81 | } | 82 | } |
82 | 83 | ||
83 | 84 | ||
84 | void cpm_uart_count(void) | 85 | static void cpm_uart_count(void) |
85 | { | 86 | { |
86 | cpm_uart_nr = 0; | 87 | cpm_uart_nr = 0; |
87 | #ifdef CONFIG_SERIAL_CPM_SMC1 | 88 | #ifdef CONFIG_SERIAL_CPM_SMC1 |
@@ -104,6 +105,21 @@ void cpm_uart_count(void) | |||
104 | #endif | 105 | #endif |
105 | } | 106 | } |
106 | 107 | ||
108 | /* Get UART number by its id */ | ||
109 | static int cpm_uart_id2nr(int id) | ||
110 | { | ||
111 | int i; | ||
112 | if (id < UART_NR) { | ||
113 | for (i=0; i<UART_NR; i++) { | ||
114 | if (cpm_uart_port_map[i] == id) | ||
115 | return i; | ||
116 | } | ||
117 | } | ||
118 | |||
119 | /* not found or invalid argument */ | ||
120 | return -1; | ||
121 | } | ||
122 | |||
107 | /* | 123 | /* |
108 | * Check, if transmit buffers are processed | 124 | * Check, if transmit buffers are processed |
109 | */ | 125 | */ |
@@ -457,7 +473,11 @@ static void cpm_uart_shutdown(struct uart_port *port) | |||
457 | } | 473 | } |
458 | 474 | ||
459 | /* Shut them really down and reinit buffer descriptors */ | 475 | /* Shut them really down and reinit buffer descriptors */ |
460 | cpm_line_cr_cmd(line, CPM_CR_STOP_TX); | 476 | if (IS_SMC(pinfo)) |
477 | cpm_line_cr_cmd(line, CPM_CR_STOP_TX); | ||
478 | else | ||
479 | cpm_line_cr_cmd(line, CPM_CR_GRA_STOP_TX); | ||
480 | |||
461 | cpm_uart_initbd(pinfo); | 481 | cpm_uart_initbd(pinfo); |
462 | } | 482 | } |
463 | } | 483 | } |
@@ -1008,7 +1028,11 @@ int cpm_uart_drv_get_platform_data(struct platform_device *pdev, int is_con) | |||
1008 | int line; | 1028 | int line; |
1009 | u32 mem, pram; | 1029 | u32 mem, pram; |
1010 | 1030 | ||
1011 | for (line=0; line<UART_NR && cpm_uart_port_map[line]!=pdata->fs_no; line++); | 1031 | line = cpm_uart_id2nr(idx); |
1032 | if(line < 0) { | ||
1033 | printk(KERN_ERR"%s(): port %d is not registered", __FUNCTION__, idx); | ||
1034 | return -1; | ||
1035 | } | ||
1012 | 1036 | ||
1013 | pinfo = (struct uart_cpm_port *) &cpm_uart_ports[idx]; | 1037 | pinfo = (struct uart_cpm_port *) &cpm_uart_ports[idx]; |
1014 | 1038 | ||
@@ -1241,8 +1265,7 @@ static int cpm_uart_drv_probe(struct device *dev) | |||
1241 | } | 1265 | } |
1242 | 1266 | ||
1243 | pdata = pdev->dev.platform_data; | 1267 | pdata = pdev->dev.platform_data; |
1244 | pr_debug("cpm_uart_drv_probe: Adding CPM UART %d\n", | 1268 | pr_debug("cpm_uart_drv_probe: Adding CPM UART %d\n", cpm_uart_id2nr(pdata->fs_no)); |
1245 | cpm_uart_port_map[pdata->fs_no]); | ||
1246 | 1269 | ||
1247 | if ((ret = cpm_uart_drv_get_platform_data(pdev, 0))) | 1270 | if ((ret = cpm_uart_drv_get_platform_data(pdev, 0))) |
1248 | return ret; | 1271 | return ret; |
@@ -1261,7 +1284,7 @@ static int cpm_uart_drv_remove(struct device *dev) | |||
1261 | struct fs_uart_platform_info *pdata = pdev->dev.platform_data; | 1284 | struct fs_uart_platform_info *pdata = pdev->dev.platform_data; |
1262 | 1285 | ||
1263 | pr_debug("cpm_uart_drv_remove: Removing CPM UART %d\n", | 1286 | pr_debug("cpm_uart_drv_remove: Removing CPM UART %d\n", |
1264 | cpm_uart_port_map[pdata->fs_no]); | 1287 | cpm_uart_id2nr(pdata->fs_no)); |
1265 | 1288 | ||
1266 | uart_remove_one_port(&cpm_reg, &cpm_uart_ports[pdata->fs_no].port); | 1289 | uart_remove_one_port(&cpm_reg, &cpm_uart_ports[pdata->fs_no].port); |
1267 | return 0; | 1290 | return 0; |
diff --git a/drivers/serial/cpm_uart/cpm_uart_cpm1.c b/drivers/serial/cpm_uart/cpm_uart_cpm1.c index a5a30622637a..17406a05ce1f 100644 --- a/drivers/serial/cpm_uart/cpm_uart_cpm1.c +++ b/drivers/serial/cpm_uart/cpm_uart_cpm1.c | |||
@@ -8,6 +8,8 @@ | |||
8 | * | 8 | * |
9 | * Copyright (C) 2004 Freescale Semiconductor, Inc. | 9 | * Copyright (C) 2004 Freescale Semiconductor, Inc. |
10 | * (C) 2004 Intracom, S.A. | 10 | * (C) 2004 Intracom, S.A. |
11 | * (C) 2006 MontaVista Software, Inc. | ||
12 | * Vitaly Bordug <vbordug@ru.mvista.com> | ||
11 | * | 13 | * |
12 | * This program is free software; you can redistribute it and/or modify | 14 | * This program is free software; you can redistribute it and/or modify |
13 | * it under the terms of the GNU General Public License as published by | 15 | * it under the terms of the GNU General Public License as published by |
diff --git a/drivers/serial/cpm_uart/cpm_uart_cpm2.c b/drivers/serial/cpm_uart/cpm_uart_cpm2.c index 7c6b07aeea92..4b2de08f46d0 100644 --- a/drivers/serial/cpm_uart/cpm_uart_cpm2.c +++ b/drivers/serial/cpm_uart/cpm_uart_cpm2.c | |||
@@ -8,6 +8,8 @@ | |||
8 | * | 8 | * |
9 | * Copyright (C) 2004 Freescale Semiconductor, Inc. | 9 | * Copyright (C) 2004 Freescale Semiconductor, Inc. |
10 | * (C) 2004 Intracom, S.A. | 10 | * (C) 2004 Intracom, S.A. |
11 | * (C) 2006 MontaVista Software, Inc. | ||
12 | * Vitaly Bordug <vbordug@ru.mvista.com> | ||
11 | * | 13 | * |
12 | * This program is free software; you can redistribute it and/or modify | 14 | * This program is free software; you can redistribute it and/or modify |
13 | * it under the terms of the GNU General Public License as published by | 15 | * it under the terms of the GNU General Public License as published by |