aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sh/boards/magicpanelr2/setup.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/sh/boards/magicpanelr2/setup.c')
-rw-r--r--arch/sh/boards/magicpanelr2/setup.c88
1 files changed, 85 insertions, 3 deletions
diff --git a/arch/sh/boards/magicpanelr2/setup.c b/arch/sh/boards/magicpanelr2/setup.c
index c5930656654f..f3b8b07ea5d6 100644
--- a/arch/sh/boards/magicpanelr2/setup.c
+++ b/arch/sh/boards/magicpanelr2/setup.c
@@ -12,14 +12,19 @@
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/irq.h> 13#include <linux/irq.h>
14#include <linux/platform_device.h> 14#include <linux/platform_device.h>
15#include <linux/ide.h>
16#include <linux/irq.h>
17#include <linux/delay.h> 15#include <linux/delay.h>
16#include <linux/mtd/mtd.h>
17#include <linux/mtd/partitions.h>
18#include <linux/mtd/physmap.h>
19#include <linux/mtd/map.h>
18#include <asm/magicpanelr2.h> 20#include <asm/magicpanelr2.h>
19#include <asm/heartbeat.h> 21#include <asm/heartbeat.h>
20 22
21#define LAN9115_READY (ctrl_inl(0xA8000084UL) & 0x00000001UL) 23#define LAN9115_READY (ctrl_inl(0xA8000084UL) & 0x00000001UL)
22 24
25/* Prefer cmdline over RedBoot */
26static const char *probes[] = { "cmdlinepart", "RedBoot", NULL };
27
23/* Wait until reset finished. Timeout is 100ms. */ 28/* Wait until reset finished. Timeout is 100ms. */
24static int __init ethernet_reset_finished(void) 29static int __init ethernet_reset_finished(void)
25{ 30{
@@ -270,13 +275,90 @@ static struct platform_device heartbeat_device = {
270 .resource = heartbeat_resources, 275 .resource = heartbeat_resources,
271}; 276};
272 277
278static struct mtd_partition *parsed_partitions;
279
280static struct mtd_partition mpr2_partitions[] = {
281 /* Reserved for bootloader, read-only */
282 {
283 .name = "Bootloader",
284 .offset = 0x00000000UL,
285 .size = MPR2_MTD_BOOTLOADER_SIZE,
286 .mask_flags = MTD_WRITEABLE,
287 },
288 /* Reserved for kernel image */
289 {
290 .name = "Kernel",
291 .offset = MTDPART_OFS_NXTBLK,
292 .size = MPR2_MTD_KERNEL_SIZE,
293 },
294 /* Rest is used for Flash FS */
295 {
296 .name = "Flash_FS",
297 .offset = MTDPART_OFS_NXTBLK,
298 .size = MTDPART_SIZ_FULL,
299 }
300};
301
302static struct physmap_flash_data flash_data = {
303 .width = 2,
304};
305
306static struct resource flash_resource = {
307 .start = 0x00000000,
308 .end = 0x2000000UL,
309 .flags = IORESOURCE_MEM,
310};
311
312static struct platform_device flash_device = {
313 .name = "physmap-flash",
314 .id = -1,
315 .resource = &flash_resource,
316 .num_resources = 1,
317 .dev = {
318 .platform_data = &flash_data,
319 },
320};
321
322static struct mtd_info *flash_mtd;
323
324static struct map_info mpr2_flash_map = {
325 .name = "Magic Panel R2 Flash",
326 .size = 0x2000000UL,
327 .bankwidth = 2,
328};
329
330static void __init set_mtd_partitions(void)
331{
332 int nr_parts = 0;
333
334 simple_map_init(&mpr2_flash_map);
335 flash_mtd = do_map_probe("cfi_probe", &mpr2_flash_map);
336 nr_parts = parse_mtd_partitions(flash_mtd, probes,
337 &parsed_partitions, 0);
338 /* If there is no partition table, used the hard coded table */
339 if (nr_parts <= 0) {
340 flash_data.parts = mpr2_partitions;
341 flash_data.nr_parts = ARRAY_SIZE(mpr2_partitions);
342 } else {
343 flash_data.nr_parts = nr_parts;
344 flash_data.parts = parsed_partitions;
345 }
346}
347
348/*
349 * Add all resources to the platform_device
350 */
351
273static struct platform_device *mpr2_devices[] __initdata = { 352static struct platform_device *mpr2_devices[] __initdata = {
274 &heartbeat_device, 353 &heartbeat_device,
275 &smc911x_device, 354 &smc911x_device,
355 &flash_device,
276}; 356};
277 357
358
278static int __init mpr2_devices_setup(void) 359static int __init mpr2_devices_setup(void)
279{ 360{
361 set_mtd_partitions();
280 return platform_add_devices(mpr2_devices, ARRAY_SIZE(mpr2_devices)); 362 return platform_add_devices(mpr2_devices, ARRAY_SIZE(mpr2_devices));
281} 363}
282device_initcall(mpr2_devices_setup); 364device_initcall(mpr2_devices_setup);
@@ -308,5 +390,5 @@ static void __init init_mpr2_IRQ(void)
308static struct sh_machine_vector mv_mpr2 __initmv = { 390static struct sh_machine_vector mv_mpr2 __initmv = {
309 .mv_name = "mpr2", 391 .mv_name = "mpr2",
310 .mv_setup = mpr2_setup, 392 .mv_setup = mpr2_setup,
311 .mv_init_irq = init_mpr2_IRQ, 393 .mv_init_irq = init_mpr2_IRQ,
312}; 394};