1ea0aac1eSPaul Mundt /*
2ea0aac1eSPaul Mundt  * Renesas Technology Europe RSK+ 7203 Support.
3ea0aac1eSPaul Mundt  *
4852af59fSPaul Mundt  * Copyright (C) 2008 - 2010  Paul Mundt
5ea0aac1eSPaul Mundt  *
6ea0aac1eSPaul Mundt  * This file is subject to the terms and conditions of the GNU General Public
7ea0aac1eSPaul Mundt  * License.  See the file "COPYING" in the main directory of this archive
8ea0aac1eSPaul Mundt  * for more details.
9ea0aac1eSPaul Mundt  */
10ea0aac1eSPaul Mundt #include <linux/init.h>
11ea0aac1eSPaul Mundt #include <linux/types.h>
12ea0aac1eSPaul Mundt #include <linux/platform_device.h>
13ea0aac1eSPaul Mundt #include <linux/interrupt.h>
148ed3592eSSteve Glendinning #include <linux/smsc911x.h>
15852af59fSPaul Mundt #include <linux/input.h>
16ea0aac1eSPaul Mundt #include <linux/gpio.h>
17852af59fSPaul Mundt #include <linux/gpio_keys.h>
18ea0aac1eSPaul Mundt #include <linux/leds.h>
19ea0aac1eSPaul Mundt #include <asm/machvec.h>
20ea0aac1eSPaul Mundt #include <asm/io.h>
21ea0aac1eSPaul Mundt #include <cpu/sh7203.h>
22ea0aac1eSPaul Mundt 
238ed3592eSSteve Glendinning static struct smsc911x_platform_config smsc911x_config = {
248ed3592eSSteve Glendinning 	.phy_interface	= PHY_INTERFACE_MODE_MII,
258ed3592eSSteve Glendinning 	.irq_polarity	= SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
268ed3592eSSteve Glendinning 	.irq_type	= SMSC911X_IRQ_TYPE_OPEN_DRAIN,
27724cfb94SMagnus Damm 	.flags		= SMSC911X_USE_32BIT | SMSC911X_SWAP_FIFO,
28ea0aac1eSPaul Mundt };
29ea0aac1eSPaul Mundt 
308ed3592eSSteve Glendinning static struct resource smsc911x_resources[] = {
31ea0aac1eSPaul Mundt 	[0] = {
32ea0aac1eSPaul Mundt 		.start		= 0x24000000,
33724cfb94SMagnus Damm 		.end		= 0x240000ff,
34ea0aac1eSPaul Mundt 		.flags		= IORESOURCE_MEM,
35ea0aac1eSPaul Mundt 	},
36ea0aac1eSPaul Mundt 	[1] = {
37ea0aac1eSPaul Mundt 		.start		= 64,
38ea0aac1eSPaul Mundt 		.end		= 64,
39ea0aac1eSPaul Mundt 		.flags		= IORESOURCE_IRQ,
40ea0aac1eSPaul Mundt 	},
41ea0aac1eSPaul Mundt };
42ea0aac1eSPaul Mundt 
438ed3592eSSteve Glendinning static struct platform_device smsc911x_device = {
448ed3592eSSteve Glendinning 	.name		= "smsc911x",
45ea0aac1eSPaul Mundt 	.id		= -1,
468ed3592eSSteve Glendinning 	.num_resources	= ARRAY_SIZE(smsc911x_resources),
478ed3592eSSteve Glendinning 	.resource	= smsc911x_resources,
48ea0aac1eSPaul Mundt 	.dev		= {
498ed3592eSSteve Glendinning 		.platform_data = &smsc911x_config,
50ea0aac1eSPaul Mundt 	},
51ea0aac1eSPaul Mundt };
52ea0aac1eSPaul Mundt 
53ea0aac1eSPaul Mundt static struct gpio_led rsk7203_gpio_leds[] = {
54ea0aac1eSPaul Mundt 	{
55ea0aac1eSPaul Mundt 		.name			= "green",
56ea0aac1eSPaul Mundt 		.gpio			= GPIO_PE10,
57ea0aac1eSPaul Mundt 		.active_low		= 1,
58ea0aac1eSPaul Mundt 	}, {
59ea0aac1eSPaul Mundt 		.name			= "orange",
60ea0aac1eSPaul Mundt 		.default_trigger	= "nand-disk",
61ea0aac1eSPaul Mundt 		.gpio			= GPIO_PE12,
62ea0aac1eSPaul Mundt 		.active_low		= 1,
63ea0aac1eSPaul Mundt 	}, {
64ea0aac1eSPaul Mundt 		.name			= "red:timer",
65ea0aac1eSPaul Mundt 		.default_trigger	= "timer",
66ea0aac1eSPaul Mundt 		.gpio			= GPIO_PC14,
67ea0aac1eSPaul Mundt 		.active_low		= 1,
68ea0aac1eSPaul Mundt 	}, {
69ea0aac1eSPaul Mundt 		.name			= "red:heartbeat",
70ea0aac1eSPaul Mundt 		.default_trigger	= "heartbeat",
71ea0aac1eSPaul Mundt 		.gpio			= GPIO_PE11,
72ea0aac1eSPaul Mundt 		.active_low		= 1,
73ea0aac1eSPaul Mundt 	},
74ea0aac1eSPaul Mundt };
75ea0aac1eSPaul Mundt 
76ea0aac1eSPaul Mundt static struct gpio_led_platform_data rsk7203_gpio_leds_info = {
77ea0aac1eSPaul Mundt 	.leds		= rsk7203_gpio_leds,
78ea0aac1eSPaul Mundt 	.num_leds	= ARRAY_SIZE(rsk7203_gpio_leds),
79ea0aac1eSPaul Mundt };
80ea0aac1eSPaul Mundt 
81ea0aac1eSPaul Mundt static struct platform_device led_device = {
82ea0aac1eSPaul Mundt 	.name		= "leds-gpio",
83ea0aac1eSPaul Mundt 	.id		= -1,
84ea0aac1eSPaul Mundt 	.dev		= {
85ea0aac1eSPaul Mundt 		.platform_data	= &rsk7203_gpio_leds_info,
86ea0aac1eSPaul Mundt 	},
87ea0aac1eSPaul Mundt };
88ea0aac1eSPaul Mundt 
89852af59fSPaul Mundt static struct gpio_keys_button rsk7203_gpio_keys_table[] = {
90852af59fSPaul Mundt 	{
91852af59fSPaul Mundt 		.code		= BTN_0,
92852af59fSPaul Mundt 		.gpio		= GPIO_PB0,
93852af59fSPaul Mundt 		.active_low	= 1,
94852af59fSPaul Mundt 		.desc		= "SW1",
95852af59fSPaul Mundt 	}, {
96852af59fSPaul Mundt 		.code		= BTN_1,
97852af59fSPaul Mundt 		.gpio		= GPIO_PB1,
98852af59fSPaul Mundt 		.active_low	= 1,
99852af59fSPaul Mundt 		.desc		= "SW2",
100852af59fSPaul Mundt 	}, {
101852af59fSPaul Mundt 		.code		= BTN_2,
102852af59fSPaul Mundt 		.gpio		= GPIO_PB2,
103852af59fSPaul Mundt 		.active_low	= 1,
104852af59fSPaul Mundt 		.desc		= "SW3",
105852af59fSPaul Mundt 	},
106852af59fSPaul Mundt };
107852af59fSPaul Mundt 
108852af59fSPaul Mundt static struct gpio_keys_platform_data rsk7203_gpio_keys_info = {
109852af59fSPaul Mundt 	.buttons	= rsk7203_gpio_keys_table,
110852af59fSPaul Mundt 	.nbuttons	= ARRAY_SIZE(rsk7203_gpio_keys_table),
111852af59fSPaul Mundt 	.poll_interval	= 50, /* default to 50ms */
112852af59fSPaul Mundt };
113852af59fSPaul Mundt 
114852af59fSPaul Mundt static struct platform_device keys_device = {
115852af59fSPaul Mundt 	.name		= "gpio-keys-polled",
116852af59fSPaul Mundt 	.dev		= {
117852af59fSPaul Mundt 		.platform_data	= &rsk7203_gpio_keys_info,
118852af59fSPaul Mundt 	},
119852af59fSPaul Mundt };
120852af59fSPaul Mundt 
121ea0aac1eSPaul Mundt static struct platform_device *rsk7203_devices[] __initdata = {
1228ed3592eSSteve Glendinning 	&smsc911x_device,
123ea0aac1eSPaul Mundt 	&led_device,
124852af59fSPaul Mundt 	&keys_device,
125ea0aac1eSPaul Mundt };
126ea0aac1eSPaul Mundt 
127ea0aac1eSPaul Mundt static int __init rsk7203_devices_setup(void)
128ea0aac1eSPaul Mundt {
129ea0aac1eSPaul Mundt 	/* Select pins for SCIF0 */
130ea0aac1eSPaul Mundt 	gpio_request(GPIO_FN_TXD0, NULL);
131ea0aac1eSPaul Mundt 	gpio_request(GPIO_FN_RXD0, NULL);
132ea0aac1eSPaul Mundt 
133724cfb94SMagnus Damm 	/* Setup LAN9118: CS1 in 16-bit Big Endian Mode, IRQ0 at Port B */
1349d56dd3bSPaul Mundt 	__raw_writel(0x36db0400, 0xfffc0008); /* CS1BCR */
135724cfb94SMagnus Damm 	gpio_request(GPIO_FN_IRQ0_PB, NULL);
136724cfb94SMagnus Damm 
137ea0aac1eSPaul Mundt 	return platform_add_devices(rsk7203_devices,
138ea0aac1eSPaul Mundt 				    ARRAY_SIZE(rsk7203_devices));
139ea0aac1eSPaul Mundt }
140ea0aac1eSPaul Mundt device_initcall(rsk7203_devices_setup);
141