| 
									
										
										
										
											2011-01-04 21:28:14 +01:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  *  Atheros AR71XX/AR724X/AR913X common devices | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  *  Copyright (C) 2008-2011 Gabor Juhos <juhosg@openwrt.org> | 
					
						
							|  |  |  |  *  Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org> | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  *  Parts of this file are based on Atheros' 2.6.15 BSP | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  *  This program is free software; you can redistribute it and/or modify it | 
					
						
							|  |  |  |  *  under the terms of the GNU General Public License version 2 as published | 
					
						
							|  |  |  |  *  by the Free Software Foundation. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <linux/kernel.h>
 | 
					
						
							|  |  |  | #include <linux/init.h>
 | 
					
						
							|  |  |  | #include <linux/platform_device.h>
 | 
					
						
							|  |  |  | #include <linux/serial_8250.h>
 | 
					
						
							|  |  |  | #include <linux/clk.h>
 | 
					
						
							|  |  |  | #include <linux/err.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <asm/mach-ath79/ath79.h>
 | 
					
						
							|  |  |  | #include <asm/mach-ath79/ar71xx_regs.h>
 | 
					
						
							|  |  |  | #include "common.h"
 | 
					
						
							|  |  |  | #include "dev-common.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static struct resource ath79_uart_resources[] = { | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		.start	= AR71XX_UART_BASE, | 
					
						
							|  |  |  | 		.end	= AR71XX_UART_BASE + AR71XX_UART_SIZE - 1, | 
					
						
							|  |  |  | 		.flags	= IORESOURCE_MEM, | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define AR71XX_UART_FLAGS (UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_IOREMAP)
 | 
					
						
							|  |  |  | static struct plat_serial8250_port ath79_uart_data[] = { | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		.mapbase	= AR71XX_UART_BASE, | 
					
						
							| 
									
										
										
										
											2013-02-07 19:32:24 +00:00
										 |  |  | 		.irq		= ATH79_MISC_IRQ(3), | 
					
						
							| 
									
										
										
										
											2011-01-04 21:28:14 +01:00
										 |  |  | 		.flags		= AR71XX_UART_FLAGS, | 
					
						
							|  |  |  | 		.iotype		= UPIO_MEM32, | 
					
						
							|  |  |  | 		.regshift	= 2, | 
					
						
							|  |  |  | 	}, { | 
					
						
							|  |  |  | 		/* terminating entry */ | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static struct platform_device ath79_uart_device = { | 
					
						
							|  |  |  | 	.name		= "serial8250", | 
					
						
							|  |  |  | 	.id		= PLAT8250_DEV_PLATFORM, | 
					
						
							|  |  |  | 	.resource	= ath79_uart_resources, | 
					
						
							|  |  |  | 	.num_resources	= ARRAY_SIZE(ath79_uart_resources), | 
					
						
							|  |  |  | 	.dev = { | 
					
						
							|  |  |  | 		.platform_data	= ath79_uart_data | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-06-20 19:26:12 +02:00
										 |  |  | static struct resource ar933x_uart_resources[] = { | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		.start	= AR933X_UART_BASE, | 
					
						
							|  |  |  | 		.end	= AR933X_UART_BASE + AR71XX_UART_SIZE - 1, | 
					
						
							|  |  |  | 		.flags	= IORESOURCE_MEM, | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2013-02-07 19:32:24 +00:00
										 |  |  | 		.start	= ATH79_MISC_IRQ(3), | 
					
						
							|  |  |  | 		.end	= ATH79_MISC_IRQ(3), | 
					
						
							| 
									
										
										
										
											2011-06-20 19:26:12 +02:00
										 |  |  | 		.flags	= IORESOURCE_IRQ, | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static struct platform_device ar933x_uart_device = { | 
					
						
							|  |  |  | 	.name		= "ar933x-uart", | 
					
						
							|  |  |  | 	.id		= -1, | 
					
						
							|  |  |  | 	.resource	= ar933x_uart_resources, | 
					
						
							|  |  |  | 	.num_resources	= ARRAY_SIZE(ar933x_uart_resources), | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-01-04 21:28:14 +01:00
										 |  |  | void __init ath79_register_uart(void) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2013-08-28 10:41:44 +02:00
										 |  |  | 	unsigned long uart_clk_rate; | 
					
						
							| 
									
										
										
										
											2011-01-04 21:28:14 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-28 10:41:44 +02:00
										 |  |  | 	uart_clk_rate = ath79_get_sys_clk_rate("uart"); | 
					
						
							| 
									
										
										
										
											2011-01-04 21:28:14 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-06-20 19:26:12 +02:00
										 |  |  | 	if (soc_is_ar71xx() || | 
					
						
							|  |  |  | 	    soc_is_ar724x() || | 
					
						
							| 
									
										
										
										
											2012-03-14 10:45:27 +01:00
										 |  |  | 	    soc_is_ar913x() || | 
					
						
							| 
									
										
										
										
											2013-02-15 13:38:21 +00:00
										 |  |  | 	    soc_is_ar934x() || | 
					
						
							|  |  |  | 	    soc_is_qca955x()) { | 
					
						
							| 
									
										
										
										
											2013-08-28 10:41:44 +02:00
										 |  |  | 		ath79_uart_data[0].uartclk = uart_clk_rate; | 
					
						
							| 
									
										
										
										
											2011-06-20 19:26:12 +02:00
										 |  |  | 		platform_device_register(&ath79_uart_device); | 
					
						
							|  |  |  | 	} else if (soc_is_ar933x()) { | 
					
						
							|  |  |  | 		platform_device_register(&ar933x_uart_device); | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		BUG(); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2011-01-04 21:28:14 +01:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2011-01-04 21:28:20 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | void __init ath79_register_wdt(void) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-12-27 15:38:26 +01:00
										 |  |  | 	struct resource res; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	memset(&res, 0, sizeof(res)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	res.flags = IORESOURCE_MEM; | 
					
						
							|  |  |  | 	res.start = AR71XX_RESET_BASE + AR71XX_RESET_REG_WDOG_CTRL; | 
					
						
							|  |  |  | 	res.end = res.start + 0x8 - 1; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	platform_device_register_simple("ath79-wdt", -1, &res, 1); | 
					
						
							| 
									
										
										
										
											2011-01-04 21:28:20 +01:00
										 |  |  | } |