Merge branch 'master' of git://git.denx.de/u-boot-arm
authorWolfgang Denk <wd@denx.de>
Wed, 22 Jul 2009 22:59:37 +0000 (00:59 +0200)
committerWolfgang Denk <wd@denx.de>
Wed, 22 Jul 2009 22:59:37 +0000 (00:59 +0200)
296 files changed:
.gitignore
Makefile
README
board/armltd/integrator/split_by_variant.sh
board/bmw/bmw.c
board/delta/nand.c
board/esd/common/auto_update.c
board/esd/cpci750/mv_eth.h
board/freescale/common/pixis.c
board/freescale/mpc832xemds/Makefile
board/freescale/mpc832xemds/pci.c
board/freescale/mpc8349emds/Makefile
board/freescale/mpc8349emds/pci.c
board/freescale/mpc8349itx/Makefile
board/freescale/mpc8349itx/pci.c
board/freescale/mpc8360emds/Makefile
board/freescale/mpc8360emds/pci.c
board/freescale/mpc837xemds/Makefile
board/freescale/mpc837xemds/pci.c
board/freescale/mpc837xerdb/Makefile
board/freescale/mpc837xerdb/pci.c
board/freescale/mpc8536ds/mpc8536ds.c
board/freescale/mpc8544ds/mpc8544ds.c
board/freescale/mpc8572ds/mpc8572ds.c
board/freescale/mpc8610hpcd/mpc8610hpcd.c
board/freescale/mpc8610hpcd/mpc8610hpcd_diu.c
board/freescale/mpc8641hpcn/mpc8641hpcn.c
board/freescale/p2020ds/p2020ds.c
board/g2000/g2000.c
board/keymile/common/common.c
board/keymile/common/common.h
board/keymile/km8xx/km8xx.c
board/keymile/kmeter1/kmeter1.c
board/keymile/mgcoge/mgcoge.c
board/mpl/common/common_util.c
board/mpl/common/common_util.h
board/mpl/common/flash.c
board/mpl/mip405/mip405.c
board/mpl/pati/cmd_pati.c
board/mpl/pati/pati.c
board/mpl/pip405/pip405.c
board/mpl/vcma9/vcma9.c
board/netphone/netphone.c
board/netta/netta.c
board/netta2/netta2.c
board/netvia/netvia.c
board/omap2420h4/omap2420h4.c
board/pcippc2/pcippc2.c
board/rbc823/rbc823.c
board/samsung/smdk6400/smdk6400.c
board/sbc8349/Makefile
board/sbc8349/pci.c
board/sbc8641d/sbc8641d.c
board/sixnet/sixnet.c
board/stxxtc/stxxtc.c
board/tqc/tqm834x/Makefile
board/tqc/tqm834x/pci.c
board/tqc/tqm85xx/sdram.c
board/xes/common/fsl_8xxx_ddr.c
board/xes/xpedite5370/xpedite5370.c
board/zylonite/nand.c
common/Makefile
common/cmd_bootm.c
common/cmd_doc.c [deleted file]
common/cmd_flash.c
common/cmd_jffs2.c
common/cmd_mtdparts.c
common/cmd_nand.c
common/cmd_tsi148.c [new file with mode: 0644]
common/cmd_ubi.c
common/console.c
common/docecc.c [deleted file]
common/env_nand.c
common/env_onenand.c
common/xyzModem.c
config.mk
cpu/arm_cortexa8/cpu.c
cpu/blackfin/Makefile
cpu/blackfin/os_log.c [new file with mode: 0644]
cpu/mpc86xx/ddr-8641.c
cpu/mpc8xxx/ddr/main.c
cpu/mpc8xxx/ddr/util.c
cpu/ppc4xx/Makefile
doc/README.nand
doc/feature-removal-schedule.txt
drivers/block/Makefile
drivers/block/fsl_sata.c
drivers/block/fsl_sata.h
drivers/block/sata_dwc.c [new file with mode: 0644]
drivers/block/sata_dwc.h [new file with mode: 0644]
drivers/i2c/fsl_i2c.c
drivers/mmc/mmc.c
drivers/mtd/nand/Makefile
drivers/mtd/nand/davinci_nand.c
drivers/mtd/nand/diskonchip.c
drivers/mtd/nand/nand_util.c
drivers/mtd/nand/ndfc.c [moved from cpu/ppc4xx/ndfc.c with 98% similarity]
drivers/mtd/nand_legacy/Makefile [deleted file]
drivers/mtd/nand_legacy/nand_legacy.c [deleted file]
examples/api/.gitignore [moved from api_examples/.gitignore with 100% similarity]
examples/api/Makefile [moved from api_examples/Makefile with 91% similarity]
examples/api/crt0.S [moved from api_examples/crt0.S with 100% similarity]
examples/api/demo.c [moved from api_examples/demo.c with 100% similarity]
examples/api/glue.c [moved from api_examples/glue.c with 100% similarity]
examples/api/glue.h [moved from api_examples/glue.h with 100% similarity]
examples/api/libgenwrap.c [moved from api_examples/libgenwrap.c with 100% similarity]
examples/standalone/.gitignore [moved from examples/.gitignore with 100% similarity]
examples/standalone/82559_eeprom.c [moved from examples/82559_eeprom.c with 100% similarity]
examples/standalone/Makefile [moved from examples/Makefile with 100% similarity]
examples/standalone/README.smc91111_eeprom [moved from examples/README.smc91111_eeprom with 100% similarity]
examples/standalone/eepro100_eeprom.c [moved from examples/eepro100_eeprom.c with 100% similarity]
examples/standalone/hello_world.c [moved from examples/hello_world.c with 100% similarity]
examples/standalone/interrupt.c [moved from examples/interrupt.c with 100% similarity]
examples/standalone/mem_to_mem_idma2intr.c [moved from examples/mem_to_mem_idma2intr.c with 100% similarity]
examples/standalone/mips.lds [moved from examples/mips.lds with 100% similarity]
examples/standalone/nios.lds [moved from examples/nios.lds with 100% similarity]
examples/standalone/nios2.lds [moved from examples/nios2.lds with 100% similarity]
examples/standalone/ppc_longjmp.S [moved from examples/ppc_longjmp.S with 100% similarity]
examples/standalone/ppc_setjmp.S [moved from examples/ppc_setjmp.S with 100% similarity]
examples/standalone/sched.c [moved from examples/sched.c with 100% similarity]
examples/standalone/smc91111_eeprom.c [moved from examples/smc91111_eeprom.c with 100% similarity]
examples/standalone/smc911x_eeprom.c [moved from examples/smc911x_eeprom.c with 100% similarity]
examples/standalone/sparc.lds [moved from examples/sparc.lds with 100% similarity]
examples/standalone/stubs.c [moved from examples/stubs.c with 100% similarity]
examples/standalone/test_burst.c [moved from examples/test_burst.c with 100% similarity]
examples/standalone/test_burst.h [moved from examples/test_burst.h with 100% similarity]
examples/standalone/test_burst_lib.S [moved from examples/test_burst_lib.S with 100% similarity]
examples/standalone/timer.c [moved from examples/timer.c with 100% similarity]
examples/standalone/x86-testapp.c [moved from examples/x86-testapp.c with 100% similarity]
fs/jffs2/jffs2_1pass.c
fs/jffs2/jffs2_nand_1pass.c
include/asm-blackfin/blackfin_local.h
include/asm-ppc/immap_86xx.h
include/common.h
include/compiler.h [new file with mode: 0644]
include/configs/ASH405.h
include/configs/BMW.h
include/configs/CATcenter.h
include/configs/CMS700.h
include/configs/CPU86.h
include/configs/CPU87.h
include/configs/G2000.h
include/configs/GEN860T.h
include/configs/HH405.h
include/configs/HUB405.h
include/configs/IDS8247.h
include/configs/MIP405.h
include/configs/MPC832XEMDS.h
include/configs/MPC8349ITX.h
include/configs/MPC8360EMDS.h
include/configs/MPC837XERDB.h
include/configs/MPC8536DS.h
include/configs/MPC8540ADS.h
include/configs/MPC8541CDS.h
include/configs/MPC8544DS.h
include/configs/MPC8548CDS.h
include/configs/MPC8555CDS.h
include/configs/MPC8560ADS.h
include/configs/MPC8568MDS.h
include/configs/MPC8569MDS.h
include/configs/MPC8572DS.h
include/configs/MPC8641HPCN.h
include/configs/NETPHONE.h
include/configs/NETTA.h
include/configs/NETTA2.h
include/configs/NETVIA.h
include/configs/P2020DS.h
include/configs/PCIPPC2.h
include/configs/PCIPPC6.h
include/configs/PIP405.h
include/configs/PLU405.h
include/configs/PM520.h
include/configs/PM826.h
include/configs/PM828.h
include/configs/PPChameleonEVB.h
include/configs/RBC823.h
include/configs/SXNI855T.h
include/configs/TQM8272.h
include/configs/TQM834x.h
include/configs/TQM85xx.h
include/configs/VCMA9.h
include/configs/VOH405.h
include/configs/WUH405.h
include/configs/XPEDITE5170.h
include/configs/XPEDITE5200.h
include/configs/XPEDITE5370.h
include/configs/acadia.h
include/configs/afeb9260.h
include/configs/apollon.h
include/configs/aria.h
include/configs/at91cap9adk.h
include/configs/at91rm9200dk.h
include/configs/at91rm9200ek.h
include/configs/at91sam9260ek.h
include/configs/at91sam9261ek.h
include/configs/at91sam9263ek.h
include/configs/at91sam9m10g45ek.h
include/configs/at91sam9rlek.h
include/configs/bf533-stamp.h
include/configs/bf537-minotaur.h
include/configs/bf537-srv1.h
include/configs/canyonlands.h
include/configs/csb637.h
include/configs/davinci_schmoogie.h
include/configs/davinci_sffsdr.h
include/configs/delta.h
include/configs/digsy_mtc.h
include/configs/keymile-common.h
include/configs/kilauea.h
include/configs/km8xx.h
include/configs/kmeter1.h
include/configs/m501sk.h
include/configs/mecp5123.h
include/configs/meesc.h
include/configs/mgcoge.h
include/configs/netstar.h
include/configs/omap2420h4.h
include/configs/omap3_beagle.h
include/configs/omap3_evm.h
include/configs/omap3_overo.h
include/configs/omap3_pandora.h
include/configs/omap3_zoom1.h
include/configs/omap3_zoom2.h
include/configs/pdnb3.h
include/configs/pm9261.h
include/configs/pm9263.h
include/configs/qemu-mips.h
include/configs/quad100hd.h
include/configs/sbc2410x.h
include/configs/sbc8349.h
include/configs/sc3.h
include/configs/smdk6400.h
include/configs/socrates.h
include/configs/stxxtc.h
include/configs/svm_sc8xx.h
include/configs/zylonite.h
include/elf.h
include/environment.h
include/i2c.h
include/image.h
include/libfdt_env.h
include/linux/mtd/nand.h
include/linux/mtd/nand_ids.h [deleted file]
include/linux/mtd/nand_legacy.h [deleted file]
include/lzma/LzmaDec.h [moved from include/lzma/LzmaDecode.h with 81% similarity]
include/lzma/LzmaTools.h
include/lzma/LzmaTypes.h
include/malloc.h
include/nand.h
include/netdev.h
include/stdio_dev.h
include/tsi148.h [new file with mode: 0644]
include/u-boot/md5.h
lib_arm/config.mk [moved from arm_config.mk with 97% similarity]
lib_avr32/config.mk [moved from avr32_config.mk with 96% similarity]
lib_blackfin/board.c
lib_blackfin/config.mk [moved from blackfin_config.mk with 98% similarity]
lib_generic/crc32.c
lib_generic/lzma/LGPL.txt [deleted file]
lib_generic/lzma/LzmaDec.c [new file with mode: 0644]
lib_generic/lzma/LzmaDec.h [new file with mode: 0644]
lib_generic/lzma/LzmaDecode.c [deleted file]
lib_generic/lzma/LzmaDecode.h [deleted file]
lib_generic/lzma/LzmaTools.c
lib_generic/lzma/LzmaTools.h
lib_generic/lzma/LzmaTypes.h [deleted file]
lib_generic/lzma/Makefile
lib_generic/lzma/README.txt
lib_generic/lzma/Types.h [new file with mode: 0644]
lib_generic/lzma/history.txt
lib_generic/lzma/import_lzmasdk.sh
lib_generic/lzma/license.txt [new file with mode: 0644]
lib_generic/lzma/lzma.txt
lib_generic/md5.c
lib_i386/config.mk [moved from i386_config.mk with 96% similarity]
lib_m68k/config.mk [moved from m68k_config.mk with 97% similarity]
lib_microblaze/config.mk [moved from microblaze_config.mk with 97% similarity]
lib_mips/config.mk [moved from mips_config.mk with 98% similarity]
lib_nios/config.mk [moved from nios_config.mk with 97% similarity]
lib_nios2/config.mk [moved from nios2_config.mk with 97% similarity]
lib_ppc/config.mk [moved from ppc_config.mk with 98% similarity]
lib_sh/config.mk [moved from sh_config.mk with 97% similarity]
lib_sparc/config.mk [moved from sparc_config.mk with 96% similarity]
nand_spl/board/amcc/acadia/Makefile
nand_spl/board/amcc/bamboo/Makefile
nand_spl/board/amcc/canyonlands/Makefile
nand_spl/board/amcc/kilauea/Makefile
nand_spl/board/amcc/sequoia/Makefile
tools/bmp_logo.c
tools/img2srec.c
tools/mingw_support.h
tools/mkimage.c
tools/mkimage.h
tools/os_support.c
tools/os_support.h
tools/ubsha1.c

index e13fc96..8ccd42a 100644 (file)
@@ -54,6 +54,7 @@ series
 cscope.*
 
 # tags files
+/tags
 /ctags
 /etags
 
index 12224ad..a7ffe25 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -140,8 +140,8 @@ endif
 # The "tools" are needed early, so put this first
 # Don't include stuff already done in $(LIBS)
 SUBDIRS        = tools \
-         examples \
-         api_examples
+         examples/standalone \
+         examples/api
 
 .PHONY : $(SUBDIRS)
 
@@ -151,50 +151,10 @@ ifeq ($(obj)include/config.mk,$(wildcard $(obj)include/config.mk))
 include $(obj)include/config.mk
 export ARCH CPU BOARD VENDOR SOC
 
-ifndef CROSS_COMPILE
+# set default to nothing for native builds
 ifeq ($(HOSTARCH),$(ARCH))
-CROSS_COMPILE =
-else
-ifeq ($(ARCH),ppc)
-CROSS_COMPILE = ppc_8xx-
-endif
-ifeq ($(ARCH),arm)
-CROSS_COMPILE = arm-linux-
-endif
-ifeq ($(ARCH),i386)
-CROSS_COMPILE = i386-linux-
-endif
-ifeq ($(ARCH),mips)
-CROSS_COMPILE = mips_4KC-
-endif
-ifeq ($(ARCH),nios)
-CROSS_COMPILE = nios-elf-
-endif
-ifeq ($(ARCH),nios2)
-CROSS_COMPILE = nios2-elf-
-endif
-ifeq ($(ARCH),m68k)
-CROSS_COMPILE = m68k-elf-
+CROSS_COMPILE ?=
 endif
-ifeq ($(ARCH),microblaze)
-CROSS_COMPILE = mb-
-endif
-ifeq ($(ARCH),blackfin)
-CROSS_COMPILE = bfin-uclinux-
-endif
-ifeq ($(ARCH),avr32)
-CROSS_COMPILE = avr32-linux-
-endif
-ifeq ($(ARCH),sh)
-CROSS_COMPILE = sh4-linux-
-endif
-ifeq ($(ARCH),sparc)
-CROSS_COMPILE = sparc-elf-
-endif  # sparc
-endif  # HOSTARCH,ARCH
-endif  # CROSS_COMPILE
-
-export CROSS_COMPILE
 
 # load other configuration
 include $(TOPDIR)/config.mk
@@ -246,7 +206,6 @@ LIBS += drivers/misc/libmisc.a
 LIBS += drivers/mmc/libmmc.a
 LIBS += drivers/mtd/libmtd.a
 LIBS += drivers/mtd/nand/libnand.a
-LIBS += drivers/mtd/nand_legacy/libnand_legacy.a
 LIBS += drivers/mtd/onenand/libonenand.a
 LIBS += drivers/mtd/ubi/libubi.a
 LIBS += drivers/mtd/spi/libspi_flash.a
@@ -428,7 +387,6 @@ TAG_SUBDIRS += drivers/misc
 TAG_SUBDIRS += drivers/mmc
 TAG_SUBDIRS += drivers/mtd
 TAG_SUBDIRS += drivers/mtd/nand
-TAG_SUBDIRS += drivers/mtd/nand_legacy
 TAG_SUBDIRS += drivers/mtd/onenand
 TAG_SUBDIRS += drivers/mtd/spi
 TAG_SUBDIRS += drivers/net
@@ -698,7 +656,8 @@ o2dnt_config:       unconfig
 
 pcm030_config \
 pcm030_LOWBOOT_config: unconfig
-       @ >include/config.h
+       @mkdir -p $(obj)include $(obj)board/phytec/pcm030
+       @ >$(obj)include/config.h
        @[ -z "$(findstring LOWBOOT_,$@)" ] || \
                { echo "TEXT_BASE = 0xFF000000" >$(obj)board/phytec/pcm030/config.tmp ; \
                  echo "... with LOWBOOT configuration" ; \
@@ -3641,11 +3600,16 @@ grsim_leon2_config : unconfig
 #########################################################################
 
 clean:
-       @rm -f $(obj)examples/82559_eeprom $(obj)examples/eepro100_eeprom \
-              $(obj)examples/hello_world  $(obj)examples/interrupt       \
-              $(obj)examples/mem_to_mem_idma2intr                        \
-              $(obj)examples/sched        $(obj)examples/smc91111_eeprom \
-              $(obj)examples/test_burst   $(obj)examples/timer
+       @rm -f $(obj)examples/standalone/82559_eeprom                     \
+              $(obj)examples/standalone/eepro100_eeprom                  \
+              $(obj)examples/standalone/hello_world                      \
+              $(obj)examples/standalone/interrupt                        \
+              $(obj)examples/standalone/mem_to_mem_idma2intr             \
+              $(obj)examples/standalone/sched                            \
+              $(obj)examples/standalone/smc91111_eeprom                  \
+              $(obj)examples/standalone/test_burst                       \
+              $(obj)examples/standalone/timer
+       @rm -f $(obj)examples/api/demo{,.bin}
        @rm -f $(obj)tools/bmp_logo        $(obj)tools/easylogo/easylogo  \
               $(obj)tools/env/{fw_printenv,fw_setenv}                    \
               $(obj)tools/envcrc                                         \
@@ -3662,7 +3626,7 @@ clean:
        @rm -f $(obj)include/bmp_logo.h
        @rm -f $(obj)nand_spl/{u-boot-spl,u-boot-spl.map,System.map}
        @rm -f $(obj)onenand_ipl/onenand-{ipl,ipl.bin,ipl-2k.bin,ipl-4k.bin,ipl.map}
-       @rm -f $(obj)api_examples/demo $(TIMESTAMP_FILE) $(VERSION_FILE)
+       @rm -f $(TIMESTAMP_FILE) $(VERSION_FILE)
        @find $(OBJTREE) -type f \
                \( -name 'core' -o -name '*.bak' -o -name '*~' \
                -o -name '*.o'  -o -name '*.a' -o -name '*.exe' \) -print \
diff --git a/README b/README
index 7e43c21..4c74cb7 100644 (file)
--- a/README
+++ b/README
@@ -603,7 +603,6 @@ The following options need to be configured:
                CONFIG_CMD_DATE         * support for RTC, date/time...
                CONFIG_CMD_DHCP         * DHCP support
                CONFIG_CMD_DIAG         * Diagnostics
-               CONFIG_CMD_DOC          * Disk-On-Chip Support
                CONFIG_CMD_DS4510       * ds4510 I2C gpio commands
                CONFIG_CMD_DS4510_INFO  * ds4510 I2C info command
                CONFIG_CMD_DS4510_MEM   * ds4510 I2C eeprom/sram commansd
index d67bdc2..702b436 100755 (executable)
@@ -231,5 +231,5 @@ fi # ap
 # ---------------------------------------------------------
 # Complete the configuration
 # ---------------------------------------------------------
-$MKCONFIG -a integrator$1 arm $cpu integrator armltd;
-echo "Variant:: $variant with core $cpu"
+$MKCONFIG -a -n "${2%%_config}" integrator$1 arm $cpu integrator armltd
+echo "Variant: $variant with core $cpu"
index 870011e..4039145 100644 (file)
@@ -117,6 +117,7 @@ sys_led_msg(char* msg)
     LED_REG(3) = msg[0];
 }
 
+#ifdef CONFIG_CMD_DOC
 /*
  * Map onboard TSOP-16MB DOC FLASH chip.
  */
@@ -124,6 +125,7 @@ void doc_init (void)
 {
     doc_probe(DOC_BASE_ADDR);
 }
+#endif
 
 #define NV_ADDR        ((volatile unsigned char *) CONFIG_ENV_ADDR)
 
index aff7c54..e87d502 100644 (file)
@@ -23,7 +23,6 @@
 #include <common.h>
 
 #if defined(CONFIG_CMD_NAND)
-#if !defined(CONFIG_NAND_LEGACY)
 
 #include <nand.h>
 #include <asm/arch/pxa-regs.h>
@@ -550,7 +549,4 @@ int board_nand_init(struct nand_chip *nand)
        return 0;
 }
 
-#else
- #error "U-Boot legacy NAND support not available for Monahans DFC."
-#endif
 #endif
index 33aeb46..c4a49e2 100644 (file)
@@ -27,9 +27,6 @@
 #include <command.h>
 #include <image.h>
 #include <asm/byteorder.h>
-#if defined(CONFIG_NAND_LEGACY)
-#include <linux/mtd/nand_legacy.h>
-#endif
 #include <fat.h>
 #include <part.h>
 
@@ -58,20 +55,6 @@ extern int flash_sect_erase(ulong, ulong);
 extern int flash_sect_protect (int, ulong, ulong);
 extern int flash_write (char *, ulong, ulong);
 
-#if defined(CONFIG_CMD_NAND) && defined(CONFIG_NAND_LEGACY)
-/* references to names in cmd_nand.c */
-#define NANDRW_READ    0x01
-#define NANDRW_WRITE   0x00
-#define NANDRW_JFFS2   0x02
-#define NANDRW_JFFS2_SKIP      0x04
-extern struct nand_chip nand_dev_desc[];
-extern int nand_legacy_rw(struct nand_chip* nand, int cmd,
-                         size_t start, size_t len,
-                         size_t * retlen, u_char * buf);
-extern int nand_legacy_erase(struct nand_chip* nand, size_t ofs,
-                            size_t len, int clean);
-#endif
-
 extern block_dev_desc_t ide_dev_desc[CONFIG_SYS_IDE_MAXDEVICE];
 
 int au_check_cksum_valid(int i, long nbytes)
@@ -158,9 +141,6 @@ int au_do_update(int i, long sz)
        int off, rc;
        uint nbytes;
        int k;
-#if defined(CONFIG_CMD_NAND) && defined(CONFIG_NAND_LEGACY)
-       int total;
-#endif
 
        hdr = (image_header_t *)LOAD_ADDR;
 #if defined(CONFIG_FIT)
@@ -240,15 +220,6 @@ int au_do_update(int i, long sz)
                                au_image[i].name);
                        debug ("flash_sect_erase(%lx, %lx);\n", start, end);
                        flash_sect_erase (start, end);
-               } else {
-#if defined(CONFIG_CMD_NAND) && defined(CONFIG_NAND_LEGACY)
-                       printf ("Updating NAND FLASH with image %s\n",
-                               au_image[i].name);
-                       debug ("nand_legacy_erase(%lx, %lx);\n", start, end);
-                       rc = nand_legacy_erase (nand_dev_desc, start,
-                                               end - start + 1, 0);
-                       debug ("nand_legacy_erase returned %x\n", rc);
-#endif
                }
 
                udelay(10000);
@@ -273,18 +244,7 @@ int au_do_update(int i, long sz)
                        rc = flash_write ((char *)addr, start,
                                          (nbytes + 1) & ~1);
                } else {
-#if defined(CONFIG_CMD_NAND) && defined(CONFIG_NAND_LEGACY)
-                       debug ("nand_legacy_rw(%p, %lx, %x)\n",
-                              addr, start, nbytes);
-                       rc = nand_legacy_rw (nand_dev_desc,
-                                            NANDRW_WRITE | NANDRW_JFFS2,
-                                            start, nbytes, (size_t *)&total,
-                                            (uchar *)addr);
-                       debug ("nand_legacy_rw: ret=%x total=%d nbytes=%d\n",
-                              rc, total, nbytes);
-#else
                        rc = -1;
-#endif
                }
                if (rc != 0) {
                        printf ("Flashing failed due to error %d\n", rc);
@@ -297,16 +257,6 @@ int au_do_update(int i, long sz)
                if (au_image[i].type != AU_NAND) {
                        rc = crc32 (0, (uchar *)(start + off),
                                    image_get_data_size (hdr));
-               } else {
-#if defined(CONFIG_CMD_NAND) && defined(CONFIG_NAND_LEGACY)
-                       rc = nand_legacy_rw (nand_dev_desc,
-                                            NANDRW_READ | NANDRW_JFFS2 |
-                                            NANDRW_JFFS2_SKIP,
-                                            start, nbytes, (size_t *)&total,
-                                            (uchar *)addr);
-                       rc = crc32 (0, (uchar *)(addr + off),
-                                   image_get_data_size (hdr));
-#endif
                }
                if (rc != image_get_dcrc (hdr)) {
                        printf ("Image %s Bad Data Checksum After COPY\n",
index c57e679..b761135 100644 (file)
@@ -37,7 +37,7 @@
 #include <common.h>
 #include <net.h>
 #include "mv_regs.h"
-#include "../../Marvell/common/ppc_error_no.h"
+#include <asm/errno.h>
 
 
 /*************************************************************************
index 4851f06..7210512 100644 (file)
@@ -39,7 +39,8 @@ static ulong strfractoint(uchar *strptr);
  */
 void pixis_reset(void)
 {
-    out8(PIXIS_BASE + PIXIS_RST, 0);
+       u8 *pixis_base = (u8 *)PIXIS_BASE;
+       out_8(pixis_base + PIXIS_RST, 0);
 }
 
 
@@ -49,6 +50,7 @@ void pixis_reset(void)
 int set_px_sysclk(ulong sysclk)
 {
        u8 sysclk_s, sysclk_r, sysclk_v, vclkh, vclkl, sysclk_aux;
+       u8 *pixis_base = (u8 *)PIXIS_BASE;
 
        switch (sysclk) {
        case 33:
@@ -107,10 +109,10 @@ int set_px_sysclk(ulong sysclk)
        vclkh = (sysclk_s << 5) | sysclk_r;
        vclkl = sysclk_v;
 
-       out8(PIXIS_BASE + PIXIS_VCLKH, vclkh);
-       out8(PIXIS_BASE + PIXIS_VCLKL, vclkl);
+       out_8(pixis_base + PIXIS_VCLKH, vclkh);
+       out_8(pixis_base + PIXIS_VCLKL, vclkl);
 
-       out8(PIXIS_BASE + PIXIS_AUX, sysclk_aux);
+       out_8(pixis_base + PIXIS_AUX, sysclk_aux);
 
        return 1;
 }
@@ -120,6 +122,7 @@ int set_px_mpxpll(ulong mpxpll)
 {
        u8 tmp;
        u8 val;
+       u8 *pixis_base = (u8 *)PIXIS_BASE;
 
        switch (mpxpll) {
        case 2:
@@ -137,9 +140,9 @@ int set_px_mpxpll(ulong mpxpll)
                return 0;
        }
 
-       tmp = in8(PIXIS_BASE + PIXIS_VSPEED1);
+       tmp = in_8(pixis_base + PIXIS_VSPEED1);
        tmp = (tmp & 0xF0) | (val & 0x0F);
-       out8(PIXIS_BASE + PIXIS_VSPEED1, tmp);
+       out_8(pixis_base + PIXIS_VSPEED1, tmp);
 
        return 1;
 }
@@ -149,6 +152,7 @@ int set_px_corepll(ulong corepll)
 {
        u8 tmp;
        u8 val;
+       u8 *pixis_base = (u8 *)PIXIS_BASE;
 
        switch ((int)corepll) {
        case 20:
@@ -174,9 +178,9 @@ int set_px_corepll(ulong corepll)
                return 0;
        }
 
-       tmp = in8(PIXIS_BASE + PIXIS_VSPEED0);
+       tmp = in_8(pixis_base + PIXIS_VSPEED0);
        tmp = (tmp & 0xE0) | (val & 0x1F);
-       out8(PIXIS_BASE + PIXIS_VSPEED0, tmp);
+       out_8(pixis_base + PIXIS_VSPEED0, tmp);
 
        return 1;
 }
@@ -184,27 +188,29 @@ int set_px_corepll(ulong corepll)
 
 void read_from_px_regs(int set)
 {
+       u8 *pixis_base = (u8 *)PIXIS_BASE;
        u8 mask = 0x1C; /* COREPLL, MPXPLL, SYSCLK controlled by PIXIS */
-       u8 tmp = in8(PIXIS_BASE + PIXIS_VCFGEN0);
+       u8 tmp = in_8(pixis_base + PIXIS_VCFGEN0);
 
        if (set)
                tmp = tmp | mask;
        else
                tmp = tmp & ~mask;
-       out8(PIXIS_BASE + PIXIS_VCFGEN0, tmp);
+       out_8(pixis_base + PIXIS_VCFGEN0, tmp);
 }
 
 
 void read_from_px_regs_altbank(int set)
 {
+       u8 *pixis_base = (u8 *)PIXIS_BASE;
        u8 mask = 0x04; /* FLASHBANK and FLASHMAP controlled by PIXIS */
-       u8 tmp = in8(PIXIS_BASE + PIXIS_VCFGEN1);
+       u8 tmp = in_8(pixis_base + PIXIS_VCFGEN1);
 
        if (set)
                tmp = tmp | mask;
        else
                tmp = tmp & ~mask;
-       out8(PIXIS_BASE + PIXIS_VCFGEN1, tmp);
+       out_8(pixis_base + PIXIS_VCFGEN1, tmp);
 }
 
 #ifndef CONFIG_SYS_PIXIS_VBOOT_MASK
@@ -214,50 +220,54 @@ void read_from_px_regs_altbank(int set)
 void clear_altbank(void)
 {
        u8 tmp;
+       u8 *pixis_base = (u8 *)PIXIS_BASE;
 
-       tmp = in8(PIXIS_BASE + PIXIS_VBOOT);
+       tmp = in_8(pixis_base + PIXIS_VBOOT);
        tmp &= ~CONFIG_SYS_PIXIS_VBOOT_MASK;
 
-       out8(PIXIS_BASE + PIXIS_VBOOT, tmp);
+       out_8(pixis_base + PIXIS_VBOOT, tmp);
 }
 
 
 void set_altbank(void)
 {
        u8 tmp;
+       u8 *pixis_base = (u8 *)PIXIS_BASE;
 
-       tmp = in8(PIXIS_BASE + PIXIS_VBOOT);
+       tmp = in_8(pixis_base + PIXIS_VBOOT);
        tmp |= CONFIG_SYS_PIXIS_VBOOT_MASK;
 
-       out8(PIXIS_BASE + PIXIS_VBOOT, tmp);
+       out_8(pixis_base + PIXIS_VBOOT, tmp);
 }
 
 
 void set_px_go(void)
 {
        u8 tmp;
+       u8 *pixis_base = (u8 *)PIXIS_BASE;
 
-       tmp = in8(PIXIS_BASE + PIXIS_VCTL);
+       tmp = in_8(pixis_base + PIXIS_VCTL);
        tmp = tmp & 0x1E;                       /* clear GO bit */
-       out8(PIXIS_BASE + PIXIS_VCTL, tmp);
+       out_8(pixis_base + PIXIS_VCTL, tmp);
 
-       tmp = in8(PIXIS_BASE + PIXIS_VCTL);
+       tmp = in_8(pixis_base + PIXIS_VCTL);
        tmp = tmp | 0x01;       /* set GO bit - start reset sequencer */
-       out8(PIXIS_BASE + PIXIS_VCTL, tmp);
+       out_8(pixis_base + PIXIS_VCTL, tmp);
 }
 
 
 void set_px_go_with_watchdog(void)
 {
        u8 tmp;
+       u8 *pixis_base = (u8 *)PIXIS_BASE;
 
-       tmp = in8(PIXIS_BASE + PIXIS_VCTL);
+       tmp = in_8(pixis_base + PIXIS_VCTL);
        tmp = tmp & 0x1E;
-       out8(PIXIS_BASE + PIXIS_VCTL, tmp);
+       out_8(pixis_base + PIXIS_VCTL, tmp);
 
-       tmp = in8(PIXIS_BASE + PIXIS_VCTL);
+       tmp = in_8(pixis_base + PIXIS_VCTL);
        tmp = tmp | 0x09;
-       out8(PIXIS_BASE + PIXIS_VCTL, tmp);
+       out_8(pixis_base + PIXIS_VCTL, tmp);
 }
 
 
@@ -265,15 +275,16 @@ int pixis_disable_watchdog_cmd(cmd_tbl_t *cmdtp,
                               int flag, int argc, char *argv[])
 {
        u8 tmp;
+       u8 *pixis_base = (u8 *)PIXIS_BASE;
 
-       tmp = in8(PIXIS_BASE + PIXIS_VCTL);
+       tmp = in_8(pixis_base + PIXIS_VCTL);
        tmp = tmp & 0x1E;
-       out8(PIXIS_BASE + PIXIS_VCTL, tmp);
+       out_8(pixis_base + PIXIS_VCTL, tmp);
 
        /* setting VCTL[WDEN] to 0 to disable watch dog */
-       tmp = in8(PIXIS_BASE + PIXIS_VCTL);
+       tmp = in_8(pixis_base + PIXIS_VCTL);
        tmp &= ~0x08;
-       out8(PIXIS_BASE + PIXIS_VCTL, tmp);
+       out_8(pixis_base + PIXIS_VCTL, tmp);
 
        return 0;
 }
@@ -288,6 +299,7 @@ U_BOOT_CMD(
 int pixis_set_sgmii(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 {
        int which_tsec = -1;
+       u8 *pixis_base = (u8 *)PIXIS_BASE;
        uchar mask;
        uchar switch_mask;
 
@@ -328,17 +340,15 @@ int pixis_set_sgmii(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 
        /* Toggle whether the switches or FPGA control the settings */
        if (!strcmp(argv[argc - 1], "switch"))
-               clrbits_8((unsigned char *)PIXIS_BASE + PIXIS_VCFGEN1,
-                       switch_mask);
+               clrbits_8(pixis_base + PIXIS_VCFGEN1, switch_mask);
        else
-               setbits_8((unsigned char *)PIXIS_BASE + PIXIS_VCFGEN1,
-                       switch_mask);
+               setbits_8(pixis_base + PIXIS_VCFGEN1, switch_mask);
 
        /* If it's not the switches, enable or disable SGMII, as specified */
        if (!strcmp(argv[argc - 1], "on"))
-               clrbits_8((unsigned char *)PIXIS_BASE + PIXIS_VSPEED2, mask);
+               clrbits_8(pixis_base + PIXIS_VSPEED2, mask);
        else if (!strcmp(argv[argc - 1], "off"))
-               setbits_8((unsigned char *)PIXIS_BASE + PIXIS_VSPEED2, mask);
+               setbits_8(pixis_base + PIXIS_VSPEED2, mask);
 
        return 0;
 }
index a97116c..c34905c 100644 (file)
@@ -25,8 +25,10 @@ include $(TOPDIR)/config.mk
 
 LIB    = $(obj)lib$(BOARD).a
 
-COBJS  := $(BOARD).o pci.o
+COBJS-y += $(BOARD).o
+COBJS-$(CONFIG_PCI) += pci.o
 
+COBJS  := $(COBJS-y)
 SRCS   := $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS   := $(addprefix $(obj),$(COBJS))
 SOBJS  := $(addprefix $(obj),$(SOBJS))
index 212fb52..e1dd757 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006 Freescale Semiconductor, Inc.
+ * Copyright (C) 2006-2009 Freescale Semiconductor, Inc.
  *
  * See file CREDITS for list of people who contributed to this
  * project.
 #include <asm/mmu.h>
 #include <asm/io.h>
 #include <common.h>
+#include <mpc83xx.h>
 #include <pci.h>
 #include <i2c.h>
-#if defined(CONFIG_OF_LIBFDT)
-#include <libfdt.h>
-#include <fdt_support.h>
-#endif
-
 #include <asm/fsl_i2c.h>
+#include "../common/pq-mds-pib.h"
 
 DECLARE_GLOBAL_DATA_PTR;
 
-#if defined(CONFIG_PCI)
-#define PCI_FUNCTION_CONFIG   0x44
-#define PCI_FUNCTION_CFG_LOCK 0x20
+static struct pci_region pci1_regions[] = {
+       {
+               bus_start: CONFIG_SYS_PCI1_MEM_BASE,
+               phys_start: CONFIG_SYS_PCI1_MEM_PHYS,
+               size: CONFIG_SYS_PCI1_MEM_SIZE,
+               flags: PCI_REGION_MEM | PCI_REGION_PREFETCH
+       },
+       {
+               bus_start: CONFIG_SYS_PCI1_IO_BASE,
+               phys_start: CONFIG_SYS_PCI1_IO_PHYS,
+               size: CONFIG_SYS_PCI1_IO_SIZE,
+               flags: PCI_REGION_IO
+       },
+       {
+               bus_start: CONFIG_SYS_PCI1_MMIO_BASE,
+               phys_start: CONFIG_SYS_PCI1_MMIO_PHYS,
+               size: CONFIG_SYS_PCI1_MMIO_SIZE,
+               flags: PCI_REGION_MEM
+       },
+};
 
-/*
- * Initialize PCI Devices, report devices found
- */
-#ifndef CONFIG_PCI_PNP
-static struct pci_config_table pci_mpc83xxemds_config_table[] = {
+#ifdef CONFIG_MPC83XX_PCI2
+static struct pci_region pci2_regions[] = {
        {
-               PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
-               pci_cfgfunc_config_device,
-               {PCI_ENET0_IOADDR,
-               PCI_ENET0_MEMADDR,
-               PCI_COMMON_MEMORY | PCI_COMMAND_MASTER}
+               bus_start: CONFIG_SYS_PCI2_MEM_BASE,
+               phys_start: CONFIG_SYS_PCI2_MEM_PHYS,
+               size: CONFIG_SYS_PCI2_MEM_SIZE,
+               flags: PCI_REGION_MEM | PCI_REGION_PREFETCH
        },
-       {}
-}
-#endif
-static struct pci_controller hose[] = {
        {
-#ifndef CONFIG_PCI_PNP
-               config_table:pci_mpc83xxemds_config_table,
-#endif
+               bus_start: CONFIG_SYS_PCI2_IO_BASE,
+               phys_start: CONFIG_SYS_PCI2_IO_PHYS,
+               size: CONFIG_SYS_PCI2_IO_SIZE,
+               flags: PCI_REGION_IO
+       },
+       {
+               bus_start: CONFIG_SYS_PCI2_MMIO_BASE,
+               phys_start: CONFIG_SYS_PCI2_MMIO_PHYS,
+               size: CONFIG_SYS_PCI2_MMIO_SIZE,
+               flags: PCI_REGION_MEM
        },
 };
+#endif
+
+DECLARE_GLOBAL_DATA_PTR;
+
 
-/**********************************************************************
- * pci_init_board()
- *********************************************************************/
 void pci_init_board(void)
 #ifdef CONFIG_PCISLAVE
 {
-       u16 reg16;
-       volatile immap_t *immr;
-       volatile law83xx_t *pci_law;
-       volatile pot83xx_t *pci_pot;
-       volatile pcictrl83xx_t *pci_ctrl;
-       volatile pciconf83xx_t *pci_conf;
+       volatile immap_t *immr = (volatile immap_t *)CONFIG_SYS_IMMR;
+       volatile law83xx_t *pci_law = immr->sysconf.pcilaw;
+       volatile pcictrl83xx_t *pci_ctrl = &immr->pci_ctrl[0];
+       struct pci_region *reg[] = { pci1_regions };
+
+       /* Configure PCI Local Access Windows */
+       pci_law[0].bar = CONFIG_SYS_PCI1_MEM_PHYS & LAWBAR_BAR;
+       pci_law[0].ar = LAWAR_EN | LAWAR_SIZE_1G;
+
+       pci_law[1].bar = CONFIG_SYS_PCI1_IO_PHYS & LAWBAR_BAR;
+       pci_law[1].ar = LAWAR_EN | LAWAR_SIZE_4M;
+
+       mpc83xx_pci_init(1, reg, 0);
 
-       immr = (immap_t *) CONFIG_SYS_IMMR;
-       pci_law = immr->sysconf.pcilaw;
-       pci_pot = immr->ios.pot;
-       pci_ctrl = immr->pci_ctrl;
-       pci_conf = immr->pci_conf;
        /*
         * Configure PCI Inbound Translation Windows
         */
@@ -90,61 +106,24 @@ void pci_init_board(void)
        pci_ctrl[0].piebar2 = 0x0;
        pci_ctrl[0].piwar2 &= ~PIWAR_EN;
 
-       hose[0].first_busno = 0;
-       hose[0].last_busno = 0xff;
-       pci_setup_indirect(&hose[0],
-                          (CONFIG_SYS_IMMR + 0x8300), (CONFIG_SYS_IMMR + 0x8304));
-       reg16 = 0xff;
-
-       pci_hose_read_config_word(&hose[0], PCI_BDF(0, 0, 0),
-                                 PCI_COMMAND, &reg16);
-       reg16 |= PCI_COMMAND_SERR | PCI_COMMAND_MEMORY;
-       pci_hose_write_config_word(&hose[0], PCI_BDF(0, 0, 0),
-                                  PCI_COMMAND, reg16);
-
-       /*
-        * Clear non-reserved bits in status register.
-        */
-       pci_hose_write_config_word(&hose[0], PCI_BDF(0, 0, 0),
-                                  PCI_STATUS, 0xffff);
-       pci_hose_write_config_byte(&hose[0], PCI_BDF(0, 0, 0),
-                                  PCI_LATENCY_TIMER, 0x80);
-
-       /*
-        * Unlock configuration lock in PCI function configuration register.
-        */
-       pci_hose_read_config_word(&hose[0], PCI_BDF(0, 0, 0),
-                                 PCI_FUNCTION_CONFIG, &reg16);
-       reg16 &= ~(PCI_FUNCTION_CFG_LOCK);
-       pci_hose_write_config_word(&hose[0], PCI_BDF(0, 0, 0),
-                                  PCI_FUNCTION_CONFIG, reg16);
-
-       printf("Enabled PCI 32bit Agent Mode\n");
+       /* Unlock the configuration bit */
+       mpc83xx_pcislave_unlock(0);
+       printf("PCI:   Agent mode enabled\n");
 }
 #else
 {
-       volatile immap_t *immr;
-       volatile clk83xx_t *clk;
-       volatile law83xx_t *pci_law;
-       volatile pot83xx_t *pci_pot;
-       volatile pcictrl83xx_t *pci_ctrl;
-       volatile pciconf83xx_t *pci_conf;
+       volatile immap_t *immr = (volatile immap_t *)CONFIG_SYS_IMMR;
+       volatile clk83xx_t *clk = (volatile clk83xx_t *)&immr->clk;
+       volatile law83xx_t *pci_law = immr->sysconf.pcilaw;
+#ifndef CONFIG_MPC83XX_PCI2
+       struct pci_region *reg[] = { pci1_regions };
+#else
+       struct pci_region *reg[] = { pci1_regions, pci2_regions };
+#endif
 
-       u16 reg16;
-       u32 val32;
-       u32 dev;
+       /* initialize the PCA9555PW IO expander on the PIB board */
+       pib_init();
 
-       immr = (immap_t *) CONFIG_SYS_IMMR;
-       clk = (clk83xx_t *) & immr->clk;
-       pci_law = immr->sysconf.pcilaw;
-       pci_pot = immr->ios.pot;
-       pci_ctrl = immr->pci_ctrl;
-       pci_conf = immr->pci_conf;
-       /*
-        * Configure PCI controller and PCI_CLK_OUTPUT both in 66M mode
-        */
-       val32 = clk->occr;
-       udelay(2000);
 #if defined(PCI_66M)
        clk->occr = OCCR_PCICOE0 | OCCR_PCICOE1 | OCCR_PCICOE2;
        printf("PCI clock is 66MHz\n");
@@ -158,129 +137,19 @@ void pci_init_board(void)
 #endif
        udelay(2000);
 
-       /*
-        * Configure PCI Local Access Windows
-        */
-       pci_law[0].bar = CONFIG_SYS_PCI_MEM_PHYS & LAWBAR_BAR;
+       /* Configure PCI Local Access Windows */
+       pci_law[0].bar = CONFIG_SYS_PCI1_MEM_PHYS & LAWBAR_BAR;
        pci_law[0].ar = LAWAR_EN | LAWAR_SIZE_512M;
 
-       pci_law[1].bar = CONFIG_SYS_PCI_IO_PHYS & LAWBAR_BAR;
+       pci_law[1].bar = CONFIG_SYS_PCI1_IO_PHYS & LAWBAR_BAR;
        pci_law[1].ar = LAWAR_EN | LAWAR_SIZE_1M;
 
-       /*
-        * Configure PCI Outbound Translation Windows
-        */
-
-       /* PCI mem space - prefetch */
-       pci_pot[0].potar = (CONFIG_SYS_PCI_MEM_BASE >> 12) & POTAR_TA_MASK;
-       pci_pot[0].pobar = (CONFIG_SYS_PCI_MEM_PHYS >> 12) & POBAR_BA_MASK;
-       pci_pot[0].pocmr =
-           POCMR_EN | POCMR_SE | (POCMR_CM_256M & POCMR_CM_MASK);
-
-       /* PCI mmio - non-prefetch mem space */
-       pci_pot[1].potar = (CONFIG_SYS_PCI_MMIO_BASE >> 12) & POTAR_TA_MASK;
-       pci_pot[1].pobar = (CONFIG_SYS_PCI_MMIO_PHYS >> 12) & POBAR_BA_MASK;
-       pci_pot[1].pocmr = POCMR_EN | (POCMR_CM_256M & POCMR_CM_MASK);
-
-       /* PCI IO space */
-       pci_pot[2].potar = (CONFIG_SYS_PCI_IO_BASE >> 12) & POTAR_TA_MASK;
-       pci_pot[2].pobar = (CONFIG_SYS_PCI_IO_PHYS >> 12) & POBAR_BA_MASK;
-       pci_pot[2].pocmr = POCMR_EN | POCMR_IO | (POCMR_CM_1M & POCMR_CM_MASK);
-
-       /*
-        * Configure PCI Inbound Translation Windows
-        */
-       pci_ctrl[0].pitar1 = (CONFIG_SYS_PCI_SLV_MEM_LOCAL >> 12) & PITAR_TA_MASK;
-       pci_ctrl[0].pibar1 = (CONFIG_SYS_PCI_SLV_MEM_BUS >> 12) & PIBAR_MASK;
-       pci_ctrl[0].piebar1 = 0x0;
-       pci_ctrl[0].piwar1 =
-           PIWAR_EN | PIWAR_PF | PIWAR_RTT_SNOOP | PIWAR_WTT_SNOOP |
-           PIWAR_IWS_2G;
-
-       /*
-        * Release PCI RST Output signal
-        */
        udelay(2000);
-       pci_ctrl[0].gcr = 1;
-       udelay(2000);
-
-       hose[0].first_busno = 0;
-       hose[0].last_busno = 0xff;
-
-       /* PCI memory prefetch space */
-       pci_set_region(hose[0].regions + 0,
-                      CONFIG_SYS_PCI_MEM_BASE,
-                      CONFIG_SYS_PCI_MEM_PHYS,
-                      CONFIG_SYS_PCI_MEM_SIZE, PCI_REGION_MEM | PCI_REGION_PREFETCH);
-
-       /* PCI memory space */
-       pci_set_region(hose[0].regions + 1,
-                      CONFIG_SYS_PCI_MMIO_BASE,
-                      CONFIG_SYS_PCI_MMIO_PHYS, CONFIG_SYS_PCI_MMIO_SIZE, PCI_REGION_MEM);
-
-       /* PCI IO space */
-       pci_set_region(hose[0].regions + 2,
-                      CONFIG_SYS_PCI_IO_BASE,
-                      CONFIG_SYS_PCI_IO_PHYS, CONFIG_SYS_PCI_IO_SIZE, PCI_REGION_IO);
-
-       /* System memory space */
-       pci_set_region(hose[0].regions + 3,
-                      CONFIG_SYS_PCI_SLV_MEM_LOCAL,
-                      CONFIG_SYS_PCI_SLV_MEM_BUS,
-                      CONFIG_SYS_PCI_SLV_MEM_SIZE,
-                      PCI_REGION_MEM | PCI_REGION_SYS_MEMORY);
 
-       hose[0].region_count = 4;
-
-       pci_setup_indirect(&hose[0],
-                          (CONFIG_SYS_IMMR + 0x8300), (CONFIG_SYS_IMMR + 0x8304));
-
-       pci_register_hose(hose);
-
-       /*
-        * Write command register
-        */
-       reg16 = 0xff;
-       dev = PCI_BDF(0, 0, 0);
-       pci_hose_read_config_word(&hose[0], dev, PCI_COMMAND, &reg16);
-       reg16 |= PCI_COMMAND_SERR | PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY;
-       pci_hose_write_config_word(&hose[0], dev, PCI_COMMAND, reg16);
-
-       /*
-        * Clear non-reserved bits in status register.
-        */
-       pci_hose_write_config_word(&hose[0], dev, PCI_STATUS, 0xffff);
-       pci_hose_write_config_byte(&hose[0], dev, PCI_LATENCY_TIMER, 0x80);
-       pci_hose_write_config_byte(&hose[0], dev, PCI_CACHE_LINE_SIZE, 0x08);
-
-       /*
-        * Hose scan.
-        */
-       hose->last_busno = pci_hose_scan(hose);
+#ifndef CONFIG_MPC83XX_PCI2
+       mpc83xx_pci_init(1, reg, 0);
+#else
+       mpc83xx_pci_init(2, reg, 0);
+#endif
 }
 #endif                         /* CONFIG_PCISLAVE */
-
-#if defined(CONFIG_OF_LIBFDT)
-void ft_pci_setup(void *blob, bd_t *bd)
-{
-       int nodeoffset;
-       int tmp[2];
-       const char *path;
-
-       nodeoffset = fdt_path_offset(blob, "/aliases");
-       if (nodeoffset >= 0) {
-               path = fdt_getprop(blob, nodeoffset, "pci0", NULL);
-               if (path) {
-                       tmp[0] = cpu_to_be32(hose[0].first_busno);
-                       tmp[1] = cpu_to_be32(hose[0].last_busno);
-                       do_fixup_by_path(blob, path, "bus-range",
-                               &tmp, sizeof(tmp), 1);
-
-                       tmp[0] = cpu_to_be32(gd->pci_clk);
-                       do_fixup_by_path(blob, path, "clock-frequency",
-                               &tmp, sizeof(tmp[0]), 1);
-               }
-       }
-}
-#endif                         /* CONFIG_OF_LIBFDT */
-#endif                         /* CONFIG_PCI */
index a97116c..c34905c 100644 (file)
@@ -25,8 +25,10 @@ include $(TOPDIR)/config.mk
 
 LIB    = $(obj)lib$(BOARD).a
 
-COBJS  := $(BOARD).o pci.o
+COBJS-y += $(BOARD).o
+COBJS-$(CONFIG_PCI) += pci.o
 
+COBJS  := $(COBJS-y)
 SRCS   := $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS   := $(addprefix $(obj),$(COBJS))
 SOBJS  := $(addprefix $(obj),$(SOBJS))
index af0b1da..9293f70 100644 (file)
@@ -1,4 +1,6 @@
 /*
+ * Copyright (C) 2006-2009 Freescale Semiconductor, Inc.
+ *
  * See file CREDITS for list of people who contributed to this
  * project.
  *
@@ -29,8 +31,6 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-#ifdef CONFIG_PCI
-
 static struct pci_region pci1_regions[] = {
        {
                bus_start: CONFIG_SYS_PCI1_MEM_BASE,
@@ -207,5 +207,3 @@ void pci_init_board(void)
        printf("PCI:   Agent mode enabled\n");
 }
 #endif /* CONFIG_PCISLAVE */
-
-#endif /* CONFIG_PCI */
index c81ba66..2fed9f0 100644 (file)
@@ -24,8 +24,10 @@ include $(TOPDIR)/config.mk
 
 LIB    = $(obj)lib$(BOARD).a
 
-COBJS  := $(BOARD).o pci.o
+COBJS-y += $(BOARD).o
+COBJS-$(CONFIG_PCI) += pci.o
 
+COBJS  := $(COBJS-y)
 SRCS   := $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS   := $(addprefix $(obj),$(COBJS))
 SOBJS  := $(addprefix $(obj),$(SOBJS))
index 8da7117..38baff3 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) Freescale Semiconductor, Inc. 2006. All rights reserved.
+ * Copyright (C) 2006-2009 Freescale Semiconductor, Inc.
  *
  * See file CREDITS for list of people who contributed to this
  * project.
 
 #include <common.h>
 
-#ifdef CONFIG_PCI
-
 #include <asm/mmu.h>
-#include <asm/global_data.h>
+#include <asm/io.h>
+#include <mpc83xx.h>
 #include <pci.h>
-#include <asm/mpc8349_pci.h>
 #include <i2c.h>
-#if defined(CONFIG_OF_LIBFDT)
-#include <libfdt.h>
-#include <fdt_support.h>
-#endif
+#include <asm/fsl_i2c.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
-/* System RAM mapped to PCI space */
-#define CONFIG_PCI_SYS_MEM_BUS CONFIG_SYS_SDRAM_BASE
-#define CONFIG_PCI_SYS_MEM_PHYS        CONFIG_SYS_SDRAM_BASE
-
-#ifndef CONFIG_PCI_PNP
-static struct pci_config_table pci_mpc8349itx_config_table[] = {
+static struct pci_region pci1_regions[] = {
+       {
+               bus_start: CONFIG_SYS_PCI1_MEM_BASE,
+               phys_start: CONFIG_SYS_PCI1_MEM_PHYS,
+               size: CONFIG_SYS_PCI1_MEM_SIZE,
+               flags: PCI_REGION_MEM | PCI_REGION_PREFETCH
+       },
+       {
+               bus_start: CONFIG_SYS_PCI1_IO_BASE,
+               phys_start: CONFIG_SYS_PCI1_IO_PHYS,
+               size: CONFIG_SYS_PCI1_IO_SIZE,
+               flags: PCI_REGION_IO
+       },
        {
-        PCI_ANY_ID,
-        PCI_ANY_ID,
-        PCI_ANY_ID,
-        PCI_ANY_ID,
-        PCI_IDSEL_NUMBER,
-        PCI_ANY_ID,
-        pci_cfgfunc_config_device,
-        {
-         PCI_ENET0_IOADDR,
-         PCI_ENET0_MEMADDR,
-         PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER}
-        },
-       {}
+               bus_start: CONFIG_SYS_PCI1_MMIO_BASE,
+               phys_start: CONFIG_SYS_PCI1_MMIO_PHYS,
+               size: CONFIG_SYS_PCI1_MMIO_SIZE,
+               flags: PCI_REGION_MEM
+       },
 };
-#endif
 
-static struct pci_controller pci_hose[] = {
+#ifdef CONFIG_MPC83XX_PCI2
+static struct pci_region pci2_regions[] = {
        {
-#ifndef CONFIG_PCI_PNP
-             config_table:pci_mpc8349itx_config_table,
-#endif
-        },
+               bus_start: CONFIG_SYS_PCI2_MEM_BASE,
+               phys_start: CONFIG_SYS_PCI2_MEM_PHYS,
+               size: CONFIG_SYS_PCI2_MEM_SIZE,
+               flags: PCI_REGION_MEM | PCI_REGION_PREFETCH
+       },
        {
-#ifndef CONFIG_PCI_PNP
-             config_table:pci_mpc8349itx_config_table,
-#endif
-        }
+               bus_start: CONFIG_SYS_PCI2_IO_BASE,
+               phys_start: CONFIG_SYS_PCI2_IO_PHYS,
+               size: CONFIG_SYS_PCI2_IO_SIZE,
+               flags: PCI_REGION_IO
+       },
+       {
+               bus_start: CONFIG_SYS_PCI2_MMIO_BASE,
+               phys_start: CONFIG_SYS_PCI2_MMIO_PHYS,
+               size: CONFIG_SYS_PCI2_MMIO_SIZE,
+               flags: PCI_REGION_MEM
+       },
 };
+#endif
 
-/**************************************************************************
- * pci_init_board()
- *
- * NOTICE: PCI2 is not currently supported
- *
- */
 void pci_init_board(void)
 {
-       volatile immap_t *immr;
-       volatile clk83xx_t *clk;
-       volatile law83xx_t *pci_law;
-       volatile pot83xx_t *pci_pot;
-       volatile pcictrl83xx_t *pci_ctrl;
-       volatile pciconf83xx_t *pci_conf;
+       volatile immap_t *immr = (volatile immap_t *)CONFIG_SYS_IMMR;
+       volatile clk83xx_t *clk = (volatile clk83xx_t *)&immr->clk;
+       volatile law83xx_t *pci_law = immr->sysconf.pcilaw;
+#ifndef CONFIG_MPC83XX_PCI2
+       struct pci_region *reg[] = { pci1_regions };
+#else
+       struct pci_region *reg[] = { pci1_regions, pci2_regions };
+#endif
        u8 reg8;
-       u16 reg16;
-       u32 reg32;
-       u32 dev;
-       struct pci_controller *hose;
-
-       immr = (immap_t *) CONFIG_SYS_IMMR;
-       clk = (clk83xx_t *) & immr->clk;
-       pci_law = immr->sysconf.pcilaw;
-       pci_pot = immr->ios.pot;
-       pci_ctrl = immr->pci_ctrl;
-       pci_conf = immr->pci_conf;
-
-       hose = &pci_hose[0];
-
-       /*
-        * Configure PCI controller and PCI_CLK_OUTPUT both in 66M mode
-        */
-
-       reg32 = clk->occr;
-       udelay(2000);
 
 #ifdef CONFIG_HARD_I2C
        i2c_set_bus_num(1);
@@ -123,250 +102,20 @@ void pci_init_board(void)
 #else
        clk->occr = 0xff000000; /* 66 MHz PCI */
 #endif
-
-       udelay(2000);
-
-       /*
-        * Release PCI RST Output signal
-        */
-       pci_ctrl[0].gcr = 0;
-       udelay(2000);
-       pci_ctrl[0].gcr = 1;
-
-#ifdef CONFIG_MPC83XX_PCI2
-       pci_ctrl[1].gcr = 0;
        udelay(2000);
-       pci_ctrl[1].gcr = 1;
-#endif
-
-       /* We need to wait at least a 1sec based on PCI specs */
-       {
-               int i;
 
-               for (i = 0; i < 1000; i++)
-                       udelay(1000);
-       }
-
-       /*
-        * Configure PCI Local Access Windows
-        */
+       /* Configure PCI Local Access Windows */
        pci_law[0].bar = CONFIG_SYS_PCI1_MEM_PHYS & LAWBAR_BAR;
        pci_law[0].ar = LAWAR_EN | LAWAR_SIZE_1G;
 
        pci_law[1].bar = CONFIG_SYS_PCI1_IO_PHYS & LAWBAR_BAR;
        pci_law[1].ar = LAWAR_EN | LAWAR_SIZE_32M;
 
-       /*
-        * Configure PCI Outbound Translation Windows
-        */
-
-       /* PCI1 mem space - prefetch */
-       pci_pot[0].potar = (CONFIG_SYS_PCI1_MEM_BASE >> 12) & POTAR_TA_MASK;
-       pci_pot[0].pobar = (CONFIG_SYS_PCI1_MEM_PHYS >> 12) & POBAR_BA_MASK;
-       pci_pot[0].pocmr = POCMR_EN | POCMR_PREFETCH_EN | POCMR_CM_256M;
-
-       /* PCI1 IO space */
-       pci_pot[1].potar = (CONFIG_SYS_PCI1_IO_BASE >> 12) & POTAR_TA_MASK;
-       pci_pot[1].pobar = (CONFIG_SYS_PCI1_IO_PHYS >> 12) & POBAR_BA_MASK;
-       pci_pot[1].pocmr = POCMR_EN | POCMR_IO | POCMR_CM_16M;
-
-       /* PCI1 mmio - non-prefetch mem space */
-       pci_pot[2].potar = (CONFIG_SYS_PCI1_MMIO_BASE >> 12) & POTAR_TA_MASK;
-       pci_pot[2].pobar = (CONFIG_SYS_PCI1_MMIO_PHYS >> 12) & POBAR_BA_MASK;
-       pci_pot[2].pocmr = POCMR_EN | POCMR_CM_256M;
-
-       /*
-        * Configure PCI Inbound Translation Windows
-        */
-
-       /* we need RAM mapped to PCI space for the devices to
-        * access main memory */
-       pci_ctrl[0].pitar1 = 0x0;
-       pci_ctrl[0].pibar1 = 0x0;
-       pci_ctrl[0].piebar1 = 0x0;
-       pci_ctrl[0].piwar1 = PIWAR_EN | PIWAR_PF | PIWAR_RTT_SNOOP |
-           PIWAR_WTT_SNOOP | (__ilog2(gd->ram_size) - 1);
-
-       hose->first_busno = 0;
-       hose->last_busno = 0xff;
-
-       /* PCI memory prefetch space */
-       pci_set_region(hose->regions + 0,
-                      CONFIG_SYS_PCI1_MEM_BASE,
-                      CONFIG_SYS_PCI1_MEM_PHYS,
-                      CONFIG_SYS_PCI1_MEM_SIZE, PCI_REGION_MEM | PCI_REGION_PREFETCH);
-
-       /* PCI memory space */
-       pci_set_region(hose->regions + 1,
-                      CONFIG_SYS_PCI1_MMIO_BASE,
-                      CONFIG_SYS_PCI1_MMIO_PHYS, CONFIG_SYS_PCI1_MMIO_SIZE, PCI_REGION_MEM);
-
-       /* PCI IO space */
-       pci_set_region(hose->regions + 2,
-                      CONFIG_SYS_PCI1_IO_BASE,
-                      CONFIG_SYS_PCI1_IO_PHYS, CONFIG_SYS_PCI1_IO_SIZE, PCI_REGION_IO);
-
-       /* System memory space */
-       pci_set_region(hose->regions + 3,
-                      CONFIG_PCI_SYS_MEM_BUS,
-                      CONFIG_PCI_SYS_MEM_PHYS,
-                      gd->ram_size, PCI_REGION_MEM | PCI_REGION_SYS_MEMORY);
-
-       hose->region_count = 4;
-
-       pci_setup_indirect(hose,
-                          (CONFIG_SYS_IMMR + 0x8300), (CONFIG_SYS_IMMR + 0x8304));
-
-       pci_register_hose(hose);
-
-       /*
-        * Write to Command register
-        */
-       reg16 = 0xff;
-       dev = PCI_BDF(hose->first_busno, 0, 0);
-       pci_hose_read_config_word(hose, dev, PCI_COMMAND, &reg16);
-       reg16 |= PCI_COMMAND_SERR | PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY;
-       pci_hose_write_config_word(hose, dev, PCI_COMMAND, reg16);
-
-       /*
-        * Clear non-reserved bits in status register.
-        */
-       pci_hose_write_config_word(hose, dev, PCI_STATUS, 0xffff);
-       pci_hose_write_config_byte(hose, dev, PCI_LATENCY_TIMER, 0x80);
-       pci_hose_write_config_byte(hose, dev, PCI_CACHE_LINE_SIZE, 0x08);
-
-#ifdef CONFIG_PCI_SCAN_SHOW
-       printf("PCI:   Bus Dev VenId DevId Class Int\n");
-#endif
-       /*
-        * Hose scan.
-        */
-       hose->last_busno = pci_hose_scan(hose);
-
-#ifdef CONFIG_MPC83XX_PCI2
-       hose = &pci_hose[1];
-
-       /*
-        * Configure PCI Outbound Translation Windows
-        */
-
-       /* PCI2 mem space - prefetch */
-       pci_pot[3].potar = (CONFIG_SYS_PCI2_MEM_BASE >> 12) & POTAR_TA_MASK;
-       pci_pot[3].pobar = (CONFIG_SYS_PCI2_MEM_PHYS >> 12) & POBAR_BA_MASK;
-       pci_pot[3].pocmr = POCMR_EN | POCMR_PCI2 | POCMR_PREFETCH_EN | POCMR_CM_256M;
-
-       /* PCI2 IO space */
-       pci_pot[4].potar = (CONFIG_SYS_PCI2_IO_BASE >> 12) & POTAR_TA_MASK;
-       pci_pot[4].pobar = (CONFIG_SYS_PCI2_IO_PHYS >> 12) & POBAR_BA_MASK;
-       pci_pot[4].pocmr = POCMR_EN | POCMR_PCI2 | POCMR_IO | POCMR_CM_16M;
-
-       /* PCI2 mmio - non-prefetch mem space */
-       pci_pot[5].potar = (CONFIG_SYS_PCI2_MMIO_BASE >> 12) & POTAR_TA_MASK;
-       pci_pot[5].pobar = (CONFIG_SYS_PCI2_MMIO_PHYS >> 12) & POBAR_BA_MASK;
-       pci_pot[5].pocmr = POCMR_EN | POCMR_PCI2 | POCMR_CM_256M;
-
-       /*
-        * Configure PCI Inbound Translation Windows
-        */
-
-       /* we need RAM mapped to PCI space for the devices to
-        * access main memory */
-       pci_ctrl[1].pitar1 = 0x0;
-       pci_ctrl[1].pibar1 = 0x0;
-       pci_ctrl[1].piebar1 = 0x0;
-       pci_ctrl[1].piwar1 =
-           PIWAR_EN | PIWAR_PF | PIWAR_RTT_SNOOP | PIWAR_WTT_SNOOP |
-           (__ilog2(gd->ram_size) - 1);
-
-       hose->first_busno = pci_hose[0].last_busno + 1;
-       hose->last_busno = 0xff;
-
-       /* PCI memory prefetch space */
-       pci_set_region(hose->regions + 0,
-                      CONFIG_SYS_PCI2_MEM_BASE,
-                      CONFIG_SYS_PCI2_MEM_PHYS,
-                      CONFIG_SYS_PCI2_MEM_SIZE, PCI_REGION_MEM | PCI_REGION_PREFETCH);
-
-       /* PCI memory space */
-       pci_set_region(hose->regions + 1,
-                      CONFIG_SYS_PCI2_MMIO_BASE,
-                      CONFIG_SYS_PCI2_MMIO_PHYS, CONFIG_SYS_PCI2_MMIO_SIZE, PCI_REGION_MEM);
-
-       /* PCI IO space */
-       pci_set_region(hose->regions + 2,
-                      CONFIG_SYS_PCI2_IO_BASE,
-                      CONFIG_SYS_PCI2_IO_PHYS, CONFIG_SYS_PCI2_IO_SIZE, PCI_REGION_IO);
-
-       /* System memory space */
-       pci_set_region(hose->regions + 3,
-                      CONFIG_PCI_SYS_MEM_BUS,
-                      CONFIG_PCI_SYS_MEM_PHYS,
-                      gd->ram_size, PCI_REGION_MEM | PCI_REGION_SYS_MEMORY);
-
-       hose->region_count = 4;
-
-       pci_setup_indirect(hose,
-                          (CONFIG_SYS_IMMR + 0x8380), (CONFIG_SYS_IMMR + 0x8384));
-
-       pci_register_hose(hose);
-
-       /*
-        * Write to Command register
-        */
-       reg16 = 0xff;
-       dev = PCI_BDF(hose->first_busno, 0, 0);
-       pci_hose_read_config_word(hose, dev, PCI_COMMAND, &reg16);
-       reg16 |= PCI_COMMAND_SERR | PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY;
-       pci_hose_write_config_word(hose, dev, PCI_COMMAND, reg16);
-
-       /*
-        * Clear non-reserved bits in status register.
-        */
-       pci_hose_write_config_word(hose, dev, PCI_STATUS, 0xffff);
-       pci_hose_write_config_byte(hose, dev, PCI_LATENCY_TIMER, 0x80);
-       pci_hose_write_config_byte(hose, dev, PCI_CACHE_LINE_SIZE, 0x08);
-
-       /*
-        * Hose scan.
-        */
-       hose->last_busno = pci_hose_scan(hose);
-#endif
-}
-
-#if defined(CONFIG_OF_LIBFDT)
-void ft_pci_setup(void *blob, bd_t *bd)
-{
-       int nodeoffset;
-       int tmp[2];
-       const char *path;
-
-       nodeoffset = fdt_path_offset(blob, "/aliases");
-       if (nodeoffset >= 0) {
-               path = fdt_getprop(blob, nodeoffset, "pci0", NULL);
-               if (path) {
-                       tmp[0] = cpu_to_be32(pci_hose[0].first_busno);
-                       tmp[1] = cpu_to_be32(pci_hose[0].last_busno);
-                       do_fixup_by_path(blob, path, "bus-range",
-                               &tmp, sizeof(tmp), 1);
-
-                       tmp[0] = cpu_to_be32(gd->pci_clk);
-                       do_fixup_by_path(blob, path, "clock-frequency",
-                               &tmp, sizeof(tmp[0]), 1);
-               }
-#ifdef CONFIG_MPC83XX_PCI2
-               path = fdt_getprop(blob, nodeoffset, "pci1", NULL);
-               if (path) {
-                       tmp[0] = cpu_to_be32(pci_hose[0].first_busno);
-                       tmp[1] = cpu_to_be32(pci_hose[0].last_busno);
-                       do_fixup_by_path(blob, path, "bus-range",
-                               &tmp, sizeof(tmp), 1);
+       udelay(2000);
 
-                       tmp[0] = cpu_to_be32(gd->pci_clk);
-                       do_fixup_by_path(blob, path, "clock-frequency",
-                               &tmp, sizeof(tmp[0]), 1);
-               }
+#ifndef CONFIG_MPC83XX_PCI2
+       mpc83xx_pci_init(1, reg, 0);
+#else
+       mpc83xx_pci_init(2, reg, 0);
 #endif
-       }
 }
-#endif /* CONFIG_OF_LIBFDT */
-#endif /* CONFIG_PCI */
index a97116c..c34905c 100644 (file)
@@ -25,8 +25,10 @@ include $(TOPDIR)/config.mk
 
 LIB    = $(obj)lib$(BOARD).a
 
-COBJS  := $(BOARD).o pci.o
+COBJS-y += $(BOARD).o
+COBJS-$(CONFIG_PCI) += pci.o
 
+COBJS  := $(COBJS-y)
 SRCS   := $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS   := $(addprefix $(obj),$(COBJS))
 SOBJS  := $(addprefix $(obj),$(SOBJS))
index 7ac35dc..04a802b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006 Freescale Semiconductor, Inc.
+ * Copyright (C) 2006-2009 Freescale Semiconductor, Inc.
  *
  * See file CREDITS for list of people who contributed to this
  * project.
 /*
  * PCI Configuration space access support for MPC83xx PCI Bridge
  */
+
 #include <asm/mmu.h>
 #include <asm/io.h>
 #include <common.h>
+#include <mpc83xx.h>
 #include <pci.h>
 #include <i2c.h>
-#if defined(CONFIG_OF_LIBFDT)
-#include <libfdt.h>
-#include <fdt_support.h>
-#endif
-
 #include <asm/fsl_i2c.h>
+#include "../common/pq-mds-pib.h"
 
 DECLARE_GLOBAL_DATA_PTR;
 
-#if defined(CONFIG_PCI)
-#define PCI_FUNCTION_CONFIG   0x44
-#define PCI_FUNCTION_CFG_LOCK 0x20
+static struct pci_region pci1_regions[] = {
+       {
+               bus_start: CONFIG_SYS_PCI1_MEM_BASE,
+               phys_start: CONFIG_SYS_PCI1_MEM_PHYS,
+               size: CONFIG_SYS_PCI1_MEM_SIZE,
+               flags: PCI_REGION_MEM | PCI_REGION_PREFETCH
+       },
+       {
+               bus_start: CONFIG_SYS_PCI1_IO_BASE,
+               phys_start: CONFIG_SYS_PCI1_IO_PHYS,
+               size: CONFIG_SYS_PCI1_IO_SIZE,
+               flags: PCI_REGION_IO
+       },
+       {
+               bus_start: CONFIG_SYS_PCI1_MMIO_BASE,
+               phys_start: CONFIG_SYS_PCI1_MMIO_PHYS,
+               size: CONFIG_SYS_PCI1_MMIO_SIZE,
+               flags: PCI_REGION_MEM
+       },
+};
 
-/*
- * Initialize PCI Devices, report devices found
- */
-#ifndef CONFIG_PCI_PNP
-static struct pci_config_table pci_mpc83xxemds_config_table[] = {
+#ifdef CONFIG_MPC83XX_PCI2
+static struct pci_region pci2_regions[] = {
        {
-        PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
-        pci_cfgfunc_config_device,
-        {PCI_ENET0_IOADDR,
-         PCI_ENET0_MEMADDR,
-         PCI_COMMON_MEMORY | PCI_COMMAND_MASTER}
-        },
-       {}
-}
-#endif
-static struct pci_controller hose[] = {
+               bus_start: CONFIG_SYS_PCI2_MEM_BASE,
+               phys_start: CONFIG_SYS_PCI2_MEM_PHYS,
+               size: CONFIG_SYS_PCI2_MEM_SIZE,
+               flags: PCI_REGION_MEM | PCI_REGION_PREFETCH
+       },
        {
-#ifndef CONFIG_PCI_PNP
-             config_table:pci_mpc83xxemds_config_table,
-#endif
-        },
+               bus_start: CONFIG_SYS_PCI2_IO_BASE,
+               phys_start: CONFIG_SYS_PCI2_IO_PHYS,
+               size: CONFIG_SYS_PCI2_IO_SIZE,
+               flags: PCI_REGION_IO
+       },
+       {
+               bus_start: CONFIG_SYS_PCI2_MMIO_BASE,
+               phys_start: CONFIG_SYS_PCI2_MMIO_PHYS,
+               size: CONFIG_SYS_PCI2_MMIO_SIZE,
+               flags: PCI_REGION_MEM
+       },
 };
+#endif
 
-/**********************************************************************
- * pci_init_board()
- *********************************************************************/
 void pci_init_board(void)
 #ifdef CONFIG_PCISLAVE
 {
-       u16 reg16;
-       volatile immap_t *immr;
-       volatile law83xx_t *pci_law;
-       volatile pot83xx_t *pci_pot;
-       volatile pcictrl83xx_t *pci_ctrl;
-       volatile pciconf83xx_t *pci_conf;
+       volatile immap_t *immr = (volatile immap_t *)CONFIG_SYS_IMMR;
+       volatile law83xx_t *pci_law = immr->sysconf.pcilaw;
+       volatile pcictrl83xx_t *pci_ctrl = &immr->pci_ctrl[0];
+       struct pci_region *reg[] = { pci1_regions };
+
+       /* Configure PCI Local Access Windows */
+       pci_law[0].bar = CONFIG_SYS_PCI1_MEM_PHYS & LAWBAR_BAR;
+       pci_law[0].ar = LAWAR_EN | LAWAR_SIZE_512M;
+
+       pci_law[1].bar = CONFIG_SYS_PCI1_IO_PHYS & LAWBAR_BAR;
+       pci_law[1].ar = LAWAR_EN | LAWAR_SIZE_1M;
+
+       mpc83xx_pci_init(1, reg, 0);
 
-       immr = (immap_t *) CONFIG_SYS_IMMR;
-       pci_law = immr->sysconf.pcilaw;
-       pci_pot = immr->ios.pot;
-       pci_ctrl = immr->pci_ctrl;
-       pci_conf = immr->pci_conf;
        /*
         * Configure PCI Inbound Translation Windows
         */
@@ -90,61 +104,24 @@ void pci_init_board(void)
        pci_ctrl[0].piebar2 = 0x0;
        pci_ctrl[0].piwar2 &= ~PIWAR_EN;
 
-       hose[0].first_busno = 0;
-       hose[0].last_busno = 0xff;
-       pci_setup_indirect(&hose[0],
-                          (CONFIG_SYS_IMMR + 0x8300), (CONFIG_SYS_IMMR + 0x8304));
-       reg16 = 0xff;
-
-       pci_hose_read_config_word(&hose[0], PCI_BDF(0, 0, 0),
-                                 PCI_COMMAND, &reg16);
-       reg16 |= PCI_COMMAND_SERR | PCI_COMMAND_MEMORY;
-       pci_hose_write_config_word(&hose[0], PCI_BDF(0, 0, 0),
-                                  PCI_COMMAND, reg16);
-
-       /*
-        * Clear non-reserved bits in status register.
-        */
-       pci_hose_write_config_word(&hose[0], PCI_BDF(0, 0, 0),
-                                  PCI_STATUS, 0xffff);
-       pci_hose_write_config_byte(&hose[0], PCI_BDF(0, 0, 0),
-                                  PCI_LATENCY_TIMER, 0x80);
-
-       /*
-        * Unlock configuration lock in PCI function configuration register.
-        */
-       pci_hose_read_config_word(&hose[0], PCI_BDF(0, 0, 0),
-                                 PCI_FUNCTION_CONFIG, &reg16);
-       reg16 &= ~(PCI_FUNCTION_CFG_LOCK);
-       pci_hose_write_config_word(&hose[0], PCI_BDF(0, 0, 0),
-                                  PCI_FUNCTION_CONFIG, reg16);
-
-       printf("Enabled PCI 32bit Agent Mode\n");
+       /* Unlock the configuration bit */
+       mpc83xx_pcislave_unlock(0);
+       printf("PCI:   Agent mode enabled\n");
 }
 #else
 {
-       volatile immap_t *immr;
-       volatile clk83xx_t *clk;
-       volatile law83xx_t *pci_law;
-       volatile pot83xx_t *pci_pot;
-       volatile pcictrl83xx_t *pci_ctrl;
-       volatile pciconf83xx_t *pci_conf;
+       volatile immap_t *immr = (volatile immap_t *)CONFIG_SYS_IMMR;
+       volatile clk83xx_t *clk = (volatile clk83xx_t *)&immr->clk;
+       volatile law83xx_t *pci_law = immr->sysconf.pcilaw;
+#ifndef CONFIG_MPC83XX_PCI2
+       struct pci_region *reg[] = { pci1_regions };
+#else
+       struct pci_region *reg[] = { pci1_regions, pci2_regions };
+#endif
 
-       u16 reg16;
-       u32 val32;
-       u32 dev;
+       /* initialize the PCA9555PW IO expander on the PIB board */
+       pib_init();
 
-       immr = (immap_t *) CONFIG_SYS_IMMR;
-       clk = (clk83xx_t *) & immr->clk;
-       pci_law = immr->sysconf.pcilaw;
-       pci_pot = immr->ios.pot;
-       pci_ctrl = immr->pci_ctrl;
-       pci_conf = immr->pci_conf;
-       /*
-        * Configure PCI controller and PCI_CLK_OUTPUT both in 66M mode
-        */
-       val32 = clk->occr;
-       udelay(2000);
 #if defined(PCI_66M)
        clk->occr = OCCR_PCICOE0 | OCCR_PCICOE1 | OCCR_PCICOE2;
        printf("PCI clock is 66MHz\n");
@@ -158,129 +135,19 @@ void pci_init_board(void)
 #endif
        udelay(2000);
 
-       /*
-        * Configure PCI Local Access Windows
-        */
-       pci_law[0].bar = CONFIG_SYS_PCI_MEM_PHYS & LAWBAR_BAR;
+       /* Configure PCI Local Access Windows */
+       pci_law[0].bar = CONFIG_SYS_PCI1_MEM_PHYS & LAWBAR_BAR;
        pci_law[0].ar = LAWAR_EN | LAWAR_SIZE_512M;
 
-       pci_law[1].bar = CONFIG_SYS_PCI_IO_PHYS & LAWBAR_BAR;
+       pci_law[1].bar = CONFIG_SYS_PCI1_IO_PHYS & LAWBAR_BAR;
        pci_law[1].ar = LAWAR_EN | LAWAR_SIZE_1M;
 
-       /*
-        * Configure PCI Outbound Translation Windows
-        */
-
-       /* PCI mem space - prefetch */
-       pci_pot[0].potar = (CONFIG_SYS_PCI_MEM_BASE >> 12) & POTAR_TA_MASK;
-       pci_pot[0].pobar = (CONFIG_SYS_PCI_MEM_PHYS >> 12) & POBAR_BA_MASK;
-       pci_pot[0].pocmr =
-           POCMR_EN | POCMR_SE | (POCMR_CM_256M & POCMR_CM_MASK);
-
-       /* PCI mmio - non-prefetch mem space */
-       pci_pot[1].potar = (CONFIG_SYS_PCI_MMIO_BASE >> 12) & POTAR_TA_MASK;
-       pci_pot[1].pobar = (CONFIG_SYS_PCI_MMIO_PHYS >> 12) & POBAR_BA_MASK;
-       pci_pot[1].pocmr = POCMR_EN | (POCMR_CM_256M & POCMR_CM_MASK);
-
-       /* PCI IO space */
-       pci_pot[2].potar = (CONFIG_SYS_PCI_IO_BASE >> 12) & POTAR_TA_MASK;
-       pci_pot[2].pobar = (CONFIG_SYS_PCI_IO_PHYS >> 12) & POBAR_BA_MASK;
-       pci_pot[2].pocmr = POCMR_EN | POCMR_IO | (POCMR_CM_1M & POCMR_CM_MASK);
-
-       /*
-        * Configure PCI Inbound Translation Windows
-        */
-       pci_ctrl[0].pitar1 = (CONFIG_SYS_PCI_SLV_MEM_LOCAL >> 12) & PITAR_TA_MASK;
-       pci_ctrl[0].pibar1 = (CONFIG_SYS_PCI_SLV_MEM_BUS >> 12) & PIBAR_MASK;
-       pci_ctrl[0].piebar1 = 0x0;
-       pci_ctrl[0].piwar1 =
-           PIWAR_EN | PIWAR_PF | PIWAR_RTT_SNOOP | PIWAR_WTT_SNOOP |
-           PIWAR_IWS_2G;
-
-       /*
-        * Release PCI RST Output signal
-        */
-       udelay(2000);
-       pci_ctrl[0].gcr = 1;
        udelay(2000);
 
-       hose[0].first_busno = 0;
-       hose[0].last_busno = 0xff;
-
-       /* PCI memory prefetch space */
-       pci_set_region(hose[0].regions + 0,
-                      CONFIG_SYS_PCI_MEM_BASE,
-                      CONFIG_SYS_PCI_MEM_PHYS,
-                      CONFIG_SYS_PCI_MEM_SIZE, PCI_REGION_MEM | PCI_REGION_PREFETCH);
-
-       /* PCI memory space */
-       pci_set_region(hose[0].regions + 1,
-                      CONFIG_SYS_PCI_MMIO_BASE,
-                      CONFIG_SYS_PCI_MMIO_PHYS, CONFIG_SYS_PCI_MMIO_SIZE, PCI_REGION_MEM);
-
-       /* PCI IO space */
-       pci_set_region(hose[0].regions + 2,
-                      CONFIG_SYS_PCI_IO_BASE,
-                      CONFIG_SYS_PCI_IO_PHYS, CONFIG_SYS_PCI_IO_SIZE, PCI_REGION_IO);
-
-       /* System memory space */
-       pci_set_region(hose[0].regions + 3,
-                      CONFIG_SYS_PCI_SLV_MEM_LOCAL,
-                      CONFIG_SYS_PCI_SLV_MEM_BUS,
-                      CONFIG_SYS_PCI_SLV_MEM_SIZE,
-                      PCI_REGION_MEM | PCI_REGION_SYS_MEMORY);
-
-       hose[0].region_count = 4;
-
-       pci_setup_indirect(&hose[0],
-                          (CONFIG_SYS_IMMR + 0x8300), (CONFIG_SYS_IMMR + 0x8304));
-
-       pci_register_hose(hose);
-
-       /*
-        * Write command register
-        */
-       reg16 = 0xff;
-       dev = PCI_BDF(0, 0, 0);
-       pci_hose_read_config_word(&hose[0], dev, PCI_COMMAND, &reg16);
-       reg16 |= PCI_COMMAND_SERR | PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY;
-       pci_hose_write_config_word(&hose[0], dev, PCI_COMMAND, reg16);
-
-       /*
-        * Clear non-reserved bits in status register.
-        */
-       pci_hose_write_config_word(&hose[0], dev, PCI_STATUS, 0xffff);
-       pci_hose_write_config_byte(&hose[0], dev, PCI_LATENCY_TIMER, 0x80);
-       pci_hose_write_config_byte(&hose[0], dev, PCI_CACHE_LINE_SIZE, 0x08);
-
-       /*
-        * Hose scan.
-        */
-       hose->last_busno = pci_hose_scan(hose);
+#ifndef CONFIG_MPC83XX_PCI2
+       mpc83xx_pci_init(1, reg, 0);
+#else
+       mpc83xx_pci_init(2, reg, 0);
+#endif
 }
 #endif                         /* CONFIG_PCISLAVE */
-
-#if defined(CONFIG_OF_LIBFDT)
-void ft_pci_setup(void *blob, bd_t *bd)
-{
-       int nodeoffset;
-       int tmp[2];
-       const char *path;
-
-       nodeoffset = fdt_path_offset(blob, "/aliases");
-       if (nodeoffset >= 0) {
-               path = fdt_getprop(blob, nodeoffset, "pci0", NULL);
-               if (path) {
-                       tmp[0] = cpu_to_be32(hose[0].first_busno);
-                       tmp[1] = cpu_to_be32(hose[0].last_busno);
-                       do_fixup_by_path(blob, path, "bus-range",
-                               &tmp, sizeof(tmp), 1);
-
-                       tmp[0] = cpu_to_be32(gd->pci_clk);
-                       do_fixup_by_path(blob, path, "clock-frequency",
-                               &tmp, sizeof(tmp[0]), 1);
-               }
-       }
-}
-#endif                         /* CONFIG_OF_LIBFDT */
-#endif                         /* CONFIG_PCI */
index a97116c..c34905c 100644 (file)
@@ -25,8 +25,10 @@ include $(TOPDIR)/config.mk
 
 LIB    = $(obj)lib$(BOARD).a
 
-COBJS  := $(BOARD).o pci.o
+COBJS-y += $(BOARD).o
+COBJS-$(CONFIG_PCI) += pci.o
 
+COBJS  := $(COBJS-y)
 SRCS   := $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS   := $(addprefix $(obj),$(COBJS))
 SOBJS  := $(addprefix $(obj),$(SOBJS))
index 29de2e7..6b7b8b2 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007 Freescale Semiconductor, Inc.
+ * Copyright (C) 2006-2009 Freescale Semiconductor, Inc.
  *
  * See file CREDITS for list of people who contributed to this
  * project.
@@ -20,7 +20,6 @@
 #include <asm/fsl_i2c.h>
 #include <asm/fsl_serdes.h>
 
-#if defined(CONFIG_PCI)
 static struct pci_region pci_regions[] = {
        {
                bus_start: CONFIG_SYS_PCI_MEM_BASE,
@@ -152,4 +151,3 @@ void ft_pcie_fixup(void *blob, bd_t *bd)
        do_fixup_by_path(blob, "pci2", "status", status,
                         strlen(status) + 1, 1);
 }
-#endif /* CONFIG_PCI */
index a97116c..c34905c 100644 (file)
@@ -25,8 +25,10 @@ include $(TOPDIR)/config.mk
 
 LIB    = $(obj)lib$(BOARD).a
 
-COBJS  := $(BOARD).o pci.o
+COBJS-y += $(BOARD).o
+COBJS-$(CONFIG_PCI) += pci.o
 
+COBJS  := $(COBJS-y)
 SRCS   := $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS   := $(addprefix $(obj),$(COBJS))
 SOBJS  := $(addprefix $(obj),$(SOBJS))
index 83e89cf..97ad227 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007 Freescale Semiconductor, Inc.
+ * Copyright (C) 2006-2009 Freescale Semiconductor, Inc.
  *
  * See file CREDITS for list of people who contributed to this
  * project.
@@ -15,7 +15,6 @@
 #include <pci.h>
 #include <asm/io.h>
 
-#if defined(CONFIG_PCI)
 static struct pci_region pci_regions[] = {
        {
                bus_start: CONFIG_SYS_PCI_MEM_BASE,
@@ -113,4 +112,3 @@ void pci_init_board(void)
 
        mpc83xx_pcie_init(2, pcie_reg, 0);
 }
-#endif /* CONFIG_PCI */
index 28b27ee..8c5984b 100644 (file)
@@ -60,10 +60,41 @@ int board_early_init_f (void)
 
 int checkboard (void)
 {
-       printf ("Board: MPC8536DS, System ID: 0x%02x, "
-               "System Version: 0x%02x, FPGA Version: 0x%02x\n",
-               in8(PIXIS_BASE + PIXIS_ID), in8(PIXIS_BASE + PIXIS_VER),
-               in8(PIXIS_BASE + PIXIS_PVER));
+       u8 vboot;
+       u8 *pixis_base = (u8 *)PIXIS_BASE;
+
+       puts("Board: MPC8536DS ");
+#ifdef CONFIG_PHYS_64BIT
+       puts("(36-bit addrmap) ");
+#endif
+
+       printf ("Sys ID: 0x%02x, "
+               "Sys Ver: 0x%02x, FPGA Ver: 0x%02x, ",
+               in_8(pixis_base + PIXIS_ID), in_8(pixis_base + PIXIS_VER),
+               in_8(pixis_base + PIXIS_PVER));
+
+       vboot = in_8(pixis_base + PIXIS_VBOOT);
+       switch ((vboot & PIXIS_VBOOT_LBMAP) >> 5) {
+               case PIXIS_VBOOT_LBMAP_NOR0:
+                       puts ("vBank: 0\n");
+                       break;
+               case PIXIS_VBOOT_LBMAP_NOR1:
+                       puts ("vBank: 1\n");
+                       break;
+               case PIXIS_VBOOT_LBMAP_NOR2:
+                       puts ("vBank: 2\n");
+                       break;
+               case PIXIS_VBOOT_LBMAP_NOR3:
+                       puts ("vBank: 3\n");
+                       break;
+               case PIXIS_VBOOT_LBMAP_PJET:
+                       puts ("Promjet\n");
+                       break;
+               case PIXIS_VBOOT_LBMAP_NAND:
+                       puts ("NAND\n");
+                       break;
+       }
+
        return 0;
 }
 
@@ -498,20 +529,24 @@ ics307_clk_freq (unsigned char cw0, unsigned char cw1, unsigned char cw2)
 unsigned long
 get_board_sys_clk(ulong dummy)
 {
+       u8 *pixis_base = (u8 *)PIXIS_BASE;
+
        return ics307_clk_freq (
-           in8(PIXIS_BASE + PIXIS_VSYSCLK0),
-           in8(PIXIS_BASE + PIXIS_VSYSCLK1),
-           in8(PIXIS_BASE + PIXIS_VSYSCLK2)
+           in_8(pixis_base + PIXIS_VSYSCLK0),
+           in_8(pixis_base + PIXIS_VSYSCLK1),
+           in_8(pixis_base + PIXIS_VSYSCLK2)
        );
 }
 
 unsigned long
 get_board_ddr_clk(ulong dummy)
 {
+       u8 *pixis_base = (u8 *)PIXIS_BASE;
+
        return ics307_clk_freq (
-           in8(PIXIS_BASE + PIXIS_VDDRCLK0),
-           in8(PIXIS_BASE + PIXIS_VDDRCLK1),
-           in8(PIXIS_BASE + PIXIS_VDDRCLK2)
+           in_8(pixis_base + PIXIS_VDDRCLK0),
+           in_8(pixis_base + PIXIS_VDDRCLK1),
+           in_8(pixis_base + PIXIS_VDDRCLK2)
        );
 }
 #else
@@ -520,8 +555,9 @@ get_board_sys_clk(ulong dummy)
 {
        u8 i;
        ulong val = 0;
+       u8 *pixis_base = (u8 *)PIXIS_BASE;
 
-       i = in8(PIXIS_BASE + PIXIS_SPD);
+       i = in_8(pixis_base + PIXIS_SPD);
        i &= 0x07;
 
        switch (i) {
@@ -559,8 +595,9 @@ get_board_ddr_clk(ulong dummy)
 {
        u8 i;
        ulong val = 0;
+       u8 *pixis_base = (u8 *)PIXIS_BASE;
 
-       i = in8(PIXIS_BASE + PIXIS_SPD);
+       i = in_8(pixis_base + PIXIS_SPD);
        i &= 0x38;
        i >>= 3;
 
index 34bdbad..fd59839 100644 (file)
@@ -43,14 +43,22 @@ int checkboard (void)
        volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
        volatile ccsr_lbc_t *lbc = (void *)(CONFIG_SYS_MPC85xx_LBC_ADDR);
        volatile ccsr_local_ecm_t *ecm = (void *)(CONFIG_SYS_MPC85xx_ECM_ADDR);
+       u8 vboot;
+       u8 *pixis_base = (u8 *)PIXIS_BASE;
 
        if ((uint)&gur->porpllsr != 0xe00e0000) {
                printf("immap size error %lx\n",(ulong)&gur->porpllsr);
        }
-       printf ("Board: MPC8544DS, System ID: 0x%02x, "
-               "System Version: 0x%02x, FPGA Version: 0x%02x\n",
-               in8(PIXIS_BASE + PIXIS_ID), in8(PIXIS_BASE + PIXIS_VER),
-               in8(PIXIS_BASE + PIXIS_PVER));
+       printf ("Board: MPC8544DS, Sys ID: 0x%02x, "
+               "Sys Ver: 0x%02x, FPGA Ver: 0x%02x, ",
+               in_8(pixis_base + PIXIS_ID), in_8(pixis_base + PIXIS_VER),
+               in_8(pixis_base + PIXIS_PVER));
+
+       vboot = in_8(pixis_base + PIXIS_VBOOT);
+       if (vboot & PIXIS_VBOOT_FMAP)
+               printf ("vBank: %d\n", ((vboot & PIXIS_VBOOT_FBANK) >> 6));
+       else
+               puts ("Promjet\n");
 
        lbc->ltesr = 0xffffffff;        /* Clear LBC error interrupts */
        lbc->lteir = 0xffffffff;        /* Enable LBC error interrupts */
@@ -383,11 +391,12 @@ get_board_sys_clk(ulong dummy)
 {
        u8 i, go_bit, rd_clks;
        ulong val = 0;
+       u8 *pixis_base = (u8 *)PIXIS_BASE;
 
-       go_bit = in8(PIXIS_BASE + PIXIS_VCTL);
+       go_bit = in_8(pixis_base + PIXIS_VCTL);
        go_bit &= 0x01;
 
-       rd_clks = in8(PIXIS_BASE + PIXIS_VCFGEN0);
+       rd_clks = in_8(pixis_base + PIXIS_VCFGEN0);
        rd_clks &= 0x1C;
 
        /*
@@ -398,11 +407,11 @@ get_board_sys_clk(ulong dummy)
 
        if (go_bit) {
                if (rd_clks == 0x1c)
-                       i = in8(PIXIS_BASE + PIXIS_AUX);
+                       i = in_8(pixis_base + PIXIS_AUX);
                else
-                       i = in8(PIXIS_BASE + PIXIS_SPD);
+                       i = in_8(pixis_base + PIXIS_SPD);
        } else {
-               i = in8(PIXIS_BASE + PIXIS_SPD);
+               i = in_8(pixis_base + PIXIS_SPD);
        }
 
        i &= 0x07;
index 4b95617..7c86134 100644 (file)
@@ -42,14 +42,34 @@ long int fixed_sdram(void);
 
 int checkboard (void)
 {
+       u8 vboot;
+       u8 *pixis_base = (u8 *)PIXIS_BASE;
+
        puts ("Board: MPC8572DS ");
 #ifdef CONFIG_PHYS_64BIT
        puts ("(36-bit addrmap) ");
 #endif
        printf ("Sys ID: 0x%02x, "
-               "Sys Ver: 0x%02x, FPGA Ver: 0x%02x\n",
-               in8(PIXIS_BASE + PIXIS_ID), in8(PIXIS_BASE + PIXIS_VER),
-               in8(PIXIS_BASE + PIXIS_PVER));
+               "Sys Ver: 0x%02x, FPGA Ver: 0x%02x, ",
+               in_8(pixis_base + PIXIS_ID), in_8(pixis_base + PIXIS_VER),
+               in_8(pixis_base + PIXIS_PVER));
+
+       vboot = in_8(pixis_base + PIXIS_VBOOT);
+       switch ((vboot & PIXIS_VBOOT_LBMAP) >> 6) {
+               case PIXIS_VBOOT_LBMAP_NOR0:
+                       puts ("vBank: 0\n");
+                       break;
+               case PIXIS_VBOOT_LBMAP_PJET:
+                       puts ("Promjet\n");
+                       break;
+               case PIXIS_VBOOT_LBMAP_NAND:
+                       puts ("NAND\n");
+                       break;
+               case PIXIS_VBOOT_LBMAP_NOR1:
+                       puts ("vBank: 1\n");
+                       break;
+       }
+
        return 0;
 }
 
@@ -412,19 +432,23 @@ ics307_clk_freq (unsigned char cw0, unsigned char cw1, unsigned char cw2)
 
 unsigned long get_board_sys_clk(ulong dummy)
 {
+       u8 *pixis_base = (u8 *)PIXIS_BASE;
+
        return ics307_clk_freq (
-                       in8(PIXIS_BASE + PIXIS_VSYSCLK0),
-                       in8(PIXIS_BASE + PIXIS_VSYSCLK1),
-                       in8(PIXIS_BASE + PIXIS_VSYSCLK2)
+                       in_8(pixis_base + PIXIS_VSYSCLK0),
+                       in_8(pixis_base + PIXIS_VSYSCLK1),
+                       in_8(pixis_base + PIXIS_VSYSCLK2)
                        );
 }
 
 unsigned long get_board_ddr_clk(ulong dummy)
 {
+       u8 *pixis_base = (u8 *)PIXIS_BASE;
+
        return ics307_clk_freq (
-                       in8(PIXIS_BASE + PIXIS_VDDRCLK0),
-                       in8(PIXIS_BASE + PIXIS_VDDRCLK1),
-                       in8(PIXIS_BASE + PIXIS_VDDRCLK2)
+                       in_8(pixis_base + PIXIS_VDDRCLK0),
+                       in_8(pixis_base + PIXIS_VDDRCLK1),
+                       in_8(pixis_base + PIXIS_VDDRCLK2)
                        );
 }
 #else
@@ -432,8 +456,9 @@ unsigned long get_board_sys_clk(ulong dummy)
 {
        u8 i;
        ulong val = 0;
+       u8 *pixis_base = (u8 *)PIXIS_BASE;
 
-       i = in8(PIXIS_BASE + PIXIS_SPD);
+       i = in_8(pixis_base + PIXIS_SPD);
        i &= 0x07;
 
        switch (i) {
@@ -470,8 +495,9 @@ unsigned long get_board_ddr_clk(ulong dummy)
 {
        u8 i;
        ulong val = 0;
+       u8 *pixis_base = (u8 *)PIXIS_BASE;
 
-       i = in8(PIXIS_BASE + PIXIS_SPD);
+       i = in_8(pixis_base + PIXIS_SPD);
        i &= 0x38;
        i >>= 3;
 
index a85ebea..2ac169b 100644 (file)
@@ -55,16 +55,17 @@ int board_early_init_f(void)
 int misc_init_r(void)
 {
        u8 tmp_val, version;
+       u8 *pixis_base = (u8 *)PIXIS_BASE;
 
        /*Do not use 8259PIC*/
-       tmp_val = in8(PIXIS_BASE + PIXIS_BRDCFG0);
-       out8(PIXIS_BASE + PIXIS_BRDCFG0, tmp_val | 0x80);
+       tmp_val = in_8(pixis_base + PIXIS_BRDCFG0);
+       out_8(pixis_base + PIXIS_BRDCFG0, tmp_val | 0x80);
 
        /*For FPGA V7 or higher, set the IRQMAPSEL to 0 to use MAP0 interrupt*/
-       version = in8(PIXIS_BASE + PIXIS_PVER);
+       version = in_8(pixis_base + PIXIS_PVER);
        if(version >= 0x07) {
-               tmp_val = in8(PIXIS_BASE + PIXIS_BRDCFG0);
-               out8(PIXIS_BASE + PIXIS_BRDCFG0, tmp_val & 0xbf);
+               tmp_val = in_8(pixis_base + PIXIS_BRDCFG0);
+               out_8(pixis_base + PIXIS_BRDCFG0, tmp_val & 0xbf);
        }
 
        /* Using this for DIU init before the driver in linux takes over
@@ -96,11 +97,12 @@ int checkboard(void)
 {
        volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
        volatile ccsr_local_mcm_t *mcm = &immap->im_local_mcm;
+       u8 *pixis_base = (u8 *)PIXIS_BASE;
 
        printf ("Board: MPC8610HPCD, System ID: 0x%02x, "
                "System Version: 0x%02x, FPGA Version: 0x%02x\n",
-               in8(PIXIS_BASE + PIXIS_ID), in8(PIXIS_BASE + PIXIS_VER),
-               in8(PIXIS_BASE + PIXIS_PVER));
+               in_8(pixis_base + PIXIS_ID), in_8(pixis_base + PIXIS_VER),
+               in_8(pixis_base + PIXIS_PVER));
 
        mcm->abcr |= 0x00010000; /* 0 */
        mcm->hpmr3 = 0x80000008; /* 4c */
@@ -154,7 +156,7 @@ phys_size_t fixed_sdram(void)
        ddr->timing_cfg_0 = 0x00260802;
        ddr->timing_cfg_1 = 0x3935d322;
        ddr->timing_cfg_2 = 0x14904cc8;
-       ddr->sdram_mode_1 = 0x00480432;
+       ddr->sdram_mode = 0x00480432;
        ddr->sdram_mode_2 = 0x00000000;
        ddr->sdram_interval = 0x06180fff; /* 0x06180100; */
        ddr->sdram_data_init = 0xDEADBEEF;
@@ -170,7 +172,7 @@ phys_size_t fixed_sdram(void)
 
        udelay(500);
 
-       ddr->sdram_cfg_1 = 0xc3000000; /* 0xe3008000;*/
+       ddr->sdram_cfg = 0xc3000000; /* 0xe3008000;*/
 
 
 #if defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER)
@@ -438,10 +440,9 @@ get_board_sys_clk(ulong dummy)
 {
        u8 i;
        ulong val = 0;
-       ulong a;
+       u8 *pixis_base = (u8 *)PIXIS_BASE;
 
-       a = PIXIS_BASE + PIXIS_SPD;
-       i = in8(a);
+       i = in_8(pixis_base + PIXIS_SPD);
        i &= 0x07;
 
        switch (i) {
@@ -481,7 +482,9 @@ int board_eth_init(bd_t *bis)
 
 void board_reset(void)
 {
-       out8(PIXIS_BASE + PIXIS_RST, 0);
+       u8 *pixis_base = (u8 *)PIXIS_BASE;
+
+       out_8(pixis_base + PIXIS_RST, 0);
 
        while (1)
                ;
index 63eba0c..4186a2e 100644 (file)
@@ -69,9 +69,10 @@ void mpc8610hpcd_diu_init(void)
        unsigned int pixel_format;
        unsigned char tmp_val;
        unsigned char pixis_arch;
+       u8 *pixis_base = (u8 *)PIXIS_BASE;
 
-       tmp_val = in8(PIXIS_BASE + PIXIS_BRDCFG0);
-       pixis_arch = in8(PIXIS_BASE + PIXIS_VER);
+       tmp_val = in_8(pixis_base + PIXIS_BRDCFG0);
+       pixis_arch = in_8(pixis_base + PIXIS_VER);
 
        monitor_port = getenv("monitor");
        if (!strncmp(monitor_port, "0", 1)) {   /* 0 - DVI */
@@ -82,28 +83,28 @@ void mpc8610hpcd_diu_init(void)
                else
                        pixel_format = 0x88883316;
                gamma_fix = 0;
-               out8(PIXIS_BASE + PIXIS_BRDCFG0, tmp_val | 0x08);
+               out_8(pixis_base + PIXIS_BRDCFG0, tmp_val | 0x08);
 
        } else if (!strncmp(monitor_port, "1", 1)) { /* 1 - Single link LVDS */
                xres = 1024;
                yres = 768;
                pixel_format = 0x88883316;
                gamma_fix = 0;
-               out8(PIXIS_BASE + PIXIS_BRDCFG0, (tmp_val & 0xf7) | 0x10);
+               out_8(pixis_base + PIXIS_BRDCFG0, (tmp_val & 0xf7) | 0x10);
 
        } else if (!strncmp(monitor_port, "2", 1)) { /* 2 - Double link LVDS */
                xres = 1280;
                yres = 1024;
                pixel_format = 0x88883316;
                gamma_fix = 1;
-               out8(PIXIS_BASE + PIXIS_BRDCFG0, tmp_val & 0xe7);
+               out_8(pixis_base + PIXIS_BRDCFG0, tmp_val & 0xe7);
 
        } else {        /* DVI */
                xres = 1280;
                yres = 1024;
                pixel_format = 0x88882317;
                gamma_fix = 0;
-               out8(PIXIS_BASE + PIXIS_BRDCFG0, tmp_val | 0x08);
+               out_8(pixis_base + PIXIS_BRDCFG0, tmp_val | 0x08);
        }
 
        fsl_diu_init(xres, pixel_format, gamma_fix,
index 7422e6b..a8b2112 100644 (file)
@@ -42,10 +42,20 @@ int board_early_init_f(void)
 
 int checkboard(void)
 {
-       printf ("Board: MPC8641HPCN, System ID: 0x%02x, "
-               "System Version: 0x%02x, FPGA Version: 0x%02x\n",
-               in8(PIXIS_BASE + PIXIS_ID), in8(PIXIS_BASE + PIXIS_VER),
-               in8(PIXIS_BASE + PIXIS_PVER));
+       u8 vboot;
+       u8 *pixis_base = (u8 *)PIXIS_BASE;
+
+       printf ("Board: MPC8641HPCN, Sys ID: 0x%02x, "
+               "Sys Ver: 0x%02x, FPGA Ver: 0x%02x, ",
+               in_8(pixis_base + PIXIS_ID), in_8(pixis_base + PIXIS_VER),
+               in_8(pixis_base + PIXIS_PVER));
+
+       vboot = in_8(pixis_base + PIXIS_VBOOT);
+       if (vboot & PIXIS_VBOOT_FMAP)
+               printf ("vBank: %d\n", ((vboot & PIXIS_VBOOT_FBANK) >> 6));
+       else
+               puts ("Promjet\n");
+
 #ifdef CONFIG_PHYS_64BIT
        printf ("       36-bit physical address map\n");
 #endif
@@ -91,7 +101,7 @@ fixed_sdram(void)
        ddr->timing_cfg_0 = CONFIG_SYS_DDR_TIMING_0;
        ddr->timing_cfg_1 = CONFIG_SYS_DDR_TIMING_1;
        ddr->timing_cfg_2 = CONFIG_SYS_DDR_TIMING_2;
-       ddr->sdram_mode_1 = CONFIG_SYS_DDR_MODE_1;
+       ddr->sdram_mode = CONFIG_SYS_DDR_MODE_1;
        ddr->sdram_mode_2 = CONFIG_SYS_DDR_MODE_2;
        ddr->sdram_interval = CONFIG_SYS_DDR_INTERVAL;
        ddr->sdram_data_init = CONFIG_SYS_DDR_DATA_INIT;
@@ -109,9 +119,9 @@ fixed_sdram(void)
 
 #if defined (CONFIG_DDR_ECC)
        /* Enable ECC checking */
-       ddr->sdram_cfg_1 = (CONFIG_SYS_DDR_CONTROL | 0x20000000);
+       ddr->sdram_cfg = (CONFIG_SYS_DDR_CONTROL | 0x20000000);
 #else
-       ddr->sdram_cfg_1 = CONFIG_SYS_DDR_CONTROL;
+       ddr->sdram_cfg = CONFIG_SYS_DDR_CONTROL;
        ddr->sdram_cfg_2 = CONFIG_SYS_DDR_CONTROL2;
 #endif
        asm("sync; isync");
@@ -300,11 +310,12 @@ get_board_sys_clk(ulong dummy)
 {
        u8 i, go_bit, rd_clks;
        ulong val = 0;
+       u8 *pixis_base = (u8 *)PIXIS_BASE;
 
-       go_bit = in8(PIXIS_BASE + PIXIS_VCTL);
+       go_bit = in_8(pixis_base + PIXIS_VCTL);
        go_bit &= 0x01;
 
-       rd_clks = in8(PIXIS_BASE + PIXIS_VCFGEN0);
+       rd_clks = in_8(pixis_base + PIXIS_VCFGEN0);
        rd_clks &= 0x1C;
 
        /*
@@ -315,11 +326,11 @@ get_board_sys_clk(ulong dummy)
 
        if (go_bit) {
                if (rd_clks == 0x1c)
-                       i = in8(PIXIS_BASE + PIXIS_AUX);
+                       i = in_8(pixis_base + PIXIS_AUX);
                else
-                       i = in8(PIXIS_BASE + PIXIS_SPD);
+                       i = in_8(pixis_base + PIXIS_SPD);
        } else {
-               i = in8(PIXIS_BASE + PIXIS_SPD);
+               i = in_8(pixis_base + PIXIS_SPD);
        }
 
        i &= 0x07;
@@ -363,7 +374,9 @@ int board_eth_init(bd_t *bis)
 
 void board_reset(void)
 {
-       out8(PIXIS_BASE + PIXIS_RST, 0);
+       u8 *pixis_base = (u8 *)PIXIS_BASE;
+
+       out_8(pixis_base + PIXIS_RST, 0);
 
        while (1)
                ;
index 293e5a4..14de7e7 100644 (file)
@@ -47,14 +47,31 @@ phys_size_t fixed_sdram(void);
 
 int checkboard(void)
 {
+       u8 sw7;
+       u8 *pixis_base = (u8 *)PIXIS_BASE;
+
        puts("Board: P2020DS ");
 #ifdef CONFIG_PHYS_64BIT
        puts("(36-bit addrmap) ");
 #endif
+
        printf("Sys ID: 0x%02x, "
-               "Sys Ver: 0x%02x, FPGA Ver: 0x%02x\n",
-               in8(PIXIS_BASE + PIXIS_ID), in8(PIXIS_BASE + PIXIS_VER),
-               in8(PIXIS_BASE + PIXIS_PVER));
+               "Sys Ver: 0x%02x, FPGA Ver: 0x%02x, ",
+               in_8(pixis_base + PIXIS_ID), in_8(pixis_base + PIXIS_VER),
+               in_8(pixis_base + PIXIS_PVER));
+
+       sw7 = in_8(pixis_base + PIXIS_SW(7));
+       switch ((sw7 & PIXIS_SW7_LBMAP) >> 6) {
+               case 0:
+               case 1:
+                       printf ("vBank: %d\n", ((sw7 & PIXIS_SW7_VBANK) >> 4));
+                       break;
+               case 2:
+               case 3:
+                       puts ("Promjet\n");
+                       break;
+       }
+
        return 0;
 }
 
@@ -462,10 +479,12 @@ unsigned long
 calculate_board_sys_clk(ulong dummy)
 {
        ulong val;
+       u8 *pixis_base = (u8 *)PIXIS_BASE;
+
        val = ics307_clk_freq(
-           in8(PIXIS_BASE + PIXIS_VSYSCLK0),
-           in8(PIXIS_BASE + PIXIS_VSYSCLK1),
-           in8(PIXIS_BASE + PIXIS_VSYSCLK2));
+           in_8(pixis_base + PIXIS_VSYSCLK0),
+           in_8(pixis_base + PIXIS_VSYSCLK1),
+           in_8(pixis_base + PIXIS_VSYSCLK2));
        debug("sysclk val = %lu\n", val);
        return val;
 }
@@ -474,10 +493,12 @@ unsigned long
 calculate_board_ddr_clk(ulong dummy)
 {
        ulong val;
+       u8 *pixis_base = (u8 *)PIXIS_BASE;
+
        val = ics307_clk_freq(
-           in8(PIXIS_BASE + PIXIS_VDDRCLK0),
-           in8(PIXIS_BASE + PIXIS_VDDRCLK1),
-           in8(PIXIS_BASE + PIXIS_VDDRCLK2));
+           in_8(pixis_base + PIXIS_VDDRCLK0),
+           in_8(pixis_base + PIXIS_VDDRCLK1),
+           in_8(pixis_base + PIXIS_VDDRCLK2));
        debug("ddrclk val = %lu\n", val);
        return val;
 }
@@ -486,8 +507,9 @@ unsigned long get_board_sys_clk(ulong dummy)
 {
        u8 i;
        ulong val = 0;
+       u8 *pixis_base = (u8 *)PIXIS_BASE;
 
-       i = in8(PIXIS_BASE + PIXIS_SPD);
+       i = in_8(pixis_base + PIXIS_SPD);
        i &= 0x07;
 
        switch (i) {
@@ -524,8 +546,9 @@ unsigned long get_board_ddr_clk(ulong dummy)
 {
        u8 i;
        ulong val = 0;
+       u8 *pixis_base = (u8 *)PIXIS_BASE;
 
-       i = in8(PIXIS_BASE + PIXIS_SPD);
+       i = in_8(pixis_base + PIXIS_SPD);
        i &= 0x38;
        i >>= 3;
 
index 218f1be..f6f4719 100644 (file)
@@ -148,21 +148,6 @@ phys_size_t initdram (int board_type)
        return ret;
 }
 
-
-#if defined(CONFIG_CMD_NAND)
-#include <linux/mtd/nand_legacy.h>
-extern struct nand_chip nand_dev_desc[CONFIG_SYS_MAX_NAND_DEVICE];
-
-void nand_init(void)
-{
-       nand_probe(CONFIG_SYS_NAND_BASE);
-       if (nand_dev_desc[0].ChipID != NAND_ChipID_UNKNOWN) {
-               print_size(nand_dev_desc[0].totlen, "\n");
-       }
-}
-#endif
-
-
 #if 0 /* test-only !!! */
 int do_dumpebc(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 {
index b2bd7fd..ec27bda 100644 (file)
@@ -203,8 +203,9 @@ static int ivm_check_crc (unsigned char *buf, int block)
        crceeprom = (buf[CONFIG_SYS_IVM_EEPROM_PAGE_LEN - 1] + \
                        buf[CONFIG_SYS_IVM_EEPROM_PAGE_LEN - 2] * 256);
        if (crc != crceeprom) {
-               printf ("Error CRC Block: %d EEprom: calculated: %lx EEprom: %lx\n",
-                       block, crc, crceeprom);
+               if (block == 0)
+                       printf ("Error CRC Block: %d EEprom: calculated: \
+                       %lx EEprom: %lx\n", block, crc, crceeprom);
                return -1;
        }
        return 0;
@@ -287,7 +288,7 @@ int ivm_analyze_eeprom (unsigned char *buf, int len)
        GET_STRING("IVM_CustomerProductID", IVM_POS_CUSTOMER_PROD_ID, 32)
 
        if (ivm_check_crc (&buf[CONFIG_SYS_IVM_EEPROM_PAGE_LEN * 2], 2) != 0)
-               return -2;
+               return 0;
        ivm_analyze_block2 (&buf[CONFIG_SYS_IVM_EEPROM_PAGE_LEN * 2], CONFIG_SYS_IVM_EEPROM_PAGE_LEN);
 
        return 0;
@@ -423,6 +424,7 @@ static int get_scl (void)
 
 #endif
 
+#if !defined(CONFIG_KMETER1)
 static void writeStartSeq (void)
 {
        set_sda (1);
@@ -473,6 +475,7 @@ static int i2c_make_abort (void)
        get_sda ();
        return ret;
 }
+#endif
 
 /**
  * i2c_init_board - reset i2c bus. When the board is powercycled during a
@@ -480,6 +483,23 @@ static int i2c_make_abort (void)
  */
 void i2c_init_board(void)
 {
+#if defined(CONFIG_KMETER1)
+       struct fsl_i2c *dev;
+       dev = (struct fsl_i2c *) (CONFIG_SYS_IMMR + CONFIG_SYS_I2C_OFFSET);
+       uchar   dummy;
+
+       out_8 (&dev->cr, (I2C_CR_MSTA));
+       out_8 (&dev->cr, (I2C_CR_MEN | I2C_CR_MSTA));
+       dummy = in_8(&dev->dr);
+       dummy = in_8(&dev->dr);
+       if (dummy != 0xff) {
+               dummy = in_8(&dev->dr);
+       }
+       out_8 (&dev->cr, (I2C_CR_MEN));
+       out_8 (&dev->cr, 0x00);
+       out_8 (&dev->cr, (I2C_CR_MEN));
+
+#else
 #if defined(CONFIG_HARD_I2C)
        volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR ;
        volatile i2c8260_t *i2c = (i2c8260_t *)&immap->im_i2c;
@@ -499,6 +519,7 @@ void i2c_init_board(void)
        /* Set the PortPins back to use for I2C */
        setports (0);
 #endif
+#endif
 }
 #endif
 #endif
@@ -527,6 +548,34 @@ int fdt_set_node_and_value (void *blob,
        }
        return ret;
 }
+int fdt_get_node_and_value (void *blob,
+                               char *nodename,
+                               char *propname,
+                               void **var)
+{
+       int len;
+       int nodeoffset = 0;
+
+       nodeoffset = fdt_path_offset (blob, nodename);
+       if (nodeoffset >= 0) {
+               *var = (void *)fdt_getprop (blob, nodeoffset, propname, &len);
+               if (len == 0) {
+                       /* no value */
+                       printf ("%s no value\n", __FUNCTION__);
+                       return -1;
+               } else if (len > 0) {
+                       return len;
+               } else {
+                       printf ("libfdt fdt_getprop(): %s\n",
+                               fdt_strerror(len));
+                       return -2;
+               }
+       } else {
+               printf("%s: cannot find %s node err:%s\n", __FUNCTION__,
+                       nodename, fdt_strerror (nodeoffset));
+               return -3;
+       }
+}
 #endif
 
 int ethernet_present (void)
index d3d6814..a38c727 100644 (file)
@@ -17,4 +17,14 @@ int ivm_read_eeprom (void);
 #ifdef CONFIG_KEYMILE_HDLC_ENET
 int keymile_hdlc_enet_initialize (bd_t *bis);
 #endif
+
+int fdt_set_node_and_value (void *blob,
+                       char *nodename,
+                       char *regname,
+                       void *var,
+                       int size);
+int fdt_get_node_and_value (void *blob,
+                               char *nodename,
+                               char *propname,
+                               void **var);
 #endif /* __KEYMILE_COMMON_H */
index 7c58179..ec883a4 100644 (file)
@@ -159,12 +159,6 @@ int hush_init_var (void)
 }
 
 #if defined(CONFIG_OF_BOARD_SETUP) && defined(CONFIG_OF_LIBFDT)
-extern int fdt_set_node_and_value (void *blob,
-                               char *nodename,
-                               char *regname,
-                               void *var,
-                               int size);
-
 /*
  * update "memory" property in the blob
  */
@@ -172,33 +166,53 @@ void ft_blob_update (void *blob, bd_t *bd)
 {
        ulong brg_data[1] = {0};
        ulong memory_data[2] = {0};
-       ulong flash_data[4] = {0};
+       ulong *flash_data = NULL;
        ulong flash_reg[3] = {0};
-       uchar enetaddr[6];
+       flash_info_t    *info;
+       int     len;
+       int     i = 0;
 
        memory_data[0] = cpu_to_be32 (bd->bi_memstart);
        memory_data[1] = cpu_to_be32 (bd->bi_memsize);
        fdt_set_node_and_value (blob, "/memory", "reg", memory_data,
                                sizeof (memory_data));
 
-       flash_data[2] = cpu_to_be32 (bd->bi_flashstart);
-       flash_data[3] = cpu_to_be32 (bd->bi_flashsize);
+       len = fdt_get_node_and_value (blob, "/localbus", "ranges",
+                                       (void *)&flash_data);
+
+       if (flash_data == NULL) {
+               printf ("%s: error /localbus/ranges entry\n", __FUNCTION__);
+               return;
+       }
+
+       /* update Flash addr, size */
+       while ( i < (len / 4)) {
+               switch (flash_data[i]) {
+               case 0:
+                       info = flash_get_info(CONFIG_SYS_FLASH_BASE);
+                       flash_data[i + 1] = 0;
+                       flash_data[i + 2] = cpu_to_be32 (CONFIG_SYS_FLASH_BASE);
+                       flash_data[i + 3] = cpu_to_be32 (info->size);
+                       break;
+               default:
+                       break;
+               }
+               i += 4;
+       }
        fdt_set_node_and_value (blob, "/localbus", "ranges", flash_data,
-                               sizeof (flash_data));
+                               len);
 
        flash_reg[2] = cpu_to_be32 (bd->bi_flashsize);
        fdt_set_node_and_value (blob, "/localbus/flash@0,0", "reg", flash_reg,
                                sizeof (flash_reg));
-
        /* BRG */
        brg_data[0] = cpu_to_be32 (bd->bi_busfreq);
        fdt_set_node_and_value (blob, "/soc/cpm", "brg-frequency", brg_data,
                                sizeof (brg_data));
 
        /* MAC adr */
-       eth_getenv_enetaddr("ethaddr", enetaddr);
        fdt_set_node_and_value (blob, "/soc/cpm/ethernet", "mac-address",
-                               enetaddr, sizeof (u8) * 6);
+                               bd->bi_enetaddr, sizeof (u8) * 6);
 }
 
 void ft_board_setup(void *blob, bd_t *bd)
index 3d1b941..8cac2c4 100644 (file)
@@ -187,9 +187,60 @@ int checkboard (void)
 }
 
 #if defined(CONFIG_OF_BOARD_SETUP)
+/*
+ * update "/localbus/ranges" property in the blob
+ */
+void ft_blob_update (void *blob, bd_t *bd)
+{
+       ulong   *flash_data = NULL;
+       flash_info_t    *info;
+       ulong   flash_reg[6] = {0};
+       int     len;
+       int     size = 0;
+       int     i = 0;
+
+       len = fdt_get_node_and_value (blob, "/localbus", "ranges",
+                                       (void *)&flash_data);
+
+       if (flash_data == NULL) {
+               printf ("%s: error /localbus/ranges entry\n", __FUNCTION__);
+               return;
+       }
+
+       /* update Flash addr, size */
+       while ( i < (len / 4)) {
+               switch (flash_data[i]) {
+               case 0:
+                       info = flash_get_info(CONFIG_SYS_FLASH_BASE);
+                       size = info->size;
+                       info = flash_get_info(CONFIG_SYS_FLASH_BASE_1);
+                       size += info->size;
+                       flash_data[i + 1] = 0;
+                       flash_data[i + 2] = cpu_to_be32 (CONFIG_SYS_FLASH_BASE);
+                       flash_data[i + 3] = cpu_to_be32 (size);
+                       break;
+               default:
+                       break;
+               }
+               i += 4;
+       }
+       fdt_set_node_and_value (blob, "/localbus", "ranges", flash_data,
+                               len);
+
+       info = flash_get_info(CONFIG_SYS_FLASH_BASE);
+       flash_reg[2] = cpu_to_be32 (size);
+       flash_reg[4] = flash_reg[2];
+       info = flash_get_info(CONFIG_SYS_FLASH_BASE_1);
+       flash_reg[5] = cpu_to_be32 (info->size);
+       fdt_set_node_and_value (blob, "/localbus/flash@f0000000,0", "reg", flash_reg,
+                               sizeof (flash_reg));
+}
+
+
 void ft_board_setup (void *blob, bd_t *bd)
 {
        ft_cpu_setup (blob, bd);
+       ft_blob_update (blob, bd);
 }
 #endif
 
index 67722e7..d24a4b5 100644 (file)
@@ -312,42 +312,71 @@ int hush_init_var (void)
 }
 
 #if defined(CONFIG_OF_BOARD_SETUP) && defined(CONFIG_OF_LIBFDT)
-extern int fdt_set_node_and_value (void *blob,
-                               char *nodename,
-                               char *regname,
-                               void *var,
-                               int size);
-
 /*
  * update "memory" property in the blob
  */
 void ft_blob_update (void *blob, bd_t *bd)
 {
        ulong memory_data[2] = {0};
-       ulong flash_data[8] = {0};
+       ulong *flash_data = NULL;
+       ulong   flash_reg[6] = {0};
        flash_info_t    *info;
-       uchar enetaddr[6];
+       int     len;
+       int     size;
+       int     i = 0;
 
        memory_data[0] = cpu_to_be32 (bd->bi_memstart);
        memory_data[1] = cpu_to_be32 (bd->bi_memsize);
        fdt_set_node_and_value (blob, "/memory", "reg", memory_data,
                                sizeof (memory_data));
 
+       len = fdt_get_node_and_value (blob, "/localbus", "ranges",
+                                       (void *)&flash_data);
+
+       if (flash_data == NULL) {
+               printf ("%s: error /localbus/ranges entry\n", __FUNCTION__);
+               return;
+       }
+
        /* update Flash addr, size */
-       info = flash_get_info(CONFIG_SYS_FLASH_BASE);
-       flash_data[2] = cpu_to_be32 (CONFIG_SYS_FLASH_BASE);
-       flash_data[3] = cpu_to_be32 (info->size);
-       flash_data[4] = cpu_to_be32 (5);
-       flash_data[5] = cpu_to_be32 (0);
-       info = flash_get_info(CONFIG_SYS_FLASH_BASE_1);
-       flash_data[6] = cpu_to_be32 (CONFIG_SYS_FLASH_BASE_1);
-       flash_data[7] = cpu_to_be32 (info->size);
+       while ( i < (len / 4)) {
+               switch (flash_data[i]) {
+               case 0:
+                       info = flash_get_info(CONFIG_SYS_FLASH_BASE);
+                       flash_data[i + 1] = 0;
+                       flash_data[i + 2] = cpu_to_be32 (CONFIG_SYS_FLASH_BASE);
+                       flash_data[i + 3] = cpu_to_be32 (info->size);
+                       break;
+               case 5:
+                       info = flash_get_info(CONFIG_SYS_FLASH_BASE_1);
+                       size = info->size;
+                       info = flash_get_info(CONFIG_SYS_FLASH_BASE_2);
+                       size += info->size;
+                       flash_data[i + 1] = 0;
+                       flash_data[i + 2] = cpu_to_be32 (CONFIG_SYS_FLASH_BASE_1);
+                       flash_data[i + 3] = cpu_to_be32 (size);
+                       break;
+               default:
+                       break;
+               }
+               i += 4;
+       }
        fdt_set_node_and_value (blob, "/localbus", "ranges", flash_data,
-                               sizeof (flash_data));
+                               len);
+
+       info = flash_get_info(CONFIG_SYS_FLASH_BASE_1);
+       flash_reg[0] = cpu_to_be32 (5);
+       flash_reg[2] = cpu_to_be32 (info->size);
+       flash_reg[3] = flash_reg[0];
+       flash_reg[4] = flash_reg[2];
+       info = flash_get_info(CONFIG_SYS_FLASH_BASE_2);
+       flash_reg[5] = cpu_to_be32 (info->size);
+       fdt_set_node_and_value (blob, "/localbus/flash@5,0", "reg", flash_reg,
+                               sizeof (flash_reg));
+
        /* MAC addr */
-       eth_getenv_enetaddr("ethaddr", enetaddr);
        fdt_set_node_and_value (blob, "/soc/cpm/ethernet", "mac-address",
-                               enetaddr, sizeof (u8) * 6);
+                               bd->bi_enetaddr, sizeof (u8) * 6);
 }
 
 void ft_board_setup (void *blob, bd_t *bd)
index 243e3eb..61af4ae 100644 (file)
@@ -29,7 +29,6 @@
 #include <asm/processor.h>
 #include <asm/byteorder.h>
 #include <i2c.h>
-#include <stdio_dev.h>
 #include <pci.h>
 #include <malloc.h>
 #include <bzlib.h>
@@ -428,35 +427,6 @@ void check_env(void)
        }
 }
 
-
-extern device_t *stdio_devices[];
-extern char *stdio_names[];
-
-void show_stdio_dev(void)
-{
-       /* Print information */
-       puts("In:    ");
-       if (stdio_devices[stdin] == NULL) {
-               puts("No input devices available!\n");
-       } else {
-               printf ("%s\n", stdio_devices[stdin]->name);
-       }
-
-       puts("Out:   ");
-       if (stdio_devices[stdout] == NULL) {
-               puts("No output devices available!\n");
-       } else {
-               printf ("%s\n", stdio_devices[stdout]->name);
-       }
-
-       puts("Err:   ");
-       if (stdio_devices[stderr] == NULL) {
-               puts("No error devices available!\n");
-       } else {
-               printf ("%s\n", stdio_devices[stderr]->name);
-       }
-}
-
 #endif /* #if !defined(CONFIG_PATI) */
 
 int do_mplcommon(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
index 46573da..29cd14f 100644 (file)
@@ -37,7 +37,6 @@ void get_backup_values(backup_t *buf);
 #define BOOT_PCI       0x02
 #endif
 
-void show_stdio_dev(void);
 void check_env(void);
 #if defined(CONFIG_CMD_DOC)
 void doc_init (void);
index 302d7a3..355608c 100644 (file)
@@ -819,13 +819,17 @@ static FLASH_WORD_SIZE *read_val = (FLASH_WORD_SIZE *)0x200000;
 
 static int write_word (flash_info_t *info, ulong dest, ulong data)
 {
-       volatile FLASH_WORD_SIZE *addr2 = (FLASH_WORD_SIZE *)(info->start[0]);
-       volatile FLASH_WORD_SIZE *dest2 = (FLASH_WORD_SIZE *)dest;
-       volatile FLASH_WORD_SIZE *data2 = (FLASH_WORD_SIZE *)&data;
+       volatile FLASH_WORD_SIZE *addr2 = (volatile FLASH_WORD_SIZE *)(info->start[0]);
+       volatile FLASH_WORD_SIZE *dest2 = (volatile FLASH_WORD_SIZE *)dest;
+       volatile FLASH_WORD_SIZE *data2;
        ulong start;
+       ulong *data_p;
        int flag;
        int i;
 
+       data_p = &data;
+       data2 = (volatile FLASH_WORD_SIZE *)data_p;
+
        /* Check if Flash is (sufficiently) erased */
        if ((*((volatile FLASH_WORD_SIZE *)dest) &
                (FLASH_WORD_SIZE)data) != (FLASH_WORD_SIZE)data) {
index 5eb90e5..24caa46 100644 (file)
@@ -68,6 +68,7 @@
 #include <4xx_i2c.h>
 #include <miiphy.h>
 #include "../common/common_util.h"
+#include <stdio_dev.h>
 #include <i2c.h>
 #include <rtc.h>
 
@@ -735,7 +736,7 @@ int last_stage_init (void)
                printf ("Error writing to the PHY\n");
        }
        print_mip405_rev ();
-       show_stdio_dev ();
+       stdio_print_current_devices ();
        check_env ();
        /* check if RTC time is valid */
        stop=get_timer(start);
index 0682323..740881e 100644 (file)
@@ -276,7 +276,7 @@ static int pati_pci_eeprom_write(unsigned short offset, unsigned long addr, unsi
 static int pati_pci_eeprom_read(unsigned short offset, unsigned long addr, unsigned short size)
 {
        int i;
-       unsigned short value;
+       unsigned short value = 0;
        unsigned short *buffer =(unsigned short *)addr;
        if((offset + size) > PATI_EEPROM_LAST_OFFSET) {
                size = PATI_EEPROM_LAST_OFFSET - offset;
index 8f23d2d..1b3b698 100644 (file)
@@ -347,8 +347,8 @@ int last_stage_init (void)
 
 int checkboard (void)
 {
-       unsigned char s[50];
-       unsigned long reg;
+       char s[50];
+       ulong reg;
        char rev;
        int i;
 
index 8724e27..f31a5e8 100644 (file)
@@ -28,6 +28,7 @@
 #include "pip405.h"
 #include <asm/processor.h>
 #include <i2c.h>
+#include <stdio_dev.h>
 #include "../common/isa.h"
 #include "../common/common_util.h"
 
@@ -705,7 +706,7 @@ int last_stage_init (void)
 {
        print_pip405_rev ();
        isa_init ();
-       show_stdio_dev ();
+       stdio_print_current_devices ();
        check_env();
        return 0;
 }
index a4c463a..2b3fad2 100644 (file)
@@ -27,6 +27,7 @@
 
 #include <common.h>
 #include <s3c2410.h>
+#include <stdio_dev.h>
 #include <i2c.h>
 
 #include "vcma9.h"
@@ -316,7 +317,7 @@ int last_stage_init(void)
 {
        mem_test_reloc();
        checkboard();
-       show_stdio_dev();
+       stdio_print_current_devices();
        check_env();
        return 0;
 }
index 53d3172..ce5f051 100644 (file)
@@ -597,22 +597,6 @@ int board_early_init_f(void)
        return 0;
 }
 
-#if defined(CONFIG_CMD_NAND)
-
-#include <linux/mtd/nand_legacy.h>
-
-extern ulong nand_probe(ulong physadr);
-extern struct nand_chip nand_dev_desc[CONFIG_SYS_MAX_NAND_DEVICE];
-
-void nand_init(void)
-{
-       unsigned long totlen;
-
-       totlen = nand_probe(CONFIG_SYS_NAND_BASE);
-       printf ("%4lu MB\n", totlen >> 20);
-}
-#endif
-
 #ifdef CONFIG_HW_WATCHDOG
 
 void hw_watchdog_reset(void)
index 02fd94c..38c9d89 100644 (file)
@@ -555,21 +555,6 @@ int board_early_init_f(void)
        return 0;
 }
 
-#if defined(CONFIG_CMD_NAND) && defined(CONFIG_NAND_LEGACY)
-
-#include <linux/mtd/nand_legacy.h>
-
-extern ulong nand_probe(ulong physadr);
-extern struct nand_chip nand_dev_desc[CONFIG_SYS_MAX_NAND_DEVICE];
-
-void nand_init(void)
-{
-       unsigned long totlen = nand_probe(CONFIG_SYS_NAND_BASE);
-
-       printf ("%4lu MB\n", totlen >> 20);
-}
-#endif
-
 #if defined(CONFIG_CMD_PCMCIA)
 
 int pcmcia_init(void)
index 2ce33cf..3b0191d 100644 (file)
@@ -595,22 +595,6 @@ int board_early_init_f(void)
        return 0;
 }
 
-#if defined(CONFIG_CMD_NAND)
-
-#include <linux/mtd/nand_legacy.h>
-
-extern ulong nand_probe(ulong physadr);
-extern struct nand_chip nand_dev_desc[CONFIG_SYS_MAX_NAND_DEVICE];
-
-void nand_init(void)
-{
-       unsigned long totlen;
-
-       totlen = nand_probe(CONFIG_SYS_NAND_BASE);
-       printf ("%4lu MB\n", totlen >> 20);
-}
-#endif
-
 #ifdef CONFIG_HW_WATCHDOG
 
 void hw_watchdog_reset(void)
index 0b032c4..5606996 100644 (file)
@@ -415,18 +415,3 @@ int board_early_init_f(void)
 
        return 0;
 }
-
-#if defined(CONFIG_CMD_NAND)
-
-#include <linux/mtd/nand_legacy.h>
-
-extern ulong nand_probe(ulong physadr);
-extern struct nand_chip nand_dev_desc[CONFIG_SYS_MAX_NAND_DEVICE];
-
-void nand_init(void)
-{
-       unsigned long totlen = nand_probe(CONFIG_SYS_NAND_BASE);
-
-       printf ("%4lu MB\n", totlen >> 20);
-}
-#endif
index 0fe9380..8d18239 100644 (file)
 #include <asm/arch/mem.h>
 #include <i2c.h>
 #include <asm/mach-types.h>
-#if defined(CONFIG_CMD_NAND)
-#include <linux/mtd/nand_legacy.h>
-extern struct nand_chip nand_dev_desc[CONFIG_SYS_MAX_NAND_DEVICE];
-#endif
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -846,22 +842,3 @@ void update_mux(u32 btype,u32 mtype)
                }
        }
 }
-
-#if defined(CONFIG_CMD_NAND)
-void nand_init(void)
-{
-    extern flash_info_t flash_info[];
-
-    nand_probe(CONFIG_SYS_NAND_ADDR);
-    if (nand_dev_desc[0].ChipID != NAND_ChipID_UNKNOWN) {
-               print_size(nand_dev_desc[0].totlen, "\n");
-    }
-
-#ifdef CONFIG_SYS_JFFS2_MEM_NAND
-    flash_info[CONFIG_SYS_JFFS2_FIRST_BANK].flash_id = nand_dev_desc[0].id;
-    flash_info[CONFIG_SYS_JFFS2_FIRST_BANK].size = 1024*1024*2;      /* only read kernel single meg partition */
-       flash_info[CONFIG_SYS_JFFS2_FIRST_BANK].sector_count = 1024;   /* 1024 blocks in 16meg chip (use less for raw/copied partition) */
-    flash_info[CONFIG_SYS_JFFS2_FIRST_BANK].start[0] = 0x80200000; /* ?, ram for now, open question, copy to RAM or adapt for NAND */
-#endif
-}
-#endif
index 7985f7d..6ee44d6 100644 (file)
@@ -147,10 +147,12 @@ void pci_init_board (void)
        cpc710_pci_enable_timeout ();
 }
 
+#ifdef CONFIG_CMD_DOC
 void doc_init (void)
 {
        doc_probe (pcippc2_fpga1_phys + HW_FPGA1_DOC);
 }
+#endif
 
 void pcippc2_cpci3264_init (void)
 {
index b294906..e10d9f9 100644 (file)
@@ -256,6 +256,7 @@ static long int dram_size (long int mamr_value, long int *base,
        return (get_ram_size (base, maxsize));
 }
 
+#ifdef CONFIG_CMD_DOC
 void doc_init (void)
 {
        volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
@@ -267,3 +268,4 @@ void doc_init (void)
 
        doc_probe (FLASH_BASE1_PRELIM);
 }
+#endif
index bd2e45a..52cd174 100644 (file)
@@ -107,17 +107,6 @@ ulong virt_to_phy_smdk6400(ulong addr)
 }
 #endif
 
-#if defined(CONFIG_CMD_NAND) && defined(CONFIG_SYS_NAND_LEGACY)
-#include <linux/mtd/nand.h>
-extern struct nand_chip nand_dev_desc[CONFIG_SYS_MAX_NAND_DEVICE];
-void nand_init(void)
-{
-       nand_probe(CONFIG_SYS_NAND_BASE);
-       if (nand_dev_desc[0].ChipID != NAND_ChipID_UNKNOWN)
-               print_size(nand_dev_desc[0].totlen, "\n");
-}
-#endif
-
 ulong board_flash_get_legacy (ulong base, int banknum, flash_info_t *info)
 {
        if (banknum == 0) {     /* non-CFI boot flash */
index fd6bb2d..454c226 100644 (file)
@@ -24,8 +24,10 @@ include $(TOPDIR)/config.mk
 
 LIB    = $(obj)lib$(BOARD).a
 
-COBJS  := $(BOARD).o pci.o
+COBJS-y += $(BOARD).o
+COBJS-$(CONFIG_PCI) += pci.o
 
+COBJS   := $(COBJS-y)
 SRCS   := $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS   := $(addprefix $(obj),$(COBJS))
 SOBJS  := $(addprefix $(obj),$(SOBJS))
index ac5f30b..ca53356 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * pci.c -- WindRiver SBC8349 PCI board support.
  * Copyright (c) 2006 Wind River Systems, Inc.
+ * Copyright (C) 2006-2009 Freescale Semiconductor, Inc.
  *
  * Based on MPC8349 PCI support but w/o PIB related code.
  *
  */
 
 #include <asm/mmu.h>
+#include <asm/io.h>
 #include <common.h>
-#include <asm/global_data.h>
+#include <mpc83xx.h>
 #include <pci.h>
-#include <asm/mpc8349_pci.h>
 #include <i2c.h>
-#if defined(CONFIG_OF_LIBFDT)
-#include <libfdt.h>
-#include <fdt_support.h>
-#endif
+#include <asm/fsl_i2c.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
-#ifdef CONFIG_PCI
-
-/* System RAM mapped to PCI space */
-#define CONFIG_PCI_SYS_MEM_BUS CONFIG_SYS_SDRAM_BASE
-#define CONFIG_PCI_SYS_MEM_PHYS        CONFIG_SYS_SDRAM_BASE
-
-#ifndef CONFIG_PCI_PNP
-static struct pci_config_table pci_mpc8349emds_config_table[] = {
-       {PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
-        PCI_IDSEL_NUMBER, PCI_ANY_ID,
-        pci_cfgfunc_config_device, {PCI_ENET0_IOADDR,
-                                    PCI_ENET0_MEMADDR,
-                                    PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER
-               }
+static struct pci_region pci1_regions[] = {
+       {
+               bus_start: CONFIG_SYS_PCI1_MEM_BASE,
+               phys_start: CONFIG_SYS_PCI1_MEM_PHYS,
+               size: CONFIG_SYS_PCI1_MEM_SIZE,
+               flags: PCI_REGION_MEM | PCI_REGION_PREFETCH
+       },
+       {
+               bus_start: CONFIG_SYS_PCI1_IO_BASE,
+               phys_start: CONFIG_SYS_PCI1_IO_PHYS,
+               size: CONFIG_SYS_PCI1_IO_SIZE,
+               flags: PCI_REGION_IO
+       },
+       {
+               bus_start: CONFIG_SYS_PCI1_MMIO_BASE,
+               phys_start: CONFIG_SYS_PCI1_MMIO_PHYS,
+               size: CONFIG_SYS_PCI1_MMIO_SIZE,
+               flags: PCI_REGION_MEM
        },
-       {}
-};
-#endif
-
-static struct pci_controller pci_hose[] = {
-       {
-#ifndef CONFIG_PCI_PNP
-       config_table:pci_mpc8349emds_config_table,
-#endif
-       },
-       {
-#ifndef CONFIG_PCI_PNP
-       config_table:pci_mpc8349emds_config_table,
-#endif
-       }
 };
 
-/**************************************************************************
+/*
  * pci_init_board()
  *
  * NOTICE: PCI2 is not supported. There is only one
@@ -79,288 +66,23 @@ static struct pci_controller pci_hose[] = {
 void
 pci_init_board(void)
 {
-       volatile immap_t *      immr;
-       volatile clk83xx_t *    clk;
-       volatile law83xx_t *    pci_law;
-       volatile pot83xx_t *    pci_pot;
-       volatile pcictrl83xx_t *        pci_ctrl;
-       volatile pciconf83xx_t *        pci_conf;
-       u16 reg16;
-       u32 reg32;
-       u32 dev;
-       struct  pci_controller * hose;
-
-       immr = (immap_t *)CONFIG_SYS_IMMR;
-       clk = (clk83xx_t *)&immr->clk;
-       pci_law = immr->sysconf.pcilaw;
-       pci_pot = immr->ios.pot;
-       pci_ctrl = immr->pci_ctrl;
-       pci_conf = immr->pci_conf;
-
-       hose = &pci_hose[0];
+       volatile immap_t *immr = (volatile immap_t *)CONFIG_SYS_IMMR;
+       volatile clk83xx_t *clk = (volatile clk83xx_t *)&immr->clk;
+       volatile law83xx_t *pci_law = immr->sysconf.pcilaw;
+       struct pci_region *reg[] = { pci1_regions };
 
-       /*
-        * Configure PCI controller and PCI_CLK_OUTPUT both in 66M mode
-        */
-
-       reg32 = clk->occr;
-       udelay(2000);
+       /* Enable all 8 PCI_CLK_OUTPUTS */
        clk->occr = 0xff000000;
        udelay(2000);
 
-       /*
-        * Release PCI RST Output signal
-        */
-       pci_ctrl[0].gcr = 0;
-       udelay(2000);
-       pci_ctrl[0].gcr = 1;
-
-#ifdef CONFIG_MPC83XX_PCI2
-       pci_ctrl[1].gcr = 0;
-       udelay(2000);
-       pci_ctrl[1].gcr = 1;
-#endif
-
-       /* We need to wait at least a 1sec based on PCI specs */
-       {
-               int i;
-
-               for (i = 0; i < 1000; ++i)
-                       udelay (1000);
-       }
-
-       /*
-        * Configure PCI Local Access Windows
-        */
+       /* Configure PCI Local Access Windows */
        pci_law[0].bar = CONFIG_SYS_PCI1_MEM_PHYS & LAWBAR_BAR;
        pci_law[0].ar = LAWAR_EN | LAWAR_SIZE_1G;
 
        pci_law[1].bar = CONFIG_SYS_PCI1_IO_PHYS & LAWBAR_BAR;
        pci_law[1].ar = LAWAR_EN | LAWAR_SIZE_4M;
 
-       /*
-        * Configure PCI Outbound Translation Windows
-        */
-
-       /* PCI1 mem space - prefetch */
-       pci_pot[0].potar = (CONFIG_SYS_PCI1_MEM_BASE >> 12) & POTAR_TA_MASK;
-       pci_pot[0].pobar = (CONFIG_SYS_PCI1_MEM_PHYS >> 12) & POBAR_BA_MASK;
-       pci_pot[0].pocmr = POCMR_EN | POCMR_PREFETCH_EN | (POCMR_CM_256M & POCMR_CM_MASK);
-
-       /* PCI1 IO space */
-       pci_pot[1].potar = (CONFIG_SYS_PCI1_IO_BASE >> 12) & POTAR_TA_MASK;
-       pci_pot[1].pobar = (CONFIG_SYS_PCI1_IO_PHYS >> 12) & POBAR_BA_MASK;
-       pci_pot[1].pocmr = POCMR_EN | POCMR_IO | (POCMR_CM_1M & POCMR_CM_MASK);
-
-       /* PCI1 mmio - non-prefetch mem space */
-       pci_pot[2].potar = (CONFIG_SYS_PCI1_MMIO_BASE >> 12) & POTAR_TA_MASK;
-       pci_pot[2].pobar = (CONFIG_SYS_PCI1_MMIO_PHYS >> 12) & POBAR_BA_MASK;
-       pci_pot[2].pocmr = POCMR_EN | (POCMR_CM_256M & POCMR_CM_MASK);
-
-       /*
-        * Configure PCI Inbound Translation Windows
-        */
-
-       /* we need RAM mapped to PCI space for the devices to
-        * access main memory */
-       pci_ctrl[0].pitar1 = 0x0;
-       pci_ctrl[0].pibar1 = 0x0;
-       pci_ctrl[0].piebar1 = 0x0;
-       pci_ctrl[0].piwar1 = PIWAR_EN | PIWAR_PF | PIWAR_RTT_SNOOP | PIWAR_WTT_SNOOP | (__ilog2(gd->ram_size) - 1);
-
-       hose->first_busno = 0;
-       hose->last_busno = 0xff;
-
-       /* PCI memory prefetch space */
-       pci_set_region(hose->regions + 0,
-                      CONFIG_SYS_PCI1_MEM_BASE,
-                      CONFIG_SYS_PCI1_MEM_PHYS,
-                      CONFIG_SYS_PCI1_MEM_SIZE,
-                      PCI_REGION_MEM|PCI_REGION_PREFETCH);
-
-       /* PCI memory space */
-       pci_set_region(hose->regions + 1,
-                      CONFIG_SYS_PCI1_MMIO_BASE,
-                      CONFIG_SYS_PCI1_MMIO_PHYS,
-                      CONFIG_SYS_PCI1_MMIO_SIZE,
-                      PCI_REGION_MEM);
-
-       /* PCI IO space */
-       pci_set_region(hose->regions + 2,
-                      CONFIG_SYS_PCI1_IO_BASE,
-                      CONFIG_SYS_PCI1_IO_PHYS,
-                      CONFIG_SYS_PCI1_IO_SIZE,
-                      PCI_REGION_IO);
-
-       /* System memory space */
-       pci_set_region(hose->regions + 3,
-                      CONFIG_PCI_SYS_MEM_BUS,
-                      CONFIG_PCI_SYS_MEM_PHYS,
-                      gd->ram_size,
-                      PCI_REGION_MEM | PCI_REGION_SYS_MEMORY);
-
-       hose->region_count = 4;
-
-       pci_setup_indirect(hose,
-                          (CONFIG_SYS_IMMR+0x8300),
-                          (CONFIG_SYS_IMMR+0x8304));
-
-       pci_register_hose(hose);
-
-       /*
-        * Write to Command register
-        */
-       reg16 = 0xff;
-       dev = PCI_BDF(hose->first_busno, 0, 0);
-       pci_hose_read_config_word (hose, dev, PCI_COMMAND, &reg16);
-       reg16 |= PCI_COMMAND_SERR | PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY;
-       pci_hose_write_config_word(hose, dev, PCI_COMMAND, reg16);
-
-       /*
-        * Clear non-reserved bits in status register.
-        */
-       pci_hose_write_config_word(hose, dev, PCI_STATUS, 0xffff);
-       pci_hose_write_config_byte(hose, dev, PCI_LATENCY_TIMER, 0x80);
-       pci_hose_write_config_byte(hose, dev, PCI_CACHE_LINE_SIZE, 0x08);
-
-#ifdef CONFIG_PCI_SCAN_SHOW
-       printf("PCI:   Bus Dev VenId DevId Class Int\n");
-#endif
-       /*
-        * Hose scan.
-        */
-       hose->last_busno = pci_hose_scan(hose);
-
-#ifdef CONFIG_MPC83XX_PCI2
-       hose = &pci_hose[1];
-
-       /*
-        * Configure PCI Outbound Translation Windows
-        */
-
-       /* PCI2 mem space - prefetch */
-       pci_pot[3].potar = (CONFIG_SYS_PCI2_MEM_BASE >> 12) & POTAR_TA_MASK;
-       pci_pot[3].pobar = (CONFIG_SYS_PCI2_MEM_PHYS >> 12) & POBAR_BA_MASK;
-       pci_pot[3].pocmr = POCMR_EN | POCMR_PCI2 | POCMR_PREFETCH_EN | (POCMR_CM_256M & POCMR_CM_MASK);
-
-       /* PCI2 IO space */
-       pci_pot[4].potar = (CONFIG_SYS_PCI2_IO_BASE >> 12) & POTAR_TA_MASK;
-       pci_pot[4].pobar = (CONFIG_SYS_PCI2_IO_PHYS >> 12) & POBAR_BA_MASK;
-       pci_pot[4].pocmr = POCMR_EN | POCMR_PCI2 | POCMR_IO | (POCMR_CM_1M & POCMR_CM_MASK);
-
-       /* PCI2 mmio - non-prefetch mem space */
-       pci_pot[5].potar = (CONFIG_SYS_PCI2_MMIO_BASE >> 12) & POTAR_TA_MASK;
-       pci_pot[5].pobar = (CONFIG_SYS_PCI2_MMIO_PHYS >> 12) & POBAR_BA_MASK;
-       pci_pot[5].pocmr = POCMR_EN | POCMR_PCI2 | (POCMR_CM_256M & POCMR_CM_MASK);
-
-       /*
-        * Configure PCI Inbound Translation Windows
-        */
-
-       /* we need RAM mapped to PCI space for the devices to
-        * access main memory */
-       pci_ctrl[1].pitar1 = 0x0;
-       pci_ctrl[1].pibar1 = 0x0;
-       pci_ctrl[1].piebar1 = 0x0;
-       pci_ctrl[1].piwar1 = PIWAR_EN | PIWAR_PF | PIWAR_RTT_SNOOP | PIWAR_WTT_SNOOP | (__ilog2(gd->ram_size) - 1);
-
-       hose->first_busno = pci_hose[0].last_busno + 1;
-       hose->last_busno = 0xff;
-
-       /* PCI memory prefetch space */
-       pci_set_region(hose->regions + 0,
-                      CONFIG_SYS_PCI2_MEM_BASE,
-                      CONFIG_SYS_PCI2_MEM_PHYS,
-                      CONFIG_SYS_PCI2_MEM_SIZE,
-                      PCI_REGION_MEM|PCI_REGION_PREFETCH);
-
-       /* PCI memory space */
-       pci_set_region(hose->regions + 1,
-                      CONFIG_SYS_PCI2_MMIO_BASE,
-                      CONFIG_SYS_PCI2_MMIO_PHYS,
-                      CONFIG_SYS_PCI2_MMIO_SIZE,
-                      PCI_REGION_MEM);
-
-       /* PCI IO space */
-       pci_set_region(hose->regions + 2,
-                      CONFIG_SYS_PCI2_IO_BASE,
-                      CONFIG_SYS_PCI2_IO_PHYS,
-                      CONFIG_SYS_PCI2_IO_SIZE,
-                      PCI_REGION_IO);
-
-       /* System memory space */
-       pci_set_region(hose->regions + 3,
-                      CONFIG_PCI_SYS_MEM_BUS,
-                      CONFIG_PCI_SYS_MEM_PHYS,
-                      gd->ram_size,
-                      PCI_REGION_MEM | PCI_REGION_SYS_MEMORY);
-
-       hose->region_count = 4;
-
-       pci_setup_indirect(hose,
-                          (CONFIG_SYS_IMMR+0x8380),
-                          (CONFIG_SYS_IMMR+0x8384));
-
-       pci_register_hose(hose);
-
-       /*
-        * Write to Command register
-        */
-       reg16 = 0xff;
-       dev = PCI_BDF(hose->first_busno, 0, 0);
-       pci_hose_read_config_word (hose, dev, PCI_COMMAND, &reg16);
-       reg16 |= PCI_COMMAND_SERR | PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY;
-       pci_hose_write_config_word(hose, dev, PCI_COMMAND, reg16);
-
-       /*
-        * Clear non-reserved bits in status register.
-        */
-       pci_hose_write_config_word(hose, dev, PCI_STATUS, 0xffff);
-       pci_hose_write_config_byte(hose, dev, PCI_LATENCY_TIMER, 0x80);
-       pci_hose_write_config_byte(hose, dev, PCI_CACHE_LINE_SIZE, 0x08);
-
-       /*
-        * Hose scan.
-        */
-       hose->last_busno = pci_hose_scan(hose);
-#endif
-
-}
-
-#if defined(CONFIG_OF_LIBFDT)
-void ft_pci_setup(void *blob, bd_t *bd)
-{
-       int nodeoffset;
-       int tmp[2];
-       const char *path;
-
-       nodeoffset = fdt_path_offset(blob, "/aliases");
-       if (nodeoffset >= 0) {
-               path = fdt_getprop(blob, nodeoffset, "pci0", NULL);
-               if (path) {
-                       tmp[0] = cpu_to_be32(pci_hose[0].first_busno);
-                       tmp[1] = cpu_to_be32(pci_hose[0].last_busno);
-                       do_fixup_by_path(blob, path, "bus-range",
-                               &tmp, sizeof(tmp), 1);
-
-                       tmp[0] = cpu_to_be32(gd->pci_clk);
-                       do_fixup_by_path(blob, path, "clock-frequency",
-                               &tmp, sizeof(tmp[0]), 1);
-               }
-#ifdef CONFIG_MPC83XX_PCI2
-               path = fdt_getprop(blob, nodeoffset, "pci1", NULL);
-               if (path) {
-                       tmp[0] = cpu_to_be32(pci_hose[0].first_busno);
-                       tmp[1] = cpu_to_be32(pci_hose[0].last_busno);
-                       do_fixup_by_path(blob, path, "bus-range",
-                               &tmp, sizeof(tmp), 1);
+       udelay(2000);
 
-                       tmp[0] = cpu_to_be32(gd->pci_clk);
-                       do_fixup_by_path(blob, path, "clock-frequency",
-                               &tmp, sizeof(tmp[0]), 1);
-               }
-#endif
-       }
+       mpc83xx_pci_init(1, reg, 0);
 }
-#endif /* CONFIG_OF_LIBFDT */
-#endif /* CONFIG_PCI */
index c39d2c0..f118a6e 100644 (file)
@@ -127,9 +127,9 @@ long int fixed_sdram (void)
        ddr->timing_cfg_0 = CONFIG_SYS_DDR_TIMING_0;
        ddr->timing_cfg_1 = CONFIG_SYS_DDR_TIMING_1;
        ddr->timing_cfg_2 = CONFIG_SYS_DDR_TIMING_2;
-       ddr->sdram_cfg_1 = CONFIG_SYS_DDR_CFG_1A;
+       ddr->sdram_cfg = CONFIG_SYS_DDR_CFG_1A;
        ddr->sdram_cfg_2 = CONFIG_SYS_DDR_CFG_2;
-       ddr->sdram_mode_1 = CONFIG_SYS_DDR_MODE_1;
+       ddr->sdram_mode = CONFIG_SYS_DDR_MODE_1;
        ddr->sdram_mode_2 = CONFIG_SYS_DDR_MODE_2;
        ddr->sdram_mode_cntl = CONFIG_SYS_DDR_MODE_CTL;
        ddr->sdram_interval = CONFIG_SYS_DDR_INTERVAL;
@@ -140,7 +140,7 @@ long int fixed_sdram (void)
 
        udelay (500);
 
-       ddr->sdram_cfg_1 = CONFIG_SYS_DDR_CFG_1B;
+       ddr->sdram_cfg = CONFIG_SYS_DDR_CFG_1B;
        asm ("sync; isync");
 
        udelay (500);
@@ -158,9 +158,9 @@ long int fixed_sdram (void)
        ddr->timing_cfg_0 = CONFIG_SYS_DDR2_TIMING_0;
        ddr->timing_cfg_1 = CONFIG_SYS_DDR2_TIMING_1;
        ddr->timing_cfg_2 = CONFIG_SYS_DDR2_TIMING_2;
-       ddr->sdram_cfg_1 = CONFIG_SYS_DDR2_CFG_1A;
+       ddr->sdram_cfg = CONFIG_SYS_DDR2_CFG_1A;
        ddr->sdram_cfg_2 = CONFIG_SYS_DDR2_CFG_2;
-       ddr->sdram_mode_1 = CONFIG_SYS_DDR2_MODE_1;
+       ddr->sdram_mode = CONFIG_SYS_DDR2_MODE_1;
        ddr->sdram_mode_2 = CONFIG_SYS_DDR2_MODE_2;
        ddr->sdram_mode_cntl = CONFIG_SYS_DDR2_MODE_CTL;
        ddr->sdram_interval = CONFIG_SYS_DDR2_INTERVAL;
@@ -171,7 +171,7 @@ long int fixed_sdram (void)
 
        udelay (500);
 
-       ddr->sdram_cfg_1 = CONFIG_SYS_DDR2_CFG_1B;
+       ddr->sdram_cfg = CONFIG_SYS_DDR2_CFG_1B;
        asm ("sync; isync");
 
        udelay (500);
index 6e39b01..edb5d13 100644 (file)
 # include <status_led.h>
 #endif
 
-#if defined(CONFIG_CMD_NAND)
-#include <linux/mtd/nand_legacy.h>
-extern struct nand_chip nand_dev_desc[CONFIG_SYS_MAX_NAND_DEVICE];
-#endif
-
 DECLARE_GLOBAL_DATA_PTR;
 
 #define ORMASK(size) ((-size) & OR_AM_MSK)
index a1a36c4..717dbe2 100644 (file)
@@ -574,22 +574,6 @@ int board_early_init_f(void)
        return 0;
 }
 
-#if defined(CONFIG_CMD_NAND)
-
-#include <linux/mtd/nand_legacy.h>
-
-extern ulong nand_probe(ulong physadr);
-extern struct nand_chip nand_dev_desc[CONFIG_SYS_MAX_NAND_DEVICE];
-
-void nand_init(void)
-{
-       unsigned long totlen;
-
-       totlen = nand_probe(CONFIG_SYS_NAND_BASE);
-       printf ("%4lu MB\n", totlen >> 20);
-}
-#endif
-
 #ifdef CONFIG_HW_WATCHDOG
 
 void hw_watchdog_reset(void)
index 8889726..011e631 100644 (file)
@@ -27,8 +27,10 @@ include $(TOPDIR)/config.mk
 
 LIB    = $(obj)lib$(BOARD).a
 
-COBJS  = $(BOARD).o pci.o
+COBJS-y += $(BOARD).o
+COBJS-$(CONFIG_PCI) += pci.o
 
+COBJS   := $(COBJS-y)
 SRCS   := $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS   := $(addprefix $(obj),$(COBJS))
 SOBJS  := $(addprefix $(obj),$(SOBJS))
index 6c113e3..fcf4379 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * (C) Copyright 2005
  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ * Copyright (C) 2006-2009 Freescale Semiconductor, Inc.
  *
  * See file CREDITS for list of people who contributed to this
  * project.
  */
 
 #include <asm/mmu.h>
+#include <asm/io.h>
 #include <common.h>
-#include <asm/global_data.h>
+#include <mpc83xx.h>
 #include <pci.h>
-#include <asm/mpc8349_pci.h>
-#if defined(CONFIG_OF_LIBFDT)
-#include <libfdt.h>
-#include <fdt_support.h>
-#endif
+#include <i2c.h>
+#include <asm/fsl_i2c.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
-#ifdef CONFIG_PCI
-
-/* System RAM mapped to PCI space */
-#define CONFIG_PCI_SYS_MEM_BUS CONFIG_SYS_SDRAM_BASE
-#define CONFIG_PCI_SYS_MEM_PHYS        CONFIG_SYS_SDRAM_BASE
-#define CONFIG_PCI_SYS_MEM_SIZE        (1024 * 1024 * 1024)
-
-#ifndef CONFIG_PCI_PNP
-static struct pci_config_table pci_tqm834x_config_table[] = {
-       {PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
-        PCI_IDSEL_NUMBER, PCI_ANY_ID,
-        pci_cfgfunc_config_device, {PCI_ENET0_IOADDR,
-                                    PCI_ENET0_MEMADDR,
-                                    PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER
-               }
+static struct pci_region pci1_regions[] = {
+       {
+               bus_start: CONFIG_SYS_PCI1_MEM_BASE,
+               phys_start: CONFIG_SYS_PCI1_MEM_PHYS,
+               size: CONFIG_SYS_PCI1_MEM_SIZE,
+               flags: PCI_REGION_MEM | PCI_REGION_PREFETCH
+       },
+       {
+               bus_start: CONFIG_SYS_PCI1_IO_BASE,
+               phys_start: CONFIG_SYS_PCI1_IO_PHYS,
+               size: CONFIG_SYS_PCI1_IO_SIZE,
+               flags: PCI_REGION_IO
+       },
+       {
+               bus_start: CONFIG_SYS_PCI1_MMIO_BASE,
+               phys_start: CONFIG_SYS_PCI1_MMIO_PHYS,
+               size: CONFIG_SYS_PCI1_MMIO_SIZE,
+               flags: PCI_REGION_MEM
        },
-       {}
-};
-#endif
-
-static struct pci_controller pci1_hose = {
-#ifndef CONFIG_PCI_PNP
-       config_table:pci_tqm834x_config_table,
-#endif
 };
 
-
-/**************************************************************************
+/*
  * pci_init_board()
  *
  * NOTICE: MPC8349 internally has two PCI controllers (PCI1 and PCI2) but since
@@ -76,30 +69,15 @@ static struct pci_controller pci1_hose = {
 void
 pci_init_board(void)
 {
-       volatile immap_t *      immr;
-       volatile clk83xx_t *    clk;
-       volatile law83xx_t *    pci_law;
-       volatile pot83xx_t *    pci_pot;
-       volatile pcictrl83xx_t *        pci_ctrl;
-       volatile pciconf83xx_t *        pci_conf;
-       u16 reg16;
+       volatile immap_t *immr = (volatile immap_t *)CONFIG_SYS_IMMR;
+       volatile clk83xx_t *clk = (volatile clk83xx_t *)&immr->clk;
+       volatile law83xx_t *pci_law = immr->sysconf.pcilaw;
+       struct pci_region *reg[] = { pci1_regions };
        u32 reg32;
-       struct  pci_controller * hose;
-
-       immr = (immap_t *)CONFIG_SYS_IMMR;
-       clk = (clk83xx_t *)&immr->clk;
-       pci_law = immr->sysconf.pcilaw;
-       pci_pot = immr->ios.pot;
-       pci_ctrl = immr->pci_ctrl;
-       pci_conf = immr->pci_conf;
-
-       hose = &pci1_hose;
 
        /*
         * Configure PCI controller and PCI_CLK_OUTPUT
-        */
-
-       /*
+        *
         * WARNING! only PCI_CLK_OUTPUT1 is enabled here as this is the one
         * line actually used for clocking all external PCI devices in TQM83xx.
         * Enabling other PCI_CLK_OUTPUT lines may lead to board's hang for
@@ -125,141 +103,14 @@ pci_init_board(void)
        clk->occr = reg32;
        udelay(2000);
 
-       /*
-        * Release PCI RST Output signal
-        */
-       pci_ctrl[0].gcr = 0;
-       udelay(2000);
-       pci_ctrl[0].gcr = 1;
-       udelay(2000);
-
-       /*
-        * Configure PCI Local Access Windows
-        */
+       /* Configure PCI Local Access Windows */
        pci_law[0].bar = CONFIG_SYS_PCI1_MEM_PHYS & LAWBAR_BAR;
        pci_law[0].ar = LAWAR_EN | LAWAR_SIZE_512M;
 
        pci_law[1].bar = CONFIG_SYS_PCI1_IO_PHYS & LAWBAR_BAR;
        pci_law[1].ar = LAWAR_EN | LAWAR_SIZE_16M;
 
-       /*
-        * Configure PCI Outbound Translation Windows
-        */
-
-       /* PCI1 mem space */
-       pci_pot[0].potar = (CONFIG_SYS_PCI1_MEM_BASE >> 12) & POTAR_TA_MASK;
-       pci_pot[0].pobar = (CONFIG_SYS_PCI1_MEM_PHYS >> 12) & POBAR_BA_MASK;
-       pci_pot[0].pocmr = POCMR_EN | (POCMR_CM_512M & POCMR_CM_MASK);
-
-       /* PCI1 IO space */
-       pci_pot[1].potar = (CONFIG_SYS_PCI1_IO_BASE >> 12) & POTAR_TA_MASK;
-       pci_pot[1].pobar = (CONFIG_SYS_PCI1_IO_PHYS >> 12) & POBAR_BA_MASK;
-       pci_pot[1].pocmr = POCMR_EN | POCMR_IO | (POCMR_CM_16M & POCMR_CM_MASK);
-
-       /*
-        * Configure PCI Inbound Translation Windows
-        */
-
-       /* we need RAM mapped to PCI space for the devices to
-        * access main memory */
-       pci_ctrl[0].pitar1 = 0x0;
-       pci_ctrl[0].pibar1 = 0x0;
-       pci_ctrl[0].piebar1 = 0x0;
-       pci_ctrl[0].piwar1 = PIWAR_EN | PIWAR_PF | PIWAR_RTT_SNOOP | PIWAR_WTT_SNOOP | PIWAR_IWS_256M;
-
-       hose->first_busno = 0;
-       hose->last_busno = 0xff;
-
-       /* PCI memory space */
-       pci_set_region(hose->regions + 0,
-                      CONFIG_SYS_PCI1_MEM_BASE,
-                      CONFIG_SYS_PCI1_MEM_PHYS,
-                      CONFIG_SYS_PCI1_MEM_SIZE,
-                      PCI_REGION_MEM);
-
-       /* PCI IO space */
-       pci_set_region(hose->regions + 1,
-                      CONFIG_SYS_PCI1_IO_BASE,
-                      CONFIG_SYS_PCI1_IO_PHYS,
-                      CONFIG_SYS_PCI1_IO_SIZE,
-                      PCI_REGION_IO);
-
-       /* System memory space */
-       pci_set_region(hose->regions + 2,
-                      CONFIG_PCI_SYS_MEM_BUS,
-                      CONFIG_PCI_SYS_MEM_PHYS,
-                      CONFIG_PCI_SYS_MEM_SIZE,
-                      PCI_REGION_MEM | PCI_REGION_SYS_MEMORY);
-
-       hose->region_count = 3;
-
-       pci_setup_indirect(hose,
-                          (CONFIG_SYS_IMMR+0x8300),
-                          (CONFIG_SYS_IMMR+0x8304));
-
-       pci_register_hose(hose);
-
-       /*
-        * Write to Command register
-        */
-       reg16 = 0xff;
-       pci_hose_read_config_word (hose, PCI_BDF(0,0,0), PCI_COMMAND,
-                                       &reg16);
-       reg16 |= PCI_COMMAND_SERR | PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY;
-       pci_hose_write_config_word(hose, PCI_BDF(0,0,0), PCI_COMMAND,
-                                       reg16);
-
-       /*
-        * Clear non-reserved bits in status register.
-        */
-       pci_hose_write_config_word(hose, PCI_BDF(0,0,0), PCI_STATUS,
-                                       0xffff);
-       pci_hose_write_config_byte(hose, PCI_BDF(0,0,0), PCI_LATENCY_TIMER,
-                                       0x80);
-
-#ifdef CONFIG_PCI_SCAN_SHOW
-       printf("PCI:   Bus Dev VenId DevId Class Int\n");
-#endif
-       /*
-        * Hose scan.
-        */
-       hose->last_busno = pci_hose_scan(hose);
-}
-
-#if defined(CONFIG_OF_LIBFDT)
-void ft_pci_setup(void *blob, bd_t *bd)
-{
-       int nodeoffset;
-       int tmp[2];
-       const char *path;
-
-       nodeoffset = fdt_path_offset(blob, "/aliases");
-       if (nodeoffset >= 0) {
-               path = fdt_getprop(blob, nodeoffset, "pci0", NULL);
-               if (path) {
-                       tmp[0] = cpu_to_be32(pci1_hose.first_busno);
-                       tmp[1] = cpu_to_be32(pci1_hose.last_busno);
-                       do_fixup_by_path(blob, path, "bus-range",
-                               &tmp, sizeof(tmp), 1);
-
-                       tmp[0] = cpu_to_be32(gd->pci_clk);
-                       do_fixup_by_path(blob, path, "clock-frequency",
-                               &tmp, sizeof(tmp[0]), 1);
-               }
-#ifdef CONFIG_MPC83XX_PCI2
-               path = fdt_getprop(blob, nodeoffset, "pci1", NULL);
-               if (path) {
-                       tmp[0] = cpu_to_be32(pci2_hose.first_busno);
-                       tmp[1] = cpu_to_be32(pci2_hose.last_busno);
-                       do_fixup_by_path(blob, path, "bus-range",
-                               &tmp, sizeof(tmp), 1);
+       udelay(2000);
 
-                       tmp[0] = cpu_to_be32(gd->pci_clk);
-                       do_fixup_by_path(blob, path, "clock-frequency",
-                               &tmp, sizeof(tmp[0]), 1);
-               }
-#endif
-       }
+       mpc83xx_pci_init(1, reg, 0);
 }
-#endif /* CONFIG_OF_LIBFDT */
-#endif /* CONFIG_PCI */
index 6d73a88..503c5e5 100644 (file)
@@ -374,31 +374,6 @@ long int sdram_setup (int casl)
        return (i < N_DDR_CS_CONF) ? ddr_cs_conf[i].size : 0;
 }
 
-void board_add_ram_info (int use_default)
-{
-       int casl;
-
-       if (use_default)
-               casl = CONFIG_DDR_DEFAULT_CL;
-       else
-               casl = cas_latency ();
-
-       puts (" (CL=");
-       switch (casl) {
-       case 20:
-               puts ("2)");
-               break;
-
-       case 25:
-               puts ("2.5)");
-               break;
-
-       case 30:
-               puts ("3)");
-               break;
-       }
-}
-
 phys_size_t initdram (int board_type)
 {
        long dram_size = 0;
@@ -438,11 +413,9 @@ phys_size_t initdram (int board_type)
                /*
                 * Try again with default CAS latency
                 */
-               puts ("Problem with CAS lantency");
-               board_add_ram_info (1);
-               puts (", using default CL!\n");
-               casl = CONFIG_DDR_DEFAULT_CL;
-               dram_size = sdram_setup (casl);
+               printf ("Problem with CAS lantency, using default CL %d/10!\n",
+                       CONFIG_DDR_DEFAULT_CL);
+               dram_size = sdram_setup (CONFIG_DDR_DEFAULT_CL);
                puts ("       ");
        }
 
index ec64efa..81ee70d 100644 (file)
@@ -44,56 +44,3 @@ phys_size_t initdram(int board_type)
 
        return dram_size;
 }
-
-#if defined(CONFIG_DDR_ECC) || (CONFIG_NUM_DDR_CONTROLLERS > 1)
-void board_add_ram_info(int use_default)
-{
-#if (CONFIG_NUM_DDR_CONTROLLERS > 1)
-#if defined(CONFIG_MPC85xx)
-       volatile ccsr_ddr_t *ddr1 = (void *)(CONFIG_SYS_MPC85xx_DDR_ADDR);
-#elif defined(CONFIG_MPC86xx)
-       volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
-       volatile ccsr_ddr_t *ddr1 = &immap->im_ddr1;
-#endif
-#endif
-
-       puts(" (");
-
-#if (CONFIG_NUM_DDR_CONTROLLERS > 1)
-       /* Print interleaving information */
-       if (ddr1->cs0_config & 0x20000000) {
-               switch ((ddr1->cs0_config >> 24) & 0xf) {
-               case 0:
-                       puts("cache line");
-                       break;
-               case 1:
-                       puts("page");
-                       break;
-               case 2:
-                       puts("bank");
-                       break;
-               case 3:
-                       puts("super-bank");
-                       break;
-               default:
-                       puts("invalid");
-                       break;
-               }
-       } else {
-               puts("no");
-       }
-
-       puts(" interleaving");
-#endif
-
-#if (CONFIG_NUM_DDR_CONTROLLERS > 1) && defined(CONFIG_DDR_ECC)
-       puts(", ");
-#endif
-
-#if defined(CONFIG_DDR_ECC)
-       puts("ECC enabled");
-#endif
-
-       puts(")");
-}
-#endif /* CONFIG_DDR_ECC || CONFIG_NUM_DDR_CONTROLLERS > 1 */
index 22cf294..d54c699 100644 (file)
@@ -84,8 +84,8 @@ int board_early_init_r(void)
        /* Initialize PCA9557 devices */
        pca953x_set_pol(CONFIG_SYS_I2C_PCA953X_ADDR0, 0xff, 0);
        pca953x_set_pol(CONFIG_SYS_I2C_PCA953X_ADDR1, 0xff, 0);
-       pca953x_set_pol(CONFIG_SYS_I2C_PCA953X_ADDR0, 0xff, 0);
-       pca953x_set_pol(CONFIG_SYS_I2C_PCA953X_ADDR0, 0xff, 0);
+       pca953x_set_pol(CONFIG_SYS_I2C_PCA953X_ADDR2, 0xff, 0);
+       pca953x_set_pol(CONFIG_SYS_I2C_PCA953X_ADDR3, 0xff, 0);
 
        /*
         * Remap NOR flash region to caching-inhibited
index 899445e..bec54cb 100644 (file)
@@ -23,7 +23,6 @@
 #include <common.h>
 
 #if defined(CONFIG_CMD_NAND)
-#ifdef CONFIG_NEW_NAND_CODE
 
 #include <nand.h>
 #include <asm/arch/pxa-regs.h>
@@ -554,7 +553,4 @@ int board_nand_init(struct nand_chip *nand)
        return 0;
 }
 
-#else
- #error "U-Boot legacy NAND support not available for Monahans DFC."
-#endif
 #endif
index f90e5dd..3781738 100644 (file)
@@ -83,7 +83,6 @@ ifdef CONFIG_POST
 COBJS-$(CONFIG_CMD_DIAG) += cmd_diag.o
 endif
 COBJS-$(CONFIG_CMD_DISPLAY) += cmd_display.o
-COBJS-$(CONFIG_CMD_DOC) += cmd_doc.o
 COBJS-$(CONFIG_CMD_DTT) += cmd_dtt.o
 COBJS-$(CONFIG_ENV_IS_IN_EEPROM) += cmd_eeprom.o
 COBJS-$(CONFIG_CMD_EEPROM) += cmd_eeprom.o
@@ -136,6 +135,7 @@ COBJS-$(CONFIG_CMD_SPI) += cmd_spi.o
 COBJS-$(CONFIG_CMD_SPIBOOTLDR) += cmd_spibootldr.o
 COBJS-$(CONFIG_CMD_STRINGS) += cmd_strings.o
 COBJS-$(CONFIG_CMD_TERMINAL) += cmd_terminal.o
+COBJS-$(CONFIG_CMD_TSI148) += cmd_tsi148.o
 COBJS-$(CONFIG_CMD_UBI) += cmd_ubi.o
 COBJS-$(CONFIG_CMD_UBIFS) += cmd_ubifs.o
 COBJS-$(CONFIG_CMD_UNIVERSE) += cmd_universe.o
@@ -150,7 +150,6 @@ COBJS-$(CONFIG_VFD) += cmd_vfd.o
 
 # others
 COBJS-$(CONFIG_DDR_SPD) += ddr_spd.o
-COBJS-$(CONFIG_CMD_DOC) += docecc.o
 COBJS-$(CONFIG_HWCONFIG) += hwconfig.o
 COBJS-$(CONFIG_CONSOLE_MUX) += iomux.o
 COBJS-y += flash.o
index 367d5a7..5d5dd33 100644 (file)
@@ -52,9 +52,8 @@
 #endif
 
 #ifdef CONFIG_LZMA
-#define _7ZIP_BYTE_DEFINED /* Byte already defined by zlib */
 #include <lzma/LzmaTypes.h>
-#include <lzma/LzmaDecode.h>
+#include <lzma/LzmaDec.h>
 #include <lzma/LzmaTools.h>
 #endif /* CONFIG_LZMA */
 
@@ -390,7 +389,7 @@ static int bootm_load_os(image_info_t os, ulong *load_end, int boot_progress)
                int ret = lzmaBuffToBuffDecompress(
                        (unsigned char *)load, &unc_len,
                        (unsigned char *)image_start, image_len);
-               if (ret != LZMA_RESULT_OK) {
+               if (ret != SZ_OK) {
                        printf ("LZMA: uncompress or overwrite error %d "
                                "- must RESET board to recover\n", ret);
                        show_boot_progress (-6);
diff --git a/common/cmd_doc.c b/common/cmd_doc.c
deleted file mode 100644 (file)
index 5cc90f0..0000000
+++ /dev/null
@@ -1,1644 +0,0 @@
-/*
- * Driver for Disk-On-Chip 2000 and Millennium
- * (c) 1999 Machine Vision Holdings, Inc.
- * (c) 1999, 2000 David Woodhouse <dwmw2@infradead.org>
- *
- * $Id: doc2000.c,v 1.46 2001/10/02 15:05:13 dwmw2 Exp $
- */
-
-#include <common.h>
-#include <config.h>
-#include <command.h>
-#include <malloc.h>
-#include <asm/io.h>
-#include <linux/mtd/nftl.h>
-#include <linux/mtd/doc2000.h>
-
-#error This code is broken and will be removed outright in the next release.
-#error If you need diskonchip support, please update the Linux driver in
-#error drivers/mtd/nand/diskonchip.c to work with u-boot.
-
-/*
- * ! BROKEN !
- *
- * TODO: must be implemented and tested by someone with HW
- */
-#if 0
-#ifdef CONFIG_SYS_DOC_SUPPORT_2000
-#define DoC_is_2000(doc) (doc->ChipID == DOC_ChipID_Doc2k)
-#else
-#define DoC_is_2000(doc) (0)
-#endif
-
-#ifdef CONFIG_SYS_DOC_SUPPORT_MILLENNIUM
-#define DoC_is_Millennium(doc) (doc->ChipID == DOC_ChipID_DocMil)
-#else
-#define DoC_is_Millennium(doc) (0)
-#endif
-
-/* CONFIG_SYS_DOC_PASSIVE_PROBE:
-   In order to ensure that the BIOS checksum is correct at boot time, and
-   hence that the onboard BIOS extension gets executed, the DiskOnChip
-   goes into reset mode when it is read sequentially: all registers
-   return 0xff until the chip is woken up again by writing to the
-   DOCControl register.
-
-   Unfortunately, this means that the probe for the DiskOnChip is unsafe,
-   because one of the first things it does is write to where it thinks
-   the DOCControl register should be - which may well be shared memory
-   for another device. I've had machines which lock up when this is
-   attempted. Hence the possibility to do a passive probe, which will fail
-   to detect a chip in reset mode, but is at least guaranteed not to lock
-   the machine.
-
-   If you have this problem, uncomment the following line:
-#define CONFIG_SYS_DOC_PASSIVE_PROBE
-*/
-
-#undef DOC_DEBUG
-#undef ECC_DEBUG
-#undef PSYCHO_DEBUG
-#undef NFTL_DEBUG
-
-static struct DiskOnChip doc_dev_desc[CONFIG_SYS_MAX_DOC_DEVICE];
-
-/* Current DOC Device  */
-static int curr_device = -1;
-
-/* Supported NAND flash devices */
-static struct nand_flash_dev nand_flash_ids[] = {
-       {"Toshiba TC5816BDC",     NAND_MFR_TOSHIBA, 0x64, 21, 1, 2, 0x1000, 0},
-       {"Toshiba TC5832DC",      NAND_MFR_TOSHIBA, 0x6b, 22, 0, 2, 0x2000, 0},
-       {"Toshiba TH58V128DC",    NAND_MFR_TOSHIBA, 0x73, 24, 0, 2, 0x4000, 0},
-       {"Toshiba TC58256FT/DC",  NAND_MFR_TOSHIBA, 0x75, 25, 0, 2, 0x4000, 0},
-       {"Toshiba TH58512FT",     NAND_MFR_TOSHIBA, 0x76, 26, 0, 3, 0x4000, 0},
-       {"Toshiba TC58V32DC",     NAND_MFR_TOSHIBA, 0xe5, 22, 0, 2, 0x2000, 0},
-       {"Toshiba TC58V64AFT/DC", NAND_MFR_TOSHIBA, 0xe6, 23, 0, 2, 0x2000, 0},
-       {"Toshiba TC58V16BDC",    NAND_MFR_TOSHIBA, 0xea, 21, 1, 2, 0x1000, 0},
-       {"Toshiba TH58100FT",     NAND_MFR_TOSHIBA, 0x79, 27, 0, 3, 0x4000, 0},
-       {"Samsung KM29N16000",    NAND_MFR_SAMSUNG, 0x64, 21, 1, 2, 0x1000, 0},
-       {"Samsung unknown 4Mb",   NAND_MFR_SAMSUNG, 0x6b, 22, 0, 2, 0x2000, 0},
-       {"Samsung KM29U128T",     NAND_MFR_SAMSUNG, 0x73, 24, 0, 2, 0x4000, 0},
-       {"Samsung KM29U256T",     NAND_MFR_SAMSUNG, 0x75, 25, 0, 2, 0x4000, 0},
-       {"Samsung unknown 64Mb",  NAND_MFR_SAMSUNG, 0x76, 26, 0, 3, 0x4000, 0},
-       {"Samsung KM29W32000",    NAND_MFR_SAMSUNG, 0xe3, 22, 0, 2, 0x2000, 0},
-       {"Samsung unknown 4Mb",   NAND_MFR_SAMSUNG, 0xe5, 22, 0, 2, 0x2000, 0},
-       {"Samsung KM29U64000",    NAND_MFR_SAMSUNG, 0xe6, 23, 0, 2, 0x2000, 0},
-       {"Samsung KM29W16000",    NAND_MFR_SAMSUNG, 0xea, 21, 1, 2, 0x1000, 0},
-       {"Samsung K9F5616Q0C",    NAND_MFR_SAMSUNG, 0x45, 25, 0, 2, 0x4000, 1},
-       {"Samsung K9K1216Q0C",    NAND_MFR_SAMSUNG, 0x46, 26, 0, 3, 0x4000, 1},
-       {"Samsung K9F1G08U0M",    NAND_MFR_SAMSUNG, 0xf1, 27, 0, 2, 0, 0},
-       {NULL,}
-};
-
-/* ------------------------------------------------------------------------- */
-
-int do_doc (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
-{
-    int rcode = 0;
-
-    switch (argc) {
-    case 0:
-    case 1:
-       cmd_usage(cmdtp);
-       return 1;
-    case 2:
-       if (strcmp(argv[1],"info") == 0) {
-               int i;
-
-               putc ('\n');
-
-               for (i=0; i<CONFIG_SYS_MAX_DOC_DEVICE; ++i) {
-                       if(doc_dev_desc[i].ChipID == DOC_ChipID_UNKNOWN)
-                               continue; /* list only known devices */
-                       printf ("Device %d: ", i);
-                       doc_print(&doc_dev_desc[i]);
-               }
-               return 0;
-
-       } else if (strcmp(argv[1],"device") == 0) {
-               if ((curr_device < 0) || (curr_device >= CONFIG_SYS_MAX_DOC_DEVICE)) {
-                       puts ("\nno devices available\n");
-                       return 1;
-               }
-               printf ("\nDevice %d: ", curr_device);
-               doc_print(&doc_dev_desc[curr_device]);
-               return 0;
-       }
-       cmd_usage(cmdtp);
-       return 1;
-    case 3:
-       if (strcmp(argv[1],"device") == 0) {
-               int dev = (int)simple_strtoul(argv[2], NULL, 10);
-
-               printf ("\nDevice %d: ", dev);
-               if (dev >= CONFIG_SYS_MAX_DOC_DEVICE) {
-                       puts ("unknown device\n");
-                       return 1;
-               }
-               doc_print(&doc_dev_desc[dev]);
-               /*doc_print (dev);*/
-
-               if (doc_dev_desc[dev].ChipID == DOC_ChipID_UNKNOWN) {
-                       return 1;
-               }
-
-               curr_device = dev;
-
-               puts ("... is now current device\n");
-
-               return 0;
-       }
-
-       cmd_usage(cmdtp);
-       return 1;
-    default:
-       /* at least 4 args */
-
-       if (strcmp(argv[1],"read") == 0 || strcmp(argv[1],"write") == 0) {
-               ulong addr = simple_strtoul(argv[2], NULL, 16);
-               ulong off  = simple_strtoul(argv[3], NULL, 16);
-               ulong size = simple_strtoul(argv[4], NULL, 16);
-               int cmd    = (strcmp(argv[1],"read") == 0);
-               int ret, total;
-
-               printf ("\nDOC %s: device %d offset %ld, size %ld ... ",
-                       cmd ? "read" : "write", curr_device, off, size);
-
-               ret = doc_rw(doc_dev_desc + curr_device, cmd, off, size,
-                            (size_t *)&total, (u_char*)addr);
-
-               printf ("%d bytes %s: %s\n", total, cmd ? "read" : "write",
-                       ret ? "ERROR" : "OK");
-
-               return ret;
-       } else if (strcmp(argv[1],"erase") == 0) {
-               ulong off = simple_strtoul(argv[2], NULL, 16);
-               ulong size = simple_strtoul(argv[3], NULL, 16);
-               int ret;
-
-               printf ("\nDOC erase: device %d offset %ld, size %ld ... ",
-                       curr_device, off, size);
-
-               ret = doc_erase (doc_dev_desc + curr_device, off, size);
-
-               printf("%s\n", ret ? "ERROR" : "OK");
-
-               return ret;
-       } else {
-               cmd_usage(cmdtp);
-               rcode = 1;
-       }
-
-       return rcode;
-    }
-}
-U_BOOT_CMD(
-       doc,    5,      1,      do_doc,
-       "Disk-On-Chip sub-system",
-       "info  - show available DOC devices\n"
-       "doc device [dev] - show or set current device\n"
-       "doc read  addr off size\n"
-       "doc write addr off size - read/write `size'"
-       " bytes starting at offset `off'\n"
-       "    to/from memory address `addr'\n"
-       "doc erase off size - erase `size' bytes of DOC from offset `off'"
-);
-
-int do_docboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
-{
-       char *boot_device = NULL;
-       char *ep;
-       int dev;
-       ulong cnt;
-       ulong addr;
-       ulong offset = 0;
-       image_header_t *hdr;
-       int rcode = 0;
-#if defined(CONFIG_FIT)
-       const void *fit_hdr = NULL;
-#endif
-
-       show_boot_progress (34);
-       switch (argc) {
-       case 1:
-               addr = CONFIG_SYS_LOAD_ADDR;
-               boot_device = getenv ("bootdevice");
-               break;
-       case 2:
-               addr = simple_strtoul(argv[1], NULL, 16);
-               boot_device = getenv ("bootdevice");
-               break;
-       case 3:
-               addr = simple_strtoul(argv[1], NULL, 16);
-               boot_device = argv[2];
-               break;
-       case 4:
-               addr = simple_strtoul(argv[1], NULL, 16);
-               boot_device = argv[2];
-               offset = simple_strtoul(argv[3], NULL, 16);
-               break;
-       default:
-               cmd_usage(cmdtp);
-               show_boot_progress (-35);
-               return 1;
-       }
-
-       show_boot_progress (35);
-       if (!boot_device) {
-               puts ("\n** No boot device **\n");
-               show_boot_progress (-36);
-               return 1;
-       }
-       show_boot_progress (36);
-
-       dev = simple_strtoul(boot_device, &ep, 16);
-
-       if ((dev >= CONFIG_SYS_MAX_DOC_DEVICE) ||
-           (doc_dev_desc[dev].ChipID == DOC_ChipID_UNKNOWN)) {
-               printf ("\n** Device %d not available\n", dev);
-               show_boot_progress (-37);
-               return 1;
-       }
-       show_boot_progress (37);
-
-       printf ("\nLoading from device %d: %s at 0x%lX (offset 0x%lX)\n",
-               dev, doc_dev_desc[dev].name, doc_dev_desc[dev].physadr,
-               offset);
-
-       if (doc_rw (doc_dev_desc + dev, 1, offset,
-                   SECTORSIZE, NULL, (u_char *)addr)) {
-               printf ("** Read error on %d\n", dev);
-               show_boot_progress (-38);
-               return 1;
-       }
-       show_boot_progress (38);
-
-       switch (genimg_get_format ((void *)addr)) {
-       case IMAGE_FORMAT_LEGACY:
-               hdr = (image_header_t *)addr;
-
-               image_print_contents (hdr);
-
-               cnt = image_get_image_size (hdr);
-               break;
-#if defined(CONFIG_FIT)
-       case IMAGE_FORMAT_FIT:
-               fit_hdr = (const void *)addr;
-               puts ("Fit image detected...\n");
-
-               cnt = fit_get_size (fit_hdr);
-               break;
-#endif
-       default:
-               show_boot_progress (-39);
-               puts ("** Unknown image type\n");
-               return 1;
-       }
-       show_boot_progress (39);
-
-       cnt -= SECTORSIZE;
-       if (doc_rw (doc_dev_desc + dev, 1, offset + SECTORSIZE, cnt,
-                   NULL, (u_char *)(addr+SECTORSIZE))) {
-               printf ("** Read error on %d\n", dev);
-               show_boot_progress (-40);
-               return 1;
-       }
-       show_boot_progress (40);
-
-#if defined(CONFIG_FIT)
-       /* This cannot be done earlier, we need complete FIT image in RAM first */
-       if (genimg_get_format ((void *)addr) == IMAGE_FORMAT_FIT) {
-               if (!fit_check_format (fit_hdr)) {
-                       show_boot_progress (-130);
-                       puts ("** Bad FIT image format\n");
-                       return 1;
-               }
-               show_boot_progress (131);
-               fit_print_contents (fit_hdr);
-       }
-#endif
-
-       /* Loading ok, update default load address */
-
-       load_addr = addr;
-
-       /* Check if we should attempt an auto-start */
-       if (((ep = getenv("autostart")) != NULL) && (strcmp(ep,"yes") == 0)) {
-               char *local_args[2];
-               extern int do_bootm (cmd_tbl_t *, int, int, char *[]);
-
-               local_args[0] = argv[0];
-               local_args[1] = NULL;
-
-               printf ("Automatic boot of image at addr 0x%08lX ...\n", addr);
-
-               do_bootm (cmdtp, 0, 1, local_args);
-               rcode = 1;
-       }
-       return rcode;
-}
-
-U_BOOT_CMD(
-       docboot,        4,      1,      do_docboot,
-       "boot from DOC device",
-       "loadAddr dev"
-);
-
-int doc_rw (struct DiskOnChip* this, int cmd,
-           loff_t from, size_t len,
-           size_t * retlen, u_char * buf)
-{
-       int noecc, ret = 0, n, total = 0;
-       char eccbuf[6];
-
-       while(len) {
-               /* The ECC will not be calculated correctly if
-                  less than 512 is written or read */
-               noecc = (from != (from | 0x1ff) + 1) || (len < 0x200);
-
-               if (cmd)
-                       ret = doc_read_ecc(this, from, len,
-                                          (size_t *)&n, (u_char*)buf,
-                                          noecc ? (uchar *)NULL : (uchar *)eccbuf);
-               else
-                       ret = doc_write_ecc(this, from, len,
-                                           (size_t *)&n, (u_char*)buf,
-                                           noecc ? (uchar *)NULL : (uchar *)eccbuf);
-
-               if (ret)
-                       break;
-
-               from  += n;
-               buf   += n;
-               total += n;
-               len   -= n;
-       }
-
-       if (retlen)
-               *retlen = total;
-
-       return ret;
-}
-
-void doc_print(struct DiskOnChip *this) {
-       printf("%s at 0x%lX,\n"
-              "\t  %d chip%s %s, size %d MB, \n"
-              "\t  total size %ld MB, sector size %ld kB\n",
-              this->name, this->physadr, this->numchips,
-              this->numchips>1 ? "s" : "", this->chips_name,
-              1 << (this->chipshift - 20),
-              this->totlen >> 20, this->erasesize >> 10);
-
-       if (this->nftl_found) {
-               struct NFTLrecord *nftl = &this->nftl;
-               unsigned long bin_size, flash_size;
-
-               bin_size = nftl->nb_boot_blocks * this->erasesize;
-               flash_size = (nftl->nb_blocks - nftl->nb_boot_blocks) * this->erasesize;
-
-               printf("\t  NFTL boot record:\n"
-                      "\t    Binary partition: size %ld%s\n"
-                      "\t    Flash disk partition: size %ld%s, offset 0x%lx\n",
-                      bin_size > (1 << 20) ? bin_size >> 20 : bin_size >> 10,
-                      bin_size > (1 << 20) ? "MB" : "kB",
-                      flash_size > (1 << 20) ? flash_size >> 20 : flash_size >> 10,
-                      flash_size > (1 << 20) ? "MB" : "kB", bin_size);
-       } else {
-               puts ("\t  No NFTL boot record found.\n");
-       }
-}
-
-/* ------------------------------------------------------------------------- */
-
-/* This function is needed to avoid calls of the __ashrdi3 function. */
-static int shr(int val, int shift) {
-       return val >> shift;
-}
-
-/* Perform the required delay cycles by reading from the appropriate register */
-static void DoC_Delay(struct DiskOnChip *doc, unsigned short cycles)
-{
-       volatile char dummy;
-       int i;
-
-       for (i = 0; i < cycles; i++) {
-               if (DoC_is_Millennium(doc))
-                       dummy = ReadDOC(doc->virtadr, NOP);
-               else
-                       dummy = ReadDOC(doc->virtadr, DOCStatus);
-       }
-
-}
-
-/* DOC_WaitReady: Wait for RDY line to be asserted by the flash chip */
-static int _DoC_WaitReady(struct DiskOnChip *doc)
-{
-       unsigned long docptr = doc->virtadr;
-       unsigned long start = get_timer(0);
-
-#ifdef PSYCHO_DEBUG
-       puts ("_DoC_WaitReady called for out-of-line wait\n");
-#endif
-
-       /* Out-of-line routine to wait for chip response */
-       while (!(ReadDOC(docptr, CDSNControl) & CDSN_CTRL_FR_B)) {
-#ifdef CONFIG_SYS_DOC_SHORT_TIMEOUT
-               /* it seems that after a certain time the DoC deasserts
-                * the CDSN_CTRL_FR_B although it is not ready...
-                * using a short timout solve this (timer increments every ms) */
-               if (get_timer(start) > 10) {
-                       return DOC_ETIMEOUT;
-               }
-#else
-               if (get_timer(start) > 10 * 1000) {
-                       puts ("_DoC_WaitReady timed out.\n");
-                       return DOC_ETIMEOUT;
-               }
-#endif
-               udelay(1);
-       }
-
-       return 0;
-}
-
-static int DoC_WaitReady(struct DiskOnChip *doc)
-{
-       unsigned long docptr = doc->virtadr;
-       /* This is inline, to optimise the common case, where it's ready instantly */
-       int ret = 0;
-
-       /* 4 read form NOP register should be issued in prior to the read from CDSNControl
-          see Software Requirement 11.4 item 2. */
-       DoC_Delay(doc, 4);
-
-       if (!(ReadDOC(docptr, CDSNControl) & CDSN_CTRL_FR_B))
-               /* Call the out-of-line routine to wait */
-               ret = _DoC_WaitReady(doc);
-
-       /* issue 2 read from NOP register after reading from CDSNControl register
-          see Software Requirement 11.4 item 2. */
-       DoC_Delay(doc, 2);
-
-       return ret;
-}
-
-/* DoC_Command: Send a flash command to the flash chip through the CDSN Slow IO register to
-   bypass the internal pipeline. Each of 4 delay cycles (read from the NOP register) is
-   required after writing to CDSN Control register, see Software Requirement 11.4 item 3. */
-
-static inline int DoC_Command(struct DiskOnChip *doc, unsigned char command,
-                             unsigned char xtraflags)
-{
-       unsigned long docptr = doc->virtadr;
-
-       if (DoC_is_2000(doc))
-               xtraflags |= CDSN_CTRL_FLASH_IO;
-
-       /* Assert the CLE (Command Latch Enable) line to the flash chip */
-       WriteDOC(xtraflags | CDSN_CTRL_CLE | CDSN_CTRL_CE, docptr, CDSNControl);
-       DoC_Delay(doc, 4);      /* Software requirement 11.4.3 for Millennium */
-
-       if (DoC_is_Millennium(doc))
-               WriteDOC(command, docptr, CDSNSlowIO);
-
-       /* Send the command */
-       WriteDOC_(command, docptr, doc->ioreg);
-
-       /* Lower the CLE line */
-       WriteDOC(xtraflags | CDSN_CTRL_CE, docptr, CDSNControl);
-       DoC_Delay(doc, 4);      /* Software requirement 11.4.3 for Millennium */
-
-       /* Wait for the chip to respond - Software requirement 11.4.1 (extended for any command) */
-       return DoC_WaitReady(doc);
-}
-
-/* DoC_Address: Set the current address for the flash chip through the CDSN Slow IO register to
-   bypass the internal pipeline. Each of 4 delay cycles (read from the NOP register) is
-   required after writing to CDSN Control register, see Software Requirement 11.4 item 3. */
-
-static int DoC_Address(struct DiskOnChip *doc, int numbytes, unsigned long ofs,
-                      unsigned char xtraflags1, unsigned char xtraflags2)
-{
-       unsigned long docptr;
-       int i;
-
-       docptr = doc->virtadr;
-
-       if (DoC_is_2000(doc))
-               xtraflags1 |= CDSN_CTRL_FLASH_IO;
-
-       /* Assert the ALE (Address Latch Enable) line to the flash chip */
-       WriteDOC(xtraflags1 | CDSN_CTRL_ALE | CDSN_CTRL_CE, docptr, CDSNControl);
-
-       DoC_Delay(doc, 4);      /* Software requirement 11.4.3 for Millennium */
-
-       /* Send the address */
-       /* Devices with 256-byte page are addressed as:
-          Column (bits 0-7), Page (bits 8-15, 16-23, 24-31)
-          * there is no device on the market with page256
-          and more than 24 bits.
-          Devices with 512-byte page are addressed as:
-          Column (bits 0-7), Page (bits 9-16, 17-24, 25-31)
-          * 25-31 is sent only if the chip support it.
-          * bit 8 changes the read command to be sent
-          (NAND_CMD_READ0 or NAND_CMD_READ1).
-        */
-
-       if (numbytes == ADDR_COLUMN || numbytes == ADDR_COLUMN_PAGE) {
-               if (DoC_is_Millennium(doc))
-                       WriteDOC(ofs & 0xff, docptr, CDSNSlowIO);
-               WriteDOC_(ofs & 0xff, docptr, doc->ioreg);
-       }
-
-       if (doc->page256) {
-               ofs = ofs >> 8;
-       } else {
-               ofs = ofs >> 9;
-       }
-
-       if (numbytes == ADDR_PAGE || numbytes == ADDR_COLUMN_PAGE) {
-               for (i = 0; i < doc->pageadrlen; i++, ofs = ofs >> 8) {
-                       if (DoC_is_Millennium(doc))
-                               WriteDOC(ofs & 0xff, docptr, CDSNSlowIO);
-                       WriteDOC_(ofs & 0xff, docptr, doc->ioreg);
-               }
-       }
-
-       DoC_Delay(doc, 2);      /* Needed for some slow flash chips. mf. */
-
-       /* FIXME: The SlowIO's for millennium could be replaced by
-          a single WritePipeTerm here. mf. */
-
-       /* Lower the ALE line */
-       WriteDOC(xtraflags1 | xtraflags2 | CDSN_CTRL_CE, docptr,
-                CDSNControl);
-
-       DoC_Delay(doc, 4);      /* Software requirement 11.4.3 for Millennium */
-
-       /* Wait for the chip to respond - Software requirement 11.4.1 */
-       return DoC_WaitReady(doc);
-}
-
-/* Read a buffer from DoC, taking care of Millennium oddities */
-static void DoC_ReadBuf(struct DiskOnChip *doc, u_char * buf, int len)
-{
-       volatile int dummy;
-       int modulus = 0xffff;
-       unsigned long docptr;
-       int i;
-
-       docptr = doc->virtadr;
-
-       if (len <= 0)
-               return;
-
-       if (DoC_is_Millennium(doc)) {
-               /* Read the data via the internal pipeline through CDSN IO register,
-                  see Pipelined Read Operations 11.3 */
-               dummy = ReadDOC(docptr, ReadPipeInit);
-
-               /* Millennium should use the LastDataRead register - Pipeline Reads */
-               len--;
-
-               /* This is needed for correctly ECC calculation */
-               modulus = 0xff;
-       }
-
-       for (i = 0; i < len; i++)
-               buf[i] = ReadDOC_(docptr, doc->ioreg + (i & modulus));
-
-       if (DoC_is_Millennium(doc)) {
-               buf[i] = ReadDOC(docptr, LastDataRead);
-       }
-}
-
-/* Write a buffer to DoC, taking care of Millennium oddities */
-static void DoC_WriteBuf(struct DiskOnChip *doc, const u_char * buf, int len)
-{
-       unsigned long docptr;
-       int i;
-
-       docptr = doc->virtadr;
-
-       if (len <= 0)
-               return;
-
-       for (i = 0; i < len; i++)
-               WriteDOC_(buf[i], docptr, doc->ioreg + i);
-
-       if (DoC_is_Millennium(doc)) {
-               WriteDOC(0x00, docptr, WritePipeTerm);
-       }
-}
-
-
-/* DoC_SelectChip: Select a given flash chip within the current floor */
-
-static inline int DoC_SelectChip(struct DiskOnChip *doc, int chip)
-{
-       unsigned long docptr = doc->virtadr;
-
-       /* Software requirement 11.4.4 before writing DeviceSelect */
-       /* Deassert the CE line to eliminate glitches on the FCE# outputs */
-       WriteDOC(CDSN_CTRL_WP, docptr, CDSNControl);
-       DoC_Delay(doc, 4);      /* Software requirement 11.4.3 for Millennium */
-
-       /* Select the individual flash chip requested */
-       WriteDOC(chip, docptr, CDSNDeviceSelect);
-       DoC_Delay(doc, 4);
-
-       /* Reassert the CE line */
-       WriteDOC(CDSN_CTRL_CE | CDSN_CTRL_FLASH_IO | CDSN_CTRL_WP, docptr,
-                CDSNControl);
-       DoC_Delay(doc, 4);      /* Software requirement 11.4.3 for Millennium */
-
-       /* Wait for it to be ready */
-       return DoC_WaitReady(doc);
-}
-
-/* DoC_SelectFloor: Select a given floor (bank of flash chips) */
-
-static inline int DoC_SelectFloor(struct DiskOnChip *doc, int floor)
-{
-       unsigned long docptr = doc->virtadr;
-
-       /* Select the floor (bank) of chips required */
-       WriteDOC(floor, docptr, FloorSelect);
-
-       /* Wait for the chip to be ready */
-       return DoC_WaitReady(doc);
-}
-
-/* DoC_IdentChip: Identify a given NAND chip given {floor,chip} */
-
-static int DoC_IdentChip(struct DiskOnChip *doc, int floor, int chip)
-{
-       int mfr, id, i;
-       volatile char dummy;
-
-       /* Page in the required floor/chip */
-       DoC_SelectFloor(doc, floor);
-       DoC_SelectChip(doc, chip);
-
-       /* Reset the chip */
-       if (DoC_Command(doc, NAND_CMD_RESET, CDSN_CTRL_WP)) {
-#ifdef DOC_DEBUG
-               printf("DoC_Command (reset) for %d,%d returned true\n",
-                      floor, chip);
-#endif
-               return 0;
-       }
-
-
-       /* Read the NAND chip ID: 1. Send ReadID command */
-       if (DoC_Command(doc, NAND_CMD_READID, CDSN_CTRL_WP)) {
-#ifdef DOC_DEBUG
-               printf("DoC_Command (ReadID) for %d,%d returned true\n",
-                      floor, chip);
-#endif
-               return 0;
-       }
-
-       /* Read the NAND chip ID: 2. Send address byte zero */
-       DoC_Address(doc, ADDR_COLUMN, 0, CDSN_CTRL_WP, 0);
-
-       /* Read the manufacturer and device id codes from the device */
-
-       /* CDSN Slow IO register see Software Requirement 11.4 item 5. */
-       dummy = ReadDOC(doc->virtadr, CDSNSlowIO);
-       DoC_Delay(doc, 2);
-       mfr = ReadDOC_(doc->virtadr, doc->ioreg);
-
-       /* CDSN Slow IO register see Software Requirement 11.4 item 5. */
-       dummy = ReadDOC(doc->virtadr, CDSNSlowIO);
-       DoC_Delay(doc, 2);
-       id = ReadDOC_(doc->virtadr, doc->ioreg);
-
-       /* No response - return failure */
-       if (mfr == 0xff || mfr == 0)
-               return 0;
-
-       /* Check it's the same as the first chip we identified.
-        * M-Systems say that any given DiskOnChip device should only
-        * contain _one_ type of flash part, although that's not a
-        * hardware restriction. */
-       if (doc->mfr) {
-               if (doc->mfr == mfr && doc->id == id)
-                       return 1;       /* This is another the same the first */
-               else
-                       printf("Flash chip at floor %d, chip %d is different:\n",
-                              floor, chip);
-       }
-
-       /* Print and store the manufacturer and ID codes. */
-       for (i = 0; nand_flash_ids[i].name != NULL; i++) {
-               if (mfr == nand_flash_ids[i].manufacture_id &&
-                   id == nand_flash_ids[i].model_id) {
-#ifdef DOC_DEBUG
-                       printf("Flash chip found: Manufacturer ID: %2.2X, "
-                              "Chip ID: %2.2X (%s)\n", mfr, id,
-                              nand_flash_ids[i].name);
-#endif
-                       if (!doc->mfr) {
-                               doc->mfr = mfr;
-                               doc->id = id;
-                               doc->chipshift =
-                                   nand_flash_ids[i].chipshift;
-                               doc->page256 = nand_flash_ids[i].page256;
-                               doc->pageadrlen =
-                                   nand_flash_ids[i].pageadrlen;
-                               doc->erasesize =
-                                   nand_flash_ids[i].erasesize;
-                               doc->chips_name =
-                                   nand_flash_ids[i].name;
-                               return 1;
-                       }
-                       return 0;
-               }
-       }
-
-
-#ifdef DOC_DEBUG
-       /* We haven't fully identified the chip. Print as much as we know. */
-       printf("Unknown flash chip found: %2.2X %2.2X\n",
-              id, mfr);
-#endif
-
-       return 0;
-}
-
-/* DoC_ScanChips: Find all NAND chips present in a DiskOnChip, and identify them */
-
-static void DoC_ScanChips(struct DiskOnChip *this)
-{
-       int floor, chip;
-       int numchips[MAX_FLOORS];
-       int maxchips = MAX_CHIPS;
-       int ret = 1;
-
-       this->numchips = 0;
-       this->mfr = 0;
-       this->id = 0;
-
-       if (DoC_is_Millennium(this))
-               maxchips = MAX_CHIPS_MIL;
-
-       /* For each floor, find the number of valid chips it contains */
-       for (floor = 0; floor < MAX_FLOORS; floor++) {
-               ret = 1;
-               numchips[floor] = 0;
-               for (chip = 0; chip < maxchips && ret != 0; chip++) {
-
-                       ret = DoC_IdentChip(this, floor, chip);
-                       if (ret) {
-                               numchips[floor]++;
-                               this->numchips++;
-                       }
-               }
-       }
-
-       /* If there are none at all that we recognise, bail */
-       if (!this->numchips) {
-               puts ("No flash chips recognised.\n");
-               return;
-       }
-
-       /* Allocate an array to hold the information for each chip */
-       this->chips = malloc(sizeof(struct Nand) * this->numchips);
-       if (!this->chips) {
-               puts ("No memory for allocating chip info structures\n");
-               return;
-       }
-
-       ret = 0;
-
-       /* Fill out the chip array with {floor, chipno} for each
-        * detected chip in the device. */
-       for (floor = 0; floor < MAX_FLOORS; floor++) {
-               for (chip = 0; chip < numchips[floor]; chip++) {
-                       this->chips[ret].floor = floor;
-                       this->chips[ret].chip = chip;
-                       this->chips[ret].curadr = 0;
-                       this->chips[ret].curmode = 0x50;
-                       ret++;
-               }
-       }
-
-       /* Calculate and print the total size of the device */
-       this->totlen = this->numchips * (1 << this->chipshift);
-
-#ifdef DOC_DEBUG
-       printf("%d flash chips found. Total DiskOnChip size: %ld MB\n",
-              this->numchips, this->totlen >> 20);
-#endif
-}
-
-/* find_boot_record: Find the NFTL Media Header and its Spare copy which contains the
- *     various device information of the NFTL partition and Bad Unit Table. Update
- *     the ReplUnitTable[] table accroding to the Bad Unit Table. ReplUnitTable[]
- *     is used for management of Erase Unit in other routines in nftl.c and nftlmount.c
- */
-static int find_boot_record(struct NFTLrecord *nftl)
-{
-       struct nftl_uci1 h1;
-       struct nftl_oob oob;
-       unsigned int block, boot_record_count = 0;
-       int retlen;
-       u8 buf[SECTORSIZE];
-       struct NFTLMediaHeader *mh = &nftl->MediaHdr;
-       unsigned int i;
-
-       nftl->MediaUnit = BLOCK_NIL;
-       nftl->SpareMediaUnit = BLOCK_NIL;
-
-       /* search for a valid boot record */
-       for (block = 0; block < nftl->nb_blocks; block++) {
-               int ret;
-
-               /* Check for ANAND header first. Then can whinge if it's found but later
-                  checks fail */
-               if ((ret = doc_read_ecc(nftl->mtd, block * nftl->EraseSize, SECTORSIZE,
-                                       (size_t *)&retlen, buf, NULL))) {
-                       static int warncount = 5;
-
-                       if (warncount) {
-                               printf("Block read at 0x%x failed\n", block * nftl->EraseSize);
-                               if (!--warncount)
-                                       puts ("Further failures for this block will not be printed\n");
-                       }
-                       continue;
-               }
-
-               if (retlen < 6 || memcmp(buf, "ANAND", 6)) {
-                       /* ANAND\0 not found. Continue */
-#ifdef PSYCHO_DEBUG
-                       printf("ANAND header not found at 0x%x\n", block * nftl->EraseSize);
-#endif
-                       continue;
-               }
-
-#ifdef NFTL_DEBUG
-               printf("ANAND header found at 0x%x\n", block * nftl->EraseSize);
-#endif
-
-               /* To be safer with BIOS, also use erase mark as discriminant */
-               if ((ret = doc_read_oob(nftl->mtd, block * nftl->EraseSize + SECTORSIZE + 8,
-                               8, (size_t *)&retlen, (uchar *)&h1) < 0)) {
-#ifdef NFTL_DEBUG
-                       printf("ANAND header found at 0x%x, but OOB data read failed\n",
-                              block * nftl->EraseSize);
-#endif
-                       continue;
-               }
-
-               /* OK, we like it. */
-
-               if (boot_record_count) {
-                       /* We've already processed one. So we just check if
-                          this one is the same as the first one we found */
-                       if (memcmp(mh, buf, sizeof(struct NFTLMediaHeader))) {
-#ifdef NFTL_DEBUG
-                               printf("NFTL Media Headers at 0x%x and 0x%x disagree.\n",
-                                      nftl->MediaUnit * nftl->EraseSize, block * nftl->EraseSize);
-#endif
-                               /* if (debug) Print both side by side */
-                               return -1;
-                       }
-                       if (boot_record_count == 1)
-                               nftl->SpareMediaUnit = block;
-
-                       boot_record_count++;
-                       continue;
-               }
-
-               /* This is the first we've seen. Copy the media header structure into place */
-               memcpy(mh, buf, sizeof(struct NFTLMediaHeader));
-
-               /* Do some sanity checks on it */
-               if (mh->UnitSizeFactor == 0) {
-#ifdef NFTL_DEBUG
-                       puts ("UnitSizeFactor 0x00 detected.\n"
-                             "This violates the spec but we think we know what it means...\n");
-#endif
-               } else if (mh->UnitSizeFactor != 0xff) {
-                       printf ("Sorry, we don't support UnitSizeFactor "
-                             "of != 1 yet.\n");
-                       return -1;
-               }
-
-               nftl->nb_boot_blocks = le16_to_cpu(mh->FirstPhysicalEUN);
-               if ((nftl->nb_boot_blocks + 2) >= nftl->nb_blocks) {
-                       printf ("NFTL Media Header sanity check failed:\n"
-                               "nb_boot_blocks (%d) + 2 > nb_blocks (%d)\n",
-                               nftl->nb_boot_blocks, nftl->nb_blocks);
-                       return -1;
-               }
-
-               nftl->numvunits = le32_to_cpu(mh->FormattedSize) / nftl->EraseSize;
-               if (nftl->numvunits > (nftl->nb_blocks - nftl->nb_boot_blocks - 2)) {
-                       printf ("NFTL Media Header sanity check failed:\n"
-                               "numvunits (%d) > nb_blocks (%d) - nb_boot_blocks(%d) - 2\n",
-                               nftl->numvunits,
-                               nftl->nb_blocks,
-                               nftl->nb_boot_blocks);
-                       return -1;
-               }
-
-               nftl->nr_sects  = nftl->numvunits * (nftl->EraseSize / SECTORSIZE);
-
-               /* If we're not using the last sectors in the device for some reason,
-                  reduce nb_blocks accordingly so we forget they're there */
-               nftl->nb_blocks = le16_to_cpu(mh->NumEraseUnits) + le16_to_cpu(mh->FirstPhysicalEUN);
-
-               /* read the Bad Erase Unit Table and modify ReplUnitTable[] accordingly */
-               for (i = 0; i < nftl->nb_blocks; i++) {
-                       if ((i & (SECTORSIZE - 1)) == 0) {
-                               /* read one sector for every SECTORSIZE of blocks */
-                               if ((ret = doc_read_ecc(nftl->mtd, block * nftl->EraseSize +
-                                                      i + SECTORSIZE, SECTORSIZE,
-                                                      (size_t *)&retlen, buf, (uchar *)&oob)) < 0) {
-                                       puts ("Read of bad sector table failed\n");
-                                       return -1;
-                               }
-                       }
-                       /* mark the Bad Erase Unit as RESERVED in ReplUnitTable */
-                       if (buf[i & (SECTORSIZE - 1)] != 0xff)
-                               nftl->ReplUnitTable[i] = BLOCK_RESERVED;
-               }
-
-               nftl->MediaUnit = block;
-               boot_record_count++;
-
-       } /* foreach (block) */
-
-       return boot_record_count?0:-1;
-}
-
-/* This routine is made available to other mtd code via
- * inter_module_register.  It must only be accessed through
- * inter_module_get which will bump the use count of this module.  The
- * addresses passed back in mtd are valid as long as the use count of
- * this module is non-zero, i.e. between inter_module_get and
- * inter_module_put.  Keith Owens <kaos@ocs.com.au> 29 Oct 2000.
- */
-static void DoC2k_init(struct DiskOnChip* this)
-{
-       struct NFTLrecord *nftl;
-
-       switch (this->ChipID) {
-       case DOC_ChipID_Doc2k:
-               this->name = "DiskOnChip 2000";
-               this->ioreg = DoC_2k_CDSN_IO;
-               break;
-       case DOC_ChipID_DocMil:
-               this->name = "DiskOnChip Millennium";
-               this->ioreg = DoC_Mil_CDSN_IO;
-               break;
-       }
-
-#ifdef DOC_DEBUG
-       printf("%s found at address 0x%lX\n", this->name,
-              this->physadr);
-#endif
-
-       this->totlen = 0;
-       this->numchips = 0;
-
-       this->curfloor = -1;
-       this->curchip = -1;
-
-       /* Ident all the chips present. */
-       DoC_ScanChips(this);
-       if ((!this->numchips) || (!this->chips))
-               return;
-
-       nftl = &this->nftl;
-
-       /* Get physical parameters */
-       nftl->EraseSize = this->erasesize;
-       nftl->nb_blocks = this->totlen / this->erasesize;
-       nftl->mtd = this;
-
-       if (find_boot_record(nftl) != 0)
-               this->nftl_found = 0;
-       else
-               this->nftl_found = 1;
-
-       printf("%s @ 0x%lX, %ld MB\n", this->name, this->physadr, this->totlen >> 20);
-}
-
-int doc_read_ecc(struct DiskOnChip* this, loff_t from, size_t len,
-                size_t * retlen, u_char * buf, u_char * eccbuf)
-{
-       unsigned long docptr;
-       struct Nand *mychip;
-       unsigned char syndrome[6];
-       volatile char dummy;
-       int i, len256 = 0, ret=0;
-
-       docptr = this->virtadr;
-
-       /* Don't allow read past end of device */
-       if (from >= this->totlen) {
-               puts ("Out of flash\n");
-               return DOC_EINVAL;
-       }
-
-       /* Don't allow a single read to cross a 512-byte block boundary */
-       if (from + len > ((from | 0x1ff) + 1))
-               len = ((from | 0x1ff) + 1) - from;
-
-       /* The ECC will not be calculated correctly if less than 512 is read */
-       if (len != 0x200 && eccbuf)
-               printf("ECC needs a full sector read (adr: %lx size %lx)\n",
-                      (long) from, (long) len);
-
-#ifdef PSYCHO_DEBUG
-       printf("DoC_Read (adr: %lx size %lx)\n", (long) from, (long) len);
-#endif
-
-       /* Find the chip which is to be used and select it */
-       mychip = &this->chips[shr(from, this->chipshift)];
-
-       if (this->curfloor != mychip->floor) {
-               DoC_SelectFloor(this, mychip->floor);
-               DoC_SelectChip(this, mychip->chip);
-       } else if (this->curchip != mychip->chip) {
-               DoC_SelectChip(this, mychip->chip);
-       }
-
-       this->curfloor = mychip->floor;
-       this->curchip = mychip->chip;
-
-       DoC_Command(this,
-                   (!this->page256
-                    && (from & 0x100)) ? NAND_CMD_READ1 : NAND_CMD_READ0,
-                   CDSN_CTRL_WP);
-       DoC_Address(this, ADDR_COLUMN_PAGE, from, CDSN_CTRL_WP,
-                   CDSN_CTRL_ECC_IO);
-
-       if (eccbuf) {
-               /* Prime the ECC engine */
-               WriteDOC(DOC_ECC_RESET, docptr, ECCConf);
-               WriteDOC(DOC_ECC_EN, docptr, ECCConf);
-       } else {
-               /* disable the ECC engine */
-               WriteDOC(DOC_ECC_RESET, docptr, ECCConf);
-               WriteDOC(DOC_ECC_DIS, docptr, ECCConf);
-       }
-
-       /* treat crossing 256-byte sector for 2M x 8bits devices */
-       if (this->page256 && from + len > (from | 0xff) + 1) {
-               len256 = (from | 0xff) + 1 - from;
-               DoC_ReadBuf(this, buf, len256);
-
-               DoC_Command(this, NAND_CMD_READ0, CDSN_CTRL_WP);
-               DoC_Address(this, ADDR_COLUMN_PAGE, from + len256,
-                           CDSN_CTRL_WP, CDSN_CTRL_ECC_IO);
-       }
-
-       DoC_ReadBuf(this, &buf[len256], len - len256);
-
-       /* Let the caller know we completed it */
-       *retlen = len;
-
-       if (eccbuf) {
-               /* Read the ECC data through the DiskOnChip ECC logic */
-               /* Note: this will work even with 2M x 8bit devices as   */
-               /*       they have 8 bytes of OOB per 256 page. mf.      */
-               DoC_ReadBuf(this, eccbuf, 6);
-
-               /* Flush the pipeline */
-               if (DoC_is_Millennium(this)) {
-                       dummy = ReadDOC(docptr, ECCConf);
-                       dummy = ReadDOC(docptr, ECCConf);
-                       i = ReadDOC(docptr, ECCConf);
-               } else {
-                       dummy = ReadDOC(docptr, 2k_ECCStatus);
-                       dummy = ReadDOC(docptr, 2k_ECCStatus);
-                       i = ReadDOC(docptr, 2k_ECCStatus);
-               }
-
-               /* Check the ECC Status */
-               if (i & 0x80) {
-                       int nb_errors;
-                       /* There was an ECC error */
-#ifdef ECC_DEBUG
-                       printf("DiskOnChip ECC Error: Read at %lx\n", (long)from);
-#endif
-                       /* Read the ECC syndrom through the DiskOnChip ECC logic.
-                          These syndrome will be all ZERO when there is no error */
-                       for (i = 0; i < 6; i++) {
-                               syndrome[i] =
-                                   ReadDOC(docptr, ECCSyndrome0 + i);
-                       }
-                       nb_errors = doc_decode_ecc(buf, syndrome);
-
-#ifdef ECC_DEBUG
-                       printf("Errors corrected: %x\n", nb_errors);
-#endif
-                       if (nb_errors < 0) {
-                               /* We return error, but have actually done the read. Not that
-                                  this can be told to user-space, via sys_read(), but at least
-                                  MTD-aware stuff can know about it by checking *retlen */
-                               printf("ECC Errors at %lx\n", (long)from);
-                               ret = DOC_EECC;
-                       }
-               }
-
-#ifdef PSYCHO_DEBUG
-               printf("ECC DATA at %lxB: %2.2X %2.2X %2.2X %2.2X %2.2X %2.2X\n",
-                            (long)from, eccbuf[0], eccbuf[1], eccbuf[2],
-                            eccbuf[3], eccbuf[4], eccbuf[5]);
-#endif
-
-               /* disable the ECC engine */
-               WriteDOC(DOC_ECC_DIS, docptr , ECCConf);
-       }
-
-       /* according to 11.4.1, we need to wait for the busy line
-        * drop if we read to the end of the page.  */
-       if(0 == ((from + *retlen) & 0x1ff))
-       {
-           DoC_WaitReady(this);
-       }
-
-       return ret;
-}
-
-int doc_write_ecc(struct DiskOnChip* this, loff_t to, size_t len,
-                 size_t * retlen, const u_char * buf,
-                 u_char * eccbuf)
-{
-       int di; /* Yes, DI is a hangover from when I was disassembling the binary driver */
-       unsigned long docptr;
-       volatile char dummy;
-       int len256 = 0;
-       struct Nand *mychip;
-
-       docptr = this->virtadr;
-
-       /* Don't allow write past end of device */
-       if (to >= this->totlen) {
-               puts ("Out of flash\n");
-               return DOC_EINVAL;
-       }
-
-       /* Don't allow a single write to cross a 512-byte block boundary */
-       if (to + len > ((to | 0x1ff) + 1))
-               len = ((to | 0x1ff) + 1) - to;
-
-       /* The ECC will not be calculated correctly if less than 512 is written */
-       if (len != 0x200 && eccbuf)
-               printf("ECC needs a full sector write (adr: %lx size %lx)\n",
-                      (long) to, (long) len);
-
-       /* printf("DoC_Write (adr: %lx size %lx)\n", (long) to, (long) len); */
-
-       /* Find the chip which is to be used and select it */
-       mychip = &this->chips[shr(to, this->chipshift)];
-
-       if (this->curfloor != mychip->floor) {
-               DoC_SelectFloor(this, mychip->floor);
-               DoC_SelectChip(this, mychip->chip);
-       } else if (this->curchip != mychip->chip) {
-               DoC_SelectChip(this, mychip->chip);
-       }
-
-       this->curfloor = mychip->floor;
-       this->curchip = mychip->chip;
-
-       /* Set device to main plane of flash */
-       DoC_Command(this, NAND_CMD_RESET, CDSN_CTRL_WP);
-       DoC_Command(this,
-                   (!this->page256
-                    && (to & 0x100)) ? NAND_CMD_READ1 : NAND_CMD_READ0,
-                   CDSN_CTRL_WP);
-
-       DoC_Command(this, NAND_CMD_SEQIN, 0);
-       DoC_Address(this, ADDR_COLUMN_PAGE, to, 0, CDSN_CTRL_ECC_IO);
-
-       if (eccbuf) {
-               /* Prime the ECC engine */
-               WriteDOC(DOC_ECC_RESET, docptr, ECCConf);
-               WriteDOC(DOC_ECC_EN | DOC_ECC_RW, docptr, ECCConf);
-       } else {
-               /* disable the ECC engine */
-               WriteDOC(DOC_ECC_RESET, docptr, ECCConf);
-               WriteDOC(DOC_ECC_DIS, docptr, ECCConf);
-       }
-
-       /* treat crossing 256-byte sector for 2M x 8bits devices */
-       if (this->page256 && to + len > (to | 0xff) + 1) {
-               len256 = (to | 0xff) + 1 - to;
-               DoC_WriteBuf(this, buf, len256);
-
-               DoC_Command(this, NAND_CMD_PAGEPROG, 0);
-
-               DoC_Command(this, NAND_CMD_STATUS, CDSN_CTRL_WP);
-               /* There's an implicit DoC_WaitReady() in DoC_Command */
-
-               dummy = ReadDOC(docptr, CDSNSlowIO);
-               DoC_Delay(this, 2);
-
-               if (ReadDOC_(docptr, this->ioreg) & 1) {
-                       puts ("Error programming flash\n");
-                       /* Error in programming */
-                       *retlen = 0;
-                       return DOC_EIO;
-               }
-
-               DoC_Command(this, NAND_CMD_SEQIN, 0);
-               DoC_Address(this, ADDR_COLUMN_PAGE, to + len256, 0,
-                           CDSN_CTRL_ECC_IO);
-       }
-
-       DoC_WriteBuf(this, &buf[len256], len - len256);
-
-       if (eccbuf) {
-               WriteDOC(CDSN_CTRL_ECC_IO | CDSN_CTRL_CE, docptr,
-                        CDSNControl);
-
-               if (DoC_is_Millennium(this)) {
-                       WriteDOC(0, docptr, NOP);
-                       WriteDOC(0, docptr, NOP);
-                       WriteDOC(0, docptr, NOP);
-               } else {
-                       WriteDOC_(0, docptr, this->ioreg);
-                       WriteDOC_(0, docptr, this->ioreg);
-                       WriteDOC_(0, docptr, this->ioreg);
-               }
-
-               /* Read the ECC data through the DiskOnChip ECC logic */
-               for (di = 0; di < 6; di++) {
-                       eccbuf[di] = ReadDOC(docptr, ECCSyndrome0 + di);
-               }
-
-               /* Reset the ECC engine */
-               WriteDOC(DOC_ECC_DIS, docptr, ECCConf);
-
-#ifdef PSYCHO_DEBUG
-               printf
-                   ("OOB data at %lx is %2.2X %2.2X %2.2X %2.2X %2.2X %2.2X\n",
-                    (long) to, eccbuf[0], eccbuf[1], eccbuf[2], eccbuf[3],
-                    eccbuf[4], eccbuf[5]);
-#endif
-       }
-
-       DoC_Command(this, NAND_CMD_PAGEPROG, 0);
-
-       DoC_Command(this, NAND_CMD_STATUS, CDSN_CTRL_WP);
-       /* There's an implicit DoC_WaitReady() in DoC_Command */
-
-       dummy = ReadDOC(docptr, CDSNSlowIO);
-       DoC_Delay(this, 2);
-
-       if (ReadDOC_(docptr, this->ioreg) & 1) {
-               puts ("Error programming flash\n");
-               /* Error in programming */
-               *retlen = 0;
-               return DOC_EIO;
-       }
-
-       /* Let the caller know we completed it */
-       *retlen = len;
-
-       if (eccbuf) {
-               unsigned char x[8];
-               size_t dummy;
-               int ret;
-
-               /* Write the ECC data to flash */
-               for (di=0; di<6; di++)
-                       x[di] = eccbuf[di];
-
-               x[6]=0x55;
-               x[7]=0x55;
-
-               ret = doc_write_oob(this, to, 8, &dummy, x);
-               return ret;
-       }
-       return 0;
-}
-
-int doc_read_oob(struct DiskOnChip* this, loff_t ofs, size_t len,
-                size_t * retlen, u_char * buf)
-{
-       int len256 = 0, ret;
-       unsigned long docptr;
-       struct Nand *mychip;
-
-       docptr = this->virtadr;
-
-       mychip = &this->chips[shr(ofs, this->chipshift)];
-
-       if (this->curfloor != mychip->floor) {
-               DoC_SelectFloor(this, mychip->floor);
-               DoC_SelectChip(this, mychip->chip);
-       } else if (this->curchip != mychip->chip) {
-               DoC_SelectChip(this, mychip->chip);
-       }
-       this->curfloor = mychip->floor;
-       this->curchip = mychip->chip;
-
-       /* update address for 2M x 8bit devices. OOB starts on the second */
-       /* page to maintain compatibility with doc_read_ecc. */
-       if (this->page256) {
-               if (!(ofs & 0x8))
-                       ofs += 0x100;
-               else
-                       ofs -= 0x8;
-       }
-
-       DoC_Command(this, NAND_CMD_READOOB, CDSN_CTRL_WP);
-       DoC_Address(this, ADDR_COLUMN_PAGE, ofs, CDSN_CTRL_WP, 0);
-
-       /* treat crossing 8-byte OOB data for 2M x 8bit devices */
-       /* Note: datasheet says it should automaticaly wrap to the */
-       /*       next OOB block, but it didn't work here. mf.      */
-       if (this->page256 && ofs + len > (ofs | 0x7) + 1) {
-               len256 = (ofs | 0x7) + 1 - ofs;
-               DoC_ReadBuf(this, buf, len256);
-
-               DoC_Command(this, NAND_CMD_READOOB, CDSN_CTRL_WP);
-               DoC_Address(this, ADDR_COLUMN_PAGE, ofs & (~0x1ff),
-                           CDSN_CTRL_WP, 0);
-       }
-
-       DoC_ReadBuf(this, &buf[len256], len - len256);
-
-       *retlen = len;
-       /* Reading the full OOB data drops us off of the end of the page,
-        * causing the flash device to go into busy mode, so we need
-        * to wait until ready 11.4.1 and Toshiba TC58256FT docs */
-
-       ret = DoC_WaitReady(this);
-
-       return ret;
-
-}
-
-int doc_write_oob(struct DiskOnChip* this, loff_t ofs, size_t len,
-                 size_t * retlen, const u_char * buf)
-{
-       int len256 = 0;
-       unsigned long docptr = this->virtadr;
-       struct Nand *mychip = &this->chips[shr(ofs, this->chipshift)];
-       volatile int dummy;
-
-#ifdef PSYCHO_DEBUG
-       printf("doc_write_oob(%lx, %d): %2.2X %2.2X %2.2X %2.2X ... %2.2X %2.2X .. %2.2X %2.2X\n",
-              (long)ofs, len, buf[0], buf[1], buf[2], buf[3],
-              buf[8], buf[9], buf[14],buf[15]);
-#endif
-
-       /* Find the chip which is to be used and select it */
-       if (this->curfloor != mychip->floor) {
-               DoC_SelectFloor(this, mychip->floor);
-               DoC_SelectChip(this, mychip->chip);
-       } else if (this->curchip != mychip->chip) {
-               DoC_SelectChip(this, mychip->chip);
-       }
-       this->curfloor = mychip->floor;
-       this->curchip = mychip->chip;
-
-       /* disable the ECC engine */
-       WriteDOC (DOC_ECC_RESET, docptr, ECCConf);
-       WriteDOC (DOC_ECC_DIS, docptr, ECCConf);
-
-       /* Reset the chip, see Software Requirement 11.4 item 1. */
-       DoC_Command(this, NAND_CMD_RESET, CDSN_CTRL_WP);
-
-       /* issue the Read2 command to set the pointer to the Spare Data Area. */
-       DoC_Command(this, NAND_CMD_READOOB, CDSN_CTRL_WP);
-
-       /* update address for 2M x 8bit devices. OOB starts on the second */
-       /* page to maintain compatibility with doc_read_ecc. */
-       if (this->page256) {
-               if (!(ofs & 0x8))
-                       ofs += 0x100;
-               else
-                       ofs -= 0x8;
-       }
-
-       /* issue the Serial Data In command to initial the Page Program process */
-       DoC_Command(this, NAND_CMD_SEQIN, 0);
-       DoC_Address(this, ADDR_COLUMN_PAGE, ofs, 0, 0);
-
-       /* treat crossing 8-byte OOB data for 2M x 8bit devices */
-       /* Note: datasheet says it should automaticaly wrap to the */
-       /*       next OOB block, but it didn't work here. mf.      */
-       if (this->page256 && ofs + len > (ofs | 0x7) + 1) {
-               len256 = (ofs | 0x7) + 1 - ofs;
-               DoC_WriteBuf(this, buf, len256);
-
-               DoC_Command(this, NAND_CMD_PAGEPROG, 0);
-               DoC_Command(this, NAND_CMD_STATUS, 0);
-               /* DoC_WaitReady() is implicit in DoC_Command */
-
-               dummy = ReadDOC(docptr, CDSNSlowIO);
-               DoC_Delay(this, 2);
-
-               if (ReadDOC_(docptr, this->ioreg) & 1) {
-                       puts ("Error programming oob data\n");
-                       /* There was an error */
-                       *retlen = 0;
-                       return DOC_EIO;
-               }
-               DoC_Command(this, NAND_CMD_SEQIN, 0);
-               DoC_Address(this, ADDR_COLUMN_PAGE, ofs & (~0x1ff), 0, 0);
-       }
-
-       DoC_WriteBuf(this, &buf[len256], len - len256);
-
-       DoC_Command(this, NAND_CMD_PAGEPROG, 0);
-       DoC_Command(this, NAND_CMD_STATUS, 0);
-       /* DoC_WaitReady() is implicit in DoC_Command */
-
-       dummy = ReadDOC(docptr, CDSNSlowIO);
-       DoC_Delay(this, 2);
-
-       if (ReadDOC_(docptr, this->ioreg) & 1) {
-               puts ("Error programming oob data\n");
-               /* There was an error */
-               *retlen = 0;
-               return DOC_EIO;
-       }
-
-       *retlen = len;
-       return 0;
-
-}
-
-int doc_erase(struct DiskOnChip* this, loff_t ofs, size_t len)
-{
-       volatile int dummy;
-       unsigned long docptr;
-       struct Nand *mychip;
-
-       if (ofs & (this->erasesize-1) || len & (this->erasesize-1)) {
-               puts ("Offset and size must be sector aligned\n");
-               return DOC_EINVAL;
-       }
-
-       docptr = this->virtadr;
-
-       /* FIXME: Do this in the background. Use timers or schedule_task() */
-       while(len) {
-               mychip = &this->chips[shr(ofs, this->chipshift)];
-
-               if (this->curfloor != mychip->floor) {
-                       DoC_SelectFloor(this, mychip->floor);
-                       DoC_SelectChip(this, mychip->chip);
-               } else if (this->curchip != mychip->chip) {
-                       DoC_SelectChip(this, mychip->chip);
-               }
-               this->curfloor = mychip->floor;
-               this->curchip = mychip->chip;
-
-               DoC_Command(this, NAND_CMD_ERASE1, 0);
-               DoC_Address(this, ADDR_PAGE, ofs, 0, 0);
-               DoC_Command(this, NAND_CMD_ERASE2, 0);
-
-               DoC_Command(this, NAND_CMD_STATUS, CDSN_CTRL_WP);
-
-               dummy = ReadDOC(docptr, CDSNSlowIO);
-               DoC_Delay(this, 2);
-
-               if (ReadDOC_(docptr, this->ioreg) & 1) {
-                       printf("Error erasing at 0x%lx\n", (long)ofs);
-                       /* There was an error */
-                       goto callback;
-               }
-               ofs += this->erasesize;
-               len -= this->erasesize;
-       }
-
- callback:
-       return 0;
-}
-
-static inline int doccheck(unsigned long potential, unsigned long physadr)
-{
-       unsigned long window=potential;
-       unsigned char tmp, ChipID;
-#ifndef DOC_PASSIVE_PROBE
-       unsigned char tmp2;
-#endif
-
-       /* Routine copied from the Linux DOC driver */
-
-#ifdef CONFIG_SYS_DOCPROBE_55AA
-       /* Check for 0x55 0xAA signature at beginning of window,
-          this is no longer true once we remove the IPL (for Millennium */
-       if (ReadDOC(window, Sig1) != 0x55 || ReadDOC(window, Sig2) != 0xaa)
-               return 0;
-#endif /* CONFIG_SYS_DOCPROBE_55AA */
-
-#ifndef DOC_PASSIVE_PROBE
-       /* It's not possible to cleanly detect the DiskOnChip - the
-        * bootup procedure will put the device into reset mode, and
-        * it's not possible to talk to it without actually writing
-        * to the DOCControl register. So we store the current contents
-        * of the DOCControl register's location, in case we later decide
-        * that it's not a DiskOnChip, and want to put it back how we
-        * found it.
-        */
-       tmp2 = ReadDOC(window, DOCControl);
-
-       /* Reset the DiskOnChip ASIC */
-       WriteDOC(DOC_MODE_CLR_ERR | DOC_MODE_MDWREN | DOC_MODE_RESET,
-                window, DOCControl);
-       WriteDOC(DOC_MODE_CLR_ERR | DOC_MODE_MDWREN | DOC_MODE_RESET,
-                window, DOCControl);
-
-       /* Enable the DiskOnChip ASIC */
-       WriteDOC(DOC_MODE_CLR_ERR | DOC_MODE_MDWREN | DOC_MODE_NORMAL,
-                window, DOCControl);
-       WriteDOC(DOC_MODE_CLR_ERR | DOC_MODE_MDWREN | DOC_MODE_NORMAL,
-                window, DOCControl);
-#endif /* !DOC_PASSIVE_PROBE */
-
-       ChipID = ReadDOC(window, ChipID);
-
-       switch (ChipID) {
-       case DOC_ChipID_Doc2k:
-               /* Check the TOGGLE bit in the ECC register */
-               tmp = ReadDOC(window, 2k_ECCStatus) & DOC_TOGGLE_BIT;
-               if ((ReadDOC(window, 2k_ECCStatus) & DOC_TOGGLE_BIT) != tmp)
-                               return ChipID;
-               break;
-
-       case DOC_ChipID_DocMil:
-               /* Check the TOGGLE bit in the ECC register */
-               tmp = ReadDOC(window, ECCConf) & DOC_TOGGLE_BIT;
-               if ((ReadDOC(window, ECCConf) & DOC_TOGGLE_BIT) != tmp)
-                               return ChipID;
-               break;
-
-       default:
-#ifndef CONFIG_SYS_DOCPROBE_55AA
-/*
- * if the ID isn't the DoC2000 or DoCMillenium ID, so we can assume
- * the DOC is missing
- */
-# if 0
-               printf("Possible DiskOnChip with unknown ChipID %2.2X found at 0x%lx\n",
-                      ChipID, physadr);
-# endif
-#endif
-#ifndef DOC_PASSIVE_PROBE
-               /* Put back the contents of the DOCControl register, in case it's not
-                * actually a DiskOnChip.
-                */
-               WriteDOC(tmp2, window, DOCControl);
-#endif
-               return 0;
-       }
-
-       puts ("DiskOnChip failed TOGGLE test, dropping.\n");
-
-#ifndef DOC_PASSIVE_PROBE
-       /* Put back the contents of the DOCControl register: it's not a DiskOnChip */
-       WriteDOC(tmp2, window, DOCControl);
-#endif
-       return 0;
-}
-
-void doc_probe(unsigned long physadr)
-{
-       struct DiskOnChip *this = NULL;
-       int i=0, ChipID;
-
-       if ((ChipID = doccheck(physadr, physadr))) {
-
-               for (i=0; i<CONFIG_SYS_MAX_DOC_DEVICE; i++) {
-                       if (doc_dev_desc[i].ChipID == DOC_ChipID_UNKNOWN) {
-                               this = doc_dev_desc + i;
-                               break;
-                       }
-               }
-
-               if (!this) {
-                       puts ("Cannot allocate memory for data structures.\n");
-                       return;
-               }
-
-               if (curr_device == -1)
-                       curr_device = i;
-
-               memset((char *)this, 0, sizeof(struct DiskOnChip));
-
-               this->virtadr = physadr;
-               this->physadr = physadr;
-               this->ChipID = ChipID;
-
-               DoC2k_init(this);
-       } else {
-               puts ("No DiskOnChip found\n");
-       }
-}
-#else
-void doc_probe(unsigned long physadr) {}
-#endif
index 9f27ab0..3773412 100644 (file)
@@ -468,17 +468,19 @@ int do_protect (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
        ulong bank;
        int i, n, sect_first, sect_last;
 #endif /* CONFIG_SYS_NO_FLASH */
+#if !defined(CONFIG_SYS_NO_FLASH) || defined(CONFIG_HAS_DATAFLASH)
        ulong addr_first, addr_last;
-       int p;
+#endif
 #if defined(CONFIG_CMD_JFFS2) && defined(CONFIG_CMD_MTDPARTS)
        struct mtd_device *dev;
        struct part_info *part;
        u8 dev_type, dev_num, pnum;
 #endif
-       int rcode = 0;
 #ifdef CONFIG_HAS_DATAFLASH
        int status;
 #endif
+       int p;
+       int rcode = 0;
 
        if (argc < 3) {
                cmd_usage(cmdtp);
index 4db4a83..372ccb2 100644 (file)
 #include <cramfs/cramfs_fs.h>
 
 #if defined(CONFIG_CMD_NAND)
-#ifdef CONFIG_NAND_LEGACY
-#include <linux/mtd/nand_legacy.h>
-#else /* !CONFIG_NAND_LEGACY */
 #include <linux/mtd/nand.h>
 #include <nand.h>
-#endif /* !CONFIG_NAND_LEGACY */
 #endif
 
 #if defined(CONFIG_CMD_ONENAND)
@@ -187,12 +183,7 @@ static int mtd_device_validate(u8 type, u8 num, u32 *size)
        } else if (type == MTD_DEV_TYPE_NAND) {
 #if defined(CONFIG_JFFS2_NAND) && defined(CONFIG_CMD_NAND)
                if (num < CONFIG_SYS_MAX_NAND_DEVICE) {
-#ifndef CONFIG_NAND_LEGACY
                        *size = nand_info[num].size;
-#else
-                       extern struct nand_chip nand_dev_desc[CONFIG_SYS_MAX_NAND_DEVICE];
-                       *size = nand_dev_desc[num].totlen;
-#endif
                        return 0;
                }
 
@@ -267,17 +258,11 @@ static int mtd_id_parse(const char *id, const char **ret_id, u8 *dev_type, u8 *d
 static inline u32 get_part_sector_size_nand(struct mtdids *id)
 {
 #if defined(CONFIG_JFFS2_NAND) && defined(CONFIG_CMD_NAND)
-#if defined(CONFIG_NAND_LEGACY)
-       extern struct nand_chip nand_dev_desc[CONFIG_SYS_MAX_NAND_DEVICE];
-
-       return nand_dev_desc[id->num].erasesize;
-#else
        nand_info_t *nand;
 
        nand = &nand_info[id->num];
 
        return nand->erasesize;
-#endif
 #else
        BUG();
        return 0;
index 2d1446e..665995d 100644 (file)
 #include <linux/mtd/mtd.h>
 
 #if defined(CONFIG_CMD_NAND)
-#ifdef CONFIG_NAND_LEGACY
-#include <linux/mtd/nand_legacy.h>
-#else /* !CONFIG_NAND_LEGACY */
 #include <linux/mtd/nand.h>
 #include <nand.h>
-#endif /* !CONFIG_NAND_LEGACY */
 #endif
 
 #if defined(CONFIG_CMD_ONENAND)
@@ -462,9 +458,6 @@ static int part_del(struct mtd_device *dev, struct part_info *part)
                }
        }
 
-#ifdef CONFIG_NAND_LEGACY
-       jffs2_free_cache(part);
-#endif
        list_del(&part->link);
        free(part);
        dev->num_parts--;
@@ -491,9 +484,6 @@ static void part_delall(struct list_head *head)
        list_for_each_safe(entry, n, head) {
                part_tmp = list_entry(entry, struct part_info, link);
 
-#ifdef CONFIG_NAND_LEGACY
-               jffs2_free_cache(part_tmp);
-#endif
                list_del(entry);
                free(part_tmp);
        }
index 2f70521..158a55f 100644 (file)
@@ -11,7 +11,6 @@
 #include <common.h>
 
 
-#ifndef CONFIG_NAND_LEGACY
 /*
  *
  * New NAND support
@@ -688,414 +687,3 @@ U_BOOT_CMD(nboot, 4, 1, do_nandboot,
        "[partition] | [[[loadAddr] dev] offset]"
 );
 #endif
-
-#else /* CONFIG_NAND_LEGACY */
-/*
- *
- * Legacy NAND support - to be phased out
- *
- */
-#include <command.h>
-#include <malloc.h>
-#include <asm/io.h>
-#include <watchdog.h>
-
-#ifdef CONFIG_show_boot_progress
-# include <status_led.h>
-# define show_boot_progress(arg)       show_boot_progress(arg)
-#else
-# define show_boot_progress(arg)
-#endif
-
-#if defined(CONFIG_CMD_NAND)
-#include <linux/mtd/nand_legacy.h>
-#if 0
-#include <linux/mtd/nand_ids.h>
-#include <jffs2/jffs2.h>
-#endif
-
-#ifdef CONFIG_OMAP1510
-void archflashwp(void *archdata, int wp);
-#endif
-
-#define ROUND_DOWN(value,boundary)      ((value) & (~((boundary)-1)))
-
-#undef NAND_DEBUG
-#undef PSYCHO_DEBUG
-
-/* ****************** WARNING *********************
- * When ALLOW_ERASE_BAD_DEBUG is non-zero the erase command will
- * erase (or at least attempt to erase) blocks that are marked
- * bad. This can be very handy if you are _sure_ that the block
- * is OK, say because you marked a good block bad to test bad
- * block handling and you are done testing, or if you have
- * accidentally marked blocks bad.
- *
- * Erasing factory marked bad blocks is a _bad_ idea. If the
- * erase succeeds there is no reliable way to find them again,
- * and attempting to program or erase bad blocks can affect
- * the data in _other_ (good) blocks.
- */
-#define         ALLOW_ERASE_BAD_DEBUG 0
-
-#define CONFIG_MTD_NAND_ECC  /* enable ECC */
-#define CONFIG_MTD_NAND_ECC_JFFS2
-
-/* bits for nand_legacy_rw() `cmd'; or together as needed */
-#define NANDRW_READ         0x01
-#define NANDRW_WRITE        0x00
-#define NANDRW_JFFS2       0x02
-#define NANDRW_JFFS2_SKIP   0x04
-
-/*
- * Imports from nand_legacy.c
- */
-extern struct nand_chip nand_dev_desc[CONFIG_SYS_MAX_NAND_DEVICE];
-extern int curr_device;
-extern int nand_legacy_erase(struct nand_chip *nand, size_t ofs,
-                           size_t len, int clean);
-extern int nand_legacy_rw(struct nand_chip *nand, int cmd, size_t start,
-                        size_t len, size_t *retlen, u_char *buf);
-extern void nand_print(struct nand_chip *nand);
-extern void nand_print_bad(struct nand_chip *nand);
-extern int nand_read_oob(struct nand_chip *nand, size_t ofs,
-                              size_t len, size_t *retlen, u_char *buf);
-extern int nand_write_oob(struct nand_chip *nand, size_t ofs,
-                               size_t len, size_t *retlen, const u_char *buf);
-
-
-int do_nand (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
-{
-       int rcode = 0;
-
-       switch (argc) {
-       case 0:
-       case 1:
-               cmd_usage(cmdtp);
-               return 1;
-       case 2:
-               if (strcmp (argv[1], "info") == 0) {
-                       int i;
-
-                       putc ('\n');
-
-                       for (i = 0; i < CONFIG_SYS_MAX_NAND_DEVICE; ++i) {
-                               if (nand_dev_desc[i].ChipID ==
-                                   NAND_ChipID_UNKNOWN)
-                                       continue;       /* list only known devices */
-                               printf ("Device %d: ", i);
-                               nand_print (&nand_dev_desc[i]);
-                       }
-                       return 0;
-
-               } else if (strcmp (argv[1], "device") == 0) {
-                       if ((curr_device < 0)
-                           || (curr_device >= CONFIG_SYS_MAX_NAND_DEVICE)) {
-                               puts ("\nno devices available\n");
-                               return 1;
-                       }
-                       printf ("\nDevice %d: ", curr_device);
-                       nand_print (&nand_dev_desc[curr_device]);
-                       return 0;
-
-               } else if (strcmp (argv[1], "bad") == 0) {
-                       if ((curr_device < 0)
-                           || (curr_device >= CONFIG_SYS_MAX_NAND_DEVICE)) {
-                               puts ("\nno devices available\n");
-                               return 1;
-                       }
-                       printf ("\nDevice %d bad blocks:\n", curr_device);
-                       nand_print_bad (&nand_dev_desc[curr_device]);
-                       return 0;
-
-               }
-               cmd_usage(cmdtp);
-               return 1;
-       case 3:
-               if (strcmp (argv[1], "device") == 0) {
-                       int dev = (int) simple_strtoul (argv[2], NULL, 10);
-
-                       printf ("\nDevice %d: ", dev);
-                       if (dev >= CONFIG_SYS_MAX_NAND_DEVICE) {
-                               puts ("unknown device\n");
-                               return 1;
-                       }
-                       nand_print (&nand_dev_desc[dev]);
-                       /*nand_print (dev); */
-
-                       if (nand_dev_desc[dev].ChipID == NAND_ChipID_UNKNOWN) {
-                               return 1;
-                       }
-
-                       curr_device = dev;
-
-                       puts ("... is now current device\n");
-
-                       return 0;
-               } else if (strcmp (argv[1], "erase") == 0
-                          && strcmp (argv[2], "clean") == 0) {
-                       struct nand_chip *nand = &nand_dev_desc[curr_device];
-                       ulong off = 0;
-                       ulong size = nand->totlen;
-                       int ret;
-
-                       printf ("\nNAND erase: device %d offset %ld, size %ld ... ", curr_device, off, size);
-
-                       ret = nand_legacy_erase (nand, off, size, 1);
-
-                       printf ("%s\n", ret ? "ERROR" : "OK");
-
-                       return ret;
-               }
-
-               cmd_usage(cmdtp);
-               return 1;
-       default:
-               /* at least 4 args */
-
-               if (strncmp (argv[1], "read", 4) == 0 ||
-                   strncmp (argv[1], "write", 5) == 0) {
-                       ulong addr = simple_strtoul (argv[2], NULL, 16);
-                       off_t off = simple_strtoul (argv[3], NULL, 16);
-                       size_t size = simple_strtoul (argv[4], NULL, 16);
-                       int cmd = (strncmp (argv[1], "read", 4) == 0) ?
-                                 NANDRW_READ : NANDRW_WRITE;
-                       size_t total;
-                       int ret;
-                       char *cmdtail = strchr (argv[1], '.');
-
-                       if (cmdtail && !strncmp (cmdtail, ".oob", 2)) {
-                               /* read out-of-band data */
-                               if (cmd & NANDRW_READ) {
-                                       ret = nand_read_oob (nand_dev_desc + curr_device,
-                                                            off, size, &total,
-                                                            (u_char *) addr);
-                               } else {
-                                       ret = nand_write_oob (nand_dev_desc + curr_device,
-                                                             off, size, &total,
-                                                             (u_char *) addr);
-                               }
-                               return ret;
-                       } else if (cmdtail && !strncmp (cmdtail, ".jffs2s", 7)) {
-                               cmd |= NANDRW_JFFS2;    /* skip bad blocks (on read too) */
-                               if (cmd & NANDRW_READ)
-                                       cmd |= NANDRW_JFFS2_SKIP;       /* skip bad blocks (on read too) */
-                       } else if (cmdtail && !strncmp (cmdtail, ".jffs2", 2))
-                               cmd |= NANDRW_JFFS2;    /* skip bad blocks */
-#ifdef SXNI855T
-                       /* need ".e" same as ".j" for compatibility with older units */
-                       else if (cmdtail && !strcmp (cmdtail, ".e"))
-                               cmd |= NANDRW_JFFS2;    /* skip bad blocks */
-#endif
-#ifdef CONFIG_SYS_NAND_SKIP_BAD_DOT_I
-                       /* need ".i" same as ".jffs2s" for compatibility with older units (esd) */
-                       /* ".i" for image -> read skips bad block (no 0xff) */
-                       else if (cmdtail && !strcmp (cmdtail, ".i")) {
-                               cmd |= NANDRW_JFFS2;    /* skip bad blocks (on read too) */
-                               if (cmd & NANDRW_READ)
-                                       cmd |= NANDRW_JFFS2_SKIP;       /* skip bad blocks (on read too) */
-                       }
-#endif /* CONFIG_SYS_NAND_SKIP_BAD_DOT_I */
-                       else if (cmdtail) {
-                               cmd_usage(cmdtp);
-                               return 1;
-                       }
-
-                       printf ("\nNAND %s: device %d offset %ld, size %lu ...\n",
-                               (cmd & NANDRW_READ) ? "read" : "write",
-                               curr_device, off, (ulong)size);
-
-                       ret = nand_legacy_rw (nand_dev_desc + curr_device,
-                                             cmd, off, size,
-                                             &total, (u_char *) addr);
-
-                       printf (" %d bytes %s: %s\n", total,
-                               (cmd & NANDRW_READ) ? "read" : "written",
-                               ret ? "ERROR" : "OK");
-
-                       return ret;
-               } else if (strcmp (argv[1], "erase") == 0 &&
-                          (argc == 4 || strcmp ("clean", argv[2]) == 0)) {
-                       int clean = argc == 5;
-                       ulong off =
-                               simple_strtoul (argv[2 + clean], NULL, 16);
-                       ulong size =
-                               simple_strtoul (argv[3 + clean], NULL, 16);
-                       int ret;
-
-                       printf ("\nNAND erase: device %d offset %ld, size %ld ...\n",
-                               curr_device, off, size);
-
-                       ret = nand_legacy_erase (nand_dev_desc + curr_device,
-                                                off, size, clean);
-
-                       printf ("%s\n", ret ? "ERROR" : "OK");
-
-                       return ret;
-               } else {
-                       cmd_usage(cmdtp);
-                       rcode = 1;
-               }
-
-               return rcode;
-       }
-}
-
-U_BOOT_CMD(
-       nand,   5,      1,      do_nand,
-       "legacy NAND sub-system",
-       "info  - show available NAND devices\n"
-       "nand device [dev] - show or set current device\n"
-       "nand read[.jffs2[s]]  addr off size\n"
-       "nand write[.jffs2] addr off size - read/write `size' bytes starting\n"
-       "    at offset `off' to/from memory address `addr'\n"
-       "nand erase [clean] [off size] - erase `size' bytes from\n"
-       "    offset `off' (entire device if not specified)\n"
-       "nand bad - show bad blocks\n"
-       "nand read.oob addr off size - read out-of-band data\n"
-       "nand write.oob addr off size - read out-of-band data"
-);
-
-int do_nandboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
-{
-       char *boot_device = NULL;
-       char *ep;
-       int dev;
-       ulong cnt;
-       ulong addr;
-       ulong offset = 0;
-       image_header_t *hdr;
-       int rcode = 0;
-#if defined(CONFIG_FIT)
-       const void *fit_hdr = NULL;
-#endif
-
-       show_boot_progress (52);
-       switch (argc) {
-       case 1:
-               addr = CONFIG_SYS_LOAD_ADDR;
-               boot_device = getenv ("bootdevice");
-               break;
-       case 2:
-               addr = simple_strtoul(argv[1], NULL, 16);
-               boot_device = getenv ("bootdevice");
-               break;
-       case 3:
-               addr = simple_strtoul(argv[1], NULL, 16);
-               boot_device = argv[2];
-               break;
-       case 4:
-               addr = simple_strtoul(argv[1], NULL, 16);
-               boot_device = argv[2];
-               offset = simple_strtoul(argv[3], NULL, 16);
-               break;
-       default:
-               cmd_usage(cmdtp);
-               show_boot_progress (-53);
-               return 1;
-       }
-
-       show_boot_progress (53);
-       if (!boot_device) {
-               puts ("\n** No boot device **\n");
-               show_boot_progress (-54);
-               return 1;
-       }
-       show_boot_progress (54);
-
-       dev = simple_strtoul(boot_device, &ep, 16);
-
-       if ((dev >= CONFIG_SYS_MAX_NAND_DEVICE) ||
-           (nand_dev_desc[dev].ChipID == NAND_ChipID_UNKNOWN)) {
-               printf ("\n** Device %d not available\n", dev);
-               show_boot_progress (-55);
-               return 1;
-       }
-       show_boot_progress (55);
-
-       printf ("\nLoading from device %d: %s at 0x%lx (offset 0x%lx)\n",
-           dev, nand_dev_desc[dev].name, nand_dev_desc[dev].IO_ADDR,
-           offset);
-
-       if (nand_legacy_rw (nand_dev_desc + dev, NANDRW_READ, offset,
-                           SECTORSIZE, NULL, (u_char *)addr)) {
-               printf ("** Read error on %d\n", dev);
-               show_boot_progress (-56);
-               return 1;
-       }
-       show_boot_progress (56);
-
-       switch (genimg_get_format ((void *)addr)) {
-       case IMAGE_FORMAT_LEGACY:
-               hdr = (image_header_t *)addr;
-               image_print_contents (hdr);
-
-               cnt = image_get_image_size (hdr);
-               cnt -= SECTORSIZE;
-               break;
-#if defined(CONFIG_FIT)
-       case IMAGE_FORMAT_FIT:
-               fit_hdr = (const void *)addr;
-               puts ("Fit image detected...\n");
-
-               cnt = fit_get_size (fit_hdr);
-               break;
-#endif
-       default:
-               show_boot_progress (-57);
-               puts ("** Unknown image type\n");
-               return 1;
-       }
-       show_boot_progress (57);
-
-       if (nand_legacy_rw (nand_dev_desc + dev, NANDRW_READ,
-                           offset + SECTORSIZE, cnt, NULL,
-                           (u_char *)(addr+SECTORSIZE))) {
-               printf ("** Read error on %d\n", dev);
-               show_boot_progress (-58);
-               return 1;
-       }
-       show_boot_progress (58);
-
-#if defined(CONFIG_FIT)
-       /* This cannot be done earlier, we need complete FIT image in RAM first */
-       if (genimg_get_format ((void *)addr) == IMAGE_FORMAT_FIT) {
-               if (!fit_check_format (fit_hdr)) {
-                       show_boot_progress (-150);
-                       puts ("** Bad FIT image format\n");
-                       return 1;
-               }
-               show_boot_progress (151);
-               fit_print_contents (fit_hdr);
-       }
-#endif
-
-       /* Loading ok, update default load address */
-
-       load_addr = addr;
-
-       /* Check if we should attempt an auto-start */
-       if (((ep = getenv("autostart")) != NULL) && (strcmp(ep,"yes") == 0)) {
-               char *local_args[2];
-               extern int do_bootm (cmd_tbl_t *, int, int, char *[]);
-
-               local_args[0] = argv[0];
-               local_args[1] = NULL;
-
-               printf ("Automatic boot of image at addr 0x%08lx ...\n", addr);
-
-               do_bootm (cmdtp, 0, 1, local_args);
-               rcode = 1;
-       }
-       return rcode;
-}
-
-U_BOOT_CMD(
-       nboot,  4,      1,      do_nandboot,
-       "boot from NAND device",
-       "loadAddr dev"
-);
-
-#endif
-
-#endif /* CONFIG_NAND_LEGACY */
diff --git a/common/cmd_tsi148.c b/common/cmd_tsi148.c
new file mode 100644 (file)
index 0000000..222938c
--- /dev/null
@@ -0,0 +1,488 @@
+/*
+ * (C) Copyright 2009 Reinhard Arlt, reinhard.arlt@esd-electronics.com
+ *
+ * base on universe.h by
+ *
+ * (C) Copyright 2003 Stefan Roese, stefan.roese@esd-electronics.com
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.         See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#define DEBUG
+
+#include <common.h>
+#include <command.h>
+#include <malloc.h>
+#include <asm/io.h>
+#include <pci.h>
+
+#include <tsi148.h>
+
+#define PCI_VENDOR PCI_VENDOR_ID_TUNDRA
+#define PCI_DEVICE PCI_DEVICE_ID_TUNDRA_TSI148
+
+typedef struct _TSI148_DEV TSI148_DEV;
+
+struct _TSI148_DEV {
+       int            bus;
+       pci_dev_t      busdevfn;
+       TSI148        *uregs;
+       unsigned int   pci_bs;
+};
+
+static TSI148_DEV *dev;
+
+/*
+ * Most of the TSI148 register are BIGENDIAN
+ * This is the reason for the __raw_writel(htonl(x), x) usage!
+ */
+
+int tsi148_init(void)
+{
+       int j, result, lastError = 0;
+       pci_dev_t busdevfn;
+       unsigned int val;
+
+       busdevfn = pci_find_device(PCI_VENDOR, PCI_DEVICE, 0);
+       if (busdevfn == -1) {
+               puts("Tsi148: No Tundra Tsi148 found!\n");
+               return -1;
+       }
+
+       /* Lets turn Latency off */
+       pci_write_config_dword(busdevfn, 0x0c, 0);
+
+       dev = malloc(sizeof(*dev));
+       if (NULL == dev) {
+               puts("Tsi148: No memory!\n");
+               result = -1;
+               goto break_20;
+       }
+
+       memset(dev, 0, sizeof(*dev));
+       dev->busdevfn = busdevfn;
+
+       pci_read_config_dword(busdevfn, PCI_BASE_ADDRESS_0, &val);
+       val &= ~0xf;
+       dev->uregs = (TSI148 *)val;
+
+       debug("Tsi148: Base    : %p\n", dev->uregs);
+
+       /* check mapping  */
+       debug("Tsi148: Read via mapping, PCI_ID = %08X\n", readl(&dev->uregs->pci_id));
+       if (((PCI_DEVICE << 16) | PCI_VENDOR) !=  readl(&dev->uregs->pci_id)) {
+               printf("Tsi148: Cannot read PCI-ID via Mapping: %08x\n",
+                       readl(&dev->uregs->pci_id));
+               result = -1;
+               goto break_30;
+       }
+
+       debug("Tsi148: PCI_BS = %08X\n", readl(&dev->uregs->pci_mbarl));
+
+       dev->pci_bs = readl(&dev->uregs->pci_mbarl);
+
+       /* turn off windows */
+       for (j = 0; j < 8; j++) {
+               __raw_writel(htonl(0x00000000), &dev->uregs->outbound[j].otat);
+               __raw_writel(htonl(0x00000000), &dev->uregs->inbound[j].itat);
+       }
+
+       /* Tsi148 VME timeout etc */
+       __raw_writel(htonl(0x00000084), &dev->uregs->vctrl);
+
+       if ((__raw_readl(&dev->uregs->vstat) & 0x00000100) != 0)
+               debug("Tsi148: System Controller!\n");
+       else
+               debug("Tsi148: Not System Controller!\n");
+
+       /*
+        * Lets turn off interrupts
+        */
+       /* Disable interrupts in Tsi148 first */
+       __raw_writel(htonl(0x00000000), &dev->uregs->inten);
+       /* Disable interrupt out */
+       __raw_writel(htonl(0x00000000), &dev->uregs->inteo);
+       eieio();
+       /* Reset all IRQ's */
+       __raw_writel(htonl(0x03ff3f00), &dev->uregs->intc);
+       /* Map all ints to 0 */
+       __raw_writel(htonl(0x00000000), &dev->uregs->intm1);
+       __raw_writel(htonl(0x00000000), &dev->uregs->intm2);
+       eieio();
+
+       val  = __raw_readl(&dev->uregs->vstat);
+       val &= ~(0x00004000);
+       __raw_writel(val, &dev->uregs->vstat);
+       eieio();
+
+       debug("Tsi148: register struct size %08x\n", sizeof(TSI148));
+
+       return 0;
+
+ break_30:
+       free(dev);
+       dev = NULL;
+ break_20:
+       lastError = result;
+
+       return result;
+}
+
+/*
+ * Create pci slave window (access: pci -> vme)
+ */
+int tsi148_pci_slave_window(unsigned int pciAddr, unsigned int vmeAddr, int size, int vam, int vdw)
+{
+       int result, i;
+       unsigned int ctl = 0;
+
+       if (NULL == dev) {
+               result = -1;
+               goto exit_10;
+       }
+
+       for (i = 0; i < 8; i++) {
+               if (0x00000000 == readl(&dev->uregs->outbound[i].otat))
+                       break;
+       }
+
+       if (i > 7) {
+               printf("Tsi148: No Image available\n");
+               result = -1;
+               goto exit_10;
+       }
+
+       debug("Tsi148: Using image %d\n", i);
+
+       printf("Tsi148: Pci addr %08x\n", pciAddr);
+
+
+       __raw_writel(htonl(pciAddr) , &dev->uregs->outbound[i].otsal);
+       __raw_writel(0x00000000 , &dev->uregs->outbound[i].otsau);
+       __raw_writel(htonl(pciAddr + size), &dev->uregs->outbound[i].oteal);
+       __raw_writel(0x00000000 , &dev->uregs->outbound[i].oteau);
+       __raw_writel(htonl(vmeAddr - pciAddr), &dev->uregs->outbound[i].otofl);
+       __raw_writel(0x00000000 , &dev->uregs->outbound[i].otofu);
+
+       switch (vam & VME_AM_Axx) {
+       case VME_AM_A16:
+               ctl = 0x00000000;
+               break;
+       case VME_AM_A24:
+               ctl = 0x00000001;
+               break;
+       case VME_AM_A32:
+               ctl = 0x00000002;
+               break;
+       }
+
+       switch (vam & VME_AM_Mxx) {
+       case VME_AM_DATA:
+               ctl |= 0x00000000;
+               break;
+       case VME_AM_PROG:
+               ctl |= 0x00000010;
+               break;
+       }
+
+       if (vam & VME_AM_SUP)
+               ctl |= 0x00000020;
+
+       switch (vdw & VME_FLAG_Dxx) {
+       case VME_FLAG_D16:
+               ctl |= 0x00000000;
+               break;
+       case VME_FLAG_D32:
+               ctl |= 0x00000040;
+               break;
+       }
+
+       ctl |= 0x80040000;    /* enable, no prefetch */
+
+       __raw_writel(htonl(ctl), &dev->uregs->outbound[i].otat);
+
+       debug("Tsi148: window-addr                =%p\n",
+             &dev->uregs->outbound[i].otsau);
+       debug("Tsi148: pci slave window[%d] attr  =%08x\n",
+             i, ntohl(__raw_readl(&dev->uregs->outbound[i].otat)));
+       debug("Tsi148: pci slave window[%d] start =%08x\n",
+             i, ntohl(__raw_readl(&dev->uregs->outbound[i].otsal)));
+       debug("Tsi148: pci slave window[%d] end   =%08x\n",
+             i, ntohl(__raw_readl(&dev->uregs->outbound[i].oteal)));
+       debug("Tsi148: pci slave window[%d] offset=%08x\n",
+             i, ntohl(__raw_readl(&dev->uregs->outbound[i].otofl)));
+
+       return 0;
+
+ exit_10:
+       return -result;
+}
+
+unsigned int tsi148_eval_vam(int vam)
+{
+       unsigned int ctl = 0;
+
+       switch (vam & VME_AM_Axx) {
+       case VME_AM_A16:
+               ctl = 0x00000000;
+               break;
+       case VME_AM_A24:
+               ctl = 0x00000010;
+               break;
+       case VME_AM_A32:
+               ctl = 0x00000020;
+               break;
+       }
+       switch (vam & VME_AM_Mxx) {
+       case VME_AM_DATA:
+               ctl |= 0x00000001;
+               break;
+       case VME_AM_PROG:
+               ctl |= 0x00000002;
+               break;
+       case (VME_AM_PROG | VME_AM_DATA):
+               ctl |= 0x00000003;
+               break;
+       }
+
+       if (vam & VME_AM_SUP)
+               ctl |= 0x00000008;
+       if (vam & VME_AM_USR)
+               ctl |= 0x00000004;
+
+       return ctl;
+}
+
+/*
+ * Create vme slave window (access: vme -> pci)
+ */
+int tsi148_vme_slave_window(unsigned int vmeAddr, unsigned int pciAddr, int size, int vam)
+{
+       int result, i;
+       unsigned int ctl = 0;
+
+       if (NULL == dev) {
+               result = -1;
+               goto exit_10;
+       }
+
+       for (i = 0; i < 8; i++) {
+               if (0x00000000 == readl(&dev->uregs->inbound[i].itat))
+                       break;
+       }
+
+       if (i > 7) {
+               printf("Tsi148: No Image available\n");
+               result = -1;
+               goto exit_10;
+       }
+
+       debug("Tsi148: Using image %d\n", i);
+
+       __raw_writel(htonl(vmeAddr), &dev->uregs->inbound[i].itsal);
+       __raw_writel(0x00000000, &dev->uregs->inbound[i].itsau);
+       __raw_writel(htonl(vmeAddr + size), &dev->uregs->inbound[i].iteal);
+       __raw_writel(0x00000000, &dev->uregs->inbound[i].iteau);
+       __raw_writel(htonl(pciAddr - vmeAddr), &dev->uregs->inbound[i].itofl);
+       if (vmeAddr > pciAddr)
+               __raw_writel(0xffffffff, &dev->uregs->inbound[i].itofu);
+       else
+               __raw_writel(0x00000000, &dev->uregs->inbound[i].itofu);
+
+       ctl = tsi148_eval_vam(vam);
+       ctl |= 0x80000000;    /* enable */
+       __raw_writel(htonl(ctl), &dev->uregs->inbound[i].itat);
+
+       debug("Tsi148: window-addr                =%p\n",
+             &dev->uregs->inbound[i].itsau);
+       debug("Tsi148: vme slave window[%d] attr  =%08x\n",
+             i, ntohl(__raw_readl(&dev->uregs->inbound[i].itat))) ;
+       debug("Tsi148: vme slave window[%d] start =%08x\n",
+             i, ntohl(__raw_readl(&dev->uregs->inbound[i].itsal)));
+       debug("Tsi148: vme slave window[%d] end   =%08x\n",
+             i, ntohl(__raw_readl(&dev->uregs->inbound[i].iteal)));
+       debug("Tsi148: vme slave window[%d] offset=%08x\n",
+             i, ntohl(__raw_readl(&dev->uregs->inbound[i].itofl)));
+
+       return 0;
+
+ exit_10:
+       return -result;
+}
+
+/*
+ * Create vme slave window (access: vme -> gcsr)
+ */
+int tsi148_vme_gcsr_window(unsigned int vmeAddr, int vam)
+{
+       int result;
+       unsigned int ctl;
+
+       result = 0;
+
+       if (NULL == dev) {
+               result = 1;
+       } else {
+              __raw_writel(htonl(vmeAddr), &dev->uregs->gbal);
+              __raw_writel(0x00000000, &dev->uregs->gbau);
+
+              ctl = tsi148_eval_vam(vam);
+              ctl |= 0x00000080;    /* enable */
+              __raw_writel(htonl(ctl), &dev->uregs->gcsrat);
+       }
+
+       return result;
+}
+
+/*
+ * Create vme slave window (access: vme -> crcsr)
+ */
+int tsi148_vme_crcsr_window(unsigned int vmeAddr)
+{
+       int result;
+       unsigned int ctl;
+
+       result = 0;
+
+       if (NULL == dev) {
+               result = 1;
+       } else {
+              __raw_writel(htonl(vmeAddr), &dev->uregs->crol);
+              __raw_writel(0x00000000, &dev->uregs->crou);
+
+              ctl = 0x00000080;    /* enable */
+              __raw_writel(htonl(ctl), &dev->uregs->crat);
+       }
+
+       return result;
+}
+
+
+/*
+ * Create vme slave window (access: vme -> crg)
+ */
+int tsi148_vme_crg_window(unsigned int vmeAddr, int vam)
+{
+       int result;
+       unsigned int ctl;
+
+       result = 0;
+
+       if (NULL == dev) {
+               result = 1;
+       } else {
+              __raw_writel(htonl(vmeAddr), &dev->uregs->cbal);
+              __raw_writel(0x00000000, &dev->uregs->cbau);
+
+              ctl = tsi148_eval_vam(vam);
+              ctl |= 0x00000080;    /* enable */
+              __raw_writel(htonl(ctl), &dev->uregs->crgat);
+       }
+
+       return result;
+}
+
+/*
+ * Tundra Tsi148 configuration
+ */
+int do_tsi148(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+{
+       ulong addr1 = 0, addr2 = 0, size = 0, vam = 0, vdw = 0;
+       char cmd = 'x';
+
+       /* get parameter */
+       if (argc > 1)
+               cmd = argv[1][0];
+       if (argc > 2)
+               addr1 = simple_strtoul(argv[2], NULL, 16);
+       if (argc > 3)
+               addr2 = simple_strtoul(argv[3], NULL, 16);
+       if (argc > 4)
+               size = simple_strtoul(argv[4], NULL, 16);
+       if (argc > 5)
+               vam = simple_strtoul(argv[5], NULL, 16);
+       if (argc > 6)
+               vdw = simple_strtoul(argv[7], NULL, 16);
+
+       switch (cmd) {
+       case 'c':
+               if (strcmp(argv[1], "crg") == 0) {
+                       vam = addr2;
+                       printf("Tsi148: Configuring VME CRG Window (VME->CRG):\n");
+                       printf("  vme=%08lx vam=%02lx\n", addr1, vam);
+                       tsi148_vme_crg_window(addr1, vam);
+               } else {
+                       printf("Tsi148: Configuring VME CR/CSR Window (VME->CR/CSR):\n");
+                       printf("  pci=%08lx\n", addr1);
+                       tsi148_vme_crcsr_window(addr1);
+               }
+               break;
+       case 'i':               /* init */
+               tsi148_init();
+               break;
+       case 'g':
+               vam = addr2;
+               printf("Tsi148: Configuring VME GCSR Window (VME->GCSR):\n");
+               printf("  vme=%08lx vam=%02lx\n", addr1, vam);
+               tsi148_vme_gcsr_window(addr1, vam);
+               break;
+       case 'v':               /* vme */
+               printf("Tsi148: Configuring VME Slave Window (VME->PCI):\n");
+               printf("  vme=%08lx pci=%08lx size=%08lx vam=%02lx\n",
+                      addr1, addr2, size, vam);
+               tsi148_vme_slave_window(addr1, addr2, size, vam);
+               break;
+       case 'p':               /* pci */
+               printf("Tsi148: Configuring PCI Slave Window (PCI->VME):\n");
+               printf("  pci=%08lx vme=%08lx size=%08lx vam=%02lx vdw=%02lx\n",
+                      addr1, addr2, size, vam, vdw);
+               tsi148_pci_slave_window(addr1, addr2, size, vam, vdw);
+               break;
+       default:
+               printf("Tsi148: Command %s not supported!\n", argv[1]);
+       }
+
+       return 0;
+}
+
+U_BOOT_CMD(
+       tsi148, 8,      1,      do_tsi148,
+       "tsi148  - initialize and configure Turndra Tsi148\n",
+       "init\n"
+       "    - initialize tsi148\n"
+       "tsi148 vme   [vme_addr] [pci_addr] [size] [vam]\n"
+       "    - create vme slave window (access: vme->pci)\n"
+       "tsi148 pci   [pci_addr] [vme_addr] [size] [vam] [vdw]\n"
+       "    - create pci slave window (access: pci->vme)\n"
+       "tsi148 crg   [vme_addr] [vam]\n"
+       "    - create vme slave window: (access vme->CRG\n"
+       "tsi148 crcsr [pci_addr]\n"
+       "    - create vme slave window: (access vme->CR/CSR\n"
+       "tsi148 gcsr  [vme_addr] [vam]\n"
+       "    - create vme slave window: (access vme->GCSR\n"
+       "    [vam] = VMEbus Address-Modifier:  01 -> A16 Address Space\n"
+       "                                      02 -> A24 Address Space\n"
+       "                                      03 -> A32 Address Space\n"
+       "                                      04 -> Usr        AM Code\n"
+       "                                      08 -> Supervisor AM Code\n"
+       "                                      10 -> Data AM Code\n"
+       "                                      20 -> Program AM Code\n"
+       "    [vdw] = VMEbus Maximum Datawidth: 02 -> D16 Data Width\n"
+       "                                      03 -> D32 Data Width\n"
+);
index 05893f5..54faac1 100644 (file)
@@ -618,7 +618,7 @@ U_BOOT_CMD(ubi, 6, 1, do_ubi,
        "ubi remove[vol] volume"
                " - Remove volume\n"
        "[Legends]\n"
-       " volume: charater name\n"
-       " size: KiB, MiB, GiB, and bytes\n"
+       " volume: character name\n"
+       " size: specified in bytes\n"
        " type: s[tatic] or d[ynamic] (default=dynamic)"
 );
index 0a36d2f..867c12c 100644 (file)
@@ -532,6 +532,33 @@ int console_init_f(void)
        return 0;
 }
 
+void stdio_print_current_devices(void)
+{
+#ifdef CONFIG_SYS_CONSOLE_INFO_QUIET
+       /* Print information */
+       puts("In:    ");
+       if (stdio_devices[stdin] == NULL) {
+               puts("No input devices available!\n");
+       } else {
+               printf ("%s\n", stdio_devices[stdin]->name);
+       }
+
+       puts("Out:   ");
+       if (stdio_devices[stdout] == NULL) {
+               puts("No output devices available!\n");
+       } else {
+               printf ("%s\n", stdio_devices[stdout]->name);
+       }
+
+       puts("Err:   ");
+       if (stdio_devices[stderr] == NULL) {
+               puts("No error devices available!\n");
+       } else {
+               printf ("%s\n", stdio_devices[stderr]->name);
+       }
+#endif /* CONFIG_SYS_CONSOLE_INFO_QUIET */
+}
+
 #ifdef CONFIG_SYS_CONSOLE_IS_IN_ENV
 /* Called after the relocation - use desired console functions */
 int console_init_r(void)
@@ -601,29 +628,7 @@ done:
 
        gd->flags |= GD_FLG_DEVINIT;    /* device initialization completed */
 
-#ifndef CONFIG_SYS_CONSOLE_INFO_QUIET
-       /* Print information */
-       puts("In:    ");
-       if (stdio_devices[stdin] == NULL) {
-               puts("No input devices available!\n");
-       } else {
-               console_printdevs(stdin);
-       }
-
-       puts("Out:   ");
-       if (stdio_devices[stdout] == NULL) {
-               puts("No output devices available!\n");
-       } else {
-               console_printdevs(stdout);
-       }
-
-       puts("Err:   ");
-       if (stdio_devices[stderr] == NULL) {
-               puts("No error devices available!\n");
-       } else {
-               console_printdevs(stderr);
-       }
-#endif /* CONFIG_SYS_CONSOLE_INFO_QUIET */
+       stdio_print_current_devices();
 
 #ifdef CONFIG_SYS_CONSOLE_ENV_OVERWRITE
        /* set the environment variables (will overwrite previous env settings) */
@@ -694,29 +699,7 @@ int console_init_r(void)
 
        gd->flags |= GD_FLG_DEVINIT;    /* device initialization completed */
 
-#ifndef CONFIG_SYS_CONSOLE_INFO_QUIET
-       /* Print information */
-       puts("In:    ");
-       if (stdio_devices[stdin] == NULL) {
-               puts("No input devices available!\n");
-       } else {
-               printf("%s\n", stdio_devices[stdin]->name);
-       }
-
-       puts("Out:   ");
-       if (stdio_devices[stdout] == NULL) {
-               puts("No output devices available!\n");
-       } else {
-               printf("%s\n", stdio_devices[stdout]->name);
-       }
-
-       puts("Err:   ");
-       if (stdio_devices[stderr] == NULL) {
-               puts("No error devices available!\n");
-       } else {
-               printf("%s\n", stdio_devices[stderr]->name);
-       }
-#endif /* CONFIG_SYS_CONSOLE_INFO_QUIET */
+       stdio_print_current_devices();
 
        /* Setting environment variables */
        for (i = 0; i < 3; i++) {
diff --git a/common/docecc.c b/common/docecc.c
deleted file mode 100644 (file)
index 3412aff..0000000
+++ /dev/null
@@ -1,513 +0,0 @@
-/*
- * ECC algorithm for M-systems disk on chip. We use the excellent Reed
- * Solmon code of Phil Karn (karn@ka9q.ampr.org) available under the
- * GNU GPL License. The rest is simply to convert the disk on chip
- * syndrom into a standard syndom.
- *
- * Author: Fabrice Bellard (fabrice.bellard@netgem.com)
- * Copyright (C) 2000 Netgem S.A.
- *
- * $Id: docecc.c,v 1.4 2001/10/02 15:05:13 dwmw2 Exp $
- *
- * 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.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#include <config.h>
-#include <common.h>
-#include <malloc.h>
-
-#undef ECC_DEBUG
-#undef PSYCHO_DEBUG
-
-#include <linux/mtd/doc2000.h>
-
-/* need to undef it (from asm/termbits.h) */
-#undef B0
-
-#define MM 10 /* Symbol size in bits */
-#define KK (1023-4) /* Number of data symbols per block */
-#define B0 510 /* First root of generator polynomial, alpha form */
-#define PRIM 1 /* power of alpha used to generate roots of generator poly */
-#define        NN ((1 << MM) - 1)
-
-typedef unsigned short dtype;
-
-/* 1+x^3+x^10 */
-static const int Pp[MM+1] = { 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1 };
-
-/* This defines the type used to store an element of the Galois Field
- * used by the code. Make sure this is something larger than a char if
- * if anything larger than GF(256) is used.
- *
- * Note: unsigned char will work up to GF(256) but int seems to run
- * faster on the Pentium.
- */
-typedef int gf;
-
-/* No legal value in index form represents zero, so
- * we need a special value for this purpose
- */
-#define A0     (NN)
-
-/* Compute x % NN, where NN is 2**MM - 1,
- * without a slow divide
- */
-static inline gf
-modnn(int x)
-{
-  while (x >= NN) {
-    x -= NN;
-    x = (x >> MM) + (x & NN);
-  }
-  return x;
-}
-
-#define        CLEAR(a,n) {\
-int ci;\
-for(ci=(n)-1;ci >=0;ci--)\
-(a)[ci] = 0;\
-}
-
-#define        COPY(a,b,n) {\
-int ci;\
-for(ci=(n)-1;ci >=0;ci--)\
-(a)[ci] = (b)[ci];\
-}
-
-#define        COPYDOWN(a,b,n) {\
-int ci;\
-for(ci=(n)-1;ci >=0;ci--)\
-(a)[ci] = (b)[ci];\
-}
-
-#define Ldec 1
-
-/* generate GF(2**m) from the irreducible polynomial p(X) in Pp[0]..Pp[m]
-   lookup tables:  index->polynomial form   alpha_to[] contains j=alpha**i;
-                  polynomial form -> index form  index_of[j=alpha**i] = i
-   alpha=2 is the primitive element of GF(2**m)
-   HARI's COMMENT: (4/13/94) alpha_to[] can be used as follows:
-       Let @ represent the primitive element commonly called "alpha" that
-   is the root of the primitive polynomial p(x). Then in GF(2^m), for any
-   0 <= i <= 2^m-2,
-       @^i = a(0) + a(1) @ + a(2) @^2 + ... + a(m-1) @^(m-1)
-   where the binary vector (a(0),a(1),a(2),...,a(m-1)) is the representation
-   of the integer "alpha_to[i]" with a(0) being the LSB and a(m-1) the MSB. Thus for
-   example the polynomial representation of @^5 would be given by the binary
-   representation of the integer "alpha_to[5]".
-                  Similarily, index_of[] can be used as follows:
-       As above, let @ represent the primitive element of GF(2^m) that is
-   the root of the primitive polynomial p(x). In order to find the power
-   of @ (alpha) that has the polynomial representation
-       a(0) + a(1) @ + a(2) @^2 + ... + a(m-1) @^(m-1)
-   we consider the integer "i" whose binary representation with a(0) being LSB
-   and a(m-1) MSB is (a(0),a(1),...,a(m-1)) and locate the entry
-   "index_of[i]". Now, @^index_of[i] is that element whose polynomial
-    representation is (a(0),a(1),a(2),...,a(m-1)).
-   NOTE:
-       The element alpha_to[2^m-1] = 0 always signifying that the
-   representation of "@^infinity" = 0 is (0,0,0,...,0).
-       Similarily, the element index_of[0] = A0 always signifying
-   that the power of alpha which has the polynomial representation
-   (0,0,...,0) is "infinity".
-
-*/
-
-static void
-generate_gf(dtype Alpha_to[NN + 1], dtype Index_of[NN + 1])
-{
-  register int i, mask;
-
-  mask = 1;
-  Alpha_to[MM] = 0;
-  for (i = 0; i < MM; i++) {
-    Alpha_to[i] = mask;
-    Index_of[Alpha_to[i]] = i;
-    /* If Pp[i] == 1 then, term @^i occurs in poly-repr of @^MM */
-    if (Pp[i] != 0)
-      Alpha_to[MM] ^= mask;    /* Bit-wise EXOR operation */
-    mask <<= 1;        /* single left-shift */
-  }
-  Index_of[Alpha_to[MM]] = MM;
-  /*
-   * Have obtained poly-repr of @^MM. Poly-repr of @^(i+1) is given by
-   * poly-repr of @^i shifted left one-bit and accounting for any @^MM
-   * term that may occur when poly-repr of @^i is shifted.
-   */
-  mask >>= 1;
-  for (i = MM + 1; i < NN; i++) {
-    if (Alpha_to[i - 1] >= mask)
-      Alpha_to[i] = Alpha_to[MM] ^ ((Alpha_to[i - 1] ^ mask) << 1);
-    else
-      Alpha_to[i] = Alpha_to[i - 1] << 1;
-    Index_of[Alpha_to[i]] = i;
-  }
-  Index_of[0] = A0;
-  Alpha_to[NN] = 0;
-}
-
-/*
- * Performs ERRORS+ERASURES decoding of RS codes. bb[] is the content
- * of the feedback shift register after having processed the data and
- * the ECC.
- *
- * Return number of symbols corrected, or -1 if codeword is illegal
- * or uncorrectable. If eras_pos is non-null, the detected error locations
- * are written back. NOTE! This array must be at least NN-KK elements long.
- * The corrected data are written in eras_val[]. They must be xor with the data
- * to retrieve the correct data : data[erase_pos[i]] ^= erase_val[i] .
- *
- * First "no_eras" erasures are declared by the calling program. Then, the
- * maximum # of errors correctable is t_after_eras = floor((NN-KK-no_eras)/2).
- * If the number of channel errors is not greater than "t_after_eras" the
- * transmitted codeword will be recovered. Details of algorithm can be found
- * in R. Blahut's "Theory ... of Error-Correcting Codes".
-
- * Warning: the eras_pos[] array must not contain duplicate entries; decoder failure
- * will result. The decoder *could* check for this condition, but it would involve
- * extra time on every decoding operation.
- * */
-static int
-eras_dec_rs(dtype Alpha_to[NN + 1], dtype Index_of[NN + 1],
-           gf bb[NN - KK + 1], gf eras_val[NN-KK], int eras_pos[NN-KK],
-           int no_eras)
-{
-  int deg_lambda, el, deg_omega;
-  int i, j, r,k;
-  gf u,q,tmp,num1,num2,den,discr_r;
-  gf lambda[NN-KK + 1], s[NN-KK + 1];  /* Err+Eras Locator poly
-                                        * and syndrome poly */
-  gf b[NN-KK + 1], t[NN-KK + 1], omega[NN-KK + 1];
-  gf root[NN-KK], reg[NN-KK + 1], loc[NN-KK];
-  int syn_error, count;
-
-  syn_error = 0;
-  for(i=0;i<NN-KK;i++)
-      syn_error |= bb[i];
-
-  if (!syn_error) {
-    /* if remainder is zero, data[] is a codeword and there are no
-     * errors to correct. So return data[] unmodified
-     */
-    count = 0;
-    goto finish;
-  }
-
-  for(i=1;i<=NN-KK;i++){
-    s[i] = bb[0];
-  }
-  for(j=1;j<NN-KK;j++){
-    if(bb[j] == 0)
-      continue;
-    tmp = Index_of[bb[j]];
-
-    for(i=1;i<=NN-KK;i++)
-      s[i] ^= Alpha_to[modnn(tmp + (B0+i-1)*PRIM*j)];
-  }
-
-  /* undo the feedback register implicit multiplication and convert
-     syndromes to index form */
-
-  for(i=1;i<=NN-KK;i++) {
-      tmp = Index_of[s[i]];
-      if (tmp != A0)
-         tmp = modnn(tmp + 2 * KK * (B0+i-1)*PRIM);
-      s[i] = tmp;
-  }
-
-  CLEAR(&lambda[1],NN-KK);
-  lambda[0] = 1;
-
-  if (no_eras > 0) {
-    /* Init lambda to be the erasure locator polynomial */
-    lambda[1] = Alpha_to[modnn(PRIM * eras_pos[0])];
-    for (i = 1; i < no_eras; i++) {
-      u = modnn(PRIM*eras_pos[i]);
-      for (j = i+1; j > 0; j--) {
-       tmp = Index_of[lambda[j - 1]];
-       if(tmp != A0)
-         lambda[j] ^= Alpha_to[modnn(u + tmp)];
-      }
-    }
-#ifdef ECC_DEBUG
-    /* Test code that verifies the erasure locator polynomial just constructed
-       Needed only for decoder debugging. */
-
-    /* find roots of the erasure location polynomial */
-    for(i=1;i<=no_eras;i++)
-      reg[i] = Index_of[lambda[i]];
-    count = 0;
-    for (i = 1,k=NN-Ldec; i <= NN; i++,k = modnn(NN+k-Ldec)) {
-      q = 1;
-      for (j = 1; j <= no_eras; j++)
-       if (reg[j] != A0) {
-         reg[j] = modnn(reg[j] + j);
-         q ^= Alpha_to[reg[j]];
-       }
-      if (q != 0)
-       continue;
-      /* store root and error location number indices */
-      root[count] = i;
-      loc[count] = k;
-      count++;
-    }
-    if (count != no_eras) {
-      printf("\n lambda(x) is WRONG\n");
-      count = -1;
-      goto finish;
-    }
-#ifdef PSYCHO_DEBUG
-    printf("\n Erasure positions as determined by roots of Eras Loc Poly:\n");
-    for (i = 0; i < count; i++)
-      printf("%d ", loc[i]);
-    printf("\n");
-#endif
-#endif
-  }
-  for(i=0;i<NN-KK+1;i++)
-    b[i] = Index_of[lambda[i]];
-
-  /*
-   * Begin Berlekamp-Massey algorithm to determine error+erasure
-   * locator polynomial
-   */
-  r = no_eras;
-  el = no_eras;
-  while (++r <= NN-KK) {       /* r is the step number */
-    /* Compute discrepancy at the r-th step in poly-form */
-    discr_r = 0;
-    for (i = 0; i < r; i++){
-      if ((lambda[i] != 0) && (s[r - i] != A0)) {
-       discr_r ^= Alpha_to[modnn(Index_of[lambda[i]] + s[r - i])];
-      }
-    }
-    discr_r = Index_of[discr_r];       /* Index form */
-    if (discr_r == A0) {
-      /* 2 lines below: B(x) <-- x*B(x) */
-      COPYDOWN(&b[1],b,NN-KK);
-      b[0] = A0;
-    } else {
-      /* 7 lines below: T(x) <-- lambda(x) - discr_r*x*b(x) */
-      t[0] = lambda[0];
-      for (i = 0 ; i < NN-KK; i++) {
-       if(b[i] != A0)
-         t[i+1] = lambda[i+1] ^ Alpha_to[modnn(discr_r + b[i])];
-       else
-         t[i+1] = lambda[i+1];
-      }
-      if (2 * el <= r + no_eras - 1) {
-       el = r + no_eras - el;
-       /*
-        * 2 lines below: B(x) <-- inv(discr_r) *
-        * lambda(x)
-        */
-       for (i = 0; i <= NN-KK; i++)
-         b[i] = (lambda[i] == 0) ? A0 : modnn(Index_of[lambda[i]] - discr_r + NN);
-      } else {
-       /* 2 lines below: B(x) <-- x*B(x) */
-       COPYDOWN(&b[1],b,NN-KK);
-       b[0] = A0;
-      }
-      COPY(lambda,t,NN-KK+1);
-    }
-  }
-
-  /* Convert lambda to index form and compute deg(lambda(x)) */
-  deg_lambda = 0;
-  for(i=0;i<NN-KK+1;i++){
-    lambda[i] = Index_of[lambda[i]];
-    if(lambda[i] != A0)
-      deg_lambda = i;
-  }
-  /*
-   * Find roots of the error+erasure locator polynomial by Chien
-   * Search
-   */
-  COPY(&reg[1],&lambda[1],NN-KK);
-  count = 0;           /* Number of roots of lambda(x) */
-  for (i = 1,k=NN-Ldec; i <= NN; i++,k = modnn(NN+k-Ldec)) {
-    q = 1;
-    for (j = deg_lambda; j > 0; j--){
-      if (reg[j] != A0) {
-       reg[j] = modnn(reg[j] + j);
-       q ^= Alpha_to[reg[j]];
-      }
-    }
-    if (q != 0)
-      continue;
-    /* store root (index-form) and error location number */
-    root[count] = i;
-    loc[count] = k;
-    /* If we've already found max possible roots,
-     * abort the search to save time
-     */
-    if(++count == deg_lambda)
-      break;
-  }
-  if (deg_lambda != count) {
-    /*
-     * deg(lambda) unequal to number of roots => uncorrectable
-     * error detected
-     */
-    count = -1;
-    goto finish;
-  }
-  /*
-   * Compute err+eras evaluator poly omega(x) = s(x)*lambda(x) (modulo
-   * x**(NN-KK)). in index form. Also find deg(omega).
-   */
-  deg_omega = 0;
-  for (i = 0; i < NN-KK;i++){
-    tmp = 0;
-    j = (deg_lambda < i) ? deg_lambda : i;
-    for(;j >= 0; j--){
-      if ((s[i + 1 - j] != A0) && (lambda[j] != A0))
-       tmp ^= Alpha_to[modnn(s[i + 1 - j] + lambda[j])];
-    }
-    if(tmp != 0)
-      deg_omega = i;
-    omega[i] = Index_of[tmp];
-  }
-  omega[NN-KK] = A0;
-
-  /*
-   * Compute error values in poly-form. num1 = omega(inv(X(l))), num2 =
-   * inv(X(l))**(B0-1) and den = lambda_pr(inv(X(l))) all in poly-form
-   */
-  for (j = count-1; j >=0; j--) {
-    num1 = 0;
-    for (i = deg_omega; i >= 0; i--) {
-      if (omega[i] != A0)
-       num1  ^= Alpha_to[modnn(omega[i] + i * root[j])];
-    }
-    num2 = Alpha_to[modnn(root[j] * (B0 - 1) + NN)];
-    den = 0;
-
-    /* lambda[i+1] for i even is the formal derivative lambda_pr of lambda[i] */
-    for (i = min(deg_lambda,NN-KK-1) & ~1; i >= 0; i -=2) {
-      if(lambda[i+1] != A0)
-       den ^= Alpha_to[modnn(lambda[i+1] + i * root[j])];
-    }
-    if (den == 0) {
-#ifdef ECC_DEBUG
-      printf("\n ERROR: denominator = 0\n");
-#endif
-      /* Convert to dual- basis */
-      count = -1;
-      goto finish;
-    }
-    /* Apply error to data */
-    if (num1 != 0) {
-       eras_val[j] = Alpha_to[modnn(Index_of[num1] + Index_of[num2] + NN - Index_of[den])];
-    } else {
-       eras_val[j] = 0;
-    }
-  }
- finish:
-  for(i=0;i<count;i++)
-      eras_pos[i] = loc[i];
-  return count;
-}
-
-/***************************************************************************/
-/* The DOC specific code begins here */
-
-#define SECTOR_SIZE 512
-/* The sector bytes are packed into NB_DATA MM bits words */
-#define NB_DATA (((SECTOR_SIZE + 1) * 8 + 6) / MM)
-
-/*
- * Correct the errors in 'sector[]' by using 'ecc1[]' which is the
- * content of the feedback shift register applyied to the sector and
- * the ECC. Return the number of errors corrected (and correct them in
- * sector), or -1 if error
- */
-int doc_decode_ecc(unsigned char sector[SECTOR_SIZE], unsigned char ecc1[6])
-{
-    int parity, i, nb_errors;
-    gf bb[NN - KK + 1];
-    gf error_val[NN-KK];
-    int error_pos[NN-KK], pos, bitpos, index, val;
-    dtype *Alpha_to, *Index_of;
-
-    /* init log and exp tables here to save memory. However, it is slower */
-    Alpha_to = malloc((NN + 1) * sizeof(dtype));
-    if (!Alpha_to)
-       return -1;
-
-    Index_of = malloc((NN + 1) * sizeof(dtype));
-    if (!Index_of) {
-       free(Alpha_to);
-       return -1;
-    }
-
-    generate_gf(Alpha_to, Index_of);
-
-    parity = ecc1[1];
-
-    bb[0] =  (ecc1[4] & 0xff) | ((ecc1[5] & 0x03) << 8);
-    bb[1] = ((ecc1[5] & 0xfc) >> 2) | ((ecc1[2] & 0x0f) << 6);
-    bb[2] = ((ecc1[2] & 0xf0) >> 4) | ((ecc1[3] & 0x3f) << 4);
-    bb[3] = ((ecc1[3] & 0xc0) >> 6) | ((ecc1[0] & 0xff) << 2);
-
-    nb_errors = eras_dec_rs(Alpha_to, Index_of, bb,
-                           error_val, error_pos, 0);
-    if (nb_errors <= 0)
-       goto the_end;
-
-    /* correct the errors */
-    for(i=0;i<nb_errors;i++) {
-       pos = error_pos[i];
-       if (pos >= NB_DATA && pos < KK) {
-           nb_errors = -1;
-           goto the_end;
-       }
-       if (pos < NB_DATA) {
-           /* extract bit position (MSB first) */
-           pos = 10 * (NB_DATA - 1 - pos) - 6;
-           /* now correct the following 10 bits. At most two bytes
-              can be modified since pos is even */
-           index = (pos >> 3) ^ 1;
-           bitpos = pos & 7;
-           if ((index >= 0 && index < SECTOR_SIZE) ||
-               index == (SECTOR_SIZE + 1)) {
-               val = error_val[i] >> (2 + bitpos);
-               parity ^= val;
-               if (index < SECTOR_SIZE)
-                   sector[index] ^= val;
-           }
-           index = ((pos >> 3) + 1) ^ 1;
-           bitpos = (bitpos + 10) & 7;
-           if (bitpos == 0)
-               bitpos = 8;
-           if ((index >= 0 && index < SECTOR_SIZE) ||
-               index == (SECTOR_SIZE + 1)) {
-               val = error_val[i] << (8 - bitpos);
-               parity ^= val;
-               if (index < SECTOR_SIZE)
-                   sector[index] ^= val;
-           }
-       }
-    }
-
-    /* use parity to test extra errors */
-    if ((parity & 0xff) != 0)
-       nb_errors = -1;
-
- the_end:
-    free(Alpha_to);
-    free(Index_of);
-    return nb_errors;
-}
index 90a1c45..8052fb7 100644 (file)
 #define CONFIG_ENV_RANGE       CONFIG_ENV_SIZE
 #endif
 
-int nand_legacy_rw (struct nand_chip* nand, int cmd,
-           size_t start, size_t len,
-           size_t * retlen, u_char * buf);
-
 /* references to names in env_common.c */
 extern uchar default_environment[];
 extern int default_environment_size;
index 48089a9..476fdbc 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * (C) Copyright 2005-2007 Samsung Electronics
+ * (C) Copyright 2005-2009 Samsung Electronics
  * Kyungmin Park <kyungmin.park@samsung.com>
  *
  * See file CREDITS for list of people who contributed to this
@@ -37,15 +37,16 @@ extern struct onenand_chip onenand_chip;
 /* References to names in env_common.c */
 extern uchar default_environment[];
 
-#define ONENAND_ENV_SIZE(mtd)  (mtd.writesize - ENV_HEADER_SIZE)
-
 char *env_name_spec = "OneNAND";
 
+#define ONENAND_MAX_ENV_SIZE   4096
+#define ONENAND_ENV_SIZE(mtd)  (ONENAND_MAX_ENV_SIZE - ENV_HEADER_SIZE)
+
 #ifdef ENV_IS_EMBEDDED
 extern uchar environment[];
 env_t *env_ptr = (env_t *) (&environment[0]);
 #else /* ! ENV_IS_EMBEDDED */
-static unsigned char onenand_env[MAX_ONENAND_PAGESIZE];
+static unsigned char onenand_env[ONENAND_MAX_ENV_SIZE];
 env_t *env_ptr = (env_t *) onenand_env;
 #endif /* ENV_IS_EMBEDDED */
 
@@ -58,6 +59,7 @@ uchar env_get_char_spec(int index)
 
 void env_relocate_spec(void)
 {
+       struct mtd_info *mtd = &onenand_mtd;
        loff_t env_addr;
        int use_default = 0;
        size_t retlen;
@@ -65,22 +67,21 @@ void env_relocate_spec(void)
        env_addr = CONFIG_ENV_ADDR;
 
        /* Check OneNAND exist */
-       if (onenand_mtd.writesize)
+       if (mtd->writesize)
                /* Ignore read fail */
-               onenand_read(&onenand_mtd, env_addr, onenand_mtd.writesize,
+               mtd->read(mtd, env_addr, ONENAND_MAX_ENV_SIZE,
                             &retlen, (u_char *) env_ptr);
        else
-               onenand_mtd.writesize = MAX_ONENAND_PAGESIZE;
+               mtd->writesize = MAX_ONENAND_PAGESIZE;
 
-       if (crc32(0, env_ptr->data, ONENAND_ENV_SIZE(onenand_mtd)) !=
-           env_ptr->crc)
+       if (crc32(0, env_ptr->data, ONENAND_ENV_SIZE(mtd)) != env_ptr->crc)
                use_default = 1;
 
        if (use_default) {
                memcpy(env_ptr->data, default_environment,
-                      ONENAND_ENV_SIZE(onenand_mtd));
+                      ONENAND_ENV_SIZE(mtd));
                env_ptr->crc =
-                   crc32(0, env_ptr->data, ONENAND_ENV_SIZE(onenand_mtd));
+                   crc32(0, env_ptr->data, ONENAND_ENV_SIZE(mtd));
        }
 
        gd->env_addr = (ulong) & env_ptr->data;
@@ -89,7 +90,8 @@ void env_relocate_spec(void)
 
 int saveenv(void)
 {
-       unsigned long env_addr = CONFIG_ENV_ADDR;
+       struct mtd_info *mtd = &onenand_mtd;
+       loff_t env_addr = CONFIG_ENV_ADDR;
        struct erase_info instr = {
                .callback       = NULL,
        };
@@ -97,17 +99,16 @@ int saveenv(void)
 
        instr.len = CONFIG_ENV_SIZE;
        instr.addr = env_addr;
-       instr.mtd = &onenand_mtd;
-       if (onenand_erase(&onenand_mtd, &instr)) {
+       instr.mtd = mtd;
+       if (mtd->erase(mtd, &instr)) {
                printf("OneNAND: erase failed at 0x%08lx\n", env_addr);
                return 1;
        }
 
        /* update crc */
-       env_ptr->crc =
-           crc32(0, env_ptr->data, ONENAND_ENV_SIZE(onenand_mtd));
+       env_ptr->crc = crc32(0, env_ptr->data, ONENAND_ENV_SIZE(mtd));
 
-       if (onenand_write(&onenand_mtd, env_addr, onenand_mtd.writesize, &retlen,
+       if (mtd->write(mtd, env_addr, ONENAND_MAX_ENV_SIZE, &retlen,
             (u_char *) env_ptr)) {
                printf("OneNAND: write failed at 0x%llx\n", instr.addr);
                return 2;
index a209dfa..7a46805 100644 (file)
@@ -544,7 +544,7 @@ xyzModem_stream_open (connection_info_t * info, int *err)
                          xyzModem_CHAR_TIMEOUT);
 #else
 /* TODO: CHECK ! */
-  int dummy;
+  int dummy = 0;
   xyz.__chan = &dummy;
 #endif
   xyz.len = 0;
index f2c2c6c..fd56621 100644 (file)
--- a/config.mk
+++ b/config.mk
@@ -83,7 +83,7 @@ RANLIB        = $(CROSS_COMPILE)RANLIB
 sinclude $(OBJTREE)/include/autoconf.mk
 
 ifdef  ARCH
-sinclude $(TOPDIR)/$(ARCH)_config.mk   # include architecture dependend rules
+sinclude $(TOPDIR)/lib_$(ARCH)/config.mk       # include architecture dependend rules
 endif
 ifdef  CPU
 sinclude $(TOPDIR)/cpu/$(CPU)/config.mk        # include  CPU  specific rules
@@ -196,7 +196,7 @@ endif
 
 #########################################################################
 
-export HPATH HOSTCC HOSTCFLAGS CROSS_COMPILE \
+export HOSTCC HOSTCFLAGS CROSS_COMPILE \
        AS LD CC CPP AR NM STRIP OBJCOPY OBJDUMP MAKE
 export TEXT_BASE PLATFORM_CPPFLAGS PLATFORM_RELFLAGS CPPFLAGS CFLAGS AFLAGS
 
index 822ee7d..5a5981e 100644 (file)
@@ -35,6 +35,9 @@
 #include <command.h>
 #include <asm/system.h>
 #include <asm/cache.h>
+#ifndef CONFIG_L2_OFF
+#include <asm/arch/sys_proto.h>
+#endif
 
 static void cache_flush(void);
 
index 1378fd1..5eef6a3 100644 (file)
@@ -17,8 +17,14 @@ EXTRA    :=
 CEXTRA   := initcode.o
 SEXTRA   := start.o
 SOBJS    := interrupt.o cache.o
-COBJS-y  := cpu.o traps.o interrupts.o reset.o serial.o watchdog.o
+COBJS-y  += cpu.o
+COBJS-y  += interrupts.o
 COBJS-$(CONFIG_JTAG_CONSOLE) += jtag-console.o
+COBJS-y  += os_log.o
+COBJS-y  += reset.o
+COBJS-y  += serial.o
+COBJS-y  += traps.o
+COBJS-y  += watchdog.o
 
 ifeq ($(CONFIG_BFIN_BOOT_MODE),BFIN_BOOT_BYPASS)
 COBJS-y  += initcode.o
diff --git a/cpu/blackfin/os_log.c b/cpu/blackfin/os_log.c
new file mode 100644 (file)
index 0000000..e1c8e29
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * functions for handling OS log buffer
+ *
+ * Copyright (c) 2009 Analog Devices Inc.
+ *
+ * Licensed under the 2-clause BSD.
+ */
+
+#include <common.h>
+
+#define OS_LOG_MAGIC       0xDEADBEEF
+#define OS_LOG_MAGIC_ADDR  ((unsigned long *)0x4f0)
+#define OS_LOG_PTR_ADDR    ((char **)0x4f4)
+
+bool bfin_os_log_check(void)
+{
+       if (*OS_LOG_MAGIC_ADDR != OS_LOG_MAGIC)
+               return false;
+       *OS_LOG_MAGIC_ADDR = 0;
+       return true;
+}
+
+void bfin_os_log_dump(void)
+{
+       char *log = *OS_LOG_PTR_ADDR;
+       while (*log) {
+               puts(log);
+               log += strlen(log) + 1;
+       }
+}
index 51d0102..b8f2c93 100644 (file)
@@ -56,7 +56,7 @@ void fsl_ddr_set_memctl_regs(const fsl_ddr_cfg_regs_t *regs,
        out_be32(&ddr->timing_cfg_1, regs->timing_cfg_1);
        out_be32(&ddr->timing_cfg_2, regs->timing_cfg_2);
        out_be32(&ddr->sdram_cfg_2, regs->ddr_sdram_cfg_2);
-       out_be32(&ddr->sdram_mode_1, regs->ddr_sdram_mode);
+       out_be32(&ddr->sdram_mode, regs->ddr_sdram_mode);
        out_be32(&ddr->sdram_mode_2, regs->ddr_sdram_mode_2);
        out_be32(&ddr->sdram_mode_cntl, regs->ddr_sdram_md_cntl);
        out_be32(&ddr->sdram_interval, regs->ddr_sdram_interval);
@@ -74,7 +74,7 @@ void fsl_ddr_set_memctl_regs(const fsl_ddr_cfg_regs_t *regs,
        udelay(200);
        asm volatile("sync;isync");
 
-       out_be32(&ddr->sdram_cfg_1, regs->ddr_sdram_cfg);
+       out_be32(&ddr->sdram_cfg, regs->ddr_sdram_cfg);
 
        /*
         * Poll DDR_SDRAM_CFG_2[D_INIT] bit until auto-data init is done
index 6dae26b..faa1af9 100644 (file)
@@ -162,28 +162,9 @@ int step_assign_addresses(fsl_ddr_info_t *pinfo,
                        j++;
                }
        }
-       if (j == 2) {
+       if (j == 2)
                *memctl_interleaving = 1;
 
-               printf("\nMemory controller interleaving enabled: ");
-
-               switch (pinfo->memctl_opts[0].memctl_interleaving_mode) {
-               case FSL_DDR_CACHE_LINE_INTERLEAVING:
-                       printf("Cache-line interleaving!\n");
-                       break;
-               case FSL_DDR_PAGE_INTERLEAVING:
-                       printf("Page interleaving!\n");
-                       break;
-               case FSL_DDR_BANK_INTERLEAVING:
-                       printf("Bank interleaving!\n");
-                       break;
-               case FSL_DDR_SUPERBANK_INTERLEAVING:
-                       printf("Super bank interleaving\n");
-               default:
-                       break;
-               }
-       }
-
        /* Check that all controllers are rank interleaving. */
        j = 0;
        for (i = 0; i < CONFIG_NUM_DDR_CONTROLLERS; i++) {
@@ -191,29 +172,9 @@ int step_assign_addresses(fsl_ddr_info_t *pinfo,
                        j++;
                }
        }
-       if (j == 2) {
+       if (j == 2)
                *rank_interleaving = 1;
 
-               printf("Bank(chip-select) interleaving enabled: ");
-
-               switch (pinfo->memctl_opts[0].ba_intlv_ctl &
-                                               FSL_DDR_CS0_CS1_CS2_CS3) {
-               case FSL_DDR_CS0_CS1_CS2_CS3:
-                       printf("CS0+CS1+CS2+CS3\n");
-                       break;
-               case FSL_DDR_CS0_CS1:
-                       printf("CS0+CS1\n");
-                       break;
-               case FSL_DDR_CS2_CS3:
-                       printf("CS2+CS3\n");
-                       break;
-               case FSL_DDR_CS0_CS1_AND_CS2_CS3:
-                       printf("CS0+CS1 and CS2+CS3\n");
-               default:
-                       break;
-               }
-       }
-
        if (*memctl_interleaving) {
                unsigned long long addr, total_mem_per_ctlr = 0;
                /*
index 70dbee0..4451989 100644 (file)
@@ -107,3 +107,99 @@ __attribute__((weak, alias("__fsl_ddr_set_lawbar"))) void
 fsl_ddr_set_lawbar(const common_timing_params_t *memctl_common_params,
                         unsigned int memctl_interleaved,
                         unsigned int ctrl_num);
+
+void board_add_ram_info(int use_default)
+{
+#if defined(CONFIG_MPC85xx)
+       volatile ccsr_ddr_t *ddr = (void *)(CONFIG_SYS_MPC85xx_DDR_ADDR);
+#elif defined(CONFIG_MPC86xx)
+       volatile ccsr_ddr_t *ddr = (void *)(CONFIG_SYS_MPC86xx_DDR_ADDR);
+#endif
+#if (CONFIG_NUM_DDR_CONTROLLERS > 1)
+       uint32_t cs0_config = in_be32(&ddr->cs0_config);
+#endif
+       uint32_t sdram_cfg = in_be32(&ddr->sdram_cfg);
+       int cas_lat;
+
+       puts(" (DDR");
+       switch ((sdram_cfg & SDRAM_CFG_SDRAM_TYPE_MASK) >>
+               SDRAM_CFG_SDRAM_TYPE_SHIFT) {
+       case SDRAM_TYPE_DDR1:
+               puts("1");
+               break;
+       case SDRAM_TYPE_DDR2:
+               puts("2");
+               break;
+       case SDRAM_TYPE_DDR3:
+               puts("3");
+               break;
+       default:
+               puts("?");
+               break;
+       }
+
+       if (sdram_cfg & SDRAM_CFG_32_BE)
+               puts(", 32-bit");
+       else
+               puts(", 64-bit");
+
+       /* Calculate CAS latency based on timing cfg values */
+       cas_lat = ((in_be32(&ddr->timing_cfg_1) >> 16) & 0xf) + 1;
+       if ((in_be32(&ddr->timing_cfg_3) >> 12) & 1)
+               cas_lat += (8 << 1);
+       printf(", CL=%d", cas_lat >> 1);
+       if (cas_lat & 0x1)
+               puts(".5");
+
+       if (sdram_cfg & SDRAM_CFG_ECC_EN)
+               puts(", ECC on)");
+       else
+               puts(", ECC off)");
+
+#if (CONFIG_NUM_DDR_CONTROLLERS > 1)
+       if (cs0_config & 0x20000000) {
+               puts("\n");
+               puts("       DDR Controller Interleaving Mode: ");
+
+               switch ((cs0_config >> 24) & 0xf) {
+               case FSL_DDR_CACHE_LINE_INTERLEAVING:
+                       puts("cache line");
+                       break;
+               case FSL_DDR_PAGE_INTERLEAVING:
+                       puts("page");
+                       break;
+               case FSL_DDR_BANK_INTERLEAVING:
+                       puts("bank");
+                       break;
+               case FSL_DDR_SUPERBANK_INTERLEAVING:
+                       puts("super-bank");
+                       break;
+               default:
+                       puts("invalid");
+                       break;
+               }
+       }
+#endif
+
+       if ((sdram_cfg >> 8) & 0x7f) {
+               puts("\n");
+               puts("       DDR Chip-Select Interleaving Mode: ");
+               switch(sdram_cfg >> 8 & 0x7f) {
+               case FSL_DDR_CS0_CS1_CS2_CS3:
+                       puts("CS0+CS1+CS2+CS3");
+                       break;
+               case FSL_DDR_CS0_CS1:
+                       puts("CS0+CS1");
+                       break;
+               case FSL_DDR_CS2_CS3:
+                       puts("CS2+CS3");
+                       break;
+               case FSL_DDR_CS0_CS1_AND_CS2_CS3:
+                       puts("CS0+CS1 and CS2+CS3");
+                       break;
+               default:
+                       puts("invalid");
+                       break;
+               }
+       }
+}
index 96ab5c6..6f52dfd 100644 (file)
@@ -51,7 +51,6 @@ COBJS += fdt.o
 COBJS  += i2c.o
 COBJS  += interrupts.o
 COBJS  += iop480_uart.o
-COBJS  += ndfc.o
 COBJS  += sdram.o
 COBJS  += speed.o
 COBJS  += tlb.o
index b077d9a..8eedb6c 100644 (file)
@@ -105,8 +105,7 @@ NOTE:
 =====
 
 The current NAND implementation is based on what is in recent
-Linux kernels.  The old legacy implementation has been disabled,
-and will be removed soon.
+Linux kernels.  The old legacy implementation has been removed.
 
 If you have board code which used CONFIG_NAND_LEGACY, you'll need
 to convert to the current NAND interface for it to continue to work.
index 9bbdc0a..0238d97 100644 (file)
@@ -56,11 +56,3 @@ Why: Over time, a couple of files have sneaked in into the U-Boot
        for an old and probably incomplete list of such files.
 
 Who:   Wolfgang Denk <wd@denx.de> and board maintainers
-
----------------------------
-
-What:  Legacy NAND code
-When:  April 2009
-Why:   Legacy NAND code is deprecated.  Similar functionality exists in
-       more recent NAND code ported from the Linux kernel.
-Who:   Scott Wood <scottwood@freescale.com>
index eccefc1..3f6ad5c 100644 (file)
@@ -31,6 +31,7 @@ COBJS-$(CONFIG_FSL_SATA) += fsl_sata.o
 COBJS-$(CONFIG_IDE_SIL680) += sil680.o
 COBJS-$(CONFIG_LIBATA) += libata.o
 COBJS-$(CONFIG_PATA_BFIN) += pata_bfin.o
+COBJS-$(CONFIG_SATA_DWC) += sata_dwc.o
 COBJS-$(CONFIG_SATA_SIL3114) += sata_sil3114.o
 COBJS-$(CONFIG_SCSI_AHCI) += ahci.o
 COBJS-$(CONFIG_SCSI_SYM53C8XX) += sym53c8xx.o
index 2009d1e..abcda6f 100644 (file)
@@ -81,7 +81,7 @@ void dprint_buffer(unsigned char *buf, int len)
        printf("\n\r");
 }
 
-static void fsl_sata_dump_sfis(struct sfis *s)
+static void fsl_sata_dump_sfis(struct sata_fis_d2h *s)
 {
        printf("Status FIS dump:\n\r");
        printf("fis_type:               %02x\n\r", s->fis_type);
@@ -347,7 +347,7 @@ static void fsl_sata_dump_regs(fsl_sata_reg_t *reg)
        printf("SYSPR:          %08x\n\r", in_be32(&reg->syspr));
 }
 
-static int fsl_ata_exec_ata_cmd(struct fsl_sata *sata, struct cfis *cfis,
+static int fsl_ata_exec_ata_cmd(struct fsl_sata *sata, struct sata_fis_h2d *cfis,
                                int is_ncq, int tag, u8 *buffer, u32 len)
 {
        cmd_hdr_entry_t *cmd_hdr;
@@ -483,7 +483,7 @@ static int fsl_ata_exec_ata_cmd(struct fsl_sata *sata, struct cfis *cfis,
 
        if (val32) {
                u32 der;
-               fsl_sata_dump_sfis((struct sfis *)cmd_desc->sfis);
+               fsl_sata_dump_sfis((struct sata_fis_d2h *)cmd_desc->sfis);
                printf("CE at device\n\r");
                fsl_sata_dump_regs(reg);
                der = in_le32(&reg->der);
@@ -498,13 +498,13 @@ static int fsl_ata_exec_ata_cmd(struct fsl_sata *sata, struct cfis *cfis,
        return len;
 }
 
-static int fsl_ata_exec_reset_cmd(struct fsl_sata *sata, struct cfis *cfis,
+static int fsl_ata_exec_reset_cmd(struct fsl_sata *sata, struct sata_fis_h2d *cfis,
                                 int tag, u8 *buffer, u32 len)
 {
        return 0;
 }
 
-static int fsl_sata_exec_cmd(struct fsl_sata *sata, struct cfis *cfis,
+static int fsl_sata_exec_cmd(struct fsl_sata *sata, struct sata_fis_h2d *cfis,
                 enum cmd_type command_type, int tag, u8 *buffer, u32 len)
 {
        int rc;
@@ -539,11 +539,9 @@ static int fsl_sata_exec_cmd(struct fsl_sata *sata, struct cfis *cfis,
 static void fsl_sata_identify(int dev, u16 *id)
 {
        fsl_sata_t *sata = (fsl_sata_t *)sata_dev_desc[dev].priv;
-       struct sata_fis_h2d h2d;
-       struct cfis *cfis;
+       struct sata_fis_h2d h2d, *cfis = &h2d;
 
-       cfis = (struct cfis *)&h2d;
-       memset((void *)cfis, 0, sizeof(struct cfis));
+       memset(cfis, 0, sizeof(struct sata_fis_h2d));
 
        cfis->fis_type = SATA_FIS_TYPE_REGISTER_H2D;
        cfis->pm_port_c = 0x80; /* is command */
@@ -566,12 +564,10 @@ static void fsl_sata_xfer_mode(int dev, u16 *id)
 static void fsl_sata_set_features(int dev)
 {
        fsl_sata_t *sata = (fsl_sata_t *)sata_dev_desc[dev].priv;
-       struct sata_fis_h2d h2d;
-       struct cfis *cfis;
+       struct sata_fis_h2d h2d, *cfis = &h2d;
        u8 udma_cap;
 
-       cfis = (struct cfis *)&h2d;
-       memset((void *)cfis, 0, sizeof(struct cfis));
+       memset(cfis, 0, sizeof(struct sata_fis_h2d));
 
        cfis->fis_type = SATA_FIS_TYPE_REGISTER_H2D;
        cfis->pm_port_c = 0x80; /* is command */
@@ -597,14 +593,12 @@ static void fsl_sata_set_features(int dev)
 static u32 fsl_sata_rw_cmd(int dev, u32 start, u32 blkcnt, u8 *buffer, int is_write)
 {
        fsl_sata_t *sata = (fsl_sata_t *)sata_dev_desc[dev].priv;
-       struct sata_fis_h2d h2d;
-       struct cfis *cfis;
+       struct sata_fis_h2d h2d, *cfis = &h2d;
        u32 block;
 
        block = start;
-       cfis = (struct cfis *)&h2d;
 
-       memset((void *)cfis, 0, sizeof(struct cfis));
+       memset(cfis, 0, sizeof(struct sata_fis_h2d));
 
        cfis->fis_type = SATA_FIS_TYPE_REGISTER_H2D;
        cfis->pm_port_c = 0x80; /* is command */
@@ -624,12 +618,9 @@ static u32 fsl_sata_rw_cmd(int dev, u32 start, u32 blkcnt, u8 *buffer, int is_wr
 void fsl_sata_flush_cache(int dev)
 {
        fsl_sata_t *sata = (fsl_sata_t *)sata_dev_desc[dev].priv;
-       struct sata_fis_h2d h2d;
-       struct cfis *cfis;
+       struct sata_fis_h2d h2d, *cfis = &h2d;
 
-       cfis = (struct cfis *)&h2d;
-
-       memset((void *)cfis, 0, sizeof(struct cfis));
+       memset(cfis, 0, sizeof(struct sata_fis_h2d));
 
        cfis->fis_type = SATA_FIS_TYPE_REGISTER_H2D;
        cfis->pm_port_c = 0x80; /* is command */
@@ -641,14 +632,12 @@ void fsl_sata_flush_cache(int dev)
 static u32 fsl_sata_rw_cmd_ext(int dev, u32 start, u32 blkcnt, u8 *buffer, int is_write)
 {
        fsl_sata_t *sata = (fsl_sata_t *)sata_dev_desc[dev].priv;
-       struct sata_fis_h2d h2d;
-       struct cfis *cfis;
+       struct sata_fis_h2d h2d, *cfis = &h2d;
        u64 block;
 
        block = (u64)start;
-       cfis = (struct cfis *)&h2d;
 
-       memset((void *)cfis, 0, sizeof(struct cfis));
+       memset(cfis, 0, sizeof(struct sata_fis_h2d));
 
        cfis->fis_type = SATA_FIS_TYPE_REGISTER_H2D;
        cfis->pm_port_c = 0x80; /* is command */
@@ -673,8 +662,7 @@ static u32 fsl_sata_rw_cmd_ext(int dev, u32 start, u32 blkcnt, u8 *buffer, int i
 u32 fsl_sata_rw_ncq_cmd(int dev, u32 start, u32 blkcnt, u8 *buffer, int is_write)
 {
        fsl_sata_t *sata = (fsl_sata_t *)sata_dev_desc[dev].priv;
-       struct sata_fis_h2d h2d;
-       struct cfis *cfis;
+       struct sata_fis_h2d h2d, *cfis = &h2d;
        int ncq_channel;
        u64 block;
 
@@ -684,9 +672,8 @@ u32 fsl_sata_rw_ncq_cmd(int dev, u32 start, u32 blkcnt, u8 *buffer, int is_write
        }
 
        block = (u64)start;
-       cfis = (struct cfis *)&h2d;
 
-       memset((void *)cfis, 0, sizeof(struct cfis));
+       memset(cfis, 0, sizeof(struct sata_fis_h2d));
 
        cfis->fis_type = SATA_FIS_TYPE_REGISTER_H2D;
        cfis->pm_port_c = 0x80; /* is command */
@@ -718,12 +705,9 @@ u32 fsl_sata_rw_ncq_cmd(int dev, u32 start, u32 blkcnt, u8 *buffer, int is_write
 void fsl_sata_flush_cache_ext(int dev)
 {
        fsl_sata_t *sata = (fsl_sata_t *)sata_dev_desc[dev].priv;
-       struct sata_fis_h2d h2d;
-       struct cfis *cfis;
-
-       cfis = (struct cfis *)&h2d;
+       struct sata_fis_h2d h2d, *cfis = &h2d;
 
-       memset((void *)cfis, 0, sizeof(struct cfis));
+       memset(cfis, 0, sizeof(struct sata_fis_h2d));
 
        cfis->fis_type = SATA_FIS_TYPE_REGISTER_H2D;
        cfis->pm_port_c = 0x80; /* is command */
index 874c0dc..18e88fa 100644 (file)
@@ -289,52 +289,6 @@ typedef struct cmd_desc {
 #define SATA_HC_CMD_DESC_ALIGN         4
 
 /*
-* CFIS - Command FIS, which is H2D register FIS, the struct defination
-* of Non-Queued command is different than NCQ command. see them is sata2.h
-*/
-typedef struct cfis {
-       u8 fis_type;
-       u8 pm_port_c;
-       u8 command;
-       u8 features;
-       u8 lba_low;
-       u8 lba_mid;
-       u8 lba_high;
-       u8 device;
-       u8 lba_low_exp;
-       u8 lba_mid_exp;
-       u8 lba_high_exp;
-       u8 features_exp;
-       u8 sector_count;
-       u8 sector_count_exp;
-       u8 res1;
-       u8 control;
-       u8 res2[4];
-} __attribute__ ((packed)) cfis_t;
-
-/*
-* SFIS - Status FIS, which is D2H register FIS.
-*/
-typedef struct sfis {
-       u8 fis_type;
-       u8 pm_port_i;
-       u8 status;
-       u8 error;
-       u8 lba_low;
-       u8 lba_mid;
-       u8 lba_high;
-       u8 device;
-       u8 lba_low_exp;
-       u8 lba_mid_exp;
-       u8 lba_high_exp;
-       u8 res1;
-       u8 sector_count;
-       u8 sector_count_exp;
-       u8 res2[2];
-       u8 res3[4];
-} __attribute__ ((packed)) sfis_t;
-
-/*
  * SATA device driver info
  */
 typedef struct fsl_sata_info {
diff --git a/drivers/block/sata_dwc.c b/drivers/block/sata_dwc.c
new file mode 100644 (file)
index 0000000..b2b3804
--- /dev/null
@@ -0,0 +1,2110 @@
+/*
+ * sata_dwc.c
+ *
+ * Synopsys DesignWare Cores (DWC) SATA host driver
+ *
+ * Author: Mark Miesfeld <mmiesfeld@amcc.com>
+ *
+ * Ported from 2.6.19.2 to 2.6.25/26 by Stefan Roese <sr@denx.de>
+ * Copyright 2008 DENX Software Engineering
+ *
+ * Based on versions provided by AMCC and Synopsys which are:
+ *          Copyright 2006 Applied Micro Circuits Corporation
+ *          COPYRIGHT (C) 2005  SYNOPSYS, INC.  ALL RIGHTS RESERVED
+ *
+ * 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.
+ *
+ */
+/*
+ * SATA support based on the chip canyonlands.
+ *
+ * 04-17-2009
+ *             The local version of this driver for the canyonlands board
+ *             does not use interrupts but polls the chip instead.
+ */
+
+#include <common.h>
+#include <command.h>
+#include <pci.h>
+#include <asm/processor.h>
+#include <asm/errno.h>
+#include <asm/io.h>
+#include <malloc.h>
+#include <ata.h>
+#include <linux/ctype.h>
+
+#include "sata_dwc.h"
+
+#define DMA_NUM_CHANS                  1
+#define DMA_NUM_CHAN_REGS              8
+
+#define AHB_DMA_BRST_DFLT              16
+
+struct dmareg {
+       u32 low;
+       u32 high;
+};
+
+struct dma_chan_regs {
+       struct dmareg sar;
+       struct dmareg dar;
+       struct dmareg llp;
+       struct dmareg ctl;
+       struct dmareg sstat;
+       struct dmareg dstat;
+       struct dmareg sstatar;
+       struct dmareg dstatar;
+       struct dmareg cfg;
+       struct dmareg sgr;
+       struct dmareg dsr;
+};
+
+struct dma_interrupt_regs {
+       struct dmareg tfr;
+       struct dmareg block;
+       struct dmareg srctran;
+       struct dmareg dsttran;
+       struct dmareg error;
+};
+
+struct ahb_dma_regs {
+       struct dma_chan_regs    chan_regs[DMA_NUM_CHAN_REGS];
+       struct dma_interrupt_regs       interrupt_raw;
+       struct dma_interrupt_regs       interrupt_status;
+       struct dma_interrupt_regs       interrupt_mask;
+       struct dma_interrupt_regs       interrupt_clear;
+       struct dmareg                   statusInt;
+       struct dmareg                   rq_srcreg;
+       struct dmareg                   rq_dstreg;
+       struct dmareg                   rq_sgl_srcreg;
+       struct dmareg                   rq_sgl_dstreg;
+       struct dmareg                   rq_lst_srcreg;
+       struct dmareg                   rq_lst_dstreg;
+       struct dmareg                   dma_cfg;
+       struct dmareg                   dma_chan_en;
+       struct dmareg                   dma_id;
+       struct dmareg                   dma_test;
+       struct dmareg                   res1;
+       struct dmareg                   res2;
+       /* DMA Comp Params
+        * Param 6 = dma_param[0], Param 5 = dma_param[1],
+        * Param 4 = dma_param[2] ...
+        */
+       struct dmareg                   dma_params[6];
+};
+
+#define DMA_EN                 0x00000001
+#define DMA_DI                 0x00000000
+#define DMA_CHANNEL(ch)                (0x00000001 << (ch))
+#define DMA_ENABLE_CHAN(ch)    ((0x00000001 << (ch)) | \
+                               ((0x000000001 << (ch)) << 8))
+#define DMA_DISABLE_CHAN(ch)   (0x00000000 |   \
+                               ((0x000000001 << (ch)) << 8))
+
+#define SATA_DWC_MAX_PORTS     1
+#define SATA_DWC_SCR_OFFSET    0x24
+#define SATA_DWC_REG_OFFSET    0x64
+
+struct sata_dwc_regs {
+       u32 fptagr;
+       u32 fpbor;
+       u32 fptcr;
+       u32 dmacr;
+       u32 dbtsr;
+       u32 intpr;
+       u32 intmr;
+       u32 errmr;
+       u32 llcr;
+       u32 phycr;
+       u32 physr;
+       u32 rxbistpd;
+       u32 rxbistpd1;
+       u32 rxbistpd2;
+       u32 txbistpd;
+       u32 txbistpd1;
+       u32 txbistpd2;
+       u32 bistcr;
+       u32 bistfctr;
+       u32 bistsr;
+       u32 bistdecr;
+       u32 res[15];
+       u32 testr;
+       u32 versionr;
+       u32 idr;
+       u32 unimpl[192];
+       u32 dmadr[256];
+};
+
+#define SATA_DWC_TXFIFO_DEPTH          0x01FF
+#define SATA_DWC_RXFIFO_DEPTH          0x01FF
+
+#define SATA_DWC_DBTSR_MWR(size)       ((size / 4) & SATA_DWC_TXFIFO_DEPTH)
+#define SATA_DWC_DBTSR_MRD(size)       (((size / 4) &  \
+                                       SATA_DWC_RXFIFO_DEPTH) << 16)
+#define SATA_DWC_INTPR_DMAT            0x00000001
+#define SATA_DWC_INTPR_NEWFP           0x00000002
+#define SATA_DWC_INTPR_PMABRT          0x00000004
+#define SATA_DWC_INTPR_ERR             0x00000008
+#define SATA_DWC_INTPR_NEWBIST         0x00000010
+#define SATA_DWC_INTPR_IPF             0x10000000
+#define SATA_DWC_INTMR_DMATM           0x00000001
+#define SATA_DWC_INTMR_NEWFPM          0x00000002
+#define SATA_DWC_INTMR_PMABRTM         0x00000004
+#define SATA_DWC_INTMR_ERRM            0x00000008
+#define SATA_DWC_INTMR_NEWBISTM                0x00000010
+
+#define SATA_DWC_DMACR_TMOD_TXCHEN     0x00000004
+#define SATA_DWC_DMACR_TXRXCH_CLEAR    SATA_DWC_DMACR_TMOD_TXCHEN
+
+#define SATA_DWC_QCMD_MAX      32
+
+#define SATA_DWC_SERROR_ERR_BITS       0x0FFF0F03
+
+#define HSDEVP_FROM_AP(ap)     (struct sata_dwc_device_port*)  \
+                               (ap)->private_data
+
+struct sata_dwc_device {
+       struct device           *dev;
+       struct ata_probe_ent    *pe;
+       struct ata_host         *host;
+       u8                      *reg_base;
+       struct sata_dwc_regs    *sata_dwc_regs;
+       int                     irq_dma;
+};
+
+struct sata_dwc_device_port {
+       struct sata_dwc_device  *hsdev;
+       int                     cmd_issued[SATA_DWC_QCMD_MAX];
+       u32                     dma_chan[SATA_DWC_QCMD_MAX];
+       int                     dma_pending[SATA_DWC_QCMD_MAX];
+};
+
+enum {
+       SATA_DWC_CMD_ISSUED_NOT         = 0,
+       SATA_DWC_CMD_ISSUED_PEND        = 1,
+       SATA_DWC_CMD_ISSUED_EXEC        = 2,
+       SATA_DWC_CMD_ISSUED_NODATA      = 3,
+
+       SATA_DWC_DMA_PENDING_NONE       = 0,
+       SATA_DWC_DMA_PENDING_TX         = 1,
+       SATA_DWC_DMA_PENDING_RX         = 2,
+};
+
+#define msleep(a)      udelay(a * 1000)
+#define ssleep(a)      msleep(a * 1000)
+
+static int ata_probe_timeout = (ATA_TMOUT_INTERNAL / 100);
+
+enum sata_dev_state {
+       SATA_INIT = 0,
+       SATA_READY = 1,
+       SATA_NODEVICE = 2,
+       SATA_ERROR = 3,
+};
+enum sata_dev_state dev_state = SATA_INIT;
+
+static struct ahb_dma_regs             *sata_dma_regs = 0;
+static struct ata_host                 *phost;
+static struct ata_port                 ap;
+static struct ata_port                 *pap = &ap;
+static struct ata_device               ata_device;
+static struct sata_dwc_device_port     dwc_devp;
+
+static void    *scr_addr_sstatus;
+static u32     temp_n_block = 0;
+
+static unsigned ata_exec_internal(struct ata_device *dev,
+                       struct ata_taskfile *tf, const u8 *cdb,
+                       int dma_dir, unsigned int buflen,
+                       unsigned long timeout);
+static unsigned int ata_dev_set_feature(struct ata_device *dev,
+                       u8 enable,u8 feature);
+static unsigned int ata_dev_init_params(struct ata_device *dev,
+                       u16 heads, u16 sectors);
+static u8 ata_irq_on(struct ata_port *ap);
+static struct ata_queued_cmd *__ata_qc_from_tag(struct ata_port *ap,
+                       unsigned int tag);
+static int ata_hsm_move(struct ata_port *ap, struct ata_queued_cmd *qc,
+                       u8 status, int in_wq);
+static void ata_tf_to_host(struct ata_port *ap,
+                       const struct ata_taskfile *tf);
+static void ata_exec_command(struct ata_port *ap,
+                       const struct ata_taskfile *tf);
+static unsigned int ata_qc_issue_prot(struct ata_queued_cmd *qc);
+static u8 ata_check_altstatus(struct ata_port *ap);
+static u8 ata_check_status(struct ata_port *ap);
+static void ata_dev_select(struct ata_port *ap, unsigned int device,
+                       unsigned int wait, unsigned int can_sleep);
+static void ata_qc_issue(struct ata_queued_cmd *qc);
+static void ata_tf_load(struct ata_port *ap,
+                       const struct ata_taskfile *tf);
+static int ata_dev_read_sectors(unsigned char* pdata,
+                       unsigned long datalen, u32 block, u32 n_block);
+static int ata_dev_write_sectors(unsigned char* pdata,
+                       unsigned long datalen , u32 block, u32 n_block);
+static void ata_std_dev_select(struct ata_port *ap, unsigned int device);
+static void ata_qc_complete(struct ata_queued_cmd *qc);
+static void __ata_qc_complete(struct ata_queued_cmd *qc);
+static void fill_result_tf(struct ata_queued_cmd *qc);
+static void ata_tf_read(struct ata_port *ap, struct ata_taskfile *tf);
+static void ata_mmio_data_xfer(struct ata_device *dev,
+                       unsigned char *buf,
+                       unsigned int buflen,int do_write);
+static void ata_pio_task(struct ata_port *arg_ap);
+static void __ata_port_freeze(struct ata_port *ap);
+static int ata_port_freeze(struct ata_port *ap);
+static void ata_qc_free(struct ata_queued_cmd *qc);
+static void ata_pio_sectors(struct ata_queued_cmd *qc);
+static void ata_pio_sector(struct ata_queued_cmd *qc);
+static void ata_pio_queue_task(struct ata_port *ap,
+                       void *data,unsigned long delay);
+static void ata_hsm_qc_complete(struct ata_queued_cmd *qc, int in_wq);
+static int sata_dwc_softreset(struct ata_port *ap);
+static int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class,
+               unsigned int flags, u16 *id);
+static int check_sata_dev_state(void);
+
+extern block_dev_desc_t sata_dev_desc[CONFIG_SYS_SATA_MAX_DEVICE];
+
+static const struct ata_port_info sata_dwc_port_info[] = {
+       {
+               .flags          = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
+                               ATA_FLAG_MMIO | ATA_FLAG_PIO_POLLING |
+                               ATA_FLAG_SRST | ATA_FLAG_NCQ,
+               .pio_mask       = 0x1f,
+               .mwdma_mask     = 0x07,
+               .udma_mask      = 0x7f,
+       },
+};
+
+int init_sata(int dev)
+{
+       struct sata_dwc_device hsdev;
+       struct ata_host host;
+       struct ata_port_info pi = sata_dwc_port_info[0];
+       struct ata_link *link;
+       struct sata_dwc_device_port hsdevp = dwc_devp;
+       u8 *base = 0;
+       u8 *sata_dma_regs_addr = 0;
+       u8 status;
+       unsigned long base_addr = 0;
+       int chan = 0;
+       int rc;
+       int i;
+
+       phost = &host;
+
+       base = (u8*)SATA_BASE_ADDR;
+
+       hsdev.sata_dwc_regs = (void *__iomem)(base + SATA_DWC_REG_OFFSET);
+
+       host.n_ports = SATA_DWC_MAX_PORTS;
+
+       for (i = 0; i < SATA_DWC_MAX_PORTS; i++) {
+               ap.pflags |= ATA_PFLAG_INITIALIZING;
+               ap.flags = ATA_FLAG_DISABLED;
+               ap.print_id = -1;
+               ap.ctl = ATA_DEVCTL_OBS;
+               ap.host = &host;
+               ap.last_ctl = 0xFF;
+
+               link = &ap.link;
+               link->ap = &ap;
+               link->pmp = 0;
+               link->active_tag = ATA_TAG_POISON;
+               link->hw_sata_spd_limit = 0;
+
+               ap.port_no = i;
+               host.ports[i] = &ap;
+       }
+
+       ap.pio_mask = pi.pio_mask;
+       ap.mwdma_mask = pi.mwdma_mask;
+       ap.udma_mask = pi.udma_mask;
+       ap.flags |= pi.flags;
+       ap.link.flags |= pi.link_flags;
+
+       host.ports[0]->ioaddr.cmd_addr = base;
+       host.ports[0]->ioaddr.scr_addr = base + SATA_DWC_SCR_OFFSET;
+       scr_addr_sstatus = base + SATA_DWC_SCR_OFFSET;
+
+       base_addr = (unsigned long)base;
+
+       host.ports[0]->ioaddr.cmd_addr = (void *)base_addr + 0x00;
+       host.ports[0]->ioaddr.data_addr = (void *)base_addr + 0x00;
+
+       host.ports[0]->ioaddr.error_addr = (void *)base_addr + 0x04;
+       host.ports[0]->ioaddr.feature_addr = (void *)base_addr + 0x04;
+
+       host.ports[0]->ioaddr.nsect_addr = (void *)base_addr + 0x08;
+
+       host.ports[0]->ioaddr.lbal_addr = (void *)base_addr + 0x0c;
+       host.ports[0]->ioaddr.lbam_addr = (void *)base_addr + 0x10;
+       host.ports[0]->ioaddr.lbah_addr = (void *)base_addr + 0x14;
+
+       host.ports[0]->ioaddr.device_addr = (void *)base_addr + 0x18;
+       host.ports[0]->ioaddr.command_addr = (void *)base_addr + 0x1c;
+       host.ports[0]->ioaddr.status_addr = (void *)base_addr + 0x1c;
+
+       host.ports[0]->ioaddr.altstatus_addr = (void *)base_addr + 0x20;
+       host.ports[0]->ioaddr.ctl_addr = (void *)base_addr + 0x20;
+
+       sata_dma_regs_addr = (u8*)SATA_DMA_REG_ADDR;
+       sata_dma_regs = (void *__iomem)sata_dma_regs_addr;
+
+       status = ata_check_altstatus(&ap);
+
+       if (status == 0x7f) {
+               printf("Hard Disk not found.\n");
+               dev_state = SATA_NODEVICE;
+               rc = FALSE;
+               return rc;
+       }
+
+       printf("Waiting for device...");
+       i = 0;
+       while (1) {
+               udelay(10000);
+
+               status = ata_check_altstatus(&ap);
+
+               if ((status & ATA_BUSY) == 0) {
+                       printf("\n");
+                       break;
+               }
+
+               i++;
+               if (i > (ATA_RESET_TIME * 100)) {
+                       printf("** TimeOUT **\n");
+
+                       dev_state = SATA_NODEVICE;
+                       rc = FALSE;
+                       return rc;
+               }
+               if ((i >= 100) && ((i % 100) == 0))
+                       printf(".");
+       }
+
+       rc = sata_dwc_softreset(&ap);
+
+       if (rc) {
+               printf("sata_dwc : error. soft reset failed\n");
+               return rc;
+       }
+
+       for (chan = 0; chan < DMA_NUM_CHANS; chan++) {
+               out_le32(&(sata_dma_regs->interrupt_mask.error.low),
+                               DMA_DISABLE_CHAN(chan));
+
+               out_le32(&(sata_dma_regs->interrupt_mask.tfr.low),
+                               DMA_DISABLE_CHAN(chan));
+       }
+
+       out_le32(&(sata_dma_regs->dma_cfg.low), DMA_DI);
+
+       out_le32(&hsdev.sata_dwc_regs->intmr,
+               SATA_DWC_INTMR_ERRM |
+               SATA_DWC_INTMR_PMABRTM);
+
+       /* Unmask the error bits that should trigger
+        * an error interrupt by setting the error mask register.
+        */
+       out_le32(&hsdev.sata_dwc_regs->errmr, SATA_DWC_SERROR_ERR_BITS);
+
+       hsdev.host = ap.host;
+       memset(&hsdevp, 0, sizeof(hsdevp));
+       hsdevp.hsdev = &hsdev;
+
+       for (i = 0; i < SATA_DWC_QCMD_MAX; i++)
+               hsdevp.cmd_issued[i] = SATA_DWC_CMD_ISSUED_NOT;
+
+       out_le32((void __iomem *)scr_addr_sstatus + 4,
+               in_le32((void __iomem *)scr_addr_sstatus + 4));
+
+       rc = 0;
+       return rc;
+}
+
+static u8 ata_check_altstatus(struct ata_port *ap)
+{
+       u8 val = 0;
+       val = readb(ap->ioaddr.altstatus_addr);
+       return val;
+}
+
+static int sata_dwc_softreset(struct ata_port *ap)
+{
+       u8 nsect,lbal = 0;
+       u8 tmp = 0;
+       u32 serror = 0;
+       u8 status = 0;
+       struct ata_ioports *ioaddr = &ap->ioaddr;
+
+       serror = in_le32((void *)ap->ioaddr.scr_addr + (SCR_ERROR * 4));
+
+       writeb(0x55, ioaddr->nsect_addr);
+       writeb(0xaa, ioaddr->lbal_addr);
+       writeb(0xaa, ioaddr->nsect_addr);
+       writeb(0x55, ioaddr->lbal_addr);
+       writeb(0x55, ioaddr->nsect_addr);
+       writeb(0xaa, ioaddr->lbal_addr);
+
+       nsect = readb(ioaddr->nsect_addr);
+       lbal = readb(ioaddr->lbal_addr);
+
+       if ((nsect == 0x55) && (lbal == 0xaa)) {
+               printf("Device found\n");
+       } else {
+               printf("No device found\n");
+               dev_state = SATA_NODEVICE;
+               return FALSE;
+       }
+
+       tmp = ATA_DEVICE_OBS;
+       writeb(tmp, ioaddr->device_addr);
+       writeb(ap->ctl, ioaddr->ctl_addr);
+
+       udelay(200);
+
+       writeb(ap->ctl | ATA_SRST, ioaddr->ctl_addr);
+
+       udelay(200);
+       writeb(ap->ctl, ioaddr->ctl_addr);
+
+       msleep(150);
+       status = ata_check_status(ap);
+
+       msleep(50);
+       ata_check_status(ap);
+
+       while (1) {
+               u8 status = ata_check_status(ap);
+
+               if (!(status & ATA_BUSY))
+                       break;
+
+               printf("Hard Disk status is BUSY.\n");
+               msleep(50);
+       }
+
+       tmp = ATA_DEVICE_OBS;
+       writeb(tmp, ioaddr->device_addr);
+
+       nsect = readb(ioaddr->nsect_addr);
+       lbal = readb(ioaddr->lbal_addr);
+
+       return 0;
+}
+
+static u8 ata_check_status(struct ata_port *ap)
+{
+       u8 val = 0;
+       val = readb(ap->ioaddr.status_addr);
+       return val;
+}
+
+static int ata_id_has_hipm(const u16 *id)
+{
+       u16 val = id[76];
+
+       if (val == 0 || val == 0xffff)
+               return -1;
+
+       return val & (1 << 9);
+}
+
+static int ata_id_has_dipm(const u16 *id)
+{
+       u16 val = id[78];
+
+       if (val == 0 || val == 0xffff)
+               return -1;
+
+       return val & (1 << 3);
+}
+
+int scan_sata(int dev)
+{
+       int i;
+       int rc;
+       u8 status;
+       const u16 *id;
+       struct ata_device *ata_dev = &ata_device;
+       unsigned long pio_mask, mwdma_mask, udma_mask;
+       unsigned long xfer_mask;
+       char revbuf[7];
+       u16 iobuf[ATA_SECTOR_WORDS];
+
+       memset(iobuf, 0, sizeof(iobuf));
+
+       if (dev_state == SATA_NODEVICE)
+               return 1;
+
+       printf("Waiting for device...");
+       i = 0;
+       while (1) {
+               udelay(10000);
+
+               status = ata_check_altstatus(&ap);
+
+               if ((status & ATA_BUSY) == 0) {
+                       printf("\n");
+                       break;
+               }
+
+               i++;
+               if (i > (ATA_RESET_TIME * 100)) {
+                       printf("** TimeOUT **\n");
+
+                       dev_state = SATA_NODEVICE;
+                       return 1;
+               }
+               if ((i >= 100) && ((i % 100) == 0))
+                       printf(".");
+       }
+
+       udelay(1000);
+
+       rc = ata_dev_read_id(ata_dev, &ata_dev->class,
+                       ATA_READID_POSTRESET,ata_dev->id);
+       if (rc) {
+               printf("sata_dwc : error. failed sata scan\n");
+               return 1;
+       }
+
+       /* SATA drives indicate we have a bridge. We don't know which
+        * end of the link the bridge is which is a problem
+        */
+       if (ata_id_is_sata(ata_dev->id))
+               ap.cbl = ATA_CBL_SATA;
+
+       id = ata_dev->id;
+
+       ata_dev->flags &= ~ATA_DFLAG_CFG_MASK;
+       ata_dev->max_sectors = 0;
+       ata_dev->cdb_len = 0;
+       ata_dev->n_sectors = 0;
+       ata_dev->cylinders = 0;
+       ata_dev->heads = 0;
+       ata_dev->sectors = 0;
+
+       if (id[ATA_ID_FIELD_VALID] & (1 << 1)) {
+               pio_mask = id[ATA_ID_PIO_MODES] & 0x03;
+               pio_mask <<= 3;
+               pio_mask |= 0x7;
+       } else {
+               /* If word 64 isn't valid then Word 51 high byte holds
+                * the PIO timing number for the maximum. Turn it into
+                * a mask.
+                */
+               u8 mode = (id[ATA_ID_OLD_PIO_MODES] >> 8) & 0xFF;
+               if (mode < 5) {
+                       pio_mask = (2 << mode) - 1;
+               } else {
+                       pio_mask = 1;
+               }
+       }
+
+       mwdma_mask = id[ATA_ID_MWDMA_MODES] & 0x07;
+
+       if (ata_id_is_cfa(id)) {
+               int pio = id[163] & 0x7;
+               int dma = (id[163] >> 3) & 7;
+
+               if (pio)
+                       pio_mask |= (1 << 5);
+               if (pio > 1)
+                       pio_mask |= (1 << 6);
+               if (dma)
+                       mwdma_mask |= (1 << 3);
+               if (dma > 1)
+                       mwdma_mask |= (1 << 4);
+       }
+
+       udma_mask = 0;
+       if (id[ATA_ID_FIELD_VALID] & (1 << 2))
+               udma_mask = id[ATA_ID_UDMA_MODES] & 0xff;
+
+       xfer_mask = ((pio_mask << ATA_SHIFT_PIO) & ATA_MASK_PIO) |
+               ((mwdma_mask << ATA_SHIFT_MWDMA) & ATA_MASK_MWDMA) |
+               ((udma_mask << ATA_SHIFT_UDMA) & ATA_MASK_UDMA);
+
+       if (ata_dev->class == ATA_DEV_ATA) {
+               if (ata_id_is_cfa(id)) {
+                       if (id[162] & 1)
+                               printf("supports DRM functions and may "
+                                       "not be fully accessable.\n");
+                       sprintf(revbuf, "%s", "CFA");
+               } else {
+                       if (ata_id_has_tpm(id))
+                               printf("supports DRM functions and may "
+                                               "not be fully accessable.\n");
+               }
+
+               ata_dev->n_sectors = ata_id_n_sectors((u16*)id);
+
+               if (ata_dev->id[59] & 0x100)
+                       ata_dev->multi_count = ata_dev->id[59] & 0xff;
+
+               if (ata_id_has_lba(id)) {
+                       const char *lba_desc;
+                       char ncq_desc[20];
+
+                       lba_desc = "LBA";
+                       ata_dev->flags |= ATA_DFLAG_LBA;
+                       if (ata_id_has_lba48(id)) {
+                               ata_dev->flags |= ATA_DFLAG_LBA48;
+                               lba_desc = "LBA48";
+
+                               if (ata_dev->n_sectors >= (1UL << 28) &&
+                                       ata_id_has_flush_ext(id))
+                                       ata_dev->flags |= ATA_DFLAG_FLUSH_EXT;
+                       }
+                       if (!ata_id_has_ncq(ata_dev->id))
+                               ncq_desc[0] = '\0';
+
+                       if (ata_dev->horkage & ATA_HORKAGE_NONCQ)
+                               sprintf(ncq_desc, "%s", "NCQ (not used)");
+
+                       if (ap.flags & ATA_FLAG_NCQ)
+                               ata_dev->flags |= ATA_DFLAG_NCQ;
+               }
+               ata_dev->cdb_len = 16;
+       }
+       ata_dev->max_sectors = ATA_MAX_SECTORS;
+       if (ata_dev->flags & ATA_DFLAG_LBA48)
+               ata_dev->max_sectors = ATA_MAX_SECTORS_LBA48;
+
+       if (!(ata_dev->horkage & ATA_HORKAGE_IPM)) {
+               if (ata_id_has_hipm(ata_dev->id))
+                       ata_dev->flags |= ATA_DFLAG_HIPM;
+               if (ata_id_has_dipm(ata_dev->id))
+                       ata_dev->flags |= ATA_DFLAG_DIPM;
+       }
+
+       if ((ap.cbl == ATA_CBL_SATA) && (!ata_id_is_sata(ata_dev->id))) {
+               ata_dev->udma_mask &= ATA_UDMA5;
+               ata_dev->max_sectors = ATA_MAX_SECTORS;
+       }
+
+       if (ata_dev->horkage & ATA_HORKAGE_DIAGNOSTIC) {
+               printf("Drive reports diagnostics failure."
+                               "This may indicate a drive\n");
+               printf("fault or invalid emulation."
+                               "Contact drive vendor for information.\n");
+       }
+
+       rc = check_sata_dev_state();
+
+       ata_id_c_string(ata_dev->id,
+                       (unsigned char *)sata_dev_desc[dev].revision,
+                        ATA_ID_FW_REV, sizeof(sata_dev_desc[dev].revision));
+       ata_id_c_string(ata_dev->id,
+                       (unsigned char *)sata_dev_desc[dev].vendor,
+                        ATA_ID_PROD, sizeof(sata_dev_desc[dev].vendor));
+       ata_id_c_string(ata_dev->id,
+                       (unsigned char *)sata_dev_desc[dev].product,
+                        ATA_ID_SERNO, sizeof(sata_dev_desc[dev].product));
+
+       sata_dev_desc[dev].lba = (u32) ata_dev->n_sectors;
+
+#ifdef CONFIG_LBA48
+       if (ata_dev->id[83] & (1 << 10)) {
+               sata_dev_desc[dev].lba48 = 1;
+       } else {
+               sata_dev_desc[dev].lba48 = 0;
+       }
+#endif
+
+       return 0;
+}
+
+static u8 ata_busy_wait(struct ata_port *ap,
+               unsigned int bits,unsigned int max)
+{
+       u8 status;
+
+       do {
+               udelay(10);
+               status = ata_check_status(ap);
+               max--;
+       } while (status != 0xff && (status & bits) && (max > 0));
+
+       return status;
+}
+
+static int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class,
+               unsigned int flags, u16 *id)
+{
+       struct ata_port *ap = pap;
+       unsigned int class = *p_class;
+       struct ata_taskfile tf;
+       unsigned int err_mask = 0;
+       const char *reason;
+       int may_fallback = 1, tried_spinup = 0;
+       u8 status;
+       int rc;
+
+       status = ata_busy_wait(ap, ATA_BUSY, 30000);
+       if (status & ATA_BUSY) {
+               printf("BSY = 0 check. timeout.\n");
+               rc = FALSE;
+               return rc;
+       }
+
+       ata_dev_select(ap, dev->devno, 1, 1);
+
+retry:
+       memset(&tf, 0, sizeof(tf));
+       ap->print_id = 1;
+       ap->flags &= ~ATA_FLAG_DISABLED;
+       tf.ctl = ap->ctl;
+       tf.device = ATA_DEVICE_OBS;
+       tf.command = ATA_CMD_ID_ATA;
+       tf.protocol = ATA_PROT_PIO;
+
+       /* Some devices choke if TF registers contain garbage.  Make
+        * sure those are properly initialized.
+        */
+       tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE;
+
+       /* Device presence detection is unreliable on some
+        * controllers.  Always poll IDENTIFY if available.
+        */
+       tf.flags |= ATA_TFLAG_POLLING;
+
+       temp_n_block = 1;
+
+       err_mask = ata_exec_internal(dev, &tf, NULL, DMA_FROM_DEVICE,
+                                       sizeof(id[0]) * ATA_ID_WORDS, 0);
+
+       if (err_mask) {
+               if (err_mask & AC_ERR_NODEV_HINT) {
+                       printf("NODEV after polling detection\n");
+                       return -ENOENT;
+               }
+
+               if ((err_mask == AC_ERR_DEV) && (tf.feature & ATA_ABORTED)) {
+                       /* Device or controller might have reported
+                        * the wrong device class.  Give a shot at the
+                        * other IDENTIFY if the current one is
+                        * aborted by the device.
+                        */
+                       if (may_fallback) {
+                               may_fallback = 0;
+
+                               if (class == ATA_DEV_ATA) {
+                                       class = ATA_DEV_ATAPI;
+                               } else {
+                                       class = ATA_DEV_ATA;
+                               }
+                               goto retry;
+                       }
+                       /* Control reaches here iff the device aborted
+                        * both flavors of IDENTIFYs which happens
+                        * sometimes with phantom devices.
+                        */
+                       printf("both IDENTIFYs aborted, assuming NODEV\n");
+                       return -ENOENT;
+               }
+               rc = -EIO;
+               reason = "I/O error";
+               goto err_out;
+       }
+
+       /* Falling back doesn't make sense if ID data was read
+        * successfully at least once.
+        */
+       may_fallback = 0;
+
+       unsigned int id_cnt;
+
+       for (id_cnt = 0; id_cnt < ATA_ID_WORDS; id_cnt++)
+               id[id_cnt] = le16_to_cpu(id[id_cnt]);
+
+
+       rc = -EINVAL;
+       reason = "device reports invalid type";
+
+       if (class == ATA_DEV_ATA) {
+               if (!ata_id_is_ata(id) && !ata_id_is_cfa(id))
+                       goto err_out;
+       } else {
+               if (ata_id_is_ata(id))
+                       goto err_out;
+       }
+       if (!tried_spinup && (id[2] == 0x37c8 || id[2] == 0x738c)) {
+               tried_spinup = 1;
+               /*
+                * Drive powered-up in standby mode, and requires a specific
+                * SET_FEATURES spin-up subcommand before it will accept
+                * anything other than the original IDENTIFY command.
+                */
+               err_mask = ata_dev_set_feature(dev, SETFEATURES_SPINUP, 0);
+               if (err_mask && id[2] != 0x738c) {
+                       rc = -EIO;
+                       reason = "SPINUP failed";
+                       goto err_out;
+               }
+               /*
+                * If the drive initially returned incomplete IDENTIFY info,
+                * we now must reissue the IDENTIFY command.
+                */
+               if (id[2] == 0x37c8)
+                       goto retry;
+       }
+
+       if ((flags & ATA_READID_POSTRESET) && class == ATA_DEV_ATA) {
+               /*
+                * The exact sequence expected by certain pre-ATA4 drives is:
+                * SRST RESET
+                * IDENTIFY (optional in early ATA)
+                * INITIALIZE DEVICE PARAMETERS (later IDE and ATA)
+                * anything else..
+                * Some drives were very specific about that exact sequence.
+                *
+                * Note that ATA4 says lba is mandatory so the second check
+                * shoud never trigger.
+                */
+               if (ata_id_major_version(id) < 4 || !ata_id_has_lba(id)) {
+                       err_mask = ata_dev_init_params(dev, id[3], id[6]);
+                       if (err_mask) {
+                               rc = -EIO;
+                               reason = "INIT_DEV_PARAMS failed";
+                               goto err_out;
+                       }
+
+                       /* current CHS translation info (id[53-58]) might be
+                        * changed. reread the identify device info.
+                        */
+                       flags &= ~ATA_READID_POSTRESET;
+                       goto retry;
+               }
+       }
+
+       *p_class = class;
+       return 0;
+
+err_out:
+       return rc;
+}
+
+static u8 ata_wait_idle(struct ata_port *ap)
+{
+       u8 status = ata_busy_wait(ap, ATA_BUSY | ATA_DRQ, 1000);
+       return status;
+}
+
+static void ata_dev_select(struct ata_port *ap, unsigned int device,
+               unsigned int wait, unsigned int can_sleep)
+{
+       if (wait)
+               ata_wait_idle(ap);
+
+       ata_std_dev_select(ap, device);
+
+       if (wait)
+               ata_wait_idle(ap);
+}
+
+static void ata_std_dev_select(struct ata_port *ap, unsigned int device)
+{
+       u8 tmp;
+
+       if (device == 0) {
+               tmp = ATA_DEVICE_OBS;
+       } else {
+               tmp = ATA_DEVICE_OBS | ATA_DEV1;
+       }
+
+       writeb(tmp, ap->ioaddr.device_addr);
+
+       readb(ap->ioaddr.altstatus_addr);
+
+       udelay(1);
+}
+
+static int waiting_for_reg_state(volatile u8 *offset,
+                               int timeout_msec,
+                               u32 sign)
+{
+       int i;
+       u32 status;
+
+       for (i = 0; i < timeout_msec; i++) {
+               status = readl(offset);
+               if ((status & sign) != 0)
+                       break;
+               msleep(1);
+       }
+
+       return (i < timeout_msec) ? 0 : -1;
+}
+
+static void ata_qc_reinit(struct ata_queued_cmd *qc)
+{
+       qc->dma_dir = DMA_NONE;
+       qc->flags = 0;
+       qc->nbytes = qc->extrabytes = qc->curbytes = 0;
+       qc->n_elem = 0;
+       qc->err_mask = 0;
+       qc->sect_size = ATA_SECT_SIZE;
+       qc->nbytes = ATA_SECT_SIZE * temp_n_block;
+
+       memset(&qc->tf, 0, sizeof(qc->tf));
+       qc->tf.ctl = 0;
+       qc->tf.device = ATA_DEVICE_OBS;
+
+       qc->result_tf.command = ATA_DRDY;
+       qc->result_tf.feature = 0;
+}
+
+struct ata_queued_cmd *__ata_qc_from_tag(struct ata_port *ap,
+                                       unsigned int tag)
+{
+       if (tag < ATA_MAX_QUEUE)
+               return &ap->qcmd[tag];
+       return NULL;
+}
+
+static void __ata_port_freeze(struct ata_port *ap)
+{
+       printf("set port freeze.\n");
+       ap->pflags |= ATA_PFLAG_FROZEN;
+}
+
+static int ata_port_freeze(struct ata_port *ap)
+{
+       __ata_port_freeze(ap);
+       return 0;
+}
+
+unsigned ata_exec_internal(struct ata_device *dev,
+                       struct ata_taskfile *tf, const u8 *cdb,
+                       int dma_dir, unsigned int buflen,
+                       unsigned long timeout)
+{
+       struct ata_link *link = dev->link;
+       struct ata_port *ap = pap;
+       struct ata_queued_cmd *qc;
+       unsigned int tag, preempted_tag;
+       u32 preempted_sactive, preempted_qc_active;
+       int preempted_nr_active_links;
+       unsigned int err_mask;
+       int rc = 0;
+       u8 status;
+
+       status = ata_busy_wait(ap, ATA_BUSY, 300000);
+       if (status & ATA_BUSY) {
+               printf("BSY = 0 check. timeout.\n");
+               rc = FALSE;
+               return rc;
+       }
+
+       if (ap->pflags & ATA_PFLAG_FROZEN)
+               return AC_ERR_SYSTEM;
+
+       tag = ATA_TAG_INTERNAL;
+
+       if (test_and_set_bit(tag, &ap->qc_allocated)) {
+               rc = FALSE;
+               return rc;
+       }
+
+       qc = __ata_qc_from_tag(ap, tag);
+       qc->tag = tag;
+       qc->ap = ap;
+       qc->dev = dev;
+
+       ata_qc_reinit(qc);
+
+       preempted_tag = link->active_tag;
+       preempted_sactive = link->sactive;
+       preempted_qc_active = ap->qc_active;
+       preempted_nr_active_links = ap->nr_active_links;
+       link->active_tag = ATA_TAG_POISON;
+       link->sactive = 0;
+       ap->qc_active = 0;
+       ap->nr_active_links = 0;
+
+       qc->tf = *tf;
+       if (cdb)
+               memcpy(qc->cdb, cdb, ATAPI_CDB_LEN);
+       qc->flags |= ATA_QCFLAG_RESULT_TF;
+       qc->dma_dir = dma_dir;
+       qc->private_data = 0;
+
+       ata_qc_issue(qc);
+
+       if (!timeout)
+               timeout = ata_probe_timeout * 1000 / HZ;
+
+       status = ata_busy_wait(ap, ATA_BUSY, 30000);
+       if (status & ATA_BUSY) {
+               printf("BSY = 0 check. timeout.\n");
+               printf("altstatus = 0x%x.\n", status);
+               qc->err_mask |= AC_ERR_OTHER;
+               return qc->err_mask;
+       }
+
+       if (waiting_for_reg_state(ap->ioaddr.altstatus_addr, 1000, 0x8)) {
+               u8 status = 0;
+               u8 errorStatus = 0;
+
+               status = readb(ap->ioaddr.altstatus_addr);
+               if ((status & 0x01) != 0) {
+                       errorStatus = readb(ap->ioaddr.feature_addr);
+                       if (errorStatus == 0x04 &&
+                               qc->tf.command == ATA_CMD_PIO_READ_EXT){
+                               printf("Hard Disk doesn't support LBA48\n");
+                               dev_state = SATA_ERROR;
+                               qc->err_mask |= AC_ERR_OTHER;
+                               return qc->err_mask;
+                       }
+               }
+               qc->err_mask |= AC_ERR_OTHER;
+               return qc->err_mask;
+       }
+
+       status = ata_busy_wait(ap, ATA_BUSY, 10);
+       if (status & ATA_BUSY) {
+               printf("BSY = 0 check. timeout.\n");
+               qc->err_mask |= AC_ERR_OTHER;
+               return qc->err_mask;
+       }
+
+       ata_pio_task(ap);
+
+       if (!rc) {
+               if (qc->flags & ATA_QCFLAG_ACTIVE) {
+                       qc->err_mask |= AC_ERR_TIMEOUT;
+                       ata_port_freeze(ap);
+               }
+       }
+
+       if (qc->flags & ATA_QCFLAG_FAILED) {
+               if (qc->result_tf.command & (ATA_ERR | ATA_DF))
+                       qc->err_mask |= AC_ERR_DEV;
+
+               if (!qc->err_mask)
+                       qc->err_mask |= AC_ERR_OTHER;
+
+               if (qc->err_mask & ~AC_ERR_OTHER)
+                       qc->err_mask &= ~AC_ERR_OTHER;
+       }
+
+       *tf = qc->result_tf;
+       err_mask = qc->err_mask;
+       ata_qc_free(qc);
+       link->active_tag = preempted_tag;
+       link->sactive = preempted_sactive;
+       ap->qc_active = preempted_qc_active;
+       ap->nr_active_links = preempted_nr_active_links;
+
+       if (ap->flags & ATA_FLAG_DISABLED) {
+               err_mask |= AC_ERR_SYSTEM;
+               ap->flags &= ~ATA_FLAG_DISABLED;
+       }
+
+       return err_mask;
+}
+
+static void ata_qc_issue(struct ata_queued_cmd *qc)
+{
+       struct ata_port *ap = qc->ap;
+       struct ata_link *link = qc->dev->link;
+       u8 prot = qc->tf.protocol;
+
+       if (ata_is_ncq(prot)) {
+               if (!link->sactive)
+                       ap->nr_active_links++;
+               link->sactive |= 1 << qc->tag;
+       } else {
+               ap->nr_active_links++;
+               link->active_tag = qc->tag;
+       }
+
+       qc->flags |= ATA_QCFLAG_ACTIVE;
+       ap->qc_active |= 1 << qc->tag;
+
+       if (qc->dev->flags & ATA_DFLAG_SLEEPING) {
+               msleep(1);
+               return;
+       }
+
+       qc->err_mask |= ata_qc_issue_prot(qc);
+       if (qc->err_mask)
+               goto err;
+
+       return;
+err:
+       ata_qc_complete(qc);
+}
+
+static unsigned int ata_qc_issue_prot(struct ata_queued_cmd *qc)
+{
+       struct ata_port *ap = qc->ap;
+
+       if (ap->flags & ATA_FLAG_PIO_POLLING) {
+               switch (qc->tf.protocol) {
+               case ATA_PROT_PIO:
+               case ATA_PROT_NODATA:
+               case ATAPI_PROT_PIO:
+               case ATAPI_PROT_NODATA:
+                       qc->tf.flags |= ATA_TFLAG_POLLING;
+                       break;
+               default:
+                       break;
+               }
+       }
+
+       ata_dev_select(ap, qc->dev->devno, 1, 0);
+
+       switch (qc->tf.protocol) {
+       case ATA_PROT_PIO:
+               if (qc->tf.flags & ATA_TFLAG_POLLING)
+                       qc->tf.ctl |= ATA_NIEN;
+
+               ata_tf_to_host(ap, &qc->tf);
+
+               ap->hsm_task_state = HSM_ST;
+
+               if (qc->tf.flags & ATA_TFLAG_POLLING)
+                       ata_pio_queue_task(ap, qc, 0);
+
+               break;
+
+       default:
+               return AC_ERR_SYSTEM;
+       }
+
+       return 0;
+}
+
+static void ata_tf_to_host(struct ata_port *ap,
+                       const struct ata_taskfile *tf)
+{
+       ata_tf_load(ap, tf);
+       ata_exec_command(ap, tf);
+}
+
+static void ata_tf_load(struct ata_port *ap,
+                       const struct ata_taskfile *tf)
+{
+       struct ata_ioports *ioaddr = &ap->ioaddr;
+       unsigned int is_addr = tf->flags & ATA_TFLAG_ISADDR;
+
+       if (tf->ctl != ap->last_ctl) {
+               if (ioaddr->ctl_addr)
+                       writeb(tf->ctl, ioaddr->ctl_addr);
+               ap->last_ctl = tf->ctl;
+               ata_wait_idle(ap);
+       }
+
+       if (is_addr && (tf->flags & ATA_TFLAG_LBA48)) {
+               writeb(tf->hob_feature, ioaddr->feature_addr);
+               writeb(tf->hob_nsect, ioaddr->nsect_addr);
+               writeb(tf->hob_lbal, ioaddr->lbal_addr);
+               writeb(tf->hob_lbam, ioaddr->lbam_addr);
+               writeb(tf->hob_lbah, ioaddr->lbah_addr);
+       }
+
+       if (is_addr) {
+               writeb(tf->feature, ioaddr->feature_addr);
+               writeb(tf->nsect, ioaddr->nsect_addr);
+               writeb(tf->lbal, ioaddr->lbal_addr);
+               writeb(tf->lbam, ioaddr->lbam_addr);
+               writeb(tf->lbah, ioaddr->lbah_addr);
+       }
+
+       if (tf->flags & ATA_TFLAG_DEVICE)
+               writeb(tf->device, ioaddr->device_addr);
+
+       ata_wait_idle(ap);
+}
+
+static void ata_exec_command(struct ata_port *ap,
+                       const struct ata_taskfile *tf)
+{
+       writeb(tf->command, ap->ioaddr.command_addr);
+
+       readb(ap->ioaddr.altstatus_addr);
+
+       udelay(1);
+}
+
+static void ata_pio_queue_task(struct ata_port *ap,
+                       void *data,unsigned long delay)
+{
+       ap->port_task_data = data;
+}
+
+static unsigned int ac_err_mask(u8 status)
+{
+       if (status & (ATA_BUSY | ATA_DRQ))
+               return AC_ERR_HSM;
+       if (status & (ATA_ERR | ATA_DF))
+               return AC_ERR_DEV;
+       return 0;
+}
+
+static unsigned int __ac_err_mask(u8 status)
+{
+       unsigned int mask = ac_err_mask(status);
+       if (mask == 0)
+               return AC_ERR_OTHER;
+       return mask;
+}
+
+static void ata_pio_task(struct ata_port *arg_ap)
+{
+       struct ata_port *ap = arg_ap;
+       struct ata_queued_cmd *qc = ap->port_task_data;
+       u8 status;
+       int poll_next;
+
+fsm_start:
+       /*
+        * This is purely heuristic.  This is a fast path.
+        * Sometimes when we enter, BSY will be cleared in
+        * a chk-status or two.  If not, the drive is probably seeking
+        * or something.  Snooze for a couple msecs, then
+        * chk-status again.  If still busy, queue delayed work.
+        */
+       status = ata_busy_wait(ap, ATA_BUSY, 5);
+       if (status & ATA_BUSY) {
+               msleep(2);
+               status = ata_busy_wait(ap, ATA_BUSY, 10);
+               if (status & ATA_BUSY) {
+                       ata_pio_queue_task(ap, qc, ATA_SHORT_PAUSE);
+                       return;
+               }
+       }
+
+       poll_next = ata_hsm_move(ap, qc, status, 1);
+
+       /* another command or interrupt handler
+        * may be running at this point.
+        */
+       if (poll_next)
+               goto fsm_start;
+}
+
+static int ata_hsm_move(struct ata_port *ap, struct ata_queued_cmd *qc,
+                       u8 status, int in_wq)
+{
+       int poll_next;
+
+fsm_start:
+       switch (ap->hsm_task_state) {
+       case HSM_ST_FIRST:
+               poll_next = (qc->tf.flags & ATA_TFLAG_POLLING);
+
+               if ((status & ATA_DRQ) == 0) {
+                       if (status & (ATA_ERR | ATA_DF)) {
+                               qc->err_mask |= AC_ERR_DEV;
+                       } else {
+                               qc->err_mask |= AC_ERR_HSM;
+                       }
+                       ap->hsm_task_state = HSM_ST_ERR;
+                       goto fsm_start;
+               }
+
+               /* Device should not ask for data transfer (DRQ=1)
+                * when it finds something wrong.
+                * We ignore DRQ here and stop the HSM by
+                * changing hsm_task_state to HSM_ST_ERR and
+                * let the EH abort the command or reset the device.
+                */
+               if (status & (ATA_ERR | ATA_DF)) {
+                       if (!(qc->dev->horkage & ATA_HORKAGE_STUCK_ERR)) {
+                               printf("DRQ=1 with device error, "
+                                       "dev_stat 0x%X\n", status);
+                               qc->err_mask |= AC_ERR_HSM;
+                               ap->hsm_task_state = HSM_ST_ERR;
+                               goto fsm_start;
+                       }
+               }
+
+               if (qc->tf.protocol == ATA_PROT_PIO) {
+                       /* PIO data out protocol.
+                        * send first data block.
+                        */
+                       /* ata_pio_sectors() might change the state
+                        * to HSM_ST_LAST. so, the state is changed here
+                        * before ata_pio_sectors().
+                        */
+                       ap->hsm_task_state = HSM_ST;
+                       ata_pio_sectors(qc);
+               } else {
+                       printf("protocol is not ATA_PROT_PIO \n");
+               }
+               break;
+
+       case HSM_ST:
+               if ((status & ATA_DRQ) == 0) {
+                       if (status & (ATA_ERR | ATA_DF)) {
+                               qc->err_mask |= AC_ERR_DEV;
+                       } else {
+                               /* HSM violation. Let EH handle this.
+                                * Phantom devices also trigger this
+                                * condition.  Mark hint.
+                                */
+                               qc->err_mask |= AC_ERR_HSM | AC_ERR_NODEV_HINT;
+                       }
+
+                       ap->hsm_task_state = HSM_ST_ERR;
+                       goto fsm_start;
+               }
+               /* For PIO reads, some devices may ask for
+                * data transfer (DRQ=1) alone with ERR=1.
+                * We respect DRQ here and transfer one
+                * block of junk data before changing the
+                * hsm_task_state to HSM_ST_ERR.
+                *
+                * For PIO writes, ERR=1 DRQ=1 doesn't make
+                * sense since the data block has been
+                * transferred to the device.
+                */
+               if (status & (ATA_ERR | ATA_DF)) {
+                       qc->err_mask |= AC_ERR_DEV;
+
+                       if (!(qc->tf.flags & ATA_TFLAG_WRITE)) {
+                               ata_pio_sectors(qc);
+                               status = ata_wait_idle(ap);
+                       }
+
+                       if (status & (ATA_BUSY | ATA_DRQ))
+                               qc->err_mask |= AC_ERR_HSM;
+
+                       /* ata_pio_sectors() might change the
+                        * state to HSM_ST_LAST. so, the state
+                        * is changed after ata_pio_sectors().
+                        */
+                       ap->hsm_task_state = HSM_ST_ERR;
+                       goto fsm_start;
+               }
+
+               ata_pio_sectors(qc);
+               if (ap->hsm_task_state == HSM_ST_LAST &&
+                       (!(qc->tf.flags & ATA_TFLAG_WRITE))) {
+                       status = ata_wait_idle(ap);
+                       goto fsm_start;
+               }
+
+               poll_next = 1;
+               break;
+
+       case HSM_ST_LAST:
+               if (!ata_ok(status)) {
+                       qc->err_mask |= __ac_err_mask(status);
+                       ap->hsm_task_state = HSM_ST_ERR;
+                       goto fsm_start;
+               }
+
+               ap->hsm_task_state = HSM_ST_IDLE;
+
+               ata_hsm_qc_complete(qc, in_wq);
+
+               poll_next = 0;
+               break;
+
+       case HSM_ST_ERR:
+               /* make sure qc->err_mask is available to
+                * know what's wrong and recover
+                */
+               ap->hsm_task_state = HSM_ST_IDLE;
+
+               ata_hsm_qc_complete(qc, in_wq);
+
+               poll_next = 0;
+               break;
+       default:
+               poll_next = 0;
+       }
+
+       return poll_next;
+}
+
+static void ata_pio_sectors(struct ata_queued_cmd *qc)
+{
+       struct ata_port *ap;
+       ap = pap;
+       qc->pdata = ap->pdata;
+
+       ata_pio_sector(qc);
+
+       readb(qc->ap->ioaddr.altstatus_addr);
+       udelay(1);
+}
+
+static void ata_pio_sector(struct ata_queued_cmd *qc)
+{
+       int do_write = (qc->tf.flags & ATA_TFLAG_WRITE);
+       struct ata_port *ap = qc->ap;
+       unsigned int offset;
+       unsigned char *buf;
+       char temp_data_buf[512];
+
+       if (qc->curbytes == qc->nbytes - qc->sect_size)
+               ap->hsm_task_state = HSM_ST_LAST;
+
+       offset = qc->curbytes;
+
+       switch (qc->tf.command) {
+       case ATA_CMD_ID_ATA:
+               buf = (unsigned char *)&ata_device.id[0];
+               break;
+       case ATA_CMD_PIO_READ_EXT:
+       case ATA_CMD_PIO_READ:
+       case ATA_CMD_PIO_WRITE_EXT:
+       case ATA_CMD_PIO_WRITE:
+               buf = qc->pdata + offset;
+               break;
+       default:
+               buf = (unsigned char *)&temp_data_buf[0];
+       }
+
+       ata_mmio_data_xfer(qc->dev, buf, qc->sect_size, do_write);
+
+       qc->curbytes += qc->sect_size;
+
+}
+
+static void ata_mmio_data_xfer(struct ata_device *dev, unsigned char *buf,
+                               unsigned int buflen, int do_write)
+{
+       struct ata_port *ap = pap;
+       void __iomem *data_addr = ap->ioaddr.data_addr;
+       unsigned int words = buflen >> 1;
+       u16 *buf16 = (u16 *)buf;
+       unsigned int i = 0;
+
+       udelay(100);
+       if (do_write) {
+               for (i = 0; i < words; i++)
+                       writew(le16_to_cpu(buf16[i]), data_addr);
+       } else {
+               for (i = 0; i < words; i++)
+                       buf16[i] = cpu_to_le16(readw(data_addr));
+       }
+
+       if (buflen & 0x01) {
+               __le16 align_buf[1] = { 0 };
+               unsigned char *trailing_buf = buf + buflen - 1;
+
+               if (do_write) {
+                       memcpy(align_buf, trailing_buf, 1);
+                       writew(le16_to_cpu(align_buf[0]), data_addr);
+               } else {
+                       align_buf[0] = cpu_to_le16(readw(data_addr));
+                       memcpy(trailing_buf, align_buf, 1);
+               }
+       }
+}
+
+static void ata_hsm_qc_complete(struct ata_queued_cmd *qc, int in_wq)
+{
+       struct ata_port *ap = qc->ap;
+
+       if (in_wq) {
+               /* EH might have kicked in while host lock is
+                * released.
+                */
+               qc = &ap->qcmd[qc->tag];
+               if (qc) {
+                       if (!(qc->err_mask & AC_ERR_HSM)) {
+                               ata_irq_on(ap);
+                               ata_qc_complete(qc);
+                       } else {
+                               ata_port_freeze(ap);
+                       }
+               }
+       } else {
+               if (!(qc->err_mask & AC_ERR_HSM)) {
+                       ata_qc_complete(qc);
+               } else {
+                       ata_port_freeze(ap);
+               }
+       }
+}
+
+static u8 ata_irq_on(struct ata_port *ap)
+{
+       struct ata_ioports *ioaddr = &ap->ioaddr;
+       u8 tmp;
+
+       ap->ctl &= ~ATA_NIEN;
+       ap->last_ctl = ap->ctl;
+
+       if (ioaddr->ctl_addr)
+               writeb(ap->ctl, ioaddr->ctl_addr);
+
+       tmp = ata_wait_idle(ap);
+
+       return tmp;
+}
+
+static unsigned int ata_tag_internal(unsigned int tag)
+{
+       return tag == ATA_MAX_QUEUE - 1;
+}
+
+static void ata_qc_complete(struct ata_queued_cmd *qc)
+{
+       struct ata_device *dev = qc->dev;
+       if (qc->err_mask)
+               qc->flags |= ATA_QCFLAG_FAILED;
+
+       if (qc->flags & ATA_QCFLAG_FAILED) {
+               if (!ata_tag_internal(qc->tag)) {
+                       fill_result_tf(qc);
+                       return;
+               }
+       }
+       if (qc->flags & ATA_QCFLAG_RESULT_TF)
+               fill_result_tf(qc);
+
+       /* Some commands need post-processing after successful
+        * completion.
+        */
+       switch (qc->tf.command) {
+       case ATA_CMD_SET_FEATURES:
+               if (qc->tf.feature != SETFEATURES_WC_ON &&
+                               qc->tf.feature != SETFEATURES_WC_OFF)
+                       break;
+       case ATA_CMD_INIT_DEV_PARAMS:
+       case ATA_CMD_SET_MULTI:
+               break;
+
+       case ATA_CMD_SLEEP:
+               dev->flags |= ATA_DFLAG_SLEEPING;
+               break;
+       }
+
+       __ata_qc_complete(qc);
+}
+
+static void fill_result_tf(struct ata_queued_cmd *qc)
+{
+       struct ata_port *ap = qc->ap;
+
+       qc->result_tf.flags = qc->tf.flags;
+       ata_tf_read(ap, &qc->result_tf);
+}
+
+static void ata_tf_read(struct ata_port *ap, struct ata_taskfile *tf)
+{
+       struct ata_ioports *ioaddr = &ap->ioaddr;
+
+       tf->command = ata_check_status(ap);
+       tf->feature = readb(ioaddr->error_addr);
+       tf->nsect = readb(ioaddr->nsect_addr);
+       tf->lbal = readb(ioaddr->lbal_addr);
+       tf->lbam = readb(ioaddr->lbam_addr);
+       tf->lbah = readb(ioaddr->lbah_addr);
+       tf->device = readb(ioaddr->device_addr);
+
+       if (tf->flags & ATA_TFLAG_LBA48) {
+               if (ioaddr->ctl_addr) {
+                       writeb(tf->ctl | ATA_HOB, ioaddr->ctl_addr);
+
+                       tf->hob_feature = readb(ioaddr->error_addr);
+                       tf->hob_nsect = readb(ioaddr->nsect_addr);
+                       tf->hob_lbal = readb(ioaddr->lbal_addr);
+                       tf->hob_lbam = readb(ioaddr->lbam_addr);
+                       tf->hob_lbah = readb(ioaddr->lbah_addr);
+
+                       writeb(tf->ctl, ioaddr->ctl_addr);
+                       ap->last_ctl = tf->ctl;
+               } else {
+                       printf("sata_dwc warnning register read.\n");
+               }
+       }
+}
+
+static void __ata_qc_complete(struct ata_queued_cmd *qc)
+{
+       struct ata_port *ap = qc->ap;
+       struct ata_link *link = qc->dev->link;
+
+       link->active_tag = ATA_TAG_POISON;
+       ap->nr_active_links--;
+
+       if (qc->flags & ATA_QCFLAG_CLEAR_EXCL && ap->excl_link == link)
+               ap->excl_link = NULL;
+
+       qc->flags &= ~ATA_QCFLAG_ACTIVE;
+       ap->qc_active &= ~(1 << qc->tag);
+}
+
+static void ata_qc_free(struct ata_queued_cmd *qc)
+{
+       struct ata_port *ap = qc->ap;
+       unsigned int tag;
+       qc->flags = 0;
+       tag = qc->tag;
+       if (tag < ATA_MAX_QUEUE) {
+               qc->tag = ATA_TAG_POISON;
+               clear_bit(tag, &ap->qc_allocated);
+       }
+}
+
+static int check_sata_dev_state(void)
+{
+       unsigned long datalen;
+       unsigned char *pdata;
+       int ret = 0;
+       int i = 0;
+       char temp_data_buf[512];
+
+       while (1) {
+               udelay(10000);
+
+               pdata = (unsigned char*)&temp_data_buf[0];
+               datalen = 512;
+
+               ret = ata_dev_read_sectors(pdata, datalen, 0, 1);
+
+               if (ret == TRUE)
+                       break;
+
+               i++;
+               if (i > (ATA_RESET_TIME * 100)) {
+                       printf("** TimeOUT **\n");
+                       dev_state = SATA_NODEVICE;
+                       return FALSE;
+               }
+
+               if ((i >= 100) && ((i % 100) == 0))
+                       printf(".");
+       }
+
+       dev_state = SATA_READY;
+
+       return TRUE;
+}
+
+static unsigned int ata_dev_set_feature(struct ata_device *dev,
+                               u8 enable, u8 feature)
+{
+       struct ata_taskfile tf;
+       struct ata_port *ap;
+       ap = pap;
+       unsigned int err_mask;
+
+       memset(&tf, 0, sizeof(tf));
+       tf.ctl = ap->ctl;
+
+       tf.device = ATA_DEVICE_OBS;
+       tf.command = ATA_CMD_SET_FEATURES;
+       tf.feature = enable;
+       tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE;
+       tf.protocol = ATA_PROT_NODATA;
+       tf.nsect = feature;
+
+       err_mask = ata_exec_internal(dev, &tf, NULL, DMA_NONE, 0, 0);
+
+       return err_mask;
+}
+
+static unsigned int ata_dev_init_params(struct ata_device *dev,
+                               u16 heads, u16 sectors)
+{
+       struct ata_taskfile tf;
+       struct ata_port *ap;
+       ap = pap;
+       unsigned int err_mask;
+
+       if (sectors < 1 || sectors > 255 || heads < 1 || heads > 16)
+               return AC_ERR_INVALID;
+
+       memset(&tf, 0, sizeof(tf));
+       tf.ctl = ap->ctl;
+       tf.device = ATA_DEVICE_OBS;
+       tf.command = ATA_CMD_INIT_DEV_PARAMS;
+       tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE;
+       tf.protocol = ATA_PROT_NODATA;
+       tf.nsect = sectors;
+       tf.device |= (heads - 1) & 0x0f;
+
+       err_mask = ata_exec_internal(dev, &tf, NULL, DMA_NONE, 0, 0);
+
+       if (err_mask == AC_ERR_DEV && (tf.feature & ATA_ABORTED))
+               err_mask = 0;
+
+       return err_mask;
+}
+
+#if defined(CONFIG_SATA_DWC) && !defined(CONFIG_LBA48)
+#define SATA_MAX_READ_BLK 0xFF
+#else
+#define SATA_MAX_READ_BLK 0xFFFF
+#endif
+
+ulong sata_read(int device, ulong blknr, lbaint_t blkcnt, void *buffer)
+{
+       ulong start,blks, buf_addr;
+       unsigned short smallblks;
+       unsigned long datalen;
+       unsigned char *pdata;
+       device &= 0xff;
+
+       u32 block = 0;
+       u32 n_block = 0;
+
+       if (dev_state != SATA_READY)
+               return 0;
+
+       buf_addr = (unsigned long)buffer;
+       start = blknr;
+       blks = blkcnt;
+       do {
+               pdata = (unsigned char *)buf_addr;
+               if (blks > SATA_MAX_READ_BLK) {
+                       datalen = sata_dev_desc[device].blksz * SATA_MAX_READ_BLK;
+                       smallblks = SATA_MAX_READ_BLK;
+
+                       block = (u32)start;
+                       n_block = (u32)smallblks;
+
+                       start += SATA_MAX_READ_BLK;
+                       blks -= SATA_MAX_READ_BLK;
+               } else {
+                       datalen = sata_dev_desc[device].blksz * SATA_MAX_READ_BLK;
+                       datalen = sata_dev_desc[device].blksz * blks;
+                       smallblks = (unsigned short)blks;
+
+                       block = (u32)start;
+                       n_block = (u32)smallblks;
+
+                       start += blks;
+                       blks = 0;
+               }
+
+               if (ata_dev_read_sectors(pdata, datalen, block, n_block) != TRUE) {
+                       printf("sata_dwc : Hard disk read error.\n");
+                       blkcnt -= blks;
+                       break;
+               }
+               buf_addr += datalen;
+       } while (blks != 0);
+
+       return (blkcnt);
+}
+
+static int ata_dev_read_sectors(unsigned char *pdata, unsigned long datalen,
+                                               u32 block, u32 n_block)
+{
+       struct ata_port *ap = pap;
+       struct ata_device *dev = &ata_device;
+       struct ata_taskfile tf;
+       unsigned int class = ATA_DEV_ATA;
+       unsigned int err_mask = 0;
+       const char *reason;
+       int may_fallback = 1;
+       int rc;
+
+       if (dev_state == SATA_ERROR)
+               return FALSE;
+
+       ata_dev_select(ap, dev->devno, 1, 1);
+
+retry:
+       memset(&tf, 0, sizeof(tf));
+       tf.ctl = ap->ctl;
+       ap->print_id = 1;
+       ap->flags &= ~ATA_FLAG_DISABLED;
+
+       ap->pdata = pdata;
+
+       tf.device = ATA_DEVICE_OBS;
+
+       temp_n_block = n_block;
+
+#ifdef CONFIG_LBA48
+       tf.command = ATA_CMD_PIO_READ_EXT;
+       tf.flags |= ATA_TFLAG_LBA | ATA_TFLAG_LBA48;
+
+       tf.hob_feature = 31;
+       tf.feature = 31;
+       tf.hob_nsect = (n_block >> 8) & 0xff;
+       tf.nsect = n_block & 0xff;
+
+       tf.hob_lbah = 0x0;
+       tf.hob_lbam = 0x0;
+       tf.hob_lbal = (block >> 24) & 0xff;
+       tf.lbah = (block >> 16) & 0xff;
+       tf.lbam = (block >> 8) & 0xff;
+       tf.lbal = block & 0xff;
+
+       tf.device = 1 << 6;
+       if (tf.flags & ATA_TFLAG_FUA)
+               tf.device |= 1 << 7;
+#else
+       tf.command = ATA_CMD_PIO_READ;
+       tf.flags |= ATA_TFLAG_LBA ;
+
+       tf.feature = 31;
+       tf.nsect = n_block & 0xff;
+
+       tf.lbah = (block >> 16) & 0xff;
+       tf.lbam = (block >> 8) & 0xff;
+       tf.lbal = block & 0xff;
+
+       tf.device = (block >> 24) & 0xf;
+
+       tf.device |= 1 << 6;
+       if (tf.flags & ATA_TFLAG_FUA)
+               tf.device |= 1 << 7;
+
+#endif
+
+       tf.protocol = ATA_PROT_PIO;
+
+       /* Some devices choke if TF registers contain garbage.  Make
+        * sure those are properly initialized.
+        */
+       tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE;
+       tf.flags |= ATA_TFLAG_POLLING;
+
+       err_mask = ata_exec_internal(dev, &tf, NULL, DMA_FROM_DEVICE, 0, 0);
+
+       if (err_mask) {
+               if (err_mask & AC_ERR_NODEV_HINT) {
+                       printf("READ_SECTORS NODEV after polling detection\n");
+                       return -ENOENT;
+               }
+
+               if ((err_mask == AC_ERR_DEV) && (tf.feature & ATA_ABORTED)) {
+                       /* Device or controller might have reported
+                        * the wrong device class.  Give a shot at the
+                        * other IDENTIFY if the current one is
+                        * aborted by the device.
+                        */
+                       if (may_fallback) {
+                               may_fallback = 0;
+
+                               if (class == ATA_DEV_ATA) {
+                                       class = ATA_DEV_ATAPI;
+                               } else {
+                                       class = ATA_DEV_ATA;
+                               }
+                               goto retry;
+                       }
+                       /* Control reaches here iff the device aborted
+                        * both flavors of IDENTIFYs which happens
+                        * sometimes with phantom devices.
+                        */
+                       printf("both IDENTIFYs aborted, assuming NODEV\n");
+                       return -ENOENT;
+               }
+
+               rc = -EIO;
+               reason = "I/O error";
+               goto err_out;
+       }
+
+       /* Falling back doesn't make sense if ID data was read
+        * successfully at least once.
+        */
+       may_fallback = 0;
+
+       rc = -EINVAL;
+       reason = "device reports invalid type";
+
+       return TRUE;
+
+err_out:
+       printf("failed to READ SECTORS (%s, err_mask=0x%x)\n", reason, err_mask);
+       return FALSE;
+}
+
+#if defined(CONFIG_SATA_DWC) && !defined(CONFIG_LBA48)
+#define SATA_MAX_WRITE_BLK 0xFF
+#else
+#define SATA_MAX_WRITE_BLK 0xFFFF
+#endif
+
+ulong sata_write(int device, ulong blknr, lbaint_t blkcnt, void *buffer)
+{
+       ulong start,blks, buf_addr;
+       unsigned short smallblks;
+       unsigned long datalen;
+       unsigned char *pdata;
+       device &= 0xff;
+
+
+       u32 block = 0;
+       u32 n_block = 0;
+
+       if (dev_state != SATA_READY)
+               return 0;
+
+       buf_addr = (unsigned long)buffer;
+       start = blknr;
+       blks = blkcnt;
+       do {
+               pdata = (unsigned char *)buf_addr;
+               if (blks > SATA_MAX_WRITE_BLK) {
+                       datalen = sata_dev_desc[device].blksz * SATA_MAX_WRITE_BLK;
+                       smallblks = SATA_MAX_WRITE_BLK;
+
+                       block = (u32)start;
+                       n_block = (u32)smallblks;
+
+                       start += SATA_MAX_WRITE_BLK;
+                       blks -= SATA_MAX_WRITE_BLK;
+               } else {
+                       datalen = sata_dev_desc[device].blksz * blks;
+                       smallblks = (unsigned short)blks;
+
+                       block = (u32)start;
+                       n_block = (u32)smallblks;
+
+                       start += blks;
+                       blks = 0;
+               }
+
+               if (ata_dev_write_sectors(pdata, datalen, block, n_block) != TRUE) {
+                       printf("sata_dwc : Hard disk read error.\n");
+                       blkcnt -= blks;
+                       break;
+               }
+               buf_addr += datalen;
+       } while (blks != 0);
+
+       return (blkcnt);
+}
+
+static int ata_dev_write_sectors(unsigned char* pdata, unsigned long datalen,
+                                               u32 block, u32 n_block)
+{
+       struct ata_port *ap = pap;
+       struct ata_device *dev = &ata_device;
+       struct ata_taskfile tf;
+       unsigned int class = ATA_DEV_ATA;
+       unsigned int err_mask = 0;
+       const char *reason;
+       int may_fallback = 1;
+       int rc;
+
+       if (dev_state == SATA_ERROR)
+               return FALSE;
+
+       ata_dev_select(ap, dev->devno, 1, 1);
+
+retry:
+       memset(&tf, 0, sizeof(tf));
+       tf.ctl = ap->ctl;
+       ap->print_id = 1;
+       ap->flags &= ~ATA_FLAG_DISABLED;
+
+       ap->pdata = pdata;
+
+       tf.device = ATA_DEVICE_OBS;
+
+       temp_n_block = n_block;
+
+
+#ifdef CONFIG_LBA48
+       tf.command = ATA_CMD_PIO_WRITE_EXT;
+       tf.flags |= ATA_TFLAG_LBA | ATA_TFLAG_LBA48 | ATA_TFLAG_WRITE;
+
+       tf.hob_feature = 31;
+       tf.feature = 31;
+       tf.hob_nsect = (n_block >> 8) & 0xff;
+       tf.nsect = n_block & 0xff;
+
+       tf.hob_lbah = 0x0;
+       tf.hob_lbam = 0x0;
+       tf.hob_lbal = (block >> 24) & 0xff;
+       tf.lbah = (block >> 16) & 0xff;
+       tf.lbam = (block >> 8) & 0xff;
+       tf.lbal = block & 0xff;
+
+       tf.device = 1 << 6;
+       if (tf.flags & ATA_TFLAG_FUA)
+               tf.device |= 1 << 7;
+#else
+       tf.command = ATA_CMD_PIO_WRITE;
+       tf.flags |= ATA_TFLAG_LBA | ATA_TFLAG_WRITE;
+
+       tf.feature = 31;
+       tf.nsect = n_block & 0xff;
+
+       tf.lbah = (block >> 16) & 0xff;
+       tf.lbam = (block >> 8) & 0xff;
+       tf.lbal = block & 0xff;
+
+       tf.device = (block >> 24) & 0xf;
+
+       tf.device |= 1 << 6;
+       if (tf.flags & ATA_TFLAG_FUA)
+               tf.device |= 1 << 7;
+
+#endif
+
+       tf.protocol = ATA_PROT_PIO;
+
+       /* Some devices choke if TF registers contain garbage.  Make
+        * sure those are properly initialized.
+        */
+       tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE;
+       tf.flags |= ATA_TFLAG_POLLING;
+
+       err_mask = ata_exec_internal(dev, &tf, NULL, DMA_FROM_DEVICE, 0, 0);
+
+       if (err_mask) {
+               if (err_mask & AC_ERR_NODEV_HINT) {
+                       printf("READ_SECTORS NODEV after polling detection\n");
+                       return -ENOENT;
+               }
+
+               if ((err_mask == AC_ERR_DEV) && (tf.feature & ATA_ABORTED)) {
+                       /* Device or controller might have reported
+                        * the wrong device class.  Give a shot at the
+                        * other IDENTIFY if the current one is
+                        * aborted by the device.
+                        */
+                       if (may_fallback) {
+                               may_fallback = 0;
+
+                               if (class == ATA_DEV_ATA) {
+                                       class = ATA_DEV_ATAPI;
+                               } else {
+                                       class = ATA_DEV_ATA;
+                               }
+                               goto retry;
+                       }
+                       /* Control reaches here iff the device aborted
+                        * both flavors of IDENTIFYs which happens
+                        * sometimes with phantom devices.
+                        */
+                       printf("both IDENTIFYs aborted, assuming NODEV\n");
+                       return -ENOENT;
+               }
+
+               rc = -EIO;
+               reason = "I/O error";
+               goto err_out;
+       }
+
+       /* Falling back doesn't make sense if ID data was read
+        * successfully at least once.
+        */
+       may_fallback = 0;
+
+       rc = -EINVAL;
+       reason = "device reports invalid type";
+
+       return TRUE;
+
+err_out:
+       printf("failed to WRITE SECTORS (%s, err_mask=0x%x)\n", reason, err_mask);
+       return FALSE;
+}
diff --git a/drivers/block/sata_dwc.h b/drivers/block/sata_dwc.h
new file mode 100644 (file)
index 0000000..204d644
--- /dev/null
@@ -0,0 +1,477 @@
+/*
+ * sata_dwc.h
+ *
+ * Synopsys DesignWare Cores (DWC) SATA host driver
+ *
+ * Author: Mark Miesfeld <mmiesfeld@amcc.com>
+ *
+ * Ported from 2.6.19.2 to 2.6.25/26 by Stefan Roese <sr@denx.de>
+ * Copyright 2008 DENX Software Engineering
+ *
+ * Based on versions provided by AMCC and Synopsys which are:
+ *          Copyright 2006 Applied Micro Circuits Corporation
+ *          COPYRIGHT (C) 2005  SYNOPSYS, INC.  ALL RIGHTS RESERVED
+ *
+ * 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.
+ *
+ */
+/*
+ * SATA support based on the chip canyonlands.
+ *
+ * 04-17-2009
+ *             The local version of this driver for the canyonlands board
+ *             does not use interrupts but polls the chip instead.
+ */
+
+
+#ifndef _SATA_DWC_H_
+#define _SATA_DWC_H_
+
+#define __U_BOOT__
+
+#define HZ 100
+#define READ 0
+#define WRITE 1
+
+enum {
+       ATA_READID_POSTRESET    = (1 << 0),
+
+       ATA_DNXFER_PIO          = 0,
+       ATA_DNXFER_DMA          = 1,
+       ATA_DNXFER_40C          = 2,
+       ATA_DNXFER_FORCE_PIO    = 3,
+       ATA_DNXFER_FORCE_PIO0   = 4,
+
+       ATA_DNXFER_QUIET        = (1 << 31),
+};
+
+enum hsm_task_states {
+       HSM_ST_IDLE,
+       HSM_ST_FIRST,
+       HSM_ST,
+       HSM_ST_LAST,
+       HSM_ST_ERR,
+};
+
+#define        ATA_SHORT_PAUSE         ((HZ >> 6) + 1)
+
+struct ata_queued_cmd {
+       struct ata_port         *ap;
+       struct ata_device       *dev;
+
+       struct ata_taskfile     tf;
+       u8                      cdb[ATAPI_CDB_LEN];
+       unsigned long           flags;
+       unsigned int            tag;
+       unsigned int            n_elem;
+
+       int                     dma_dir;
+       unsigned int            sect_size;
+
+       unsigned int            nbytes;
+       unsigned int            extrabytes;
+       unsigned int            curbytes;
+
+       unsigned int            err_mask;
+       struct ata_taskfile     result_tf;
+
+       void                    *private_data;
+#ifndef __U_BOOT__
+       void                    *lldd_task;
+#endif
+       unsigned char           *pdata;
+};
+
+typedef void (*ata_qc_cb_t) (struct ata_queued_cmd *qc);
+
+#define ATA_TAG_POISON 0xfafbfcfdU
+
+enum {
+       LIBATA_MAX_PRD          = ATA_MAX_PRD / 2,
+       LIBATA_DUMB_MAX_PRD     = ATA_MAX_PRD / 4,
+       ATA_MAX_PORTS           = 8,
+       ATA_DEF_QUEUE           = 1,
+       ATA_MAX_QUEUE           = 32,
+       ATA_TAG_INTERNAL        = ATA_MAX_QUEUE - 1,
+       ATA_MAX_BUS             = 2,
+       ATA_DEF_BUSY_WAIT       = 10000,
+
+       ATAPI_MAX_DRAIN         = 16 << 10,
+
+       ATA_SHT_EMULATED        = 1,
+       ATA_SHT_CMD_PER_LUN     = 1,
+       ATA_SHT_THIS_ID         = -1,
+       ATA_SHT_USE_CLUSTERING  = 1,
+
+       ATA_DFLAG_LBA           = (1 << 0),
+       ATA_DFLAG_LBA48         = (1 << 1),
+       ATA_DFLAG_CDB_INTR      = (1 << 2),
+       ATA_DFLAG_NCQ           = (1 << 3),
+       ATA_DFLAG_FLUSH_EXT     = (1 << 4),
+       ATA_DFLAG_ACPI_PENDING  = (1 << 5),
+       ATA_DFLAG_ACPI_FAILED   = (1 << 6),
+       ATA_DFLAG_AN            = (1 << 7),
+       ATA_DFLAG_HIPM          = (1 << 8),
+       ATA_DFLAG_DIPM          = (1 << 9),
+       ATA_DFLAG_DMADIR        = (1 << 10),
+       ATA_DFLAG_CFG_MASK      = (1 << 12) - 1,
+
+       ATA_DFLAG_PIO           = (1 << 12),
+       ATA_DFLAG_NCQ_OFF       = (1 << 13),
+       ATA_DFLAG_SPUNDOWN      = (1 << 14),
+       ATA_DFLAG_SLEEPING      = (1 << 15),
+       ATA_DFLAG_DUBIOUS_XFER  = (1 << 16),
+       ATA_DFLAG_INIT_MASK     = (1 << 24) - 1,
+
+       ATA_DFLAG_DETACH        = (1 << 24),
+       ATA_DFLAG_DETACHED      = (1 << 25),
+
+       ATA_LFLAG_HRST_TO_RESUME        = (1 << 0),
+       ATA_LFLAG_SKIP_D2H_BSY          = (1 << 1),
+       ATA_LFLAG_NO_SRST               = (1 << 2),
+       ATA_LFLAG_ASSUME_ATA            = (1 << 3),
+       ATA_LFLAG_ASSUME_SEMB           = (1 << 4),
+       ATA_LFLAG_ASSUME_CLASS = ATA_LFLAG_ASSUME_ATA | ATA_LFLAG_ASSUME_SEMB,
+       ATA_LFLAG_NO_RETRY              = (1 << 5),
+       ATA_LFLAG_DISABLED              = (1 << 6),
+
+       ATA_FLAG_SLAVE_POSS     = (1 << 0),
+       ATA_FLAG_SATA           = (1 << 1),
+       ATA_FLAG_NO_LEGACY      = (1 << 2),
+       ATA_FLAG_MMIO           = (1 << 3),
+       ATA_FLAG_SRST           = (1 << 4),
+       ATA_FLAG_SATA_RESET     = (1 << 5),
+       ATA_FLAG_NO_ATAPI       = (1 << 6),
+       ATA_FLAG_PIO_DMA        = (1 << 7),
+       ATA_FLAG_PIO_LBA48      = (1 << 8),
+       ATA_FLAG_PIO_POLLING    = (1 << 9),
+       ATA_FLAG_NCQ            = (1 << 10),
+       ATA_FLAG_DEBUGMSG       = (1 << 13),
+       ATA_FLAG_IGN_SIMPLEX    = (1 << 15),
+       ATA_FLAG_NO_IORDY       = (1 << 16),
+       ATA_FLAG_ACPI_SATA      = (1 << 17),
+       ATA_FLAG_AN             = (1 << 18),
+       ATA_FLAG_PMP            = (1 << 19),
+       ATA_FLAG_IPM            = (1 << 20),
+
+       ATA_FLAG_DISABLED       = (1 << 23),
+
+       ATA_PFLAG_EH_PENDING            = (1 << 0),
+       ATA_PFLAG_EH_IN_PROGRESS        = (1 << 1),
+       ATA_PFLAG_FROZEN                = (1 << 2),
+       ATA_PFLAG_RECOVERED             = (1 << 3),
+       ATA_PFLAG_LOADING               = (1 << 4),
+       ATA_PFLAG_UNLOADING             = (1 << 5),
+       ATA_PFLAG_SCSI_HOTPLUG          = (1 << 6),
+       ATA_PFLAG_INITIALIZING          = (1 << 7),
+       ATA_PFLAG_RESETTING             = (1 << 8),
+       ATA_PFLAG_SUSPENDED             = (1 << 17),
+       ATA_PFLAG_PM_PENDING            = (1 << 18),
+
+       ATA_QCFLAG_ACTIVE       = (1 << 0),
+       ATA_QCFLAG_DMAMAP       = (1 << 1),
+       ATA_QCFLAG_IO           = (1 << 3),
+       ATA_QCFLAG_RESULT_TF    = (1 << 4),
+       ATA_QCFLAG_CLEAR_EXCL   = (1 << 5),
+       ATA_QCFLAG_QUIET        = (1 << 6),
+
+       ATA_QCFLAG_FAILED       = (1 << 16),
+       ATA_QCFLAG_SENSE_VALID  = (1 << 17),
+       ATA_QCFLAG_EH_SCHEDULED = (1 << 18),
+
+       ATA_HOST_SIMPLEX        = (1 << 0),
+       ATA_HOST_STARTED        = (1 << 1),
+
+       ATA_TMOUT_BOOT                  = 30 * 100,
+       ATA_TMOUT_BOOT_QUICK            = 7 * 100,
+       ATA_TMOUT_INTERNAL              = 30 * 100,
+       ATA_TMOUT_INTERNAL_QUICK        = 5 * 100,
+
+       /* FIXME: GoVault needs 2s but we can't afford that without
+        * parallel probing.  800ms is enough for iVDR disk
+        * HHD424020F7SV00.  Increase to 2secs when parallel probing
+        * is in place.
+        */
+       ATA_TMOUT_FF_WAIT       = 4 * 100 / 5,
+
+       BUS_UNKNOWN             = 0,
+       BUS_DMA                 = 1,
+       BUS_IDLE                = 2,
+       BUS_NOINTR              = 3,
+       BUS_NODATA              = 4,
+       BUS_TIMER               = 5,
+       BUS_PIO                 = 6,
+       BUS_EDD                 = 7,
+       BUS_IDENTIFY            = 8,
+       BUS_PACKET              = 9,
+
+       PORT_UNKNOWN            = 0,
+       PORT_ENABLED            = 1,
+       PORT_DISABLED           = 2,
+
+       /* encoding various smaller bitmaps into a single
+        * unsigned long bitmap
+        */
+       ATA_NR_PIO_MODES        = 7,
+       ATA_NR_MWDMA_MODES      = 5,
+       ATA_NR_UDMA_MODES       = 8,
+
+       ATA_SHIFT_PIO           = 0,
+       ATA_SHIFT_MWDMA         = ATA_SHIFT_PIO + ATA_NR_PIO_MODES,
+       ATA_SHIFT_UDMA          = ATA_SHIFT_MWDMA + ATA_NR_MWDMA_MODES,
+
+       ATA_DMA_PAD_SZ          = 4,
+
+       ATA_ERING_SIZE          = 32,
+
+       ATA_DEFER_LINK          = 1,
+       ATA_DEFER_PORT          = 2,
+
+       ATA_EH_DESC_LEN         = 80,
+
+       ATA_EH_REVALIDATE       = (1 << 0),
+       ATA_EH_SOFTRESET        = (1 << 1),
+       ATA_EH_HARDRESET        = (1 << 2),
+       ATA_EH_ENABLE_LINK      = (1 << 3),
+       ATA_EH_LPM              = (1 << 4),
+
+       ATA_EH_RESET_MASK       = ATA_EH_SOFTRESET | ATA_EH_HARDRESET,
+       ATA_EH_PERDEV_MASK      = ATA_EH_REVALIDATE,
+
+       ATA_EHI_HOTPLUGGED      = (1 << 0),
+       ATA_EHI_RESUME_LINK     = (1 << 1),
+       ATA_EHI_NO_AUTOPSY      = (1 << 2),
+       ATA_EHI_QUIET           = (1 << 3),
+
+       ATA_EHI_DID_SOFTRESET   = (1 << 16),
+       ATA_EHI_DID_HARDRESET   = (1 << 17),
+       ATA_EHI_PRINTINFO       = (1 << 18),
+       ATA_EHI_SETMODE         = (1 << 19),
+       ATA_EHI_POST_SETMODE    = (1 << 20),
+
+       ATA_EHI_DID_RESET = ATA_EHI_DID_SOFTRESET | ATA_EHI_DID_HARDRESET,
+       ATA_EHI_RESET_MODIFIER_MASK = ATA_EHI_RESUME_LINK,
+
+       ATA_EH_MAX_TRIES        = 5,
+
+       ATA_PROBE_MAX_TRIES     = 3,
+       ATA_EH_DEV_TRIES        = 3,
+       ATA_EH_PMP_TRIES        = 5,
+       ATA_EH_PMP_LINK_TRIES   = 3,
+
+       SATA_PMP_SCR_TIMEOUT    = 250,
+
+       /* Horkage types. May be set by libata or controller on drives
+       (some horkage may be drive/controller pair dependant */
+
+       ATA_HORKAGE_DIAGNOSTIC  = (1 << 0),
+       ATA_HORKAGE_NODMA       = (1 << 1),
+       ATA_HORKAGE_NONCQ       = (1 << 2),
+       ATA_HORKAGE_MAX_SEC_128 = (1 << 3),
+       ATA_HORKAGE_BROKEN_HPA  = (1 << 4),
+       ATA_HORKAGE_SKIP_PM     = (1 << 5),
+       ATA_HORKAGE_HPA_SIZE    = (1 << 6),
+       ATA_HORKAGE_IPM         = (1 << 7),
+       ATA_HORKAGE_IVB         = (1 << 8),
+       ATA_HORKAGE_STUCK_ERR   = (1 << 9),
+
+       ATA_DMA_MASK_ATA        = (1 << 0),
+       ATA_DMA_MASK_ATAPI      = (1 << 1),
+       ATA_DMA_MASK_CFA        = (1 << 2),
+
+       ATAPI_READ              = 0,
+       ATAPI_WRITE             = 1,
+       ATAPI_READ_CD           = 2,
+       ATAPI_PASS_THRU         = 3,
+       ATAPI_MISC              = 4,
+};
+
+enum ata_completion_errors {
+       AC_ERR_DEV              = (1 << 0),
+       AC_ERR_HSM              = (1 << 1),
+       AC_ERR_TIMEOUT          = (1 << 2),
+       AC_ERR_MEDIA            = (1 << 3),
+       AC_ERR_ATA_BUS          = (1 << 4),
+       AC_ERR_HOST_BUS         = (1 << 5),
+       AC_ERR_SYSTEM           = (1 << 6),
+       AC_ERR_INVALID          = (1 << 7),
+       AC_ERR_OTHER            = (1 << 8),
+       AC_ERR_NODEV_HINT       = (1 << 9),
+       AC_ERR_NCQ              = (1 << 10),
+};
+
+enum ata_xfer_mask {
+       ATA_MASK_PIO    = ((1LU << ATA_NR_PIO_MODES) - 1) << ATA_SHIFT_PIO,
+       ATA_MASK_MWDMA  = ((1LU << ATA_NR_MWDMA_MODES) - 1) << ATA_SHIFT_MWDMA,
+       ATA_MASK_UDMA   = ((1LU << ATA_NR_UDMA_MODES) - 1) << ATA_SHIFT_UDMA,
+};
+
+struct ata_port_info {
+#ifndef __U_BOOT__
+       struct scsi_host_template       *sht;
+#endif
+       unsigned long                   flags;
+       unsigned long                   link_flags;
+       unsigned long                   pio_mask;
+       unsigned long                   mwdma_mask;
+       unsigned long                   udma_mask;
+#ifndef __U_BOOT__
+       const struct ata_port_operations *port_ops;
+       void                            *private_data;
+#endif
+};
+
+struct ata_ioports {
+       void __iomem            *cmd_addr;
+       void __iomem            *data_addr;
+       void __iomem            *error_addr;
+       void __iomem            *feature_addr;
+       void __iomem            *nsect_addr;
+       void __iomem            *lbal_addr;
+       void __iomem            *lbam_addr;
+       void __iomem            *lbah_addr;
+       void __iomem            *device_addr;
+       void __iomem            *status_addr;
+       void __iomem            *command_addr;
+       void __iomem            *altstatus_addr;
+       void __iomem            *ctl_addr;
+#ifndef __U_BOOT__
+       void __iomem            *bmdma_addr;
+#endif
+       void __iomem            *scr_addr;
+};
+
+struct ata_host {
+#ifndef __U_BOOT__
+       void __iomem * const    *iomap;
+       void                    *private_data;
+       const struct ata_port_operations *ops;
+       unsigned long           flags;
+       struct ata_port         *simplex_claimed;
+#endif
+       unsigned int            n_ports;
+       struct ata_port         *ports[0];
+};
+
+#ifndef __U_BOOT__
+struct ata_port_stats {
+       unsigned long           unhandled_irq;
+       unsigned long           idle_irq;
+       unsigned long           rw_reqbuf;
+};
+#endif
+
+struct ata_device {
+       struct ata_link         *link;
+       unsigned int            devno;
+       unsigned long           flags;
+       unsigned int            horkage;
+#ifndef __U_BOOT__
+       struct scsi_device      *sdev;
+#ifdef CONFIG_ATA_ACPI
+       acpi_handle             acpi_handle;
+       union acpi_object       *gtf_cache;
+#endif
+#endif
+       u64                     n_sectors;
+       unsigned int            class;
+
+       union {
+               u16             id[ATA_ID_WORDS];
+               u32             gscr[SATA_PMP_GSCR_DWORDS];
+       };
+#ifndef __U_BOOT__
+       u8                      pio_mode;
+       u8                      dma_mode;
+       u8                      xfer_mode;
+       unsigned int            xfer_shift;
+#endif
+       unsigned int            multi_count;
+       unsigned int            max_sectors;
+       unsigned int            cdb_len;
+#ifndef __U_BOOT__
+       unsigned long           pio_mask;
+       unsigned long           mwdma_mask;
+#endif
+       unsigned long           udma_mask;
+       u16                     cylinders;
+       u16                     heads;
+       u16                     sectors;
+#ifndef __U_BOOT__
+       int                     spdn_cnt;
+#endif
+};
+
+enum dma_data_direction {
+       DMA_BIDIRECTIONAL = 0,
+       DMA_TO_DEVICE = 1,
+       DMA_FROM_DEVICE = 2,
+       DMA_NONE = 3,
+};
+
+struct ata_link {
+       struct ata_port         *ap;
+       int                     pmp;
+       unsigned int            active_tag;
+       u32                     sactive;
+       unsigned int            flags;
+       unsigned int            hw_sata_spd_limit;
+#ifndef __U_BOOT__
+       unsigned int            sata_spd_limit;
+       unsigned int            sata_spd;
+       struct ata_device       device[2];
+#endif
+};
+
+struct ata_port {
+       unsigned long           flags;
+       unsigned int            pflags;
+       unsigned int            print_id;
+       unsigned int            port_no;
+
+       struct ata_ioports      ioaddr;
+
+       u8                      ctl;
+       u8                      last_ctl;
+       unsigned int            pio_mask;
+       unsigned int            mwdma_mask;
+       unsigned int            udma_mask;
+       unsigned int            cbl;
+
+       struct ata_queued_cmd   qcmd[ATA_MAX_QUEUE];
+       unsigned long           qc_allocated;
+       unsigned int            qc_active;
+       int                     nr_active_links;
+
+       struct ata_link         link;
+#ifndef __U_BOOT__
+       int                     nr_pmp_links;
+       struct ata_link         *pmp_link;
+#endif
+       struct ata_link         *excl_link;
+       int                     nr_pmp_links;
+#ifndef __U_BOOT__
+       struct ata_port_stats   stats;
+       struct device           *dev;
+       u32                     msg_enable;
+#endif
+       struct ata_host         *host;
+       void                    *port_task_data;
+
+       unsigned int            hsm_task_state;
+       void                    *private_data;
+       unsigned char           *pdata;
+};
+
+#ifndef TRUE
+#define TRUE 1
+#endif
+#ifndef FALSE
+#define FALSE 0
+#endif
+
+#endif
index 6ab7d3d..ce0f301 100644 (file)
@@ -178,6 +178,12 @@ i2c_init(int speed, int slaveadd)
        struct fsl_i2c *dev;
        unsigned int temp;
 
+#ifdef CONFIG_SYS_I2C_INIT_BOARD
+       /* call board specific i2c bus reset routine before accessing the   */
+       /* environment, which might be in a chip on that bus. For details   */
+       /* about this problem see doc/I2C_Edge_Conditions.                  */
+       i2c_init_board();
+#endif
        dev = (struct fsl_i2c *) (CONFIG_SYS_IMMR + CONFIG_SYS_I2C_OFFSET);
 
        writeb(0, &dev->cr);                    /* stop I2C controller */
index 8c736ce..b69ce15 100644 (file)
@@ -859,6 +859,9 @@ int mmc_init(struct mmc *mmc)
        if (err)
                return err;
 
+       mmc_set_bus_width(mmc, 1);
+       mmc_set_clock(mmc, 1);
+
        /* Reset the Card */
        err = mmc_go_idle(mmc);
 
index a5680e8..89ccec2 100644 (file)
@@ -26,14 +26,12 @@ include $(TOPDIR)/config.mk
 LIB    := $(obj)libnand.a
 
 ifdef CONFIG_CMD_NAND
-ifndef CONFIG_NAND_LEGACY
 COBJS-y += nand.o
 COBJS-y += nand_base.o
 COBJS-y += nand_bbt.o
 COBJS-y += nand_ecc.o
 COBJS-y += nand_ids.o
 COBJS-y += nand_util.o
-endif
 
 COBJS-$(CONFIG_NAND_ATMEL) += atmel_nand.o
 COBJS-$(CONFIG_DRIVER_NAND_BFIN) += bfin_nand.o
@@ -42,6 +40,7 @@ COBJS-$(CONFIG_NAND_FSL_ELBC) += fsl_elbc_nand.o
 COBJS-$(CONFIG_NAND_FSL_UPM) += fsl_upm.o
 COBJS-$(CONFIG_NAND_KIRKWOOD) += kirkwood_nand.o
 COBJS-$(CONFIG_NAND_MPC5121_NFC) += mpc5121_nfc.o
+COBJS-$(CONFIG_NAND_NDFC) += ndfc.o
 COBJS-$(CONFIG_NAND_NOMADIK) += nomadik.o
 COBJS-$(CONFIG_NAND_S3C2410) += s3c2410_nand.o
 COBJS-$(CONFIG_NAND_S3C64XX) += s3c64xx.o
index ca40c6a..7837a8e 100644 (file)
@@ -182,7 +182,7 @@ static void nand_flash_init(void)
         * knowledge of the clocks and what devices are hooked up ... and
         * don't even do that unless no UBL handled it.
         */
-#ifdef CONFIG_SOC_DM6446
+#ifdef CONFIG_SOC_DM644X
        u_int32_t       acfg1 = 0x3ffffffc;
 
        /*------------------------------------------------------------------*
index e9dc4d1..edf3a09 100644 (file)
@@ -19,8 +19,6 @@
 
 #include <common.h>
 
-#if !defined(CONFIG_NAND_LEGACY)
-
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/sched.h>
@@ -1779,4 +1777,3 @@ module_exit(cleanup_nanddoc);
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("David Woodhouse <dwmw2@infradead.org>");
 MODULE_DESCRIPTION("M-Systems DiskOnChip 2000, Millennium and Millennium Plus device driver\n");
-#endif
index fc16282..694ead6 100644 (file)
@@ -567,10 +567,10 @@ int nand_read_skip_bad(nand_info_t *nand, loff_t offset, size_t *length,
 
        if (len_incl_bad == *length) {
                rval = nand_read (nand, offset, length, buffer);
-               if (rval != 0)
-                       printf ("NAND read from offset %llx failed %d\n",
-                               offset, rval);
-
+               if (!rval || rval == -EUCLEAN)
+                       return 0;
+               printf ("NAND read from offset %llx failed %d\n",
+                       offset, rval);
                return rval;
        }
 
@@ -591,7 +591,7 @@ int nand_read_skip_bad(nand_info_t *nand, loff_t offset, size_t *length,
                        read_length = nand->erasesize - block_offset;
 
                rval = nand_read (nand, offset, &read_length, p_buffer);
-               if (rval != 0) {
+               if (rval && rval != -EUCLEAN) {
                        printf ("NAND read from offset %llx failed %d\n",
                                offset, rval);
                        *length -= left_to_read;
similarity index 98%
rename from cpu/ppc4xx/ndfc.c
rename to drivers/mtd/nand/ndfc.c
index 971e2ae..528b22b 100644 (file)
  */
 
 #include <common.h>
-
-#if defined(CONFIG_CMD_NAND) && !defined(CONFIG_NAND_LEGACY) && \
-    defined(CONFIG_NAND_NDFC)
-
 #include <nand.h>
 #include <linux/mtd/ndfc.h>
 #include <linux/mtd/nand_ecc.h>
@@ -219,5 +215,3 @@ int board_nand_init(struct nand_chip *nand)
 
        return 0;
 }
-
-#endif
diff --git a/drivers/mtd/nand_legacy/Makefile b/drivers/mtd/nand_legacy/Makefile
deleted file mode 100644 (file)
index a1a9cc9..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-#
-# (C) Copyright 2006
-# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
-#
-# See file CREDITS for list of people who contributed to this
-# project.
-#
-# 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.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
-# MA 02111-1307 USA
-#
-
-include $(TOPDIR)/config.mk
-
-LIB    := $(obj)libnand_legacy.a
-
-ifdef CONFIG_CMD_NAND
-COBJS-$(CONFIG_NAND_LEGACY)    := nand_legacy.o
-endif
-
-COBJS  := $(COBJS-y)
-SRCS   := $(COBJS:.o=.c)
-OBJS   := $(addprefix $(obj),$(COBJS))
-
-all:   $(LIB)
-
-$(LIB):        $(obj).depend $(OBJS)
-       $(AR) $(ARFLAGS) $@ $(OBJS)
-
-#########################################################################
-
-# defines $(obj).depend target
-include $(SRCTREE)/rules.mk
-
-sinclude $(obj).depend
-
-#########################################################################
diff --git a/drivers/mtd/nand_legacy/nand_legacy.c b/drivers/mtd/nand_legacy/nand_legacy.c
deleted file mode 100644 (file)
index d9ae9c7..0000000
+++ /dev/null
@@ -1,1610 +0,0 @@
-/*
- * (C) 2006 Denx
- * 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>
-#include <command.h>
-#include <malloc.h>
-#include <asm/io.h>
-#include <watchdog.h>
-#include <linux/mtd/nand_legacy.h>
-#include <linux/mtd/nand_ids.h>
-#include <jffs2/jffs2.h>
-
-#error Legacy NAND is deprecated.  Please convert to the current NAND interface.
-#error This code will be removed outright in the next release.
-
-#ifdef CONFIG_OMAP1510
-void archflashwp(void *archdata, int wp);
-#endif
-
-#define ROUND_DOWN(value,boundary)      ((value) & (~((boundary)-1)))
-
-#undef PSYCHO_DEBUG
-#undef NAND_DEBUG
-
-/* ****************** WARNING *********************
- * When ALLOW_ERASE_BAD_DEBUG is non-zero the erase command will
- * erase (or at least attempt to erase) blocks that are marked
- * bad. This can be very handy if you are _sure_ that the block
- * is OK, say because you marked a good block bad to test bad
- * block handling and you are done testing, or if you have
- * accidentally marked blocks bad.
- *
- * Erasing factory marked bad blocks is a _bad_ idea. If the
- * erase succeeds there is no reliable way to find them again,
- * and attempting to program or erase bad blocks can affect
- * the data in _other_ (good) blocks.
- */
-#define         ALLOW_ERASE_BAD_DEBUG 0
-
-#define CONFIG_MTD_NAND_ECC  /* enable ECC */
-#define CONFIG_MTD_NAND_ECC_JFFS2
-
-/* bits for nand_legacy_rw() `cmd'; or together as needed */
-#define NANDRW_READ    0x01
-#define NANDRW_WRITE   0x00
-#define NANDRW_JFFS2   0x02
-#define NANDRW_JFFS2_SKIP      0x04
-
-
-/*
- * Exported variables etc.
- */
-
-/* Definition of the out of band configuration structure */
-struct nand_oob_config {
-       /* position of ECC bytes inside oob */
-       int ecc_pos[6];
-       /* position of  bad blk flag inside oob -1 = inactive */
-       int badblock_pos;
-       /* position of ECC valid flag inside oob -1 = inactive */
-       int eccvalid_pos;
-} oob_config = { {0}, 0, 0};
-
-struct nand_chip nand_dev_desc[CONFIG_SYS_MAX_NAND_DEVICE] = {{0}};
-
-int curr_device = -1; /* Current NAND Device */
-
-
-/*
- * Exported functionss
- */
-int nand_legacy_erase(struct nand_chip* nand, size_t ofs,
-                    size_t len, int clean);
-int nand_legacy_rw(struct nand_chip* nand, int cmd,
-                 size_t start, size_t len,
-                 size_t * retlen, u_char * buf);
-void nand_print(struct nand_chip *nand);
-void nand_print_bad(struct nand_chip *nand);
-int nand_read_oob(struct nand_chip* nand, size_t ofs, size_t len,
-                size_t * retlen, u_char * buf);
-int nand_write_oob(struct nand_chip* nand, size_t ofs, size_t len,
-                size_t * retlen, const u_char * buf);
-
-/*
- * Internals
- */
-static int NanD_WaitReady(struct nand_chip *nand, int ale_wait);
-static int nand_read_ecc(struct nand_chip *nand, size_t start, size_t len,
-                size_t * retlen, u_char *buf, u_char *ecc_code);
-static int nand_write_ecc (struct nand_chip* nand, size_t to, size_t len,
-                          size_t * retlen, const u_char * buf,
-                          u_char * ecc_code);
-#ifdef CONFIG_MTD_NAND_ECC
-static int nand_correct_data (u_char *dat, u_char *read_ecc, u_char *calc_ecc);
-static void nand_calculate_ecc (const u_char *dat, u_char *ecc_code);
-#endif
-
-
-/*
- *
- * Function definitions
- *
- */
-
-/* returns 0 if block containing pos is OK:
- *             valid erase block and
- *             not marked bad, or no bad mark position is specified
- * returns 1 if marked bad or otherwise invalid
- */
-static int check_block (struct nand_chip *nand, unsigned long pos)
-{
-       size_t retlen;
-       uint8_t oob_data;
-       uint16_t oob_data16[6];
-       int page0 = pos & (-nand->erasesize);
-       int page1 = page0 + nand->oobblock;
-       int badpos = oob_config.badblock_pos;
-
-       if (pos >= nand->totlen)
-               return 1;
-
-       if (badpos < 0)
-               return 0;       /* no way to check, assume OK */
-
-       if (nand->bus16) {
-               if (nand_read_oob(nand, (page0 + 0), 12, &retlen, (uint8_t *)oob_data16)
-                   || (oob_data16[2] & 0xff00) != 0xff00)
-                       return 1;
-               if (nand_read_oob(nand, (page1 + 0), 12, &retlen, (uint8_t *)oob_data16)
-                   || (oob_data16[2] & 0xff00) != 0xff00)
-                       return 1;
-       } else {
-               /* Note - bad block marker can be on first or second page */
-               if (nand_read_oob(nand, page0 + badpos, 1, &retlen, (unsigned char *)&oob_data)
-                   || oob_data != 0xff
-                   || nand_read_oob (nand, page1 + badpos, 1, &retlen, (unsigned char *)&oob_data)
-                   || oob_data != 0xff)
-                       return 1;
-       }
-
-       return 0;
-}
-
-/* print bad blocks in NAND flash */
-void nand_print_bad(struct nand_chip* nand)
-{
-       unsigned long pos;
-
-       for (pos = 0; pos < nand->totlen; pos += nand->erasesize) {
-               if (check_block(nand, pos))
-                       printf(" 0x%8.8lx\n", pos);
-       }
-       puts("\n");
-}
-
-/* cmd: 0: NANDRW_WRITE                        write, fail on bad block
- *     1: NANDRW_READ                  read, fail on bad block
- *     2: NANDRW_WRITE | NANDRW_JFFS2  write, skip bad blocks
- *     3: NANDRW_READ | NANDRW_JFFS2   read, data all 0xff for bad blocks
- *      7: NANDRW_READ | NANDRW_JFFS2 | NANDRW_JFFS2_SKIP read, skip bad blocks
- */
-int nand_legacy_rw (struct nand_chip* nand, int cmd,
-                  size_t start, size_t len,
-                  size_t * retlen, u_char * buf)
-{
-       int ret = 0, n, total = 0;
-       char eccbuf[6];
-       /* eblk (once set) is the start of the erase block containing the
-        * data being processed.
-        */
-       unsigned long eblk = ~0;        /* force mismatch on first pass */
-       unsigned long erasesize = nand->erasesize;
-
-       while (len) {
-               if ((start & (-erasesize)) != eblk) {
-                       /* have crossed into new erase block, deal with
-                        * it if it is sure marked bad.
-                        */
-                       eblk = start & (-erasesize); /* start of block */
-                       if (check_block(nand, eblk)) {
-                               if (cmd == (NANDRW_READ | NANDRW_JFFS2)) {
-                                       while (len > 0 &&
-                                              start - eblk < erasesize) {
-                                               *(buf++) = 0xff;
-                                               ++start;
-                                               ++total;
-                                               --len;
-                                       }
-                                       continue;
-                               } else if (cmd == (NANDRW_READ | NANDRW_JFFS2 | NANDRW_JFFS2_SKIP)) {
-                                       start += erasesize;
-                                       continue;
-                               } else if (cmd == (NANDRW_WRITE | NANDRW_JFFS2)) {
-                                       /* skip bad block */
-                                       start += erasesize;
-                                       continue;
-                               } else {
-                                       ret = 1;
-                                       break;
-                               }
-                       }
-               }
-               /* The ECC will not be calculated correctly if
-                  less than 512 is written or read */
-               /* Is request at least 512 bytes AND it starts on a proper boundry */
-               if((start != ROUND_DOWN(start, 0x200)) || (len < 0x200))
-                       printf("Warning block writes should be at least 512 bytes and start on a 512 byte boundry\n");
-
-               if (cmd & NANDRW_READ) {
-                       ret = nand_read_ecc(nand, start,
-                                          min(len, eblk + erasesize - start),
-                                          (size_t *)&n, (u_char*)buf, (u_char *)eccbuf);
-               } else {
-                       ret = nand_write_ecc(nand, start,
-                                           min(len, eblk + erasesize - start),
-                                           (size_t *)&n, (u_char*)buf, (u_char *)eccbuf);
-               }
-
-               if (ret)
-                       break;
-
-               start  += n;
-               buf   += n;
-               total += n;
-               len   -= n;
-       }
-       if (retlen)
-               *retlen = total;
-
-       return ret;
-}
-
-void nand_print(struct nand_chip *nand)
-{
-       if (nand->numchips > 1) {
-               printf("%s at 0x%lx,\n"
-                      "\t  %d chips %s, size %d MB, \n"
-                      "\t  total size %ld MB, sector size %ld kB\n",
-                      nand->name, nand->IO_ADDR, nand->numchips,
-                      nand->chips_name, 1 << (nand->chipshift - 20),
-                      nand->totlen >> 20, nand->erasesize >> 10);
-       }
-       else {
-               printf("%s at 0x%lx (", nand->chips_name, nand->IO_ADDR);
-               print_size(nand->totlen, ", ");
-               print_size(nand->erasesize, " sector)\n");
-       }
-}
-
-/* ------------------------------------------------------------------------- */
-
-static int NanD_WaitReady(struct nand_chip *nand, int ale_wait)
-{
-       /* This is inline, to optimise the common case, where it's ready instantly */
-       int ret = 0;
-
-#ifdef NAND_NO_RB      /* in config file, shorter delays currently wrap accesses */
-       if(ale_wait)
-               NAND_WAIT_READY(nand);  /* do the worst case 25us wait */
-       else
-               udelay(10);
-#else  /* has functional r/b signal */
-       NAND_WAIT_READY(nand);
-#endif
-       return ret;
-}
-
-/* NanD_Command: Send a flash command to the flash chip */
-
-static inline int NanD_Command(struct nand_chip *nand, unsigned char command)
-{
-       unsigned long nandptr = nand->IO_ADDR;
-
-       /* Assert the CLE (Command Latch Enable) line to the flash chip */
-       NAND_CTL_SETCLE(nandptr);
-
-       /* Send the command */
-       WRITE_NAND_COMMAND(command, nandptr);
-
-       /* Lower the CLE line */
-       NAND_CTL_CLRCLE(nandptr);
-
-#ifdef NAND_NO_RB
-       if(command == NAND_CMD_RESET){
-               u_char ret_val;
-               NanD_Command(nand, NAND_CMD_STATUS);
-               do {
-                       ret_val = READ_NAND(nandptr);/* wait till ready */
-               } while((ret_val & 0x40) != 0x40);
-       }
-#endif
-       return NanD_WaitReady(nand, 0);
-}
-
-/* NanD_Address: Set the current address for the flash chip */
-
-static int NanD_Address(struct nand_chip *nand, int numbytes, unsigned long ofs)
-{
-       unsigned long nandptr;
-       int i;
-
-       nandptr = nand->IO_ADDR;
-
-       /* Assert the ALE (Address Latch Enable) line to the flash chip */
-       NAND_CTL_SETALE(nandptr);
-
-       /* Send the address */
-       /* Devices with 256-byte page are addressed as:
-        * Column (bits 0-7), Page (bits 8-15, 16-23, 24-31)
-        * there is no device on the market with page256
-        * and more than 24 bits.
-        * Devices with 512-byte page are addressed as:
-        * Column (bits 0-7), Page (bits 9-16, 17-24, 25-31)
-        * 25-31 is sent only if the chip support it.
-        * bit 8 changes the read command to be sent
-        * (NAND_CMD_READ0 or NAND_CMD_READ1).
-        */
-
-       if (numbytes == ADDR_COLUMN || numbytes == ADDR_COLUMN_PAGE)
-               WRITE_NAND_ADDRESS(ofs, nandptr);
-
-       ofs = ofs >> nand->page_shift;
-
-       if (numbytes == ADDR_PAGE || numbytes == ADDR_COLUMN_PAGE) {
-               for (i = 0; i < nand->pageadrlen; i++, ofs = ofs >> 8) {
-                       WRITE_NAND_ADDRESS(ofs, nandptr);
-               }
-       }
-
-       /* Lower the ALE line */
-       NAND_CTL_CLRALE(nandptr);
-
-       /* Wait for the chip to respond */
-       return NanD_WaitReady(nand, 1);
-}
-
-/* NanD_SelectChip: Select a given flash chip within the current floor */
-
-static inline int NanD_SelectChip(struct nand_chip *nand, int chip)
-{
-       /* Wait for it to be ready */
-       return NanD_WaitReady(nand, 0);
-}
-
-/* NanD_IdentChip: Identify a given NAND chip given {floor,chip} */
-
-static int NanD_IdentChip(struct nand_chip *nand, int floor, int chip)
-{
-       int mfr, id, i;
-
-       NAND_ENABLE_CE(nand);  /* set pin low */
-       /* Reset the chip */
-       if (NanD_Command(nand, NAND_CMD_RESET)) {
-#ifdef NAND_DEBUG
-               printf("NanD_Command (reset) for %d,%d returned true\n",
-                      floor, chip);
-#endif
-               NAND_DISABLE_CE(nand);  /* set pin high */
-               return 0;
-       }
-
-       /* Read the NAND chip ID: 1. Send ReadID command */
-       if (NanD_Command(nand, NAND_CMD_READID)) {
-#ifdef NAND_DEBUG
-               printf("NanD_Command (ReadID) for %d,%d returned true\n",
-                      floor, chip);
-#endif
-               NAND_DISABLE_CE(nand);  /* set pin high */
-               return 0;
-       }
-
-       /* Read the NAND chip ID: 2. Send address byte zero */
-       NanD_Address(nand, ADDR_COLUMN, 0);
-
-       /* Read the manufacturer and device id codes from the device */
-
-       mfr = READ_NAND(nand->IO_ADDR);
-
-       id = READ_NAND(nand->IO_ADDR);
-
-       NAND_DISABLE_CE(nand);  /* set pin high */
-
-#ifdef NAND_DEBUG
-       printf("NanD_Command (ReadID) got %x %x\n", mfr, id);
-#endif
-       if (mfr == 0xff || mfr == 0) {
-               /* No response - return failure */
-               return 0;
-       }
-
-       /* Check it's the same as the first chip we identified.
-        * M-Systems say that any given nand_chip device should only
-        * contain _one_ type of flash part, although that's not a
-        * hardware restriction. */
-       if (nand->mfr) {
-               if (nand->mfr == mfr && nand->id == id) {
-                       return 1;       /* This is another the same the first */
-               } else {
-                       printf("Flash chip at floor %d, chip %d is different:\n",
-                              floor, chip);
-               }
-       }
-
-       /* Print and store the manufacturer and ID codes. */
-       for (i = 0; nand_flash_ids[i].name != NULL; i++) {
-               if (mfr == nand_flash_ids[i].manufacture_id &&
-                   id == nand_flash_ids[i].model_id) {
-#ifdef NAND_DEBUG
-                       printf("Flash chip found:\n\t Manufacturer ID: 0x%2.2X, "
-                              "Chip ID: 0x%2.2X (%s)\n", mfr, id,
-                              nand_flash_ids[i].name);
-#endif
-                       if (!nand->mfr) {
-                               nand->mfr = mfr;
-                               nand->id = id;
-                               nand->chipshift =
-                                   nand_flash_ids[i].chipshift;
-                               nand->page256 = nand_flash_ids[i].page256;
-                               nand->eccsize = 256;
-                               if (nand->page256) {
-                                       nand->oobblock = 256;
-                                       nand->oobsize = 8;
-                                       nand->page_shift = 8;
-                               } else {
-                                       nand->oobblock = 512;
-                                       nand->oobsize = 16;
-                                       nand->page_shift = 9;
-                               }
-                               nand->pageadrlen = nand_flash_ids[i].pageadrlen;
-                               nand->erasesize  = nand_flash_ids[i].erasesize;
-                               nand->chips_name = nand_flash_ids[i].name;
-                               nand->bus16      = nand_flash_ids[i].bus16;
-                               return 1;
-                       }
-                       return 0;
-               }
-       }
-
-
-#ifdef NAND_DEBUG
-       /* We haven't fully identified the chip. Print as much as we know. */
-       printf("Unknown flash chip found: %2.2X %2.2X\n",
-              id, mfr);
-#endif
-
-       return 0;
-}
-
-/* NanD_ScanChips: Find all NAND chips present in a nand_chip, and identify them */
-
-static void NanD_ScanChips(struct nand_chip *nand)
-{
-       int floor, chip;
-       int numchips[NAND_MAX_FLOORS];
-       int maxchips = CONFIG_SYS_NAND_MAX_CHIPS;
-       int ret = 1;
-
-       nand->numchips = 0;
-       nand->mfr = 0;
-       nand->id = 0;
-
-
-       /* For each floor, find the number of valid chips it contains */
-       for (floor = 0; floor < NAND_MAX_FLOORS; floor++) {
-               ret = 1;
-               numchips[floor] = 0;
-               for (chip = 0; chip < maxchips && ret != 0; chip++) {
-
-                       ret = NanD_IdentChip(nand, floor, chip);
-                       if (ret) {
-                               numchips[floor]++;
-                               nand->numchips++;
-                       }
-               }
-       }
-
-       /* If there are none at all that we recognise, bail */
-       if (!nand->numchips) {
-#ifdef NAND_DEBUG
-               puts ("No NAND flash chips recognised.\n");
-#endif
-               return;
-       }
-
-       /* Allocate an array to hold the information for each chip */
-       nand->chips = malloc(sizeof(struct Nand) * nand->numchips);
-       if (!nand->chips) {
-               puts ("No memory for allocating chip info structures\n");
-               return;
-       }
-
-       ret = 0;
-
-       /* Fill out the chip array with {floor, chipno} for each
-        * detected chip in the device. */
-       for (floor = 0; floor < NAND_MAX_FLOORS; floor++) {
-               for (chip = 0; chip < numchips[floor]; chip++) {
-                       nand->chips[ret].floor = floor;
-                       nand->chips[ret].chip = chip;
-                       nand->chips[ret].curadr = 0;
-                       nand->chips[ret].curmode = 0x50;
-                       ret++;
-               }
-       }
-
-       /* Calculate and print the total size of the device */
-       nand->totlen = nand->numchips * (1 << nand->chipshift);
-
-#ifdef NAND_DEBUG
-       printf("%d flash chips found. Total nand_chip size: %ld MB\n",
-              nand->numchips, nand->totlen >> 20);
-#endif
-}
-
-/* we need to be fast here, 1 us per read translates to 1 second per meg */
-static void NanD_ReadBuf (struct nand_chip *nand, u_char * data_buf, int cntr)
-{
-       unsigned long nandptr = nand->IO_ADDR;
-
-       NanD_Command (nand, NAND_CMD_READ0);
-
-       if (nand->bus16) {
-               u16 val;
-
-               while (cntr >= 16) {
-                       val = READ_NAND (nandptr);
-                       *data_buf++ = val & 0xff;
-                       *data_buf++ = val >> 8;
-                       val = READ_NAND (nandptr);
-                       *data_buf++ = val & 0xff;
-                       *data_buf++ = val >> 8;
-                       val = READ_NAND (nandptr);
-                       *data_buf++ = val & 0xff;
-                       *data_buf++ = val >> 8;
-                       val = READ_NAND (nandptr);
-                       *data_buf++ = val & 0xff;
-                       *data_buf++ = val >> 8;
-                       val = READ_NAND (nandptr);
-                       *data_buf++ = val & 0xff;
-                       *data_buf++ = val >> 8;
-                       val = READ_NAND (nandptr);
-                       *data_buf++ = val & 0xff;
-                       *data_buf++ = val >> 8;
-                       val = READ_NAND (nandptr);
-                       *data_buf++ = val & 0xff;
-                       *data_buf++ = val >> 8;
-                       val = READ_NAND (nandptr);
-                       *data_buf++ = val & 0xff;
-                       *data_buf++ = val >> 8;
-                       cntr -= 16;
-               }
-
-               while (cntr > 0) {
-                       val = READ_NAND (nandptr);
-                       *data_buf++ = val & 0xff;
-                       *data_buf++ = val >> 8;
-                       cntr -= 2;
-               }
-       } else {
-               while (cntr >= 16) {
-                       *data_buf++ = READ_NAND (nandptr);
-                       *data_buf++ = READ_NAND (nandptr);
-                       *data_buf++ = READ_NAND (nandptr);
-                       *data_buf++ = READ_NAND (nandptr);
-                       *data_buf++ = READ_NAND (nandptr);
-                       *data_buf++ = READ_NAND (nandptr);
-                       *data_buf++ = READ_NAND (nandptr);
-                       *data_buf++ = READ_NAND (nandptr);
-                       *data_buf++ = READ_NAND (nandptr);
-                       *data_buf++ = READ_NAND (nandptr);
-                       *data_buf++ = READ_NAND (nandptr);
-                       *data_buf++ = READ_NAND (nandptr);
-                       *data_buf++ = READ_NAND (nandptr);
-                       *data_buf++ = READ_NAND (nandptr);
-                       *data_buf++ = READ_NAND (nandptr);
-                       *data_buf++ = READ_NAND (nandptr);
-                       cntr -= 16;
-               }
-
-               while (cntr > 0) {
-                       *data_buf++ = READ_NAND (nandptr);
-                       cntr--;
-               }
-       }
-}
-
-/*
- * NAND read with ECC
- */
-static int nand_read_ecc(struct nand_chip *nand, size_t start, size_t len,
-                size_t * retlen, u_char *buf, u_char *ecc_code)
-{
-       int col, page;
-       int ecc_status = 0;
-#ifdef CONFIG_MTD_NAND_ECC
-       int j;
-       int ecc_failed = 0;
-       u_char *data_poi;
-       u_char ecc_calc[6];
-#endif
-
-       /* Do not allow reads past end of device */
-       if ((start + len) > nand->totlen) {
-               printf ("%s: Attempt read beyond end of device %x %x %x\n",
-                       __FUNCTION__, (uint) start, (uint) len, (uint) nand->totlen);
-               *retlen = 0;
-               return -1;
-       }
-
-       /* First we calculate the starting page */
-       /*page = shr(start, nand->page_shift);*/
-       page = start >> nand->page_shift;
-
-       /* Get raw starting column */
-       col = start & (nand->oobblock - 1);
-
-       /* Initialize return value */
-       *retlen = 0;
-
-       /* Select the NAND device */
-       NAND_ENABLE_CE(nand);  /* set pin low */
-
-       /* Loop until all data read */
-       while (*retlen < len) {
-
-#ifdef CONFIG_MTD_NAND_ECC
-               /* Do we have this page in cache ? */
-               if (nand->cache_page == page)
-                       goto readdata;
-               /* Send the read command */
-               NanD_Command(nand, NAND_CMD_READ0);
-               if (nand->bus16) {
-                       NanD_Address(nand, ADDR_COLUMN_PAGE,
-                                    (page << nand->page_shift) + (col >> 1));
-               } else {
-                       NanD_Address(nand, ADDR_COLUMN_PAGE,
-                                    (page << nand->page_shift) + col);
-               }
-
-               /* Read in a page + oob data */
-               NanD_ReadBuf(nand, nand->data_buf, nand->oobblock + nand->oobsize);
-
-               /* copy data into cache, for read out of cache and if ecc fails */
-               if (nand->data_cache) {
-                       memcpy (nand->data_cache, nand->data_buf,
-                               nand->oobblock + nand->oobsize);
-               }
-
-               /* Pick the ECC bytes out of the oob data */
-               for (j = 0; j < 6; j++) {
-                       ecc_code[j] = nand->data_buf[(nand->oobblock + oob_config.ecc_pos[j])];
-               }
-
-               /* Calculate the ECC and verify it */
-               /* If block was not written with ECC, skip ECC */
-               if (oob_config.eccvalid_pos != -1 &&
-                   (nand->data_buf[nand->oobblock + oob_config.eccvalid_pos] & 0x0f) != 0x0f) {
-
-                       nand_calculate_ecc (&nand->data_buf[0], &ecc_calc[0]);
-                       switch (nand_correct_data (&nand->data_buf[0], &ecc_code[0], &ecc_calc[0])) {
-                       case -1:
-                               printf ("%s: Failed ECC read, page 0x%08x\n", __FUNCTION__, page);
-                               ecc_failed++;
-                               break;
-                       case 1:
-                       case 2: /* transfer ECC corrected data to cache */
-                               if (nand->data_cache)
-                                       memcpy (nand->data_cache, nand->data_buf, 256);
-                               break;
-                       }
-               }
-
-               if (oob_config.eccvalid_pos != -1 &&
-                   nand->oobblock == 512 && (nand->data_buf[nand->oobblock + oob_config.eccvalid_pos] & 0xf0) != 0xf0) {
-
-                       nand_calculate_ecc (&nand->data_buf[256], &ecc_calc[3]);
-                       switch (nand_correct_data (&nand->data_buf[256], &ecc_code[3], &ecc_calc[3])) {
-                       case -1:
-                               printf ("%s: Failed ECC read, page 0x%08x\n", __FUNCTION__, page);
-                               ecc_failed++;
-                               break;
-                       case 1:
-                       case 2: /* transfer ECC corrected data to cache */
-                               if (nand->data_cache)
-                                       memcpy (&nand->data_cache[256], &nand->data_buf[256], 256);
-                               break;
-                       }
-               }
-readdata:
-               /* Read the data from ECC data buffer into return buffer */
-               data_poi = (nand->data_cache) ? nand->data_cache : nand->data_buf;
-               data_poi += col;
-               if ((*retlen + (nand->oobblock - col)) >= len) {
-                       memcpy (buf + *retlen, data_poi, len - *retlen);
-                       *retlen = len;
-               } else {
-                       memcpy (buf + *retlen, data_poi,  nand->oobblock - col);
-                       *retlen += nand->oobblock - col;
-               }
-               /* Set cache page address, invalidate, if ecc_failed */
-               nand->cache_page = (nand->data_cache && !ecc_failed) ? page : -1;
-
-               ecc_status += ecc_failed;
-               ecc_failed = 0;
-
-#else
-               /* Send the read command */
-               NanD_Command(nand, NAND_CMD_READ0);
-               if (nand->bus16) {
-                       NanD_Address(nand, ADDR_COLUMN_PAGE,
-                                    (page << nand->page_shift) + (col >> 1));
-               } else {
-                       NanD_Address(nand, ADDR_COLUMN_PAGE,
-                                    (page << nand->page_shift) + col);
-               }
-
-               /* Read the data directly into the return buffer */
-               if ((*retlen + (nand->oobblock - col)) >= len) {
-                       NanD_ReadBuf(nand, buf + *retlen, len - *retlen);
-                       *retlen = len;
-                       /* We're done */
-                       continue;
-               } else {
-                       NanD_ReadBuf(nand, buf + *retlen, nand->oobblock - col);
-                       *retlen += nand->oobblock - col;
-                       }
-#endif
-               /* For subsequent reads align to page boundary. */
-               col = 0;
-               /* Increment page address */
-               page++;
-       }
-
-       /* De-select the NAND device */
-       NAND_DISABLE_CE(nand);  /* set pin high */
-
-       /*
-        * Return success, if no ECC failures, else -EIO
-        * fs driver will take care of that, because
-        * retlen == desired len and result == -EIO
-        */
-       return ecc_status ? -1 : 0;
-}
-
-/*
- *     Nand_page_program function is used for write and writev !
- */
-static int nand_write_page (struct nand_chip *nand,
-                           int page, int col, int last, u_char * ecc_code)
-{
-
-       int i;
-       unsigned long nandptr = nand->IO_ADDR;
-
-#ifdef CONFIG_MTD_NAND_ECC
-#ifdef CONFIG_MTD_NAND_VERIFY_WRITE
-       int ecc_bytes = (nand->oobblock == 512) ? 6 : 3;
-#endif
-#endif
-       /* pad oob area */
-       for (i = nand->oobblock; i < nand->oobblock + nand->oobsize; i++)
-               nand->data_buf[i] = 0xff;
-
-#ifdef CONFIG_MTD_NAND_ECC
-       /* Zero out the ECC array */
-       for (i = 0; i < 6; i++)
-               ecc_code[i] = 0x00;
-
-       /* Read back previous written data, if col > 0 */
-       if (col) {
-               NanD_Command (nand, NAND_CMD_READ0);
-               if (nand->bus16) {
-                       NanD_Address (nand, ADDR_COLUMN_PAGE,
-                                     (page << nand->page_shift) + (col >> 1));
-               } else {
-                       NanD_Address (nand, ADDR_COLUMN_PAGE,
-                                     (page << nand->page_shift) + col);
-               }
-
-               if (nand->bus16) {
-                       u16 val;
-
-                       for (i = 0; i < col; i += 2) {
-                               val = READ_NAND (nandptr);
-                               nand->data_buf[i] = val & 0xff;
-                               nand->data_buf[i + 1] = val >> 8;
-                       }
-               } else {
-                       for (i = 0; i < col; i++)
-                               nand->data_buf[i] = READ_NAND (nandptr);
-               }
-       }
-
-       /* Calculate and write the ECC if we have enough data */
-       if ((col < nand->eccsize) && (last >= nand->eccsize)) {
-               nand_calculate_ecc (&nand->data_buf[0], &(ecc_code[0]));
-               for (i = 0; i < 3; i++) {
-                       nand->data_buf[(nand->oobblock +
-                                       oob_config.ecc_pos[i])] = ecc_code[i];
-               }
-               if (oob_config.eccvalid_pos != -1) {
-                       nand->data_buf[nand->oobblock +
-                                      oob_config.eccvalid_pos] = 0xf0;
-               }
-       }
-
-       /* Calculate and write the second ECC if we have enough data */
-       if ((nand->oobblock == 512) && (last == nand->oobblock)) {
-               nand_calculate_ecc (&nand->data_buf[256], &(ecc_code[3]));
-               for (i = 3; i < 6; i++) {
-                       nand->data_buf[(nand->oobblock +
-                                       oob_config.ecc_pos[i])] = ecc_code[i];
-               }
-               if (oob_config.eccvalid_pos != -1) {
-                       nand->data_buf[nand->oobblock +
-                                      oob_config.eccvalid_pos] &= 0x0f;
-               }
-       }
-#endif
-       /* Prepad for partial page programming !!! */
-       for (i = 0; i < col; i++)
-               nand->data_buf[i] = 0xff;
-
-       /* Postpad for partial page programming !!! oob is already padded */
-       for (i = last; i < nand->oobblock; i++)
-               nand->data_buf[i] = 0xff;
-
-       /* Send command to begin auto page programming */
-       NanD_Command (nand, NAND_CMD_READ0);
-       NanD_Command (nand, NAND_CMD_SEQIN);
-       if (nand->bus16) {
-               NanD_Address (nand, ADDR_COLUMN_PAGE,
-                             (page << nand->page_shift) + (col >> 1));
-       } else {
-               NanD_Address (nand, ADDR_COLUMN_PAGE,
-                             (page << nand->page_shift) + col);
-       }
-
-       /* Write out complete page of data */
-       if (nand->bus16) {
-               for (i = 0; i < (nand->oobblock + nand->oobsize); i += 2) {
-                       WRITE_NAND (nand->data_buf[i] +
-                                   (nand->data_buf[i + 1] << 8),
-                                   nand->IO_ADDR);
-               }
-       } else {
-               for (i = 0; i < (nand->oobblock + nand->oobsize); i++)
-                       WRITE_NAND (nand->data_buf[i], nand->IO_ADDR);
-       }
-
-       /* Send command to actually program the data */
-       NanD_Command (nand, NAND_CMD_PAGEPROG);
-       NanD_Command (nand, NAND_CMD_STATUS);
-#ifdef NAND_NO_RB
-       {
-               u_char ret_val;
-
-               do {
-                       ret_val = READ_NAND (nandptr);  /* wait till ready */
-               } while ((ret_val & 0x40) != 0x40);
-       }
-#endif
-       /* See if device thinks it succeeded */
-       if (READ_NAND (nand->IO_ADDR) & 0x01) {
-               printf ("%s: Failed write, page 0x%08x, ", __FUNCTION__,
-                       page);
-               return -1;
-       }
-#ifdef CONFIG_MTD_NAND_VERIFY_WRITE
-       /*
-        * The NAND device assumes that it is always writing to
-        * a cleanly erased page. Hence, it performs its internal
-        * write verification only on bits that transitioned from
-        * 1 to 0. The device does NOT verify the whole page on a
-        * byte by byte basis. It is possible that the page was
-        * not completely erased or the page is becoming unusable
-        * due to wear. The read with ECC would catch the error
-        * later when the ECC page check fails, but we would rather
-        * catch it early in the page write stage. Better to write
-        * no data than invalid data.
-        */
-
-       /* Send command to read back the page */
-       if (col < nand->eccsize)
-               NanD_Command (nand, NAND_CMD_READ0);
-       else
-               NanD_Command (nand, NAND_CMD_READ1);
-       if (nand->bus16) {
-               NanD_Address (nand, ADDR_COLUMN_PAGE,
-                             (page << nand->page_shift) + (col >> 1));
-       } else {
-               NanD_Address (nand, ADDR_COLUMN_PAGE,
-                             (page << nand->page_shift) + col);
-       }
-
-       /* Loop through and verify the data */
-       if (nand->bus16) {
-               for (i = col; i < last; i = +2) {
-                       if ((nand->data_buf[i] +
-                            (nand->data_buf[i + 1] << 8)) != READ_NAND (nand->IO_ADDR)) {
-                               printf ("%s: Failed write verify, page 0x%08x ",
-                                       __FUNCTION__, page);
-                               return -1;
-                       }
-               }
-       } else {
-               for (i = col; i < last; i++) {
-                       if (nand->data_buf[i] != READ_NAND (nand->IO_ADDR)) {
-                               printf ("%s: Failed write verify, page 0x%08x ",
-                                       __FUNCTION__, page);
-                               return -1;
-                       }
-               }
-       }
-
-#ifdef CONFIG_MTD_NAND_ECC
-       /*
-        * We also want to check that the ECC bytes wrote
-        * correctly for the same reasons stated above.
-        */
-       NanD_Command (nand, NAND_CMD_READOOB);
-       if (nand->bus16) {
-               NanD_Address (nand, ADDR_COLUMN_PAGE,
-                             (page << nand->page_shift) + (col >> 1));
-       } else {
-               NanD_Address (nand, ADDR_COLUMN_PAGE,
-                             (page << nand->page_shift) + col);
-       }
-       if (nand->bus16) {
-               for (i = 0; i < nand->oobsize; i += 2) {
-                       u16 val;
-
-                       val = READ_NAND (nand->IO_ADDR);
-                       nand->data_buf[i] = val & 0xff;
-                       nand->data_buf[i + 1] = val >> 8;
-               }
-       } else {
-               for (i = 0; i < nand->oobsize; i++) {
-                       nand->data_buf[i] = READ_NAND (nand->IO_ADDR);
-               }
-       }
-       for (i = 0; i < ecc_bytes; i++) {
-               if ((nand->data_buf[(oob_config.ecc_pos[i])] != ecc_code[i]) && ecc_code[i]) {
-                       printf ("%s: Failed ECC write "
-                               "verify, page 0x%08x, "
-                               "%6i bytes were succesful\n",
-                               __FUNCTION__, page, i);
-                       return -1;
-               }
-       }
-#endif /* CONFIG_MTD_NAND_ECC */
-#endif /* CONFIG_MTD_NAND_VERIFY_WRITE */
-       return 0;
-}
-
-static int nand_write_ecc (struct nand_chip* nand, size_t to, size_t len,
-                          size_t * retlen, const u_char * buf, u_char * ecc_code)
-{
-       int i, page, col, cnt, ret = 0;
-
-       /* Do not allow write past end of device */
-       if ((to + len) > nand->totlen) {
-               printf ("%s: Attempt to write past end of page\n", __FUNCTION__);
-               return -1;
-       }
-
-       /* Shift to get page */
-       page = ((int) to) >> nand->page_shift;
-
-       /* Get the starting column */
-       col = to & (nand->oobblock - 1);
-
-       /* Initialize return length value */
-       *retlen = 0;
-
-       /* Select the NAND device */
-#ifdef CONFIG_OMAP1510
-       archflashwp(0,0);
-#endif
-#ifdef CONFIG_SYS_NAND_WP
-       NAND_WP_OFF();
-#endif
-
-       NAND_ENABLE_CE(nand);  /* set pin low */
-
-       /* Check the WP bit */
-       NanD_Command(nand, NAND_CMD_STATUS);
-       if (!(READ_NAND(nand->IO_ADDR) & 0x80)) {
-               printf ("%s: Device is write protected!!!\n", __FUNCTION__);
-               ret = -1;
-               goto out;
-       }
-
-       /* Loop until all data is written */
-       while (*retlen < len) {
-               /* Invalidate cache, if we write to this page */
-               if (nand->cache_page == page)
-                       nand->cache_page = -1;
-
-               /* Write data into buffer */
-               if ((col + len) >= nand->oobblock) {
-                       for (i = col, cnt = 0; i < nand->oobblock; i++, cnt++) {
-                               nand->data_buf[i] = buf[(*retlen + cnt)];
-                       }
-               } else {
-                       for (i = col, cnt = 0; cnt < (len - *retlen); i++, cnt++) {
-                               nand->data_buf[i] = buf[(*retlen + cnt)];
-                       }
-               }
-               /* We use the same function for write and writev !) */
-               ret = nand_write_page (nand, page, col, i, ecc_code);
-               if (ret)
-                       goto out;
-
-               /* Next data start at page boundary */
-               col = 0;
-
-               /* Update written bytes count */
-               *retlen += cnt;
-
-               /* Increment page address */
-               page++;
-       }
-
-       /* Return happy */
-       *retlen = len;
-
-out:
-       /* De-select the NAND device */
-       NAND_DISABLE_CE(nand);  /* set pin high */
-#ifdef CONFIG_OMAP1510
-       archflashwp(0,1);
-#endif
-#ifdef CONFIG_SYS_NAND_WP
-       NAND_WP_ON();
-#endif
-
-       return ret;
-}
-
-/* read from the 16 bytes of oob data that correspond to a 512 byte
- * page or 2 256-byte pages.
- */
-int nand_read_oob(struct nand_chip* nand, size_t ofs, size_t len,
-                        size_t * retlen, u_char * buf)
-{
-       int len256 = 0;
-       struct Nand *mychip;
-       int ret = 0;
-
-       mychip = &nand->chips[ofs >> nand->chipshift];
-
-       /* update address for 2M x 8bit devices. OOB starts on the second */
-       /* page to maintain compatibility with nand_read_ecc. */
-       if (nand->page256) {
-               if (!(ofs & 0x8))
-                       ofs += 0x100;
-               else
-                       ofs -= 0x8;
-       }
-
-       NAND_ENABLE_CE(nand);  /* set pin low */
-       NanD_Command(nand, NAND_CMD_READOOB);
-       if (nand->bus16) {
-               NanD_Address(nand, ADDR_COLUMN_PAGE,
-                            ((ofs >> nand->page_shift) << nand->page_shift) +
-                               ((ofs & (nand->oobblock - 1)) >> 1));
-       } else {
-               NanD_Address(nand, ADDR_COLUMN_PAGE, ofs);
-       }
-
-       /* treat crossing 8-byte OOB data for 2M x 8bit devices */
-       /* Note: datasheet says it should automaticaly wrap to the */
-       /*       next OOB block, but it didn't work here. mf.      */
-       if (nand->page256 && ofs + len > (ofs | 0x7) + 1) {
-               len256 = (ofs | 0x7) + 1 - ofs;
-               NanD_ReadBuf(nand, buf, len256);
-
-               NanD_Command(nand, NAND_CMD_READOOB);
-               NanD_Address(nand, ADDR_COLUMN_PAGE, ofs & (~0x1ff));
-       }
-
-       NanD_ReadBuf(nand, &buf[len256], len - len256);
-
-       *retlen = len;
-       /* Reading the full OOB data drops us off of the end of the page,
-        * causing the flash device to go into busy mode, so we need
-        * to wait until ready 11.4.1 and Toshiba TC58256FT nands */
-
-       ret = NanD_WaitReady(nand, 1);
-       NAND_DISABLE_CE(nand);  /* set pin high */
-
-       return ret;
-
-}
-
-/* write to the 16 bytes of oob data that correspond to a 512 byte
- * page or 2 256-byte pages.
- */
-int nand_write_oob(struct nand_chip* nand, size_t ofs, size_t len,
-                 size_t * retlen, const u_char * buf)
-{
-       int len256 = 0;
-       int i;
-       unsigned long nandptr = nand->IO_ADDR;
-
-#ifdef PSYCHO_DEBUG
-       printf("nand_write_oob(%lx, %d): %2.2X %2.2X %2.2X %2.2X ... %2.2X %2.2X .. %2.2X %2.2X\n",
-              (long)ofs, len, buf[0], buf[1], buf[2], buf[3],
-              buf[8], buf[9], buf[14],buf[15]);
-#endif
-
-       NAND_ENABLE_CE(nand);  /* set pin low to enable chip */
-
-       /* Reset the chip */
-       NanD_Command(nand, NAND_CMD_RESET);
-
-       /* issue the Read2 command to set the pointer to the Spare Data Area. */
-       NanD_Command(nand, NAND_CMD_READOOB);
-       if (nand->bus16) {
-               NanD_Address(nand, ADDR_COLUMN_PAGE,
-                            ((ofs >> nand->page_shift) << nand->page_shift) +
-                               ((ofs & (nand->oobblock - 1)) >> 1));
-       } else {
-               NanD_Address(nand, ADDR_COLUMN_PAGE, ofs);
-       }
-
-       /* update address for 2M x 8bit devices. OOB starts on the second */
-       /* page to maintain compatibility with nand_read_ecc. */
-       if (nand->page256) {
-               if (!(ofs & 0x8))
-                       ofs += 0x100;
-               else
-                       ofs -= 0x8;
-       }
-
-       /* issue the Serial Data In command to initial the Page Program process */
-       NanD_Command(nand, NAND_CMD_SEQIN);
-       if (nand->bus16) {
-               NanD_Address(nand, ADDR_COLUMN_PAGE,
-                            ((ofs >> nand->page_shift) << nand->page_shift) +
-                               ((ofs & (nand->oobblock - 1)) >> 1));
-       } else {
-               NanD_Address(nand, ADDR_COLUMN_PAGE, ofs);
-       }
-
-       /* treat crossing 8-byte OOB data for 2M x 8bit devices */
-       /* Note: datasheet says it should automaticaly wrap to the */
-       /*       next OOB block, but it didn't work here. mf.      */
-       if (nand->page256 && ofs + len > (ofs | 0x7) + 1) {
-               len256 = (ofs | 0x7) + 1 - ofs;
-               for (i = 0; i < len256; i++)
-                       WRITE_NAND(buf[i], nandptr);
-
-               NanD_Command(nand, NAND_CMD_PAGEPROG);
-               NanD_Command(nand, NAND_CMD_STATUS);
-#ifdef NAND_NO_RB
-               { u_char ret_val;
-                       do {
-                               ret_val = READ_NAND(nandptr); /* wait till ready */
-                       } while ((ret_val & 0x40) != 0x40);
-               }
-#endif
-               if (READ_NAND(nandptr) & 1) {
-                       puts ("Error programming oob data\n");
-                       /* There was an error */
-                       NAND_DISABLE_CE(nand);  /* set pin high */
-                       *retlen = 0;
-                       return -1;
-               }
-               NanD_Command(nand, NAND_CMD_SEQIN);
-               NanD_Address(nand, ADDR_COLUMN_PAGE, ofs & (~0x1ff));
-       }
-
-       if (nand->bus16) {
-               for (i = len256; i < len; i += 2) {
-                       WRITE_NAND(buf[i] + (buf[i+1] << 8), nandptr);
-               }
-       } else {
-               for (i = len256; i < len; i++)
-                       WRITE_NAND(buf[i], nandptr);
-       }
-
-       NanD_Command(nand, NAND_CMD_PAGEPROG);
-       NanD_Command(nand, NAND_CMD_STATUS);
-#ifdef NAND_NO_RB
-       {       u_char ret_val;
-               do {
-                       ret_val = READ_NAND(nandptr); /* wait till ready */
-               } while ((ret_val & 0x40) != 0x40);
-       }
-#endif
-       if (READ_NAND(nandptr) & 1) {
-               puts ("Error programming oob data\n");
-               /* There was an error */
-               NAND_DISABLE_CE(nand);  /* set pin high */
-               *retlen = 0;
-               return -1;
-       }
-
-       NAND_DISABLE_CE(nand);  /* set pin high */
-       *retlen = len;
-       return 0;
-
-}
-
-int nand_legacy_erase(struct nand_chip* nand, size_t ofs, size_t len, int clean)
-{
-       /* This is defined as a structure so it will work on any system
-        * using native endian jffs2 (the default).
-        */
-       static struct jffs2_unknown_node clean_marker = {
-               JFFS2_MAGIC_BITMASK,
-               JFFS2_NODETYPE_CLEANMARKER,
-               8               /* 8 bytes in this node */
-       };
-       unsigned long nandptr;
-       struct Nand *mychip;
-       int ret = 0;
-
-       if (ofs & (nand->erasesize-1) || len & (nand->erasesize-1)) {
-               printf ("Offset and size must be sector aligned, erasesize = %d\n",
-                       (int) nand->erasesize);
-               return -1;
-       }
-
-       nandptr = nand->IO_ADDR;
-
-       /* Select the NAND device */
-#ifdef CONFIG_OMAP1510
-       archflashwp(0,0);
-#endif
-#ifdef CONFIG_SYS_NAND_WP
-       NAND_WP_OFF();
-#endif
-    NAND_ENABLE_CE(nand);  /* set pin low */
-
-       /* Check the WP bit */
-       NanD_Command(nand, NAND_CMD_STATUS);
-       if (!(READ_NAND(nand->IO_ADDR) & 0x80)) {
-               printf ("nand_write_ecc: Device is write protected!!!\n");
-               ret = -1;
-               goto out;
-       }
-
-       /* Check the WP bit */
-       NanD_Command(nand, NAND_CMD_STATUS);
-       if (!(READ_NAND(nand->IO_ADDR) & 0x80)) {
-               printf ("%s: Device is write protected!!!\n", __FUNCTION__);
-               ret = -1;
-               goto out;
-       }
-
-       /* FIXME: Do nand in the background. Use timers or schedule_task() */
-       while(len) {
-               /*mychip = &nand->chips[shr(ofs, nand->chipshift)];*/
-               mychip = &nand->chips[ofs >> nand->chipshift];
-
-               /* always check for bad block first, genuine bad blocks
-                * should _never_  be erased.
-                */
-               if (ALLOW_ERASE_BAD_DEBUG || !check_block(nand, ofs)) {
-                       /* Select the NAND device */
-                       NAND_ENABLE_CE(nand);  /* set pin low */
-
-                       NanD_Command(nand, NAND_CMD_ERASE1);
-                       NanD_Address(nand, ADDR_PAGE, ofs);
-                       NanD_Command(nand, NAND_CMD_ERASE2);
-
-                       NanD_Command(nand, NAND_CMD_STATUS);
-
-#ifdef NAND_NO_RB
-                       {       u_char ret_val;
-                               do {
-                                       ret_val = READ_NAND(nandptr); /* wait till ready */
-                               } while ((ret_val & 0x40) != 0x40);
-                       }
-#endif
-                       if (READ_NAND(nandptr) & 1) {
-                               printf ("%s: Error erasing at 0x%lx\n",
-                                       __FUNCTION__, (long)ofs);
-                               /* There was an error */
-                               ret = -1;
-                               goto out;
-                       }
-                       if (clean) {
-                               int n;  /* return value not used */
-                               int p, l;
-
-                               /* clean marker position and size depend
-                                * on the page size, since 256 byte pages
-                                * only have 8 bytes of oob data
-                                */
-                               if (nand->page256) {
-                                       p = NAND_JFFS2_OOB8_FSDAPOS;
-                                       l = NAND_JFFS2_OOB8_FSDALEN;
-                               } else {
-                                       p = NAND_JFFS2_OOB16_FSDAPOS;
-                                       l = NAND_JFFS2_OOB16_FSDALEN;
-                               }
-
-                               ret = nand_write_oob(nand, ofs + p, l, (size_t *)&n,
-                                                    (u_char *)&clean_marker);
-                               /* quit here if write failed */
-                               if (ret)
-                                       goto out;
-                       }
-               }
-               ofs += nand->erasesize;
-               len -= nand->erasesize;
-       }
-
-out:
-       /* De-select the NAND device */
-       NAND_DISABLE_CE(nand);  /* set pin high */
-#ifdef CONFIG_OMAP1510
-       archflashwp(0,1);
-#endif
-#ifdef CONFIG_SYS_NAND_WP
-       NAND_WP_ON();
-#endif
-
-       return ret;
-}
-
-
-static inline int nandcheck(unsigned long potential, unsigned long physadr)
-{
-       return 0;
-}
-
-unsigned long nand_probe(unsigned long physadr)
-{
-       struct nand_chip *nand = NULL;
-       int i = 0, ChipID = 1;
-
-#ifdef CONFIG_MTD_NAND_ECC_JFFS2
-       oob_config.ecc_pos[0] = NAND_JFFS2_OOB_ECCPOS0;
-       oob_config.ecc_pos[1] = NAND_JFFS2_OOB_ECCPOS1;
-       oob_config.ecc_pos[2] = NAND_JFFS2_OOB_ECCPOS2;
-       oob_config.ecc_pos[3] = NAND_JFFS2_OOB_ECCPOS3;
-       oob_config.ecc_pos[4] = NAND_JFFS2_OOB_ECCPOS4;
-       oob_config.ecc_pos[5] = NAND_JFFS2_OOB_ECCPOS5;
-       oob_config.eccvalid_pos = 4;
-#else
-       oob_config.ecc_pos[0] = NAND_NOOB_ECCPOS0;
-       oob_config.ecc_pos[1] = NAND_NOOB_ECCPOS1;
-       oob_config.ecc_pos[2] = NAND_NOOB_ECCPOS2;
-       oob_config.ecc_pos[3] = NAND_NOOB_ECCPOS3;
-       oob_config.ecc_pos[4] = NAND_NOOB_ECCPOS4;
-       oob_config.ecc_pos[5] = NAND_NOOB_ECCPOS5;
-       oob_config.eccvalid_pos = NAND_NOOB_ECCVPOS;
-#endif
-       oob_config.badblock_pos = 5;
-
-       for (i=0; i<CONFIG_SYS_MAX_NAND_DEVICE; i++) {
-               if (nand_dev_desc[i].ChipID == NAND_ChipID_UNKNOWN) {
-                       nand = &nand_dev_desc[i];
-                       break;
-               }
-       }
-       if (!nand)
-               return (0);
-
-       memset((char *)nand, 0, sizeof(struct nand_chip));
-
-       nand->IO_ADDR = physadr;
-       nand->cache_page = -1;  /* init the cache page */
-       NanD_ScanChips(nand);
-
-       if (nand->totlen == 0) {
-               /* no chips found, clean up and quit */
-               memset((char *)nand, 0, sizeof(struct nand_chip));
-               nand->ChipID = NAND_ChipID_UNKNOWN;
-               return (0);
-       }
-
-       nand->ChipID = ChipID;
-       if (curr_device == -1)
-               curr_device = i;
-
-       nand->data_buf = malloc (nand->oobblock + nand->oobsize);
-       if (!nand->data_buf) {
-               puts ("Cannot allocate memory for data structures.\n");
-               return (0);
-       }
-
-       return (nand->totlen);
-}
-
-#ifdef CONFIG_MTD_NAND_ECC
-/*
- * Pre-calculated 256-way 1 byte column parity
- */
-static const u_char nand_ecc_precalc_table[] = {
-       0x00, 0x55, 0x56, 0x03, 0x59, 0x0c, 0x0f, 0x5a,
-       0x5a, 0x0f, 0x0c, 0x59, 0x03, 0x56, 0x55, 0x00,
-       0x65, 0x30, 0x33, 0x66, 0x3c, 0x69, 0x6a, 0x3f,
-       0x3f, 0x6a, 0x69, 0x3c, 0x66, 0x33, 0x30, 0x65,
-       0x66, 0x33, 0x30, 0x65, 0x3f, 0x6a, 0x69, 0x3c,
-       0x3c, 0x69, 0x6a, 0x3f, 0x65, 0x30, 0x33, 0x66,
-       0x03, 0x56, 0x55, 0x00, 0x5a, 0x0f, 0x0c, 0x59,
-       0x59, 0x0c, 0x0f, 0x5a, 0x00, 0x55, 0x56, 0x03,
-       0x69, 0x3c, 0x3f, 0x6a, 0x30, 0x65, 0x66, 0x33,
-       0x33, 0x66, 0x65, 0x30, 0x6a, 0x3f, 0x3c, 0x69,
-       0x0c, 0x59, 0x5a, 0x0f, 0x55, 0x00, 0x03, 0x56,
-       0x56, 0x03, 0x00, 0x55, 0x0f, 0x5a, 0x59, 0x0c,
-       0x0f, 0x5a, 0x59, 0x0c, 0x56, 0x03, 0x00, 0x55,
-       0x55, 0x00, 0x03, 0x56, 0x0c, 0x59, 0x5a, 0x0f,
-       0x6a, 0x3f, 0x3c, 0x69, 0x33, 0x66, 0x65, 0x30,
-       0x30, 0x65, 0x66, 0x33, 0x69, 0x3c, 0x3f, 0x6a,
-       0x6a, 0x3f, 0x3c, 0x69, 0x33, 0x66, 0x65, 0x30,
-       0x30, 0x65, 0x66, 0x33, 0x69, 0x3c, 0x3f, 0x6a,
-       0x0f, 0x5a, 0x59, 0x0c, 0x56, 0x03, 0x00, 0x55,
-       0x55, 0x00, 0x03, 0x56, 0x0c, 0x59, 0x5a, 0x0f,
-       0x0c, 0x59, 0x5a, 0x0f, 0x55, 0x00, 0x03, 0x56,
-       0x56, 0x03, 0x00, 0x55, 0x0f, 0x5a, 0x59, 0x0c,
-       0x69, 0x3c, 0x3f, 0x6a, 0x30, 0x65, 0x66, 0x33,
-       0x33, 0x66, 0x65, 0x30, 0x6a, 0x3f, 0x3c, 0x69,
-       0x03, 0x56, 0x55, 0x00, 0x5a, 0x0f, 0x0c, 0x59,
-       0x59, 0x0c, 0x0f, 0x5a, 0x00, 0x55, 0x56, 0x03,
-       0x66, 0x33, 0x30, 0x65, 0x3f, 0x6a, 0x69, 0x3c,
-       0x3c, 0x69, 0x6a, 0x3f, 0x65, 0x30, 0x33, 0x66,
-       0x65, 0x30, 0x33, 0x66, 0x3c, 0x69, 0x6a, 0x3f,
-       0x3f, 0x6a, 0x69, 0x3c, 0x66, 0x33, 0x30, 0x65,
-       0x00, 0x55, 0x56, 0x03, 0x59, 0x0c, 0x0f, 0x5a,
-       0x5a, 0x0f, 0x0c, 0x59, 0x03, 0x56, 0x55, 0x00
-};
-
-
-/*
- * Creates non-inverted ECC code from line parity
- */
-static void nand_trans_result(u_char reg2, u_char reg3,
-       u_char *ecc_code)
-{
-       u_char a, b, i, tmp1, tmp2;
-
-       /* Initialize variables */
-       a = b = 0x80;
-       tmp1 = tmp2 = 0;
-
-       /* Calculate first ECC byte */
-       for (i = 0; i < 4; i++) {
-               if (reg3 & a)           /* LP15,13,11,9 --> ecc_code[0] */
-                       tmp1 |= b;
-               b >>= 1;
-               if (reg2 & a)           /* LP14,12,10,8 --> ecc_code[0] */
-                       tmp1 |= b;
-               b >>= 1;
-               a >>= 1;
-       }
-
-       /* Calculate second ECC byte */
-       b = 0x80;
-       for (i = 0; i < 4; i++) {
-               if (reg3 & a)           /* LP7,5,3,1 --> ecc_code[1] */
-                       tmp2 |= b;
-               b >>= 1;
-               if (reg2 & a)           /* LP6,4,2,0 --> ecc_code[1] */
-                       tmp2 |= b;
-               b >>= 1;
-               a >>= 1;
-       }
-
-       /* Store two of the ECC bytes */
-       ecc_code[0] = tmp1;
-       ecc_code[1] = tmp2;
-}
-
-/*
- * Calculate 3 byte ECC code for 256 byte block
- */
-static void nand_calculate_ecc (const u_char *dat, u_char *ecc_code)
-{
-       u_char idx, reg1, reg3;
-       int j;
-
-       /* Initialize variables */
-       reg1 = reg3 = 0;
-       ecc_code[0] = ecc_code[1] = ecc_code[2] = 0;
-
-       /* Build up column parity */
-       for(j = 0; j < 256; j++) {
-
-               /* Get CP0 - CP5 from table */
-               idx = nand_ecc_precalc_table[dat[j]];
-               reg1 ^= idx;
-
-               /* All bit XOR = 1 ? */
-               if (idx & 0x40) {
-                       reg3 ^= (u_char) j;
-               }
-       }
-
-       /* Create non-inverted ECC code from line parity */
-       nand_trans_result((reg1 & 0x40) ? ~reg3 : reg3, reg3, ecc_code);
-
-       /* Calculate final ECC code */
-       ecc_code[0] = ~ecc_code[0];
-       ecc_code[1] = ~ecc_code[1];
-       ecc_code[2] = ((~reg1) << 2) | 0x03;
-}
-
-/*
- * Detect and correct a 1 bit error for 256 byte block
- */
-static int nand_correct_data (u_char *dat, u_char *read_ecc, u_char *calc_ecc)
-{
-       u_char a, b, c, d1, d2, d3, add, bit, i;
-
-       /* Do error detection */
-       d1 = calc_ecc[0] ^ read_ecc[0];
-       d2 = calc_ecc[1] ^ read_ecc[1];
-       d3 = calc_ecc[2] ^ read_ecc[2];
-
-       if ((d1 | d2 | d3) == 0) {
-               /* No errors */
-               return 0;
-       } else {
-               a = (d1 ^ (d1 >> 1)) & 0x55;
-               b = (d2 ^ (d2 >> 1)) & 0x55;
-               c = (d3 ^ (d3 >> 1)) & 0x54;
-
-               /* Found and will correct single bit error in the data */
-               if ((a == 0x55) && (b == 0x55) && (c == 0x54)) {
-                       c = 0x80;
-                       add = 0;
-                       a = 0x80;
-                       for (i=0; i<4; i++) {
-                               if (d1 & c)
-                                       add |= a;
-                               c >>= 2;
-                               a >>= 1;
-                       }
-                       c = 0x80;
-                       for (i=0; i<4; i++) {
-                               if (d2 & c)
-                                       add |= a;
-                               c >>= 2;
-                               a >>= 1;
-                       }
-                       bit = 0;
-                       b = 0x04;
-                       c = 0x80;
-                       for (i=0; i<3; i++) {
-                               if (d3 & c)
-                                       bit |= b;
-                               c >>= 2;
-                               b >>= 1;
-                       }
-                       b = 0x01;
-                       a = dat[add];
-                       a ^= (b << bit);
-                       dat[add] = a;
-                       return 1;
-               }
-               else {
-                       i = 0;
-                       while (d1) {
-                               if (d1 & 0x01)
-                                       ++i;
-                               d1 >>= 1;
-                       }
-                       while (d2) {
-                               if (d2 & 0x01)
-                                       ++i;
-                               d2 >>= 1;
-                       }
-                       while (d3) {
-                               if (d3 & 0x01)
-                                       ++i;
-                               d3 >>= 1;
-                       }
-                       if (i == 1) {
-                               /* ECC Code Error Correction */
-                               read_ecc[0] = calc_ecc[0];
-                               read_ecc[1] = calc_ecc[1];
-                               read_ecc[2] = calc_ecc[2];
-                               return 2;
-                       }
-                       else {
-                               /* Uncorrectable Error */
-                               return -1;
-                       }
-               }
-       }
-
-       /* Should never happen */
-       return -1;
-}
-
-#endif
-
-#ifdef CONFIG_JFFS2_NAND
-int read_jffs2_nand(size_t start, size_t len,
-               size_t * retlen, u_char * buf, int nanddev)
-{
-       return nand_legacy_rw(nand_dev_desc + nanddev, NANDRW_READ | NANDRW_JFFS2,
-                       start, len, retlen, buf);
-}
-#endif /* CONFIG_JFFS2_NAND */
similarity index 91%
rename from api_examples/Makefile
rename to examples/api/Makefile
index 2a30bef..2d05a01 100644 (file)
@@ -33,13 +33,13 @@ include $(TOPDIR)/config.mk
 OUTPUT-$(CONFIG_API) = $(obj)demo
 OUTPUT = $(OUTPUT-y)
 
-# Source files located in the api_examples directory
+# Source files located in the examples/api directory
 SOBJ_FILES-$(CONFIG_API) += crt0.o
 COBJ_FILES-$(CONFIG_API) += demo.o
 COBJ_FILES-$(CONFIG_API) += glue.o
 COBJ_FILES-$(CONFIG_API) += libgenwrap.o
 
-# Source files which exist outside the api_examples directory
+# Source files which exist outside the examples/api directory
 EXT_COBJ_FILES-$(CONFIG_API) += lib_generic/crc32.o
 EXT_COBJ_FILES-$(CONFIG_API) += lib_generic/ctype.o
 EXT_COBJ_FILES-$(CONFIG_API) += lib_generic/string.o
@@ -51,8 +51,8 @@ endif
 # Create a list of source files so their dependencies can be auto-generated
 SRCS   += $(addprefix $(SRCTREE)/,$(EXT_COBJ_FILES-y:.o=.c))
 SRCS   += $(addprefix $(SRCTREE)/,$(EXT_SOBJ_FILES-y:.o=.S))
-SRCS   += $(addprefix $(SRCTREE)/api_examples/,$(COBJ_FILES-y:.o=.c))
-SRCS   += $(addprefix $(SRCTREE)/api_examples/,$(SOBJ_FILES-y:.o=.S))
+SRCS   += $(addprefix $(SRCTREE)/examples/api/,$(COBJ_FILES-y:.o=.c))
+SRCS   += $(addprefix $(SRCTREE)/examples/api/,$(SOBJ_FILES-y:.o=.S))
 
 # Create a list of object files to be compiled
 OBJS   += $(addprefix $(obj),$(SOBJ_FILES-y))
similarity index 100%
rename from api_examples/crt0.S
rename to examples/api/crt0.S
similarity index 100%
rename from api_examples/demo.c
rename to examples/api/demo.c
similarity index 100%
rename from api_examples/glue.c
rename to examples/api/glue.c
similarity index 100%
rename from api_examples/glue.h
rename to examples/api/glue.h
similarity index 100%
rename from examples/sched.c
rename to examples/standalone/sched.c
similarity index 100%
rename from examples/stubs.c
rename to examples/standalone/stubs.c
similarity index 100%
rename from examples/timer.c
rename to examples/standalone/timer.c
index 11b66ab..8c9e2eb 100644 (file)
@@ -146,11 +146,7 @@ static struct part_info *current_part;
 
 #if (defined(CONFIG_JFFS2_NAND) && \
      defined(CONFIG_CMD_NAND) )
-#if defined(CONFIG_NAND_LEGACY)
-#include <linux/mtd/nand_legacy.h>
-#else
 #include <nand.h>
-#endif
 /*
  * Support for jffs2 on top of NAND-flash
  *
@@ -161,12 +157,6 @@ static struct part_info *current_part;
  *
  */
 
-#if defined(CONFIG_NAND_LEGACY)
-/* this one defined in nand_legacy.c */
-int read_jffs2_nand(size_t start, size_t len,
-               size_t * retlen, u_char * buf, int nanddev);
-#endif
-
 #define NAND_PAGE_SIZE 512
 #define NAND_PAGE_SHIFT 9
 #define NAND_PAGE_MASK (~(NAND_PAGE_SIZE-1))
@@ -201,15 +191,6 @@ static int read_nand_cached(u32 off, u32 size, u_char *buf)
                                }
                        }
 
-#if defined(CONFIG_NAND_LEGACY)
-                       if (read_jffs2_nand(nand_cache_off, NAND_CACHE_SIZE,
-                                               &retlen, nand_cache, id->num) < 0 ||
-                                       retlen != NAND_CACHE_SIZE) {
-                               printf("read_nand_cached: error reading nand off %#x size %d bytes\n",
-                                               nand_cache_off, NAND_CACHE_SIZE);
-                               return -1;
-                       }
-#else
                        retlen = NAND_CACHE_SIZE;
                        if (nand_read(&nand_info[id->num], nand_cache_off,
                                                &retlen, nand_cache) != 0 ||
@@ -218,7 +199,6 @@ static int read_nand_cached(u32 off, u32 size, u_char *buf)
                                                nand_cache_off, NAND_CACHE_SIZE);
                                return -1;
                        }
-#endif
                }
                cpy_bytes = nand_cache_off + NAND_CACHE_SIZE - (off + bytes_read);
                if (cpy_bytes > size - bytes_read)
index 6eb6745..fe8c70d 100644 (file)
@@ -1,7 +1,5 @@
 #include <common.h>
 
-#if !defined(CONFIG_NAND_LEGACY)
-
 #include <malloc.h>
 #include <linux/stat.h>
 #include <linux/time.h>
@@ -1034,5 +1032,3 @@ jffs2_1pass_info(struct part_info * part)
        }
        return 1;
 }
-
-#endif
index e17d8a2..8ec7928 100644 (file)
@@ -61,6 +61,9 @@ extern u_long get_sclk(void);
 
 # define bfin_revid() (*pCHIPID >> 28)
 
+extern bool bfin_os_log_check(void);
+extern void bfin_os_log_dump(void);
+
 extern void blackfin_icache_flush_range(const void *, const void *);
 extern void blackfin_dcache_flush_range(const void *, const void *);
 extern void blackfin_icache_dcache_flush_range(const void *, const void *);
index a839834..fdfc654 100644 (file)
@@ -114,9 +114,9 @@ typedef struct ccsr_ddr {
        uint    timing_cfg_0;           /* 0x2104 - DDR SDRAM Timing Configuration Register 0 */
        uint    timing_cfg_1;           /* 0x2108 - DDR SDRAM Timing Configuration Register 1 */
        uint    timing_cfg_2;           /* 0x210c - DDR SDRAM Timing Configuration Register 2 */
-       uint    sdram_cfg_1;            /* 0x2110 - DDR SDRAM Control Configuration 1 */
+       uint    sdram_cfg;              /* 0x2110 - DDR SDRAM Control Configuration 1 */
        uint    sdram_cfg_2;            /* 0x2114 - DDR SDRAM Control Configuration 2 */
-       uint    sdram_mode_1;           /* 0x2118 - DDR SDRAM Mode Configuration 1 */
+       uint    sdram_mode;             /* 0x2118 - DDR SDRAM Mode Configuration 1 */
        uint    sdram_mode_2;           /* 0x211c - DDR SDRAM Mode Configuration 2 */
        uint    sdram_mode_cntl;        /* 0x2120 - DDR SDRAM Mode Control */
        uint    sdram_interval;         /* 0x2124 - DDR SDRAM Interval Configuration */
index a6c7c07..6e689b2 100644 (file)
@@ -697,6 +697,7 @@ void show_boot_progress(int val);
 
 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
 
+#define ROUND(a,b)             (((a) + (b)) & ~((b) - 1))
 #define DIV_ROUND(n,d)         (((n) + ((d)/2)) / (d))
 #define DIV_ROUND_UP(n,d)      (((n) + (d) - 1) / (d))
 #define roundup(x, y)          ((((x) + ((y) - 1)) / (y)) * (y))
diff --git a/include/compiler.h b/include/compiler.h
new file mode 100644 (file)
index 0000000..272fd3c
--- /dev/null
@@ -0,0 +1,125 @@
+/*
+ * Keep all the ugly #ifdef for system stuff here
+ */
+
+#ifndef __COMPILER_H__
+#define __COMPILER_H__
+
+#include <stddef.h>
+
+#ifdef USE_HOSTCC
+
+#if defined(__BEOS__)   || \
+    defined(__NetBSD__)  || \
+    defined(__FreeBSD__) || \
+    defined(__sun__)    || \
+    defined(__APPLE__)
+# include <inttypes.h>
+#elif defined(__linux__) || defined(__WIN32__) || defined(__MINGW32__)
+# include <stdint.h>
+#endif
+
+#include <errno.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
+
+extern int errno;
+
+#if !defined(__WIN32__) && !defined(__MINGW32__)
+# include <sys/mman.h>
+#endif
+
+/* Not all systems (like Windows) has this define, and yes
+ * we do replace/emulate mmap() on those systems ...
+ */
+#ifndef MAP_FAILED
+# define MAP_FAILED ((void *)-1)
+#endif
+
+#include <fcntl.h>
+#ifndef O_BINARY               /* should be define'd on __WIN32__ */
+#define O_BINARY       0
+#endif
+
+#ifdef __linux__
+# include <endian.h>
+# include <byteswap.h>
+#elif defined(__MACH__)
+# include <machine/endian.h>
+typedef unsigned long ulong;
+typedef unsigned int  uint;
+#endif
+
+typedef uint8_t __u8;
+typedef uint16_t __u16;
+typedef uint32_t __u32;
+
+#define uswap_16(x) \
+       ((((x) & 0xff00) >> 8) | \
+        (((x) & 0x00ff) << 8))
+#define uswap_32(x) \
+       ((((x) & 0xff000000) >> 24) | \
+        (((x) & 0x00ff0000) >>  8) | \
+        (((x) & 0x0000ff00) <<  8) | \
+        (((x) & 0x000000ff) << 24))
+#define _uswap_64(x, sfx) \
+       ((((x) & 0xff00000000000000##sfx) >> 56) | \
+        (((x) & 0x00ff000000000000##sfx) >> 40) | \
+        (((x) & 0x0000ff0000000000##sfx) >> 24) | \
+        (((x) & 0x000000ff00000000##sfx) >>  8) | \
+        (((x) & 0x00000000ff000000##sfx) <<  8) | \
+        (((x) & 0x0000000000ff0000##sfx) << 24) | \
+        (((x) & 0x000000000000ff00##sfx) << 40) | \
+        (((x) & 0x00000000000000ff##sfx) << 56))
+#if defined(__GNUC__)
+# define uswap_64(x) _uswap_64(x, ull)
+#else
+# define uswap_64(x) _uswap_64(x, )
+#endif
+
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+# define cpu_to_le16(x)                (x)
+# define cpu_to_le32(x)                (x)
+# define cpu_to_le64(x)                (x)
+# define le16_to_cpu(x)                (x)
+# define le32_to_cpu(x)                (x)
+# define le64_to_cpu(x)                (x)
+# define cpu_to_be16(x)                uswap_16(x)
+# define cpu_to_be32(x)                uswap_32(x)
+# define cpu_to_be64(x)                uswap_64(x)
+# define be16_to_cpu(x)                uswap_16(x)
+# define be32_to_cpu(x)                uswap_32(x)
+# define be64_to_cpu(x)                uswap_64(x)
+#else
+# define cpu_to_le16(x)                uswap_16(x)
+# define cpu_to_le32(x)                uswap_32(x)
+# define cpu_to_le64(x)                uswap_64(x)
+# define le16_to_cpu(x)                uswap_16(x)
+# define le32_to_cpu(x)                uswap_32(x)
+# define le64_to_cpu(x)                uswap_64(x)
+# define cpu_to_be16(x)                (x)
+# define cpu_to_be32(x)                (x)
+# define cpu_to_be64(x)                (x)
+# define be16_to_cpu(x)                (x)
+# define be32_to_cpu(x)                (x)
+# define be64_to_cpu(x)                (x)
+#endif
+
+#else /* !USE_HOSTCC */
+
+#include <linux/string.h>
+#include <linux/types.h>
+#include <asm/byteorder.h>
+
+/* Types for `void *' pointers. */
+#if __WORDSIZE == 64
+typedef unsigned long int       uintptr_t;
+#else
+typedef unsigned int            uintptr_t;
+#endif
+
+#endif
+
+#endif
index 2ee4f80..694a87b 100644 (file)
 #define CONFIG_SYS_NAND_CLE            (0x80000000 >> 2)   /* our CLE is GPIO2 */
 #define CONFIG_SYS_NAND_ALE            (0x80000000 >> 3)   /* our ALE is GPIO3 */
 
-#define CONFIG_SYS_NAND_SKIP_BAD_DOT_I 1       /* ".i" read skips bad blocks   */
-#define CONFIG_SYS_NAND_QUIET          1
+#define CONFIG_SYS_NAND_SKIP_BAD_DOT_I 1       /* ".i" read skips bad blocks   */
+#define CONFIG_SYS_NAND_QUIET          1
+
+#define CONFIG_SYS_64BIT_VSPRINTF      /* needed for nand_util.c */
 
 /*-----------------------------------------------------------------------
  * PCI stuff
index 24ffb00..98f6396 100644 (file)
 #include <config_cmd_default.h>
 
 #define CONFIG_CMD_DATE
-#define CONFIG_CMD_DOC
 #define CONFIG_CMD_ELF
 
 
-/* CONFIG_CMD_DOC required legacy NAND support */
-#define CONFIG_NAND_LEGACY
-
 #if 0
 #define CONFIG_PCI             1
 #define CONFIG_PCI_PNP         1       /* PCI plug-and-play */
index 39f41e6..229a513 100644 (file)
 
 /* For CATcenter there is only NAND on the module */
 #define CONFIG_SYS_MAX_NAND_DEVICE     1       /* Max number of NAND devices           */
-#define SECTORSIZE 512
 #define NAND_NO_RB
 
-#define ADDR_COLUMN 1
-#define ADDR_PAGE 2
-#define ADDR_COLUMN_PAGE 3
-
-#define NAND_ChipID_UNKNOWN    0x00
-#define NAND_MAX_FLOORS 1
-
 #define CONFIG_SYS_NAND0_CE  (0x80000000 >> 1)  /* our CE is GPIO1 */
 #define CONFIG_SYS_NAND0_CLE (0x80000000 >> 2)  /* our CLE is GPIO2 */
 #define CONFIG_SYS_NAND0_ALE (0x80000000 >> 3)  /* our ALE is GPIO3 */
index ae8494d..2384925 100644 (file)
 #define CONFIG_SYS_NAND_SKIP_BAD_DOT_I 1       /* ".i" read skips bad blocks   */
 #define CONFIG_SYS_NAND_QUIET          1
 
+#define CONFIG_SYS_64BIT_VSPRINTF      /* needed for nand_util.c */
+
 /*
  * For booting Linux, the board info and command line data
  * have to be in the first 8 MB of memory, since this is
index cf21fd9..6d76d9f 100644 (file)
 #undef CONFIG_WATCHDOG                 /* watchdog disabled            */
 
 /*-----------------------------------------------------------------------
- * Disk-On-Chip configuration
- */
-
-#define CONFIG_SYS_MAX_DOC_DEVICE      1       /* Max number of DOC devices    */
-
-#define CONFIG_SYS_DOC_SUPPORT_2000
-#define CONFIG_SYS_DOC_SUPPORT_MILLENNIUM
-
-/*-----------------------------------------------------------------------
  * Miscellaneous configuration options
  */
 
 #define CONFIG_CMD_BEDBUG
 #define CONFIG_CMD_DATE
 #define CONFIG_CMD_DHCP
-#define CONFIG_CMD_DOC
 #define CONFIG_CMD_EEPROM
 #define CONFIG_CMD_I2C
 #define CONFIG_CMD_NFS
index 489378a..83b010c 100644 (file)
 
 #define CONFIG_CMD_BEDBUG
 #define CONFIG_CMD_DATE
-#define CONFIG_CMD_DOC
 #define CONFIG_CMD_EEPROM
 #define CONFIG_CMD_I2C
 
     #define CONFIG_CMD_PCI
 #endif
 
-
-#define CONFIG_NAND_LEGACY
-
 /*
  * Miscellaneous configurable options
  */
index bf9fd82..6819c3e 100644 (file)
  *-----------------------------------------------------------------------
  */
 #define CONFIG_SYS_MAX_NAND_DEVICE     1       /* Max number of NAND devices           */
-#define SECTORSIZE 512
-
-#define ADDR_COLUMN 1
-#define ADDR_PAGE 2
-#define ADDR_COLUMN_PAGE 3
-
-#define NAND_ChipID_UNKNOWN    0x00
-#define NAND_MAX_FLOORS 1
 
 #define CONFIG_SYS_NAND_CE  (0x80000000 >> 1)  /* our CE is GPIO1 */
 #define CONFIG_SYS_NAND_CLE (0x80000000 >> 2)  /* our CLE is GPIO2 */
 #define CONFIG_SYS_NAND_ALE (0x80000000 >> 3)  /* our ALE is GPIO3 */
 #define CONFIG_SYS_NAND_RDY (0x80000000 >> 4)  /* our RDY is GPIO4 */
 
-#define NAND_DISABLE_CE(nand) do { out32(GPIO0_OR, in32(GPIO0_OR) | CONFIG_SYS_NAND_CE);} while(0)
-#define NAND_ENABLE_CE(nand) do { out32(GPIO0_OR, in32(GPIO0_OR) & ~CONFIG_SYS_NAND_CE);} while(0)
-#define NAND_CTL_CLRALE(nandptr) do { out32(GPIO0_OR, in32(GPIO0_OR) & ~CONFIG_SYS_NAND_ALE);} while(0)
-#define NAND_CTL_SETALE(nandptr) do { out32(GPIO0_OR, in32(GPIO0_OR) | CONFIG_SYS_NAND_ALE);} while(0)
-#define NAND_CTL_CLRCLE(nandptr) do { out32(GPIO0_OR, in32(GPIO0_OR) & ~CONFIG_SYS_NAND_CLE);} while(0)
-#define NAND_CTL_SETCLE(nandptr) do { out32(GPIO0_OR, in32(GPIO0_OR) | CONFIG_SYS_NAND_CLE);} while(0)
-#define NAND_WAIT_READY(nand) while (!(in32(GPIO0_IR) & CONFIG_SYS_NAND_RDY))
-
-#define WRITE_NAND_COMMAND(d, adr) do{ *(volatile __u8 *)((unsigned long)adr) = (__u8)(d); } while(0)
-#define WRITE_NAND_ADDRESS(d, adr) do{ *(volatile __u8 *)((unsigned long)adr) = (__u8)(d); } while(0)
-#define WRITE_NAND(d, adr) do{ *(volatile __u8 *)((unsigned long)adr) = (__u8)d; } while(0)
-#define READ_NAND(adr) ((volatile unsigned char)(*(volatile __u8 *)(unsigned long)adr))
 #endif
 
 /*-----------------------------------------------------------------------
index 8f18ab2..12f879a 100644 (file)
 #define CONFIG_CMD_MII
 #define CONFIG_CMD_BEDBUG
 
-#if !defined(CONFIG_SC)
-    #define CONFIG_CMD_DOC
-#endif
-
 #ifdef CONFIG_POST
 #define CONFIG_CMD_DIAG
 #endif
 #define CONFIG_FPGA_VIRTEX2
 #define CONFIG_SYS_FPGA_PROG_FEEDBACK
 
-
-#define CONFIG_NAND_LEGACY
-
 /*
  * Verbose help from command monitor.
  */
 #define BOOTFLAG_WARM  0x02    /* Software reboot                                      */
 
 /*
- * Disk On Chip (millenium) configuration
- */
-#if !defined(CONFIG_SC)
-#define CONFIG_SYS_MAX_DOC_DEVICE      1
-#undef CONFIG_SYS_DOC_SUPPORT_2000
-#define CONFIG_SYS_DOC_SUPPORT_MILLENNIUM
-#undef CONFIG_SYS_DOC_PASSIVE_PROBE
-#endif
-
-/*
  * FEC interrupt assignment
  */
 #define FEC_INTERRUPT   SIU_LEVEL1
index 9233523..1a2266f 100644 (file)
 #define CONFIG_SYS_NAND_SKIP_BAD_DOT_I 1       /* ".i" read skips bad blocks   */
 #define CONFIG_SYS_NAND_QUIET          1
 
+#define CONFIG_SYS_64BIT_VSPRINTF      /* needed for nand_util.c */
+
 /*-----------------------------------------------------------------------
  * PCI stuff
  *-----------------------------------------------------------------------
index ea502d4..518d94d 100644 (file)
 #define CONFIG_SYS_NAND_SKIP_BAD_DOT_I 1       /* ".i" read skips bad blocks   */
 #define CONFIG_SYS_NAND_QUIET          1
 
+#define CONFIG_SYS_64BIT_VSPRINTF      /* needed for nand_util.c */
+
 /*-----------------------------------------------------------------------
  * PCI stuff
  *-----------------------------------------------------------------------
index 51e012c..4c4af05 100644 (file)
 #define CONFIG_SYS_NAND0_BASE 0xE1000000
 #define CONFIG_SYS_MAX_NAND_DEVICE     1       /* Max number of NAND devices           */
 
+#define CONFIG_SYS_64BIT_VSPRINTF              /* needed for nand_util.c */
+
 #endif /* CONFIG_CMD_NAND */
 
 /*-----------------------------------------------------------------------
index da9b1cf..7ac9342 100644 (file)
 
 #if !defined(CONFIG_MIP405T)
     #define CONFIG_CMD_USB
-    #define CONFIG_CMD_DOC
 #endif
 
 
-#define CONFIG_NAND_LEGACY
-
 #define         CONFIG_SYS_HUSH_PARSER
 #define         CONFIG_SYS_PROMPT_HUSH_PS2 "> "
 /**************************************************************
 #define CONFIG_ISO_PARTITION /* Experimental */
 
 /************************************************************
- * Disk-On-Chip configuration
- ************************************************************/
-#define CONFIG_SYS_MAX_DOC_DEVICE      1       /* Max number of DOC devices            */
-#define CONFIG_SYS_DOC_SHORT_TIMEOUT
-#define CONFIG_SYS_DOC_SUPPORT_2000
-#define CONFIG_SYS_DOC_SUPPORT_MILLENNIUM
-/************************************************************
  * Keyboard support
  ************************************************************/
 #undef CONFIG_ISA_KEYBOARD
index c4acc05..6928981 100644 (file)
  * General PCI
  * Addresses are mapped 1-1.
  */
-#define CONFIG_SYS_PCI_MEM_BASE        0x80000000
-#define CONFIG_SYS_PCI_MEM_PHYS        CONFIG_SYS_PCI_MEM_BASE
-#define CONFIG_SYS_PCI_MEM_SIZE        0x10000000      /* 256M */
-#define CONFIG_SYS_PCI_MMIO_BASE       0x90000000
-#define CONFIG_SYS_PCI_MMIO_PHYS       CONFIG_SYS_PCI_MMIO_BASE
-#define CONFIG_SYS_PCI_MMIO_SIZE       0x10000000      /* 256M */
-#define CONFIG_SYS_PCI_IO_BASE         0x00000000
-#define CONFIG_SYS_PCI_IO_PHYS         0xE0300000
-#define CONFIG_SYS_PCI_IO_SIZE         0x100000        /* 1M */
+#define CONFIG_SYS_PCI1_MEM_BASE       0x80000000
+#define CONFIG_SYS_PCI1_MEM_PHYS       CONFIG_SYS_PCI1_MEM_BASE
+#define CONFIG_SYS_PCI1_MEM_SIZE       0x10000000      /* 256M */
+#define CONFIG_SYS_PCI1_MMIO_BASE      0x90000000
+#define CONFIG_SYS_PCI1_MMIO_PHYS      CONFIG_SYS_PCI1_MMIO_BASE
+#define CONFIG_SYS_PCI1_MMIO_SIZE      0x10000000      /* 256M */
+#define CONFIG_SYS_PCI1_IO_BASE                0x00000000
+#define CONFIG_SYS_PCI1_IO_PHYS                0xE0300000
+#define CONFIG_SYS_PCI1_IO_SIZE                0x100000        /* 1M */
 
 #define CONFIG_SYS_PCI_SLV_MEM_LOCAL   CONFIG_SYS_SDRAM_BASE
 #define CONFIG_SYS_PCI_SLV_MEM_BUS     0x00000000
 
 #define CONFIG_NET_MULTI
 #define CONFIG_PCI_PNP         /* do pci plug-and-play */
+#define CONFIG_83XX_GENERIC_PCI
+#define CONFIG_83XX_PCI_STREAMING
 
 #undef CONFIG_EEPRO100
 #undef CONFIG_PCI_SCAN_SHOW    /* show pci devices on startup */
 
 #ifdef CONFIG_PCI
 /* PCI MEM space: cacheable */
-#define CONFIG_SYS_IBAT6L      (CONFIG_SYS_PCI_MEM_PHYS | BATL_PP_10 | BATL_MEMCOHERENCE)
-#define CONFIG_SYS_IBAT6U      (CONFIG_SYS_PCI_MEM_PHYS | BATU_BL_256M | BATU_VS | BATU_VP)
+#define CONFIG_SYS_IBAT6L      (CONFIG_SYS_PCI1_MEM_PHYS | BATL_PP_10 | BATL_MEMCOHERENCE)
+#define CONFIG_SYS_IBAT6U      (CONFIG_SYS_PCI1_MEM_PHYS | BATU_BL_256M | BATU_VS | BATU_VP)
 #define CONFIG_SYS_DBAT6L      CONFIG_SYS_IBAT6L
 #define CONFIG_SYS_DBAT6U      CONFIG_SYS_IBAT6U
 /* PCI MMIO space: cache-inhibit and guarded */
-#define CONFIG_SYS_IBAT7L      (CONFIG_SYS_PCI_MMIO_PHYS | BATL_PP_10 | \
+#define CONFIG_SYS_IBAT7L      (CONFIG_SYS_PCI1_MMIO_PHYS | BATL_PP_10 | \
                        BATL_CACHEINHIBIT | BATL_GUARDEDSTORAGE)
-#define CONFIG_SYS_IBAT7U      (CONFIG_SYS_PCI_MMIO_PHYS | BATU_BL_256M | BATU_VS | BATU_VP)
+#define CONFIG_SYS_IBAT7U      (CONFIG_SYS_PCI1_MMIO_PHYS | BATU_BL_256M | BATU_VS | BATU_VP)
 #define CONFIG_SYS_DBAT7L      CONFIG_SYS_IBAT7L
 #define CONFIG_SYS_DBAT7U      CONFIG_SYS_IBAT7U
 #else
 
 /*
  * Environment Configuration
- */
-
-#define CONFIG_ENV_OVERWRITE
+ */ #define CONFIG_ENV_OVERWRITE
 
 #if defined(CONFIG_UEC_ETH)
 #define CONFIG_HAS_ETH0
index 068df57..037cad5 100644 (file)
@@ -382,6 +382,7 @@ boards, we say we have two, but don't display a message if we find only one. */
 
 #define CONFIG_NET_MULTI
 #define CONFIG_PCI_PNP                 /* do pci plug-and-play */
+#define CONFIG_83XX_GENERIC_PCI
 
 #ifndef CONFIG_PCI_PNP
     #define PCI_ENET0_IOADDR   0x00000000
index 60c9968..028ef8c 100644 (file)
  * General PCI
  * Addresses are mapped 1-1.
  */
-#define CONFIG_SYS_PCI_MEM_BASE        0x80000000
-#define CONFIG_SYS_PCI_MEM_PHYS        CONFIG_SYS_PCI_MEM_BASE
-#define CONFIG_SYS_PCI_MEM_SIZE        0x10000000 /* 256M */
-#define CONFIG_SYS_PCI_MMIO_BASE       0x90000000
-#define CONFIG_SYS_PCI_MMIO_PHYS       CONFIG_SYS_PCI_MMIO_BASE
-#define CONFIG_SYS_PCI_MMIO_SIZE       0x10000000 /* 256M */
-#define CONFIG_SYS_PCI_IO_BASE         0x00000000
-#define CONFIG_SYS_PCI_IO_PHYS         0xE0300000
-#define CONFIG_SYS_PCI_IO_SIZE         0x100000 /* 1M */
+#define CONFIG_SYS_PCI1_MEM_BASE       0x80000000
+#define CONFIG_SYS_PCI1_MEM_PHYS       CONFIG_SYS_PCI1_MEM_BASE
+#define CONFIG_SYS_PCI1_MEM_SIZE       0x10000000 /* 256M */
+#define CONFIG_SYS_PCI1_MMIO_BASE      0x90000000
+#define CONFIG_SYS_PCI1_MMIO_PHYS      CONFIG_SYS_PCI1_MMIO_BASE
+#define CONFIG_SYS_PCI1_MMIO_SIZE      0x10000000 /* 256M */
+#define CONFIG_SYS_PCI1_IO_BASE                0x00000000
+#define CONFIG_SYS_PCI1_IO_PHYS                0xE0300000
+#define CONFIG_SYS_PCI1_IO_SIZE                0x100000 /* 1M */
 
 #define CONFIG_SYS_PCI_SLV_MEM_LOCAL   CONFIG_SYS_SDRAM_BASE
 #define CONFIG_SYS_PCI_SLV_MEM_BUS     0x00000000
 
 #define CONFIG_NET_MULTI
 #define CONFIG_PCI_PNP         /* do pci plug-and-play */
+#define CONFIG_83XX_GENERIC_PCI
+#define CONFIG_83XX_PCI_STREAMING
 
 #undef CONFIG_EEPRO100
 #undef CONFIG_PCI_SCAN_SHOW    /* show pci devices on startup */
 
 #ifdef CONFIG_PCI
 /* PCI MEM space: cacheable */
-#define CONFIG_SYS_IBAT6L      (CONFIG_SYS_PCI_MEM_PHYS | BATL_PP_10 | BATL_MEMCOHERENCE)
-#define CONFIG_SYS_IBAT6U      (CONFIG_SYS_PCI_MEM_PHYS | BATU_BL_256M | BATU_VS | BATU_VP)
+#define CONFIG_SYS_IBAT6L      (CONFIG_SYS_PCI1_MEM_PHYS | BATL_PP_10 | BATL_MEMCOHERENCE)
+#define CONFIG_SYS_IBAT6U      (CONFIG_SYS_PCI1_MEM_PHYS | BATU_BL_256M | BATU_VS | BATU_VP)
 #define CONFIG_SYS_DBAT6L      CONFIG_SYS_IBAT6L
 #define CONFIG_SYS_DBAT6U      CONFIG_SYS_IBAT6U
 /* PCI MMIO space: cache-inhibit and guarded */
-#define CONFIG_SYS_IBAT7L      (CONFIG_SYS_PCI_MMIO_PHYS | BATL_PP_10 | \
+#define CONFIG_SYS_IBAT7L      (CONFIG_SYS_PCI1_MMIO_PHYS | BATL_PP_10 | \
                        BATL_CACHEINHIBIT | BATL_GUARDEDSTORAGE)
-#define CONFIG_SYS_IBAT7U      (CONFIG_SYS_PCI_MMIO_PHYS | BATU_BL_256M | BATU_VS | BATU_VP)
+#define CONFIG_SYS_IBAT7U      (CONFIG_SYS_PCI1_MMIO_PHYS | BATU_BL_256M | BATU_VS | BATU_VP)
 #define CONFIG_SYS_DBAT7L      CONFIG_SYS_IBAT7L
 #define CONFIG_SYS_DBAT7U      CONFIG_SYS_IBAT7U
 #else
index 807a534..9132718 100644 (file)
 #endif
 
 #define CONFIG_SYS_MONITOR_LEN         (384 * 1024) /* Reserve 384 kB for Mon */
-#define CONFIG_SYS_MONITOR_LEN         (320 * 1024) /* Reserve 320 kB for Mon */
 #define CONFIG_SYS_MALLOC_LEN          (512 * 1024) /* Reserved for malloc */
 
 /*
index 7085d28..0aaab4a 100644 (file)
@@ -45,6 +45,7 @@
 #define CONFIG_SYS_PCI_64BIT   1       /* enable 64-bit PCI resources */
 
 #define CONFIG_FSL_LAW         1       /* Use common FSL init code */
+#define CONFIG_E1000           1       /* Defind e1000 pci Ethernet card*/
 
 #define CONFIG_TSEC_ENET               /* tsec ethernet support */
 #define CONFIG_ENV_OVERWRITE
@@ -218,6 +219,13 @@ extern unsigned long get_board_ddr_clk(unsigned long dummy);
 #define PIXIS_VCFGEN1          0x13    /* VELA Config Enable 1 */
 #define PIXIS_VCORE0           0x14    /* VELA VCORE0 Register */
 #define PIXIS_VBOOT            0x16    /* VELA VBOOT Register */
+#define PIXIS_VBOOT_LBMAP      0xe0    /* VBOOT - CFG_LBMAP */
+#define PIXIS_VBOOT_LBMAP_NOR0 0x00    /* cfg_lbmap - boot from NOR 0 */
+#define PIXIS_VBOOT_LBMAP_NOR1 0x01    /* cfg_lbmap - boot from NOR 1 */
+#define PIXIS_VBOOT_LBMAP_NOR2 0x02    /* cfg_lbmap - boot from NOR 2 */
+#define PIXIS_VBOOT_LBMAP_NOR3 0x03    /* cfg_lbmap - boot from NOR 3 */
+#define PIXIS_VBOOT_LBMAP_PJET 0x04    /* cfg_lbmap - boot from projet */
+#define PIXIS_VBOOT_LBMAP_NAND 0x05    /* cfg_lbmap - boot from NAND */
 #define PIXIS_VSPEED0          0x17    /* VELA VSpeed 0 */
 #define PIXIS_VSPEED1          0x18    /* VELA VSpeed 1 */
 #define PIXIS_VSPEED2          0x19    /* VELA VSpeed 2 */
@@ -563,10 +571,10 @@ extern unsigned long get_board_ddr_clk(unsigned long dummy);
 
 /*
  * For booting Linux, the board info and command line data
- * have to be in the first 8 MB of memory, since this is
+ * have to be in the first 16 MB of memory, since this is
  * the maximum mapped by the Linux kernel during initialization.
  */
-#define CONFIG_SYS_BOOTMAPSZ   (8 << 20)       /* Initial Memory map for Linux*/
+#define CONFIG_SYS_BOOTMAPSZ   (16 << 20)      /* Initial Memory map for Linux*/
 
 /*
  * Internal Definitions
index 5253611..4af599b 100644 (file)
 
 /*
  * For booting Linux, the board info and command line data
- * have to be in the first 8 MB of memory, since this is
+ * have to be in the first 16 MB of memory, since this is
  * the maximum mapped by the Linux kernel during initialization.
  */
-#define CONFIG_SYS_BOOTMAPSZ   (8 << 20)       /* Initial Memory map for Linux*/
+#define CONFIG_SYS_BOOTMAPSZ   (16 << 20)      /* Initial Memory map for Linux*/
 
 /*
  * Internal Definitions
index 813512c..a8f206f 100644 (file)
@@ -440,10 +440,10 @@ extern unsigned long get_clock_freq(void);
 
 /*
  * For booting Linux, the board info and command line data
- * have to be in the first 8 MB of memory, since this is
+ * have to be in the first 16 MB of memory, since this is
  * the maximum mapped by the Linux kernel during initialization.
  */
-#define CONFIG_SYS_BOOTMAPSZ   (8 << 20)       /* Initial Memory map for Linux*/
+#define CONFIG_SYS_BOOTMAPSZ   (16 << 20)      /* Initial Memory map for Linux*/
 
 /*
  * Internal Definitions
index 1d8fecf..2de3139 100644 (file)
@@ -44,6 +44,7 @@
 #define CONFIG_SYS_PCI_64BIT   1       /* enable 64-bit PCI resources */
 
 #define CONFIG_FSL_LAW         1       /* Use common FSL init code */
+#define CONFIG_E1000           1       /* Defind e1000 pci Ethernet card*/
 
 #define CONFIG_TSEC_ENET               /* tsec ethernet support */
 #define CONFIG_ENV_OVERWRITE
@@ -192,6 +193,8 @@ extern unsigned long get_board_sys_clk(unsigned long dummy);
 #define PIXIS_VCFGEN0          0x12    /* VELA Config Enable 0 */
 #define PIXIS_VCFGEN1          0x13    /* VELA Config Enable 1 */
 #define PIXIS_VBOOT            0x16    /* VELA VBOOT Register */
+#define PIXIS_VBOOT_FMAP       0x80    /* VBOOT - CFG_FLASHMAP */
+#define PIXIS_VBOOT_FBANK      0x40    /* VBOOT - CFG_FLASHBANK */
 #define PIXIS_VSPEED0          0x17    /* VELA VSpeed 0 */
 #define PIXIS_VSPEED1          0x18    /* VELA VSpeed 1 */
 #define PIXIS_VCLKH            0x19    /* VELA VCLKH register */
@@ -458,10 +461,10 @@ extern unsigned long get_board_sys_clk(unsigned long dummy);
 
 /*
  * For booting Linux, the board info and command line data
- * have to be in the first 8 MB of memory, since this is
+ * have to be in the first 16 MB of memory, since this is
  * the maximum mapped by the Linux kernel during initialization.
  */
-#define CONFIG_SYS_BOOTMAPSZ   (8 << 20)       /* Initial Memory map for Linux*/
+#define CONFIG_SYS_BOOTMAPSZ   (16 << 20)      /* Initial Memory map for Linux*/
 
 /*
  * Internal Definitions
index 7089ac7..bebb9e9 100644 (file)
@@ -500,10 +500,10 @@ extern unsigned long get_clock_freq(void);
 
 /*
  * For booting Linux, the board info and command line data
- * have to be in the first 8 MB of memory, since this is
+ * have to be in the first 16 MB of memory, since this is
  * the maximum mapped by the Linux kernel during initialization.
  */
-#define CONFIG_SYS_BOOTMAPSZ   (8 << 20)       /* Initial Memory map for Linux*/
+#define CONFIG_SYS_BOOTMAPSZ   (16 << 20)      /* Initial Memory map for Linux*/
 
 /*
  * Internal Definitions
index ef95118..94952dc 100644 (file)
@@ -438,10 +438,10 @@ extern unsigned long get_clock_freq(void);
 
 /*
  * For booting Linux, the board info and command line data
- * have to be in the first 8 MB of memory, since this is
+ * have to be in the first 16 MB of memory, since this is
  * the maximum mapped by the Linux kernel during initialization.
  */
-#define CONFIG_SYS_BOOTMAPSZ   (8 << 20)       /* Initial Memory map for Linux*/
+#define CONFIG_SYS_BOOTMAPSZ   (16 << 20)      /* Initial Memory map for Linux*/
 
 /*
  * Internal Definitions
index 761a370..c1a1a6d 100644 (file)
 
 /*
  * For booting Linux, the board info and command line data
- * have to be in the first 8 MB of memory, since this is
+ * have to be in the first 16 MB of memory, since this is
  * the maximum mapped by the Linux kernel during initialization.
  */
-#define CONFIG_SYS_BOOTMAPSZ   (8 << 20)       /* Initial Memory map for Linux*/
+#define CONFIG_SYS_BOOTMAPSZ   (16 << 20)      /* Initial Memory map for Linux*/
 
 /*
  * Internal Definitions
index ac34047..7b8c6c7 100644 (file)
@@ -456,10 +456,10 @@ extern unsigned long get_clock_freq(void);
 
 /*
  * For booting Linux, the board info and command line data
- * have to be in the first 8 MB of memory, since this is
+ * have to be in the first 16 MB of memory, since this is
  * the maximum mapped by the Linux kernel during initialization.
  */
-#define CONFIG_SYS_BOOTMAPSZ   (8 << 20)       /* Initial Memory map for Linux*/
+#define CONFIG_SYS_BOOTMAPSZ   (16 << 20)      /* Initial Memory map for Linux*/
 
 /*
  * Internal Definitions
index 27044f7..6e8f1ff 100644 (file)
@@ -471,10 +471,10 @@ extern unsigned long get_clock_freq(void);
 
 /*
  * For booting Linux, the board info and command line data
- * have to be in the first 8 MB of memory, since this is
+ * have to be in the first 16 MB of memory, since this is
  * the maximum mapped by the Linux kernel during initialization.
  */
-#define CONFIG_SYS_BOOTMAPSZ   (8 << 20)
+#define CONFIG_SYS_BOOTMAPSZ   (16 << 20)
                                        /* Initial Memory map for Linux*/
 
 /*
index 235be51..64f5c4b 100644 (file)
@@ -237,6 +237,11 @@ extern unsigned long get_board_ddr_clk(unsigned long dummy);
 #define PIXIS_VCFGEN1          0x13    /* VELA Config Enable 1 */
 #define PIXIS_VCORE0           0x14    /* VELA VCORE0 Register */
 #define PIXIS_VBOOT            0x16    /* VELA VBOOT Register */
+#define PIXIS_VBOOT_LBMAP      0xc0    /* VBOOT - CFG_LBMAP */
+#define PIXIS_VBOOT_LBMAP_NOR0 0x00    /* cfg_lbmap - boot from NOR 0 */
+#define PIXIS_VBOOT_LBMAP_PJET 0x01    /* cfg_lbmap - boot from projet */
+#define PIXIS_VBOOT_LBMAP_NAND 0x02    /* cfg_lbmap - boot from NAND */
+#define PIXIS_VBOOT_LBMAP_NOR1 0x03    /* cfg_lbmap - boot from NOR 1 */
 #define PIXIS_VSPEED0          0x17    /* VELA VSpeed 0 */
 #define PIXIS_VSPEED1          0x18    /* VELA VSpeed 1 */
 #define PIXIS_VSPEED2          0x19    /* VELA VSpeed 2 */
@@ -607,10 +612,10 @@ extern unsigned long get_board_ddr_clk(unsigned long dummy);
 
 /*
  * For booting Linux, the board info and command line data
- * have to be in the first 8 MB of memory, since this is
+ * have to be in the first 16 MB of memory, since this is
  * the maximum mapped by the Linux kernel during initialization.
  */
-#define CONFIG_SYS_BOOTMAPSZ   (8 << 20)       /* Initial Memory map for Linux*/
+#define CONFIG_SYS_BOOTMAPSZ   (16 << 20)      /* Initial Memory map for Linux*/
 
 /*
  * Internal Definitions
index 955ac3d..bf2e359 100644 (file)
@@ -224,6 +224,8 @@ extern unsigned long get_board_sys_clk(unsigned long dummy);
 #define PIXIS_VCFGEN0          0x12    /* VELA Config Enable 0 */
 #define PIXIS_VCFGEN1          0x13    /* VELA Config Enable 1 */
 #define PIXIS_VBOOT            0x16    /* VELA VBOOT Register */
+#define PIXIS_VBOOT_FMAP       0x80    /* VBOOT - CFG_FLASHMAP */
+#define PIXIS_VBOOT_FBANK      0x40    /* VBOOT - CFG_FLASHBANK */
 #define PIXIS_VSPEED0          0x17    /* VELA VSpeed 0 */
 #define PIXIS_VSPEED1          0x18    /* VELA VSpeed 1 */
 #define PIXIS_VCLKH            0x19    /* VELA VCLKH register */
index 796938a..76ca916 100644 (file)
  */
 #include <config_cmd_default.h>
 
-#define CONFIG_CMD_NAND
 #define CONFIG_CMD_DHCP
 #define CONFIG_CMD_PING
 #define CONFIG_CMD_MII
 #define DSP_BASE       0xF1000000
 #define NAND_BASE      0xF1010000
 
-/****************************************************************/
-
-/* NAND */
-#define CONFIG_NAND_LEGACY
-#define CONFIG_SYS_NAND_BASE           NAND_BASE
-#define CONFIG_MTD_NAND_ECC_JFFS2
-#define CONFIG_MTD_NAND_VERIFY_WRITE
-#define CONFIG_MTD_NAND_UNSAFE
-
-#define CONFIG_SYS_MAX_NAND_DEVICE     1
-
-#define SECTORSIZE             512
-#define ADDR_COLUMN            1
-#define ADDR_PAGE              2
-#define ADDR_COLUMN_PAGE       3
-#define NAND_ChipID_UNKNOWN    0x00
-#define NAND_MAX_FLOORS                1
-
-/* ALE = PD17, CLE = PE18, CE = PE20, F_RY_BY = PE31 */
-#define NAND_DISABLE_CE(nand) \
-       do { \
-               (((volatile immap_t *)CONFIG_SYS_IMMR)->im_cpm.cp_pedat) |=  (1 << (31 - 20)); \
-       } while(0)
-
-#define NAND_ENABLE_CE(nand) \
-       do { \
-               (((volatile immap_t *)CONFIG_SYS_IMMR)->im_cpm.cp_pedat) &= ~(1 << (31 - 20)); \
-       } while(0)
-
-#define NAND_CTL_CLRALE(nandptr) \
-       do { \
-               (((volatile immap_t *)CONFIG_SYS_IMMR)->im_cpm.cp_pedat) &= ~(1 << (31 - 17)); \
-       } while(0)
-
-#define NAND_CTL_SETALE(nandptr) \
-       do { \
-               (((volatile immap_t *)CONFIG_SYS_IMMR)->im_cpm.cp_pedat) |=  (1 << (31 - 17)); \
-       } while(0)
-
-#define NAND_CTL_CLRCLE(nandptr) \
-       do { \
-               (((volatile immap_t *)CONFIG_SYS_IMMR)->im_cpm.cp_pedat) &= ~(1 << (31 - 18)); \
-       } while(0)
-
-#define NAND_CTL_SETCLE(nandptr) \
-       do { \
-               (((volatile immap_t *)CONFIG_SYS_IMMR)->im_cpm.cp_pedat) |=  (1 << (31 - 18)); \
-       } while(0)
-
-#if CONFIG_NETPHONE_VERSION == 1
-#define NAND_WAIT_READY(nand) \
-       do { \
-               int _tries = 0; \
-               while ((((volatile immap_t *)CONFIG_SYS_IMMR)->im_cpm.cp_pedat & (1 << (31 - 31))) == 0) \
-                       if (++_tries > 100000) \
-                               break; \
-       } while (0)
-#elif CONFIG_NETPHONE_VERSION == 2
-#define NAND_WAIT_READY(nand) \
-       do { \
-               int _tries = 0; \
-               while ((((volatile immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pcdat & (1 << (15 - 15))) == 0) \
-                       if (++_tries > 100000) \
-                               break; \
-       } while (0)
-#endif
-
-#define WRITE_NAND_COMMAND(d, adr) \
-       do { \
-               *(volatile unsigned char *)((unsigned long)(adr)) = (unsigned char)(d); \
-       } while(0)
-
-#define WRITE_NAND_ADDRESS(d, adr) \
-       do { \
-               *(volatile unsigned char *)((unsigned long)(adr)) = (unsigned char)(d); \
-       } while(0)
-
-#define WRITE_NAND(d, adr) \
-       do { \
-               *(volatile unsigned char *)((unsigned long)(adr)) = (unsigned char)(d); \
-       } while(0)
-
-#define READ_NAND(adr) \
-       ((unsigned char)(*(volatile unsigned char *)(unsigned long)(adr)))
-
 /*****************************************************************************/
 
 #define CONFIG_SYS_DIRECT_FLASH_TFTP
-#define CONFIG_SYS_DIRECT_NAND_TFTP
 
 /*****************************************************************************/
 
index 724e807..4f9f9fe 100644 (file)
 #define CONFIG_CMD_IDE
 #define CONFIG_CMD_JFFS2
 #define CONFIG_CMD_MII
-#define CONFIG_CMD_NAND
 #define CONFIG_CMD_NFS
 #define CONFIG_CMD_PCMCIA
 #define CONFIG_CMD_PING
 #define ER_BASE                0xF1020000
 #define DUMMY_BASE     0xF1FF0000
 
-/****************************************************************/
-
-/* NAND */
-#define CONFIG_NAND_LEGACY
-#define CONFIG_SYS_NAND_BASE                   NAND_BASE
-#define CONFIG_MTD_NAND_VERIFY_WRITE
-#define CONFIG_MTD_NAND_UNSAFE
-
-#define CONFIG_SYS_MAX_NAND_DEVICE             1
-/* #define NAND_NO_RB */
-
-#define SECTORSIZE             512
-#define ADDR_COLUMN            1
-#define ADDR_PAGE              2
-#define ADDR_COLUMN_PAGE       3
-#define NAND_ChipID_UNKNOWN    0x00
-#define NAND_MAX_FLOORS                1
-
-/* ALE = PD3, CLE = PD4, CE = PD5, F_RY_BY = PC13 */
-#define NAND_DISABLE_CE(nand) \
-       do { \
-               (((volatile immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pddat) |=  (1 << (15 - 5)); \
-       } while(0)
-
-#define NAND_ENABLE_CE(nand) \
-       do { \
-               (((volatile immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pddat) &= ~(1 << (15 - 5)); \
-       } while(0)
-
-#define NAND_CTL_CLRALE(nandptr) \
-       do { \
-               (((volatile immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pddat) &= ~(1 << (15 - 3)); \
-       } while(0)
-
-#define NAND_CTL_SETALE(nandptr) \
-       do { \
-               (((volatile immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pddat) |=  (1 << (15 - 3)); \
-       } while(0)
-
-#define NAND_CTL_CLRCLE(nandptr) \
-       do { \
-               (((volatile immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pddat) &= ~(1 << (15 - 4)); \
-       } while(0)
-
-#define NAND_CTL_SETCLE(nandptr) \
-       do { \
-               (((volatile immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pddat) |=  (1 << (15 - 4)); \
-       } while(0)
-
-#ifndef NAND_NO_RB
-#define NAND_WAIT_READY(nand) \
-       do { \
-               while ((((volatile immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pcdat & (1 << (15 - 13))) == 0) { \
-                       WATCHDOG_RESET(); \
-               } \
-       } while (0)
-#else
-#define NAND_WAIT_READY(nand) udelay(12)
-#endif
-
-#define WRITE_NAND_COMMAND(d, adr) \
-       do { \
-               *(volatile unsigned char *)((unsigned long)(adr)) = (unsigned char)(d); \
-       } while(0)
-
-#define WRITE_NAND_ADDRESS(d, adr) \
-       do { \
-               *(volatile unsigned char *)((unsigned long)(adr)) = (unsigned char)(d); \
-       } while(0)
-
-#define WRITE_NAND(d, adr) \
-       do { \
-               *(volatile unsigned char *)((unsigned long)(adr)) = (unsigned char)(d); \
-       } while(0)
-
-#define READ_NAND(adr) \
-       ((unsigned char)(*(volatile unsigned char *)(unsigned long)(adr)))
-
-#define CONFIG_JFFS2_NAND      1                       /* jffs2 on nand support */
-#define NAND_CACHE_PAGES       16                      /* size of nand cache in 512 bytes pages */
-
-/*
- * JFFS2 partitions
- *
- */
-/* No command line, one static partition, whole device */
-#undef CONFIG_CMD_MTDPARTS
-#define CONFIG_JFFS2_DEV               "nand0"
-#define CONFIG_JFFS2_PART_SIZE         0x00100000
-#define CONFIG_JFFS2_PART_OFFSET       0x00200000
-
-/* mtdparts command line support */
-/* Note: fake mtd_id used, no linux mtd map file */
-/*
-#define CONFIG_CMD_MTDPARTS
-#define MTDIDS_DEFAULT         "nand0=netta-nand"
-#define MTDPARTS_DEFAULT       "mtdparts=netta-nand:1m@2m(jffs2)"
-*/
-
 /*****************************************************************************/
 
 #define CONFIG_SYS_DIRECT_FLASH_TFTP
index a14b2dd..d060cb7 100644 (file)
  */
 #include <config_cmd_default.h>
 
-#define CONFIG_CMD_NAND
 #define CONFIG_CMD_DHCP
 #define CONFIG_CMD_PING
 #define CONFIG_CMD_MII
 #define DSP_BASE       0xF1000000
 #define NAND_BASE      0xF1010000
 
-/****************************************************************/
-
-/* NAND */
-#define CONFIG_NAND_LEGACY
-#define CONFIG_SYS_NAND_BASE           NAND_BASE
-#define CONFIG_MTD_NAND_ECC_JFFS2
-#define CONFIG_MTD_NAND_VERIFY_WRITE
-#define CONFIG_MTD_NAND_UNSAFE
-
-#define CONFIG_SYS_MAX_NAND_DEVICE     1
-
-#define SECTORSIZE             512
-#define ADDR_COLUMN            1
-#define ADDR_PAGE              2
-#define ADDR_COLUMN_PAGE       3
-#define NAND_ChipID_UNKNOWN    0x00
-#define NAND_MAX_FLOORS                1
-
-/* ALE = PD17, CLE = PE18, CE = PE20, F_RY_BY = PE31 */
-#define NAND_DISABLE_CE(nand) \
-       do { \
-               (((volatile immap_t *)CONFIG_SYS_IMMR)->im_cpm.cp_pedat) |=  (1 << (31 - 20)); \
-       } while(0)
-
-#define NAND_ENABLE_CE(nand) \
-       do { \
-               (((volatile immap_t *)CONFIG_SYS_IMMR)->im_cpm.cp_pedat) &= ~(1 << (31 - 20)); \
-       } while(0)
-
-#define NAND_CTL_CLRALE(nandptr) \
-       do { \
-               (((volatile immap_t *)CONFIG_SYS_IMMR)->im_cpm.cp_pedat) &= ~(1 << (31 - 17)); \
-       } while(0)
-
-#define NAND_CTL_SETALE(nandptr) \
-       do { \
-               (((volatile immap_t *)CONFIG_SYS_IMMR)->im_cpm.cp_pedat) |=  (1 << (31 - 17)); \
-       } while(0)
-
-#define NAND_CTL_CLRCLE(nandptr) \
-       do { \
-               (((volatile immap_t *)CONFIG_SYS_IMMR)->im_cpm.cp_pedat) &= ~(1 << (31 - 18)); \
-       } while(0)
-
-#define NAND_CTL_SETCLE(nandptr) \
-       do { \
-               (((volatile immap_t *)CONFIG_SYS_IMMR)->im_cpm.cp_pedat) |=  (1 << (31 - 18)); \
-       } while(0)
-
-#if CONFIG_NETTA2_VERSION == 1
-#define NAND_WAIT_READY(nand) \
-       do { \
-               int _tries = 0; \
-               while ((((volatile immap_t *)CONFIG_SYS_IMMR)->im_cpm.cp_pedat & (1 << (31 - 31))) == 0) \
-                       if (++_tries > 100000) \
-                               break; \
-       } while (0)
-#elif CONFIG_NETTA2_VERSION == 2
-#define NAND_WAIT_READY(nand) \
-       do { \
-               int _tries = 0; \
-               while ((((volatile immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pcdat & (1 << (15 - 15))) == 0) \
-                       if (++_tries > 100000) \
-                               break; \
-       } while (0)
-#endif
-
-#define WRITE_NAND_COMMAND(d, adr) \
-       do { \
-               *(volatile unsigned char *)((unsigned long)(adr)) = (unsigned char)(d); \
-       } while(0)
-
-#define WRITE_NAND_ADDRESS(d, adr) \
-       do { \
-               *(volatile unsigned char *)((unsigned long)(adr)) = (unsigned char)(d); \
-       } while(0)
-
-#define WRITE_NAND(d, adr) \
-       do { \
-               *(volatile unsigned char *)((unsigned long)(adr)) = (unsigned char)(d); \
-       } while(0)
-
-#define READ_NAND(adr) \
-       ((unsigned char)(*(volatile unsigned char *)(unsigned long)(adr)))
-
 /*****************************************************************************/
 
 #define CONFIG_SYS_DIRECT_FLASH_TFTP
-#define CONFIG_SYS_DIRECT_NAND_TFTP
 
 /*****************************************************************************/
 
index f97bdcb..a18b480 100644 (file)
 #define CONFIG_CMD_PING
 
 #if defined(CONFIG_NETVIA_VERSION) && CONFIG_NETVIA_VERSION >= 2
-#define CONFIG_CMD_NAND
+/* #define CONFIG_CMD_NAND */ /* disabled */
 #endif
 
 
 
 #endif
 
-/*****************************************************************************/
-
-#define CONFIG_NAND_LEGACY
-
-#if defined(CONFIG_NETVIA_VERSION) && CONFIG_NETVIA_VERSION >= 2
-
-/* NAND */
-#define CONFIG_SYS_NAND_BASE                   NAND_BASE
-#define CONFIG_MTD_NAND_ECC_JFFS2
-
-#define CONFIG_SYS_MAX_NAND_DEVICE             1
-
-#define SECTORSIZE             512
-#define ADDR_COLUMN            1
-#define ADDR_PAGE              2
-#define ADDR_COLUMN_PAGE       3
-#define NAND_ChipID_UNKNOWN    0x00
-#define NAND_MAX_FLOORS                1
-
-#define NAND_DISABLE_CE(nand) \
-       do { \
-               (((volatile immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pddat) |=  0x0040; \
-       } while(0)
-
-#define NAND_ENABLE_CE(nand) \
-       do { \
-               (((volatile immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pddat) &= ~0x0040; \
-       } while(0)
-
-#define NAND_CTL_CLRALE(nandptr) \
-       do { \
-               (((volatile immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pddat) &= ~0x0100; \
-       } while(0)
-
-#define NAND_CTL_SETALE(nandptr) \
-       do { \
-               (((volatile immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pddat) |=  0x0100; \
-       } while(0)
-
-#define NAND_CTL_CLRCLE(nandptr) \
-       do { \
-               (((volatile immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pddat) &= ~0x0080; \
-       } while(0)
-
-#define NAND_CTL_SETCLE(nandptr) \
-       do { \
-               (((volatile immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pddat) |=  0x0080; \
-       } while(0)
-
-#define NAND_WAIT_READY(nand) \
-       do { \
-               while ((((volatile immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pcdat & 0x100) == 0) \
-                       ; \
-       } while (0)
-
-#define WRITE_NAND_COMMAND(d, adr) \
-       do { \
-               *(volatile unsigned char *)((unsigned long)(adr)) = (unsigned char)(d); \
-       } while(0)
-
-#define WRITE_NAND_ADDRESS(d, adr) \
-       do { \
-               *(volatile unsigned char *)((unsigned long)(adr)) = (unsigned char)(d); \
-       } while(0)
-
-#define WRITE_NAND(d, adr) \
-       do { \
-               *(volatile unsigned char *)((unsigned long)(adr)) = (unsigned char)(d); \
-       } while(0)
-
-#define READ_NAND(adr) \
-       ((unsigned char)(*(volatile unsigned char *)(unsigned long)(adr)))
-
-#endif
 
 /*****************************************************************************/
 
index 676f013..5c2c5cb 100644 (file)
@@ -282,6 +282,11 @@ extern unsigned long calculate_board_ddr_clk(unsigned long dummy);
 #define PIXIS_VWATCH           0x24    /* Watchdog Register */
 #define PIXIS_LED              0x25    /* LED Register */
 
+#define PIXIS_SW(x)            0x20 + (x - 1) * 2
+#define PIXIS_EN(x)            0x21 + (x - 1) * 2
+#define PIXIS_SW7_LBMAP                0xc0    /* SW7 - cfg_lbmap */
+#define PIXIS_SW7_VBANK                0x30    /* SW7 - cfg_vbank */
+
 /* old pixis referenced names */
 #define PIXIS_VCLKH            0x19    /* VELA VCLKH register */
 #define PIXIS_VCLKL            0x1A    /* VELA VCLKL register */
@@ -412,7 +417,6 @@ extern unsigned long calculate_board_ddr_clk(unsigned long dummy);
 #define CONFIG_HARD_I2C                /* I2C with hardware support */
 #undef CONFIG_SOFT_I2C         /* I2C bit-banged */
 #define CONFIG_I2C_MULTI_BUS
-#define CONFIG_I2C_CMD_TREE
 #define CONFIG_SYS_I2C_SPEED           400000  /* I2C speed and slave address */
 #define CONFIG_SYS_I2C_EEPROM_ADDR     0x57
 #define CONFIG_SYS_I2C_SLAVE           0x7F
@@ -637,10 +641,10 @@ extern unsigned long calculate_board_ddr_clk(unsigned long dummy);
 
 /*
  * For booting Linux, the board info and command line data
- * have to be in the first 8 MB of memory, since this is
+ * have to be in the first 16 MB of memory, since this is
  * the maximum mapped by the Linux kernel during initialization.
  */
-#define CONFIG_SYS_BOOTMAPSZ   (8 << 20)       /* Initial Memory map for Linux*/
+#define CONFIG_SYS_BOOTMAPSZ   (16 << 20)      /* Initial Memory map for Linux*/
 
 /*
  * Internal Definitions
index 5951d00..99a8c4a 100644 (file)
@@ -75,7 +75,6 @@
 #define CONFIG_CMD_BSP
 #define CONFIG_CMD_DATE
 #define CONFIG_CMD_DHCP
-#define CONFIG_CMD_DOC
 #define CONFIG_CMD_ELF
 #define CONFIG_CMD_NFS
 #define CONFIG_CMD_PCI
@@ -84,8 +83,6 @@
 #define CONFIG_PCI             1
 #define CONFIG_PCI_PNP         1       /* PCI plug-and-play */
 
-#define CONFIG_NAND_LEGACY
-
 /*
  * Miscellaneous configurable options
  */
 #define BOOTFLAG_WARM          0x02    /* Software reboot                      */
 
 /*-----------------------------------------------------------------------
- * Disk-On-Chip configuration
- */
-
-#define CONFIG_SYS_MAX_DOC_DEVICE      1       /* Max number of DOC devices            */
-
-#define CONFIG_SYS_DOC_SUPPORT_2000
-#undef CONFIG_SYS_DOC_SUPPORT_MILLENNIUM
-
-/*-----------------------------------------------------------------------
   RTC m48t59
 */
 #define CONFIG_RTC_MK48T59
index a683a8f..66e6d24 100644 (file)
@@ -75,7 +75,6 @@
 #define CONFIG_CMD_BSP
 #define CONFIG_CMD_DATE
 #define CONFIG_CMD_DHCP
-#define CONFIG_CMD_DOC
 #define CONFIG_CMD_ELF
 #define CONFIG_CMD_NFS
 #define CONFIG_CMD_PCI
@@ -86,8 +85,6 @@
 #define CONFIG_PCI             1
 #define CONFIG_PCI_PNP         1       /* PCI plug-and-play */
 
-#define CONFIG_NAND_LEGACY
-
 /*
  * Miscellaneous configurable options
  */
 #define BOOTFLAG_WARM          0x02    /* Software reboot                      */
 
 /*-----------------------------------------------------------------------
- * Disk-On-Chip configuration
- */
-
-#define CONFIG_SYS_MAX_DOC_DEVICE      1       /* Max number of DOC devices            */
-
-#define CONFIG_SYS_DOC_SUPPORT_2000
-#undef CONFIG_SYS_DOC_SUPPORT_MILLENNIUM
-
-/*-----------------------------------------------------------------------
   RTC m48t59
 */
 #define CONFIG_RTC_MK48T59
index e301599..962b29e 100644 (file)
 #define CONFIG_CMD_USB
 #define CONFIG_CMD_MII
 #define CONFIG_CMD_SDRAM
-#define CONFIG_CMD_DOC
 #define CONFIG_CMD_PING
 #define CONFIG_CMD_SAVES
 #define CONFIG_CMD_BSP
 
-
-#define CONFIG_NAND_LEGACY
-
 #define         CONFIG_SYS_HUSH_PARSER
 #define         CONFIG_SYS_PROMPT_HUSH_PS2 "> "
 /**************************************************************
index 7f2337b..2e41526 100644 (file)
 #define CONFIG_SYS_NAND_SKIP_BAD_DOT_I 1       /* ".i" read skips bad blocks   */
 #define CONFIG_SYS_NAND_QUIET          1
 
+#define CONFIG_SYS_64BIT_VSPRINTF      /* needed for nand_util.c */
+
 /*
  * PCI stuff
  */
index ff73ef9..f9687d2 100644 (file)
 #define CONFIG_USB_STORAGE
 #endif
 
-#if !defined(CONFIG_BOOT_ROM)
-/* DoC requires legacy NAND for now */
-#define CONFIG_NAND_LEGACY
-#endif
-
-
 /*
  * BOOTP options
  */
 #define CONFIG_CMD_SNTP
 #define CONFIG_CMD_USB
 
-#if !defined(CONFIG_BOOT_ROM)
-#define CONFIG_CMD_DOC
-#endif
-
 #if defined(CONFIG_MPC5200)
 #define CONFIG_CMD_PCI
 #endif
 #define CONFIG_RTC_PCF8563
 #define CONFIG_SYS_I2C_RTC_ADDR                0x51
 
-/*
- * Disk-On-Chip configuration
- */
-
-#define CONFIG_SYS_DOC_SHORT_TIMEOUT
-#define CONFIG_SYS_MAX_DOC_DEVICE      1       /* Max number of DOC devices    */
-
-#define CONFIG_SYS_DOC_SUPPORT_2000
-#define CONFIG_SYS_DOC_SUPPORT_MILLENNIUM
 #define CONFIG_SYS_DOC_BASE            0xE0000000
 #define CONFIG_SYS_DOC_SIZE            0x00100000
 
index b58f529..636bd26 100644 (file)
 #define CONFIG_CMD_BEDBUG
 #define CONFIG_CMD_DATE
 #define CONFIG_CMD_DHCP
-#define CONFIG_CMD_DOC
 #define CONFIG_CMD_EEPROM
 #define CONFIG_CMD_I2C
 #define CONFIG_CMD_NFS
 #define CONFIG_CMD_PCI
 #endif
 
-
-#define CONFIG_NAND_LEGACY
-
-/*
- * Disk-On-Chip configuration
- */
-
-#define CONFIG_SYS_DOC_SHORT_TIMEOUT
-#define CONFIG_SYS_MAX_DOC_DEVICE      1       /* Max number of DOC devices    */
-
-#define CONFIG_SYS_DOC_SUPPORT_2000
-#define CONFIG_SYS_DOC_SUPPORT_MILLENNIUM
-
 /*
  * Miscellaneous configurable options
  */
index 96c86f7..9d620af 100644 (file)
 #define CONFIG_CMD_BEDBUG
 #define CONFIG_CMD_DATE
 #define CONFIG_CMD_DHCP
-#define CONFIG_CMD_DOC
 #define CONFIG_CMD_EEPROM
 #define CONFIG_CMD_I2C
 #define CONFIG_CMD_NFS
 #define CONFIG_CMD_PCI
 #endif
 
-
-/*
- * Disk-On-Chip configuration
- */
-#define CONFIG_NAND_LEGACY
-
-#define CONFIG_SYS_DOC_SHORT_TIMEOUT
-#define CONFIG_SYS_MAX_DOC_DEVICE      1       /* Max number of DOC devices    */
-
-#define CONFIG_SYS_DOC_SUPPORT_2000
-#define CONFIG_SYS_DOC_SUPPORT_MILLENNIUM
-
 /*
  * Miscellaneous configurable options
  */
index 16baf8c..6fba0ca 100644 (file)
  * NAND-FLASH stuff
  *-----------------------------------------------------------------------
  */
+
+#define CONFIG_SYS_64BIT_VSPRINTF      /* needed for nand_util.c */
+
 /*
  * nand device 1 on dave (PPChameleonEVB) needs more time,
  * so we just introduce additional wait in nand_wait(),
        } \
 } while(0)
 
-#if 0
-#define SECTORSIZE 512
-#define NAND_NO_RB
-
-#define ADDR_COLUMN 1
-#define ADDR_PAGE 2
-#define ADDR_COLUMN_PAGE 3
-
-#define NAND_ChipID_UNKNOWN    0x00
-#define NAND_MAX_FLOORS 1
-
-#ifdef NAND_NO_RB
-/* constant delay (see also tR in the datasheet) */
-#define NAND_WAIT_READY(nand) do { \
-       udelay(12); \
-} while (0)
-#else
-/* use the R/B pin */
-/* TBD */
-#endif
-
-#define WRITE_NAND_COMMAND(d, adr) do{ *(volatile __u8 *)((unsigned long)adr) = (__u8)(d); } while(0)
-#define WRITE_NAND_ADDRESS(d, adr) do{ *(volatile __u8 *)((unsigned long)adr) = (__u8)(d); } while(0)
-#define WRITE_NAND(d, adr) do{ *(volatile __u8 *)((unsigned long)adr) = (__u8)d; } while(0)
-#define READ_NAND(adr) ((volatile unsigned char)(*(volatile __u8 *)(unsigned long)adr))
-#endif
 /*-----------------------------------------------------------------------
  * PCI stuff
  *-----------------------------------------------------------------------
index f36244d..00ac6cf 100644 (file)
 #define CONFIG_CMD_CDP
 #define CONFIG_CMD_DHCP
 #define CONFIG_CMD_DIAG
-#define CONFIG_CMD_DOC
 #define CONFIG_CMD_EEPROM
 #define CONFIG_CMD_ELF
 #define CONFIG_CMD_FAT
 
 #endif
 
-/************************************************************
- * Disk-On-Chip configuration
- ************************************************************/
-#define CONFIG_SYS_MAX_DOC_DEVICE      1       /* Max number of DOC devices            */
-#define CONFIG_SYS_DOC_SHORT_TIMEOUT
-#define CONFIG_SYS_DOC_SUPPORT_2000
-#define CONFIG_SYS_DOC_SUPPORT_MILLENNIUM
-
 /*-----------------------------------------------------------------------
  *
  *-----------------------------------------------------------------------
index cac04b4..8ee8cbf 100644 (file)
 
 #define CONFIG_CMD_EEPROM
 #define CONFIG_CMD_JFFS2
-#define CONFIG_CMD_NAND
 #define CONFIG_CMD_DATE
 
-
-#define CONFIG_SYS_JFFS2_SORT_FRAGMENTS
-
-/*
- * JFFS2 partitions
- *
- */
-/* No command line, one static partition */
-#undef CONFIG_CMD_MTDPARTS
-
-/*
-#define CONFIG_JFFS2_DEV               "nor0"
-#define CONFIG_JFFS2_PART_SIZE         0x00780000
-#define CONFIG_JFFS2_PART_OFFSET       0x00080000
-*/
-
-#define CONFIG_JFFS2_DEV               "nand0"
-#define CONFIG_JFFS2_PART_SIZE         0x00200000
-#define CONFIG_JFFS2_PART_OFFSET       0x00000000
-
-/* mtdparts command line support */
-/* Note: fake mtd_id used, no linux mtd map file */
-/*
-#define CONFIG_CMD_MTDPARTS
-#define MTDIDS_DEFAULT         "nor0=sixnet-0,nand0=sixnet-nand"
-#define MTDPARTS_DEFAULT       "mtdparts=sixnet-0:7680k@512k();sixnet-nand:2m(jffs2-nand)"
-*/
-
-/* NAND flash support */
-#define CONFIG_NAND_LEGACY
-#define CONFIG_MTD_NAND_ECC_JFFS2
-#define CONFIG_SYS_MAX_NAND_DEVICE     1       /* Max number of NAND devices   */
-#define SECTORSIZE 512
-
-#define ADDR_COLUMN 1
-#define ADDR_PAGE 2
-#define ADDR_COLUMN_PAGE 3
-
-#define NAND_ChipID_UNKNOWN    0x00
-#define NAND_MAX_FLOORS 1
-
-/* DFBUSY is available on Port C, bit 12; 0 if busy */
-#define NAND_WAIT_READY(nand)  \
-       while (!(((volatile immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pcdat & 0x0008));
-#define WRITE_NAND_COMMAND(d, adr) WRITE_NAND((d), (adr))
-#define WRITE_NAND_ADDRESS(d, adr) WRITE_NAND((d), (adr))
-#define WRITE_NAND(d, adr)     \
-        do { (*(volatile uint8_t *)(adr) = (uint8_t)(d)); } while (0)
-#define READ_NAND(adr) (*(volatile uint8_t *)(adr))
-#define        CLE_LO  0x01    /* 0 selects CLE mode (CLE high) */
-#define        ALE_LO  0x02    /* 0 selects ALE mode (ALE high) */
-#define        CE_LO   0x04    /* 1 selects chip (CE low) */
-#define        nand_setcr(cr, val) do {*(volatile uint8_t*)(cr) = (val);} while (0)
-#define NAND_DISABLE_CE(nand) \
-       nand_setcr((nand)->IO_ADDR + 1, ALE_LO | CLE_LO)
-#define NAND_ENABLE_CE(nand) \
-       nand_setcr((nand)->IO_ADDR + 1, CE_LO | ALE_LO | CLE_LO)
-#define NAND_CTL_CLRALE(nandptr) \
-       nand_setcr((nandptr) + 1, CE_LO | ALE_LO | CLE_LO)
-#define NAND_CTL_SETALE(nandptr) \
-       nand_setcr((nandptr) + 1, CE_LO | CLE_LO)
-#define NAND_CTL_CLRCLE(nandptr) \
-       nand_setcr((nandptr) + 1, CE_LO | ALE_LO | CLE_LO)
-#define NAND_CTL_SETCLE(nandptr) \
-       nand_setcr((nandptr) + 1, CE_LO | ALE_LO)
-
 /*
  * Miscellaneous configurable options
  */
index 9cac696..6c462af 100644 (file)
        WRITE_NAND(d, addr); \
 } while(0)
 
+#define CONFIG_SYS_64BIT_VSPRINTF      /* needed for nand_util.c */
+
 #endif /* CONFIG_CMD_NAND */
 
 #define        CONFIG_PCI
index efade69..541a27b 100644 (file)
@@ -247,12 +247,16 @@ extern int tqm834x_num_flash_banks;
 #if defined(CONFIG_PCI)
 
 #define CONFIG_PCI_PNP                  /* do pci plug-and-play */
+#define CONFIG_83XX_GENERIC_PCI
 #define CONFIG_PCI_SCAN_SHOW            /* show pci devices on startup */
 
 /* PCI1 host bridge */
-#define CONFIG_SYS_PCI1_MEM_BASE       0xc0000000
+#define CONFIG_SYS_PCI1_MEM_BASE       0x80000000
 #define CONFIG_SYS_PCI1_MEM_PHYS       CONFIG_SYS_PCI1_MEM_BASE
-#define CONFIG_SYS_PCI1_MEM_SIZE       0x20000000      /* 512M */
+#define CONFIG_SYS_PCI1_MEM_SIZE       0x10000000      /* 256M */
+#define CONFIG_SYS_PCI1_MMIO_BASE      (CONFIG_SYS_PCI1_MEM_BASE + CONFIG_SYS_PCI1_MEM_SIZE)
+#define CONFIG_SYS_PCI1_MMIO_PHYS      CONFIG_SYS_PCI1_MMIO_BASE
+#define CONFIG_SYS_PCI1_MMIO_SIZE      0x10000000     /* 256M */
 #define CONFIG_SYS_PCI1_IO_BASE        0xe2000000
 #define CONFIG_SYS_PCI1_IO_PHYS        CONFIG_SYS_PCI1_IO_BASE
 #define CONFIG_SYS_PCI1_IO_SIZE        0x1000000       /* 16M */
@@ -418,10 +422,10 @@ extern int tqm834x_num_flash_banks;
 #ifdef CONFIG_PCI
 #define CONFIG_SYS_IBAT3L      (CONFIG_SYS_PCI1_MEM_BASE | BATL_PP_10 | BATL_MEMCOHERENCE)
 #define CONFIG_SYS_IBAT3U      (CONFIG_SYS_PCI1_MEM_BASE | BATU_BL_256M | BATU_VS | BATU_VP)
-#define CONFIG_SYS_IBAT4L      (CONFIG_SYS_PCI1_MEM_BASE + 0x10000000 | BATL_PP_10 | BATL_MEMCOHERENCE)
-#define CONFIG_SYS_IBAT4U      (CONFIG_SYS_PCI1_MEM_BASE + 0x10000000 | BATU_BL_256M | BATU_VS | BATU_VP)
+#define CONFIG_SYS_IBAT4L      (CONFIG_SYS_PCI1_MMIO_BASE | BATL_PP_10 | BATL_MEMCOHERENCE | BATL_GUARDEDSTORAGE)
+#define CONFIG_SYS_IBAT4U      (CONFIG_SYS_PCI1_MMIO_BASE | BATU_BL_256M | BATU_VS | BATU_VP)
 #define CONFIG_SYS_IBAT5L      (CONFIG_SYS_PCI1_IO_BASE | BATL_PP_10 | BATL_CACHEINHIBIT | BATL_GUARDEDSTORAGE)
-#define CONFIG_SYS_IBAT5U      (CONFIG_SYS_PCI1_IO_BASE + 0x10000000 | BATU_BL_16M | BATU_VS | BATU_VP)
+#define CONFIG_SYS_IBAT5U      (CONFIG_SYS_PCI1_IO_BASE | BATU_BL_16M | BATU_VS | BATU_VP)
 #else
 #define CONFIG_SYS_IBAT3L      (0)
 #define CONFIG_SYS_IBAT3U      (0)
index 6f13c63..1fbf4bf 100644 (file)
 /* NAND FLASH */
 #ifdef CONFIG_NAND
 
-#undef CONFIG_NAND_LEGACY
-
 #define CONFIG_NAND_FSL_UPM    1
 
 #define        CONFIG_MTD_NAND_ECC_JFFS2       1       /* use JFFS2 ECC        */
 
 #define NAND_BIG_DELAY_US              25      /* max tR for Samsung devices   */
 
+#define CONFIG_SYS_64BIT_VSPRINTF              /* needed for nand_util.c */
+
 #endif /* CONFIG_NAND */
 
 /*
index 7edea6a..6051480 100644 (file)
 
 #define MULTI_PURPOSE_SOCKET_ADDR 0x08000000
 
-/*-----------------------------------------------------------------------
- * NAND flash settings
- */
-#if defined(CONFIG_CMD_NAND)
-
-#define CONFIG_NAND_LEGACY
-#define CONFIG_SYS_MAX_NAND_DEVICE     1       /* Max number of NAND devices           */
-#define SECTORSIZE 512
-
-#define ADDR_COLUMN 1
-#define ADDR_PAGE 2
-#define ADDR_COLUMN_PAGE 3
-
-#define NAND_ChipID_UNKNOWN    0x00
-#define NAND_MAX_FLOORS 1
-
-#define NAND_WAIT_READY(nand)  NF_WaitRB()
-
-#define NAND_DISABLE_CE(nand)  NF_SetCE(NFCE_HIGH)
-#define NAND_ENABLE_CE(nand)   NF_SetCE(NFCE_LOW)
-
-
-#define WRITE_NAND_COMMAND(d, adr)     NF_Cmd(d)
-#define WRITE_NAND_COMMANDW(d, adr)    NF_CmdW(d)
-#define WRITE_NAND_ADDRESS(d, adr)     NF_Addr(d)
-#define WRITE_NAND(d, adr)             NF_Write(d)
-#define READ_NAND(adr)                 NF_Read()
-/* the following functions are NOP's because S3C24X0 handles this in hardware */
-#define NAND_CTL_CLRALE(nandptr)
-#define NAND_CTL_SETALE(nandptr)
-#define NAND_CTL_CLRCLE(nandptr)
-#define NAND_CTL_SETCLE(nandptr)
-
-#define CONFIG_MTD_NAND_VERIFY_WRITE   1
-#define CONFIG_MTD_NAND_ECC_JFFS2      1
-
-#endif
-
 #endif /* __CONFIG_H */
index 38a1d0d..17397e8 100644 (file)
 #define CONFIG_SYS_NAND_SKIP_BAD_DOT_I 1       /* ".i" read skips bad blocks   */
 #define CONFIG_SYS_NAND_QUIET          1
 
+#define CONFIG_SYS_64BIT_VSPRINTF      /* needed for nand_util.c */
+
 /*-----------------------------------------------------------------------
  * PCI stuff
  *-----------------------------------------------------------------------
index 5c281a1..dbfa1aa 100644 (file)
 
 #define CONFIG_SYS_NAND_SKIP_BAD_DOT_I      1  /* ".i" read skips bad blocks   */
 
+#define CONFIG_SYS_64BIT_VSPRINTF      /* needed for nand_util.c */
+
 /*-----------------------------------------------------------------------
  * PCI stuff
  *-----------------------------------------------------------------------
index 2553293..8be9fa0 100644 (file)
@@ -254,7 +254,6 @@ extern unsigned long get_board_sys_clk(unsigned long dummy);
 #define CONFIG_SYS_I2C_OFFSET          0x3000
 #define CONFIG_SYS_I2C2_OFFSET         0x3100
 #define CONFIG_I2C_MULTI_BUS
-#define CONFIG_I2C_CMD_TREE
 
 /* PEX8518 slave I2C interface */
 #define CONFIG_SYS_I2C_PEX8518_ADDR    0x70
@@ -580,6 +579,7 @@ extern unsigned long get_board_sys_clk(unsigned long dummy);
  * the maximum mapped by the Linux kernel during initialization.
  */
 #define CONFIG_SYS_BOOTMAPSZ   (16 << 20)      /* Initial Memory map for Linux*/
+#define CONFIG_SYS_BOOTM_LEN   (16 << 20)      /* Increase max gunzip size */
 
 /*
  * Boot Flags
index 89ab692..deda208 100644 (file)
 #define CONFIG_SYS_FLASH_WRITE_TOUT    500             /* Flash Write Timeout (ms) */
 #define CONFIG_FLASH_CFI_DRIVER
 #define CONFIG_SYS_FLASH_CFI
+#define CONFIG_SYS_FLASH_USE_BUFFER_WRITE
 #define CONFIG_SYS_FLASH_AUTOPROTECT_LIST      { {0xfff40000, 0xc0000}, \
                                                  {0xfbf40000, 0xc0000} }
 #define CONFIG_SYS_MONITOR_BASE        TEXT_BASE       /* start of monitor */
  * the maximum mapped by the Linux kernel during initialization.
  */
 #define CONFIG_SYS_BOOTMAPSZ   (16 << 20)      /* Initial Memory map for Linux*/
+#define CONFIG_SYS_BOOTM_LEN   (16 << 20)      /* Increase max gunzip size */
 
 /*
  * Boot Flags
index 536e063..acb62ad 100644 (file)
@@ -124,6 +124,12 @@ extern unsigned long get_board_ddr_clk(unsigned long dummy);
  */
 #define CONFIG_SYS_NAND_BASE           0xef800000
 #define CONFIG_SYS_NAND_BASE2          0xef840000 /* Unused at this time */
+#define CONFIG_SYS_NAND_BASE_LIST      {CONFIG_SYS_NAND_BASE, \
+                                        CONFIG_SYS_NAND_BASE2}
+#define CONFIG_SYS_MAX_NAND_DEVICE     2
+#define CONFIG_MTD_NAND_VERIFY_WRITE
+#define CONFIG_SYS_NAND_QUIET_TEST     /* 2nd NAND flash not always populated */
+#define CONFIG_NAND_FSL_ELBC
 
 /*
  * NOR flash configuration
@@ -137,6 +143,7 @@ extern unsigned long get_board_ddr_clk(unsigned long dummy);
 #define CONFIG_SYS_FLASH_WRITE_TOUT    500             /* Flash Write Timeout (ms) */
 #define CONFIG_FLASH_CFI_DRIVER
 #define CONFIG_SYS_FLASH_CFI
+#define CONFIG_SYS_FLASH_USE_BUFFER_WRITE
 #define CONFIG_SYS_FLASH_AUTOPROTECT_LIST      { {0xfff40000, 0xc0000}, \
                                                  {0xf7f40000, 0xc0000} }
 #define CONFIG_SYS_MONITOR_BASE        TEXT_BASE       /* start of monitor */
@@ -374,16 +381,17 @@ extern unsigned long get_board_ddr_clk(unsigned long dummy);
 #define CONFIG_CMD_DTT
 #define CONFIG_CMD_EEPROM
 #define CONFIG_CMD_ELF
-#define CONFIG_CMD_SAVEENV
 #define CONFIG_CMD_FLASH
 #define CONFIG_CMD_I2C
 #define CONFIG_CMD_JFFS2
 #define CONFIG_CMD_MII
+#define CONFIG_CMD_NAND
 #define CONFIG_CMD_NET
 #define CONFIG_CMD_PCA953X
 #define CONFIG_CMD_PCA953X_INFO
 #define CONFIG_CMD_PCI
 #define CONFIG_CMD_PING
+#define CONFIG_CMD_SAVEENV
 #define CONFIG_CMD_SNTP
 
 /*
@@ -412,6 +420,7 @@ extern unsigned long get_board_ddr_clk(unsigned long dummy);
  * the maximum mapped by the Linux kernel during initialization.
  */
 #define CONFIG_SYS_BOOTMAPSZ   (16 << 20)      /* Initial Memory map for Linux*/
+#define CONFIG_SYS_BOOTM_LEN   (16 << 20)      /* Increase max gunzip size */
 
 /*
  * Boot Flags
index 9ffd86b..b710107 100644 (file)
 #define CONFIG_SYS_NAND_BASE           (CONFIG_SYS_NAND_ADDR + CONFIG_SYS_NAND_CS)
 #define CONFIG_SYS_NAND_SELECT_DEVICE  1       /* nand driver supports mutipl. chips   */
 
+#define CONFIG_SYS_64BIT_VSPRINTF      /* needed for nand_util.c */
+
 /*-----------------------------------------------------------------------
  * External Bus Controller (EBC) Setup
  *----------------------------------------------------------------------*/
index c5134a2..74677d8 100644 (file)
 #define CONFIG_SYS_NAND_MASK_CLE               (1 << 22)
 #define CONFIG_SYS_NAND_ENABLE_PIN             AT91_PIN_PC14
 #define CONFIG_SYS_NAND_READY_PIN              AT91_PIN_PC13
+
+#define CONFIG_SYS_64BIT_VSPRINTF              /* needed for nand_util.c */
 #endif
 
 /* NOR flash - no real flash on this board */
 #define CONFIG_SYS_LONGHELP            1
 #define CONFIG_CMDLINE_EDITING 1
 
-#define ROUND(A, B)            (((A) + (B)) & ~((B) - 1))
 /*
  * Size of malloc() pool
  */
index fa5a7a9..575f60e 100644 (file)
 #define        CONFIG_ENV_IS_IN_ONENAND        1
 #define CONFIG_ENV_ADDR                0x00020000
 
+#define CONFIG_SYS_64BIT_VSPRINTF              /* needed for nand_util.c */
+
 #ifdef CONFIG_SYS_USE_UBI
 #define CONFIG_CMD_MTDPARTS
 #define MTDIDS_DEFAULT         "onenand0=onenand"
index e7e238d..4211113 100644 (file)
 #define CONFIG_HARD_I2C                        /* I2C with hardware support */
 #undef CONFIG_SOFT_I2C                 /* so disable bit-banged I2C */
 #define CONFIG_I2C_MULTI_BUS
-#define CONFIG_I2C_CMD_TREE
 
 /* I2C speed and slave address */
 #define CONFIG_SYS_I2C_SPEED           100000
index 219eea3..27f8fd1 100644 (file)
 #define CONFIG_SYS_NAND_DBW_8                  1
 #endif
 
+#define CONFIG_SYS_64BIT_VSPRINTF              /* needed for nand_util.c */
+#endif
+
 /* Ethernet */
 #define CONFIG_MACB                    1
 #define CONFIG_RMII                    1
 #define CONFIG_SYS_LONGHELP            1
 #define CONFIG_CMDLINE_EDITING 1
 
-#define ROUND(A, B)            (((A) + (B)) & ~((B) - 1))
 /*
  * Size of malloc() pool
  */
index 56128c1..2017b66 100644 (file)
 
 #define CONFIG_CMD_DHCP
 #define CONFIG_CMD_MII
-#define CONFIG_CMD_NAND
-
-#define CONFIG_NAND_LEGACY
-
-#define CONFIG_SYS_MAX_NAND_DEVICE     1       /* Max number of NAND devices           */
-#define SECTORSIZE 512
-
-#define ADDR_COLUMN 1
-#define ADDR_PAGE 2
-#define ADDR_COLUMN_PAGE 3
-
-#define NAND_ChipID_UNKNOWN    0x00
-#define NAND_MAX_FLOORS 1
-
-#define AT91_SMART_MEDIA_ALE (1 << 22) /* our ALE is AD22 */
-#define AT91_SMART_MEDIA_CLE (1 << 21) /* our CLE is AD21 */
 
 #include <asm/arch/AT91RM9200.h>       /* needed for port definitions */
-#define NAND_DISABLE_CE(nand) do { *AT91C_PIOC_SODR = AT91C_PIO_PC0;} while(0)
-#define NAND_ENABLE_CE(nand) do { *AT91C_PIOC_CODR = AT91C_PIO_PC0;} while(0)
-
-#define NAND_WAIT_READY(nand) while (!(*AT91C_PIOC_PDSR & AT91C_PIO_PC2))
-
-#define WRITE_NAND_COMMAND(d, adr) do{ *(volatile __u8 *)((unsigned long)adr | AT91_SMART_MEDIA_CLE) = (__u8)(d); } while(0)
-#define WRITE_NAND_ADDRESS(d, adr) do{ *(volatile __u8 *)((unsigned long)adr | AT91_SMART_MEDIA_ALE) = (__u8)(d); } while(0)
-#define WRITE_NAND(d, adr) do{ *(volatile __u8 *)((unsigned long)adr) = (__u8)d; } while(0)
-#define READ_NAND(adr) ((volatile unsigned char)(*(volatile __u8 *)(unsigned long)adr))
-/* the following are NOP's in our implementation */
-#define NAND_CTL_CLRALE(nandptr)
-#define NAND_CTL_SETALE(nandptr)
-#define NAND_CTL_CLRCLE(nandptr)
-#define NAND_CTL_SETCLE(nandptr)
 
 #define CONFIG_NR_DRAM_BANKS 1
 #define PHYS_SDRAM 0x20000000
index c898c73..58ec94a 100644 (file)
@@ -311,7 +311,6 @@ struct bd_info_ext {
  */
 #define CONFIG_SYS_HZ_CLOCK (AT91C_MASTER_CLOCK / 2)
 
-#define ROUND(A, B)            (((A) + (B)) & ~((B) - 1))
 /*
  * Size of malloc() pool
  */
index 1828c63..6cee593 100644 (file)
 #define CONFIG_SYS_NAND_MASK_CLE               (1 << 22)
 #define CONFIG_SYS_NAND_ENABLE_PIN             AT91_PIN_PC14
 #define CONFIG_SYS_NAND_READY_PIN              AT91_PIN_PC13
+
+#define CONFIG_SYS_64BIT_VSPRINTF              /* needed for nand_util.c */
 #endif
 
 /* NOR flash - no real flash on this board */
 #define CONFIG_SYS_LONGHELP            1
 #define CONFIG_CMDLINE_EDITING 1
 
-#define ROUND(A, B)            (((A) + (B)) & ~((B) - 1))
 /*
  * Size of malloc() pool
  */
index 6d24023..3d108ab 100644 (file)
 #define CONFIG_SYS_NAND_MASK_CLE               (1 << 21)
 #define CONFIG_SYS_NAND_ENABLE_PIN             AT91_PIN_PC14
 #define CONFIG_SYS_NAND_READY_PIN              AT91_PIN_PC15
+
+#define CONFIG_SYS_64BIT_VSPRINTF              /* needed for nand_util.c */
 #endif
 
 /* NOR flash - no real flash on this board */
 #define CONFIG_SYS_LONGHELP            1
 #define CONFIG_CMDLINE_EDITING 1
 
-#define ROUND(A, B)            (((A) + (B)) & ~((B) - 1))
 /*
  * Size of malloc() pool
  */
index 00f3114..32f3f62 100644 (file)
 #define CONFIG_SYS_NAND_MASK_CLE               (1 << 22)
 #define CONFIG_SYS_NAND_ENABLE_PIN             AT91_PIN_PD15
 #define CONFIG_SYS_NAND_READY_PIN              AT91_PIN_PA22
+
+#define CONFIG_SYS_64BIT_VSPRINTF              /* needed for nand_util.c */
 #endif
 
 /* Ethernet */
 #define CONFIG_SYS_HUSH_PARSER
 #define CONFIG_SYS_PROMPT_HUSH_PS2     "> "
 
-#define ROUND(A, B)            (((A) + (B)) & ~((B) - 1))
 /*
  * Size of malloc() pool
  */
index 572c45b..4b46c31 100644 (file)
 /* NOR flash, if populated */
 #ifndef CONFIG_CMD_NAND
 #define CONFIG_SYS_NO_FLASH            1
+#define CONFIG_SYS_64BIT_VSPRINTF              /* needed for nand_util.c */
 #else
 #define CONFIG_SYS_FLASH_CFI           1
 #define CONFIG_FLASH_CFI_DRIVER                1
 #define CONFIG_SYS_NAND_MASK_CLE               (1 << 22)
 #define CONFIG_SYS_NAND_ENABLE_PIN             AT91_PIN_PC14
 #define CONFIG_SYS_NAND_READY_PIN              AT91_PIN_PC8
+
+#define CONFIG_SYS_64BIT_VSPRINTF              /* needed for nand_util.c */
 #endif
 
 /* Ethernet */
 #define CONFIG_SYS_HUSH_PARSER
 #define CONFIG_SYS_PROMPT_HUSH_PS2     "> "
 
-#define ROUND(A, B)            (((A) + (B)) & ~((B) - 1))
 /*
  * Size of malloc() pool
  */
index c466823..9167304 100644 (file)
 #define CONFIG_SYS_NAND_MASK_CLE               (1 << 22)
 #define CONFIG_SYS_NAND_ENABLE_PIN             AT91_PIN_PB6
 #define CONFIG_SYS_NAND_READY_PIN              AT91_PIN_PD17
+
+#define CONFIG_SYS_64BIT_VSPRINTF              /* needed for nand_util.c */
 #endif
 
 /* Ethernet - not present */
 #define CONFIG_SYS_LONGHELP            1
 #define CONFIG_CMDLINE_EDITING 1
 
-#define ROUND(A, B)            (((A) + (B)) & ~((B) - 1))
 /*
  * Size of malloc() pool
  */
index c03561c..4be2a5c 100644 (file)
@@ -36,7 +36,7 @@
 #define CONFIG_CCLK_DIV                        1
 /* SCLK_DIV controls the system clock divider                          */
 /* Values can range from 1-15                                          */
-#define CONFIG_SCLK_DIV                        5
+#define CONFIG_SCLK_DIV                        6 /* note: 1.2 boards can go faster */
 
 
 /*
index 23c2d33..463b7d0 100644 (file)
@@ -87,9 +87,8 @@
 
 #define CONFIG_SYS_AUTOLOAD    "no"
 #define CONFIG_ROOTPATH                /romfs
-/* Use a fixed MAC address for booting up. Firstboot linux
- * must fetch a valid MAC from the production server. */
-#define CONFIG_ETHADDR 02:80:ad:20:31:42
+/* Uncomment next line to use fixed MAC address */
+/* #define CONFIG_ETHADDR      02:80:ad:20:31:42 */
 
 
 /*
index 727b7e7..7368629 100644 (file)
@@ -87,9 +87,8 @@
 
 #define CONFIG_SYS_AUTOLOAD    "no"
 #define CONFIG_ROOTPATH                /romfs
-/* Use a fixed MAC address for booting up. Firstboot linux
- * must fetch a valid MAC from the production server. */
-#define CONFIG_ETHADDR 02:80:ad:20:31:42
+/* Uncomment next line to use fixed MAC address */
+/* #define CONFIG_ETHADDR      02:80:ad:20:31:42 */
 
 
 /*
index 48c5198..d22d411 100644 (file)
 #define CONFIG_CMD_FAT
 #define CONFIG_CMD_NAND
 #define CONFIG_CMD_PCI
+#define CONFIG_CMD_SATA
 #define CONFIG_CMD_SDRAM
 #define CONFIG_CMD_SNTP
 #define CONFIG_CMD_USB
 #endif /* CONFIG_ARCHES */
 #endif /* CONFIG_460GT */
 
+/*
+ * SATA driver setup
+ */
+#ifdef CONFIG_CMD_SATA
+#define CONFIG_SATA_DWC
+#define CONFIG_LIBATA
+#define SATA_BASE_ADDR         0xe20d1000      /* PPC460EX SATA Base Address */
+#define SATA_DMA_REG_ADDR      0xe20d0800      /* PPC460EX SATA Base Address */
+#define CONFIG_SYS_SATA_MAX_DEVICE     1       /* SATA MAX DEVICE */
+/* Convert sectorsize to wordsize */
+#define ATA_SECTOR_WORDS (ATA_SECT_SIZE/2)
+#endif
+
 /*-----------------------------------------------------------------------
  * External Bus Controller (EBC) Setup
  *----------------------------------------------------------------------*/
index e1cdc7f..7a57696 100644 (file)
 #define CONFIG_CMD_JFFS2
 #define CONFIG_CMD_PING
 
-#ifdef NAND_SUPPORT_HAS_BEEN_FIXED     /* NAND support is broken / unimplemented */
-
-#define CONFIG_SYS_MAX_NAND_DEVICE     1       /* Max number of NAND devices           */
-#define SECTORSIZE 512
-
-#define ADDR_COLUMN 1
-#define ADDR_PAGE 2
-#define ADDR_COLUMN_PAGE 3
-
-#define NAND_ChipID_UNKNOWN    0x00
-#define NAND_MAX_FLOORS 1
-
-#define AT91_SMART_MEDIA_ALE (1 << 22) /* our ALE is AD22 */
-#define AT91_SMART_MEDIA_CLE (1 << 21) /* our CLE is AD21 */
-
-#include <asm/arch/AT91RM9200.h>       /* needed for port definitions */
-#define NAND_DISABLE_CE(nand) do { *AT91C_PIOC_SODR = AT91C_PIO_PC0;} while(0)
-#define NAND_ENABLE_CE(nand) do { *AT91C_PIOC_CODR = AT91C_PIO_PC0;} while(0)
-
-#define NAND_WAIT_READY(nand) while (!(*AT91C_PIOC_PDSR & AT91C_PIO_PC2))
-
-#define WRITE_NAND_COMMAND(d, adr) do{ *(volatile __u8 *)((unsigned long)adr | AT91_SMART_MEDIA_CLE) = (__u8)(d); } while(0)
-#define WRITE_NAND_ADDRESS(d, adr) do{ *(volatile __u8 *)((unsigned long)adr | AT91_SMART_MEDIA_ALE) = (__u8)(d); } while(0)
-#define WRITE_NAND(d, adr) do{ *(volatile __u8 *)((unsigned long)adr) = (__u8)d; } while(0)
-#define READ_NAND(adr) ((volatile unsigned char)(*(volatile __u8 *)(unsigned long)adr))
-/* the following are NOP's in our implementation */
-#define NAND_CTL_CLRALE(nandptr)
-#define NAND_CTL_SETALE(nandptr)
-#define NAND_CTL_CLRCLE(nandptr)
-#define NAND_CTL_SETCLE(nandptr)
-
-#endif /* NAND_SUPPORT_HAS_BEEN_FIXED */
 
 #define CONFIG_NR_DRAM_BANKS 1
 #define PHYS_SDRAM                     0x20000000
index 9cb9838..7909569 100644 (file)
@@ -93,6 +93,7 @@
 #define CONFIG_SYS_NAND_HW_ECC
 #define CONFIG_SYS_MAX_NAND_DEVICE     1       /* Max number of NAND devices */
 #define CONFIG_ENV_OFFSET              0x0     /* Block 0--not used by bootcode */
+#define CONFIG_SYS_64BIT_VSPRINTF              /* needed for nand_util.c */
 /*=====================*/
 /* Board related stuff */
 /*=====================*/
index a47620f..531baf1 100644 (file)
@@ -88,6 +88,7 @@
 #define CONFIG_SYS_NAND_HW_ECC
 #define CONFIG_SYS_MAX_NAND_DEVICE     1       /* Max number of NAND devices */
 #define CONFIG_ENV_OFFSET              0x0     /* Block 0--not used by bootcode */
+#define CONFIG_SYS_64BIT_VSPRINTF              /* needed for nand_util.c */
 /* I2C switch definitions for PCA9543 chip */
 #define CONFIG_SYS_I2C_PCA9543_ADDR            0x70
 #define CONFIG_SYS_I2C_PCA9543_ADDR_LEN        0       /* Single register. */
index e7186e8..95e04f9 100644 (file)
 /*
  * NAND Flash
  */
-#undef CONFIG_NAND_LEGACY
-
 #define CONFIG_SYS_NAND0_BASE          0x0 /* 0x43100040 */ /* 0x10000000 */
 #undef CONFIG_SYS_NAND1_BASE
 
 #define CONFIG_SYS_NAND_BASE_LIST      { CONFIG_SYS_NAND0_BASE }
 #define CONFIG_SYS_MAX_NAND_DEVICE     1       /* Max number of NAND devices */
 
+#define CONFIG_SYS_64BIT_VSPRINTF              /* needed for nand_util.c */
+
 /* nand timeout values */
 #define CONFIG_SYS_NAND_PROG_ERASE_TO  3000
 #define CONFIG_SYS_NAND_OTHER_TO       100
 #define CONFIG_MTD_DEBUG
 #define CONFIG_MTD_DEBUG_VERBOSE 1
 
-#define ADDR_COLUMN            1
-#define ADDR_PAGE              2
-#define ADDR_COLUMN_PAGE       3
-
-#define NAND_ChipID_UNKNOWN    0x00
-#define NAND_MAX_FLOORS                1
-
 #define CONFIG_SYS_NO_FLASH            1
 
 #define CONFIG_ENV_IS_IN_NAND  1
index 558010f..6ccebfa 100644 (file)
  */
 #define CONFIG_SYS_LONGHELP
 #define CONFIG_AUTO_COMPLETE   1
+#define CONFIG_CMDLINE_EDITING 1
 #define CONFIG_SYS_PROMPT      "=> "
 #define CONFIG_SYS_HUSH_PARSER
 #define CONFIG_SYS_PROMPT_HUSH_PS2     "> "
index 0fcf692..0cc1b3b 100644 (file)
@@ -45,6 +45,7 @@
 #define CONFIG_CMD_I2C
 #define CONFIG_CMD_JFFS2
 #define CONFIG_JFFS2_CMDLINE
+#define CONFIG_CMD_MTDPARTS
 
 #undef CONFIG_WATCHDOG                 /* disable platform specific watchdog */
 
@@ -97,7 +98,7 @@
 #define CONFIG_SYS_SLOT_ID_MASK                (0x3f)  /* mask for slot ID bits */
 
 #define CONFIG_I2C_MULTI_BUS   1
-#define CONFIG_SYS_MAX_I2C_BUS         2
+#define CONFIG_SYS_MAX_I2C_BUS         1
 #define CONFIG_SYS_I2C_INIT_BOARD      1
 #define CONFIG_I2C_MUX         1
 
 #define CONFIG_BOOTP_GATEWAY
 #define CONFIG_BOOTP_HOSTNAME
 
+#define CONFIG_ENV_SIZE                0x04000 /* Size of Environment */
+
+#define CONFIG_SYS_MALLOC_LEN  (1024 * 1024)   /* Reserved for malloc */
+
+#define CONFIG_SYS_64BIT_VSPRINTF      /* needed for UBI/UBIFS */
+
+/* UBI Support for all Keymile boards */
+#define CONFIG_CMD_UBI
+#define CONFIG_RBTREE
+#define CONFIG_MTD_PARTITIONS
+#define CONFIG_FLASH_CFI_MTD
+#define CONFIG_MTD_DEVICE
+#define CONFIG_MTD_CONCAT
+
 /* define this to use the keymile's io muxing feature */
 /*#define CONFIG_IO_MUXING */
 
index 97bac99..df1b061 100644 (file)
 #define CONFIG_SYS_NAND_BASE           (CONFIG_SYS_NAND_ADDR + CONFIG_SYS_NAND_CS)
 #define CONFIG_SYS_NAND_SELECT_DEVICE  1       /* nand driver supports mutipl. chips   */
 
+#define CONFIG_SYS_64BIT_VSPRINTF      /* needed for nand_util.c */
+
 /*-----------------------------------------------------------------------
  * DDR SDRAM
  *----------------------------------------------------------------------*/
index c305b89..b5552d2 100644 (file)
 #define CONFIG_SYS_FLASH_BASE          0xf0000000
 #define CONFIG_SYS_MONITOR_LEN         (384 << 10) /* 384 kB for Monitor */
 #define CONFIG_SYS_MONITOR_BASE        CONFIG_SYS_FLASH_BASE
-#define CONFIG_SYS_MALLOC_LEN          (256 << 10) /* 256 kB for malloc() */
 
 /*
  * For booting Linux, the board info and command line data
 
 #define CONFIG_ENV_IS_IN_FLASH 1
 #define CONFIG_ENV_OFFSET      CONFIG_SYS_MONITOR_LEN
-#define CONFIG_ENV_SIZE                0x04000 /* Total Size of Environment Sector */
 #define CONFIG_ENV_SECT_SIZE   0x20000 /* Total Size of Environment Sector */
 
 /* Address and size of Redundant Environment Sector    */
index 41dbd0d..869fd4c 100644 (file)
@@ -33,7 +33,6 @@
 /* include common defines/options for all Keymile boards */
 #include "keymile-common.h"
 
-#undef CONFIG_SYS_I2C_INIT_BOARD
 #define CONFIG_MISC_INIT_R     1
 /*
  * System Clock Setup
 #endif
 
 #define CONFIG_SYS_MONITOR_LEN         (384 * 1024) /* Reserve 384 kB for Mon */
-#define CONFIG_SYS_MALLOC_LEN          (128 * 1024) /* Reserved for malloc */
 
 /*
  * Initial RAM Base Address Setup
 #define CONFIG_ENV_IS_IN_FLASH 1
 #define CONFIG_ENV_ADDR                (CONFIG_SYS_MONITOR_BASE + CONFIG_SYS_MONITOR_LEN)
 #define CONFIG_ENV_SECT_SIZE   0x20000 /* 128K(one sector) for env */
-#define CONFIG_ENV_SIZE                0x20000
 #define CONFIG_ENV_OFFSET      (CONFIG_SYS_MONITOR_LEN)
 
 /* Address and size of Redundant Environment Sector    */
 #define CONFIG_SYS_I2C_SLAVE   0x7F
 #define CONFIG_SYS_I2C_OFFSET  0x3000
 #define CONFIG_I2C_MULTI_BUS   1
-#define CONFIG_SYS_MAX_I2C_BUS         2
 #define CONFIG_I2C_MUX         1
 
 /* EEprom support */
 #define CONFIG_SYS_DTT_MAX_TEMP        70
 #define CONFIG_SYS_DTT_LOW_TEMP        -30
 #define CONFIG_SYS_DTT_HYSTERESIS      3
-#define CONFIG_SYS_DTT_BUS_NUM         (2)
+#define CONFIG_SYS_DTT_BUS_NUM         (CONFIG_SYS_MAX_I2C_BUS)
 
 #if defined(CONFIG_PCI)
 #define CONFIG_CMD_PCI
 
 #define CONFIG_PRAM    512     /* protected RAM [KBytes] */
 
-#define MTDIDS_DEFAULT         "nor0=app"
+#define MTDIDS_DEFAULT         "nor2=app"
 #define MTDPARTS_DEFAULT \
        "mtdparts=app:256k(u-boot),128k(env),128k(envred),"     \
        "1536k(esw0),8704k(rootfs0),1536k(esw1),2432k(rootfs1),640k(var),768k(cfg)"
index 1e7d90e..32a8194 100644 (file)
 #define CONFIG_SYS_PROMPT_HUSH_PS2         ">>"
 
 #define CONFIG_SYS_MAX_NAND_DEVICE     0 /* Max number of NAND devices */
-#define SECTORSIZE                          512
-
-#define ADDR_COLUMN            1
-#define ADDR_PAGE              2
-#define ADDR_COLUMN_PAGE       3
 
 #define CONFIG_NR_DRAM_BANKS   1
 #define PHYS_SDRAM             0x20000000
index e00859a..1ecae00 100644 (file)
 #define CONFIG_HARD_I2C                        /* I2C with hardware support */
 #undef CONFIG_SOFT_I2C                 /* so disable bit-banged I2C */
 #define CONFIG_I2C_MULTI_BUS
-#define CONFIG_I2C_CMD_TREE
 #define CONFIG_SYS_I2C_SPEED           400000  /* I2C speed */
 #define CONFIG_SYS_I2C_SLAVE           0x7F    /* slave address */
 
index 28c4de0..8253172 100644 (file)
 #define CONFIG_SYS_NAND_MASK_CLE               (1 << 22)
 #define CONFIG_SYS_NAND_ENABLE_PIN             AT91_PIN_PD15
 #define CONFIG_SYS_NAND_READY_PIN              AT91_PIN_PA22
+
+#define CONFIG_SYS_64BIT_VSPRINTF              /* needed for nand_util.c */
 #endif
 
 /* Ethernet */
index cc42101..ea14948 100644 (file)
        "addcon=setenv bootargs ${bootargs} "                           \
                "console=ttyCPM0,${baudrate}\0"                         \
        "mtdids=nor0=boot,nor1=app \0"                                  \
-       "mtdparts=mtdparts=boot:384k(u-boot),128k(env),128k(envred),"   \
-               "3456k(free);app:3m(esw0),10m(rootfs0),3m(esw1),"       \
-               "10m(rootfs1),1m(var),5m(cfg) \0"                       \
        "partition=nor1,5 \0"                                           \
        "new_env=prot off FE060000 FE09FFFF; era FE060000 FE09FFFF \0"  \
        "EEprom_ivm=pca9544a:70:4 \0"                                   \
-       "mtdparts=" MK_STR(MTDPARTS_DEFAULT) "\0"                               \
+       "mtdparts=" MK_STR(MTDPARTS_DEFAULT) "\0"                       \
+       "unlock=yes\0"                                                  \
        ""
 
 #define CONFIG_SYS_SDRAM_BASE          0x00000000
 #define CONFIG_SYS_FLASH_SIZE          32
 #define CONFIG_SYS_FLASH_CFI
 #define CONFIG_FLASH_CFI_DRIVER
-#define CONFIG_SYS_MAX_FLASH_BANKS     2       /* max num of flash banks       */
+#define CONFIG_SYS_MAX_FLASH_BANKS     3       /* max num of flash banks       */
 #define CONFIG_SYS_MAX_FLASH_SECT      512     /* max num of sects on one chip */
 
 #define CONFIG_SYS_FLASH_BASE_1        0x50000000
-#define CONFIG_SYS_FLASH_SIZE_1        64
+#define CONFIG_SYS_FLASH_SIZE_1        32
+#define CONFIG_SYS_FLASH_BASE_2        0x52000000
+#define CONFIG_SYS_FLASH_SIZE_2        32
 
-#define CONFIG_SYS_FLASH_BANKS_LIST { CONFIG_SYS_FLASH_BASE, CONFIG_SYS_FLASH_BASE_1 }
+#define CONFIG_SYS_FLASH_BANKS_LIST { CONFIG_SYS_FLASH_BASE, \
+                                       CONFIG_SYS_FLASH_BASE_1, \
+                                       CONFIG_SYS_FLASH_BASE_2 }
 
 #define CONFIG_SYS_MONITOR_BASE        TEXT_BASE
 #if (CONFIG_SYS_MONITOR_BASE < CONFIG_SYS_FLASH_BASE)
 #define BOOTFLAG_COLD          0x01    /* Normal Power-On: Boot from FLASH */
 #define BOOTFLAG_WARM          0x02    /* Software reboot                  */
 
-#define CONFIG_SYS_MALLOC_LEN          (4096 << 10)    /* Reserve 4 MB for malloc()    */
 #define CONFIG_SYS_BOOTMAPSZ           (8 << 20)       /* Initial Memory map for Linux */
 
 #define CONFIG_SYS_CACHELINE_SIZE      32      /* For MPC8260 CPUs */
 #define CONFIG_SYS_BR5_PRELIM  ((CONFIG_SYS_FLASH_BASE_1 & BRx_BA_MSK) |\
                         BRx_PS_16 | BRx_MS_GPCM_P | BRx_V)
 
-#define CONFIG_SYS_OR5_PRELIM  (MEG_TO_AM(CONFIG_SYS_FLASH_SIZE_1) |\
-                        ORxG_CSNT | ORxG_ACS_DIV2 |\
-                        ORxG_SCY_5_CLK | ORxG_TRLX )
+#define CONFIG_SYS_OR5_PRELIM  (MEG_TO_AM(CONFIG_SYS_FLASH_SIZE_1 + \
+                                CONFIG_SYS_FLASH_SIZE_2) |\
+                                ORxG_CSNT | ORxG_ACS_DIV2 |\
+                                ORxG_SCY_5_CLK | ORxG_TRLX )
 
 #define        CONFIG_SYS_RESET_ADDRESS 0xFDFFFFFC     /* "bad" address                */
 
index 5062cdb..f0b4207 100644 (file)
 #define CONFIG_SYS_NAND_BASE           0x04000000 + (2 << 23)
 #define NAND_ALLOW_ERASE_ALL           1
 
+#define CONFIG_SYS_64BIT_VSPRINTF              /* needed for nand_util.c */
+
 #define CONFIG_HARD_I2C
 #define CONFIG_SYS_I2C_SPEED           100000
 #define CONFIG_SYS_I2C_SLAVE           1
index 1803b13..9c18842 100644 (file)
 #define CONFIG_BOOTP_HOSTNAME
 #define CONFIG_BOOTP_BOOTPATH
 
-
-/*
- *  Board NAND Info.
- */
-#define CONFIG_NAND_LEGACY
-#define CONFIG_SYS_NAND_ADDR 0x04000000  /* physical address to access nand at CS0*/
-
-#define CONFIG_SYS_MAX_NAND_DEVICE 1   /* Max number of NAND devices */
-#define SECTORSIZE          512
-
-#define ADDR_COLUMN         1
-#define ADDR_PAGE           2
-#define ADDR_COLUMN_PAGE    3
-
-#define NAND_ChipID_UNKNOWN 0x00
-#define NAND_MAX_FLOORS     1
-
-#define WRITE_NAND_COMMAND(d, adr) do {*(volatile u16 *)0x6800A07C = d;} while(0)
-#define WRITE_NAND_ADDRESS(d, adr) do {*(volatile u16 *)0x6800A080 = d;} while(0)
-#define WRITE_NAND(d, adr) do {*(volatile u16 *)0x6800A084 = d;} while(0)
-#define READ_NAND(adr) (*(volatile u16 *)0x6800A084)
-#define NAND_WAIT_READY(nand)  udelay(10)
-
-#define NAND_NO_RB          1
-
-#define CONFIG_SYS_NAND_WP
-#define NAND_WP_OFF()  do {*(volatile u32 *)(0x6800A050) |= 0x00000010;} while(0)
-#define NAND_WP_ON()  do {*(volatile u32 *)(0x6800A050) &= ~0x00000010;} while(0)
-
-#define NAND_CTL_CLRALE(nandptr)
-#define NAND_CTL_SETALE(nandptr)
-#define NAND_CTL_CLRCLE(nandptr)
-#define NAND_CTL_SETCLE(nandptr)
-#define NAND_DISABLE_CE(nand)
-#define NAND_ENABLE_CE(nand)
-
 #define CONFIG_BOOTDELAY         3
 
 #ifdef NFS_BOOT_DEFAULTS
index c2bd7e6..a1a849e 100644 (file)
 
 #define CONFIG_SYS_MAX_NAND_DEVICE     1               /* Max number of NAND */
                                                        /* devices */
+#define CONFIG_SYS_64BIT_VSPRINTF              /* needed for nand_util.c */
 
 #define CONFIG_JFFS2_NAND
 /* nand device jffs2 lives on */
index e205c01..198c3d1 100644 (file)
 
 #define CONFIG_SYS_MAX_NAND_DEVICE     1               /* Max number of */
                                                        /* NAND devices */
+#define CONFIG_SYS_64BIT_VSPRINTF              /* needed for nand_util.c */
 
 #define CONFIG_JFFS2_NAND
 /* nand device jffs2 lives on */
index 8902312..3bf798a 100644 (file)
 
 #define CONFIG_SYS_MAX_NAND_DEVICE     1       /* Max number of NAND */
                                                /* devices */
+#define CONFIG_SYS_64BIT_VSPRINTF              /* needed for nand_util.c */
+
 #define CONFIG_JFFS2_NAND
 /* nand device jffs2 lives on */
 #define CONFIG_JFFS2_DEV               "nand0"
index dbd4dcc..d7e0ea1 100644 (file)
 #define CONFIG_SYS_MAX_NAND_DEVICE     1       /* Max number of NAND */
                                                /* devices */
 
+#define CONFIG_SYS_64BIT_VSPRINTF              /* needed for nand_util.c */
+
 #define CONFIG_JFFS2_NAND
 /* nand device jffs2 lives on */
 #define CONFIG_JFFS2_DEV               "nand0"
index 9e000ed..4034ea4 100644 (file)
 
 #define CONFIG_SYS_MAX_NAND_DEVICE     1               /* Max number of NAND */
                                                        /* devices */
+
+#define CONFIG_SYS_64BIT_VSPRINTF              /* needed for nand_util.c */
+
 #define CONFIG_JFFS2_NAND
 /* nand device jffs2 lives on */
 #define CONFIG_JFFS2_DEV               "nand0"
index c2ad5bf..701a296 100644 (file)
 #define GPMC_NAND_ECC_LP_x16_LAYOUT    1
 #define CONFIG_SYS_MAX_NAND_DEVICE     1
 
+#define CONFIG_SYS_64BIT_VSPRINTF              /* needed for nand_util.c */
+
 /* Environment information */
 #define CONFIG_BOOTDELAY               10
 
index 1255f21..2612165 100644 (file)
  * NAND-FLASH stuff
  */
 #define CONFIG_SYS_MAX_NAND_DEVICE     1
-#define CONFIG_SYS_NAND_BASE           0x51000000      /* NAND FLASH Base Address      */
+#define CONFIG_SYS_NAND_BASE           0x51000000      /* NAND FLASH Base Address */
+#define CONFIG_SYS_64BIT_VSPRINTF                      /* needed for nand_util.c */
 #endif
 
 /*
index 4784c40..203a14c 100644 (file)
 #define CONFIG_SYS_NAND_ENABLE_PIN             AT91_PIN_PC14
 #define CONFIG_SYS_NAND_READY_PIN              AT91_PIN_PA16
 
+#define CONFIG_SYS_64BIT_VSPRINTF              /* needed for nand_util.c */
+
 
 /* NOR flash */
 #define CONFIG_SYS_FLASH_CFI                   1
 #define CONFIG_SYS_LONGHELP            1
 #define CONFIG_CMDLINE_EDITING 1
 
-#define ROUND(A, B)            (((A) + (B)) & ~((B) - 1))
 /*
  * Size of malloc() pool
  */
index 94e1eb9..a6ff28c 100644 (file)
 #define CONFIG_SYS_NAND_MASK_CLE       (1 << 22)
 #define CONFIG_SYS_NAND_ENABLE_PIN     AT91_PIN_PD15
 #define CONFIG_SYS_NAND_READY_PIN      AT91_PIN_PB30
+
+#define CONFIG_SYS_64BIT_VSPRINTF              /* needed for nand_util.c */
 #endif
 
 #define CONFIG_CMD_JFFS2               1
 #define CONFIG_SYS_LONGHELP            1
 #define CONFIG_CMDLINE_EDITING         1
 
-#define ROUND(A, B)                    (((A) + (B)) & ~((B) - 1))
 /*
  * Size of malloc() pool
  */
index 8444462..cbacdf9 100644 (file)
 
 #undef CONFIG_MEMSIZE_IN_BYTES
 
+#define CONFIG_LZMA
+
 /*-----------------------------------------------------------------------
  * Cache Configuration
  */
index 3ea854b..d63c43e 100644 (file)
 #define CONFIG_SYS_NAND_CLE    31   /* our CLE is GPIO31 */
 #define CONFIG_SYS_NAND_ALE    30   /* our ALE is GPIO30 */
 #define CONFIG_SYS_MAX_NAND_DEVICE     1
+
+#define CONFIG_SYS_64BIT_VSPRINTF      /* needed for nand_util.c */
 #endif
 
 /*-----------------------------------------------------------------------
index eab9629..f3dc7fe 100644 (file)
 #if defined(CONFIG_CMD_NAND)
 #define CONFIG_NAND_S3C2410
 #define CONFIG_SYS_MAX_NAND_DEVICE     1       /* Max number of NAND devices           */
-#define SECTORSIZE 512
-
-#define ADDR_COLUMN 1
-#define ADDR_PAGE 2
-#define ADDR_COLUMN_PAGE 3
-
-#define NAND_ChipID_UNKNOWN    0x00
-#define NAND_MAX_FLOORS 1
-
-#define NAND_WAIT_READY(nand)  NF_WaitRB()
-#define NAND_DISABLE_CE(nand)  NF_SetCE(NFCE_HIGH)
-#define NAND_ENABLE_CE(nand)   NF_SetCE(NFCE_LOW)
-#define WRITE_NAND_COMMAND(d, adr)     NF_Cmd(d)
-#define WRITE_NAND_COMMANDW(d, adr)    NF_CmdW(d)
-#define WRITE_NAND_ADDRESS(d, adr)     NF_Addr(d)
-#define WRITE_NAND(d, adr)             NF_Write(d)
-#define READ_NAND(adr)                 NF_Read()
-/* the following functions are NOP's because S3C24X0 handles this in hardware */
-#define NAND_CTL_CLRALE(nandptr)
-#define NAND_CTL_SETALE(nandptr)
-#define NAND_CTL_CLRCLE(nandptr)
-#define NAND_CTL_SETCLE(nandptr)
-/* #undef CONFIG_MTD_NAND_VERIFY_WRITE */
 #endif /* CONFIG_CMD_NAND */
 
 #define CONFIG_SETUP_MEMORY_TAGS
index 84a251a..20dcd1c 100644 (file)
 
 #define CONFIG_NET_MULTI
 #define CONFIG_PCI_PNP         /* do pci plug-and-play */
+#define CONFIG_83XX_GENERIC_PCI
 
 #undef CONFIG_EEPRO100
 #undef CONFIG_TULIP
index 97e1da2..7e00ab8 100644 (file)
@@ -426,6 +426,7 @@ extern unsigned long offsetOfEnvironment;
 #define CONFIG_SYS_MAX_NAND_DEVICE     1
 #define CONFIG_SYS_NAND_BASE           0x77D00000
 
+#define CONFIG_SYS_64BIT_VSPRINTF      /* needed for nand_util.c */
 
 #define CONFIG_JFFS2_NAND 1                    /* jffs2 on nand support */
 
index 018f576..ddc8e71 100644 (file)
                                 48, 49, 50, 51, 52, 53, 54, 55, \
                                 56, 57, 58, 59, 60, 61, 62, 63}
 
+#define CONFIG_SYS_64BIT_VSPRINTF              /* needed for nand_util.c */
+
 /* Boot configuration (define only one of next 3) */
 #define CONFIG_BOOT_NAND
 /* None of these are currently implemented. Left from the original Samsung
index 5b91b4d..35feed0 100644 (file)
 #define CONFIG_SYS_MAX_NAND_DEVICE     1
 #define CONFIG_CMD_NAND
 
+#define CONFIG_SYS_64BIT_VSPRINTF      /* needed for nand_util.c */
+
 /* LIME GDC */
 #define CONFIG_SYS_LIME_BASE           0xc8000000
 #define CONFIG_SYS_LIME_SIZE           0x04000000      /* 64 MB        */
index 147233d..d16262b 100644 (file)
 
 #define CONFIG_CMD_DHCP
 #define CONFIG_CMD_MII
-#define CONFIG_CMD_NAND
 #define CONFIG_CMD_NFS
 #define CONFIG_CMD_PING
 
 #define NAND_SIZE      0x00010000      /* 64K */
 #define NAND_BASE      0xF1000000
 
-/****************************************************************/
-
-/* NAND */
-#define CONFIG_NAND_LEGACY
-#define CONFIG_SYS_NAND_BASE           NAND_BASE
-#define CONFIG_MTD_NAND_ECC_JFFS2
-#define CONFIG_MTD_NAND_VERIFY_WRITE
-#define CONFIG_MTD_NAND_UNSAFE
-
-#define CONFIG_SYS_MAX_NAND_DEVICE     1
-#undef NAND_NO_RB
-
-#define SECTORSIZE             512
-#define ADDR_COLUMN            1
-#define ADDR_PAGE              2
-#define ADDR_COLUMN_PAGE       3
-#define NAND_ChipID_UNKNOWN    0x00
-#define NAND_MAX_FLOORS                1
-
-/* ALE = PC15, CLE = PB23, CE = PA7, F_RY_BY = PA6 */
-#define NAND_DISABLE_CE(nand) \
-       do { \
-               (((volatile immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_padat) |=  (1 << (15 - 7)); \
-       } while(0)
-
-#define NAND_ENABLE_CE(nand) \
-       do { \
-               (((volatile immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_padat) &= ~(1 << (15 - 7)); \
-       } while(0)
-
-#define NAND_CTL_CLRALE(nandptr) \
-       do { \
-               (((volatile immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pcdat) &= ~(1 << (15 - 15)); \
-       } while(0)
-
-#define NAND_CTL_SETALE(nandptr) \
-       do { \
-               (((volatile immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pcdat) |=  (1 << (15 - 15)); \
-       } while(0)
-
-#define NAND_CTL_CLRCLE(nandptr) \
-       do { \
-               (((volatile immap_t *)CONFIG_SYS_IMMR)->im_cpm.cp_pbdat) &= ~(1 << (31 - 23)); \
-       } while(0)
-
-#define NAND_CTL_SETCLE(nandptr) \
-       do { \
-               (((volatile immap_t *)CONFIG_SYS_IMMR)->im_cpm.cp_pbdat) |=  (1 << (31 - 23)); \
-       } while(0)
-
-#ifndef NAND_NO_RB
-#define NAND_WAIT_READY(nand) \
-       do { \
-               int _tries = 0; \
-               while ((((volatile immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_padat & (1 << (15 - 6))) == 0) \
-                       if (++_tries > 100000) \
-                               break; \
-       } while (0)
-#else
-#define NAND_WAIT_READY(nand) udelay(12)
-#endif
-
-#define WRITE_NAND_COMMAND(d, adr) \
-       do { \
-               *(volatile unsigned char *)((unsigned long)(adr)) = (unsigned char)(d); \
-       } while(0)
-
-#define WRITE_NAND_ADDRESS(d, adr) \
-       do { \
-               *(volatile unsigned char *)((unsigned long)(adr)) = (unsigned char)(d); \
-       } while(0)
-
-#define WRITE_NAND(d, adr) \
-       do { \
-               *(volatile unsigned char *)((unsigned long)(adr)) = (unsigned char)(d); \
-       } while(0)
-
-#define READ_NAND(adr) \
-       ((unsigned char)(*(volatile unsigned char *)(unsigned long)(adr)))
-
 /*****************************************************************************/
 
 #define CONFIG_SYS_DIRECT_FLASH_TFTP
-#define CONFIG_SYS_DIRECT_NAND_TFTP
 
 /*****************************************************************************/
 
index 3917a1b..425f472 100644 (file)
 
 #define CONFIG_CMD_ASKENV
 #define CONFIG_CMD_DHCP
-#define CONFIG_CMD_DOC
 #define CONFIG_CMD_DATE
 
-
-#define CONFIG_NAND_LEGACY
-
 /*
  * Miscellaneous configurable options
  */
index 15c3708..86b6ea1 100644 (file)
 /*
  * NAND Flash
  */
-#define CONFIG_NEW_NAND_CODE
 #define CONFIG_SYS_NAND0_BASE          0x0
 #undef CONFIG_SYS_NAND1_BASE
 
 #define CONFIG_SYS_NAND_SENDCMD_RETRY  3
 #undef NAND_ALLOW_ERASE_ALL    /* Allow erasing bad blocks - don't use */
 
+#define CONFIG_SYS_64BIT_VSPRINTF              /* needed for nand_util.c */
+
 /* NAND Timing Parameters (in ns) */
 #define NAND_TIMING_tCH                10
 #define NAND_TIMING_tCS                0
 #define CONFIG_MTD_DEBUG
 #define CONFIG_MTD_DEBUG_VERBOSE 1
 
-#define ADDR_COLUMN            1
-#define ADDR_PAGE              2
-#define ADDR_COLUMN_PAGE       3
-
-#define NAND_ChipID_UNKNOWN    0x00
-#define NAND_MAX_FLOORS                1
-
 #define CONFIG_SYS_NO_FLASH            1
 
 #define CONFIG_ENV_IS_IN_NAND  1
index f640388..29f276d 100644 (file)
 #ifndef _ELF_H
 #define _ELF_H
 
-#if defined(__BEOS__)   || \
-    defined(__NetBSD__)  || \
-    defined(__FreeBSD__) || \
-    defined(__sun__)    || \
-    defined(__APPLE__)
-#include <inttypes.h>
-#elif (defined(__linux__) && defined(USE_HOSTCC)) || defined(__WIN32__)
-#include <stdint.h>
-#endif
+#include "compiler.h"
 
 /*
  *  This version doesn't work for 64-bit ABIs - Erik.
index 507e832..5bed32f 100644 (file)
 # endif
 #endif /* CONFIG_ENV_IS_IN_MG_DISK */
 
-#ifdef USE_HOSTCC
-# include <stdint.h>
-#else
-# include <linux/types.h>
-#endif
+#include "compiler.h"
 
 #ifdef CONFIG_SYS_REDUNDAND_ENVIRONMENT
 # define ENV_HEADER_SIZE       (sizeof(uint32_t) + 1)
index 668e754..b754769 100644 (file)
@@ -47,7 +47,9 @@
 #define I2C_RXTX_LEN   128     /* maximum tx/rx buffer length */
 
 #if defined(CONFIG_I2C_MULTI_BUS)
+#if !defined(CONFIG_SYS_MAX_I2C_BUS)
 #define CONFIG_SYS_MAX_I2C_BUS         2
+#endif
 #define I2C_GET_BUS()          i2c_get_bus_num()
 #define I2C_SET_BUS(a)         i2c_set_bus_num(a)
 #else
index f183757..beb3a16 100644 (file)
 #ifndef __IMAGE_H__
 #define __IMAGE_H__
 
-#if USE_HOSTCC
-#ifndef __MINGW32__
-#include <endian.h>
-#endif
+#include "compiler.h"
+
+#ifdef USE_HOSTCC
 
 /* new uImage format support enabled on host */
 #define CONFIG_FIT             1
@@ -46,9 +45,7 @@
 #else
 
 #include <lmb.h>
-#include <linux/string.h>
 #include <asm/u-boot.h>
-#include <asm/byteorder.h>
 
 #endif /* USE_HOSTCC */
 
@@ -284,8 +281,8 @@ typedef struct bootm_headers {
 #define CHUNKSZ_SHA1 (64 * 1024)
 #endif
 
-#define uimage_to_cpu(x)               ntohl(x)
-#define cpu_to_uimage(x)               htonl(x)
+#define uimage_to_cpu(x)               be32_to_cpu(x)
+#define cpu_to_uimage(x)               cpu_to_be32(x)
 
 const char *genimg_get_os_name (uint8_t os);
 const char *genimg_get_arch_name (uint8_t arch);
index 1c67015..bf63583 100644 (file)
 #ifndef _LIBFDT_ENV_H
 #define _LIBFDT_ENV_H
 
-#ifdef USE_HOSTCC
-#include <stdint.h>
-#include <string.h>
-#ifdef __MINGW32__
-#include <linux/types.h>
-#include <linux/byteorder/swab.h>
-#else
-#include <endian.h>
-#include <byteswap.h>
-#endif /* __MINGW32__ */
-#else
-#include <linux/string.h>
-#include <linux/types.h>
-#include <asm/byteorder.h>
-#endif /* USE_HOSTCC */
+#include "compiler.h"
 
-#include <stddef.h>
 extern struct fdt_header *working_fdt;  /* Pointer to the working fdt */
 
-#if __BYTE_ORDER == __LITTLE_ENDIAN
-#ifdef __MINGW32__
-#define fdt32_to_cpu(x)                ___swab32(x)
-#define cpu_to_fdt32(x)                ___swab32(x)
-#define fdt64_to_cpu(x)                ___swab64(x)
-#define cpu_to_fdt64(x)                ___swab64(x)
-#else
-#define fdt32_to_cpu(x)                bswap_32(x)
-#define cpu_to_fdt32(x)                bswap_32(x)
-#define fdt64_to_cpu(x)                bswap_64(x)
-#define cpu_to_fdt64(x)                bswap_64(x)
-#endif
-#else
-#define fdt32_to_cpu(x)                (x)
-#define cpu_to_fdt32(x)                (x)
-#define fdt64_to_cpu(x)                (x)
-#define cpu_to_fdt64(x)                (x)
-#endif
-
-#ifndef USE_HOSTCC
-/*
- * Types for `void *' pointers.
- *
- * Note: libfdt uses this definition from /usr/include/stdint.h.
- * Define it here rather than pulling in all of stdint.h.
- */
-#if __WORDSIZE == 64
-typedef unsigned long int       uintptr_t;
-#else
-typedef unsigned int            uintptr_t;
-#endif
-#endif /* not USE_HOSTCC */
+#define fdt32_to_cpu(x)                be32_to_cpu(x)
+#define cpu_to_fdt32(x)                cpu_to_be32(x)
+#define fdt64_to_cpu(x)                be64_to_cpu(x)
+#define cpu_to_fdt64(x)                cpu_to_be64(x)
 
 #endif /* _LIBFDT_ENV_H */
index a4ad571..3e0044b 100644 (file)
@@ -50,7 +50,7 @@ extern void nand_wait_ready(struct mtd_info *mtd);
  * is supported now. If you add a chip with bigger oobsize/page
  * adjust this accordingly.
  */
-#define NAND_MAX_OOBSIZE       128
+#define NAND_MAX_OOBSIZE       218
 #define NAND_MAX_PAGESIZE      4096
 
 /*
diff --git a/include/linux/mtd/nand_ids.h b/include/linux/mtd/nand_ids.h
deleted file mode 100644 (file)
index e7aa26d..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- *  u-boot/include/linux/mtd/nand_ids.h
- *
- *  Copyright (c) 2000 David Woodhouse <dwmw2@mvhi.com>
- *                     Steven J. Hill <sjhill@cotw.com>
- *
- * $Id: nand_ids.h,v 1.1 2000/10/13 16:16:26 mdeans Exp $
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- *  Info:
- *   Contains standard defines and IDs for NAND flash devices
- *
- *  Changelog:
- *   01-31-2000 DMW     Created
- *   09-18-2000 SJH     Moved structure out of the Disk-On-Chip drivers
- *                     so it can be used by other NAND flash device
- *                     drivers. I also changed the copyright since none
- *                     of the original contents of this file are specific
- *                     to DoC devices. David can whack me with a baseball
- *                     bat later if I did something naughty.
- *   10-11-2000 SJH     Added private NAND flash structure for driver
- *   2000-10-13 BE      Moved out of 'nand.h' - avoids duplication.
- */
-
-#ifndef __LINUX_MTD_NAND_IDS_H
-#define __LINUX_MTD_NAND_IDS_H
-
-#ifndef CONFIG_NAND_LEGACY
-#error This module is for the legacy NAND support
-#endif
-
-static struct nand_flash_dev nand_flash_ids[] = {
-       {"Toshiba TC5816BDC",     NAND_MFR_TOSHIBA, 0x64, 21, 1, 2, 0x1000, 0},
-       {"Toshiba TC5832DC",      NAND_MFR_TOSHIBA, 0x6b, 22, 0, 2, 0x2000, 0},
-       {"Toshiba TH58V128DC",    NAND_MFR_TOSHIBA, 0x73, 24, 0, 2, 0x4000, 0},
-       {"Toshiba TC58256FT/DC",  NAND_MFR_TOSHIBA, 0x75, 25, 0, 2, 0x4000, 0},
-       {"Toshiba TH58512FT",     NAND_MFR_TOSHIBA, 0x76, 26, 0, 3, 0x4000, 0},
-       {"Toshiba TC58V32DC",     NAND_MFR_TOSHIBA, 0xe5, 22, 0, 2, 0x2000, 0},
-       {"Toshiba TC58V64AFT/DC", NAND_MFR_TOSHIBA, 0xe6, 23, 0, 2, 0x2000, 0},
-       {"Toshiba TC58V16BDC",    NAND_MFR_TOSHIBA, 0xea, 21, 1, 2, 0x1000, 0},
-       {"Toshiba TH58100FT",     NAND_MFR_TOSHIBA, 0x79, 27, 0, 3, 0x4000, 0},
-       {"Samsung KM29N16000",    NAND_MFR_SAMSUNG, 0x64, 21, 1, 2, 0x1000, 0},
-       {"Samsung unknown 4Mb",   NAND_MFR_SAMSUNG, 0x6b, 22, 0, 2, 0x2000, 0},
-       {"Samsung KM29U128T",     NAND_MFR_SAMSUNG, 0x73, 24, 0, 2, 0x4000, 0},
-       {"Samsung KM29U256T",     NAND_MFR_SAMSUNG, 0x75, 25, 0, 2, 0x4000, 0},
-       {"Samsung unknown 64Mb",  NAND_MFR_SAMSUNG, 0x76, 26, 0, 3, 0x4000, 0},
-       {"Samsung KM29W32000",    NAND_MFR_SAMSUNG, 0xe3, 22, 0, 2, 0x2000, 0},
-       {"Samsung unknown 4Mb",   NAND_MFR_SAMSUNG, 0xe5, 22, 0, 2, 0x2000, 0},
-       {"Samsung KM29U64000",    NAND_MFR_SAMSUNG, 0xe6, 23, 0, 2, 0x2000, 0},
-       {"Samsung KM29W16000",    NAND_MFR_SAMSUNG, 0xea, 21, 1, 2, 0x1000, 0},
-       {"Samsung K9F5616Q0C",    NAND_MFR_SAMSUNG, 0x45, 25, 0, 2, 0x4000, 1},
-       {"Samsung K9K1216Q0C",    NAND_MFR_SAMSUNG, 0x46, 26, 0, 3, 0x4000, 1},
-       {"Samsung K9F1G08U0M",    NAND_MFR_SAMSUNG, 0xf1, 27, 0, 2, 0, 0},
-       {NULL,}
-};
-
-#endif /* __LINUX_MTD_NAND_IDS_H */
diff --git a/include/linux/mtd/nand_legacy.h b/include/linux/mtd/nand_legacy.h
deleted file mode 100644 (file)
index 4334448..0000000
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
- *  linux/include/linux/mtd/nand.h
- *
- *  Copyright (c) 2000 David Woodhouse <dwmw2@mvhi.com>
- *                     Steven J. Hill <sjhill@cotw.com>
- *                    Thomas Gleixner <gleixner@autronix.de>
- *
- * $Id: nand.h,v 1.7 2003/07/24 23:30:46 a0384864 Exp $
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- *  Info:
- *   Contains standard defines and IDs for NAND flash devices
- *
- *  Changelog:
- *   01-31-2000 DMW     Created
- *   09-18-2000 SJH     Moved structure out of the Disk-On-Chip drivers
- *                     so it can be used by other NAND flash device
- *                     drivers. I also changed the copyright since none
- *                     of the original contents of this file are specific
- *                     to DoC devices. David can whack me with a baseball
- *                     bat later if I did something naughty.
- *   10-11-2000 SJH     Added private NAND flash structure for driver
- *   10-24-2000 SJH     Added prototype for 'nand_scan' function
- *   10-29-2001 TG     changed nand_chip structure to support
- *                     hardwarespecific function for accessing control lines
- *   02-21-2002 TG     added support for different read/write adress and
- *                     ready/busy line access function
- *   02-26-2002 TG     added chip_delay to nand_chip structure to optimize
- *                     command delay times for different chips
- *   04-28-2002 TG     OOB config defines moved from nand.c to avoid duplicate
- *                     defines in jffs2/wbuf.c
- */
-#ifndef __LINUX_MTD_NAND_LEGACY_H
-#define __LINUX_MTD_NAND_LEGACY_H
-
-#ifndef CONFIG_NAND_LEGACY
-#error This module is for the legacy NAND support
-#endif
-
-/* The maximum number of NAND chips in an array */
-#ifndef CONFIG_SYS_NAND_MAX_CHIPS
-#define CONFIG_SYS_NAND_MAX_CHIPS      1
-#endif
-
-/*
- * Standard NAND flash commands
- */
-#define NAND_CMD_READ0         0
-#define NAND_CMD_READ1         1
-#define NAND_CMD_PAGEPROG      0x10
-#define NAND_CMD_READOOB       0x50
-#define NAND_CMD_ERASE1                0x60
-#define NAND_CMD_STATUS                0x70
-#define NAND_CMD_SEQIN         0x80
-#define NAND_CMD_READID                0x90
-#define NAND_CMD_ERASE2                0xd0
-#define NAND_CMD_RESET         0xff
-
-/*
- * NAND Private Flash Chip Data
- *
- * Structure overview:
- *
- *  IO_ADDR - address to access the 8 I/O lines of the flash device
- *
- *  hwcontrol - hardwarespecific function for accesing control-lines
- *
- *  dev_ready - hardwarespecific function for accesing device ready/busy line
- *
- *  chip_lock - spinlock used to protect access to this structure
- *
- *  wq - wait queue to sleep on if a NAND operation is in progress
- *
- *  state - give the current state of the NAND device
- *
- *  page_shift - number of address bits in a page (column address bits)
- *
- *  data_buf - data buffer passed to/from MTD user modules
- *
- *  data_cache - data cache for redundant page access and shadow for
- *              ECC failure
- *
- *  ecc_code_buf - used only for holding calculated or read ECCs for
- *                 a page read or written when ECC is in use
- *
- *  reserved - padding to make structure fall on word boundary if
- *             when ECC is in use
- */
-struct Nand {
-       char floor, chip;
-       unsigned long curadr;
-       unsigned char curmode;
-       /* Also some erase/write/pipeline info when we get that far */
-};
-
-struct nand_chip {
-       int             page_shift;
-       u_char          *data_buf;
-       u_char          *data_cache;
-       int             cache_page;
-       u_char          ecc_code_buf[6];
-       u_char          reserved[2];
-       char ChipID; /* Type of DiskOnChip */
-       struct Nand *chips;
-       int chipshift;
-       char* chips_name;
-       unsigned long erasesize;
-       unsigned long mfr; /* Flash IDs - only one type of flash per device */
-       unsigned long id;
-       char* name;
-       int numchips;
-       char page256;
-       char pageadrlen;
-       unsigned long IO_ADDR;  /* address to access the 8 I/O lines to the flash device */
-       unsigned long totlen;
-       uint oobblock;  /* Size of OOB blocks (e.g. 512) */
-       uint oobsize;   /* Amount of OOB data per block (e.g. 16) */
-       uint eccsize;
-       int bus16;
-};
-
-/*
- * NAND Flash Manufacturer ID Codes
- */
-#define NAND_MFR_TOSHIBA       0x98
-#define NAND_MFR_SAMSUNG       0xec
-
-/*
- * NAND Flash Device ID Structure
- *
- * Structure overview:
- *
- *  name - Complete name of device
- *
- *  manufacture_id - manufacturer ID code of device.
- *
- *  model_id - model ID code of device.
- *
- *  chipshift - total number of address bits for the device which
- *              is used to calculate address offsets and the total
- *              number of bytes the device is capable of.
- *
- *  page256 - denotes if flash device has 256 byte pages or not.
- *
- *  pageadrlen - number of bytes minus one needed to hold the
- *               complete address into the flash array. Keep in
- *               mind that when a read or write is done to a
- *               specific address, the address is input serially
- *               8 bits at a time. This structure member is used
- *               by the read/write routines as a loop index for
- *               shifting the address out 8 bits at a time.
- *
- *  erasesize - size of an erase block in the flash device.
- */
-struct nand_flash_dev {
-       char * name;
-       int manufacture_id;
-       int model_id;
-       int chipshift;
-       char page256;
-       char pageadrlen;
-       unsigned long erasesize;
-       int bus16;
-};
-
-/*
-* Constants for oob configuration
-*/
-#define NAND_NOOB_ECCPOS0              0
-#define NAND_NOOB_ECCPOS1              1
-#define NAND_NOOB_ECCPOS2              2
-#define NAND_NOOB_ECCPOS3              3
-#define NAND_NOOB_ECCPOS4              6
-#define NAND_NOOB_ECCPOS5              7
-#define NAND_NOOB_BADBPOS              -1
-#define NAND_NOOB_ECCVPOS              -1
-
-#define NAND_JFFS2_OOB_ECCPOS0         0
-#define NAND_JFFS2_OOB_ECCPOS1         1
-#define NAND_JFFS2_OOB_ECCPOS2         2
-#define NAND_JFFS2_OOB_ECCPOS3         3
-#define NAND_JFFS2_OOB_ECCPOS4         6
-#define NAND_JFFS2_OOB_ECCPOS5         7
-#define NAND_JFFS2_OOB_BADBPOS         5
-#define NAND_JFFS2_OOB_ECCVPOS         4
-
-#define NAND_JFFS2_OOB8_FSDAPOS                6
-#define NAND_JFFS2_OOB16_FSDAPOS       8
-#define NAND_JFFS2_OOB8_FSDALEN                2
-#define NAND_JFFS2_OOB16_FSDALEN       8
-
-unsigned long nand_probe(unsigned long physadr);
-#endif /* __LINUX_MTD_NAND_LEGACY_H */
similarity index 81%
rename from include/lzma/LzmaDecode.h
rename to include/lzma/LzmaDec.h
index 8fdb2c0..967cdd1 100644 (file)
@@ -1,7 +1,7 @@
 /*
- * Fake include for LzmaDecode.h
+ * Fake include for LzmaDec.h
  *
- * Copyright (C) 2007-2008 Industrie Dial Face S.p.A.
+ * Copyright (C) 2007-2009 Industrie Dial Face S.p.A.
  * Luigi 'Comio' Mantellini (luigi.mantellini@idf-hit.com)
  *
  * See file CREDITS for list of people who contributed to this
@@ -23,9 +23,9 @@
  * MA 02111-1307 USA
  */
 
-#ifndef __LZMADECODE_H__FAKE__
-#define __LZMADECODE_H__FAKE__
+#ifndef __LZMADEC_H__FAKE__
+#define __LZMADEC_H__FAKE__
 
-#include "../../lib_generic/lzma/LzmaDecode.h"
+#include "../../lib_generic/lzma/LzmaDec.h"
 
 #endif
index 7c5eea1..87943c0 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Fake include for LzmaTools.h
  *
- * Copyright (C) 2007-2008 Industrie Dial Face S.p.A.
+ * Copyright (C) 2007-2009 Industrie Dial Face S.p.A.
  * Luigi 'Comio' Mantellini (luigi.mantellini@idf-hit.com)
  *
  * See file CREDITS for list of people who contributed to this
index 02daa59..86160a4 100644 (file)
@@ -1,7 +1,7 @@
 /*
- * Fake include for LzmaTypes.h
+ * Fake include for Types.h
  *
- * Copyright (C) 2007-2008 Industrie Dial Face S.p.A.
+ * Copyright (C) 2007-2009 Industrie Dial Face S.p.A.
  * Luigi 'Comio' Mantellini (luigi.mantellini@idf-hit.com)
  *
  * See file CREDITS for list of people who contributed to this
  * MA 02111-1307 USA
  */
 
-#ifndef __LZMATYPES_H__FAKE__
-#define __LZMATYPES_H__FAKE__
+#ifndef __TYPES_H__FAKE__
+#define __TYPES_H__FAKE__
 
-#include "../../lib_generic/lzma/LzmaTypes.h"
+/*
+ *This avoids the collition with zlib.h Byte definition
+ */
+#define Byte LZByte
+
+#include "../../lib_generic/lzma/Types.h"
 
 #endif
index 47154b0..a38464e 100644 (file)
 */
 
 \f
-
+#ifndef __MALLOC_H__
+#define __MALLOC_H__
 
 /* Preliminaries */
 
@@ -940,3 +941,5 @@ struct mallinfo mALLINFo();
 #ifdef __cplusplus
 };  /* end of extern "C" */
 #endif
+
+#endif /* __MALLOC_H__ */
index 23f3ca1..2a81597 100644 (file)
@@ -26,7 +26,6 @@
 
 extern void nand_init(void);
 
-#ifndef CONFIG_NAND_LEGACY
 #include <linux/mtd/compat.h>
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/nand.h>
@@ -130,5 +129,4 @@ void board_nand_select_device(struct nand_chip *nand, int chip);
 
 __attribute__((noreturn)) void nand_boot(void);
 
-#endif /* !CONFIG_NAND_LEGACY */
 #endif
index aed5c4c..17fdafb 100644 (file)
@@ -73,6 +73,7 @@ int scc_initialize(bd_t *bis);
 int skge_initialize(bd_t *bis);
 int tsi108_eth_initialize(bd_t *bis);
 int uec_initialize(int index);
+int uec_standard_init(bd_t *bis);
 int uli526x_initialize(bd_t *bis);
 int sh_eth_initialize(bd_t *bis);
 int dm9000_initialize(bd_t *bis);
index 8b06ccf..83da4cd 100644 (file)
@@ -91,6 +91,7 @@ extern char *stdio_names[MAX_FILES];
  */
 int    stdio_register (struct stdio_dev * dev);
 int    stdio_init (void);
+void   stdio_print_current_devices(void);
 #ifdef CONFIG_SYS_STDIO_DEREGISTER
 int    stdio_deregister(char *devname);
 #endif
diff --git a/include/tsi148.h b/include/tsi148.h
new file mode 100644 (file)
index 0000000..8e8e12b
--- /dev/null
@@ -0,0 +1,218 @@
+/*
+ * (C) Copyright 2009 Reinhard Arlt, reinhard.arlt@esd-electronics.com
+ *
+ * base on universe.h by
+ *
+ * (C) Copyright 2003 Stefan Roese, stefan.roese@esd-electronics.com
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.         See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef _tsi148_h
+#define _tsi148_h
+
+#ifndef PCI_DEVICE_ID_TUNDRA_TSI148
+#define PCI_DEVICE_ID_TUNDRA_TSI148 0x0148
+#endif
+
+typedef struct _TSI148 TSI148;
+typedef struct _OUTBOUND OUTBOUND;
+typedef struct _INBOUND  INBOUND;
+typedef struct _TDMA_CMD_PACKET TDMA_CMD_PACKET;
+
+struct _OUTBOUND {
+       unsigned int otsau;                   /* 0x000 Outbound start       upper */
+       unsigned int otsal;                   /* 0x004 Outbouud start       lower */
+       unsigned int oteau;                   /* 0x008 Outbound end         upper */
+       unsigned int oteal;                   /* 0x00c Outbound end         lower */
+       unsigned int otofu;                   /* 0x010 Outbound translation upper */
+       unsigned int otofl;                   /* 0x014 Outbound translation lower */
+       unsigned int otbs;                    /* 0x018 Outbound translation 2eSST */
+       unsigned int otat;                    /* 0x01c Outbound translation attr  */
+};
+
+struct _INBOUND {
+       unsigned int itsau;                   /* 0x000 inbound  start       upper */
+       unsigned int itsal;                   /* 0x004 inbouud  start       lower */
+       unsigned int iteau;                   /* 0x008 inbound  end         upper */
+       unsigned int iteal;                   /* 0x00c inbound  end         lower */
+       unsigned int itofu;                   /* 0x010 inbound  translation upper */
+       unsigned int itofl;                   /* 0x014 inbound  translation lower */
+       unsigned int itat;                    /* 0x018 inbound  translation attr  */
+       unsigned int spare;                   /* 0x01c not used                   */
+};
+
+struct _TSI148 {
+       unsigned int pci_id;                  /* 0x000         */
+       unsigned int pci_csr;                 /* 0x004         */
+       unsigned int pci_class;               /* 0x008         */
+       unsigned int pci_misc0;               /* 0x00c         */
+       unsigned int pci_mbarl;               /* 0x010         */
+       unsigned int pci_mbarh;               /* 0x014         */
+       unsigned int spare0[(0x03c-0x018)/4]; /* 0x018         */
+       unsigned int pci_misc1;               /* 0x03c         */
+       unsigned int pci_pcixcap;             /* 0x040         */
+       unsigned int pci_pcixstat;            /* 0x044         */
+       unsigned int spare1[(0x100-0x048)/4]; /* 0x048         */
+       OUTBOUND     outbound[8];             /* 0x100         */
+       unsigned int viack[8];                /* 0x204         */
+       unsigned int rmwau;                   /* 0x220         */
+       unsigned int rmwal;                   /* 0x224         */
+       unsigned int rmwen;                   /* 0x228         */
+       unsigned int rmwc;                    /* 0x22c         */
+       unsigned int rmws;                    /* 0x230         */
+       unsigned int vmctrl;                  /* 0x234         */
+       unsigned int vctrl;                   /* 0x238         */
+       unsigned int vstat;                   /* 0x23c         */
+       unsigned int pcsr;                    /* 0x240         */
+       unsigned int spare2[3];               /* 0x244 - 0x24c */
+       unsigned int vmefl;                   /* 0x250         */
+       unsigned int spare3[3];               /* 0x254 - 0x25c */
+       unsigned int veau;                    /* 0x260         */
+       unsigned int veal;                    /* 0x264         */
+       unsigned int veat;                    /* 0x268         */
+       unsigned int spare4[1];               /* 0x26c         */
+       unsigned int edpau;                   /* 0x270         */
+       unsigned int edpal;                   /* 0x274         */
+       unsigned int edpxa;                   /* 0x278         */
+       unsigned int edpxs;                   /* 0x27c         */
+       unsigned int edpat;                   /* 0x280         */
+       unsigned int spare5[31];              /* 0x284 - 0x2fc */
+       INBOUND      inbound[8];              /* 0x100         */
+       unsigned int gbau;                    /* 0x400         */
+       unsigned int gbal;                    /* 0x404         */
+       unsigned int gcsrat;                  /* 0x408         */
+       unsigned int cbau;                    /* 0x40c         */
+       unsigned int cbal;                    /* 0x410         */
+       unsigned int crgat;                   /* 0x414         */
+       unsigned int crou;                    /* 0x418         */
+       unsigned int crol;                    /* 0x41c         */
+       unsigned int crat;                    /* 0x420         */
+       unsigned int lmbau;                   /* 0x424         */
+       unsigned int lmbal;                   /* 0x428         */
+       unsigned int lmat;                    /* 0x42c         */
+       unsigned int r64bcu;                  /* 0x430         */
+       unsigned int r64bcl;                  /* 0x434         */
+       unsigned int bpgtr;                   /* 0x438         */
+       unsigned int bpctr;                   /* 0x43c         */
+       unsigned int vicr;                    /* 0x440         */
+       unsigned int spare6[1];               /* 0x444         */
+       unsigned int inten;                   /* 0x448         */
+       unsigned int inteo;                   /* 0x44c         */
+       unsigned int ints;                    /* 0x450         */
+       unsigned int intc;                    /* 0x454         */
+       unsigned int intm1;                   /* 0x458         */
+       unsigned int intm2;                   /* 0x45c         */
+       unsigned int spare7[40];              /* 0x460 - 0x4fc */
+       unsigned int dctl0;                   /* 0x500         */
+       unsigned int dsta0;                   /* 0x504         */
+       unsigned int dcsau0;                  /* 0x508         */
+       unsigned int dcsal0;                  /* 0x50c         */
+       unsigned int dcdau0;                  /* 0x510         */
+       unsigned int dcdal0;                  /* 0x514         */
+       unsigned int dclau0;                  /* 0x518         */
+       unsigned int dclal0;                  /* 0x51c         */
+       unsigned int dsau0;                   /* 0x520         */
+       unsigned int dsal0;                   /* 0x524         */
+       unsigned int ddau0;                   /* 0x528         */
+       unsigned int ddal0;                   /* 0x52c         */
+       unsigned int dsat0;                   /* 0x530         */
+       unsigned int ddat0;                   /* 0x534         */
+       unsigned int dnlau0;                  /* 0x538         */
+       unsigned int dnlal0;                  /* 0x53c         */
+       unsigned int dcnt0;                   /* 0x540         */
+       unsigned int ddbs0;                   /* 0x544         */
+       unsigned int r20[14];                 /* 0x548 - 0x57c */
+       unsigned int dctl1;                   /* 0x580         */
+       unsigned int dsta1;                   /* 0x584         */
+       unsigned int dcsau1;                  /* 0x588         */
+       unsigned int dcsal1;                  /* 0x58c         */
+       unsigned int dcdau1;                  /* 0x590         */
+       unsigned int dcdal1;                  /* 0x594         */
+       unsigned int dclau1;                  /* 0x598         */
+       unsigned int dclal1;                  /* 0x59c         */
+       unsigned int dsau1;                   /* 0x5a0         */
+       unsigned int dsal1;                   /* 0x5a4         */
+       unsigned int ddau1;                   /* 0x5a8         */
+       unsigned int ddal1;                   /* 0x5ac         */
+       unsigned int dsat1;                   /* 0x5b0         */
+       unsigned int ddat1;                   /* 0x5b4         */
+       unsigned int dnlau1;                  /* 0x5b8         */
+       unsigned int dnlal1;                  /* 0x5bc         */
+       unsigned int dcnt1;                   /* 0x5c0         */
+       unsigned int ddbs1;                   /* 0x5c4         */
+       unsigned int r21[14];                 /* 0x5c8 - 0x5fc */
+       unsigned int devi_veni_2;             /* 0x600         */
+       unsigned int gctrl_ga_revid;          /* 0x604         */
+       unsigned int semaphore0_1_2_3;        /* 0x608         */
+       unsigned int semaphore4_5_6_7;        /* 0x60c         */
+       unsigned int mbox0;                   /* 0x610         */
+       unsigned int mbox1;                   /* 0x614         */
+       unsigned int mbox2;                   /* 0x618         */
+       unsigned int mbox3;                   /* 0x61c         */
+       unsigned int r22[629];                /* 0x620 - 0xff0 */
+       unsigned int csrbcr;                  /* 0xff4         */
+       unsigned int csrbsr;                  /* 0xff8         */
+       unsigned int cbar;                    /* 0xffc         */
+};
+
+#define IRQ_VOWN       0x0001
+#define IRQ_VIRQ1      0x0002
+#define IRQ_VIRQ2      0x0004
+#define IRQ_VIRQ3      0x0008
+#define IRQ_VIRQ4      0x0010
+#define IRQ_VIRQ5      0x0020
+#define IRQ_VIRQ6      0x0040
+#define IRQ_VIRQ7      0x0080
+#define IRQ_DMA                0x0100
+#define IRQ_LERR       0x0200
+#define IRQ_VERR       0x0400
+#define IRQ_res                0x0800
+#define IRQ_IACK       0x1000
+#define IRQ_SWINT      0x2000
+#define IRQ_SYSFAIL    0x4000
+#define IRQ_ACFAIL     0x8000
+
+struct _TDMA_CMD_PACKET {
+       unsigned int dctl;   /* DMA Control         */
+       unsigned int dtbc;   /* Transfer Byte Count */
+       unsigned int dlv;    /* PCI Address         */
+       unsigned int res1;   /* Reserved            */
+       unsigned int dva;    /* Vme Address         */
+       unsigned int res2;   /* Reserved            */
+       unsigned int dcpp;   /* Pointer to Numed Cmd Packet with rPN */
+       unsigned int res3;   /* Reserved                             */
+};
+
+#define VME_AM_A16             0x01
+#define VME_AM_A24             0x02
+#define VME_AM_A32             0x03
+#define VME_AM_Axx             0x03
+#define VME_AM_USR             0x04
+#define VME_AM_SUP             0x08
+#define VME_AM_DATA            0x10
+#define VME_AM_PROG            0x20
+#define VME_AM_Mxx             (VME_AM_DATA | VME_AM_PROG)
+
+#define VME_FLAG_D8            0x01
+#define VME_FLAG_D16           0x02
+#define VME_FLAG_D32           0x03
+#define VME_FLAG_Dxx           0x03
+
+#endif
index 8b44a7f..08924cc 100644 (file)
@@ -6,7 +6,7 @@
 #ifndef _MD5_H
 #define _MD5_H
 
-#include <linux/types.h>
+#include "compiler.h"
 
 struct MD5Context {
        __u32 buf[4];
similarity index 97%
rename from arm_config.mk
rename to lib_arm/config.mk
index c4cf99d..a13603e 100644 (file)
@@ -21,6 +21,8 @@
 # MA 02111-1307 USA
 #
 
+CROSS_COMPILE ?= arm-linux-
+
 PLATFORM_CPPFLAGS += -DCONFIG_ARM -D__ARM__
 
 LDSCRIPT := $(SRCTREE)/cpu/$(CPU)/u-boot.lds
similarity index 96%
rename from avr32_config.mk
rename to lib_avr32/config.mk
index 441caa4..c258b4b 100644 (file)
@@ -21,5 +21,7 @@
 # MA 02111-1307 USA
 #
 
+CROSS_COMPILE ?= avr32-linux-
+
 PLATFORM_RELFLAGS      += -ffixed-r5 -fPIC -mno-init-got -mrelax
 PLATFORM_LDFLAGS       += --relax
index 28de372..b957a9d 100644 (file)
@@ -384,6 +384,12 @@ void board_init_r(gd_t * id, ulong dest_addr)
                post_run(NULL, POST_RAM | post_bootmode_get(0));
 #endif
 
+       if (bfin_os_log_check()) {
+               puts("\nLog buffer from operating system:\n");
+               bfin_os_log_dump();
+               puts("\n");
+       }
+
        /* main_loop() can return to retry autoboot, if so just run it again. */
        for (;;)
                main_loop();
similarity index 98%
rename from blackfin_config.mk
rename to lib_blackfin/config.mk
index 821f082..0dd2ac6 100644 (file)
@@ -21,6 +21,8 @@
 # MA 02111-1307 USA
 #
 
+CROSS_COMPILE ?= bfin-uclinux-
+
 CONFIG_BFIN_CPU := $(strip $(subst ",,$(CONFIG_BFIN_CPU)))
 CONFIG_BFIN_BOOT_MODE := $(strip $(subst ",,$(CONFIG_BFIN_BOOT_MODE)))
 CONFIG_ENV_OFFSET := $(strip $(subst ",,$(CONFIG_ENV_OFFSET)))
index 3927ce1..b27048c 100644 (file)
@@ -172,9 +172,7 @@ uint32_t ZEXPORT crc32 (uint32_t crc, const Bytef *buf, uInt len)
     return crc ^ 0xffffffffL;
 }
 
-#if defined(CONFIG_CMD_JFFS2) || \
-       (defined(CONFIG_CMD_NAND) \
-       && !defined(CONFIG_NAND_LEGACY))
+#if defined(CONFIG_CMD_JFFS2) || defined(CONFIG_CMD_NAND)
 
 /* No ones complement version. JFFS2 (and other things ?)
  * don't use ones compliment in their CRC calculations.
diff --git a/lib_generic/lzma/LGPL.txt b/lib_generic/lzma/LGPL.txt
deleted file mode 100644 (file)
index 9e76f5b..0000000
+++ /dev/null
@@ -1,502 +0,0 @@
-      GNU LESSER GENERAL PUBLIC LICENSE
-          Version 2.1, February 1999
-
- Copyright (C) 1991, 1999 Free Software Foundation, Inc.
-     59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-[This is the first released version of the Lesser GPL. It also counts
- as the successor of the GNU Library Public License, version 2, hence
- the version number 2.1.]
-
-         Preamble
-
-  The licenses for most software are designed to take away your
-freedom to share and change it.  By contrast, the GNU General Public
-Licenses are intended to guarantee your freedom to share and change
-free software--to make sure the software is free for all its users.
-
-  This license, the Lesser General Public License, applies to some
-specially designated software packages--typically libraries--of the
-Free Software Foundation and other authors who decide to use it.  You
-can use it too, but we suggest you first think carefully about whether
-this license or the ordinary General Public License is the better
-strategy to use in any particular case, based on the explanations below.
-
-  When we speak of free software, we are referring to freedom of use,
-not price.  Our General Public Licenses are designed to make sure that
-you have the freedom to distribute copies of free software (and charge
-for this service if you wish); that you receive source code or can get
-it if you want it; that you can change the software and use pieces of
-it in new free programs; and that you are informed that you can do
-these things.
-
-  To protect your rights, we need to make restrictions that forbid
-distributors to deny you these rights or to ask you to surrender these
-rights.  These restrictions translate to certain responsibilities for
-you if you distribute copies of the library or if you modify it.
-
-  For example, if you distribute copies of the library, whether gratis
-or for a fee, you must give the recipients all the rights that we gave
-you.  You must make sure that they, too, receive or can get the source
-code.  If you link other code with the library, you must provide
-complete object files to the recipients, so that they can relink them
-with the library after making changes to the library and recompiling
-it.  And you must show them these terms so they know their rights.
-
-  We protect your rights with a two-step method: (1) we copyright the
-library, and (2) we offer you this license, which gives you legal
-permission to copy, distribute and/or modify the library.
-
-  To protect each distributor, we want to make it very clear that
-there is no warranty for the free library.  Also, if the library is
-modified by someone else and passed on, the recipients should know
-that what they have is not the original version, so that the original
-author's reputation will not be affected by problems that might be
-introduced by others.
-\f
-  Finally, software patents pose a constant threat to the existence of
-any free program.  We wish to make sure that a company cannot
-effectively restrict the users of a free program by obtaining a
-restrictive license from a patent holder.  Therefore, we insist that
-any patent license obtained for a version of the library must be
-consistent with the full freedom of use specified in this license.
-
-  Most GNU software, including some libraries, is covered by the
-ordinary GNU General Public License.  This license, the GNU Lesser
-General Public License, applies to certain designated libraries, and
-is quite different from the ordinary General Public License.  We use
-this license for certain libraries in order to permit linking those
-libraries into non-free programs.
-
-  When a program is linked with a library, whether statically or using
-a shared library, the combination of the two is legally speaking a
-combined work, a derivative of the original library.  The ordinary
-General Public License therefore permits such linking only if the
-entire combination fits its criteria of freedom.  The Lesser General
-Public License permits more lax criteria for linking other code with
-the library.
-
-  We call this license the "Lesser" General Public License because it
-does Less to protect the user's freedom than the ordinary General
-Public License.  It also provides other free software developers Less
-of an advantage over competing non-free programs.  These disadvantages
-are the reason we use the ordinary General Public License for many
-libraries.  However, the Lesser license provides advantages in certain
-special circumstances.
-
-  For example, on rare occasions, there may be a special need to
-encourage the widest possible use of a certain library, so that it becomes
-a de-facto standard.  To achieve this, non-free programs must be
-allowed to use the library.  A more frequent case is that a free
-library does the same job as widely used non-free libraries.  In this
-case, there is little to gain by limiting the free library to free
-software only, so we use the Lesser General Public License.
-
-  In other cases, permission to use a particular library in non-free
-programs enables a greater number of people to use a large body of
-free software. For example, permission to use the GNU C Library in
-non-free programs enables many more people to use the whole GNU
-operating system, as well as its variant, the GNU/Linux operating
-system.
-
-  Although the Lesser General Public License is Less protective of the
-users' freedom, it does ensure that the user of a program that is
-linked with the Library has the freedom and the wherewithal to run
-that program using a modified version of the Library.
-
-  The precise terms and conditions for copying, distribution and
-modification follow.  Pay close attention to the difference between a
-"work based on the library" and a "work that uses the library".  The
-former contains code derived from the library, whereas the latter must
-be combined with the library in order to run.
-\f
-      GNU LESSER GENERAL PUBLIC LICENSE
-   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
-  0. This License Agreement applies to any software library or other
-program which contains a notice placed by the copyright holder or
-other authorized party saying it may be distributed under the terms of
-this Lesser General Public License (also called "this License").
-Each licensee is addressed as "you".
-
-  A "library" means a collection of software functions and/or data
-prepared so as to be conveniently linked with application programs
-(which use some of those functions and data) to form executables.
-
-  The "Library", below, refers to any such software library or work
-which has been distributed under these terms.  A "work based on the
-Library" means either the Library or any derivative work under
-copyright law: that is to say, a work containing the Library or a
-portion of it, either verbatim or with modifications and/or translated
-straightforwardly into another language.  (Hereinafter, translation is
-included without limitation in the term "modification".)
-
-  "Source code" for a work means the preferred form of the work for
-making modifications to it.  For a library, complete source code means
-all the source code for all modules it contains, plus any associated
-interface definition files, plus the scripts used to control compilation
-and installation of the library.
-
-  Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope.  The act of
-running a program using the Library is not restricted, and output from
-such a program is covered only if its contents constitute a work based
-on the Library (independent of the use of the Library in a tool for
-writing it).  Whether that is true depends on what the Library does
-and what the program that uses the Library does.
-
-  1. You may copy and distribute verbatim copies of the Library's
-complete source code as you receive it, in any medium, provided that
-you conspicuously and appropriately publish on each copy an
-appropriate copyright notice and disclaimer of warranty; keep intact
-all the notices that refer to this License and to the absence of any
-warranty; and distribute a copy of this License along with the
-Library.
-
-  You may charge a fee for the physical act of transferring a copy,
-and you may at your option offer warranty protection in exchange for a
-fee.
-\f
-  2. You may modify your copy or copies of the Library or any portion
-of it, thus forming a work based on the Library, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
-    a) The modified work must itself be a software library.
-
-    b) You must cause the files modified to carry prominent notices
-    stating that you changed the files and the date of any change.
-
-    c) You must cause the whole of the work to be licensed at no
-    charge to all third parties under the terms of this License.
-
-    d) If a facility in the modified Library refers to a function or a
-    table of data to be supplied by an application program that uses
-    the facility, other than as an argument passed when the facility
-    is invoked, then you must make a good faith effort to ensure that,
-    in the event an application does not supply such function or
-    table, the facility still operates, and performs whatever part of
-    its purpose remains meaningful.
-
-    (For example, a function in a library to compute square roots has
-    a purpose that is entirely well-defined independent of the
-    application.  Therefore, Subsection 2d requires that any
-    application-supplied function or table used by this function must
-    be optional: if the application does not supply it, the square
-    root function must still compute square roots.)
-
-These requirements apply to the modified work as a whole.  If
-identifiable sections of that work are not derived from the Library,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works.  But when you
-distribute the same sections as part of a whole which is a work based
-on the Library, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote
-it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Library.
-
-In addition, mere aggregation of another work not based on the Library
-with the Library (or with a work based on the Library) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
-  3. You may opt to apply the terms of the ordinary GNU General Public
-License instead of this License to a given copy of the Library.  To do
-this, you must alter all the notices that refer to this License, so
-that they refer to the ordinary GNU General Public License, version 2,
-instead of to this License.  (If a newer version than version 2 of the
-ordinary GNU General Public License has appeared, then you can specify
-that version instead if you wish.)  Do not make any other change in
-these notices.
-\f
-  Once this change is made in a given copy, it is irreversible for
-that copy, so the ordinary GNU General Public License applies to all
-subsequent copies and derivative works made from that copy.
-
-  This option is useful when you wish to copy part of the code of
-the Library into a program that is not a library.
-
-  4. You may copy and distribute the Library (or a portion or
-derivative of it, under Section 2) in object code or executable form
-under the terms of Sections 1 and 2 above provided that you accompany
-it with the complete corresponding machine-readable source code, which
-must be distributed under the terms of Sections 1 and 2 above on a
-medium customarily used for software interchange.
-
-  If distribution of object code is made by offering access to copy
-from a designated place, then offering equivalent access to copy the
-source code from the same place satisfies the requirement to
-distribute the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
-  5. A program that contains no derivative of any portion of the
-Library, but is designed to work with the Library by being compiled or
-linked with it, is called a "work that uses the Library".  Such a
-work, in isolation, is not a derivative work of the Library, and
-therefore falls outside the scope of this License.
-
-  However, linking a "work that uses the Library" with the Library
-creates an executable that is a derivative of the Library (because it
-contains portions of the Library), rather than a "work that uses the
-library".  The executable is therefore covered by this License.
-Section 6 states terms for distribution of such executables.
-
-  When a "work that uses the Library" uses material from a header file
-that is part of the Library, the object code for the work may be a
-derivative work of the Library even though the source code is not.
-Whether this is true is especially significant if the work can be
-linked without the Library, or if the work is itself a library.  The
-threshold for this to be true is not precisely defined by law.
-
-  If such an object file uses only numerical parameters, data
-structure layouts and accessors, and small macros and small inline
-functions (ten lines or less in length), then the use of the object
-file is unrestricted, regardless of whether it is legally a derivative
-work.  (Executables containing this object code plus portions of the
-Library will still fall under Section 6.)
-
-  Otherwise, if the work is a derivative of the Library, you may
-distribute the object code for the work under the terms of Section 6.
-Any executables containing that work also fall under Section 6,
-whether or not they are linked directly with the Library itself.
-\f
-  6. As an exception to the Sections above, you may also combine or
-link a "work that uses the Library" with the Library to produce a
-work containing portions of the Library, and distribute that work
-under terms of your choice, provided that the terms permit
-modification of the work for the customer's own use and reverse
-engineering for debugging such modifications.
-
-  You must give prominent notice with each copy of the work that the
-Library is used in it and that the Library and its use are covered by
-this License.  You must supply a copy of this License. If the work
-during execution displays copyright notices, you must include the
-copyright notice for the Library among them, as well as a reference
-directing the user to the copy of this License.  Also, you must do one
-of these things:
-
-    a) Accompany the work with the complete corresponding
-    machine-readable source code for the Library including whatever
-    changes were used in the work (which must be distributed under
-    Sections 1 and 2 above); and, if the work is an executable linked
-    with the Library, with the complete machine-readable "work that
-    uses the Library", as object code and/or source code, so that the
-    user can modify the Library and then relink to produce a modified
-    executable containing the modified Library.  (It is understood
-    that the user who changes the contents of definitions files in the
-    Library will not necessarily be able to recompile the application
-    to use the modified definitions.)
-
-    b) Use a suitable shared library mechanism for linking with the
-    Library.  A suitable mechanism is one that (1) uses at run time a
-    copy of the library already present on the user's computer system,
-    rather than copying library functions into the executable, and (2)
-    will operate properly with a modified version of the library, if
-    the user installs one, as long as the modified version is
-    interface-compatible with the version that the work was made with.
-
-    c) Accompany the work with a written offer, valid for at
-    least three years, to give the same user the materials
-    specified in Subsection 6a, above, for a charge no more
-    than the cost of performing this distribution.
-
-    d) If distribution of the work is made by offering access to copy
-    from a designated place, offer equivalent access to copy the above
-    specified materials from the same place.
-
-    e) Verify that the user has already received a copy of these
-    materials or that you have already sent this user a copy.
-
-  For an executable, the required form of the "work that uses the
-Library" must include any data and utility programs needed for
-reproducing the executable from it.  However, as a special exception,
-the materials to be distributed need not include anything that is
-normally distributed (in either source or binary form) with the major
-components (compiler, kernel, and so on) of the operating system on
-which the executable runs, unless that component itself accompanies
-the executable.
-
-  It may happen that this requirement contradicts the license
-restrictions of other proprietary libraries that do not normally
-accompany the operating system.  Such a contradiction means you cannot
-use both them and the Library together in an executable that you
-distribute.
-\f
-  7. You may place library facilities that are a work based on the
-Library side-by-side in a single library together with other library
-facilities not covered by this License, and distribute such a combined
-library, provided that the separate distribution of the work based on
-the Library and of the other library facilities is otherwise
-permitted, and provided that you do these two things:
-
-    a) Accompany the combined library with a copy of the same work
-    based on the Library, uncombined with any other library
-    facilities.  This must be distributed under the terms of the
-    Sections above.
-
-    b) Give prominent notice with the combined library of the fact
-    that part of it is a work based on the Library, and explaining
-    where to find the accompanying uncombined form of the same work.
-
-  8. You may not copy, modify, sublicense, link with, or distribute
-the Library except as expressly provided under this License.  Any
-attempt otherwise to copy, modify, sublicense, link with, or
-distribute the Library is void, and will automatically terminate your
-rights under this License.  However, parties who have received copies,
-or rights, from you under this License will not have their licenses
-terminated so long as such parties remain in full compliance.
-
-  9. You are not required to accept this License, since you have not
-signed it.  However, nothing else grants you permission to modify or
-distribute the Library or its derivative works.  These actions are
-prohibited by law if you do not accept this License.  Therefore, by
-modifying or distributing the Library (or any work based on the
-Library), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Library or works based on it.
-
-  10. Each time you redistribute the Library (or any work based on the
-Library), the recipient automatically receives a license from the
-original licensor to copy, distribute, link with or modify the Library
-subject to these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties with
-this License.
-\f
-  11. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License.  If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Library at all. For example, if a patent
-license would not permit royalty-free redistribution of the Library by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Library.
-
-If any portion of this section is held invalid or unenforceable under any
-particular circumstance, the balance of the section is intended to apply,
-and the section as a whole is intended to apply in other circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system which is
-implemented by public license practices.  Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
-  12. If the distribution and/or use of the Library is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Library under this License may add
-an explicit geographical distribution limitation excluding those countries,
-so that distribution is permitted only in or among countries not thus
-excluded.  In such case, this License incorporates the limitation as if
-written in the body of this License.
-
-  13. The Free Software Foundation may publish revised and/or new
-versions of the Lesser General Public License from time to time.
-Such new versions will be similar in spirit to the present version,
-but may differ in detail to address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Library
-specifies a version number of this License which applies to it and
-"any later version", you have the option of following the terms and
-conditions either of that version or of any later version published by
-the Free Software Foundation.  If the Library does not specify a
-license version number, you may choose any version ever published by
-the Free Software Foundation.
-\f
-  14. If you wish to incorporate parts of the Library into other free
-programs whose distribution conditions are incompatible with these,
-write to the author to ask for permission.  For software which is
-copyrighted by the Free Software Foundation, write to the Free
-Software Foundation; we sometimes make exceptions for this.  Our
-decision will be guided by the two goals of preserving the free status
-of all derivatives of our free software and of promoting the sharing
-and reuse of software generally.
-
-         NO WARRANTY
-
-  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
-WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
-EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
-OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
-KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
-LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
-THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
-  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
-WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
-AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
-FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
-CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
-LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
-RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
-FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
-SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGES.
-
-        END OF TERMS AND CONDITIONS
-\f
-          How to Apply These Terms to Your New Libraries
-
-  If you develop a new library, and you want it to be of the greatest
-possible use to the public, we recommend making it free software that
-everyone can redistribute and change.  You can do so by permitting
-redistribution under these terms (or, alternatively, under the terms of the
-ordinary General Public License).
-
-  To apply these terms, attach the following notices to the library.  It is
-safest to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least the
-"copyright" line and a pointer to where the full notice is found.
-
-    <one line to give the library's name and a brief idea of what it does.>
-    Copyright (C) <year>  <name of author>
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-Also add information on how to contact you by electronic and paper mail.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the library, if
-necessary.  Here is a sample; alter the names:
-
-  Yoyodyne, Inc., hereby disclaims all copyright interest in the
-  library `Frob' (a library for tweaking knobs) written by James Random Hacker.
-
-  <signature of Ty Coon>, 1 April 1990
-  Ty Coon, President of Vice
-
-That's all there is to it!
diff --git a/lib_generic/lzma/LzmaDec.c b/lib_generic/lzma/LzmaDec.c
new file mode 100644 (file)
index 0000000..89d934a
--- /dev/null
@@ -0,0 +1,1007 @@
+/* LzmaDec.c -- LZMA Decoder
+2008-11-06 : Igor Pavlov : Public domain */
+
+#include "LzmaDec.h"
+
+#include <string.h>
+
+#define kNumTopBits 24
+#define kTopValue ((UInt32)1 << kNumTopBits)
+
+#define kNumBitModelTotalBits 11
+#define kBitModelTotal (1 << kNumBitModelTotalBits)
+#define kNumMoveBits 5
+
+#define RC_INIT_SIZE 5
+
+#define NORMALIZE if (range < kTopValue) { range <<= 8; code = (code << 8) | (*buf++); }
+
+#define IF_BIT_0(p) ttt = *(p); NORMALIZE; bound = (range >> kNumBitModelTotalBits) * ttt; if (code < bound)
+#define UPDATE_0(p) range = bound; *(p) = (CLzmaProb)(ttt + ((kBitModelTotal - ttt) >> kNumMoveBits));
+#define UPDATE_1(p) range -= bound; code -= bound; *(p) = (CLzmaProb)(ttt - (ttt >> kNumMoveBits));
+#define GET_BIT2(p, i, A0, A1) IF_BIT_0(p) \
+  { UPDATE_0(p); i = (i + i); A0; } else \
+  { UPDATE_1(p); i = (i + i) + 1; A1; }
+#define GET_BIT(p, i) GET_BIT2(p, i, ; , ;)
+
+#define TREE_GET_BIT(probs, i) { GET_BIT((probs + i), i); }
+#define TREE_DECODE(probs, limit, i) \
+  { i = 1; do { TREE_GET_BIT(probs, i); } while (i < limit); i -= limit; }
+
+/* #define _LZMA_SIZE_OPT */
+
+#ifdef _LZMA_SIZE_OPT
+#define TREE_6_DECODE(probs, i) TREE_DECODE(probs, (1 << 6), i)
+#else
+#define TREE_6_DECODE(probs, i) \
+  { i = 1; \
+  TREE_GET_BIT(probs, i); \
+  TREE_GET_BIT(probs, i); \
+  TREE_GET_BIT(probs, i); \
+  TREE_GET_BIT(probs, i); \
+  TREE_GET_BIT(probs, i); \
+  TREE_GET_BIT(probs, i); \
+  i -= 0x40; }
+#endif
+
+#define NORMALIZE_CHECK if (range < kTopValue) { if (buf >= bufLimit) return DUMMY_ERROR; range <<= 8; code = (code << 8) | (*buf++); }
+
+#define IF_BIT_0_CHECK(p) ttt = *(p); NORMALIZE_CHECK; bound = (range >> kNumBitModelTotalBits) * ttt; if (code < bound)
+#define UPDATE_0_CHECK range = bound;
+#define UPDATE_1_CHECK range -= bound; code -= bound;
+#define GET_BIT2_CHECK(p, i, A0, A1) IF_BIT_0_CHECK(p) \
+  { UPDATE_0_CHECK; i = (i + i); A0; } else \
+  { UPDATE_1_CHECK; i = (i + i) + 1; A1; }
+#define GET_BIT_CHECK(p, i) GET_BIT2_CHECK(p, i, ; , ;)
+#define TREE_DECODE_CHECK(probs, limit, i) \
+  { i = 1; do { GET_BIT_CHECK(probs + i, i) } while (i < limit); i -= limit; }
+
+
+#define kNumPosBitsMax 4
+#define kNumPosStatesMax (1 << kNumPosBitsMax)
+
+#define kLenNumLowBits 3
+#define kLenNumLowSymbols (1 << kLenNumLowBits)
+#define kLenNumMidBits 3
+#define kLenNumMidSymbols (1 << kLenNumMidBits)
+#define kLenNumHighBits 8
+#define kLenNumHighSymbols (1 << kLenNumHighBits)
+
+#define LenChoice 0
+#define LenChoice2 (LenChoice + 1)
+#define LenLow (LenChoice2 + 1)
+#define LenMid (LenLow + (kNumPosStatesMax << kLenNumLowBits))
+#define LenHigh (LenMid + (kNumPosStatesMax << kLenNumMidBits))
+#define kNumLenProbs (LenHigh + kLenNumHighSymbols)
+
+
+#define kNumStates 12
+#define kNumLitStates 7
+
+#define kStartPosModelIndex 4
+#define kEndPosModelIndex 14
+#define kNumFullDistances (1 << (kEndPosModelIndex >> 1))
+
+#define kNumPosSlotBits 6
+#define kNumLenToPosStates 4
+
+#define kNumAlignBits 4
+#define kAlignTableSize (1 << kNumAlignBits)
+
+#define kMatchMinLen 2
+#define kMatchSpecLenStart (kMatchMinLen + kLenNumLowSymbols + kLenNumMidSymbols + kLenNumHighSymbols)
+
+#define IsMatch 0
+#define IsRep (IsMatch + (kNumStates << kNumPosBitsMax))
+#define IsRepG0 (IsRep + kNumStates)
+#define IsRepG1 (IsRepG0 + kNumStates)
+#define IsRepG2 (IsRepG1 + kNumStates)
+#define IsRep0Long (IsRepG2 + kNumStates)
+#define PosSlot (IsRep0Long + (kNumStates << kNumPosBitsMax))
+#define SpecPos (PosSlot + (kNumLenToPosStates << kNumPosSlotBits))
+#define Align (SpecPos + kNumFullDistances - kEndPosModelIndex)
+#define LenCoder (Align + kAlignTableSize)
+#define RepLenCoder (LenCoder + kNumLenProbs)
+#define Literal (RepLenCoder + kNumLenProbs)
+
+#define LZMA_BASE_SIZE 1846
+#define LZMA_LIT_SIZE 768
+
+#define LzmaProps_GetNumProbs(p) ((UInt32)LZMA_BASE_SIZE + (LZMA_LIT_SIZE << ((p)->lc + (p)->lp)))
+
+#if Literal != LZMA_BASE_SIZE
+StopCompilingDueBUG
+#endif
+
+static const Byte kLiteralNextStates[kNumStates * 2] =
+{
+  0, 0, 0, 0, 1, 2, 3,  4,  5,  6,  4,  5,
+  7, 7, 7, 7, 7, 7, 7, 10, 10, 10, 10, 10
+};
+
+#define LZMA_DIC_MIN (1 << 12)
+
+/* First LZMA-symbol is always decoded.
+And it decodes new LZMA-symbols while (buf < bufLimit), but "buf" is without last normalization
+Out:
+  Result:
+    SZ_OK - OK
+    SZ_ERROR_DATA - Error
+  p->remainLen:
+    < kMatchSpecLenStart : normal remain
+    = kMatchSpecLenStart : finished
+    = kMatchSpecLenStart + 1 : Flush marker
+    = kMatchSpecLenStart + 2 : State Init Marker
+*/
+
+static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte *bufLimit)
+{
+  CLzmaProb *probs = p->probs;
+
+  unsigned state = p->state;
+  UInt32 rep0 = p->reps[0], rep1 = p->reps[1], rep2 = p->reps[2], rep3 = p->reps[3];
+  unsigned pbMask = ((unsigned)1 << (p->prop.pb)) - 1;
+  unsigned lpMask = ((unsigned)1 << (p->prop.lp)) - 1;
+  unsigned lc = p->prop.lc;
+
+  Byte *dic = p->dic;
+  SizeT dicBufSize = p->dicBufSize;
+  SizeT dicPos = p->dicPos;
+
+  UInt32 processedPos = p->processedPos;
+  UInt32 checkDicSize = p->checkDicSize;
+  unsigned len = 0;
+
+  const Byte *buf = p->buf;
+  UInt32 range = p->range;
+  UInt32 code = p->code;
+
+  do
+  {
+    CLzmaProb *prob;
+    UInt32 bound;
+    unsigned ttt;
+    unsigned posState = processedPos & pbMask;
+
+    prob = probs + IsMatch + (state << kNumPosBitsMax) + posState;
+    IF_BIT_0(prob)
+    {
+      unsigned symbol;
+      UPDATE_0(prob);
+      prob = probs + Literal;
+      if (checkDicSize != 0 || processedPos != 0)
+        prob += (LZMA_LIT_SIZE * (((processedPos & lpMask) << lc) +
+        (dic[(dicPos == 0 ? dicBufSize : dicPos) - 1] >> (8 - lc))));
+
+      if (state < kNumLitStates)
+      {
+        symbol = 1;
+        do { GET_BIT(prob + symbol, symbol) } while (symbol < 0x100);
+      }
+      else
+      {
+        unsigned matchByte = p->dic[(dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0)];
+        unsigned offs = 0x100;
+        symbol = 1;
+        do
+        {
+          unsigned bit;
+          CLzmaProb *probLit;
+          matchByte <<= 1;
+          bit = (matchByte & offs);
+          probLit = prob + offs + bit + symbol;
+          GET_BIT2(probLit, symbol, offs &= ~bit, offs &= bit)
+        }
+        while (symbol < 0x100);
+      }
+      dic[dicPos++] = (Byte)symbol;
+      processedPos++;
+
+      state = kLiteralNextStates[state];
+      /* if (state < 4) state = 0; else if (state < 10) state -= 3; else state -= 6; */
+      continue;
+    }
+    else
+    {
+      UPDATE_1(prob);
+      prob = probs + IsRep + state;
+      IF_BIT_0(prob)
+      {
+        UPDATE_0(prob);
+        state += kNumStates;
+        prob = probs + LenCoder;
+      }
+      else
+      {
+        UPDATE_1(prob);
+        if (checkDicSize == 0 && processedPos == 0)
+          return SZ_ERROR_DATA;
+        prob = probs + IsRepG0 + state;
+        IF_BIT_0(prob)
+        {
+          UPDATE_0(prob);
+          prob = probs + IsRep0Long + (state << kNumPosBitsMax) + posState;
+          IF_BIT_0(prob)
+          {
+            UPDATE_0(prob);
+            dic[dicPos] = dic[(dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0)];
+            dicPos++;
+            processedPos++;
+            state = state < kNumLitStates ? 9 : 11;
+            continue;
+          }
+          UPDATE_1(prob);
+        }
+        else
+        {
+          UInt32 distance;
+          UPDATE_1(prob);
+          prob = probs + IsRepG1 + state;
+          IF_BIT_0(prob)
+          {
+            UPDATE_0(prob);
+            distance = rep1;
+          }
+          else
+          {
+            UPDATE_1(prob);
+            prob = probs + IsRepG2 + state;
+            IF_BIT_0(prob)
+            {
+              UPDATE_0(prob);
+              distance = rep2;
+            }
+            else
+            {
+              UPDATE_1(prob);
+              distance = rep3;
+              rep3 = rep2;
+            }
+            rep2 = rep1;
+          }
+          rep1 = rep0;
+          rep0 = distance;
+        }
+        state = state < kNumLitStates ? 8 : 11;
+        prob = probs + RepLenCoder;
+      }
+      {
+        unsigned limit, offset;
+        CLzmaProb *probLen = prob + LenChoice;
+        IF_BIT_0(probLen)
+        {
+          UPDATE_0(probLen);
+          probLen = prob + LenLow + (posState << kLenNumLowBits);
+          offset = 0;
+          limit = (1 << kLenNumLowBits);
+        }
+        else
+        {
+          UPDATE_1(probLen);
+          probLen = prob + LenChoice2;
+          IF_BIT_0(probLen)
+          {
+            UPDATE_0(probLen);
+            probLen = prob + LenMid + (posState << kLenNumMidBits);
+            offset = kLenNumLowSymbols;
+            limit = (1 << kLenNumMidBits);
+          }
+          else
+          {
+            UPDATE_1(probLen);
+            probLen = prob + LenHigh;
+            offset = kLenNumLowSymbols + kLenNumMidSymbols;
+            limit = (1 << kLenNumHighBits);
+          }
+        }
+        TREE_DECODE(probLen, limit, len);
+        len += offset;
+      }
+
+      if (state >= kNumStates)
+      {
+        UInt32 distance;
+        prob = probs + PosSlot +
+            ((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) << kNumPosSlotBits);
+        TREE_6_DECODE(prob, distance);
+        if (distance >= kStartPosModelIndex)
+        {
+          unsigned posSlot = (unsigned)distance;
+          int numDirectBits = (int)(((distance >> 1) - 1));
+          distance = (2 | (distance & 1));
+          if (posSlot < kEndPosModelIndex)
+          {
+            distance <<= numDirectBits;
+            prob = probs + SpecPos + distance - posSlot - 1;
+            {
+              UInt32 mask = 1;
+              unsigned i = 1;
+              do
+              {
+                GET_BIT2(prob + i, i, ; , distance |= mask);
+                mask <<= 1;
+              }
+              while (--numDirectBits != 0);
+            }
+          }
+          else
+          {
+            numDirectBits -= kNumAlignBits;
+            do
+            {
+              NORMALIZE
+              range >>= 1;
+
+              {
+                UInt32 t;
+                code -= range;
+                t = (0 - ((UInt32)code >> 31)); /* (UInt32)((Int32)code >> 31) */
+                distance = (distance << 1) + (t + 1);
+                code += range & t;
+              }
+              /*
+              distance <<= 1;
+              if (code >= range)
+              {
+                code -= range;
+                distance |= 1;
+              }
+              */
+            }
+            while (--numDirectBits != 0);
+            prob = probs + Align;
+            distance <<= kNumAlignBits;
+            {
+              unsigned i = 1;
+              GET_BIT2(prob + i, i, ; , distance |= 1);
+              GET_BIT2(prob + i, i, ; , distance |= 2);
+              GET_BIT2(prob + i, i, ; , distance |= 4);
+              GET_BIT2(prob + i, i, ; , distance |= 8);
+            }
+            if (distance == (UInt32)0xFFFFFFFF)
+            {
+              len += kMatchSpecLenStart;
+              state -= kNumStates;
+              break;
+            }
+          }
+        }
+        rep3 = rep2;
+        rep2 = rep1;
+        rep1 = rep0;
+        rep0 = distance + 1;
+        if (checkDicSize == 0)
+        {
+          if (distance >= processedPos)
+            return SZ_ERROR_DATA;
+        }
+        else if (distance >= checkDicSize)
+          return SZ_ERROR_DATA;
+        state = (state < kNumStates + kNumLitStates) ? kNumLitStates : kNumLitStates + 3;
+        /* state = kLiteralNextStates[state]; */
+      }
+
+      len += kMatchMinLen;
+
+      if (limit == dicPos)
+        return SZ_ERROR_DATA;
+      {
+        SizeT rem = limit - dicPos;
+        unsigned curLen = ((rem < len) ? (unsigned)rem : len);
+        SizeT pos = (dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0);
+
+        processedPos += curLen;
+
+        len -= curLen;
+        if (pos + curLen <= dicBufSize)
+        {
+          Byte *dest = dic + dicPos;
+          ptrdiff_t src = (ptrdiff_t)pos - (ptrdiff_t)dicPos;
+          const Byte *lim = dest + curLen;
+          dicPos += curLen;
+          do
+            *(dest) = (Byte)*(dest + src);
+          while (++dest != lim);
+        }
+        else
+        {
+          do
+          {
+            dic[dicPos++] = dic[pos];
+            if (++pos == dicBufSize)
+              pos = 0;
+          }
+          while (--curLen != 0);
+        }
+      }
+    }
+  }
+  while (dicPos < limit && buf < bufLimit);
+  NORMALIZE;
+  p->buf = buf;
+  p->range = range;
+  p->code = code;
+  p->remainLen = len;
+  p->dicPos = dicPos;
+  p->processedPos = processedPos;
+  p->reps[0] = rep0;
+  p->reps[1] = rep1;
+  p->reps[2] = rep2;
+  p->reps[3] = rep3;
+  p->state = state;
+
+  return SZ_OK;
+}
+
+static void MY_FAST_CALL LzmaDec_WriteRem(CLzmaDec *p, SizeT limit)
+{
+  if (p->remainLen != 0 && p->remainLen < kMatchSpecLenStart)
+  {
+    Byte *dic = p->dic;
+    SizeT dicPos = p->dicPos;
+    SizeT dicBufSize = p->dicBufSize;
+    unsigned len = p->remainLen;
+    UInt32 rep0 = p->reps[0];
+    if (limit - dicPos < len)
+      len = (unsigned)(limit - dicPos);
+
+    if (p->checkDicSize == 0 && p->prop.dicSize - p->processedPos <= len)
+      p->checkDicSize = p->prop.dicSize;
+
+    p->processedPos += len;
+    p->remainLen -= len;
+    while (len-- != 0)
+    {
+      dic[dicPos] = dic[(dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0)];
+      dicPos++;
+    }
+    p->dicPos = dicPos;
+  }
+}
+
+static int MY_FAST_CALL LzmaDec_DecodeReal2(CLzmaDec *p, SizeT limit, const Byte *bufLimit)
+{
+  do
+  {
+    SizeT limit2 = limit;
+    if (p->checkDicSize == 0)
+    {
+      UInt32 rem = p->prop.dicSize - p->processedPos;
+      if (limit - p->dicPos > rem)
+        limit2 = p->dicPos + rem;
+    }
+    RINOK(LzmaDec_DecodeReal(p, limit2, bufLimit));
+    if (p->processedPos >= p->prop.dicSize)
+      p->checkDicSize = p->prop.dicSize;
+    LzmaDec_WriteRem(p, limit);
+  }
+  while (p->dicPos < limit && p->buf < bufLimit && p->remainLen < kMatchSpecLenStart);
+
+  if (p->remainLen > kMatchSpecLenStart)
+  {
+    p->remainLen = kMatchSpecLenStart;
+  }
+  return 0;
+}
+
+typedef enum
+{
+  DUMMY_ERROR, /* unexpected end of input stream */
+  DUMMY_LIT,
+  DUMMY_MATCH,
+  DUMMY_REP
+} ELzmaDummy;
+
+static ELzmaDummy LzmaDec_TryDummy(const CLzmaDec *p, const Byte *buf, SizeT inSize)
+{
+  UInt32 range = p->range;
+  UInt32 code = p->code;
+  const Byte *bufLimit = buf + inSize;
+  CLzmaProb *probs = p->probs;
+  unsigned state = p->state;
+  ELzmaDummy res;
+
+  {
+    CLzmaProb *prob;
+    UInt32 bound;
+    unsigned ttt;
+    unsigned posState = (p->processedPos) & ((1 << p->prop.pb) - 1);
+
+    prob = probs + IsMatch + (state << kNumPosBitsMax) + posState;
+    IF_BIT_0_CHECK(prob)
+    {
+      UPDATE_0_CHECK
+
+      /* if (bufLimit - buf >= 7) return DUMMY_LIT; */
+
+      prob = probs + Literal;
+      if (p->checkDicSize != 0 || p->processedPos != 0)
+        prob += (LZMA_LIT_SIZE *
+          ((((p->processedPos) & ((1 << (p->prop.lp)) - 1)) << p->prop.lc) +
+          (p->dic[(p->dicPos == 0 ? p->dicBufSize : p->dicPos) - 1] >> (8 - p->prop.lc))));
+
+      if (state < kNumLitStates)
+      {
+        unsigned symbol = 1;
+        do { GET_BIT_CHECK(prob + symbol, symbol) } while (symbol < 0x100);
+      }
+      else
+      {
+        unsigned matchByte = p->dic[p->dicPos - p->reps[0] +
+            ((p->dicPos < p->reps[0]) ? p->dicBufSize : 0)];
+        unsigned offs = 0x100;
+        unsigned symbol = 1;
+        do
+        {
+          unsigned bit;
+          CLzmaProb *probLit;
+          matchByte <<= 1;
+          bit = (matchByte & offs);
+          probLit = prob + offs + bit + symbol;
+          GET_BIT2_CHECK(probLit, symbol, offs &= ~bit, offs &= bit)
+        }
+        while (symbol < 0x100);
+      }
+      res = DUMMY_LIT;
+    }
+    else
+    {
+      unsigned len;
+      UPDATE_1_CHECK;
+
+      prob = probs + IsRep + state;
+      IF_BIT_0_CHECK(prob)
+      {
+        UPDATE_0_CHECK;
+        state = 0;
+        prob = probs + LenCoder;
+        res = DUMMY_MATCH;
+      }
+      else
+      {
+        UPDATE_1_CHECK;
+        res = DUMMY_REP;
+        prob = probs + IsRepG0 + state;
+        IF_BIT_0_CHECK(prob)
+        {
+          UPDATE_0_CHECK;
+          prob = probs + IsRep0Long + (state << kNumPosBitsMax) + posState;
+          IF_BIT_0_CHECK(prob)
+          {
+            UPDATE_0_CHECK;
+            NORMALIZE_CHECK;
+            return DUMMY_REP;
+          }
+          else
+          {
+            UPDATE_1_CHECK;
+          }
+        }
+        else
+        {
+          UPDATE_1_CHECK;
+          prob = probs + IsRepG1 + state;
+          IF_BIT_0_CHECK(prob)
+          {
+            UPDATE_0_CHECK;
+          }
+          else
+          {
+            UPDATE_1_CHECK;
+            prob = probs + IsRepG2 + state;
+            IF_BIT_0_CHECK(prob)
+            {
+              UPDATE_0_CHECK;
+            }
+            else
+            {
+              UPDATE_1_CHECK;
+            }
+          }
+        }
+        state = kNumStates;
+        prob = probs + RepLenCoder;
+      }
+      {
+        unsigned limit, offset;
+        CLzmaProb *probLen = prob + LenChoice;
+        IF_BIT_0_CHECK(probLen)
+        {
+          UPDATE_0_CHECK;
+          probLen = prob + LenLow + (posState << kLenNumLowBits);
+          offset = 0;
+          limit = 1 << kLenNumLowBits;
+        }
+        else
+        {
+          UPDATE_1_CHECK;
+          probLen = prob + LenChoice2;
+          IF_BIT_0_CHECK(probLen)
+          {
+            UPDATE_0_CHECK;
+            probLen = prob + LenMid + (posState << kLenNumMidBits);
+            offset = kLenNumLowSymbols;
+            limit = 1 << kLenNumMidBits;
+          }
+          else
+          {
+            UPDATE_1_CHECK;
+            probLen = prob + LenHigh;
+            offset = kLenNumLowSymbols + kLenNumMidSymbols;
+            limit = 1 << kLenNumHighBits;
+          }
+        }
+        TREE_DECODE_CHECK(probLen, limit, len);
+        len += offset;
+      }
+
+      if (state < 4)
+      {
+        unsigned posSlot;
+        prob = probs + PosSlot +
+            ((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) <<
+            kNumPosSlotBits);
+        TREE_DECODE_CHECK(prob, 1 << kNumPosSlotBits, posSlot);
+        if (posSlot >= kStartPosModelIndex)
+        {
+          int numDirectBits = ((posSlot >> 1) - 1);
+
+          /* if (bufLimit - buf >= 8) return DUMMY_MATCH; */
+
+          if (posSlot < kEndPosModelIndex)
+          {
+            prob = probs + SpecPos + ((2 | (posSlot & 1)) << numDirectBits) - posSlot - 1;
+          }
+          else
+          {
+            numDirectBits -= kNumAlignBits;
+            do
+            {
+              NORMALIZE_CHECK
+              range >>= 1;
+              code -= range & (((code - range) >> 31) - 1);
+              /* if (code >= range) code -= range; */
+            }
+            while (--numDirectBits != 0);
+            prob = probs + Align;
+            numDirectBits = kNumAlignBits;
+          }
+          {
+            unsigned i = 1;
+            do
+            {
+              GET_BIT_CHECK(prob + i, i);
+            }
+            while (--numDirectBits != 0);
+          }
+        }
+      }
+    }
+  }
+  NORMALIZE_CHECK;
+  return res;
+}
+
+
+static void LzmaDec_InitRc(CLzmaDec *p, const Byte *data)
+{
+  p->code = ((UInt32)data[1] << 24) | ((UInt32)data[2] << 16) | ((UInt32)data[3] << 8) | ((UInt32)data[4]);
+  p->range = 0xFFFFFFFF;
+  p->needFlush = 0;
+}
+
+void LzmaDec_InitDicAndState(CLzmaDec *p, Bool initDic, Bool initState)
+{
+  p->needFlush = 1;
+  p->remainLen = 0;
+  p->tempBufSize = 0;
+
+  if (initDic)
+  {
+    p->processedPos = 0;
+    p->checkDicSize = 0;
+    p->needInitState = 1;
+  }
+  if (initState)
+    p->needInitState = 1;
+}
+
+void LzmaDec_Init(CLzmaDec *p)
+{
+  p->dicPos = 0;
+  LzmaDec_InitDicAndState(p, True, True);
+}
+
+static void LzmaDec_InitStateReal(CLzmaDec *p)
+{
+  UInt32 numProbs = Literal + ((UInt32)LZMA_LIT_SIZE << (p->prop.lc + p->prop.lp));
+  UInt32 i;
+  CLzmaProb *probs = p->probs;
+  for (i = 0; i < numProbs; i++)
+    probs[i] = kBitModelTotal >> 1;
+  p->reps[0] = p->reps[1] = p->reps[2] = p->reps[3] = 1;
+  p->state = 0;
+  p->needInitState = 0;
+}
+
+SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit, const Byte *src, SizeT *srcLen,
+    ELzmaFinishMode finishMode, ELzmaStatus *status)
+{
+  SizeT inSize = *srcLen;
+  (*srcLen) = 0;
+  LzmaDec_WriteRem(p, dicLimit);
+
+  *status = LZMA_STATUS_NOT_SPECIFIED;
+
+  while (p->remainLen != kMatchSpecLenStart)
+  {
+      int checkEndMarkNow;
+
+      if (p->needFlush != 0)
+      {
+        for (; inSize > 0 && p->tempBufSize < RC_INIT_SIZE; (*srcLen)++, inSize--)
+          p->tempBuf[p->tempBufSize++] = *src++;
+        if (p->tempBufSize < RC_INIT_SIZE)
+        {
+          *status = LZMA_STATUS_NEEDS_MORE_INPUT;
+          return SZ_OK;
+        }
+        if (p->tempBuf[0] != 0)
+          return SZ_ERROR_DATA;
+
+        LzmaDec_InitRc(p, p->tempBuf);
+        p->tempBufSize = 0;
+      }
+
+      checkEndMarkNow = 0;
+      if (p->dicPos >= dicLimit)
+      {
+        if (p->remainLen == 0 && p->code == 0)
+        {
+          *status = LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK;
+          return SZ_OK;
+        }
+        if (finishMode == LZMA_FINISH_ANY)
+        {
+          *status = LZMA_STATUS_NOT_FINISHED;
+          return SZ_OK;
+        }
+        if (p->remainLen != 0)
+        {
+          *status = LZMA_STATUS_NOT_FINISHED;
+          return SZ_ERROR_DATA;
+        }
+        checkEndMarkNow = 1;
+      }
+
+      if (p->needInitState)
+        LzmaDec_InitStateReal(p);
+
+      if (p->tempBufSize == 0)
+      {
+        SizeT processed;
+        const Byte *bufLimit;
+        if (inSize < LZMA_REQUIRED_INPUT_MAX || checkEndMarkNow)
+        {
+          int dummyRes = LzmaDec_TryDummy(p, src, inSize);
+          if (dummyRes == DUMMY_ERROR)
+          {
+            memcpy(p->tempBuf, src, inSize);
+            p->tempBufSize = (unsigned)inSize;
+            (*srcLen) += inSize;
+            *status = LZMA_STATUS_NEEDS_MORE_INPUT;
+            return SZ_OK;
+          }
+          if (checkEndMarkNow && dummyRes != DUMMY_MATCH)
+          {
+            *status = LZMA_STATUS_NOT_FINISHED;
+            return SZ_ERROR_DATA;
+          }
+          bufLimit = src;
+        }
+        else
+          bufLimit = src + inSize - LZMA_REQUIRED_INPUT_MAX;
+        p->buf = src;
+        if (LzmaDec_DecodeReal2(p, dicLimit, bufLimit) != 0)
+          return SZ_ERROR_DATA;
+        processed = (SizeT)(p->buf - src);
+        (*srcLen) += processed;
+        src += processed;
+        inSize -= processed;
+      }
+      else
+      {
+        unsigned rem = p->tempBufSize, lookAhead = 0;
+        while (rem < LZMA_REQUIRED_INPUT_MAX && lookAhead < inSize)
+          p->tempBuf[rem++] = src[lookAhead++];
+        p->tempBufSize = rem;
+        if (rem < LZMA_REQUIRED_INPUT_MAX || checkEndMarkNow)
+        {
+          int dummyRes = LzmaDec_TryDummy(p, p->tempBuf, rem);
+          if (dummyRes == DUMMY_ERROR)
+          {
+            (*srcLen) += lookAhead;
+            *status = LZMA_STATUS_NEEDS_MORE_INPUT;
+            return SZ_OK;
+          }
+          if (checkEndMarkNow && dummyRes != DUMMY_MATCH)
+          {
+            *status = LZMA_STATUS_NOT_FINISHED;
+            return SZ_ERROR_DATA;
+          }
+        }
+        p->buf = p->tempBuf;
+        if (LzmaDec_DecodeReal2(p, dicLimit, p->buf) != 0)
+          return SZ_ERROR_DATA;
+        lookAhead -= (rem - (unsigned)(p->buf - p->tempBuf));
+        (*srcLen) += lookAhead;
+        src += lookAhead;
+        inSize -= lookAhead;
+        p->tempBufSize = 0;
+      }
+  }
+  if (p->code == 0)
+    *status = LZMA_STATUS_FINISHED_WITH_MARK;
+  return (p->code == 0) ? SZ_OK : SZ_ERROR_DATA;
+}
+
+SRes LzmaDec_DecodeToBuf(CLzmaDec *p, Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status)
+{
+  SizeT outSize = *destLen;
+  SizeT inSize = *srcLen;
+  *srcLen = *destLen = 0;
+  for (;;)
+  {
+    SizeT inSizeCur = inSize, outSizeCur, dicPos;
+    ELzmaFinishMode curFinishMode;
+    SRes res;
+    if (p->dicPos == p->dicBufSize)
+      p->dicPos = 0;
+    dicPos = p->dicPos;
+    if (outSize > p->dicBufSize - dicPos)
+    {
+      outSizeCur = p->dicBufSize;
+      curFinishMode = LZMA_FINISH_ANY;
+    }
+    else
+    {
+      outSizeCur = dicPos + outSize;
+      curFinishMode = finishMode;
+    }
+
+    res = LzmaDec_DecodeToDic(p, outSizeCur, src, &inSizeCur, curFinishMode, status);
+    src += inSizeCur;
+    inSize -= inSizeCur;
+    *srcLen += inSizeCur;
+    outSizeCur = p->dicPos - dicPos;
+    memcpy(dest, p->dic + dicPos, outSizeCur);
+    dest += outSizeCur;
+    outSize -= outSizeCur;
+    *destLen += outSizeCur;
+    if (res != 0)
+      return res;
+    if (outSizeCur == 0 || outSize == 0)
+      return SZ_OK;
+  }
+}
+
+void LzmaDec_FreeProbs(CLzmaDec *p, ISzAlloc *alloc)
+{
+  alloc->Free(alloc, p->probs);
+  p->probs = 0;
+}
+
+static void LzmaDec_FreeDict(CLzmaDec *p, ISzAlloc *alloc)
+{
+  alloc->Free(alloc, p->dic);
+  p->dic = 0;
+}
+
+void LzmaDec_Free(CLzmaDec *p, ISzAlloc *alloc)
+{
+  LzmaDec_FreeProbs(p, alloc);
+  LzmaDec_FreeDict(p, alloc);
+}
+
+SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size)
+{
+  UInt32 dicSize;
+  Byte d;
+
+  if (size < LZMA_PROPS_SIZE)
+    return SZ_ERROR_UNSUPPORTED;
+  else
+    dicSize = data[1] | ((UInt32)data[2] << 8) | ((UInt32)data[3] << 16) | ((UInt32)data[4] << 24);
+
+  if (dicSize < LZMA_DIC_MIN)
+    dicSize = LZMA_DIC_MIN;
+  p->dicSize = dicSize;
+
+  d = data[0];
+  if (d >= (9 * 5 * 5))
+    return SZ_ERROR_UNSUPPORTED;
+
+  p->lc = d % 9;
+  d /= 9;
+  p->pb = d / 5;
+  p->lp = d % 5;
+
+  return SZ_OK;
+}
+
+static SRes LzmaDec_AllocateProbs2(CLzmaDec *p, const CLzmaProps *propNew, ISzAlloc *alloc)
+{
+  UInt32 numProbs = LzmaProps_GetNumProbs(propNew);
+  if (p->probs == 0 || numProbs != p->numProbs)
+  {
+    LzmaDec_FreeProbs(p, alloc);
+    p->probs = (CLzmaProb *)alloc->Alloc(alloc, numProbs * sizeof(CLzmaProb));
+    p->numProbs = numProbs;
+    if (p->probs == 0)
+      return SZ_ERROR_MEM;
+  }
+  return SZ_OK;
+}
+
+SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc)
+{
+  CLzmaProps propNew;
+  RINOK(LzmaProps_Decode(&propNew, props, propsSize));
+  RINOK(LzmaDec_AllocateProbs2(p, &propNew, alloc));
+  p->prop = propNew;
+  return SZ_OK;
+}
+
+SRes LzmaDec_Allocate(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc)
+{
+  CLzmaProps propNew;
+  SizeT dicBufSize;
+  RINOK(LzmaProps_Decode(&propNew, props, propsSize));
+  RINOK(LzmaDec_AllocateProbs2(p, &propNew, alloc));
+  dicBufSize = propNew.dicSize;
+  if (p->dic == 0 || dicBufSize != p->dicBufSize)
+  {
+    LzmaDec_FreeDict(p, alloc);
+    p->dic = (Byte *)alloc->Alloc(alloc, dicBufSize);
+    if (p->dic == 0)
+    {
+      LzmaDec_FreeProbs(p, alloc);
+      return SZ_ERROR_MEM;
+    }
+  }
+  p->dicBufSize = dicBufSize;
+  p->prop = propNew;
+  return SZ_OK;
+}
+
+SRes LzmaDecode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen,
+    const Byte *propData, unsigned propSize, ELzmaFinishMode finishMode,
+    ELzmaStatus *status, ISzAlloc *alloc)
+{
+  CLzmaDec p;
+  SRes res;
+  SizeT inSize = *srcLen;
+  SizeT outSize = *destLen;
+  *srcLen = *destLen = 0;
+  if (inSize < RC_INIT_SIZE)
+    return SZ_ERROR_INPUT_EOF;
+
+  LzmaDec_Construct(&p);
+  res = LzmaDec_AllocateProbs(&p, propData, propSize, alloc);
+  if (res != 0)
+    return res;
+  p.dic = dest;
+  p.dicBufSize = outSize;
+
+  LzmaDec_Init(&p);
+
+  *srcLen = inSize;
+  res = LzmaDec_DecodeToDic(&p, outSize, src, srcLen, finishMode, status);
+
+  if (res == SZ_OK && *status == LZMA_STATUS_NEEDS_MORE_INPUT)
+    res = SZ_ERROR_INPUT_EOF;
+
+  (*destLen) = p.dicPos;
+  LzmaDec_FreeProbs(&p, alloc);
+  return res;
+}
diff --git a/lib_generic/lzma/LzmaDec.h b/lib_generic/lzma/LzmaDec.h
new file mode 100644 (file)
index 0000000..7fba87f
--- /dev/null
@@ -0,0 +1,223 @@
+/* LzmaDec.h -- LZMA Decoder
+2008-10-04 : Igor Pavlov : Public domain */
+
+#ifndef __LZMADEC_H
+#define __LZMADEC_H
+
+#include "Types.h"
+
+/* #define _LZMA_PROB32 */
+/* _LZMA_PROB32 can increase the speed on some CPUs,
+   but memory usage for CLzmaDec::probs will be doubled in that case */
+
+#ifdef _LZMA_PROB32
+#define CLzmaProb UInt32
+#else
+#define CLzmaProb UInt16
+#endif
+
+
+/* ---------- LZMA Properties ---------- */
+
+#define LZMA_PROPS_SIZE 5
+
+typedef struct _CLzmaProps
+{
+  unsigned lc, lp, pb;
+  UInt32 dicSize;
+} CLzmaProps;
+
+/* LzmaProps_Decode - decodes properties
+Returns:
+  SZ_OK
+  SZ_ERROR_UNSUPPORTED - Unsupported properties
+*/
+
+SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size);
+
+
+/* ---------- LZMA Decoder state ---------- */
+
+/* LZMA_REQUIRED_INPUT_MAX = number of required input bytes for worst case.
+   Num bits = log2((2^11 / 31) ^ 22) + 26 < 134 + 26 = 160; */
+
+#define LZMA_REQUIRED_INPUT_MAX 20
+
+typedef struct
+{
+  CLzmaProps prop;
+  CLzmaProb *probs;
+  Byte *dic;
+  const Byte *buf;
+  UInt32 range, code;
+  SizeT dicPos;
+  SizeT dicBufSize;
+  UInt32 processedPos;
+  UInt32 checkDicSize;
+  unsigned state;
+  UInt32 reps[4];
+  unsigned remainLen;
+  int needFlush;
+  int needInitState;
+  UInt32 numProbs;
+  unsigned tempBufSize;
+  Byte tempBuf[LZMA_REQUIRED_INPUT_MAX];
+} CLzmaDec;
+
+#define LzmaDec_Construct(p) { (p)->dic = 0; (p)->probs = 0; }
+
+void LzmaDec_Init(CLzmaDec *p);
+
+/* There are two types of LZMA streams:
+     0) Stream with end mark. That end mark adds about 6 bytes to compressed size.
+     1) Stream without end mark. You must know exact uncompressed size to decompress such stream. */
+
+typedef enum
+{
+  LZMA_FINISH_ANY,   /* finish at any point */
+  LZMA_FINISH_END    /* block must be finished at the end */
+} ELzmaFinishMode;
+
+/* ELzmaFinishMode has meaning only if the decoding reaches output limit !!!
+
+   You must use LZMA_FINISH_END, when you know that current output buffer
+   covers last bytes of block. In other cases you must use LZMA_FINISH_ANY.
+
+   If LZMA decoder sees end marker before reaching output limit, it returns SZ_OK,
+   and output value of destLen will be less than output buffer size limit.
+   You can check status result also.
+
+   You can use multiple checks to test data integrity after full decompression:
+     1) Check Result and "status" variable.
+     2) Check that output(destLen) = uncompressedSize, if you know real uncompressedSize.
+     3) Check that output(srcLen) = compressedSize, if you know real compressedSize.
+        You must use correct finish mode in that case. */
+
+typedef enum
+{
+  LZMA_STATUS_NOT_SPECIFIED,               /* use main error code instead */
+  LZMA_STATUS_FINISHED_WITH_MARK,          /* stream was finished with end mark. */
+  LZMA_STATUS_NOT_FINISHED,                /* stream was not finished */
+  LZMA_STATUS_NEEDS_MORE_INPUT,            /* you must provide more input bytes */
+  LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK  /* there is probability that stream was finished without end mark */
+} ELzmaStatus;
+
+/* ELzmaStatus is used only as output value for function call */
+
+
+/* ---------- Interfaces ---------- */
+
+/* There are 3 levels of interfaces:
+     1) Dictionary Interface
+     2) Buffer Interface
+     3) One Call Interface
+   You can select any of these interfaces, but don't mix functions from different
+   groups for same object. */
+
+
+/* There are two variants to allocate state for Dictionary Interface:
+     1) LzmaDec_Allocate / LzmaDec_Free
+     2) LzmaDec_AllocateProbs / LzmaDec_FreeProbs
+   You can use variant 2, if you set dictionary buffer manually.
+   For Buffer Interface you must always use variant 1.
+
+LzmaDec_Allocate* can return:
+  SZ_OK
+  SZ_ERROR_MEM         - Memory allocation error
+  SZ_ERROR_UNSUPPORTED - Unsupported properties
+*/
+
+SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc);
+void LzmaDec_FreeProbs(CLzmaDec *p, ISzAlloc *alloc);
+
+SRes LzmaDec_Allocate(CLzmaDec *state, const Byte *prop, unsigned propsSize, ISzAlloc *alloc);
+void LzmaDec_Free(CLzmaDec *state, ISzAlloc *alloc);
+
+/* ---------- Dictionary Interface ---------- */
+
+/* You can use it, if you want to eliminate the overhead for data copying from
+   dictionary to some other external buffer.
+   You must work with CLzmaDec variables directly in this interface.
+
+   STEPS:
+     LzmaDec_Constr()
+     LzmaDec_Allocate()
+     for (each new stream)
+     {
+       LzmaDec_Init()
+       while (it needs more decompression)
+       {
+         LzmaDec_DecodeToDic()
+         use data from CLzmaDec::dic and update CLzmaDec::dicPos
+       }
+     }
+     LzmaDec_Free()
+*/
+
+/* LzmaDec_DecodeToDic
+
+   The decoding to internal dictionary buffer (CLzmaDec::dic).
+   You must manually update CLzmaDec::dicPos, if it reaches CLzmaDec::dicBufSize !!!
+
+finishMode:
+  It has meaning only if the decoding reaches output limit (dicLimit).
+  LZMA_FINISH_ANY - Decode just dicLimit bytes.
+  LZMA_FINISH_END - Stream must be finished after dicLimit.
+
+Returns:
+  SZ_OK
+    status:
+      LZMA_STATUS_FINISHED_WITH_MARK
+      LZMA_STATUS_NOT_FINISHED
+      LZMA_STATUS_NEEDS_MORE_INPUT
+      LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK
+  SZ_ERROR_DATA - Data error
+*/
+
+SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit,
+    const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status);
+
+
+/* ---------- Buffer Interface ---------- */
+
+/* It's zlib-like interface.
+   See LzmaDec_DecodeToDic description for information about STEPS and return results,
+   but you must use LzmaDec_DecodeToBuf instead of LzmaDec_DecodeToDic and you don't need
+   to work with CLzmaDec variables manually.
+
+finishMode:
+  It has meaning only if the decoding reaches output limit (*destLen).
+  LZMA_FINISH_ANY - Decode just destLen bytes.
+  LZMA_FINISH_END - Stream must be finished after (*destLen).
+*/
+
+SRes LzmaDec_DecodeToBuf(CLzmaDec *p, Byte *dest, SizeT *destLen,
+    const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status);
+
+
+/* ---------- One Call Interface ---------- */
+
+/* LzmaDecode
+
+finishMode:
+  It has meaning only if the decoding reaches output limit (*destLen).
+  LZMA_FINISH_ANY - Decode just destLen bytes.
+  LZMA_FINISH_END - Stream must be finished after (*destLen).
+
+Returns:
+  SZ_OK
+    status:
+      LZMA_STATUS_FINISHED_WITH_MARK
+      LZMA_STATUS_NOT_FINISHED
+      LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK
+  SZ_ERROR_DATA - Data error
+  SZ_ERROR_MEM  - Memory allocation error
+  SZ_ERROR_UNSUPPORTED - Unsupported properties
+  SZ_ERROR_INPUT_EOF - It needs more bytes in input buffer (src).
+*/
+
+SRes LzmaDecode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen,
+    const Byte *propData, unsigned propSize, ELzmaFinishMode finishMode,
+    ELzmaStatus *status, ISzAlloc *alloc);
+
+#endif
diff --git a/lib_generic/lzma/LzmaDecode.c b/lib_generic/lzma/LzmaDecode.c
deleted file mode 100644 (file)
index 3470e55..0000000
+++ /dev/null
@@ -1,584 +0,0 @@
-/*
-  LzmaDecode.c
-  LZMA Decoder (optimized for Speed version)
-
-  LZMA SDK 4.40 Copyright (c) 1999-2006 Igor Pavlov (2006-05-01)
-  http://www.7-zip.org/
-
-  LZMA SDK is licensed under two licenses:
-  1) GNU Lesser General Public License (GNU LGPL)
-  2) Common Public License (CPL)
-  It means that you can select one of these two licenses and
-  follow rules of that license.
-
-  SPECIAL EXCEPTION:
-  Igor Pavlov, as the author of this Code, expressly permits you to
-  statically or dynamically link your Code (or bind by name) to the
-  interfaces of this file without subjecting your linked Code to the
-  terms of the CPL or GNU LGPL. Any modifications or additions
-  to this file, however, are subject to the LGPL or CPL terms.
-*/
-
-#include "LzmaDecode.h"
-
-#define kNumTopBits 24
-#define kTopValue ((UInt32)1 << kNumTopBits)
-
-#define kNumBitModelTotalBits 11
-#define kBitModelTotal (1 << kNumBitModelTotalBits)
-#define kNumMoveBits 5
-
-#define RC_READ_BYTE (*Buffer++)
-
-#define RC_INIT2 Code = 0; Range = 0xFFFFFFFF; \
-  { int i; for(i = 0; i < 5; i++) { RC_TEST; Code = (Code << 8) | RC_READ_BYTE; }}
-
-#ifdef _LZMA_IN_CB
-
-#define RC_TEST { if (Buffer == BufferLim) \
-  { SizeT size; int result = InCallback->Read(InCallback, &Buffer, &size); if (result != LZMA_RESULT_OK) return result; \
-  BufferLim = Buffer + size; if (size == 0) return LZMA_RESULT_DATA_ERROR; }}
-
-#define RC_INIT Buffer = BufferLim = 0; RC_INIT2
-
-#else
-
-#define RC_TEST { if (Buffer == BufferLim) return LZMA_RESULT_DATA_ERROR; }
-
-#define RC_INIT(buffer, bufferSize) Buffer = buffer; BufferLim = buffer + bufferSize; RC_INIT2
-
-#endif
-
-#define RC_NORMALIZE if (Range < kTopValue) { RC_TEST; Range <<= 8; Code = (Code << 8) | RC_READ_BYTE; }
-
-#define IfBit0(p) RC_NORMALIZE; bound = (Range >> kNumBitModelTotalBits) * *(p); if (Code < bound)
-#define UpdateBit0(p) Range = bound; *(p) += (kBitModelTotal - *(p)) >> kNumMoveBits;
-#define UpdateBit1(p) Range -= bound; Code -= bound; *(p) -= (*(p)) >> kNumMoveBits;
-
-#define RC_GET_BIT2(p, mi, A0, A1) IfBit0(p) \
-  { UpdateBit0(p); mi <<= 1; A0; } else \
-  { UpdateBit1(p); mi = (mi + mi) + 1; A1; }
-
-#define RC_GET_BIT(p, mi) RC_GET_BIT2(p, mi, ; , ;)
-
-#define RangeDecoderBitTreeDecode(probs, numLevels, res) \
-  { int i = numLevels; res = 1; \
-  do { CProb *p = probs + res; RC_GET_BIT(p, res) } while(--i != 0); \
-  res -= (1 << numLevels); }
-
-
-#define kNumPosBitsMax 4
-#define kNumPosStatesMax (1 << kNumPosBitsMax)
-
-#define kLenNumLowBits 3
-#define kLenNumLowSymbols (1 << kLenNumLowBits)
-#define kLenNumMidBits 3
-#define kLenNumMidSymbols (1 << kLenNumMidBits)
-#define kLenNumHighBits 8
-#define kLenNumHighSymbols (1 << kLenNumHighBits)
-
-#define LenChoice 0
-#define LenChoice2 (LenChoice + 1)
-#define LenLow (LenChoice2 + 1)
-#define LenMid (LenLow + (kNumPosStatesMax << kLenNumLowBits))
-#define LenHigh (LenMid + (kNumPosStatesMax << kLenNumMidBits))
-#define kNumLenProbs (LenHigh + kLenNumHighSymbols)
-
-
-#define kNumStates 12
-#define kNumLitStates 7
-
-#define kStartPosModelIndex 4
-#define kEndPosModelIndex 14
-#define kNumFullDistances (1 << (kEndPosModelIndex >> 1))
-
-#define kNumPosSlotBits 6
-#define kNumLenToPosStates 4
-
-#define kNumAlignBits 4
-#define kAlignTableSize (1 << kNumAlignBits)
-
-#define kMatchMinLen 2
-
-#define IsMatch 0
-#define IsRep (IsMatch + (kNumStates << kNumPosBitsMax))
-#define IsRepG0 (IsRep + kNumStates)
-#define IsRepG1 (IsRepG0 + kNumStates)
-#define IsRepG2 (IsRepG1 + kNumStates)
-#define IsRep0Long (IsRepG2 + kNumStates)
-#define PosSlot (IsRep0Long + (kNumStates << kNumPosBitsMax))
-#define SpecPos (PosSlot + (kNumLenToPosStates << kNumPosSlotBits))
-#define Align (SpecPos + kNumFullDistances - kEndPosModelIndex)
-#define LenCoder (Align + kAlignTableSize)
-#define RepLenCoder (LenCoder + kNumLenProbs)
-#define Literal (RepLenCoder + kNumLenProbs)
-
-#if Literal != LZMA_BASE_SIZE
-StopCompilingDueBUG
-#endif
-
-int LzmaDecodeProperties(CLzmaProperties *propsRes, const unsigned char *propsData, int size)
-{
-  unsigned char prop0;
-  if (size < LZMA_PROPERTIES_SIZE)
-    return LZMA_RESULT_DATA_ERROR;
-  prop0 = propsData[0];
-  if (prop0 >= (9 * 5 * 5))
-    return LZMA_RESULT_DATA_ERROR;
-  {
-    for (propsRes->pb = 0; prop0 >= (9 * 5); propsRes->pb++, prop0 -= (9 * 5));
-    for (propsRes->lp = 0; prop0 >= 9; propsRes->lp++, prop0 -= 9);
-    propsRes->lc = prop0;
-    /*
-    unsigned char remainder = (unsigned char)(prop0 / 9);
-    propsRes->lc = prop0 % 9;
-    propsRes->pb = remainder / 5;
-    propsRes->lp = remainder % 5;
-    */
-  }
-
-  #ifdef _LZMA_OUT_READ
-  {
-    int i;
-    propsRes->DictionarySize = 0;
-    for (i = 0; i < 4; i++)
-      propsRes->DictionarySize += (UInt32)(propsData[1 + i]) << (i * 8);
-    if (propsRes->DictionarySize == 0)
-      propsRes->DictionarySize = 1;
-  }
-  #endif
-  return LZMA_RESULT_OK;
-}
-
-#define kLzmaStreamWasFinishedId (-1)
-
-int LzmaDecode(CLzmaDecoderState *vs,
-    #ifdef _LZMA_IN_CB
-    ILzmaInCallback *InCallback,
-    #else
-    const unsigned char *inStream, SizeT inSize, SizeT *inSizeProcessed,
-    #endif
-    unsigned char *outStream, SizeT outSize, SizeT *outSizeProcessed)
-{
-  CProb *p = vs->Probs;
-  SizeT nowPos = 0;
-  Byte previousByte = 0;
-  UInt32 posStateMask = (1 << (vs->Properties.pb)) - 1;
-  UInt32 literalPosMask = (1 << (vs->Properties.lp)) - 1;
-  int lc = vs->Properties.lc;
-
-  #ifdef _LZMA_OUT_READ
-
-  UInt32 Range = vs->Range;
-  UInt32 Code = vs->Code;
-  #ifdef _LZMA_IN_CB
-  const Byte *Buffer = vs->Buffer;
-  const Byte *BufferLim = vs->BufferLim;
-  #else
-  const Byte *Buffer = inStream;
-  const Byte *BufferLim = inStream + inSize;
-  #endif
-  int state = vs->State;
-  UInt32 rep0 = vs->Reps[0], rep1 = vs->Reps[1], rep2 = vs->Reps[2], rep3 = vs->Reps[3];
-  int len = vs->RemainLen;
-  UInt32 globalPos = vs->GlobalPos;
-  UInt32 distanceLimit = vs->DistanceLimit;
-
-  Byte *dictionary = vs->Dictionary;
-  UInt32 dictionarySize = vs->Properties.DictionarySize;
-  UInt32 dictionaryPos = vs->DictionaryPos;
-
-  Byte tempDictionary[4];
-
-  #ifndef _LZMA_IN_CB
-  *inSizeProcessed = 0;
-  #endif
-  *outSizeProcessed = 0;
-  if (len == kLzmaStreamWasFinishedId)
-    return LZMA_RESULT_OK;
-
-  if (dictionarySize == 0)
-  {
-    dictionary = tempDictionary;
-    dictionarySize = 1;
-    tempDictionary[0] = vs->TempDictionary[0];
-  }
-
-  if (len == kLzmaNeedInitId)
-  {
-    {
-      UInt32 numProbs = Literal + ((UInt32)LZMA_LIT_SIZE << (lc + vs->Properties.lp));
-      UInt32 i;
-      for (i = 0; i < numProbs; i++)
-        p[i] = kBitModelTotal >> 1;
-      rep0 = rep1 = rep2 = rep3 = 1;
-      state = 0;
-      globalPos = 0;
-      distanceLimit = 0;
-      dictionaryPos = 0;
-      dictionary[dictionarySize - 1] = 0;
-      #ifdef _LZMA_IN_CB
-      RC_INIT;
-      #else
-      RC_INIT(inStream, inSize);
-      #endif
-    }
-    len = 0;
-  }
-  while(len != 0 && nowPos < outSize)
-  {
-    UInt32 pos = dictionaryPos - rep0;
-    if (pos >= dictionarySize)
-      pos += dictionarySize;
-    outStream[nowPos++] = dictionary[dictionaryPos] = dictionary[pos];
-    if (++dictionaryPos == dictionarySize)
-      dictionaryPos = 0;
-    len--;
-  }
-  if (dictionaryPos == 0)
-    previousByte = dictionary[dictionarySize - 1];
-  else
-    previousByte = dictionary[dictionaryPos - 1];
-
-  #else /* if !_LZMA_OUT_READ */
-
-  int state = 0;
-  UInt32 rep0 = 1, rep1 = 1, rep2 = 1, rep3 = 1;
-  int len = 0;
-  const Byte *Buffer;
-  const Byte *BufferLim;
-  UInt32 Range;
-  UInt32 Code;
-
-  #ifndef _LZMA_IN_CB
-  *inSizeProcessed = 0;
-  #endif
-  *outSizeProcessed = 0;
-
-  {
-    UInt32 i;
-    UInt32 numProbs = Literal + ((UInt32)LZMA_LIT_SIZE << (lc + vs->Properties.lp));
-    for (i = 0; i < numProbs; i++)
-      p[i] = kBitModelTotal >> 1;
-  }
-
-  #ifdef _LZMA_IN_CB
-  RC_INIT;
-  #else
-  RC_INIT(inStream, inSize);
-  #endif
-
-  #endif /* _LZMA_OUT_READ */
-
-  while(nowPos < outSize)
-  {
-    CProb *prob;
-    UInt32 bound;
-    int posState = (int)(
-        (nowPos
-        #ifdef _LZMA_OUT_READ
-        + globalPos
-        #endif
-        )
-        & posStateMask);
-
-    prob = p + IsMatch + (state << kNumPosBitsMax) + posState;
-    IfBit0(prob)
-    {
-      int symbol = 1;
-      UpdateBit0(prob)
-      prob = p + Literal + (LZMA_LIT_SIZE *
-        (((
-        (nowPos
-        #ifdef _LZMA_OUT_READ
-        + globalPos
-        #endif
-        )
-        & literalPosMask) << lc) + (previousByte >> (8 - lc))));
-
-      if (state >= kNumLitStates)
-      {
-        int matchByte;
-        #ifdef _LZMA_OUT_READ
-        UInt32 pos = dictionaryPos - rep0;
-        if (pos >= dictionarySize)
-          pos += dictionarySize;
-        matchByte = dictionary[pos];
-        #else
-        matchByte = outStream[nowPos - rep0];
-        #endif
-        do
-        {
-          int bit;
-          CProb *probLit;
-          matchByte <<= 1;
-          bit = (matchByte & 0x100);
-          probLit = prob + 0x100 + bit + symbol;
-          RC_GET_BIT2(probLit, symbol, if (bit != 0) break, if (bit == 0) break)
-        }
-        while (symbol < 0x100);
-      }
-      while (symbol < 0x100)
-      {
-        CProb *probLit = prob + symbol;
-        RC_GET_BIT(probLit, symbol)
-      }
-      previousByte = (Byte)symbol;
-
-      outStream[nowPos++] = previousByte;
-      #ifdef _LZMA_OUT_READ
-      if (distanceLimit < dictionarySize)
-        distanceLimit++;
-
-      dictionary[dictionaryPos] = previousByte;
-      if (++dictionaryPos == dictionarySize)
-        dictionaryPos = 0;
-      #endif
-      if (state < 4) state = 0;
-      else if (state < 10) state -= 3;
-      else state -= 6;
-    }
-    else
-    {
-      UpdateBit1(prob);
-      prob = p + IsRep + state;
-      IfBit0(prob)
-      {
-        UpdateBit0(prob);
-        rep3 = rep2;
-        rep2 = rep1;
-        rep1 = rep0;
-        state = state < kNumLitStates ? 0 : 3;
-        prob = p + LenCoder;
-      }
-      else
-      {
-        UpdateBit1(prob);
-        prob = p + IsRepG0 + state;
-        IfBit0(prob)
-        {
-          UpdateBit0(prob);
-          prob = p + IsRep0Long + (state << kNumPosBitsMax) + posState;
-          IfBit0(prob)
-          {
-            #ifdef _LZMA_OUT_READ
-            UInt32 pos;
-            #endif
-            UpdateBit0(prob);
-
-            #ifdef _LZMA_OUT_READ
-            if (distanceLimit == 0)
-            #else
-            if (nowPos == 0)
-            #endif
-              return LZMA_RESULT_DATA_ERROR;
-
-            state = state < kNumLitStates ? 9 : 11;
-            #ifdef _LZMA_OUT_READ
-            pos = dictionaryPos - rep0;
-            if (pos >= dictionarySize)
-              pos += dictionarySize;
-            previousByte = dictionary[pos];
-            dictionary[dictionaryPos] = previousByte;
-            if (++dictionaryPos == dictionarySize)
-              dictionaryPos = 0;
-            #else
-            previousByte = outStream[nowPos - rep0];
-            #endif
-            outStream[nowPos++] = previousByte;
-            #ifdef _LZMA_OUT_READ
-            if (distanceLimit < dictionarySize)
-              distanceLimit++;
-            #endif
-
-            continue;
-          }
-          else
-          {
-            UpdateBit1(prob);
-          }
-        }
-        else
-        {
-          UInt32 distance;
-          UpdateBit1(prob);
-          prob = p + IsRepG1 + state;
-          IfBit0(prob)
-          {
-            UpdateBit0(prob);
-            distance = rep1;
-          }
-          else
-          {
-            UpdateBit1(prob);
-            prob = p + IsRepG2 + state;
-            IfBit0(prob)
-            {
-              UpdateBit0(prob);
-              distance = rep2;
-            }
-            else
-            {
-              UpdateBit1(prob);
-              distance = rep3;
-              rep3 = rep2;
-            }
-            rep2 = rep1;
-          }
-          rep1 = rep0;
-          rep0 = distance;
-        }
-        state = state < kNumLitStates ? 8 : 11;
-        prob = p + RepLenCoder;
-      }
-      {
-        int numBits, offset;
-        CProb *probLen = prob + LenChoice;
-        IfBit0(probLen)
-        {
-          UpdateBit0(probLen);
-          probLen = prob + LenLow + (posState << kLenNumLowBits);
-          offset = 0;
-          numBits = kLenNumLowBits;
-        }
-        else
-        {
-          UpdateBit1(probLen);
-          probLen = prob + LenChoice2;
-          IfBit0(probLen)
-          {
-            UpdateBit0(probLen);
-            probLen = prob + LenMid + (posState << kLenNumMidBits);
-            offset = kLenNumLowSymbols;
-            numBits = kLenNumMidBits;
-          }
-          else
-          {
-            UpdateBit1(probLen);
-            probLen = prob + LenHigh;
-            offset = kLenNumLowSymbols + kLenNumMidSymbols;
-            numBits = kLenNumHighBits;
-          }
-        }
-        RangeDecoderBitTreeDecode(probLen, numBits, len);
-        len += offset;
-      }
-
-      if (state < 4)
-      {
-        int posSlot;
-        state += kNumLitStates;
-        prob = p + PosSlot +
-            ((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) <<
-            kNumPosSlotBits);
-        RangeDecoderBitTreeDecode(prob, kNumPosSlotBits, posSlot);
-        if (posSlot >= kStartPosModelIndex)
-        {
-          int numDirectBits = ((posSlot >> 1) - 1);
-          rep0 = (2 | ((UInt32)posSlot & 1));
-          if (posSlot < kEndPosModelIndex)
-          {
-            rep0 <<= numDirectBits;
-            prob = p + SpecPos + rep0 - posSlot - 1;
-          }
-          else
-          {
-            numDirectBits -= kNumAlignBits;
-            do
-            {
-              RC_NORMALIZE
-              Range >>= 1;
-              rep0 <<= 1;
-              if (Code >= Range)
-              {
-                Code -= Range;
-                rep0 |= 1;
-              }
-            }
-            while (--numDirectBits != 0);
-            prob = p + Align;
-            rep0 <<= kNumAlignBits;
-            numDirectBits = kNumAlignBits;
-          }
-          {
-            int i = 1;
-            int mi = 1;
-            do
-            {
-              CProb *prob3 = prob + mi;
-              RC_GET_BIT2(prob3, mi, ; , rep0 |= i);
-              i <<= 1;
-            }
-            while(--numDirectBits != 0);
-          }
-        }
-        else
-          rep0 = posSlot;
-        if (++rep0 == (UInt32)(0))
-        {
-          /* it's for stream version */
-          len = kLzmaStreamWasFinishedId;
-          break;
-        }
-      }
-
-      len += kMatchMinLen;
-      #ifdef _LZMA_OUT_READ
-      if (rep0 > distanceLimit)
-      #else
-      if (rep0 > nowPos)
-      #endif
-        return LZMA_RESULT_DATA_ERROR;
-
-      #ifdef _LZMA_OUT_READ
-      if (dictionarySize - distanceLimit > (UInt32)len)
-        distanceLimit += len;
-      else
-        distanceLimit = dictionarySize;
-      #endif
-
-      do
-      {
-        #ifdef _LZMA_OUT_READ
-        UInt32 pos = dictionaryPos - rep0;
-        if (pos >= dictionarySize)
-          pos += dictionarySize;
-        previousByte = dictionary[pos];
-        dictionary[dictionaryPos] = previousByte;
-        if (++dictionaryPos == dictionarySize)
-          dictionaryPos = 0;
-        #else
-        previousByte = outStream[nowPos - rep0];
-        #endif
-        len--;
-        outStream[nowPos++] = previousByte;
-      }
-      while(len != 0 && nowPos < outSize);
-    }
-  }
-  RC_NORMALIZE;
-
-  #ifdef _LZMA_OUT_READ
-  vs->Range = Range;
-  vs->Code = Code;
-  vs->DictionaryPos = dictionaryPos;
-  vs->GlobalPos = globalPos + (UInt32)nowPos;
-  vs->DistanceLimit = distanceLimit;
-  vs->Reps[0] = rep0;
-  vs->Reps[1] = rep1;
-  vs->Reps[2] = rep2;
-  vs->Reps[3] = rep3;
-  vs->State = state;
-  vs->RemainLen = len;
-  vs->TempDictionary[0] = tempDictionary[0];
-  #endif
-
-  #ifdef _LZMA_IN_CB
-  vs->Buffer = Buffer;
-  vs->BufferLim = BufferLim;
-  #else
-  *inSizeProcessed = (SizeT)(Buffer - inStream);
-  #endif
-  *outSizeProcessed = nowPos;
-  return LZMA_RESULT_OK;
-}
diff --git a/lib_generic/lzma/LzmaDecode.h b/lib_generic/lzma/LzmaDecode.h
deleted file mode 100644 (file)
index bd75525..0000000
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
-  LzmaDecode.h
-  LZMA Decoder interface
-
-  LZMA SDK 4.40 Copyright (c) 1999-2006 Igor Pavlov (2006-05-01)
-  http://www.7-zip.org/
-
-  LZMA SDK is licensed under two licenses:
-  1) GNU Lesser General Public License (GNU LGPL)
-  2) Common Public License (CPL)
-  It means that you can select one of these two licenses and
-  follow rules of that license.
-
-  SPECIAL EXCEPTION:
-  Igor Pavlov, as the author of this code, expressly permits you to
-  statically or dynamically link your code (or bind by name) to the
-  interfaces of this file without subjecting your linked code to the
-  terms of the CPL or GNU LGPL. Any modifications or additions
-  to this file, however, are subject to the LGPL or CPL terms.
-*/
-
-#ifndef __LZMADECODE_H
-#define __LZMADECODE_H
-
-#include "LzmaTypes.h"
-
-/* #define _LZMA_IN_CB */
-/* Use callback for input data */
-
-/* #define _LZMA_OUT_READ */
-/* Use read function for output data */
-
-/* #define _LZMA_PROB32 */
-/* It can increase speed on some 32-bit CPUs,
-   but memory usage will be doubled in that case */
-
-/* #define _LZMA_LOC_OPT */
-/* Enable local speed optimizations inside code */
-
-#ifdef _LZMA_PROB32
-#define CProb UInt32
-#else
-#define CProb UInt16
-#endif
-
-#define LZMA_RESULT_OK 0
-#define LZMA_RESULT_DATA_ERROR 1
-
-#ifdef _LZMA_IN_CB
-typedef struct _ILzmaInCallback
-{
-  int (*Read)(void *object, const unsigned char **buffer, SizeT *bufferSize);
-} ILzmaInCallback;
-#endif
-
-#define LZMA_BASE_SIZE 1846
-#define LZMA_LIT_SIZE 768
-
-#define LZMA_PROPERTIES_SIZE 5
-
-typedef struct _CLzmaProperties
-{
-  int lc;
-  int lp;
-  int pb;
-  #ifdef _LZMA_OUT_READ
-  UInt32 DictionarySize;
-  #endif
-}CLzmaProperties;
-
-int LzmaDecodeProperties(CLzmaProperties *propsRes, const unsigned char *propsData, int size);
-
-#define LzmaGetNumProbs(Properties) (LZMA_BASE_SIZE + (LZMA_LIT_SIZE << ((Properties)->lc + (Properties)->lp)))
-
-#define kLzmaNeedInitId (-2)
-
-typedef struct _CLzmaDecoderState
-{
-  CLzmaProperties Properties;
-  CProb *Probs;
-
-  #ifdef _LZMA_IN_CB
-  const unsigned char *Buffer;
-  const unsigned char *BufferLim;
-  #endif
-
-  #ifdef _LZMA_OUT_READ
-  unsigned char *Dictionary;
-  UInt32 Range;
-  UInt32 Code;
-  UInt32 DictionaryPos;
-  UInt32 GlobalPos;
-  UInt32 DistanceLimit;
-  UInt32 Reps[4];
-  int State;
-  int RemainLen;
-  unsigned char TempDictionary[4];
-  #endif
-} CLzmaDecoderState;
-
-#ifdef _LZMA_OUT_READ
-#define LzmaDecoderInit(vs) { (vs)->RemainLen = kLzmaNeedInitId; }
-#endif
-
-int LzmaDecode(CLzmaDecoderState *vs,
-    #ifdef _LZMA_IN_CB
-    ILzmaInCallback *inCallback,
-    #else
-    const unsigned char *inStream, SizeT inSize, SizeT *inSizeProcessed,
-    #endif
-    unsigned char *outStream, SizeT outSize, SizeT *outSizeProcessed);
-
-#endif
index 5ac42e5..c2a91e5 100644 (file)
@@ -1,7 +1,7 @@
 /*
- * Usefuls routines based on the LzmaTest.c file from LZMA SDK 4.57
+ * Usefuls routines based on the LzmaTest.c file from LZMA SDK 4.65
  *
- * Copyright (C) 2007-2008 Industrie Dial Face S.p.A.
+ * Copyright (C) 2007-2009 Industrie Dial Face S.p.A.
  * Luigi 'Comio' Mantellini (luigi.mantellini@idf-hit.com)
  *
  * Copyright (C) 1999-2005 Igor Pavlov
 #ifdef CONFIG_LZMA
 
 #define LZMA_PROPERTIES_OFFSET 0
-#define LZMA_SIZE_OFFSET       LZMA_PROPERTIES_SIZE
+#define LZMA_SIZE_OFFSET       LZMA_PROPS_SIZE
 #define LZMA_DATA_OFFSET       LZMA_SIZE_OFFSET+sizeof(uint64_t)
 
 #include "LzmaTools.h"
-#include "LzmaDecode.h"
+#include "LzmaDec.h"
 
 #include <linux/string.h>
 #include <malloc.h>
 
+static void *SzAlloc(void *p, size_t size) { p = p; return malloc(size); }
+static void SzFree(void *p, void *address) { p = p; free(address); }
+
 int lzmaBuffToBuffDecompress (unsigned char *outStream, SizeT *uncompressedSize,
-                             unsigned char *inStream,  SizeT  length)
+                  unsigned char *inStream,  SizeT  length)
 {
-       int res = LZMA_RESULT_DATA_ERROR;
-       int i;
-
-       SizeT outSizeFull = 0xFFFFFFFF; /* 4GBytes limit */
-       SizeT inProcessed;
-       SizeT outProcessed;
-       SizeT outSize;
-       SizeT outSizeHigh;
-       CLzmaDecoderState state;  /* it's about 24-80 bytes structure, if int is 32-bit */
-       unsigned char properties[LZMA_PROPERTIES_SIZE];
-       SizeT compressedSize = (SizeT)(length - LZMA_DATA_OFFSET);
-
-       debug ("LZMA: Image address............... 0x%lx\n", inStream);
-       debug ("LZMA: Properties address.......... 0x%lx\n", inStream + LZMA_PROPERTIES_OFFSET);
-       debug ("LZMA: Uncompressed size address... 0x%lx\n", inStream + LZMA_SIZE_OFFSET);
-       debug ("LZMA: Compressed data address..... 0x%lx\n", inStream + LZMA_DATA_OFFSET);
-       debug ("LZMA: Destination address......... 0x%lx\n", outStream);
-
-       memcpy(properties, inStream + LZMA_PROPERTIES_OFFSET, LZMA_PROPERTIES_SIZE);
-
-       memset(&state, 0, sizeof(state));
-       res = LzmaDecodeProperties(&state.Properties,
-                                properties,
-                                LZMA_PROPERTIES_SIZE);
-       if (res != LZMA_RESULT_OK) {
-               return res;
-       }
-
-       outSize = 0;
-       outSizeHigh = 0;
-       /* Read the uncompressed size */
-       for (i = 0; i < 8; i++) {
-               unsigned char b = inStream[LZMA_SIZE_OFFSET + i];
-               if (i < 4) {
-                       outSize     += (UInt32)(b) << (i * 8);
-               } else {
-                       outSizeHigh += (UInt32)(b) << ((i - 4) * 8);
-               }
-       }
-
-       outSizeFull = (SizeT)outSize;
-       if (sizeof(SizeT) >= 8) {
-               /*
-                * SizeT is a 64 bit uint => We can manage files larger than 4GB!
-                *
-                */
-               outSizeFull |= (((SizeT)outSizeHigh << 16) << 16);
-       } else if (outSizeHigh != 0 || (UInt32)(SizeT)outSize != outSize) {
-               /*
-                * SizeT is a 32 bit uint => We cannot manage files larger than
-                * 4GB!
-                *
-                */
-               debug ("LZMA: 64bit support not enabled.\n");
-               return LZMA_RESULT_DATA_ERROR;
-       }
-
-       debug ("LZMA: Uncompresed size............ 0x%lx\n", outSizeFull);
-       debug ("LZMA: Compresed size.............. 0x%lx\n", compressedSize);
-       debug ("LZMA: Dynamic memory needed....... 0x%lx", LzmaGetNumProbs(&state.Properties) * sizeof(CProb));
-
-       state.Probs = (CProb *)malloc(LzmaGetNumProbs(&state.Properties) * sizeof(CProb));
-
-       if (state.Probs == 0
-           || (outStream == 0 && outSizeFull != 0)
-           || (inStream == 0 && compressedSize != 0)) {
-               free(state.Probs);
-               debug ("\n");
-               return LZMA_RESULT_DATA_ERROR;
-       }
-
-       debug (" allocated.\n");
-
-       /* Decompress */
-
-       res = LzmaDecode(&state,
-               inStream + LZMA_DATA_OFFSET, compressedSize, &inProcessed,
-               outStream, outSizeFull,  &outProcessed);
-       if (res != LZMA_RESULT_OK)  {
-               return res;
-       }
-
-       *uncompressedSize = outProcessed;
-       free(state.Probs);
-       return res;
+    int res = SZ_ERROR_DATA;
+    int i;
+    ISzAlloc g_Alloc;
+
+    SizeT outSizeFull = 0xFFFFFFFF; /* 4GBytes limit */
+    SizeT inProcessed;
+    SizeT outProcessed;
+    SizeT outSize;
+    SizeT outSizeHigh;
+    ELzmaStatus state;
+    SizeT compressedSize = (SizeT)(length - LZMA_PROPS_SIZE);
+
+    debug ("LZMA: Image address............... 0x%lx\n", inStream);
+    debug ("LZMA: Properties address.......... 0x%lx\n", inStream + LZMA_PROPERTIES_OFFSET);
+    debug ("LZMA: Uncompressed size address... 0x%lx\n", inStream + LZMA_SIZE_OFFSET);
+    debug ("LZMA: Compressed data address..... 0x%lx\n", inStream + LZMA_DATA_OFFSET);
+    debug ("LZMA: Destination address......... 0x%lx\n", outStream);
+
+    memset(&state, 0, sizeof(state));
+
+    outSize = 0;
+    outSizeHigh = 0;
+    /* Read the uncompressed size */
+    for (i = 0; i < 8; i++) {
+        unsigned char b = inStream[LZMA_SIZE_OFFSET + i];
+            if (i < 4) {
+                outSize     += (UInt32)(b) << (i * 8);
+        } else {
+                outSizeHigh += (UInt32)(b) << ((i - 4) * 8);
+        }
+    }
+
+    outSizeFull = (SizeT)outSize;
+    if (sizeof(SizeT) >= 8) {
+        /*
+         * SizeT is a 64 bit uint => We can manage files larger than 4GB!
+         *
+         */
+            outSizeFull |= (((SizeT)outSizeHigh << 16) << 16);
+    } else if (outSizeHigh != 0 || (UInt32)(SizeT)outSize != outSize) {
+        /*
+         * SizeT is a 32 bit uint => We cannot manage files larger than
+         * 4GB!
+         *
+         */
+        debug ("LZMA: 64bit support not enabled.\n");
+        return SZ_ERROR_DATA;
+    }
+
+    debug ("LZMA: Uncompresed size............ 0x%lx\n", outSizeFull);
+    debug ("LZMA: Compresed size.............. 0x%lx\n", compressedSize);
+
+    g_Alloc.Alloc = SzAlloc;
+    g_Alloc.Free = SzFree;
+
+    /* Decompress */
+    outProcessed = outSizeFull;
+    res = LzmaDecode(
+        outStream, &outProcessed,
+        inStream + LZMA_DATA_OFFSET, &compressedSize,
+        inStream, LZMA_PROPS_SIZE, LZMA_FINISH_ANY, &state, &g_Alloc);
+    *uncompressedSize = outProcessed;
+    if (res != SZ_OK)  {
+        return res;
+    }
+
+    return res;
 }
 
 #endif
index c91fb89..2db80fc 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Usefuls routines based on the LzmaTest.c file from LZMA SDK 4.57
+ * Usefuls routines based on the LzmaTest.c file from LZMA SDK 4.65
  *
  * Copyright (C) 2007-2008 Industrie Dial Face S.p.A.
  * Luigi 'Comio' Mantellini (luigi.mantellini@idf-hit.com)
@@ -28,7 +28,7 @@
 #ifndef __LZMA_TOOL_H__
 #define __LZMA_TOOL_H__
 
-#include "LzmaTypes.h"
+#include <lzma/LzmaTypes.h>
 
 extern int lzmaBuffToBuffDecompress (unsigned char *outStream, SizeT *uncompressedSize,
                              unsigned char *inStream,  SizeT  length);
diff --git a/lib_generic/lzma/LzmaTypes.h b/lib_generic/lzma/LzmaTypes.h
deleted file mode 100644 (file)
index 83f96f4..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
-LzmaTypes.h
-
-Types for LZMA Decoder
-
-This file written and distributed to public domain by Igor Pavlov.
-This file is part of LZMA SDK 4.40 (2006-05-01)
-*/
-
-#ifndef __LZMATYPES_H
-#define __LZMATYPES_H
-
-#ifndef _7ZIP_BYTE_DEFINED
-#define _7ZIP_BYTE_DEFINED
-typedef unsigned char Byte;
-#endif
-
-#ifndef _7ZIP_UINT16_DEFINED
-#define _7ZIP_UINT16_DEFINED
-typedef unsigned short UInt16;
-#endif
-
-#ifndef _7ZIP_UINT32_DEFINED
-#define _7ZIP_UINT32_DEFINED
-#ifdef _LZMA_UINT32_IS_ULONG
-typedef unsigned long UInt32;
-#else
-typedef unsigned int UInt32;
-#endif
-#endif
-
-/* #define _LZMA_NO_SYSTEM_SIZE_T */
-/* You can use it, if you don't want <stddef.h> */
-
-#ifndef _7ZIP_SIZET_DEFINED
-#define _7ZIP_SIZET_DEFINED
-#ifdef _LZMA_NO_SYSTEM_SIZE_T
-typedef UInt32 SizeT;
-#else
-#include <stddef.h>
-typedef size_t SizeT;
-#endif
-#endif
-
-#endif
index 3400cd9..2916f21 100644 (file)
@@ -30,7 +30,9 @@ LIB   = $(obj)liblzma.a
 
 SOBJS  =
 
-COBJS-$(CONFIG_LZMA) += LzmaDecode.o LzmaTools.o
+CFLAGS += -D_LZMA_PROB32 -I$(TOPDIR)/include/linux
+
+COBJS-$(CONFIG_LZMA) += LzmaDec.o LzmaTools.o
 
 COBJS  = $(COBJS-y)
 SRCS   := $(SOBJS:.o=.S) $(COBJS:.o=.c)
index fdb3086..23a9be2 100644 (file)
@@ -7,14 +7,14 @@ Author:         Igor Pavlov
 The import is made using the import_lzmasdk.sh script that:
 
 * untars the lzmaXYY.tar.bz2 file (from the download web page)
-* copies the files LzmaDecode.h, LzmaTypes.h, LzmaDecode.c, history.txt,
-  LGPL.txt, and lzma.txt from source archive into the lib_lzma directory (pwd).
+* copies the files LzmaDec.h, Types.h, LzmaDec.c, history.txt,
+  and lzma.txt from source archive into the lib_lzma directory (pwd).
 
 Example:
 
- ./import_lzmasdk.sh ~/lzma457.tar.bz2
+ . import_lzmasdk.sh ~/lzma465.tar.bz2
 
-Notice: The files from lzma sdk are not _modified_ by this script!
+Notice: The files from lzma sdk are _not modified_ by this script!
 
 The files LzmaTools.{c,h} are provided to export the lzmaBuffToBuffDecompress()
 function that wraps the complex LzmaDecode() function from the LZMA SDK. The
diff --git a/lib_generic/lzma/Types.h b/lib_generic/lzma/Types.h
new file mode 100644 (file)
index 0000000..1af5cfc
--- /dev/null
@@ -0,0 +1,208 @@
+/* Types.h -- Basic types
+2008-11-23 : Igor Pavlov : Public domain */
+
+#ifndef __7Z_TYPES_H
+#define __7Z_TYPES_H
+
+#include <stddef.h>
+
+#ifdef _WIN32
+#include <windows.h>
+#endif
+
+#define SZ_OK 0
+
+#define SZ_ERROR_DATA 1
+#define SZ_ERROR_MEM 2
+#define SZ_ERROR_CRC 3
+#define SZ_ERROR_UNSUPPORTED 4
+#define SZ_ERROR_PARAM 5
+#define SZ_ERROR_INPUT_EOF 6
+#define SZ_ERROR_OUTPUT_EOF 7
+#define SZ_ERROR_READ 8
+#define SZ_ERROR_WRITE 9
+#define SZ_ERROR_PROGRESS 10
+#define SZ_ERROR_FAIL 11
+#define SZ_ERROR_THREAD 12
+
+#define SZ_ERROR_ARCHIVE 16
+#define SZ_ERROR_NO_ARCHIVE 17
+
+typedef int SRes;
+
+#ifdef _WIN32
+typedef DWORD WRes;
+#else
+typedef int WRes;
+#endif
+
+#ifndef RINOK
+#define RINOK(x) { int __result__ = (x); if (__result__ != 0) return __result__; }
+#endif
+
+typedef unsigned char Byte;
+typedef short Int16;
+typedef unsigned short UInt16;
+
+#ifdef _LZMA_UINT32_IS_ULONG
+typedef long Int32;
+typedef unsigned long UInt32;
+#else
+typedef int Int32;
+typedef unsigned int UInt32;
+#endif
+
+#ifdef _SZ_NO_INT_64
+
+/* define _SZ_NO_INT_64, if your compiler doesn't support 64-bit integers.
+   NOTES: Some code will work incorrectly in that case! */
+
+typedef long Int64;
+typedef unsigned long UInt64;
+
+#else
+
+#if defined(_MSC_VER) || defined(__BORLANDC__)
+typedef __int64 Int64;
+typedef unsigned __int64 UInt64;
+#else
+typedef long long int Int64;
+typedef unsigned long long int UInt64;
+#endif
+
+#endif
+
+#ifdef _LZMA_NO_SYSTEM_SIZE_T
+typedef UInt32 SizeT;
+#else
+typedef size_t SizeT;
+#endif
+
+typedef int Bool;
+#define True 1
+#define False 0
+
+
+#ifdef _MSC_VER
+
+#if _MSC_VER >= 1300
+#define MY_NO_INLINE __declspec(noinline)
+#else
+#define MY_NO_INLINE
+#endif
+
+#define MY_CDECL __cdecl
+#define MY_STD_CALL __stdcall
+#define MY_FAST_CALL MY_NO_INLINE __fastcall
+
+#else
+
+#define MY_CDECL
+#define MY_STD_CALL
+#define MY_FAST_CALL
+
+#endif
+
+
+/* The following interfaces use first parameter as pointer to structure */
+
+typedef struct
+{
+  SRes (*Read)(void *p, void *buf, size_t *size);
+    /* if (input(*size) != 0 && output(*size) == 0) means end_of_stream.
+       (output(*size) < input(*size)) is allowed */
+} ISeqInStream;
+
+/* it can return SZ_ERROR_INPUT_EOF */
+SRes SeqInStream_Read(ISeqInStream *stream, void *buf, size_t size);
+SRes SeqInStream_Read2(ISeqInStream *stream, void *buf, size_t size, SRes errorType);
+SRes SeqInStream_ReadByte(ISeqInStream *stream, Byte *buf);
+
+typedef struct
+{
+  size_t (*Write)(void *p, const void *buf, size_t size);
+    /* Returns: result - the number of actually written bytes.
+       (result < size) means error */
+} ISeqOutStream;
+
+typedef enum
+{
+  SZ_SEEK_SET = 0,
+  SZ_SEEK_CUR = 1,
+  SZ_SEEK_END = 2
+} ESzSeek;
+
+typedef struct
+{
+  SRes (*Read)(void *p, void *buf, size_t *size);  /* same as ISeqInStream::Read */
+  SRes (*Seek)(void *p, Int64 *pos, ESzSeek origin);
+} ISeekInStream;
+
+typedef struct
+{
+  SRes (*Look)(void *p, void **buf, size_t *size);
+    /* if (input(*size) != 0 && output(*size) == 0) means end_of_stream.
+       (output(*size) > input(*size)) is not allowed
+       (output(*size) < input(*size)) is allowed */
+  SRes (*Skip)(void *p, size_t offset);
+    /* offset must be <= output(*size) of Look */
+
+  SRes (*Read)(void *p, void *buf, size_t *size);
+    /* reads directly (without buffer). It's same as ISeqInStream::Read */
+  SRes (*Seek)(void *p, Int64 *pos, ESzSeek origin);
+} ILookInStream;
+
+SRes LookInStream_LookRead(ILookInStream *stream, void *buf, size_t *size);
+SRes LookInStream_SeekTo(ILookInStream *stream, UInt64 offset);
+
+/* reads via ILookInStream::Read */
+SRes LookInStream_Read2(ILookInStream *stream, void *buf, size_t size, SRes errorType);
+SRes LookInStream_Read(ILookInStream *stream, void *buf, size_t size);
+
+#define LookToRead_BUF_SIZE (1 << 14)
+
+typedef struct
+{
+  ILookInStream s;
+  ISeekInStream *realStream;
+  size_t pos;
+  size_t size;
+  Byte buf[LookToRead_BUF_SIZE];
+} CLookToRead;
+
+void LookToRead_CreateVTable(CLookToRead *p, int lookahead);
+void LookToRead_Init(CLookToRead *p);
+
+typedef struct
+{
+  ISeqInStream s;
+  ILookInStream *realStream;
+} CSecToLook;
+
+void SecToLook_CreateVTable(CSecToLook *p);
+
+typedef struct
+{
+  ISeqInStream s;
+  ILookInStream *realStream;
+} CSecToRead;
+
+void SecToRead_CreateVTable(CSecToRead *p);
+
+typedef struct
+{
+  SRes (*Progress)(void *p, UInt64 inSize, UInt64 outSize);
+    /* Returns: result. (result != SZ_OK) means break.
+       Value (UInt64)(Int64)-1 for size means unknown value. */
+} ICompressProgress;
+
+typedef struct
+{
+  void *(*Alloc)(void *p, size_t size);
+  void (*Free)(void *p, void *address); /* address can be 0 */
+} ISzAlloc;
+
+#define IAlloc_Alloc(p, size) (p)->Alloc((p), size)
+#define IAlloc_Free(p, a) (p)->Free((p), a)
+
+#endif
index dad1858..624fb1d 100644 (file)
 HISTORY of the LZMA SDK
 -----------------------
 
-  4.57          2007-12-12
-  -------------------------
-    - Speed optimizations in Ã‘++ LZMA Decoder.
-    - Small changes for more compatibility with some C/C++ compilers.
+4.65           2009-02-03
+-------------------------
+- Some minor fixes
 
 
-  4.49 beta     2007-07-05
-  -------------------------
-    - .7z ANSI-C Decoder:
-        - now it supports BCJ and BCJ2 filters
-        - now it supports files larger than 4 GB.
-        - now it supports "Last Write Time" field for files.
-    - C++ code for .7z archives compressing/decompressing from 7-zip
-      was included to LZMA SDK.
+4.63           2008-12-31
+-------------------------
+- Some minor fixes
 
 
-  4.43          2006-06-04
-  -------------------------
-    - Small changes for more compatibility with some C/C++ compilers.
+4.61 beta      2008-11-23
+-------------------------
+- The bug in ANSI-C LZMA Decoder was fixed:
+    If encoded stream was corrupted, decoder could access memory
+    outside of allocated range.
+- Some changes in ANSI-C 7z Decoder interfaces.
+- LZMA SDK is placed in the public domain.
 
 
-  4.42          2006-05-15
-  -------------------------
-    - Small changes in .h files in ANSI-C version.
+4.60 beta      2008-08-19
+-------------------------
+- Some minor fixes.
 
 
-  4.39 beta     2006-04-14
-  -------------------------
-    - Bug in versions 4.33b:4.38b was fixed:
-      C++ version of LZMA encoder could not correctly compress
-      files larger than 2 GB with HC4 match finder (-mfhc4).
+4.59 beta      2008-08-13
+-------------------------
+- The bug was fixed:
+    LZMA Encoder in fast compression mode could access memory outside of
+    allocated range in some rare cases.
 
 
-  4.37 beta     2005-04-06
-  -------------------------
-    - Fixes in C++ code: code could no be compiled if _NO_EXCEPTIONS was defined.
+4.58 beta      2008-05-05
+-------------------------
+- ANSI-C LZMA Decoder was rewritten for speed optimizations.
+- ANSI-C LZMA Encoder was included to LZMA SDK.
+- C++ LZMA code now is just wrapper over ANSI-C code.
 
 
-  4.35 beta     2005-03-02
-  -------------------------
-    - Bug was fixed in C++ version of LZMA Decoder:
-       If encoded stream was corrupted, decoder could access memory
-       outside of allocated range.
+4.57           2007-12-12
+-------------------------
+- Speed optimizations in Ã‘++ LZMA Decoder.
+- Small changes for more compatibility with some C/C++ compilers.
 
 
-  4.34 beta     2006-02-27
-  -------------------------
-    - Compressing speed and memory requirements for compressing were increased
-    - LZMA now can use only these match finders: HC4, BT2, BT3, BT4
+4.49 beta      2007-07-05
+-------------------------
+- .7z ANSI-C Decoder:
+     - now it supports BCJ and BCJ2 filters
+     - now it supports files larger than 4 GB.
+     - now it supports "Last Write Time" field for files.
+- C++ code for .7z archives compressing/decompressing from 7-zip
+  was included to LZMA SDK.
 
 
-  4.32          2005-12-09
-  -------------------------
-    - Java version of LZMA SDK was included
+4.43           2006-06-04
+-------------------------
+- Small changes for more compatibility with some C/C++ compilers.
 
 
-  4.30          2005-11-20
-  -------------------------
-    - Compression ratio was improved in -a2 mode
-    - Speed optimizations for compressing in -a2 mode
-    - -fb switch now supports values up to 273
-    - Bug in 7z_C (7zIn.c) was fixed:
-      It used Alloc/Free functions from different memory pools.
-      So if program used two memory pools, it worked incorrectly.
-    - 7z_C: .7z format supporting was improved
-    - LZMA# SDK (C#.NET version) was included
+4.42           2006-05-15
+-------------------------
+- Small changes in .h files in ANSI-C version.
 
 
-  4.27 (Updated) 2005-09-21
-  -------------------------
-   - Some GUIDs/interfaces in C++ were changed.
-     IStream.h:
-       ISequentialInStream::Read now works as old ReadPart
-       ISequentialOutStream::Write now works as old WritePart
+4.39 beta      2006-04-14
+-------------------------
+- The bug in versions 4.33b:4.38b was fixed:
+  C++ version of LZMA encoder could not correctly compress
+  files larger than 2 GB with HC4 match finder (-mfhc4).
 
 
-  4.27          2005-08-07
-  -------------------------
-    - Bug in LzmaDecodeSize.c was fixed:
-       if _LZMA_IN_CB and _LZMA_OUT_READ were defined,
-       decompressing worked incorrectly.
+4.37 beta      2005-04-06
+-------------------------
+- Fixes in C++ code: code could no be compiled if _NO_EXCEPTIONS was defined.
 
 
-  4.26          2005-08-05
-  -------------------------
-    - Fixes in 7z_C code and LzmaTest.c:
-      previous versions could work incorrectly,
-      if malloc(0) returns 0
+4.35 beta      2005-03-02
+-------------------------
+- The bug was fixed in C++ version of LZMA Decoder:
+    If encoded stream was corrupted, decoder could access memory
+    outside of allocated range.
 
 
-  4.23          2005-06-29
-  -------------------------
-    - Small fixes in C++ code
+4.34 beta      2006-02-27
+-------------------------
+- Compressing speed and memory requirements for compressing were increased
+- LZMA now can use only these match finders: HC4, BT2, BT3, BT4
 
 
-  4.22          2005-06-10
-  -------------------------
-    - Small fixes
+4.32           2005-12-09
+-------------------------
+- Java version of LZMA SDK was included
 
 
-  4.21          2005-06-08
-  -------------------------
-    - Interfaces for ANSI-C LZMA Decoder (LzmaDecode.c) were changed
-    - New additional version of ANSI-C LZMA Decoder with zlib-like interface:
-       - LzmaStateDecode.h
-       - LzmaStateDecode.c
-       - LzmaStateTest.c
-    - ANSI-C LZMA Decoder now can decompress files larger than 4 GB
+4.30           2005-11-20
+-------------------------
+- Compression ratio was improved in -a2 mode
+- Speed optimizations for compressing in -a2 mode
+- -fb switch now supports values up to 273
+- The bug in 7z_C (7zIn.c) was fixed:
+  It used Alloc/Free functions from different memory pools.
+  So if program used two memory pools, it worked incorrectly.
+- 7z_C: .7z format supporting was improved
+- LZMA# SDK (C#.NET version) was included
 
 
-  4.17          2005-04-18
-  -------------------------
-    - New example for RAM->RAM compressing/decompressing:
-      LZMA + BCJ (filter for x86 code):
-       - LzmaRam.h
-       - LzmaRam.cpp
-       - LzmaRamDecode.h
-       - LzmaRamDecode.c
-       - -f86 switch for lzma.exe
+4.27 (Updated) 2005-09-21
+-------------------------
+- Some GUIDs/interfaces in C++ were changed.
+ IStream.h:
+   ISequentialInStream::Read now works as old ReadPart
+   ISequentialOutStream::Write now works as old WritePart
 
 
-  4.16          2005-03-29
-  -------------------------
-    - Bug was fixed in LzmaDecode.c (ANSI-C LZMA Decoder):
-       If _LZMA_OUT_READ was defined, and if encoded stream was corrupted,
-       decoder could access memory outside of allocated range.
-    - Speed optimization of ANSI-C LZMA Decoder (now it's about 20% faster).
-      Old version of LZMA Decoder now is in file LzmaDecodeSize.c.
-      LzmaDecodeSize.c can provide slightly smaller code than LzmaDecode.c
-    - Small speed optimization in LZMA C++ code
-    - filter for SPARC's code was added
-    - Simplified version of .7z ANSI-C Decoder was included
+4.27           2005-08-07
+-------------------------
+- The bug in LzmaDecodeSize.c was fixed:
+   if _LZMA_IN_CB and _LZMA_OUT_READ were defined,
+   decompressing worked incorrectly.
 
 
-  4.06          2004-09-05
-  -------------------------
-    - Bug in v4.05 was fixed:
-       LZMA-Encoder didn't release output stream in some cases.
+4.26           2005-08-05
+-------------------------
+- Fixes in 7z_C code and LzmaTest.c:
+  previous versions could work incorrectly,
+  if malloc(0) returns 0
 
 
-  4.05          2004-08-25
-  -------------------------
-    - Source code of filters for x86, IA-64, ARM, ARM-Thumb
-      and PowerPC code was included to SDK
-    - Some internal minor changes
+4.23           2005-06-29
+-------------------------
+- Small fixes in C++ code
 
 
-  4.04          2004-07-28
-  -------------------------
-    - More compatibility with some C++ compilers
+4.22           2005-06-10
+-------------------------
+- Small fixes
 
 
-  4.03          2004-06-18
-  -------------------------
-    - "Benchmark" command was added. It measures compressing
-      and decompressing speed and shows rating values.
-      Also it checks hardware errors.
+4.21           2005-06-08
+-------------------------
+- Interfaces for ANSI-C LZMA Decoder (LzmaDecode.c) were changed
+- New additional version of ANSI-C LZMA Decoder with zlib-like interface:
+    - LzmaStateDecode.h
+    - LzmaStateDecode.c
+    - LzmaStateTest.c
+- ANSI-C LZMA Decoder now can decompress files larger than 4 GB
 
 
-  4.02          2004-06-10
-  -------------------------
-    - C++ LZMA Encoder/Decoder code now is more portable
-      and it can be compiled by GCC on Linux.
+4.17           2005-04-18
+-------------------------
+- New example for RAM->RAM compressing/decompressing:
+  LZMA + BCJ (filter for x86 code):
+    - LzmaRam.h
+    - LzmaRam.cpp
+    - LzmaRamDecode.h
+    - LzmaRamDecode.c
+    - -f86 switch for lzma.exe
 
 
-  4.01          2004-02-15
-  -------------------------
-    - Some detection of data corruption was enabled.
-       LzmaDecode.c / RangeDecoderReadByte
-       .....
-       {
-         rd->ExtraBytes = 1;
-         return 0xFF;
-       }
+4.16           2005-03-29
+-------------------------
+- The bug was fixed in LzmaDecode.c (ANSI-C LZMA Decoder):
+   If _LZMA_OUT_READ was defined, and if encoded stream was corrupted,
+   decoder could access memory outside of allocated range.
+- Speed optimization of ANSI-C LZMA Decoder (now it's about 20% faster).
+  Old version of LZMA Decoder now is in file LzmaDecodeSize.c.
+  LzmaDecodeSize.c can provide slightly smaller code than LzmaDecode.c
+- Small speed optimization in LZMA C++ code
+- filter for SPARC's code was added
+- Simplified version of .7z ANSI-C Decoder was included
 
 
-  4.00          2004-02-13
-  -------------------------
-    - Original version of LZMA SDK
+4.06           2004-09-05
+-------------------------
+- The bug in v4.05 was fixed:
+    LZMA-Encoder didn't release output stream in some cases.
+
+
+4.05           2004-08-25
+-------------------------
+- Source code of filters for x86, IA-64, ARM, ARM-Thumb
+  and PowerPC code was included to SDK
+- Some internal minor changes
+
+
+4.04           2004-07-28
+-------------------------
+- More compatibility with some C++ compilers
+
+
+4.03           2004-06-18
+-------------------------
+- "Benchmark" command was added. It measures compressing
+  and decompressing speed and shows rating values.
+  Also it checks hardware errors.
+
+
+4.02           2004-06-10
+-------------------------
+- C++ LZMA Encoder/Decoder code now is more portable
+  and it can be compiled by GCC on Linux.
+
+
+4.01           2004-02-15
+-------------------------
+- Some detection of data corruption was enabled.
+    LzmaDecode.c / RangeDecoderReadByte
+    .....
+    {
+      rd->ExtraBytes = 1;
+      return 0xFF;
+    }
+
+
+4.00           2004-02-13
+-------------------------
+- Original version of LZMA SDK
 
 
 
 HISTORY of the LZMA
 -------------------
-  2001-2007:  Improvements to LZMA compressing/decompressing code,
-             keeping compatibility with original LZMA format
+  2001-2008:  Improvements to LZMA compressing/decompressing code,
+              keeping compatibility with original LZMA format
   1996-2001:  Development of LZMA compression format
 
   Some milestones:
index 5212e48..1e0f686 100644 (file)
@@ -17,14 +17,12 @@ fi
 
 BASENAME=`basename $1 .tar.bz2`
 TMPDIR=/tmp/tmp_lib_$BASENAME
-FILES="C/Compress/Lzma/LzmaDecode.h
-      C/Compress/Lzma/LzmaTypes.h
-      C/Compress/Lzma/LzmaDecode.c
+FILES="C/LzmaDec.h
+      C/Types.h
+      C/LzmaDec.c
       history.txt
-      LGPL.txt
       lzma.txt"
 
-
 mkdir -p $TMPDIR
 echo "Untar $1 -> $TMPDIR"
 tar -jxf $1 -C $TMPDIR
diff --git a/lib_generic/lzma/license.txt b/lib_generic/lzma/license.txt
new file mode 100644 (file)
index 0000000..48b9820
--- /dev/null
@@ -0,0 +1,3 @@
+               License
+
+LZMA SDK is placed in the public domain.
index 5f1a0c9..aa20f9d 100644 (file)
@@ -1,8 +1,6 @@
-LZMA SDK 4.57
+LZMA SDK 4.65
 -------------
 
-LZMA SDK   Copyright (C) 1999-2007 Igor Pavlov
-
 LZMA SDK provides the documentation, samples, header files, libraries,
 and tools you need to develop applications that use LZMA compression.
 
@@ -20,70 +18,7 @@ decompressing.
 LICENSE
 -------
 
-LZMA SDK is available under any of the following licenses:
-
-1) GNU Lesser General Public License (GNU LGPL)
-2) Common Public License (CPL)
-3) Simplified license for unmodified code (read SPECIAL EXCEPTION)
-4) Proprietary license
-
-It means that you can select one of these four options and follow rules of that license.
-
-
-1,2) GNU LGPL and CPL licenses are pretty similar and both these
-licenses are classified as
- - "Free software licenses" at http://www.gnu.org/
- - "OSI-approved" at http://www.opensource.org/
-
-
-3) SPECIAL EXCEPTION
-
-Igor Pavlov, as the author of this code, expressly permits you
-to statically or dynamically link your code (or bind by name)
-to the files from LZMA SDK without subjecting your linked
-code to the terms of the CPL or GNU LGPL.
-Any modifications or additions to files from LZMA SDK, however,
-are subject to the GNU LGPL or CPL terms.
-
-SPECIAL EXCEPTION allows you to use LZMA SDK in applications with closed code,
-while you keep LZMA SDK code unmodified.
-
-
-SPECIAL EXCEPTION #2: Igor Pavlov, as the author of this code, expressly permits
-you to use this code under the same terms and conditions contained in the License
-Agreement you have for any previous version of LZMA SDK developed by Igor Pavlov.
-
-SPECIAL EXCEPTION #2 allows owners of proprietary licenses to use latest version
-of LZMA SDK as update for previous versions.
-
-
-SPECIAL EXCEPTION #3: Igor Pavlov, as the author of this code, expressly permits
-you to use code of the following files:
-BranchTypes.h, LzmaTypes.h, LzmaTest.c, LzmaStateTest.c, LzmaAlone.cpp,
-LzmaAlone.cs, LzmaAlone.java
-as public domain code.
-
-
-4) Proprietary license
-
-LZMA SDK also can be available under a proprietary license which
-can include:
-
-1) Right to modify code without subjecting modified code to the
-terms of the CPL or GNU LGPL
-2) Technical support for code
-
-To request such proprietary license or any additional consultations,
-send email message from that page:
-http://www.7-zip.org/support.html
-
-
-You should have received a copy of the GNU Lesser General Public
-License along with this library; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-You should have received a copy of the Common Public License
-along with this library.
+LZMA SDK is written and placed in the public domain by Igor Pavlov.
 
 
 LZMA SDK Contents
@@ -91,87 +26,71 @@ LZMA SDK Contents
 
 LZMA SDK includes:
 
-  - C++ source code of LZMA compressing and decompressing
-  - ANSI-C compatible source code for LZMA decompressing
-  - C# source code for LZMA compressing and decompressing
-  - Java source code for LZMA compressing and decompressing
+  - ANSI-C/C++/C#/Java source code for LZMA compressing and decompressing
   - Compiled file->file LZMA compressing/decompressing program for Windows system
 
-ANSI-C LZMA decompression code was ported from original C++ sources to C.
-Also it was simplified and optimized for code size.
-But it is fully compatible with LZMA from 7-Zip.
-
 
 UNIX/Linux version
 ------------------
-To compile C++ version of file->file LZMA, go to directory
-C/7zip/Compress/LZMA_Alone
-and type "make" or "make clean all" to recompile all.
+To compile C++ version of file->file LZMA encoding, go to directory
+C++/7zip/Compress/LZMA_Alone
+and call make to recompile it:
+  make -f makefile.gcc clean all
 
 In some UNIX/Linux versions you must compile LZMA with static libraries.
-To compile with static libraries, change string in makefile
-LIB = -lm
-to string
+To compile with static libraries, you can use
 LIB = -lm -static
 
 
 Files
 ---------------------
-C       - C source code
-CPP     - CPP source code
-CS      - C# source code
-Java    - Java source code
-lzma.txt - LZMA SDK description (this file)
+lzma.txt     - LZMA SDK description (this file)
 7zFormat.txt - 7z Format description
-7zC.txt  - 7z ANSI-C Decoder description (this file)
+7zC.txt      - 7z ANSI-C Decoder description
 methods.txt  - Compression method IDs for .7z
-LGPL.txt - GNU Lesser General Public License
-CPL.html - Common Public License
-lzma.exe - Compiled file->file LZMA encoder/decoder for Windows
-history.txt - history of the LZMA SDK
+lzma.exe     - Compiled file->file LZMA encoder/decoder for Windows
+history.txt  - history of the LZMA SDK
 
 
 Source code structure
 ---------------------
 
-C  - C files
-    Compress - files related to compression/decompression
-      Lz     - files related to LZ (Lempel-Ziv) compression algorithm
-      Lzma   - ANSI-C compatible LZMA decompressor
+C/  - C files
+        7zCrc*.*   - CRC code
+        Alloc.*    - Memory allocation functions
+        Bra*.*     - Filters for x86, IA-64, ARM, ARM-Thumb, PowerPC and SPARC code
+        LzFind.*   - Match finder for LZ (LZMA) encoders
+        LzFindMt.* - Match finder for LZ (LZMA) encoders for multithreading encoding
+        LzHash.h   - Additional file for LZ match finder
+        LzmaDec.*  - LZMA decoding
+        LzmaEnc.*  - LZMA encoding
+        LzmaLib.*  - LZMA Library for DLL calling
+        Types.h    - Basic types for another .c files
+       Threads.*  - The code for multithreading.
 
-       LzmaDecode.h  - interface for LZMA decoding on ANSI-C
-       LzmaDecode.c      - LZMA decoding on ANSI-C (new fastest version)
-       LzmaDecodeSize.c  - LZMA decoding on ANSI-C (old size-optimized version)
-       LzmaTest.c        - test application that decodes LZMA encoded file
-       LzmaTypes.h       - basic types for LZMA Decoder
-       LzmaStateDecode.h - interface for LZMA decoding (State version)
-       LzmaStateDecode.c - LZMA decoding on ANSI-C (State version)
-       LzmaStateTest.c   - test application (State version)
+    LzmaLib  - LZMA Library (.DLL for Windows)
 
-      Branch      - Filters for x86, IA-64, ARM, ARM-Thumb, PowerPC and SPARC code
+    LzmaUtil - LZMA Utility (file->file LZMA encoder/decoder).
 
     Archive - files related to archiving
-      7z_C     - 7z ANSI-C Decoder
-
+      7z     - 7z ANSI-C Decoder
 
-CPP -- CPP files
+CPP/ -- CPP files
 
   Common  - common files for C++ projects
   Windows - common files for Windows related code
-  7zip   - files related to 7-Zip Project
+
+  7zip    - files related to 7-Zip Project
 
     Common   - common files for 7-Zip
 
     Compress - files related to compression/decompression
 
-      LZ     - files related to LZ (Lempel-Ziv) compression algorithm
-
-      Copy        - Copy coder
+      Copy         - Copy coder
       RangeCoder   - Range Coder (special code of compression/decompression)
-      LZMA        - LZMA compression/decompression on C++
+      LZMA         - LZMA compression/decompression on C++
       LZMA_Alone   - file->file LZMA compression/decompression
-
-      Branch      - Filters for x86, IA-64, ARM, ARM-Thumb, PowerPC and SPARC code
+      Branch       - Filters for x86, IA-64, ARM, ARM-Thumb, PowerPC and SPARC code
 
     Archive - files related to archiving
 
@@ -180,67 +99,61 @@ CPP -- CPP files
 
     Bundles    - Modules that are bundles of other modules
 
-      Alone7z          - 7zr.exe: Standalone version of 7z.exe that supports only 7z/LZMA/BCJ/BCJ2
-      Format7zR                - 7zr.dll: Reduced version of 7za.dll: extracting/compressing to 7z/LZMA/BCJ/BCJ2
-      Format7zExtractR - 7zxr.dll: Reduced version of 7zxa.dll: extracting from 7z/LZMA/BCJ/BCJ2.
+      Alone7z           - 7zr.exe: Standalone version of 7z.exe that supports only 7z/LZMA/BCJ/BCJ2
+      Format7zR         - 7zr.dll: Reduced version of 7za.dll: extracting/compressing to 7z/LZMA/BCJ/BCJ2
+      Format7zExtractR  - 7zxr.dll: Reduced version of 7zxa.dll: extracting from 7z/LZMA/BCJ/BCJ2.
 
-    UI       - User Interface files
+    UI        - User Interface files
 
-      Client7z - Test application for 7za.dll, 7zr.dll, 7zxr.dll
+      Client7z - Test application for 7za.dll,  7zr.dll, 7zxr.dll
       Common   - Common UI files
       Console  - Code for console archiver
 
 
 
-CS - C# files
+CS/ - C# files
   7zip
     Common   - some common files for 7-Zip
     Compress - files related to compression/decompression
       LZ     - files related to LZ (Lempel-Ziv) compression algorithm
-      LZMA        - LZMA compression/decompression
+      LZMA         - LZMA compression/decompression
       LzmaAlone    - file->file LZMA compression/decompression
       RangeCoder   - Range Coder (special code of compression/decompression)
 
-Java  - Java files
+Java/  - Java files
   SevenZip
     Compression    - files related to compression/decompression
-      LZ          - files related to LZ (Lempel-Ziv) compression algorithm
-      LZMA        - LZMA compression/decompression
+      LZ           - files related to LZ (Lempel-Ziv) compression algorithm
+      LZMA         - LZMA compression/decompression
       RangeCoder   - Range Coder (special code of compression/decompression)
 
-C/C++ source code of LZMA SDK is part of 7-Zip project.
-
-You can find ANSI-C LZMA decompressing code at folder
-  C/7zip/Compress/Lzma
-7-Zip doesn't use that ANSI-C LZMA code and that code was developed
-specially for this SDK. And files from C/7zip/Compress/Lzma do not need
-files from other directories of SDK for compiling.
 
+C/C++ source code of LZMA SDK is part of 7-Zip project.
 7-Zip source code can be downloaded from 7-Zip's SourceForge page:
 
   http://sourceforge.net/projects/sevenzip/
 
 
+
 LZMA features
 -------------
   - Variable dictionary size (up to 1 GB)
-  - Estimated compressing speed: about 1 MB/s on 1 GHz CPU
+  - Estimated compressing speed: about 2 MB/s on 2 GHz CPU
   - Estimated decompressing speed:
-      - 8-12 MB/s on 1 GHz Intel Pentium 3 or AMD Athlon
-      - 500-1000 KB/s on 100 MHz ARM, MIPS, PowerPC or other simple RISC
-  - Small memory requirements for decompressing (8-32 KB + DictionarySize)
-  - Small code size for decompressing: 2-8 KB (depending from
-    speed optimizations)
+      - 20-30 MB/s on 2 GHz Core 2 or AMD Athlon 64
+      - 1-2 MB/s on 200 MHz ARM, MIPS, PowerPC or other simple RISC
+  - Small memory requirements for decompressing (16 KB + DictionarySize)
+  - Small code size for decompressing: 5-8 KB
 
 LZMA decoder uses only integer operations and can be
 implemented in any modern 32-bit CPU (or on 16-bit CPU with some conditions).
 
-Some critical operations that affect to speed of LZMA decompression:
+Some critical operations that affect the speed of LZMA decompression:
   1) 32*16 bit integer multiply
   2) Misspredicted branches (penalty mostly depends from pipeline length)
   3) 32-bit shift and arithmetic operations
 
-Speed of LZMA decompressing mostly depends from CPU speed.
+The speed of LZMA decompressing mostly depends from CPU speed.
 Memory speed has no big meaning. But if your CPU has small data cache,
 overall weight of memory speed will slightly increase.
 
@@ -251,7 +164,7 @@ How To Use
 Using LZMA encoder/decoder executable
 --------------------------------------
 
-Usage: LZMA <e|d> inputFile outputFile [<switches>...]
+Usage:  LZMA <e|d> inputFile outputFile [<switches>...]
 
   e: encode file
 
@@ -260,11 +173,11 @@ Usage:    LZMA <e|d> inputFile outputFile [<switches>...]
   b: Benchmark. There are two tests: compressing and decompressing
      with LZMA method. Benchmark shows rating in MIPS (million
      instructions per second). Rating value is calculated from
-     measured speed and it is normalized with AMD Athlon 64 X2 CPU
-     results. Also Benchmark checks possible hardware errors (RAM
+     measured speed and it is normalized with Intel's Core 2 results.
+     Also Benchmark checks possible hardware errors (RAM
      errors in most cases). Benchmark uses these settings:
-     (-a1, -d21, -fb32, -mfbt4). You can change only -d. Also you
-     can change number of iterations. Example for 30 iterations:
+     (-a1, -d21, -fb32, -mfbt4). You can change only -d parameter.
+     Also you can change the number of iterations. Example for 30 iterations:
        LZMA b 30
      Default number of iterations is 10.
 
@@ -272,52 +185,52 @@ Usage:    LZMA <e|d> inputFile outputFile [<switches>...]
 
 
   -a{N}:  set compression mode 0 = fast, 1 = normal
-         default: 1 (normal)
+          default: 1 (normal)
 
   d{N}:   Sets Dictionary size - [0, 30], default: 23 (8MB)
-         The maximum value for dictionary size is 1 GB = 2^30 bytes.
-         Dictionary size is calculated as DictionarySize = 2^N bytes.
-         For decompressing file compressed by LZMA method with dictionary
-         size D = 2^N you need about D bytes of memory (RAM).
+          The maximum value for dictionary size is 1 GB = 2^30 bytes.
+          Dictionary size is calculated as DictionarySize = 2^N bytes.
+          For decompressing file compressed by LZMA method with dictionary
+          size D = 2^N you need about D bytes of memory (RAM).
 
   -fb{N}: set number of fast bytes - [5, 273], default: 128
-         Usually big number gives a little bit better compression ratio
-         and slower compression process.
+          Usually big number gives a little bit better compression ratio
+          and slower compression process.
 
   -lc{N}: set number of literal context bits - [0, 8], default: 3
-         Sometimes lc=4 gives gain for big files.
+          Sometimes lc=4 gives gain for big files.
 
   -lp{N}: set number of literal pos bits - [0, 4], default: 0
-         lp switch is intended for periodical data when period is
-         equal 2^N. For example, for 32-bit (4 bytes)
-         periodical data you can use lp=2. Often it's better to set lc0,
-         if you change lp switch.
+          lp switch is intended for periodical data when period is
+          equal 2^N. For example, for 32-bit (4 bytes)
+          periodical data you can use lp=2. Often it's better to set lc0,
+          if you change lp switch.
 
   -pb{N}: set number of pos bits - [0, 4], default: 2
-         pb switch is intended for periodical data
-         when period is equal 2^N.
+          pb switch is intended for periodical data
+          when period is equal 2^N.
 
   -mf{MF_ID}: set Match Finder. Default: bt4.
-             Algorithms from hc* group doesn't provide good compression
-             ratio, but they often works pretty fast in combination with
-             fast mode (-a0).
+              Algorithms from hc* group doesn't provide good compression
+              ratio, but they often works pretty fast in combination with
+              fast mode (-a0).
 
-             Memory requirements depend from dictionary size
-             (parameter "d" in table below).
+              Memory requirements depend from dictionary size
+              (parameter "d" in table below).
 
-              MF_ID     Memory                   Description
+               MF_ID     Memory                   Description
 
-               bt2    d *  9.5 + 4MB  Binary Tree with 2 bytes hashing.
-               bt3    d * 11.5 + 4MB  Binary Tree with 3 bytes hashing.
-               bt4    d * 11.5 + 4MB  Binary Tree with 4 bytes hashing.
-               hc4    d *  7.5 + 4MB  Hash Chain with 4 bytes hashing.
+                bt2    d *  9.5 + 4MB  Binary Tree with 2 bytes hashing.
+                bt3    d * 11.5 + 4MB  Binary Tree with 3 bytes hashing.
+                bt4    d * 11.5 + 4MB  Binary Tree with 4 bytes hashing.
+                hc4    d *  7.5 + 4MB  Hash Chain with 4 bytes hashing.
 
   -eos:   write End Of Stream marker. By default LZMA doesn't write
-         eos marker, since LZMA decoder knows uncompressed size
-         stored in .lzma file header.
+          eos marker, since LZMA decoder knows uncompressed size
+          stored in .lzma file header.
 
-  -si:   Read data from stdin (it will write End Of Stream marker).
-  -so:   Write data to stdout
+  -si:    Read data from stdin (it will write End Of Stream marker).
+  -so:    Write data to stdout
 
 
 Examples:
@@ -345,32 +258,29 @@ Compression ratio hints
 Recommendations
 ---------------
 
-To increase compression ratio for LZMA compressing it's desirable
+To increase the compression ratio for LZMA compressing it's desirable
 to have aligned data (if it's possible) and also it's desirable to locate
 data in such order, where code is grouped in one place and data is
 grouped in other place (it's better than such mixing: code, data, code,
 data, ...).
 
 
-Using Filters
--------------
-You can increase compression ratio for some data types, using
+Filters
+-------
+You can increase the compression ratio for some data types, using
 special filters before compressing. For example, it's possible to
-increase compression ratio on 5-10% for code for those CPU ISAs:
+increase the compression ratio on 5-10% for code for those CPU ISAs:
 x86, IA-64, ARM, ARM-Thumb, PowerPC, SPARC.
 
-You can find C/C++ source code of such filters in folder "7zip/Compress/Branch"
+You can find C source code of such filters in C/Bra*.* files
 
-You can check compression ratio gain of these filters with such
+You can check the compression ratio gain of these filters with such
 7-Zip commands (example for ARM code):
 No filter:
   7z a a1.7z a.bin -m0=lzma
 
 With filter for little-endian ARM code:
-  7z a a2.7z a.bin -m0=bc_arm -m1=lzma
-
-With filter for big-endian ARM code (using additional Swap4 filter):
-  7z a a3.7z a.bin -m0=swap4 -m1=bc_arm -m2=lzma
+  7z a a2.7z a.bin -m0=arm -m1=lzma
 
 It works in such manner:
 Compressing    = Filter_encoding + LZMA_encoding
@@ -383,8 +293,7 @@ since compression ratio with filtering is higher.
 
 These filters convert CALL (calling procedure) instructions
 from relative offsets to absolute addresses, so such data becomes more
-compressible. Source code of these CALL filters is pretty simple
-(about 20 lines of C++), so you can convert it from C++ version yourself.
+compressible.
 
 For some ISAs (for example, for MIPS) it's impossible to get gain from such filter.
 
@@ -392,272 +301,294 @@ For some ISAs (for example, for MIPS) it's impossible to get gain from such filt
 LZMA compressed file format
 ---------------------------
 Offset Size Description
-  0    1   Special LZMA properties for compressed data
-  1    4   Dictionary size (little endian)
-  5    8   Uncompressed size (little endian). -1 means unknown size
- 13        Compressed data
+  0     1   Special LZMA properties (lc,lp, pb in encoded form)
+  1     4   Dictionary size (little endian)
+  5     8   Uncompressed size (little endian). -1 means unknown size
+ 13         Compressed data
 
 
 ANSI-C LZMA Decoder
 ~~~~~~~~~~~~~~~~~~~
 
-To compile ANSI-C LZMA Decoder you can use one of the following files sets:
-1) LzmaDecode.h + LzmaDecode.c + LzmaTest.c  (fastest version)
-2) LzmaDecode.h + LzmaDecodeSize.c + LzmaTest.c  (old size-optimized version)
-3) LzmaStateDecode.h + LzmaStateDecode.c + LzmaStateTest.c  (zlib-like interface)
+Please note that interfaces for ANSI-C code were changed in LZMA SDK 4.58.
+If you want to use old interfaces you can download previous version of LZMA SDK
+from sourceforge.net site.
+
+To use ANSI-C LZMA Decoder you need the following files:
+1) LzmaDec.h + LzmaDec.c + Types.h
+LzmaUtil/LzmaUtil.c is example application that uses these files.
 
 
 Memory requirements for LZMA decoding
 -------------------------------------
 
-LZMA decoder doesn't allocate memory itself, so you must
-allocate memory and send it to LZMA.
-
 Stack usage of LZMA decoding function for local variables is not
-larger than 200 bytes.
+larger than 200-400 bytes.
+
+LZMA Decoder uses dictionary buffer and internal state structure.
+Internal state structure consumes
+  state_size = (4 + (1.5 << (lc + lp))) KB
+by default (lc=3, lp=0), state_size = 16 KB.
+
 
 How To decompress data
 ----------------------
 
-LZMA Decoder (ANSI-C version) now supports 5 interfaces:
+LZMA Decoder (ANSI-C version) now supports 2 interfaces:
 1) Single-call Decompressing
-2) Single-call Decompressing with input stream callback
-3) Multi-call Decompressing with output buffer
-4) Multi-call Decompressing with input callback and output buffer
-5) Multi-call State Decompressing (zlib-like interface)
-
-Variant-5 is similar to Variant-4, but Variant-5 doesn't use callback functions.
-
-Decompressing steps
--------------------
-
-1) read LZMA properties (5 bytes):
-   unsigned char properties[LZMA_PROPERTIES_SIZE];
-
-2) read uncompressed size (8 bytes, little-endian)
+2) Multi-call State Decompressing (zlib-like interface)
 
-3) Decode properties:
+You must use external allocator:
+Example:
+void *SzAlloc(void *p, size_t size) { p = p; return malloc(size); }
+void SzFree(void *p, void *address) { p = p; free(address); }
+ISzAlloc alloc = { SzAlloc, SzFree };
 
-  CLzmaDecoderState state;  /* it's 24-140 bytes structure, if int is 32-bit */
+You can use p = p; operator to disable compiler warnings.
 
-  if (LzmaDecodeProperties(&state.Properties, properties, LZMA_PROPERTIES_SIZE) != LZMA_RESULT_OK)
-    return PrintError(rs, "Incorrect stream properties");
 
-4) Allocate memory block for internal Structures:
-
-  state.Probs = (CProb *)malloc(LzmaGetNumProbs(&state.Properties) * sizeof(CProb));
-  if (state.Probs == 0)
-    return PrintError(rs, kCantAllocateMessage);
-
-  LZMA decoder uses array of CProb variables as internal structure.
-  By default, CProb is unsigned_short. But you can define _LZMA_PROB32 to make
-  it unsigned_int. It can increase speed on some 32-bit CPUs, but memory
-  usage will be doubled in that case.
-
-
-5) Main Decompressing
-
-You must use one of the following interfaces:
-
-5.1 Single-call Decompressing
------------------------------
+Single-call Decompressing
+-------------------------
 When to use: RAM->RAM decompressing
-Compile files: LzmaDecode.h, LzmaDecode.c
+Compile files: LzmaDec.h + LzmaDec.c + Types.h
 Compile defines: no defines
 Memory Requirements:
   - Input buffer: compressed size
   - Output buffer: uncompressed size
-  - LZMA Internal Structures (~16 KB for default settings)
+  - LZMA Internal Structures: state_size (16 KB for default settings)
 
 Interface:
-  int res = LzmaDecode(&state,
-      inStream, compressedSize, &inProcessed,
-      outStream, outSize, &outProcessed);
+  int LzmaDecode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen,
+      const Byte *propData, unsigned propSize, ELzmaFinishMode finishMode,
+      ELzmaStatus *status, ISzAlloc *alloc);
+  In:
+    dest     - output data
+    destLen  - output data size
+    src      - input data
+    srcLen   - input data size
+    propData - LZMA properties  (5 bytes)
+    propSize - size of propData buffer (5 bytes)
+    finishMode - It has meaning only if the decoding reaches output limit (*destLen).
+        LZMA_FINISH_ANY - Decode just destLen bytes.
+        LZMA_FINISH_END - Stream must be finished after (*destLen).
+                           You can use LZMA_FINISH_END, when you know that
+                           current output buffer covers last bytes of stream.
+    alloc    - Memory allocator.
+
+  Out:
+    destLen  - processed output size
+    srcLen   - processed input size
+
+  Output:
+    SZ_OK
+      status:
+        LZMA_STATUS_FINISHED_WITH_MARK
+        LZMA_STATUS_NOT_FINISHED
+        LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK
+    SZ_ERROR_DATA - Data error
+    SZ_ERROR_MEM  - Memory allocation error
+    SZ_ERROR_UNSUPPORTED - Unsupported properties
+    SZ_ERROR_INPUT_EOF - It needs more bytes in input buffer (src).
+
+  If LZMA decoder sees end_marker before reaching output limit, it returns OK result,
+  and output value of destLen will be less than output buffer size limit.
+
+  You can use multiple checks to test data integrity after full decompression:
+    1) Check Result and "status" variable.
+    2) Check that output(destLen) = uncompressedSize, if you know real uncompressedSize.
+    3) Check that output(srcLen) = compressedSize, if you know real compressedSize.
+       You must use correct finish mode in that case. */
+
+
+Multi-call State Decompressing (zlib-like interface)
+----------------------------------------------------
 
+When to use: file->file decompressing
+Compile files: LzmaDec.h + LzmaDec.c + Types.h
 
-5.2 Single-call Decompressing with input stream callback
---------------------------------------------------------
-When to use: File->RAM or Flash->RAM decompressing.
-Compile files: LzmaDecode.h, LzmaDecode.c
-Compile defines: _LZMA_IN_CB
 Memory Requirements:
-  - Buffer for input stream: any size (for example, 16 KB)
-  - Output buffer: uncompressed size
-  - LZMA Internal Structures (~16 KB for default settings)
+ - Buffer for input stream: any size (for example, 16 KB)
+ - Buffer for output stream: any size (for example, 16 KB)
+ - LZMA Internal Structures: state_size (16 KB for default settings)
+ - LZMA dictionary (dictionary size is encoded in LZMA properties header)
 
-Interface:
-  typedef struct _CBuffer
-  {
-    ILzmaInCallback InCallback;
-    FILE *File;
-    unsigned char Buffer[kInBufferSize];
-  } CBuffer;
+1) read LZMA properties (5 bytes) and uncompressed size (8 bytes, little-endian) to header:
+   unsigned char header[LZMA_PROPS_SIZE + 8];
+   ReadFile(inFile, header, sizeof(header)
 
-  int LzmaReadCompressed(void *object, const unsigned char **buffer, SizeT *size)
+2) Allocate CLzmaDec structures (state + dictionary) using LZMA properties
+
+  CLzmaDec state;
+  LzmaDec_Constr(&state);
+  res = LzmaDec_Allocate(&state, header, LZMA_PROPS_SIZE, &g_Alloc);
+  if (res != SZ_OK)
+    return res;
+
+3) Init LzmaDec structure before any new LZMA stream. And call LzmaDec_DecodeToBuf in loop
+
+  LzmaDec_Init(&state);
+  for (;;)
   {
-    CBuffer *bo = (CBuffer *)object;
-    *buffer = bo->Buffer;
-    *size = MyReadFile(bo->File, bo->Buffer, kInBufferSize);
-    return LZMA_RESULT_OK;
+    ...
+    int res = LzmaDec_DecodeToBuf(CLzmaDec *p, Byte *dest, SizeT *destLen,
+       const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode);
+    ...
   }
 
-  CBuffer g_InBuffer;
 
-  g_InBuffer.File = inFile;
-  g_InBuffer.InCallback.Read = LzmaReadCompressed;
-  int res = LzmaDecode(&state,
-      &g_InBuffer.InCallback,
-      outStream, outSize, &outProcessed);
+4) Free all allocated structures
+  LzmaDec_Free(&state, &g_Alloc);
+
+For full code example, look at C/LzmaUtil/LzmaUtil.c code.
+
+
+How To compress data
+--------------------
 
+Compile files: LzmaEnc.h + LzmaEnc.c + Types.h +
+LzFind.c + LzFind.h + LzFindMt.c + LzFindMt.h + LzHash.h
 
-5.3 Multi-call decompressing with output buffer
------------------------------------------------
-When to use: RAM->File decompressing
-Compile files: LzmaDecode.h, LzmaDecode.c
-Compile defines: _LZMA_OUT_READ
 Memory Requirements:
- - Input buffer: compressed size
- - Buffer for output stream: any size (for example, 16 KB)
- - LZMA Internal Structures (~16 KB for default settings)
- - LZMA dictionary (dictionary size is encoded in stream properties)
+  - (dictSize * 11.5 + 6 MB) + state_size
 
-Interface:
+Lzma Encoder can use two memory allocators:
+1) alloc - for small arrays.
+2) allocBig - for big arrays.
 
-  state.Dictionary = (unsigned char *)malloc(state.Properties.DictionarySize);
+For example, you can use Large RAM Pages (2 MB) in allocBig allocator for
+better compression speed. Note that Windows has bad implementation for
+Large RAM Pages.
+It's OK to use same allocator for alloc and allocBig.
 
-  LzmaDecoderInit(&state);
-  do
-  {
-    LzmaDecode(&state,
-      inBuffer, inAvail, &inProcessed,
-      g_OutBuffer, outAvail, &outProcessed);
-    inAvail -= inProcessed;
-    inBuffer += inProcessed;
-  }
-  while you need more bytes
 
-  see LzmaTest.c for more details.
+Single-call Compression with callbacks
+--------------------------------------
 
+Check C/LzmaUtil/LzmaUtil.c as example,
 
-5.4 Multi-call decompressing with input callback and output buffer
-------------------------------------------------------------------
-When to use: File->File decompressing
-Compile files: LzmaDecode.h, LzmaDecode.c
-Compile defines: _LZMA_IN_CB, _LZMA_OUT_READ
-Memory Requirements:
- - Buffer for input stream: any size (for example, 16 KB)
- - Buffer for output stream: any size (for example, 16 KB)
- - LZMA Internal Structures (~16 KB for default settings)
- - LZMA dictionary (dictionary size is encoded in stream properties)
+When to use: file->file decompressing
 
-Interface:
+1) you must implement callback structures for interfaces:
+ISeqInStream
+ISeqOutStream
+ICompressProgress
+ISzAlloc
 
-  state.Dictionary = (unsigned char *)malloc(state.Properties.DictionarySize);
+static void *SzAlloc(void *p, size_t size) { p = p; return MyAlloc(size); }
+static void SzFree(void *p, void *address) {  p = p; MyFree(address); }
+static ISzAlloc g_Alloc = { SzAlloc, SzFree };
 
-  LzmaDecoderInit(&state);
-  do
-  {
-    LzmaDecode(&state,
-      &bo.InCallback,
-      g_OutBuffer, outAvail, &outProcessed);
-  }
-  while you need more bytes
+  CFileSeqInStream inStream;
+  CFileSeqOutStream outStream;
 
-  see LzmaTest.c for more details:
+  inStream.funcTable.Read = MyRead;
+  inStream.file = inFile;
+  outStream.funcTable.Write = MyWrite;
+  outStream.file = outFile;
 
 
-5.5 Multi-call State Decompressing (zlib-like interface)
-------------------------------------------------------------------
-When to use: file->file decompressing
-Compile files: LzmaStateDecode.h, LzmaStateDecode.c
-Compile defines:
-Memory Requirements:
- - Buffer for input stream: any size (for example, 16 KB)
- - Buffer for output stream: any size (for example, 16 KB)
- - LZMA Internal Structures (~16 KB for default settings)
- - LZMA dictionary (dictionary size is encoded in stream properties)
+2) Create CLzmaEncHandle object;
 
-Interface:
+  CLzmaEncHandle enc;
 
-  state.Dictionary = (unsigned char *)malloc(state.Properties.DictionarySize);
+  enc = LzmaEnc_Create(&g_Alloc);
+  if (enc == 0)
+    return SZ_ERROR_MEM;
 
 
-  LzmaDecoderInit(&state);
-  do
-  {
-    res = LzmaDecode(&state,
-      inBuffer, inAvail, &inProcessed,
-      g_OutBuffer, outAvail, &outProcessed,
-      finishDecoding);
-    inAvail -= inProcessed;
-    inBuffer += inProcessed;
-  }
-  while you need more bytes
+3) initialize CLzmaEncProps properties;
 
-  see LzmaStateTest.c for more details:
+  LzmaEncProps_Init(&props);
 
+  Then you can change some properties in that structure.
 
-6) Free all allocated blocks
+4) Send LZMA properties to LZMA Encoder
 
+  res = LzmaEnc_SetProps(enc, &props);
 
-Note
-----
-LzmaDecodeSize.c is size-optimized version of LzmaDecode.c.
-But compiled code of LzmaDecodeSize.c can be larger than
-compiled code of LzmaDecode.c. So it's better to use
-LzmaDecode.c in most cases.
+5) Write encoded properties to header
 
+    Byte header[LZMA_PROPS_SIZE + 8];
+    size_t headerSize = LZMA_PROPS_SIZE;
+    UInt64 fileSize;
+    int i;
 
-EXIT codes
------------
+    res = LzmaEnc_WriteProperties(enc, header, &headerSize);
+    fileSize = MyGetFileLength(inFile);
+    for (i = 0; i < 8; i++)
+      header[headerSize++] = (Byte)(fileSize >> (8 * i));
+    MyWriteFileAndCheck(outFile, header, headerSize)
 
-LZMA decoder can return one of the following codes:
+6) Call encoding function:
+      res = LzmaEnc_Encode(enc, &outStream.funcTable, &inStream.funcTable,
+        NULL, &g_Alloc, &g_Alloc);
 
-#define LZMA_RESULT_OK 0
-#define LZMA_RESULT_DATA_ERROR 1
+7) Destroy LZMA Encoder Object
+  LzmaEnc_Destroy(enc, &g_Alloc, &g_Alloc);
 
-If you use callback function for input data and you return some
-error code, LZMA Decoder also returns that code.
 
+If callback function return some error code, LzmaEnc_Encode also returns that code.
 
 
-LZMA Defines
-------------
+Single-call RAM->RAM Compression
+--------------------------------
 
-_LZMA_IN_CB    - Use callback for input data
+Single-call RAM->RAM Compression is similar to Compression with callbacks,
+but you provide pointers to buffers instead of pointers to stream callbacks:
 
-_LZMA_OUT_READ - Use read function for output data
+HRes LzmaEncode(Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen,
+    CLzmaEncProps *props, Byte *propsEncoded, SizeT *propsSize, int writeEndMark,
+    ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig);
 
-_LZMA_LOC_OPT  - Enable local speed optimizations inside code.
-                _LZMA_LOC_OPT is only for LzmaDecodeSize.c (size-optimized version).
-                _LZMA_LOC_OPT doesn't affect LzmaDecode.c (speed-optimized version)
-                and LzmaStateDecode.c
+Return code:
+  SZ_OK               - OK
+  SZ_ERROR_MEM        - Memory allocation error
+  SZ_ERROR_PARAM      - Incorrect paramater
+  SZ_ERROR_OUTPUT_EOF - output buffer overflow
+  SZ_ERROR_THREAD     - errors in multithreading functions (only for Mt version)
 
-_LZMA_PROB32   - It can increase speed on some 32-bit CPUs,
-                but memory usage will be doubled in that case
 
-_LZMA_UINT32_IS_ULONG  - Define it if int is 16-bit on your compiler
-                        and long is 32-bit.
 
-_LZMA_SYSTEM_SIZE_T  - Define it if you want to use system's size_t.
-                      You can use it to enable 64-bit sizes supporting
+LZMA Defines
+------------
+
+_LZMA_SIZE_OPT - Enable some optimizations in LZMA Decoder to get smaller executable code.
+
+_LZMA_PROB32   - It can increase the speed on some 32-bit CPUs, but memory usage for
+                 some structures will be doubled in that case.
 
+_LZMA_UINT32_IS_ULONG  - Define it if int is 16-bit on your compiler and long is 32-bit.
+
+_LZMA_NO_SYSTEM_SIZE_T  - Define it if you don't want to use size_t type.
 
 
 C++ LZMA Encoder/Decoder
 ~~~~~~~~~~~~~~~~~~~~~~~~
 C++ LZMA code use COM-like interfaces. So if you want to use it,
 you can study basics of COM/OLE.
+C++ LZMA code is just wrapper over ANSI-C code.
 
-By default, LZMA Encoder contains all Match Finders.
-But for compressing it's enough to have just one of them.
-So for reducing size of compressing code you can define:
-  #define COMPRESS_MF_BT
-  #define COMPRESS_MF_BT4
-and it will use only bt4 match finder.
 
+C++ Notes
+~~~~~~~~~~~~~~~~~~~~~~~~
+If you use some C++ code folders in 7-Zip (for example, C++ code for .7z handling),
+you must check that you correctly work with "new" operator.
+7-Zip can be compiled with MSVC 6.0 that doesn't throw "exception" from "new" operator.
+So 7-Zip uses "CPP\Common\NewHandler.cpp" that redefines "new" operator:
+operator new(size_t size)
+{
+  void *p = ::malloc(size);
+  if (p == 0)
+    throw CNewException();
+  return p;
+}
+If you use MSCV that throws exception for "new" operator, you can compile without
+"NewHandler.cpp". So standard exception will be used. Actually some code of
+7-Zip catches any exception in internal code and converts it to HRESULT code.
+So you don't need to catch CNewException, if you call COM interfaces of 7-Zip.
 
 ---
 
 http://www.7-zip.org
+http://www.7-zip.org/sdk.html
 http://www.7-zip.org/support.html
index 9150510..81a09e3 100644 (file)
    and to fit the cifs vfs by
    Steve French sfrench@us.ibm.com */
 
+#include "compiler.h"
+
 #ifndef USE_HOSTCC
 #include <common.h>
-#include <linux/string.h>
-#else
-#include <string.h>
-#endif /* USE_HOSTCC */
 #include <watchdog.h>
-#include <linux/types.h>
+#endif /* USE_HOSTCC */
 #include <u-boot/md5.h>
 
 static void
similarity index 96%
rename from i386_config.mk
rename to lib_i386/config.mk
index 9e6d37d..5fe36d5 100644 (file)
@@ -21,4 +21,6 @@
 # MA 02111-1307 USA
 #
 
+CROSS_COMPILE ?= i386-linux-
+
 PLATFORM_CPPFLAGS += -DCONFIG_I386 -D__I386__
similarity index 97%
rename from m68k_config.mk
rename to lib_m68k/config.mk
index 12bd27c..f41d1b3 100644 (file)
@@ -21,5 +21,7 @@
 # MA 02111-1307 USA
 #
 
+CROSS_COMPILE ?= m68k-elf-
+
 PLATFORM_CPPFLAGS += -DCONFIG_M68K -D__M68K__
 PLATFORM_LDFLAGS  += -n
similarity index 97%
rename from microblaze_config.mk
rename to lib_microblaze/config.mk
index e44c79e..68e7e21 100644 (file)
@@ -24,4 +24,6 @@
 # MA 02111-1307 USA
 #
 
+CROSS_COMPILE ?= mb-
+
 PLATFORM_CPPFLAGS += -ffixed-r31 -D__microblaze__
similarity index 98%
rename from mips_config.mk
rename to lib_mips/config.mk
index 05eb05d..c785677 100644 (file)
@@ -21,6 +21,8 @@
 # MA 02111-1307 USA
 #
 
+CROSS_COMPILE ?= mips_4KC-
+
 PLATFORM_CPPFLAGS += -DCONFIG_MIPS -D__MIPS__
 
 #
similarity index 97%
rename from nios_config.mk
rename to lib_nios/config.mk
index 1cf0f32..3ed7170 100644 (file)
@@ -22,4 +22,6 @@
 # MA 02111-1307 USA
 #
 
+CROSS_COMPILE ?= nios-elf-
+
 PLATFORM_CPPFLAGS += -m32 -DCONFIG_NIOS -D__NIOS__ -ffixed-g7 -gstabs
similarity index 97%
rename from nios2_config.mk
rename to lib_nios2/config.mk
index 3f23b56..59931c2 100644 (file)
@@ -22,5 +22,7 @@
 # MA 02111-1307 USA
 #
 
+CROSS_COMPILE ?= nios2-elf-
+
 PLATFORM_CPPFLAGS += -DCONFIG_NIOS2 -D__NIOS2__
 PLATFORM_CPPFLAGS += -ffixed-r15 -G0
similarity index 98%
rename from ppc_config.mk
rename to lib_ppc/config.mk
index c95b3b1..d91ef7f 100644 (file)
@@ -21,6 +21,8 @@
 # MA 02111-1307 USA
 #
 
+CROSS_COMPILE ?= ppc_8xx-
+
 PLATFORM_CPPFLAGS += -DCONFIG_PPC -D__powerpc__
 PLATFORM_LDFLAGS  += -n
 
similarity index 97%
rename from sh_config.mk
rename to lib_sh/config.mk
index 407e076..67d7e9e 100644 (file)
@@ -21,6 +21,8 @@
 # MA 02111-1307 USA
 #
 
+CROSS_COMPILE ?= sh4-linux-
+
 PLATFORM_CPPFLAGS += -DCONFIG_SH -D__SH__
 PLATFORM_LDFLAGS += -e $(TEXT_BASE) --defsym reloc_dst=$(TEXT_BASE)
 
similarity index 96%
rename from sparc_config.mk
rename to lib_sparc/config.mk
index 87f745f..07b528c 100644 (file)
@@ -21,4 +21,6 @@
 # MA 02111-1307 USA
 #
 
+CROSS_COMPILE ?= sparc-elf-
+
 PLATFORM_CPPFLAGS += -DCONFIG_SPARC -D__sparc__
index 931f04b..822f82f 100644 (file)
@@ -73,7 +73,7 @@ $(obj)gpio.c:
 
 $(obj)ndfc.c:
        @rm -f $(obj)ndfc.c
-       ln -s $(SRCTREE)/cpu/ppc4xx/ndfc.c $(obj)ndfc.c
+       ln -s $(SRCTREE)/drivers/mtd/nand/ndfc.c $(obj)ndfc.c
 
 $(obj)resetvec.S:
        @rm -f $(obj)resetvec.S
index e1c1467..2932927 100644 (file)
@@ -59,7 +59,7 @@ $(nandobj)u-boot-spl: $(OBJS)
 # from cpu directory
 $(obj)ndfc.c:
        @rm -f $(obj)ndfc.c
-       ln -s $(SRCTREE)/cpu/ppc4xx/ndfc.c $(obj)ndfc.c
+       ln -s $(SRCTREE)/drivers/mtd/nand/ndfc.c $(obj)ndfc.c
 
 $(obj)resetvec.S:
        @rm -f $(obj)resetvec.S
index fb86752..84b1454 100644 (file)
@@ -64,7 +64,7 @@ $(nandobj)u-boot-spl: $(OBJS)
 # from cpu directory
 $(obj)ndfc.c:
        @rm -f $(obj)ndfc.c
-       ln -s $(SRCTREE)/cpu/ppc4xx/ndfc.c $(obj)ndfc.c
+       ln -s $(SRCTREE)/drivers/mtd/nand/ndfc.c $(obj)ndfc.c
 
 $(obj)resetvec.S:
        @rm -f $(obj)resetvec.S
index cedc8e0..8a062fe 100644 (file)
@@ -71,7 +71,7 @@ $(obj)ecc.h:
 
 $(obj)ndfc.c:
        @rm -f $(obj)ndfc.c
-       ln -s $(SRCTREE)/cpu/ppc4xx/ndfc.c $(obj)ndfc.c
+       ln -s $(SRCTREE)/drivers/mtd/nand/ndfc.c $(obj)ndfc.c
 
 $(obj)resetvec.S:
        @rm -f $(obj)resetvec.S
index fba0322..462005f 100644 (file)
@@ -63,7 +63,7 @@ $(obj)denali_data_eye.c:
 
 $(obj)ndfc.c:
        @rm -f $(obj)ndfc.c
-       ln -s $(SRCTREE)/cpu/ppc4xx/ndfc.c $(obj)ndfc.c
+       ln -s $(SRCTREE)/drivers/mtd/nand/ndfc.c $(obj)ndfc.c
 
 $(obj)resetvec.S:
        @rm -f $(obj)resetvec.S
index e8dd8c8..47228d2 100644 (file)
@@ -1,15 +1,4 @@
-#include <stdio.h>
-#include <stdlib.h>
-
-#if defined(__linux__)
-#include <stdint.h>
-#else
-#ifdef __CYGWIN__
-#include "elf.h"
-#else
-#include <inttypes.h>
-#endif
-#endif
+#include "compiler.h"
 
 typedef struct bitmap_s {              /* bitmap description */
        uint16_t width;
index b04abbd..f10379f 100644 (file)
@@ -52,6 +52,7 @@
 |  INCLUDES
 |*************************************************************************/
 
+#include "os_support.h"
 #include <stddef.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -61,8 +62,6 @@
 #include <unistd.h>
 #include <errno.h>
 
-extern int errno;
-
 /*************************************************************************
 |  DEFINES
 |*************************************************************************/
index 1fb6c93..9e45e64 100644 (file)
@@ -34,9 +34,6 @@
 #define MAP_SHARED     0x01            /* Share changes */
 #define MAP_PRIVATE    0x02            /* Changes are private */
 
-/* Return value of `mmap' in case of an error */
-#define MAP_FAILED     ((void *) -1)
-
 /* Windows 64-bit access macros */
 #define LODWORD(x) ((DWORD)((DWORDLONG)(x)))
 #define HIDWORD(x) ((DWORD)(((DWORDLONG)(x) >> 32) & 0xffffffff))
index 967fe9a..02cdb95 100644 (file)
 #include "mkimage.h"
 #include <image.h>
 
-extern int errno;
-
-#ifndef MAP_FAILED
-#define MAP_FAILED (void *)(-1)
-#endif
-
 extern unsigned long   crc32 (unsigned long crc, const char *buf, unsigned int len);
 static void            copy_file (int, const char *, int);
 static void            usage (void);
@@ -502,7 +496,7 @@ image_verify_header (char *ptr, int image_size)
         */
        memcpy (hdr, ptr, sizeof(image_header_t));
 
-       if (ntohl(hdr->ih_magic) != IH_MAGIC) {
+       if (be32_to_cpu(hdr->ih_magic) != IH_MAGIC) {
                fprintf (stderr,
                        "%s: Bad Magic Number: \"%s\" is no valid image\n",
                        cmdname, imagefile);
@@ -512,8 +506,8 @@ image_verify_header (char *ptr, int image_size)
        data = (char *)hdr;
        len  = sizeof(image_header_t);
 
-       checksum = ntohl(hdr->ih_hcrc);
-       hdr->ih_hcrc = htonl(0);        /* clear for re-calculation */
+       checksum = be32_to_cpu(hdr->ih_hcrc);
+       hdr->ih_hcrc = cpu_to_be32(0);  /* clear for re-calculation */
 
        if (crc32 (0, data, len) != checksum) {
                fprintf (stderr,
@@ -525,7 +519,7 @@ image_verify_header (char *ptr, int image_size)
        data = ptr + sizeof(image_header_t);
        len  = image_size - sizeof(image_header_t) ;
 
-       if (crc32 (0, data, len) != ntohl(hdr->ih_dcrc)) {
+       if (crc32 (0, data, len) != be32_to_cpu(hdr->ih_dcrc)) {
                fprintf (stderr,
                        "%s: ERROR: \"%s\" has corrupted data!\n",
                        cmdname, imagefile);
index c8df6e1..70c53ad 100644 (file)
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#ifndef __WIN32__
-#include <netinet/in.h>                /* for host / network byte order conversions    */
-#endif
-#ifdef __MINGW32__
-#include <stdint.h>
-#else
-#include <sys/mman.h>
-#endif
 #include <sys/stat.h>
 #include <time.h>
 #include <unistd.h>
 #define MKIMAGE_DEFAULT_DTC_OPTIONS    "-I dts -O dtb -p 500"
 #define MKIMAGE_MAX_DTC_CMDLINE_LEN    512
 #define MKIMAGE_DTC                    "dtc"   /* assume dtc is in $PATH */
-
-#if defined(__BEOS__) || defined(__NetBSD__) || defined(__APPLE__)
-#include <inttypes.h>
-#endif
-
-#ifdef __WIN32__
-typedef unsigned int __u32;
-
-#define SWAP_LONG(x) \
-       ((__u32)( \
-               (((__u32)(x) & (__u32)0x000000ffUL) << 24) | \
-               (((__u32)(x) & (__u32)0x0000ff00UL) <<  8) | \
-               (((__u32)(x) & (__u32)0x00ff0000UL) >>  8) | \
-               (((__u32)(x) & (__u32)0xff000000UL) >> 24) ))
-typedef                unsigned char   uint8_t;
-typedef                unsigned short  uint16_t;
-typedef                unsigned int    uint32_t;
-
-#define     ntohl(a)   SWAP_LONG(a)
-#define     htonl(a)   SWAP_LONG(a)
-#endif /* __WIN32__ */
-
-#ifndef        O_BINARY                /* should be define'd on __WIN32__ */
-#define O_BINARY       0
-#endif
index 001fe64..5b919aa 100644 (file)
@@ -19,6 +19,7 @@
 /*
  * Include additional files required for supporting different operating systems
  */
+#include "compiler.h"
 #ifdef __MINGW32__
 #include "mingw_support.c"
 #endif
index f6f86b0..7bf930e 100644 (file)
@@ -19,6 +19,8 @@
 #ifndef __OS_SUPPORT_H_
 #define __OS_SUPPORT_H_
 
+#include "compiler.h"
+
 /*
  * Include additional files required for supporting different operating systems
  */
index c4203ed..9774eea 100644 (file)
@@ -28,9 +28,6 @@
 #include <fcntl.h>
 #include <errno.h>
 #include <string.h>
-#ifndef __MINGW32__
-#include <sys/mman.h>
-#endif
 #include <sys/stat.h>
 #include "sha1.h"
 
 #include <config.h>
 #undef __ASSEMBLY__
 
-#ifndef        O_BINARY                /* should be define'd on __WIN32__ */
-#define O_BINARY       0
-#endif
-
-#ifndef MAP_FAILED
-#define MAP_FAILED (-1)
-#endif
-
-extern int errno;
-
 extern void sha1_csum (unsigned char *input, int ilen, unsigned char output[20]);
 
 int main (int argc, char **argv)