blob: c8114cdb95e861f971c4269ed187cc3ede513621 [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 Mundt3787aa12008-05-19 16:47:56 +090020#include <asm/machvec.h>
21#include <asm/io.h>
Paul Mundta51413a2008-10-21 09:52:02 +090022#include <cpu/sh7203.h>
Paul Mundt3787aa12008-05-19 16:47:56 +090023
Paul Mundt6d0b3652008-07-28 22:31:02 +090024static struct smc911x_platdata smc911x_info = {
25 .flags = SMC911X_USE_16BIT,
26 .irq_flags = IRQF_TRIGGER_LOW,
27};
28
Paul Mundt3787aa12008-05-19 16:47:56 +090029static struct resource smc911x_resources[] = {
30 [0] = {
31 .start = 0x24000000,
32 .end = 0x24000000 + 0x100,
33 .flags = IORESOURCE_MEM,
34 },
35 [1] = {
36 .start = 64,
37 .end = 64,
38 .flags = IORESOURCE_IRQ,
39 },
40};
41
42static struct platform_device smc911x_device = {
43 .name = "smc911x",
44 .id = -1,
45 .num_resources = ARRAY_SIZE(smc911x_resources),
46 .resource = smc911x_resources,
Paul Mundt6d0b3652008-07-28 22:31:02 +090047 .dev = {
48 .platform_data = &smc911x_info,
49 },
Paul Mundt3787aa12008-05-19 16:47:56 +090050};
51
52static const char *probes[] = { "cmdlinepart", NULL };
53
54static struct mtd_partition *parsed_partitions;
55
56static struct mtd_partition rsk7203_partitions[] = {
57 {
58 .name = "Bootloader",
59 .offset = 0x00000000,
60 .size = 0x00040000,
61 .mask_flags = MTD_WRITEABLE,
62 }, {
63 .name = "Kernel",
64 .offset = MTDPART_OFS_NXTBLK,
65 .size = 0x001c0000,
66 }, {
67 .name = "Flash_FS",
68 .offset = MTDPART_OFS_NXTBLK,
69 .size = MTDPART_SIZ_FULL,
70 }
71};
72
73static struct physmap_flash_data flash_data = {
74 .width = 2,
75};
76
77static struct resource flash_resource = {
78 .start = 0x20000000,
79 .end = 0x20400000,
80 .flags = IORESOURCE_MEM,
81};
82
83static struct platform_device flash_device = {
84 .name = "physmap-flash",
85 .id = -1,
86 .resource = &flash_resource,
87 .num_resources = 1,
88 .dev = {
89 .platform_data = &flash_data,
90 },
91};
92
93static struct mtd_info *flash_mtd;
94
95static struct map_info rsk7203_flash_map = {
96 .name = "RSK+ Flash",
97 .size = 0x400000,
98 .bankwidth = 2,
99};
100
101static void __init set_mtd_partitions(void)
102{
103 int nr_parts = 0;
104
105 simple_map_init(&rsk7203_flash_map);
106 flash_mtd = do_map_probe("cfi_probe", &rsk7203_flash_map);
107 nr_parts = parse_mtd_partitions(flash_mtd, probes,
108 &parsed_partitions, 0);
109 /* If there is no partition table, used the hard coded table */
110 if (nr_parts <= 0) {
111 flash_data.parts = rsk7203_partitions;
112 flash_data.nr_parts = ARRAY_SIZE(rsk7203_partitions);
113 } else {
114 flash_data.nr_parts = nr_parts;
115 flash_data.parts = parsed_partitions;
116 }
117}
118
119
120static struct platform_device *rsk7203_devices[] __initdata = {
121 &smc911x_device,
122 &flash_device,
123};
124
125static int __init rsk7203_devices_setup(void)
126{
Magnus Damm7a5c6792008-10-08 20:42:38 +0900127 /* Select pins for SCIF0 */
128 gpio_request(GPIO_FN_TXD0, NULL);
129 gpio_request(GPIO_FN_RXD0, NULL);
130
131 /* Lit LED0 */
132 gpio_request(GPIO_PE10, NULL);
133 gpio_direction_output(GPIO_PE10, 0);
134 gpio_export(GPIO_PE10, 0);
135
Paul Mundt3787aa12008-05-19 16:47:56 +0900136 set_mtd_partitions();
137 return platform_add_devices(rsk7203_devices,
138 ARRAY_SIZE(rsk7203_devices));
139}
140device_initcall(rsk7203_devices_setup);
141
142/*
143 * The Machine Vector
144 */
145static struct sh_machine_vector mv_rsk7203 __initmv = {
146 .mv_name = "RSK+7203",
147};