| Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 1 | /* | 
 | 2 |  * TI DaVinci serial driver | 
 | 3 |  * | 
 | 4 |  * Copyright (C) 2006 Texas Instruments. | 
 | 5 |  * | 
 | 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. | 
 | 10 |  * | 
 | 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. | 
 | 15 |  * | 
 | 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. | 
 | 19 |  * | 
 | 20 |  */ | 
 | 21 |  | 
 | 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> | 
 | 29 |  | 
 | 30 | #include <asm/io.h> | 
 | 31 | #include <asm/irq.h> | 
 | 32 | #include <asm/hardware.h> | 
 | 33 | #include <asm/arch/serial.h> | 
 | 34 | #include <asm/arch/irqs.h> | 
 | 35 |  | 
 | 36 | #define UART_DAVINCI_PWREMU 0x0c | 
 | 37 |  | 
 | 38 | static inline unsigned int davinci_serial_in(struct plat_serial8250_port *up, | 
 | 39 | 					  int offset) | 
 | 40 | { | 
 | 41 | 	offset <<= up->regshift; | 
 | 42 | 	return (unsigned int)__raw_readb(up->membase + offset); | 
 | 43 | } | 
 | 44 |  | 
 | 45 | static inline void davinci_serial_outp(struct plat_serial8250_port *p, | 
 | 46 | 				       int offset, int value) | 
 | 47 | { | 
 | 48 | 	offset <<= p->regshift; | 
 | 49 | 	__raw_writeb(value, p->membase + offset); | 
 | 50 | } | 
 | 51 |  | 
 | 52 | static struct plat_serial8250_port serial_platform_data[] = { | 
 | 53 | 	{ | 
 | 54 | 		.membase	= (char *)IO_ADDRESS(DAVINCI_UART0_BASE), | 
 | 55 | 		.mapbase	= (unsigned long)DAVINCI_UART0_BASE, | 
 | 56 | 		.irq		= IRQ_UARTINT0, | 
 | 57 | 		.flags		= UPF_BOOT_AUTOCONF | UPF_SKIP_TEST, | 
 | 58 | 		.iotype		= UPIO_MEM, | 
 | 59 | 		.regshift	= 2, | 
 | 60 | 		.uartclk	= 27000000, | 
 | 61 | 	}, | 
 | 62 | 	{ | 
 | 63 | 		.flags		= 0 | 
 | 64 | 	}, | 
 | 65 | }; | 
 | 66 |  | 
 | 67 | static struct platform_device serial_device = { | 
 | 68 | 	.name			= "serial8250", | 
 | 69 | 	.id			= PLAT8250_DEV_PLATFORM, | 
 | 70 | 	.dev			= { | 
 | 71 | 		.platform_data	= serial_platform_data, | 
 | 72 | 	}, | 
 | 73 | }; | 
 | 74 |  | 
 | 75 | static void __init davinci_serial_reset(struct plat_serial8250_port *p) | 
 | 76 | { | 
 | 77 | 	/* reset both transmitter and receiver: bits 14,13 = UTRST, URRST */ | 
 | 78 | 	unsigned int pwremu = 0; | 
 | 79 |  | 
 | 80 | 	davinci_serial_outp(p, UART_IER, 0);  /* disable all interrupts */ | 
 | 81 |  | 
 | 82 | 	davinci_serial_outp(p, UART_DAVINCI_PWREMU, pwremu); | 
 | 83 | 	mdelay(10); | 
 | 84 |  | 
 | 85 | 	pwremu |= (0x3 << 13); | 
 | 86 | 	pwremu |= 0x1; | 
 | 87 | 	davinci_serial_outp(p, UART_DAVINCI_PWREMU, pwremu); | 
 | 88 | } | 
 | 89 |  | 
 | 90 | static int __init davinci_init(void) | 
 | 91 | { | 
 | 92 | 	davinci_serial_reset(&serial_platform_data[0]); | 
 | 93 | 	return platform_device_register(&serial_device); | 
 | 94 | } | 
 | 95 |  | 
 | 96 | arch_initcall(davinci_init); |