|
| 1 | +/* |
| 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> |
| 13 | +#include <linux/mtd/mtd.h> |
| 14 | +#include <linux/mtd/partitions.h> |
| 15 | +#include <linux/mtd/physmap.h> |
| 16 | +#include <linux/mtd/map.h> |
| 17 | +#include <asm/machvec.h> |
| 18 | +#include <asm/io.h> |
| 19 | + |
| 20 | +static struct resource smc911x_resources[] = { |
| 21 | + [0] = { |
| 22 | + .start = 0x24000000, |
| 23 | + .end = 0x24000000 + 0x100, |
| 24 | + .flags = IORESOURCE_MEM, |
| 25 | + }, |
| 26 | + [1] = { |
| 27 | + .start = 64, |
| 28 | + .end = 64, |
| 29 | + .flags = IORESOURCE_IRQ, |
| 30 | + }, |
| 31 | +}; |
| 32 | + |
| 33 | +static struct platform_device smc911x_device = { |
| 34 | + .name = "smc911x", |
| 35 | + .id = -1, |
| 36 | + .num_resources = ARRAY_SIZE(smc911x_resources), |
| 37 | + .resource = smc911x_resources, |
| 38 | +}; |
| 39 | + |
| 40 | +static const char *probes[] = { "cmdlinepart", NULL }; |
| 41 | + |
| 42 | +static struct mtd_partition *parsed_partitions; |
| 43 | + |
| 44 | +static struct mtd_partition rsk7203_partitions[] = { |
| 45 | + { |
| 46 | + .name = "Bootloader", |
| 47 | + .offset = 0x00000000, |
| 48 | + .size = 0x00040000, |
| 49 | + .mask_flags = MTD_WRITEABLE, |
| 50 | + }, { |
| 51 | + .name = "Kernel", |
| 52 | + .offset = MTDPART_OFS_NXTBLK, |
| 53 | + .size = 0x001c0000, |
| 54 | + }, { |
| 55 | + .name = "Flash_FS", |
| 56 | + .offset = MTDPART_OFS_NXTBLK, |
| 57 | + .size = MTDPART_SIZ_FULL, |
| 58 | + } |
| 59 | +}; |
| 60 | + |
| 61 | +static struct physmap_flash_data flash_data = { |
| 62 | + .width = 2, |
| 63 | +}; |
| 64 | + |
| 65 | +static struct resource flash_resource = { |
| 66 | + .start = 0x20000000, |
| 67 | + .end = 0x20400000, |
| 68 | + .flags = IORESOURCE_MEM, |
| 69 | +}; |
| 70 | + |
| 71 | +static struct platform_device flash_device = { |
| 72 | + .name = "physmap-flash", |
| 73 | + .id = -1, |
| 74 | + .resource = &flash_resource, |
| 75 | + .num_resources = 1, |
| 76 | + .dev = { |
| 77 | + .platform_data = &flash_data, |
| 78 | + }, |
| 79 | +}; |
| 80 | + |
| 81 | +static struct mtd_info *flash_mtd; |
| 82 | + |
| 83 | +static struct map_info rsk7203_flash_map = { |
| 84 | + .name = "RSK+ Flash", |
| 85 | + .size = 0x400000, |
| 86 | + .bankwidth = 2, |
| 87 | +}; |
| 88 | + |
| 89 | +static void __init set_mtd_partitions(void) |
| 90 | +{ |
| 91 | + int nr_parts = 0; |
| 92 | + |
| 93 | + simple_map_init(&rsk7203_flash_map); |
| 94 | + flash_mtd = do_map_probe("cfi_probe", &rsk7203_flash_map); |
| 95 | + nr_parts = parse_mtd_partitions(flash_mtd, probes, |
| 96 | + &parsed_partitions, 0); |
| 97 | + /* If there is no partition table, used the hard coded table */ |
| 98 | + if (nr_parts <= 0) { |
| 99 | + flash_data.parts = rsk7203_partitions; |
| 100 | + flash_data.nr_parts = ARRAY_SIZE(rsk7203_partitions); |
| 101 | + } else { |
| 102 | + flash_data.nr_parts = nr_parts; |
| 103 | + flash_data.parts = parsed_partitions; |
| 104 | + } |
| 105 | +} |
| 106 | + |
| 107 | + |
| 108 | +static struct platform_device *rsk7203_devices[] __initdata = { |
| 109 | + &smc911x_device, |
| 110 | + &flash_device, |
| 111 | +}; |
| 112 | + |
| 113 | +static int __init rsk7203_devices_setup(void) |
| 114 | +{ |
| 115 | + set_mtd_partitions(); |
| 116 | + return platform_add_devices(rsk7203_devices, |
| 117 | + ARRAY_SIZE(rsk7203_devices)); |
| 118 | +} |
| 119 | +device_initcall(rsk7203_devices_setup); |
| 120 | + |
| 121 | +/* |
| 122 | + * The Machine Vector |
| 123 | + */ |
| 124 | +static struct sh_machine_vector mv_rsk7203 __initmv = { |
| 125 | + .mv_name = "RSK+7203", |
| 126 | +}; |
0 commit comments