Peter Griffin | 6feb348 | 2008-11-28 22:56:45 +0900 | [diff] [blame] | 1 | /* |
Paul Mundt | ea0aac1 | 2008-12-08 14:32:03 +0900 | [diff] [blame] | 2 | * Renesas Technology Europe RSK+ Support. |
Peter Griffin | 6feb348 | 2008-11-28 22:56:45 +0900 | [diff] [blame] | 3 | * |
Paul Mundt | ea0aac1 | 2008-12-08 14:32:03 +0900 | [diff] [blame] | 4 | * Copyright (C) 2008 Paul Mundt |
Peter Griffin | 6feb348 | 2008-11-28 22:56:45 +0900 | [diff] [blame] | 5 | * 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> |
Magnus Damm | 8834541 | 2009-10-26 10:08:55 +0000 | [diff] [blame] | 18 | #ifdef CONFIG_MTD |
Peter Griffin | 6feb348 | 2008-11-28 22:56:45 +0900 | [diff] [blame] | 19 | #include <linux/mtd/map.h> |
Magnus Damm | 8834541 | 2009-10-26 10:08:55 +0000 | [diff] [blame] | 20 | #endif |
Peter Griffin | 6feb348 | 2008-11-28 22:56:45 +0900 | [diff] [blame] | 21 | #include <asm/machvec.h> |
| 22 | #include <asm/io.h> |
| 23 | |
Paul Mundt | ea0aac1 | 2008-12-08 14:32:03 +0900 | [diff] [blame] | 24 | static struct mtd_partition rsk_partitions[] = { |
Peter Griffin | 6feb348 | 2008-11-28 22:56:45 +0900 | [diff] [blame] | 25 | { |
| 26 | .name = "Bootloader", |
| 27 | .offset = 0x00000000, |
| 28 | .size = 0x00040000, |
| 29 | .mask_flags = MTD_WRITEABLE, |
| 30 | }, { |
| 31 | .name = "Kernel", |
| 32 | .offset = MTDPART_OFS_NXTBLK, |
| 33 | .size = 0x001c0000, |
| 34 | }, { |
| 35 | .name = "Flash_FS", |
| 36 | .offset = MTDPART_OFS_NXTBLK, |
| 37 | .size = MTDPART_SIZ_FULL, |
| 38 | } |
| 39 | }; |
| 40 | |
| 41 | static struct physmap_flash_data flash_data = { |
Magnus Damm | 8834541 | 2009-10-26 10:08:55 +0000 | [diff] [blame] | 42 | .parts = rsk_partitions, |
| 43 | .nr_parts = ARRAY_SIZE(rsk_partitions), |
Peter Griffin | 6feb348 | 2008-11-28 22:56:45 +0900 | [diff] [blame] | 44 | .width = 2, |
| 45 | }; |
| 46 | |
| 47 | static struct resource flash_resource = { |
| 48 | .start = 0x20000000, |
| 49 | .end = 0x20400000, |
| 50 | .flags = IORESOURCE_MEM, |
| 51 | }; |
| 52 | |
| 53 | static 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 | |
Magnus Damm | 8834541 | 2009-10-26 10:08:55 +0000 | [diff] [blame] | 63 | #ifdef CONFIG_MTD |
| 64 | static const char *probes[] = { "cmdlinepart", NULL }; |
Peter Griffin | 6feb348 | 2008-11-28 22:56:45 +0900 | [diff] [blame] | 65 | |
Paul Mundt | ea0aac1 | 2008-12-08 14:32:03 +0900 | [diff] [blame] | 66 | static struct map_info rsk_flash_map = { |
Peter Griffin | 6feb348 | 2008-11-28 22:56:45 +0900 | [diff] [blame] | 67 | .name = "RSK+ Flash", |
| 68 | .size = 0x400000, |
| 69 | .bankwidth = 2, |
| 70 | }; |
| 71 | |
Magnus Damm | 8834541 | 2009-10-26 10:08:55 +0000 | [diff] [blame] | 72 | static struct mtd_info *flash_mtd; |
| 73 | |
| 74 | static struct mtd_partition *parsed_partitions; |
| 75 | |
Peter Griffin | 6feb348 | 2008-11-28 22:56:45 +0900 | [diff] [blame] | 76 | static void __init set_mtd_partitions(void) |
| 77 | { |
| 78 | int nr_parts = 0; |
| 79 | |
Paul Mundt | ea0aac1 | 2008-12-08 14:32:03 +0900 | [diff] [blame] | 80 | simple_map_init(&rsk_flash_map); |
| 81 | flash_mtd = do_map_probe("cfi_probe", &rsk_flash_map); |
Peter Griffin | 6feb348 | 2008-11-28 22:56:45 +0900 | [diff] [blame] | 82 | nr_parts = parse_mtd_partitions(flash_mtd, probes, |
| 83 | &parsed_partitions, 0); |
| 84 | /* If there is no partition table, used the hard coded table */ |
Magnus Damm | 8834541 | 2009-10-26 10:08:55 +0000 | [diff] [blame] | 85 | if (nr_parts > 0) { |
Peter Griffin | 6feb348 | 2008-11-28 22:56:45 +0900 | [diff] [blame] | 86 | flash_data.nr_parts = nr_parts; |
| 87 | flash_data.parts = parsed_partitions; |
| 88 | } |
| 89 | } |
Magnus Damm | 8834541 | 2009-10-26 10:08:55 +0000 | [diff] [blame] | 90 | #else |
| 91 | static inline void set_mtd_partitions(void) {} |
| 92 | #endif |
Peter Griffin | 6feb348 | 2008-11-28 22:56:45 +0900 | [diff] [blame] | 93 | |
Paul Mundt | ea0aac1 | 2008-12-08 14:32:03 +0900 | [diff] [blame] | 94 | static struct platform_device *rsk_devices[] __initdata = { |
Peter Griffin | 6feb348 | 2008-11-28 22:56:45 +0900 | [diff] [blame] | 95 | &flash_device, |
| 96 | }; |
| 97 | |
Paul Mundt | ea0aac1 | 2008-12-08 14:32:03 +0900 | [diff] [blame] | 98 | static int __init rsk_devices_setup(void) |
Peter Griffin | 6feb348 | 2008-11-28 22:56:45 +0900 | [diff] [blame] | 99 | { |
| 100 | set_mtd_partitions(); |
Paul Mundt | ea0aac1 | 2008-12-08 14:32:03 +0900 | [diff] [blame] | 101 | return platform_add_devices(rsk_devices, |
| 102 | ARRAY_SIZE(rsk_devices)); |
Peter Griffin | 6feb348 | 2008-11-28 22:56:45 +0900 | [diff] [blame] | 103 | } |
Paul Mundt | ea0aac1 | 2008-12-08 14:32:03 +0900 | [diff] [blame] | 104 | device_initcall(rsk_devices_setup); |
Peter Griffin | 6feb348 | 2008-11-28 22:56:45 +0900 | [diff] [blame] | 105 | |
| 106 | /* |
| 107 | * The Machine Vector |
| 108 | */ |
Paul Mundt | ea0aac1 | 2008-12-08 14:32:03 +0900 | [diff] [blame] | 109 | static struct sh_machine_vector mv_rsk __initmv = { |
| 110 | .mv_name = "RSK+", |
Peter Griffin | 6feb348 | 2008-11-28 22:56:45 +0900 | [diff] [blame] | 111 | }; |