Linux Audio

Check our new training course

Loading...
v3.15
 1/*
 2 * This file is subject to the terms and conditions of the GNU General Public
 3 * License.  See the file "COPYING" in the main directory of this archive
 4 * for more details.
 5 *
 6 * Copyright (C) 2012 MIPS Technologies, Inc.  All rights reserved.
 7 */
 8#include <linux/module.h>
 9#include <linux/init.h>
 
 
 
 
 
10#include <linux/serial_8250.h>
 
11
12#define UART(base, int)							\
 
 
13{									\
14	.mapbase	= base,						\
15	.irq		= int,						\
16	.uartclk	= 14745600,					\
17	.iotype		= UPIO_MEM32,					\
18	.flags		= UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_IOREMAP, \
19	.regshift	= 2,						\
20}
21
22static struct plat_serial8250_port uart8250_data[] = {
23	UART(0x1f000900, MIPS_CPU_IRQ_BASE + 4),   /* ttyS0 = USB   */
24	UART(0x1f000800, MIPS_CPU_IRQ_BASE + 4),   /* ttyS1 = RS232 */
25	{ },
26};
27
28static struct platform_device uart8250_device = {
29	.name			= "serial8250",
30	.id			= PLAT8250_DEV_PLATFORM2,
31	.dev			= {
32		.platform_data	= uart8250_data,
33	},
34};
35
36static int __init uart8250_init(void)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37{
38	return platform_device_register(&uart8250_device);
39}
 
 
 
 
 
 
 
 
 
