blob: af64d030a5c7027a09be844ca28014a8ee728e49 [file] [log] [blame]
Peter Griffin6feb3482008-11-28 22:56:45 +09001/*
Paul Mundtea0aac12008-12-08 14:32:03 +09002 * Renesas Technology Europe RSK+ Support.
Peter Griffin6feb3482008-11-28 22:56:45 +09003 *
Paul Mundtea0aac12008-12-08 14:32:03 +09004 * Copyright (C) 2008 Paul Mundt
Peter Griffin6feb3482008-11-28 22:56:45 +09005 * Copyright (C) 2008 Peter Griffin <pgriffin@mpc-data.co.uk>
6 *
7 * This file is subject to the terms and conditions of the GNU General Public
8 * License. See the file "COPYING" in the main directory of this archive
9 * for more details.
10 */
11#include <linux/init.h>
12#include <linux/types.h>
13#include <linux/platform_device.h>
14#include <linux/interrupt.h>
15#include <linux/mtd/mtd.h>
16#include <linux/mtd/partitions.h>
17#include <linux/mtd/physmap.h>
18#include <linux/mtd/map.h>
19#include <asm/machvec.h>
20#include <asm/io.h>
21
22static const char *probes[] = { "cmdlinepart", NULL };
23
24static struct mtd_partition *parsed_partitions;
25
Paul Mundtea0aac12008-12-08 14:32:03 +090026static struct mtd_partition rsk_partitions[] = {
Peter Griffin6feb3482008-11-28 22:56:45 +090027 {
28 .name = "Bootloader",
29 .offset = 0x00000000,
30 .size = 0x00040000,
31 .mask_flags = MTD_WRITEABLE,
32 }, {
33 .name = "Kernel",
34 .offset = MTDPART_OFS_NXTBLK,
35 .size = 0x001c0000,
36 }, {
37 .name = "Flash_FS",
38 .offset = MTDPART_OFS_NXTBLK,
39 .size = MTDPART_SIZ_FULL,
40 }
41};
42
43static struct physmap_flash_data flash_data = {
44 .width = 2,
45};
46
47static struct resource flash_resource = {
48 .start = 0x20000000,
49 .end = 0x20400000,
50 .flags = IORESOURCE_MEM,
51};
52
53static struct platform_device flash_device = {
54 .name = "physmap-flash",
55 .id = -1,
56 .resource = &flash_resource,
57 .num_resources = 1,
58 .dev = {
59 .platform_data = &flash_data,
60 },
61};
62
63static struct mtd_info *flash_mtd;
64
Paul Mundtea0aac12008-12-08 14:32:03 +090065static struct map_info rsk_flash_map = {
Peter Griffin6feb3482008-11-28 22:56:45 +090066 .name = "RSK+ Flash",
67 .size = 0x400000,
68 .bankwidth = 2,
69};
70
71static void __init set_mtd_partitions(void)
72{
73 int nr_parts = 0;
74
Paul Mundtea0aac12008-12-08 14:32:03 +090075 simple_map_init(&rsk_flash_map);
76 flash_mtd = do_map_probe("cfi_probe", &rsk_flash_map);
Peter Griffin6feb3482008-11-28 22:56:45 +090077 nr_parts = parse_mtd_partitions(flash_mtd, probes,
78 &parsed_partitions, 0);
79 /* If there is no partition table, used the hard coded table */
80 if (nr_parts <= 0) {
Paul Mundtea0aac12008-12-08 14:32:03 +090081 flash_data.parts = rsk_partitions;
82 flash_data.nr_parts = ARRAY_SIZE(rsk_partitions);
Peter Griffin6feb3482008-11-28 22:56:45 +090083 } else {
84 flash_data.nr_parts = nr_parts;
85 flash_data.parts = parsed_partitions;
86 }
87}
88
Paul Mundtea0aac12008-12-08 14:32:03 +090089static struct platform_device *rsk_devices[] __initdata = {
Peter Griffin6feb3482008-11-28 22:56:45 +090090 &flash_device,
91};
92
Paul Mundtea0aac12008-12-08 14:32:03 +090093static int __init rsk_devices_setup(void)
Peter Griffin6feb3482008-11-28 22:56:45 +090094{
95 set_mtd_partitions();
Paul Mundtea0aac12008-12-08 14:32:03 +090096 return platform_add_devices(rsk_devices,
97 ARRAY_SIZE(rsk_devices));
Peter Griffin6feb3482008-11-28 22:56:45 +090098}
Paul Mundtea0aac12008-12-08 14:32:03 +090099device_initcall(rsk_devices_setup);
Peter Griffin6feb3482008-11-28 22:56:45 +0900100
101/*
102 * The Machine Vector
103 */
Paul Mundtea0aac12008-12-08 14:32:03 +0900104static struct sh_machine_vector mv_rsk __initmv = {
105 .mv_name = "RSK+",
Peter Griffin6feb3482008-11-28 22:56:45 +0900106};