| 
									
										
										
										
											2012-07-25 16:17:24 +02:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Copyright (c) 2011 Zhang, Keguang <keguang.zhang@gmail.com> | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2013-01-22 12:59:30 +01:00
										 |  |  |  * This program is free software; you can redistribute	it and/or modify it | 
					
						
							|  |  |  |  * under  the terms of	the GNU General	 Public License as published by the | 
					
						
							| 
									
										
										
										
											2012-07-25 16:17:24 +02:00
										 |  |  |  * Free Software Foundation;  either version 2 of the  License, or (at your | 
					
						
							|  |  |  |  * option) any later version. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <linux/clk.h>
 | 
					
						
							|  |  |  | #include <linux/dma-mapping.h>
 | 
					
						
							|  |  |  | #include <linux/err.h>
 | 
					
						
							|  |  |  | #include <linux/phy.h>
 | 
					
						
							|  |  |  | #include <linux/serial_8250.h>
 | 
					
						
							|  |  |  | #include <linux/stmmac.h>
 | 
					
						
							| 
									
										
										
										
											2012-10-08 15:11:17 +02:00
										 |  |  | #include <linux/usb/ehci_pdriver.h>
 | 
					
						
							| 
									
										
										
										
											2012-07-25 16:17:24 +02:00
										 |  |  | #include <asm-generic/sizes.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <loongson1.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define LS1X_UART(_id)						\
 | 
					
						
							|  |  |  | 	{							\ | 
					
						
							|  |  |  | 		.mapbase	= LS1X_UART ## _id ## _BASE,	\ | 
					
						
							|  |  |  | 		.irq		= LS1X_UART ## _id ## _IRQ,	\ | 
					
						
							|  |  |  | 		.iotype		= UPIO_MEM,			\ | 
					
						
							| 
									
										
										
										
											2013-01-22 12:59:30 +01:00
										 |  |  | 		.flags		= UPF_IOREMAP | UPF_FIXED_TYPE, \ | 
					
						
							| 
									
										
										
										
											2012-07-25 16:17:24 +02:00
										 |  |  | 		.type		= PORT_16550A,			\ | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static struct plat_serial8250_port ls1x_serial8250_port[] = { | 
					
						
							|  |  |  | 	LS1X_UART(0), | 
					
						
							|  |  |  | 	LS1X_UART(1), | 
					
						
							|  |  |  | 	LS1X_UART(2), | 
					
						
							|  |  |  | 	LS1X_UART(3), | 
					
						
							|  |  |  | 	{}, | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | struct platform_device ls1x_uart_device = { | 
					
						
							|  |  |  | 	.name		= "serial8250", | 
					
						
							|  |  |  | 	.id		= PLAT8250_DEV_PLATFORM, | 
					
						
							|  |  |  | 	.dev		= { | 
					
						
							|  |  |  | 		.platform_data = ls1x_serial8250_port, | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-23 05:17:01 +00:00
										 |  |  | void __init ls1x_serial_setup(struct platform_device *pdev) | 
					
						
							| 
									
										
										
										
											2012-07-25 16:17:24 +02:00
										 |  |  | { | 
					
						
							|  |  |  | 	struct clk *clk; | 
					
						
							|  |  |  | 	struct plat_serial8250_port *p; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-23 05:17:01 +00:00
										 |  |  | 	clk = clk_get(NULL, pdev->name); | 
					
						
							| 
									
										
										
										
											2012-07-25 16:17:24 +02:00
										 |  |  | 	if (IS_ERR(clk)) | 
					
						
							| 
									
										
										
										
											2012-10-23 05:17:01 +00:00
										 |  |  | 		panic("unable to get %s clock, err=%ld", | 
					
						
							|  |  |  | 			pdev->name, PTR_ERR(clk)); | 
					
						
							| 
									
										
										
										
											2012-07-25 16:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-23 05:17:01 +00:00
										 |  |  | 	for (p = pdev->dev.platform_data; p->flags != 0; ++p) | 
					
						
							| 
									
										
										
										
											2012-07-25 16:17:24 +02:00
										 |  |  | 		p->uartclk = clk_get_rate(clk); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* Synopsys Ethernet GMAC */ | 
					
						
							|  |  |  | static struct resource ls1x_eth0_resources[] = { | 
					
						
							|  |  |  | 	[0] = { | 
					
						
							|  |  |  | 		.start	= LS1X_GMAC0_BASE, | 
					
						
							|  |  |  | 		.end	= LS1X_GMAC0_BASE + SZ_64K - 1, | 
					
						
							|  |  |  | 		.flags	= IORESOURCE_MEM, | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 	[1] = { | 
					
						
							|  |  |  | 		.name	= "macirq", | 
					
						
							|  |  |  | 		.start	= LS1X_GMAC0_IRQ, | 
					
						
							|  |  |  | 		.flags	= IORESOURCE_IRQ, | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static struct stmmac_mdio_bus_data ls1x_mdio_bus_data = { | 
					
						
							|  |  |  | 	.phy_mask	= 0, | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static struct plat_stmmacenet_data ls1x_eth_data = { | 
					
						
							|  |  |  | 	.bus_id		= 0, | 
					
						
							|  |  |  | 	.phy_addr	= -1, | 
					
						
							|  |  |  | 	.mdio_bus_data	= &ls1x_mdio_bus_data, | 
					
						
							|  |  |  | 	.has_gmac	= 1, | 
					
						
							|  |  |  | 	.tx_coe		= 1, | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | struct platform_device ls1x_eth0_device = { | 
					
						
							|  |  |  | 	.name		= "stmmaceth", | 
					
						
							|  |  |  | 	.id		= 0, | 
					
						
							|  |  |  | 	.num_resources	= ARRAY_SIZE(ls1x_eth0_resources), | 
					
						
							|  |  |  | 	.resource	= ls1x_eth0_resources, | 
					
						
							|  |  |  | 	.dev		= { | 
					
						
							|  |  |  | 		.platform_data = &ls1x_eth_data, | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* USB EHCI */ | 
					
						
							|  |  |  | static u64 ls1x_ehci_dmamask = DMA_BIT_MASK(32); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static struct resource ls1x_ehci_resources[] = { | 
					
						
							|  |  |  | 	[0] = { | 
					
						
							|  |  |  | 		.start	= LS1X_EHCI_BASE, | 
					
						
							|  |  |  | 		.end	= LS1X_EHCI_BASE + SZ_32K - 1, | 
					
						
							|  |  |  | 		.flags	= IORESOURCE_MEM, | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 	[1] = { | 
					
						
							|  |  |  | 		.start	= LS1X_EHCI_IRQ, | 
					
						
							|  |  |  | 		.flags	= IORESOURCE_IRQ, | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-08 15:11:17 +02:00
										 |  |  | static struct usb_ehci_pdata ls1x_ehci_pdata = { | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-07-25 16:17:24 +02:00
										 |  |  | struct platform_device ls1x_ehci_device = { | 
					
						
							| 
									
										
										
										
											2012-10-08 15:11:17 +02:00
										 |  |  | 	.name		= "ehci-platform", | 
					
						
							| 
									
										
										
										
											2012-07-25 16:17:24 +02:00
										 |  |  | 	.id		= -1, | 
					
						
							|  |  |  | 	.num_resources	= ARRAY_SIZE(ls1x_ehci_resources), | 
					
						
							|  |  |  | 	.resource	= ls1x_ehci_resources, | 
					
						
							|  |  |  | 	.dev		= { | 
					
						
							|  |  |  | 		.dma_mask = &ls1x_ehci_dmamask, | 
					
						
							| 
									
										
										
										
											2012-10-08 15:11:17 +02:00
										 |  |  | 		.platform_data = &ls1x_ehci_pdata, | 
					
						
							| 
									
										
										
										
											2012-07-25 16:17:24 +02:00
										 |  |  | 	}, | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* Real Time Clock */ | 
					
						
							|  |  |  | struct platform_device ls1x_rtc_device = { | 
					
						
							|  |  |  | 	.name		= "ls1x-rtc", | 
					
						
							|  |  |  | 	.id		= -1, | 
					
						
							|  |  |  | }; |