40
41module_init(uart8250_init);
 
 
42
43MODULE_AUTHOR("Chris Dearman <chris@mips.com>");
44MODULE_LICENSE("GPL");
45MODULE_DESCRIPTION("8250 UART probe driver for SEAD3");
v4.6
  1/*
  2 * This file is subject to the terms and conditions of the GNU General Public
  3 * License.  See the file "COPYING" in the main directory of this archive
  4 * for more details.
  5 *
  6 * Copyright (C) 2012 MIPS Technologies, Inc.  All rights reserved.
  7 */
  8#include <linux/dma-mapping.h>
  9#include <linux/init.h>
 10#include <linux/irq.h>
 11#include <linux/irqchip/mips-gic.h>
 12#include <linux/leds.h>
 13#include <linux/mtd/physmap.h>
 14#include <linux/platform_device.h>
 15#include <linux/serial_8250.h>
 16#include <linux/smsc911x.h>
 17
 18#include <asm/mips-boards/sead3int.h>
 19
 20#define UART(base)							\
 21{									\
 22	.mapbase	= base,						\
 23	.irq		= -1,						\
 24	.uartclk	= 14745600,					\
 25	.iotype		= UPIO_MEM32,					\
 26	.flags		= UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_IOREMAP, \
 27	.regshift	= 2,						\
 28}
 29
 30static struct plat_serial8250_port uart8250_data[] = {
 31	UART(0x1f000900),   /* ttyS0 = USB   */
 32	UART(0x1f000800),   /* ttyS1 = RS232 */
 33	{ },
 34};
 35
 36static struct platform_device uart8250_device = {
 37	.name			= "serial8250",
 38	.id			= PLAT8250_DEV_PLATFORM2,
 39	.dev			= {
 40		.platform_data	= uart8250_data,
 41	},
 42};
 43
 44static struct smsc911x_platform_config sead3_smsc911x_data = {
 45	.irq_polarity	= SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
 46	.irq_type	= SMSC911X_IRQ_TYPE_PUSH_PULL,
 47	.flags		= SMSC911X_USE_32BIT | SMSC911X_SAVE_MAC_ADDRESS,
 48	.phy_interface	= PHY_INTERFACE_MODE_MII,
 49};
 50
 51static struct resource sead3_net_resources[] = {
 52	{
 53		.start			= 0x1f010000,
 54		.end			= 0x1f01ffff,
 55		.flags			= IORESOURCE_MEM
 56	}, {
 57		.flags			= IORESOURCE_IRQ
 58	}
 59};
 60
 61static struct platform_device sead3_net_device = {
 62	.name			= "smsc911x",
 63	.id			= 0,
 64	.dev			= {
 65		.platform_data	= &sead3_smsc911x_data,
 66	},
 67	.num_resources		= ARRAY_SIZE(sead3_net_resources),
 68	.resource		= sead3_net_resources
 69};
 70
 71static struct mtd_partition sead3_mtd_partitions[] = {
 72	{
 73		.name =		"User FS",
 74		.offset =	0x00000000,
 75		.size =		0x01fc0000,
 76	}, {
 77		.name =		"Board Config",
 78		.offset =	0x01fc0000,
 79		.size =		0x00040000,
 80		.mask_flags =	MTD_WRITEABLE
 81	},
 82};
 83
 84static struct physmap_flash_data sead3_flash_data = {
 85	.width		= 4,
 86	.nr_parts	= ARRAY_SIZE(sead3_mtd_partitions),
 87	.parts		= sead3_mtd_partitions
 88};
 89
 90static struct resource sead3_flash_resource = {
 91	.start		= 0x1c000000,
 92	.end		= 0x1dffffff,
 93	.flags		= IORESOURCE_MEM
 94};
 95
 96static struct platform_device sead3_flash = {
 97	.name		= "physmap-flash",
 98	.id		= 0,
 99	.dev		= {
100		.platform_data	= &sead3_flash_data,
101	},
102	.num_resources	= 1,
103	.resource	= &sead3_flash_resource,
104};
105
106#define LEDFLAGS(bits, shift)		\
107	((bits << 8) | (shift << 8))
108
109#define LEDBITS(id, shift, bits)	\
110	.name = id #shift,		\
111	.flags = LEDFLAGS(bits, shift)
112
113static struct led_info led_data_info[] = {
114	{ LEDBITS("bit", 0, 1) },
115	{ LEDBITS("bit", 1, 1) },
116	{ LEDBITS("bit", 2, 1) },
117	{ LEDBITS("bit", 3, 1) },
118	{ LEDBITS("bit", 4, 1) },
119	{ LEDBITS("bit", 5, 1) },
120	{ LEDBITS("bit", 6, 1) },
121	{ LEDBITS("bit", 7, 1) },
122	{ LEDBITS("all", 0, 8) },
123};
124
125static struct led_platform_data led_data = {
126	.num_leds	= ARRAY_SIZE(led_data_info),
127	.leds		= led_data_info
128};
129
130static struct resource pled_resources[] = {
131	{
132		.start	= 0x1f000210,
133		.end	= 0x1f000217,
134		.flags	= IORESOURCE_MEM
135	}
136};
137
138static struct platform_device pled_device = {
139	.name			= "sead3::pled",
140	.id			= 0,
141	.dev			= {
142		.platform_data	= &led_data,
143	},
144	.num_resources		= ARRAY_SIZE(pled_resources),
145	.resource		= pled_resources
146};
147
148
149static struct resource fled_resources[] = {
150	{
151		.start			= 0x1f000218,
152		.end			= 0x1f00021f,
153		.flags			= IORESOURCE_MEM
154	}
155};
156
157static struct platform_device fled_device = {
158	.name			= "sead3::fled",
159	.id			= 0,
160	.dev			= {
161		.platform_data	= &led_data,
162	},
163	.num_resources		= ARRAY_SIZE(fled_resources),
164	.resource		= fled_resources
165};
166
167static struct platform_device sead3_led_device = {
168        .name   = "sead3-led",
169        .id     = -1,
170};
171
172static struct resource ehci_resources[] = {
173	{
174		.start			= 0x1b200000,
175		.end			= 0x1b200fff,
176		.flags			= IORESOURCE_MEM
177	}, {
178		.flags			= IORESOURCE_IRQ
179	}
180};
181
182static u64 sead3_usbdev_dma_mask = DMA_BIT_MASK(32);
183
184static struct platform_device ehci_device = {
185	.name		= "sead3-ehci",
186	.id		= 0,
187	.dev		= {
188		.dma_mask		= &sead3_usbdev_dma_mask,
189		.coherent_dma_mask	= DMA_BIT_MASK(32)
190	},
191	.num_resources	= ARRAY_SIZE(ehci_resources),
192	.resource	= ehci_resources
193};
194
195static struct platform_device *sead3_platform_devices[] __initdata = {
196	&uart8250_device,
197	&sead3_flash,
198	&pled_device,
199	&fled_device,
200	&sead3_led_device,
201	&ehci_device,
202	&sead3_net_device,
203};
204
205static int __init sead3_platforms_device_init(void)
206{
207	if (gic_present) {
208		uart8250_data[0].irq = MIPS_GIC_IRQ_BASE + GIC_INT_UART0;
209		uart8250_data[1].irq = MIPS_GIC_IRQ_BASE + GIC_INT_UART1;
210		ehci_resources[1].start = MIPS_GIC_IRQ_BASE + GIC_INT_EHCI;
211		sead3_net_resources[1].start = MIPS_GIC_IRQ_BASE + GIC_INT_NET;
212	} else {
213		uart8250_data[0].irq = MIPS_CPU_IRQ_BASE + CPU_INT_UART0;
214		uart8250_data[1].irq = MIPS_CPU_IRQ_BASE + CPU_INT_UART1;
215		ehci_resources[1].start = MIPS_CPU_IRQ_BASE + CPU_INT_EHCI;
216		sead3_net_resources[1].start = MIPS_CPU_IRQ_BASE + CPU_INT_NET;
217	}
218
219	return platform_add_devices(sead3_platform_devices,
220				    ARRAY_SIZE(sead3_platform_devices));
221}
222
223device_initcall(sead3_platforms_device_init);