Index: drivers/mtd/maps/Config.in =================================================================== RCS file: /home/cvs/mtd/drivers/mtd/maps/Config.in,v retrieving revision 1.61 diff -u -r1.61 Config.in --- drivers/mtd/maps/Config.in 27 Oct 2003 19:49:23 -0000 1.61 +++ drivers/mtd/maps/Config.in 11 Nov 2003 18:55:35 -0000 @@ -8,12 +8,7 @@ bool ' Support for non-linear mappings of flash chips' CONFIG_MTD_COMPLEX_MAPPINGS -dep_tristate ' CFI Flash device in physical memory map' CONFIG_MTD_PHYSMAP $CONFIG_MTD_GEN_PROBE -if [ "$CONFIG_MTD_PHYSMAP" = "y" -o "$CONFIG_MTD_PHYSMAP" = "m" ]; then - hex ' Physical start address of flash mapping' CONFIG_MTD_PHYSMAP_START 0x8000000 - hex ' Physical length of flash mapping' CONFIG_MTD_PHYSMAP_LEN 0x4000000 - int ' Bus width in octets' CONFIG_MTD_PHYSMAP_BUSWIDTH 2 -fi +bool ' CFI Flash device in physical memory map' CONFIG_MTD_PHYSMAP $CONFIG_MTD_GEN_PROBE if [ "$CONFIG_SPARC" = "y" -o "$CONFIG_SPARC64" = "y" ]; then dep_tristate ' Sun Microsystems userflash support' CONFIG_MTD_SUN_UFLASH $CONFIG_MTD_CFI Index: drivers/mtd/maps/physmap.c =================================================================== RCS file: /home/cvs/mtd/drivers/mtd/maps/physmap.c,v retrieving revision 1.29 diff -u -r1.29 physmap.c --- drivers/mtd/maps/physmap.c 29 May 2003 09:24:10 -0000 1.29 +++ drivers/mtd/maps/physmap.c 11 Nov 2003 18:55:35 -0000 @@ -2,6 +2,11 @@ * $Id: physmap.c,v 1.29 2003/05/29 09:24:10 dwmw2 Exp $ * * Normal mappings of chips in physical memory + * + * Copyright (C) 2003 MontaVista Software Inc. + * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net + * + * 031022 - [jsun] add run-time configure and partition setup */ #include @@ -15,53 +20,24 @@ #include #include -#define WINDOW_ADDR CONFIG_MTD_PHYSMAP_START -#define WINDOW_SIZE CONFIG_MTD_PHYSMAP_LEN -#define BUSWIDTH CONFIG_MTD_PHYSMAP_BUSWIDTH - static struct mtd_info *mymtd; - -struct map_info physmap_map = { - .name = "Physically mapped flash", - .size = WINDOW_SIZE, - .buswidth = BUSWIDTH, - .phys = WINDOW_ADDR, -}; +struct map_info physmap_map = {.name = "phys_mapped_flash"}; #ifdef CONFIG_MTD_PARTITIONS static struct mtd_partition *mtd_parts; static int mtd_parts_nb; -static struct mtd_partition physmap_partitions[] = { -#if 0 -/* Put your own partition definitions here */ - { - .name = "bootROM", - .size = 0x80000, - .offset = 0, - .mask_flags = MTD_WRITEABLE, /* force read-only */ - }, { - .name = "zImage", - .size = 0x100000, - .offset = MTDPART_OFS_APPEND, - .mask_flags = MTD_WRITEABLE, /* force read-only */ - }, { - .name = "ramdisk.gz", - .size = 0x300000, - .offset = MTDPART_OFS_APPEND, - .mask_flags = MTD_WRITEABLE, /* force read-only */ - }, { - .name = "User FS", - .size = MTDPART_SIZ_FULL, - .offset = MTDPART_OFS_APPEND, - } -#endif -}; +static int num_physmap_partitions; +static struct mtd_partition *physmap_partitions; -#define NUM_PARTITIONS (sizeof(physmap_partitions)/sizeof(struct mtd_partition)) -const char *part_probes[] = {"cmdlinepart", "RedBoot", NULL}; +char *part_probes[] __initdata = {"cmdlinepart", "RedBoot", NULL}; +void physmap_set_partitions(struct mtd_partition *parts, int num_parts) +{ + physmap_partitions=parts; + num_physmap_partitions=num_parts; +} #endif /* CONFIG_MTD_PARTITIONS */ int __init init_physmap(void) @@ -69,8 +45,8 @@ static const char *rom_probe_types[] = { "cfi_probe", "jedec_probe", "map_rom", 0 }; const char **type; - printk(KERN_NOTICE "physmap flash device: %x at %x\n", WINDOW_SIZE, WINDOW_ADDR); - physmap_map.virt = (unsigned long)ioremap(WINDOW_ADDR, WINDOW_SIZE); + printk(KERN_NOTICE "physmap flash device: %lx at %lx\n", physmap_map.size, physmap_map.phys); + physmap_map.virt = (unsigned long)ioremap(physmap_map.phys, physmap_map.size); if (!physmap_map.virt) { printk("Failed to ioremap\n"); @@ -97,11 +73,11 @@ return 0; } - if (NUM_PARTITIONS != 0) + if (num_physmap_partitions != 0) { printk(KERN_NOTICE "Using physmap partition definition\n"); - add_mtd_partitions (mymtd, physmap_partitions, NUM_PARTITIONS); + add_mtd_partitions (mymtd, physmap_partitions, num_physmap_partitions); return 0; } @@ -121,7 +97,7 @@ if (mtd_parts_nb) { del_mtd_partitions(mymtd); kfree(mtd_parts); - } else if (NUM_PARTITIONS) { + } else if (num_physmap_partitions) { del_mtd_partitions(mymtd); } else { del_mtd_device(mymtd); Index: include/linux/mtd/physmap.h =================================================================== RCS file: include/linux/mtd/physmap.h diff -N include/linux/mtd/physmap.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ include/linux/mtd/physmap.h 11 Nov 2003 18:55:35 -0000 @@ -0,0 +1,59 @@ +/* + * For boards with physically mapped flash and using + * drivers/mtd/maps/physmap.c mapping driver. + * + * Copyright (C) 2003 MontaVista Software Inc. + * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + */ + +#ifndef __LINUX_MTD_PHYSMAP__ + +#include + +#if defined(CONFIG_MTD_PHYSMAP) + +#include +#include +#include + +/* + * The map_info for physmap. Board can override size, buswidth, phys, + * (*set_vpp)(), etc in their initial setup routine. + */ +extern struct map_info physmap_map; + +/* + * Board needs to specify the exact mapping during their setup time. + */ +static inline void physmap_configure(unsigned long addr, unsigned long size, int buswidth, void (*set_vpp)(struct map_info *, int) ) +{ + physmap_map.phys = addr; + physmap_map.size = size; + physmap_map.buswidth = buswidth; + physmap_map.set_vpp = set_vpp; +} + +#if defined(CONFIG_MTD_PARTITIONS) + +/* + * Machines that wish to do flash partition may want to call this function in + * their setup routine. + * + * physmap_set_partitions(mypartitions, num_parts); + * + * Note that one can always override this hard-coded partition with + * command line partition (you need to enable CONFIG_MTD_CMDLINE_PARTS). + */ +void physmap_set_partitions(struct mtd_partition *parts, int num_parts); + +#endif /* defined(CONFIG_MTD_PARTITIONS) */ +#endif /* defined(CONFIG_MTD) */ + +#endif /* __LINUX_MTD_PHYSMAP__ */ +