aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/ppc/platforms/mpc866ads_setup.c2
-rw-r--r--drivers/serial/cpm_uart/cpm_uart.h19
-rw-r--r--drivers/serial/cpm_uart/cpm_uart_core.c31
-rw-r--r--drivers/serial/cpm_uart/cpm_uart_cpm1.c2
-rw-r--r--drivers/serial/cpm_uart/cpm_uart_cpm2.c2
-rw-r--r--include/linux/fs_uart_pd.h60
6 files changed, 104 insertions, 12 deletions
diff --git a/arch/ppc/platforms/mpc866ads_setup.c b/arch/ppc/platforms/mpc866ads_setup.c
index 6ce3b842defe..d919dab61347 100644
--- a/arch/ppc/platforms/mpc866ads_setup.c
+++ b/arch/ppc/platforms/mpc866ads_setup.c
@@ -378,7 +378,7 @@ int __init mpc866ads_init(void)
378 ppc_sys_device_setfunc(MPC8xx_CPM_SMC1, PPC_SYS_FUNC_UART); 378 ppc_sys_device_setfunc(MPC8xx_CPM_SMC1, PPC_SYS_FUNC_UART);
379#endif 379#endif
380 380
381#ifdef CONFIG_SERIAL_CPM_SMCer 381#ifdef CONFIG_SERIAL_CPM_SMC
382 ppc_sys_device_enable(MPC8xx_CPM_SMC2); 382 ppc_sys_device_enable(MPC8xx_CPM_SMC2);
383 ppc_sys_device_setfunc(MPC8xx_CPM_SMC2, PPC_SYS_FUNC_UART); 383 ppc_sys_device_setfunc(MPC8xx_CPM_SMC2, PPC_SYS_FUNC_UART);
384#endif 384#endif
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 b9d1185df20c..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
84void cpm_uart_count(void) 85static 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 */
109static 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*/
@@ -1012,7 +1028,11 @@ int cpm_uart_drv_get_platform_data(struct platform_device *pdev, int is_con)
1012 int line; 1028 int line;
1013 u32 mem, pram; 1029 u32 mem, pram;
1014 1030
1015 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 }
1016 1036
1017 pinfo = (struct uart_cpm_port *) &cpm_uart_ports[idx]; 1037 pinfo = (struct uart_cpm_port *) &cpm_uart_ports[idx];
1018 1038
@@ -1245,8 +1265,7 @@ static int cpm_uart_drv_probe(struct device *dev)
1245 } 1265 }
1246 1266
1247 pdata = pdev->dev.platform_data; 1267 pdata = pdev->dev.platform_data;
1248 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));
1249 cpm_uart_port_map[pdata->fs_no]);
1250 1269
1251 if ((ret = cpm_uart_drv_get_platform_data(pdev, 0))) 1270 if ((ret = cpm_uart_drv_get_platform_data(pdev, 0)))
1252 return ret; 1271 return ret;
@@ -1265,7 +1284,7 @@ static int cpm_uart_drv_remove(struct device *dev)
1265 struct fs_uart_platform_info *pdata = pdev->dev.platform_data; 1284 struct fs_uart_platform_info *pdata = pdev->dev.platform_data;
1266 1285
1267 pr_debug("cpm_uart_drv_remove: Removing CPM UART %d\n", 1286 pr_debug("cpm_uart_drv_remove: Removing CPM UART %d\n",
1268 cpm_uart_port_map[pdata->fs_no]); 1287 cpm_uart_id2nr(pdata->fs_no));
1269 1288
1270 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);
1271 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
diff --git a/include/linux/fs_uart_pd.h b/include/linux/fs_uart_pd.h
new file mode 100644
index 000000000000..f5975126b712
--- /dev/null
+++ b/include/linux/fs_uart_pd.h
@@ -0,0 +1,60 @@
1/*
2 * Platform information definitions for the CPM Uart driver.
3 *
4 * 2006 (c) MontaVista Software, Inc.
5 * Vitaly Bordug <vbordug@ru.mvista.com>
6 *
7 * This file is licensed under the terms of the GNU General Public License
8 * version 2. This program is licensed "as is" without any warranty of any
9 * kind, whether express or implied.
10 */
11
12#ifndef FS_UART_PD_H
13#define FS_UART_PD_H
14
15#include <linux/version.h>
16#include <asm/types.h>
17
18enum fs_uart_id {
19 fsid_smc1_uart,
20 fsid_smc2_uart,
21 fsid_scc1_uart,
22 fsid_scc2_uart,
23 fsid_scc3_uart,
24 fsid_scc4_uart,
25 fs_uart_nr,
26};
27
28static inline int fs_uart_id_scc2fsid(int id)
29{
30 return fsid_scc1_uart + id - 1;
31}
32
33static inline int fs_uart_id_fsid2scc(int id)
34{
35 return id - fsid_scc1_uart + 1;
36}
37
38static inline int fs_uart_id_smc2fsid(int id)
39{
40 return fsid_smc1_uart + id - 1;
41}
42
43static inline int fs_uart_id_fsid2smc(int id)
44{
45 return id - fsid_smc1_uart + 1;
46}
47
48struct fs_uart_platform_info {
49 void(*init_ioports)(void);
50 /* device specific information */
51 int fs_no; /* controller index */
52 u32 uart_clk;
53 u8 tx_num_fifo;
54 u8 tx_buf_size;
55 u8 rx_num_fifo;
56 u8 rx_buf_size;
57 u8 brg;
58};
59
60#endif