Peter Griffin | 6feb348 | 2008-11-28 22:56:45 +0900 | [diff] [blame^] | 1 | /* |
| 2 | * Renesas Technology Europe RSK+ 7201 Support. |
| 3 | * |
| 4 | * Copyright (C) 2008 Peter Griffin <pgriffin@mpc-data.co.uk> |
| 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> |
| 13 | #include <linux/interrupt.h> |
| 14 | #include <linux/mtd/mtd.h> |
| 15 | #include <linux/mtd/partitions.h> |
| 16 | #include <linux/mtd/physmap.h> |
| 17 | #include <linux/mtd/map.h> |
| 18 | #include <asm/machvec.h> |
| 19 | #include <asm/io.h> |
| 20 | |
| 21 | static const char *probes[] = { "cmdlinepart", NULL }; |
| 22 | |
| 23 | static struct mtd_partition *parsed_partitions; |
| 24 | |
| 25 | static struct mtd_partition rsk7201_partitions[] = { |
| 26 | { |
| 27 | .name = "Bootloader", |
| 28 | .offset = 0x00000000, |
| 29 | .size = 0x00040000, |
| 30 | .mask_flags = MTD_WRITEABLE, |
| 31 | }, { |
| 32 | .name = "Kernel", |
| 33 | .offset = MTDPART_OFS_NXTBLK, |
| 34 | .size = 0x001c0000, |
| 35 | }, { |
| 36 | .name = "Flash_FS", |
| 37 | .offset = MTDPART_OFS_NXTBLK, |
| 38 | .size = MTDPART_SIZ_FULL, |
| 39 | } |
| 40 | }; |
| 41 | |
| 42 | static struct physmap_flash_data flash_data = { |
| 43 | .width = 2, |
| 44 | }; |
| 45 | |
| 46 | static struct resource flash_resource = { |
| 47 | .start = 0x20000000, |
| 48 | .end = 0x20400000, |
| 49 | .flags = IORESOURCE_MEM, |
| 50 | }; |
| 51 | |
| 52 | static struct platform_device flash_device = { |
| 53 | .name = "physmap-flash", |
| 54 | .id = -1, |
| 55 | .resource = &flash_resource, |
| 56 | .num_resources = 1, |
| 57 | .dev = { |
| 58 | .platform_data = &flash_data, |
| 59 | }, |
| 60 | }; |
| 61 | |
| 62 | static struct mtd_info *flash_mtd; |
| 63 | |
| 64 | static struct map_info rsk7201_flash_map = { |
| 65 | .name = "RSK+ Flash", |
| 66 | .size = 0x400000, |
| 67 | .bankwidth = 2, |
| 68 | }; |
| 69 | |
| 70 | static void __init set_mtd_partitions(void) |
| 71 | { |
| 72 | int nr_parts = 0; |
| 73 | |
| 74 | simple_map_init(&rsk7201_flash_map); |
| 75 | flash_mtd = do_map_probe("cfi_probe", &rsk7201_flash_map); |
| 76 | nr_parts = parse_mtd_partitions(flash_mtd, probes, |
| 77 | &parsed_partitions, 0); |
| 78 | /* If there is no partition table, used the hard coded table */ |
| 79 | if (nr_parts <= 0) { |
| 80 | flash_data.parts = rsk7201_partitions; |
| 81 | flash_data.nr_parts = ARRAY_SIZE(rsk7201_partitions); |
| 82 | } else { |
| 83 | flash_data.nr_parts = nr_parts; |
| 84 | flash_data.parts = parsed_partitions; |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | static struct platform_device *rsk7201_devices[] __initdata = { |
| 89 | &flash_device, |
| 90 | }; |
| 91 | |
| 92 | static int __init rsk7201_devices_setup(void) |
| 93 | { |
| 94 | set_mtd_partitions(); |
| 95 | return platform_add_devices(rsk7201_devices, |
| 96 | ARRAY_SIZE(rsk7201_devices)); |
| 97 | } |
| 98 | device_initcall(rsk7201_devices_setup); |
| 99 | |
| 100 | /* |
| 101 | * The Machine Vector |
| 102 | */ |
| 103 | static struct sh_machine_vector mv_rsk7201 __initmv = { |
| 104 | .mv_name = "RSK+7201", |
| 105 | }; |