2 * TI DaVinci serial driver
4 * Copyright (C) 2006 Texas Instruments.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #include <linux/kernel.h>
23 #include <linux/init.h>
24 #include <linux/serial_8250.h>
25 #include <linux/serial_reg.h>
26 #include <linux/platform_device.h>
27 #include <linux/delay.h>
28 #include <linux/clk.h>
32 #include <asm/hardware.h>
33 #include <asm/arch/serial.h>
34 #include <asm/arch/irqs.h>
36 #define UART_DAVINCI_PWREMU 0x0c
38 static inline unsigned int davinci_serial_in(struct plat_serial8250_port *up,
41 offset <<= up->regshift;
42 return (unsigned int)__raw_readb(up->membase + offset);
45 static inline void davinci_serial_outp(struct plat_serial8250_port *p,
46 int offset, int value)
48 offset <<= p->regshift;
49 __raw_writeb(value, p->membase + offset);
52 static struct plat_serial8250_port serial_platform_data[] = {
54 .membase = (char *)IO_ADDRESS(DAVINCI_UART0_BASE),
55 .mapbase = (unsigned long)DAVINCI_UART0_BASE,
57 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
67 static struct platform_device serial_device = {
69 .id = PLAT8250_DEV_PLATFORM,
71 .platform_data = serial_platform_data,
75 static void __init davinci_serial_reset(struct plat_serial8250_port *p)
77 /* reset both transmitter and receiver: bits 14,13 = UTRST, URRST */
78 unsigned int pwremu = 0;
80 davinci_serial_outp(p, UART_IER, 0); /* disable all interrupts */
82 davinci_serial_outp(p, UART_DAVINCI_PWREMU, pwremu);
85 pwremu |= (0x3 << 13);
87 davinci_serial_outp(p, UART_DAVINCI_PWREMU, pwremu);
90 static int __init davinci_init(void)
92 davinci_serial_reset(&serial_platform_data[0]);
93 return platform_device_register(&serial_device);
96 arch_initcall(davinci_init);