blob: a8089f79d0580d5d0725e07c9193e1fa7c8d996c [file] [log] [blame]
Paul Mundtea0aac12008-12-08 14:32:03 +09001/*
2 * Renesas Technology Europe RSK+ 7203 Support.
3 *
Paul Mundt852af592010-12-13 15:33:16 +09004 * Copyright (C) 2008 - 2010 Paul Mundt
Paul Mundtea0aac12008-12-08 14:32:03 +09005 *
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>
Steve Glendinning8ed35922009-01-07 17:22:24 +090014#include <linux/smsc911x.h>
Paul Mundt852af592010-12-13 15:33:16 +090015#include <linux/input.h>
Paul Mundtea0aac12008-12-08 14:32:03 +090016#include <linux/gpio.h>
Paul Mundt852af592010-12-13 15:33:16 +090017#include <linux/gpio_keys.h>
Paul Mundtea0aac12008-12-08 14:32:03 +090018#include <linux/leds.h>
19#include <asm/machvec.h>
20#include <asm/io.h>
21#include <cpu/sh7203.h>
22
Steve Glendinning8ed35922009-01-07 17:22:24 +090023static struct smsc911x_platform_config smsc911x_config = {
24 .phy_interface = PHY_INTERFACE_MODE_MII,
25 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
26 .irq_type = SMSC911X_IRQ_TYPE_OPEN_DRAIN,
Magnus Damm724cfb92009-04-28 08:02:13 +000027 .flags = SMSC911X_USE_32BIT | SMSC911X_SWAP_FIFO,
Paul Mundtea0aac12008-12-08 14:32:03 +090028};
29
Steve Glendinning8ed35922009-01-07 17:22:24 +090030static struct resource smsc911x_resources[] = {
Paul Mundtea0aac12008-12-08 14:32:03 +090031 [0] = {
32 .start = 0x24000000,
Magnus Damm724cfb92009-04-28 08:02:13 +000033 .end = 0x240000ff,
Paul Mundtea0aac12008-12-08 14:32:03 +090034 .flags = IORESOURCE_MEM,
35 },
36 [1] = {
37 .start = 64,
38 .end = 64,
39 .flags = IORESOURCE_IRQ,
40 },
41};
42
Steve Glendinning8ed35922009-01-07 17:22:24 +090043static struct platform_device smsc911x_device = {
44 .name = "smsc911x",
Paul Mundtea0aac12008-12-08 14:32:03 +090045 .id = -1,
Steve Glendinning8ed35922009-01-07 17:22:24 +090046 .num_resources = ARRAY_SIZE(smsc911x_resources),
47 .resource = smsc911x_resources,
Paul Mundtea0aac12008-12-08 14:32:03 +090048 .dev = {
Steve Glendinning8ed35922009-01-07 17:22:24 +090049 .platform_data = &smsc911x_config,
Paul Mundtea0aac12008-12-08 14:32:03 +090050 },
51};
52
53static struct gpio_led rsk7203_gpio_leds[] = {
54 {
55 .name = "green",
56 .gpio = GPIO_PE10,
57 .active_low = 1,
58 }, {
59 .name = "orange",
60 .default_trigger = "nand-disk",
61 .gpio = GPIO_PE12,
62 .active_low = 1,
63 }, {
64 .name = "red:timer",
65 .default_trigger = "timer",
66 .gpio = GPIO_PC14,
67 .active_low = 1,
68 }, {
69 .name = "red:heartbeat",
70 .default_trigger = "heartbeat",
71 .gpio = GPIO_PE11,
72 .active_low = 1,
73 },
74};
75
76static struct gpio_led_platform_data rsk7203_gpio_leds_info = {
77 .leds = rsk7203_gpio_leds,
78 .num_leds = ARRAY_SIZE(rsk7203_gpio_leds),
79};
80
81static struct platform_device led_device = {
82 .name = "leds-gpio",
83 .id = -1,
84 .dev = {
85 .platform_data = &rsk7203_gpio_leds_info,
86 },
87};
88
Paul Mundt852af592010-12-13 15:33:16 +090089static struct gpio_keys_button rsk7203_gpio_keys_table[] = {
90 {
91 .code = BTN_0,
92 .gpio = GPIO_PB0,
93 .active_low = 1,
94 .desc = "SW1",
95 }, {
96 .code = BTN_1,
97 .gpio = GPIO_PB1,
98 .active_low = 1,
99 .desc = "SW2",
100 }, {
101 .code = BTN_2,
102 .gpio = GPIO_PB2,
103 .active_low = 1,
104 .desc = "SW3",
105 },
106};
107
108static struct gpio_keys_platform_data rsk7203_gpio_keys_info = {
109 .buttons = rsk7203_gpio_keys_table,
110 .nbuttons = ARRAY_SIZE(rsk7203_gpio_keys_table),
111 .poll_interval = 50, /* default to 50ms */
112};
113
114static struct platform_device keys_device = {
115 .name = "gpio-keys-polled",
116 .dev = {
117 .platform_data = &rsk7203_gpio_keys_info,
118 },
119};
120
Paul Mundtea0aac12008-12-08 14:32:03 +0900121static struct platform_device *rsk7203_devices[] __initdata = {
Steve Glendinning8ed35922009-01-07 17:22:24 +0900122 &smsc911x_device,
Paul Mundtea0aac12008-12-08 14:32:03 +0900123 &led_device,
Paul Mundt852af592010-12-13 15:33:16 +0900124 &keys_device,
Paul Mundtea0aac12008-12-08 14:32:03 +0900125};
126
127static int __init rsk7203_devices_setup(void)
128{
129 /* Select pins for SCIF0 */
130 gpio_request(GPIO_FN_TXD0, NULL);
131 gpio_request(GPIO_FN_RXD0, NULL);
132
Magnus Damm724cfb92009-04-28 08:02:13 +0000133 /* Setup LAN9118: CS1 in 16-bit Big Endian Mode, IRQ0 at Port B */
Paul Mundt9d56dd32010-01-26 12:58:40 +0900134 __raw_writel(0x36db0400, 0xfffc0008); /* CS1BCR */
Magnus Damm724cfb92009-04-28 08:02:13 +0000135 gpio_request(GPIO_FN_IRQ0_PB, NULL);
136
Paul Mundtea0aac12008-12-08 14:32:03 +0900137 return platform_add_devices(rsk7203_devices,
138 ARRAY_SIZE(rsk7203_devices));
139}
140device_initcall(rsk7203_devices_setup);