blob: 58266f06134ae5a187673e23eb89765a3c171510 [file] [log] [blame]
Paul Mundt3787aa12008-05-19 16:47:56 +09001/*
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>
Paul Mundt6d0b3652008-07-28 22:31:02 +090013#include <linux/interrupt.h>
Paul Mundt3787aa12008-05-19 16:47:56 +090014#include <linux/mtd/mtd.h>
15#include <linux/mtd/partitions.h>
16#include <linux/mtd/physmap.h>
17#include <linux/mtd/map.h>
Paul Mundt6d0b3652008-07-28 22:31:02 +090018#include <linux/smc911x.h>
Magnus Damm7a5c6792008-10-08 20:42:38 +090019#include <linux/gpio.h>
Paul Mundtbbc97412008-10-21 14:27:51 +090020#include <linux/leds.h>
Paul Mundt3787aa12008-05-19 16:47:56 +090021#include <asm/machvec.h>
22#include <asm/io.h>
Paul Mundta51413a2008-10-21 09:52:02 +090023#include <cpu/sh7203.h>
Paul Mundt3787aa12008-05-19 16:47:56 +090024
Paul Mundt6d0b3652008-07-28 22:31:02 +090025static struct smc911x_platdata smc911x_info = {
26 .flags = SMC911X_USE_16BIT,
27 .irq_flags = IRQF_TRIGGER_LOW,
28};
29
Paul Mundt3787aa12008-05-19 16:47:56 +090030static struct resource smc911x_resources[] = {
31 [0] = {
32 .start = 0x24000000,
33 .end = 0x24000000 + 0x100,
34 .flags = IORESOURCE_MEM,
35 },
36 [1] = {
37 .start = 64,
38 .end = 64,
39 .flags = IORESOURCE_IRQ,
40 },
41};
42
43static struct platform_device smc911x_device = {
44 .name = "smc911x",
45 .id = -1,
46 .num_resources = ARRAY_SIZE(smc911x_resources),
47 .resource = smc911x_resources,
Paul Mundt6d0b3652008-07-28 22:31:02 +090048 .dev = {
49 .platform_data = &smc911x_info,
50 },
Paul Mundt3787aa12008-05-19 16:47:56 +090051};
52
53static const char *probes[] = { "cmdlinepart", NULL };
54
55static struct mtd_partition *parsed_partitions;
56
57static struct mtd_partition rsk7203_partitions[] = {
58 {
59 .name = "Bootloader",
60 .offset = 0x00000000,
61 .size = 0x00040000,
62 .mask_flags = MTD_WRITEABLE,
63 }, {
64 .name = "Kernel",
65 .offset = MTDPART_OFS_NXTBLK,
66 .size = 0x001c0000,
67 }, {
68 .name = "Flash_FS",
69 .offset = MTDPART_OFS_NXTBLK,
70 .size = MTDPART_SIZ_FULL,
71 }
72};
73
74static struct physmap_flash_data flash_data = {
75 .width = 2,
76};
77
78static struct resource flash_resource = {
79 .start = 0x20000000,
80 .end = 0x20400000,
81 .flags = IORESOURCE_MEM,
82};
83
84static struct platform_device flash_device = {
85 .name = "physmap-flash",
86 .id = -1,
87 .resource = &flash_resource,
88 .num_resources = 1,
89 .dev = {
90 .platform_data = &flash_data,
91 },
92};
93
94static struct mtd_info *flash_mtd;
95
96static struct map_info rsk7203_flash_map = {
97 .name = "RSK+ Flash",
98 .size = 0x400000,
99 .bankwidth = 2,
100};
101
102static void __init set_mtd_partitions(void)
103{
104 int nr_parts = 0;
105
106 simple_map_init(&rsk7203_flash_map);
107 flash_mtd = do_map_probe("cfi_probe", &rsk7203_flash_map);
108 nr_parts = parse_mtd_partitions(flash_mtd, probes,
109 &parsed_partitions, 0);
110 /* If there is no partition table, used the hard coded table */
111 if (nr_parts <= 0) {
112 flash_data.parts = rsk7203_partitions;
113 flash_data.nr_parts = ARRAY_SIZE(rsk7203_partitions);
114 } else {
115 flash_data.nr_parts = nr_parts;
116 flash_data.parts = parsed_partitions;
117 }
118}
119
Paul Mundtbbc97412008-10-21 14:27:51 +0900120static struct gpio_led rsk7203_gpio_leds[] = {
121 {
122 .name = "green",
123 .gpio = GPIO_PE10,
124 .active_low = 1,
125 }, {
126 .name = "orange",
127 .default_trigger = "nand-disk",
128 .gpio = GPIO_PE12,
129 .active_low = 1,
130 }, {
131 .name = "red:timer",
132 .default_trigger = "timer",
133 .gpio = GPIO_PC14,
134 .active_low = 1,
135 }, {
136 .name = "red:heartbeat",
137 .default_trigger = "heartbeat",
138 .gpio = GPIO_PE11,
139 .active_low = 1,
140 },
141};
142
143static struct gpio_led_platform_data rsk7203_gpio_leds_info = {
144 .leds = rsk7203_gpio_leds,
145 .num_leds = ARRAY_SIZE(rsk7203_gpio_leds),
146};
147
148static struct platform_device led_device = {
149 .name = "leds-gpio",
150 .id = -1,
151 .dev = {
152 .platform_data = &rsk7203_gpio_leds_info,
153 },
154};
Paul Mundt3787aa12008-05-19 16:47:56 +0900155
156static struct platform_device *rsk7203_devices[] __initdata = {
157 &smc911x_device,
158 &flash_device,
Paul Mundtbbc97412008-10-21 14:27:51 +0900159 &led_device,
Paul Mundt3787aa12008-05-19 16:47:56 +0900160};
161
162static int __init rsk7203_devices_setup(void)
163{
Magnus Damm7a5c6792008-10-08 20:42:38 +0900164 /* Select pins for SCIF0 */
165 gpio_request(GPIO_FN_TXD0, NULL);
166 gpio_request(GPIO_FN_RXD0, NULL);
167
Paul Mundt3787aa12008-05-19 16:47:56 +0900168 set_mtd_partitions();
169 return platform_add_devices(rsk7203_devices,
170 ARRAY_SIZE(rsk7203_devices));
171}
172device_initcall(rsk7203_devices_setup);
173
174/*
175 * The Machine Vector
176 */
177static struct sh_machine_vector mv_rsk7203 __initmv = {
178 .mv_name = "RSK+7203",
179};