aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/serial/cpm_uart/cpm_uart.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/serial/cpm_uart/cpm_uart.h')
-rw-r--r--drivers/serial/cpm_uart/cpm_uart.h42
1 files changed, 22 insertions, 20 deletions
diff --git a/drivers/serial/cpm_uart/cpm_uart.h b/drivers/serial/cpm_uart/cpm_uart.h
index 4e1987adc23b..32b9737759c4 100644
--- a/drivers/serial/cpm_uart/cpm_uart.h
+++ b/drivers/serial/cpm_uart/cpm_uart.h
@@ -56,21 +56,21 @@ struct uart_cpm_port {
56 u16 rx_fifosize; 56 u16 rx_fifosize;
57 u16 tx_nrfifos; 57 u16 tx_nrfifos;
58 u16 tx_fifosize; 58 u16 tx_fifosize;
59 smc_t *smcp; 59 smc_t __iomem *smcp;
60 smc_uart_t *smcup; 60 smc_uart_t __iomem *smcup;
61 scc_t *sccp; 61 scc_t __iomem *sccp;
62 scc_uart_t *sccup; 62 scc_uart_t __iomem *sccup;
63 volatile cbd_t *rx_bd_base; 63 cbd_t __iomem *rx_bd_base;
64 volatile cbd_t *rx_cur; 64 cbd_t __iomem *rx_cur;
65 volatile cbd_t *tx_bd_base; 65 cbd_t __iomem *tx_bd_base;
66 volatile cbd_t *tx_cur; 66 cbd_t __iomem *tx_cur;
67 unsigned char *tx_buf; 67 unsigned char *tx_buf;
68 unsigned char *rx_buf; 68 unsigned char *rx_buf;
69 u32 flags; 69 u32 flags;
70 void (*set_lineif)(struct uart_cpm_port *); 70 void (*set_lineif)(struct uart_cpm_port *);
71 u8 brg; 71 u8 brg;
72 uint dp_addr; 72 uint dp_addr;
73 void *mem_addr; 73 void *mem_addr;
74 dma_addr_t dma_addr; 74 dma_addr_t dma_addr;
75 u32 mem_size; 75 u32 mem_size;
76 /* helpers */ 76 /* helpers */
@@ -106,34 +106,36 @@ void scc4_lineif(struct uart_cpm_port *pinfo);
106/* 106/*
107 virtual to phys transtalion 107 virtual to phys transtalion
108*/ 108*/
109static inline unsigned long cpu2cpm_addr(void* addr, struct uart_cpm_port *pinfo) 109static inline unsigned long cpu2cpm_addr(void *addr,
110 struct uart_cpm_port *pinfo)
110{ 111{
111 int offset; 112 int offset;
112 u32 val = (u32)addr; 113 u32 val = (u32)addr;
114 u32 mem = (u32)pinfo->mem_addr;
113 /* sane check */ 115 /* sane check */
114 if (likely((val >= (u32)pinfo->mem_addr)) && 116 if (likely(val >= mem && val < mem + pinfo->mem_size)) {
115 (val<((u32)pinfo->mem_addr + pinfo->mem_size))) { 117 offset = val - mem;
116 offset = val - (u32)pinfo->mem_addr; 118 return pinfo->dma_addr + offset;
117 return pinfo->dma_addr+offset;
118 } 119 }
119 /* something nasty happened */ 120 /* something nasty happened */
120 BUG(); 121 BUG();
121 return 0; 122 return 0;
122} 123}
123 124
124static inline void *cpm2cpu_addr(unsigned long addr, struct uart_cpm_port *pinfo) 125static inline void *cpm2cpu_addr(unsigned long addr,
126 struct uart_cpm_port *pinfo)
125{ 127{
126 int offset; 128 int offset;
127 u32 val = addr; 129 u32 val = addr;
130 u32 dma = (u32)pinfo->dma_addr;
128 /* sane check */ 131 /* sane check */
129 if (likely((val >= pinfo->dma_addr) && 132 if (likely(val >= dma && val < dma + pinfo->mem_size)) {
130 (val<(pinfo->dma_addr + pinfo->mem_size)))) { 133 offset = val - dma;
131 offset = val - (u32)pinfo->dma_addr; 134 return pinfo->mem_addr + offset;
132 return (void*)(pinfo->mem_addr+offset);
133 } 135 }
134 /* something nasty happened */ 136 /* something nasty happened */
135 BUG(); 137 BUG();
136 return 0; 138 return NULL;
137} 139}
138 140
139 141