Skip to content
Snippets Groups Projects
Select Git revision
1 result Searching

timer.c

Blame
  • Forked from Reform / reform-boundary-uboot
    Source project has a limited visibility.
    cmd_nand.c 26.75 KiB
    /*
     * Driver for NAND support, Rick Bronson
     * borrowed heavily from:
     * (c) 1999 Machine Vision Holdings, Inc.
     * (c) 1999, 2000 David Woodhouse <dwmw2@infradead.org>
     *
     * Added 16-bit nand support
     * (C) 2004 Texas Instruments
     */
    
    #include <common.h>
    
    
    #ifndef CONFIG_NAND_LEGACY
    /*
     *
     * New NAND support
     *
     */
    #include <common.h>
    #include <linux/mtd/mtd.h>
    
    #if defined(CONFIG_CMD_NAND)
    
    #include <command.h>
    #include <watchdog.h>
    #include <malloc.h>
    #include <asm/byteorder.h>
    #include <jffs2/jffs2.h>
    #include <nand.h>
    
    #if defined(CONFIG_CMD_JFFS2) && defined(CONFIG_JFFS2_CMDLINE)
    
    /* parition handling routines */
    int mtdparts_init(void);
    int id_parse(const char *id, const char **ret_id, u8 *dev_type, u8 *dev_num);
    int find_dev_and_part(const char *id, struct mtd_device **dev,
    		      u8 *part_num, struct part_info **part);
    #endif
    
    static int nand_dump(nand_info_t *nand, ulong off, int only_oob)
    {
    	int i;
    	u_char *datbuf, *oobbuf, *p;
    
    	datbuf = malloc(nand->writesize + nand->oobsize);
    	oobbuf = malloc(nand->oobsize);
    	if (!datbuf || !oobbuf) {
    		puts("No memory for page buffer\n");
    		return 1;
    	}
    	off &= ~(nand->writesize - 1);
    	loff_t addr = (loff_t) off;
    	struct mtd_oob_ops ops;
    	memset(&ops, 0, sizeof(ops));
    	ops.datbuf = datbuf;
    	ops.oobbuf = oobbuf; /* must exist, but oob data will be appended to ops.datbuf */
    	ops.len = nand->writesize;
    	ops.ooblen = nand->oobsize;
    	ops.mode = MTD_OOB_RAW;
    	i = nand->read_oob(nand, addr, &ops);
    	if (i < 0) {
    		printf("Error (%d) reading page %08lx\n", i, off);
    		free(datbuf);
    		free(oobbuf);
    		return 1;
    	}
    	printf("Page %08lx dump:\n", off);
    	i = nand->writesize >> 4;
    	p = datbuf;