1aaf9128aSKuninori Morimoto // SPDX-License-Identifier: GPL-2.0
2ea0aac1eSPaul Mundt /*
3ea0aac1eSPaul Mundt  * Renesas Technology Europe RSK+ 7203 Support.
4ea0aac1eSPaul Mundt  *
5852af59fSPaul Mundt  * Copyright (C) 2008 - 2010  Paul Mundt
6ea0aac1eSPaul Mundt  */
7ea0aac1eSPaul Mundt #include <linux/init.h>
8ea0aac1eSPaul Mundt #include <linux/types.h>
9ea0aac1eSPaul Mundt #include <linux/platform_device.h>
10ea0aac1eSPaul Mundt #include <linux/interrupt.h>
118ed3592eSSteve Glendinning #include <linux/smsc911x.h>
12852af59fSPaul Mundt #include <linux/input.h>
13ea0aac1eSPaul Mundt #include <linux/gpio.h>
14852af59fSPaul Mundt #include <linux/gpio_keys.h>
15ea0aac1eSPaul Mundt #include <linux/leds.h>
16ea0aac1eSPaul Mundt #include <asm/machvec.h>
17ea0aac1eSPaul Mundt #include <asm/io.h>
18ea0aac1eSPaul Mundt #include <cpu/sh7203.h>
19ea0aac1eSPaul Mundt 
208ed3592eSSteve Glendinning static struct smsc911x_platform_config smsc911x_config = {
218ed3592eSSteve Glendinning 	.phy_interface	= PHY_INTERFACE_MODE_MII,
228ed3592eSSteve Glendinning 	.irq_polarity	= SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
238ed3592eSSteve Glendinning 	.irq_type	= SMSC911X_IRQ_TYPE_OPEN_DRAIN,
24724cfb94SMagnus Damm 	.flags		= SMSC911X_USE_32BIT | SMSC911X_SWAP_FIFO,
25ea0aac1eSPaul Mundt };
26ea0aac1eSPaul Mundt 
278ed3592eSSteve Glendinning static struct resource smsc911x_resources[] = {
28ea0aac1eSPaul Mundt 	[0] = {
29ea0aac1eSPaul Mundt 		.start		= 0x24000000,
30724cfb94SMagnus Damm 		.end		= 0x240000ff,
31ea0aac1eSPaul Mundt 		.flags		= IORESOURCE_MEM,
32ea0aac1eSPaul Mundt 	},
33ea0aac1eSPaul Mundt 	[1] = {
34ea0aac1eSPaul Mundt 		.start		= 64,
35ea0aac1eSPaul Mundt 		.end		= 64,
36ea0aac1eSPaul Mundt 		.flags		= IORESOURCE_IRQ,
37ea0aac1eSPaul Mundt 	},
38ea0aac1eSPaul Mundt };
39ea0aac1eSPaul Mundt 
408ed3592eSSteve Glendinning static struct platform_device smsc911x_device = {
418ed3592eSSteve Glendinning 	.name		= "smsc911x",
42ea0aac1eSPaul Mundt 	.id		= -1,
438ed3592eSSteve Glendinning 	.num_resources	= ARRAY_SIZE(smsc911x_resources),
448ed3592eSSteve Glendinning 	.resource	= smsc911x_resources,
45ea0aac1eSPaul Mundt 	.dev		= {
468ed3592eSSteve Glendinning 		.platform_data = &smsc911x_config,
47ea0aac1eSPaul Mundt 	},
48ea0aac1eSPaul Mundt };
49ea0aac1eSPaul Mundt 
50ea0aac1eSPaul Mundt static struct gpio_led rsk7203_gpio_leds[] = {
51ea0aac1eSPaul Mundt 	{
52ea0aac1eSPaul Mundt 		.name			= "green",
53ea0aac1eSPaul Mundt 		.gpio			= GPIO_PE10,
54ea0aac1eSPaul Mundt 		.active_low		= 1,
55ea0aac1eSPaul Mundt 	}, {
56ea0aac1eSPaul Mundt 		.name			= "orange",
57ea0aac1eSPaul Mundt 		.default_trigger	= "nand-disk",
58ea0aac1eSPaul Mundt 		.gpio			= GPIO_PE12,
59ea0aac1eSPaul Mundt 		.active_low		= 1,
60ea0aac1eSPaul Mundt 	}, {
61ea0aac1eSPaul Mundt 		.name			= "red:timer",
62ea0aac1eSPaul Mundt 		.default_trigger	= "timer",
63ea0aac1eSPaul Mundt 		.gpio			= GPIO_PC14,
64ea0aac1eSPaul Mundt 		.active_low		= 1,
65ea0aac1eSPaul Mundt 	}, {
66ea0aac1eSPaul Mundt 		.name			= "red:heartbeat",
67ea0aac1eSPaul Mundt 		.default_trigger	= "heartbeat",
68ea0aac1eSPaul Mundt 		.gpio			= GPIO_PE11,
69ea0aac1eSPaul Mundt 		.active_low		= 1,
70ea0aac1eSPaul Mundt 	},
71ea0aac1eSPaul Mundt };
72ea0aac1eSPaul Mundt 
73ea0aac1eSPaul Mundt static struct gpio_led_platform_data rsk7203_gpio_leds_info = {
74ea0aac1eSPaul Mundt 	.leds		= rsk7203_gpio_leds,
75ea0aac1eSPaul Mundt 	.num_leds	= ARRAY_SIZE(rsk7203_gpio_leds),
76ea0aac1eSPaul Mundt };
77ea0aac1eSPaul Mundt 
78ea0aac1eSPaul Mundt static struct platform_device led_device = {
79ea0aac1eSPaul Mundt 	.name		= "leds-gpio",
80ea0aac1eSPaul Mundt 	.id		= -1,
81ea0aac1eSPaul Mundt 	.dev		= {
82ea0aac1eSPaul Mundt 		.platform_data	= &rsk7203_gpio_leds_info,
83ea0aac1eSPaul Mundt 	},
84ea0aac1eSPaul Mundt };
85ea0aac1eSPaul Mundt 
86852af59fSPaul Mundt static struct gpio_keys_button rsk7203_gpio_keys_table[] = {
87852af59fSPaul Mundt 	{
88852af59fSPaul Mundt 		.code		= BTN_0,
89852af59fSPaul Mundt 		.gpio		= GPIO_PB0,
90852af59fSPaul Mundt 		.active_low	= 1,
91852af59fSPaul Mundt 		.desc		= "SW1",
92852af59fSPaul Mundt 	}, {
93852af59fSPaul Mundt 		.code		= BTN_1,
94852af59fSPaul Mundt 		.gpio		= GPIO_PB1,
95852af59fSPaul Mundt 		.active_low	= 1,
96852af59fSPaul Mundt 		.desc		= "SW2",
97852af59fSPaul Mundt 	}, {
98852af59fSPaul Mundt 		.code		= BTN_2,
99852af59fSPaul Mundt 		.gpio		= GPIO_PB2,
100852af59fSPaul Mundt 		.active_low	= 1,
101852af59fSPaul Mundt 		.desc		= "SW3",
102852af59fSPaul Mundt 	},
103852af59fSPaul Mundt };
104852af59fSPaul Mundt 
105852af59fSPaul Mundt static struct gpio_keys_platform_data rsk7203_gpio_keys_info = {
106852af59fSPaul Mundt 	.buttons	= rsk7203_gpio_keys_table,
107852af59fSPaul Mundt 	.nbuttons	= ARRAY_SIZE(rsk7203_gpio_keys_table),
108852af59fSPaul Mundt 	.poll_interval	= 50, /* default to 50ms */
109852af59fSPaul Mundt };
110852af59fSPaul Mundt 
111852af59fSPaul Mundt static struct platform_device keys_device = {
112852af59fSPaul Mundt 	.name		= "gpio-keys-polled",
113852af59fSPaul Mundt 	.dev		= {
114852af59fSPaul Mundt 		.platform_data	= &rsk7203_gpio_keys_info,
115852af59fSPaul Mundt 	},
116852af59fSPaul Mundt };
117852af59fSPaul Mundt 
118ea0aac1eSPaul Mundt static struct platform_device *rsk7203_devices[] __initdata = {
1198ed3592eSSteve Glendinning 	&smsc911x_device,
120ea0aac1eSPaul Mundt 	&led_device,
121852af59fSPaul Mundt 	&keys_device,
122ea0aac1eSPaul Mundt };
123ea0aac1eSPaul Mundt 
rsk7203_devices_setup(void)124ea0aac1eSPaul Mundt static int __init rsk7203_devices_setup(void)
125ea0aac1eSPaul Mundt {
126ea0aac1eSPaul Mundt 	/* Select pins for SCIF0 */
127ea0aac1eSPaul Mundt 	gpio_request(GPIO_FN_TXD0, NULL);
128ea0aac1eSPaul Mundt 	gpio_request(GPIO_FN_RXD0, NULL);
129ea0aac1eSPaul Mundt 
130724cfb94SMagnus Damm 	/* Setup LAN9118: CS1 in 16-bit Big Endian Mode, IRQ0 at Port B */
1319d56dd3bSPaul Mundt 	__raw_writel(0x36db0400, 0xfffc0008); /* CS1BCR */
132724cfb94SMagnus Damm 	gpio_request(GPIO_FN_IRQ0_PB, NULL);
133724cfb94SMagnus Damm 
134ea0aac1eSPaul Mundt 	return platform_add_devices(rsk7203_devices,
135ea0aac1eSPaul Mundt 				    ARRAY_SIZE(rsk7203_devices));
136ea0aac1eSPaul Mundt }
137ea0aac1eSPaul Mundt device_initcall(rsk7203_devices_setup);
138