1 /*
2  * Renesas Technology Europe RSK+ 7203 Support.
3  *
4  * Copyright (C) 2008 Paul Mundt
5  *
6  * This file is subject to the terms and conditions of the GNU General Public
7  * License.  See the file "COPYING" in the main directory of this archive
8  * for more details.
9  */
10 #include <linux/init.h>
11 #include <linux/types.h>
12 #include <linux/platform_device.h>
13 #include <linux/interrupt.h>
14 #include <linux/mtd/mtd.h>
15 #include <linux/mtd/partitions.h>
16 #include <linux/mtd/physmap.h>
17 #include <linux/mtd/map.h>
18 #include <linux/smsc911x.h>
19 #include <linux/gpio.h>
20 #include <linux/leds.h>
21 #include <asm/machvec.h>
22 #include <asm/io.h>
23 #include <cpu/sh7203.h>
24 
25 static struct smsc911x_platform_config smsc911x_config = {
26 	.phy_interface	= PHY_INTERFACE_MODE_MII,
27 	.irq_polarity	= SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
28 	.irq_type	= SMSC911X_IRQ_TYPE_OPEN_DRAIN,
29 	.flags		= SMSC911X_USE_32BIT | SMSC911X_SWAP_FIFO,
30 };
31 
32 static struct resource smsc911x_resources[] = {
33 	[0] = {
34 		.start		= 0x24000000,
35 		.end		= 0x240000ff,
36 		.flags		= IORESOURCE_MEM,
37 	},
38 	[1] = {
39 		.start		= 64,
40 		.end		= 64,
41 		.flags		= IORESOURCE_IRQ,
42 	},
43 };
44 
45 static struct platform_device smsc911x_device = {
46 	.name		= "smsc911x",
47 	.id		= -1,
48 	.num_resources	= ARRAY_SIZE(smsc911x_resources),
49 	.resource	= smsc911x_resources,
50 	.dev		= {
51 		.platform_data = &smsc911x_config,
52 	},
53 };
54 
55 static struct gpio_led rsk7203_gpio_leds[] = {
56 	{
57 		.name			= "green",
58 		.gpio			= GPIO_PE10,
59 		.active_low		= 1,
60 	}, {
61 		.name			= "orange",
62 		.default_trigger	= "nand-disk",
63 		.gpio			= GPIO_PE12,
64 		.active_low		= 1,
65 	}, {
66 		.name			= "red:timer",
67 		.default_trigger	= "timer",
68 		.gpio			= GPIO_PC14,
69 		.active_low		= 1,
70 	}, {
71 		.name			= "red:heartbeat",
72 		.default_trigger	= "heartbeat",
73 		.gpio			= GPIO_PE11,
74 		.active_low		= 1,
75 	},
76 };
77 
78 static struct gpio_led_platform_data rsk7203_gpio_leds_info = {
79 	.leds		= rsk7203_gpio_leds,
80 	.num_leds	= ARRAY_SIZE(rsk7203_gpio_leds),
81 };
82 
83 static struct platform_device led_device = {
84 	.name		= "leds-gpio",
85 	.id		= -1,
86 	.dev		= {
87 		.platform_data	= &rsk7203_gpio_leds_info,
88 	},
89 };
90 
91 static struct platform_device *rsk7203_devices[] __initdata = {
92 	&smsc911x_device,
93 	&led_device,
94 };
95 
96 static int __init rsk7203_devices_setup(void)
97 {
98 	/* Select pins for SCIF0 */
99 	gpio_request(GPIO_FN_TXD0, NULL);
100 	gpio_request(GPIO_FN_RXD0, NULL);
101 
102 	/* Setup LAN9118: CS1 in 16-bit Big Endian Mode, IRQ0 at Port B */
103 	ctrl_outl(0x36db0400, 0xfffc0008); /* CS1BCR */
104 	gpio_request(GPIO_FN_IRQ0_PB, NULL);
105 
106 	return platform_add_devices(rsk7203_devices,
107 				    ARRAY_SIZE(rsk7203_devices));
108 }
109 device_initcall(rsk7203_devices_setup);
110