aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-davinci/serial.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-davinci/serial.c')
-rw-r--r--arch/arm/mach-davinci/serial.c34
1 files changed, 26 insertions, 8 deletions
diff --git a/arch/arm/mach-davinci/serial.c b/arch/arm/mach-davinci/serial.c
index 7ce5ba086575..1875740fe27c 100644
--- a/arch/arm/mach-davinci/serial.c
+++ b/arch/arm/mach-davinci/serial.c
@@ -35,14 +35,20 @@ static inline unsigned int serial_read_reg(struct plat_serial8250_port *up,
35 int offset) 35 int offset)
36{ 36{
37 offset <<= up->regshift; 37 offset <<= up->regshift;
38 return (unsigned int)__raw_readl(IO_ADDRESS(up->mapbase) + offset); 38
39 WARN_ONCE(!up->membase, "unmapped read: uart[%d]\n", offset);
40
41 return (unsigned int)__raw_readl(up->membase + offset);
39} 42}
40 43
41static inline void serial_write_reg(struct plat_serial8250_port *p, int offset, 44static inline void serial_write_reg(struct plat_serial8250_port *p, int offset,
42 int value) 45 int value)
43{ 46{
44 offset <<= p->regshift; 47 offset <<= p->regshift;
45 __raw_writel(value, IO_ADDRESS(p->mapbase) + offset); 48
49 WARN_ONCE(!p->membase, "unmapped write: uart[%d]\n", offset);
50
51 __raw_writel(value, p->membase + offset);
46} 52}
47 53
48static void __init davinci_serial_reset(struct plat_serial8250_port *p) 54static void __init davinci_serial_reset(struct plat_serial8250_port *p)
@@ -77,20 +83,32 @@ int __init davinci_serial_init(struct davinci_uart_config *info)
77 * Make sure the serial ports are muxed on at this point. 83 * Make sure the serial ports are muxed on at this point.
78 * You have to mux them off in device drivers later on if not needed. 84 * You have to mux them off in device drivers later on if not needed.
79 */ 85 */
80 for (i = 0; i < DAVINCI_MAX_NR_UARTS; i++, p++) { 86 for (i = 0; p->flags; i++, p++) {
81 if (!(info->enabled_uarts & (1 << i))) 87 if (!(info->enabled_uarts & (1 << i)))
82 continue; 88 continue;
83 89
84 sprintf(name, "uart%d", i); 90 sprintf(name, "uart%d", i);
85 uart_clk = clk_get(dev, name); 91 uart_clk = clk_get(dev, name);
86 if (IS_ERR(uart_clk)) 92 if (IS_ERR(uart_clk)) {
87 printk(KERN_ERR "%s:%d: failed to get UART%d clock\n", 93 printk(KERN_ERR "%s:%d: failed to get UART%d clock\n",
88 __func__, __LINE__, i); 94 __func__, __LINE__, i);
89 else { 95 continue;
90 clk_enable(uart_clk);
91 p->uartclk = clk_get_rate(uart_clk);
92 davinci_serial_reset(p);
93 } 96 }
97
98 clk_enable(uart_clk);
99 p->uartclk = clk_get_rate(uart_clk);
100
101 if (!p->membase && p->mapbase) {
102 p->membase = ioremap(p->mapbase, SZ_4K);
103
104 if (p->membase)
105 p->flags &= ~UPF_IOREMAP;
106 else
107 pr_err("uart regs ioremap failed\n");
108 }
109
110 if (p->membase && p->type != PORT_AR7)
111 davinci_serial_reset(p);
94 } 112 }
95 113
96 return platform_device_register(soc_info->serial_dev); 114 return platform_device_register(soc_info->serial_dev);