diff -Naur mtd-20020403/drivers/mtd/maps/Makefile linux-denx-2.4.4-20020321-edu/drivers/mtd/maps/Makefile --- mtd-20020403/drivers/mtd/maps/Makefile Wed Apr 3 15:33:54 2002 +++ linux-denx-2.4.4-20020321-edu/drivers/mtd/maps/Makefile Fri Apr 12 15:35:08 2002 @@ -39,5 +39,7 @@ obj-$(CONFIG_MTD_PB1000) += pb1xxx-flash.o obj-$(CONFIG_MTD_PB1500) += pb1xxx-flash.o obj-$(CONFIG_MTD_AUTCPU12) += autcpu12-nvram.o +# GANS: add support for EDU partitions +obj-y += mpc8260ads-edu-flash.o include $(TOPDIR)/Rules.make diff -Naur mtd-20020403/drivers/mtd/maps/mpc8260ads-edu-flash.c linux-denx-2.4.4-20020321-edu/drivers/mtd/maps/mpc8260ads-edu-flash.c --- mtd-20020403/drivers/mtd/maps/mpc8260ads-edu-flash.c Thu Jan 1 01:00:00 1970 +++ linux-denx-2.4.4-20020321-edu/drivers/mtd/maps/mpc8260ads-edu-flash.c Thu Apr 25 17:35:03 2002 @@ -0,0 +1,330 @@ +/* + * Handle mapping of the flash memory access routines + * on Motorola MPC8260ADS Board. + * + * based on tqm8xxl.c + * + * Copyright(C) 2001 + * Christian Gagneraud. Anfora + * + * This code is GPLed + * + */ + +/* + * The MPC8260ADS can use flash DIMM by Smart Modular Technology: + * - SM73288XG4JHBG0 - 32 MBytes (4 banks of 4*2M*8). + * - SM73248XG2JHBG0 - 16 MBytes (2 banks of 4*2M*8). + * - SM73228XG1JHBG0 - 8 MBytes (1 bank of 4*2M*8) (default). + * + * Flash delay, size and type can be detect by flash presence detect bits + * in BCSR2[25-27,28-31] ( see UM p 4-67 and 4-68). + * + * The SM73228XG1JHBG0 uses 4 x SHARP LH29F016SCT (16 Mbit) + * for a total of 8 MB flash in one bank + * + * Thus we have to chose: + * - Support 32-bit buswidth => CONFIG_MTD_CFI_B4 + * - Support 4-chip flash interleave => CONFIG_MTD_CFI_I4 + */ + +/* + * TODO: + * - Add support for 16 and 32 Mbytes + * - Add support for autodetection of flash DIMM type? + */ + +#include +#include +#include +#include +#include + +#include +#include +#include + +#undef DEBUG + +#ifdef DEBUG +# define debugk(fmt,args...) printk(fmt ,##args) +#else +# define debugk(fmt,args...) +#endif + + +#define FLASH_BANK_MAX 1 + +/* trivial struct to describe partition information */ +struct mtd_part_def +{ + int nums; + unsigned char *type; + struct mtd_partition* mtd_part; +}; + +static struct mtd_info* mtd_banks[FLASH_BANK_MAX]; +static struct map_info* map_banks[FLASH_BANK_MAX]; +static struct mtd_part_def part_banks[FLASH_BANK_MAX]; +static unsigned long num_banks; +static unsigned long start_scan_addr; + +static __u8 mpc8260ads_read8(struct map_info *map, unsigned long ofs) +{ + return *((__u8 *)(map->map_priv_1 + ofs)); +} + +static __u16 mpc8260ads_read16(struct map_info *map, unsigned long ofs) +{ + return *((__u16 *)(map->map_priv_1 + ofs)); +} + +static __u32 mpc8260ads_read32(struct map_info *map, unsigned long ofs) +{ + return *((__u32 *)(map->map_priv_1 + ofs)); +} + +static void mpc8260ads_copy_from(struct map_info *map, + void *to, unsigned long from, ssize_t len) +{ + memcpy_fromio(to, (void *)(map->map_priv_1 + from), len); +} + +static void mpc8260ads_write8(struct map_info *map, __u8 d, unsigned long adr) +{ + *((__u8 *)(map->map_priv_1 + adr)) = d; +} + +static void mpc8260ads_write16(struct map_info *map, __u16 d, unsigned long adr) +{ + *((__u16 *)( map->map_priv_1 + adr)) = d; +} + +static void mpc8260ads_write32(struct map_info *map, __u32 d, unsigned long adr) +{ + *((__u32 *)(map->map_priv_1 + adr)) = d; +} + +static void mpc8260ads_copy_to(struct map_info *map, + unsigned long to, const void *from, ssize_t len) +{ + memcpy_toio((void *)(map->map_priv_1 + to), from, len); +} + +struct map_info mpc8260ads_map = { + name: "MPC8260ADS", +/* size: WINDOW_SIZE, */ + buswidth: 4, + read8: mpc8260ads_read8, + read16: mpc8260ads_read16, + read32: mpc8260ads_read32, + copy_from: mpc8260ads_copy_from, + write8: mpc8260ads_write8, + write16: mpc8260ads_write16, + write32: mpc8260ads_write32, + copy_to: mpc8260ads_copy_to +}; + +/* + * The following defines the partition layout of MPC8260ADS boards. + * + * See include/linux/mtd/partitions.h for definition of the + * mtd_partition structure. + * + * The *_max_flash_size is the maximum possible mapped flash size + * which is not necessarily the actual flash size. It must correspond + * to the value specified in the mapping definition defined by the + * "struct map_desc *_io_desc" for the corresponding machine. + */ + +#ifdef CONFIG_MTD_PARTITIONS +/* Currently, MPC8260ADS has upto 32 MB flash */ +static unsigned long mpc8260ads_max_flash_size = 32 << 20; + +/* partition definition for first (and only) flash bank + * also ref. to "drivers/char/flash_config.c" + */ +static struct mtd_partition mpc8260ads_partitions[] = { + { + name: "jffs2-root", /* JFFS(2) filesystem */ + offset: 0, + size: 7 << 20, + }, + { + name: "ppcboot", /* PPCBoot Firmware */ + offset: 7 << 20, + size: 256 << 10, /* 256 kB */ + }, + { + name: "environment", /* PPCBoot Environment */ + offset: ((7 << 20) + (256 << 10)), + size: 256 << 10, /* 256 kB */ + }, + { + name: "spare", /* Unused */ + offset: ((7 << 20) + (512 << 10)), + size: 512 << 10, /* 512 kB */ + }, +}; +#endif /* CONFIG_MTD_PARTITIONS */ + +#define NB_OF(x) (sizeof(x)/sizeof(x[0])) + +int __init init_ads(void) +{ + int idx = 0, ret = 0; + unsigned long flash_addr, flash_size, mtd_size = 0; + /* pointer to MPC8260ADS board info data */ + bd_t *bd = (bd_t *)__res; + + flash_addr = bd->bi_flashstart; + flash_size = bd->bi_flashsize; + + printk("%s: bd->bi_flashstart=0x%8X, bd->bi_flashsize=%8X\n", + __FUNCTION__,bd->bi_flashstart,bd->bi_flashsize); + + /* request maximum flash size address space */ + start_scan_addr = (unsigned long)ioremap(flash_addr, flash_size); + if (!start_scan_addr) { + printk("%s: Failed to ioremap address: 0x%x\n", + __FUNCTION__, flash_addr); + return -EIO; + } + + for(idx = 0 ; idx < FLASH_BANK_MAX ; idx++) { + + printk("%s: mtd_size=0x%8X\n",__FUNCTION__,mtd_size); +#if 0 /* mtd_size ??? XXX FIXME */ + if (mtd_size >= flash_size) + break; +#endif + + debugk ("%s: chip probing count %d\n", __FUNCTION__, idx); + + map_banks[idx] = (struct map_info *)kmalloc(sizeof(struct map_info), + GFP_KERNEL); + if (map_banks[idx] == NULL) + { + ret = -ENOMEM; + goto error_mem; + } + memset((void *)map_banks[idx], 0, sizeof(struct map_info)); + map_banks[idx]->name = (char *)kmalloc(16, GFP_KERNEL); + if (map_banks[idx]->name == NULL) + { + ret = -ENOMEM; + goto error_mem; + } + memset((void *)map_banks[idx]->name, 0, 16); + + sprintf(map_banks[idx]->name, "MPC8260ADS Bank %d", idx); + map_banks[idx]->buswidth = 4; + map_banks[idx]->size = flash_size; + map_banks[idx]->read8 = mpc8260ads_read8; + map_banks[idx]->read16 = mpc8260ads_read16; + map_banks[idx]->read32 = mpc8260ads_read32; + map_banks[idx]->copy_from = mpc8260ads_copy_from; + map_banks[idx]->write8 = mpc8260ads_write8; + map_banks[idx]->write16 = mpc8260ads_write16; + map_banks[idx]->write32 = mpc8260ads_write32; + map_banks[idx]->copy_to = mpc8260ads_copy_to; + map_banks[idx]->map_priv_1= + start_scan_addr + ((idx > 0) ? + (mtd_banks[idx-1] ? mtd_banks[idx-1]->size : 0) : 0); + + /* start to probe flash chips */ + mtd_banks[idx] = do_map_probe("jedec_probe", map_banks[idx]); + if (mtd_banks[idx]) { + mtd_banks[idx]->module = THIS_MODULE; + mtd_size += mtd_banks[idx]->size; + num_banks++; + debugk ("%s: bank%d, name:%s, size:%dbytes \n", + __FUNCTION__, + num_banks, + mtd_banks[idx]->name, + mtd_banks[idx]->size); + } + } + + /* no supported flash chips found */ + if (!num_banks) { + printk("MPC8260ADS: No supported flash chips found!\n"); + ret = -ENXIO; + goto error_mem; + } + +#ifdef CONFIG_MTD_PARTITIONS + /* + * Select static partition definitions + */ + part_banks[0].mtd_part = mpc8260ads_partitions; + part_banks[0].type = "static image"; + part_banks[0].nums = NB_OF(mpc8260ads_partitions); + + for(idx = 0; idx < num_banks ; idx++) { + if (part_banks[idx].nums == 0) { + printk (KERN_NOTICE + "MPC8260ADS flash bank %d: no partition info available, " + "registering whole device\n", + idx); + add_mtd_device(mtd_banks[idx]); + } else { + printk (KERN_NOTICE + "MPC8260ADS flash bank %d: Using %s partition definition\n", + idx, + part_banks[idx].type); + add_mtd_partitions (mtd_banks[idx], + part_banks[idx].mtd_part, + part_banks[idx].nums); + } + } +#else + printk (KERN_NOTICE "MPC8260ADS flash: registering %d flash banks at once\n", + num_banks); + + for(idx = 0 ; idx < num_banks ; idx++) { + add_mtd_device(mtd_banks[idx]); + } +#endif + return 0; +error_mem: + for(idx = 0 ; idx < FLASH_BANK_MAX ; idx++) { + if (map_banks[idx] != NULL) { + if (map_banks[idx]->name != NULL) { + kfree(map_banks[idx]->name); + map_banks[idx]->name = NULL; + } + kfree(map_banks[idx]); + map_banks[idx] = NULL; + } + } +error: + iounmap((void *)start_scan_addr); + return ret; +} + +static void __exit cleanup_ads(void) +{ + unsigned int idx = 0; + for(idx = 0 ; idx < num_banks ; idx++) { + /* destroy mtd_info previously allocated */ + if (mtd_banks[idx]) { + del_mtd_partitions(mtd_banks[idx]); + map_destroy(mtd_banks[idx]); + } + /* release map_info not used anymore */ + kfree(map_banks[idx]->name); + kfree(map_banks[idx]); + } + if (start_scan_addr) { + iounmap((void *)start_scan_addr); + start_scan_addr = 0; + } +} + +module_init(init_ads); +module_exit(cleanup_ads); + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Christian Gagneraud "); +MODULE_DESCRIPTION("MTD map driver for MPC8260ADS boards"); diff -Naur --exclude=test mtd-20020403/fs/jffs2/background.c linux-denx-2.4.4-20020321-edu/fs/jffs2/background.c --- mtd-20020403/fs/jffs2/background.c Wed Apr 3 15:33:54 2002 +++ linux-denx-2.4.4-20020321-edu/fs/jffs2/background.c Thu Apr 25 17:40:29 2002 @@ -37,6 +37,7 @@ #define __KERNEL_SYSCALLS__ +#include /* GANS */ #include #include #include diff -Naur mtd-20020403/include/linux/mtd/compatmac.h mtd-20020403-edu/include/linux/mtd/compatmac.h --- mtd-20020403/include/linux/mtd/compatmac.h Wed Apr 3 15:33:54 2002 +++ linux-denx-2.4.4-20020321-edu/include/linux/mtd/compatmac.h Fri Apr 26 17:07:32 2002 @@ -426,6 +426,7 @@ ({ type __x = (x); type __y = (y); __x > __y ? __x: __y; }) #endif +#ifndef _COMPLETION_H_ /* GANS */ #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,7) struct completion { struct semaphore s; @@ -435,12 +436,14 @@ #define wait_for_completion(c) down(&(c)->s) #define init_completion(c) init_MUTEX_LOCKED(&(c)->s); -#endif +#endif #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,9) /* This came later */ #define complete_and_exit(c, r) do { complete(c); do_exit(r); } while(0) #endif + +#endif /* _COMPLETION_H_ GANS */ #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,9) || \ (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,10) && !defined(__rh_config_h__)) diff -Naur mtd-20020403/lib/zlib_deflate/Makefile mtd-20020403-edu/lib/zlib_deflate/Makefile --- mtd-20020403/lib/zlib_deflate/Makefile Wed Apr 10 17:02:55 2002 +++ mtd-20020403-edu/lib/zlib_deflate/Makefile Mon Apr 22 19:34:33 2002 @@ -8,10 +8,10 @@ O_TARGET := zlib_deflate.o -export-objs := deflate_syms.o +#GANS export-objs := deflate_syms.o -obj-y := deflate.o deftree.o deflate_syms.o -obj-y := $(O_TARGET) +obj-y := deflate.o deftree.o #GANS deflate_syms.o +#GANS obj-y := $(O_TARGET) EXTRA_CFLAGS += -I $(TOPDIR)/lib/zlib_deflate diff -Naur mtd-20020403/lib/zlib_inflate/Makefile mtd-20020403-edu/lib/zlib_inflate/Makefile --- mtd-20020403/lib/zlib_inflate/Makefile Wed Apr 10 17:03:50 2002 +++ mtd-20020403-edu/lib/zlib_inflate/Makefile Mon Apr 22 19:34:33 2002 @@ -15,11 +15,11 @@ O_TARGET := zlib_inflate.o -export-objs := inflate_syms.o +#GANS export-objs := inflate_syms.o obj-y := infblock.o infcodes.o inffast.o inflate.o \ - inftrees.o infutil.o inflate_syms.o -obj-y := $(O_TARGET) + inftrees.o infutil.o #GANS inflate_syms.o +#GANS obj-y := $(O_TARGET) EXTRA_CFLAGS += -I $(TOPDIR)/lib/zlib_inflate diff -Naur mtd-20020403/patches/patchin.sh mtd-20020403-edu/patches/patchin.sh --- mtd-20020403/patches/patchin.sh Wed Apr 3 15:33:55 2002 +++ mtd-20020403-edu/patches/patchin.sh Thu Apr 11 19:19:01 2002 @@ -6,11 +6,14 @@ exit 1 fi +HERE=`pwd` cd `dirname $0` THISDIR=`pwd` TOPDIR=`dirname $THISDIR` LINUXDIR=$1 + +cd $HERE if [ ! -f $LINUXDIR/Makefile ] then echo "Directory" $LINUXDIR "doesn't exist, or doesn't contain Linux sources" @@ -30,6 +33,9 @@ mkdir -p drivers/mtd/nand mkdir -p include/linux/mtd mkdir -p fs/jffs +mkdir -p fs/jffs2 +mkdir -p lib/zlib_deflate +mkdir -p lib/zlib_inflate ln -sf $TOPDIR/drivers/mtd/*.[ch] drivers/mtd ln -sf $TOPDIR/drivers/mtd/*akefile $TOPDIR/drivers/mtd/Rules.make $TOPDIR/drivers/mtd/Config.in drivers/mtd ln -sf $TOPDIR/drivers/mtd/chips/*.[ch] drivers/mtd/chips @@ -42,8 +48,17 @@ ln -sf $TOPDIR/drivers/mtd/nand/*akefile $TOPDIR/drivers/mtd/nand/Config.in drivers/mtd/nand ln -sf $TOPDIR/fs/jffs/*.[ch] fs/jffs ln -sf $TOPDIR/fs/jffs/*akefile fs/jffs -ln -sf $TOPDIR/include/linux/jffs.h include/linux +ln -sf $TOPDIR/fs/jffs2/*.[ch] fs/jffs2 +ln -sf $TOPDIR/fs/jffs2/*akefile fs/jffs2 +ln -sf $TOPDIR/include/linux/jffs*.h include/linux +ln -sf $TOPDIR/include/linux/jffs2*.h include/linux ln -sf $TOPDIR/include/linux/mtd/*.h include/linux/mtd +ln -sf $TOPDIR/include/linux/z*.h include/linux +ln -sf $TOPDIR/fs/jffs2/crc32.h include/linux +ln -sf $TOPDIR/lib/zlib_deflate/*akefile lib/zlib_deflate +ln -sf $TOPDIR/lib/zlib_deflate/*.[ch] lib/zlib_deflate +ln -sf $TOPDIR/lib/zlib_inflate/*akefile lib/zlib_inflate +ln -sf $TOPDIR/lib/zlib_inflate/*.[ch] lib/zlib_inflate # # kernel patches