Merge branch 'master' of git://git.denx.de/u-boot-arm
authorTom Rini <trini@ti.com>
Fri, 10 Jan 2014 15:56:00 +0000 (10:56 -0500)
committerTom Rini <trini@ti.com>
Fri, 10 Jan 2014 15:56:00 +0000 (10:56 -0500)
Bringing in the MMC tree means that CONFIG_BOUNCE_BUFFER needed to be
added to include/configs/exynos5-dt.h now.

Conflicts:
include/configs/exynos5250-dt.h

Signed-off-by: Tom Rini <trini@ti.com>
308 files changed:
.gitignore
Makefile
README
arch/arm/cpu/armv7/zynq/timer.c
arch/arm/cpu/pxa/timer.c
arch/arm/include/asm/arch-socfpga/dwmmc.h [new file with mode: 0644]
arch/arm/include/asm/arch-socfpga/system_manager.h
arch/arm/lib/bootm.c
arch/blackfin/config.mk
arch/blackfin/cpu/initcode.c
arch/blackfin/include/asm/blackfin_local.h
arch/blackfin/lib/board.c
arch/blackfin/lib/clocks.c
arch/powerpc/config.mk
arch/powerpc/cpu/74xx_7xx/config.mk
arch/powerpc/cpu/Makefile
arch/powerpc/cpu/mpc512x/config.mk
arch/powerpc/cpu/mpc5xx/config.mk
arch/powerpc/cpu/mpc5xxx/config.mk
arch/powerpc/cpu/mpc824x/config.mk
arch/powerpc/cpu/mpc8260/config.mk
arch/powerpc/cpu/mpc83xx/config.mk
arch/powerpc/cpu/mpc85xx/config.mk
arch/powerpc/cpu/mpc85xx/speed.c
arch/powerpc/cpu/mpc86xx/config.mk
arch/powerpc/cpu/mpc8xx/config.mk
arch/powerpc/cpu/mpc8xxx/Makefile
arch/powerpc/cpu/ppc4xx/config.mk
arch/powerpc/include/asm/config_mpc85xx.h
arch/powerpc/include/asm/immap_85xx.h
arch/powerpc/lib/bootm.c
arch/sandbox/cpu/cpu.c
arch/sandbox/cpu/os.c
arch/sandbox/cpu/start.c
arch/sandbox/cpu/state.c
arch/sandbox/include/asm/global_data.h
arch/sandbox/include/asm/state.h
arch/sandbox/include/asm/u-boot-sandbox.h
arch/sh/cpu/sh2/config.mk
arch/sh/cpu/sh2/cpu.c
arch/sh/cpu/sh3/config.mk
arch/sh/cpu/sh4/config.mk
arch/sh/cpu/sh4/cpu.c
arch/sh/include/asm/cache.h
arch/sh/include/asm/cpu_sh4.h
arch/sh/include/asm/cpu_sh7753.h [new file with mode: 0644]
arch/sh/include/asm/processor.h
arch/sh/lib/time_sh2.c
board/bf609-ezkit/bf609-ezkit.c
board/freescale/b4860qds/b4_rcw.cfg
board/freescale/bsc9131rdb/tlb.c
board/freescale/bsc9132qds/tlb.c
board/freescale/common/p_corenet/Makefile
board/freescale/p1010rdb/tlb.c
board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c
board/freescale/t1040qds/t1040_pbi.cfg
board/freescale/t1040qds/t1040qds.c
board/linkstation/Makefile [deleted file]
board/linkstation/avr.c [deleted file]
board/linkstation/hwctl.c [deleted file]
board/linkstation/ide.c [deleted file]
board/linkstation/linkstation.c [deleted file]
board/renesas/sh7753evb/Makefile [new file with mode: 0644]
board/renesas/sh7753evb/lowlevel_init.S [new file with mode: 0644]
board/renesas/sh7753evb/sh7753evb.c [new file with mode: 0644]
board/renesas/sh7753evb/spi-boot.c [new file with mode: 0644]
board/renesas/sh7753evb/u-boot.lds [new file with mode: 0644]
boards.cfg
common/Makefile
common/board_f.c
common/cmd_bootm.c
common/cmd_elf.c
common/cmd_mmc.c
common/cmd_sandbox.c
common/console.c
common/fdt_support.c
config.mk
disk/part.c
doc/README.sh7753evb [new file with mode: 0644]
doc/README.socfpga [new file with mode: 0644]
doc/README.vxworks [new file with mode: 0644]
doc/SPI/README.sh_qspi_test [new file with mode: 0644]
drivers/block/Makefile
drivers/block/sandbox.c [new file with mode: 0644]
drivers/dfu/dfu.c
drivers/mmc/Makefile
drivers/mmc/dw_mmc.c [changed mode: 0644->0755]
drivers/mmc/mmc.c
drivers/mmc/sdhci.c
drivers/mmc/socfpga_dw_mmc.c [new file with mode: 0644]
drivers/mtd/nand/Makefile
drivers/mtd/nand/nand_util.c
drivers/mtd/nand/omap_gpmc.c
drivers/mtd/onenand/onenand_base.c
drivers/mtd/spi/sf_ops.c
drivers/mtd/spi/sf_probe.c
drivers/mtd/ubi/Makefile
drivers/net/fm/init.c
drivers/net/sh_eth.h
drivers/serial/lpc32xx_hsuart.c
drivers/serial/serial_sh.h
drivers/spi/Makefile
drivers/spi/sh_qspi.c [new file with mode: 0644]
drivers/spi/tegra114_spi.c
drivers/tpm/Makefile
drivers/tpm/tpm_tis_sandbox.c [new file with mode: 0644]
drivers/usb/gadget/Makefile
drivers/usb/gadget/f_dfu.c
drivers/usb/gadget/f_dfu.h
drivers/usb/host/ehci-hcd.c
drivers/usb/host/ehci-pci.c
drivers/video/ipu_disp.c
dts/Makefile
examples/standalone/.gitignore
examples/standalone/82559_eeprom.c [deleted file]
examples/standalone/Makefile
fs/jffs2/jffs2_1pass.c
fs/yaffs2/yaffs_uboot_glue.c
fs/yaffs2/yaffsfs.c
include/common.h
include/config_defaults.h
include/config_fallbacks.h
include/configs/B4860QDS.h
include/configs/BSC9131RDB.h
include/configs/BSC9132QDS.h
include/configs/CMS700.h
include/configs/DU440.h
include/configs/EXBITGEN.h
include/configs/JSE.h
include/configs/KAREF.h
include/configs/METROBOX.h
include/configs/MIP405.h
include/configs/MPC8315ERDB.h
include/configs/MPC8323ERDB.h
include/configs/MPC832XEMDS.h
include/configs/MPC8349EMDS.h
include/configs/MPC8349ITX.h
include/configs/MPC8360EMDS.h
include/configs/MPC8360ERDK.h
include/configs/MPC837XEMDS.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/MPC8610HPCD.h
include/configs/MPC8641HPCN.h
include/configs/MigoR.h
include/configs/P1010RDB.h
include/configs/P1022DS.h
include/configs/P1023RDS.h
include/configs/P1_P2_RDB.h
include/configs/P2020COME.h
include/configs/P2020DS.h
include/configs/P2041RDB.h
include/configs/PIP405.h
include/configs/PMC440.h
include/configs/T1040QDS.h
include/configs/T1040RDB.h
include/configs/T1042RDB_PI.h
include/configs/TQM834x.h
include/configs/VCMA9.h
include/configs/W7OLMC.h
include/configs/W7OLMG.h
include/configs/ac14xx.h
include/configs/actux1.h
include/configs/actux2.h
include/configs/actux3.h
include/configs/actux4.h
include/configs/alpr.h
include/configs/amcc-common.h
include/configs/ap325rxa.h
include/configs/ap_sh4a_4a.h
include/configs/aria.h
include/configs/arndale.h
include/configs/balloon3.h
include/configs/bf506f-ezkit.h
include/configs/bf561-acvilon.h
include/configs/bf561-ezkit.h
include/configs/blackvme.h
include/configs/cm-bf537e.h
include/configs/cm-bf537u.h
include/configs/coreboot.h
include/configs/corenet_ds.h
include/configs/csb272.h
include/configs/csb472.h
include/configs/dra7xx_evm.h
include/configs/dvlhost.h
include/configs/ecovec.h
include/configs/espt.h
include/configs/exynos5-dt.h
include/configs/km/kmp204x-common.h
include/configs/korat.h
include/configs/linkstation.h [deleted file]
include/configs/lp8x4x.h
include/configs/lubbock.h
include/configs/lwmon5.h
include/configs/mecp5123.h
include/configs/mpc5121ads.h
include/configs/mpq101.h
include/configs/mpr2.h
include/configs/ms7720se.h
include/configs/ms7722se.h
include/configs/ms7750se.h
include/configs/mx1ads.h
include/configs/omap5912osk.h
include/configs/omap5_uevm.h
include/configs/p1_p2_rdb_pc.h
include/configs/p3p440.h
include/configs/palmld.h
include/configs/palmtc.h
include/configs/palmtreo680.h
include/configs/pcs440ep.h
include/configs/pdm360ng.h
include/configs/pxa-common.h
include/configs/pxa255_idp.h
include/configs/quad100hd.h
include/configs/r0p7734.h
include/configs/r2dplus.h
include/configs/r7780mp.h
include/configs/rsdproto.h
include/configs/rsk7203.h
include/configs/rsk7264.h
include/configs/rsk7269.h
include/configs/sandbox.h
include/configs/sbc8349.h
include/configs/sbc8548.h
include/configs/sbc8641d.h
include/configs/sh7752evb.h
include/configs/sh7753evb.h [new file with mode: 0644]
include/configs/sh7757lcr.h
include/configs/sh7763rdp.h
include/configs/sh7785lcr.h
include/configs/shmin.h
include/configs/smdk2410.h
include/configs/socrates.h
include/configs/stxgp3.h
include/configs/stxssa.h
include/configs/t4qds.h
include/configs/tcm-bf537.h
include/configs/trats.h
include/configs/trizepsiv.h
include/configs/vme8349.h
include/configs/vpac270.h
include/configs/xaeniax.h
include/configs/zeus.h
include/configs/zipitz2.h
include/dfu.h
include/linux/crc8.h [new file with mode: 0644]
include/mmc.h
include/os.h
include/part.h
include/sandboxblockdev.h [new file with mode: 0644]
include/sh_tmu.h
include/vxworks.h
lib/Makefile
lib/crc8.c [new file with mode: 0644]
lib/time.c
post/Makefile
post/board/lwmon/Makefile
post/board/lwmon5/Makefile
post/board/netta/Makefile
post/board/pdm360ng/Makefile
post/cpu/mpc83xx/Makefile
post/cpu/ppc4xx/Makefile
post/drivers/Makefile
post/lib_powerpc/Makefile
post/lib_powerpc/fpu/Makefile
scripts/binutils-version.sh [new file with mode: 0644]
scripts/checkpatch.pl [new file with mode: 0755]
scripts/checkstack.pl [new file with mode: 0755]
scripts/cleanpatch [new file with mode: 0755]
scripts/dtc-version.sh [new file with mode: 0644]
scripts/gcc-version.sh [new file with mode: 0644]
scripts/setlocalversion [new file with mode: 0755]
spl/.gitignore [deleted file]
spl/Makefile
test/image/test-imagetools.sh [new file with mode: 0755]
tools/.gitignore
tools/Makefile
tools/aisimage.c
tools/binutils-version.sh [deleted file]
tools/checkpatch.pl [deleted file]
tools/checkstack.pl [deleted file]
tools/cleanpatch [deleted file]
tools/default_image.c
tools/dtc-version.sh [deleted file]
tools/dumpimage.c [new file with mode: 0644]
tools/dumpimage.h [new file with mode: 0644]
tools/fit_image.c
tools/gcc-version.sh [deleted file]
tools/imagetool.c [new file with mode: 0644]
tools/imagetool.h [new file with mode: 0644]
tools/imximage.c
tools/kwbimage.c
tools/mkimage.c
tools/mkimage.h
tools/mxsimage.c
tools/omapimage.c
tools/pblimage.c
tools/setlocalversion [deleted file]
tools/ublimage.c

index a39bd54d38db4f635c71813c9f1b4319898c5b3b..3b14c256e1971d23df29348ca161cccd84130592 100644 (file)
@@ -47,8 +47,6 @@
 /u-boot.ais
 /u-boot.dtb
 /u-boot.sb
-/u-boot.bd
-/u-boot.geany
 
 #
 # Generated files
 /errlog
 /reloc_off
 
+/spl/
+!/spl/Makefile
+/tpl/
+
 /include/generated/
 /include/spl-autoconf.mk
 /include/tpl-autoconf.mk
@@ -88,6 +90,3 @@ GPATH
 GRTAGS
 GSYMS
 GTAGS
-
-# spl ais files
-/spl/*.ais
index dc5ba046164110bab85f41b15ef38b2d3da9952e..e6f6edbb3a6d459a121d6c8d284f5343bf05a0a2 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -8,7 +8,7 @@
 VERSION = 2014
 PATCHLEVEL = 01
 SUBLEVEL =
-EXTRAVERSION = -rc1
+EXTRAVERSION = -rc2
 ifneq "$(SUBLEVEL)" ""
 U_BOOT_VERSION = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
 else
@@ -109,11 +109,6 @@ export     TOPDIR SRCTREE OBJTREE SPLTREE TPLTREE
 MKCONFIG       := $(SRCTREE)/mkconfig
 export MKCONFIG
 
-ifneq ($(OBJTREE),$(SRCTREE))
-REMOTE_BUILD   := 1
-export REMOTE_BUILD
-endif
-
 # $(obj) and (src) are defined in config.mk but here in main Makefile
 # we also need them before config.mk is included which is the case for
 # some targets like unconfig, clean, clobber, distclean, etc.
@@ -168,7 +163,7 @@ endif
 include $(TOPDIR)/config.mk
 
 # Targets which don't build the source code
-NON_BUILD_TARGETS = backup clean clobber distclean mkproper tidy unconfig
+NON_BUILD_TARGETS = backup clean clobber distclean mrproper tidy unconfig
 
 # Only do the generic board check when actually building, not configuring
 ifeq ($(filter $(NON_BUILD_TARGETS),$(MAKECMDGOALS)),)
@@ -187,7 +182,7 @@ ifndef LDSCRIPT
        #LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot.lds.debug
        ifdef CONFIG_SYS_LDSCRIPT
                # need to strip off double quotes
-               LDSCRIPT := $(subst ",,$(CONFIG_SYS_LDSCRIPT))
+               LDSCRIPT := $(CONFIG_SYS_LDSCRIPT:"%"=%)
        endif
 endif
 
@@ -218,15 +213,11 @@ endif
 #########################################################################
 # U-Boot objects....order is important (i.e. start must be first)
 
-OBJS  = $(CPUDIR)/start.o
-ifeq ($(CPU),ppc4xx)
-OBJS += $(CPUDIR)/resetvec.o
-endif
-ifeq ($(CPU),mpc85xx)
-OBJS += $(CPUDIR)/resetvec.o
-endif
+head-y := $(CPUDIR)/start.o
+head-$(CONFIG_4xx) += arch/powerpc/cpu/ppc4xx/resetvec.o
+head-$(CONFIG_MPC85xx) += arch/powerpc/cpu/mpc85xx/resetvec.o
 
-OBJS := $(addprefix $(obj),$(OBJS))
+OBJS := $(addprefix $(obj),$(head-y))
 
 HAVE_VENDOR_COMMON_LIB = $(if $(wildcard board/$(VENDOR)/common/Makefile),y,n)
 
@@ -249,9 +240,9 @@ LIBS-y += drivers/i2c/
 LIBS-y += drivers/input/
 LIBS-y += drivers/mmc/
 LIBS-y += drivers/mtd/
-LIBS-y += drivers/mtd/nand/
+LIBS-$(CONFIG_CMD_NAND) += drivers/mtd/nand/
 LIBS-y += drivers/mtd/onenand/
-LIBS-y += drivers/mtd/ubi/
+LIBS-$(CONFIG_CMD_UBI) += drivers/mtd/ubi/
 LIBS-y += drivers/mtd/spi/
 LIBS-y += drivers/net/
 LIBS-y += drivers/net/phy/
@@ -275,7 +266,7 @@ LIBS-y += drivers/usb/ulpi/
 LIBS-y += common/
 LIBS-y += lib/libfdt/
 LIBS-$(CONFIG_API) += api/
-LIBS-y += post/
+LIBS-$(CONFIG_HAS_POST) += post/
 LIBS-y += test/
 
 ifneq (,$(filter $(SOC), mx25 mx27 mx5 mx6 mx31 mx35 mxs vf610))
@@ -356,7 +347,7 @@ ALL-$(CONFIG_SPL_FRAMEWORK) += $(obj)u-boot.img
 ALL-$(CONFIG_TPL) += $(obj)tpl/u-boot-tpl.bin
 ALL-$(CONFIG_OF_SEPARATE) += $(obj)u-boot.dtb $(obj)u-boot-dtb.bin
 ifneq ($(CONFIG_SPL_TARGET),)
-ALL-$(CONFIG_SPL) += $(obj)$(subst ",,$(CONFIG_SPL_TARGET))
+ALL-$(CONFIG_SPL) += $(obj)$(CONFIG_SPL_TARGET:"%"=%)
 endif
 ALL-$(CONFIG_REMAKE_ELF) += $(obj)u-boot.elf
 
@@ -495,12 +486,10 @@ $(obj)u-boot.sb:       $(obj)u-boot.bin $(obj)spl/u-boot-spl.bin
 $(obj)u-boot.spr:      $(obj)u-boot.img $(obj)spl/u-boot-spl.bin
                $(obj)tools/mkimage -A $(ARCH) -T firmware -C none \
                -a $(CONFIG_SPL_TEXT_BASE) -e $(CONFIG_SPL_TEXT_BASE) -n XLOADER \
-               -d $(obj)spl/u-boot-spl.bin $(obj)spl/u-boot-spl.img
-               tr "\000" "\377" < /dev/zero | dd ibs=1 count=$(CONFIG_SPL_PAD_TO) \
-                       of=$(obj)spl/u-boot-spl-pad.img 2>/dev/null
-               dd if=$(obj)spl/u-boot-spl.img of=$(obj)spl/u-boot-spl-pad.img \
-                       conv=notrunc 2>/dev/null
-               cat $(obj)spl/u-boot-spl-pad.img $(obj)u-boot.img > $@
+               -d $(obj)spl/u-boot-spl.bin $@
+               $(OBJCOPY) -I binary -O binary \
+                       --pad-to=$(CONFIG_SPL_PAD_TO) --gap-fill=0xff $@
+               cat $(obj)u-boot.img >> $@
 
 ifneq ($(CONFIG_TEGRA),)
 $(obj)u-boot-nodtb-tegra.bin: $(obj)spl/u-boot-spl.bin $(obj)u-boot.bin
@@ -523,11 +512,9 @@ $(obj)u-boot-img.bin: $(obj)spl/u-boot-spl.bin $(obj)u-boot.img
 # at the start padded up to the start of the SPL image. And then concat
 # the SPL image to the end.
 $(obj)u-boot-img-spl-at-end.bin: $(obj)spl/u-boot-spl.bin $(obj)u-boot.img
-               tr "\000" "\377" < /dev/zero | dd ibs=1 count=$(CONFIG_UBOOT_PAD_TO) \
-                       of=$(obj)u-boot-pad.img 2>/dev/null
-               dd if=$(obj)u-boot.img of=$(obj)u-boot-pad.img \
-                       conv=notrunc 2>/dev/null
-               cat $(obj)u-boot-pad.img $(obj)spl/u-boot-spl.bin > $@
+               $(OBJCOPY) -I binary -O binary --pad-to=$(CONFIG_UBOOT_PAD_TO) \
+                        --gap-fill=0xff $(obj)u-boot.img $@
+               cat $(obj)spl/u-boot-spl.bin >> $@
 
 # Create a new ELF from a raw binary file.  This is useful for arm64
 # where static relocation needs to be performed on the raw binary,
@@ -555,7 +542,7 @@ GEN_UBOOT = \
 endif
 
 $(obj)u-boot:  depend \
-               $(SUBDIR_TOOLS) $(OBJS) $(LIBS) $(LDSCRIPT) $(obj)u-boot.lds
+               $(SUBDIR_TOOLS) $(OBJS) $(LIBS) $(obj)u-boot.lds
                $(GEN_UBOOT)
 ifeq ($(CONFIG_KALLSYMS),y)
                smap=`$(call SYSTEM_MAP,$(obj)u-boot) | \
@@ -576,10 +563,7 @@ $(SUBDIRS):        depend
 
 $(SUBDIR_EXAMPLES-y): $(obj)u-boot
 
-$(LDSCRIPT):   depend
-               $(MAKE) -C $(dir $@) $(notdir $@)
-
-$(obj)u-boot.lds: $(LDSCRIPT)
+$(obj)u-boot.lds: $(LDSCRIPT) depend
                $(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$< >$@
 
 nand_spl:      $(TIMESTAMP_FILE) $(VERSION_FILE) depend
@@ -613,7 +597,7 @@ FINDFLAGS := -L
 checkstack:
                $(CROSS_COMPILE)objdump -d $(obj)u-boot \
                        `$(FIND) $(obj) -name u-boot-spl -print` | \
-                       perl $(src)tools/checkstack.pl $(ARCH)
+                       perl $(src)scripts/checkstack.pl $(ARCH)
 
 tags ctags:
                ctags -w -o $(obj)ctags `$(FIND) $(FINDFLAGS) $(TAG_SUBDIRS) \
@@ -665,63 +649,49 @@ checkdtc:
 # to regenerate the autoconf.mk file.
 $(obj)include/autoconf.mk.dep: $(obj)include/config.h include/common.h
        @$(XECHO) Generating $@ ; \
-       set -e ; \
        : Generate the dependancies ; \
        $(CC) -x c -DDO_DEPS_ONLY -M $(CFLAGS) $(CPPFLAGS) \
-               -MQ $(obj)include/autoconf.mk include/common.h > $@
+               -MQ $(obj)include/autoconf.mk include/common.h > $@ || \
+               rm $@
 
 $(obj)include/autoconf.mk: $(obj)include/config.h
        @$(XECHO) Generating $@ ; \
-       set -e ; \
        : Extract the config macros ; \
-       $(CPP) $(CFLAGS) -DDO_DEPS_ONLY -dM include/common.h | \
-               sed -n -f tools/scripts/define2mk.sed > $@.tmp && \
-       mv $@.tmp $@
+       $(CPP) $(CFLAGS) -DDO_DEPS_ONLY -dM include/common.h > $@.tmp && \
+               sed -n -f tools/scripts/define2mk.sed $@.tmp > $@; \
+       rm $@.tmp
 
 # Auto-generate the spl-autoconf.mk file (which is included by all makefiles for SPL)
 $(obj)include/tpl-autoconf.mk: $(obj)include/config.h
        @$(XECHO) Generating $@ ; \
-       set -e ; \
        : Extract the config macros ; \
        $(CPP) $(CFLAGS) -DCONFIG_TPL_BUILD  -DCONFIG_SPL_BUILD\
-                       -DDO_DEPS_ONLY -dM include/common.h | \
-       sed -n -f tools/scripts/define2mk.sed > $@.tmp && \
-       mv $@.tmp $@
+                       -DDO_DEPS_ONLY -dM include/common.h > $@.tmp && \
+               sed -n -f tools/scripts/define2mk.sed $@.tmp > $@; \
+       rm $@.tmp
 
 $(obj)include/spl-autoconf.mk: $(obj)include/config.h
        @$(XECHO) Generating $@ ; \
-       set -e ; \
        : Extract the config macros ; \
-       $(CPP) $(CFLAGS) -DCONFIG_SPL_BUILD -DDO_DEPS_ONLY -dM include/common.h | \
-       sed -n -f tools/scripts/define2mk.sed > $@.tmp && \
-       mv $@.tmp $@
-
-$(obj)include/generated/generic-asm-offsets.h: $(obj)include/autoconf.mk.dep \
-       $(obj)include/spl-autoconf.mk \
-       $(obj)include/tpl-autoconf.mk \
-       $(obj)lib/asm-offsets.s
+       $(CPP) $(CFLAGS) -DCONFIG_SPL_BUILD -DDO_DEPS_ONLY -dM include/common.h > $@.tmp && \
+               sed -n -f tools/scripts/define2mk.sed $@.tmp > $@; \
+       rm $@.tmp
+
+$(obj)include/generated/generic-asm-offsets.h: $(obj)lib/asm-offsets.s
        @$(XECHO) Generating $@
        tools/scripts/make-asm-offsets $(obj)lib/asm-offsets.s $@
 
-$(obj)lib/asm-offsets.s:       $(obj)include/autoconf.mk.dep \
-       $(obj)include/spl-autoconf.mk \
-       $(obj)include/tpl-autoconf.mk \
-       $(src)lib/asm-offsets.c
+$(obj)lib/asm-offsets.s: $(obj)include/config.h $(src)lib/asm-offsets.c
        @mkdir -p $(obj)lib
        $(CC) -DDO_DEPS_ONLY \
                $(CFLAGS) $(CFLAGS_$(BCURDIR)/$(@F)) $(CFLAGS_$(BCURDIR)) \
                -o $@ $(src)lib/asm-offsets.c -c -S
 
-$(obj)include/generated/asm-offsets.h: $(obj)include/autoconf.mk.dep \
-       $(obj)include/spl-autoconf.mk \
-       $(obj)include/tpl-autoconf.mk \
-       $(obj)$(CPUDIR)/$(SOC)/asm-offsets.s
+$(obj)include/generated/asm-offsets.h: $(obj)$(CPUDIR)/$(SOC)/asm-offsets.s
        @$(XECHO) Generating $@
        tools/scripts/make-asm-offsets $(obj)$(CPUDIR)/$(SOC)/asm-offsets.s $@
 
-$(obj)$(CPUDIR)/$(SOC)/asm-offsets.s:  $(obj)include/autoconf.mk.dep \
-       $(obj)include/spl-autoconf.mk \
-       $(obj)include/tpl-autoconf.mk
+$(obj)$(CPUDIR)/$(SOC)/asm-offsets.s: $(obj)include/config.h
        @mkdir -p $(obj)$(CPUDIR)/$(SOC)
        if [ -f $(src)$(CPUDIR)/$(SOC)/asm-offsets.c ];then \
                $(CC) -DDO_DEPS_ONLY \
@@ -757,7 +727,7 @@ checkarmreloc: $(obj)u-boot
 
 $(VERSION_FILE):
                @mkdir -p $(dir $(VERSION_FILE))
-               @( localvers='$(shell $(TOPDIR)/tools/setlocalversion $(TOPDIR))' ; \
+               @( localvers='$(shell $(TOPDIR)/scripts/setlocalversion $(TOPDIR))' ; \
                   printf '#define PLAIN_VERSION "%s%s"\n' \
                        "$(U_BOOT_VERSION)" "$${localvers}" ; \
                   printf '#define U_BOOT_VERSION "U-Boot %s%s"\n' \
@@ -812,9 +782,7 @@ $(obj).boards.depend:       boards.cfg
 #########################################################################
 
 clean:
-       @rm -f $(obj)examples/standalone/82559_eeprom                     \
-              $(obj)examples/standalone/atmel_df_pow2                    \
-              $(obj)examples/standalone/eepro100_eeprom                  \
+       @rm -f $(obj)examples/standalone/atmel_df_pow2                    \
               $(obj)examples/standalone/hello_world                      \
               $(obj)examples/standalone/interrupt                        \
               $(obj)examples/standalone/mem_to_mem_idma2intr             \
@@ -824,10 +792,11 @@ clean:
               $(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/env/fw_printenv                                \
               $(obj)tools/envcrc                                         \
-              $(obj)tools/gdb/{astest,gdbcont,gdbsend}                   \
+              $(obj)tools/gdb/{gdbcont,gdbsend}                          \
               $(obj)tools/gen_eth_addr    $(obj)tools/img2srec           \
+              $(obj)tools/dump{env,}image                \
               $(obj)tools/mk{env,}image   $(obj)tools/mpc86x_clk         \
               $(obj)tools/mk{$(BOARD),}spl                               \
               $(obj)tools/mxsboot                                        \
@@ -836,7 +805,6 @@ clean:
               $(obj)tools/proftool
        @rm -f $(obj)board/cray/L1/{bootscript.c,bootscript.image}        \
               $(obj)board/matrix_vision/*/bootscript.img                 \
-              $(obj)board/voiceblue/eeprom                               \
               $(obj)u-boot.lds                                           \
               $(obj)arch/blackfin/cpu/init.{lds,elf}
        @rm -f $(obj)include/bmp_logo.h
@@ -872,7 +840,6 @@ clobber:    tidy
        @rm -f $(obj)u-boot.ais
        @rm -f $(obj)u-boot.dtb
        @rm -f $(obj)u-boot.sb
-       @rm -f $(obj)u-boot.bd
        @rm -f $(obj)u-boot.spr
        @rm -f $(obj)nand_spl/{u-boot.{lds,lst},System.map}
        @rm -f $(obj)nand_spl/{u-boot-nand_spl.lds,u-boot-spl,u-boot-spl.map}
diff --git a/README b/README
index 8f0b38cbf38b16de6f2a9d8707cde096f3b52b51..a0646c36657b3b69b37a9a1816a27fcdb55d8d43 100644 (file)
--- a/README
+++ b/README
@@ -423,6 +423,11 @@ The following options need to be configured:
                CONFIG_SYS_FSL_DSP_CCSRBAR_DEFAULT
                This value denotes start offset of DSP CCSR space.
 
+               CONFIG_SYS_FSL_SINGLE_SOURCE_CLK
+               Single Source Clock is clocking mode present in some of FSL SoC's.
+               In this mode, a single differential clock is used to supply
+               clocks to the sysclock, ddrclock and usbclock.
+
 - Generic CPU options:
                CONFIG_SYS_BIG_ENDIAN, CONFIG_SYS_LITTLE_ENDIAN
 
@@ -3267,6 +3272,9 @@ FIT uImage format:
                Defines the size and behavior of the NAND that SPL uses
                to read U-Boot
 
+               CONFIG_SPL_NAND_BOOT
+               Add support NAND boot
+
                CONFIG_SYS_NAND_U_BOOT_OFFS
                Location in NAND to read U-Boot from
 
@@ -5252,6 +5260,15 @@ when your kernel is intended to use an initial ramdisk:
        Load Address: 0x00000000
        Entry Point:  0x00000000
 
+The "dumpimage" is a tool to disassemble images built by mkimage. Its "-i"
+option performs the converse operation of the mkimage's second form (the "-d"
+option). Given an image built by mkimage, the dumpimage extracts a "data file"
+from the image:
+
+       tools/dumpimage -i image -p position data_file
+         -i ==> extract from the 'image' a specific 'data_file', \
+          indexed by 'position'
+
 
 Installing a Linux Image:
 -------------------------
index 636322a8e5728de647c8a333b0a2feb9b1b730ed..2be253c2c3d5ec29d2e7a50da9542701728d0340 100644 (file)
@@ -107,8 +107,7 @@ void __udelay(unsigned long usec)
        if (usec == 0)
                return;
 
-       countticks = (u32) (((unsigned long long) TIMER_TICK_HZ * usec) /
-                                                               1000000);
+       countticks = lldiv(TIMER_TICK_HZ * usec, 1000000);
 
        /* decrementing timer */
        timeend = readl(&timer_base->counter) - countticks;
index 78d9f3274528a6974d99954cbb09822b8f0b1960..c4717de6a9c4ccdd3d551c1e5acd8016d93f840a 100644 (file)
@@ -28,12 +28,12 @@ DECLARE_GLOBAL_DATA_PTR;
 
 static unsigned long long tick_to_time(unsigned long long tick)
 {
-       return tick * CONFIG_SYS_HZ / TIMER_FREQ_HZ;
+       return lldiv(tick * CONFIG_SYS_HZ, TIMER_FREQ_HZ);
 }
 
 static unsigned long long us_to_tick(unsigned long long us)
 {
-       return (us * TIMER_FREQ_HZ) / 1000000;
+       return lldiv(us * TIMER_FREQ_HZ, 1000000);
 }
 
 int timer_init(void)
diff --git a/arch/arm/include/asm/arch-socfpga/dwmmc.h b/arch/arm/include/asm/arch-socfpga/dwmmc.h
new file mode 100644 (file)
index 0000000..945eb64
--- /dev/null
@@ -0,0 +1,12 @@
+/*
+ * (C) Copyright 2013 Altera Corporation <www.altera.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#ifndef        _SOCFPGA_DWMMC_H_
+#define        _SOCFPGA_DWMMC_H_
+
+extern int socfpga_dwmmc_init(u32 regbase, int bus_width, int index);
+
+#endif /* _SOCFPGA_SDMMC_H_ */
index d965d25effcc8b16e0b2127a6f432a6749eb06b7..838d21053ef051d3aea4969d66982cfe639b6736 100644 (file)
@@ -19,4 +19,69 @@ extern unsigned long sys_mgr_init_table[CONFIG_HPS_PINMUX_NUM];
 
 #define CONFIG_SYSMGR_PINMUXGRP_OFFSET (0x400)
 
+#define SYSMGR_SDMMC_CTRL_SET(smplsel, drvsel) \
+       ((((drvsel) << 0) & 0x7) | (((smplsel) << 3) & 0x38))
+
+struct socfpga_system_manager {
+       u32     siliconid1;
+       u32     siliconid2;
+       u32     _pad_0x8_0xf[2];
+       u32     wddbg;
+       u32     bootinfo;
+       u32     hpsinfo;
+       u32     parityinj;
+       u32     fpgaintfgrp_gbl;
+       u32     fpgaintfgrp_indiv;
+       u32     fpgaintfgrp_module;
+       u32     _pad_0x2c_0x2f;
+       u32     scanmgrgrp_ctrl;
+       u32     _pad_0x34_0x3f[3];
+       u32     frzctrl_vioctrl;
+       u32     _pad_0x44_0x4f[3];
+       u32     frzctrl_hioctrl;
+       u32     frzctrl_src;
+       u32     frzctrl_hwctrl;
+       u32     _pad_0x5c_0x5f;
+       u32     emacgrp_ctrl;
+       u32     emacgrp_l3master;
+       u32     _pad_0x68_0x6f[2];
+       u32     dmagrp_ctrl;
+       u32     dmagrp_persecurity;
+       u32     _pad_0x78_0x7f[2];
+       u32     iswgrp_handoff[8];
+       u32     _pad_0xa0_0xbf[8];
+       u32     romcodegrp_ctrl;
+       u32     romcodegrp_cpu1startaddr;
+       u32     romcodegrp_initswstate;
+       u32     romcodegrp_initswlastld;
+       u32     romcodegrp_bootromswstate;
+       u32     __pad_0xd4_0xdf[3];
+       u32     romcodegrp_warmramgrp_enable;
+       u32     romcodegrp_warmramgrp_datastart;
+       u32     romcodegrp_warmramgrp_length;
+       u32     romcodegrp_warmramgrp_execution;
+       u32     romcodegrp_warmramgrp_crc;
+       u32     __pad_0xf4_0xff[3];
+       u32     romhwgrp_ctrl;
+       u32     _pad_0x104_0x107;
+       u32     sdmmcgrp_ctrl;
+       u32     sdmmcgrp_l3master;
+       u32     nandgrp_bootstrap;
+       u32     nandgrp_l3master;
+       u32     usbgrp_l3master;
+       u32     _pad_0x11c_0x13f[9];
+       u32     eccgrp_l2;
+       u32     eccgrp_ocram;
+       u32     eccgrp_usb0;
+       u32     eccgrp_usb1;
+       u32     eccgrp_emac0;
+       u32     eccgrp_emac1;
+       u32     eccgrp_dma;
+       u32     eccgrp_can0;
+       u32     eccgrp_can1;
+       u32     eccgrp_nand;
+       u32     eccgrp_qspi;
+       u32     eccgrp_sdmmc;
+};
+
 #endif /* _SYSTEM_MANAGER_H_ */
index 77f1a5c9736f13ec4034a641f19f360c86fd8fc7..a8295bf1f1e1e0dd3bbd1d590e0065501b1d2dc2 100644 (file)
@@ -350,3 +350,26 @@ int bootz_setup(ulong image, ulong *start, ulong *end)
 }
 
 #endif /* CONFIG_CMD_BOOTZ */
+
+#if defined(CONFIG_BOOTM_VXWORKS)
+void boot_prep_vxworks(bootm_headers_t *images)
+{
+#if defined(CONFIG_OF_LIBFDT)
+       int off;
+
+       if (images->ft_addr) {
+               off = fdt_path_offset(images->ft_addr, "/memory");
+               if (off < 0) {
+                       if (arch_fixup_memory_node(images->ft_addr))
+                               puts("## WARNING: fixup memory failed!\n");
+               }
+       }
+#endif
+       cleanup_before_linux();
+}
+void boot_jump_vxworks(bootm_headers_t *images)
+{
+       /* ARM VxWorks requires device tree physical address to be passed */
+       ((void (*)(void *))images->ep)(images->ft_addr);
+}
+#endif
index 35f871662df19ac9b20c769a1ef5d0ebc4e1459c..73fa79855f59bf38715d55160010ce25d2cedbff 100644 (file)
@@ -14,9 +14,9 @@ CONFIG_BFIN_CPU := \
        $(shell awk '$$2 == "CONFIG_BFIN_CPU" { print $$3 }' \
                $(src)include/configs/$(BOARD).h)
 else
-CONFIG_BFIN_CPU := $(strip $(subst ",,$(CONFIG_BFIN_CPU)))
+CONFIG_BFIN_CPU := $(strip $(CONFIG_BFIN_CPU:"%"=%))
 endif
-CONFIG_BFIN_BOOT_MODE := $(strip $(subst ",,$(CONFIG_BFIN_BOOT_MODE)))
+CONFIG_BFIN_BOOT_MODE := $(strip $(CONFIG_BFIN_BOOT_MODE:"%"=%))
 
 PLATFORM_RELFLAGS += -ffixed-P3 -fomit-frame-pointer -mno-fdpic
 PLATFORM_CPPFLAGS += -DCONFIG_BLACKFIN
index ffaf1017d7b7772f2b0aa25133ae572e5646bd23..2e640afc453a853b32b6f064a5a4688bbba6a1ff 100644 (file)
@@ -18,8 +18,6 @@
 #include <asm/mach-common/bits/core.h>
 #include <asm/serial.h>
 
-#define BUG() while (1) asm volatile("emuexcpt;");
-
 #ifndef __ADSPBF60x__
 #include <asm/mach-common/bits/ebiu.h>
 #include <asm/mach-common/bits/pll.h>
@@ -147,8 +145,6 @@ static struct ddr_config ddr_config_table[] = {
 __attribute__((always_inline))
 static inline void serial_init(void)
 {
-       uint32_t uart_base = UART_BASE;
-
 #if defined(__ADSPBF54x__) || defined(__ADSPBF60x__)
 # ifdef BFIN_BOOT_UART_USE_RTS
 #  define BFIN_UART_USE_RTS 1
@@ -156,6 +152,7 @@ static inline void serial_init(void)
 #  define BFIN_UART_USE_RTS 0
 # endif
        if (BFIN_UART_USE_RTS && CONFIG_BFIN_BOOT_MODE == BFIN_BOOT_UART) {
+               uint32_t uart_base = UART_BASE;
                size_t i;
 
                /* force RTS rather than relying on auto RTS */
@@ -195,8 +192,8 @@ static inline void serial_init(void)
 
 #if CONFIG_BFIN_BOOT_MODE != BFIN_BOOT_BYPASS
        if (BFIN_DEBUG_EARLY_SERIAL) {
-               serial_early_init(uart_base);
-               serial_early_set_baud(uart_base, CONFIG_BAUDRATE);
+               serial_early_init(UART_BASE);
+               serial_early_set_baud(UART_BASE, CONFIG_BAUDRATE);
        }
 #endif
 }
@@ -547,7 +544,7 @@ maybe_self_refresh(ADI_BOOT_DATA *bs)
 __attribute__((always_inline)) static inline u16
 program_clocks(ADI_BOOT_DATA *bs, bool put_into_srfs)
 {
-       u16 vr_ctl;
+       u16 vr_ctl = 0;
 
        serial_putc('a');
 
@@ -731,6 +728,8 @@ update_serial_clocks(ADI_BOOT_DATA *bs, uint sdivB, uint divB, uint vcoB)
 
        serial_putc('a');
 
+       if (BFIN_DEBUG_EARLY_SERIAL ||
+               CONFIG_BFIN_BOOT_MODE == BFIN_BOOT_UART) {
 #ifdef __ADSPBF60x__
        sdivR = bfin_read_CGU_DIV();
        sdivR = ((sdivR >> 8) & 0x1f) * ((sdivR >> 5) & 0x7);
@@ -744,6 +743,8 @@ update_serial_clocks(ADI_BOOT_DATA *bs, uint sdivB, uint divB, uint vcoB)
        divisor = vcoB * sdivR;
        quotient = early_division(dividend, divisor);
        serial_early_put_div(quotient - ANOMALY_05000230);
+       }
+
        serial_putc('c');
 }
 
@@ -913,7 +914,8 @@ check_hibernation(ADI_BOOT_DATA *bs, u16 vr_ctl, bool put_into_srfs)
                        continue;
 
                serial_putc('z');
-               uint32_t *hibernate_magic = bfin_read32(DPM0_RESTORE4);
+               uint32_t *hibernate_magic =
+                       (uint32_t *)bfin_read32(DPM0_RESTORE4);
                SSYNC(); /* make sure memory controller is done */
                if (hibernate_magic[0] == 0xDEADBEEF) {
                        serial_putc('c');
index 8ea8cde691af46d3dac02ab3cdf79c0e137ec9c8..4d6eeab0ec126f576a00317b554b60d35ca111b2 100644 (file)
@@ -81,6 +81,8 @@ extern void blackfin_dcache_flush_invalidate_range(const void *, const void *);
 # define NOP_PAD_ANOMALY_05000198
 #endif
 
+#define BFIN_BUG() while (1) asm volatile("emuexcpt;");
+
 #define _bfin_readX(addr, size, asm_size, asm_ext) ({ \
        u32 __v; \
        __asm__ __volatile__( \
@@ -111,7 +113,7 @@ extern void blackfin_dcache_flush_invalidate_range(const void *, const void *);
        sizeof(*(addr)) == 1 ? bfin_read8(addr)  : \
        sizeof(*(addr)) == 2 ? bfin_read16(addr) : \
        sizeof(*(addr)) == 4 ? bfin_read32(addr) : \
-       ({ BUG(); 0; }); \
+       ({ BFIN_BUG(); 0; }); \
 })
 #define bfin_write(addr, val) \
 do { \
@@ -119,7 +121,8 @@ do { \
        case 1: bfin_write8(addr, val);  break; \
        case 2: bfin_write16(addr, val); break; \
        case 4: bfin_write32(addr, val); break; \
-       default: BUG(); \
+       default: \
+               BFIN_BUG(); \
        } \
 } while (0)
 
index 17d1f468dd3a53b0394d4beebbe52f000f41a811..392d72d23214064224208c795eefb9d07cb91387 100644 (file)
@@ -19,6 +19,7 @@
 #include <net.h>
 #include <status_led.h>
 #include <version.h>
+#include <watchdog.h>
 
 #include <asm/cplb.h>
 #include <asm/mach-common/bits/mpu.h>
index 97795e11ac993498d60848ecda562df08d625872..7ed56a72742759a3b7f8ac8b0f7683da586e2b49 100644 (file)
@@ -36,7 +36,10 @@ u_long get_vco(void)
 u_long get_cclk(void)
 {
        static u_long cached_cclk_pll_div, cached_cclk;
-       u_long div, csel, ssel;
+       u_long div, csel;
+#ifndef CGU_DIV
+       u_long ssel;
+#endif
 
        if (pll_is_bypassed())
                return CONFIG_CLKIN_HZ;
index e6bb9357292b5374c5fee314227a88c66585c810..f75c3bf187caecea7ba2a458744c9f72636aaef3 100644 (file)
@@ -9,8 +9,9 @@ CROSS_COMPILE ?= ppc_8xx-
 
 CONFIG_STANDALONE_LOAD_ADDR ?= 0x40000
 LDFLAGS_FINAL += --gc-sections
-PLATFORM_RELFLAGS += -fpic -mrelocatable -ffunction-sections -fdata-sections
-PLATFORM_CPPFLAGS += -DCONFIG_PPC -D__powerpc__
+PLATFORM_RELFLAGS += -fpic -mrelocatable -ffunction-sections -fdata-sections \
+                                                               -meabi
+PLATFORM_CPPFLAGS += -DCONFIG_PPC -D__powerpc__ -ffixed-r2
 PLATFORM_LDFLAGS  += -n
 
 # Support generic board on PPC
index 9053191602ec359ed0e93b6a2794a3c353d31ec6..96812a02d824fe2b781255a3fb6d4d1c1ff45d1f 100644 (file)
@@ -5,6 +5,4 @@
 # SPDX-License-Identifier:     GPL-2.0+
 #
 
-PLATFORM_RELFLAGS += -meabi
-
-PLATFORM_CPPFLAGS += -DCONFIG_74xx_7xx -ffixed-r2 -mstring
+PLATFORM_CPPFLAGS += -DCONFIG_74xx_7xx -mstring
index d630abe1da5f37d06e934cab669e15f3214f01d0..88b5298be0ca62a6e5d5a245d14f741112c7bdd4 100644 (file)
@@ -1,3 +1,3 @@
-ifneq ($(filter mpc83xx mpc85xx mpc86xx,$(CPU)),)
-obj-y += mpc8xxx/
-endif
+obj-$(CONFIG_MPC83xx) += mpc8xxx/
+obj-$(CONFIG_MPC85xx) += mpc8xxx/
+obj-$(CONFIG_MPC86xx) += mpc8xxx/
index 04717a485e8fecdcbb42b44138fcea17925f5531..03759e662505dd35f6246acdcc39c1b98ff175fc 100644 (file)
@@ -4,7 +4,4 @@
 # SPDX-License-Identifier:     GPL-2.0+
 #
 
-PLATFORM_RELFLAGS += -meabi
-
-PLATFORM_CPPFLAGS += -DCONFIG_MPC512X -DCONFIG_E300 \
-                       -ffixed-r2 -msoft-float -mcpu=603e
+PLATFORM_CPPFLAGS += -DCONFIG_MPC512X -DCONFIG_E300 -msoft-float -mcpu=603e
index b33f17a1ba6d44949da366f0e36da4d433576496..31e2dc98731f2235c51e0ec71466b542317cc2e6 100644 (file)
@@ -5,6 +5,4 @@
 # SPDX-License-Identifier:     GPL-2.0+
 #
 
-PLATFORM_RELFLAGS +=   -meabi
-
-PLATFORM_CPPFLAGS +=   -DCONFIG_5xx -ffixed-r2 -mpowerpc -msoft-float
+PLATFORM_CPPFLAGS += -DCONFIG_5xx -mpowerpc -msoft-float
index 57bdd2d252dade4e4e5d5373a6a68b070c7926dd..3384f6ffccc55fbbd04ca89239e6d7c19e8249d0 100644 (file)
@@ -5,7 +5,5 @@
 # SPDX-License-Identifier:     GPL-2.0+
 #
 
-PLATFORM_RELFLAGS += -meabi
-
-PLATFORM_CPPFLAGS += -DCONFIG_MPC5xxx -ffixed-r2 \
+PLATFORM_CPPFLAGS += -DCONFIG_MPC5xxx \
                     -mstring -mcpu=603e -mmultiple
index ef605f07975a38f18c29a46f15e9505a5ff849ad..a224bc8e73e451a966cec97d073efff9f33149f7 100644 (file)
@@ -5,6 +5,4 @@
 # SPDX-License-Identifier:     GPL-2.0+
 #
 
-PLATFORM_RELFLAGS += -meabi
-
-PLATFORM_CPPFLAGS += -DCONFIG_MPC824X -ffixed-r2 -mstring -mcpu=603e -msoft-float
+PLATFORM_CPPFLAGS += -DCONFIG_MPC824X -mstring -mcpu=603e -msoft-float
index 91b0497ccbc02b3eb97046a643f174f750d7817d..dfac710e630a62bbf0960581c30e5ce947a147c0 100644 (file)
@@ -5,7 +5,5 @@
 # SPDX-License-Identifier:     GPL-2.0+
 #
 
-PLATFORM_RELFLAGS += -meabi
-
-PLATFORM_CPPFLAGS += -DCONFIG_8260 -DCONFIG_CPM2 -ffixed-r2 \
+PLATFORM_CPPFLAGS += -DCONFIG_8260 -DCONFIG_CPM2 \
                     -mstring -mcpu=603e -mmultiple
index c16a00376f2ec18f5bac260640fb542f148274dd..dfce4d53b4aed861f1401bc4158839fee00960af 100644 (file)
@@ -4,7 +4,4 @@
 # SPDX-License-Identifier:     GPL-2.0+
 #
 
-PLATFORM_RELFLAGS += -meabi
-
-PLATFORM_CPPFLAGS += -DCONFIG_MPC83xx -DCONFIG_E300 \
-                       -ffixed-r2 -msoft-float
+PLATFORM_CPPFLAGS += -DCONFIG_MPC83xx -DCONFIG_E300 -msoft-float
index 9eef539e5e12f2ea9edff6568d8cff0146d545ee..72c964cd151c89eab2ed5fcaec2011ac975df687 100644 (file)
@@ -5,13 +5,10 @@
 # SPDX-License-Identifier:     GPL-2.0+
 #
 
-PLATFORM_RELFLAGS += -meabi
-
-PLATFORM_CPPFLAGS += -ffixed-r2 -Wa,-me500 -msoft-float -mno-string
+PLATFORM_CPPFLAGS += -Wa,-me500 -msoft-float -mno-string
 
 # -mspe=yes is needed to have -mno-spe accepted by a buggy GCC;
 # see "[PATCH,rs6000] make -mno-spe work as expected" on
 # http://gcc.gnu.org/ml/gcc-patches/2008-04/msg00311.html
-PF_CPPFLAGS_SPE := $(call cc-option,-mspe=yes) \
+PLATFORM_CPPFLAGS += $(call cc-option,-mspe=yes) \
                   $(call cc-option,-mno-spe)
-PLATFORM_CPPFLAGS += $(PF_CPPFLAGS_SPE)
index 46ae80c4d819b244de758d60a28a09cd6095d4a5..35867dffdd718740184933d86456212e7fc1d09e 100644 (file)
@@ -74,12 +74,33 @@ void get_sys_info(sys_info_t *sys_info)
        uint ratio[CONFIG_SYS_FSL_NUM_CC_PLLS];
        unsigned long sysclk = CONFIG_SYS_CLK_FREQ;
        uint mem_pll_rat;
+#ifdef CONFIG_SYS_FSL_SINGLE_SOURCE_CLK
+       uint single_src;
+#endif
 
        sys_info->freq_systembus = sysclk;
+#ifdef CONFIG_SYS_FSL_SINGLE_SOURCE_CLK
+       /*
+        * DDR_REFCLK_SEL rcw bit is used to determine if DDR PLLS
+        * are driven by separate DDR Refclock or single source
+        * differential clock.
+        */
+       single_src = (in_be32(&gur->rcwsr[5]) >>
+                     FSL_CORENET2_RCWSR5_DDR_REFCLK_SEL_SHIFT) &
+                     FSL_CORENET2_RCWSR5_DDR_REFCLK_SEL_MASK;
+       /*
+        * For single source clocking, both ddrclock and syclock
+        * are driven by differential sysclock.
+        */
+       if (single_src == FSL_CORENET2_RCWSR5_DDR_REFCLK_SINGLE_CLK) {
+               printf("Single Source Clock Configuration\n");
+               sys_info->freq_ddrbus = CONFIG_SYS_CLK_FREQ;
+       } else
+#endif
 #ifdef CONFIG_DDR_CLK_FREQ
-       sys_info->freq_ddrbus = CONFIG_DDR_CLK_FREQ;
+               sys_info->freq_ddrbus = CONFIG_DDR_CLK_FREQ;
 #else
-       sys_info->freq_ddrbus = sysclk;
+               sys_info->freq_ddrbus = sysclk;
 #endif
 
        sys_info->freq_systembus *= (in_be32(&gur->rcwsr[0]) >> 25) & 0x1f;
@@ -229,6 +250,9 @@ void get_sys_info(sys_info_t *sys_info)
        case 4:
                sys_info->freq_fman[1] = freq_c_pll[CONFIG_SYS_FM2_CLK + 1] / 4;
                break;
+       case 5:
+               sys_info->freq_fman[1] = sys_info->freq_systembus;
+               break;
        case 6:
                sys_info->freq_fman[1] = freq_c_pll[CONFIG_SYS_FM2_CLK] / 2;
                break;
index 5dbf6a8472e30130110b422a7d6bb712a06d8f31..69a0b96eadb742918daa651a0c210eca612f474a 100644 (file)
@@ -5,7 +5,4 @@
 # SPDX-License-Identifier:     GPL-2.0+
 #
 
-PLATFORM_RELFLAGS += -meabi
-
-PLATFORM_CPPFLAGS += -ffixed-r2 -mstring
-PLATFORM_CPPFLAGS += -maltivec -mabi=altivec -msoft-float
+PLATFORM_CPPFLAGS += -mstring -maltivec -mabi=altivec -msoft-float
index c04e7338c84370c578512002a4f0ed977669af4b..ee2c883665cb2e0b08594a8dfb2837dcc9553f71 100644 (file)
@@ -5,6 +5,4 @@
 # SPDX-License-Identifier:     GPL-2.0+
 #
 
-PLATFORM_RELFLAGS += -meabi
-
-PLATFORM_CPPFLAGS += -DCONFIG_8xx -ffixed-r2 -mstring -mcpu=860 -msoft-float
+PLATFORM_CPPFLAGS += -DCONFIG_8xx -mstring -mcpu=860 -msoft-float
index f66ee2e4239d553cbbfc2b73481e7dc974a7e8f7..e95539e0a3efce0a25d9e624438cb690ed85024d 100644 (file)
@@ -19,10 +19,8 @@ ifdef MINIMAL
 obj-$(CONFIG_FSL_LAW) += law.o
 
 else
-
-ifneq ($(CPU),mpc83xx)
-obj-y  += cpu.o
-endif
+obj-$(CONFIG_MPC85xx) += cpu.o
+obj-$(CONFIG_MPC86xx) += cpu.o
 
 obj-$(CONFIG_OF_LIBFDT) += fdt.o
 obj-$(CONFIG_FSL_LBC) += fsl_lbc.o
index c2b0f9aab6084918730b403816230bc685a4f7e1..71c2a6c729f5762321746d50c2df87c0783bea44 100644 (file)
@@ -5,8 +5,7 @@
 # SPDX-License-Identifier:     GPL-2.0+
 #
 
-PLATFORM_RELFLAGS += -meabi
-PLATFORM_CPPFLAGS += -DCONFIG_4xx -ffixed-r2 -mstring -msoft-float
+PLATFORM_CPPFLAGS += -DCONFIG_4xx -mstring -msoft-float
 
 cfg=$(shell grep configs $(OBJTREE)/include/config.h | sed 's/.*<\(configs.*\)>/\1/')
 is440:=$(shell grep CONFIG_440 $(TOPDIR)/include/$(cfg))
index 99e16bdf631b2831c863154fdae0e078d97ddbd0..54ce2f053cc9dc841af29c1efea370bdbe266fc2 100644 (file)
@@ -711,7 +711,8 @@ defined(CONFIG_PPC_T1020) || defined(CONFIG_PPC_T1022)
 #define CONFIG_FM_PLAT_CLK_DIV 1
 #define CONFIG_SYS_FM1_CLK             CONFIG_FM_PLAT_CLK_DIV
 #define CONFIG_SYS_FM_MURAM_SIZE       0x30000
-#define CONFIG_SYS_FSL_TBCLK_DIV       32
+#define CONFIG_SYS_FSL_SINGLE_SOURCE_CLK
+#define CONFIG_SYS_FSL_TBCLK_DIV       16
 #define CONFIG_SYS_FSL_PCIE_COMPAT     "fsl,qoriq-pcie-v2.4"
 #define CONFIG_SYS_FSL_USB1_PHY_ENABLE
 #define CONFIG_SYS_FSL_USB2_PHY_ENABLE
@@ -745,7 +746,7 @@ defined(CONFIG_PPC_T1020) || defined(CONFIG_PPC_T1022)
 #define CONFIG_SYS_NUM_FM1_DTSEC       6
 #define CONFIG_SYS_NUM_FM1_10GEC       2
 #endif
-#define CONFIG_SYS_FSL_NUM_USB_CTRLS   2
+#define CONFIG_USB_MAX_CONTROLLER_COUNT 2
 #define CONFIG_NUM_DDR_CONTROLLERS     1
 #define CONFIG_PME_PLAT_CLK_DIV                1
 #define CONFIG_SYS_PME_CLK             CONFIG_PME_PLAT_CLK_DIV
index 672e8c6650c39ea703d7cd6307c91b381e92e0b4..68c3c8245338053b473c57923703d6d7859d1ff0 100644 (file)
@@ -1774,6 +1774,9 @@ defined(CONFIG_PPC_T1020) || defined(CONFIG_PPC_T1022)
 #define FSL_CORENET2_RCWSR5_SRDS_PLL_PD_S3_PLL2        0x00040000
 #define FSL_CORENET2_RCWSR5_SRDS_PLL_PD_S4_PLL1        0x00020000
 #define FSL_CORENET2_RCWSR5_SRDS_PLL_PD_S4_PLL2        0x00010000
+#define FSL_CORENET2_RCWSR5_DDR_REFCLK_SEL_SHIFT 4
+#define FSL_CORENET2_RCWSR5_DDR_REFCLK_SEL_MASK        0x00000011
+#define FSL_CORENET2_RCWSR5_DDR_REFCLK_SINGLE_CLK      1
 
 #else /* CONFIG_SYS_FSL_QORIQ_CHASSIS2 */
 #define FSL_CORENET_RCWSR0_MEM_PLL_RAT_SHIFT   17
index e7153b048003491264d6e0424fdfd37bfc8a9849..41fc8f7ff7a355ec3a2cbbd548e63022324489d0 100644 (file)
@@ -32,6 +32,7 @@ DECLARE_GLOBAL_DATA_PTR;
 
 extern ulong get_effective_memsize(void);
 static ulong get_sp (void);
+extern void ft_fixup_num_cores(void *blob);
 static void set_clocks_in_mhz (bd_t *kbd);
 
 #ifndef CONFIG_SYS_LINUX_LOWMEM_MAX_SIZE
@@ -277,3 +278,58 @@ static void set_clocks_in_mhz (bd_t *kbd)
 #endif /* CONFIG_MPC5xxx */
        }
 }
+
+#if defined(CONFIG_BOOTM_VXWORKS)
+void boot_prep_vxworks(bootm_headers_t *images)
+{
+#if defined(CONFIG_OF_LIBFDT)
+       int off;
+       u64 base, size;
+
+       if (!images->ft_addr)
+               return;
+
+       base = (u64)gd->bd->bi_memstart;
+       size = (u64)gd->bd->bi_memsize;
+
+       off = fdt_path_offset(images->ft_addr, "/memory");
+       if (off < 0)
+               fdt_fixup_memory(images->ft_addr, base, size);
+
+#if defined(CONFIG_MP)
+#if defined(CONFIG_MPC85xx)
+       ft_fixup_cpu(images->ft_addr, base + size);
+       ft_fixup_num_cores(images->ft_addr);
+#elif defined(CONFIG_MPC86xx)
+       off = fdt_add_mem_rsv(images->ft_addr,
+                       determine_mp_bootpg(NULL), (u64)4096);
+       if (off < 0)
+               printf("## WARNING %s: %s\n", __func__, fdt_strerror(off));
+       ft_fixup_num_cores(images->ft_addr);
+#endif
+       flush_cache((unsigned long)images->ft_addr, images->ft_len);
+#endif
+#endif
+}
+
+void boot_jump_vxworks(bootm_headers_t *images)
+{
+       /* PowerPC VxWorks boot interface conforms to the ePAPR standard
+        * general purpuse registers:
+        *
+        *      r3: Effective address of the device tree image
+        *      r4: 0
+        *      r5: 0
+        *      r6: ePAPR magic value
+        *      r7: shall be the size of the boot IMA in bytes
+        *      r8: 0
+        *      r9: 0
+        *      TCR: WRC = 0, no watchdog timer reset will occur
+        */
+       WATCHDOG_RESET();
+
+       ((void (*)(void *, ulong, ulong, ulong,
+               ulong, ulong, ulong))images->ep)(images->ft_addr,
+               0, 0, EPAPR_MAGIC, getenv_bootm_mapsize(), 0, 0);
+}
+#endif
index cfc1fda1e15c651ef76a15e6d834e966ebe6a2e6..38019e0b48e57585b0e89f23ab929c9cad5f2edc 100644 (file)
@@ -5,13 +5,23 @@
 
 #include <common.h>
 #include <os.h>
+#include <asm/state.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
-int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+void reset_cpu(ulong ignored)
 {
+       if (state_uninit())
+               os_exit(2);
+
        /* This is considered normal termination for now */
        os_exit(0);
+}
+
+int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+       reset_cpu(0);
+
        return 0;
 }
 
@@ -28,7 +38,14 @@ unsigned long __attribute__((no_instrument_function)) timer_get_us(void)
 
 int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)
 {
-       return -1;
+       if (flag & (BOOTM_STATE_OS_GO | BOOTM_STATE_OS_FAKE_GO)) {
+               bootstage_mark(BOOTSTAGE_ID_RUN_OS);
+               printf("## Transferring control to Linux (at address %08lx)...\n",
+                      images->ep);
+               reset_cpu(0);
+       }
+
+       return 0;
 }
 
 int cleanup_before_linux(void)
index 26f44cb597ef14cd8f05376e0b96fd2ab2522ae1..725b505177d33938cee5cf4ce8308bb13bf11c9a 100644 (file)
 
 /* Operating System Interface */
 
+struct os_mem_hdr {
+       size_t length;          /* number of bytes in the block */
+};
+
 ssize_t os_read(int fd, void *buf, size_t count)
 {
        return read(fd, buf, count);
@@ -128,8 +132,45 @@ void os_tty_raw(int fd)
 
 void *os_malloc(size_t length)
 {
-       return mmap(NULL, length, PROT_READ | PROT_WRITE,
-                       MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+       struct os_mem_hdr *hdr;
+
+       hdr = mmap(NULL, length + sizeof(*hdr), PROT_READ | PROT_WRITE,
+                  MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+       if (hdr == MAP_FAILED)
+               return NULL;
+       hdr->length = length;
+
+       return hdr + 1;
+}
+
+void *os_free(void *ptr)
+{
+       struct os_mem_hdr *hdr = ptr;
+
+       hdr--;
+       if (ptr)
+               munmap(hdr, hdr->length + sizeof(*hdr));
+}
+
+void *os_realloc(void *ptr, size_t length)
+{
+       struct os_mem_hdr *hdr = ptr;
+       void *buf = NULL;
+
+       hdr--;
+       if (length != 0) {
+               buf = os_malloc(length);
+               if (!buf)
+                       return buf;
+               if (ptr) {
+                       if (length > hdr->length)
+                               length = hdr->length;
+                       memcpy(buf, ptr, length);
+               }
+       }
+       os_free(ptr);
+
+       return buf;
 }
 
 void os_usleep(unsigned long usec)
@@ -347,3 +388,53 @@ ssize_t os_get_filesize(const char *fname)
                return ret;
        return buf.st_size;
 }
+
+void os_putc(int ch)
+{
+       putchar(ch);
+}
+
+void os_puts(const char *str)
+{
+       while (*str)
+               os_putc(*str++);
+}
+
+int os_write_ram_buf(const char *fname)
+{
+       struct sandbox_state *state = state_get_current();
+       int fd, ret;
+
+       fd = open(fname, O_CREAT | O_WRONLY, 0777);
+       if (fd < 0)
+               return -ENOENT;
+       ret = write(fd, state->ram_buf, state->ram_size);
+       close(fd);
+       if (ret != state->ram_size)
+               return -EIO;
+
+       return 0;
+}
+
+int os_read_ram_buf(const char *fname)
+{
+       struct sandbox_state *state = state_get_current();
+       int fd, ret;
+       int size;
+
+       size = os_get_filesize(fname);
+       if (size < 0)
+               return -ENOENT;
+       if (size != state->ram_size)
+               return -ENOSPC;
+       fd = open(fname, O_RDONLY);
+       if (fd < 0)
+               return -ENOENT;
+
+       ret = read(fd, state->ram_buf, state->ram_size);
+       close(fd);
+       if (ret != state->ram_size)
+               return -EIO;
+
+       return 0;
+}
index 1b1545478470c48bbfe4a9275fb4853d4aa1813a..1df21d49fa501d9744b5a589cc1904d1f0bc20c6 100644 (file)
@@ -4,11 +4,12 @@
  */
 
 #include <common.h>
+#include <os.h>
 #include <asm/getopt.h>
 #include <asm/sections.h>
 #include <asm/state.h>
 
-#include <os.h>
+DECLARE_GLOBAL_DATA_PTR;
 
 int sandbox_early_getopt_check(void)
 {
@@ -50,9 +51,9 @@ int sandbox_early_getopt_check(void)
 
                /* then the long flag */
                if (opt->has_arg)
-                       printf("--%-*s", max_noarg_len, opt->flag);
-               else
                        printf("--%-*s <arg> ", max_arg_len, opt->flag);
+               else
+                       printf("--%-*s", max_noarg_len, opt->flag);
 
                /* finally the help text */
                printf("  %s\n", opt->help);
@@ -75,7 +76,8 @@ int sandbox_main_loop_init(void)
        /* Execute command if required */
        if (state->cmd) {
                run_command_list(state->cmd, -1, 0);
-               os_exit(state->exit_type);
+               if (!state->interactive)
+                       os_exit(state->exit_type);
        }
 
        return 0;
@@ -96,25 +98,93 @@ static int sandbox_cmdline_cb_fdt(struct sandbox_state *state, const char *arg)
 }
 SANDBOX_CMDLINE_OPT_SHORT(fdt, 'd', 1, "Specify U-Boot's control FDT");
 
-int main(int argc, char *argv[])
+static int sandbox_cmdline_cb_interactive(struct sandbox_state *state,
+                                         const char *arg)
+{
+       state->interactive = true;
+       return 0;
+}
+
+SANDBOX_CMDLINE_OPT_SHORT(interactive, 'i', 0, "Enter interactive mode");
+
+static int sandbox_cmdline_cb_memory(struct sandbox_state *state,
+                                    const char *arg)
 {
-       struct sandbox_state *state;
        int err;
 
-       err = state_init();
-       if (err)
+       /* For now assume we always want to write it */
+       state->write_ram_buf = true;
+       state->ram_buf_fname = arg;
+
+       if (os_read_ram_buf(arg)) {
+               printf("Failed to read RAM buffer\n");
                return err;
+       }
+
+       return 0;
+}
+SANDBOX_CMDLINE_OPT_SHORT(memory, 'm', 1,
+                         "Read/write ram_buf memory contents from file");
+
+static int sandbox_cmdline_cb_state(struct sandbox_state *state,
+                                   const char *arg)
+{
+       state->state_fname = arg;
+       return 0;
+}
+SANDBOX_CMDLINE_OPT_SHORT(state, 's', 1, "Specify the sandbox state FDT");
+
+static int sandbox_cmdline_cb_read(struct sandbox_state *state,
+                                  const char *arg)
+{
+       state->read_state = true;
+       return 0;
+}
+SANDBOX_CMDLINE_OPT_SHORT(read, 'r', 0, "Read the state FDT on startup");
+
+static int sandbox_cmdline_cb_write(struct sandbox_state *state,
+                                   const char *arg)
+{
+       state->write_state = true;
+       return 0;
+}
+SANDBOX_CMDLINE_OPT_SHORT(write, 'w', 0, "Write state FDT on exit");
+
+static int sandbox_cmdline_cb_ignore_missing(struct sandbox_state *state,
+                                            const char *arg)
+{
+       state->ignore_missing_state_on_read = true;
+       return 0;
+}
+SANDBOX_CMDLINE_OPT_SHORT(ignore_missing, 'n', 0,
+                         "Ignore missing state on read");
+
+int main(int argc, char *argv[])
+{
+       struct sandbox_state *state;
+       int ret;
+
+       ret = state_init();
+       if (ret)
+               goto err;
 
        state = state_get_current();
        if (os_parse_args(state, argc, argv))
                return 1;
 
-       /*
-        * Do pre- and post-relocation init, then start up U-Boot. This will
-        * never return.
-        */
+       ret = sandbox_read_state(state, state->state_fname);
+       if (ret)
+               goto err;
+
+       /* Do pre- and post-relocation init */
        board_init_f(0);
 
-       /* NOTREACHED - board_init_f() does not return */
+       board_init_r(gd->new_gd, 0);
+
+       /* NOTREACHED - board_init_r() does not return */
        return 0;
+
+err:
+       printf("Error %d\n", ret);
+       return 1;
 }
index 56d5041411c77b993bf0a5622106dcf863a32385..a145808a52d43c350b7b568d9678fe102bf4d662 100644 (file)
@@ -4,6 +4,9 @@
  */
 
 #include <common.h>
+#include <errno.h>
+#include <fdtdec.h>
+#include <os.h>
 #include <asm/state.h>
 
 /* Main state record for the sandbox */
@@ -15,6 +18,324 @@ void state_record_exit(enum exit_type_id exit_type)
        state->exit_type = exit_type;
 }
 
+static int state_ensure_space(int extra_size)
+{
+       void *blob = state->state_fdt;
+       int used, size, free;
+       void *buf;
+       int ret;
+
+       used = fdt_off_dt_strings(blob) + fdt_size_dt_strings(blob);
+       size = fdt_totalsize(blob);
+       free = size - used;
+       if (free > extra_size)
+               return 0;
+
+       size = used + extra_size;
+       buf = os_malloc(size);
+       if (!buf)
+               return -ENOMEM;
+
+       ret = fdt_open_into(blob, buf, size);
+       if (ret) {
+               os_free(buf);
+               return -EIO;
+       }
+
+       os_free(blob);
+       state->state_fdt = buf;
+       return 0;
+}
+
+static int state_read_file(struct sandbox_state *state, const char *fname)
+{
+       int size;
+       int ret;
+       int fd;
+
+       size = os_get_filesize(fname);
+       if (size < 0) {
+               printf("Cannot find sandbox state file '%s'\n", fname);
+               return -ENOENT;
+       }
+       state->state_fdt = os_malloc(size);
+       if (!state->state_fdt) {
+               puts("No memory to read sandbox state\n");
+               return -ENOMEM;
+       }
+       fd = os_open(fname, OS_O_RDONLY);
+       if (fd < 0) {
+               printf("Cannot open sandbox state file '%s'\n", fname);
+               ret = -EPERM;
+               goto err_open;
+       }
+       if (os_read(fd, state->state_fdt, size) != size) {
+               printf("Cannot read sandbox state file '%s'\n", fname);
+               ret = -EIO;
+               goto err_read;
+       }
+       os_close(fd);
+
+       return 0;
+err_read:
+       os_close(fd);
+err_open:
+       os_free(state->state_fdt);
+       state->state_fdt = NULL;
+
+       return ret;
+}
+
+/***
+ * sandbox_read_state_nodes() - Read state associated with a driver
+ *
+ * This looks through all compatible nodes and calls the read function on
+ * each one, to read in the state.
+ *
+ * If nothing is found, it still calls the read function once, to set up a
+ * single global state for that driver.
+ *
+ * @state: Sandbox state
+ * @io: Method to use for reading state
+ * @blob: FDT containing state
+ * @return 0 if OK, -EINVAL if the read function returned failure
+ */
+int sandbox_read_state_nodes(struct sandbox_state *state,
+                            struct sandbox_state_io *io, const void *blob)
+{
+       int count;
+       int node;
+       int ret;
+
+       debug("   - read %s\n", io->name);
+       if (!io->read)
+               return 0;
+
+       node = -1;
+       count = 0;
+       while (blob) {
+               node = fdt_node_offset_by_compatible(blob, node, io->compat);
+               if (node < 0)
+                       return 0;       /* No more */
+               debug("   - read node '%s'\n", fdt_get_name(blob, node, NULL));
+               ret = io->read(blob, node);
+               if (ret) {
+                       printf("Unable to read state for '%s'\n", io->compat);
+                       return -EINVAL;
+               }
+               count++;
+       }
+
+       /*
+        * If we got no saved state, call the read function once without a
+        * node, to set up the global state.
+        */
+       if (count == 0) {
+               debug("   - read global\n");
+               ret = io->read(NULL, -1);
+               if (ret) {
+                       printf("Unable to read global state for '%s'\n",
+                              io->name);
+                       return -EINVAL;
+               }
+       }
+
+       return 0;
+}
+
+int sandbox_read_state(struct sandbox_state *state, const char *fname)
+{
+       struct sandbox_state_io *io;
+       const void *blob;
+       bool got_err;
+       int ret;
+
+       if (state->read_state && fname) {
+               ret = state_read_file(state, fname);
+               if (ret == -ENOENT && state->ignore_missing_state_on_read)
+                       ret = 0;
+               if (ret)
+                       return ret;
+       }
+
+       /* Call all the state read funtcions */
+       got_err = false;
+       blob = state->state_fdt;
+       io = ll_entry_start(struct sandbox_state_io, state_io);
+       for (; io < ll_entry_end(struct sandbox_state_io, state_io); io++) {
+               ret = sandbox_read_state_nodes(state, io, blob);
+               if (ret < 0)
+                       got_err = true;
+       }
+
+       if (state->read_state && fname) {
+               debug("Read sandbox state from '%s'%s\n", fname,
+                     got_err ? " (with errors)" : "");
+       }
+
+       return got_err ? -1 : 0;
+}
+
+/***
+ * sandbox_write_state_node() - Write state associated with a driver
+ *
+ * This calls the write function to write out global state for that driver.
+ *
+ * TODO(sjg@chromium.org): Support writing out state from multiple drivers
+ * of the same time. We don't need this yet,and it will be much easier to
+ * do when driver model is available.
+ *
+ * @state: Sandbox state
+ * @io: Method to use for writing state
+ * @return 0 if OK, -EIO if there is a fatal error (such as out of space
+ * for adding the data), -EINVAL if the write function failed.
+ */
+int sandbox_write_state_node(struct sandbox_state *state,
+                            struct sandbox_state_io *io)
+{
+       void *blob;
+       int node;
+       int ret;
+
+       if (!io->write)
+               return 0;
+
+       ret = state_ensure_space(SANDBOX_STATE_MIN_SPACE);
+       if (ret) {
+               printf("Failed to add more space for state\n");
+               return -EIO;
+       }
+
+       /* The blob location can change when the size increases */
+       blob = state->state_fdt;
+       node = fdt_node_offset_by_compatible(blob, -1, io->compat);
+       if (node == -FDT_ERR_NOTFOUND) {
+               node = fdt_add_subnode(blob, 0, io->name);
+               if (node < 0) {
+                       printf("Cannot create node '%s': %s\n", io->name,
+                              fdt_strerror(node));
+                       return -EIO;
+               }
+
+               if (fdt_setprop_string(blob, node, "compatible", io->compat)) {
+                       puts("Cannot set compatible\n");
+                       return -EIO;
+               }
+       } else if (node < 0) {
+               printf("Cannot access node '%s': %s\n", io->name,
+                      fdt_strerror(node));
+               return -EIO;
+       }
+       debug("Write state for '%s' to node %d\n", io->compat, node);
+       ret = io->write(blob, node);
+       if (ret) {
+               printf("Unable to write state for '%s'\n", io->compat);
+               return -EINVAL;
+       }
+
+       return 0;
+}
+
+int sandbox_write_state(struct sandbox_state *state, const char *fname)
+{
+       struct sandbox_state_io *io;
+       bool got_err;
+       int size;
+       int ret;
+       int fd;
+
+       /* Create a state FDT if we don't have one */
+       if (!state->state_fdt) {
+               size = 0x4000;
+               state->state_fdt = os_malloc(size);
+               if (!state->state_fdt) {
+                       puts("No memory to create FDT\n");
+                       return -ENOMEM;
+               }
+               ret = fdt_create_empty_tree(state->state_fdt, size);
+               if (ret < 0) {
+                       printf("Cannot create empty state FDT: %s\n",
+                              fdt_strerror(ret));
+                       ret = -EIO;
+                       goto err_create;
+               }
+       }
+
+       /* Call all the state write funtcions */
+       got_err = false;
+       io = ll_entry_start(struct sandbox_state_io, state_io);
+       ret = 0;
+       for (; io < ll_entry_end(struct sandbox_state_io, state_io); io++) {
+               ret = sandbox_write_state_node(state, io);
+               if (ret == -EIO)
+                       break;
+               else if (ret)
+                       got_err = true;
+       }
+
+       if (ret == -EIO) {
+               printf("Could not write sandbox state\n");
+               goto err_create;
+       }
+
+       ret = fdt_pack(state->state_fdt);
+       if (ret < 0) {
+               printf("Cannot pack state FDT: %s\n", fdt_strerror(ret));
+               ret = -EINVAL;
+               goto err_create;
+       }
+       size = fdt_totalsize(state->state_fdt);
+       fd = os_open(fname, OS_O_WRONLY | OS_O_CREAT);
+       if (fd < 0) {
+               printf("Cannot open sandbox state file '%s'\n", fname);
+               ret = -EIO;
+               goto err_create;
+       }
+       if (os_write(fd, state->state_fdt, size) != size) {
+               printf("Cannot write sandbox state file '%s'\n", fname);
+               ret = -EIO;
+               goto err_write;
+       }
+       os_close(fd);
+
+       debug("Wrote sandbox state to '%s'%s\n", fname,
+             got_err ? " (with errors)" : "");
+
+       return 0;
+err_write:
+       os_close(fd);
+err_create:
+       os_free(state->state_fdt);
+
+       return ret;
+}
+
+int state_setprop(int node, const char *prop_name, const void *data, int size)
+{
+       void *blob;
+       int len;
+       int ret;
+
+       fdt_getprop(state->state_fdt, node, prop_name, &len);
+
+       /* Add space for the new property, its name and some overhead */
+       ret = state_ensure_space(size - len + strlen(prop_name) + 32);
+       if (ret)
+               return ret;
+
+       /* This should succeed, barring a mutiny */
+       blob = state->state_fdt;
+       ret = fdt_setprop(blob, node, prop_name, data, size);
+       if (ret) {
+               printf("%s: Unable to set property '%s' in node '%s': %s\n",
+                      __func__, prop_name, fdt_get_name(blob, node, NULL),
+                       fdt_strerror(ret));
+               return -ENOSPC;
+       }
+
+       return 0;
+}
+
 struct sandbox_state *state_get_current(void)
 {
        assert(state);
@@ -25,6 +346,10 @@ int state_init(void)
 {
        state = &main_state;
 
+       state->ram_size = CONFIG_SYS_SDRAM_SIZE;
+       state->ram_buf = os_malloc(state->ram_size);
+       assert(state->ram_buf);
+
        /*
         * Example of how to use GPIOs:
         *
@@ -33,3 +358,31 @@ int state_init(void)
         */
        return 0;
 }
+
+int state_uninit(void)
+{
+       int err;
+
+       state = &main_state;
+
+       if (state->write_ram_buf) {
+               err = os_write_ram_buf(state->ram_buf_fname);
+               if (err) {
+                       printf("Failed to write RAM buffer\n");
+                       return err;
+               }
+       }
+
+       if (state->write_state) {
+               if (sandbox_write_state(state, state->state_fname)) {
+                       printf("Failed to write sandbox state\n");
+                       return -1;
+               }
+       }
+
+       if (state->state_fdt)
+               os_free(state->state_fdt);
+       memset(state, '\0', sizeof(*state));
+
+       return 0;
+}
index d70532aa4d7a6bca2b38d68573f6e476bf0ffdc3..b2e9b488f13be33563b07bb5435a999ddfb99521 100644 (file)
@@ -12,7 +12,7 @@
 
 /* Architecture-specific global data */
 struct arch_global_data {
-       u8              *ram_buf;       /* emulated RAM buffer */
+       uint8_t         *ram_buf;       /* emulated RAM buffer */
 };
 
 #include <asm-generic/global_data.h>
index a38820bdeeb919180497b1d73d8078c12cd56edc..e8e4fea1b57de66865ac84e0f06011f77a93202f 100644 (file)
@@ -7,6 +7,8 @@
 #define __SANDBOX_STATE_H
 
 #include <config.h>
+#include <stdbool.h>
+#include <linux/stringify.h>
 
 /* How we exited U-Boot */
 enum exit_type_id {
@@ -23,17 +25,92 @@ struct sandbox_spi_info {
 /* The complete state of the test system */
 struct sandbox_state {
        const char *cmd;                /* Command to execute */
+       bool interactive;               /* Enable cmdline after execute */
        const char *fdt_fname;          /* Filename of FDT binary */
        enum exit_type_id exit_type;    /* How we exited U-Boot */
        const char *parse_err;          /* Error to report from parsing */
        int argc;                       /* Program arguments */
        char **argv;
+       uint8_t *ram_buf;               /* Emulated RAM buffer */
+       unsigned int ram_size;          /* Size of RAM buffer */
+       const char *ram_buf_fname;      /* Filename to use for RAM buffer */
+       bool write_ram_buf;             /* Write RAM buffer on exit */
+       const char *state_fname;        /* File containing sandbox state */
+       void *state_fdt;                /* Holds saved state for sandbox */
+       bool read_state;                /* Read sandbox state on startup */
+       bool write_state;               /* Write sandbox state on exit */
+       bool ignore_missing_state_on_read;      /* No error if state missing */
 
        /* Pointer to information for each SPI bus/cs */
        struct sandbox_spi_info spi[CONFIG_SANDBOX_SPI_MAX_BUS]
                                        [CONFIG_SANDBOX_SPI_MAX_CS];
 };
 
+/* Minimum space we guarantee in the state FDT when calling read/write*/
+#define SANDBOX_STATE_MIN_SPACE                0x1000
+
+/**
+ * struct sandbox_state_io - methods to saved/restore sandbox state
+ * @name: Name of of the device tree node, also the name of the variable
+ *     holding this data so it should be an identifier (use underscore
+ *     instead of minus)
+ * @compat: Compatible string for the node containing this state
+ *
+ * @read: Function to read state from FDT
+ *     If data is available, then blob and node will provide access to it. If
+ *     not (blob == NULL and node == -1) this function should set up an empty
+ *     data set for start-of-day.
+ *     @param blob: Pointer to device tree blob, or NULL if no data to read
+ *     @param node: Node offset to read from
+ *     @return 0 if OK, -ve on error
+ *
+ * @write: Function to write state to FDT
+ *     The caller will ensure that there is a node ready for the state. The
+ *     node may already contain the old state, in which case it should be
+ *     overridden. There is guaranteed to be SANDBOX_STATE_MIN_SPACE bytes
+ *     of free space, so error checking is not required for fdt_setprop...()
+ *     calls which add up to less than this much space.
+ *
+ *     For adding larger properties, use state_setprop().
+ *
+ * @param blob: Device tree blob holding state
+ * @param node: Node to write our state into
+ *
+ * Note that it is possible to save data as large blobs or as individual
+ * hierarchical properties. However, unless you intend to keep state files
+ * around for a long time and be able to run an old state file on a new
+ * sandbox, it might not be worth using individual properties for everything.
+ * This is certainly supported, it is just a matter of the effort you wish
+ * to put into the state read/write feature.
+ */
+struct sandbox_state_io {
+       const char *name;
+       const char *compat;
+       int (*write)(void *blob, int node);
+       int (*read)(const void *blob, int node);
+};
+
+/**
+ * SANDBOX_STATE_IO - Declare sandbox state to read/write
+ *
+ * Sandbox permits saving state from one run and restoring it in another. This
+ * allows the test system to retain state between runs and thus better
+ * emulate a real system. Examples of state that might be useful to save are
+ * the emulated GPIOs pin settings, flash memory contents and TPM private
+ * data. U-Boot memory contents is dealth with separately since it is large
+ * and it is not normally useful to save it (since a normal system does not
+ * preserve DRAM between runs). See the '-m' option for this.
+ *
+ * See struct sandbox_state_io above for member documentation.
+ */
+#define SANDBOX_STATE_IO(_name, _compat, _read, _write) \
+       ll_entry_declare(struct sandbox_state_io, _name, state_io) = { \
+               .name = __stringify(_name), \
+               .read = _read, \
+               .write = _write, \
+               .compat = _compat, \
+       }
+
 /**
  * Record the exit type to be reported by the test program.
  *
@@ -48,9 +125,60 @@ void state_record_exit(enum exit_type_id exit_type);
  */
 struct sandbox_state *state_get_current(void);
 
+/**
+ * Read the sandbox state from the supplied device tree file
+ *
+ * This calls all registered state handlers to read in the sandbox state
+ * from a previous test run.
+ *
+ * @param state                Sandbox state to update
+ * @param fname                Filename of device tree file to read from
+ * @return 0 if OK, -ve on error
+ */
+int sandbox_read_state(struct sandbox_state *state, const char *fname);
+
+/**
+ * Write the sandbox state to the supplied device tree file
+ *
+ * This calls all registered state handlers to write out the sandbox state
+ * so that it can be preserved for a future test run.
+ *
+ * If the file exists it is overwritten.
+ *
+ * @param state                Sandbox state to update
+ * @param fname                Filename of device tree file to write to
+ * @return 0 if OK, -ve on error
+ */
+int sandbox_write_state(struct sandbox_state *state, const char *fname);
+
+/**
+ * Add a property to a sandbox state node
+ *
+ * This is equivalent to fdt_setprop except that it automatically enlarges
+ * the device tree if necessary. That means it is safe to write any amount
+ * of data here.
+ *
+ * This function can only be called from within struct sandbox_state_io's
+ * ->write method, i.e. within state I/O drivers.
+ *
+ * @param node         Device tree node to write to
+ * @param prop_name    Property to write
+ * @param data         Data to write into property
+ * @param size         Size of data to write into property
+ */
+int state_setprop(int node, const char *prop_name, const void *data, int size);
+
 /**
  * Initialize the test system state
  */
 int state_init(void);
 
+/**
+ * Uninitialize the test system state, writing out state if configured to
+ * do so.
+ *
+ * @return 0 if OK, -ve on error
+ */
+int state_uninit(void);
+
 #endif
index bed720cf81bfe5e79cd574d1d100ff13c5f1dc61..5707c2710d9fc1707ae25df940c82fe81260950f 100644 (file)
@@ -23,4 +23,6 @@ int dram_init(void);
 int sandbox_early_getopt_check(void);
 int sandbox_main_loop_init(void);
 
+int cleanup_before_linux(void);
+
 #endif /* _U_BOOT_SANDBOX_H_ */
index 8a0de9671461054bec076628d0ae08c680ce806c..69273b4f382fa38f3963a852201ccf5dbae59ea6 100644 (file)
@@ -12,7 +12,7 @@ PLATFORM_CPPFLAGS += -m2a -m2a-nofpu -mb -ffreestanding
 else # SH2
 PLATFORM_CPPFLAGS += -m3e -mb
 endif
-PLATFORM_CPPFLAGS += $(call cc-option,-mno-fdpic)
+PLATFORM_CPPFLAGS += -DCONFIG_SH2 $(call cc-option,-mno-fdpic)
 
 PLATFORM_RELFLAGS += -ffixed-r13
 PLATFORM_LDFLAGS += $(ENDIANNESS)
index 18479a4c40f3b6ddaafc771e7d6823791dce4e8f..a2f856f4594510f5aaeaa366894f03c1de2249a8 100644 (file)
 
 int checkcpu(void)
 {
-#if defined(CONFIG_SH2A)
-       puts("CPU: SH2A\n");
-#else
        puts("CPU: SH2\n");
-#endif
        return 0;
 }
 
index 5c77e5c32d9086719ed3411ebd90439cf27f1d0a..abd4b8d2bd96da122499a06b263ac2e332c4ab75 100644 (file)
@@ -11,5 +11,5 @@
 # SPDX-License-Identifier:     GPL-2.0+
 #
 #
-PLATFORM_CPPFLAGS += -m3
+PLATFORM_CPPFLAGS += -DCONFIG_SH3 -m3
 PLATFORM_RELFLAGS += -ffixed-r13
index c3575570e753603a93be95525a4fe0cad62e661c..753580beb1cc66524954c191e5250d73b8e55514 100644 (file)
@@ -8,5 +8,5 @@
 # SPDX-License-Identifier:     GPL-2.0+
 #
 #
-PLATFORM_CPPFLAGS += -m4-nofpu
+PLATFORM_CPPFLAGS += -DCONFIG_SH4 -m4-nofpu
 PLATFORM_RELFLAGS += -ffixed-r13
index 91133a38aee345a697ef52f24ec25b0d62d7ab6e..e8ee0a45ab93cd9f42c48110cc381a90724001ae 100644 (file)
 
 int checkcpu(void)
 {
-#ifdef CONFIG_SH4A
-       puts("CPU: SH-4A\n");
-#else
        puts("CPU: SH4\n");
-#endif
        return 0;
 }
 
index b21dc4422ed21355fa717228a6a4d51b98e79227..0698a377595df89d71e40ce62f0c1a402a98e49f 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef __ASM_SH_CACHE_H
 #define __ASM_SH_CACHE_H
 
-#if defined(CONFIG_SH4) || defined(CONFIG_SH4A)
+#if defined(CONFIG_SH4)
 
 int cache_control(unsigned int cmd);
 
@@ -18,7 +18,7 @@ struct __large_struct { unsigned long buf[100]; };
  */
 #define ARCH_DMA_MINALIGN      32
 
-#endif /* CONFIG_SH4 || CONFIG_SH4A */
+#endif /* CONFIG_SH4 */
 
 /*
  * Use the L1 data cache line size value for the minimum DMA buffer alignment
index 9181d59a947f2643ca51cafdf11c7c464fef03a2..9f48e4fe048317763af10aa7fda71af6c517e397 100644 (file)
@@ -37,6 +37,8 @@
 # include <asm/cpu_sh7734.h>
 #elif defined (CONFIG_CPU_SH7752)
 # include <asm/cpu_sh7752.h>
+#elif defined (CONFIG_CPU_SH7753)
+# include <asm/cpu_sh7753.h>
 #elif defined (CONFIG_CPU_SH7757)
 # include <asm/cpu_sh7757.h>
 #elif defined (CONFIG_CPU_SH7763)
diff --git a/arch/sh/include/asm/cpu_sh7753.h b/arch/sh/include/asm/cpu_sh7753.h
new file mode 100644 (file)
index 0000000..cd0e0bb
--- /dev/null
@@ -0,0 +1,197 @@
+/*
+ * Copyright (C) 2012  Renesas Solutions Corp.
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#ifndef _ASM_CPU_SH7753_H_
+#define _ASM_CPU_SH7753_H_
+
+#define CCR            0xFF00001C
+#define WTCNT          0xFFCC0000
+#define CCR_CACHE_INIT 0x0000090b
+#define CACHE_OC_NUM_WAYS      1
+
+#ifndef __ASSEMBLY__           /* put C only stuff in this section */
+/* MMU */
+struct mmu_regs {
+       unsigned int    reserved[4];
+       unsigned int    mmucr;
+};
+#define MMU_BASE       ((struct mmu_regs *)0xff000000)
+
+/* Watchdog */
+#define WTCSR0         0xffcc0002
+#define WRSTCSR_R      0xffcc0003
+#define WRSTCSR_W      0xffcc0002
+#define WTCSR_PREFIX           0xa500
+#define WRSTCSR_PREFIX         0x6900
+#define WRSTCSR_WOVF_PREFIX    0x9600
+
+/* SCIF */
+#define SCIF0_BASE     0xfe4b0000      /* The real name is SCIF2 */
+#define SCIF1_BASE     0xfe4c0000      /* The real name is SCIF3 */
+#define SCIF2_BASE     0xfe4d0000      /* The real name is SCIF4 */
+
+/* TMU0 */
+#define TMU_BASE        0xFE430000
+
+/* ETHER, GETHER MAC address */
+struct ether_mac_regs {
+       unsigned int    reserved[114];
+       unsigned int    mahr;
+       unsigned int    reserved2;
+       unsigned int    malr;
+};
+#define GETHER0_MAC_BASE       ((struct ether_mac_regs *)0xfee0400)
+#define GETHER1_MAC_BASE       ((struct ether_mac_regs *)0xfee0c00)
+#define ETHER0_MAC_BASE                ((struct ether_mac_regs *)0xfef0000)
+#define ETHER1_MAC_BASE                ((struct ether_mac_regs *)0xfef0800)
+
+/* GETHER */
+struct gether_control_regs {
+       unsigned int    gbecont;
+};
+#define GETHER_CONTROL_BASE    ((struct gether_control_regs *)0xffc10100)
+#define GBECONT_RMII1          0x00020000
+#define GBECONT_RMII0          0x00010000
+
+/* SerMux */
+struct sermux_regs {
+       unsigned char   smr0;
+       unsigned char   smr1;
+       unsigned char   smr2;
+       unsigned char   smr3;
+       unsigned char   smr4;
+       unsigned char   smr5;
+};
+#define SERMUX_BASE    ((struct sermux_regs *)0xfe470000)
+
+
+/* USB0/1 */
+struct usb_common_regs {
+       unsigned short  reserved[129];
+       unsigned short  suspmode;
+};
+#define USB0_COMMON_BASE       ((struct usb_common_regs *)0xfe450000)
+#define USB1_COMMON_BASE       ((struct usb_common_regs *)0xfe4f0000)
+
+struct usb0_phy_regs {
+       unsigned short  reset;
+       unsigned short  reserved[4];
+       unsigned short  portsel;
+};
+#define USB0_PHY_BASE          ((struct usb0_phy_regs *)0xfe5f0000)
+
+struct usb1_port_regs {
+       unsigned int    port1sel;
+       unsigned int    reserved;
+       unsigned int    usb1intsts;
+};
+#define USB1_PORT_BASE         ((struct usb1_port_regs *)0xfe4f2000)
+
+struct usb1_alignment_regs {
+       unsigned int    ehcidatac;      /* 0xfe4fe018 */
+       unsigned int    reserved[63];
+       unsigned int    ohcidatac;
+};
+#define USB1_ALIGNMENT_BASE    ((struct usb1_alignment_regs *)0xfe4fe018)
+
+/* GPIO */
+struct gpio_regs {
+       unsigned short  pacr;
+       unsigned short  pbcr;
+       unsigned short  pccr;
+       unsigned short  pdcr;
+       unsigned short  pecr;
+       unsigned short  pfcr;
+       unsigned short  pgcr;
+       unsigned short  phcr;
+       unsigned short  picr;
+       unsigned short  pjcr;
+       unsigned short  pkcr;
+       unsigned short  plcr;
+       unsigned short  pmcr;
+       unsigned short  pncr;
+       unsigned short  pocr;
+       unsigned short  reserved;
+       unsigned short  pqcr;
+       unsigned short  prcr;
+       unsigned short  pscr;
+       unsigned short  ptcr;
+       unsigned short  pucr;
+       unsigned short  pvcr;
+       unsigned short  pwcr;
+       unsigned short  pxcr;
+       unsigned short  pycr;
+       unsigned short  pzcr;
+       unsigned char   padr;
+       unsigned char   reserved_a;
+       unsigned char   pbdr;
+       unsigned char   reserved_b;
+       unsigned char   pcdr;
+       unsigned char   reserved_c;
+       unsigned char   pddr;
+       unsigned char   reserved_d;
+       unsigned char   pedr;
+       unsigned char   reserved_e;
+       unsigned char   pfdr;
+       unsigned char   reserved_f;
+       unsigned char   pgdr;
+       unsigned char   reserved_g;
+       unsigned char   phdr;
+       unsigned char   reserved_h;
+       unsigned char   pidr;
+       unsigned char   reserved_i;
+       unsigned char   pjdr;
+       unsigned char   reserved_j;
+       unsigned char   pkdr;
+       unsigned char   reserved_k;
+       unsigned char   pldr;
+       unsigned char   reserved_l;
+       unsigned char   pmdr;
+       unsigned char   reserved_m;
+       unsigned char   pndr;
+       unsigned char   reserved_n;
+       unsigned char   podr;
+       unsigned char   reserved_o;
+       unsigned char   ppdr;
+       unsigned char   reserved_p;
+       unsigned char   pqdr;
+       unsigned char   reserved_q;
+       unsigned char   prdr;
+       unsigned char   reserved_r;
+       unsigned char   psdr;
+       unsigned char   reserved_s;
+       unsigned char   ptdr;
+       unsigned char   reserved_t;
+       unsigned char   pudr;
+       unsigned char   reserved_u;
+       unsigned char   pvdr;
+       unsigned char   reserved_v;
+       unsigned char   pwdr;
+       unsigned char   reserved_w;
+       unsigned char   pxdr;
+       unsigned char   reserved_x;
+       unsigned char   pydr;
+       unsigned char   reserved_y;
+       unsigned char   pzdr;
+       unsigned char   reserved_z;
+       unsigned short  ncer;
+       unsigned short  ncmcr;
+       unsigned short  nccsr;
+       unsigned char   reserved2[2];
+       unsigned short  psel0;          /* +0x70 */
+       unsigned short  psel1;
+       unsigned short  psel2;
+       unsigned short  psel3;
+       unsigned short  psel4;
+       unsigned short  psel5;
+       unsigned short  psel6;
+       unsigned short  reserved3[2];
+       unsigned short  psel7;
+};
+#define GPIO_BASE      ((struct gpio_regs *)0xffec0000)
+
+#endif /* ifndef __ASSEMBLY__ */
+#endif /* _ASM_CPU_SH7753_H_ */
index 938a89cff50b1b54ea418aab1889b923364591a7..b8677da959358992714f9dd5f726630ac829dcf2 100644 (file)
@@ -1,12 +1,10 @@
 #ifndef _ASM_SH_PROCESSOR_H_
 #define _ASM_SH_PROCESSOR_H_
-#if defined(CONFIG_SH2) || \
-       defined (CONFIG_SH2A)
+#if defined(CONFIG_SH2)
 # include <asm/cpu_sh2.h>
-#elif defined (CONFIG_SH3)
+#elif defined(CONFIG_SH3)
 # include <asm/cpu_sh3.h>
-#elif defined (CONFIG_SH4) || \
-       defined (CONFIG_SH4A)
+#elif defined(CONFIG_SH4)
 # include <asm/cpu_sh4.h>
 #endif
 #endif
index be3896c3ed71a62129b63d94e0989aff4bc30b0a..4b1f47b6adf5cac2a9d73dd0383dd8ae4b97818f 100644 (file)
@@ -84,5 +84,5 @@ void __udelay(unsigned long usec)
 
 unsigned long get_tbclk(void)
 {
-       return CONFIG_SYS_HZ;
+       return CONFIG_SH_CMT_CLK_FREQ;
 }
index 0388226db485e893a6dd32b64f5508c518206eb1..cfc64fe51d6626793fd7bb6b9ed529c50769a2de 100644 (file)
@@ -10,6 +10,7 @@
 #include <netdev.h>
 #include <asm/blackfin.h>
 #include <asm/io.h>
+#include <asm/sdh.h>
 #include <asm/portmux.h>
 #include "soft_switch.h"
 
index 577dabf1d28012f5d813645f3e936b9c9af066ba..597d3914ca489637cb86e5c2e5163b8153743ce0 100644 (file)
@@ -2,6 +2,6 @@
 aa55aa55 010e0100
 # serdes protocol 0x2A_0x98
 140e0018 0f001218 00000000 00000000
-54980000 9000a000 f8025000 a9000000
+54980000 9000a000 e8104000 a9000000
 01000000 00000000 00000000 0001b1f8
 00000000 14000020 00000000 00000011
index 669fe8ad32cc451df03e0eebebdba32e57a6ff3e..c8ecf5de59190f2fd06ad06cccc266a2ef1db639 100644 (file)
@@ -30,7 +30,7 @@ struct fsl_e_tlb_entry tlb_table[] = {
        SET_TLB_ENTRY(1, 0xfffff000, 0xfffff000,
                      MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
                      0, 0, BOOKE_PAGESZ_4K, 1),
-#ifdef CONFIG_SPL_NAND_MINIMAL
+#ifdef CONFIG_SPL_NAND_BOOT
        SET_TLB_ENTRY(1, 0xffffe000, 0xffffe000,
                      MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
                      0, 10, BOOKE_PAGESZ_4K, 1),
index 02655e9bafd68275ffba14cb362341d4a5de22a5..07febc2b375ba1f8ff80003e8f5ee90b23f20457 100644 (file)
@@ -30,7 +30,7 @@ struct fsl_e_tlb_entry tlb_table[] = {
        SET_TLB_ENTRY(1, 0xfffff000, 0xfffff000,
                      MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
                      0, 0, BOOKE_PAGESZ_4K, 1),
-#ifdef CONFIG_SPL_NAND_MINIMAL
+#ifdef CONFIG_SPL_NAND_BOOT
        SET_TLB_ENTRY(1, 0xffffe000, 0xffffe000,
                      MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
                      0, 10, BOOKE_PAGESZ_4K, 1),
index 889c4938c00d538f2dabb6751e1993bac0b6b309..1f399d2496c8dc08ac2d89b4b2fe9e267c7ecf13 100644 (file)
@@ -5,8 +5,6 @@
 # SPDX-License-Identifier:     GPL-2.0+
 #
 
-CPPFLAGS += -I$(TOPDIR)
-
 obj-y                  += law.o
 obj-$(CONFIG_PCI)      += pci.o
 obj-y                  += tlb.o
index a7af0f675660a2cfc6b89dea395f31f198fbc259..a3d36b35d562c0dc53d506eef74b9d23bf2b55ee 100644 (file)
@@ -30,7 +30,7 @@ struct fsl_e_tlb_entry tlb_table[] = {
        SET_TLB_ENTRY(1, 0xfffff000, 0xfffff000,
                      MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
                      0, 0, BOOKE_PAGESZ_4K, 1),
-#ifdef CONFIG_SPL_NAND_MINIMAL
+#ifdef CONFIG_SPL_NAND_BOOT
        SET_TLB_ENTRY(1, 0xffffe000, 0xffffe000,
                      MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
                      0, 10, BOOKE_PAGESZ_4K, 1),
index 966abb24a681e4d9261ebe89d4059f205dd20a21..5f3d6fd28bf6676af107fb49a2144d961bb1005c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2010-2011 Freescale Semiconductor, Inc.
+ * Copyright 2010-2011, 2013 Freescale Semiconductor, Inc.
  *
  * SPDX-License-Identifier:    GPL-2.0+
  */
@@ -354,7 +354,7 @@ int board_eth_init(bd_t *bis)
                puts("No address specified for VSC7385 microcode.\n");
 #endif
 
-       mdio_info.regs = (struct tsec_mii_mng *)CONFIG_SYS_MDIO_BASE_ADDR;
+       mdio_info.regs = TSEC_GET_MDIO_REGS_BASE(1);
        mdio_info.name = DEFAULT_MII_NAME;
 
        fsl_pq_mdio_init(bis, &mdio_info);
index 624398a25df582afc61f2ab5d3148690c2818df3..10b1a6d179f687ca46e66a37516de02ef3546ad2 100644 (file)
@@ -3,7 +3,7 @@
 09010000 00200400
 09138000 00000000
 091380c0 00000100
-#Configure CPC1 as 512KB SRAM
+#Configure CPC1 as 256KB SRAM
 09010100 00000000
 09010104 fffc0007
 09010f00 08000000
index 2aa176c7a295d01e6161e99215691c85bb6384a5..de3ea5c2aa27abee534eb4679aa55dd42bb07a73 100644 (file)
@@ -239,3 +239,8 @@ void qixis_dump_switch(void)
                printf("SW%d = (0x%02x)\n", i, QIXIS_READ(cms[1]));
        }
 }
+
+int board_need_mem_reset(void)
+{
+       return 1;
+}
diff --git a/board/linkstation/Makefile b/board/linkstation/Makefile
deleted file mode 100644 (file)
index 3eeba7d..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-#
-# (C) Copyright 2001
-# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
-#
-# SPDX-License-Identifier:     GPL-2.0+
-#
-
-obj-y  = linkstation.o ide.o hwctl.o avr.o
diff --git a/board/linkstation/avr.c b/board/linkstation/avr.c
deleted file mode 100644 (file)
index 62e586b..0000000
+++ /dev/null
@@ -1,280 +0,0 @@
-/*
- * avr.c
- *
- * AVR functions
- *
- * Copyright (C) 2006 Mihai Georgian <u-boot@linuxnotincluded.org.uk>
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-#include <common.h>
-#include <ns16550.h>
-#include <stdio_dev.h>
-
-/* Button codes from the AVR */
-#define PWRR                   0x20            /* Power button release */
-#define PWRP                   0x21            /* Power button push    */
-#define RESR                   0x22            /* Reset button release */
-#define RESP                   0x23            /* Reset button push    */
-#define AVRINIT                        0x33            /* Init complete        */
-#define AVRRESET               0x31            /* Reset request        */
-
-/* LED commands */
-#define PWRBLINKSTRT           '['             /* Blink power LED      */
-#define PWRBLINKSTOP           'Z'             /* Solid power LED      */
-#define HDDLEDON               'W'             /* HDD LED on           */
-#define HDDLEDOFF              'V'             /* HDD LED off          */
-#define HDDBLINKSTRT           'Y'             /* HDD LED start blink  */
-#define HDDBLINKSTOP           'X'             /* HDD LED stop blink   */
-
-/* Timings for LEDs blinking to show choice */
-#define PULSETIME              250             /* msecs                */
-#define LONGPAUSE              (5 * PULSETIME)
-
-/* Button press times */
-#define PUSHHOLD               1000            /* msecs                */
-#define NOBUTTON               (6 * (LONGPAUSE+PULSETIME))
-
-/* Boot and console choices */
-#define MAX_BOOT_CHOICE                3
-
-static char *consoles[] = {
-       "serial",
-#if defined(CONFIG_NETCONSOLE)
-       "nc",
-#endif
-};
-#define MAX_CONS_CHOICE                (sizeof(consoles)/sizeof(char *))
-
-#if !defined(CONFIG_NETCONSOLE)
-#define DEF_CONS_CHOICE                0
-#else
-#define DEF_CONS_CHOICE                1
-#endif
-
-#define perror(fmt, args...) printf("%s: " fmt, __FUNCTION__ , ##args)
-
-extern void miconCntl_SendCmd(unsigned char dat);
-extern void miconCntl_DisWDT(void);
-
-static int boot_stop;
-
-static int boot_choice = 1;
-static int cons_choice = DEF_CONS_CHOICE;
-
-static char envbuffer[16];
-
-void init_AVR_DUART (void)
-{
-       NS16550_t AVR_port = (NS16550_t) CONFIG_SYS_NS16550_COM2;
-       int clock_divisor = CONFIG_SYS_NS16550_CLK / 16 / 9600;
-
-       /*
-        * AVR port init sequence taken from
-        * the original Linkstation init code
-        * Normal U-Boot serial reinit doesn't
-        * work because the AVR uses even parity
-        */
-       AVR_port->lcr = 0x00;
-       AVR_port->ier = 0x00;
-       AVR_port->lcr = UART_LCR_BKSE;
-       AVR_port->dll = clock_divisor & 0xff;
-       AVR_port->dlm = (clock_divisor >> 8) & 0xff;
-       AVR_port->lcr = UART_LCR_WLS_8 | UART_LCR_PEN | UART_LCR_EPS;
-       AVR_port->mcr = 0x00;
-       AVR_port->fcr = UART_FCR_FIFO_EN | UART_FCR_RXSR | UART_FCR_TXSR;
-
-       miconCntl_DisWDT();
-
-       boot_stop = 0;
-       miconCntl_SendCmd(PWRBLINKSTRT);
-}
-
-static inline int avr_tstc(void)
-{
-       return (NS16550_tstc((NS16550_t)CONFIG_SYS_NS16550_COM2));
-}
-
-static inline char avr_getc(void)
-{
-       return (NS16550_getc((NS16550_t)CONFIG_SYS_NS16550_COM2));
-}
-
-static int push_timeout(char button_code)
-{
-       ulong push_start = get_timer(0);
-       while (get_timer(push_start) <= PUSHHOLD)
-               if (avr_tstc() && avr_getc() == button_code)
-                       return 0;
-       return 1;
-}
-
-static void next_boot_choice(void)
-{
-       ulong return_start;
-       ulong pulse_start;
-       int on_times;
-       int button_on;
-       int led_state;
-       char c;
-
-       button_on = 0;
-       return_start = get_timer(0);
-
-       on_times = boot_choice;
-       led_state = 0;
-       miconCntl_SendCmd(HDDLEDOFF);
-       pulse_start = get_timer(0);
-
-       while (get_timer(return_start) <= NOBUTTON || button_on) {
-               if (avr_tstc()) {
-                       c = avr_getc();
-                       if (c == PWRP)
-                               button_on = 1;
-                       else if (c == PWRR) {
-                               button_on = 0;
-                               return_start = get_timer(0);
-                               if (++boot_choice > MAX_BOOT_CHOICE)
-                                       boot_choice = 1;
-                               sprintf(envbuffer, "bootcmd%d", boot_choice);
-                               if (getenv(envbuffer)) {
-                                       sprintf(envbuffer, "run bootcmd%d", boot_choice);
-                                       setenv("bootcmd", envbuffer);
-                               }
-                               on_times = boot_choice;
-                               led_state = 1;
-                               miconCntl_SendCmd(HDDLEDON);
-                               pulse_start = get_timer(0);
-                       } else {
-                               perror("Unexpected code: 0x%02X\n", c);
-                       }
-               }
-               if (on_times && get_timer(pulse_start) > PULSETIME) {
-                       if (led_state == 1) {
-                               --on_times;
-                               led_state = 0;
-                               miconCntl_SendCmd(HDDLEDOFF);
-                       } else {
-                               led_state = 1;
-                               miconCntl_SendCmd(HDDLEDON);
-                       }
-                       pulse_start = get_timer(0);
-               }
-               if (!on_times && get_timer(pulse_start) > LONGPAUSE) {
-                       on_times = boot_choice;
-                       led_state = 1;
-                       miconCntl_SendCmd(HDDLEDON);
-                       pulse_start = get_timer(0);
-               }
-       }
-       if (led_state)
-               miconCntl_SendCmd(HDDLEDOFF);
-}
-
-void next_cons_choice(int console)
-{
-       ulong return_start;
-       ulong pulse_start;
-       int on_times;
-       int button_on;
-       int led_state;
-       char c;
-
-       button_on = 0;
-       cons_choice = console;
-       return_start = get_timer(0);
-
-       on_times = cons_choice+1;
-       led_state = 1;
-       miconCntl_SendCmd(HDDLEDON);
-       pulse_start = get_timer(0);
-
-       while (get_timer(return_start) <= NOBUTTON || button_on) {
-               if (avr_tstc()) {
-                       c = avr_getc();
-                       if (c == RESP)
-                               button_on = 1;
-                       else if (c == RESR) {
-                               button_on = 0;
-                               return_start = get_timer(0);
-                               cons_choice = (cons_choice + 1) % MAX_CONS_CHOICE;
-                               console_assign(stdin, consoles[cons_choice]);
-                               console_assign(stdout, consoles[cons_choice]);
-                               console_assign(stderr, consoles[cons_choice]);
-                               on_times = cons_choice+1;
-                               led_state = 0;
-                               miconCntl_SendCmd(HDDLEDOFF);
-                               pulse_start = get_timer(0);
-                       } else {
-                               perror("Unexpected code: 0x%02X\n", c);
-                       }
-               }
-               if (on_times && get_timer(pulse_start) > PULSETIME) {
-                       if (led_state == 0) {
-                               --on_times;
-                               led_state = 1;
-                               miconCntl_SendCmd(HDDLEDON);
-                       } else {
-                               led_state = 0;
-                               miconCntl_SendCmd(HDDLEDOFF);
-                       }
-                       pulse_start = get_timer(0);
-               }
-               if (!on_times && get_timer(pulse_start) > LONGPAUSE) {
-                       on_times = cons_choice+1;
-                       led_state = 0;
-                       miconCntl_SendCmd(HDDLEDOFF);
-                       pulse_start = get_timer(0);
-               }
-       }
-       if (led_state);
-       miconCntl_SendCmd(HDDLEDOFF);
-}
-
-int avr_input(void)
-{
-       char avr_button;
-
-       if (!avr_tstc())
-               return 0;
-
-       avr_button = avr_getc();
-       switch (avr_button) {
-       case PWRP:
-               if (push_timeout(PWRR)) {
-                       /* Timeout before power button release */
-                       boot_stop = ~boot_stop;
-                       if (boot_stop)
-                               miconCntl_SendCmd(PWRBLINKSTOP);
-                       else
-                               miconCntl_SendCmd(PWRBLINKSTRT);
-                       /* Wait for power button release */
-                       while (avr_getc() != PWRR)
-                               ;
-               } else
-                       /* Power button released */
-                       next_boot_choice();
-               break;
-       case RESP:
-               /* Wait for Reset button release */
-               while (avr_getc() != RESR)
-                       ;
-               next_cons_choice(cons_choice);
-               break;
-       case AVRINIT:
-               return 0;
-       default:
-               perror("Unexpected code: 0x%02X\n", avr_button);
-               return 0;
-       }
-       if (boot_stop)
-               return (-3);
-       else
-               return (-2);
-}
-
-void avr_StopBoot(void)
-{
-       boot_stop = ~0;
-       miconCntl_SendCmd(PWRBLINKSTOP);
-}
diff --git a/board/linkstation/hwctl.c b/board/linkstation/hwctl.c
deleted file mode 100644 (file)
index d2090be..0000000
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * hwctl.c
- *
- * LinkStation HW Control Driver
- *
- * Copyright (C) 2001-2004  BUFFALO INC.
- *
- * This software may be used and distributed according to the terms of
- * the GNU General Public License (GPL), incorporated herein by reference.
- * Drivers based on or derived from this code fall under the GPL and must
- * retain the authorship, copyright and license notice.  This file is not
- * a complete program and may only be used when the entire operating
- * system is licensed under the GPL.
- *
- */
-
-#include <config.h>
-#include <common.h>
-#include <command.h>
-#include <asm/io.h>
-
-#define AVR_PORT CONFIG_SYS_NS16550_COM2
-
-/* 2005.5.10 BUFFALO add */
-/*--------------------------------------------------------------*/
-static inline void miconCntl_SendUart(unsigned char dat)
-{
-       out_8((unsigned char *)AVR_PORT, dat);
-       mdelay(1);
-}
-
-/*--------------------------------------------------------------*/
-void miconCntl_SendCmd(unsigned char dat)
-{
-       int i;
-
-       for (i=0; i<4; i++){
-               miconCntl_SendUart(dat);
-       }
-}
-
-/*--------------------------------------------------------------*/
-void miconCntl_FanLow(void)
-{
-#ifdef CONFIG_HTGL
-       miconCntl_SendCmd(0x5C);
-#endif
-}
-
-/*--------------------------------------------------------------*/
-void miconCntl_FanHigh(void)
-{
-#ifdef CONFIG_HTGL
-       miconCntl_SendCmd(0x5D);
-#endif
-}
-
-/*--------------------------------------------------------------*/
-/* 1000Mbps */
-void miconCntl_Eth1000M(int up)
-{
-#ifdef CONFIG_HTGL
-       if (up)
-               miconCntl_SendCmd(0x93);
-       else
-               miconCntl_SendCmd(0x92);
-#else
-       if (up)
-               miconCntl_SendCmd(0x5D);
-       else
-               miconCntl_SendCmd(0x5C);
-#endif
-}
-
-/*--------------------------------------------------------------*/
-/* 100Mbps */
-void miconCntl_Eth100M(int up)
-{
-#ifdef CONFIG_HTGL
-       if (up)
-               miconCntl_SendCmd(0x91);
-       else
-               miconCntl_SendCmd(0x90);
-#else
-       if (up)
-               miconCntl_SendCmd(0x5C);
-#endif
-}
-
-/*--------------------------------------------------------------*/
-/* 10Mbps */
-void miconCntl_Eth10M(int up)
-{
-#ifdef CONFIG_HTGL
-       if (up)
-               miconCntl_SendCmd(0x8F);
-       else
-               miconCntl_SendCmd(0x8E);
-#else
-       if (up)
-               miconCntl_SendCmd(0x5C);
-#endif
-}
-
-/*--------------------------------------------------------------*/
-/*  */
-void miconCntl_5f(void)
-{
-       miconCntl_SendCmd(0x5F);
-       mdelay(100);
-}
-
-/*--------------------------------------------------------------*/
-/* "reboot start" signal */
-void miconCntl_Reboot(void)
-{
-       miconCntl_SendCmd(0x43);
-}
-
-/*--------------------------------------------------------------*/
-/* Disable watchdog timer */
-void miconCntl_DisWDT(void)
-{
-       miconCntl_SendCmd(0x41); /* A */
-       miconCntl_SendCmd(0x46); /* F */
-       miconCntl_SendCmd(0x4A); /* J */
-       miconCntl_SendCmd(0x3E); /* > */
-       miconCntl_SendCmd(0x56); /* V */
-       miconCntl_SendCmd(0x3E); /* > */
-       miconCntl_SendCmd(0x5A); /* Z */
-       miconCntl_SendCmd(0x56); /* V */
-       miconCntl_SendCmd(0x4B); /* K */
-}
diff --git a/board/linkstation/ide.c b/board/linkstation/ide.c
deleted file mode 100644 (file)
index 7b3fe65..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * (C) Copyright 2000
- * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-/* ide.c - ide support functions */
-
-
-#include <common.h>
-
-#ifdef CONFIG_CMD_IDE
-#include <ata.h>
-#include <ide.h>
-#include <pci.h>
-
-#define IT8212_PCI_CpuCONTROL          0x5e
-#define IT8212_PCI_PciModeCONTROL      0x50
-#define IT8212_PCI_IdeIoCONFIG         0x40
-#define IT8212_PCI_IdeBusSkewCONTROL   0x4c
-#define IT8212_PCI_IdeDrivingCURRENT   0x42
-
-extern struct pci_controller hose;
-
-int ide_preinit (void)
-{
-       int status;
-       pci_dev_t devbusfn;
-       int l;
-
-       status = 1;
-       for (l = 0; l < CONFIG_SYS_IDE_MAXBUS; l++) {
-               ide_bus_offset[l] = -ATA_STATUS;
-       }
-       devbusfn = pci_find_device(PCI_VENDOR_ID_CMD, PCI_DEVICE_ID_SII_680, 0);
-       if (devbusfn == -1)
-               devbusfn = pci_find_device(PCI_VENDOR_ID_ITE,PCI_DEVICE_ID_ITE_8212,0);
-       if (devbusfn != -1) {
-               u32 ide_bus_offset32;
-
-               status = 0;
-
-               pci_read_config_dword (devbusfn, PCI_BASE_ADDRESS_0,
-                                                          &ide_bus_offset32);
-               ide_bus_offset[0] = ide_bus_offset32 & 0xfffffffe;
-               ide_bus_offset[0] = pci_hose_bus_to_phys(&hose,
-                                               ide_bus_offset[0] & 0xfffffffe,
-                                               PCI_REGION_IO);
-               if (CONFIG_SYS_IDE_MAXBUS > 1) {
-                       pci_read_config_dword(devbusfn, PCI_BASE_ADDRESS_2,
-                                             (u32 *) &ide_bus_offset[1]);
-                       ide_bus_offset[1] &= 0xfffffffe;
-                       ide_bus_offset[1] = pci_hose_bus_to_phys(&hose,
-                                               ide_bus_offset[1] & 0xfffffffe,
-                                               PCI_REGION_IO);
-               }
-       }
-
-       if (pci_find_device (PCI_VENDOR_ID_ITE, PCI_DEVICE_ID_ITE_8212, 0) != -1) {
-               pci_write_config_byte(devbusfn, IT8212_PCI_CpuCONTROL, 0x01);
-               pci_write_config_byte(devbusfn, IT8212_PCI_PciModeCONTROL, 0x00);
-               pci_write_config_word(devbusfn, PCI_COMMAND, 0x0047);
-#ifdef CONFIG_IT8212_SECONDARY_ENABLE
-               pci_write_config_word(devbusfn, IT8212_PCI_IdeIoCONFIG, 0xA0F3);
-#else
-               pci_write_config_word(devbusfn, IT8212_PCI_IdeIoCONFIG, 0x8031);
-#endif
-               pci_write_config_dword(devbusfn, IT8212_PCI_IdeBusSkewCONTROL, 0x02040204);
-/* __LS_COMMENT__ BUFFALO changed 2004.11.10  changed for EMI */
-               pci_write_config_byte(devbusfn, IT8212_PCI_IdeDrivingCURRENT, 0x36); /* 10mA */
-/*             pci_write_config_byte(dev, IT8212_PCI_IdeDrivingCURRENT, 0x09); */ /* 4mA */
-/*             pci_write_config_byte(dev, IT8212_PCI_IdeDrivingCURRENT, 0x12); */ /* 6mA */
-/*             pci_write_config_byte(dev, IT8212_PCI_IdeDrivingCURRENT, 0x24); */ /* 6mA,2mA */
-/*             pci_write_config_byte(dev, IT8212_PCI_IdeDrivingCURRENT, 0x2D); */ /* 8mA,4mA */
-               pci_write_config_byte(devbusfn, PCI_LATENCY_TIMER, 0x00);
-       }
-
-       return (status);
-}
-
-void ide_set_reset (int flag) {
-       return;
-}
-
-#endif /* CONFIG_CMD_IDE */
diff --git a/board/linkstation/linkstation.c b/board/linkstation/linkstation.c
deleted file mode 100644 (file)
index 75cda86..0000000
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * linkstation.c
- *
- * Misc LinkStation specific functions
- *
- * Copyright (C) 2006 Mihai Georgian <u-boot@linuxnotincluded.org.uk>
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#include <common.h>
-#include <version.h>
-#include <mpc824x.h>
-#include <asm/io.h>
-#include <ns16550.h>
-#include <netdev.h>
-
-#ifdef CONFIG_PCI
-#include <pci.h>
-#endif
-
-DECLARE_GLOBAL_DATA_PTR;
-
-extern void init_AVR_DUART(void);
-
-int checkboard (void)
-{
-       char *p;
-       bd_t *bd = gd->bd;
-
-       init_AVR_DUART();
-
-       if ((p = getenv ("console_nr")) != NULL) {
-               unsigned long con_nr = simple_strtoul (p, NULL, 10) & 3;
-
-               bd->bi_baudrate &= ~3;
-               bd->bi_baudrate |= con_nr & 3;
-       }
-       return 0;
-}
-
-phys_size_t initdram (int board_type)
-{
-       return (get_ram_size(CONFIG_SYS_SDRAM_BASE, CONFIG_SYS_MAX_RAM_SIZE));
-}
-
-/*
- * Initialize PCI Devices
- */
-#ifdef CONFIG_PCI
-
-#ifndef CONFIG_PCI_PNP
-
-static struct pci_config_table pci_linkstation_config_table[] = {
-       /* vendor, device, class */
-       /* bus, dev, func */
-       { PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
-         PCI_ANY_ID, 0x0b, 0,          /* AN983B or RTL8110S  */
-                                                               /* ethernet controller */
-         pci_cfgfunc_config_device, { PCI_ETH_IOADDR,
-                                      PCI_ETH_MEMADDR,
-                                      PCI_COMMAND_IO |
-                                      PCI_COMMAND_MEMORY |
-                                      PCI_COMMAND_MASTER }},
-       { PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
-         PCI_ANY_ID, 0x0c, 0,          /* SII680 or IT8211AF */
-                                                               /* ide controller     */
-         pci_cfgfunc_config_device, { PCI_IDE_IOADDR,
-                                      PCI_IDE_MEMADDR,
-                                      PCI_COMMAND_IO |
-                                      PCI_COMMAND_MEMORY |
-                                      PCI_COMMAND_MASTER }},
-       { PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
-         PCI_ANY_ID, 0x0e, 0,          /* D720101 USB controller, 1st USB 1.1 */
-         pci_cfgfunc_config_device, { PCI_USB0_IOADDR,
-                                      PCI_USB0_MEMADDR,
-                                      PCI_COMMAND_MEMORY |
-                                      PCI_COMMAND_MASTER }},
-       { PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
-         PCI_ANY_ID, 0x0e, 1,          /* D720101 USB controller, 2nd USB 1.1 */
-         pci_cfgfunc_config_device, { PCI_USB1_IOADDR,
-                                      PCI_USB1_MEMADDR,
-                                      PCI_COMMAND_MEMORY |
-                                      PCI_COMMAND_MASTER }},
-       { PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
-         PCI_ANY_ID, 0x0e, 2,          /* D720101 USB controller, USB 2.0 */
-         pci_cfgfunc_config_device, { PCI_USB2_IOADDR,
-                                      PCI_USB2_MEMADDR,
-                                      PCI_COMMAND_MEMORY |
-                                      PCI_COMMAND_MASTER }},
-       { }
-};
-#endif
-
-struct pci_controller hose = {
-#ifndef CONFIG_PCI_PNP
-       config_table:pci_linkstation_config_table,
-#endif
-};
-
-void pci_init_board (void)
-{
-       pci_mpc824x_init (&hose);
-
-       /* Reset USB 1.1 */
-       /* Haven't seen any change without these on a HG, maybe it is
-        * needed on other models */
-       out_le32((volatile unsigned*)(PCI_USB0_MEMADDR + 8), 1);
-       out_le32((volatile unsigned*)(PCI_USB1_MEMADDR + 8), 1);
-}
-#endif /* CONFIG_PCI */
-
-#define UART_DCR       0x80004511
-int board_early_init_f (void)
-{
-       /* set DUART mode */
-       out_8((volatile u8*)UART_DCR, 1);
-       return 0;
-}
-
-int board_eth_init(bd_t *bis)
-{
-       return pci_eth_init(bis);
-}
diff --git a/board/renesas/sh7753evb/Makefile b/board/renesas/sh7753evb/Makefile
new file mode 100644 (file)
index 0000000..f7c8e94
--- /dev/null
@@ -0,0 +1,7 @@
+#
+# Copyright (C) 2012  Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
+#
+# SPDX-License-Identifier:     GPL-2.0+
+
+obj-y  := sh7753evb.o spi-boot.o
+obj-y  += lowlevel_init.o
diff --git a/board/renesas/sh7753evb/lowlevel_init.S b/board/renesas/sh7753evb/lowlevel_init.S
new file mode 100644 (file)
index 0000000..21987a5
--- /dev/null
@@ -0,0 +1,416 @@
+/*
+ * Copyright (C) 2013  Renesas Solutions Corp.
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <config.h>
+#include <version.h>
+#include <asm/processor.h>
+#include <asm/macro.h>
+
+.macro or32, addr, data
+       mov.l \addr, r1
+       mov.l \data, r0
+       mov.l @r1, r2
+       or    r2, r0
+       mov.l r0, @r1
+.endm
+
+.macro wait_DBCMD
+       mov.l   DBWAIT_A, r0
+       mov.l   @r0, r1
+.endm
+
+       .global lowlevel_init
+       .section        .spiboot1.text
+       .align  2
+
+lowlevel_init:
+       mov     #0, r14
+       mova    2f, r0
+       mov.l   PC_MASK, r1
+       tst     r0, r1
+       bf      2f
+
+       bra     exit_pmb
+       nop
+
+       .align  2
+
+/* If CPU runs on SDRAM (PC=0x5???????) or not. */
+PC_MASK:       .long   0x20000000
+
+2:
+       mov     #1, r14
+
+       mov.l   EXPEVT_A, r0
+       mov.l   @r0, r0
+       mov.l   EXPEVT_POWER_ON_RESET, r1
+       cmp/eq  r0, r1
+       bt      1f
+
+       /*
+        * If EXPEVT value is manual reset or tlb multipul-hit,
+        * initialization of DBSC3 is not necessary.
+        */
+       bra     exit_ddr
+       nop
+
+1:
+       /*------- Reset -------*/
+       write32 MRSTCR0_A, MRSTCR0_D
+       write32 MRSTCR1_A, MRSTCR1_D
+
+       /* For Core Reset */
+       mov.l   DBACEN_A, r0
+       mov.l   @r0, r0
+       cmp/eq  #0, r0
+       bt      3f
+
+       /*
+        * If DBACEN == 1(DBSC was already enabled), we have to avoid the
+        * initialization of DDR3-SDRAM.
+        */
+       bra     exit_ddr
+       nop
+
+3:
+       /*------- DBSC3 -------*/
+       /* oscillation stabilization time */
+       wait_timer      WAIT_OSC_TIME
+
+       /* step 3 */
+       write32 DBKIND_A, DBKIND_D
+
+       /* step 4 */
+       write32 DBCONF_A, DBCONF_D
+       write32 DBTR0_A, DBTR0_D
+       write32 DBTR1_A, DBTR1_D
+       write32 DBTR2_A, DBTR2_D
+       write32 DBTR3_A, DBTR3_D
+       write32 DBTR4_A, DBTR4_D
+       write32 DBTR5_A, DBTR5_D
+       write32 DBTR6_A, DBTR6_D
+       write32 DBTR7_A, DBTR7_D
+       write32 DBTR8_A, DBTR8_D
+       write32 DBTR9_A, DBTR9_D
+       write32 DBTR10_A, DBTR10_D
+       write32 DBTR11_A, DBTR11_D
+       write32 DBTR12_A, DBTR12_D
+       write32 DBTR13_A, DBTR13_D
+       write32 DBTR14_A, DBTR14_D
+       write32 DBTR15_A, DBTR15_D
+       write32 DBTR16_A, DBTR16_D
+       write32 DBTR17_A, DBTR17_D
+       write32 DBTR18_A, DBTR18_D
+       write32 DBTR19_A, DBTR19_D
+       write32 DBRNK0_A, DBRNK0_D
+       write32 DBADJ0_A, DBADJ0_D
+       write32 DBADJ2_A, DBADJ2_D
+
+       /* step 5 */
+       write32 DBCMD_A, DBCMD_RSTL_VAL
+       wait_timer      WAIT_30US
+
+       /* step 6 */
+       write32 DBCMD_A, DBCMD_PDEN_VAL
+
+       /* step 7 */
+       write32 DBPDCNT3_A, DBPDCNT3_D
+
+       /* step 8 */
+       write32 DBPDCNT1_A, DBPDCNT1_D
+       write32 DBPDCNT2_A, DBPDCNT2_D
+       write32 DBPDLCK_A, DBPDLCK_D
+       write32 DBPDRGA_A, DBPDRGA_D
+       write32 DBPDRGD_A, DBPDRGD_D
+
+       /* step 9 */
+       wait_timer      WAIT_30US
+
+       /* step 10 */
+       write32 DBPDCNT0_A, DBPDCNT0_D
+
+       /* step 11 */
+       wait_timer      WAIT_30US
+       wait_timer      WAIT_30US
+
+       /* step 12 */
+       write32 DBCMD_A, DBCMD_WAIT_VAL
+       wait_DBCMD
+
+       /* step 13 */
+       write32 DBCMD_A, DBCMD_RSTH_VAL
+       wait_DBCMD
+
+       /* step 14 */
+       write32 DBCMD_A, DBCMD_WAIT_VAL
+       write32 DBCMD_A, DBCMD_WAIT_VAL
+       write32 DBCMD_A, DBCMD_WAIT_VAL
+       write32 DBCMD_A, DBCMD_WAIT_VAL
+
+       /* step 15 */
+       write32 DBCMD_A, DBCMD_PDXT_VAL
+
+       /* step 16 */
+       write32 DBCMD_A, DBCMD_MRS2_VAL
+
+       /* step 17 */
+       write32 DBCMD_A, DBCMD_MRS3_VAL
+
+       /* step 18 */
+       write32 DBCMD_A, DBCMD_MRS1_VAL
+
+       /* step 19 */
+       write32 DBCMD_A, DBCMD_MRS0_VAL
+       write32 DBPDNCNF_A, DBPDNCNF_D
+
+       /* step 20 */
+       write32 DBCMD_A, DBCMD_ZQCL_VAL
+
+       write32 DBCMD_A, DBCMD_REF_VAL
+       write32 DBCMD_A, DBCMD_REF_VAL
+       wait_DBCMD
+
+       /* step 21 */
+       write32 DBCALTR_A, DBCALTR_D
+
+       /* step 22 */
+       write32 DBRFCNF0_A, DBRFCNF0_D
+       write32 DBRFCNF1_A, DBRFCNF1_D
+       write32 DBRFCNF2_A, DBRFCNF2_D
+
+       /* step 23 */
+       write32 DBCALCNF_A, DBCALCNF_D
+
+       /* step 24 */
+       write32 DBRFEN_A, DBRFEN_D
+       write32 DBCMD_A, DBCMD_SRXT_VAL
+
+       /* step 25 */
+       write32 DBACEN_A, DBACEN_D
+
+       /* step 26 */
+       wait_DBCMD
+
+       bra     exit_ddr
+       nop
+
+       .align 2
+
+EXPEVT_A:              .long   0xff000024
+EXPEVT_POWER_ON_RESET: .long   0x00000000
+
+/*------- Reset -------*/
+MRSTCR0_A:     .long   0xffd50030
+MRSTCR0_D:     .long   0xfe1ffe7f
+MRSTCR1_A:     .long   0xffd50034
+MRSTCR1_D:     .long   0xfff3ffff
+
+/*------- DBSC3 -------*/
+DBCMD_A:       .long   0xfe800018
+DBKIND_A:      .long   0xfe800020
+DBCONF_A:      .long   0xfe800024
+DBTR0_A:       .long   0xfe800040
+DBTR1_A:       .long   0xfe800044
+DBTR2_A:       .long   0xfe800048
+DBTR3_A:       .long   0xfe800050
+DBTR4_A:       .long   0xfe800054
+DBTR5_A:       .long   0xfe800058
+DBTR6_A:       .long   0xfe80005c
+DBTR7_A:       .long   0xfe800060
+DBTR8_A:       .long   0xfe800064
+DBTR9_A:       .long   0xfe800068
+DBTR10_A:      .long   0xfe80006c
+DBTR11_A:      .long   0xfe800070
+DBTR12_A:      .long   0xfe800074
+DBTR13_A:      .long   0xfe800078
+DBTR14_A:      .long   0xfe80007c
+DBTR15_A:      .long   0xfe800080
+DBTR16_A:      .long   0xfe800084
+DBTR17_A:      .long   0xfe800088
+DBTR18_A:      .long   0xfe80008c
+DBTR19_A:      .long   0xfe800090
+DBRNK0_A:      .long   0xfe800100
+DBPDCNT0_A:    .long   0xfe800200
+DBPDCNT1_A:    .long   0xfe800204
+DBPDCNT2_A:    .long   0xfe800208
+DBPDCNT3_A:    .long   0xfe80020c
+DBPDLCK_A:     .long   0xfe800280
+DBPDRGA_A:     .long   0xfe800290
+DBPDRGD_A:     .long   0xfe8002a0
+DBADJ0_A:      .long   0xfe8000c0
+DBADJ2_A:      .long   0xfe8000c8
+DBRFCNF0_A:    .long   0xfe8000e0
+DBRFCNF1_A:    .long   0xfe8000e4
+DBRFCNF2_A:    .long   0xfe8000e8
+DBCALCNF_A:    .long   0xfe8000f4
+DBRFEN_A:      .long   0xfe800014
+DBACEN_A:      .long   0xfe800010
+DBWAIT_A:      .long   0xfe80001c
+DBCALTR_A:     .long   0xfe8000f8
+DBPDNCNF_A:    .long   0xfe800180
+
+WAIT_OSC_TIME: .long   6000
+WAIT_30US:     .long   13333
+
+DBCMD_RSTL_VAL:        .long   0x20000000
+DBCMD_PDEN_VAL:        .long   0x1000d73c
+DBCMD_WAIT_VAL:        .long   0x0000d73c
+DBCMD_RSTH_VAL:        .long   0x2100d73c
+DBCMD_PDXT_VAL:        .long   0x110000c8
+DBCMD_MRS0_VAL:        .long   0x28000930
+DBCMD_MRS1_VAL:        .long   0x29000004
+DBCMD_MRS2_VAL:        .long   0x2a000008
+DBCMD_MRS3_VAL:        .long   0x2b000000
+DBCMD_ZQCL_VAL:        .long   0x03000200
+DBCMD_REF_VAL: .long   0x0c000000
+DBCMD_SRXT_VAL:        .long   0x19000000
+DBKIND_D:      .long   0x00000007
+DBCONF_D:      .long   0x0f030a01
+DBTR0_D:       .long   0x00000007
+DBTR1_D:       .long   0x00000006
+DBTR2_D:       .long   0x00000000
+DBTR3_D:       .long   0x00000007
+DBTR4_D:       .long   0x00070007
+DBTR5_D:       .long   0x0000001b
+DBTR6_D:       .long   0x00000014
+DBTR7_D:       .long   0x00000004
+DBTR8_D:       .long   0x00000014
+DBTR9_D:       .long   0x00000004
+DBTR10_D:      .long   0x00000008
+DBTR11_D:      .long   0x00000007
+DBTR12_D:      .long   0x0000000e
+DBTR13_D:      .long   0x000000a0
+DBTR14_D:      .long   0x00060006
+DBTR15_D:      .long   0x00000003
+DBTR16_D:      .long   0x00160002
+DBTR17_D:      .long   0x000c0000
+DBTR18_D:      .long   0x00000200
+DBTR19_D:      .long   0x00000040
+DBRNK0_D:      .long   0x00000001
+DBPDCNT0_D:    .long   0x00000001
+DBPDCNT1_D:    .long   0x00000001
+DBPDCNT2_D:    .long   0x00000000
+DBPDCNT3_D:    .long   0x00004010
+DBPDLCK_D:     .long   0x0000a55a
+DBPDRGA_D:     .long   0x00000028
+DBPDRGD_D:     .long   0x00017100
+
+DBADJ0_D:      .long   0x00010000
+DBADJ2_D:      .long   0x18061806
+DBRFCNF0_D:    .long   0x000001ff
+DBRFCNF1_D:    .long   0x00081040
+DBRFCNF2_D:    .long   0x00000000
+DBCALCNF_D:    .long   0x0000ffff
+DBRFEN_D:      .long   0x00000001
+DBACEN_D:      .long   0x00000001
+DBCALTR_D:     .long   0x08200820
+DBPDNCNF_D:    .long   0x00000001
+
+       .align 2
+exit_ddr:
+#if defined(CONFIG_SH_32BIT)
+       /*------- set PMB -------*/
+       write32 PASCR_A,        PASCR_29BIT_D
+       write32 MMUCR_A,        MMUCR_D
+
+       /*****************************************************************
+        * ent  virt            phys            v       sz      c       wt
+        * 0    0xa0000000      0x00000000      1       128M    0       1
+        * 1    0xa8000000      0x48000000      1       128M    0       1
+        * 5    0x88000000      0x48000000      1       128M    1       1
+        */
+       write32 PMB_ADDR_SPIBOOT_A,     PMB_ADDR_SPIBOOT_D
+       write32 PMB_DATA_SPIBOOT_A,     PMB_DATA_SPIBOOT_D
+       write32 PMB_ADDR_DDR_C1_A,      PMB_ADDR_DDR_C1_D
+       write32 PMB_DATA_DDR_C1_A,      PMB_DATA_DDR_C1_D
+       write32 PMB_ADDR_DDR_N1_A,      PMB_ADDR_DDR_N1_D
+       write32 PMB_DATA_DDR_N1_A,      PMB_DATA_DDR_N1_D
+
+       write32 PMB_ADDR_ENTRY2,        PMB_ADDR_NOT_USE_D
+       write32 PMB_ADDR_ENTRY3,        PMB_ADDR_NOT_USE_D
+       write32 PMB_ADDR_ENTRY4,        PMB_ADDR_NOT_USE_D
+       write32 PMB_ADDR_ENTRY6,        PMB_ADDR_NOT_USE_D
+       write32 PMB_ADDR_ENTRY7,        PMB_ADDR_NOT_USE_D
+       write32 PMB_ADDR_ENTRY8,        PMB_ADDR_NOT_USE_D
+       write32 PMB_ADDR_ENTRY9,        PMB_ADDR_NOT_USE_D
+       write32 PMB_ADDR_ENTRY10,       PMB_ADDR_NOT_USE_D
+       write32 PMB_ADDR_ENTRY11,       PMB_ADDR_NOT_USE_D
+       write32 PMB_ADDR_ENTRY12,       PMB_ADDR_NOT_USE_D
+       write32 PMB_ADDR_ENTRY13,       PMB_ADDR_NOT_USE_D
+       write32 PMB_ADDR_ENTRY14,       PMB_ADDR_NOT_USE_D
+       write32 PMB_ADDR_ENTRY15,       PMB_ADDR_NOT_USE_D
+
+       write32 PASCR_A,        PASCR_INIT
+       mov.l   DUMMY_ADDR, r0
+       icbi    @r0
+#endif /* if defined(CONFIG_SH_32BIT) */
+
+exit_pmb:
+       /* CPU is running on ILRAM? */
+       mov     r14, r0
+       tst     #1, r0
+       bt      1f
+
+       mov.l   _stack_ilram, r15
+       mov.l   _spiboot_main, r0
+100:   bsrf    r0
+       nop
+
+       .align  2
+_spiboot_main: .long   (spiboot_main - (100b + 4))
+_stack_ilram:  .long   0xe5204000
+
+1:
+       write32 CCR_A,  CCR_D
+
+       rts
+        nop
+
+       .align 2
+
+#if defined(CONFIG_SH_32BIT)
+/*------- set PMB -------*/
+PMB_ADDR_SPIBOOT_A:    .long   PMB_ADDR_BASE(0)
+PMB_ADDR_DDR_N1_A:     .long   PMB_ADDR_BASE(1)
+PMB_ADDR_DDR_C1_A:     .long   PMB_ADDR_BASE(5)
+PMB_ADDR_ENTRY2:       .long   PMB_ADDR_BASE(2)
+PMB_ADDR_ENTRY3:       .long   PMB_ADDR_BASE(3)
+PMB_ADDR_ENTRY4:       .long   PMB_ADDR_BASE(4)
+PMB_ADDR_ENTRY6:       .long   PMB_ADDR_BASE(6)
+PMB_ADDR_ENTRY7:       .long   PMB_ADDR_BASE(7)
+PMB_ADDR_ENTRY8:       .long   PMB_ADDR_BASE(8)
+PMB_ADDR_ENTRY9:       .long   PMB_ADDR_BASE(9)
+PMB_ADDR_ENTRY10:      .long   PMB_ADDR_BASE(10)
+PMB_ADDR_ENTRY11:      .long   PMB_ADDR_BASE(11)
+PMB_ADDR_ENTRY12:      .long   PMB_ADDR_BASE(12)
+PMB_ADDR_ENTRY13:      .long   PMB_ADDR_BASE(13)
+PMB_ADDR_ENTRY14:      .long   PMB_ADDR_BASE(14)
+PMB_ADDR_ENTRY15:      .long   PMB_ADDR_BASE(15)
+
+PMB_ADDR_SPIBOOT_D:    .long   mk_pmb_addr_val(0xa0)
+PMB_ADDR_DDR_C1_D:     .long   mk_pmb_addr_val(0x88)
+PMB_ADDR_DDR_N1_D:     .long   mk_pmb_addr_val(0xa8)
+PMB_ADDR_NOT_USE_D:    .long   0x00000000
+
+PMB_DATA_SPIBOOT_A:    .long   PMB_DATA_BASE(0)
+PMB_DATA_DDR_N1_A:     .long   PMB_DATA_BASE(1)
+PMB_DATA_DDR_C1_A:     .long   PMB_DATA_BASE(5)
+
+/*                                             ppn   ub v s1 s0  c  wt */
+PMB_DATA_SPIBOOT_D:    .long   mk_pmb_data_val(0x00, 0, 1, 1, 0, 0, 1)
+PMB_DATA_DDR_C1_D:     .long   mk_pmb_data_val(0x48, 0, 1, 1, 0, 1, 1)
+PMB_DATA_DDR_N1_D:     .long   mk_pmb_data_val(0x48, 1, 1, 1, 0, 0, 1)
+
+PASCR_A:               .long   0xff000070
+DUMMY_ADDR:            .long   0xa0000000
+PASCR_29BIT_D:         .long   0x00000000
+PASCR_INIT:            .long   0x80000080
+MMUCR_A:               .long   0xff000010
+MMUCR_D:               .long   0x00000004      /* clear ITLB */
+#endif /* CONFIG_SH_32BIT */
+
+CCR_A:         .long   CCR
+CCR_D:         .long   CCR_CACHE_INIT
diff --git a/board/renesas/sh7753evb/sh7753evb.c b/board/renesas/sh7753evb/sh7753evb.c
new file mode 100644 (file)
index 0000000..42b920f
--- /dev/null
@@ -0,0 +1,326 @@
+/*
+ * Copyright (C) 2012  Renesas Solutions Corp.
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <common.h>
+#include <malloc.h>
+#include <asm/processor.h>
+#include <asm/io.h>
+#include <asm/mmc.h>
+#include <spi_flash.h>
+
+int checkboard(void)
+{
+       puts("BOARD: SH7753 EVB\n");
+
+       return 0;
+}
+
+static void init_gpio(void)
+{
+       struct gpio_regs *gpio = GPIO_BASE;
+       struct sermux_regs *sermux = SERMUX_BASE;
+
+       /* GPIO */
+       writew(0x0000, &gpio->pacr);    /* GETHER */
+       writew(0x0001, &gpio->pbcr);    /* INTC */
+       writew(0x0000, &gpio->pccr);    /* PWMU, INTC */
+       writew(0x0000, &gpio->pdcr);    /* SPI0 */
+       writew(0xeaff, &gpio->pecr);    /* GPIO */
+       writew(0x0000, &gpio->pfcr);    /* WDT */
+       writew(0x0004, &gpio->pgcr);    /* SPI0, GETHER MDIO gate(PTG1) */
+       writew(0x0000, &gpio->phcr);    /* SPI1 */
+       writew(0x0000, &gpio->picr);    /* SDHI */
+       writew(0x0000, &gpio->pjcr);    /* SCIF4 */
+       writew(0x0003, &gpio->pkcr);    /* SerMux */
+       writew(0x0000, &gpio->plcr);    /* SerMux */
+       writew(0x0000, &gpio->pmcr);    /* RIIC */
+       writew(0x0000, &gpio->pncr);    /* USB, SGPIO */
+       writew(0x0000, &gpio->pocr);    /* SGPIO */
+       writew(0xd555, &gpio->pqcr);    /* GPIO */
+       writew(0x0000, &gpio->prcr);    /* RIIC */
+       writew(0x0000, &gpio->pscr);    /* RIIC */
+       writew(0x0000, &gpio->ptcr);    /* STATUS */
+       writeb(0x00, &gpio->pudr);
+       writew(0x5555, &gpio->pucr);    /* Debug LED */
+       writew(0x0000, &gpio->pvcr);    /* RSPI */
+       writew(0x0000, &gpio->pwcr);    /* EVC */
+       writew(0x0000, &gpio->pxcr);    /* LBSC */
+       writew(0x0000, &gpio->pycr);    /* LBSC */
+       writew(0x0000, &gpio->pzcr);    /* eMMC */
+       writew(0xfe00, &gpio->psel0);
+       writew(0x0000, &gpio->psel1);
+       writew(0x3000, &gpio->psel2);
+       writew(0xff00, &gpio->psel3);
+       writew(0x771f, &gpio->psel4);
+       writew(0x0ffc, &gpio->psel5);
+       writew(0x00ff, &gpio->psel6);
+       writew(0xfc00, &gpio->psel7);
+
+       writeb(0x10, &sermux->smr0);    /* SMR0: SerMux mode 0 */
+}
+
+static void init_usb_phy(void)
+{
+       struct usb_common_regs *common0 = USB0_COMMON_BASE;
+       struct usb_common_regs *common1 = USB1_COMMON_BASE;
+       struct usb0_phy_regs *phy = USB0_PHY_BASE;
+       struct usb1_port_regs *port = USB1_PORT_BASE;
+       struct usb1_alignment_regs *align = USB1_ALIGNMENT_BASE;
+
+       writew(0x0100, &phy->reset);            /* set reset */
+       /* port0 = USB0, port1 = USB1 */
+       writew(0x0002, &phy->portsel);
+       writel(0x0001, &port->port1sel);        /* port1 = Host */
+       writew(0x0111, &phy->reset);            /* clear reset */
+
+       writew(0x4000, &common0->suspmode);
+       writew(0x4000, &common1->suspmode);
+
+#if defined(__LITTLE_ENDIAN)
+       writel(0x00000000, &align->ehcidatac);
+       writel(0x00000000, &align->ohcidatac);
+#endif
+}
+
+static void init_gether_mdio(void)
+{
+       struct gpio_regs *gpio = GPIO_BASE;
+
+       writew(readw(&gpio->pgcr) | 0x0004, &gpio->pgcr);
+       writeb(readb(&gpio->pgdr) | 0x02, &gpio->pgdr); /* Use ET0-MDIO */
+}
+
+static void set_mac_to_sh_giga_eth_register(int channel, char *mac_string)
+{
+       struct ether_mac_regs *ether;
+       unsigned char mac[6];
+       unsigned long val;
+
+       eth_parse_enetaddr(mac_string, mac);
+
+       if (!channel)
+               ether = GETHER0_MAC_BASE;
+       else
+               ether = GETHER1_MAC_BASE;
+
+       val = (mac[0] << 24) | (mac[1] << 16) | (mac[2] << 8) | mac[3];
+       writel(val, &ether->mahr);
+       val = (mac[4] << 8) | mac[5];
+       writel(val, &ether->malr);
+}
+
+/*****************************************************************
+ * This PMB must be set on this timing. The lowlevel_init is run on
+ * Area 0(phys 0x00000000), so we have to map it.
+ *
+ * The new PMB table is following:
+ * ent virt            phys            v       sz      c       wt
+ * 0   0xa0000000      0x40000000      1       128M    0       1
+ * 1   0xa8000000      0x48000000      1       128M    0       1
+ * 2   0xb0000000      0x50000000      1       128M    0       1
+ * 3   0xb8000000      0x58000000      1       128M    0       1
+ * 4   0x80000000      0x40000000      1       128M    1       1
+ * 5   0x88000000      0x48000000      1       128M    1       1
+ * 6   0x90000000      0x50000000      1       128M    1       1
+ * 7   0x98000000      0x58000000      1       128M    1       1
+ */
+static void set_pmb_on_board_init(void)
+{
+       struct mmu_regs *mmu = MMU_BASE;
+
+       /* clear ITLB */
+       writel(0x00000004, &mmu->mmucr);
+
+       /* delete PMB for SPIBOOT */
+       writel(0, PMB_ADDR_BASE(0));
+       writel(0, PMB_DATA_BASE(0));
+
+       /* add PMB for SDRAM(0x40000000 - 0x47ffffff) */
+       /*                      ppn  ub v s1 s0  c  wt */
+       writel(mk_pmb_addr_val(0xa0), PMB_ADDR_BASE(0));
+       writel(mk_pmb_data_val(0x40, 1, 1, 1, 0, 0, 1), PMB_DATA_BASE(0));
+       writel(mk_pmb_addr_val(0xb0), PMB_ADDR_BASE(2));
+       writel(mk_pmb_data_val(0x50, 1, 1, 1, 0, 0, 1), PMB_DATA_BASE(2));
+       writel(mk_pmb_addr_val(0xb8), PMB_ADDR_BASE(3));
+       writel(mk_pmb_data_val(0x58, 1, 1, 1, 0, 0, 1), PMB_DATA_BASE(3));
+       writel(mk_pmb_addr_val(0x80), PMB_ADDR_BASE(4));
+       writel(mk_pmb_data_val(0x40, 0, 1, 1, 0, 1, 1), PMB_DATA_BASE(4));
+       writel(mk_pmb_addr_val(0x90), PMB_ADDR_BASE(6));
+       writel(mk_pmb_data_val(0x50, 0, 1, 1, 0, 1, 1), PMB_DATA_BASE(6));
+       writel(mk_pmb_addr_val(0x98), PMB_ADDR_BASE(7));
+       writel(mk_pmb_data_val(0x58, 0, 1, 1, 0, 1, 1), PMB_DATA_BASE(7));
+}
+
+int board_init(void)
+{
+       struct gether_control_regs *gether = GETHER_CONTROL_BASE;
+
+       init_gpio();
+       set_pmb_on_board_init();
+
+       /* Sets TXnDLY to B'010 */
+       writel(0x00000202, &gether->gbecont);
+
+       init_usb_phy();
+       init_gether_mdio();
+
+       return 0;
+}
+
+int dram_init(void)
+{
+       DECLARE_GLOBAL_DATA_PTR;
+
+       gd->bd->bi_memstart = CONFIG_SYS_SDRAM_BASE;
+       gd->bd->bi_memsize = CONFIG_SYS_SDRAM_SIZE;
+       printf("DRAM:  %dMB\n", CONFIG_SYS_SDRAM_SIZE / (1024 * 1024));
+
+       return 0;
+}
+
+int board_mmc_init(bd_t *bis)
+{
+       struct gpio_regs *gpio = GPIO_BASE;
+
+       writew(readw(&gpio->pgcr) | 0x0040, &gpio->pgcr);
+       writeb(readb(&gpio->pgdr) & ~0x08, &gpio->pgdr); /* Reset */
+       udelay(1);
+       writeb(readb(&gpio->pgdr) | 0x08, &gpio->pgdr); /* Release reset */
+       udelay(200);
+
+       return mmcif_mmc_init();
+}
+
+static int get_sh_eth_mac_raw(unsigned char *buf, int size)
+{
+       struct spi_flash *spi;
+       int ret;
+
+       spi = spi_flash_probe(0, 0, 1000000, SPI_MODE_3);
+       if (spi == NULL) {
+               printf("%s: spi_flash probe failed.\n", __func__);
+               return 1;
+       }
+
+       ret = spi_flash_read(spi, SH7753EVB_ETHERNET_MAC_BASE, size, buf);
+       if (ret) {
+               printf("%s: spi_flash read failed.\n", __func__);
+               spi_flash_free(spi);
+               return 1;
+       }
+       spi_flash_free(spi);
+
+       return 0;
+}
+
+static int get_sh_eth_mac(int channel, char *mac_string, unsigned char *buf)
+{
+       memcpy(mac_string, &buf[channel * (SH7753EVB_ETHERNET_MAC_SIZE + 1)],
+               SH7753EVB_ETHERNET_MAC_SIZE);
+       mac_string[SH7753EVB_ETHERNET_MAC_SIZE] = 0x00; /* terminate */
+
+       return 0;
+}
+
+static void init_ethernet_mac(void)
+{
+       char mac_string[64];
+       char env_string[64];
+       int i;
+       unsigned char *buf;
+
+       buf = malloc(256);
+       if (!buf) {
+               printf("%s: malloc failed.\n", __func__);
+               return;
+       }
+       get_sh_eth_mac_raw(buf, 256);
+
+       /* Gigabit Ethernet */
+       for (i = 0; i < SH7753EVB_ETHERNET_NUM_CH; i++) {
+               get_sh_eth_mac(i, mac_string, buf);
+               if (i == 0)
+                       setenv("ethaddr", mac_string);
+               else {
+                       sprintf(env_string, "eth%daddr", i);
+                       setenv(env_string, mac_string);
+               }
+               set_mac_to_sh_giga_eth_register(i, mac_string);
+       }
+
+       free(buf);
+}
+
+int board_late_init(void)
+{
+       init_ethernet_mac();
+
+       return 0;
+}
+
+int do_write_mac(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+       int i, ret;
+       char mac_string[256];
+       struct spi_flash *spi;
+       unsigned char *buf;
+
+       if (argc != 3) {
+               buf = malloc(256);
+               if (!buf) {
+                       printf("%s: malloc failed.\n", __func__);
+                       return 1;
+               }
+
+               get_sh_eth_mac_raw(buf, 256);
+
+               /* print current MAC address */
+               for (i = 0; i < SH7753EVB_ETHERNET_NUM_CH; i++) {
+                       get_sh_eth_mac(i, mac_string, buf);
+                       printf("GETHERC ch%d = %s\n", i, mac_string);
+               }
+               free(buf);
+               return 0;
+       }
+
+       /* new setting */
+       memset(mac_string, 0xff, sizeof(mac_string));
+       sprintf(mac_string, "%s\t%s",
+               argv[1], argv[2]);
+
+       /* write MAC data to SPI rom */
+       spi = spi_flash_probe(0, 0, 1000000, SPI_MODE_3);
+       if (!spi) {
+               printf("%s: spi_flash probe failed.\n", __func__);
+               return 1;
+       }
+
+       ret = spi_flash_erase(spi, SH7753EVB_ETHERNET_MAC_BASE_SPI,
+                               SH7753EVB_SPI_SECTOR_SIZE);
+       if (ret) {
+               printf("%s: spi_flash erase failed.\n", __func__);
+               return 1;
+       }
+
+       ret = spi_flash_write(spi, SH7753EVB_ETHERNET_MAC_BASE_SPI,
+                               sizeof(mac_string), mac_string);
+       if (ret) {
+               printf("%s: spi_flash write failed.\n", __func__);
+               spi_flash_free(spi);
+               return 1;
+       }
+       spi_flash_free(spi);
+
+       puts("The writing of the MAC address to SPI ROM was completed.\n");
+
+       return 0;
+}
+
+U_BOOT_CMD(
+       write_mac,      3,      1,      do_write_mac,
+       "write MAC address for GETHERC",
+       "[GETHERC ch0] [GETHERC ch1]\n"
+);
diff --git a/board/renesas/sh7753evb/spi-boot.c b/board/renesas/sh7753evb/spi-boot.c
new file mode 100644 (file)
index 0000000..21903d9
--- /dev/null
@@ -0,0 +1,134 @@
+/*
+ * Copyright (C) 2013  Renesas Solutions Corp.
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <common.h>
+
+#define CONFIG_SPI_ADDR                0x00000000
+#define PHYADDR(_addr)         ((_addr & 0x1fffffff) | 0x40000000)
+#define CONFIG_RAM_BOOT_PHYS   PHYADDR(CONFIG_SYS_TEXT_BASE)
+
+#define SPIWDMADR      0xFE001018
+#define SPIWDMCNTR     0xFE001020
+#define SPIDMCOR       0xFE001028
+#define SPIDMINTSR     0xFE001188
+#define SPIDMINTMR     0xFE001190
+
+#define SPIDMINTSR_DMEND       0x00000004
+
+#define TBR    0xFE002000
+#define RBR    0xFE002000
+
+#define CR1    0xFE002008
+#define CR2    0xFE002010
+#define CR3    0xFE002018
+#define CR4    0xFE002020
+#define CR7    0xFE002038
+#define CR8    0xFE002040
+
+/* CR1 */
+#define SPI_TBE                0x80
+#define SPI_TBF                0x40
+#define SPI_RBE                0x20
+#define SPI_RBF                0x10
+#define SPI_PFONRD     0x08
+#define SPI_SSDB       0x04
+#define SPI_SSD                0x02
+#define SPI_SSA                0x01
+
+/* CR2 */
+#define SPI_RSTF       0x80
+#define SPI_LOOPBK     0x40
+#define SPI_CPOL       0x20
+#define SPI_CPHA       0x10
+#define SPI_L1M0       0x08
+
+/* CR4 */
+#define SPI_TBEI       0x80
+#define SPI_TBFI       0x40
+#define SPI_RBEI       0x20
+#define SPI_RBFI       0x10
+#define SPI_SpiS0      0x02
+#define SPI_SSS                0x01
+
+/* CR7 */
+#define CR7_IDX_OR12   0x12
+#define OR12_ADDR32    0x00000001
+
+#define spi_write(val, addr)   (*(volatile unsigned long *)(addr)) = val
+#define spi_read(addr)         (*(volatile unsigned long *)(addr))
+
+/* M25P80 */
+#define M25_READ       0x03
+#define M25_READ_4BYTE 0x13
+
+extern void bss_start(void);
+
+#define __uses_spiboot2        __attribute__((section(".spiboot2.text")))
+static void __uses_spiboot2 spi_reset(void)
+{
+       int timeout = 0x00100000;
+
+       /* Make sure the last transaction is finalized */
+       spi_write(0x00, CR3);
+       spi_write(0x02, CR1);
+       while (!(spi_read(CR4) & SPI_SpiS0)) {
+               if (timeout-- < 0)
+                       break;
+       }
+       spi_write(0x00, CR1);
+
+       spi_write(spi_read(CR2) | SPI_RSTF, CR2);       /* fifo reset */
+       spi_write(spi_read(CR2) & ~SPI_RSTF, CR2);
+
+       spi_write(0, SPIDMCOR);
+}
+
+static void __uses_spiboot2 spi_read_flash(void *buf, unsigned long addr,
+                                          unsigned long len)
+{
+       spi_write(CR7_IDX_OR12, CR7);
+       if (spi_read(CR8) & OR12_ADDR32) {
+               /* 4-bytes address mode */
+               spi_write(M25_READ_4BYTE, TBR);
+               spi_write((addr >> 24) & 0xFF, TBR);    /* ADDR31-24 */
+       } else {
+               /* 3-bytes address mode */
+               spi_write(M25_READ, TBR);
+       }
+       spi_write((addr >> 16) & 0xFF, TBR);    /* ADDR23-16 */
+       spi_write((addr >> 8) & 0xFF, TBR);     /* ADDR15-8 */
+       spi_write(addr & 0xFF, TBR);            /* ADDR7-0 */
+
+       spi_write(SPIDMINTSR_DMEND, SPIDMINTSR);
+       spi_write((unsigned long)buf, SPIWDMADR);
+       spi_write(len & 0xFFFFFFE0, SPIWDMCNTR);
+       spi_write(1, SPIDMCOR);
+
+       spi_write(0xff, CR3);
+       spi_write(spi_read(CR1) | SPI_SSDB, CR1);
+       spi_write(spi_read(CR1) | SPI_SSA, CR1);
+
+       while (!(spi_read(SPIDMINTSR) & SPIDMINTSR_DMEND))
+               ;
+
+       /* Nagate SP0-SS0 */
+       spi_write(0, CR1);
+}
+
+void __uses_spiboot2 spiboot_main(void)
+{
+       /*
+        * This code rounds len up for SPIWDMCNTR. We should set it to 0 in
+        * lower 5-bits.
+        */
+       void (*_start)(void) = (void *)CONFIG_SYS_TEXT_BASE;
+       volatile unsigned long len = (bss_start - _start + 31) & 0xffffffe0;
+
+       spi_reset();
+       spi_read_flash((void *)CONFIG_RAM_BOOT_PHYS, CONFIG_SPI_ADDR, len);
+
+       _start();
+}
diff --git a/board/renesas/sh7753evb/u-boot.lds b/board/renesas/sh7753evb/u-boot.lds
new file mode 100644 (file)
index 0000000..053df64
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2007
+ * Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
+ *
+ * Copyright (C) 2012
+ * Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+OUTPUT_FORMAT("elf32-sh-linux", "elf32-sh-linux", "elf32-sh-linux")
+OUTPUT_ARCH(sh)
+ENTRY(_start)
+
+SECTIONS
+{
+       /*
+        * entry and reloct_dst will be provided via ldflags
+        */
+       . = .;
+
+       PROVIDE (_ftext = .);
+       PROVIDE (_fcode = .);
+       PROVIDE (_start = .);
+
+       .text :
+       {
+               KEEP(arch/sh/cpu/sh4/start.o            (.text))
+               *(.spiboot1.text)
+               *(.spiboot2.text)
+               . = ALIGN(8192);
+               common/env_embedded.o   (.ppcenv)
+               . = ALIGN(8192);
+               common/env_embedded.o   (.ppcenvr)
+               . = ALIGN(8192);
+               *(.text)
+               . = ALIGN(4);
+       } =0xFF
+       PROVIDE (_ecode = .);
+       .rodata :
+       {
+               *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*)))
+               . = ALIGN(4);
+       }
+       PROVIDE (_etext = .);
+
+
+       PROVIDE (_fdata = .);
+       .data :
+       {
+               *(.data)
+               . = ALIGN(4);
+       }
+       PROVIDE (_edata = .);
+
+       PROVIDE (_fgot = .);
+       .got :
+       {
+               *(.got)
+               . = ALIGN(4);
+       }
+       PROVIDE (_egot = .);
+
+       .u_boot_list : {
+               KEEP(*(SORT(.u_boot_list*)));
+       }
+
+       PROVIDE (reloc_dst_end = .);
+       /* _reloc_dst_end = .; */
+
+       PROVIDE (bss_start = .);
+       PROVIDE (__bss_start = .);
+       .bss (NOLOAD) :
+       {
+               *(.bss)
+               . = ALIGN(4);
+       }
+       PROVIDE (bss_end = .);
+
+       PROVIDE (__bss_end = .);
+}
index a1a727fb5ecee39db16106c3f5db9c38cdc13ed2..d177f8227c7fc4b3ff95b923a734a353481c51fc 100644 (file)
@@ -281,7 +281,7 @@ Active  arm         armv7          exynos      samsung         smdk5420
 Active  arm         armv7          exynos      samsung         smdkv310            smdkv310                             -                                                                                                                                 Chander Kashyap <k.chander@samsung.com>
 Active  arm         armv7          exynos      samsung         trats               trats                                -                                                                                                                                 Lukasz Majewski <l.majewski@samsung.com>
 Active  arm         armv7          exynos      samsung         trats2              trats2                               -                                                                                                                                 Piotr Wilczek <p.wilczek@samsung.com>
-Active  arm         armv7          exynos      samsung         universal_c210      s5pc210_universal                    -                                                                                                                                 Minkyu Kang <mk7.kang@samsung.com>
+Active  arm         armv7          exynos      samsung         universal_c210      s5pc210_universal                    -                                                                                                                                 Przemyslaw Marczak <p.marczak@samsung.com>
 Active  arm         armv7          highbank    -               highbank            highbank                             -                                                                                                                                 Rob Herring <rob.herring@calxeda.com>
 Active  arm         armv7          mx5         denx            m53evk              m53evk                               m53evk:IMX_CONFIG=board/denx/m53evk/imximage.cfg                                                                                  Marek Vasut <marek.vasut@gmail.com>
 Active  arm         armv7          mx5         esg             ima3-mx53           ima3-mx53                            ima3-mx53:IMX_CONFIG=board/esg/ima3-mx53/imximage.cfg                                                                             -
@@ -351,7 +351,7 @@ Active  arm         armv7          rmobile     renesas         lager
 Active  arm         armv7          rmobile     renesas         lager               lager_nor                            lager:NORFLASH                                                                                                                    Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
 Active  arm         armv7          rmobile     renesas         koelsch             koelsch                              -                                                                                                                                 Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
 Active  arm         armv7          rmobile     renesas         koelsch             koelsch_nor                          koelsch:NORFLASH                                                                                                                  Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
-Active  arm         armv7          s5pc1xx     samsung         goni                s5p_goni                             -                                                                                                                                 Minkyu Kang <mk7.kang@samsung.com>
+Active  arm         armv7          s5pc1xx     samsung         goni                s5p_goni                             -                                                                                                                                 Mateusz Zalega <m.zalega@samsung.com>
 Active  arm         armv7          s5pc1xx     samsung         smdkc100            smdkc100                             -                                                                                                                                 Minkyu Kang <mk7.kang@samsung.com>
 Active  arm         armv7          socfpga     altera          socfpga             socfpga_cyclone5                     -                                                                                                                                 -
 Active  arm         armv7          u8500       st-ericsson     snowball            snowball                             -                                                                                                                                 Mathieu Poirier <mathieu.poirier@linaro.org>
@@ -645,7 +645,6 @@ Active  powerpc     mpc824x        -           -               cpc45
 Active  powerpc     mpc824x        -           -               cu824               CU824                                -                                                                                                                                 Wolfgang Denk <wd@denx.de>
 Active  powerpc     mpc824x        -           -               eXalion             eXalion                              -                                                                                                                                 Torsten Demke <torsten.demke@fci.com>
 Active  powerpc     mpc824x        -           -               hidden_dragon       HIDDEN_DRAGON                        -                                                                                                                                 Yusdi Santoso <yusdi_santoso@adaptec.com>
-Active  powerpc     mpc824x        -           -               linkstation         linkstation_HGLAN                    linkstation:HGLAN=1                                                                                                               Guennadi Liakhovetski <g.liakhovetski@gmx.de>
 Active  powerpc     mpc824x        -           -               musenki             MUSENKI                              -                                                                                                                                 Jim Thompson <jim@musenki.com>
 Active  powerpc     mpc824x        -           -               mvblue              MVBLUE                               -                                                                                                                                 -
 Active  powerpc     mpc824x        -           -               sandpoint           Sandpoint8240                        -                                                                                                                                 Wolfgang Denk <wd@denx.de>
@@ -975,6 +974,7 @@ Active  powerpc     mpc85xx        -           freescale       t4qds
 Active  powerpc     mpc85xx        -           freescale       t4qds               T4160QDS_SPIFLASH                    T4240QDS:PPC_T4160,RAMBOOT_PBL,SPIFLASH,SYS_TEXT_BASE=0xFFF80000                                                                  -
 Active  powerpc     mpc85xx        -           freescale       t4qds               T4240EMU                             T4240EMU:PPC_T4240                                                                                                                York Sun <yorksun@freescale.com>
 Active  powerpc     mpc85xx        -           freescale       t4qds               T4240QDS                             T4240QDS:PPC_T4240                                                                                                                -
+Active  powerpc     mpc85xx        -           freescale       t4qds               T4240QDS_NAND                       T4240QDS:PPC_T4240,RAMBOOT_PBL,NAND,SYS_TEXT_BASE=0xFFF80000                                                                      -
 Active  powerpc     mpc85xx        -           freescale       t4qds               T4240QDS_SDCARD                      T4240QDS:PPC_T4240,RAMBOOT_PBL,SDCARD,SYS_TEXT_BASE=0xFFF80000                                                                    -
 Active  powerpc     mpc85xx        -           freescale       t4qds               T4240QDS_SPIFLASH                    T4240QDS:PPC_T4240,RAMBOOT_PBL,SPIFLASH,SYS_TEXT_BASE=0xFFF80000                                                                  -
 Active  powerpc     mpc85xx        -           freescale       t4qds               T4240QDS_SRIO_PCIE_BOOT              T4240QDS:PPC_T4240,SRIO_PCIE_BOOT_SLAVE,SYS_TEXT_BASE=0xFFF80000                                                                  -
@@ -1218,6 +1218,7 @@ Active  sh          sh4            -           renesas         r0p7734
 Active  sh          sh4            -           renesas         r2dplus             r2dplus                              -                                                                                                                                 Nobuhiro Iwamatsu <iwamatsu.nobuhiro@renesas.com>:Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
 Active  sh          sh4            -           renesas         r7780mp             r7780mp                              -                                                                                                                                 Nobuhiro Iwamatsu <iwamatsu.nobuhiro@renesas.com>:Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
 Active  sh          sh4            -           renesas         sh7752evb           sh7752evb                            -                                                                                                                                 -
+Active  sh          sh4            -           renesas         sh7753evb           sh7753evb                            -                                                                                                                                 -
 Active  sh          sh4            -           renesas         sh7757lcr           sh7757lcr                            -                                                                                                                                 -
 Active  sh          sh4            -           renesas         sh7763rdp           sh7763rdp                            -                                                                                                                                 Nobuhiro Iwamatsu <iwamatsu.nobuhiro@renesas.com>:Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
 Active  sh          sh4            -           renesas         sh7785lcr           sh7785lcr                            -                                                                                                                                 -
index 74404beb3635624cf04fa12159f66f531e638dc7..d12cba5bf0d9b5392b67217253bd50c191b5d17b 100644 (file)
@@ -230,8 +230,6 @@ obj-$(CONFIG_FIT_SIGNATURE) += image-sig.o
 obj-y += memsize.o
 obj-y += stdio.o
 
-CPPFLAGS += -I..
-
 $(obj)env_embedded.o: $(src)env_embedded.c
        $(CC) $(AFLAGS) -Wa,--no-warn \
                -DENV_CRC=$(shell $(obj)../tools/envcrc) \
index d918e4bb16fe39dc8539163e8554c89999f8905e..aa70c3e57de67e5041225abd88b6080fa46ca692 100644 (file)
@@ -347,9 +347,10 @@ done:
 #ifdef CONFIG_SANDBOX
 static int setup_ram_buf(void)
 {
-       gd->arch.ram_buf = os_malloc(CONFIG_SYS_SDRAM_SIZE);
-       assert(gd->arch.ram_buf);
-       gd->ram_size = CONFIG_SYS_SDRAM_SIZE;
+       struct sandbox_state *state = state_get_current();
+
+       gd->arch.ram_buf = state->ram_buf;
+       gd->ram_size = state->ram_size;
 
        return 0;
 }
@@ -772,7 +773,7 @@ static int setup_reloc(void)
 }
 
 /* ARM calls relocate_code from its crt0.S */
-#if !defined(CONFIG_ARM)
+#if !defined(CONFIG_ARM) && !defined(CONFIG_SANDBOX)
 
 static int jump_to_copy(void)
 {
@@ -792,8 +793,6 @@ static int jump_to_copy(void)
         * (CPU cache)
         */
        board_init_f_r_trampoline(gd->start_addr_sp);
-#elif defined(CONFIG_SANDBOX)
-       board_init_r(gd->new_gd, 0);
 #else
        relocate_code(gd->start_addr_sp, gd->new_gd, gd->relocaddr);
 #endif
@@ -990,7 +989,7 @@ static init_fnc_t init_sequence_f[] = {
        INIT_FUNC_WATCHDOG_RESET
        reloc_fdt,
        setup_reloc,
-#ifndef CONFIG_ARM
+#if !defined(CONFIG_ARM) && !defined(CONFIG_SANDBOX)
        jump_to_copy,
 #endif
        NULL,
@@ -1016,11 +1015,12 @@ void board_init_f(ulong boot_flags)
 #endif
 
        gd->flags = boot_flags;
+       gd->have_console = 0;
 
        if (initcall_run_list(init_sequence_f))
                hang();
 
-#ifndef CONFIG_ARM
+#if !defined(CONFIG_ARM) && !defined(CONFIG_SANDBOX)
        /* NOTREACHED - jump_to_copy() does not return */
        hang();
 #endif
index ba73f5781a92258c306907f15fc83c37e40278d0..3f576594d1774e49ccadec312fbf5cb302a81981 100644 (file)
 #include <asm/io.h>
 #include <linux/compiler.h>
 
+#if defined(CONFIG_BOOTM_VXWORKS) && \
+       (defined(CONFIG_PPC) || defined(CONFIG_ARM))
+#include <vxworks.h>
+#endif
+
 #if defined(CONFIG_CMD_USB)
 #include <usb.h>
 #endif
@@ -120,8 +125,11 @@ static boot_os_fn do_bootm_ose;
 #if defined(CONFIG_BOOTM_PLAN9)
 static boot_os_fn do_bootm_plan9;
 #endif
-#if defined(CONFIG_CMD_ELF)
+#if defined(CONFIG_BOOTM_VXWORKS) && \
+       (defined(CONFIG_PPC) || defined(CONFIG_ARM))
 static boot_os_fn do_bootm_vxworks;
+#endif
+#if defined(CONFIG_CMD_ELF)
 static boot_os_fn do_bootm_qnxelf;
 int do_bootvx(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
 int do_bootelf(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
@@ -149,8 +157,11 @@ static boot_os_fn *boot_os[] = {
 #if defined(CONFIG_BOOTM_PLAN9)
        [IH_OS_PLAN9] = do_bootm_plan9,
 #endif
-#if defined(CONFIG_CMD_ELF)
+#if defined(CONFIG_BOOTM_VXWORKS) && \
+       (defined(CONFIG_PPC) || defined(CONFIG_ARM))
        [IH_OS_VXWORKS] = do_bootm_vxworks,
+#endif
+#if defined(CONFIG_CMD_ELF)
        [IH_OS_QNX] = do_bootm_qnxelf,
 #endif
 #ifdef CONFIG_INTEGRITY
@@ -333,7 +344,8 @@ static int bootm_find_other(cmd_tbl_t *cmdtp, int flag, int argc,
        if (((images.os.type == IH_TYPE_KERNEL) ||
             (images.os.type == IH_TYPE_KERNEL_NOLOAD) ||
             (images.os.type == IH_TYPE_MULTI)) &&
-           (images.os.os == IH_OS_LINUX)) {
+           (images.os.os == IH_OS_LINUX ||
+                images.os.os == IH_OS_VXWORKS)) {
                if (bootm_find_ramdisk(flag, argc, argv))
                        return 1;
 
@@ -1531,10 +1543,10 @@ static int do_bootm_netbsd(int flag, int argc, char * const argv[],
 
        /*
         * NetBSD Stage-2 Loader Parameters:
-        *   r3: ptr to board info data
-        *   r4: image address
-        *   r5: console device
-        *   r6: boot args string
+        *   arg[0]: pointer to board info data
+        *   arg[1]: image load address
+        *   arg[2]: char pointer to the console device to use
+        *   arg[3]: char pointer to the boot arguments
         */
        (*loader)(gd->bd, os_hdr, consdev, cmdline);
 
@@ -1678,12 +1690,66 @@ static int do_bootm_plan9(int flag, int argc, char * const argv[],
 }
 #endif /* CONFIG_BOOTM_PLAN9 */
 
-#if defined(CONFIG_CMD_ELF)
+#if defined(CONFIG_BOOTM_VXWORKS) && \
+       (defined(CONFIG_PPC) || defined(CONFIG_ARM))
+
+void do_bootvx_fdt(bootm_headers_t *images)
+{
+#if defined(CONFIG_OF_LIBFDT)
+       int ret;
+       char *bootline;
+       ulong of_size = images->ft_len;
+       char **of_flat_tree = &images->ft_addr;
+       struct lmb *lmb = &images->lmb;
+
+       if (*of_flat_tree) {
+               boot_fdt_add_mem_rsv_regions(lmb, *of_flat_tree);
+
+               ret = boot_relocate_fdt(lmb, of_flat_tree, &of_size);
+               if (ret)
+                       return;
+
+               ret = fdt_add_subnode(*of_flat_tree, 0, "chosen");
+               if ((ret >= 0 || ret == -FDT_ERR_EXISTS)) {
+                       bootline = getenv("bootargs");
+                       if (bootline) {
+                               ret = fdt_find_and_setprop(*of_flat_tree,
+                                               "/chosen", "bootargs",
+                                               bootline,
+                                               strlen(bootline) + 1, 1);
+                               if (ret < 0) {
+                                       printf("## ERROR: %s : %s\n", __func__,
+                                              fdt_strerror(ret));
+                                       return;
+                               }
+                       }
+               } else {
+                       printf("## ERROR: %s : %s\n", __func__,
+                              fdt_strerror(ret));
+                       return;
+               }
+       }
+#endif
+
+       boot_prep_vxworks(images);
+
+       bootstage_mark(BOOTSTAGE_ID_RUN_OS);
+
+#if defined(CONFIG_OF_LIBFDT)
+       printf("## Starting vxWorks at 0x%08lx, device tree at 0x%08lx ...\n",
+              (ulong)images->ep, (ulong)*of_flat_tree);
+#else
+       printf("## Starting vxWorks at 0x%08lx\n", (ulong)images->ep);
+#endif
+
+       boot_jump_vxworks(images);
+
+       puts("## vxWorks terminated\n");
+}
+
 static int do_bootm_vxworks(int flag, int argc, char * const argv[],
                             bootm_headers_t *images)
 {
-       char str[80];
-
        if (flag != BOOTM_STATE_OS_GO)
                return 0;
 
@@ -1694,13 +1760,13 @@ static int do_bootm_vxworks(int flag, int argc, char * const argv[],
        }
 #endif
 
-       sprintf(str, "%lx", images->ep); /* write entry-point into string */
-       setenv("loadaddr", str);
-       do_bootvx(NULL, 0, 0, NULL);
+       do_bootvx_fdt(images);
 
        return 1;
 }
+#endif
 
+#if defined(CONFIG_CMD_ELF)
 static int do_bootm_qnxelf(int flag, int argc, char * const argv[],
                            bootm_headers_t *images)
 {
index f741f6b83f942d967f5b1280e15db9c72e891062..ab9c7e332d97b200109e09e464b0fb786ac967c6 100644 (file)
@@ -156,16 +156,16 @@ int do_bootvx(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
         * If we don't know where the image is then we're done.
         */
 
-       if (argc < 1)
+       if (argc < 2)
                addr = load_addr;
        else
-               addr = simple_strtoul(argv[0], NULL, 16);
+               addr = simple_strtoul(argv[1], NULL, 16);
 
 #if defined(CONFIG_CMD_NET)
        /*
         * Check to see if we need to tftp the image ourselves before starting
         */
-       if ((argc == 1) && (strcmp(argv[0], "tftp") == 0)) {
+       if ((argc == 2) && (strcmp(argv[1], "tftp") == 0)) {
                if (NetLoop(TFTPGET) <= 0)
                        return 1;
                printf("Automatic boot of VxWorks image at address 0x%08lx ...\n",
index 67a94a746882c2c3cafd1c35e7bd295c76ae5b6e..da5fef9db9dd936a995a92e04826a69fe0521635 100644 (file)
@@ -340,6 +340,28 @@ static int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
                }
 #endif /* CONFIG_SUPPORT_EMMC_BOOT */
        }
+
+       else if (argc == 3 && strcmp(argv[1], "setdsr") == 0) {
+               struct mmc *mmc = find_mmc_device(curr_device);
+               u32 val = simple_strtoul(argv[2], NULL, 16);
+               int ret;
+
+               if (!mmc) {
+                       printf("no mmc device at slot %x\n", curr_device);
+                       return 1;
+               }
+               ret = mmc_set_dsr(mmc, val);
+               printf("set dsr %s\n", (!ret) ? "OK, force rescan" : "ERROR");
+               if (!ret) {
+                       mmc->has_init = 0;
+                       if (mmc_init(mmc))
+                               return 1;
+                       else
+                               return 0;
+               }
+               return ret;
+       }
+
        state = MMC_INVALID;
        if (argc == 5 && strcmp(argv[1], "read") == 0)
                state = MMC_READ;
@@ -423,5 +445,6 @@ U_BOOT_CMD(
        "mmc bootpart <device num> <boot part size MB> <RPMB part size MB>\n"
        " - change sizes of boot and RPMB partitions of specified device\n"
 #endif
+       "mmc setdsr - set DSR register value\n"
        );
 #endif /* !CONFIG_GENERIC_MMC */
index 8d59364b63653aee6e84b9cb89d72df1fff2e130..00982b164dd3c41e562fadffa0adf522c8841e66 100644 (file)
@@ -6,6 +6,9 @@
 
 #include <common.h>
 #include <fs.h>
+#include <part.h>
+#include <sandboxblockdev.h>
+#include <asm/errno.h>
 
 static int do_sandbox_load(cmd_tbl_t *cmdtp, int flag, int argc,
                           char * const argv[])
@@ -25,10 +28,69 @@ static int do_sandbox_save(cmd_tbl_t *cmdtp, int flag, int argc,
        return do_save(cmdtp, flag, argc, argv, FS_TYPE_SANDBOX);
 }
 
+static int do_sandbox_bind(cmd_tbl_t *cmdtp, int flag, int argc,
+                          char * const argv[])
+{
+       if (argc < 2 || argc > 3)
+               return CMD_RET_USAGE;
+       char *ep;
+       char *dev_str = argv[1];
+       char *file = argc >= 3 ? argv[2] : NULL;
+       int dev = simple_strtoul(dev_str, &ep, 16);
+       if (*ep) {
+               printf("** Bad device specification %s **\n", dev_str);
+               return CMD_RET_USAGE;
+       }
+       return host_dev_bind(dev, file);
+}
+
+static int do_sandbox_info(cmd_tbl_t *cmdtp, int flag, int argc,
+                          char * const argv[])
+{
+       if (argc < 1 || argc > 2)
+               return CMD_RET_USAGE;
+       int min_dev = 0;
+       int max_dev = CONFIG_HOST_MAX_DEVICES - 1;
+       if (argc >= 2) {
+               char *ep;
+               char *dev_str = argv[1];
+               int dev = simple_strtoul(dev_str, &ep, 16);
+               if (*ep) {
+                       printf("** Bad device specification %s **\n", dev_str);
+                       return CMD_RET_USAGE;
+               }
+               min_dev = dev;
+               max_dev = dev;
+       }
+       int dev;
+       printf("%3s %12s %s\n", "dev", "blocks", "path");
+       for (dev = min_dev; dev <= max_dev; dev++) {
+               block_dev_desc_t *blk_dev;
+               int ret;
+
+               printf("%3d ", dev);
+               ret = host_get_dev_err(dev, &blk_dev);
+               if (ret) {
+                       if (ret == -ENOENT)
+                               puts("Not bound to a backing file\n");
+                       else if (ret == -ENODEV)
+                               puts("Invalid host device number\n");
+
+                       continue;
+               }
+               struct host_block_dev *host_dev = blk_dev->priv;
+               printf("%12lu %s\n", (unsigned long)blk_dev->lba,
+                      host_dev->filename);
+       }
+       return 0;
+}
+
 static cmd_tbl_t cmd_sandbox_sub[] = {
        U_BOOT_CMD_MKENT(load, 7, 0, do_sandbox_load, "", ""),
        U_BOOT_CMD_MKENT(ls, 3, 0, do_sandbox_ls, "", ""),
        U_BOOT_CMD_MKENT(save, 6, 0, do_sandbox_save, "", ""),
+       U_BOOT_CMD_MKENT(bind, 3, 0, do_sandbox_bind, "", ""),
+       U_BOOT_CMD_MKENT(info, 3, 0, do_sandbox_info, "", ""),
 };
 
 static int do_sandbox(cmd_tbl_t *cmdtp, int flag, int argc,
@@ -57,4 +119,6 @@ U_BOOT_CMD(
        "sb ls host <filename>                      - list files on host\n"
        "sb save host <dev> <filename> <addr> <bytes> [<offset>] - "
                "save a file to host\n"
+       "sb bind <dev> [<filename>] - bind \"host\" device to file\n"
+       "sb info [<dev>]            - show device binding & info"
 );
index cc55068c7cd823c138c4f90d1657a899621da0bf..2dfb788885bc81609224e9d3d7d43d1735bc6d65 100644 (file)
@@ -8,6 +8,7 @@
 #include <common.h>
 #include <stdarg.h>
 #include <malloc.h>
+#include <os.h>
 #include <serial.h>
 #include <stdio_dev.h>
 #include <exports.h>
@@ -415,6 +416,12 @@ static inline void print_pre_console_buffer(void) {}
 
 void putc(const char c)
 {
+#ifdef CONFIG_SANDBOX
+       if (!gd) {
+               os_putc(c);
+               return;
+       }
+#endif
 #ifdef CONFIG_SILENT_CONSOLE
        if (gd->flags & GD_FLG_SILENT)
                return;
@@ -439,6 +446,13 @@ void putc(const char c)
 
 void puts(const char *s)
 {
+#ifdef CONFIG_SANDBOX
+       if (!gd) {
+               os_puts(s);
+               return;
+       }
+#endif
+
 #ifdef CONFIG_SILENT_CONSOLE
        if (gd->flags & GD_FLG_SILENT)
                return;
@@ -467,7 +481,7 @@ int printf(const char *fmt, ...)
        uint i;
        char printbuffer[CONFIG_SYS_PBSIZE];
 
-#ifndef CONFIG_PRE_CONSOLE_BUFFER
+#if !defined(CONFIG_SANDBOX) && !defined(CONFIG_PRE_CONSOLE_BUFFER)
        if (!gd->have_console)
                return 0;
 #endif
index a3f7442c324a3b873bd630144c3afa883059b320..b9dce994624edff4c75a17a14dae6858005caffd 100644 (file)
@@ -402,10 +402,11 @@ int fdt_fixup_memory_banks(void *blob, u64 start[], u64 size[], int banks)
        nodeoffset = fdt_path_offset(blob, "/memory");
        if (nodeoffset < 0) {
                nodeoffset = fdt_add_subnode(blob, 0, "memory");
-               if (nodeoffset < 0)
+               if (nodeoffset < 0) {
                        printf("WARNING: could not create /memory: %s.\n",
                                        fdt_strerror(nodeoffset));
-               return nodeoffset;
+                       return nodeoffset;
+               }
        }
        err = fdt_setprop(blob, nodeoffset, "device_type", "memory",
                        sizeof("memory"));
index d5b09a0095d5eef7f8f0452d3835f3163d5aa90e..b824bb3469dd577909ad804d655f29d56f0b14cd 100644 (file)
--- a/config.mk
+++ b/config.mk
@@ -125,9 +125,9 @@ endif
 
 # cc-version
 # Usage gcc-ver := $(call cc-version)
-cc-version = $(shell $(SHELL) $(SRCTREE)/tools/gcc-version.sh $(CC))
-binutils-version = $(shell $(SHELL) $(SRCTREE)/tools/binutils-version.sh $(AS))
-dtc-version = $(shell $(SHELL) $(SRCTREE)/tools/dtc-version.sh $(DTC))
+cc-version = $(shell $(SHELL) $(SRCTREE)/scripts/gcc-version.sh $(CC))
+binutils-version = $(shell $(SHELL) $(SRCTREE)/scripts/binutils-version.sh $(AS))
+dtc-version = $(shell $(SHELL) $(SRCTREE)/scripts/dtc-version.sh $(DTC))
 
 #
 # Include the make variables (CC, etc...)
index d2e34cfcfa985409c2307608ede51276653ea3be..6941033d8d7b7850561e9cd386ce62433ab1cdcd 100644 (file)
@@ -42,6 +42,9 @@ static const struct block_drvr block_drvr[] = {
 #endif
 #if defined(CONFIG_SYSTEMACE)
        { .name = "ace", .get_dev = systemace_get_dev, },
+#endif
+#if defined(CONFIG_SANDBOX)
+       { .name = "host", .get_dev = host_get_dev, },
 #endif
        { },
 };
@@ -286,6 +289,9 @@ static void print_part_header (const char *type, block_dev_desc_t * dev_desc)
        case IF_TYPE_MMC:
                puts ("MMC");
                break;
+       case IF_TYPE_HOST:
+               puts("HOST");
+               break;
        default:
                puts ("UNKNOWN");
                break;
diff --git a/doc/README.sh7753evb b/doc/README.sh7753evb
new file mode 100644 (file)
index 0000000..5fe178c
--- /dev/null
@@ -0,0 +1,67 @@
+========================================
+Renesas SH7753 EVB board
+========================================
+
+This board specification:
+=========================
+
+The SH7753 EVB (board config name:sh7753evb) has the following device:
+
+ - SH7753 (SH-4A)
+ - DDR3-SDRAM 512MB
+ - SPI ROM 8MB
+ - Gigabit Ethernet controllers
+ - eMMC 4GB
+
+
+Configuration for This board:
+=============================
+
+You can select the configuration as follows:
+
+ - make sh7753evb_config
+
+
+This board specific command:
+============================
+
+This board has the following its specific command:
+
+ - write_mac
+
+
+1. write_mac
+
+You can write MAC address to SPI ROM.
+
+ Usage 1) Write MAC address
+
+   write_mac [GETHERC ch0] [GETHERC ch1]
+
+       For example)
+        => write_mac 74:90:50:00:33:9e 74:90:50:00:33:9f
+               *) We have to input the command as a single line
+                  (without carriage return)
+               *) We have to reset after input the command.
+
+ Usage 2) Show current data
+
+   write_mac
+
+       For example)
+               => write_mac
+               GETHERC ch0 = 74:90:50:00:33:9e
+               GETHERC ch1 = 74:90:50:00:33:9f
+
+
+Update SPI ROM:
+============================
+
+1. Copy u-boot image to RAM area.
+2. Probe SPI device.
+   => sf probe 0
+   SF: Detected MX25L6405D with page size 64KiB, total 8 MiB
+3. Erase SPI ROM.
+   => sf erase 0 80000
+4. Write u-boot image to SPI ROM.
+   => sf write 0x48000000 0 80000
diff --git a/doc/README.socfpga b/doc/README.socfpga
new file mode 100644 (file)
index 0000000..cfcbbfe
--- /dev/null
@@ -0,0 +1,53 @@
+
+--------------------------------------------
+SOCFPGA Documentation for U-Boot and SPL
+--------------------------------------------
+
+This README is about U-Boot and SPL support for Altera's ARM Cortex-A9MPCore
+based SOCFPGA. To know more about the hardware itself, please refer to
+www.altera.com.
+
+
+--------------------------------------------
+socfpga_dw_mmc
+--------------------------------------------
+Here are macro and detailed configuration required to enable DesignWare SDMMC
+controller support within SOCFPGA
+
+#define CONFIG_MMC
+-> To enable the SD MMC framework support
+
+#define CONFIG_SDMMC_BASE              (SOCFPGA_SDMMC_ADDRESS)
+-> The base address of CSR register for DesignWare SDMMC controller
+
+#define CONFIG_GENERIC_MMC
+-> Enable the generic MMC driver
+
+#define CONFIG_SYS_MMC_MAX_BLK_COUNT   256
+-> Using smaller max blk cnt to avoid flooding the limited stack in OCRAM
+
+#define CONFIG_DWMMC
+-> Enable the common DesignWare SDMMC controller framework
+
+#define CONFIG_SOCFPGA_DWMMC
+-> Enable the SOCFPGA specific driver for DesignWare SDMMC controller
+
+#define CONFIG_SOCFPGA_DWMMC_FIFO_DEPTH                1024
+-> The FIFO depth for SOCFPGA DesignWare SDMMC controller
+
+#define CONFIG_SOCFPGA_DWMMC_DRVSEL    3
+-> Phase-shifted clock of sdmmc_clk for controller to drive command and data to
+the card to meet hold time requirements. SD clock is running at 50MHz and
+drvsel is set to shift 135 degrees (3 * 45 degrees). With that, the hold time
+is 135 / 360 * 20ns = 7.5ns.
+
+#define CONFIG_SOCFPGA_DWMMC_SMPSEL    0
+-> Phase-shifted clock of sdmmc_clk used to sample the command and data from
+the card
+
+#define CONFIG_SOCFPGA_DWMMC_BUS_WIDTH 4
+-> Bus width of data line which either 1, 4 or 8 and based on board routing.
+
+#define CONFIG_SOCFPGA_DWMMC_BUS_HZ    50000000
+-> The clock rate to controller. Do note the controller have a wrapper which
+divide the clock from PLL by 4.
diff --git a/doc/README.vxworks b/doc/README.vxworks
new file mode 100644 (file)
index 0000000..4cb302e
--- /dev/null
@@ -0,0 +1,19 @@
+From VxWorks 6.9+ (not include 6.9), VxWorks starts adopting device tree as its hardware
+decription mechansim (for PowerPC and ARM), thus requiring boot interface changes.
+This section will describe the new interface.
+
+For PowerPC, the calling convention of the new VxWorks entry point conforms to the ePAPR standard,
+which is shown below (see ePAPR for more details):
+
+    void (*kernel_entry)(fdt_addr,
+              0, 0, EPAPR_MAGIC, boot_IMA, 0, 0)
+
+For ARM, the calling convention is show below:
+
+    void (*kernel_entry)(void *fdt_addr)
+
+When booting new VxWorks kernel (uImage format), the parameters passed to bootm is like below:
+
+    bootm <kernel image address> - <device tree address>
+
+The do_bootvx command still works as it was for older VxWorks kernels.
diff --git a/doc/SPI/README.sh_qspi_test b/doc/SPI/README.sh_qspi_test
new file mode 100644 (file)
index 0000000..8a33fec
--- /dev/null
@@ -0,0 +1,38 @@
+-------------------------------------------------
+   Simple steps used to test the SH-QSPI at U-Boot
+-------------------------------------------------
+
+#0, Currently, SH-QSPI is used by lager board (Renesas ARM SoC R8A7790)
+    and koelsch board (Renesas ARM SoC R8A7791). These boot from SPI ROM
+    basically. Thus, U-Boot start, SH-QSPI will is operating normally.
+
+#1, build U-Boot and load u-boot.bin
+
+  => tftpboot 40000000 u-boot.bin
+  sh_eth Waiting for PHY auto negotiation to complete.. done
+  sh_eth: 100Base/Half
+  Using sh_eth device
+  TFTP from server 192.168.169.1; our IP address is 192.168.169.79
+  Filename 'u-boot.bin'.
+  Load address: 0x40000000
+  Loading: ############
+    2.5 MiB/s
+  done
+  Bytes transferred = 175364 (2ad04 hex)
+
+#2, Commands to erase/write u-boot to flash device
+
+  Note: This method is description of the lager board. If you want to use the
+  other boards, please change the value according to each environment.
+
+  =>  sf probe 0
+  SF: Detected S25FL512S_256K with page size 512 Bytes, erase size 64 KiB, total 64 MiB
+  => sf erase 80000 40000
+  SF: 262144 bytes @ 0x80000 Erased: OK
+  => sf write 40000000 80000 175364
+  SF: 1528676 bytes @ 0x80000 Written: OK
+  =>
+
+#3, Push reset button.
+
+  If you're written correctly and driver works properly, U-Boot starts.
index 4e94378388cf1a305abd4645b4558776bcb38695..8697da4262b2504f1be1e5a0a4074a9de9040744 100644 (file)
@@ -18,5 +18,6 @@ obj-$(CONFIG_SATA_DWC) += sata_dwc.o
 obj-$(CONFIG_SATA_SIL3114) += sata_sil3114.o
 obj-$(CONFIG_SATA_SIL) += sata_sil.o
 obj-$(CONFIG_IDE_SIL680) += sil680.o
+obj-$(CONFIG_SANDBOX) += sandbox.o
 obj-$(CONFIG_SCSI_SYM53C8XX) += sym53c8xx.o
 obj-$(CONFIG_SYSTEMACE) += systemace.o
diff --git a/drivers/block/sandbox.c b/drivers/block/sandbox.c
new file mode 100644 (file)
index 0000000..73f4c4a
--- /dev/null
@@ -0,0 +1,124 @@
+/*
+ * Copyright (C) 2013 Henrik Nordstrom <henrik@henriknordstrom.net>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <config.h>
+#include <common.h>
+#include <part.h>
+#include <os.h>
+#include <malloc.h>
+#include <sandboxblockdev.h>
+#include <asm/errno.h>
+
+static struct host_block_dev host_devices[CONFIG_HOST_MAX_DEVICES];
+
+static struct host_block_dev *find_host_device(int dev)
+{
+       if (dev >= 0 && dev < CONFIG_HOST_MAX_DEVICES)
+               return &host_devices[dev];
+
+       return NULL;
+}
+
+static unsigned long host_block_read(int dev, unsigned long start,
+                                    lbaint_t blkcnt, void *buffer)
+{
+       struct host_block_dev *host_dev = find_host_device(dev);
+
+       if (!host_dev)
+               return -1;
+       if (os_lseek(host_dev->fd,
+                    start * host_dev->blk_dev.blksz,
+                    OS_SEEK_SET) == -1) {
+               printf("ERROR: Invalid position\n");
+               return -1;
+       }
+       ssize_t len = os_read(host_dev->fd, buffer,
+                             blkcnt * host_dev->blk_dev.blksz);
+       if (len >= 0)
+               return len / host_dev->blk_dev.blksz;
+       return -1;
+}
+
+static unsigned long host_block_write(int dev, unsigned long start,
+                                     lbaint_t blkcnt, const void *buffer)
+{
+       struct host_block_dev *host_dev = find_host_device(dev);
+       if (os_lseek(host_dev->fd,
+                    start * host_dev->blk_dev.blksz,
+                    OS_SEEK_SET) == -1) {
+               printf("ERROR: Invalid position\n");
+               return -1;
+       }
+       ssize_t len = os_write(host_dev->fd, buffer, blkcnt *
+                              host_dev->blk_dev.blksz);
+       if (len >= 0)
+               return len / host_dev->blk_dev.blksz;
+       return -1;
+}
+
+int host_dev_bind(int dev, char *filename)
+{
+       struct host_block_dev *host_dev = find_host_device(dev);
+
+       if (!host_dev)
+               return -1;
+       if (host_dev->blk_dev.priv) {
+               os_close(host_dev->fd);
+               host_dev->blk_dev.priv = NULL;
+       }
+       if (host_dev->filename)
+               free(host_dev->filename);
+       if (filename && *filename) {
+               host_dev->filename = strdup(filename);
+       } else {
+               host_dev->filename = NULL;
+               return 0;
+       }
+
+       host_dev->fd = os_open(host_dev->filename, OS_O_RDWR);
+       if (host_dev->fd == -1) {
+               printf("Failed to access host backing file '%s'\n",
+                      host_dev->filename);
+               return 1;
+       }
+
+       block_dev_desc_t *blk_dev = &host_dev->blk_dev;
+       blk_dev->if_type = IF_TYPE_HOST;
+       blk_dev->priv = host_dev;
+       blk_dev->blksz = 512;
+       blk_dev->lba = os_lseek(host_dev->fd, 0, OS_SEEK_END) / blk_dev->blksz;
+       blk_dev->block_read = host_block_read;
+       blk_dev->block_write = host_block_write;
+       blk_dev->dev = dev;
+       blk_dev->part_type = PART_TYPE_UNKNOWN;
+       init_part(blk_dev);
+
+       return 0;
+}
+
+int host_get_dev_err(int dev, block_dev_desc_t **blk_devp)
+{
+       struct host_block_dev *host_dev = find_host_device(dev);
+
+       if (!host_dev)
+               return -ENODEV;
+
+       if (!host_dev->blk_dev.priv)
+               return -ENOENT;
+
+       *blk_devp = &host_dev->blk_dev;
+       return 0;
+}
+
+block_dev_desc_t *host_get_dev(int dev)
+{
+       block_dev_desc_t *blk_dev;
+
+       if (host_get_dev_err(dev, &blk_dev))
+               return NULL;
+
+       return blk_dev;
+}
index 1eb92e54176148081491ff449ba1107f90eaf641..07011e99a850fafa7475d02451c8f358986b7f3c 100644 (file)
@@ -74,6 +74,11 @@ unsigned char *dfu_free_buf(void)
        return dfu_buf;
 }
 
+unsigned long dfu_get_buf_size(void)
+{
+       return dfu_buf_size;
+}
+
 unsigned char *dfu_get_buf(void)
 {
        char *s;
index 1ed26cab34f463c37c4f60dd3f749f43fd68e09e..e793ed994e453ba81306189182abcf8da7b658f7 100644 (file)
@@ -28,6 +28,7 @@ obj-$(CONFIG_TEGRA_MMC) += tegra_mmc.o
 obj-$(CONFIG_DWMMC) += dw_mmc.o
 obj-$(CONFIG_EXYNOS_DWMMC) += exynos_dw_mmc.o
 obj-$(CONFIG_ZYNQ_SDHCI) += zynq_sdhci.o
+obj-$(CONFIG_SOCFPGA_DWMMC) += socfpga_dw_mmc.o
 ifdef CONFIG_SPL_BUILD
 obj-$(CONFIG_SPL_MMC_BOOT) += fsl_esdhc_spl.o
 else
old mode 100644 (file)
new mode 100755 (executable)
index 19d9b0b..4cec5aa
@@ -6,6 +6,7 @@
  * SPDX-License-Identifier:    GPL-2.0+
  */
 
+#include <bouncebuf.h>
 #include <common.h>
 #include <malloc.h>
 #include <mmc.h>
@@ -41,11 +42,13 @@ static void dwmci_set_idma_desc(struct dwmci_idmac *idmac,
 }
 
 static void dwmci_prepare_data(struct dwmci_host *host,
-               struct mmc_data *data, struct dwmci_idmac *cur_idmac)
+                              struct mmc_data *data,
+                              struct dwmci_idmac *cur_idmac,
+                              void *bounce_buffer)
 {
        unsigned long ctrl;
        unsigned int i = 0, flags, cnt, blk_cnt;
-       ulong data_start, data_end, start_addr;
+       ulong data_start, data_end;
 
 
        blk_cnt = data->blocks;
@@ -55,11 +58,6 @@ static void dwmci_prepare_data(struct dwmci_host *host,
        data_start = (ulong)cur_idmac;
        dwmci_writel(host, DWMCI_DBADDR, (unsigned int)cur_idmac);
 
-       if (data->flags == MMC_DATA_READ)
-               start_addr = (unsigned int)data->dest;
-       else
-               start_addr = (unsigned int)data->src;
-
        do {
                flags = DWMCI_IDMAC_OWN | DWMCI_IDMAC_CH ;
                flags |= (i == 0) ? DWMCI_IDMAC_FS : 0;
@@ -70,7 +68,7 @@ static void dwmci_prepare_data(struct dwmci_host *host,
                        cnt = data->blocksize * 8;
 
                dwmci_set_idma_desc(cur_idmac, flags, cnt,
-                               start_addr + (i * PAGE_SIZE));
+                                   (u32)bounce_buffer + (i * PAGE_SIZE));
 
                if (blk_cnt <= 8)
                        break;
@@ -117,6 +115,7 @@ static int dwmci_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd,
        u32 retry = 10000;
        u32 mask, ctrl;
        ulong start = get_timer(0);
+       struct bounce_buffer bbstate;
 
        while (dwmci_readl(host, DWMCI_STATUS) & DWMCI_BUSY) {
                if (get_timer(start) > timeout) {
@@ -127,8 +126,19 @@ static int dwmci_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd,
 
        dwmci_writel(host, DWMCI_RINTSTS, DWMCI_INTMSK_ALL);
 
-       if (data)
-               dwmci_prepare_data(host, data, cur_idmac);
+       if (data) {
+               if (data->flags == MMC_DATA_READ) {
+                       bounce_buffer_start(&bbstate, (void*)data->dest,
+                                           data->blocksize *
+                                           data->blocks, GEN_BB_WRITE);
+               } else {
+                       bounce_buffer_start(&bbstate, (void*)data->src,
+                                           data->blocksize *
+                                           data->blocks, GEN_BB_READ);
+               }
+               dwmci_prepare_data(host, data, cur_idmac,
+                                  bbstate.bounce_buffer);
+       }
 
        dwmci_writel(host, DWMCI_CMDARG, cmd->cmdarg);
 
@@ -204,6 +214,8 @@ static int dwmci_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd,
                ctrl = dwmci_readl(host, DWMCI_CTRL);
                ctrl &= ~(DWMCI_DMA_EN);
                dwmci_writel(host, DWMCI_CTRL, ctrl);
+
+               bounce_buffer_stop(&bbstate);
        }
 
        udelay(100);
@@ -336,9 +348,9 @@ int add_dwmci(struct dwmci_host *host, u32 max_clk, u32 min_clk)
        struct mmc *mmc;
        int err = 0;
 
-       mmc = malloc(sizeof(struct mmc));
+       mmc = calloc(sizeof(struct mmc), 1);
        if (!mmc) {
-               printf("mmc malloc fail!\n");
+               printf("mmc calloc fail!\n");
                return -1;
        }
 
index e1461a98dd96e875558ee9713d735235d072711a..c6a1c23fbf1cdf268d79bf1da3a7a3ed80dd220c 100644 (file)
@@ -877,6 +877,7 @@ static int mmc_startup(struct mmc *mmc)
 
        mmc->tran_speed = freq * mult;
 
+       mmc->dsr_imp = ((cmd.response[1] >> 12) & 0x1);
        mmc->read_bl_len = 1 << ((cmd.response[1] >> 16) & 0xf);
 
        if (IS_SD(mmc))
@@ -907,6 +908,14 @@ static int mmc_startup(struct mmc *mmc)
        if (mmc->write_bl_len > MMC_MAX_BLOCK_LEN)
                mmc->write_bl_len = MMC_MAX_BLOCK_LEN;
 
+       if ((mmc->dsr_imp) && (0xffffffff != mmc->dsr)) {
+               cmd.cmdidx = MMC_CMD_SET_DSR;
+               cmd.cmdarg = (mmc->dsr & 0xffff) << 16;
+               cmd.resp_type = MMC_RSP_NONE;
+               if (mmc_send_cmd(mmc, &cmd, NULL))
+                       printf("MMC: SET_DSR failed\n");
+       }
+
        /* Select the card, and put it into Transfer Mode */
        if (!mmc_host_is_spi(mmc)) { /* cmd not supported in spi */
                cmd.cmdidx = MMC_CMD_SELECT_CARD;
@@ -1163,6 +1172,9 @@ static int mmc_send_if_cond(struct mmc *mmc)
 
 int mmc_register(struct mmc *mmc)
 {
+       /* Setup dsr related values */
+       mmc->dsr_imp = 0;
+       mmc->dsr = 0xffffffff;
        /* Setup the universal parts of the block interface just once */
        mmc->block_dev.if_type = IF_TYPE_MMC;
        mmc->block_dev.dev = cur_dev_num++;
@@ -1280,6 +1292,12 @@ int mmc_init(struct mmc *mmc)
        return err;
 }
 
+int mmc_set_dsr(struct mmc *mmc, u16 val)
+{
+       mmc->dsr = val;
+       return 0;
+}
+
 /*
  * CPU and board-specific MMC initializations.  Aliased function
  * signals caller to move on
index 46ae9cb52d9cfb45781080c04b9ec84a27d6f7e3..1e86b92beec913dc1dc554ac1dcb24d082146591 100644 (file)
@@ -24,7 +24,8 @@ static void sdhci_reset(struct sdhci_host *host, u8 mask)
        sdhci_writeb(host, mask, SDHCI_SOFTWARE_RESET);
        while (sdhci_readb(host, SDHCI_SOFTWARE_RESET) & mask) {
                if (timeout == 0) {
-                       printf("Reset 0x%x never completed.\n", (int)mask);
+                       printf("%s: Reset 0x%x never completed.\n",
+                              __func__, (int)mask);
                        return;
                }
                timeout--;
@@ -79,7 +80,8 @@ static int sdhci_transfer_data(struct sdhci_host *host, struct mmc_data *data,
        do {
                stat = sdhci_readl(host, SDHCI_INT_STATUS);
                if (stat & SDHCI_INT_ERROR) {
-                       printf("Error detected in status(0x%X)!\n", stat);
+                       printf("%s: Error detected in status(0x%X)!\n",
+                              __func__, stat);
                        return -1;
                }
                if (stat & rdy) {
@@ -102,7 +104,7 @@ static int sdhci_transfer_data(struct sdhci_host *host, struct mmc_data *data,
                if (timeout-- > 0)
                        udelay(10);
                else {
-                       printf("Transfer data timeout\n");
+                       printf("%s: Transfer data timeout\n", __func__);
                        return -1;
                }
        } while (!(stat & SDHCI_INT_DATA_END));
@@ -147,7 +149,7 @@ int sdhci_send_command(struct mmc *mmc, struct mmc_cmd *cmd,
 
        while (sdhci_readl(host, SDHCI_PRESENT_STATE) & mask) {
                if (time >= cmd_timeout) {
-                       printf("MMC: %d busy ", mmc_dev);
+                       printf("%s: MMC: %d busy ", __func__, mmc_dev);
                        if (2 * cmd_timeout <= CONFIG_SDHCI_CMD_MAX_TIMEOUT) {
                                cmd_timeout += cmd_timeout;
                                printf("timeout increasing to: %u ms.\n",
@@ -179,7 +181,7 @@ int sdhci_send_command(struct mmc *mmc, struct mmc_cmd *cmd,
        if (data)
                flags |= SDHCI_CMD_DATA;
 
-       /*Set Transfer mode regarding to data flag*/
+       /* Set Transfer mode regarding to data flag */
        if (data != 0) {
                sdhci_writeb(host, 0xe, SDHCI_TIMEOUT_CONTROL);
                mode = SDHCI_TRNS_BLK_CNT_EN;
@@ -230,7 +232,7 @@ int sdhci_send_command(struct mmc *mmc, struct mmc_cmd *cmd,
                if (host->quirks & SDHCI_QUIRK_BROKEN_R1B)
                        return 0;
                else {
-                       printf("Timeout for status update!\n");
+                       printf("%s: Timeout for status update!\n", __func__);
                        return TIMEOUT;
                }
        }
@@ -307,7 +309,8 @@ static int sdhci_set_clock(struct mmc *mmc, unsigned int clock)
        while (!((clk = sdhci_readw(host, SDHCI_CLOCK_CONTROL))
                & SDHCI_CLOCK_INT_STABLE)) {
                if (timeout == 0) {
-                       printf("Internal clock never stabilised.\n");
+                       printf("%s: Internal clock never stabilised.\n",
+                              __func__);
                        return -1;
                }
                timeout--;
@@ -397,7 +400,8 @@ int sdhci_init(struct mmc *mmc)
        if ((host->quirks & SDHCI_QUIRK_32BIT_DMA_ADDR) && !aligned_buffer) {
                aligned_buffer = memalign(8, 512*1024);
                if (!aligned_buffer) {
-                       printf("Aligned buffer alloc failed!!!");
+                       printf("%s: Aligned buffer alloc failed!!!\n",
+                              __func__);
                        return -1;
                }
        }
@@ -418,8 +422,8 @@ int sdhci_init(struct mmc *mmc)
        }
 
        /* Enable only interrupts served by the SD controller */
-       sdhci_writel(host, SDHCI_INT_DATA_MASK | SDHCI_INT_CMD_MASK
-                    SDHCI_INT_ENABLE);
+       sdhci_writel(host, SDHCI_INT_DATA_MASK | SDHCI_INT_CMD_MASK,
+                    SDHCI_INT_ENABLE);
        /* Mask all sdhci interrupt sources */
        sdhci_writel(host, 0x0, SDHCI_SIGNAL_ENABLE);
 
@@ -433,7 +437,7 @@ int add_sdhci(struct sdhci_host *host, u32 max_clk, u32 min_clk)
 
        mmc = malloc(sizeof(struct mmc));
        if (!mmc) {
-               printf("mmc malloc fail!\n");
+               printf("%s: mmc malloc fail!\n", __func__);
                return -1;
        }
 
@@ -450,7 +454,8 @@ int add_sdhci(struct sdhci_host *host, u32 max_clk, u32 min_clk)
        caps = sdhci_readl(host, SDHCI_CAPABILITIES);
 #ifdef CONFIG_MMC_SDMA
        if (!(caps & SDHCI_CAN_DO_SDMA)) {
-               printf("Your controller don't support sdma!!\n");
+               printf("%s: Your controller doesn't support SDMA!!\n",
+                      __func__);
                return -1;
        }
 #endif
@@ -467,7 +472,8 @@ int add_sdhci(struct sdhci_host *host, u32 max_clk, u32 min_clk)
                mmc->f_max *= 1000000;
        }
        if (mmc->f_max == 0) {
-               printf("Hardware doesn't specify base clock frequency\n");
+               printf("%s: Hardware doesn't specify base clock frequency\n",
+                      __func__);
                return -1;
        }
        if (min_clk)
diff --git a/drivers/mmc/socfpga_dw_mmc.c b/drivers/mmc/socfpga_dw_mmc.c
new file mode 100644 (file)
index 0000000..bc53a5d
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * (C) Copyright 2013 Altera Corporation <www.altera.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <common.h>
+#include <malloc.h>
+#include <dwmmc.h>
+#include <asm/arch/dwmmc.h>
+#include <asm/arch/clock_manager.h>
+#include <asm/arch/system_manager.h>
+
+static const struct socfpga_clock_manager *clock_manager_base =
+               (void *)SOCFPGA_CLKMGR_ADDRESS;
+static const struct socfpga_system_manager *system_manager_base =
+               (void *)SOCFPGA_SYSMGR_ADDRESS;
+
+static char *SOCFPGA_NAME = "SOCFPGA DWMMC";
+
+static void socfpga_dwmci_clksel(struct dwmci_host *host)
+{
+       unsigned int drvsel;
+       unsigned int smplsel;
+
+       /* Disable SDMMC clock. */
+       clrbits_le32(&clock_manager_base->per_pll_en,
+               CLKMGR_PERPLLGRP_EN_SDMMCCLK_MASK);
+
+       /* Configures drv_sel and smpl_sel */
+       drvsel = CONFIG_SOCFPGA_DWMMC_DRVSEL;
+       smplsel = CONFIG_SOCFPGA_DWMMC_SMPSEL;
+
+       debug("%s: drvsel %d smplsel %d\n", __func__, drvsel, smplsel);
+       writel(SYSMGR_SDMMC_CTRL_SET(smplsel, drvsel),
+               &system_manager_base->sdmmcgrp_ctrl);
+
+       debug("%s: SYSMGR_SDMMCGRP_CTRL_REG = 0x%x\n", __func__,
+               readl(&system_manager_base->sdmmcgrp_ctrl));
+
+       /* Enable SDMMC clock */
+       setbits_le32(&clock_manager_base->per_pll_en,
+               CLKMGR_PERPLLGRP_EN_SDMMCCLK_MASK);
+}
+
+int socfpga_dwmmc_init(u32 regbase, int bus_width, int index)
+{
+       struct dwmci_host *host = NULL;
+       host = calloc(sizeof(struct dwmci_host), 1);
+       if (!host) {
+               printf("dwmci_host calloc fail!\n");
+               return -1;
+       }
+
+       host->name = SOCFPGA_NAME;
+       host->ioaddr = (void *)regbase;
+       host->buswidth = bus_width;
+       host->clksel = socfpga_dwmci_clksel;
+       host->dev_index = index;
+       /* fixed clock divide by 4 which due to the SDMMC wrapper */
+       host->bus_hz = CONFIG_SOCFPGA_DWMMC_BUS_HZ;
+       host->fifoth_val = MSIZE(0x2) |
+               RX_WMARK(CONFIG_SOCFPGA_DWMMC_FIFO_DEPTH / 2 - 1) |
+               TX_WMARK(CONFIG_SOCFPGA_DWMMC_FIFO_DEPTH / 2);
+
+       return add_dwmci(host, host->bus_hz, 400000);
+}
+
index e145cd18421ad764f661c174ea1b70357f2b4d4e..02b149caccaa9793ff00a85d8d1299037fa25101 100644 (file)
@@ -5,8 +5,6 @@
 # SPDX-License-Identifier:     GPL-2.0+
 #
 
-ifdef CONFIG_CMD_NAND
-
 ifdef CONFIG_SPL_BUILD
 
 ifdef CONFIG_SPL_NAND_DRIVERS
@@ -69,4 +67,3 @@ obj-$(CONFIG_NAND_FSL_IFC) += fsl_ifc_spl.o
 obj-$(CONFIG_NAND_MXC) += mxc_nand_spl.o
 
 endif # drivers
-endif # nand
index eeaa7e8a488b0e90e91cb0846013975162092776..b292826034f9f3964ae4278ed77314b953bcb761 100644 (file)
@@ -315,7 +315,7 @@ int nand_unlock(struct mtd_info *mtd, loff_t start, size_t length,
        int page;
        struct nand_chip *chip = mtd->priv;
 
-       debug("nand_unlock%s: start: %08llx, length: %d!\n",
+       debug("nand_unlock%s: start: %08llx, length: %zd!\n",
                allexcept ? " (allexcept)" : "", start, length);
 
        /* select the NAND device */
index 5e7e6b337544f3f7543baf7e8c1bcee9242a00e4..790d5385e0bdc18ec5172f21735f8232265b46e5 100644 (file)
@@ -283,53 +283,55 @@ static void omap_hwecc_init_bch(struct nand_chip *chip, int32_t mode)
        if (bch->ecc_scheme == OMAP_ECC_BCH8_CODE_HW) {
                wr_mode = BCH_WRAPMODE_1;
 
-       switch (bch->nibbles) {
-       case ECC_BCH4_NIBBLES:
-               unused_length = 3;
-               break;
-       case ECC_BCH8_NIBBLES:
-               unused_length = 2;
-               break;
-       case ECC_BCH16_NIBBLES:
-               unused_length = 0;
-               break;
-       }
-
-       /*
-        * This is ecc_size_config for ELM mode.
-        * Here we are using different settings for read and write access and
-        * also depending on BCH strength.
-        */
-       switch (mode) {
-       case NAND_ECC_WRITE:
-               /* write access only setup eccsize1 config */
-               val = ((unused_length + bch->nibbles) << 22);
-               break;
+               switch (bch->nibbles) {
+               case ECC_BCH4_NIBBLES:
+                       unused_length = 3;
+                       break;
+               case ECC_BCH8_NIBBLES:
+                       unused_length = 2;
+                       break;
+               case ECC_BCH16_NIBBLES:
+                       unused_length = 0;
+                       break;
+               }
 
-       case NAND_ECC_READ:
-       default:
                /*
-                * by default eccsize0 selected for ecc1resultsize
-                * eccsize0 config.
+                * This is ecc_size_config for ELM mode.  Here we are using
+                * different settings for read and write access and also
+                * depending on BCH strength.
                 */
-               val  = (bch->nibbles << 12);
-               /* eccsize1 config */
-               val |= (unused_length << 22);
-               break;
-       }
+               switch (mode) {
+               case NAND_ECC_WRITE:
+                       /* write access only setup eccsize1 config */
+                       val = ((unused_length + bch->nibbles) << 22);
+                       break;
+
+               case NAND_ECC_READ:
+               default:
+                       /*
+                        * by default eccsize0 selected for ecc1resultsize
+                        * eccsize0 config.
+                        */
+                       val  = (bch->nibbles << 12);
+                       /* eccsize1 config */
+                       val |= (unused_length << 22);
+                       break;
+               }
        } else {
-       /*
-        * This ecc_size_config setting is for BCH sw library.
-        *
-        * Note: we only support BCH8 currently with BCH sw library!
-        * Should be really easy to adobt to BCH4, however some omap3 have
-        * flaws with BCH4.
-        *
-        * Here we are using wrapping mode 6 both for reading and writing, with:
-        *  size0 = 0  (no additional protected byte in spare area)
-        *  size1 = 32 (skip 32 nibbles = 16 bytes per sector in spare area)
-        */
-       val = (32 << 22) | (0 << 12);
+               /*
+                * This ecc_size_config setting is for BCH sw library.
+                *
+                * Note: we only support BCH8 currently with BCH sw library!
+                * Should be really easy to adobt to BCH4, however some omap3
+                * have flaws with BCH4.
+                *
+                * Here we are using wrapping mode 6 both for reading and
+                * writing, with:
+                *  size0 = 0  (no additional protected byte in spare area)
+                *  size1 = 32 (skip 32 nibbles = 16 bytes per sector in
+                *              spare area)
+                */
+               val = (32 << 22) | (0 << 12);
        }
        /* ecc size configuration */
        writel(val, &gpmc_cfg->ecc_size_config);
@@ -761,7 +763,7 @@ static void __maybe_unused omap_free_bch(struct mtd_info *mtd)
 static int omap_select_ecc_scheme(struct nand_chip *nand,
        enum omap_ecc ecc_scheme, unsigned int pagesize, unsigned int oobsize) {
        struct nand_bch_priv    *bch            = nand->priv;
-       struct nand_ecclayout   *ecclayout      = nand->ecc.layout;
+       struct nand_ecclayout   *ecclayout      = &omap_ecclayout;
        int eccsteps = pagesize / SECTOR_BYTES;
        int i;
 
@@ -774,7 +776,7 @@ static int omap_select_ecc_scheme(struct nand_chip *nand,
                bch_priv.type           = 0;
                nand->ecc.mode          = NAND_ECC_SOFT;
                nand->ecc.layout        = NULL;
-               nand->ecc.size          = pagesize;
+               nand->ecc.size          = 0;
                bch->ecc_scheme         = OMAP_ECC_HAM1_CODE_SW;
                break;
 
@@ -789,6 +791,7 @@ static int omap_select_ecc_scheme(struct nand_chip *nand,
                bch_priv.control        = NULL;
                bch_priv.type           = 0;
                /* populate ecc specific fields */
+               memset(&nand->ecc, 0, sizeof(struct nand_ecc_ctrl));
                nand->ecc.mode          = NAND_ECC_HW;
                nand->ecc.strength      = 1;
                nand->ecc.size          = SECTOR_BYTES;
@@ -798,8 +801,12 @@ static int omap_select_ecc_scheme(struct nand_chip *nand,
                nand->ecc.calculate     = omap_calculate_ecc;
                /* define ecc-layout */
                ecclayout->eccbytes     = nand->ecc.bytes * eccsteps;
-               for (i = 0; i < ecclayout->eccbytes; i++)
-                       ecclayout->eccpos[i] = i + BADBLOCK_MARKER_LENGTH;
+               for (i = 0; i < ecclayout->eccbytes; i++) {
+                       if (nand->options & NAND_BUSWIDTH_16)
+                               ecclayout->eccpos[i] = i + 2;
+                       else
+                               ecclayout->eccpos[i] = i + 1;
+               }
                ecclayout->oobfree[0].offset = i + BADBLOCK_MARKER_LENGTH;
                ecclayout->oobfree[0].length = oobsize - ecclayout->eccbytes -
                                                BADBLOCK_MARKER_LENGTH;
@@ -823,6 +830,7 @@ static int omap_select_ecc_scheme(struct nand_chip *nand,
                }
                bch_priv.type = ECC_BCH8;
                /* populate ecc specific fields */
+               memset(&nand->ecc, 0, sizeof(struct nand_ecc_ctrl));
                nand->ecc.mode          = NAND_ECC_HW;
                nand->ecc.strength      = 8;
                nand->ecc.size          = SECTOR_BYTES;
@@ -865,6 +873,7 @@ static int omap_select_ecc_scheme(struct nand_chip *nand,
                elm_init();
                bch_priv.type           = ECC_BCH8;
                /* populate ecc specific fields */
+               memset(&nand->ecc, 0, sizeof(struct nand_ecc_ctrl));
                nand->ecc.mode          = NAND_ECC_HW;
                nand->ecc.strength      = 8;
                nand->ecc.size          = SECTOR_BYTES;
@@ -891,6 +900,11 @@ static int omap_select_ecc_scheme(struct nand_chip *nand,
                debug("nand: error: ecc scheme not enabled or supported\n");
                return -EINVAL;
        }
+
+       /* nand_scan_tail() sets ham1 sw ecc; hw ecc layout is set by driver */
+       if (ecc_scheme != OMAP_ECC_HAM1_CODE_SW)
+               nand->ecc.layout = ecclayout;
+
        return 0;
 }
 
index 979e4af7c5fc73df42165fdb4b86034fb6cdc8c2..e33e8d38e7a48808d9e8c982a7470b2b78eea01c 100644 (file)
@@ -91,7 +91,13 @@ static struct nand_ecclayout onenand_oob_32 = {
        .oobfree        = { {2, 3}, {14, 2}, {18, 3}, {30, 2} }
 };
 
-static const unsigned char ffchars[] = {
+/*
+ * Warning! This array is used with the memcpy_16() function, thus
+ * it must be aligned to 2 bytes. GCC can make this array unaligned
+ * as the array is made of unsigned char, which memcpy16() doesn't
+ * like and will cause unaligned access.
+ */
+static const unsigned char __aligned(2) ffchars[] = {
        0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
        0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 16 */
        0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
index 108665f4415f60433ccefa596b1c39e3836d5017..e316a692a8de61f0870b0022256cd44b30f71003 100644 (file)
@@ -273,9 +273,15 @@ int spi_flash_cmd_read_ops(struct spi_flash *flash, u32 offset,
 
        /* Handle memory-mapped SPI */
        if (flash->memory_map) {
+               ret = spi_claim_bus(flash->spi);
+               if (ret) {
+                       debug("SF: unable to claim SPI bus\n");
+                       return ret;
+               }
                spi_xfer(flash->spi, 0, NULL, NULL, SPI_XFER_MMAP);
                memcpy(data, flash->memory_map + offset, len);
                spi_xfer(flash->spi, 0, NULL, NULL, SPI_XFER_MMAP_END);
+               spi_release_bus(flash->spi);
                return 0;
        }
 
index c1eb7548983355f19ce5596941ed6472f11fd1d0..b863a9828348a535b668c298f5a98a71434f6070 100644 (file)
@@ -60,6 +60,7 @@ static const struct spi_flash_params spi_flash_params_table[] = {
        {"GD25LQ32",       0xc86016, 0x0,       64 * 1024,    64,              SECT_4K},
 #endif
 #ifdef CONFIG_SPI_FLASH_MACRONIX       /* MACRONIX */
+       {"MX25L2006E",     0xc22012, 0x0,       64 * 1024,     4,                    0},
        {"MX25L4005",      0xc22013, 0x0,       64 * 1024,     8,                    0},
        {"MX25L8005",      0xc22014, 0x0,       64 * 1024,    16,                    0},
        {"MX25L1605D",     0xc22015, 0x0,       64 * 1024,    32,                    0},
@@ -67,7 +68,7 @@ static const struct spi_flash_params spi_flash_params_table[] = {
        {"MX25L6405D",     0xc22017, 0x0,       64 * 1024,   128,                    0},
        {"MX25L12805",     0xc22018, 0x0,       64 * 1024,   256,                    0},
        {"MX25L25635F",    0xc22019, 0x0,       64 * 1024,   512,                    0},
-       {"MX25L51235F",    0xc2201A, 0x0,       64 * 1024,  1024,                    0},
+       {"MX25L51235F",    0xc2201a, 0x0,       64 * 1024,  1024,                    0},
        {"MX25L12855E",    0xc22618, 0x0,       64 * 1024,   256,                    0},
 #endif
 #ifdef CONFIG_SPI_FLASH_SPANSION       /* SPANSION */
index e1f3a241a260f3b818dd2216459936cb09fbdd52..56c2823477da3388d455b23b18b7253a29f776be 100644 (file)
@@ -5,9 +5,6 @@
 # SPDX-License-Identifier:     GPL-2.0+
 #
 
-ifdef CONFIG_CMD_UBI
 obj-y += build.o vtbl.o vmt.o upd.o kapi.o eba.o io.o wl.o scan.o crc32.o
-
 obj-y += misc.o
 obj-y += debug.o
-endif
index cd787f4eedabf13d091a1fc05577a7cde1b9102b..74c72d3ff796847d607974d5939d7389f7500712 100644 (file)
@@ -276,13 +276,64 @@ static void ft_fixup_port(void *blob, struct fm_eth_info *info, char *prop)
                "status", "disabled", strlen("disabled") + 1, 1);
 }
 
+#ifdef CONFIG_SYS_FMAN_V3
+static int ft_fixup_xgec(void *blob, struct fm_eth_info *info)
+{
+       int off, i, ci;
+#define FM1_10GEC3_RX_PORT_ADDR        (CONFIG_SYS_CCSRBAR_PHYS + 0x488000)
+#define FM1_10GEC3_TX_PORT_ADDR        (CONFIG_SYS_CCSRBAR_PHYS + 0x4a8000)
+#define FM1_10GEC3_MAC_ADDR    (CONFIG_SYS_CCSRBAR_PHYS + 0x4e0000)
+
+       if ((info->port == FM1_10GEC3) || (info->port == FM1_10GEC4)) {
+               ci = (info->port == FM1_10GEC3) ? 2 : 3;
+               i = (info->port == FM1_10GEC3) ? 0 : 1;
+
+               off = fdt_node_offset_by_compat_reg(blob, "fsl,fman-port-1g-rx",
+                                                   FM1_10GEC3_RX_PORT_ADDR +
+                                                   i * 0x1000);
+               if (off > 0) {
+                       fdt_setprop(blob, off, "cell-index", &ci, sizeof(int));
+                       fdt_setprop(blob, off, "compatible",
+                                   "fsl,fman-port-10g-rx", 20);
+               } else {
+                       goto err;
+               }
+
+               off = fdt_node_offset_by_compat_reg(blob, "fsl,fman-port-1g-tx",
+                                                   FM1_10GEC3_TX_PORT_ADDR +
+                                                   i * 0x1000);
+               if (off > 0) {
+                       fdt_setprop(blob, off, "cell-index", &ci, sizeof(int));
+                       fdt_setprop(blob, off, "compatible",
+                                   "fsl,fman-port-10g-tx", 20);
+               } else {
+                       goto err;
+               }
+
+               off = fdt_node_offset_by_compat_reg(blob, "fsl,fman-memac",
+                                                   FM1_10GEC3_MAC_ADDR +
+                                                   i * 0x2000);
+               if (off > 0)
+                       fdt_setprop(blob, off, "cell-index", &ci, sizeof(int));
+               else
+                       goto err;
+       }
+       return 0;
+err:
+       printf("WARNING: Fail to find the node\n");
+       return -1;
+}
+#endif
+
 void fdt_fixup_fman_ethernet(void *blob)
 {
        int i;
 
 #ifdef CONFIG_SYS_FMAN_V3
-       for (i = 0; i < ARRAY_SIZE(fm_info); i++)
+       for (i = 0; i < ARRAY_SIZE(fm_info); i++) {
                ft_fixup_port(blob, &fm_info[i], "fsl,fman-memac");
+               ft_fixup_xgec(blob, &fm_info[i]);
+       }
 #else
        for (i = 0; i < ARRAY_SIZE(fm_info); i++) {
                if (fm_info[i].type == FM_ETH_1G_E)
index 8aa71098cb3126092e486136dfc7e81b53089b99..331c07cb5962ac1a6d7b9d4ce9319ef19a94ca50 100644 (file)
@@ -287,7 +287,9 @@ static const u16 sh_eth_offset_fast_sh4[SH_ETH_MAX_REGISTER_OFFSET] = {
 #if defined(CONFIG_CPU_SH7763) || defined(CONFIG_CPU_SH7734)
 #define SH_ETH_TYPE_GETHER
 #define BASE_IO_ADDR   0xfee00000
-#elif defined(CONFIG_CPU_SH7757) || defined(CONFIG_CPU_SH7752)
+#elif defined(CONFIG_CPU_SH7757) || \
+       defined(CONFIG_CPU_SH7752) || \
+       defined(CONFIG_CPU_SH7753)
 #if defined(CONFIG_SH_ETHER_USE_GETHER)
 #define SH_ETH_TYPE_GETHER
 #define BASE_IO_ADDR   0xfee00000
@@ -356,7 +358,9 @@ enum DMAC_T_BIT {
 
 /* GECMR */
 enum GECMR_BIT {
-#if defined(CONFIG_CPU_SH7757) || defined(CONFIG_CPU_SH7752)
+#if defined(CONFIG_CPU_SH7757) || \
+       defined(CONFIG_CPU_SH7752) || \
+       defined(CONFIG_CPU_SH7753)
        GECMR_1000B = 0x20, GECMR_100B = 0x01, GECMR_10B = 0x00,
 #else
        GECMR_1000B = 0x01, GECMR_100B = 0x04, GECMR_10B = 0x00,
index 9c7c6213a589894cfd7ebedc9ed4ca0bc53fb6cc..c8926a8945ac6c84e81ff651a18ed0b2eb8566ef 100644 (file)
@@ -38,6 +38,9 @@ static int lpc32xx_serial_getc(void)
 
 static void lpc32xx_serial_putc(const char c)
 {
+       if (c == '\n')
+               serial_putc('\r');
+
        writel(c, &hsuart->tx);
 
        /* Wait for character to be sent */
index 556b8681502833b6a3e32926eee162976f54ac43..f5e9854d13d23dfce7065f5ed401b06be567c6af 100644 (file)
@@ -143,7 +143,9 @@ struct uart_port {
 #elif defined(CONFIG_H8S2678)
 # define SCSCR_INIT(port)          0x30 /* TIE=0,RIE=0,TE=1,RE=1 */
 # define H8300_SCI_DR(ch) (*(volatile char *)(P1DR + h8300_sci_pins[ch].port))
-#elif defined(CONFIG_CPU_SH7757) || defined(CONFIG_CPU_SH7752)
+#elif defined(CONFIG_CPU_SH7757) || \
+       defined(CONFIG_CPU_SH7752) || \
+       defined(CONFIG_CPU_SH7753)
 # define SCSPTR0 0xfe4b0020
 # define SCSPTR1 0xfe4b0020
 # define SCSPTR2 0xfe4b0020
index ed4ecd754b4fe2a1d723214254f3aee8dfe7c3f1..d5a7143b5001b3590a9643b311aa80175ed53391 100644 (file)
@@ -30,6 +30,7 @@ obj-$(CONFIG_OMAP3_SPI) += omap3_spi.o
 obj-$(CONFIG_SANDBOX_SPI) += sandbox_spi.o
 obj-$(CONFIG_SOFT_SPI) += soft_spi.o
 obj-$(CONFIG_SH_SPI) += sh_spi.o
+obj-$(CONFIG_SH_QSPI) += sh_qspi.o
 obj-$(CONFIG_FSL_ESPI) += fsl_espi.o
 obj-$(CONFIG_FDT_SPI) += fdt_spi.o
 obj-$(CONFIG_TEGRA20_SFLASH) += tegra20_sflash.o
diff --git a/drivers/spi/sh_qspi.c b/drivers/spi/sh_qspi.c
new file mode 100644 (file)
index 0000000..edeb42d
--- /dev/null
@@ -0,0 +1,277 @@
+/*
+ * SH QSPI (Quad SPI) driver
+ *
+ * Copyright (C) 2013 Renesas Electronics Corporation
+ * Copyright (C) 2013 Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#include <common.h>
+#include <malloc.h>
+#include <spi.h>
+#include <asm/io.h>
+
+/* SH QSPI register bit masks <REG>_<BIT> */
+#define SPCR_MSTR      0x08
+#define SPCR_SPE       0x40
+#define SPSR_SPRFF     0x80
+#define SPSR_SPTEF     0x20
+#define SPPCR_IO3FV    0x04
+#define SPPCR_IO2FV    0x02
+#define SPPCR_IO1FV    0x01
+#define SPBDCR_RXBC0   (1 << 0)
+#define SPCMD_SCKDEN   (1 << 15)
+#define SPCMD_SLNDEN   (1 << 14)
+#define SPCMD_SPNDEN   (1 << 13)
+#define SPCMD_SSLKP    (1 << 7)
+#define SPCMD_BRDV0    (1 << 2)
+#define SPCMD_INIT1    SPCMD_SCKDEN | SPCMD_SLNDEN | \
+                       SPCMD_SPNDEN | SPCMD_SSLKP | \
+                       SPCMD_BRDV0
+#define SPCMD_INIT2    SPCMD_SPNDEN | SPCMD_SSLKP | \
+                       SPCMD_BRDV0
+#define SPBFCR_TXRST   (1 << 7)
+#define SPBFCR_RXRST   (1 << 6)
+
+/* SH QSPI register set */
+struct sh_qspi_regs {
+       unsigned char spcr;
+       unsigned char sslp;
+       unsigned char sppcr;
+       unsigned char spsr;
+       unsigned long spdr;
+       unsigned char spscr;
+       unsigned char spssr;
+       unsigned char spbr;
+       unsigned char spdcr;
+       unsigned char spckd;
+       unsigned char sslnd;
+       unsigned char spnd;
+       unsigned char dummy0;
+       unsigned short spcmd0;
+       unsigned short spcmd1;
+       unsigned short spcmd2;
+       unsigned short spcmd3;
+       unsigned char spbfcr;
+       unsigned char dummy1;
+       unsigned short spbdcr;
+       unsigned long spbmul0;
+       unsigned long spbmul1;
+       unsigned long spbmul2;
+       unsigned long spbmul3;
+};
+
+struct sh_qspi_slave {
+       struct spi_slave        slave;
+       struct sh_qspi_regs     *regs;
+};
+
+static inline struct sh_qspi_slave *to_sh_qspi(struct spi_slave *slave)
+{
+       return container_of(slave, struct sh_qspi_slave, slave);
+}
+
+static void sh_qspi_init(struct sh_qspi_slave *ss)
+{
+       /* QSPI initialize */
+       /* Set master mode only */
+       writeb(SPCR_MSTR, &ss->regs->spcr);
+
+       /* Set SSL signal level */
+       writeb(0x00, &ss->regs->sslp);
+
+       /* Set MOSI signal value when transfer is in idle state */
+       writeb(SPPCR_IO3FV|SPPCR_IO2FV, &ss->regs->sppcr);
+
+       /* Set bit rate. See 58.3.8 Quad Serial Peripheral Interface */
+       writeb(0x01, &ss->regs->spbr);
+
+       /* Disable Dummy Data Transmission */
+       writeb(0x00, &ss->regs->spdcr);
+
+       /* Set clock delay value */
+       writeb(0x00, &ss->regs->spckd);
+
+       /* Set SSL negation delay value */
+       writeb(0x00, &ss->regs->sslnd);
+
+       /* Set next-access delay value */
+       writeb(0x00, &ss->regs->spnd);
+
+       /* Set equence command */
+       writew(SPCMD_INIT2, &ss->regs->spcmd0);
+
+       /* Reset transfer and receive Buffer */
+       setbits_8(&ss->regs->spbfcr, SPBFCR_TXRST|SPBFCR_RXRST);
+
+       /* Clear transfer and receive Buffer control bit */
+       clrbits_8(&ss->regs->spbfcr, SPBFCR_TXRST|SPBFCR_RXRST);
+
+       /* Set equence control method. Use equence0 only */
+       writeb(0x00, &ss->regs->spscr);
+
+       /* Enable SPI function */
+       setbits_8(&ss->regs->spcr, SPCR_SPE);
+}
+
+int spi_cs_is_valid(unsigned int bus, unsigned int cs)
+{
+       return 1;
+}
+
+void spi_cs_activate(struct spi_slave *slave)
+{
+       struct sh_qspi_slave *ss = to_sh_qspi(slave);
+
+       /* Set master mode only */
+       writeb(SPCR_MSTR, &ss->regs->spcr);
+
+       /* Set command */
+       writew(SPCMD_INIT1, &ss->regs->spcmd0);
+
+       /* Reset transfer and receive Buffer */
+       setbits_8(&ss->regs->spbfcr, SPBFCR_TXRST|SPBFCR_RXRST);
+
+       /* Clear transfer and receive Buffer control bit */
+       clrbits_8(&ss->regs->spbfcr, SPBFCR_TXRST|SPBFCR_RXRST);
+
+       /* Set equence control method. Use equence0 only */
+       writeb(0x00, &ss->regs->spscr);
+
+       /* Enable SPI function */
+       setbits_8(&ss->regs->spcr, SPCR_SPE);
+}
+
+void spi_cs_deactivate(struct spi_slave *slave)
+{
+       struct sh_qspi_slave *ss = to_sh_qspi(slave);
+
+       /* Disable SPI Function */
+       clrbits_8(&ss->regs->spcr, SPCR_SPE);
+}
+
+void spi_init(void)
+{
+       /* nothing to do */
+}
+
+struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
+               unsigned int max_hz, unsigned int mode)
+{
+       struct sh_qspi_slave *ss;
+
+       if (!spi_cs_is_valid(bus, cs))
+               return NULL;
+
+       ss = spi_alloc_slave(struct sh_qspi_slave, bus, cs);
+       if (!ss) {
+               printf("SPI_error: Fail to allocate sh_qspi_slave\n");
+               return NULL;
+       }
+
+       ss->regs = (struct sh_qspi_regs *)CONFIG_SH_QSPI_BASE;
+
+       /* Init SH QSPI */
+       sh_qspi_init(ss);
+
+       return &ss->slave;
+}
+
+void spi_free_slave(struct spi_slave *slave)
+{
+       struct sh_qspi_slave *spi = to_sh_qspi(slave);
+
+       free(spi);
+}
+
+int spi_claim_bus(struct spi_slave *slave)
+{
+       return 0;
+}
+
+void spi_release_bus(struct spi_slave *slave)
+{
+}
+
+int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,
+            void *din, unsigned long flags)
+{
+       struct sh_qspi_slave *ss = to_sh_qspi(slave);
+       unsigned long nbyte;
+       int ret = 0;
+       unsigned char dtdata = 0, drdata;
+       unsigned char *tdata = &dtdata, *rdata = &drdata;
+       unsigned long *spbmul0 = &ss->regs->spbmul0;
+
+       if (dout == NULL && din == NULL) {
+               if (flags & SPI_XFER_END)
+                       spi_cs_deactivate(slave);
+               return 0;
+       }
+
+       if (bitlen % 8) {
+               printf("%s: bitlen is not 8bit alined %d", __func__, bitlen);
+               return 1;
+       }
+
+       nbyte = bitlen / 8;
+
+       if (flags & SPI_XFER_BEGIN) {
+               spi_cs_activate(slave);
+
+               /* Set 1048576 byte */
+               writel(0x100000, spbmul0);
+       }
+
+       if (flags & SPI_XFER_END)
+               writel(nbyte, spbmul0);
+
+       if (dout != NULL)
+               tdata = (unsigned char *)dout;
+
+       if (din != NULL)
+               rdata = din;
+
+       while (nbyte > 0) {
+               while (!(readb(&ss->regs->spsr) & SPSR_SPTEF)) {
+                       if (ctrlc()) {
+                               puts("abort\n");
+                               return 1;
+                       }
+                       udelay(10);
+               }
+
+               writeb(*tdata, (unsigned char *)(&ss->regs->spdr));
+
+               while ((readw(&ss->regs->spbdcr) != SPBDCR_RXBC0)) {
+                       if (ctrlc()) {
+                               puts("abort\n");
+                               return 1;
+                       }
+                       udelay(1);
+               }
+
+               while (!(readb(&ss->regs->spsr) & SPSR_SPRFF)) {
+                       if (ctrlc()) {
+                               puts("abort\n");
+                               return 1;
+                       }
+                       udelay(10);
+               }
+
+               *rdata = readb((unsigned char *)(&ss->regs->spdr));
+
+               if (dout != NULL)
+                       tdata++;
+               if (din != NULL)
+                       rdata++;
+
+               nbyte--;
+       }
+
+       if (flags & SPI_XFER_END)
+               spi_cs_deactivate(slave);
+
+       return ret;
+}
index 4d2af483d77f07688e6a4297a1ad952ea0d9a99a..810fa4718ce17b87c389a522c6cea788c9df3867 100644 (file)
@@ -289,9 +289,6 @@ int tegra114_spi_xfer(struct spi_slave *slave, unsigned int bitlen,
        reg = readl(&regs->fifo_status);
        writel(reg, &regs->fifo_status);
 
-       /* clear ready bit */
-       setbits_le32(&regs->xfer_status, SPI_XFER_STS_RDY);
-
        clrsetbits_le32(&regs->command1, SPI_CMD1_CS_SW_VAL,
                        SPI_CMD1_RX_EN | SPI_CMD1_TX_EN | SPI_CMD1_LSBY_FE |
                        (slave->cs << SPI_CMD1_CS_SEL_SHIFT));
@@ -305,7 +302,6 @@ int tegra114_spi_xfer(struct spi_slave *slave, unsigned int bitlen,
        /* handle data in 32-bit chunks */
        while (num_bytes > 0) {
                int bytes;
-               int is_read = 0;
                int tm, i;
 
                tmpdout = 0;
@@ -319,6 +315,9 @@ int tegra114_spi_xfer(struct spi_slave *slave, unsigned int bitlen,
 
                num_bytes -= bytes;
 
+               /* clear ready bit */
+               setbits_le32(&regs->xfer_status, SPI_XFER_STS_RDY);
+
                clrsetbits_le32(&regs->command1,
                                SPI_CMD1_BIT_LEN_MASK << SPI_CMD1_BIT_LEN_SHIFT,
                                (bytes * 8 - 1) << SPI_CMD1_BIT_LEN_SHIFT);
@@ -329,20 +328,14 @@ int tegra114_spi_xfer(struct spi_slave *slave, unsigned int bitlen,
                 * Wait for SPI transmit FIFO to empty, or to time out.
                 * The RX FIFO status will be read and cleared last
                 */
-               for (tm = 0, is_read = 0; tm < SPI_TIMEOUT; ++tm) {
+               for (tm = 0; tm < SPI_TIMEOUT; ++tm) {
                        u32 fifo_status, xfer_status;
 
-                       fifo_status = readl(&regs->fifo_status);
-
-                       /* We can exit when we've had both RX and TX activity */
-                       if (is_read &&
-                           (fifo_status & SPI_FIFO_STS_TX_FIFO_EMPTY))
-                               break;
-
                        xfer_status = readl(&regs->xfer_status);
                        if (!(xfer_status & SPI_XFER_STS_RDY))
                                continue;
 
+                       fifo_status = readl(&regs->fifo_status);
                        if (fifo_status & SPI_FIFO_STS_ERR) {
                                debug("%s: got a fifo error: ", __func__);
                                if (fifo_status & SPI_FIFO_STS_TX_FIFO_OVF)
@@ -367,7 +360,6 @@ int tegra114_spi_xfer(struct spi_slave *slave, unsigned int bitlen,
 
                        if (!(fifo_status & SPI_FIFO_STS_RX_FIFO_EMPTY)) {
                                tmpdin = readl(&regs->rx_fifo);
-                               is_read = 1;
 
                                /* swap bytes read in */
                                if (din != NULL) {
@@ -377,6 +369,9 @@ int tegra114_spi_xfer(struct spi_slave *slave, unsigned int bitlen,
                                        }
                                        din += bytes;
                                }
+
+                               /* We can exit when we've had both RX and TX */
+                               break;
                        }
                }
 
index 2f2353f809bc98e0899a3ba6611397456cfeed53..150570ee7e4d94c096ad2b2340cfef13c043fc51 100644 (file)
@@ -8,3 +8,4 @@ obj-$(CONFIG_TPM_ATMEL_TWI) += tpm_atmel_twi.o
 obj-$(CONFIG_TPM_TIS_I2C) += tpm.o
 obj-$(CONFIG_TPM_TIS_I2C) += tpm_tis_i2c.o
 obj-$(CONFIG_TPM_TIS_LPC) += tpm_tis_lpc.o
+obj-$(CONFIG_TPM_TIS_SANDBOX) += tpm_tis_sandbox.o
diff --git a/drivers/tpm/tpm_tis_sandbox.c b/drivers/tpm/tpm_tis_sandbox.c
new file mode 100644 (file)
index 0000000..ed4b039
--- /dev/null
@@ -0,0 +1,260 @@
+/*
+ * Copyright (c) 2013 Google, Inc
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <common.h>
+#include <asm/state.h>
+#include <asm/unaligned.h>
+#include <linux/crc8.h>
+
+/* TPM NVRAM location indices. */
+#define FIRMWARE_NV_INDEX              0x1007
+#define KERNEL_NV_INDEX                        0x1008
+
+#define NV_DATA_PUBLIC_PERMISSIONS_OFFSET      60
+
+/* Kernel TPM space - KERNEL_NV_INDEX, locked with physical presence */
+#define ROLLBACK_SPACE_KERNEL_VERSION  2
+#define ROLLBACK_SPACE_KERNEL_UID      0x4752574C  /* 'GRWL' */
+
+struct rollback_space_kernel {
+       /* Struct version, for backwards compatibility */
+       uint8_t struct_version;
+       /* Unique ID to detect space redefinition */
+       uint32_t uid;
+       /* Kernel versions */
+       uint32_t kernel_versions;
+       /* Reserved for future expansion */
+       uint8_t reserved[3];
+       /* Checksum (v2 and later only) */
+       uint8_t crc8;
+} __packed rollback_space_kernel;
+
+/*
+ * These numbers derive from adding the sizes of command fields as shown in
+ * the TPM commands manual.
+ */
+#define TPM_REQUEST_HEADER_LENGTH      10
+#define TPM_RESPONSE_HEADER_LENGTH     10
+
+/* These are the different non-volatile spaces that we emulate */
+enum {
+       NV_GLOBAL_LOCK,
+       NV_SEQ_FIRMWARE,
+       NV_SEQ_KERNEL,
+       NV_SEQ_COUNT,
+};
+
+/* Size of each non-volatile space */
+#define NV_DATA_SIZE           0x20
+
+/*
+ * Information about our TPM emulation. This is preserved in the sandbox
+ * state file if enabled.
+ */
+static struct tpm_state {
+       uint8_t nvdata[NV_SEQ_COUNT][NV_DATA_SIZE];
+} state;
+
+/**
+ * sandbox_tpm_read_state() - read the sandbox EC state from the state file
+ *
+ * If data is available, then blob and node will provide access to it. If
+ * not this function sets up an empty TPM.
+ *
+ * @blob: Pointer to device tree blob, or NULL if no data to read
+ * @node: Node offset to read from
+ */
+static int sandbox_tpm_read_state(const void *blob, int node)
+{
+       const char *prop;
+       int len;
+       int i;
+
+       if (!blob)
+               return 0;
+
+       for (i = 0; i < NV_SEQ_COUNT; i++) {
+               char prop_name[20];
+
+               sprintf(prop_name, "nvdata%d", i);
+               prop = fdt_getprop(blob, node, prop_name, &len);
+               if (prop && len == NV_DATA_SIZE)
+                       memcpy(state.nvdata[i], prop, NV_DATA_SIZE);
+       }
+
+       return 0;
+}
+
+/**
+ * cros_ec_write_state() - Write out our state to the state file
+ *
+ * The caller will ensure that there is a node ready for the state. The node
+ * may already contain the old state, in which case it is overridden.
+ *
+ * @blob: Device tree blob holding state
+ * @node: Node to write our state into
+ */
+static int sandbox_tpm_write_state(void *blob, int node)
+{
+       int i;
+
+       /*
+        * We are guaranteed enough space to write basic properties.
+        * We could use fdt_add_subnode() to put each set of data in its
+        * own node - perhaps useful if we add access informaiton to each.
+        */
+       for (i = 0; i < NV_SEQ_COUNT; i++) {
+               char prop_name[20];
+
+               sprintf(prop_name, "nvdata%d", i);
+               fdt_setprop(blob, node, prop_name, state.nvdata[i],
+                           NV_DATA_SIZE);
+       }
+
+       return 0;
+}
+
+SANDBOX_STATE_IO(sandbox_tpm, "google,sandbox-tpm", sandbox_tpm_read_state,
+                sandbox_tpm_write_state);
+
+static int index_to_seq(uint32_t index)
+{
+       switch (index) {
+       case FIRMWARE_NV_INDEX:
+               return NV_SEQ_FIRMWARE;
+       case KERNEL_NV_INDEX:
+               return NV_SEQ_KERNEL;
+       case 0:
+               return NV_GLOBAL_LOCK;
+       }
+
+       printf("Invalid nv index %#x\n", index);
+       return -1;
+}
+
+int tis_sendrecv(const u8 *sendbuf, size_t send_size,
+                u8 *recvbuf, size_t *recv_len)
+{
+       struct tpm_state *tpm = &state;
+       uint32_t code, index, length, type;
+       uint8_t *data;
+       int seq;
+
+       code = get_unaligned_be32(sendbuf + sizeof(uint16_t) +
+                                 sizeof(uint32_t));
+       printf("tpm: %zd bytes, recv_len %zd, cmd = %x\n", send_size,
+              *recv_len, code);
+       print_buffer(0, sendbuf, 1, send_size, 0);
+       switch (code) {
+       case 0x65: /* get flags */
+               type = get_unaligned_be32(sendbuf + 14);
+               switch (type) {
+               case 4:
+                       index = get_unaligned_be32(sendbuf + 18);
+                       printf("Get flags index %#02x\n", index);
+                       *recv_len = 22;
+                       memset(recvbuf, '\0', *recv_len);
+                       put_unaligned_be32(22, recvbuf +
+                                          TPM_RESPONSE_HEADER_LENGTH);
+                       data = recvbuf + TPM_RESPONSE_HEADER_LENGTH +
+                                       sizeof(uint32_t);
+                       switch (index) {
+                       case FIRMWARE_NV_INDEX:
+                               break;
+                       case KERNEL_NV_INDEX:
+                               /* TPM_NV_PER_PPWRITE */
+                               put_unaligned_be32(1, data +
+                                       NV_DATA_PUBLIC_PERMISSIONS_OFFSET);
+                               break;
+                       }
+                       break;
+               case 0x11: /* TPM_CAP_NV_INDEX */
+                       index = get_unaligned_be32(sendbuf + 18);
+                       printf("Get cap nv index %#02x\n", index);
+                       put_unaligned_be32(22, recvbuf +
+                                          TPM_RESPONSE_HEADER_LENGTH);
+                       break;
+               default:
+                       printf("   ** Unknown 0x65 command type %#02x\n",
+                              type);
+                       return -1;
+               }
+               break;
+       case 0xcd: /* nvwrite */
+               index = get_unaligned_be32(sendbuf + 10);
+               length = get_unaligned_be32(sendbuf + 18);
+               seq = index_to_seq(index);
+               if (seq < 0)
+                       return -1;
+               printf("tpm: nvwrite index=%#02x, len=%#02x\n", index, length);
+               memcpy(&tpm->nvdata[seq], sendbuf + 22, length);
+               *recv_len = 12;
+               memset(recvbuf, '\0', *recv_len);
+               break;
+       case 0xcf: /* nvread */
+               index = get_unaligned_be32(sendbuf + 10);
+               length = get_unaligned_be32(sendbuf + 18);
+               seq = index_to_seq(index);
+               if (seq < 0)
+                       return -1;
+               printf("tpm: nvread index=%#02x, len=%#02x\n", index, length);
+               *recv_len = TPM_RESPONSE_HEADER_LENGTH + sizeof(uint32_t) +
+                                       length;
+               memset(recvbuf, '\0', *recv_len);
+               put_unaligned_be32(length, recvbuf +
+                                  TPM_RESPONSE_HEADER_LENGTH);
+               if (seq == NV_SEQ_KERNEL) {
+                       struct rollback_space_kernel rsk;
+
+                       data = recvbuf + TPM_RESPONSE_HEADER_LENGTH +
+                                       sizeof(uint32_t);
+                       rsk.struct_version = 2;
+                       rsk.uid = ROLLBACK_SPACE_KERNEL_UID;
+                       rsk.kernel_versions = 0;
+                       rsk.crc8 = crc8((unsigned char *)&rsk,
+                                       offsetof(struct rollback_space_kernel,
+                                                crc8));
+                       memcpy(data, &rsk, sizeof(rsk));
+               } else {
+                       memcpy(recvbuf + TPM_RESPONSE_HEADER_LENGTH +
+                              sizeof(uint32_t), &tpm->nvdata[seq], length);
+               }
+               break;
+       case 0x14: /* tpm extend */
+       case 0x15: /* pcr read */
+       case 0x5d: /* force clear */
+       case 0x6f: /* physical enable */
+       case 0x72: /* physical set deactivated */
+       case 0x99: /* startup */
+       case 0x4000000a:  /* assert physical presence */
+               *recv_len = 12;
+               memset(recvbuf, '\0', *recv_len);
+               break;
+       default:
+               printf("Unknown tpm command %02x\n", code);
+               return -1;
+       }
+
+       return 0;
+}
+
+int tis_open(void)
+{
+       printf("%s\n", __func__);
+       return 0;
+}
+
+int tis_close(void)
+{
+       printf("%s\n", __func__);
+       return 0;
+}
+
+int tis_init(void)
+{
+       printf("%s\n", __func__);
+       return 0;
+}
index f52d3f450039b38d3e2f4e183adbcf29a2f6cac2..f13b172a6677333087116f0d3beb47abba7d99d4 100644 (file)
@@ -5,12 +5,8 @@
 # SPDX-License-Identifier:     GPL-2.0+
 #
 
-# if defined(CONFIG_USB_GADGET) || defined(CONFIG_USB_ETHER)
-#   Everytime you forget how crufty makefiles can get things like
-#   this remind you...
-ifneq (,$(CONFIG_USB_GADGET)$(CONFIG_USB_ETHER))
-obj-y += epautoconf.o config.o usbstring.o
-endif
+obj-$(CONFIG_USB_GADGET) += epautoconf.o config.o usbstring.o
+obj-$(CONFIG_USB_ETHER) += epautoconf.o config.o usbstring.o
 
 # new USB gadget layer dependencies
 ifdef CONFIG_USB_GADGET
index 37d04a19285e605a6d4e34ae9b54b989eca28891..a045864d730686448c4740eccd56585a80291f54 100644 (file)
@@ -40,6 +40,7 @@ struct f_dfu {
 
        /* Send/received block number is handy for data integrity check */
        int                             blk_seq_num;
+       unsigned int                    poll_timeout;
 };
 
 typedef int (*dfu_state_fn) (struct f_dfu *,
@@ -128,6 +129,33 @@ static struct usb_gadget_strings *dfu_strings[] = {
        NULL,
 };
 
+static void dfu_set_poll_timeout(struct dfu_status *dstat, unsigned int ms)
+{
+       /*
+        * The bwPollTimeout DFU_GETSTATUS request payload provides information
+        * about minimum time, in milliseconds, that the host should wait before
+        * sending a subsequent DFU_GETSTATUS request
+        *
+        * This permits the device to vary the delay depending on its need to
+        * erase or program the memory
+        *
+        */
+
+       unsigned char *p = (unsigned char *)&ms;
+
+       if (!ms || (ms & ~DFU_POLL_TIMEOUT_MASK)) {
+               dstat->bwPollTimeout[0] = 0;
+               dstat->bwPollTimeout[1] = 0;
+               dstat->bwPollTimeout[2] = 0;
+
+               return;
+       }
+
+       dstat->bwPollTimeout[0] = *p++;
+       dstat->bwPollTimeout[1] = *p++;
+       dstat->bwPollTimeout[2] = *p;
+}
+
 /*-------------------------------------------------------------------------*/
 
 static void dnload_request_complete(struct usb_ep *ep, struct usb_request *req)
@@ -157,11 +185,15 @@ static void handle_getstatus(struct usb_request *req)
                break;
        }
 
+       dfu_set_poll_timeout(dstat, 0);
+
+       if (f_dfu->poll_timeout)
+               if (!(f_dfu->blk_seq_num %
+                     (dfu_get_buf_size() / DFU_USB_BUFSIZ)))
+                       dfu_set_poll_timeout(dstat, f_dfu->poll_timeout);
+
        /* send status response */
        dstat->bStatus = f_dfu->dfu_status;
-       dstat->bwPollTimeout[0] = 0;
-       dstat->bwPollTimeout[1] = 0;
-       dstat->bwPollTimeout[2] = 0;
        dstat->bState = f_dfu->dfu_state;
        dstat->iString = 0;
 }
@@ -723,8 +755,9 @@ static int dfu_bind_config(struct usb_configuration *c)
        f_dfu->usb_function.unbind = dfu_unbind;
        f_dfu->usb_function.set_alt = dfu_set_alt;
        f_dfu->usb_function.disable = dfu_disable;
-       f_dfu->usb_function.strings = dfu_generic_strings,
-       f_dfu->usb_function.setup = dfu_handle,
+       f_dfu->usb_function.strings = dfu_generic_strings;
+       f_dfu->usb_function.setup = dfu_handle;
+       f_dfu->poll_timeout = DFU_DEFAULT_POLL_TIMEOUT;
 
        status = usb_add_function(c, &f_dfu->usb_function);
        if (status)
index cc2c45567b6cb2e0830d1275b144a75186bd2dfa..0c29954add7d8c32f8cf4aea2ca0415c1e024b64 100644 (file)
@@ -82,4 +82,6 @@ struct dfu_function_descriptor {
        __le16                          wTransferSize;
        __le16                          bcdDFUVersion;
 } __packed;
+
+#define DFU_POLL_TIMEOUT_MASK           (0xFFFFFFUL)
 #endif /* __F_DFU_H_ */
index 8bd1eb8a99836f16f95113ac6d2e68b339cf5489..17187caed4827841615bf2f3a66b915bb291a131 100644 (file)
@@ -201,6 +201,9 @@ static int ehci_shutdown(struct ehci_ctrl *ctrl)
        int i, ret = 0;
        uint32_t cmd, reg;
 
+       if (!ctrl || !ctrl->hcor)
+               return -EINVAL;
+
        cmd = ehci_readl(&ctrl->hcor->or_usbcmd);
        cmd &= ~(CMD_PSE | CMD_ASE);
        ehci_writel(&ctrl->hcor->or_usbcmd, cmd);
@@ -945,7 +948,7 @@ int usb_lowlevel_init(int index, enum usb_init_type init, void **controller)
 #endif
        /* Set the high address word (aka segment) for 64-bit controller */
        if (ehci_readl(&ehcic[index].hccr->cr_hccparams) & 1)
-               ehci_writel(ehcic[index].hcor->or_ctrldssegment, 0);
+               ehci_writel(&ehcic[index].hcor->or_ctrldssegment, 0);
 
        qh_list = &ehcic[index].qh_list;
 
index 7a1ffe5e28bbc1fd6bf9dc806649e49a30d1ec2c..991b19998b7e407a214f698939284577d61cb4da 100644 (file)
@@ -54,9 +54,31 @@ static pci_dev_t ehci_find_class(int index)
                                        bdf += PCI_BDF(0, 0, 1)) {
                                pci_read_config_dword(bdf, PCI_CLASS_REVISION,
                                                      &class);
-                               if ((class >> 8 == PCI_CLASS_SERIAL_USB_EHCI)
-                                               && !index--)
-                                       return bdf;
+                               class >>= 8;
+                               /*
+                                * Here be dragons! In case we have multiple
+                                * PCI EHCI controllers, this function will
+                                * be called multiple times as well. This
+                                * function will scan the PCI busses, always
+                                * starting from bus 0, device 0, function 0,
+                                * until it finds an USB controller. The USB
+                                * stack gives us an 'index' of a controller
+                                * that is currently being registered, which
+                                * is a number, starting from 0 and growing
+                                * in ascending order as controllers are added.
+                                * To avoid probing the same controller in tne
+                                * subsequent runs of this function, we will
+                                * skip 'index - 1' detected controllers and
+                                * report the index'th controller.
+                                */
+                               if (class != PCI_CLASS_SERIAL_USB_EHCI)
+                                       continue;
+                               if (index) {
+                                       index--;
+                                       continue;
+                               }
+                               /* Return index'th controller. */
+                               return bdf;
                        }
                }
        }
index 22ac1429ba498fe10c3171f594593d722251a816..cefd2dc14a2ebbcd9b6c91228da3fb361b8fc05d 100644 (file)
@@ -889,7 +889,7 @@ int32_t ipu_init_sync_panel(int disp, uint32_t pixel_clk,
        debug("panel size = %d x %d\n", width, height);
 
        if ((v_sync_width == 0) || (h_sync_width == 0))
-               return EINVAL;
+               return -EINVAL;
 
        adapt_panel_to_ipu_restricitions(&pixel_clk, width, height,
                                         h_start_width, h_end_width,
index 140c8bc5e76cc418070999a72c216490fd427efa..6c7198f65ff565da9d305d318f1047551c5764cc 100644 (file)
@@ -10,7 +10,7 @@
 ifeq ($(DEVICE_TREE),)
 $(if $(CONFIG_DEFAULT_DEVICE_TREE),,\
 $(error Please define CONFIG_DEFAULT_DEVICE_TREE in your board header file))
-DEVICE_TREE = $(subst ",,$(CONFIG_DEFAULT_DEVICE_TREE))
+DEVICE_TREE = $(CONFIG_DEFAULT_DEVICE_TREE:"%"=%)
 endif
 
 DTS_INCDIRS =  $(SRCTREE)/board/$(VENDOR)/$(BOARD)/dts
index 4d9ce66402616f24db9d68646ad4ef0cab4ea1f4..6d3a6166d26898b2726d2ff04f6f2458188b8fd7 100644 (file)
@@ -1,6 +1,4 @@
-/82559_eeprom
 /atmel_df_pow2
-/eepro100_eeprom
 /hello_world
 /interrupt
 /mem_to_mem_idma2intr
diff --git a/examples/standalone/82559_eeprom.c b/examples/standalone/82559_eeprom.c
deleted file mode 100644 (file)
index c253055..0000000
+++ /dev/null
@@ -1,356 +0,0 @@
-/*
- * Copyright 1998-2001 by Donald Becker.
- * This software may be used and distributed according to the terms of
- * the GNU General Public License (GPL), incorporated herein by reference.
- * Contact the author for use under other terms.
- *
- * This program must be compiled with "-O"!
- * See the bottom of this file for the suggested compile-command.
- *
- * The author may be reached as becker@scyld.com, or C/O
- *  Scyld Computing Corporation
- *  410 Severn Ave., Suite 210
- *  Annapolis MD 21403
- *
- * Common-sense licensing statement: Using any portion of this program in
- * your own program means that you must give credit to the original author
- * and release the resulting code under the GPL.
- */
-
-#define _PPC_STRING_H_         /* avoid unnecessary str/mem functions */
-
-#include <common.h>
-#include <exports.h>
-#include <asm/io.h>
-
-
-/* Default EEPROM for i82559 */
-static unsigned short default_eeprom[64] = {
-       0x0100, 0x0302, 0x0504, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
-       0xffff, 0xffff, 0x40c0, 0x0000, 0x0000, 0xffff, 0xffff, 0xffff,
-       0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
-       0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
-       0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
-       0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
-       0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
-       0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff
-};
-
-static unsigned short eeprom[256];
-
-static int eeprom_size = 64;
-static int eeprom_addr_size = 6;
-
-static int debug = 0;
-
-static inline unsigned short swap16(unsigned short x)
-{
-       return (((x & 0xff) << 8) | ((x & 0xff00) >> 8));
-}
-
-
-void * memcpy(void * dest,const void *src,size_t count)
-{
-       char *tmp = (char *) dest, *s = (char *) src;
-
-       while (count--)
-               *tmp++ = *s++;
-
-       return dest;
-}
-
-
-/* The EEPROM commands include the alway-set leading bit. */
-#define EE_WRITE_CMD   (5)
-#define EE_READ_CMD            (6)
-#define EE_ERASE_CMD   (7)
-
-/* Serial EEPROM section. */
-#define EE_SHIFT_CLK   0x01    /* EEPROM shift clock. */
-#define EE_CS                  0x02    /* EEPROM chip select. */
-#define EE_DATA_WRITE  0x04    /* EEPROM chip data in. */
-#define EE_DATA_READ   0x08    /* EEPROM chip data out. */
-#define EE_ENB                 (0x4800 | EE_CS)
-#define EE_WRITE_0             0x4802
-#define EE_WRITE_1             0x4806
-#define EE_OFFSET              14
-
-/* Delay between EEPROM clock transitions. */
-#define eeprom_delay(ee_addr)  inw(ee_addr)
-
-/* Wait for the EEPROM to finish the previous operation. */
-static int eeprom_busy_poll(long ee_ioaddr)
-{
-       int i;
-       outw(EE_ENB, ee_ioaddr);
-       for (i = 0; i < 10000; i++)                     /* Typical 2000 ticks */
-               if (inw(ee_ioaddr) & EE_DATA_READ)
-                       break;
-       return i;
-}
-
-/* This executes a generic EEPROM command, typically a write or write enable.
-   It returns the data output from the EEPROM, and thus may also be used for
-   reads. */
-static int do_eeprom_cmd(long ioaddr, int cmd, int cmd_len)
-{
-       unsigned retval = 0;
-       long ee_addr = ioaddr + EE_OFFSET;
-
-       if (debug > 1)
-               printf(" EEPROM op 0x%x: ", cmd);
-
-       outw(EE_ENB | EE_SHIFT_CLK, ee_addr);
-
-       /* Shift the command bits out. */
-       do {
-               short dataval = (cmd & (1 << cmd_len)) ? EE_WRITE_1 : EE_WRITE_0;
-               outw(dataval, ee_addr);
-               eeprom_delay(ee_addr);
-               if (debug > 2)
-                       printf("%X", inw(ee_addr) & 15);
-               outw(dataval | EE_SHIFT_CLK, ee_addr);
-               eeprom_delay(ee_addr);
-               retval = (retval << 1) | ((inw(ee_addr) & EE_DATA_READ) ? 1 : 0);
-       } while (--cmd_len >= 0);
-#if 0
-       outw(EE_ENB, ee_addr);
-#endif
-       /* Terminate the EEPROM access. */
-       outw(EE_ENB & ~EE_CS, ee_addr);
-       if (debug > 1)
-               printf(" EEPROM result is 0x%5.5x.\n", retval);
-       return retval;
-}
-
-static int read_eeprom(long ioaddr, int location, int addr_len)
-{
-       return do_eeprom_cmd(ioaddr, ((EE_READ_CMD << addr_len) | location)
-               << 16 , 3 + addr_len + 16) & 0xffff;
-}
-
-static void write_eeprom(long ioaddr, int index, int value, int addr_len)
-{
-       long ee_ioaddr = ioaddr + EE_OFFSET;
-       int i;
-
-       /* Poll for previous op finished. */
-       eeprom_busy_poll(ee_ioaddr);                    /* Typical 0 ticks */
-       /* Enable programming modes. */
-       do_eeprom_cmd(ioaddr, (0x4f << (addr_len-4)), 3 + addr_len);
-       /* Do the actual write. */
-       do_eeprom_cmd(ioaddr,
-                                 (((EE_WRITE_CMD<<addr_len) | index)<<16) | (value & 0xffff),
-                                 3 + addr_len + 16);
-       /* Poll for write finished. */
-       i = eeprom_busy_poll(ee_ioaddr);                        /* Typical 2000 ticks */
-       if (debug)
-               printf(" Write finished after %d ticks.\n", i);
-       /* Disable programming. This command is not instantaneous, so we check
-          for busy before the next op. */
-       do_eeprom_cmd(ioaddr, (0x40 << (addr_len-4)), 3 + addr_len);
-       eeprom_busy_poll(ee_ioaddr);
-}
-
-static int reset_eeprom(unsigned long ioaddr, unsigned char *hwaddr)
-{
-       unsigned short checksum = 0;
-       int size_test;
-       int i;
-
-       printf("Resetting i82559 EEPROM @ 0x%08lx ... ", ioaddr);
-
-       size_test = do_eeprom_cmd(ioaddr, (EE_READ_CMD << 8) << 16, 27);
-       eeprom_addr_size = (size_test & 0xffe0000) == 0xffe0000 ? 8 : 6;
-       eeprom_size = 1 << eeprom_addr_size;
-
-       memcpy(eeprom, default_eeprom, sizeof default_eeprom);
-
-       for (i = 0; i < 3; i++)
-               eeprom[i] = (hwaddr[i*2+1]<<8) + hwaddr[i*2];
-
-       /* Recalculate the checksum. */
-       for (i = 0; i < eeprom_size - 1; i++)
-               checksum += eeprom[i];
-       eeprom[i] = 0xBABA - checksum;
-
-       for (i = 0; i < eeprom_size; i++)
-               write_eeprom(ioaddr, i, eeprom[i], eeprom_addr_size);
-
-       for (i = 0; i < eeprom_size; i++)
-               if (read_eeprom(ioaddr, i, eeprom_addr_size) != eeprom[i]) {
-                       printf("failed\n");
-                       return 1;
-               }
-
-       printf("done\n");
-       return 0;
-}
-
-static unsigned int hatoi(char *p, char **errp)
-{
-       unsigned int res = 0;
-
-       while (1) {
-               switch (*p) {
-               case 'a':
-               case 'b':
-               case 'c':
-               case 'd':
-               case 'e':
-               case 'f':
-                       res |= (*p - 'a' + 10);
-                       break;
-               case 'A':
-               case 'B':
-               case 'C':
-               case 'D':
-               case 'E':
-               case 'F':
-                       res |= (*p - 'A' + 10);
-                       break;
-               case '0':
-               case '1':
-               case '2':
-               case '3':
-               case '4':
-               case '5':
-               case '6':
-               case '7':
-               case '8':
-               case '9':
-                       res |= (*p - '0');
-                       break;
-               default:
-                       if (errp) {
-                               *errp = p;
-                       }
-               return res;
-               }
-               p++;
-               if (*p == 0) {
-                       break;
-               }
-               res <<= 4;
-       }
-
-       if (errp) {
-               *errp = NULL;
-       }
-
-       return res;
-}
-
-static unsigned char *gethwaddr(char *in, unsigned char *out)
-{
-       char tmp[3];
-       int i;
-       char *err;
-
-       for (i=0;i<6;i++) {
-               if (in[i*3+2] == 0 && i == 5) {
-                       out[i] = hatoi(&in[i*3], &err);
-                       if (err) {
-                               return NULL;
-                       }
-               } else if (in[i*3+2] == ':' && i < 5) {
-                       tmp[0] = in[i*3];
-                       tmp[1] = in[i*3+1];
-                       tmp[2] = 0;
-                       out[i] = hatoi(tmp, &err);
-                       if (err) {
-                               return NULL;
-                       }
-               } else {
-                       return NULL;
-               }
-       }
-
-       return out;
-}
-
-static u32
-read_config_dword(int bus, int dev, int func, int reg)
-{
-       u32 res;
-
-       outl(0x80000000|(bus&0xff)<<16|(dev&0x1f)<<11|(func&7)<<8|(reg&0xfc),
-            0xcf8);
-       res = inl(0xcfc);
-       outl(0, 0xcf8);
-       return res;
-}
-
-static u16
-read_config_word(int bus, int dev, int func, int reg)
-{
-       u32 res;
-
-       outl(0x80000000|(bus&0xff)<<16|(dev&0x1f)<<11|(func&7)<<8|(reg&0xfc),
-            0xcf8);
-       res = inw(0xcfc + (reg & 2));
-       outl(0, 0xcf8);
-       return res;
-}
-
-static void
-write_config_word(int bus, int dev, int func, int reg, u16 data)
-{
-
-       outl(0x80000000|(bus&0xff)<<16|(dev&0x1f)<<11|(func&7)<<8|(reg&0xfc),
-            0xcf8);
-       outw(data, 0xcfc + (reg & 2));
-       outl(0, 0xcf8);
-}
-
-
-int main (int argc, char * const argv[])
-{
-       unsigned char *eth_addr;
-       uchar buf[6];
-       int instance;
-
-       app_startup(argv);
-       if (argc != 2) {
-               printf ("call with base Ethernet address\n");
-               return 1;
-       }
-
-
-       eth_addr = gethwaddr(argv[1], buf);
-       if (NULL == eth_addr) {
-               printf ("Can not parse ethernet address\n");
-               return 1;
-       }
-       if (eth_addr[5] & 0x01) {
-               printf("Base Ethernet address must be even\n");
-       }
-
-
-       for (instance = 0; instance < 2; instance ++)  {
-               unsigned int io_addr;
-               unsigned char mac[6];
-               int bar1 = read_config_dword(0, 6+instance, 0, 0x14);
-               if (! (bar1 & 1)) {
-                       printf("ETH%d is disabled %x\n", instance, bar1);
-               } else {
-                       printf("ETH%d IO=0x%04x\n", instance, bar1 & ~3);
-               }
-               io_addr = (bar1 & (~3L));
-
-
-               write_config_word(0, 6+instance, 0, 4,
-                                 read_config_word(0, 6+instance, 0, 4) | 1);
-               printf("ETH%d CMD %04x\n", instance,
-                          read_config_word(0, 6+instance, 0, 4));
-
-               memcpy(mac, eth_addr, 6);
-               mac[5] += instance;
-
-               printf("got io=%04x, ha=%02x:%02x:%02x:%02x:%02x:%02x\n",
-                          io_addr, mac[0], mac[1], mac[2],
-                          mac[3], mac[4], mac[5]);
-               reset_eeprom(io_addr, mac);
-       }
-       return 0;
-}
index f4f102b3e1c47494cf4f9ddb51c130a069edc739..0841c758ff9660e33123ef00ab234bf85d32de65 100644 (file)
@@ -7,25 +7,22 @@
 
 include $(TOPDIR)/config.mk
 
-ELF-$(ARCH)  :=
-ELF-$(CPU)   :=
 ELF-y        := hello_world
 
 ELF-$(CONFIG_SMC91111)           += smc91111_eeprom
 ELF-$(CONFIG_SMC911X)            += smc911x_eeprom
 ELF-$(CONFIG_SPI_FLASH_ATMEL)    += atmel_df_pow2
-ELF-i386                         += 82559_eeprom
-ELF-mpc5xxx                      += interrupt
-ELF-mpc8xx                       += test_burst timer
-ELF-mpc8260                      += mem_to_mem_idma2intr
-ELF-ppc                          += sched
+ELF-$(CONFIG_MPC5xxx)            += interrupt
+ELF-$(CONFIG_8xx)                += test_burst timer
+ELF-$(CONFIG_8260)               += mem_to_mem_idma2intr
+ELF-$(CONFIG_PPC)                += sched
 
 #
 # Some versions of make do not handle trailing white spaces properly;
 # leading to build failures. The problem was found with GNU Make 3.80.
 # Using 'strip' as a workaround for the problem.
 #
-ELF := $(strip $(ELF-y) $(ELF-$(ARCH)) $(ELF-$(CPU)))
+ELF := $(strip $(ELF-y))
 
 SREC := $(addsuffix .srec,$(ELF))
 BIN  := $(addsuffix .bin,$(ELF))
@@ -34,11 +31,9 @@ COBJS        := $(ELF:=.o)
 
 LIB    = $(obj)libstubs.o
 
-LIBAOBJS-$(ARCH)     :=
-LIBAOBJS-$(CPU)      :=
-LIBAOBJS-ppc         += $(ARCH)_longjmp.o $(ARCH)_setjmp.o
-LIBAOBJS-mpc8xx      += test_burst_lib.o
-LIBAOBJS := $(LIBAOBJS-$(ARCH)) $(LIBAOBJS-$(CPU))
+LIBAOBJS-$(CONFIG_PPC) += ppc_longjmp.o ppc_setjmp.o
+LIBAOBJS-$(CONFIG_8xx) += test_burst_lib.o
+LIBAOBJS := $(LIBAOBJS-y)
 
 LIBCOBJS = stubs.o
 
index c856983ef444bfb3292a5aa2efafdd18b489e3e5..3fb5db383ec9206fba37f5f4039f635b30c1cce0 100644 (file)
 #include <common.h>
 #include <config.h>
 #include <malloc.h>
+#include <div64.h>
 #include <linux/stat.h>
 #include <linux/time.h>
 #include <watchdog.h>
@@ -1438,7 +1439,7 @@ jffs2_1pass_build_lists(struct part_info * part)
 {
        struct b_lists *pL;
        struct jffs2_unknown_node *node;
-       u32 nr_sectors = part->size/part->sector_size;
+       u32 nr_sectors;
        u32 i;
        u32 counter4 = 0;
        u32 counterF = 0;
@@ -1447,6 +1448,7 @@ jffs2_1pass_build_lists(struct part_info * part)
        u32 buf_size = DEFAULT_EMPTY_SCAN_SIZE;
        char *buf;
 
+       nr_sectors = lldiv(part->size, part->sector_size);
        /* turn off the lcd.  Refreshing the lcd adds 50% overhead to the */
        /* jffs2 list building enterprise nope.  in newer versions the overhead is */
        /* only about 5 %.  not enough to inconvenience people for. */
index e113e4039e1f78a66d7258142df8854f6519eb06..50000a135b54f229e4aa914939ab6c554bdab0c4 100644 (file)
@@ -20,6 +20,7 @@
  */
 
 #include <common.h>
+#include <div64.h>
 
 #include <config.h>
 #include "nand.h"
@@ -184,7 +185,7 @@ void cmd_yaffs_devconfig(char *_mp, int flash_dev,
        }
 
        if (end_block == 0)
-               end_block = mtd->size / mtd->erasesize - 1;
+               end_block = lldiv(mtd->size, mtd->erasesize - 1);
 
        if (end_block < start_block) {
                printf("Bad start/end\n");
index ac4a010bdf7c413b1a37f831fbedf25e7dd32b16..334598eedff9bf4e46d6d3a5b25371ea11461486 100644 (file)
@@ -11,6 +11,7 @@
  * published by the Free Software Foundation.
  */
 
+#include <div64.h>
 #include "yaffsfs.h"
 #include "yaffs_guts.h"
 #include "yaffscfg.h"
@@ -1603,8 +1604,8 @@ static int yaffsfs_DoStat(struct yaffs_obj *obj, struct yaffs_stat *buf)
                buf->st_rdev = obj->yst_rdev;
                buf->st_size = yaffs_get_obj_length(obj);
                buf->st_blksize = obj->my_dev->data_bytes_per_chunk;
-               buf->st_blocks = (buf->st_size + buf->st_blksize - 1) /
-                   buf->st_blksize;
+               buf->st_blocks = lldiv(buf->st_size + buf->st_blksize - 1,
+                   buf->st_blksize);
 #if CONFIG_YAFFS_WINCE
                buf->yst_wince_atime[0] = obj->win_atime[0];
                buf->yst_wince_atime[1] = obj->win_atime[1];
index 8ca67f64facf6d8c1a330a343366749ec34077b5..d49c51464dadb77a5296ef3705112229d75f24a0 100644 (file)
@@ -698,6 +698,10 @@ ulong get_ddr_freq(ulong);
 #if defined(CONFIG_MPC85xx)
 typedef MPC85xx_SYS_INFO sys_info_t;
 void   get_sys_info  ( sys_info_t * );
+#  if defined(CONFIG_OF_LIBFDT)
+       void ft_fixup_cpu(void *, u64);
+       void ft_fixup_num_cores(void *);
+#  endif
 #endif
 #if defined(CONFIG_MPC86xx)
 typedef MPC86xx_SYS_INFO sys_info_t;
index 567b46c87a5a6fc7bf8451255eb9383da1de3016..ad08c1d335d3ba29fd75dcab99f948a5c6a7e278 100644 (file)
@@ -14,6 +14,7 @@
 #define CONFIG_BOOTM_NETBSD 1
 #define CONFIG_BOOTM_PLAN9 1
 #define CONFIG_BOOTM_RTEMS 1
+#define CONFIG_BOOTM_VXWORKS 1
 
 #define CONFIG_GZIP 1
 #define CONFIG_ZLIB 1
index 3633b09aa9122bf64ad2621705420203223295fb..d8339b26cca91e53a703ca60be6805e117561d3a 100644 (file)
@@ -50,7 +50,8 @@
        defined(CONFIG_CMD_PART) || \
        defined(CONFIG_CMD_GPT) || \
        defined(CONFIG_MMC) || \
-       defined(CONFIG_SYSTEMACE)
+       defined(CONFIG_SYSTEMACE) || \
+       defined(CONFIG_SANDBOX)
 #define HAVE_BLOCK_DEVICE
 #endif
 
index b2a5c19e0ef291645c17d69ddcfef6ba04f78249..c182158be4ac04ba7c3a6079aea10aab21abb392 100644 (file)
@@ -289,6 +289,8 @@ unsigned long get_board_ddr_clk(void);
 
 /* NAND Flash on IFC */
 #define CONFIG_NAND_FSL_IFC
+#define CONFIG_SYS_NAND_MAX_ECCPOS     256
+#define CONFIG_SYS_NAND_MAX_OOBFREE    2
 #define CONFIG_SYS_NAND_BASE           0xff800000
 #ifdef CONFIG_PHYS_64BIT
 #define CONFIG_SYS_NAND_BASE_PHYS      (0xf00000000ull | CONFIG_SYS_NAND_BASE)
@@ -737,7 +739,6 @@ unsigned long get_board_ddr_clk(void);
 
 #ifdef CONFIG_CMD_KGDB
 #define CONFIG_KGDB_BAUDRATE   230400  /* speed to run kgdb serial port */
-#define CONFIG_KGDB_SER_INDEX  2       /* which serial port to use */
 #endif
 
 /*
index 499d8c2054c971287e3e9abd9590ff2a2ba711aa..584aba8d0e44bcc8ce5ba4016564cf7d50a7ac56 100644 (file)
@@ -29,7 +29,7 @@
 #define CONFIG_SPL_INIT_MINIMAL
 #define CONFIG_SPL_SERIAL_SUPPORT
 #define CONFIG_SPL_NAND_SUPPORT
-#define CONFIG_SPL_NAND_MINIMAL
+#define CONFIG_SPL_NAND_BOOT
 #define CONFIG_SPL_FLUSH_IMAGE
 #define CONFIG_SPL_TARGET              "u-boot-with-spl.bin"
 
@@ -382,7 +382,6 @@ extern unsigned long get_sdram_size(void);
 
 #if defined(CONFIG_CMD_KGDB)
 #define CONFIG_KGDB_BAUDRATE   230400  /* speed to run kgdb serial port */
-#define CONFIG_KGDB_SER_INDEX  2       /* which serial port to use */
 #endif
 
 #define CONFIG_USB_EHCI
index a6601fee86b19d2c6f18b1caab3cd027656c6c07..6170cbc81f9e3dd7d810abd36fb491dd3a711fce 100644 (file)
@@ -38,7 +38,7 @@
 #define CONFIG_SPL_INIT_MINIMAL
 #define CONFIG_SPL_SERIAL_SUPPORT
 #define CONFIG_SPL_NAND_SUPPORT
-#define CONFIG_SPL_NAND_MINIMAL
+#define CONFIG_SPL_NAND_BOOT
 #define CONFIG_SPL_FLUSH_IMAGE
 #define CONFIG_SPL_TARGET              "u-boot-with-spl.bin"
 
@@ -625,7 +625,6 @@ combinations. this should be removed later
 
 #if defined(CONFIG_CMD_KGDB)
 #define CONFIG_KGDB_BAUDRATE   230400  /* speed to run kgdb serial port */
-#define CONFIG_KGDB_SER_INDEX  2       /* which serial port to use */
 #endif
 
 /*
index 4a5fc864a653c6ad8f6aaea8f3cc503c81161e52..0bb22be9f3cf2b6dd9f670692afbe9bea1046c0c 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_NAND_MAX_OOBFREE    2
+#define CONFIG_SYS_NAND_MAX_ECCPOS     48
+
 /*
  * For booting Linux, the board info and command line data
  * have to be in the first 8 MB of memory, since this is
index 2d7fc59ea20268010e8a5f41786289cc4334a30f..71be1224f1424dfdef8a06122a0611a2c0543073 100644 (file)
@@ -406,7 +406,6 @@ int du440_phy_addr(int devnum);
 
 #if defined(CONFIG_CMD_KGDB)
 #define CONFIG_KGDB_BAUDRATE   230400  /* speed to run kgdb serial port */
-#define CONFIG_KGDB_SER_INDEX  2       /* which serial port to use */
 #endif
 
 #define CONFIG_SOURCE          1
index f366308f45d3c63d84f89288436030217fc779c4..208b599f6d058f7c72836ddc4dd8c7ba832890ff 100644 (file)
 
 #if defined(CONFIG_CMD_KGDB)
 #define CONFIG_KGDB_BAUDRATE   230400  /* speed to run kgdb serial port */
-#define CONFIG_KGDB_SER_INDEX  2       /* which serial port to use */
 #endif
 #endif /* __CONFIG_H */
index 4284d6a3a9b20bf8b22a63b2a1c55c30f4fc1541..5738ea97ad79bb588f15ae38fb6ed816a96cb95c 100644 (file)
 
 #if defined(CONFIG_CMD_KGDB)
 #define CONFIG_KGDB_BAUDRATE   230400  /* speed to run kgdb serial port */
-#define CONFIG_KGDB_SER_INDEX  2       /* which serial port to use */
 #endif
 #endif /* __CONFIG_H */
index 71e90d77d7d2cbfbdc8bcb8503d1de9b75429fc6..39eb2ef1336bd8600f4c3628ad0aa3d88097f132 100644 (file)
 
 #if defined(CONFIG_CMD_KGDB)
 #define CONFIG_KGDB_BAUDRATE  230400        /* kgdb serial port baud   */
-#define CONFIG_KGDB_SER_INDEX 2                     /* kgdb serial port        */
 #endif
 
 /*-----------------------------------------------------------------------
index 32ec0bf06504adf8c66b7416acf2eaa95db75ef7..67154353d331e83d00d661d8fa94dc6c5f050e3b 100644 (file)
 
 #if defined(CONFIG_CMD_KGDB)
 #define CONFIG_KGDB_BAUDRATE  230400        /* kgdb serial port baud   */
-#define CONFIG_KGDB_SER_INDEX 2                     /* kgdb serial port        */
 #endif
 
 /*-----------------------------------------------------------------------
index f248a56421cebd2d7dc9f99810b9c8b99e6f028d..6042a1e3c4136d81cb5982f9c1bec21f7c649c33 100644 (file)
  ************************************************************/
 #if defined(CONFIG_CMD_KGDB)
 #define CONFIG_KGDB_BAUDRATE   230400  /* speed to run kgdb serial port */
-#define CONFIG_KGDB_SER_INDEX  2       /* which serial port to use */
 #endif
 
 /************************************************************
index 0f9f436e33dedd3a239fe1d9863e07b60af63b72..aedb529f86133133541e0d6e2b73e00ffc677836 100644 (file)
 
 #if defined(CONFIG_CMD_KGDB)
 #define CONFIG_KGDB_BAUDRATE   230400  /* speed of kgdb serial port */
-#define CONFIG_KGDB_SER_INDEX  2       /* which serial port to use */
 #endif
 
 /*
index a1e5f3b2b2e7c559bdf6f54125c6099d87d170dc..c4c771b502eac0c285dc24eb7a2a92fa84b57fb8 100644 (file)
 
 #if (CONFIG_CMD_KGDB)
 #define CONFIG_KGDB_BAUDRATE   230400  /* speed of kgdb serial port */
-#define CONFIG_KGDB_SER_INDEX  2       /* which serial port to use */
 #endif
 
 /*
index 71fc497e78e5976affcce8d6140500f9937472b4..f5b62025d6ff27010579eb9f1c8e363ca45ae8a3 100644 (file)
 
 #if defined(CONFIG_CMD_KGDB)
 #define CONFIG_KGDB_BAUDRATE   230400  /* speed of kgdb serial port */
-#define CONFIG_KGDB_SER_INDEX  2       /* which serial port to use */
 #endif
 
 /*
index 037484104fcfaff6db17d360b70af1f85de3c698..7640d06ee77aa76f9815585db66ffef6cb27e3ef 100644 (file)
 
 #if defined(CONFIG_CMD_KGDB)
 #define CONFIG_KGDB_BAUDRATE   230400  /* speed of kgdb serial port */
-#define CONFIG_KGDB_SER_INDEX  2       /* which serial port to use */
 #endif
 
 /*
index e2ae596323c30ca243f246d33e332535416db98d..ffb9a158aec96f8a8580fde30f74bb4b6732cc07 100644 (file)
@@ -730,7 +730,6 @@ boards, we say we have two, but don't display a message if we find only one. */
 
 #if defined(CONFIG_CMD_KGDB)
 #define CONFIG_KGDB_BAUDRATE   230400  /* speed of kgdb serial port */
-#define CONFIG_KGDB_SER_INDEX  2       /* which serial port to use */
 #endif
 
 
index ed780f17ff2713d79131f3f1b97f7f753d67302f..d4c82cd669ed5bbe90608ab48e3c2e082ef481f4 100644 (file)
 
 #if defined(CONFIG_CMD_KGDB)
 #define CONFIG_KGDB_BAUDRATE   230400  /* speed of kgdb serial port */
-#define CONFIG_KGDB_SER_INDEX  2       /* which serial port to use */
 #endif
 
 /*
index d31be19735c93c33b7609d61ce409029d36c0796..01e7ac76817b086896baef979994c0523a5ee117 100644 (file)
 
 #if defined(CONFIG_CMD_KGDB)
 #define CONFIG_KGDB_BAUDRATE   230400  /* speed of kgdb serial port */
-#define CONFIG_KGDB_SER_INDEX  2       /* which serial port to use */
 #endif
 
 /*
index 98ffb9c29eeb169fe4c8111d9106289b60ec3e48..f52e77a3a7c71591f331811dea5363a8634464a3 100644 (file)
@@ -662,7 +662,6 @@ extern int board_pci_host_broken(void);
 
 #if defined(CONFIG_CMD_KGDB)
 #define CONFIG_KGDB_BAUDRATE   230400  /* speed of kgdb serial port */
-#define CONFIG_KGDB_SER_INDEX  2       /* which serial port to use */
 #endif
 
 /*
index ca28c0eb243ceba10ba558b72a9d847bfa89d537..938f7ab3c4f59654dfaafae37c12288e795716f3 100644 (file)
 
 #if defined(CONFIG_CMD_KGDB)
 #define CONFIG_KGDB_BAUDRATE   230400  /* speed of kgdb serial port */
-#define CONFIG_KGDB_SER_INDEX  2       /* which serial port to use */
 #endif
 
 /*
index 9ab1bc106b685ef745a420fb7375520f2ac29521..9b7cc6474cfd96406595e444fa2f9f522ec1283a 100644 (file)
 
 #if defined(CONFIG_CMD_KGDB)
 #define CONFIG_KGDB_BAUDRATE   230400  /* speed to run kgdb serial port */
-#define CONFIG_KGDB_SER_INDEX  2       /* which serial port to use */
 #endif
 
 /*
index 046b14bddac8f764e26e7fcb78143f77327bf15e..2d42b25121d2a36b0a661c459c7a28fa2475752f 100644 (file)
 
 #if defined(CONFIG_CMD_KGDB)
 #define CONFIG_KGDB_BAUDRATE   230400  /* speed to run kgdb serial port */
-#define CONFIG_KGDB_SER_INDEX  2       /* which serial port to use */
 #endif
 
 
index eca3b537b41da5a3866f49f257018eb2c6ff165b..b9ad0342256b5ed901f512cba7339ec501b4d0bd 100644 (file)
@@ -410,7 +410,6 @@ extern unsigned long get_clock_freq(void);
 
 #if defined(CONFIG_CMD_KGDB)
 #define CONFIG_KGDB_BAUDRATE   230400  /* speed to run kgdb serial port */
-#define CONFIG_KGDB_SER_INDEX  2       /* which serial port to use */
 #endif
 
 /*
index 8132ec055b90dfd4e05a2dc52da0090827cf764e..90fc2da34b806f4b5bd55821079a231b878ec189 100644 (file)
@@ -441,7 +441,6 @@ extern unsigned long get_board_sys_clk(unsigned long dummy);
 
 #if defined(CONFIG_CMD_KGDB)
 #define CONFIG_KGDB_BAUDRATE   230400  /* speed to run kgdb serial port */
-#define CONFIG_KGDB_SER_INDEX  2       /* which serial port to use */
 #endif
 
 /*
index 6acd54db8502686b207f80e385c00e16cfaeecba..5fff1e2cac83b43a3d5da253142fd7ca62f9e181 100644 (file)
@@ -535,7 +535,6 @@ extern unsigned long get_clock_freq(void);
 
 #if defined(CONFIG_CMD_KGDB)
 #define CONFIG_KGDB_BAUDRATE   230400  /* speed to run kgdb serial port */
-#define CONFIG_KGDB_SER_INDEX  2       /* which serial port to use */
 #endif
 
 /*
index 5ffdd01629bf146ef8936fd921f309685c778d36..23c6b07c3593f45096d9c291ba426a0cb54309cd 100644 (file)
@@ -408,7 +408,6 @@ extern unsigned long get_clock_freq(void);
 
 #if defined(CONFIG_CMD_KGDB)
 #define CONFIG_KGDB_BAUDRATE   230400  /* speed to run kgdb serial port */
-#define CONFIG_KGDB_SER_INDEX  2       /* which serial port to use */
 #endif
 
 /*
index bb9ae2dcb53438ba9c6d76b1f9353bcc674d6678..44b767919e2011664f15f449b5c491a1379627d3 100644 (file)
 
 #if defined(CONFIG_CMD_KGDB)
 #define CONFIG_KGDB_BAUDRATE   230400  /* speed to run kgdb serial port */
-#define CONFIG_KGDB_SER_INDEX  2       /* which serial port to use */
 #endif
 
 
index 7406ac3be823da99fffd33e98968a501f0099a2d..4f438a807562eeb674e0c49af5c590052809d988 100644 (file)
@@ -430,7 +430,6 @@ extern unsigned long get_clock_freq(void);
 
 #if defined(CONFIG_CMD_KGDB)
 #define CONFIG_KGDB_BAUDRATE   230400  /* speed to run kgdb serial port */
-#define CONFIG_KGDB_SER_INDEX  2       /* which serial port to use */
 #endif
 
 /*
index df5572b3a811db4501c1077fc38f9cefb19ed715..d877e8bbd1812d8a94774fccf3fa06228e9e9122 100644 (file)
@@ -566,7 +566,6 @@ extern unsigned long get_clock_freq(void);
 
 #if defined(CONFIG_CMD_KGDB)
 #define CONFIG_KGDB_BAUDRATE   230400  /* speed to run kgdb serial port */
-#define CONFIG_KGDB_SER_INDEX  2       /* which serial port to use */
 #endif
 
 /*
index 63480ecb0defb670208151faf369d9a63a89c98b..44d83a236e846b5bc499035400fa7fa3b9338e17 100644 (file)
 
 #if defined(CONFIG_CMD_KGDB)
 #define CONFIG_KGDB_BAUDRATE   230400  /* speed to run kgdb serial port */
-#define CONFIG_KGDB_SER_INDEX  2       /* which serial port to use */
 #endif
 
 /*
index 41ebe31dd4a6fc13e7afc1ea9f27d4166d0ba233..f930fcde34fac0a112412eca884a6430e8ca44fd 100644 (file)
 
 #if defined(CONFIG_CMD_KGDB)
 #define CONFIG_KGDB_BAUDRATE   230400  /* speed to run kgdb serial port */
-#define CONFIG_KGDB_SER_INDEX  2       /* which serial port to use */
 #endif
 
 /*
index 0e666bac01865338d6df32a9fe35760b23858102..65d61c28d1f0af5c54e4b0b5e76c79affaaceb3b 100644 (file)
@@ -670,7 +670,6 @@ extern unsigned long get_board_sys_clk(unsigned long dummy);
 
 #if defined(CONFIG_CMD_KGDB)
     #define CONFIG_KGDB_BAUDRATE       230400  /* speed to run kgdb serial port */
-    #define CONFIG_KGDB_SER_INDEX      2       /* which serial port to use */
 #endif
 
 /*
index 9fd45514266a407116fddc5f24bed9a7e3ede660..88df94f11231dd4aaf27c564d4cc616763f348f4 100644 (file)
@@ -10,8 +10,6 @@
 #define __MIGO_R_H
 
 #undef DEBUG
-#define CONFIG_SH              1
-#define CONFIG_SH4             1
 #define CONFIG_CPU_SH7722      1
 #define CONFIG_MIGO_R          1
 
index 1ed5e1df21f3dff8e3809657643919440dd98de0..ea5cb6501b6f4ec32d01228980f8b544bc1b32cd 100644 (file)
@@ -37,7 +37,7 @@
 #define CONFIG_SPL_INIT_MINIMAL
 #define CONFIG_SPL_SERIAL_SUPPORT
 #define CONFIG_SPL_NAND_SUPPORT
-#define CONFIG_SPL_NAND_MINIMAL
+#define CONFIG_SPL_NAND_BOOT
 #define CONFIG_SPL_FLUSH_IMAGE
 #define CONFIG_SPL_TARGET              "u-boot-with-spl.bin"
 
@@ -739,7 +739,6 @@ extern unsigned long get_sdram_size(void);
 
 #if defined(CONFIG_CMD_KGDB)
 #define CONFIG_KGDB_BAUDRATE   230400  /* speed to run kgdb serial port */
-#define CONFIG_KGDB_SER_INDEX  2       /* which serial port to use */
 #endif
 
 /*
index 262c3e5f1fa624617af09dbd7b02e65044f1f60b..934a6cb7a6a00f10d49e386c24e52ffb892dc8e1 100644 (file)
@@ -75,6 +75,8 @@
 #endif
 
 #define CONFIG_NAND_FSL_ELBC
+#define CONFIG_SYS_NAND_MAX_ECCPOS     56
+#define CONFIG_SYS_NAND_MAX_OOBFREE    5
 
 #ifdef CONFIG_NAND
 #define CONFIG_SPL
 
 #ifdef CONFIG_CMD_KGDB
 #define CONFIG_KGDB_BAUDRATE   230400  /* speed to run kgdb serial port */
-#define CONFIG_KGDB_SER_INDEX  2       /* which serial port to use */
 #endif
 
 /*
index 2aa1f59ea7a38148b08f3f0e90597eb661646ab0..11c74ff5f5720bd000689056975e5cb2ee3119da 100644 (file)
@@ -469,7 +469,6 @@ extern unsigned long get_clock_freq(void);
 
 #if defined(CONFIG_CMD_KGDB)
 #define CONFIG_KGDB_BAUDRATE   230400  /* speed to run kgdb serial port */
-#define CONFIG_KGDB_SER_INDEX  2       /* which serial port to use */
 #endif
 
 /*
index b592c1966aac3aac1b8695dfa18cdd9f37873517..85cb0767efd2852928c699ce0470ded320ff708b 100644 (file)
@@ -606,7 +606,6 @@ extern unsigned long get_board_sys_clk(unsigned long dummy);
 
 #if defined(CONFIG_CMD_KGDB)
 #define CONFIG_KGDB_BAUDRATE   230400  /* speed to run kgdb serial port */
-#define CONFIG_KGDB_SER_INDEX  2       /* which serial port to use */
 #endif
 
 /*
index 15d2a43cd0d729dda8cc5d5bd4099032db361d25..ce3c762559b9c77d13172cbbbedaf435e84688e4 100644 (file)
@@ -432,7 +432,6 @@ extern unsigned long get_board_sys_clk(unsigned long dummy);
 
 #if defined(CONFIG_CMD_KGDB)
 #define CONFIG_KGDB_BAUDRATE   230400  /* speed to run kgdb serial port */
-#define CONFIG_KGDB_SER_INDEX  2       /* which serial port to use */
 #endif
 
 /*
index 9d3d9b33e553a0a6955e36d0ab235c4fa3f190fd..ada6c7b871768edea487cb64e632c39c69a6fdfb 100644 (file)
 
 #if defined(CONFIG_CMD_KGDB)
 #define CONFIG_KGDB_BAUDRATE   230400  /* speed to run kgdb serial port */
-#define CONFIG_KGDB_SER_INDEX  2       /* which serial port to use */
 #endif
 
 /*
index b238574b5d2de99e14f1ae547e4045d4bec58a4e..ee71252b00a7bed7c2852fa658ccab9ae1f21f65 100644 (file)
@@ -677,7 +677,6 @@ unsigned long get_board_sys_clk(unsigned long dummy);
 
 #ifdef CONFIG_CMD_KGDB
 #define CONFIG_KGDB_BAUDRATE   230400  /* speed to run kgdb serial port */
-#define CONFIG_KGDB_SER_INDEX  2       /* which serial port to use */
 #endif
 
 /*
index 118072486275f872678d5d0a63efdb773594858c..29888b4e1c272d917a2ca704dd34dc6b1dfe1b38 100644 (file)
  ************************************************************/
 #if defined(CONFIG_CMD_KGDB)
 #define CONFIG_KGDB_BAUDRATE   230400  /* speed to run kgdb serial port */
-#define CONFIG_KGDB_SER_INDEX  2       /* which serial port to use */
 #endif
 
 /************************************************************
index 5ab9315b1d091a12f263cd705a2230b30bbd3d37..efe69601f38d433c0d8958bd92e29699e4db647d 100644 (file)
 
 #if defined(CONFIG_CMD_KGDB)
 #define CONFIG_KGDB_BAUDRATE   230400  /* speed to run kgdb serial port */
-#define CONFIG_KGDB_SER_INDEX  2       /* which serial port to use */
 #endif
 
 /* pass open firmware flat tree */
index 43a57780043f07231cf5acefefc9284bb0097eec..7d0bc043f99b4f77912d886150e33000732c60a5 100644 (file)
@@ -233,6 +233,7 @@ unsigned long get_board_ddr_clk(void);
 #define QIXIS_RCFG_CTL_RECONFIG_IDLE   0x20
 #define QIXIS_RCFG_CTL_RECONFIG_START  0x21
 #define QIXIS_RCFG_CTL_WATCHDOG_ENBLE  0x08
+#define        QIXIS_RST_FORCE_MEM             0x01
 
 #define CONFIG_SYS_CSPR3_EXT   (0xf)
 #define CONFIG_SYS_CSPR3       (CSPR_PHYS_ADDR(QIXIS_BASE_PHYS) \
@@ -248,7 +249,7 @@ unsigned long get_board_ddr_clk(void);
 #define CONFIG_SYS_CS3_FTIM1           (FTIM1_GPCM_TACO(0xff) | \
                                        FTIM1_GPCM_TRAD(0x3f))
 #define CONFIG_SYS_CS3_FTIM2           (FTIM2_GPCM_TCS(0x0e) | \
-                                       FTIM2_GPCM_TCH(0x0) | \
+                                       FTIM2_GPCM_TCH(0x8) | \
                                        FTIM2_GPCM_TWP(0x1f))
 #define CONFIG_SYS_CS3_FTIM3           0x0
 
@@ -682,7 +683,6 @@ unsigned long get_board_ddr_clk(void);
 
 #ifdef CONFIG_CMD_KGDB
 #define CONFIG_KGDB_BAUDRATE   230400  /* speed to run kgdb serial port */
-#define CONFIG_KGDB_SER_INDEX  2       /* which serial port to use */
 #endif
 
 /*
index 79312311d8b5a8ebbb02f2140d938bd025f43443..d721139a1f6d59abed13b44f24974ff5e3e2d1c2 100644 (file)
 
 #ifdef CONFIG_CMD_KGDB
 #define CONFIG_KGDB_BAUDRATE   230400  /* speed to run kgdb serial port */
-#define CONFIG_KGDB_SER_INDEX  2       /* which serial port to use */
 #endif
 
 /*
index eff08e3804f986058ef5f37dc60d4d2d082e6bf6..2c02d9da58fdd377732451cebcdfa4e6ce353347 100644 (file)
 
 #ifdef CONFIG_CMD_KGDB
 #define CONFIG_KGDB_BAUDRATE   230400  /* speed to run kgdb serial port */
-#define CONFIG_KGDB_SER_INDEX  2       /* which serial port to use */
 #endif
 
 /*
index fc254256a0eda5f4ef0491a08491434441641b44..15cf2bd793eb6620d3f673f110c128abedf2b51e 100644 (file)
 
 #if defined(CONFIG_CMD_KGDB)
 #define CONFIG_KGDB_BAUDRATE   230400  /* speed of kgdb serial port */
-#define CONFIG_KGDB_SER_INDEX  2       /* which serial port to use */
 #endif
 
 /*
index 57b620d4810743d81da20194898977ea7111c6a0..d40185e1e2c67433a39f1ef06a5c8997b884cd28 100644 (file)
 #if defined(CONFIG_CMD_KGDB)
 /* speed to run kgdb serial port */
 #define CONFIG_KGDB_BAUDRATE           115200
-/* what's this ? it's not used anywhere */
-#define CONFIG_KGDB_SER_INDEX          2       /* which serial port to use */
 #endif
 
 /* Miscellaneous configurable options */
index 8fda1b1ea5ce477e38012f21b434b53d4c896264..00a24ab8460bf42df1073d3532a1600c4d833a46 100644 (file)
 
 #if defined(CONFIG_CMD_KGDB)
 #define CONFIG_KGDB_BAUDRATE   230400          /* speed to run kgdb serial port */
-#define CONFIG_KGDB_SER_INDEX  2               /* which serial port to use     */
 #endif
 
 /*
index 6836fc7b5f83b7ee485226baefc988b86a3c26aa..8ed2fa2d87ae0802b7f2374e0400020db2641694 100644 (file)
 
 #if defined(CONFIG_CMD_KGDB)
 #define CONFIG_KGDB_BAUDRATE   230400          /* speed to run kgdb serial port */
-#define CONFIG_KGDB_SER_INDEX  2               /* which serial port to use     */
 #endif
 
 /*
index 1205557d8887a47863c843e716ce7bac022f2a69..d6cef888c6f00618276762ecc0a065163457a36d 100644 (file)
 
 #ifdef CONFIG_CMD_KGDB
 #define CONFIG_KGDB_BAUDRATE           230400  /* speed of kgdb serial port */
-#define CONFIG_KGDB_SER_INDEX          2       /* which serial port to use */
 #endif
 
 /*
index 3315f54f3883b103bd376307c18c1e8c61700166..9b8bd78943f407ea4e6326e42aba275a90601127 100644 (file)
@@ -58,8 +58,6 @@
 
 #if defined(CONFIG_CMD_KGDB)
 # define CONFIG_KGDB_BAUDRATE          230400
-/* which serial port to use */
-# define CONFIG_KGDB_SER_INDEX         1
 #endif
 
 /* Miscellaneous configurable options */
index fb391ecd59fb4b41fab13da3f702306618efe4be..f0cbff79cae0101ec175153a9f51577b49b9804e 100644 (file)
@@ -51,8 +51,6 @@
 
 #if defined(CONFIG_CMD_KGDB)
 # define CONFIG_KGDB_BAUDRATE          230400
-/* which serial port to use */
-# define CONFIG_KGDB_SER_INDEX         1
 #endif
 
 /* Miscellaneous configurable options */
index 61d96f5ed075939f5a2e18d13df72b90c1ea117c..763910745ce522686c61d89c69c95ccd7507619d 100644 (file)
@@ -49,8 +49,6 @@
 
 #if defined(CONFIG_CMD_KGDB)
 # define CONFIG_KGDB_BAUDRATE          230400
-/* which serial port to use */
-# define CONFIG_KGDB_SER_INDEX         1
 #endif
 
 /* Miscellaneous configurable options */
index 23872794e3c78183e9ea0e1466dcc5a56d096b31..12bd98a7e187f1e7b369c7dcf50d37dd8fdb0b55 100644 (file)
@@ -56,8 +56,6 @@
 
 #if defined(CONFIG_CMD_KGDB)
 # define CONFIG_KGDB_BAUDRATE          230400
-/* which serial port to use */
-# define CONFIG_KGDB_SER_INDEX         1
 #endif
 
 /* Miscellaneous configurable options */
index 61fdebac3f6c672e9618c9292a119f80b6d61b3c..08bba36095435b13e8592828f68b9ccb29ec2a9f 100644 (file)
 
 #if defined(CONFIG_CMD_KGDB)
 #define CONFIG_KGDB_BAUDRATE   230400  /* speed to run kgdb serial port */
-#define CONFIG_KGDB_SER_INDEX  2       /* which serial port to use */
 #endif
 
 /* pass open firmware flat tree */
index c9e9a038d4ffc5d1961e5527a983f849b1506e37..0f38c92fa0668c7c1769e9c1cd6faaf3d7c89a4d 100644 (file)
  */
 #if defined(CONFIG_CMD_KGDB)
 #define CONFIG_KGDB_BAUDRATE   230400  /* speed to run kgdb serial port*/
-#define CONFIG_KGDB_SER_INDEX  2       /* which serial port to use     */
 #endif
 
 /*
index 933de52c568a07c21ee0d245abe83f815ce38ebf..462b2e29106fbc7094e98ad76821b8f6b7130bf4 100644 (file)
@@ -11,8 +11,6 @@
 #define __AP325RXA_H
 
 #undef DEBUG
-#define CONFIG_SH              1
-#define CONFIG_SH4             1
 #define CONFIG_CPU_SH7723      1
 #define CONFIG_AP325RXA        1
 
index 83a5c37e43f8fd8544f7df8fc952c95ad4b03d42..bb39491f8b6d329d8b017af7ed2dd6d0bc3c9eed 100644 (file)
@@ -10,9 +10,6 @@
 #define __AP_SH4A_4A_H
 
 #undef DEBUG
-#define CONFIG_SH              1
-#define CONFIG_SH4             1
-#define CONFIG_SH4A            1
 #define CONFIG_CPU_SH7734      1
 #define CONFIG_AP_SH4A_4A      1
 #define CONFIG_400MHZ_MODE     1
index 32216cd50e4bc28dac442e6dcb9290b66e4fca2e..b8d955abd0b278d1d3bc208adbc9f6b5bc74066a 100644 (file)
 
 #ifdef CONFIG_CMD_KGDB
 #define CONFIG_KGDB_BAUDRATE           230400  /* speed of kgdb serial port */
-#define CONFIG_KGDB_SER_INDEX          2       /* which serial port to use */
 #endif
 
 /*
index b7fb29ea720022d029cc90fa592803702f41eb9b..7e367f39b27297ad984381b98cc20535c54f216f 100644 (file)
@@ -85,6 +85,7 @@
 #define CONFIG_DWMMC
 #define CONFIG_EXYNOS_DWMMC
 #define CONFIG_SUPPORT_EMMC_BOOT
+#define CONFIG_BOUNCE_BUFFER
 
 
 #define CONFIG_BOARD_EARLY_INIT_F
index d3d62744fa04a827492890f3a5252137d41cc27d..b41a823600d74348a5260bb3d255467ad0ea1e22 100644 (file)
@@ -61,7 +61,6 @@
  */
 #ifdef CONFIG_CMD_KGDB
 #define        CONFIG_KGDB_BAUDRATE            230400  /* kgdb serial port speed */
-#define        CONFIG_KGDB_SER_INDEX           2       /* which serial port to use */
 #endif
 
 /*
index 5ad3ee70d445a22b497ed254e70dd7d29f80f476..eed2d5bcef72779b17496e7c4c61514d00b49644 100644 (file)
@@ -56,6 +56,7 @@
 /*
  * Flash Settings
  */
+
 #define CONFIG_FLASH_CFI_DRIVER
 #define CONFIG_SYS_FLASH_BASE          0x20000000
 #define CONFIG_SYS_FLASH_CFI
@@ -63,7 +64,9 @@
 #define CONFIG_SYS_MAX_FLASH_SECT      71
 #define CONFIG_CMD_FLASH
 #define CONFIG_MONITOR_IS_IN_RAM
-
+/*
+#define CONFIG_SYS_NO_FLASH
+*/
 
 /*
  * SPI Settings
 #define CONFIG_BFIN_SPI
 #define CONFIG_ENV_SPI_MAX_HZ  30000000
 #define CONFIG_SF_DEFAULT_SPEED        30000000
+/*
 #define CONFIG_SPI_FLASH
 #define CONFIG_SPI_FLASH_STMICRO
 #define CONFIG_CMD_SF
 #define CONFIG_CMD_SPI
-
+*/
 
 /*
  * Env Storage Settings
index ee585c0ffdeabe5a66cbaccc1bf37188e580622b..15ca1af23058e37394228bdaa356451a37f2804e 100644 (file)
@@ -53,7 +53,7 @@
 #define CONFIG_EBIU_AMBCTL0_VAL                0xffc2ffc2
 #define CONFIG_EBIU_AMBCTL1_VAL                0x99b35554
 
-#define CONFIG_SYS_MONITOR_LEN         (256 * 1024)
+#define CONFIG_SYS_MONITOR_LEN         (384 * 1024)
 #define CONFIG_SYS_MALLOC_LEN          (128 * 1024)
 
 
index 404039ac230479804992c4ec51ef28d7492a05c8..fb6f94873af222f5e4d25a4790bf647ff0c42e0a 100644 (file)
@@ -90,6 +90,7 @@
  */
 #define CONFIG_SYS_I2C_SOFT
 #ifdef CONFIG_SYS_I2C_SOFT
+#define CONFIG_SYS_I2C
 #define CONFIG_SOFT_I2C_GPIO_SCL GPIO_PF0
 #define CONFIG_SOFT_I2C_GPIO_SDA GPIO_PF1
 #define I2C_DELAY              udelay(5)       /* 1/4 I2C clock duration */
index cd37f9adb9beb0af9caca69927f656951fb6d0ff..6e5774c6ba5fc29abcf309a0771c7ea8940d11b5 100644 (file)
 #define CONFIG_BAUDRATE                57600
 #define CONFIG_LOADS_ECHO      1
 #define CONFIG_UART_CONSOLE    0
+#define CONFIG_BFIN_SERIAL
 
 /*
  * U-Boot environment variables. Use "printenv" to examine.
index 8f10eba4677cefa5d8888a2dda1da19b6f5d7011..2838012e2052fa968001f65381eea61e8d3cbf64 100644 (file)
@@ -55,7 +55,7 @@
 #define CONFIG_EBIU_AMBCTL0_VAL        (B1WAT_7 | B1RAT_11 | B1HT_2 | B1ST_3 | B0WAT_7 | B0RAT_11 | B0HT_2 | B0ST_3)
 #define CONFIG_EBIU_AMBCTL1_VAL        (B3WAT_7 | B3RAT_11 | B3HT_2 | B3ST_3 | B2WAT_7 | B2RAT_11 | B2HT_2 | B2ST_3)
 
-#define CONFIG_SYS_MONITOR_LEN (512 * 1024)
+#define CONFIG_SYS_MONITOR_LEN (768 * 1024)
 #define CONFIG_SYS_MALLOC_LEN  (128 * 1024)
 
 
 #define FLASHBOOT_ENV_SETTINGS \
        "flashboot=flread 20040000 1000000 3c0000;" \
        "bootm 0x1000000\0"
-
+#define CONFIG_BOARD_SIZE_LIMIT $$((384 * 1024))
 
 /*
  * Pull in common ADI header for remaining command/environment setup
index a1c8e8a8560cb823e708d82916181049159e0510..da4cc6718d84197aee168905eebba23142ba5dc0 100644 (file)
@@ -54,7 +54,7 @@
 #define CONFIG_EBIU_AMBCTL0_VAL        (B1WAT_7 | B1RAT_11 | B1HT_2 | B1ST_3 | B0WAT_7 | B0RAT_11 | B0HT_2 | B0ST_3)
 #define CONFIG_EBIU_AMBCTL1_VAL        (B3WAT_7 | B3RAT_11 | B3HT_2 | B3ST_3 | B2WAT_7 | B2RAT_11 | B2HT_2 | B2ST_3)
 
-#define CONFIG_SYS_MONITOR_LEN (512 * 1024)
+#define CONFIG_SYS_MONITOR_LEN (768 * 1024)
 #define CONFIG_SYS_MALLOC_LEN  (128 * 1024)
 
 
 #define FLASHBOOT_ENV_SETTINGS \
        "flashboot=flread 20040000 1000000 300000;" \
        "bootm 0x1000000\0"
+#define CONFIG_BOARD_SIZE_LIMIT $$((384 * 1024))
 
 
 /*
index 556b42a38b40be1c4b7eccf09f95a64885174914..d1d732f211f18704fd96ea106e2df88cb2f52d6e 100644 (file)
 
 #if defined(CONFIG_CMD_KGDB)
 #define CONFIG_KGDB_BAUDRATE                   115200
-#define CONFIG_KGDB_SER_INDEX                  2
 #endif
 
 /*
index 665295c1a2fe75e4458959eca392c602c3c910a1..969b9903fbce88a8f7495e9e46cfb8d11ea5e9a5 100644 (file)
 
 #ifdef CONFIG_CMD_KGDB
 #define CONFIG_KGDB_BAUDRATE   230400  /* speed to run kgdb serial port */
-#define CONFIG_KGDB_SER_INDEX  2       /* which serial port to use */
 #endif
 
 /*
index ca0bffa72e5e9d9313cf553eeb864d383558e2bc..8a848bea8bec8c01099537df9d4f29e1594b976d 100644 (file)
@@ -99,7 +99,6 @@
  */
 #if defined(CONFIG_CMD_KGDB)
 #define CONFIG_KGDB_BAUDRATE   230400  /* speed to run kgdb serial port */
-#define CONFIG_KGDB_SER_INDEX  2       /* which serial port to use */
 #endif
 
 /*
index 596095d21f8265a2d4de4b555556c3d7a6a3e92c..5c034175ce8ee428f0db963a09df96c5a6bce556 100644 (file)
@@ -98,7 +98,6 @@
  */
 #if defined(CONFIG_CMD_KGDB)
 #define CONFIG_KGDB_BAUDRATE   230400  /* speed to run kgdb serial port */
-#define CONFIG_KGDB_SER_INDEX  2       /* which serial port to use */
 #endif
 
 /*
index 48b47cbd0b59099281b498ca48b0c550b5fe64b7..f210ed8b92429bd8be1b40d21c8155d0c3b5ba3c 100644 (file)
@@ -60,6 +60,7 @@
 #define CONFIG_SPI_FLASH_SPANSION
 #define CONFIG_CMD_SF
 #define CONFIG_CMD_SPI
+#define CONFIG_SPI_FLASH_BAR
 #define CONFIG_TI_SPI_MMAP
 #define CONFIG_SF_DEFAULT_SPEED                48000000
 #define CONFIG_DEFAULT_SPI_MODE                SPI_MODE_3
index 87b3314841755ae3a112091688c6ff1143158da6..1af7f169893247a7e6dfe4e899e65ada0bae2813 100644 (file)
@@ -57,8 +57,6 @@
 
 #if defined(CONFIG_CMD_KGDB)
 # define CONFIG_KGDB_BAUDRATE          230400
-/* which serial port to use */
-# define CONFIG_KGDB_SER_INDEX         1
 #endif
 
 /* Miscellaneous configurable options */
index 3483cf1f58bc7aa50d33e1839be35fcefcaca7fb..3a5cc74829cc37db26ba6babb10bcd96457eed21 100644 (file)
@@ -23,9 +23,6 @@
  */
 
 #undef DEBUG
-#define CONFIG_SH              1
-#define CONFIG_SH4             1
-#define CONFIG_SH4A            1
 #define CONFIG_CPU_SH7724      1
 #define CONFIG_BOARD_LATE_INIT         1
 #define CONFIG_ECOVEC          1
index 1bd7eeceb9ac2025c50e9d92699334f8e07e9631..de16be70b2cbea68b6dd8534a16506d00a66c2ee 100644 (file)
@@ -10,8 +10,6 @@
 #ifndef __ESPT_H
 #define __ESPT_H
 
-#define CONFIG_SH              1
-#define CONFIG_SH4             1
 #define CONFIG_CPU_SH7763      1
 #define CONFIG_ESPT    1
 #define __LITTLE_ENDIAN                1
index d684790f8e501be8d388cd59aef52bb68a504308..414db420dc30684ebc8d42614198a951fe195a52 100644 (file)
@@ -98,6 +98,7 @@
 #define CONFIG_DWMMC
 #define CONFIG_EXYNOS_DWMMC
 #define CONFIG_SUPPORT_EMMC_BOOT
+#define CONFIG_BOUNCE_BUFFER
 
 #define CONFIG_BOARD_EARLY_INIT_F
 #define CONFIG_SKIP_LOWLEVEL_INIT
index 7700b38c2de4639eebb19bd5150265be0521ec61..50330ccf6e692db63b7e9c783404c26c35771749 100644 (file)
@@ -385,7 +385,6 @@ unsigned long get_board_sys_clk(unsigned long dummy);
 
 #ifdef CONFIG_CMD_KGDB
 #define CONFIG_KGDB_BAUDRATE   230400  /* speed to run kgdb serial port */
-#define CONFIG_KGDB_SER_INDEX  2       /* which serial port to use */
 #endif
 
 #define __USB_PHY_TYPE utmi
index b09af199c8c14e377a36caad411baa4f32137c59..811ff995e260be6017c70b787d8aa572ca36611d 100644 (file)
 
 #if defined(CONFIG_CMD_KGDB)
 #define CONFIG_KGDB_BAUDRATE   230400 /* speed to run kgdb serial port */
-#define CONFIG_KGDB_SER_INDEX  2       /* which serial port to use     */
 #endif
 
 /* Pass open firmware flat tree */
diff --git a/include/configs/linkstation.h b/include/configs/linkstation.h
deleted file mode 100644 (file)
index fcd809d..0000000
+++ /dev/null
@@ -1,504 +0,0 @@
-/*
- * Copyright (C) 2006 Mihai Georgian <u-boot@linuxnotincluded.org.uk>
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#ifndef __CONFIG_H
-#define __CONFIG_H
-
-/*
- * Valid values for CONFIG_SYS_TEXT_BASE are:
- *
- * Standard configuration - all models
- * 0xFFF00000  boot from flash
- *
- * Test configuration (boot from RAM using uloader.o)
- * LinkStation HD-HLAN and KuroBox Standard
- * 0x03F00000  boot from RAM
- * LinkStation HD-HGLAN and KuroBox HG
- * 0x07F00000  boot from RAM
- */
-#ifndef CONFIG_SYS_TEXT_BASE
-#define CONFIG_SYS_TEXT_BASE   0xFFF00000
-#endif
-
-#if 0
-#define DEBUG
-#endif
-
-#define CONFIG_BOARD_EARLY_INIT_F 1    /* Call board_early_init_f      */
-
-/*-----------------------------------------------------------------------
- * User configurable settings:
- *   Mandatory settings:
- *     CONFIG_IPADDR_LS                - the IP address of the LinkStation
- *     CONFIG_SERVERIP_LS      - the address of the server for NFS/TFTP/DHCP/BOOTP
- *   Optional settins:
- *     CONFIG_NCIP_LS          - the adress of the computer running net console
- *                                                       if not configured, it will be set to
- *                                                       CONFIG_SERVERIP_LS
- */
-
-
-#define CONFIG_IPADDR_LS       192.168.11.150
-#define CONFIG_SERVERIP_LS     192.168.11.149
-
-#if !defined(CONFIG_IPADDR_LS) || !defined(CONFIG_SERVERIP_LS)
-#error Both CONFIG_IPADDR_LS and CONFIG_SERVERIP_LS must be defined
-#endif
-
-#if !defined(CONFIG_NCIP_LS)
-#define CONFIG_NCIP_LS         CONFIG_SERVERIP_LS
-#endif
-
-/*----------------------------------------------------------------------
- * DO NOT CHANGE ANYTHING BELOW, UNLESS YOU KNOW WHAT YOU ARE DOING
- *---------------------------------------------------------------------*/
-
-#define CONFIG_MPC8245         1
-#define CONFIG_LINKSTATION     1
-
-/*---------------------------------------
- * Supported models
- *
- * LinkStation HDLAN /KuroBox Standard (CONFIG_HLAN)
- * LinkStation old model               (CONFIG_LAN) - totally untested
- * LinkStation HGLAN / KuroBox HG      (CONFIG_HGLAN)
- *
- * Models not supported yet
- * TeraStatin                          (CONFIG_HTGL)
- */
-
-#if defined(CONFIG_HLAN) || defined(CONFIG_LAN)
-#define CONFIG_IDENT_STRING            " LinkStation / KuroBox"
-#elif defined(CONFIG_HGLAN)
-#define CONFIG_IDENT_STRING            " LinkStation HG / KuroBox HG"
-#elif defined(CONFIG_HTGL)
-#define CONFIG_IDENT_STRING            " TeraStation"
-#else
-#error No LinkStation model defined
-#endif
-
-#define CONFIG_BOOTDELAY       5
-#define CONFIG_ZERO_BOOTDELAY_CHECK
-#undef CONFIG_BOOT_RETRY_TIME
-
-#define CONFIG_AUTOBOOT_KEYED
-#define CONFIG_AUTOBOOT_PROMPT         \
-       "Boot in %02d seconds ('s' to stop)...", bootdelay
-#define CONFIG_AUTOBOOT_STOP_STR       "s"
-
-#define CONFIG_CMD_IDE
-#define CONFIG_CMD_PCI
-#define CONFIG_CMD_DHCP
-#define CONFIG_CMD_PING
-#define CONFIG_CMD_EXT2
-
-#define CONFIG_BOOTP_SUBNETMASK
-#define CONFIG_BOOTP_GATEWAY
-#define CONFIG_BOOTP_HOSTNAME
-#define CONFIG_BOOTP_NISDOMAIN
-#define CONFIG_BOOTP_BOOTPATH
-#define CONFIG_BOOTP_BOOTFILESIZE
-#define CONFIG_BOOTP_DNS
-#define CONFIG_BOOTP_DNS2
-#define CONFIG_BOOTP_SEND_HOSTNAME
-#define CONFIG_BOOTP_NTPSERVER
-#define CONFIG_BOOTP_TIMEOFFSET
-
-#define CONFIG_OF_LIBFDT       1
-
-#define OF_STDOUT_PATH         "/soc10x/serial@80004600"
-
-/* this must be included AFTER the definition of CONFIG_COMMANDS (if any) */
-#include <config_cmd_default.h>
-
-/*
- * Miscellaneous configurable options
- */
-#define CONFIG_SYS_LONGHELP                            /* undef to save memory         */
-#define CONFIG_SYS_CBSIZE              256             /* Console I/O Buffer Size      */
-
-#define CONFIG_SYS_PBSIZE              (CONFIG_SYS_CBSIZE + sizeof(CONFIG_SYS_PROMPT) + 16)
-#define CONFIG_SYS_MAXARGS             16              /* Max number of command args   */
-#define CONFIG_SYS_BARGSIZE            CONFIG_SYS_CBSIZE       /* Boot Argument Buffer Size    */
-#define CONFIG_SYS_LOAD_ADDR           0x00800000      /* Default load address: 8 MB   */
-
-#define CONFIG_BOOTCOMMAND     "run bootcmd1"
-#define CONFIG_BOOTARGS                "root=/dev/sda1 console=ttyS1,57600 netconsole=@192.168.1.7/eth0,@192.168.1.1/00:50:BF:A4:59:71 rtc-rs5c372.probe=0,0x32 debug"
-#define CONFIG_NFSBOOTCOMMAND  "bootp;run nfsargs;bootm"
-
-#define CONFIG_SYS_CONSOLE_IS_IN_ENV
-
-#if defined(CONFIG_HLAN) || defined(CONFIG_LAN)
-#define UBFILE                 "share/u-boot/u-boot-hd.flash.bin"
-#elif defined(CONFIG_HGLAN)
-#define UBFILE                 "share/u-boot/u-boot-hg.flash.bin"
-#elif defined(CONFIG_HTGL)
-#define UBFILE                 "share/u-boot/u-boot-ht.flash.bin"
-#else
-#error No LinkStation model defined
-#endif
-
-#define CONFIG_EXTRA_ENV_SETTINGS                                              \
-       "autoload=no\0"                                                         \
-       "stdin=nc\0"                                                            \
-       "stdout=nc\0"                                                           \
-       "stderr=nc\0"                                                           \
-       "ipaddr="__stringify(CONFIG_IPADDR_LS)"\0"                      \
-       "netmask=255.255.255.0\0"                                               \
-       "serverip="__stringify(CONFIG_SERVERIP_LS)"\0"                  \
-       "ncip="__stringify(CONFIG_NCIP_LS)"\0"                          \
-       "netretry=no\0"                                                         \
-       "nc=setenv stdin nc;setenv stdout nc;setenv stderr nc\0"                \
-       "ser=setenv stdin serial;setenv stdout serial;setenv stderr serial\0"   \
-       "ldaddr=800000\0"                                                       \
-       "hdpart=0:1\0"                                                          \
-       "hdfile=boot/uImage\0"                                                  \
-       "hdload=echo Loading ${hdpart}:${hdfile};ext2load ide ${hdpart} ${ldaddr} ${hdfile};ext2load ide ${hdpart} 7f0000 boot/kuroboxHG.dtb\0" \
-       "boothd=setenv bootargs " CONFIG_BOOTARGS ";bootm ${ldaddr} - 7f0000\0" \
-       "hdboot=run hdload;run boothd\0"                                        \
-       "flboot=setenv bootargs root=/dev/hda1;bootm ffc00000\0"                \
-       "emboot=setenv bootargs root=/dev/ram0;bootm ffc00000\0"                \
-       "nfsargs=setenv bootargs root=/dev/nfs rw nfsroot=${serverip}:${rootpath} "     \
-       "ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:${hostname}::off\0"   \
-       "bootretry=30\0"                                                        \
-       "bootcmd1=run hdboot;run flboot\0"                                      \
-       "bootcmd2=run flboot\0"                                                 \
-       "bootcmd3=run emboot\0"                                                 \
-       "writeng=protect off fff70000 fff7ffff;era fff70000 fff7ffff;mw.l 800000 4e474e47 1;cp.b 800000 fff70000 4\0" \
-       "writeok=protect off fff70000 fff7ffff;era fff70000 fff7ffff;mw.l 800000 4f4b4f4b 1;cp.b 800000 fff70000 4\0" \
-       "ubpart=0:3\0"                                                          \
-       "ubfile="UBFILE"\0"                                                     \
-       "ubload=echo Loading ${ubpart}:${ubfile};ext2load ide ${ubpart} ${ldaddr} ${ubfile}\0" \
-       "ubsaddr=fff00000\0"                                                    \
-       "ubeaddr=fff2ffff\0"                                                    \
-       "ubflash=protect off ${ubsaddr} ${ubeaddr};era ${ubsaddr} ${ubeaddr};cp.b ${ldaddr} ${ubsaddr} ${filesize};cmp.b ${ldaddr} ${ubsaddr} ${filesize}\0" \
-       "upgrade=run ubload ubflash\0"
-
-/*-----------------------------------------------------------------------
- * PCI stuff
- */
-#define CONFIG_PCI
-#define CONFIG_PCI_INDIRECT_BRIDGE
-/* Verified: CONFIG_PCI_PNP doesn't work */
-#undef CONFIG_PCI_PNP
-#define CONFIG_PCI_SCAN_SHOW
-
-#ifndef CONFIG_PCI_PNP
-/* Keep the following defines in sync with the BAT mappings */
-
-#define PCI_ETH_IOADDR      0xbfff00
-#define PCI_ETH_MEMADDR     0xbffffc00
-#define PCI_IDE_IOADDR      0xbffed0
-#define PCI_IDE_MEMADDR     0xbffffb00
-#define PCI_USB0_IOADDR     0
-#define PCI_USB0_MEMADDR    0xbfffe000
-#define PCI_USB1_IOADDR     0
-#define PCI_USB1_MEMADDR    0xbfffd000
-#define PCI_USB2_IOADDR     0
-#define PCI_USB2_MEMADDR    0xbfffcf00
-
-#endif
-
-/*-----------------------------------------------------------------------
- * Ethernet stuff
- */
-
-#if defined(CONFIG_LAN) || defined(CONFIG_HLAN)
-#define CONFIG_TULIP
-#define CONFIG_TULIP_USE_IO
-#elif defined(CONFIG_HGLAN) || defined(CONFIG_HTGL)
-#define CONFIG_RTL8169
-#endif
-
-#define CONFIG_NET_RETRY_COUNT         5
-
-#define CONFIG_NETCONSOLE
-
-/*-----------------------------------------------------------------------
- * Start addresses for the final memory configuration
- * (Set up by the startup code)
- * Please note that CONFIG_SYS_SDRAM_BASE _must_ start at 0
- */
-#define CONFIG_SYS_SDRAM_BASE          0x00000000
-
-#define CONFIG_SYS_FLASH_BASE          0xFFC00000
-#define CONFIG_SYS_FLASH_SIZE          0x00400000
-#define CONFIG_SYS_MONITOR_BASE        CONFIG_SYS_TEXT_BASE
-
-#define CONFIG_SYS_RESET_ADDRESS       0xFFF00100
-#define CONFIG_SYS_EUMB_ADDR           0x80000000
-#define CONFIG_SYS_PCI_MEM_ADDR        0xB0000000
-#define CONFIG_SYS_MISC_REGION_ADDR    0xFE000000
-
-#define CONFIG_SYS_MONITOR_LEN         0x00040000      /* 256 kB                       */
-#define CONFIG_SYS_MALLOC_LEN          (512 << 10)     /* Reserve some kB for malloc() */
-
-#define CONFIG_SYS_MEMTEST_START       0x00100000      /* memtest works on             */
-#define CONFIG_SYS_MEMTEST_END         0x00800000      /* 1M ... 8M in DRAM            */
-
-/* Maximum amount of RAM */
-#if defined(CONFIG_HLAN) || defined(CONFIG_LAN)
-#define CONFIG_SYS_MAX_RAM_SIZE        0x04000000      /* 64MB of SDRAM  */
-#elif defined(CONFIG_HGLAN) || defined(CONFIG_HTGL)
-#define CONFIG_SYS_MAX_RAM_SIZE        0x08000000      /* 128MB of SDRAM */
-#else
-#error Unknown LinkStation type
-#endif
-
-/*-----------------------------------------------------------------------
- * Change CONFIG_SYS_TEXT_BASE in bord/linkstation/config.mk to get a RAM build
- *
- * RAM based builds are for testing purposes. A Linux module, uloader.o,
- * exists to load U-Boot and pass control to it
- *
- * Always do "make clean" after changing the build type
- */
-#if CONFIG_SYS_MONITOR_BASE < CONFIG_SYS_FLASH_BASE
-#define CONFIG_SYS_RAMBOOT
-#endif
-
-/*-----------------------------------------------------------------------
- * Definitions for initial stack pointer and data area
- */
-#if 1 /* RAM is available when the first C function is called */
-#define CONFIG_SYS_INIT_RAM_ADDR       (CONFIG_SYS_SDRAM_BASE + CONFIG_SYS_MAX_RAM_SIZE - 0x1000)
-#else
-#define CONFIG_SYS_INIT_RAM_ADDR       0x40000000
-#endif
-#define CONFIG_SYS_INIT_RAM_SIZE       0x1000
-#define CONFIG_SYS_GBL_DATA_OFFSET     (CONFIG_SYS_INIT_RAM_SIZE - GENERATED_GBL_DATA_SIZE)
-
-/*----------------------------------------------------------------------
- * Serial configuration
- */
-#define CONFIG_CONS_INDEX      1
-#define CONFIG_BAUDRATE                57600
-
-#define CONFIG_SYS_NS16550
-#define CONFIG_SYS_NS16550_SERIAL
-
-#define CONFIG_SYS_NS16550_REG_SIZE    1
-
-#define CONFIG_SYS_NS16550_CLK         get_bus_freq(0)
-
-#define CONFIG_SYS_NS16550_COM1        (CONFIG_SYS_EUMB_ADDR + 0x4600) /* Console port */
-#define CONFIG_SYS_NS16550_COM2        (CONFIG_SYS_EUMB_ADDR + 0x4500) /* AVR port     */
-
-/*
- * Low Level Configuration Settings
- * (address mappings, register initial values, etc.)
- * You should know what you are doing if you make changes here.
- * For the detail description refer to the MPC8245 user's manual.
- *
- * Unless indicated otherwise, the values are
- * taken from the orignal Linkstation boot code
- *
- * Most of the low level configuration setttings are normally used
- * in arch/powerpc/cpu/mpc824x/cpu_init.c which is NOT used by this implementation.
- * Low level initialisation is done in board/linkstation/early_init.S
- * The values below are included for reference purpose only
- */
-
-/* FIXME: 32.768 MHz is the crystal frequency but */
-/* the real frequency is lower by about 0.75%     */
-#define CONFIG_SYS_CLK_FREQ    32768000
-
-/* Bit-field values for MCCR1.  */
-#define CONFIG_SYS_ROMNAL      0
-#define CONFIG_SYS_ROMFAL      11
-
-#define CONFIG_SYS_BANK0_ROW   2       /* Only bank 0 used: 13 x n x 4 */
-#define CONFIG_SYS_BANK1_ROW   0
-#define CONFIG_SYS_BANK2_ROW   0
-#define CONFIG_SYS_BANK3_ROW   0
-#define CONFIG_SYS_BANK4_ROW   0
-#define CONFIG_SYS_BANK5_ROW   0
-#define CONFIG_SYS_BANK6_ROW   0
-#define CONFIG_SYS_BANK7_ROW   0
-
-/* Bit-field values for MCCR2.  */
-#define CONFIG_SYS_TSWAIT      0
-#if defined(CONFIG_LAN) || defined(CONFIG_HLAN)
-#define CONFIG_SYS_REFINT      0x15e0
-#elif defined(CONFIG_HGLAN) || defined(CONFIG_HTGL)
-#define CONFIG_SYS_REFINT      0x1580
-#endif
-
-/* Burst To Precharge. Bits of this value go to MCCR3 and MCCR4. */
-#define CONFIG_SYS_BSTOPRE     0x91c
-
-/* Bit-field values for MCCR3.  */
-#define CONFIG_SYS_REFREC      7
-
-/* Bit-field values for MCCR4.  */
-#define CONFIG_SYS_PRETOACT            2
-#define CONFIG_SYS_ACTTOPRE            2       /* Original value was 2 */
-#define CONFIG_SYS_ACTORW              2
-#if defined(CONFIG_LAN) || defined(CONFIG_HLAN)
-#define CONFIG_SYS_SDMODE_CAS_LAT      2       /* For 100MHz bus       */
-/*#define CONFIG_SYS_SDMODE_BURSTLEN   3*/
-#elif defined(CONFIG_HGLAN) || defined(CONFIG_HTGL)
-#define CONFIG_SYS_SDMODE_CAS_LAT      3       /* For 133MHz bus       */
-/*#define CONFIG_SYS_SDMODE_BURSTLEN   2*/
-#endif
-#define CONFIG_SYS_REGISTERD_TYPE_BUFFER 1
-#define CONFIG_SYS_EXTROM              1       /* Original setting but there is no EXTROM */
-#define CONFIG_SYS_REGDIMM             0
-#define CONFIG_SYS_DBUS_SIZE2          1
-#define CONFIG_SYS_SDMODE_WRAP         0
-
-#define CONFIG_SYS_PGMAX               0x32    /* All boards use this setting. Original 0x92 */
-#define CONFIG_SYS_SDRAM_DSCD          0x30
-
-/* Memory bank settings.
- * Only bits 20-29 are actually used from these vales to set the
- * start/end addresses. The upper two bits will always be 0, and the lower
- * 20 bits will be 0x00000 for a start address, or 0xfffff for an end
- * address. Refer to the MPC8240 book.
- */
-
-#define CONFIG_SYS_BANK0_START     0x00000000
-#define CONFIG_SYS_BANK0_END       (CONFIG_SYS_MAX_RAM_SIZE - 1)
-#define CONFIG_SYS_BANK0_ENABLE    1
-#define CONFIG_SYS_BANK1_START     0x3ff00000
-#define CONFIG_SYS_BANK1_END       0x3fffffff
-#define CONFIG_SYS_BANK1_ENABLE    0
-#define CONFIG_SYS_BANK2_START     0x3ff00000
-#define CONFIG_SYS_BANK2_END       0x3fffffff
-#define CONFIG_SYS_BANK2_ENABLE    0
-#define CONFIG_SYS_BANK3_START     0x3ff00000
-#define CONFIG_SYS_BANK3_END       0x3fffffff
-#define CONFIG_SYS_BANK3_ENABLE    0
-#define CONFIG_SYS_BANK4_START     0x3ff00000
-#define CONFIG_SYS_BANK4_END       0x3fffffff
-#define CONFIG_SYS_BANK4_ENABLE    0
-#define CONFIG_SYS_BANK5_START     0x3ff00000
-#define CONFIG_SYS_BANK5_END       0x3fffffff
-#define CONFIG_SYS_BANK5_ENABLE    0
-#define CONFIG_SYS_BANK6_START     0x3ff00000
-#define CONFIG_SYS_BANK6_END       0x3fffffff
-#define CONFIG_SYS_BANK6_ENABLE    0
-#define CONFIG_SYS_BANK7_START     0x3ff00000
-#define CONFIG_SYS_BANK7_END       0x3fffffff
-#define CONFIG_SYS_BANK7_ENABLE    0
-
-#define CONFIG_SYS_ODCR            0x15
-
-/*----------------------------------------------------------------------
- * Initial BAT mappings
- */
-
-/* NOTES:
- * 1) GUARDED and WRITETHROUGH not allowed in IBATS
- * 2) CACHEINHIBIT and WRITETHROUGH not allowed together in same BAT
- */
-
-/* SDRAM */
-#define CONFIG_SYS_IBAT0L      (CONFIG_SYS_SDRAM_BASE | BATL_PP_10 | BATL_MEMCOHERENCE)
-#define CONFIG_SYS_IBAT0U      (CONFIG_SYS_SDRAM_BASE | BATU_BL_128M | BATU_VS | BATU_VP)
-
-#define CONFIG_SYS_DBAT0L      CONFIG_SYS_IBAT0L
-#define CONFIG_SYS_DBAT0U      CONFIG_SYS_IBAT0U
-
-/* EUMB: 1MB of address space */
-#define CONFIG_SYS_IBAT1L      (CONFIG_SYS_EUMB_ADDR | BATL_PP_10 | BATL_CACHEINHIBIT)
-#define CONFIG_SYS_IBAT1U      (CONFIG_SYS_EUMB_ADDR | BATU_BL_1M | BATU_VS | BATU_VP)
-
-#define CONFIG_SYS_DBAT1L      (CONFIG_SYS_IBAT1L | BATL_GUARDEDSTORAGE)
-#define CONFIG_SYS_DBAT1U      CONFIG_SYS_IBAT1U
-
-/* PCI Mem: 256MB of address space */
-#define CONFIG_SYS_IBAT2L      (CONFIG_SYS_PCI_MEM_ADDR | BATL_PP_10 | BATL_CACHEINHIBIT)
-#define CONFIG_SYS_IBAT2U      (CONFIG_SYS_PCI_MEM_ADDR | BATU_BL_256M | BATU_VS | BATU_VP)
-
-#define CONFIG_SYS_DBAT2L      (CONFIG_SYS_IBAT2L | BATL_GUARDEDSTORAGE)
-#define CONFIG_SYS_DBAT2U      CONFIG_SYS_IBAT2U
-
-/* PCI and local ROM/Flash: last 32MB of address space */
-#define CONFIG_SYS_IBAT3L      (CONFIG_SYS_MISC_REGION_ADDR | BATL_PP_10 | BATL_CACHEINHIBIT)
-#define CONFIG_SYS_IBAT3U      (CONFIG_SYS_MISC_REGION_ADDR | BATU_BL_32M | BATU_VS | BATU_VP)
-
-#define CONFIG_SYS_DBAT3L      (CONFIG_SYS_IBAT3L | BATL_GUARDEDSTORAGE)
-#define CONFIG_SYS_DBAT3U      CONFIG_SYS_IBAT3U
-
-/*
- * For booting Linux, the board info and command line data
- * have to be in the first 8 MB of memory, since this is
- * the maximum mapped by the Linux kernel during initialization.
- *
- * FIXME: This doesn't appear to be true for the newer kernels
- * which map more that 8 MB
- */
-#define CONFIG_SYS_BOOTMAPSZ   (8 << 20)       /* Initial Memory map for Linux */
-
-/*-----------------------------------------------------------------------
- * FLASH organization
- */
-#define CONFIG_SYS_FLASH_CFI                   /* The flash is CFI compatible  */
-#define CONFIG_FLASH_CFI_DRIVER                /* Use common CFI driver        */
-
-#undef  CONFIG_SYS_FLASH_PROTECTION
-#define CONFIG_SYS_FLASH_BANKS_LIST    { CONFIG_SYS_FLASH_BASE }
-#define CONFIG_SYS_MAX_FLASH_BANKS     1       /* Max number of flash banks            */
-#define CONFIG_SYS_MAX_FLASH_SECT      72      /* Max number of sectors per flash      */
-
-#define CONFIG_SYS_FLASH_ERASE_TOUT    12000
-#define CONFIG_SYS_FLASH_WRITE_TOUT    1000
-
-#define CONFIG_SYS_FLASH_USE_BUFFER_WRITE 1    /* use buffered writes (20x faster)     */
-
-#define CONFIG_SYS_FLASH_EMPTY_INFO            /* print 'E' for empty sector on flinfo */
-#define CONFIG_SYS_FLASH_QUIET_TEST    1       /* don't warn upon unknown flash        */
-
-#define CONFIG_ENV_IS_IN_FLASH
-/*
- * The original LinkStation flash organisation uses
- * 448 kB (0xFFF00000 - 0xFFF6FFFF) for the boot loader
- * We use the last sector of this area to store the environment
- * which leaves max. 384 kB for the U-Boot itself
- */
-#define CONFIG_ENV_ADDR                0xFFF60000
-#define CONFIG_ENV_SIZE                0x00010000
-#define CONFIG_ENV_SECT_SIZE   0x00010000
-
-/*-----------------------------------------------------------------------
- * Cache Configuration
- */
-#define CONFIG_SYS_CACHELINE_SIZE      32
-#ifdef CONFIG_CMD_KGDB
-#define CONFIG_SYS_CACHELINE_SHIFT     5       /* log base 2 of the above value        */
-#endif
-
-/*-----------------------------------------------------------------------
- * IDE/ATA definitions
- */
-#undef  CONFIG_IDE_LED                         /* No IDE LED                   */
-#define CONFIG_IDE_RESET                       /* no reset for ide supported   */
-#define CONFIG_IDE_PREINIT                     /* check for units              */
-#define CONFIG_LBA48                           /* 48 bit LBA supported         */
-
-#if defined(CONFIG_LAN) || defined(CONFIG_HLAN) || defined(CONFIG_HGLAN)
-#define CONFIG_SYS_IDE_MAXBUS          1               /* Scan only 1 IDE bus          */
-#define CONFIG_SYS_IDE_MAXDEVICE       1               /* Only 1 drive per IDE bus     */
-#elif defined(CONFIG_HGTL)
-#define CONFIG_SYS_IDE_MAXBUS          2               /* Max. 2 IDE busses            */
-#define CONFIG_SYS_IDE_MAXDEVICE       2               /* max. 2 drives per IDE bus    */
-#else
-#error Config IDE: Unknown LinkStation type
-#endif
-
-#define CONFIG_SYS_ATA_BASE_ADDR       0
-
-#define CONFIG_SYS_ATA_DATA_OFFSET     0               /* Offset for data I/O          */
-#define CONFIG_SYS_ATA_REG_OFFSET      0               /* Offset for normal registers  */
-#define CONFIG_SYS_ATA_ALT_OFFSET      0               /* Offset for alternate registers */
-
-/*-----------------------------------------------------------------------
- * Partitions and file system
- */
-#define CONFIG_DOS_PARTITION
-
-#endif /* __CONFIG_H */
index 8e58fea3b378980637f7ea37324cfcc31db9550b..a26937265a55a44ab81f2c2305704c4550858280 100644 (file)
@@ -93,7 +93,6 @@
  */
 #ifdef CONFIG_CMD_KGDB
 #define        CONFIG_KGDB_BAUDRATE            230400  /* kgdb serial port speed */
-#define        CONFIG_KGDB_SER_INDEX           2       /* which serial port to use */
 #endif
 
 /*
index b87df5479d6223360424ff807f2483b56424ea14..4ffe165dec5f11edfee799f54f4054d7ee51f138 100644 (file)
@@ -86,7 +86,6 @@
 
 #if defined(CONFIG_CMD_KGDB)
 #define CONFIG_KGDB_BAUDRATE   230400          /* speed to run kgdb serial port */
-#define CONFIG_KGDB_SER_INDEX  2               /* which serial port to use */
 #endif
 
 /*
index c348329cb1e4e83d02ddc808220c756e59a66f71..e9c8d8fd554a468c1f9f4925dbed1db09a6f156a 100644 (file)
 
 #if defined(CONFIG_CMD_KGDB)
 #define CONFIG_KGDB_BAUDRATE   230400  /* speed to run kgdb serial port */
-#define CONFIG_KGDB_SER_INDEX  2           /* which serial port to use */
 #endif
 
 /*
index 6501ea40e10486f056ea6180ad5c00a29afaefc2..d415ecdb5a2502ca16eb726ab02054b75c4a93a5 100644 (file)
 
 #ifdef CONFIG_CMD_KGDB
 #define CONFIG_KGDB_BAUDRATE   230400  /* speed of kgdb serial port */
-#define CONFIG_KGDB_SER_INDEX  2       /* which serial port to use */
 #endif
 
 /*
index 4a8adf6f3300d362d146f7fee31c35c227991725..38337b4564e6930839f2facf2ea0d834cd13d054 100644 (file)
 
 #ifdef CONFIG_CMD_KGDB
 #define CONFIG_KGDB_BAUDRATE   230400  /* speed of kgdb serial port */
-#define CONFIG_KGDB_SER_INDEX  2       /* which serial port to use */
 #endif
 
 /*
index ec09e15dbf6cc1f3a1d1f7e53c139f9787079338..4cac8ee46aaed5a2cecb88423b33b689a72c2227 100644 (file)
 
 #ifdef CONFIG_CMD_KGDB
 # define CONFIG_KGDB_BAUDRATE  230400 /* speed to run kgdb serial port */
-# define CONFIG_KGDB_SER_INDEX 2      /* which serial port to use */
 #endif
 
 /*
index fcf237edb9161fc06b5b9091bf55ff727a0da131..8ae497c6d56edb5d350ed7ded3ef56c2ad185ba6 100644 (file)
@@ -24,8 +24,6 @@
 #define CONFIG_VERSION_VARIABLE
 
 /* CPU and platform */
-#define CONFIG_SH              1
-#define CONFIG_SH3             1
 #define CONFIG_CPU_SH7720      1
 #define CONFIG_MPR2            1
 
index ec8523eb95c4f5ef8db865ce4a3ee7adb4cf6ab4..585d68f208e04cde19568dcdb72dead94afe2729 100644 (file)
@@ -9,8 +9,6 @@
 #ifndef __MS7720SE_H
 #define __MS7720SE_H
 
-#define CONFIG_SH              1
-#define CONFIG_SH3             1
 #define CONFIG_CPU_SH7720      1
 #define CONFIG_MS7720SE                1
 
index 54fb7c3e86d806b25d14306192e928ff1dcbea2b..1c8ada6c03f6cf0a3e05f30ccd5ababcb9ef8442 100644 (file)
@@ -9,8 +9,6 @@
 #ifndef __MS7722SE_H
 #define __MS7722SE_H
 
-#define CONFIG_SH              1
-#define CONFIG_SH4             1
 #define CONFIG_CPU_SH7722      1
 #define CONFIG_MS7722SE                1
 
index eea3bd1f2cc42719683d458f6061e3ffd7569228..4cf8efeca039d3b8a8b0b2391d7a0cd6d4a8061e 100644 (file)
@@ -9,8 +9,6 @@
 #ifndef __MS7750SE_H
 #define __MS7750SE_H
 
-#define CONFIG_SH              1
-#define CONFIG_SH4             1
 #define CONFIG_CPU_SH7750      1
 /* #define CONFIG_CPU_SH7751   1 */
 /* #define CONFIG_CPU_TYPE_R   1 */
index c15d54631a592dadbbb65eb6cdcf989a2c2b1edd..12667c57c137522b14b7430b57c1dc45057732f1 100644 (file)
@@ -86,8 +86,6 @@
 
 #if defined(CONFIG_CMD_KGDB)
 #define CONFIG_KGDB_BAUDRATE   115200          /* speed to run kgdb serial port */
-                                               /* what's this ? it's not used anywhere */
-#define CONFIG_KGDB_SER_INDEX  1               /* which serial port to use */
 #endif
 
 /*
index c48790d2ae4372736ae7878aa102d3ceb24454b6..376dfdb14cdec7994d9b3bd935d47e60778861a7 100644 (file)
@@ -94,7 +94,6 @@
 
 #if defined(CONFIG_CMD_KGDB)
 #define CONFIG_KGDB_BAUDRATE   115200  /* speed to run kgdb serial port */
-#define CONFIG_KGDB_SER_INDEX  1       /* which serial port to use */
 #endif
 
 /*
index 2f128b8a690aedd040be540f9ce983514de46e7a..76c5106b45eaaf55a682083f0fc1bfa9eab2511a 100644 (file)
@@ -36,6 +36,7 @@
 #define CONFIG_EFI_PARTITION
 #define CONFIG_PARTITION_UUIDS
 #define CONFIG_CMD_PART
+#define CONFIG_HSMMC2_8BIT
 
 /* Required support for the TCA642X GPIO we have on the uEVM */
 #define CONFIG_TCA642X
index 57ed0199523b8ba150273da2d8c81921ab5e0ce2..c6df11b8f1c24275c3c8349caf1f5afaac848f28 100644 (file)
 
 #if defined(CONFIG_CMD_KGDB)
 #define CONFIG_KGDB_BAUDRATE   230400  /* speed to run kgdb serial port */
-#define CONFIG_KGDB_SER_INDEX  2       /* which serial port to use */
 #endif
 
 /*
index 3fde7ca3a3433236d56be842e7d85b21b7ab723b..1fdd602f5bcf55d1ec0c95ccdb1198dd1abf2cfb 100644 (file)
 
 #if defined(CONFIG_CMD_KGDB)
 #define CONFIG_KGDB_BAUDRATE   230400  /* speed to run kgdb serial port */
-#define CONFIG_KGDB_SER_INDEX  2       /* which serial port to use */
 #endif
 #endif /* __CONFIG_H */
index a5b6e3aa95db5bb4c24ad959afc90949901da628..2a9fd22dd6b901b6a09955045b6438ae5f654117 100644 (file)
@@ -93,7 +93,6 @@
  */
 #ifdef CONFIG_CMD_KGDB
 #define        CONFIG_KGDB_BAUDRATE            230400  /* kgdb serial port speed */
-#define        CONFIG_KGDB_SER_INDEX           2       /* which serial port to use */
 #endif
 
 /*
index 7303e1c31f0a837c746e58b8ec8683d8f5c4599a..de254076f23c3c82c54c1929a412a6d73e0802c4 100644 (file)
@@ -95,7 +95,6 @@
  */
 #ifdef CONFIG_CMD_KGDB
 #define        CONFIG_KGDB_BAUDRATE            230400  /* kgdb serial port speed */
-#define        CONFIG_KGDB_SER_INDEX           2       /* which serial port to use */
 #endif
 
 /*
index adf85190d10c2bba56fae1c2a823436858e9a90b..36626639d374a0624fa59adc47118791bccfecea 100644 (file)
@@ -94,7 +94,6 @@
  */
 #ifdef CONFIG_CMD_KGDB
 #define CONFIG_KGDB_BAUDRATE            230400  /* kgdb serial port speed */
-#define CONFIG_KGDB_SER_INDEX           2       /* which serial port to use */
 #endif
 
 /*
index 400cb3e8261ca8a3e2bed0d82154161c34779e1a..5a5fe7ff009b0040023838109f4b2095a22b4044 100644 (file)
 
 #if defined(CONFIG_CMD_KGDB)
 #define CONFIG_KGDB_BAUDRATE   230400  /* speed to run kgdb serial port */
-#define CONFIG_KGDB_SER_INDEX  2       /* which serial port to use */
 #endif
 
 /*-----------------------------------------------------------------------
index 266d107e4467e4baa9c51d8242406a8cd487f39c..2a54e5cea0de6f1ed0de9c2a9793bdd918e00a8a 100644 (file)
 
 #ifdef CONFIG_CMD_KGDB
 #define CONFIG_KGDB_BAUDRATE   230400  /* speed of kgdb serial port */
-#define CONFIG_KGDB_SER_INDEX  2       /* which serial port to use */
 #endif
 
 /* POST support */
index 5856ee180ba5977306e467dd879666195e2eedc8..f0ecc3458700b5431a5778d5558e2e774114e847 100644 (file)
@@ -16,7 +16,6 @@
  */
 #ifdef CONFIG_CMD_KGDB
 #define        CONFIG_KGDB_BAUDRATE            230400
-#define        CONFIG_KGDB_SER_INDEX           2
 #endif
 
 /*
index 84ad006acd1ab2b40476d589c846327ba93046e7..af7c076df073bb673f18f680a377f37caf2768cf 100644 (file)
 
 #if defined(CONFIG_CMD_KGDB)
 #define CONFIG_KGDB_BAUDRATE   115200          /* speed to run kgdb serial port */
-#define CONFIG_KGDB_SER_INDEX  2               /* which serial port to use */
 #endif
 
 /*
index 7b04e0c3e30f22ca9cd79a6c5871fb50e5cc8f14..20d6178dc1a7989d1bc46d8ee3a1c21d9f5ff49b 100644 (file)
 
 #if defined(CONFIG_CMD_KGDB)
 #define CONFIG_KGDB_BAUDRATE   230400          /* speed to run kgdb serial port */
-#define CONFIG_KGDB_SER_INDEX  2               /* which serial port to use */
 #endif
 
 /* ENVIRONMENT VARS */
index dd26a71bcbc59ceecaa9df007b7779b2be131589..53128ecc12045717643455dafe4340b100f8b58b 100644 (file)
@@ -10,9 +10,6 @@
 #define __R0P7734_H
 
 #undef DEBUG
-#define CONFIG_SH              1
-#define CONFIG_SH4             1
-#define CONFIG_SH4A            1
 #define CONFIG_CPU_SH7734      1
 #define CONFIG_R0P7734         1
 #define CONFIG_400MHZ_MODE     1
index ddcc975874bdfd68411f18a2e2c29471a7f4878c..24d0c34db68055ca2c456440629eae8f80bddce9 100644 (file)
@@ -3,8 +3,6 @@
 
 #undef DEBUG
 
-#define CONFIG_SH              1
-#define CONFIG_SH4             1
 #define CONFIG_CPU_SH7751      1
 #define CONFIG_CPU_SH_TYPE_R   1
 #define CONFIG_R2DPLUS         1
index f5e4daab8f9d38015320691a39c94bdabef77885..8156724f7f6c3d63f68b87be06a78637abc9154e 100644 (file)
@@ -11,8 +11,6 @@
 #define __R7780RP_H
 
 #undef DEBUG
-#define CONFIG_SH              1
-#define CONFIG_SH4A            1
 #define CONFIG_CPU_SH7780      1
 #define CONFIG_R7780MP         1
 #define CONFIG_SYS_R7780MP_OLD_FLASH   1
index f144f84320183cbd55ae27deacaa4ca51436d8d4..92318c339435e2a2aac8c22ef5f9c62860e3e8f9 100644 (file)
 
 #if defined(CONFIG_CMD_KGDB)
 #define CONFIG_KGDB_BAUDRATE   230400          /* speed to run kgdb serial port */
-#define CONFIG_KGDB_SER_INDEX  2               /* which serial port to use */
 #endif
 
 /*
index acee4e89857df7c2d07de2eb186935d01f531076..5436324580384065e8760f06e4fa0114bd8642e0 100644 (file)
@@ -11,8 +11,6 @@
 #define __RSK7203_H
 
 #undef DEBUG
-#define CONFIG_SH              1
-#define CONFIG_SH2             1
 #define CONFIG_SH2A            1
 #define CONFIG_CPU_SH7203      1
 #define CONFIG_RSK7203 1
@@ -87,7 +85,7 @@
 #define CONFIG_SH_TMU_CLK_FREQ CONFIG_SYS_CLK_FREQ
 #define CONFIG_SH_SCIF_CLK_FREQ CONFIG_SYS_CLK_FREQ
 #define CMT_CLK_DIVIDER        32      /* 8 (default), 32, 128 or 512 */
-#define CONFIG_SYS_HZ                  (CONFIG_SYS_CLK_FREQ / CMT_CLK_DIVIDER)
+#define CONFIG_SH_CMT_CLK_FREQ (CONFIG_SYS_CLK_FREQ / CMT_CLK_DIVIDER)
 
 /* Network interface */
 #define CONFIG_SMC911X
index a5dbb64f48db7de916171f01701ec3a7b837adec..4aaa3ef74b73ba036b6879db26797866ce39c70a 100644 (file)
@@ -12,8 +12,6 @@
 #define __RSK7264_H
 
 #undef DEBUG
-#define CONFIG_SH              1
-#define CONFIG_SH2             1
 #define CONFIG_SH2A            1
 #define CONFIG_CPU_SH7264      1
 #define CONFIG_RSK7264         1
@@ -67,7 +65,7 @@
 #define CONFIG_SH_TMU_CLK_FREQ CONFIG_SYS_CLK_FREQ
 #define CONFIG_SH_SCIF_CLK_FREQ CONFIG_SYS_CLK_FREQ
 #define CMT_CLK_DIVIDER                32      /* 8 (default), 32, 128 or 512 */
-#define CONFIG_SYS_HZ          (CONFIG_SYS_CLK_FREQ / CMT_CLK_DIVIDER)
+#define CONFIG_SH_CMT_CLK_FREQ (CONFIG_SYS_CLK_FREQ / CMT_CLK_DIVIDER)
 
 /* Network interface */
 #define CONFIG_SMC911X
index 9f54160afb3085600482989181970f7021966426..11fc231fa675419b5b64ca678e04387a50e13aa0 100644 (file)
@@ -11,8 +11,6 @@
 #define __RSK7269_H
 
 #undef DEBUG
-#define CONFIG_SH              1
-#define CONFIG_SH2             1
 #define CONFIG_SH2A            1
 #define CONFIG_CPU_SH7269      1
 #define CONFIG_RSK7269         1
@@ -66,7 +64,7 @@
 #define CONFIG_SH_TMU_CLK_FREQ CONFIG_SYS_CLK_FREQ
 #define CONFIG_SH_SCIF_CLK_FREQ CONFIG_SYS_CLK_FREQ
 #define CMT_CLK_DIVIDER                32      /* 8 (default), 32, 128 or 512 */
-#define CONFIG_SYS_HZ          (CONFIG_SYS_CLK_FREQ / CMT_CLK_DIVIDER)
+#define CONFIG_SH_CMT_CLK_FREQ (CONFIG_SYS_CLK_FREQ / CMT_CLK_DIVIDER)
 
 /* Network interface */
 #define CONFIG_SMC911X
index 7e78a231d7adc6e34793b079b40f9a8bdabeb773..a6d55822b82e238ceb449b5935fc8044341d0e74 100644 (file)
@@ -39,6 +39,9 @@
 #define CONFIG_CMD_FAT
 #define CONFIG_CMD_EXT4
 #define CONFIG_CMD_EXT4_WRITE
+#define CONFIG_CMD_PART
+#define CONFIG_DOS_PARTITION
+#define CONFIG_HOST_MAX_DEVICES 4
 
 #define CONFIG_SYS_VSNPRINTF
 
 #define CONFIG_LZO
 #define CONFIG_LZMA
 
+#define CONFIG_TPM_TIS_SANDBOX
+
 #endif
index a258fe83ddb98cfa567fb64515c55be5af17ec62..b7f83e010525eb81bd3c9f71050eb0aef932b986 100644 (file)
 
 #if defined(CONFIG_CMD_KGDB)
 #define CONFIG_KGDB_BAUDRATE   230400  /* speed of kgdb serial port */
-#define CONFIG_KGDB_SER_INDEX  2       /* which serial port to use */
 #endif
 
 /*
index bdb8eb529d70064a366b83817e9ef1fa4e668a00..4912d69dcfee92c2b5d9d82fec5757b96f92a0f9 100644 (file)
 
 #if defined(CONFIG_CMD_KGDB)
 #define CONFIG_KGDB_BAUDRATE   230400  /* speed to run kgdb serial port */
-#define CONFIG_KGDB_SER_INDEX  2       /* which serial port to use */
 #endif
 
 /*
index dba948a5ce02bda8c2ebe303af08283e358d01a2..78f8219c5f7e7ce679d98b1cd19a6ff1a3113b1c 100644 (file)
 
 #if defined(CONFIG_CMD_KGDB)
 #define CONFIG_KGDB_BAUDRATE   230400  /* speed to run kgdb serial port */
-#define CONFIG_KGDB_SER_INDEX  2       /* which serial port to use */
 #endif
 
 /*
index ebdc5c8b0544cf1853e63b5128d2d54168b27c28..f06abbca0c210deec791eb36701a074f25f4f703 100644 (file)
@@ -10,8 +10,6 @@
 #define __SH7752EVB_H
 
 #undef DEBUG
-#define CONFIG_SH              1
-#define CONFIG_SH4A            1
 #define CONFIG_SH_32BIT                1
 #define CONFIG_CPU_SH7752      1
 #define CONFIG_SH7752EVB       1
diff --git a/include/configs/sh7753evb.h b/include/configs/sh7753evb.h
new file mode 100644 (file)
index 0000000..e400db0
--- /dev/null
@@ -0,0 +1,135 @@
+/*
+ * Configuation settings for the sh7753evb board
+ *
+ * Copyright (C) 2012 Renesas Solutions Corp.
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#ifndef __SH7753EVB_H
+#define __SH7753EVB_H
+
+#undef DEBUG
+#define CONFIG_SH_32BIT                1
+#define CONFIG_CPU_SH7753      1
+#define CONFIG_SH7753EVB       1
+
+#define CONFIG_SYS_TEXT_BASE   0x5ff80000
+#define CONFIG_SYS_LDSCRIPT    "board/renesas/sh7753evb/u-boot.lds"
+
+#define CONFIG_CMD_MEMORY
+#define CONFIG_CMD_NET
+#define CONFIG_CMD_MII
+#define CONFIG_CMD_PING
+#define CONFIG_CMD_NFS
+#define CONFIG_CMD_DFL
+#define CONFIG_CMD_SDRAM
+#define CONFIG_CMD_SF
+#define CONFIG_CMD_RUN
+#define CONFIG_CMD_SAVEENV
+#define CONFIG_CMD_MD5SUM
+#define CONFIG_MD5
+#define CONFIG_CMD_LOADS
+#define CONFIG_CMD_MMC
+#define CONFIG_CMD_EXT2
+#define CONFIG_DOS_PARTITION
+#define CONFIG_MAC_PARTITION
+
+#define CONFIG_BAUDRATE                115200
+#define CONFIG_BOOTDELAY       3
+#define CONFIG_BOOTARGS                "console=ttySC2,115200 root=/dev/nfs ip=dhcp"
+
+#define CONFIG_VERSION_VARIABLE
+#undef CONFIG_SHOW_BOOT_PROGRESS
+#define CONFIG_CMDLINE_EDITING
+#define CONFIG_AUTO_COMPLETE
+
+/* MEMORY */
+#define SH7753EVB_SDRAM_BASE           (0x40000000)
+#define SH7753EVB_SDRAM_SIZE           (512 * 1024 * 1024)
+
+#define CONFIG_SYS_LONGHELP
+#define CONFIG_SYS_CBSIZE              256
+#define CONFIG_SYS_PBSIZE              256
+#define CONFIG_SYS_MAXARGS             16
+#define CONFIG_SYS_BARGSIZE            512
+#define CONFIG_SYS_BAUDRATE_TABLE      { 115200 }
+
+/* SCIF */
+#define CONFIG_SCIF_CONSOLE    1
+#define CONFIG_CONS_SCIF2      1
+#undef CONFIG_SYS_CONSOLE_INFO_QUIET
+#undef CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE
+#undef CONFIG_SYS_CONSOLE_ENV_OVERWRITE
+
+#define CONFIG_SYS_MEMTEST_START       (SH7753EVB_SDRAM_BASE)
+#define CONFIG_SYS_MEMTEST_END         (CONFIG_SYS_MEMTEST_START + \
+                                        480 * 1024 * 1024)
+#undef CONFIG_SYS_ALT_MEMTEST
+#undef CONFIG_SYS_MEMTEST_SCRATCH
+#undef CONFIG_SYS_LOADS_BAUD_CHANGE
+
+#define CONFIG_SYS_SDRAM_BASE          (SH7753EVB_SDRAM_BASE)
+#define CONFIG_SYS_SDRAM_SIZE          (SH7753EVB_SDRAM_SIZE)
+#define CONFIG_SYS_LOAD_ADDR           (CONFIG_SYS_SDRAM_BASE + \
+                                        128 * 1024 * 1024)
+
+#define CONFIG_SYS_MONITOR_BASE                0x00000000
+#define CONFIG_SYS_MONITOR_LEN         (512 * 1024)
+#define CONFIG_SYS_MALLOC_LEN          (4 * 1024 * 1024)
+#define CONFIG_SYS_BOOTMAPSZ           (8 * 1024 * 1024)
+
+/* FLASH */
+#define CONFIG_SYS_NO_FLASH
+
+/* Ether */
+#define CONFIG_SH_ETHER                        1
+#define CONFIG_SH_ETHER_USE_PORT       0
+#define CONFIG_SH_ETHER_PHY_ADDR       18
+#define CONFIG_SH_ETHER_CACHE_WRITEBACK        1
+#define CONFIG_SH_ETHER_USE_GETHER     1
+#define CONFIG_PHYLIB
+#define CONFIG_BITBANGMII
+#define CONFIG_BITBANGMII_MULTI
+#define CONFIG_SH_ETHER_PHY_MODE PHY_INTERFACE_MODE_RGMII
+#define CONFIG_PHY_VITESSE
+
+#define SH7753EVB_ETHERNET_MAC_BASE_SPI        0x00090000
+#define SH7753EVB_SPI_SECTOR_SIZE      (64 * 1024)
+#define SH7753EVB_ETHERNET_MAC_BASE    SH7753EVB_ETHERNET_MAC_BASE_SPI
+#define SH7753EVB_ETHERNET_MAC_SIZE    17
+#define SH7753EVB_ETHERNET_NUM_CH      2
+#define CONFIG_BOARD_LATE_INIT
+
+/* SPI */
+#define CONFIG_SH_SPI                  1
+#define CONFIG_SH_SPI_BASE             0xfe002000
+#define CONFIG_SPI_FLASH
+#define CONFIG_SPI_FLASH_STMICRO       1
+#define CONFIG_SPI_FLASH_MACRONIX      1
+
+/* MMCIF */
+#define CONFIG_MMC                     1
+#define CONFIG_GENERIC_MMC             1
+#define CONFIG_SH_MMCIF                        1
+#define CONFIG_SH_MMCIF_ADDR           0xffcb0000
+#define CONFIG_SH_MMCIF_CLK            48000000
+
+/* ENV setting */
+#define CONFIG_ENV_IS_EMBEDDED
+#define CONFIG_ENV_IS_IN_SPI_FLASH
+#define CONFIG_ENV_SECT_SIZE   (64 * 1024)
+#define CONFIG_ENV_ADDR                (0x00080000)
+#define CONFIG_ENV_OFFSET      (CONFIG_ENV_ADDR)
+#define CONFIG_ENV_OVERWRITE   1
+#define CONFIG_ENV_SIZE                (CONFIG_ENV_SECT_SIZE)
+#define CONFIG_ENV_SIZE_REDUND (CONFIG_ENV_SECT_SIZE)
+#define CONFIG_EXTRA_ENV_SETTINGS                              \
+               "netboot=bootp; bootm\0"
+
+/* Board Clock */
+#define CONFIG_SYS_CLK_FREQ    48000000
+#define CONFIG_SH_TMU_CLK_FREQ CONFIG_SYS_CLK_FREQ
+#define CONFIG_SH_SCIF_CLK_FREQ CONFIG_SYS_CLK_FREQ
+#define CONFIG_SYS_TMU_CLK_DIV 4
+#endif /* __SH7753EVB_H */
index ce1add2689460b178a72b8b3ed3896d940f7df28..08bff1da3fa227b012eca0b96a1ecf685d7afa15 100644 (file)
@@ -10,8 +10,6 @@
 #define __SH7757LCR_H
 
 #undef DEBUG
-#define CONFIG_SH              1
-#define CONFIG_SH4A            1
 #define CONFIG_SH_32BIT                1
 #define CONFIG_CPU_SH7757      1
 #define CONFIG_SH7757LCR       1
index a13778830a3b9e01445fc79a3e0832fb4d8dd2ee..2438318fca528343090f321cb84d245552b95c50 100644 (file)
@@ -10,8 +10,6 @@
 #ifndef __SH7763RDP_H
 #define __SH7763RDP_H
 
-#define CONFIG_SH              1
-#define CONFIG_SH4             1
 #define CONFIG_CPU_SH7763      1
 #define CONFIG_SH7763RDP       1
 #define __LITTLE_ENDIAN                1
index 4acbcab1b20badc9f166156c689dc0d7a9e6b882..2723eaf2d3d9f50624930e2ca0a16cc4906401f6 100644 (file)
@@ -10,8 +10,6 @@
 #define __SH7785LCR_H
 
 #undef DEBUG
-#define CONFIG_SH              1
-#define CONFIG_SH4A            1
 #define CONFIG_CPU_SH7785      1
 #define CONFIG_SH7785LCR       1
 
index 5c990fc96d03a03ace322d9cc4a45c1c0aeca863..f8155efbc9848cc9ecd5fa13d726517847e10f0a 100644 (file)
@@ -9,8 +9,6 @@
 #ifndef __SHMIN_H
 #define __SHMIN_H
 
-#define CONFIG_SH              1
-#define CONFIG_SH3             1
 #define CONFIG_CPU_SH7706      1
 /* T-SH7706LAN */
 #define CONFIG_SHMIN           1
index a87444e0b1bc9418e000194241da4d20d4950389..d4ae19f96cec077c4c92e176cbd8eeafc07ffe39 100644 (file)
 
 #if defined(CONFIG_CMD_KGDB)
 #define CONFIG_KGDB_BAUDRATE   115200  /* speed to run kgdb serial port */
-/* what's this ? it's not used anywhere */
-#define CONFIG_KGDB_SER_INDEX  2       /* which serial port to use */
 #endif
 
 /*
index 0e6b86412d125597cab3617b86cc22b7b87a21b7..fd590e4e122d0fa0f34af30d7e38228fb07833d0 100644 (file)
 
 #if defined(CONFIG_CMD_KGDB)
 #define CONFIG_KGDB_BAUDRATE   230400  /* speed to run kgdb serial port*/
-#define CONFIG_KGDB_SER_INDEX  2       /* which serial port to use     */
 #endif
 
 
index ee1f1f3ed00829c04ce5ef1f2ee809fa43ecd99d..2a9c9a349c074d1b5ac95cf14a1c85ef005330a1 100644 (file)
 
 #if defined(CONFIG_CMD_KGDB)
 #define CONFIG_KGDB_BAUDRATE   230400  /* speed to run kgdb serial port */
-#define CONFIG_KGDB_SER_INDEX  2       /* which serial port to use */
 #endif
 
 /*Note: change below for your network setting!!! */
index 63dd767047b3b97773cd675760e7c9db6d5f9d31..d0cb68a0ed5e7757880aba71ea9e55b54d846cb6 100644 (file)
 
 #if defined(CONFIG_CMD_KGDB)
 #define CONFIG_KGDB_BAUDRATE   230400  /* speed to run kgdb serial port */
-#define CONFIG_KGDB_SER_INDEX  2       /* which serial port to use */
 #endif
 
 /*Note: change below for your network setting!!! */
index d9b0ed07d6c9e02ed946d70153ee64f3d863b952..54a5e3e2609935374f5ab8b4be13ab4fb00e7f56 100644 (file)
 
 #ifdef CONFIG_CMD_KGDB
 #define CONFIG_KGDB_BAUDRATE   230400  /* speed to run kgdb serial port */
-#define CONFIG_KGDB_SER_INDEX  2       /* which serial port to use */
 #endif
 
 /*
index 627836a7e818c0983c045a73a1a69ae930a1e2d4..58bcdc8f47c49246899bd93f0d527f21a25a7345 100644 (file)
@@ -55,7 +55,7 @@
 #define CONFIG_EBIU_AMBCTL0_VAL        (B1WAT_7 | B1RAT_11 | B1HT_2 | B1ST_3 | B0WAT_7 | B0RAT_11 | B0HT_2 | B0ST_3)
 #define CONFIG_EBIU_AMBCTL1_VAL        (B3WAT_7 | B3RAT_11 | B3HT_2 | B3ST_3 | B2WAT_7 | B2RAT_11 | B2HT_2 | B2ST_3)
 
-#define CONFIG_SYS_MONITOR_LEN (512 * 1024)
+#define CONFIG_SYS_MONITOR_LEN (768 * 1024)
 #define CONFIG_SYS_MALLOC_LEN  (128 * 1024)
 
 
 #define FLASHBOOT_ENV_SETTINGS \
        "flashboot=flread 20040000 1000000 300000;" \
        "bootm 0x1000000\0"
+#define CONFIG_BOARD_SIZE_LIMIT $$((384 * 1024))
 
 
 /*
index 08771422ec42598c168641165488f5891c6749b1..6cd15c25bdbdfc5ce29160b376b2443e684629c9 100644 (file)
@@ -99,6 +99,7 @@
 #define CONFIG_THOR_FUNCTION
 
 #define CONFIG_SYS_DFU_DATA_BUF_SIZE SZ_32M
+#define DFU_DEFAULT_POLL_TIMEOUT 300
 #define CONFIG_DFU_FUNCTION
 #define CONFIG_DFU_MMC
 
index 06151177735319d4ebca530174eab301698f4e1c..b7804d2872460b75492246f3cfae5901b68e3cd7 100644 (file)
 
 #if defined(CONFIG_CMD_KGDB)
 #define CONFIG_KGDB_BAUDRATE   230400          /* speed to run kgdb serial port */
-#define CONFIG_KGDB_SER_INDEX  2               /* which serial port to use */
 #endif
 
 /*
index 734d13f0056d00bbb2b9dfac01974e292ab247bc..7ecbafe2e582276c1787c8a96307e449811bc3b4 100644 (file)
 
 #if defined(CONFIG_CMD_KGDB)
 #define CONFIG_KGDB_BAUDRATE   230400  /* speed of kgdb serial port */
-#define CONFIG_KGDB_SER_INDEX  2       /* which serial port to use */
 #endif
 
 /*
index c3ac612a8c8c3690b70ccb5ad7e9bf1ada1d308a..71a89b6edd1b02855c8c3ea8443af1bf9c20ff50 100644 (file)
  */
 #ifdef CONFIG_CMD_KGDB
 #define        CONFIG_KGDB_BAUDRATE            230400  /* kgdb serial port speed */
-#define        CONFIG_KGDB_SER_INDEX           2       /* which serial port to use */
 #endif
 
 /*
index 431ed96e29e5174ed5cb0459910688d93f49172a..2999d1b0f54ddd55e7473c83878c6644aec296f6 100644 (file)
@@ -84,7 +84,6 @@
 
 #if defined(CONFIG_CMD_KGDB)
 #define CONFIG_KGDB_BAUDRATE   115200                  /* speed to run kgdb serial port */
-#define CONFIG_KGDB_SER_INDEX  1                       /* which serial port to use */
 #endif
 
 /*
index 9d58738ce85b18f2da081a6c9f4e9643df295360..d8aeb3794e7e3130acd644a2da5c82454e142d67 100644 (file)
 
 #if defined(CONFIG_CMD_KGDB)
 #define CONFIG_KGDB_BAUDRATE   230400          /* speed to run kgdb serial port */
-#define CONFIG_KGDB_SER_INDEX  2               /* which serial port to use */
 #endif
 
 /*
index 904f3b0fb15ea425f9d4dd733cc61ac2039ac099..e38fa89fdac504972f3e245d42ad1a31cd3f1ae1 100644 (file)
@@ -117,7 +117,6 @@ unsigned char zipitz2_spi_read(void);
  */
 #ifdef CONFIG_CMD_KGDB
 #define        CONFIG_KGDB_BAUDRATE            230400          /* speed to run kgdb serial port */
-#define        CONFIG_KGDB_SER_INDEX           2               /* which serial port to use */
 #endif
 
 /*
index cc140449271d7f8db2b72c93a5d9d614ca74f939..f973426aa90b321e34e0127e785f114b869261f4 100644 (file)
@@ -77,6 +77,9 @@ static inline unsigned int get_mmc_blk_size(int dev)
 #ifndef CONFIG_SYS_DFU_MAX_FILE_SIZE
 #define CONFIG_SYS_DFU_MAX_FILE_SIZE CONFIG_SYS_DFU_DATA_BUF_SIZE
 #endif
+#ifndef DFU_DEFAULT_POLL_TIMEOUT
+#define DFU_DEFAULT_POLL_TIMEOUT 0
+#endif
 
 struct dfu_entity {
        char                    name[DFU_NAME_SIZE];
@@ -131,6 +134,7 @@ bool dfu_reset(void);
 int dfu_init_env_entities(char *interface, int dev);
 unsigned char *dfu_get_buf(void);
 unsigned char *dfu_free_buf(void);
+unsigned long dfu_get_buf_size(void);
 
 int dfu_read(struct dfu_entity *de, void *buf, int size, int blk_seq_num);
 int dfu_write(struct dfu_entity *de, void *buf, int size, int blk_seq_num);
diff --git a/include/linux/crc8.h b/include/linux/crc8.h
new file mode 100644 (file)
index 0000000..b5fd2ac
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2013 Google, Inc
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+
+#ifndef __linux_crc8_h
+#define __linux_crc8_h
+
+/**
+ * crc8() - Calculate and return CRC-8 of the data
+ *
+ * This uses an x^8 + x^2 + x + 1 polynomial.  A table-based algorithm would
+ * be faster, but for only a few bytes it isn't worth the code size
+ *
+ * @vptr: Buffer to checksum
+ * @len: Length of buffer in bytes
+ * @return CRC8 checksum
+ */
+unsigned int crc8(const unsigned char *vptr, int len);
+
+#endif
index cb558da63d8307024d88002de8daecb28cddd834..e1060b9ff2794f5b3ebb77b14321ccad1c499d54 100644 (file)
@@ -262,6 +262,8 @@ struct mmc {
        uint card_caps;
        uint host_caps;
        uint ocr;
+       uint dsr;
+       uint dsr_imp;
        uint scr[2];
        uint csd[4];
        uint cid[4];
@@ -304,7 +306,7 @@ int board_mmc_getcd(struct mmc *mmc);
 int mmc_switch_part(int dev_num, unsigned int part_num);
 int mmc_getcd(struct mmc *mmc);
 int mmc_getwp(struct mmc *mmc);
-void spl_mmc_load(void) __noreturn;
+int mmc_set_dsr(struct mmc *mmc, u16 val);
 /* Function to change the size of boot partition and rpmb partitions */
 int mmc_boot_partition_size_change(struct mmc *mmc, unsigned long bootsize,
                                        unsigned long rpmbsize);
index 950433daa32dbabce603e3a4941d142162e5506b..b65fba430144d2587c068756fd8bfbd001799354 100644 (file)
@@ -106,6 +106,35 @@ void os_tty_raw(int fd);
  */
 void *os_malloc(size_t length);
 
+/**
+ * Free memory previous allocated with os_malloc()/os_realloc()
+ *
+ * This returns the memory to the OS.
+ *
+ * \param ptr          Pointer to memory block to free
+ */
+void *os_free(void *ptr);
+
+/**
+ * Reallocate previously-allocated memory to increase/decrease space
+ *
+ * This works in a similar way to the C library realloc() function. If
+ * length is 0, then ptr is freed. Otherwise the space used by ptr is
+ * expanded or reduced depending on whether length is larger or smaller
+ * than before.
+ *
+ * If ptr is NULL, then this is similar to calling os_malloc().
+ *
+ * This function may need to move the memory block to make room for any
+ * extra space, in which case the new pointer is returned.
+ *
+ * \param ptr          Pointer to memory block to reallocate
+ * \param length       New length for memory block
+ * \return pointer to new memory block, or NULL on failure or if length
+ *     is 0.
+ */
+void *os_realloc(void *ptr, size_t length);
+
 /**
  * Access to the usleep function of the os
  *
@@ -180,4 +209,40 @@ const char *os_dirent_get_typename(enum os_dirent_t type);
  */
 ssize_t os_get_filesize(const char *fname);
 
+/**
+ * Write a character to the controlling OS terminal
+ *
+ * This bypasses the U-Boot console support and writes directly to the OS
+ * stdout file descriptor.
+ *
+ * @param ch   Character to write
+ */
+void os_putc(int ch);
+
+/**
+ * Write a string to the controlling OS terminal
+ *
+ * This bypasses the U-Boot console support and writes directly to the OS
+ * stdout file descriptor.
+ *
+ * @param str  String to write (note that \n is not appended)
+ */
+void os_puts(const char *str);
+
+/**
+ * Write the sandbox RAM buffer to a existing file
+ *
+ * @param fname                Filename to write memory to (simple binary format)
+ * @return 0 if OK, -ve on error
+ */
+int os_write_ram_buf(const char *fname);
+
+/**
+ * Read the sandbox RAM buffer from an existing file
+ *
+ * @param fname                Filename containing memory (simple binary format)
+ * @return 0 if OK, -ve on error
+ */
+int os_read_ram_buf(const char *fname);
+
 #endif
index ce840bd841b21d7ce4fb1080264567c42c3d4b65..4beb6db89b104aa2096ef25b02695af7ba2be46f 100644 (file)
@@ -58,6 +58,8 @@ typedef struct block_dev_desc {
 #define IF_TYPE_MMC            6
 #define IF_TYPE_SD             7
 #define IF_TYPE_SATA           8
+#define IF_TYPE_HOST           9
+#define IF_TYPE_MAX            10      /* Max number of IF_TYPE_* supported */
 
 /* Part types */
 #define PART_TYPE_UNKNOWN      0x00
@@ -102,6 +104,8 @@ block_dev_desc_t* usb_stor_get_dev(int dev);
 block_dev_desc_t* mmc_get_dev(int dev);
 block_dev_desc_t* systemace_get_dev(int dev);
 block_dev_desc_t* mg_disk_get_dev(int dev);
+block_dev_desc_t *host_get_dev(int dev);
+int host_get_dev_err(int dev, block_dev_desc_t **blk_devp);
 
 /* disk/part.c */
 int get_partition_info (block_dev_desc_t * dev_desc, int part, disk_partition_t *info);
@@ -123,6 +127,7 @@ static inline block_dev_desc_t* usb_stor_get_dev(int dev) { return NULL; }
 static inline block_dev_desc_t* mmc_get_dev(int dev) { return NULL; }
 static inline block_dev_desc_t* systemace_get_dev(int dev) { return NULL; }
 static inline block_dev_desc_t* mg_disk_get_dev(int dev) { return NULL; }
+static inline block_dev_desc_t *host_get_dev(int dev) { return NULL; }
 
 static inline int get_partition_info (block_dev_desc_t * dev_desc, int part,
        disk_partition_t *info) { return -1; }
diff --git a/include/sandboxblockdev.h b/include/sandboxblockdev.h
new file mode 100644 (file)
index 0000000..627787a
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+ * Copyright (c) 2013, Henrik Nordstrom <henrik@henriknordstrom.net>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#ifndef __SANDBOX_BLOCK_DEV__
+#define __SANDBOX_BLOCK_DEV__
+
+struct host_block_dev {
+       block_dev_desc_t blk_dev;
+       char *filename;
+       int fd;
+};
+
+int host_dev_bind(int dev, char *filename);
+
+#endif
index f5b42faea418aff5857849810172f824f3fd677b..61afc7136d7c1ea8c84c7ef17d1b917ac3051a59 100644 (file)
@@ -47,7 +47,7 @@ struct tmu_regs {
 };
 #endif /* CONFIG_SH3 */
 
-#if defined(CONFIG_SH4) || defined(CONFIG_SH4A) || defined(CONFIG_RMOBILE)
+#if defined(CONFIG_SH4) || defined(CONFIG_RMOBILE)
 struct tmu_regs {
        u32 reserved;
        u8  tstr;
index c5d1577f9cb51bfdcde210ae8a328efb5791089f..122043c941e9b17b41c6d10df4b8449aa18b458b 100644 (file)
@@ -9,6 +9,9 @@
 #define _VXWORKS_H_
 
 int do_bootvx(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
+void boot_prep_vxworks(bootm_headers_t *images);
+void boot_jump_vxworks(bootm_headers_t *images);
+void do_bootvx_fdt(bootm_headers_t *images);
 
 /*
  * Use bootaddr to find the location in memory that VxWorks
index e787f77be8533dd85429e98b39b5ca165fb1d73c..760340fbdef85f0ad1980b6c062093522ba8d0d5 100644 (file)
@@ -21,6 +21,7 @@ obj-$(CONFIG_BZIP2) += bzlib_randtable.o
 obj-$(CONFIG_BZIP2) += bzlib_huffman.o
 obj-$(CONFIG_USB_TTY) += circbuf.o
 obj-y += crc7.o
+obj-y += crc8.o
 obj-y += crc16.o
 obj-$(CONFIG_OF_CONTROL) += fdtdec.o
 obj-$(CONFIG_TEST_FDTDEC) += fdtdec_test.o
diff --git a/lib/crc8.c b/lib/crc8.c
new file mode 100644 (file)
index 0000000..8b68a29
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2013 Google, Inc
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include "linux/crc8.h"
+
+unsigned int crc8(const unsigned char *vptr, int len)
+{
+       const unsigned char *data = vptr;
+       unsigned int crc = 0;
+       int i, j;
+
+       for (j = len; j; j--, data++) {
+               crc ^= (*data << 8);
+               for (i = 8; i; i--) {
+                       if (crc & 0x8000)
+                               crc ^= (0x1070 << 3);
+                       crc <<= 1;
+               }
+       }
+
+       return (crc >> 8) & 0xff;
+}
index 09bb05a24d331b0f023a149024278952e0e89054..8085aa40d1c96de75c4af0fcf74e2a8b917458c6 100644 (file)
@@ -71,8 +71,8 @@ unsigned long __weak notrace timer_get_us(void)
 }
 static unsigned long long usec_to_tick(unsigned long usec)
 {
-       uint64_t tick = usec * get_tbclk();
-       usec *= get_tbclk();
+       uint64_t tick = usec;
+       tick *= get_tbclk();
        do_div(tick, 1000000);
        return tick;
 }
index 143924482ff0c9da69ad6539aa72870b8136e163..2fa6f8a295a03d165e2bc0dbae89950a93ff44bd 100644 (file)
@@ -5,16 +5,14 @@
 # SPDX-License-Identifier:     GPL-2.0+
 #
 
-obj-$(CONFIG_HAS_POST) += post.o
+obj- += post.o
 obj-$(CONFIG_POST_STD_LIST)    += tests.o
 
-obj-$(CONFIG_HAS_POST) += drivers/
-ifeq ($(ARCH),powerpc)
-obj-$(CONFIG_HAS_POST) += lib_powerpc/
-endif
-ifneq ($(filter mpc83xx mpc8xx ppc4xx,$(CPU)),)
-obj-$(CONFIG_HAS_POST) += cpu/$(CPU)/
-endif
+obj-y += drivers/
+obj-$(CONFIG_PPC) += lib_powerpc/
+obj-$(CONFIG_MPC83xx) += cpu/mpc83xx/
+obj-$(CONFIG_8xx) += cpu/mpc8xx/
+obj-$(CONFIG_4xx) += cpu/ppc4xx/
 ifneq ($(filter lwmon lwmon5 netta pdm360ng,$(BOARD)),)
-obj-$(CONFIG_HAS_POST) += board/$(BOARD)/
+obj-y += board/$(BOARD)/
 endif
index b23debcabe9cac3ffe637ee747121152943ab403..7f6d5a084e846d3f3ad0e094b5a6e240f53dbc1a 100644 (file)
@@ -5,4 +5,4 @@
 # SPDX-License-Identifier:     GPL-2.0+
 #
 
-obj-$(CONFIG_HAS_POST) += sysmon.o
+obj-y += sysmon.o
index a50ce67cde408d241343ec04831285033216a17a..76262c76bcb2b6efe368733f9996617f42457a0b 100644 (file)
@@ -5,4 +5,4 @@
 #
 # SPDX-License-Identifier:     GPL-2.0+
 
-obj-$(CONFIG_HAS_POST) += sysmon.o watchdog.o dspic.o fpga.o dsp.o gdc.o
+obj-y += sysmon.o watchdog.o dspic.o fpga.o dsp.o gdc.o
index 5c37f497ccc858721f202579a50565a6cf1efab9..8fc1945b078ba9d375c93cd299cd284aa9ba5ea2 100644 (file)
@@ -5,4 +5,4 @@
 # SPDX-License-Identifier:     GPL-2.0+
 #
 
-obj-$(CONFIG_HAS_POST) += codec.o dsp.o
+obj-y += codec.o dsp.o
index b43b77b2d31f91f2683f0d5b9f9af3e9140c2530..9aa96a1f6a63dd81c4e7b0846cb18ce9f7b08371 100644 (file)
@@ -5,4 +5,4 @@
 # SPDX-License-Identifier:     GPL-2.0+
 #
 
-obj-$(CONFIG_HAS_POST) += coproc_com.o
+obj-y += coproc_com.o
index 4b3c50e6afdb31b3d8b134fa3be7959a9c6c895e..d57b66757e8cb680e578b5cd65d955f9ff1232e6 100644 (file)
@@ -5,4 +5,4 @@
 # SPDX-License-Identifier:     GPL-2.0+
 #
 
-obj-$(CONFIG_HAS_POST) += ecc.o
+obj-y += ecc.o
index ed3e8e87fdd1f996788959b7161895f6f3229778..e9ec286c7cc29e3daffa781b2b6f2664480e348e 100644 (file)
@@ -5,12 +5,12 @@
 # SPDX-License-Identifier:     GPL-2.0+
 #
 
-obj-$(CONFIG_HAS_POST) += cache_4xx.o
-obj-$(CONFIG_HAS_POST) += cache.o
-obj-$(CONFIG_HAS_POST) += denali_ecc.o
-obj-$(CONFIG_HAS_POST) += ether.o
-obj-$(CONFIG_HAS_POST) += fpu.o
-obj-$(CONFIG_HAS_POST) += ocm.o
-obj-$(CONFIG_HAS_POST) += spr.o
-obj-$(CONFIG_HAS_POST) += uart.o
-obj-$(CONFIG_HAS_POST) += watchdog.o
+obj-y += cache_4xx.o
+obj-y += cache.o
+obj-y += denali_ecc.o
+obj-y += ether.o
+obj-y += fpu.o
+obj-y += ocm.o
+obj-y += spr.o
+obj-y += uart.o
+obj-y += watchdog.o
index 328f880b1d952367be8372f15374513481c086a3..1abfb1ffe6fbba78149b28c847905970dc5f2040 100644 (file)
@@ -5,4 +5,4 @@
 # SPDX-License-Identifier:     GPL-2.0+
 #
 
-obj-$(CONFIG_HAS_POST) += flash.o i2c.o memory.o rtc.o
+obj-y += flash.o i2c.o memory.o rtc.o
index d2b8a940df11ccc1642d5ed052b00a03035828f1..0cbb6b6bd2a7ec98c636a385173f785e6dc0acf9 100644 (file)
@@ -5,9 +5,9 @@
 # SPDX-License-Identifier:     GPL-2.0+
 #
 
-obj-$(CONFIG_HAS_POST) += asm.o
-obj-$(CONFIG_HAS_POST) += cpu.o cmp.o cmpi.o two.o twox.o three.o threex.o
-obj-$(CONFIG_HAS_POST) += threei.o andi.o srawi.o rlwnm.o rlwinm.o rlwimi.o
-obj-$(CONFIG_HAS_POST) += store.o load.o cr.o b.o multi.o string.o complex.o
+obj-y += asm.o
+obj-y += cpu.o cmp.o cmpi.o two.o twox.o three.o threex.o
+obj-y += threei.o andi.o srawi.o rlwnm.o rlwinm.o rlwimi.o
+obj-y += store.o load.o cr.o b.o multi.o string.o complex.o
 
-obj-$(CONFIG_HAS_POST) += fpu/
+obj-y += fpu/
index ee01a313f1b019002f50da80c6c485135a321354..ae56a82af350da370534f468e4723437e691a9af 100644 (file)
@@ -5,15 +5,15 @@
 # SPDX-License-Identifier:     GPL-2.0+
 #
 
-obj-$(CONFIG_HAS_POST) += 20001122-1.o
-obj-$(CONFIG_HAS_POST) += 20010114-2.o
-obj-$(CONFIG_HAS_POST) += 20010226-1.o
-obj-$(CONFIG_HAS_POST) += 980619-1.o
-obj-$(CONFIG_HAS_POST) += acc1.o
-obj-$(CONFIG_HAS_POST) += compare-fp-1.o
-obj-$(CONFIG_HAS_POST) += fpu.o
-obj-$(CONFIG_HAS_POST) += mul-subnormal-single-1.o
-obj-$(CONFIG_HAS_POST) += darwin-ldouble.o
+obj- += 20001122-1.o
+obj- += 20010114-2.o
+obj- += 20010226-1.o
+obj- += 980619-1.o
+obj- += acc1.o
+obj- += compare-fp-1.o
+obj- += fpu.o
+obj- += mul-subnormal-single-1.o
+obj- += darwin-ldouble.o
 
 CFLAGS := $(shell echo $(CFLAGS) | sed s/-msoft-float//)
 CFLAGS += -mhard-float -fkeep-inline-functions
diff --git a/scripts/binutils-version.sh b/scripts/binutils-version.sh
new file mode 100644 (file)
index 0000000..d4d9eb4
--- /dev/null
@@ -0,0 +1,20 @@
+#!/bin/sh
+#
+# binutils-version [-p] gas-command
+#
+# Prints the binutils version of `gas-command' in a canonical 4-digit form
+# such as `0222' for binutils 2.22
+#
+
+gas="$*"
+
+if [ ${#gas} -eq 0 ]; then
+       echo "Error: No assembler specified."
+       printf "Usage:\n\t$0 <gas-command>\n"
+       exit 1
+fi
+
+MAJOR=$($gas --version | head -1 | awk '{print $NF}' | cut -d . -f 1)
+MINOR=$($gas --version | head -1 | awk '{print $NF}' | cut -d . -f 2)
+
+printf "%02d%02d\\n" $MAJOR $MINOR
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
new file mode 100755 (executable)
index 0000000..88c5bc7
--- /dev/null
@@ -0,0 +1,3709 @@
+#!/usr/bin/perl -w
+# (c) 2001, Dave Jones. (the file handling bit)
+# (c) 2005, Joel Schopp <jschopp@austin.ibm.com> (the ugly bit)
+# (c) 2007,2008, Andy Whitcroft <apw@uk.ibm.com> (new conditions, test suite)
+# (c) 2008-2010 Andy Whitcroft <apw@canonical.com>
+# Licensed under the terms of the GNU GPL License version 2
+
+use strict;
+
+my $P = $0;
+$P =~ s@.*/@@g;
+
+my $V = '0.32';
+
+use Getopt::Long qw(:config no_auto_abbrev);
+
+my $quiet = 0;
+my $tree = 1;
+my $chk_signoff = 1;
+my $chk_patch = 1;
+my $tst_only;
+my $emacs = 0;
+my $terse = 0;
+my $file = 0;
+my $check = 0;
+my $summary = 1;
+my $mailback = 0;
+my $summary_file = 0;
+my $show_types = 0;
+my $root;
+my %debug;
+my %ignore_type = ();
+my @ignore = ();
+my $help = 0;
+my $configuration_file = ".checkpatch.conf";
+my $max_line_length = 80;
+
+sub help {
+       my ($exitcode) = @_;
+
+       print << "EOM";
+Usage: $P [OPTION]... [FILE]...
+Version: $V
+
+Options:
+  -q, --quiet                quiet
+  --no-tree                  run without a kernel tree
+  --no-signoff               do not check for 'Signed-off-by' line
+  --patch                    treat FILE as patchfile (default)
+  --emacs                    emacs compile window format
+  --terse                    one line per report
+  -f, --file                 treat FILE as regular source file
+  --subjective, --strict     enable more subjective tests
+  --ignore TYPE(,TYPE2...)   ignore various comma separated message types
+  --max-line-length=n        set the maximum line length, if exceeded, warn
+  --show-types               show the message "types" in the output
+  --root=PATH                PATH to the kernel tree root
+  --no-summary               suppress the per-file summary
+  --mailback                 only produce a report in case of warnings/errors
+  --summary-file             include the filename in summary
+  --debug KEY=[0|1]          turn on/off debugging of KEY, where KEY is one of
+                             'values', 'possible', 'type', and 'attr' (default
+                             is all off)
+  --test-only=WORD           report only warnings/errors containing WORD
+                             literally
+  -h, --help, --version      display this help and exit
+
+When FILE is - read standard input.
+EOM
+
+       exit($exitcode);
+}
+
+my $conf = which_conf($configuration_file);
+if (-f $conf) {
+       my @conf_args;
+       open(my $conffile, '<', "$conf")
+           or warn "$P: Can't find a readable $configuration_file file $!\n";
+
+       while (<$conffile>) {
+               my $line = $_;
+
+               $line =~ s/\s*\n?$//g;
+               $line =~ s/^\s*//g;
+               $line =~ s/\s+/ /g;
+
+               next if ($line =~ m/^\s*#/);
+               next if ($line =~ m/^\s*$/);
+
+               my @words = split(" ", $line);
+               foreach my $word (@words) {
+                       last if ($word =~ m/^#/);
+                       push (@conf_args, $word);
+               }
+       }
+       close($conffile);
+       unshift(@ARGV, @conf_args) if @conf_args;
+}
+
+GetOptions(
+       'q|quiet+'      => \$quiet,
+       'tree!'         => \$tree,
+       'signoff!'      => \$chk_signoff,
+       'patch!'        => \$chk_patch,
+       'emacs!'        => \$emacs,
+       'terse!'        => \$terse,
+       'f|file!'       => \$file,
+       'subjective!'   => \$check,
+       'strict!'       => \$check,
+       'ignore=s'      => \@ignore,
+       'show-types!'   => \$show_types,
+       'max-line-length=i' => \$max_line_length,
+       'root=s'        => \$root,
+       'summary!'      => \$summary,
+       'mailback!'     => \$mailback,
+       'summary-file!' => \$summary_file,
+
+       'debug=s'       => \%debug,
+       'test-only=s'   => \$tst_only,
+       'h|help'        => \$help,
+       'version'       => \$help
+) or help(1);
+
+help(0) if ($help);
+
+my $exit = 0;
+
+if ($#ARGV < 0) {
+       print "$P: no input files\n";
+       exit(1);
+}
+
+@ignore = split(/,/, join(',',@ignore));
+foreach my $word (@ignore) {
+       $word =~ s/\s*\n?$//g;
+       $word =~ s/^\s*//g;
+       $word =~ s/\s+/ /g;
+       $word =~ tr/[a-z]/[A-Z]/;
+
+       next if ($word =~ m/^\s*#/);
+       next if ($word =~ m/^\s*$/);
+
+       $ignore_type{$word}++;
+}
+
+my $dbg_values = 0;
+my $dbg_possible = 0;
+my $dbg_type = 0;
+my $dbg_attr = 0;
+for my $key (keys %debug) {
+       ## no critic
+       eval "\${dbg_$key} = '$debug{$key}';";
+       die "$@" if ($@);
+}
+
+my $rpt_cleaners = 0;
+
+if ($terse) {
+       $emacs = 1;
+       $quiet++;
+}
+
+if ($tree) {
+       if (defined $root) {
+               if (!top_of_kernel_tree($root)) {
+                       die "$P: $root: --root does not point at a valid tree\n";
+               }
+       } else {
+               if (top_of_kernel_tree('.')) {
+                       $root = '.';
+               } elsif ($0 =~ m@(.*)/scripts/[^/]*$@ &&
+                                               top_of_kernel_tree($1)) {
+                       $root = $1;
+               }
+       }
+
+       if (!defined $root) {
+               print "Must be run from the top-level dir. of a kernel tree\n";
+               exit(2);
+       }
+}
+
+my $emitted_corrupt = 0;
+
+our $Ident     = qr{
+                       [A-Za-z_][A-Za-z\d_]*
+                       (?:\s*\#\#\s*[A-Za-z_][A-Za-z\d_]*)*
+               }x;
+our $Storage   = qr{extern|static|asmlinkage};
+our $Sparse    = qr{
+                       __user|
+                       __kernel|
+                       __force|
+                       __iomem|
+                       __must_check|
+                       __init_refok|
+                       __kprobes|
+                       __ref|
+                       __rcu
+               }x;
+
+# Notes to $Attribute:
+# We need \b after 'init' otherwise 'initconst' will cause a false positive in a check
+our $Attribute = qr{
+                       const|
+                       __percpu|
+                       __nocast|
+                       __safe|
+                       __bitwise__|
+                       __packed__|
+                       __packed2__|
+                       __naked|
+                       __maybe_unused|
+                       __always_unused|
+                       __noreturn|
+                       __used|
+                       __cold|
+                       __noclone|
+                       __deprecated|
+                       __read_mostly|
+                       __kprobes|
+                       __(?:mem|cpu|dev|)(?:initdata|initconst|init\b)|
+                       ____cacheline_aligned|
+                       ____cacheline_aligned_in_smp|
+                       ____cacheline_internodealigned_in_smp|
+                       __weak
+                 }x;
+our $Modifier;
+our $Inline    = qr{inline|__always_inline|noinline};
+our $Member    = qr{->$Ident|\.$Ident|\[[^]]*\]};
+our $Lval      = qr{$Ident(?:$Member)*};
+
+our $Float_hex = qr{(?i)0x[0-9a-f]+p-?[0-9]+[fl]?};
+our $Float_dec = qr{(?i)(?:[0-9]+\.[0-9]*|[0-9]*\.[0-9]+)(?:e-?[0-9]+)?[fl]?};
+our $Float_int = qr{(?i)[0-9]+e-?[0-9]+[fl]?};
+our $Float     = qr{$Float_hex|$Float_dec|$Float_int};
+our $Constant  = qr{$Float|(?i)(?:0x[0-9a-f]+|[0-9]+)[ul]*};
+our $Assignment        = qr{\*\=|/=|%=|\+=|-=|<<=|>>=|&=|\^=|\|=|=};
+our $Compare    = qr{<=|>=|==|!=|<|>};
+our $Operators = qr{
+                       <=|>=|==|!=|
+                       =>|->|<<|>>|<|>|!|~|
+                       &&|\|\||,|\^|\+\+|--|&|\||\+|-|\*|\/|%
+                 }x;
+
+our $NonptrType;
+our $Type;
+our $Declare;
+
+our $NON_ASCII_UTF8    = qr{
+       [\xC2-\xDF][\x80-\xBF]               # non-overlong 2-byte
+       |  \xE0[\xA0-\xBF][\x80-\xBF]        # excluding overlongs
+       | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}  # straight 3-byte
+       |  \xED[\x80-\x9F][\x80-\xBF]        # excluding surrogates
+       |  \xF0[\x90-\xBF][\x80-\xBF]{2}     # planes 1-3
+       | [\xF1-\xF3][\x80-\xBF]{3}          # planes 4-15
+       |  \xF4[\x80-\x8F][\x80-\xBF]{2}     # plane 16
+}x;
+
+our $UTF8      = qr{
+       [\x09\x0A\x0D\x20-\x7E]              # ASCII
+       | $NON_ASCII_UTF8
+}x;
+
+our $typeTypedefs = qr{(?x:
+       (?:__)?(?:u|s|be|le)(?:8|16|32|64)|
+       atomic_t
+)};
+
+our $logFunctions = qr{(?x:
+       printk(?:_ratelimited|_once|)|
+       [a-z0-9]+_(?:printk|emerg|alert|crit|err|warning|warn|notice|info|debug|dbg|vdbg|devel|cont|WARN)(?:_ratelimited|_once|)|
+       WARN(?:_RATELIMIT|_ONCE|)|
+       panic|
+       debug|
+       printf|
+       MODULE_[A-Z_]+
+)};
+
+our $signature_tags = qr{(?xi:
+       Signed-off-by:|
+       Acked-by:|
+       Tested-by:|
+       Reviewed-by:|
+       Reported-by:|
+       To:|
+       Cc:
+)};
+
+our @typeList = (
+       qr{void},
+       qr{(?:unsigned\s+)?char},
+       qr{(?:unsigned\s+)?short},
+       qr{(?:unsigned\s+)?int},
+       qr{(?:unsigned\s+)?long},
+       qr{(?:unsigned\s+)?long\s+int},
+       qr{(?:unsigned\s+)?long\s+long},
+       qr{(?:unsigned\s+)?long\s+long\s+int},
+       qr{unsigned},
+       qr{float},
+       qr{double},
+       qr{bool},
+       qr{struct\s+$Ident},
+       qr{union\s+$Ident},
+       qr{enum\s+$Ident},
+       qr{${Ident}_t},
+       qr{${Ident}_handler},
+       qr{${Ident}_handler_fn},
+);
+our @modifierList = (
+       qr{fastcall},
+);
+
+our $allowed_asm_includes = qr{(?x:
+       irq|
+       memory
+)};
+# memory.h: ARM has a custom one
+
+sub build_types {
+       my $mods = "(?x:  \n" . join("|\n  ", @modifierList) . "\n)";
+       my $all = "(?x:  \n" . join("|\n  ", @typeList) . "\n)";
+       $Modifier       = qr{(?:$Attribute|$Sparse|$mods)};
+       $NonptrType     = qr{
+                       (?:$Modifier\s+|const\s+)*
+                       (?:
+                               (?:typeof|__typeof__)\s*\([^\)]*\)|
+                               (?:$typeTypedefs\b)|
+                               (?:${all}\b)
+                       )
+                       (?:\s+$Modifier|\s+const)*
+                 }x;
+       $Type   = qr{
+                       $NonptrType
+                       (?:(?:\s|\*|\[\])+\s*const|(?:\s|\*|\[\])+|(?:\s*\[\s*\])+)?
+                       (?:\s+$Inline|\s+$Modifier)*
+                 }x;
+       $Declare        = qr{(?:$Storage\s+)?$Type};
+}
+build_types();
+
+
+our $Typecast  = qr{\s*(\(\s*$NonptrType\s*\)){0,1}\s*};
+
+# Using $balanced_parens, $LvalOrFunc, or $FuncArg
+# requires at least perl version v5.10.0
+# Any use must be runtime checked with $^V
+
+our $balanced_parens = qr/(\((?:[^\(\)]++|(?-1))*\))/;
+our $LvalOrFunc        = qr{($Lval)\s*($balanced_parens{0,1})\s*};
+our $FuncArg = qr{$Typecast{0,1}($LvalOrFunc|$Constant)};
+
+sub deparenthesize {
+       my ($string) = @_;
+       return "" if (!defined($string));
+       $string =~ s@^\s*\(\s*@@g;
+       $string =~ s@\s*\)\s*$@@g;
+       $string =~ s@\s+@ @g;
+       return $string;
+}
+
+$chk_signoff = 0 if ($file);
+
+my @rawlines = ();
+my @lines = ();
+my $vname;
+for my $filename (@ARGV) {
+       my $FILE;
+       if ($file) {
+               open($FILE, '-|', "diff -u /dev/null $filename") ||
+                       die "$P: $filename: diff failed - $!\n";
+       } elsif ($filename eq '-') {
+               open($FILE, '<&STDIN');
+       } else {
+               open($FILE, '<', "$filename") ||
+                       die "$P: $filename: open failed - $!\n";
+       }
+       if ($filename eq '-') {
+               $vname = 'Your patch';
+       } else {
+               $vname = $filename;
+       }
+       while (<$FILE>) {
+               chomp;
+               push(@rawlines, $_);
+       }
+       close($FILE);
+       if (!process($filename)) {
+               $exit = 1;
+       }
+       @rawlines = ();
+       @lines = ();
+}
+
+exit($exit);
+
+sub top_of_kernel_tree {
+       my ($root) = @_;
+
+       my @tree_check = (
+               "COPYING", "CREDITS", "Kbuild", "Makefile",
+               "README", "Documentation", "arch", "include", "drivers",
+               "fs", "init", "ipc", "kernel", "lib", "scripts",
+       );
+
+       foreach my $check (@tree_check) {
+               if (! -e $root . '/' . $check) {
+                       return 0;
+               }
+       }
+       return 1;
+}
+
+sub parse_email {
+       my ($formatted_email) = @_;
+
+       my $name = "";
+       my $address = "";
+       my $comment = "";
+
+       if ($formatted_email =~ /^(.*)<(\S+\@\S+)>(.*)$/) {
+               $name = $1;
+               $address = $2;
+               $comment = $3 if defined $3;
+       } elsif ($formatted_email =~ /^\s*<(\S+\@\S+)>(.*)$/) {
+               $address = $1;
+               $comment = $2 if defined $2;
+       } elsif ($formatted_email =~ /(\S+\@\S+)(.*)$/) {
+               $address = $1;
+               $comment = $2 if defined $2;
+               $formatted_email =~ s/$address.*$//;
+               $name = $formatted_email;
+               $name =~ s/^\s+|\s+$//g;
+               $name =~ s/^\"|\"$//g;
+               # If there's a name left after stripping spaces and
+               # leading quotes, and the address doesn't have both
+               # leading and trailing angle brackets, the address
+               # is invalid. ie:
+               #   "joe smith joe@smith.com" bad
+               #   "joe smith <joe@smith.com" bad
+               if ($name ne "" && $address !~ /^<[^>]+>$/) {
+                       $name = "";
+                       $address = "";
+                       $comment = "";
+               }
+       }
+
+       $name =~ s/^\s+|\s+$//g;
+       $name =~ s/^\"|\"$//g;
+       $address =~ s/^\s+|\s+$//g;
+       $address =~ s/^\<|\>$//g;
+
+       if ($name =~ /[^\w \-]/i) { ##has "must quote" chars
+               $name =~ s/(?<!\\)"/\\"/g; ##escape quotes
+               $name = "\"$name\"";
+       }
+
+       return ($name, $address, $comment);
+}
+
+sub format_email {
+       my ($name, $address) = @_;
+
+       my $formatted_email;
+
+       $name =~ s/^\s+|\s+$//g;
+       $name =~ s/^\"|\"$//g;
+       $address =~ s/^\s+|\s+$//g;
+
+       if ($name =~ /[^\w \-]/i) { ##has "must quote" chars
+               $name =~ s/(?<!\\)"/\\"/g; ##escape quotes
+               $name = "\"$name\"";
+       }
+
+       if ("$name" eq "") {
+               $formatted_email = "$address";
+       } else {
+               $formatted_email = "$name <$address>";
+       }
+
+       return $formatted_email;
+}
+
+sub which_conf {
+       my ($conf) = @_;
+
+       foreach my $path (split(/:/, ".:$ENV{HOME}:.scripts")) {
+               if (-e "$path/$conf") {
+                       return "$path/$conf";
+               }
+       }
+
+       return "";
+}
+
+sub expand_tabs {
+       my ($str) = @_;
+
+       my $res = '';
+       my $n = 0;
+       for my $c (split(//, $str)) {
+               if ($c eq "\t") {
+                       $res .= ' ';
+                       $n++;
+                       for (; ($n % 8) != 0; $n++) {
+                               $res .= ' ';
+                       }
+                       next;
+               }
+               $res .= $c;
+               $n++;
+       }
+
+       return $res;
+}
+sub copy_spacing {
+       (my $res = shift) =~ tr/\t/ /c;
+       return $res;
+}
+
+sub line_stats {
+       my ($line) = @_;
+
+       # Drop the diff line leader and expand tabs
+       $line =~ s/^.//;
+       $line = expand_tabs($line);
+
+       # Pick the indent from the front of the line.
+       my ($white) = ($line =~ /^(\s*)/);
+
+       return (length($line), length($white));
+}
+
+my $sanitise_quote = '';
+
+sub sanitise_line_reset {
+       my ($in_comment) = @_;
+
+       if ($in_comment) {
+               $sanitise_quote = '*/';
+       } else {
+               $sanitise_quote = '';
+       }
+}
+sub sanitise_line {
+       my ($line) = @_;
+
+       my $res = '';
+       my $l = '';
+
+       my $qlen = 0;
+       my $off = 0;
+       my $c;
+
+       # Always copy over the diff marker.
+       $res = substr($line, 0, 1);
+
+       for ($off = 1; $off < length($line); $off++) {
+               $c = substr($line, $off, 1);
+
+               # Comments we are wacking completly including the begin
+               # and end, all to $;.
+               if ($sanitise_quote eq '' && substr($line, $off, 2) eq '/*') {
+                       $sanitise_quote = '*/';
+
+                       substr($res, $off, 2, "$;$;");
+                       $off++;
+                       next;
+               }
+               if ($sanitise_quote eq '*/' && substr($line, $off, 2) eq '*/') {
+                       $sanitise_quote = '';
+                       substr($res, $off, 2, "$;$;");
+                       $off++;
+                       next;
+               }
+               if ($sanitise_quote eq '' && substr($line, $off, 2) eq '//') {
+                       $sanitise_quote = '//';
+
+                       substr($res, $off, 2, $sanitise_quote);
+                       $off++;
+                       next;
+               }
+
+               # A \ in a string means ignore the next character.
+               if (($sanitise_quote eq "'" || $sanitise_quote eq '"') &&
+                   $c eq "\\") {
+                       substr($res, $off, 2, 'XX');
+                       $off++;
+                       next;
+               }
+               # Regular quotes.
+               if ($c eq "'" || $c eq '"') {
+                       if ($sanitise_quote eq '') {
+                               $sanitise_quote = $c;
+
+                               substr($res, $off, 1, $c);
+                               next;
+                       } elsif ($sanitise_quote eq $c) {
+                               $sanitise_quote = '';
+                       }
+               }
+
+               #print "c<$c> SQ<$sanitise_quote>\n";
+               if ($off != 0 && $sanitise_quote eq '*/' && $c ne "\t") {
+                       substr($res, $off, 1, $;);
+               } elsif ($off != 0 && $sanitise_quote eq '//' && $c ne "\t") {
+                       substr($res, $off, 1, $;);
+               } elsif ($off != 0 && $sanitise_quote && $c ne "\t") {
+                       substr($res, $off, 1, 'X');
+               } else {
+                       substr($res, $off, 1, $c);
+               }
+       }
+
+       if ($sanitise_quote eq '//') {
+               $sanitise_quote = '';
+       }
+
+       # The pathname on a #include may be surrounded by '<' and '>'.
+       if ($res =~ /^.\s*\#\s*include\s+\<(.*)\>/) {
+               my $clean = 'X' x length($1);
+               $res =~ s@\<.*\>@<$clean>@;
+
+       # The whole of a #error is a string.
+       } elsif ($res =~ /^.\s*\#\s*(?:error|warning)\s+(.*)\b/) {
+               my $clean = 'X' x length($1);
+               $res =~ s@(\#\s*(?:error|warning)\s+).*@$1$clean@;
+       }
+
+       return $res;
+}
+
+sub ctx_statement_block {
+       my ($linenr, $remain, $off) = @_;
+       my $line = $linenr - 1;
+       my $blk = '';
+       my $soff = $off;
+       my $coff = $off - 1;
+       my $coff_set = 0;
+
+       my $loff = 0;
+
+       my $type = '';
+       my $level = 0;
+       my @stack = ();
+       my $p;
+       my $c;
+       my $len = 0;
+
+       my $remainder;
+       while (1) {
+               @stack = (['', 0]) if ($#stack == -1);
+
+               #warn "CSB: blk<$blk> remain<$remain>\n";
+               # If we are about to drop off the end, pull in more
+               # context.
+               if ($off >= $len) {
+                       for (; $remain > 0; $line++) {
+                               last if (!defined $lines[$line]);
+                               next if ($lines[$line] =~ /^-/);
+                               $remain--;
+                               $loff = $len;
+                               $blk .= $lines[$line] . "\n";
+                               $len = length($blk);
+                               $line++;
+                               last;
+                       }
+                       # Bail if there is no further context.
+                       #warn "CSB: blk<$blk> off<$off> len<$len>\n";
+                       if ($off >= $len) {
+                               last;
+                       }
+                       if ($level == 0 && substr($blk, $off) =~ /^.\s*#\s*define/) {
+                               $level++;
+                               $type = '#';
+                       }
+               }
+               $p = $c;
+               $c = substr($blk, $off, 1);
+               $remainder = substr($blk, $off);
+
+               #warn "CSB: c<$c> type<$type> level<$level> remainder<$remainder> coff_set<$coff_set>\n";
+
+               # Handle nested #if/#else.
+               if ($remainder =~ /^#\s*(?:ifndef|ifdef|if)\s/) {
+                       push(@stack, [ $type, $level ]);
+               } elsif ($remainder =~ /^#\s*(?:else|elif)\b/) {
+                       ($type, $level) = @{$stack[$#stack - 1]};
+               } elsif ($remainder =~ /^#\s*endif\b/) {
+                       ($type, $level) = @{pop(@stack)};
+               }
+
+               # Statement ends at the ';' or a close '}' at the
+               # outermost level.
+               if ($level == 0 && $c eq ';') {
+                       last;
+               }
+
+               # An else is really a conditional as long as its not else if
+               if ($level == 0 && $coff_set == 0 &&
+                               (!defined($p) || $p =~ /(?:\s|\}|\+)/) &&
+                               $remainder =~ /^(else)(?:\s|{)/ &&
+                               $remainder !~ /^else\s+if\b/) {
+                       $coff = $off + length($1) - 1;
+                       $coff_set = 1;
+                       #warn "CSB: mark coff<$coff> soff<$soff> 1<$1>\n";
+                       #warn "[" . substr($blk, $soff, $coff - $soff + 1) . "]\n";
+               }
+
+               if (($type eq '' || $type eq '(') && $c eq '(') {
+                       $level++;
+                       $type = '(';
+               }
+               if ($type eq '(' && $c eq ')') {
+                       $level--;
+                       $type = ($level != 0)? '(' : '';
+
+                       if ($level == 0 && $coff < $soff) {
+                               $coff = $off;
+                               $coff_set = 1;
+                               #warn "CSB: mark coff<$coff>\n";
+                       }
+               }
+               if (($type eq '' || $type eq '{') && $c eq '{') {
+                       $level++;
+                       $type = '{';
+               }
+               if ($type eq '{' && $c eq '}') {
+                       $level--;
+                       $type = ($level != 0)? '{' : '';
+
+                       if ($level == 0) {
+                               if (substr($blk, $off + 1, 1) eq ';') {
+                                       $off++;
+                               }
+                               last;
+                       }
+               }
+               # Preprocessor commands end at the newline unless escaped.
+               if ($type eq '#' && $c eq "\n" && $p ne "\\") {
+                       $level--;
+                       $type = '';
+                       $off++;
+                       last;
+               }
+               $off++;
+       }
+       # We are truly at the end, so shuffle to the next line.
+       if ($off == $len) {
+               $loff = $len + 1;
+               $line++;
+               $remain--;
+       }
+
+       my $statement = substr($blk, $soff, $off - $soff + 1);
+       my $condition = substr($blk, $soff, $coff - $soff + 1);
+
+       #warn "STATEMENT<$statement>\n";
+       #warn "CONDITION<$condition>\n";
+
+       #print "coff<$coff> soff<$off> loff<$loff>\n";
+
+       return ($statement, $condition,
+                       $line, $remain + 1, $off - $loff + 1, $level);
+}
+
+sub statement_lines {
+       my ($stmt) = @_;
+
+       # Strip the diff line prefixes and rip blank lines at start and end.
+       $stmt =~ s/(^|\n)./$1/g;
+       $stmt =~ s/^\s*//;
+       $stmt =~ s/\s*$//;
+
+       my @stmt_lines = ($stmt =~ /\n/g);
+
+       return $#stmt_lines + 2;
+}
+
+sub statement_rawlines {
+       my ($stmt) = @_;
+
+       my @stmt_lines = ($stmt =~ /\n/g);
+
+       return $#stmt_lines + 2;
+}
+
+sub statement_block_size {
+       my ($stmt) = @_;
+
+       $stmt =~ s/(^|\n)./$1/g;
+       $stmt =~ s/^\s*{//;
+       $stmt =~ s/}\s*$//;
+       $stmt =~ s/^\s*//;
+       $stmt =~ s/\s*$//;
+
+       my @stmt_lines = ($stmt =~ /\n/g);
+       my @stmt_statements = ($stmt =~ /;/g);
+
+       my $stmt_lines = $#stmt_lines + 2;
+       my $stmt_statements = $#stmt_statements + 1;
+
+       if ($stmt_lines > $stmt_statements) {
+               return $stmt_lines;
+       } else {
+               return $stmt_statements;
+       }
+}
+
+sub ctx_statement_full {
+       my ($linenr, $remain, $off) = @_;
+       my ($statement, $condition, $level);
+
+       my (@chunks);
+
+       # Grab the first conditional/block pair.
+       ($statement, $condition, $linenr, $remain, $off, $level) =
+                               ctx_statement_block($linenr, $remain, $off);
+       #print "F: c<$condition> s<$statement> remain<$remain>\n";
+       push(@chunks, [ $condition, $statement ]);
+       if (!($remain > 0 && $condition =~ /^\s*(?:\n[+-])?\s*(?:if|else|do)\b/s)) {
+               return ($level, $linenr, @chunks);
+       }
+
+       # Pull in the following conditional/block pairs and see if they
+       # could continue the statement.
+       for (;;) {
+               ($statement, $condition, $linenr, $remain, $off, $level) =
+                               ctx_statement_block($linenr, $remain, $off);
+               #print "C: c<$condition> s<$statement> remain<$remain>\n";
+               last if (!($remain > 0 && $condition =~ /^(?:\s*\n[+-])*\s*(?:else|do)\b/s));
+               #print "C: push\n";
+               push(@chunks, [ $condition, $statement ]);
+       }
+
+       return ($level, $linenr, @chunks);
+}
+
+sub ctx_block_get {
+       my ($linenr, $remain, $outer, $open, $close, $off) = @_;
+       my $line;
+       my $start = $linenr - 1;
+       my $blk = '';
+       my @o;
+       my @c;
+       my @res = ();
+
+       my $level = 0;
+       my @stack = ($level);
+       for ($line = $start; $remain > 0; $line++) {
+               next if ($rawlines[$line] =~ /^-/);
+               $remain--;
+
+               $blk .= $rawlines[$line];
+
+               # Handle nested #if/#else.
+               if ($lines[$line] =~ /^.\s*#\s*(?:ifndef|ifdef|if)\s/) {
+                       push(@stack, $level);
+               } elsif ($lines[$line] =~ /^.\s*#\s*(?:else|elif)\b/) {
+                       $level = $stack[$#stack - 1];
+               } elsif ($lines[$line] =~ /^.\s*#\s*endif\b/) {
+                       $level = pop(@stack);
+               }
+
+               foreach my $c (split(//, $lines[$line])) {
+                       ##print "C<$c>L<$level><$open$close>O<$off>\n";
+                       if ($off > 0) {
+                               $off--;
+                               next;
+                       }
+
+                       if ($c eq $close && $level > 0) {
+                               $level--;
+                               last if ($level == 0);
+                       } elsif ($c eq $open) {
+                               $level++;
+                       }
+               }
+
+               if (!$outer || $level <= 1) {
+                       push(@res, $rawlines[$line]);
+               }
+
+               last if ($level == 0);
+       }
+
+       return ($level, @res);
+}
+sub ctx_block_outer {
+       my ($linenr, $remain) = @_;
+
+       my ($level, @r) = ctx_block_get($linenr, $remain, 1, '{', '}', 0);
+       return @r;
+}
+sub ctx_block {
+       my ($linenr, $remain) = @_;
+
+       my ($level, @r) = ctx_block_get($linenr, $remain, 0, '{', '}', 0);
+       return @r;
+}
+sub ctx_statement {
+       my ($linenr, $remain, $off) = @_;
+
+       my ($level, @r) = ctx_block_get($linenr, $remain, 0, '(', ')', $off);
+       return @r;
+}
+sub ctx_block_level {
+       my ($linenr, $remain) = @_;
+
+       return ctx_block_get($linenr, $remain, 0, '{', '}', 0);
+}
+sub ctx_statement_level {
+       my ($linenr, $remain, $off) = @_;
+
+       return ctx_block_get($linenr, $remain, 0, '(', ')', $off);
+}
+
+sub ctx_locate_comment {
+       my ($first_line, $end_line) = @_;
+
+       # Catch a comment on the end of the line itself.
+       my ($current_comment) = ($rawlines[$end_line - 1] =~ m@.*(/\*.*\*/)\s*(?:\\\s*)?$@);
+       return $current_comment if (defined $current_comment);
+
+       # Look through the context and try and figure out if there is a
+       # comment.
+       my $in_comment = 0;
+       $current_comment = '';
+       for (my $linenr = $first_line; $linenr < $end_line; $linenr++) {
+               my $line = $rawlines[$linenr - 1];
+               #warn "           $line\n";
+               if ($linenr == $first_line and $line =~ m@^.\s*\*@) {
+                       $in_comment = 1;
+               }
+               if ($line =~ m@/\*@) {
+                       $in_comment = 1;
+               }
+               if (!$in_comment && $current_comment ne '') {
+                       $current_comment = '';
+               }
+               $current_comment .= $line . "\n" if ($in_comment);
+               if ($line =~ m@\*/@) {
+                       $in_comment = 0;
+               }
+       }
+
+       chomp($current_comment);
+       return($current_comment);
+}
+sub ctx_has_comment {
+       my ($first_line, $end_line) = @_;
+       my $cmt = ctx_locate_comment($first_line, $end_line);
+
+       ##print "LINE: $rawlines[$end_line - 1 ]\n";
+       ##print "CMMT: $cmt\n";
+
+       return ($cmt ne '');
+}
+
+sub raw_line {
+       my ($linenr, $cnt) = @_;
+
+       my $offset = $linenr - 1;
+       $cnt++;
+
+       my $line;
+       while ($cnt) {
+               $line = $rawlines[$offset++];
+               next if (defined($line) && $line =~ /^-/);
+               $cnt--;
+       }
+
+       return $line;
+}
+
+sub cat_vet {
+       my ($vet) = @_;
+       my ($res, $coded);
+
+       $res = '';
+       while ($vet =~ /([^[:cntrl:]]*)([[:cntrl:]]|$)/g) {
+               $res .= $1;
+               if ($2 ne '') {
+                       $coded = sprintf("^%c", unpack('C', $2) + 64);
+                       $res .= $coded;
+               }
+       }
+       $res =~ s/$/\$/;
+
+       return $res;
+}
+
+my $av_preprocessor = 0;
+my $av_pending;
+my @av_paren_type;
+my $av_pend_colon;
+
+sub annotate_reset {
+       $av_preprocessor = 0;
+       $av_pending = '_';
+       @av_paren_type = ('E');
+       $av_pend_colon = 'O';
+}
+
+sub annotate_values {
+       my ($stream, $type) = @_;
+
+       my $res;
+       my $var = '_' x length($stream);
+       my $cur = $stream;
+
+       print "$stream\n" if ($dbg_values > 1);
+
+       while (length($cur)) {
+               @av_paren_type = ('E') if ($#av_paren_type < 0);
+               print " <" . join('', @av_paren_type) .
+                               "> <$type> <$av_pending>" if ($dbg_values > 1);
+               if ($cur =~ /^(\s+)/o) {
+                       print "WS($1)\n" if ($dbg_values > 1);
+                       if ($1 =~ /\n/ && $av_preprocessor) {
+                               $type = pop(@av_paren_type);
+                               $av_preprocessor = 0;
+                       }
+
+               } elsif ($cur =~ /^(\(\s*$Type\s*)\)/ && $av_pending eq '_') {
+                       print "CAST($1)\n" if ($dbg_values > 1);
+                       push(@av_paren_type, $type);
+                       $type = 'c';
+
+               } elsif ($cur =~ /^($Type)\s*(?:$Ident|,|\)|\(|\s*$)/) {
+                       print "DECLARE($1)\n" if ($dbg_values > 1);
+                       $type = 'T';
+
+               } elsif ($cur =~ /^($Modifier)\s*/) {
+                       print "MODIFIER($1)\n" if ($dbg_values > 1);
+                       $type = 'T';
+
+               } elsif ($cur =~ /^(\#\s*define\s*$Ident)(\(?)/o) {
+                       print "DEFINE($1,$2)\n" if ($dbg_values > 1);
+                       $av_preprocessor = 1;
+                       push(@av_paren_type, $type);
+                       if ($2 ne '') {
+                               $av_pending = 'N';
+                       }
+                       $type = 'E';
+
+               } elsif ($cur =~ /^(\#\s*(?:undef\s*$Ident|include\b))/o) {
+                       print "UNDEF($1)\n" if ($dbg_values > 1);
+                       $av_preprocessor = 1;
+                       push(@av_paren_type, $type);
+
+               } elsif ($cur =~ /^(\#\s*(?:ifdef|ifndef|if))/o) {
+                       print "PRE_START($1)\n" if ($dbg_values > 1);
+                       $av_preprocessor = 1;
+
+                       push(@av_paren_type, $type);
+                       push(@av_paren_type, $type);
+                       $type = 'E';
+
+               } elsif ($cur =~ /^(\#\s*(?:else|elif))/o) {
+                       print "PRE_RESTART($1)\n" if ($dbg_values > 1);
+                       $av_preprocessor = 1;
+
+                       push(@av_paren_type, $av_paren_type[$#av_paren_type]);
+
+                       $type = 'E';
+
+               } elsif ($cur =~ /^(\#\s*(?:endif))/o) {
+                       print "PRE_END($1)\n" if ($dbg_values > 1);
+
+                       $av_preprocessor = 1;
+
+                       # Assume all arms of the conditional end as this
+                       # one does, and continue as if the #endif was not here.
+                       pop(@av_paren_type);
+                       push(@av_paren_type, $type);
+                       $type = 'E';
+
+               } elsif ($cur =~ /^(\\\n)/o) {
+                       print "PRECONT($1)\n" if ($dbg_values > 1);
+
+               } elsif ($cur =~ /^(__attribute__)\s*\(?/o) {
+                       print "ATTR($1)\n" if ($dbg_values > 1);
+                       $av_pending = $type;
+                       $type = 'N';
+
+               } elsif ($cur =~ /^(sizeof)\s*(\()?/o) {
+                       print "SIZEOF($1)\n" if ($dbg_values > 1);
+                       if (defined $2) {
+                               $av_pending = 'V';
+                       }
+                       $type = 'N';
+
+               } elsif ($cur =~ /^(if|while|for)\b/o) {
+                       print "COND($1)\n" if ($dbg_values > 1);
+                       $av_pending = 'E';
+                       $type = 'N';
+
+               } elsif ($cur =~/^(case)/o) {
+                       print "CASE($1)\n" if ($dbg_values > 1);
+                       $av_pend_colon = 'C';
+                       $type = 'N';
+
+               } elsif ($cur =~/^(return|else|goto|typeof|__typeof__)\b/o) {
+                       print "KEYWORD($1)\n" if ($dbg_values > 1);
+                       $type = 'N';
+
+               } elsif ($cur =~ /^(\()/o) {
+                       print "PAREN('$1')\n" if ($dbg_values > 1);
+                       push(@av_paren_type, $av_pending);
+                       $av_pending = '_';
+                       $type = 'N';
+
+               } elsif ($cur =~ /^(\))/o) {
+                       my $new_type = pop(@av_paren_type);
+                       if ($new_type ne '_') {
+                               $type = $new_type;
+                               print "PAREN('$1') -> $type\n"
+                                                       if ($dbg_values > 1);
+                       } else {
+                               print "PAREN('$1')\n" if ($dbg_values > 1);
+                       }
+
+               } elsif ($cur =~ /^($Ident)\s*\(/o) {
+                       print "FUNC($1)\n" if ($dbg_values > 1);
+                       $type = 'V';
+                       $av_pending = 'V';
+
+               } elsif ($cur =~ /^($Ident\s*):(?:\s*\d+\s*(,|=|;))?/) {
+                       if (defined $2 && $type eq 'C' || $type eq 'T') {
+                               $av_pend_colon = 'B';
+                       } elsif ($type eq 'E') {
+                               $av_pend_colon = 'L';
+                       }
+                       print "IDENT_COLON($1,$type>$av_pend_colon)\n" if ($dbg_values > 1);
+                       $type = 'V';
+
+               } elsif ($cur =~ /^($Ident|$Constant)/o) {
+                       print "IDENT($1)\n" if ($dbg_values > 1);
+                       $type = 'V';
+
+               } elsif ($cur =~ /^($Assignment)/o) {
+                       print "ASSIGN($1)\n" if ($dbg_values > 1);
+                       $type = 'N';
+
+               } elsif ($cur =~/^(;|{|})/) {
+                       print "END($1)\n" if ($dbg_values > 1);
+                       $type = 'E';
+                       $av_pend_colon = 'O';
+
+               } elsif ($cur =~/^(,)/) {
+                       print "COMMA($1)\n" if ($dbg_values > 1);
+                       $type = 'C';
+
+               } elsif ($cur =~ /^(\?)/o) {
+                       print "QUESTION($1)\n" if ($dbg_values > 1);
+                       $type = 'N';
+
+               } elsif ($cur =~ /^(:)/o) {
+                       print "COLON($1,$av_pend_colon)\n" if ($dbg_values > 1);
+
+                       substr($var, length($res), 1, $av_pend_colon);
+                       if ($av_pend_colon eq 'C' || $av_pend_colon eq 'L') {
+                               $type = 'E';
+                       } else {
+                               $type = 'N';
+                       }
+                       $av_pend_colon = 'O';
+
+               } elsif ($cur =~ /^(\[)/o) {
+                       print "CLOSE($1)\n" if ($dbg_values > 1);
+                       $type = 'N';
+
+               } elsif ($cur =~ /^(-(?![->])|\+(?!\+)|\*|\&\&|\&)/o) {
+                       my $variant;
+
+                       print "OPV($1)\n" if ($dbg_values > 1);
+                       if ($type eq 'V') {
+                               $variant = 'B';
+                       } else {
+                               $variant = 'U';
+                       }
+
+                       substr($var, length($res), 1, $variant);
+                       $type = 'N';
+
+               } elsif ($cur =~ /^($Operators)/o) {
+                       print "OP($1)\n" if ($dbg_values > 1);
+                       if ($1 ne '++' && $1 ne '--') {
+                               $type = 'N';
+                       }
+
+               } elsif ($cur =~ /(^.)/o) {
+                       print "C($1)\n" if ($dbg_values > 1);
+               }
+               if (defined $1) {
+                       $cur = substr($cur, length($1));
+                       $res .= $type x length($1);
+               }
+       }
+
+       return ($res, $var);
+}
+
+sub possible {
+       my ($possible, $line) = @_;
+       my $notPermitted = qr{(?:
+               ^(?:
+                       $Modifier|
+                       $Storage|
+                       $Type|
+                       DEFINE_\S+
+               )$|
+               ^(?:
+                       goto|
+                       return|
+                       case|
+                       else|
+                       asm|__asm__|
+                       do|
+                       \#|
+                       \#\#|
+               )(?:\s|$)|
+               ^(?:typedef|struct|enum)\b
+           )}x;
+       warn "CHECK<$possible> ($line)\n" if ($dbg_possible > 2);
+       if ($possible !~ $notPermitted) {
+               # Check for modifiers.
+               $possible =~ s/\s*$Storage\s*//g;
+               $possible =~ s/\s*$Sparse\s*//g;
+               if ($possible =~ /^\s*$/) {
+
+               } elsif ($possible =~ /\s/) {
+                       $possible =~ s/\s*$Type\s*//g;
+                       for my $modifier (split(' ', $possible)) {
+                               if ($modifier !~ $notPermitted) {
+                                       warn "MODIFIER: $modifier ($possible) ($line)\n" if ($dbg_possible);
+                                       push(@modifierList, $modifier);
+                               }
+                       }
+
+               } else {
+                       warn "POSSIBLE: $possible ($line)\n" if ($dbg_possible);
+                       push(@typeList, $possible);
+               }
+               build_types();
+       } else {
+               warn "NOTPOSS: $possible ($line)\n" if ($dbg_possible > 1);
+       }
+}
+
+my $prefix = '';
+
+sub show_type {
+       return !defined $ignore_type{$_[0]};
+}
+
+sub report {
+       if (!show_type($_[1]) ||
+           (defined $tst_only && $_[2] !~ /\Q$tst_only\E/)) {
+               return 0;
+       }
+       my $line;
+       if ($show_types) {
+               $line = "$prefix$_[0]:$_[1]: $_[2]\n";
+       } else {
+               $line = "$prefix$_[0]: $_[2]\n";
+       }
+       $line = (split('\n', $line))[0] . "\n" if ($terse);
+
+       push(our @report, $line);
+
+       return 1;
+}
+sub report_dump {
+       our @report;
+}
+
+sub ERROR {
+       if (report("ERROR", $_[0], $_[1])) {
+               our $clean = 0;
+               our $cnt_error++;
+       }
+}
+sub WARN {
+       if (report("WARNING", $_[0], $_[1])) {
+               our $clean = 0;
+               our $cnt_warn++;
+       }
+}
+sub CHK {
+       if ($check && report("CHECK", $_[0], $_[1])) {
+               our $clean = 0;
+               our $cnt_chk++;
+       }
+}
+
+sub check_absolute_file {
+       my ($absolute, $herecurr) = @_;
+       my $file = $absolute;
+
+       ##print "absolute<$absolute>\n";
+
+       # See if any suffix of this path is a path within the tree.
+       while ($file =~ s@^[^/]*/@@) {
+               if (-f "$root/$file") {
+                       ##print "file<$file>\n";
+                       last;
+               }
+       }
+       if (! -f _)  {
+               return 0;
+       }
+
+       # It is, so see if the prefix is acceptable.
+       my $prefix = $absolute;
+       substr($prefix, -length($file)) = '';
+
+       ##print "prefix<$prefix>\n";
+       if ($prefix ne ".../") {
+               WARN("USE_RELATIVE_PATH",
+                    "use relative pathname instead of absolute in changelog text\n" . $herecurr);
+       }
+}
+
+sub pos_last_openparen {
+       my ($line) = @_;
+
+       my $pos = 0;
+
+       my $opens = $line =~ tr/\(/\(/;
+       my $closes = $line =~ tr/\)/\)/;
+
+       my $last_openparen = 0;
+
+       if (($opens == 0) || ($closes >= $opens)) {
+               return -1;
+       }
+
+       my $len = length($line);
+
+       for ($pos = 0; $pos < $len; $pos++) {
+               my $string = substr($line, $pos);
+               if ($string =~ /^($FuncArg|$balanced_parens)/) {
+                       $pos += length($1) - 1;
+               } elsif (substr($line, $pos, 1) eq '(') {
+                       $last_openparen = $pos;
+               } elsif (index($string, '(') == -1) {
+                       last;
+               }
+       }
+
+       return $last_openparen + 1;
+}
+
+sub process {
+       my $filename = shift;
+
+       my $linenr=0;
+       my $prevline="";
+       my $prevrawline="";
+       my $stashline="";
+       my $stashrawline="";
+
+       my $length;
+       my $indent;
+       my $previndent=0;
+       my $stashindent=0;
+
+       our $clean = 1;
+       my $signoff = 0;
+       my $is_patch = 0;
+
+       my $in_header_lines = 1;
+       my $in_commit_log = 0;          #Scanning lines before patch
+
+       my $non_utf8_charset = 0;
+
+       our @report = ();
+       our $cnt_lines = 0;
+       our $cnt_error = 0;
+       our $cnt_warn = 0;
+       our $cnt_chk = 0;
+
+       # Trace the real file/line as we go.
+       my $realfile = '';
+       my $realline = 0;
+       my $realcnt = 0;
+       my $here = '';
+       my $in_comment = 0;
+       my $comment_edge = 0;
+       my $first_line = 0;
+       my $p1_prefix = '';
+
+       my $prev_values = 'E';
+
+       # suppression flags
+       my %suppress_ifbraces;
+       my %suppress_whiletrailers;
+       my %suppress_export;
+       my $suppress_statement = 0;
+
+       my %camelcase = ();
+
+       # Pre-scan the patch sanitizing the lines.
+       # Pre-scan the patch looking for any __setup documentation.
+       #
+       my @setup_docs = ();
+       my $setup_docs = 0;
+
+       sanitise_line_reset();
+       my $line;
+       foreach my $rawline (@rawlines) {
+               $linenr++;
+               $line = $rawline;
+
+               if ($rawline=~/^\+\+\+\s+(\S+)/) {
+                       $setup_docs = 0;
+                       if ($1 =~ m@Documentation/kernel-parameters.txt$@) {
+                               $setup_docs = 1;
+                       }
+                       #next;
+               }
+               if ($rawline=~/^\@\@ -\d+(?:,\d+)? \+(\d+)(,(\d+))? \@\@/) {
+                       $realline=$1-1;
+                       if (defined $2) {
+                               $realcnt=$3+1;
+                       } else {
+                               $realcnt=1+1;
+                       }
+                       $in_comment = 0;
+
+                       # Guestimate if this is a continuing comment.  Run
+                       # the context looking for a comment "edge".  If this
+                       # edge is a close comment then we must be in a comment
+                       # at context start.
+                       my $edge;
+                       my $cnt = $realcnt;
+                       for (my $ln = $linenr + 1; $cnt > 0; $ln++) {
+                               next if (defined $rawlines[$ln - 1] &&
+                                        $rawlines[$ln - 1] =~ /^-/);
+                               $cnt--;
+                               #print "RAW<$rawlines[$ln - 1]>\n";
+                               last if (!defined $rawlines[$ln - 1]);
+                               if ($rawlines[$ln - 1] =~ m@(/\*|\*/)@ &&
+                                   $rawlines[$ln - 1] !~ m@"[^"]*(?:/\*|\*/)[^"]*"@) {
+                                       ($edge) = $1;
+                                       last;
+                               }
+                       }
+                       if (defined $edge && $edge eq '*/') {
+                               $in_comment = 1;
+                       }
+
+                       # Guestimate if this is a continuing comment.  If this
+                       # is the start of a diff block and this line starts
+                       # ' *' then it is very likely a comment.
+                       if (!defined $edge &&
+                           $rawlines[$linenr] =~ m@^.\s*(?:\*\*+| \*)(?:\s|$)@)
+                       {
+                               $in_comment = 1;
+                       }
+
+                       ##print "COMMENT:$in_comment edge<$edge> $rawline\n";
+                       sanitise_line_reset($in_comment);
+
+               } elsif ($realcnt && $rawline =~ /^(?:\+| |$)/) {
+                       # Standardise the strings and chars within the input to
+                       # simplify matching -- only bother with positive lines.
+                       $line = sanitise_line($rawline);
+               }
+               push(@lines, $line);
+
+               if ($realcnt > 1) {
+                       $realcnt-- if ($line =~ /^(?:\+| |$)/);
+               } else {
+                       $realcnt = 0;
+               }
+
+               #print "==>$rawline\n";
+               #print "-->$line\n";
+
+               if ($setup_docs && $line =~ /^\+/) {
+                       push(@setup_docs, $line);
+               }
+       }
+
+       $prefix = '';
+
+       $realcnt = 0;
+       $linenr = 0;
+       foreach my $line (@lines) {
+               $linenr++;
+
+               my $rawline = $rawlines[$linenr - 1];
+
+#extract the line range in the file after the patch is applied
+               if ($line=~/^\@\@ -\d+(?:,\d+)? \+(\d+)(,(\d+))? \@\@/) {
+                       $is_patch = 1;
+                       $first_line = $linenr + 1;
+                       $realline=$1-1;
+                       if (defined $2) {
+                               $realcnt=$3+1;
+                       } else {
+                               $realcnt=1+1;
+                       }
+                       annotate_reset();
+                       $prev_values = 'E';
+
+                       %suppress_ifbraces = ();
+                       %suppress_whiletrailers = ();
+                       %suppress_export = ();
+                       $suppress_statement = 0;
+                       next;
+
+# track the line number as we move through the hunk, note that
+# new versions of GNU diff omit the leading space on completely
+# blank context lines so we need to count that too.
+               } elsif ($line =~ /^( |\+|$)/) {
+                       $realline++;
+                       $realcnt-- if ($realcnt != 0);
+
+                       # Measure the line length and indent.
+                       ($length, $indent) = line_stats($rawline);
+
+                       # Track the previous line.
+                       ($prevline, $stashline) = ($stashline, $line);
+                       ($previndent, $stashindent) = ($stashindent, $indent);
+                       ($prevrawline, $stashrawline) = ($stashrawline, $rawline);
+
+                       #warn "line<$line>\n";
+
+               } elsif ($realcnt == 1) {
+                       $realcnt--;
+               }
+
+               my $hunk_line = ($realcnt != 0);
+
+#make up the handle for any error we report on this line
+               $prefix = "$filename:$realline: " if ($emacs && $file);
+               $prefix = "$filename:$linenr: " if ($emacs && !$file);
+
+               $here = "#$linenr: " if (!$file);
+               $here = "#$realline: " if ($file);
+
+               # extract the filename as it passes
+               if ($line =~ /^diff --git.*?(\S+)$/) {
+                       $realfile = $1;
+                       $realfile =~ s@^([^/]*)/@@;
+                       $in_commit_log = 0;
+               } elsif ($line =~ /^\+\+\+\s+(\S+)/) {
+                       $realfile = $1;
+                       $realfile =~ s@^([^/]*)/@@;
+                       $in_commit_log = 0;
+
+                       $p1_prefix = $1;
+                       if (!$file && $tree && $p1_prefix ne '' &&
+                           -e "$root/$p1_prefix") {
+                               WARN("PATCH_PREFIX",
+                                    "patch prefix '$p1_prefix' exists, appears to be a -p0 patch\n");
+                       }
+
+                       if ($realfile =~ m@^include/asm/@) {
+                               ERROR("MODIFIED_INCLUDE_ASM",
+                                     "do not modify files in include/asm, change architecture specific files in include/asm-<architecture>\n" . "$here$rawline\n");
+                       }
+                       next;
+               }
+
+               $here .= "FILE: $realfile:$realline:" if ($realcnt != 0);
+
+               my $hereline = "$here\n$rawline\n";
+               my $herecurr = "$here\n$rawline\n";
+               my $hereprev = "$here\n$prevrawline\n$rawline\n";
+
+               $cnt_lines++ if ($realcnt != 0);
+
+# Check for incorrect file permissions
+               if ($line =~ /^new (file )?mode.*[7531]\d{0,2}$/) {
+                       my $permhere = $here . "FILE: $realfile\n";
+                       if ($realfile =~ /(Makefile|Kconfig|\.c|\.h|\.S|\.tmpl)$/) {
+                               ERROR("EXECUTE_PERMISSIONS",
+                                     "do not set execute permissions for source files\n" . $permhere);
+                       }
+               }
+
+# Check the patch for a signoff:
+               if ($line =~ /^\s*signed-off-by:/i) {
+                       $signoff++;
+                       $in_commit_log = 0;
+               }
+
+# Check signature styles
+               if (!$in_header_lines &&
+                   $line =~ /^(\s*)([a-z0-9_-]+by:|$signature_tags)(\s*)(.*)/i) {
+                       my $space_before = $1;
+                       my $sign_off = $2;
+                       my $space_after = $3;
+                       my $email = $4;
+                       my $ucfirst_sign_off = ucfirst(lc($sign_off));
+
+                       if ($sign_off !~ /$signature_tags/) {
+                               WARN("BAD_SIGN_OFF",
+                                    "Non-standard signature: $sign_off\n" . $herecurr);
+                       }
+                       if (defined $space_before && $space_before ne "") {
+                               WARN("BAD_SIGN_OFF",
+                                    "Do not use whitespace before $ucfirst_sign_off\n" . $herecurr);
+                       }
+                       if ($sign_off =~ /-by:$/i && $sign_off ne $ucfirst_sign_off) {
+                               WARN("BAD_SIGN_OFF",
+                                    "'$ucfirst_sign_off' is the preferred signature form\n" . $herecurr);
+                       }
+                       if (!defined $space_after || $space_after ne " ") {
+                               WARN("BAD_SIGN_OFF",
+                                    "Use a single space after $ucfirst_sign_off\n" . $herecurr);
+                       }
+
+                       my ($email_name, $email_address, $comment) = parse_email($email);
+                       my $suggested_email = format_email(($email_name, $email_address));
+                       if ($suggested_email eq "") {
+                               ERROR("BAD_SIGN_OFF",
+                                     "Unrecognized email address: '$email'\n" . $herecurr);
+                       } else {
+                               my $dequoted = $suggested_email;
+                               $dequoted =~ s/^"//;
+                               $dequoted =~ s/" </ </;
+                               # Don't force email to have quotes
+                               # Allow just an angle bracketed address
+                               if ("$dequoted$comment" ne $email &&
+                                   "<$email_address>$comment" ne $email &&
+                                   "$suggested_email$comment" ne $email) {
+                                       WARN("BAD_SIGN_OFF",
+                                            "email address '$email' might be better as '$suggested_email$comment'\n" . $herecurr);
+                               }
+                       }
+               }
+
+# Check for wrappage within a valid hunk of the file
+               if ($realcnt != 0 && $line !~ m{^(?:\+|-| |\\ No newline|$)}) {
+                       ERROR("CORRUPTED_PATCH",
+                             "patch seems to be corrupt (line wrapped?)\n" .
+                               $herecurr) if (!$emitted_corrupt++);
+               }
+
+# Check for absolute kernel paths.
+               if ($tree) {
+                       while ($line =~ m{(?:^|\s)(/\S*)}g) {
+                               my $file = $1;
+
+                               if ($file =~ m{^(.*?)(?::\d+)+:?$} &&
+                                   check_absolute_file($1, $herecurr)) {
+                                       #
+                               } else {
+                                       check_absolute_file($file, $herecurr);
+                               }
+                       }
+               }
+
+# UTF-8 regex found at http://www.w3.org/International/questions/qa-forms-utf-8.en.php
+               if (($realfile =~ /^$/ || $line =~ /^\+/) &&
+                   $rawline !~ m/^$UTF8*$/) {
+                       my ($utf8_prefix) = ($rawline =~ /^($UTF8*)/);
+
+                       my $blank = copy_spacing($rawline);
+                       my $ptr = substr($blank, 0, length($utf8_prefix)) . "^";
+                       my $hereptr = "$hereline$ptr\n";
+
+                       CHK("INVALID_UTF8",
+                           "Invalid UTF-8, patch and commit message should be encoded in UTF-8\n" . $hereptr);
+               }
+
+# Check if it's the start of a commit log
+# (not a header line and we haven't seen the patch filename)
+               if ($in_header_lines && $realfile =~ /^$/ &&
+                   $rawline !~ /^(commit\b|from\b|[\w-]+:).+$/i) {
+                       $in_header_lines = 0;
+                       $in_commit_log = 1;
+               }
+
+# Check if there is UTF-8 in a commit log when a mail header has explicitly
+# declined it, i.e defined some charset where it is missing.
+               if ($in_header_lines &&
+                   $rawline =~ /^Content-Type:.+charset="(.+)".*$/ &&
+                   $1 !~ /utf-8/i) {
+                       $non_utf8_charset = 1;
+               }
+
+               if ($in_commit_log && $non_utf8_charset && $realfile =~ /^$/ &&
+                   $rawline =~ /$NON_ASCII_UTF8/) {
+                       WARN("UTF8_BEFORE_PATCH",
+                           "8-bit UTF-8 used in possible commit log\n" . $herecurr);
+               }
+
+# ignore non-hunk lines and lines being removed
+               next if (!$hunk_line || $line =~ /^-/);
+
+#trailing whitespace
+               if ($line =~ /^\+.*\015/) {
+                       my $herevet = "$here\n" . cat_vet($rawline) . "\n";
+                       ERROR("DOS_LINE_ENDINGS",
+                             "DOS line endings\n" . $herevet);
+
+               } elsif ($rawline =~ /^\+.*\S\s+$/ || $rawline =~ /^\+\s+$/) {
+                       my $herevet = "$here\n" . cat_vet($rawline) . "\n";
+                       ERROR("TRAILING_WHITESPACE",
+                             "trailing whitespace\n" . $herevet);
+                       $rpt_cleaners = 1;
+               }
+
+# check for Kconfig help text having a real description
+# Only applies when adding the entry originally, after that we do not have
+# sufficient context to determine whether it is indeed long enough.
+               if ($realfile =~ /Kconfig/ &&
+                   $line =~ /.\s*config\s+/) {
+                       my $length = 0;
+                       my $cnt = $realcnt;
+                       my $ln = $linenr + 1;
+                       my $f;
+                       my $is_start = 0;
+                       my $is_end = 0;
+                       for (; $cnt > 0 && defined $lines[$ln - 1]; $ln++) {
+                               $f = $lines[$ln - 1];
+                               $cnt-- if ($lines[$ln - 1] !~ /^-/);
+                               $is_end = $lines[$ln - 1] =~ /^\+/;
+
+                               next if ($f =~ /^-/);
+
+                               if ($lines[$ln - 1] =~ /.\s*(?:bool|tristate)\s*\"/) {
+                                       $is_start = 1;
+                               } elsif ($lines[$ln - 1] =~ /.\s*(?:---)?help(?:---)?$/) {
+                                       $length = -1;
+                               }
+
+                               $f =~ s/^.//;
+                               $f =~ s/#.*//;
+                               $f =~ s/^\s+//;
+                               next if ($f =~ /^$/);
+                               if ($f =~ /^\s*config\s/) {
+                                       $is_end = 1;
+                                       last;
+                               }
+                               $length++;
+                       }
+                       WARN("CONFIG_DESCRIPTION",
+                            "please write a paragraph that describes the config symbol fully\n" . $herecurr) if ($is_start && $is_end && $length < 4);
+                       #print "is_start<$is_start> is_end<$is_end> length<$length>\n";
+               }
+
+# discourage the addition of CONFIG_EXPERIMENTAL in Kconfig.
+               if ($realfile =~ /Kconfig/ &&
+                   $line =~ /.\s*depends on\s+.*\bEXPERIMENTAL\b/) {
+                       WARN("CONFIG_EXPERIMENTAL",
+                            "Use of CONFIG_EXPERIMENTAL is deprecated. For alternatives, see https://lkml.org/lkml/2012/10/23/580\n");
+               }
+
+               if (($realfile =~ /Makefile.*/ || $realfile =~ /Kbuild.*/) &&
+                   ($line =~ /\+(EXTRA_[A-Z]+FLAGS).*/)) {
+                       my $flag = $1;
+                       my $replacement = {
+                               'EXTRA_AFLAGS' =>   'asflags-y',
+                               'EXTRA_CFLAGS' =>   'ccflags-y',
+                               'EXTRA_CPPFLAGS' => 'cppflags-y',
+                               'EXTRA_LDFLAGS' =>  'ldflags-y',
+                       };
+
+                       WARN("DEPRECATED_VARIABLE",
+                            "Use of $flag is deprecated, please use \`$replacement->{$flag} instead.\n" . $herecurr) if ($replacement->{$flag});
+               }
+
+# check we are in a valid source file if not then ignore this hunk
+               next if ($realfile !~ /\.(h|c|s|S|pl|sh)$/);
+
+#line length limit
+               if ($line =~ /^\+/ && $prevrawline !~ /\/\*\*/ &&
+                   $rawline !~ /^.\s*\*\s*\@$Ident\s/ &&
+                   !($line =~ /^\+\s*$logFunctions\s*\(\s*(?:(KERN_\S+\s*|[^"]*))?"[X\t]*"\s*(?:|,|\)\s*;)\s*$/ ||
+                   $line =~ /^\+\s*"[^"]*"\s*(?:\s*|,|\)\s*;)\s*$/) &&
+                   $length > $max_line_length)
+               {
+                       WARN("LONG_LINE",
+                            "line over $max_line_length characters\n" . $herecurr);
+               }
+
+# Check for user-visible strings broken across lines, which breaks the ability
+# to grep for the string.  Limited to strings used as parameters (those
+# following an open parenthesis), which almost completely eliminates false
+# positives, as well as warning only once per parameter rather than once per
+# line of the string.  Make an exception when the previous string ends in a
+# newline (multiple lines in one string constant) or \n\t (common in inline
+# assembly to indent the instruction on the following line).
+               if ($line =~ /^\+\s*"/ &&
+                   $prevline =~ /"\s*$/ &&
+                   $prevline =~ /\(/ &&
+                   $prevrawline !~ /\\n(?:\\t)*"\s*$/) {
+                       WARN("SPLIT_STRING",
+                            "quoted string split across lines\n" . $hereprev);
+               }
+
+# check for spaces before a quoted newline
+               if ($rawline =~ /^.*\".*\s\\n/) {
+                       WARN("QUOTED_WHITESPACE_BEFORE_NEWLINE",
+                            "unnecessary whitespace before a quoted newline\n" . $herecurr);
+               }
+
+# check for adding lines without a newline.
+               if ($line =~ /^\+/ && defined $lines[$linenr] && $lines[$linenr] =~ /^\\ No newline at end of file/) {
+                       WARN("MISSING_EOF_NEWLINE",
+                            "adding a line without newline at end of file\n" . $herecurr);
+               }
+
+# Blackfin: use hi/lo macros
+               if ($realfile =~ m@arch/blackfin/.*\.S$@) {
+                       if ($line =~ /\.[lL][[:space:]]*=.*&[[:space:]]*0x[fF][fF][fF][fF]/) {
+                               my $herevet = "$here\n" . cat_vet($line) . "\n";
+                               ERROR("LO_MACRO",
+                                     "use the LO() macro, not (... & 0xFFFF)\n" . $herevet);
+                       }
+                       if ($line =~ /\.[hH][[:space:]]*=.*>>[[:space:]]*16/) {
+                               my $herevet = "$here\n" . cat_vet($line) . "\n";
+                               ERROR("HI_MACRO",
+                                     "use the HI() macro, not (... >> 16)\n" . $herevet);
+                       }
+               }
+
+# check we are in a valid source file C or perl if not then ignore this hunk
+               next if ($realfile !~ /\.(h|c|pl)$/);
+
+# at the beginning of a line any tabs must come first and anything
+# more than 8 must use tabs.
+               if ($rawline =~ /^\+\s* \t\s*\S/ ||
+                   $rawline =~ /^\+\s*        \s*/) {
+                       my $herevet = "$here\n" . cat_vet($rawline) . "\n";
+                       ERROR("CODE_INDENT",
+                             "code indent should use tabs where possible\n" . $herevet);
+                       $rpt_cleaners = 1;
+               }
+
+# check for space before tabs.
+               if ($rawline =~ /^\+/ && $rawline =~ / \t/) {
+                       my $herevet = "$here\n" . cat_vet($rawline) . "\n";
+                       WARN("SPACE_BEFORE_TAB",
+                            "please, no space before tabs\n" . $herevet);
+               }
+
+# check for && or || at the start of a line
+               if ($rawline =~ /^\+\s*(&&|\|\|)/) {
+                       CHK("LOGICAL_CONTINUATIONS",
+                           "Logical continuations should be on the previous line\n" . $hereprev);
+               }
+
+# check multi-line statement indentation matches previous line
+               if ($^V && $^V ge 5.10.0 &&
+                   $prevline =~ /^\+(\t*)(if \(|$Ident\().*(\&\&|\|\||,)\s*$/) {
+                       $prevline =~ /^\+(\t*)(.*)$/;
+                       my $oldindent = $1;
+                       my $rest = $2;
+
+                       my $pos = pos_last_openparen($rest);
+                       if ($pos >= 0) {
+                               $line =~ /^(\+| )([ \t]*)/;
+                               my $newindent = $2;
+
+                               my $goodtabindent = $oldindent .
+                                       "\t" x ($pos / 8) .
+                                       " "  x ($pos % 8);
+                               my $goodspaceindent = $oldindent . " "  x $pos;
+
+                               if ($newindent ne $goodtabindent &&
+                                   $newindent ne $goodspaceindent) {
+                                       CHK("PARENTHESIS_ALIGNMENT",
+                                           "Alignment should match open parenthesis\n" . $hereprev);
+                               }
+                       }
+               }
+
+               if ($line =~ /^\+.*\*[ \t]*\)[ \t]+/) {
+                       CHK("SPACING",
+                           "No space is necessary after a cast\n" . $hereprev);
+               }
+
+               if ($realfile =~ m@^(drivers/net/|net/)@ &&
+                   $rawline =~ /^\+[ \t]*\/\*[ \t]*$/ &&
+                   $prevrawline =~ /^\+[ \t]*$/) {
+                       WARN("NETWORKING_BLOCK_COMMENT_STYLE",
+                            "networking block comments don't use an empty /* line, use /* Comment...\n" . $hereprev);
+               }
+
+               if ($realfile =~ m@^(drivers/net/|net/)@ &&
+                   $rawline !~ m@^\+[ \t]*\*/[ \t]*$@ &&       #trailing */
+                   $rawline !~ m@^\+.*/\*.*\*/[ \t]*$@ &&      #inline /*...*/
+                   $rawline !~ m@^\+.*\*{2,}/[ \t]*$@ &&       #trailing **/
+                   $rawline =~ m@^\+[ \t]*.+\*\/[ \t]*$@) {    #non blank */
+                       WARN("NETWORKING_BLOCK_COMMENT_STYLE",
+                            "networking block comments put the trailing */ on a separate line\n" . $herecurr);
+               }
+
+# check for spaces at the beginning of a line.
+# Exceptions:
+#  1) within comments
+#  2) indented preprocessor commands
+#  3) hanging labels
+               if ($rawline =~ /^\+ / && $line !~ /\+ *(?:$;|#|$Ident:)/)  {
+                       my $herevet = "$here\n" . cat_vet($rawline) . "\n";
+                       WARN("LEADING_SPACE",
+                            "please, no spaces at the start of a line\n" . $herevet);
+               }
+
+# check we are in a valid C source file if not then ignore this hunk
+               next if ($realfile !~ /\.(h|c)$/);
+
+# discourage the addition of CONFIG_EXPERIMENTAL in #if(def).
+               if ($line =~ /^\+\s*\#\s*if.*\bCONFIG_EXPERIMENTAL\b/) {
+                       WARN("CONFIG_EXPERIMENTAL",
+                            "Use of CONFIG_EXPERIMENTAL is deprecated. For alternatives, see https://lkml.org/lkml/2012/10/23/580\n");
+               }
+
+# check for RCS/CVS revision markers
+               if ($rawline =~ /^\+.*\$(Revision|Log|Id)(?:\$|)/) {
+                       WARN("CVS_KEYWORD",
+                            "CVS style keyword markers, these will _not_ be updated\n". $herecurr);
+               }
+
+# Blackfin: don't use __builtin_bfin_[cs]sync
+               if ($line =~ /__builtin_bfin_csync/) {
+                       my $herevet = "$here\n" . cat_vet($line) . "\n";
+                       ERROR("CSYNC",
+                             "use the CSYNC() macro in asm/blackfin.h\n" . $herevet);
+               }
+               if ($line =~ /__builtin_bfin_ssync/) {
+                       my $herevet = "$here\n" . cat_vet($line) . "\n";
+                       ERROR("SSYNC",
+                             "use the SSYNC() macro in asm/blackfin.h\n" . $herevet);
+               }
+
+# check for old HOTPLUG __dev<foo> section markings
+               if ($line =~ /\b(__dev(init|exit)(data|const|))\b/) {
+                       WARN("HOTPLUG_SECTION",
+                            "Using $1 is unnecessary\n" . $herecurr);
+               }
+
+# Check for potential 'bare' types
+               my ($stat, $cond, $line_nr_next, $remain_next, $off_next,
+                   $realline_next);
+#print "LINE<$line>\n";
+               if ($linenr >= $suppress_statement &&
+                   $realcnt && $line =~ /.\s*\S/) {
+                       ($stat, $cond, $line_nr_next, $remain_next, $off_next) =
+                               ctx_statement_block($linenr, $realcnt, 0);
+                       $stat =~ s/\n./\n /g;
+                       $cond =~ s/\n./\n /g;
+
+#print "linenr<$linenr> <$stat>\n";
+                       # If this statement has no statement boundaries within
+                       # it there is no point in retrying a statement scan
+                       # until we hit end of it.
+                       my $frag = $stat; $frag =~ s/;+\s*$//;
+                       if ($frag !~ /(?:{|;)/) {
+#print "skip<$line_nr_next>\n";
+                               $suppress_statement = $line_nr_next;
+                       }
+
+                       # Find the real next line.
+                       $realline_next = $line_nr_next;
+                       if (defined $realline_next &&
+                           (!defined $lines[$realline_next - 1] ||
+                            substr($lines[$realline_next - 1], $off_next) =~ /^\s*$/)) {
+                               $realline_next++;
+                       }
+
+                       my $s = $stat;
+                       $s =~ s/{.*$//s;
+
+                       # Ignore goto labels.
+                       if ($s =~ /$Ident:\*$/s) {
+
+                       # Ignore functions being called
+                       } elsif ($s =~ /^.\s*$Ident\s*\(/s) {
+
+                       } elsif ($s =~ /^.\s*else\b/s) {
+
+                       # declarations always start with types
+                       } elsif ($prev_values eq 'E' && $s =~ /^.\s*(?:$Storage\s+)?(?:$Inline\s+)?(?:const\s+)?((?:\s*$Ident)+?)\b(?:\s+$Sparse)?\s*\**\s*(?:$Ident|\(\*[^\)]*\))(?:\s*$Modifier)?\s*(?:;|=|,|\()/s) {
+                               my $type = $1;
+                               $type =~ s/\s+/ /g;
+                               possible($type, "A:" . $s);
+
+                       # definitions in global scope can only start with types
+                       } elsif ($s =~ /^.(?:$Storage\s+)?(?:$Inline\s+)?(?:const\s+)?($Ident)\b\s*(?!:)/s) {
+                               possible($1, "B:" . $s);
+                       }
+
+                       # any (foo ... *) is a pointer cast, and foo is a type
+                       while ($s =~ /\(($Ident)(?:\s+$Sparse)*[\s\*]+\s*\)/sg) {
+                               possible($1, "C:" . $s);
+                       }
+
+                       # Check for any sort of function declaration.
+                       # int foo(something bar, other baz);
+                       # void (*store_gdt)(x86_descr_ptr *);
+                       if ($prev_values eq 'E' && $s =~ /^(.(?:typedef\s*)?(?:(?:$Storage|$Inline)\s*)*\s*$Type\s*(?:\b$Ident|\(\*\s*$Ident\))\s*)\(/s) {
+                               my ($name_len) = length($1);
+
+                               my $ctx = $s;
+                               substr($ctx, 0, $name_len + 1, '');
+                               $ctx =~ s/\)[^\)]*$//;
+
+                               for my $arg (split(/\s*,\s*/, $ctx)) {
+                                       if ($arg =~ /^(?:const\s+)?($Ident)(?:\s+$Sparse)*\s*\**\s*(:?\b$Ident)?$/s || $arg =~ /^($Ident)$/s) {
+
+                                               possible($1, "D:" . $s);
+                                       }
+                               }
+                       }
+
+               }
+
+#
+# Checks which may be anchored in the context.
+#
+
+# Check for switch () and associated case and default
+# statements should be at the same indent.
+               if ($line=~/\bswitch\s*\(.*\)/) {
+                       my $err = '';
+                       my $sep = '';
+                       my @ctx = ctx_block_outer($linenr, $realcnt);
+                       shift(@ctx);
+                       for my $ctx (@ctx) {
+                               my ($clen, $cindent) = line_stats($ctx);
+                               if ($ctx =~ /^\+\s*(case\s+|default:)/ &&
+                                                       $indent != $cindent) {
+                                       $err .= "$sep$ctx\n";
+                                       $sep = '';
+                               } else {
+                                       $sep = "[...]\n";
+                               }
+                       }
+                       if ($err ne '') {
+                               ERROR("SWITCH_CASE_INDENT_LEVEL",
+                                     "switch and case should be at the same indent\n$hereline$err");
+                       }
+               }
+
+# if/while/etc brace do not go on next line, unless defining a do while loop,
+# or if that brace on the next line is for something else
+               if ($line =~ /(.*)\b((?:if|while|for|switch)\s*\(|do\b|else\b)/ && $line !~ /^.\s*\#/) {
+                       my $pre_ctx = "$1$2";
+
+                       my ($level, @ctx) = ctx_statement_level($linenr, $realcnt, 0);
+
+                       if ($line =~ /^\+\t{6,}/) {
+                               WARN("DEEP_INDENTATION",
+                                    "Too many leading tabs - consider code refactoring\n" . $herecurr);
+                       }
+
+                       my $ctx_cnt = $realcnt - $#ctx - 1;
+                       my $ctx = join("\n", @ctx);
+
+                       my $ctx_ln = $linenr;
+                       my $ctx_skip = $realcnt;
+
+                       while ($ctx_skip > $ctx_cnt || ($ctx_skip == $ctx_cnt &&
+                                       defined $lines[$ctx_ln - 1] &&
+                                       $lines[$ctx_ln - 1] =~ /^-/)) {
+                               ##print "SKIP<$ctx_skip> CNT<$ctx_cnt>\n";
+                               $ctx_skip-- if (!defined $lines[$ctx_ln - 1] || $lines[$ctx_ln - 1] !~ /^-/);
+                               $ctx_ln++;
+                       }
+
+                       #print "realcnt<$realcnt> ctx_cnt<$ctx_cnt>\n";
+                       #print "pre<$pre_ctx>\nline<$line>\nctx<$ctx>\nnext<$lines[$ctx_ln - 1]>\n";
+
+                       if ($ctx !~ /{\s*/ && defined($lines[$ctx_ln -1]) && $lines[$ctx_ln - 1] =~ /^\+\s*{/) {
+                               ERROR("OPEN_BRACE",
+                                     "that open brace { should be on the previous line\n" .
+                                       "$here\n$ctx\n$rawlines[$ctx_ln - 1]\n");
+                       }
+                       if ($level == 0 && $pre_ctx !~ /}\s*while\s*\($/ &&
+                           $ctx =~ /\)\s*\;\s*$/ &&
+                           defined $lines[$ctx_ln - 1])
+                       {
+                               my ($nlength, $nindent) = line_stats($lines[$ctx_ln - 1]);
+                               if ($nindent > $indent) {
+                                       WARN("TRAILING_SEMICOLON",
+                                            "trailing semicolon indicates no statements, indent implies otherwise\n" .
+                                               "$here\n$ctx\n$rawlines[$ctx_ln - 1]\n");
+                               }
+                       }
+               }
+
+# Check relative indent for conditionals and blocks.
+               if ($line =~ /\b(?:(?:if|while|for)\s*\(|do\b)/ && $line !~ /^.\s*#/ && $line !~ /\}\s*while\s*/) {
+                       ($stat, $cond, $line_nr_next, $remain_next, $off_next) =
+                               ctx_statement_block($linenr, $realcnt, 0)
+                                       if (!defined $stat);
+                       my ($s, $c) = ($stat, $cond);
+
+                       substr($s, 0, length($c), '');
+
+                       # Make sure we remove the line prefixes as we have
+                       # none on the first line, and are going to readd them
+                       # where necessary.
+                       $s =~ s/\n./\n/gs;
+
+                       # Find out how long the conditional actually is.
+                       my @newlines = ($c =~ /\n/gs);
+                       my $cond_lines = 1 + $#newlines;
+
+                       # We want to check the first line inside the block
+                       # starting at the end of the conditional, so remove:
+                       #  1) any blank line termination
+                       #  2) any opening brace { on end of the line
+                       #  3) any do (...) {
+                       my $continuation = 0;
+                       my $check = 0;
+                       $s =~ s/^.*\bdo\b//;
+                       $s =~ s/^\s*{//;
+                       if ($s =~ s/^\s*\\//) {
+                               $continuation = 1;
+                       }
+                       if ($s =~ s/^\s*?\n//) {
+                               $check = 1;
+                               $cond_lines++;
+                       }
+
+                       # Also ignore a loop construct at the end of a
+                       # preprocessor statement.
+                       if (($prevline =~ /^.\s*#\s*define\s/ ||
+                           $prevline =~ /\\\s*$/) && $continuation == 0) {
+                               $check = 0;
+                       }
+
+                       my $cond_ptr = -1;
+                       $continuation = 0;
+                       while ($cond_ptr != $cond_lines) {
+                               $cond_ptr = $cond_lines;
+
+                               # If we see an #else/#elif then the code
+                               # is not linear.
+                               if ($s =~ /^\s*\#\s*(?:else|elif)/) {
+                                       $check = 0;
+                               }
+
+                               # Ignore:
+                               #  1) blank lines, they should be at 0,
+                               #  2) preprocessor lines, and
+                               #  3) labels.
+                               if ($continuation ||
+                                   $s =~ /^\s*?\n/ ||
+                                   $s =~ /^\s*#\s*?/ ||
+                                   $s =~ /^\s*$Ident\s*:/) {
+                                       $continuation = ($s =~ /^.*?\\\n/) ? 1 : 0;
+                                       if ($s =~ s/^.*?\n//) {
+                                               $cond_lines++;
+                                       }
+                               }
+                       }
+
+                       my (undef, $sindent) = line_stats("+" . $s);
+                       my $stat_real = raw_line($linenr, $cond_lines);
+
+                       # Check if either of these lines are modified, else
+                       # this is not this patch's fault.
+                       if (!defined($stat_real) ||
+                           $stat !~ /^\+/ && $stat_real !~ /^\+/) {
+                               $check = 0;
+                       }
+                       if (defined($stat_real) && $cond_lines > 1) {
+                               $stat_real = "[...]\n$stat_real";
+                       }
+
+                       #print "line<$line> prevline<$prevline> indent<$indent> sindent<$sindent> check<$check> continuation<$continuation> s<$s> cond_lines<$cond_lines> stat_real<$stat_real> stat<$stat>\n";
+
+                       if ($check && (($sindent % 8) != 0 ||
+                           ($sindent <= $indent && $s ne ''))) {
+                               WARN("SUSPECT_CODE_INDENT",
+                                    "suspect code indent for conditional statements ($indent, $sindent)\n" . $herecurr . "$stat_real\n");
+                       }
+               }
+
+               # Track the 'values' across context and added lines.
+               my $opline = $line; $opline =~ s/^./ /;
+               my ($curr_values, $curr_vars) =
+                               annotate_values($opline . "\n", $prev_values);
+               $curr_values = $prev_values . $curr_values;
+               if ($dbg_values) {
+                       my $outline = $opline; $outline =~ s/\t/ /g;
+                       print "$linenr > .$outline\n";
+                       print "$linenr > $curr_values\n";
+                       print "$linenr >  $curr_vars\n";
+               }
+               $prev_values = substr($curr_values, -1);
+
+#ignore lines not being added
+               if ($line=~/^[^\+]/) {next;}
+
+# TEST: allow direct testing of the type matcher.
+               if ($dbg_type) {
+                       if ($line =~ /^.\s*$Declare\s*$/) {
+                               ERROR("TEST_TYPE",
+                                     "TEST: is type\n" . $herecurr);
+                       } elsif ($dbg_type > 1 && $line =~ /^.+($Declare)/) {
+                               ERROR("TEST_NOT_TYPE",
+                                     "TEST: is not type ($1 is)\n". $herecurr);
+                       }
+                       next;
+               }
+# TEST: allow direct testing of the attribute matcher.
+               if ($dbg_attr) {
+                       if ($line =~ /^.\s*$Modifier\s*$/) {
+                               ERROR("TEST_ATTR",
+                                     "TEST: is attr\n" . $herecurr);
+                       } elsif ($dbg_attr > 1 && $line =~ /^.+($Modifier)/) {
+                               ERROR("TEST_NOT_ATTR",
+                                     "TEST: is not attr ($1 is)\n". $herecurr);
+                       }
+                       next;
+               }
+
+# check for initialisation to aggregates open brace on the next line
+               if ($line =~ /^.\s*{/ &&
+                   $prevline =~ /(?:^|[^=])=\s*$/) {
+                       ERROR("OPEN_BRACE",
+                             "that open brace { should be on the previous line\n" . $hereprev);
+               }
+
+#
+# Checks which are anchored on the added line.
+#
+
+# check for malformed paths in #include statements (uses RAW line)
+               if ($rawline =~ m{^.\s*\#\s*include\s+[<"](.*)[">]}) {
+                       my $path = $1;
+                       if ($path =~ m{//}) {
+                               ERROR("MALFORMED_INCLUDE",
+                                     "malformed #include filename\n" . $herecurr);
+                       }
+                       if ($path =~ "^uapi/" && $realfile =~ m@\binclude/uapi/@) {
+                               ERROR("UAPI_INCLUDE",
+                                     "No #include in ...include/uapi/... should use a uapi/ path prefix\n" . $herecurr);
+                       }
+               }
+
+# no C99 // comments
+               if ($line =~ m{//}) {
+                       ERROR("C99_COMMENTS",
+                             "do not use C99 // comments\n" . $herecurr);
+               }
+               # Remove C99 comments.
+               $line =~ s@//.*@@;
+               $opline =~ s@//.*@@;
+
+# EXPORT_SYMBOL should immediately follow the thing it is exporting, consider
+# the whole statement.
+#print "APW <$lines[$realline_next - 1]>\n";
+               if (defined $realline_next &&
+                   exists $lines[$realline_next - 1] &&
+                   !defined $suppress_export{$realline_next} &&
+                   ($lines[$realline_next - 1] =~ /EXPORT_SYMBOL.*\((.*)\)/ ||
+                    $lines[$realline_next - 1] =~ /EXPORT_UNUSED_SYMBOL.*\((.*)\)/)) {
+                       # Handle definitions which produce identifiers with
+                       # a prefix:
+                       #   XXX(foo);
+                       #   EXPORT_SYMBOL(something_foo);
+                       my $name = $1;
+                       if ($stat =~ /^(?:.\s*}\s*\n)?.([A-Z_]+)\s*\(\s*($Ident)/ &&
+                           $name =~ /^${Ident}_$2/) {
+#print "FOO C name<$name>\n";
+                               $suppress_export{$realline_next} = 1;
+
+                       } elsif ($stat !~ /(?:
+                               \n.}\s*$|
+                               ^.DEFINE_$Ident\(\Q$name\E\)|
+                               ^.DECLARE_$Ident\(\Q$name\E\)|
+                               ^.LIST_HEAD\(\Q$name\E\)|
+                               ^.(?:$Storage\s+)?$Type\s*\(\s*\*\s*\Q$name\E\s*\)\s*\(|
+                               \b\Q$name\E(?:\s+$Attribute)*\s*(?:;|=|\[|\()
+                           )/x) {
+#print "FOO A<$lines[$realline_next - 1]> stat<$stat> name<$name>\n";
+                               $suppress_export{$realline_next} = 2;
+                       } else {
+                               $suppress_export{$realline_next} = 1;
+                       }
+               }
+               if (!defined $suppress_export{$linenr} &&
+                   $prevline =~ /^.\s*$/ &&
+                   ($line =~ /EXPORT_SYMBOL.*\((.*)\)/ ||
+                    $line =~ /EXPORT_UNUSED_SYMBOL.*\((.*)\)/)) {
+#print "FOO B <$lines[$linenr - 1]>\n";
+                       $suppress_export{$linenr} = 2;
+               }
+               if (defined $suppress_export{$linenr} &&
+                   $suppress_export{$linenr} == 2) {
+                       WARN("EXPORT_SYMBOL",
+                            "EXPORT_SYMBOL(foo); should immediately follow its function/variable\n" . $herecurr);
+               }
+
+# check for global initialisers.
+               if ($line =~ /^.$Type\s*$Ident\s*(?:\s+$Modifier)*\s*=\s*(0|NULL|false)\s*;/) {
+                       ERROR("GLOBAL_INITIALISERS",
+                             "do not initialise globals to 0 or NULL\n" .
+                               $herecurr);
+               }
+# check for static initialisers.
+               if ($line =~ /\bstatic\s.*=\s*(0|NULL|false)\s*;/) {
+                       ERROR("INITIALISED_STATIC",
+                             "do not initialise statics to 0 or NULL\n" .
+                               $herecurr);
+               }
+
+# check for static const char * arrays.
+               if ($line =~ /\bstatic\s+const\s+char\s*\*\s*(\w+)\s*\[\s*\]\s*=\s*/) {
+                       WARN("STATIC_CONST_CHAR_ARRAY",
+                            "static const char * array should probably be static const char * const\n" .
+                               $herecurr);
+               }
+
+# check for static char foo[] = "bar" declarations.
+               if ($line =~ /\bstatic\s+char\s+(\w+)\s*\[\s*\]\s*=\s*"/) {
+                       WARN("STATIC_CONST_CHAR_ARRAY",
+                            "static char array declaration should probably be static const char\n" .
+                               $herecurr);
+               }
+
+# check for declarations of struct pci_device_id
+               if ($line =~ /\bstruct\s+pci_device_id\s+\w+\s*\[\s*\]\s*\=\s*\{/) {
+                       WARN("DEFINE_PCI_DEVICE_TABLE",
+                            "Use DEFINE_PCI_DEVICE_TABLE for struct pci_device_id\n" . $herecurr);
+               }
+
+# check for new typedefs, only function parameters and sparse annotations
+# make sense.
+               if ($line =~ /\btypedef\s/ &&
+                   $line !~ /\btypedef\s+$Type\s*\(\s*\*?$Ident\s*\)\s*\(/ &&
+                   $line !~ /\btypedef\s+$Type\s+$Ident\s*\(/ &&
+                   $line !~ /\b$typeTypedefs\b/ &&
+                   $line !~ /\b__bitwise(?:__|)\b/) {
+                       WARN("NEW_TYPEDEFS",
+                            "do not add new typedefs\n" . $herecurr);
+               }
+
+# * goes on variable not on type
+               # (char*[ const])
+               while ($line =~ m{(\($NonptrType(\s*(?:$Modifier\b\s*|\*\s*)+)\))}g) {
+                       #print "AA<$1>\n";
+                       my ($from, $to) = ($2, $2);
+
+                       # Should start with a space.
+                       $to =~ s/^(\S)/ $1/;
+                       # Should not end with a space.
+                       $to =~ s/\s+$//;
+                       # '*'s should not have spaces between.
+                       while ($to =~ s/\*\s+\*/\*\*/) {
+                       }
+
+                       #print "from<$from> to<$to>\n";
+                       if ($from ne $to) {
+                               ERROR("POINTER_LOCATION",
+                                     "\"(foo$from)\" should be \"(foo$to)\"\n" .  $herecurr);
+                       }
+               }
+               while ($line =~ m{(\b$NonptrType(\s*(?:$Modifier\b\s*|\*\s*)+)($Ident))}g) {
+                       #print "BB<$1>\n";
+                       my ($from, $to, $ident) = ($2, $2, $3);
+
+                       # Should start with a space.
+                       $to =~ s/^(\S)/ $1/;
+                       # Should not end with a space.
+                       $to =~ s/\s+$//;
+                       # '*'s should not have spaces between.
+                       while ($to =~ s/\*\s+\*/\*\*/) {
+                       }
+                       # Modifiers should have spaces.
+                       $to =~ s/(\b$Modifier$)/$1 /;
+
+                       #print "from<$from> to<$to> ident<$ident>\n";
+                       if ($from ne $to && $ident !~ /^$Modifier$/) {
+                               ERROR("POINTER_LOCATION",
+                                     "\"foo${from}bar\" should be \"foo${to}bar\"\n" .  $herecurr);
+                       }
+               }
+
+# # no BUG() or BUG_ON()
+#              if ($line =~ /\b(BUG|BUG_ON)\b/) {
+#                      print "Try to use WARN_ON & Recovery code rather than BUG() or BUG_ON()\n";
+#                      print "$herecurr";
+#                      $clean = 0;
+#              }
+
+               if ($line =~ /\bLINUX_VERSION_CODE\b/) {
+                       WARN("LINUX_VERSION_CODE",
+                            "LINUX_VERSION_CODE should be avoided, code should be for the version to which it is merged\n" . $herecurr);
+               }
+
+# check for uses of printk_ratelimit
+               if ($line =~ /\bprintk_ratelimit\s*\(/) {
+                       WARN("PRINTK_RATELIMITED",
+"Prefer printk_ratelimited or pr_<level>_ratelimited to printk_ratelimit\n" . $herecurr);
+               }
+
+# printk should use KERN_* levels.  Note that follow on printk's on the
+# same line do not need a level, so we use the current block context
+# to try and find and validate the current printk.  In summary the current
+# printk includes all preceding printk's which have no newline on the end.
+# we assume the first bad printk is the one to report.
+               if ($line =~ /\bprintk\((?!KERN_)\s*"/) {
+                       my $ok = 0;
+                       for (my $ln = $linenr - 1; $ln >= $first_line; $ln--) {
+                               #print "CHECK<$lines[$ln - 1]\n";
+                               # we have a preceding printk if it ends
+                               # with "\n" ignore it, else it is to blame
+                               if ($lines[$ln - 1] =~ m{\bprintk\(}) {
+                                       if ($rawlines[$ln - 1] !~ m{\\n"}) {
+                                               $ok = 1;
+                                       }
+                                       last;
+                               }
+                       }
+                       if ($ok == 0) {
+                               WARN("PRINTK_WITHOUT_KERN_LEVEL",
+                                    "printk() should include KERN_ facility level\n" . $herecurr);
+                       }
+               }
+
+               if ($line =~ /\bprintk\s*\(\s*KERN_([A-Z]+)/) {
+                       my $orig = $1;
+                       my $level = lc($orig);
+                       $level = "warn" if ($level eq "warning");
+                       my $level2 = $level;
+                       $level2 = "dbg" if ($level eq "debug");
+                       WARN("PREFER_PR_LEVEL",
+                            "Prefer netdev_$level2(netdev, ... then dev_$level2(dev, ... then pr_$level(...  to printk(KERN_$orig ...\n" . $herecurr);
+               }
+
+               if ($line =~ /\bpr_warning\s*\(/) {
+                       WARN("PREFER_PR_LEVEL",
+                            "Prefer pr_warn(... to pr_warning(...\n" . $herecurr);
+               }
+
+               if ($line =~ /\bdev_printk\s*\(\s*KERN_([A-Z]+)/) {
+                       my $orig = $1;
+                       my $level = lc($orig);
+                       $level = "warn" if ($level eq "warning");
+                       $level = "dbg" if ($level eq "debug");
+                       WARN("PREFER_DEV_LEVEL",
+                            "Prefer dev_$level(... to dev_printk(KERN_$orig, ...\n" . $herecurr);
+               }
+
+# function brace can't be on same line, except for #defines of do while,
+# or if closed on same line
+               if (($line=~/$Type\s*$Ident\(.*\).*\s{/) and
+                   !($line=~/\#\s*define.*do\s{/) and !($line=~/}/)) {
+                       ERROR("OPEN_BRACE",
+                             "open brace '{' following function declarations go on the next line\n" . $herecurr);
+               }
+
+# open braces for enum, union and struct go on the same line.
+               if ($line =~ /^.\s*{/ &&
+                   $prevline =~ /^.\s*(?:typedef\s+)?(enum|union|struct)(?:\s+$Ident)?\s*$/) {
+                       ERROR("OPEN_BRACE",
+                             "open brace '{' following $1 go on the same line\n" . $hereprev);
+               }
+
+# missing space after union, struct or enum definition
+               if ($line =~ /^.\s*(?:typedef\s+)?(enum|union|struct)(?:\s+$Ident)?(?:\s+$Ident)?[=\{]/) {
+                   WARN("SPACING",
+                        "missing space after $1 definition\n" . $herecurr);
+               }
+
+# check for spacing round square brackets; allowed:
+#  1. with a type on the left -- int [] a;
+#  2. at the beginning of a line for slice initialisers -- [0...10] = 5,
+#  3. inside a curly brace -- = { [0...10] = 5 }
+               while ($line =~ /(.*?\s)\[/g) {
+                       my ($where, $prefix) = ($-[1], $1);
+                       if ($prefix !~ /$Type\s+$/ &&
+                           ($where != 0 || $prefix !~ /^.\s+$/) &&
+                           $prefix !~ /[{,]\s+$/) {
+                               ERROR("BRACKET_SPACE",
+                                     "space prohibited before open square bracket '['\n" . $herecurr);
+                       }
+               }
+
+# check for spaces between functions and their parentheses.
+               while ($line =~ /($Ident)\s+\(/g) {
+                       my $name = $1;
+                       my $ctx_before = substr($line, 0, $-[1]);
+                       my $ctx = "$ctx_before$name";
+
+                       # Ignore those directives where spaces _are_ permitted.
+                       if ($name =~ /^(?:
+                               if|for|while|switch|return|case|
+                               volatile|__volatile__|
+                               __attribute__|format|__extension__|
+                               asm|__asm__)$/x)
+                       {
+
+                       # cpp #define statements have non-optional spaces, ie
+                       # if there is a space between the name and the open
+                       # parenthesis it is simply not a parameter group.
+                       } elsif ($ctx_before =~ /^.\s*\#\s*define\s*$/) {
+
+                       # cpp #elif statement condition may start with a (
+                       } elsif ($ctx =~ /^.\s*\#\s*elif\s*$/) {
+
+                       # If this whole things ends with a type its most
+                       # likely a typedef for a function.
+                       } elsif ($ctx =~ /$Type$/) {
+
+                       } else {
+                               WARN("SPACING",
+                                    "space prohibited between function name and open parenthesis '('\n" . $herecurr);
+                       }
+               }
+
+# check for whitespace before a non-naked semicolon
+               if ($line =~ /^\+.*\S\s+;/) {
+                       CHK("SPACING",
+                           "space prohibited before semicolon\n" . $herecurr);
+               }
+
+# Check operator spacing.
+               if (!($line=~/\#\s*include/)) {
+                       my $ops = qr{
+                               <<=|>>=|<=|>=|==|!=|
+                               \+=|-=|\*=|\/=|%=|\^=|\|=|&=|
+                               =>|->|<<|>>|<|>|=|!|~|
+                               &&|\|\||,|\^|\+\+|--|&|\||\+|-|\*|\/|%|
+                               \?|:
+                       }x;
+                       my @elements = split(/($ops|;)/, $opline);
+                       my $off = 0;
+
+                       my $blank = copy_spacing($opline);
+
+                       for (my $n = 0; $n < $#elements; $n += 2) {
+                               $off += length($elements[$n]);
+
+                               # Pick up the preceding and succeeding characters.
+                               my $ca = substr($opline, 0, $off);
+                               my $cc = '';
+                               if (length($opline) >= ($off + length($elements[$n + 1]))) {
+                                       $cc = substr($opline, $off + length($elements[$n + 1]));
+                               }
+                               my $cb = "$ca$;$cc";
+
+                               my $a = '';
+                               $a = 'V' if ($elements[$n] ne '');
+                               $a = 'W' if ($elements[$n] =~ /\s$/);
+                               $a = 'C' if ($elements[$n] =~ /$;$/);
+                               $a = 'B' if ($elements[$n] =~ /(\[|\()$/);
+                               $a = 'O' if ($elements[$n] eq '');
+                               $a = 'E' if ($ca =~ /^\s*$/);
+
+                               my $op = $elements[$n + 1];
+
+                               my $c = '';
+                               if (defined $elements[$n + 2]) {
+                                       $c = 'V' if ($elements[$n + 2] ne '');
+                                       $c = 'W' if ($elements[$n + 2] =~ /^\s/);
+                                       $c = 'C' if ($elements[$n + 2] =~ /^$;/);
+                                       $c = 'B' if ($elements[$n + 2] =~ /^(\)|\]|;)/);
+                                       $c = 'O' if ($elements[$n + 2] eq '');
+                                       $c = 'E' if ($elements[$n + 2] =~ /^\s*\\$/);
+                               } else {
+                                       $c = 'E';
+                               }
+
+                               my $ctx = "${a}x${c}";
+
+                               my $at = "(ctx:$ctx)";
+
+                               my $ptr = substr($blank, 0, $off) . "^";
+                               my $hereptr = "$hereline$ptr\n";
+
+                               # Pull out the value of this operator.
+                               my $op_type = substr($curr_values, $off + 1, 1);
+
+                               # Get the full operator variant.
+                               my $opv = $op . substr($curr_vars, $off, 1);
+
+                               # Ignore operators passed as parameters.
+                               if ($op_type ne 'V' &&
+                                   $ca =~ /\s$/ && $cc =~ /^\s*,/) {
+
+#                              # Ignore comments
+#                              } elsif ($op =~ /^$;+$/) {
+
+                               # ; should have either the end of line or a space or \ after it
+                               } elsif ($op eq ';') {
+                                       if ($ctx !~ /.x[WEBC]/ &&
+                                           $cc !~ /^\\/ && $cc !~ /^;/) {
+                                               ERROR("SPACING",
+                                                     "space required after that '$op' $at\n" . $hereptr);
+                                       }
+
+                               # // is a comment
+                               } elsif ($op eq '//') {
+
+                               # No spaces for:
+                               #   ->
+                               #   :   when part of a bitfield
+                               } elsif ($op eq '->' || $opv eq ':B') {
+                                       if ($ctx =~ /Wx.|.xW/) {
+                                               ERROR("SPACING",
+                                                     "spaces prohibited around that '$op' $at\n" . $hereptr);
+                                       }
+
+                               # , must have a space on the right.
+                               } elsif ($op eq ',') {
+                                       if ($ctx !~ /.x[WEC]/ && $cc !~ /^}/) {
+                                               ERROR("SPACING",
+                                                     "space required after that '$op' $at\n" . $hereptr);
+                                       }
+
+                               # '*' as part of a type definition -- reported already.
+                               } elsif ($opv eq '*_') {
+                                       #warn "'*' is part of type\n";
+
+                               # unary operators should have a space before and
+                               # none after.  May be left adjacent to another
+                               # unary operator, or a cast
+                               } elsif ($op eq '!' || $op eq '~' ||
+                                        $opv eq '*U' || $opv eq '-U' ||
+                                        $opv eq '&U' || $opv eq '&&U') {
+                                       if ($ctx !~ /[WEBC]x./ && $ca !~ /(?:\)|!|~|\*|-|\&|\||\+\+|\-\-|\{)$/) {
+                                               ERROR("SPACING",
+                                                     "space required before that '$op' $at\n" . $hereptr);
+                                       }
+                                       if ($op eq '*' && $cc =~/\s*$Modifier\b/) {
+                                               # A unary '*' may be const
+
+                                       } elsif ($ctx =~ /.xW/) {
+                                               ERROR("SPACING",
+                                                     "space prohibited after that '$op' $at\n" . $hereptr);
+                                       }
+
+                               # unary ++ and unary -- are allowed no space on one side.
+                               } elsif ($op eq '++' or $op eq '--') {
+                                       if ($ctx !~ /[WEOBC]x[^W]/ && $ctx !~ /[^W]x[WOBEC]/) {
+                                               ERROR("SPACING",
+                                                     "space required one side of that '$op' $at\n" . $hereptr);
+                                       }
+                                       if ($ctx =~ /Wx[BE]/ ||
+                                           ($ctx =~ /Wx./ && $cc =~ /^;/)) {
+                                               ERROR("SPACING",
+                                                     "space prohibited before that '$op' $at\n" . $hereptr);
+                                       }
+                                       if ($ctx =~ /ExW/) {
+                                               ERROR("SPACING",
+                                                     "space prohibited after that '$op' $at\n" . $hereptr);
+                                       }
+
+
+                               # << and >> may either have or not have spaces both sides
+                               } elsif ($op eq '<<' or $op eq '>>' or
+                                        $op eq '&' or $op eq '^' or $op eq '|' or
+                                        $op eq '+' or $op eq '-' or
+                                        $op eq '*' or $op eq '/' or
+                                        $op eq '%')
+                               {
+                                       if ($ctx =~ /Wx[^WCE]|[^WCE]xW/) {
+                                               ERROR("SPACING",
+                                                     "need consistent spacing around '$op' $at\n" .
+                                                       $hereptr);
+                                       }
+
+                               # A colon needs no spaces before when it is
+                               # terminating a case value or a label.
+                               } elsif ($opv eq ':C' || $opv eq ':L') {
+                                       if ($ctx =~ /Wx./) {
+                                               ERROR("SPACING",
+                                                     "space prohibited before that '$op' $at\n" . $hereptr);
+                                       }
+
+                               # All the others need spaces both sides.
+                               } elsif ($ctx !~ /[EWC]x[CWE]/) {
+                                       my $ok = 0;
+
+                                       # Ignore email addresses <foo@bar>
+                                       if (($op eq '<' &&
+                                            $cc =~ /^\S+\@\S+>/) ||
+                                           ($op eq '>' &&
+                                            $ca =~ /<\S+\@\S+$/))
+                                       {
+                                               $ok = 1;
+                                       }
+
+                                       # Ignore ?:
+                                       if (($opv eq ':O' && $ca =~ /\?$/) ||
+                                           ($op eq '?' && $cc =~ /^:/)) {
+                                               $ok = 1;
+                                       }
+
+                                       if ($ok == 0) {
+                                               ERROR("SPACING",
+                                                     "spaces required around that '$op' $at\n" . $hereptr);
+                                       }
+                               }
+                               $off += length($elements[$n + 1]);
+                       }
+               }
+
+# check for multiple assignments
+               if ($line =~ /^.\s*$Lval\s*=\s*$Lval\s*=(?!=)/) {
+                       CHK("MULTIPLE_ASSIGNMENTS",
+                           "multiple assignments should be avoided\n" . $herecurr);
+               }
+
+## # check for multiple declarations, allowing for a function declaration
+## # continuation.
+##             if ($line =~ /^.\s*$Type\s+$Ident(?:\s*=[^,{]*)?\s*,\s*$Ident.*/ &&
+##                 $line !~ /^.\s*$Type\s+$Ident(?:\s*=[^,{]*)?\s*,\s*$Type\s*$Ident.*/) {
+##
+##                     # Remove any bracketed sections to ensure we do not
+##                     # falsly report the parameters of functions.
+##                     my $ln = $line;
+##                     while ($ln =~ s/\([^\(\)]*\)//g) {
+##                     }
+##                     if ($ln =~ /,/) {
+##                             WARN("MULTIPLE_DECLARATION",
+##                                  "declaring multiple variables together should be avoided\n" . $herecurr);
+##                     }
+##             }
+
+#need space before brace following if, while, etc
+               if (($line =~ /\(.*\){/ && $line !~ /\($Type\){/) ||
+                   $line =~ /do{/) {
+                       ERROR("SPACING",
+                             "space required before the open brace '{'\n" . $herecurr);
+               }
+
+# closing brace should have a space following it when it has anything
+# on the line
+               if ($line =~ /}(?!(?:,|;|\)))\S/) {
+                       ERROR("SPACING",
+                             "space required after that close brace '}'\n" . $herecurr);
+               }
+
+# check spacing on square brackets
+               if ($line =~ /\[\s/ && $line !~ /\[\s*$/) {
+                       ERROR("SPACING",
+                             "space prohibited after that open square bracket '['\n" . $herecurr);
+               }
+               if ($line =~ /\s\]/) {
+                       ERROR("SPACING",
+                             "space prohibited before that close square bracket ']'\n" . $herecurr);
+               }
+
+# check spacing on parentheses
+               if ($line =~ /\(\s/ && $line !~ /\(\s*(?:\\)?$/ &&
+                   $line !~ /for\s*\(\s+;/) {
+                       ERROR("SPACING",
+                             "space prohibited after that open parenthesis '('\n" . $herecurr);
+               }
+               if ($line =~ /(\s+)\)/ && $line !~ /^.\s*\)/ &&
+                   $line !~ /for\s*\(.*;\s+\)/ &&
+                   $line !~ /:\s+\)/) {
+                       ERROR("SPACING",
+                             "space prohibited before that close parenthesis ')'\n" . $herecurr);
+               }
+
+#goto labels aren't indented, allow a single space however
+               if ($line=~/^.\s+[A-Za-z\d_]+:(?![0-9]+)/ and
+                  !($line=~/^. [A-Za-z\d_]+:/) and !($line=~/^.\s+default:/)) {
+                       WARN("INDENTED_LABEL",
+                            "labels should not be indented\n" . $herecurr);
+               }
+
+# Return is not a function.
+               if (defined($stat) && $stat =~ /^.\s*return(\s*)(\(.*);/s) {
+                       my $spacing = $1;
+                       my $value = $2;
+
+                       # Flatten any parentheses
+                       $value =~ s/\(/ \(/g;
+                       $value =~ s/\)/\) /g;
+                       while ($value =~ s/\[[^\[\]]*\]/1/ ||
+                              $value !~ /(?:$Ident|-?$Constant)\s*
+                                            $Compare\s*
+                                            (?:$Ident|-?$Constant)/x &&
+                              $value =~ s/\([^\(\)]*\)/1/) {
+                       }
+#print "value<$value>\n";
+                       if ($value =~ /^\s*(?:$Ident|-?$Constant)\s*$/) {
+                               ERROR("RETURN_PARENTHESES",
+                                     "return is not a function, parentheses are not required\n" . $herecurr);
+
+                       } elsif ($spacing !~ /\s+/) {
+                               ERROR("SPACING",
+                                     "space required before the open parenthesis '('\n" . $herecurr);
+                       }
+               }
+# Return of what appears to be an errno should normally be -'ve
+               if ($line =~ /^.\s*return\s*(E[A-Z]*)\s*;/) {
+                       my $name = $1;
+                       if ($name ne 'EOF' && $name ne 'ERROR') {
+                               WARN("USE_NEGATIVE_ERRNO",
+                                    "return of an errno should typically be -ve (return -$1)\n" . $herecurr);
+                       }
+               }
+
+# Need a space before open parenthesis after if, while etc
+               if ($line=~/\b(if|while|for|switch)\(/) {
+                       ERROR("SPACING", "space required before the open parenthesis '('\n" . $herecurr);
+               }
+
+# Check for illegal assignment in if conditional -- and check for trailing
+# statements after the conditional.
+               if ($line =~ /do\s*(?!{)/) {
+                       ($stat, $cond, $line_nr_next, $remain_next, $off_next) =
+                               ctx_statement_block($linenr, $realcnt, 0)
+                                       if (!defined $stat);
+                       my ($stat_next) = ctx_statement_block($line_nr_next,
+                                               $remain_next, $off_next);
+                       $stat_next =~ s/\n./\n /g;
+                       ##print "stat<$stat> stat_next<$stat_next>\n";
+
+                       if ($stat_next =~ /^\s*while\b/) {
+                               # If the statement carries leading newlines,
+                               # then count those as offsets.
+                               my ($whitespace) =
+                                       ($stat_next =~ /^((?:\s*\n[+-])*\s*)/s);
+                               my $offset =
+                                       statement_rawlines($whitespace) - 1;
+
+                               $suppress_whiletrailers{$line_nr_next +
+                                                               $offset} = 1;
+                       }
+               }
+               if (!defined $suppress_whiletrailers{$linenr} &&
+                   $line =~ /\b(?:if|while|for)\s*\(/ && $line !~ /^.\s*#/) {
+                       my ($s, $c) = ($stat, $cond);
+
+                       if ($c =~ /\bif\s*\(.*[^<>!=]=[^=].*/s) {
+                               ERROR("ASSIGN_IN_IF",
+                                     "do not use assignment in if condition\n" . $herecurr);
+                       }
+
+                       # Find out what is on the end of the line after the
+                       # conditional.
+                       substr($s, 0, length($c), '');
+                       $s =~ s/\n.*//g;
+                       $s =~ s/$;//g;  # Remove any comments
+                       if (length($c) && $s !~ /^\s*{?\s*\\*\s*$/ &&
+                           $c !~ /}\s*while\s*/)
+                       {
+                               # Find out how long the conditional actually is.
+                               my @newlines = ($c =~ /\n/gs);
+                               my $cond_lines = 1 + $#newlines;
+                               my $stat_real = '';
+
+                               $stat_real = raw_line($linenr, $cond_lines)
+                                                       . "\n" if ($cond_lines);
+                               if (defined($stat_real) && $cond_lines > 1) {
+                                       $stat_real = "[...]\n$stat_real";
+                               }
+
+                               ERROR("TRAILING_STATEMENTS",
+                                     "trailing statements should be on next line\n" . $herecurr . $stat_real);
+                       }
+               }
+
+# Check for bitwise tests written as boolean
+               if ($line =~ /
+                       (?:
+                               (?:\[|\(|\&\&|\|\|)
+                               \s*0[xX][0-9]+\s*
+                               (?:\&\&|\|\|)
+                       |
+                               (?:\&\&|\|\|)
+                               \s*0[xX][0-9]+\s*
+                               (?:\&\&|\|\||\)|\])
+                       )/x)
+               {
+                       WARN("HEXADECIMAL_BOOLEAN_TEST",
+                            "boolean test with hexadecimal, perhaps just 1 \& or \|?\n" . $herecurr);
+               }
+
+# if and else should not have general statements after it
+               if ($line =~ /^.\s*(?:}\s*)?else\b(.*)/) {
+                       my $s = $1;
+                       $s =~ s/$;//g;  # Remove any comments
+                       if ($s !~ /^\s*(?:\sif|(?:{|)\s*\\?\s*$)/) {
+                               ERROR("TRAILING_STATEMENTS",
+                                     "trailing statements should be on next line\n" . $herecurr);
+                       }
+               }
+# if should not continue a brace
+               if ($line =~ /}\s*if\b/) {
+                       ERROR("TRAILING_STATEMENTS",
+                             "trailing statements should be on next line\n" .
+                               $herecurr);
+               }
+# case and default should not have general statements after them
+               if ($line =~ /^.\s*(?:case\s*.*|default\s*):/g &&
+                   $line !~ /\G(?:
+                       (?:\s*$;*)(?:\s*{)?(?:\s*$;*)(?:\s*\\)?\s*$|
+                       \s*return\s+
+                   )/xg)
+               {
+                       ERROR("TRAILING_STATEMENTS",
+                             "trailing statements should be on next line\n" . $herecurr);
+               }
+
+               # Check for }<nl>else {, these must be at the same
+               # indent level to be relevant to each other.
+               if ($prevline=~/}\s*$/ and $line=~/^.\s*else\s*/ and
+                                               $previndent == $indent) {
+                       ERROR("ELSE_AFTER_BRACE",
+                             "else should follow close brace '}'\n" . $hereprev);
+               }
+
+               if ($prevline=~/}\s*$/ and $line=~/^.\s*while\s*/ and
+                                               $previndent == $indent) {
+                       my ($s, $c) = ctx_statement_block($linenr, $realcnt, 0);
+
+                       # Find out what is on the end of the line after the
+                       # conditional.
+                       substr($s, 0, length($c), '');
+                       $s =~ s/\n.*//g;
+
+                       if ($s =~ /^\s*;/) {
+                               ERROR("WHILE_AFTER_BRACE",
+                                     "while should follow close brace '}'\n" . $hereprev);
+                       }
+               }
+
+#CamelCase
+               while ($line =~ m{($Constant|$Lval)}g) {
+                       my $var = $1;
+                       if ($var !~ /$Constant/ &&
+                           $var =~ /[A-Z]\w*[a-z]|[a-z]\w*[A-Z]/ &&
+                           $var !~ /"^(?:Clear|Set|TestClear|TestSet|)Page[A-Z]/ &&
+                           !defined $camelcase{$var}) {
+                               $camelcase{$var} = 1;
+                               WARN("CAMELCASE",
+                                    "Avoid CamelCase: <$var>\n" . $herecurr);
+                       }
+               }
+
+#no spaces allowed after \ in define
+               if ($line=~/\#\s*define.*\\\s$/) {
+                       WARN("WHITESPACE_AFTER_LINE_CONTINUATION",
+                            "Whitepspace after \\ makes next lines useless\n" . $herecurr);
+               }
+
+#warn if <asm/foo.h> is #included and <linux/foo.h> is available (uses RAW line)
+               if ($tree && $rawline =~ m{^.\s*\#\s*include\s*\<asm\/(.*)\.h\>}) {
+                       my $file = "$1.h";
+                       my $checkfile = "include/linux/$file";
+                       if (-f "$root/$checkfile" &&
+                           $realfile ne $checkfile &&
+                           $1 !~ /$allowed_asm_includes/)
+                       {
+                               if ($realfile =~ m{^arch/}) {
+                                       CHK("ARCH_INCLUDE_LINUX",
+                                           "Consider using #include <linux/$file> instead of <asm/$file>\n" . $herecurr);
+                               } else {
+                                       WARN("INCLUDE_LINUX",
+                                            "Use #include <linux/$file> instead of <asm/$file>\n" . $herecurr);
+                               }
+                       }
+               }
+
+# multi-statement macros should be enclosed in a do while loop, grab the
+# first statement and ensure its the whole macro if its not enclosed
+# in a known good container
+               if ($realfile !~ m@/vmlinux.lds.h$@ &&
+                   $line =~ /^.\s*\#\s*define\s*$Ident(\()?/) {
+                       my $ln = $linenr;
+                       my $cnt = $realcnt;
+                       my ($off, $dstat, $dcond, $rest);
+                       my $ctx = '';
+                       ($dstat, $dcond, $ln, $cnt, $off) =
+                               ctx_statement_block($linenr, $realcnt, 0);
+                       $ctx = $dstat;
+                       #print "dstat<$dstat> dcond<$dcond> cnt<$cnt> off<$off>\n";
+                       #print "LINE<$lines[$ln-1]> len<" . length($lines[$ln-1]) . "\n";
+
+                       $dstat =~ s/^.\s*\#\s*define\s+$Ident(?:\([^\)]*\))?\s*//;
+                       $dstat =~ s/$;//g;
+                       $dstat =~ s/\\\n.//g;
+                       $dstat =~ s/^\s*//s;
+                       $dstat =~ s/\s*$//s;
+
+                       # Flatten any parentheses and braces
+                       while ($dstat =~ s/\([^\(\)]*\)/1/ ||
+                              $dstat =~ s/\{[^\{\}]*\}/1/ ||
+                              $dstat =~ s/\[[^\[\]]*\]/1/)
+                       {
+                       }
+
+                       # Flatten any obvious string concatentation.
+                       while ($dstat =~ s/("X*")\s*$Ident/$1/ ||
+                              $dstat =~ s/$Ident\s*("X*")/$1/)
+                       {
+                       }
+
+                       my $exceptions = qr{
+                               $Declare|
+                               module_param_named|
+                               MODULE_PARM_DESC|
+                               DECLARE_PER_CPU|
+                               DEFINE_PER_CPU|
+                               __typeof__\(|
+                               union|
+                               struct|
+                               \.$Ident\s*=\s*|
+                               ^\"|\"$
+                       }x;
+                       #print "REST<$rest> dstat<$dstat> ctx<$ctx>\n";
+                       if ($dstat ne '' &&
+                           $dstat !~ /^(?:$Ident|-?$Constant),$/ &&                    # 10, // foo(),
+                           $dstat !~ /^(?:$Ident|-?$Constant);$/ &&                    # foo();
+                           $dstat !~ /^[!~-]?(?:$Ident|$Constant)$/ &&         # 10 // foo() // !foo // ~foo // -foo
+                           $dstat !~ /^'X'$/ &&                                        # character constants
+                           $dstat !~ /$exceptions/ &&
+                           $dstat !~ /^\.$Ident\s*=/ &&                                # .foo =
+                           $dstat !~ /^do\s*$Constant\s*while\s*$Constant;?$/ &&       # do {...} while (...); // do {...} while (...)
+                           $dstat !~ /^for\s*$Constant$/ &&                            # for (...)
+                           $dstat !~ /^for\s*$Constant\s+(?:$Ident|-?$Constant)$/ &&   # for (...) bar()
+                           $dstat !~ /^do\s*{/ &&                                      # do {...
+                           $dstat !~ /^\({/)                                           # ({...
+                       {
+                               $ctx =~ s/\n*$//;
+                               my $herectx = $here . "\n";
+                               my $cnt = statement_rawlines($ctx);
+
+                               for (my $n = 0; $n < $cnt; $n++) {
+                                       $herectx .= raw_line($linenr, $n) . "\n";
+                               }
+
+                               if ($dstat =~ /;/) {
+                                       ERROR("MULTISTATEMENT_MACRO_USE_DO_WHILE",
+                                             "Macros with multiple statements should be enclosed in a do - while loop\n" . "$herectx");
+                               } else {
+                                       ERROR("COMPLEX_MACRO",
+                                             "Macros with complex values should be enclosed in parenthesis\n" . "$herectx");
+                               }
+                       }
+
+# check for line continuations outside of #defines, preprocessor #, and asm
+
+               } else {
+                       if ($prevline !~ /^..*\\$/ &&
+                           $line !~ /^\+\s*\#.*\\$/ &&         # preprocessor
+                           $line !~ /^\+.*\b(__asm__|asm)\b.*\\$/ &&   # asm
+                           $line =~ /^\+.*\\$/) {
+                               WARN("LINE_CONTINUATIONS",
+                                    "Avoid unnecessary line continuations\n" . $herecurr);
+                       }
+               }
+
+# do {} while (0) macro tests:
+# single-statement macros do not need to be enclosed in do while (0) loop,
+# macro should not end with a semicolon
+               if ($^V && $^V ge 5.10.0 &&
+                   $realfile !~ m@/vmlinux.lds.h$@ &&
+                   $line =~ /^.\s*\#\s*define\s+$Ident(\()?/) {
+                       my $ln = $linenr;
+                       my $cnt = $realcnt;
+                       my ($off, $dstat, $dcond, $rest);
+                       my $ctx = '';
+                       ($dstat, $dcond, $ln, $cnt, $off) =
+                               ctx_statement_block($linenr, $realcnt, 0);
+                       $ctx = $dstat;
+
+                       $dstat =~ s/\\\n.//g;
+
+                       if ($dstat =~ /^\+\s*#\s*define\s+$Ident\s*${balanced_parens}\s*do\s*{(.*)\s*}\s*while\s*\(\s*0\s*\)\s*([;\s]*)\s*$/) {
+                               my $stmts = $2;
+                               my $semis = $3;
+
+                               $ctx =~ s/\n*$//;
+                               my $cnt = statement_rawlines($ctx);
+                               my $herectx = $here . "\n";
+
+                               for (my $n = 0; $n < $cnt; $n++) {
+                                       $herectx .= raw_line($linenr, $n) . "\n";
+                               }
+
+                               if (($stmts =~ tr/;/;/) == 1 &&
+                                   $stmts !~ /^\s*(if|while|for|switch)\b/) {
+                                       WARN("SINGLE_STATEMENT_DO_WHILE_MACRO",
+                                            "Single statement macros should not use a do {} while (0) loop\n" . "$herectx");
+                               }
+                               if (defined $semis && $semis ne "") {
+                                       WARN("DO_WHILE_MACRO_WITH_TRAILING_SEMICOLON",
+                                            "do {} while (0) macros should not be semicolon terminated\n" . "$herectx");
+                               }
+                       }
+               }
+
+# make sure symbols are always wrapped with VMLINUX_SYMBOL() ...
+# all assignments may have only one of the following with an assignment:
+#      .
+#      ALIGN(...)
+#      VMLINUX_SYMBOL(...)
+               if ($realfile eq 'vmlinux.lds.h' && $line =~ /(?:(?:^|\s)$Ident\s*=|=\s*$Ident(?:\s|$))/) {
+                       WARN("MISSING_VMLINUX_SYMBOL",
+                            "vmlinux.lds.h needs VMLINUX_SYMBOL() around C-visible symbols\n" . $herecurr);
+               }
+
+# check for redundant bracing round if etc
+               if ($line =~ /(^.*)\bif\b/ && $1 !~ /else\s*$/) {
+                       my ($level, $endln, @chunks) =
+                               ctx_statement_full($linenr, $realcnt, 1);
+                       #print "chunks<$#chunks> linenr<$linenr> endln<$endln> level<$level>\n";
+                       #print "APW: <<$chunks[1][0]>><<$chunks[1][1]>>\n";
+                       if ($#chunks > 0 && $level == 0) {
+                               my @allowed = ();
+                               my $allow = 0;
+                               my $seen = 0;
+                               my $herectx = $here . "\n";
+                               my $ln = $linenr - 1;
+                               for my $chunk (@chunks) {
+                                       my ($cond, $block) = @{$chunk};
+
+                                       # If the condition carries leading newlines, then count those as offsets.
+                                       my ($whitespace) = ($cond =~ /^((?:\s*\n[+-])*\s*)/s);
+                                       my $offset = statement_rawlines($whitespace) - 1;
+
+                                       $allowed[$allow] = 0;
+                                       #print "COND<$cond> whitespace<$whitespace> offset<$offset>\n";
+
+                                       # We have looked at and allowed this specific line.
+                                       $suppress_ifbraces{$ln + $offset} = 1;
+
+                                       $herectx .= "$rawlines[$ln + $offset]\n[...]\n";
+                                       $ln += statement_rawlines($block) - 1;
+
+                                       substr($block, 0, length($cond), '');
+
+                                       $seen++ if ($block =~ /^\s*{/);
+
+                                       #print "cond<$cond> block<$block> allowed<$allowed[$allow]>\n";
+                                       if (statement_lines($cond) > 1) {
+                                               #print "APW: ALLOWED: cond<$cond>\n";
+                                               $allowed[$allow] = 1;
+                                       }
+                                       if ($block =~/\b(?:if|for|while)\b/) {
+                                               #print "APW: ALLOWED: block<$block>\n";
+                                               $allowed[$allow] = 1;
+                                       }
+                                       if (statement_block_size($block) > 1) {
+                                               #print "APW: ALLOWED: lines block<$block>\n";
+                                               $allowed[$allow] = 1;
+                                       }
+                                       $allow++;
+                               }
+                               if ($seen) {
+                                       my $sum_allowed = 0;
+                                       foreach (@allowed) {
+                                               $sum_allowed += $_;
+                                       }
+                                       if ($sum_allowed == 0) {
+                                               WARN("BRACES",
+                                                    "braces {} are not necessary for any arm of this statement\n" . $herectx);
+                                       } elsif ($sum_allowed != $allow &&
+                                                $seen != $allow) {
+                                               CHK("BRACES",
+                                                   "braces {} should be used on all arms of this statement\n" . $herectx);
+                                       }
+                               }
+                       }
+               }
+               if (!defined $suppress_ifbraces{$linenr - 1} &&
+                                       $line =~ /\b(if|while|for|else)\b/) {
+                       my $allowed = 0;
+
+                       # Check the pre-context.
+                       if (substr($line, 0, $-[0]) =~ /(\}\s*)$/) {
+                               #print "APW: ALLOWED: pre<$1>\n";
+                               $allowed = 1;
+                       }
+
+                       my ($level, $endln, @chunks) =
+                               ctx_statement_full($linenr, $realcnt, $-[0]);
+
+                       # Check the condition.
+                       my ($cond, $block) = @{$chunks[0]};
+                       #print "CHECKING<$linenr> cond<$cond> block<$block>\n";
+                       if (defined $cond) {
+                               substr($block, 0, length($cond), '');
+                       }
+                       if (statement_lines($cond) > 1) {
+                               #print "APW: ALLOWED: cond<$cond>\n";
+                               $allowed = 1;
+                       }
+                       if ($block =~/\b(?:if|for|while)\b/) {
+                               #print "APW: ALLOWED: block<$block>\n";
+                               $allowed = 1;
+                       }
+                       if (statement_block_size($block) > 1) {
+                               #print "APW: ALLOWED: lines block<$block>\n";
+                               $allowed = 1;
+                       }
+                       # Check the post-context.
+                       if (defined $chunks[1]) {
+                               my ($cond, $block) = @{$chunks[1]};
+                               if (defined $cond) {
+                                       substr($block, 0, length($cond), '');
+                               }
+                               if ($block =~ /^\s*\{/) {
+                                       #print "APW: ALLOWED: chunk-1 block<$block>\n";
+                                       $allowed = 1;
+                               }
+                       }
+                       if ($level == 0 && $block =~ /^\s*\{/ && !$allowed) {
+                               my $herectx = $here . "\n";
+                               my $cnt = statement_rawlines($block);
+
+                               for (my $n = 0; $n < $cnt; $n++) {
+                                       $herectx .= raw_line($linenr, $n) . "\n";
+                               }
+
+                               WARN("BRACES",
+                                    "braces {} are not necessary for single statement blocks\n" . $herectx);
+                       }
+               }
+
+# check for unnecessary blank lines around braces
+               if (($line =~ /^..*}\s*$/ && $prevline =~ /^.\s*$/)) {
+                       CHK("BRACES",
+                           "Blank lines aren't necessary before a close brace '}'\n" . $hereprev);
+               }
+               if (($line =~ /^.\s*$/ && $prevline =~ /^..*{\s*$/)) {
+                       CHK("BRACES",
+                           "Blank lines aren't necessary after an open brace '{'\n" . $hereprev);
+               }
+
+# no volatiles please
+               my $asm_volatile = qr{\b(__asm__|asm)\s+(__volatile__|volatile)\b};
+               if ($line =~ /\bvolatile\b/ && $line !~ /$asm_volatile/) {
+                       WARN("VOLATILE",
+                            "Use of volatile is usually wrong: see Documentation/volatile-considered-harmful.txt\n" . $herecurr);
+               }
+
+# warn about #if 0
+               if ($line =~ /^.\s*\#\s*if\s+0\b/) {
+                       CHK("REDUNDANT_CODE",
+                           "if this code is redundant consider removing it\n" .
+                               $herecurr);
+               }
+
+# check for needless "if (<foo>) fn(<foo>)" uses
+               if ($prevline =~ /\bif\s*\(\s*($Lval)\s*\)/) {
+                       my $expr = '\s*\(\s*' . quotemeta($1) . '\s*\)\s*;';
+                       if ($line =~ /\b(kfree|usb_free_urb|debugfs_remove(?:_recursive)?)$expr/) {
+                               WARN('NEEDLESS_IF',
+                                    "$1(NULL) is safe this check is probably not required\n" . $hereprev);
+                       }
+               }
+
+# prefer usleep_range over udelay
+               if ($line =~ /\budelay\s*\(\s*(\d+)\s*\)/) {
+                       # ignore udelay's < 10, however
+                       if (! ($1 < 10) ) {
+                               CHK("USLEEP_RANGE",
+                                   "usleep_range is preferred over udelay; see Documentation/timers/timers-howto.txt\n" . $line);
+                       }
+               }
+
+# warn about unexpectedly long msleep's
+               if ($line =~ /\bmsleep\s*\((\d+)\);/) {
+                       if ($1 < 20) {
+                               WARN("MSLEEP",
+                                    "msleep < 20ms can sleep for up to 20ms; see Documentation/timers/timers-howto.txt\n" . $line);
+                       }
+               }
+
+# warn about #ifdefs in C files
+#              if ($line =~ /^.\s*\#\s*if(|n)def/ && ($realfile =~ /\.c$/)) {
+#                      print "#ifdef in C files should be avoided\n";
+#                      print "$herecurr";
+#                      $clean = 0;
+#              }
+
+# warn about spacing in #ifdefs
+               if ($line =~ /^.\s*\#\s*(ifdef|ifndef|elif)\s\s+/) {
+                       ERROR("SPACING",
+                             "exactly one space required after that #$1\n" . $herecurr);
+               }
+
+# check for spinlock_t definitions without a comment.
+               if ($line =~ /^.\s*(struct\s+mutex|spinlock_t)\s+\S+;/ ||
+                   $line =~ /^.\s*(DEFINE_MUTEX)\s*\(/) {
+                       my $which = $1;
+                       if (!ctx_has_comment($first_line, $linenr)) {
+                               CHK("UNCOMMENTED_DEFINITION",
+                                   "$1 definition without comment\n" . $herecurr);
+                       }
+               }
+# check for memory barriers without a comment.
+               if ($line =~ /\b(mb|rmb|wmb|read_barrier_depends|smp_mb|smp_rmb|smp_wmb|smp_read_barrier_depends)\(/) {
+                       if (!ctx_has_comment($first_line, $linenr)) {
+                               CHK("MEMORY_BARRIER",
+                                   "memory barrier without comment\n" . $herecurr);
+                       }
+               }
+# check of hardware specific defines
+               if ($line =~ m@^.\s*\#\s*if.*\b(__i386__|__powerpc64__|__sun__|__s390x__)\b@ && $realfile !~ m@include/asm-@) {
+                       CHK("ARCH_DEFINES",
+                           "architecture specific defines should be avoided\n" .  $herecurr);
+               }
+
+# Check that the storage class is at the beginning of a declaration
+               if ($line =~ /\b$Storage\b/ && $line !~ /^.\s*$Storage\b/) {
+                       WARN("STORAGE_CLASS",
+                            "storage class should be at the beginning of the declaration\n" . $herecurr)
+               }
+
+# check the location of the inline attribute, that it is between
+# storage class and type.
+               if ($line =~ /\b$Type\s+$Inline\b/ ||
+                   $line =~ /\b$Inline\s+$Storage\b/) {
+                       ERROR("INLINE_LOCATION",
+                             "inline keyword should sit between storage class and type\n" . $herecurr);
+               }
+
+# Check for __inline__ and __inline, prefer inline
+               if ($line =~ /\b(__inline__|__inline)\b/) {
+                       WARN("INLINE",
+                            "plain inline is preferred over $1\n" . $herecurr);
+               }
+
+# Check for __attribute__ packed, prefer __packed
+               if ($line =~ /\b__attribute__\s*\(\s*\(.*\bpacked\b/) {
+                       WARN("PREFER_PACKED",
+                            "__packed is preferred over __attribute__((packed))\n" . $herecurr);
+               }
+
+# Check for __attribute__ aligned, prefer __aligned
+               if ($line =~ /\b__attribute__\s*\(\s*\(.*aligned/) {
+                       WARN("PREFER_ALIGNED",
+                            "__aligned(size) is preferred over __attribute__((aligned(size)))\n" . $herecurr);
+               }
+
+# Check for __attribute__ format(printf, prefer __printf
+               if ($line =~ /\b__attribute__\s*\(\s*\(\s*format\s*\(\s*printf/) {
+                       WARN("PREFER_PRINTF",
+                            "__printf(string-index, first-to-check) is preferred over __attribute__((format(printf, string-index, first-to-check)))\n" . $herecurr);
+               }
+
+# Check for __attribute__ format(scanf, prefer __scanf
+               if ($line =~ /\b__attribute__\s*\(\s*\(\s*format\s*\(\s*scanf\b/) {
+                       WARN("PREFER_SCANF",
+                            "__scanf(string-index, first-to-check) is preferred over __attribute__((format(scanf, string-index, first-to-check)))\n" . $herecurr);
+               }
+
+# check for sizeof(&)
+               if ($line =~ /\bsizeof\s*\(\s*\&/) {
+                       WARN("SIZEOF_ADDRESS",
+                            "sizeof(& should be avoided\n" . $herecurr);
+               }
+
+# check for sizeof without parenthesis
+               if ($line =~ /\bsizeof\s+((?:\*\s*|)$Lval|$Type(?:\s+$Lval|))/) {
+                       WARN("SIZEOF_PARENTHESIS",
+                            "sizeof $1 should be sizeof($1)\n" . $herecurr);
+               }
+
+# check for line continuations in quoted strings with odd counts of "
+               if ($rawline =~ /\\$/ && $rawline =~ tr/"/"/ % 2) {
+                       WARN("LINE_CONTINUATIONS",
+                            "Avoid line continuations in quoted strings\n" . $herecurr);
+               }
+
+# check for struct spinlock declarations
+               if ($line =~ /^.\s*\bstruct\s+spinlock\s+\w+\s*;/) {
+                       WARN("USE_SPINLOCK_T",
+                            "struct spinlock should be spinlock_t\n" . $herecurr);
+               }
+
+# Check for misused memsets
+               if ($^V && $^V ge 5.10.0 &&
+                   defined $stat &&
+                   $stat =~ /^\+(?:.*?)\bmemset\s*\(\s*$FuncArg\s*,\s*$FuncArg\s*\,\s*$FuncArg\s*\)/s) {
+
+                       my $ms_addr = $2;
+                       my $ms_val = $7;
+                       my $ms_size = $12;
+
+                       if ($ms_size =~ /^(0x|)0$/i) {
+                               ERROR("MEMSET",
+                                     "memset to 0's uses 0 as the 2nd argument, not the 3rd\n" . "$here\n$stat\n");
+                       } elsif ($ms_size =~ /^(0x|)1$/i) {
+                               WARN("MEMSET",
+                                    "single byte memset is suspicious. Swapped 2nd/3rd argument?\n" . "$here\n$stat\n");
+                       }
+               }
+
+# typecasts on min/max could be min_t/max_t
+               if ($^V && $^V ge 5.10.0 &&
+                   defined $stat &&
+                   $stat =~ /^\+(?:.*?)\b(min|max)\s*\(\s*$FuncArg\s*,\s*$FuncArg\s*\)/) {
+                       if (defined $2 || defined $7) {
+                               my $call = $1;
+                               my $cast1 = deparenthesize($2);
+                               my $arg1 = $3;
+                               my $cast2 = deparenthesize($7);
+                               my $arg2 = $8;
+                               my $cast;
+
+                               if ($cast1 ne "" && $cast2 ne "" && $cast1 ne $cast2) {
+                                       $cast = "$cast1 or $cast2";
+                               } elsif ($cast1 ne "") {
+                                       $cast = $cast1;
+                               } else {
+                                       $cast = $cast2;
+                               }
+                               WARN("MINMAX",
+                                    "$call() should probably be ${call}_t($cast, $arg1, $arg2)\n" . "$here\n$stat\n");
+                       }
+               }
+
+# check usleep_range arguments
+               if ($^V && $^V ge 5.10.0 &&
+                   defined $stat &&
+                   $stat =~ /^\+(?:.*?)\busleep_range\s*\(\s*($FuncArg)\s*,\s*($FuncArg)\s*\)/) {
+                       my $min = $1;
+                       my $max = $7;
+                       if ($min eq $max) {
+                               WARN("USLEEP_RANGE",
+                                    "usleep_range should not use min == max args; see Documentation/timers/timers-howto.txt\n" . "$here\n$stat\n");
+                       } elsif ($min =~ /^\d+$/ && $max =~ /^\d+$/ &&
+                                $min > $max) {
+                               WARN("USLEEP_RANGE",
+                                    "usleep_range args reversed, use min then max; see Documentation/timers/timers-howto.txt\n" . "$here\n$stat\n");
+                       }
+               }
+
+# check for new externs in .c files.
+               if ($realfile =~ /\.c$/ && defined $stat &&
+                   $stat =~ /^.\s*(?:extern\s+)?$Type\s+($Ident)(\s*)\(/s)
+               {
+                       my $function_name = $1;
+                       my $paren_space = $2;
+
+                       my $s = $stat;
+                       if (defined $cond) {
+                               substr($s, 0, length($cond), '');
+                       }
+                       if ($s =~ /^\s*;/ &&
+                           $function_name ne 'uninitialized_var')
+                       {
+                               WARN("AVOID_EXTERNS",
+                                    "externs should be avoided in .c files\n" .  $herecurr);
+                       }
+
+                       if ($paren_space =~ /\n/) {
+                               WARN("FUNCTION_ARGUMENTS",
+                                    "arguments for function declarations should follow identifier\n" . $herecurr);
+                       }
+
+               } elsif ($realfile =~ /\.c$/ && defined $stat &&
+                   $stat =~ /^.\s*extern\s+/)
+               {
+                       WARN("AVOID_EXTERNS",
+                            "externs should be avoided in .c files\n" .  $herecurr);
+               }
+
+# checks for new __setup's
+               if ($rawline =~ /\b__setup\("([^"]*)"/) {
+                       my $name = $1;
+
+                       if (!grep(/$name/, @setup_docs)) {
+                               CHK("UNDOCUMENTED_SETUP",
+                                   "__setup appears un-documented -- check Documentation/kernel-parameters.txt\n" . $herecurr);
+                       }
+               }
+
+# check for pointless casting of kmalloc return
+               if ($line =~ /\*\s*\)\s*[kv][czm]alloc(_node){0,1}\b/) {
+                       WARN("UNNECESSARY_CASTS",
+                            "unnecessary cast may hide bugs, see http://c-faq.com/malloc/mallocnocast.html\n" . $herecurr);
+               }
+
+# check for alloc argument mismatch
+               if ($line =~ /\b(kcalloc|kmalloc_array)\s*\(\s*sizeof\b/) {
+                       WARN("ALLOC_ARRAY_ARGS",
+                            "$1 uses number as first arg, sizeof is generally wrong\n" . $herecurr);
+               }
+
+# check for multiple semicolons
+               if ($line =~ /;\s*;\s*$/) {
+                       WARN("ONE_SEMICOLON",
+                            "Statements terminations use 1 semicolon\n" . $herecurr);
+               }
+
+# check for switch/default statements without a break;
+               if ($^V && $^V ge 5.10.0 &&
+                   defined $stat &&
+                   $stat =~ /^\+[$;\s]*(?:case[$;\s]+\w+[$;\s]*:[$;\s]*|)*[$;\s]*\bdefault[$;\s]*:[$;\s]*;/g) {
+                       my $ctx = '';
+                       my $herectx = $here . "\n";
+                       my $cnt = statement_rawlines($stat);
+                       for (my $n = 0; $n < $cnt; $n++) {
+                               $herectx .= raw_line($linenr, $n) . "\n";
+                       }
+                       WARN("DEFAULT_NO_BREAK",
+                            "switch default: should use break\n" . $herectx);
+               }
+
+# check for gcc specific __FUNCTION__
+               if ($line =~ /__FUNCTION__/) {
+                       WARN("USE_FUNC",
+                            "__func__ should be used instead of gcc specific __FUNCTION__\n"  . $herecurr);
+               }
+
+# check for use of yield()
+               if ($line =~ /\byield\s*\(\s*\)/) {
+                       WARN("YIELD",
+                            "Using yield() is generally wrong. See yield() kernel-doc (sched/core.c)\n"  . $herecurr);
+               }
+
+# check for semaphores initialized locked
+               if ($line =~ /^.\s*sema_init.+,\W?0\W?\)/) {
+                       WARN("CONSIDER_COMPLETION",
+                            "consider using a completion\n" . $herecurr);
+               }
+
+# recommend kstrto* over simple_strto* and strict_strto*
+               if ($line =~ /\b((simple|strict)_(strto(l|ll|ul|ull)))\s*\(/) {
+                       WARN("CONSIDER_KSTRTO",
+                            "$1 is obsolete, use k$3 instead\n" . $herecurr);
+               }
+
+# check for __initcall(), use device_initcall() explicitly please
+               if ($line =~ /^.\s*__initcall\s*\(/) {
+                       WARN("USE_DEVICE_INITCALL",
+                            "please use device_initcall() instead of __initcall()\n" . $herecurr);
+               }
+
+# check for various ops structs, ensure they are const.
+               my $struct_ops = qr{acpi_dock_ops|
+                               address_space_operations|
+                               backlight_ops|
+                               block_device_operations|
+                               dentry_operations|
+                               dev_pm_ops|
+                               dma_map_ops|
+                               extent_io_ops|
+                               file_lock_operations|
+                               file_operations|
+                               hv_ops|
+                               ide_dma_ops|
+                               intel_dvo_dev_ops|
+                               item_operations|
+                               iwl_ops|
+                               kgdb_arch|
+                               kgdb_io|
+                               kset_uevent_ops|
+                               lock_manager_operations|
+                               microcode_ops|
+                               mtrr_ops|
+                               neigh_ops|
+                               nlmsvc_binding|
+                               pci_raw_ops|
+                               pipe_buf_operations|
+                               platform_hibernation_ops|
+                               platform_suspend_ops|
+                               proto_ops|
+                               rpc_pipe_ops|
+                               seq_operations|
+                               snd_ac97_build_ops|
+                               soc_pcmcia_socket_ops|
+                               stacktrace_ops|
+                               sysfs_ops|
+                               tty_operations|
+                               usb_mon_operations|
+                               wd_ops}x;
+               if ($line !~ /\bconst\b/ &&
+                   $line =~ /\bstruct\s+($struct_ops)\b/) {
+                       WARN("CONST_STRUCT",
+                            "struct $1 should normally be const\n" .
+                               $herecurr);
+               }
+
+# use of NR_CPUS is usually wrong
+# ignore definitions of NR_CPUS and usage to define arrays as likely right
+               if ($line =~ /\bNR_CPUS\b/ &&
+                   $line !~ /^.\s*\s*#\s*if\b.*\bNR_CPUS\b/ &&
+                   $line !~ /^.\s*\s*#\s*define\b.*\bNR_CPUS\b/ &&
+                   $line !~ /^.\s*$Declare\s.*\[[^\]]*NR_CPUS[^\]]*\]/ &&
+                   $line !~ /\[[^\]]*\.\.\.[^\]]*NR_CPUS[^\]]*\]/ &&
+                   $line !~ /\[[^\]]*NR_CPUS[^\]]*\.\.\.[^\]]*\]/)
+               {
+                       WARN("NR_CPUS",
+                            "usage of NR_CPUS is often wrong - consider using cpu_possible(), num_possible_cpus(), for_each_possible_cpu(), etc\n" . $herecurr);
+               }
+
+# check for %L{u,d,i} in strings
+               my $string;
+               while ($line =~ /(?:^|")([X\t]*)(?:"|$)/g) {
+                       $string = substr($rawline, $-[1], $+[1] - $-[1]);
+                       $string =~ s/%%/__/g;
+                       if ($string =~ /(?<!%)%L[udi]/) {
+                               WARN("PRINTF_L",
+                                    "\%Ld/%Lu are not-standard C, use %lld/%llu\n" . $herecurr);
+                               last;
+                       }
+               }
+
+# whine mightly about in_atomic
+               if ($line =~ /\bin_atomic\s*\(/) {
+                       if ($realfile =~ m@^drivers/@) {
+                               ERROR("IN_ATOMIC",
+                                     "do not use in_atomic in drivers\n" . $herecurr);
+                       } elsif ($realfile !~ m@^kernel/@) {
+                               WARN("IN_ATOMIC",
+                                    "use of in_atomic() is incorrect outside core kernel code\n" . $herecurr);
+                       }
+               }
+
+# check for lockdep_set_novalidate_class
+               if ($line =~ /^.\s*lockdep_set_novalidate_class\s*\(/ ||
+                   $line =~ /__lockdep_no_validate__\s*\)/ ) {
+                       if ($realfile !~ m@^kernel/lockdep@ &&
+                           $realfile !~ m@^include/linux/lockdep@ &&
+                           $realfile !~ m@^drivers/base/core@) {
+                               ERROR("LOCKDEP",
+                                     "lockdep_no_validate class is reserved for device->mutex.\n" . $herecurr);
+                       }
+               }
+
+               if ($line =~ /debugfs_create_file.*S_IWUGO/ ||
+                   $line =~ /DEVICE_ATTR.*S_IWUGO/ ) {
+                       WARN("EXPORTED_WORLD_WRITABLE",
+                            "Exporting world writable files is usually an error. Consider more restrictive permissions.\n" . $herecurr);
+               }
+       }
+
+       # If we have no input at all, then there is nothing to report on
+       # so just keep quiet.
+       if ($#rawlines == -1) {
+               exit(0);
+       }
+
+       # In mailback mode only produce a report in the negative, for
+       # things that appear to be patches.
+       if ($mailback && ($clean == 1 || !$is_patch)) {
+               exit(0);
+       }
+
+       # This is not a patch, and we are are in 'no-patch' mode so
+       # just keep quiet.
+       if (!$chk_patch && !$is_patch) {
+               exit(0);
+       }
+
+       if (!$is_patch) {
+               ERROR("NOT_UNIFIED_DIFF",
+                     "Does not appear to be a unified-diff format patch\n");
+       }
+       if ($is_patch && $chk_signoff && $signoff == 0) {
+               ERROR("MISSING_SIGN_OFF",
+                     "Missing Signed-off-by: line(s)\n");
+       }
+
+       print report_dump();
+       if ($summary && !($clean == 1 && $quiet == 1)) {
+               print "$filename " if ($summary_file);
+               print "total: $cnt_error errors, $cnt_warn warnings, " .
+                       (($check)? "$cnt_chk checks, " : "") .
+                       "$cnt_lines lines checked\n";
+               print "\n" if ($quiet == 0);
+       }
+
+       if ($quiet == 0) {
+
+               if ($^V lt 5.10.0) {
+                       print("NOTE: perl $^V is not modern enough to detect all possible issues.\n");
+                       print("An upgrade to at least perl v5.10.0 is suggested.\n\n");
+               }
+
+               # If there were whitespace errors which cleanpatch can fix
+               # then suggest that.
+               if ($rpt_cleaners) {
+                       print "NOTE: whitespace errors detected, you may wish to use scripts/cleanpatch or\n";
+                       print "      scripts/cleanfile\n\n";
+                       $rpt_cleaners = 0;
+               }
+       }
+
+       if ($quiet == 0 && keys %ignore_type) {
+           print "NOTE: Ignored message types:";
+           foreach my $ignore (sort keys %ignore_type) {
+               print " $ignore";
+           }
+           print "\n\n";
+       }
+
+       if ($clean == 1 && $quiet == 0) {
+               print "$vname has no obvious style problems and is ready for submission.\n"
+       }
+       if ($clean == 0 && $quiet == 0) {
+               print << "EOM";
+$vname has style problems, please review.
+
+If any of these errors are false positives, please report
+them to the maintainer, see boards.cfg.
+EOM
+       }
+
+       return $clean;
+}
diff --git a/scripts/checkstack.pl b/scripts/checkstack.pl
new file mode 100755 (executable)
index 0000000..c1cdc0a
--- /dev/null
@@ -0,0 +1,171 @@
+#!/usr/bin/perl
+
+#      Check the stack usage of functions
+#
+#      Copyright Joern Engel <joern@lazybastard.org>
+#      Inspired by Linus Torvalds
+#      Original idea maybe from Keith Owens
+#      s390 port and big speedup by Arnd Bergmann <arnd@bergmann-dalldorf.de>
+#      Mips port by Juan Quintela <quintela@mandrakesoft.com>
+#      IA64 port via Andreas Dilger
+#      Arm port by Holger Schurig
+#      sh64 port by Paul Mundt
+#      Random bits by Matt Mackall <mpm@selenic.com>
+#      M68k port by Geert Uytterhoeven and Andreas Schwab
+#      AVR32 port by Haavard Skinnemoen (Atmel)
+#      PARISC port by Kyle McMartin <kyle@parisc-linux.org>
+#      sparc port by Martin Habets <errandir_news@mph.eclipse.co.uk>
+#
+#      Usage:
+#      objdump -d vmlinux | scripts/checkstack.pl [arch]
+#
+#      TODO :  Port to all architectures (one regex per arch)
+
+use strict;
+
+# check for arch
+#
+# $re is used for two matches:
+# $& (whole re) matches the complete objdump line with the stack growth
+# $1 (first bracket) matches the size of the stack growth
+#
+# $dre is similar, but for dynamic stack redutions:
+# $& (whole re) matches the complete objdump line with the stack growth
+# $1 (first bracket) matches the dynamic amount of the stack growth
+#
+# use anything else and feel the pain ;)
+my (@stack, $re, $dre, $x, $xs);
+{
+       my $arch = shift;
+       if ($arch eq "") {
+               $arch = `uname -m`;
+               chomp($arch);
+       }
+
+       $x      = "[0-9a-f]";   # hex character
+       $xs     = "[0-9a-f ]";  # hex character or space
+       if ($arch eq 'arm') {
+               #c0008ffc:      e24dd064        sub     sp, sp, #100    ; 0x64
+               $re = qr/.*sub.*sp, sp, #(([0-9]{2}|[3-9])[0-9]{2})/o;
+       } elsif ($arch eq 'avr32') {
+               #8000008a:       20 1d           sub sp,4
+               #80000ca8:       fa cd 05 b0     sub sp,sp,1456
+               $re = qr/^.*sub.*sp.*,([0-9]{1,8})/o;
+       } elsif ($arch =~ /^i[3456]86$/) {
+               #c0105234:       81 ec ac 05 00 00       sub    $0x5ac,%esp
+               $re = qr/^.*[as][du][db]    \$(0x$x{1,8}),\%esp$/o;
+               $dre = qr/^.*[as][du][db]    (%.*),\%esp$/o;
+       } elsif ($arch eq 'x86_64') {
+               #    2f60:      48 81 ec e8 05 00 00    sub    $0x5e8,%rsp
+               $re = qr/^.*[as][du][db]    \$(0x$x{1,8}),\%rsp$/o;
+               $dre = qr/^.*[as][du][db]    (\%.*),\%rsp$/o;
+       } elsif ($arch eq 'ia64') {
+               #e0000000044011fc:       01 0f fc 8c     adds r12=-384,r12
+               $re = qr/.*adds.*r12=-(([0-9]{2}|[3-9])[0-9]{2}),r12/o;
+       } elsif ($arch eq 'm68k') {
+               #    2b6c:       4e56 fb70       linkw %fp,#-1168
+               #  1df770:       defc ffe4       addaw #-28,%sp
+               $re = qr/.*(?:linkw %fp,|addaw )#-([0-9]{1,4})(?:,%sp)?$/o;
+       } elsif ($arch eq 'mips64') {
+               #8800402c:       67bdfff0        daddiu  sp,sp,-16
+               $re = qr/.*daddiu.*sp,sp,-(([0-9]{2}|[3-9])[0-9]{2})/o;
+       } elsif ($arch eq 'mips') {
+               #88003254:       27bdffe0        addiu   sp,sp,-32
+               $re = qr/.*addiu.*sp,sp,-(([0-9]{2}|[3-9])[0-9]{2})/o;
+       } elsif ($arch eq 'parisc' || $arch eq 'parisc64') {
+               $re = qr/.*ldo ($x{1,8})\(sp\),sp/o;
+       } elsif ($arch eq 'ppc') {
+               #c00029f4:       94 21 ff 30     stwu    r1,-208(r1)
+               $re = qr/.*stwu.*r1,-($x{1,8})\(r1\)/o;
+       } elsif ($arch eq 'ppc64') {
+               #XXX
+               $re = qr/.*stdu.*r1,-($x{1,8})\(r1\)/o;
+       } elsif ($arch eq 'powerpc') {
+               $re = qr/.*st[dw]u.*r1,-($x{1,8})\(r1\)/o;
+       } elsif ($arch =~ /^s390x?$/) {
+               #   11160:       a7 fb ff 60             aghi   %r15,-160
+               # or
+               #  100092:       e3 f0 ff c8 ff 71       lay     %r15,-56(%r15)
+               $re = qr/.*(?:lay|ag?hi).*\%r15,-(([0-9]{2}|[3-9])[0-9]{2})
+                     (?:\(\%r15\))?$/ox;
+       } elsif ($arch =~ /^sh64$/) {
+               #XXX: we only check for the immediate case presently,
+               #     though we will want to check for the movi/sub
+               #     pair for larger users. -- PFM.
+               #a00048e0:       d4fc40f0        addi.l  r15,-240,r15
+               $re = qr/.*addi\.l.*r15,-(([0-9]{2}|[3-9])[0-9]{2}),r15/o;
+       } elsif ($arch =~ /^blackfin$/) {
+               #   0:   00 e8 38 01     LINK 0x4e0;
+               $re = qr/.*[[:space:]]LINK[[:space:]]*(0x$x{1,8})/o;
+       } elsif ($arch eq 'sparc' || $arch eq 'sparc64') {
+               # f0019d10:       9d e3 bf 90     save  %sp, -112, %sp
+               $re = qr/.*save.*%sp, -(([0-9]{2}|[3-9])[0-9]{2}), %sp/o;
+       } else {
+               print("wrong or unknown architecture \"$arch\"\n");
+               exit
+       }
+}
+
+#
+# main()
+#
+my $funcre = qr/^$x* <(.*)>:$/;
+my ($func, $file, $lastslash);
+
+while (my $line = <STDIN>) {
+       if ($line =~ m/$funcre/) {
+               $func = $1;
+       }
+       elsif ($line =~ m/(.*):\s*file format/) {
+               $file = $1;
+               $file =~ s/\.ko//;
+               $lastslash = rindex($file, "/");
+               if ($lastslash != -1) {
+                       $file = substr($file, $lastslash + 1);
+               }
+       }
+       elsif ($line =~ m/$re/) {
+               my $size = $1;
+               $size = hex($size) if ($size =~ /^0x/);
+
+               if ($size > 0xf0000000) {
+                       $size = - $size;
+                       $size += 0x80000000;
+                       $size += 0x80000000;
+               }
+               next if ($size > 0x10000000);
+
+               next if $line !~ m/^($xs*)/;
+               my $addr = $1;
+               $addr =~ s/ /0/g;
+               $addr = "0x$addr";
+
+               my $intro = "$addr $func [$file]:";
+               my $padlen = 56 - length($intro);
+               while ($padlen > 0) {
+                       $intro .= '     ';
+                       $padlen -= 8;
+               }
+               next if ($size < 100);
+               push @stack, "$intro$size\n";
+       }
+       elsif (defined $dre && $line =~ m/$dre/) {
+               my $size = "Dynamic ($1)";
+
+               next if $line !~ m/^($xs*)/;
+               my $addr = $1;
+               $addr =~ s/ /0/g;
+               $addr = "0x$addr";
+
+               my $intro = "$addr $func [$file]:";
+               my $padlen = 56 - length($intro);
+               while ($padlen > 0) {
+                       $intro .= '     ';
+                       $padlen -= 8;
+               }
+               push @stack, "$intro$size\n";
+       }
+}
+
+# Sort output by size (last field)
+print sort { ($b =~ /:\t*(\d+)$/)[0] <=> ($a =~ /:\t*(\d+)$/)[0] } @stack;
diff --git a/scripts/cleanpatch b/scripts/cleanpatch
new file mode 100755 (executable)
index 0000000..9680d03
--- /dev/null
@@ -0,0 +1,258 @@
+#!/usr/bin/perl -w
+#
+# Clean a patch file -- or directory of patch files -- of stealth whitespace.
+# WARNING: this can be a highly destructive operation.  Use with caution.
+#
+
+use bytes;
+use File::Basename;
+
+# Default options
+$max_width = 79;
+
+# Clean up space-tab sequences, either by removing spaces or
+# replacing them with tabs.
+sub clean_space_tabs($)
+{
+    no bytes;                  # Tab alignment depends on characters
+
+    my($li) = @_;
+    my($lo) = '';
+    my $pos = 0;
+    my $nsp = 0;
+    my($i, $c);
+
+    for ($i = 0; $i < length($li); $i++) {
+       $c = substr($li, $i, 1);
+       if ($c eq "\t") {
+           my $npos = ($pos+$nsp+8) & ~7;
+           my $ntab = ($npos >> 3) - ($pos >> 3);
+           $lo .= "\t" x $ntab;
+           $pos = $npos;
+           $nsp = 0;
+       } elsif ($c eq "\n" || $c eq "\r") {
+           $lo .= " " x $nsp;
+           $pos += $nsp;
+           $nsp = 0;
+           $lo .= $c;
+           $pos = 0;
+       } elsif ($c eq " ") {
+           $nsp++;
+       } else {
+           $lo .= " " x $nsp;
+           $pos += $nsp;
+           $nsp = 0;
+           $lo .= $c;
+           $pos++;
+       }
+    }
+    $lo .= " " x $nsp;
+    return $lo;
+}
+
+# Compute the visual width of a string
+sub strwidth($) {
+    no bytes;                  # Tab alignment depends on characters
+
+    my($li) = @_;
+    my($c, $i);
+    my $pos = 0;
+    my $mlen = 0;
+
+    for ($i = 0; $i < length($li); $i++) {
+       $c = substr($li,$i,1);
+       if ($c eq "\t") {
+           $pos = ($pos+8) & ~7;
+       } elsif ($c eq "\n") {
+           $mlen = $pos if ($pos > $mlen);
+           $pos = 0;
+       } else {
+           $pos++;
+       }
+    }
+
+    $mlen = $pos if ($pos > $mlen);
+    return $mlen;
+}
+
+$name = basename($0);
+
+@files = ();
+
+while (defined($a = shift(@ARGV))) {
+    if ($a =~ /^-/) {
+       if ($a eq '-width' || $a eq '-w') {
+           $max_width = shift(@ARGV)+0;
+       } else {
+           print STDERR "Usage: $name [-width #] files...\n";
+           exit 1;
+       }
+    } else {
+       push(@files, $a);
+    }
+}
+
+foreach $f ( @files ) {
+    print STDERR "$name: $f\n";
+
+    if (! -f $f) {
+       print STDERR "$f: not a file\n";
+       next;
+    }
+
+    if (!open(FILE, '+<', $f)) {
+       print STDERR "$name: Cannot open file: $f: $!\n";
+       next;
+    }
+
+    binmode FILE;
+
+    # First, verify that it is not a binary file; consider any file
+    # with a zero byte to be a binary file.  Is there any better, or
+    # additional, heuristic that should be applied?
+    $is_binary = 0;
+
+    while (read(FILE, $data, 65536) > 0) {
+       if ($data =~ /\0/) {
+           $is_binary = 1;
+           last;
+       }
+    }
+
+    if ($is_binary) {
+       print STDERR "$name: $f: binary file\n";
+       next;
+    }
+
+    seek(FILE, 0, 0);
+
+    $in_bytes = 0;
+    $out_bytes = 0;
+    $lineno = 0;
+
+    @lines  = ();
+
+    $in_hunk = 0;
+    $err = 0;
+
+    while ( defined($line = <FILE>) ) {
+       $lineno++;
+       $in_bytes += length($line);
+
+       if (!$in_hunk) {
+           if ($line =~
+               /^\@\@\s+\-([0-9]+),([0-9]+)\s+\+([0-9]+),([0-9]+)\s\@\@/) {
+               $minus_lines = $2;
+               $plus_lines = $4;
+               if ($minus_lines || $plus_lines) {
+                   $in_hunk = 1;
+                   @hunk_lines = ($line);
+               }
+           } else {
+               push(@lines, $line);
+               $out_bytes += length($line);
+           }
+       } else {
+           # We're in a hunk
+
+           if ($line =~ /^\+/) {
+               $plus_lines--;
+
+               $text = substr($line, 1);
+               $text =~ s/[ \t\r]*$//;         # Remove trailing spaces
+               $text = clean_space_tabs($text);
+
+               $l_width = strwidth($text);
+               if ($max_width && $l_width > $max_width) {
+                   print STDERR
+                       "$f:$lineno: adds line exceeds $max_width ",
+                       "characters ($l_width)\n";
+               }
+
+               push(@hunk_lines, '+'.$text);
+           } elsif ($line =~ /^\-/) {
+               $minus_lines--;
+               push(@hunk_lines, $line);
+           } elsif ($line =~ /^ /) {
+               $plus_lines--;
+               $minus_lines--;
+               push(@hunk_lines, $line);
+           } else {
+               print STDERR "$name: $f: malformed patch\n";
+               $err = 1;
+               last;
+           }
+
+           if ($plus_lines < 0 || $minus_lines < 0) {
+               print STDERR "$name: $f: malformed patch\n";
+               $err = 1;
+               last;
+           } elsif ($plus_lines == 0 && $minus_lines == 0) {
+               # End of a hunk.  Process this hunk.
+               my $i;
+               my $l;
+               my @h = ();
+               my $adj = 0;
+               my $done = 0;
+
+               for ($i = scalar(@hunk_lines)-1; $i > 0; $i--) {
+                   $l = $hunk_lines[$i];
+                   if (!$done && $l eq "+\n") {
+                       $adj++; # Skip this line
+                   } elsif ($l =~ /^[ +]/) {
+                       $done = 1;
+                       unshift(@h, $l);
+                   } else {
+                       unshift(@h, $l);
+                   }
+               }
+
+               $l = $hunk_lines[0];  # Hunk header
+               undef @hunk_lines;    # Free memory
+
+               if ($adj) {
+                   die unless
+                       ($l =~ /^\@\@\s+\-([0-9]+),([0-9]+)\s+\+([0-9]+),([0-9]+)\s\@\@(.*)$/);
+                   my $mstart = $1;
+                   my $mlin = $2;
+                   my $pstart = $3;
+                   my $plin = $4;
+                   my $tail = $5; # doesn't include the final newline
+
+                   $l = sprintf("@@ -%d,%d +%d,%d @@%s\n",
+                                $mstart, $mlin, $pstart, $plin-$adj,
+                                $tail);
+               }
+               unshift(@h, $l);
+
+               # Transfer to the output array
+               foreach $l (@h) {
+                   $out_bytes += length($l);
+                   push(@lines, $l);
+               }
+
+               $in_hunk = 0;
+           }
+       }
+    }
+
+    if ($in_hunk) {
+       print STDERR "$name: $f: malformed patch\n";
+       $err = 1;
+    }
+
+    if (!$err) {
+       if ($in_bytes != $out_bytes) {
+           # Only write to the file if changed
+           seek(FILE, 0, 0);
+           print FILE @lines;
+
+           if ( !defined($where = tell(FILE)) ||
+                !truncate(FILE, $where) ) {
+               die "$name: Failed to truncate modified file: $f: $!\n";
+           }
+       }
+    }
+
+    close(FILE);
+}
diff --git a/scripts/dtc-version.sh b/scripts/dtc-version.sh
new file mode 100644 (file)
index 0000000..e8c94d3
--- /dev/null
@@ -0,0 +1,20 @@
+#!/bin/sh
+#
+# dtc-version dtc-command
+#
+# Prints the dtc version of `dtc-command' in a canonical 4-digit form
+# such as `0222' for binutils 2.22
+#
+
+dtc="$*"
+
+if [ ${#dtc} -eq 0 ]; then
+       echo "Error: No dtc command specified."
+       printf "Usage:\n\t$0 <dtc-command>\n"
+       exit 1
+fi
+
+MAJOR=$($dtc -v | head -1 | awk '{print $NF}' | cut -d . -f 1)
+MINOR=$($dtc -v | head -1 | awk '{print $NF}' | cut -d . -f 2)
+
+printf "%02d%02d\\n" $MAJOR $MINOR
diff --git a/scripts/gcc-version.sh b/scripts/gcc-version.sh
new file mode 100644 (file)
index 0000000..debecb5
--- /dev/null
@@ -0,0 +1,32 @@
+#!/bin/sh
+#
+# gcc-version [-p] gcc-command
+#
+# Prints the gcc version of `gcc-command' in a canonical 4-digit form
+# such as `0295' for gcc-2.95, `0303' for gcc-3.3, etc.
+#
+# With the -p option, prints the patchlevel as well, for example `029503' for
+# gcc-2.95.3, `030301' for gcc-3.3.1, etc.
+#
+
+if [ "$1" = "-p" ] ; then
+       with_patchlevel=1;
+       shift;
+fi
+
+compiler="$*"
+
+if [ ${#compiler} -eq 0 ]; then
+       echo "Error: No compiler specified."
+       printf "Usage:\n\t$0 <gcc-command>\n"
+       exit 1
+fi
+
+MAJOR=$(echo __GNUC__ | $compiler -E -xc - | tail -n 1)
+MINOR=$(echo __GNUC_MINOR__ | $compiler -E -xc - | tail -n 1)
+if [ "x$with_patchlevel" != "x" ] ; then
+       PATCHLEVEL=$(echo __GNUC_PATCHLEVEL__ | $compiler -E -xc - | tail -n 1)
+       printf "%02d%02d%02d\\n" $MAJOR $MINOR $PATCHLEVEL
+else
+       printf "%02d%02d\\n" $MAJOR $MINOR
+fi
diff --git a/scripts/setlocalversion b/scripts/setlocalversion
new file mode 100755 (executable)
index 0000000..f551b4c
--- /dev/null
@@ -0,0 +1,177 @@
+#!/bin/sh
+#
+# This scripts adds local version information from the version
+# control systems git, mercurial (hg) and subversion (svn).
+#
+# It was originally copied from the Linux kernel v3.2.0-rc4 and modified
+# to support the U-Boot build-system.
+#
+
+usage() {
+       echo "Usage: $0 [--save-scmversion] [srctree]" >&2
+       exit 1
+}
+
+scm_only=false
+srctree=.
+if test "$1" = "--save-scmversion"; then
+       scm_only=true
+       shift
+fi
+if test $# -gt 0; then
+       srctree=$1
+       shift
+fi
+if test $# -gt 0 -o ! -d "$srctree"; then
+       usage
+fi
+
+scm_version()
+{
+       local short
+       short=false
+
+       cd "$srctree"
+       if test -e .scmversion; then
+               cat .scmversion
+               return
+       fi
+       if test "$1" = "--short"; then
+               short=true
+       fi
+
+       # Check for git and a git repo.
+       if test -e .git && head=`git rev-parse --verify --short HEAD 2>/dev/null`; then
+
+               # If we are at a tagged commit (like "v2.6.30-rc6"), we ignore
+               # it, because this version is defined in the top level Makefile.
+               if [ -z "`git describe --exact-match 2>/dev/null`" ]; then
+
+                       # If only the short version is requested, don't bother
+                       # running further git commands
+                       if $short; then
+                               echo "+"
+                               return
+                       fi
+                       # If we are past a tagged commit (like
+                       # "v2.6.30-rc5-302-g72357d5"), we pretty print it.
+                       if atag="`git describe 2>/dev/null`"; then
+                               echo "$atag" | awk -F- '{printf("-%05d-%s", $(NF-1),$(NF))}'
+
+                       # If we don't have a tag at all we print -g{commitish}.
+                       else
+                               printf '%s%s' -g $head
+                       fi
+               fi
+
+               # Is this git on svn?
+               if git config --get svn-remote.svn.url >/dev/null; then
+                       printf -- '-svn%s' "`git svn find-rev $head`"
+               fi
+
+               # Update index only on r/w media
+               [ -w . ] && git update-index --refresh --unmerged > /dev/null
+
+               # Check for uncommitted changes
+               if git diff-index --name-only HEAD | grep -v "^scripts/package" \
+                   | read dummy; then
+                       printf '%s' -dirty
+               fi
+
+               # All done with git
+               return
+       fi
+
+       # Check for mercurial and a mercurial repo.
+       if test -d .hg && hgid=`hg id 2>/dev/null`; then
+               # Do we have an tagged version?  If so, latesttagdistance == 1
+               if [ "`hg log -r . --template '{latesttagdistance}'`" == "1" ]; then
+                       id=`hg log -r . --template '{latesttag}'`
+                       printf '%s%s' -hg "$id"
+               else
+                       tag=`printf '%s' "$hgid" | cut -d' ' -f2`
+                       if [ -z "$tag" -o "$tag" = tip ]; then
+                               id=`printf '%s' "$hgid" | sed 's/[+ ].*//'`
+                               printf '%s%s' -hg "$id"
+                       fi
+               fi
+
+               # Are there uncommitted changes?
+               # These are represented by + after the changeset id.
+               case "$hgid" in
+                       *+|*+\ *) printf '%s' -dirty ;;
+               esac
+
+               # All done with mercurial
+               return
+       fi
+
+       # Check for svn and a svn repo.
+       if rev=`svn info 2>/dev/null | grep '^Last Changed Rev'`; then
+               rev=`echo $rev | awk '{print $NF}'`
+               printf -- '-svn%s' "$rev"
+
+               # All done with svn
+               return
+       fi
+}
+
+collect_files()
+{
+       local file res
+
+       for file; do
+               case "$file" in
+               *\~*)
+                       continue
+                       ;;
+               esac
+               if test -e "$file"; then
+                       res="$res$(cat "$file")"
+               fi
+       done
+       echo "$res"
+}
+
+if $scm_only; then
+       if test ! -e .scmversion; then
+               res=$(scm_version)
+               echo "$res" >.scmversion
+       fi
+       exit
+fi
+
+#if test -e include/config/auto.conf; then
+#      . include/config/auto.conf
+#else
+#      echo "Error: kernelrelease not valid - run 'make prepare' to update it"
+#      exit 1
+#fi
+CONFIG_LOCALVERSION=
+CONFIG_LOCALVERSION_AUTO=y
+
+# localversion* files in the build and source directory
+res="$(collect_files localversion*)"
+if test ! "$srctree" -ef .; then
+       res="$res$(collect_files "$srctree"/localversion*)"
+fi
+
+# CONFIG_LOCALVERSION and LOCALVERSION (if set)
+res="${res}${CONFIG_LOCALVERSION}${LOCALVERSION}"
+
+# scm version string if not at a tagged commit
+if test "$CONFIG_LOCALVERSION_AUTO" = "y"; then
+       # full scm version string
+       res="$res$(scm_version)"
+else
+       # append a plus sign if the repository is not in a clean
+       # annotated or signed tagged state (as git describe only
+       # looks at signed or annotated tags - git tag -a/-s) and
+       # LOCALVERSION= is not specified
+       if test "${LOCALVERSION+set}" != "set"; then
+               scm=$(scm_version --short)
+               res="$res${scm:++}"
+       fi
+fi
+
+echo "$res"
diff --git a/spl/.gitignore b/spl/.gitignore
deleted file mode 100644 (file)
index 7c88147..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-u-boot-spl
-u-boot-spl.bin
-u-boot-spl.lds
-u-boot-spl.map
index 0caa982470bc5e6d5c28d9c08afdaec5d7c7a813..003956ebb34b980ffab28562603fe953c5c9beff 100644 (file)
@@ -37,22 +37,15 @@ endif
 HAVE_VENDOR_COMMON_LIB = $(if $(wildcard $(SRCTREE)/board/$(VENDOR)/common/Makefile),y,n)
 
 ifdef  CONFIG_SPL_START_S_PATH
-START_PATH := $(subst ",,$(CONFIG_SPL_START_S_PATH))
+START_PATH := $(CONFIG_SPL_START_S_PATH:"%"=%)
 else
 START_PATH := $(CPUDIR)
 endif
 
-START := $(START_PATH)/start.o
-ifeq ($(CPU),x86)
-START += $(START_PATH)/start16.o
-START += $(START_PATH)/resetvec.o
-endif
-ifeq ($(CPU),ppc4xx)
-START += $(START_PATH)/resetvec.o
-endif
-ifeq ($(CPU),mpc85xx)
-START += $(START_PATH)/resetvec.o
-endif
+head-y := $(START_PATH)/start.o
+head-$(CONFIG_X86) += $(START_PATH)/start16.o $(START_PATH)/resetvec.o
+head-$(CONFIG_4xx) += $(START_PATH)/resetvec.o
+head-$(CONFIG_MPC85xx) += $(START_PATH)/resetvec.o
 
 LIBS-y += arch/$(ARCH)/lib/
 
@@ -78,7 +71,7 @@ LIBS-y += fs/
 LIBS-$(CONFIG_SPL_LIBGENERIC_SUPPORT) += lib/
 LIBS-$(CONFIG_SPL_POWER_SUPPORT) += drivers/power/ \
        drivers/power/pmic/
-LIBS-$(CONFIG_SPL_NAND_SUPPORT) += drivers/mtd/nand/
+LIBS-$(if $(CONFIG_CMD_NAND),$(CONFIG_SPL_NAND_SUPPORT)) += drivers/mtd/nand/
 LIBS-$(CONFIG_SPL_ONENAND_SUPPORT) += drivers/mtd/onenand/
 LIBS-$(CONFIG_SPL_DMA_SUPPORT) += drivers/dma/
 LIBS-$(CONFIG_SPL_POST_MEM_SUPPORT) += post/drivers/
@@ -90,17 +83,13 @@ LIBS-$(CONFIG_SPL_MUSB_NEW_SUPPORT) += drivers/usb/musb-new/
 LIBS-$(CONFIG_SPL_USBETH_SUPPORT) += drivers/usb/gadget/
 LIBS-$(CONFIG_SPL_WATCHDOG_SUPPORT) += drivers/watchdog/
 
-ifneq (,$(CONFIG_MX23)$(filter $(SOC), mx25 mx27 mx5 mx6 mx31 mx35))
+ifneq (,$(CONFIG_MX23)$(CONFIG_MX35)$(filter $(SOC), mx25 mx27 mx5 mx6 mx31 mx35))
 LIBS-y += arch/$(ARCH)/imx-common/
 endif
 
 LIBS-$(CONFIG_ARM) += arch/arm/cpu/
 LIBS-$(CONFIG_PPC) += arch/powerpc/cpu/
 
-ifneq ($(CONFIG_MX23)$(CONFIG_MX35),)
-LIBS-y += arch/$(ARCH)/imx-common/
-endif
-
 LIBS-y := $(patsubst %/, %/built-in.o, $(LIBS-y))
 
 # Add GCC lib
@@ -109,7 +98,7 @@ PLATFORM_LIBGCC = $(SPLTREE)/arch/$(ARCH)/lib/libgcc.o
 PLATFORM_LIBS := $(filter-out %/libgcc.o, $(filter-out -lgcc, $(PLATFORM_LIBS))) $(PLATFORM_LIBGCC)
 endif
 
-START := $(addprefix $(SPLTREE)/,$(START))
+START := $(addprefix $(SPLTREE)/,$(head-y))
 LIBS := $(addprefix $(SPLTREE)/,$(sort $(LIBS-y)))
 
 __START := $(subst $(obj),,$(START))
@@ -118,7 +107,7 @@ __LIBS := $(subst $(obj),,$(LIBS))
 # Linker Script
 ifdef CONFIG_SPL_LDSCRIPT
 # need to strip off double quotes
-LDSCRIPT := $(addprefix $(SRCTREE)/,$(subst ",,$(CONFIG_SPL_LDSCRIPT)))
+LDSCRIPT := $(addprefix $(SRCTREE)/,$(CONFIG_SPL_LDSCRIPT:"%"=%))
 endif
 
 ifeq ($(wildcard $(LDSCRIPT)),)
diff --git a/test/image/test-imagetools.sh b/test/image/test-imagetools.sh
new file mode 100755 (executable)
index 0000000..9e299e1
--- /dev/null
@@ -0,0 +1,141 @@
+#!/bin/bash
+#
+# Written by Guilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
+#
+# Sanity check for mkimage and dumpimage tools
+#
+# SPDX-License-Identifier:     GPL-2.0+
+#
+# To run this:
+#
+# make O=sandbox sandbox_config
+# make O=sandbox
+# ./test/image/test-imagetools.sh
+
+BASEDIR=sandbox
+SRCDIR=sandbox/boot
+IMAGE_NAME="v1.0-test"
+IMAGE=linux.img
+DATAFILE0=vmlinuz
+DATAFILE1=initrd.img
+DATAFILE2=System.map
+DATAFILES="${DATAFILE0} ${DATAFILE1} ${DATAFILE2}"
+TEST_OUT=test_output
+MKIMAGE=${BASEDIR}/tools/mkimage
+DUMPIMAGE=${BASEDIR}/tools/dumpimage
+MKIMAGE_LIST=mkimage.list
+DUMPIMAGE_LIST=dumpimage.list
+
+# Remove all the files we created
+cleanup()
+{
+       local file
+
+       for file in ${DATAFILES}; do
+               rm -f ${file} ${SRCDIR}/${file}
+       done
+       rm -f ${IMAGE} ${DUMPIMAGE_LIST} ${MKIMAGE_LIST} ${TEST_OUT}
+       rmdir ${SRCDIR}
+}
+
+# Check that two files are the same
+assert_equal()
+{
+       if ! diff $1 $2; then
+               echo "Failed."
+               cleanup
+               exit 1
+       fi
+}
+
+# Create some test files
+create_files()
+{
+       local file
+
+       mkdir -p ${SRCDIR}
+       for file in ${DATAFILES}; do
+               head -c $RANDOM /dev/urandom >${SRCDIR}/${file}
+       done
+}
+
+# Run a command, echoing it first
+do_cmd()
+{
+       local cmd="$@"
+
+       echo "# ${cmd}"
+       ${cmd} 2>&1
+}
+
+# Run a command, redirecting output
+# Args:
+#    redirect_file
+#    command...
+do_cmd_redir()
+{
+       local redir="$1"
+       shift
+       local cmd="$@"
+
+       echo "# ${cmd}"
+       ${cmd} >${redir}
+}
+
+# Write files into an image
+create_image()
+{
+       local files="${SRCDIR}/${DATAFILE0}:${SRCDIR}/${DATAFILE1}"
+       files+=":${SRCDIR}/${DATAFILE2}"
+
+       echo -e "\nBuilding image..."
+       do_cmd ${MKIMAGE} -A x86 -O linux -T multi -n \"${IMAGE_NAME}\" \
+               -d ${files} ${IMAGE}
+       echo "done."
+}
+
+# Extract files from an image
+extract_image()
+{
+       echo -e "\nExtracting image contents..."
+       do_cmd ${DUMPIMAGE} -i ${IMAGE} -p 0 ${DATAFILE0}
+       do_cmd ${DUMPIMAGE} -i ${IMAGE} -p 1 ${DATAFILE1}
+       do_cmd ${DUMPIMAGE} -i ${IMAGE} -p 2 ${DATAFILE2}
+       do_cmd ${DUMPIMAGE} -i ${IMAGE} -p 2 ${DATAFILE2} -o ${TEST_OUT}
+       echo "done."
+}
+
+# List the contents of a file
+list_image()
+{
+       echo -e "\nListing image contents..."
+       do_cmd_redir ${MKIMAGE_LIST} ${MKIMAGE} -l ${IMAGE}
+       do_cmd_redir ${DUMPIMAGE_LIST} ${DUMPIMAGE} -l ${IMAGE}
+       echo "done."
+}
+
+main()
+{
+       local file
+
+       create_files
+
+       # Compress and extract multifile images, compare the result
+       create_image
+       extract_image
+       for file in ${DATAFILES}; do
+               assert_equal ${file} ${SRCDIR}/${file}
+       done
+       assert_equal ${TEST_OUT} ${DATAFILE2}
+
+       # List contents and compares output fro tools
+       list_image
+       assert_equal ${DUMPIMAGE_LIST} ${MKIMAGE_LIST}
+
+       # Remove files created
+       cleanup
+
+       echo "Tests passed."
+}
+
+main
index a7fee26cdd41087fe5e1f68482ce6b650fca62c9..930fa2e8a0eaf933677346dc166957cd162568b4 100644 (file)
@@ -3,12 +3,12 @@
 /gen_eth_addr
 /img2srec
 /kwboot
+/dumpimage
 /mkenvimage
 /mkimage
 /mpc86x_clk
 /mxsboot
 /ncb
-/ncp
 /proftool
 /ubsha1
 /xway-swap-bytes
index 4a7e7e572888ecef8be9f0bf453758b4bb86b77e..328cea319ed7fffb32c047de17b2e6d66732ff81 100644 (file)
@@ -50,6 +50,7 @@ BIN_FILES-$(CONFIG_BUILD_ENVCRC) += envcrc$(SFX)
 BIN_FILES-$(CONFIG_CMD_NET) += gen_eth_addr$(SFX)
 BIN_FILES-$(CONFIG_CMD_LOADS) += img2srec$(SFX)
 BIN_FILES-$(CONFIG_XWAY_SWAP_BYTES) += xway-swap-bytes$(SFX)
+BIN_FILES-y += dumpimage$(SFX)
 BIN_FILES-y += mkenvimage$(SFX)
 BIN_FILES-y += mkimage$(SFX)
 BIN_FILES-$(CONFIG_EXYNOS5250) += mk$(BOARD)spl$(SFX)
@@ -74,10 +75,12 @@ EXT_OBJ_FILES-y += lib/sha1.o
 # Source files located in the tools directory
 NOPED_OBJ_FILES-y += aisimage.o
 NOPED_OBJ_FILES-y += default_image.o
+NOPED_OBJ_FILES-y += dumpimage.o
 NOPED_OBJ_FILES-y += fit_image.o
 NOPED_OBJ_FILES-y += image-host.o
 NOPED_OBJ_FILES-y += imximage.o
 NOPED_OBJ_FILES-y += kwbimage.o
+NOPED_OBJ_FILES-y += imagetool.o
 NOPED_OBJ_FILES-y += mkenvimage.o
 NOPED_OBJ_FILES-y += mkimage.o
 NOPED_OBJ_FILES-y += mxsimage.o
@@ -202,6 +205,30 @@ $(obj)xway-swap-bytes$(SFX):       $(obj)xway-swap-bytes.o
        $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
        $(HOSTSTRIP) $@
 
+$(obj)dumpimage$(SFX): $(obj)aisimage.o \
+                       $(FIT_SIG_OBJS) \
+                       $(obj)crc32.o \
+                       $(obj)default_image.o \
+                       $(obj)fit_image.o \
+                       $(obj)image-fit.o \
+                       $(obj)image.o \
+                       $(obj)image-host.o \
+                       $(obj)imagetool.o \
+                       $(obj)imximage.o \
+                       $(obj)kwbimage.o \
+                       $(obj)dumpimage.o \
+                       $(obj)md5.o \
+                       $(obj)mxsimage.o \
+                       $(obj)omapimage.o \
+                       $(obj)os_support.o \
+                       $(obj)pblimage.o \
+                       $(obj)sha1.o \
+                       $(obj)ublimage.o \
+                       $(LIBFDT_OBJS) \
+                       $(RSA_OBJS)
+       $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^ $(HOSTLIBS)
+       $(HOSTSTRIP) $@
+
 $(obj)mkenvimage$(SFX):        $(obj)crc32.o $(obj)mkenvimage.o \
        $(obj)os_support.o
        $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
@@ -215,6 +242,7 @@ $(obj)mkimage$(SFX):        $(obj)aisimage.o \
                        $(obj)image-fit.o \
                        $(obj)image-host.o \
                        $(obj)image.o \
+                       $(obj)imagetool.o \
                        $(obj)imximage.o \
                        $(obj)kwbimage.o \
                        $(obj)md5.o \
index 04fb649899bd7beb9698aab044f74eb8125cdd1f..8de370a2e08d4cb7deff61f333c5986c722b77f9 100644 (file)
@@ -5,7 +5,7 @@
  * SPDX-License-Identifier:    GPL-2.0+
  */
 
-#include "mkimage.h"
+#include "imagetool.h"
 #include "aisimage.h"
 #include <image.h>
 
@@ -176,7 +176,7 @@ static uint32_t *ais_insert_cmd_header(uint32_t cmd, uint32_t nargs,
 
 }
 
-static uint32_t *ais_alloc_buffer(struct mkimage_params *params)
+static uint32_t *ais_alloc_buffer(struct image_tool_params *params)
 {
        int dfd;
        struct stat sbuf;
@@ -216,7 +216,7 @@ static uint32_t *ais_alloc_buffer(struct mkimage_params *params)
        return ptr;
 }
 
-static uint32_t *ais_copy_image(struct mkimage_params *params,
+static uint32_t *ais_copy_image(struct image_tool_params *params,
        uint32_t *aisptr)
 
 {
@@ -252,7 +252,7 @@ static uint32_t *ais_copy_image(struct mkimage_params *params,
 
 }
 
-static int aisimage_generate(struct mkimage_params *params,
+static int aisimage_generate(struct image_tool_params *params,
        struct image_type_params *tparams)
 {
        FILE *fd = NULL;
@@ -370,7 +370,7 @@ static int aisimage_check_image_types(uint8_t type)
 }
 
 static int aisimage_verify_header(unsigned char *ptr, int image_size,
-                       struct mkimage_params *params)
+                       struct image_tool_params *params)
 {
        struct ais_header *ais_hdr = (struct ais_header *)ptr;
 
@@ -384,11 +384,11 @@ static int aisimage_verify_header(unsigned char *ptr, int image_size,
 }
 
 static void aisimage_set_header(void *ptr, struct stat *sbuf, int ifd,
-                               struct mkimage_params *params)
+                               struct image_tool_params *params)
 {
 }
 
-int aisimage_check_params(struct mkimage_params *params)
+int aisimage_check_params(struct image_tool_params *params)
 {
        if (!params)
                return CFG_INVALID;
@@ -427,5 +427,5 @@ static struct image_type_params aisimage_params = {
 
 void init_ais_image_type(void)
 {
-       mkimage_register(&aisimage_params);
+       register_image_type(&aisimage_params);
 }
diff --git a/tools/binutils-version.sh b/tools/binutils-version.sh
deleted file mode 100755 (executable)
index d4d9eb4..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/bin/sh
-#
-# binutils-version [-p] gas-command
-#
-# Prints the binutils version of `gas-command' in a canonical 4-digit form
-# such as `0222' for binutils 2.22
-#
-
-gas="$*"
-
-if [ ${#gas} -eq 0 ]; then
-       echo "Error: No assembler specified."
-       printf "Usage:\n\t$0 <gas-command>\n"
-       exit 1
-fi
-
-MAJOR=$($gas --version | head -1 | awk '{print $NF}' | cut -d . -f 1)
-MINOR=$($gas --version | head -1 | awk '{print $NF}' | cut -d . -f 2)
-
-printf "%02d%02d\\n" $MAJOR $MINOR
diff --git a/tools/checkpatch.pl b/tools/checkpatch.pl
deleted file mode 100755 (executable)
index 88c5bc7..0000000
+++ /dev/null
@@ -1,3709 +0,0 @@
-#!/usr/bin/perl -w
-# (c) 2001, Dave Jones. (the file handling bit)
-# (c) 2005, Joel Schopp <jschopp@austin.ibm.com> (the ugly bit)
-# (c) 2007,2008, Andy Whitcroft <apw@uk.ibm.com> (new conditions, test suite)
-# (c) 2008-2010 Andy Whitcroft <apw@canonical.com>
-# Licensed under the terms of the GNU GPL License version 2
-
-use strict;
-
-my $P = $0;
-$P =~ s@.*/@@g;
-
-my $V = '0.32';
-
-use Getopt::Long qw(:config no_auto_abbrev);
-
-my $quiet = 0;
-my $tree = 1;
-my $chk_signoff = 1;
-my $chk_patch = 1;
-my $tst_only;
-my $emacs = 0;
-my $terse = 0;
-my $file = 0;
-my $check = 0;
-my $summary = 1;
-my $mailback = 0;
-my $summary_file = 0;
-my $show_types = 0;
-my $root;
-my %debug;
-my %ignore_type = ();
-my @ignore = ();
-my $help = 0;
-my $configuration_file = ".checkpatch.conf";
-my $max_line_length = 80;
-
-sub help {
-       my ($exitcode) = @_;
-
-       print << "EOM";
-Usage: $P [OPTION]... [FILE]...
-Version: $V
-
-Options:
-  -q, --quiet                quiet
-  --no-tree                  run without a kernel tree
-  --no-signoff               do not check for 'Signed-off-by' line
-  --patch                    treat FILE as patchfile (default)
-  --emacs                    emacs compile window format
-  --terse                    one line per report
-  -f, --file                 treat FILE as regular source file
-  --subjective, --strict     enable more subjective tests
-  --ignore TYPE(,TYPE2...)   ignore various comma separated message types
-  --max-line-length=n        set the maximum line length, if exceeded, warn
-  --show-types               show the message "types" in the output
-  --root=PATH                PATH to the kernel tree root
-  --no-summary               suppress the per-file summary
-  --mailback                 only produce a report in case of warnings/errors
-  --summary-file             include the filename in summary
-  --debug KEY=[0|1]          turn on/off debugging of KEY, where KEY is one of
-                             'values', 'possible', 'type', and 'attr' (default
-                             is all off)
-  --test-only=WORD           report only warnings/errors containing WORD
-                             literally
-  -h, --help, --version      display this help and exit
-
-When FILE is - read standard input.
-EOM
-
-       exit($exitcode);
-}
-
-my $conf = which_conf($configuration_file);
-if (-f $conf) {
-       my @conf_args;
-       open(my $conffile, '<', "$conf")
-           or warn "$P: Can't find a readable $configuration_file file $!\n";
-
-       while (<$conffile>) {
-               my $line = $_;
-
-               $line =~ s/\s*\n?$//g;
-               $line =~ s/^\s*//g;
-               $line =~ s/\s+/ /g;
-
-               next if ($line =~ m/^\s*#/);
-               next if ($line =~ m/^\s*$/);
-
-               my @words = split(" ", $line);
-               foreach my $word (@words) {
-                       last if ($word =~ m/^#/);
-                       push (@conf_args, $word);
-               }
-       }
-       close($conffile);
-       unshift(@ARGV, @conf_args) if @conf_args;
-}
-
-GetOptions(
-       'q|quiet+'      => \$quiet,
-       'tree!'         => \$tree,
-       'signoff!'      => \$chk_signoff,
-       'patch!'        => \$chk_patch,
-       'emacs!'        => \$emacs,
-       'terse!'        => \$terse,
-       'f|file!'       => \$file,
-       'subjective!'   => \$check,
-       'strict!'       => \$check,
-       'ignore=s'      => \@ignore,
-       'show-types!'   => \$show_types,
-       'max-line-length=i' => \$max_line_length,
-       'root=s'        => \$root,
-       'summary!'      => \$summary,
-       'mailback!'     => \$mailback,
-       'summary-file!' => \$summary_file,
-
-       'debug=s'       => \%debug,
-       'test-only=s'   => \$tst_only,
-       'h|help'        => \$help,
-       'version'       => \$help
-) or help(1);
-
-help(0) if ($help);
-
-my $exit = 0;
-
-if ($#ARGV < 0) {
-       print "$P: no input files\n";
-       exit(1);
-}
-
-@ignore = split(/,/, join(',',@ignore));
-foreach my $word (@ignore) {
-       $word =~ s/\s*\n?$//g;
-       $word =~ s/^\s*//g;
-       $word =~ s/\s+/ /g;
-       $word =~ tr/[a-z]/[A-Z]/;
-
-       next if ($word =~ m/^\s*#/);
-       next if ($word =~ m/^\s*$/);
-
-       $ignore_type{$word}++;
-}
-
-my $dbg_values = 0;
-my $dbg_possible = 0;
-my $dbg_type = 0;
-my $dbg_attr = 0;
-for my $key (keys %debug) {
-       ## no critic
-       eval "\${dbg_$key} = '$debug{$key}';";
-       die "$@" if ($@);
-}
-
-my $rpt_cleaners = 0;
-
-if ($terse) {
-       $emacs = 1;
-       $quiet++;
-}
-
-if ($tree) {
-       if (defined $root) {
-               if (!top_of_kernel_tree($root)) {
-                       die "$P: $root: --root does not point at a valid tree\n";
-               }
-       } else {
-               if (top_of_kernel_tree('.')) {
-                       $root = '.';
-               } elsif ($0 =~ m@(.*)/scripts/[^/]*$@ &&
-                                               top_of_kernel_tree($1)) {
-                       $root = $1;
-               }
-       }
-
-       if (!defined $root) {
-               print "Must be run from the top-level dir. of a kernel tree\n";
-               exit(2);
-       }
-}
-
-my $emitted_corrupt = 0;
-
-our $Ident     = qr{
-                       [A-Za-z_][A-Za-z\d_]*
-                       (?:\s*\#\#\s*[A-Za-z_][A-Za-z\d_]*)*
-               }x;
-our $Storage   = qr{extern|static|asmlinkage};
-our $Sparse    = qr{
-                       __user|
-                       __kernel|
-                       __force|
-                       __iomem|
-                       __must_check|
-                       __init_refok|
-                       __kprobes|
-                       __ref|
-                       __rcu
-               }x;
-
-# Notes to $Attribute:
-# We need \b after 'init' otherwise 'initconst' will cause a false positive in a check
-our $Attribute = qr{
-                       const|
-                       __percpu|
-                       __nocast|
-                       __safe|
-                       __bitwise__|
-                       __packed__|
-                       __packed2__|
-                       __naked|
-                       __maybe_unused|
-                       __always_unused|
-                       __noreturn|
-                       __used|
-                       __cold|
-                       __noclone|
-                       __deprecated|
-                       __read_mostly|
-                       __kprobes|
-                       __(?:mem|cpu|dev|)(?:initdata|initconst|init\b)|
-                       ____cacheline_aligned|
-                       ____cacheline_aligned_in_smp|
-                       ____cacheline_internodealigned_in_smp|
-                       __weak
-                 }x;
-our $Modifier;
-our $Inline    = qr{inline|__always_inline|noinline};
-our $Member    = qr{->$Ident|\.$Ident|\[[^]]*\]};
-our $Lval      = qr{$Ident(?:$Member)*};
-
-our $Float_hex = qr{(?i)0x[0-9a-f]+p-?[0-9]+[fl]?};
-our $Float_dec = qr{(?i)(?:[0-9]+\.[0-9]*|[0-9]*\.[0-9]+)(?:e-?[0-9]+)?[fl]?};
-our $Float_int = qr{(?i)[0-9]+e-?[0-9]+[fl]?};
-our $Float     = qr{$Float_hex|$Float_dec|$Float_int};
-our $Constant  = qr{$Float|(?i)(?:0x[0-9a-f]+|[0-9]+)[ul]*};
-our $Assignment        = qr{\*\=|/=|%=|\+=|-=|<<=|>>=|&=|\^=|\|=|=};
-our $Compare    = qr{<=|>=|==|!=|<|>};
-our $Operators = qr{
-                       <=|>=|==|!=|
-                       =>|->|<<|>>|<|>|!|~|
-                       &&|\|\||,|\^|\+\+|--|&|\||\+|-|\*|\/|%
-                 }x;
-
-our $NonptrType;
-our $Type;
-our $Declare;
-
-our $NON_ASCII_UTF8    = qr{
-       [\xC2-\xDF][\x80-\xBF]               # non-overlong 2-byte
-       |  \xE0[\xA0-\xBF][\x80-\xBF]        # excluding overlongs
-       | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}  # straight 3-byte
-       |  \xED[\x80-\x9F][\x80-\xBF]        # excluding surrogates
-       |  \xF0[\x90-\xBF][\x80-\xBF]{2}     # planes 1-3
-       | [\xF1-\xF3][\x80-\xBF]{3}          # planes 4-15
-       |  \xF4[\x80-\x8F][\x80-\xBF]{2}     # plane 16
-}x;
-
-our $UTF8      = qr{
-       [\x09\x0A\x0D\x20-\x7E]              # ASCII
-       | $NON_ASCII_UTF8
-}x;
-
-our $typeTypedefs = qr{(?x:
-       (?:__)?(?:u|s|be|le)(?:8|16|32|64)|
-       atomic_t
-)};
-
-our $logFunctions = qr{(?x:
-       printk(?:_ratelimited|_once|)|
-       [a-z0-9]+_(?:printk|emerg|alert|crit|err|warning|warn|notice|info|debug|dbg|vdbg|devel|cont|WARN)(?:_ratelimited|_once|)|
-       WARN(?:_RATELIMIT|_ONCE|)|
-       panic|
-       debug|
-       printf|
-       MODULE_[A-Z_]+
-)};
-
-our $signature_tags = qr{(?xi:
-       Signed-off-by:|
-       Acked-by:|
-       Tested-by:|
-       Reviewed-by:|
-       Reported-by:|
-       To:|
-       Cc:
-)};
-
-our @typeList = (
-       qr{void},
-       qr{(?:unsigned\s+)?char},
-       qr{(?:unsigned\s+)?short},
-       qr{(?:unsigned\s+)?int},
-       qr{(?:unsigned\s+)?long},
-       qr{(?:unsigned\s+)?long\s+int},
-       qr{(?:unsigned\s+)?long\s+long},
-       qr{(?:unsigned\s+)?long\s+long\s+int},
-       qr{unsigned},
-       qr{float},
-       qr{double},
-       qr{bool},
-       qr{struct\s+$Ident},
-       qr{union\s+$Ident},
-       qr{enum\s+$Ident},
-       qr{${Ident}_t},
-       qr{${Ident}_handler},
-       qr{${Ident}_handler_fn},
-);
-our @modifierList = (
-       qr{fastcall},
-);
-
-our $allowed_asm_includes = qr{(?x:
-       irq|
-       memory
-)};
-# memory.h: ARM has a custom one
-
-sub build_types {
-       my $mods = "(?x:  \n" . join("|\n  ", @modifierList) . "\n)";
-       my $all = "(?x:  \n" . join("|\n  ", @typeList) . "\n)";
-       $Modifier       = qr{(?:$Attribute|$Sparse|$mods)};
-       $NonptrType     = qr{
-                       (?:$Modifier\s+|const\s+)*
-                       (?:
-                               (?:typeof|__typeof__)\s*\([^\)]*\)|
-                               (?:$typeTypedefs\b)|
-                               (?:${all}\b)
-                       )
-                       (?:\s+$Modifier|\s+const)*
-                 }x;
-       $Type   = qr{
-                       $NonptrType
-                       (?:(?:\s|\*|\[\])+\s*const|(?:\s|\*|\[\])+|(?:\s*\[\s*\])+)?
-                       (?:\s+$Inline|\s+$Modifier)*
-                 }x;
-       $Declare        = qr{(?:$Storage\s+)?$Type};
-}
-build_types();
-
-
-our $Typecast  = qr{\s*(\(\s*$NonptrType\s*\)){0,1}\s*};
-
-# Using $balanced_parens, $LvalOrFunc, or $FuncArg
-# requires at least perl version v5.10.0
-# Any use must be runtime checked with $^V
-
-our $balanced_parens = qr/(\((?:[^\(\)]++|(?-1))*\))/;
-our $LvalOrFunc        = qr{($Lval)\s*($balanced_parens{0,1})\s*};
-our $FuncArg = qr{$Typecast{0,1}($LvalOrFunc|$Constant)};
-
-sub deparenthesize {
-       my ($string) = @_;
-       return "" if (!defined($string));
-       $string =~ s@^\s*\(\s*@@g;
-       $string =~ s@\s*\)\s*$@@g;
-       $string =~ s@\s+@ @g;
-       return $string;
-}
-
-$chk_signoff = 0 if ($file);
-
-my @rawlines = ();
-my @lines = ();
-my $vname;
-for my $filename (@ARGV) {
-       my $FILE;
-       if ($file) {
-               open($FILE, '-|', "diff -u /dev/null $filename") ||
-                       die "$P: $filename: diff failed - $!\n";
-       } elsif ($filename eq '-') {
-               open($FILE, '<&STDIN');
-       } else {
-               open($FILE, '<', "$filename") ||
-                       die "$P: $filename: open failed - $!\n";
-       }
-       if ($filename eq '-') {
-               $vname = 'Your patch';
-       } else {
-               $vname = $filename;
-       }
-       while (<$FILE>) {
-               chomp;
-               push(@rawlines, $_);
-       }
-       close($FILE);
-       if (!process($filename)) {
-               $exit = 1;
-       }
-       @rawlines = ();
-       @lines = ();
-}
-
-exit($exit);
-
-sub top_of_kernel_tree {
-       my ($root) = @_;
-
-       my @tree_check = (
-               "COPYING", "CREDITS", "Kbuild", "Makefile",
-               "README", "Documentation", "arch", "include", "drivers",
-               "fs", "init", "ipc", "kernel", "lib", "scripts",
-       );
-
-       foreach my $check (@tree_check) {
-               if (! -e $root . '/' . $check) {
-                       return 0;
-               }
-       }
-       return 1;
-}
-
-sub parse_email {
-       my ($formatted_email) = @_;
-
-       my $name = "";
-       my $address = "";
-       my $comment = "";
-
-       if ($formatted_email =~ /^(.*)<(\S+\@\S+)>(.*)$/) {
-               $name = $1;
-               $address = $2;
-               $comment = $3 if defined $3;
-       } elsif ($formatted_email =~ /^\s*<(\S+\@\S+)>(.*)$/) {
-               $address = $1;
-               $comment = $2 if defined $2;
-       } elsif ($formatted_email =~ /(\S+\@\S+)(.*)$/) {
-               $address = $1;
-               $comment = $2 if defined $2;
-               $formatted_email =~ s/$address.*$//;
-               $name = $formatted_email;
-               $name =~ s/^\s+|\s+$//g;
-               $name =~ s/^\"|\"$//g;
-               # If there's a name left after stripping spaces and
-               # leading quotes, and the address doesn't have both
-               # leading and trailing angle brackets, the address
-               # is invalid. ie:
-               #   "joe smith joe@smith.com" bad
-               #   "joe smith <joe@smith.com" bad
-               if ($name ne "" && $address !~ /^<[^>]+>$/) {
-                       $name = "";
-                       $address = "";
-                       $comment = "";
-               }
-       }
-
-       $name =~ s/^\s+|\s+$//g;
-       $name =~ s/^\"|\"$//g;
-       $address =~ s/^\s+|\s+$//g;
-       $address =~ s/^\<|\>$//g;
-
-       if ($name =~ /[^\w \-]/i) { ##has "must quote" chars
-               $name =~ s/(?<!\\)"/\\"/g; ##escape quotes
-               $name = "\"$name\"";
-       }
-
-       return ($name, $address, $comment);
-}
-
-sub format_email {
-       my ($name, $address) = @_;
-
-       my $formatted_email;
-
-       $name =~ s/^\s+|\s+$//g;
-       $name =~ s/^\"|\"$//g;
-       $address =~ s/^\s+|\s+$//g;
-
-       if ($name =~ /[^\w \-]/i) { ##has "must quote" chars
-               $name =~ s/(?<!\\)"/\\"/g; ##escape quotes
-               $name = "\"$name\"";
-       }
-
-       if ("$name" eq "") {
-               $formatted_email = "$address";
-       } else {
-               $formatted_email = "$name <$address>";
-       }
-
-       return $formatted_email;
-}
-
-sub which_conf {
-       my ($conf) = @_;
-
-       foreach my $path (split(/:/, ".:$ENV{HOME}:.scripts")) {
-               if (-e "$path/$conf") {
-                       return "$path/$conf";
-               }
-       }
-
-       return "";
-}
-
-sub expand_tabs {
-       my ($str) = @_;
-
-       my $res = '';
-       my $n = 0;
-       for my $c (split(//, $str)) {
-               if ($c eq "\t") {
-                       $res .= ' ';
-                       $n++;
-                       for (; ($n % 8) != 0; $n++) {
-                               $res .= ' ';
-                       }
-                       next;
-               }
-               $res .= $c;
-               $n++;
-       }
-
-       return $res;
-}
-sub copy_spacing {
-       (my $res = shift) =~ tr/\t/ /c;
-       return $res;
-}
-
-sub line_stats {
-       my ($line) = @_;
-
-       # Drop the diff line leader and expand tabs
-       $line =~ s/^.//;
-       $line = expand_tabs($line);
-
-       # Pick the indent from the front of the line.
-       my ($white) = ($line =~ /^(\s*)/);
-
-       return (length($line), length($white));
-}
-
-my $sanitise_quote = '';
-
-sub sanitise_line_reset {
-       my ($in_comment) = @_;
-
-       if ($in_comment) {
-               $sanitise_quote = '*/';
-       } else {
-               $sanitise_quote = '';
-       }
-}
-sub sanitise_line {
-       my ($line) = @_;
-
-       my $res = '';
-       my $l = '';
-
-       my $qlen = 0;
-       my $off = 0;
-       my $c;
-
-       # Always copy over the diff marker.
-       $res = substr($line, 0, 1);
-
-       for ($off = 1; $off < length($line); $off++) {
-               $c = substr($line, $off, 1);
-
-               # Comments we are wacking completly including the begin
-               # and end, all to $;.
-               if ($sanitise_quote eq '' && substr($line, $off, 2) eq '/*') {
-                       $sanitise_quote = '*/';
-
-                       substr($res, $off, 2, "$;$;");
-                       $off++;
-                       next;
-               }
-               if ($sanitise_quote eq '*/' && substr($line, $off, 2) eq '*/') {
-                       $sanitise_quote = '';
-                       substr($res, $off, 2, "$;$;");
-                       $off++;
-                       next;
-               }
-               if ($sanitise_quote eq '' && substr($line, $off, 2) eq '//') {
-                       $sanitise_quote = '//';
-
-                       substr($res, $off, 2, $sanitise_quote);
-                       $off++;
-                       next;
-               }
-
-               # A \ in a string means ignore the next character.
-               if (($sanitise_quote eq "'" || $sanitise_quote eq '"') &&
-                   $c eq "\\") {
-                       substr($res, $off, 2, 'XX');
-                       $off++;
-                       next;
-               }
-               # Regular quotes.
-               if ($c eq "'" || $c eq '"') {
-                       if ($sanitise_quote eq '') {
-                               $sanitise_quote = $c;
-
-                               substr($res, $off, 1, $c);
-                               next;
-                       } elsif ($sanitise_quote eq $c) {
-                               $sanitise_quote = '';
-                       }
-               }
-
-               #print "c<$c> SQ<$sanitise_quote>\n";
-               if ($off != 0 && $sanitise_quote eq '*/' && $c ne "\t") {
-                       substr($res, $off, 1, $;);
-               } elsif ($off != 0 && $sanitise_quote eq '//' && $c ne "\t") {
-                       substr($res, $off, 1, $;);
-               } elsif ($off != 0 && $sanitise_quote && $c ne "\t") {
-                       substr($res, $off, 1, 'X');
-               } else {
-                       substr($res, $off, 1, $c);
-               }
-       }
-
-       if ($sanitise_quote eq '//') {
-               $sanitise_quote = '';
-       }
-
-       # The pathname on a #include may be surrounded by '<' and '>'.
-       if ($res =~ /^.\s*\#\s*include\s+\<(.*)\>/) {
-               my $clean = 'X' x length($1);
-               $res =~ s@\<.*\>@<$clean>@;
-
-       # The whole of a #error is a string.
-       } elsif ($res =~ /^.\s*\#\s*(?:error|warning)\s+(.*)\b/) {
-               my $clean = 'X' x length($1);
-               $res =~ s@(\#\s*(?:error|warning)\s+).*@$1$clean@;
-       }
-
-       return $res;
-}
-
-sub ctx_statement_block {
-       my ($linenr, $remain, $off) = @_;
-       my $line = $linenr - 1;
-       my $blk = '';
-       my $soff = $off;
-       my $coff = $off - 1;
-       my $coff_set = 0;
-
-       my $loff = 0;
-
-       my $type = '';
-       my $level = 0;
-       my @stack = ();
-       my $p;
-       my $c;
-       my $len = 0;
-
-       my $remainder;
-       while (1) {
-               @stack = (['', 0]) if ($#stack == -1);
-
-               #warn "CSB: blk<$blk> remain<$remain>\n";
-               # If we are about to drop off the end, pull in more
-               # context.
-               if ($off >= $len) {
-                       for (; $remain > 0; $line++) {
-                               last if (!defined $lines[$line]);
-                               next if ($lines[$line] =~ /^-/);
-                               $remain--;
-                               $loff = $len;
-                               $blk .= $lines[$line] . "\n";
-                               $len = length($blk);
-                               $line++;
-                               last;
-                       }
-                       # Bail if there is no further context.
-                       #warn "CSB: blk<$blk> off<$off> len<$len>\n";
-                       if ($off >= $len) {
-                               last;
-                       }
-                       if ($level == 0 && substr($blk, $off) =~ /^.\s*#\s*define/) {
-                               $level++;
-                               $type = '#';
-                       }
-               }
-               $p = $c;
-               $c = substr($blk, $off, 1);
-               $remainder = substr($blk, $off);
-
-               #warn "CSB: c<$c> type<$type> level<$level> remainder<$remainder> coff_set<$coff_set>\n";
-
-               # Handle nested #if/#else.
-               if ($remainder =~ /^#\s*(?:ifndef|ifdef|if)\s/) {
-                       push(@stack, [ $type, $level ]);
-               } elsif ($remainder =~ /^#\s*(?:else|elif)\b/) {
-                       ($type, $level) = @{$stack[$#stack - 1]};
-               } elsif ($remainder =~ /^#\s*endif\b/) {
-                       ($type, $level) = @{pop(@stack)};
-               }
-
-               # Statement ends at the ';' or a close '}' at the
-               # outermost level.
-               if ($level == 0 && $c eq ';') {
-                       last;
-               }
-
-               # An else is really a conditional as long as its not else if
-               if ($level == 0 && $coff_set == 0 &&
-                               (!defined($p) || $p =~ /(?:\s|\}|\+)/) &&
-                               $remainder =~ /^(else)(?:\s|{)/ &&
-                               $remainder !~ /^else\s+if\b/) {
-                       $coff = $off + length($1) - 1;
-                       $coff_set = 1;
-                       #warn "CSB: mark coff<$coff> soff<$soff> 1<$1>\n";
-                       #warn "[" . substr($blk, $soff, $coff - $soff + 1) . "]\n";
-               }
-
-               if (($type eq '' || $type eq '(') && $c eq '(') {
-                       $level++;
-                       $type = '(';
-               }
-               if ($type eq '(' && $c eq ')') {
-                       $level--;
-                       $type = ($level != 0)? '(' : '';
-
-                       if ($level == 0 && $coff < $soff) {
-                               $coff = $off;
-                               $coff_set = 1;
-                               #warn "CSB: mark coff<$coff>\n";
-                       }
-               }
-               if (($type eq '' || $type eq '{') && $c eq '{') {
-                       $level++;
-                       $type = '{';
-               }
-               if ($type eq '{' && $c eq '}') {
-                       $level--;
-                       $type = ($level != 0)? '{' : '';
-
-                       if ($level == 0) {
-                               if (substr($blk, $off + 1, 1) eq ';') {
-                                       $off++;
-                               }
-                               last;
-                       }
-               }
-               # Preprocessor commands end at the newline unless escaped.
-               if ($type eq '#' && $c eq "\n" && $p ne "\\") {
-                       $level--;
-                       $type = '';
-                       $off++;
-                       last;
-               }
-               $off++;
-       }
-       # We are truly at the end, so shuffle to the next line.
-       if ($off == $len) {
-               $loff = $len + 1;
-               $line++;
-               $remain--;
-       }
-
-       my $statement = substr($blk, $soff, $off - $soff + 1);
-       my $condition = substr($blk, $soff, $coff - $soff + 1);
-
-       #warn "STATEMENT<$statement>\n";
-       #warn "CONDITION<$condition>\n";
-
-       #print "coff<$coff> soff<$off> loff<$loff>\n";
-
-       return ($statement, $condition,
-                       $line, $remain + 1, $off - $loff + 1, $level);
-}
-
-sub statement_lines {
-       my ($stmt) = @_;
-
-       # Strip the diff line prefixes and rip blank lines at start and end.
-       $stmt =~ s/(^|\n)./$1/g;
-       $stmt =~ s/^\s*//;
-       $stmt =~ s/\s*$//;
-
-       my @stmt_lines = ($stmt =~ /\n/g);
-
-       return $#stmt_lines + 2;
-}
-
-sub statement_rawlines {
-       my ($stmt) = @_;
-
-       my @stmt_lines = ($stmt =~ /\n/g);
-
-       return $#stmt_lines + 2;
-}
-
-sub statement_block_size {
-       my ($stmt) = @_;
-
-       $stmt =~ s/(^|\n)./$1/g;
-       $stmt =~ s/^\s*{//;
-       $stmt =~ s/}\s*$//;
-       $stmt =~ s/^\s*//;
-       $stmt =~ s/\s*$//;
-
-       my @stmt_lines = ($stmt =~ /\n/g);
-       my @stmt_statements = ($stmt =~ /;/g);
-
-       my $stmt_lines = $#stmt_lines + 2;
-       my $stmt_statements = $#stmt_statements + 1;
-
-       if ($stmt_lines > $stmt_statements) {
-               return $stmt_lines;
-       } else {
-               return $stmt_statements;
-       }
-}
-
-sub ctx_statement_full {
-       my ($linenr, $remain, $off) = @_;
-       my ($statement, $condition, $level);
-
-       my (@chunks);
-
-       # Grab the first conditional/block pair.
-       ($statement, $condition, $linenr, $remain, $off, $level) =
-                               ctx_statement_block($linenr, $remain, $off);
-       #print "F: c<$condition> s<$statement> remain<$remain>\n";
-       push(@chunks, [ $condition, $statement ]);
-       if (!($remain > 0 && $condition =~ /^\s*(?:\n[+-])?\s*(?:if|else|do)\b/s)) {
-               return ($level, $linenr, @chunks);
-       }
-
-       # Pull in the following conditional/block pairs and see if they
-       # could continue the statement.
-       for (;;) {
-               ($statement, $condition, $linenr, $remain, $off, $level) =
-                               ctx_statement_block($linenr, $remain, $off);
-               #print "C: c<$condition> s<$statement> remain<$remain>\n";
-               last if (!($remain > 0 && $condition =~ /^(?:\s*\n[+-])*\s*(?:else|do)\b/s));
-               #print "C: push\n";
-               push(@chunks, [ $condition, $statement ]);
-       }
-
-       return ($level, $linenr, @chunks);
-}
-
-sub ctx_block_get {
-       my ($linenr, $remain, $outer, $open, $close, $off) = @_;
-       my $line;
-       my $start = $linenr - 1;
-       my $blk = '';
-       my @o;
-       my @c;
-       my @res = ();
-
-       my $level = 0;
-       my @stack = ($level);
-       for ($line = $start; $remain > 0; $line++) {
-               next if ($rawlines[$line] =~ /^-/);
-               $remain--;
-
-               $blk .= $rawlines[$line];
-
-               # Handle nested #if/#else.
-               if ($lines[$line] =~ /^.\s*#\s*(?:ifndef|ifdef|if)\s/) {
-                       push(@stack, $level);
-               } elsif ($lines[$line] =~ /^.\s*#\s*(?:else|elif)\b/) {
-                       $level = $stack[$#stack - 1];
-               } elsif ($lines[$line] =~ /^.\s*#\s*endif\b/) {
-                       $level = pop(@stack);
-               }
-
-               foreach my $c (split(//, $lines[$line])) {
-                       ##print "C<$c>L<$level><$open$close>O<$off>\n";
-                       if ($off > 0) {
-                               $off--;
-                               next;
-                       }
-
-                       if ($c eq $close && $level > 0) {
-                               $level--;
-                               last if ($level == 0);
-                       } elsif ($c eq $open) {
-                               $level++;
-                       }
-               }
-
-               if (!$outer || $level <= 1) {
-                       push(@res, $rawlines[$line]);
-               }
-
-               last if ($level == 0);
-       }
-
-       return ($level, @res);
-}
-sub ctx_block_outer {
-       my ($linenr, $remain) = @_;
-
-       my ($level, @r) = ctx_block_get($linenr, $remain, 1, '{', '}', 0);
-       return @r;
-}
-sub ctx_block {
-       my ($linenr, $remain) = @_;
-
-       my ($level, @r) = ctx_block_get($linenr, $remain, 0, '{', '}', 0);
-       return @r;
-}
-sub ctx_statement {
-       my ($linenr, $remain, $off) = @_;
-
-       my ($level, @r) = ctx_block_get($linenr, $remain, 0, '(', ')', $off);
-       return @r;
-}
-sub ctx_block_level {
-       my ($linenr, $remain) = @_;
-
-       return ctx_block_get($linenr, $remain, 0, '{', '}', 0);
-}
-sub ctx_statement_level {
-       my ($linenr, $remain, $off) = @_;
-
-       return ctx_block_get($linenr, $remain, 0, '(', ')', $off);
-}
-
-sub ctx_locate_comment {
-       my ($first_line, $end_line) = @_;
-
-       # Catch a comment on the end of the line itself.
-       my ($current_comment) = ($rawlines[$end_line - 1] =~ m@.*(/\*.*\*/)\s*(?:\\\s*)?$@);
-       return $current_comment if (defined $current_comment);
-
-       # Look through the context and try and figure out if there is a
-       # comment.
-       my $in_comment = 0;
-       $current_comment = '';
-       for (my $linenr = $first_line; $linenr < $end_line; $linenr++) {
-               my $line = $rawlines[$linenr - 1];
-               #warn "           $line\n";
-               if ($linenr == $first_line and $line =~ m@^.\s*\*@) {
-                       $in_comment = 1;
-               }
-               if ($line =~ m@/\*@) {
-                       $in_comment = 1;
-               }
-               if (!$in_comment && $current_comment ne '') {
-                       $current_comment = '';
-               }
-               $current_comment .= $line . "\n" if ($in_comment);
-               if ($line =~ m@\*/@) {
-                       $in_comment = 0;
-               }
-       }
-
-       chomp($current_comment);
-       return($current_comment);
-}
-sub ctx_has_comment {
-       my ($first_line, $end_line) = @_;
-       my $cmt = ctx_locate_comment($first_line, $end_line);
-
-       ##print "LINE: $rawlines[$end_line - 1 ]\n";
-       ##print "CMMT: $cmt\n";
-
-       return ($cmt ne '');
-}
-
-sub raw_line {
-       my ($linenr, $cnt) = @_;
-
-       my $offset = $linenr - 1;
-       $cnt++;
-
-       my $line;
-       while ($cnt) {
-               $line = $rawlines[$offset++];
-               next if (defined($line) && $line =~ /^-/);
-               $cnt--;
-       }
-
-       return $line;
-}
-
-sub cat_vet {
-       my ($vet) = @_;
-       my ($res, $coded);
-
-       $res = '';
-       while ($vet =~ /([^[:cntrl:]]*)([[:cntrl:]]|$)/g) {
-               $res .= $1;
-               if ($2 ne '') {
-                       $coded = sprintf("^%c", unpack('C', $2) + 64);
-                       $res .= $coded;
-               }
-       }
-       $res =~ s/$/\$/;
-
-       return $res;
-}
-
-my $av_preprocessor = 0;
-my $av_pending;
-my @av_paren_type;
-my $av_pend_colon;
-
-sub annotate_reset {
-       $av_preprocessor = 0;
-       $av_pending = '_';
-       @av_paren_type = ('E');
-       $av_pend_colon = 'O';
-}
-
-sub annotate_values {
-       my ($stream, $type) = @_;
-
-       my $res;
-       my $var = '_' x length($stream);
-       my $cur = $stream;
-
-       print "$stream\n" if ($dbg_values > 1);
-
-       while (length($cur)) {
-               @av_paren_type = ('E') if ($#av_paren_type < 0);
-               print " <" . join('', @av_paren_type) .
-                               "> <$type> <$av_pending>" if ($dbg_values > 1);
-               if ($cur =~ /^(\s+)/o) {
-                       print "WS($1)\n" if ($dbg_values > 1);
-                       if ($1 =~ /\n/ && $av_preprocessor) {
-                               $type = pop(@av_paren_type);
-                               $av_preprocessor = 0;
-                       }
-
-               } elsif ($cur =~ /^(\(\s*$Type\s*)\)/ && $av_pending eq '_') {
-                       print "CAST($1)\n" if ($dbg_values > 1);
-                       push(@av_paren_type, $type);
-                       $type = 'c';
-
-               } elsif ($cur =~ /^($Type)\s*(?:$Ident|,|\)|\(|\s*$)/) {
-                       print "DECLARE($1)\n" if ($dbg_values > 1);
-                       $type = 'T';
-
-               } elsif ($cur =~ /^($Modifier)\s*/) {
-                       print "MODIFIER($1)\n" if ($dbg_values > 1);
-                       $type = 'T';
-
-               } elsif ($cur =~ /^(\#\s*define\s*$Ident)(\(?)/o) {
-                       print "DEFINE($1,$2)\n" if ($dbg_values > 1);
-                       $av_preprocessor = 1;
-                       push(@av_paren_type, $type);
-                       if ($2 ne '') {
-                               $av_pending = 'N';
-                       }
-                       $type = 'E';
-
-               } elsif ($cur =~ /^(\#\s*(?:undef\s*$Ident|include\b))/o) {
-                       print "UNDEF($1)\n" if ($dbg_values > 1);
-                       $av_preprocessor = 1;
-                       push(@av_paren_type, $type);
-
-               } elsif ($cur =~ /^(\#\s*(?:ifdef|ifndef|if))/o) {
-                       print "PRE_START($1)\n" if ($dbg_values > 1);
-                       $av_preprocessor = 1;
-
-                       push(@av_paren_type, $type);
-                       push(@av_paren_type, $type);
-                       $type = 'E';
-
-               } elsif ($cur =~ /^(\#\s*(?:else|elif))/o) {
-                       print "PRE_RESTART($1)\n" if ($dbg_values > 1);
-                       $av_preprocessor = 1;
-
-                       push(@av_paren_type, $av_paren_type[$#av_paren_type]);
-
-                       $type = 'E';
-
-               } elsif ($cur =~ /^(\#\s*(?:endif))/o) {
-                       print "PRE_END($1)\n" if ($dbg_values > 1);
-
-                       $av_preprocessor = 1;
-
-                       # Assume all arms of the conditional end as this
-                       # one does, and continue as if the #endif was not here.
-                       pop(@av_paren_type);
-                       push(@av_paren_type, $type);
-                       $type = 'E';
-
-               } elsif ($cur =~ /^(\\\n)/o) {
-                       print "PRECONT($1)\n" if ($dbg_values > 1);
-
-               } elsif ($cur =~ /^(__attribute__)\s*\(?/o) {
-                       print "ATTR($1)\n" if ($dbg_values > 1);
-                       $av_pending = $type;
-                       $type = 'N';
-
-               } elsif ($cur =~ /^(sizeof)\s*(\()?/o) {
-                       print "SIZEOF($1)\n" if ($dbg_values > 1);
-                       if (defined $2) {
-                               $av_pending = 'V';
-                       }
-                       $type = 'N';
-
-               } elsif ($cur =~ /^(if|while|for)\b/o) {
-                       print "COND($1)\n" if ($dbg_values > 1);
-                       $av_pending = 'E';
-                       $type = 'N';
-
-               } elsif ($cur =~/^(case)/o) {
-                       print "CASE($1)\n" if ($dbg_values > 1);
-                       $av_pend_colon = 'C';
-                       $type = 'N';
-
-               } elsif ($cur =~/^(return|else|goto|typeof|__typeof__)\b/o) {
-                       print "KEYWORD($1)\n" if ($dbg_values > 1);
-                       $type = 'N';
-
-               } elsif ($cur =~ /^(\()/o) {
-                       print "PAREN('$1')\n" if ($dbg_values > 1);
-                       push(@av_paren_type, $av_pending);
-                       $av_pending = '_';
-                       $type = 'N';
-
-               } elsif ($cur =~ /^(\))/o) {
-                       my $new_type = pop(@av_paren_type);
-                       if ($new_type ne '_') {
-                               $type = $new_type;
-                               print "PAREN('$1') -> $type\n"
-                                                       if ($dbg_values > 1);
-                       } else {
-                               print "PAREN('$1')\n" if ($dbg_values > 1);
-                       }
-
-               } elsif ($cur =~ /^($Ident)\s*\(/o) {
-                       print "FUNC($1)\n" if ($dbg_values > 1);
-                       $type = 'V';
-                       $av_pending = 'V';
-
-               } elsif ($cur =~ /^($Ident\s*):(?:\s*\d+\s*(,|=|;))?/) {
-                       if (defined $2 && $type eq 'C' || $type eq 'T') {
-                               $av_pend_colon = 'B';
-                       } elsif ($type eq 'E') {
-                               $av_pend_colon = 'L';
-                       }
-                       print "IDENT_COLON($1,$type>$av_pend_colon)\n" if ($dbg_values > 1);
-                       $type = 'V';
-
-               } elsif ($cur =~ /^($Ident|$Constant)/o) {
-                       print "IDENT($1)\n" if ($dbg_values > 1);
-                       $type = 'V';
-
-               } elsif ($cur =~ /^($Assignment)/o) {
-                       print "ASSIGN($1)\n" if ($dbg_values > 1);
-                       $type = 'N';
-
-               } elsif ($cur =~/^(;|{|})/) {
-                       print "END($1)\n" if ($dbg_values > 1);
-                       $type = 'E';
-                       $av_pend_colon = 'O';
-
-               } elsif ($cur =~/^(,)/) {
-                       print "COMMA($1)\n" if ($dbg_values > 1);
-                       $type = 'C';
-
-               } elsif ($cur =~ /^(\?)/o) {
-                       print "QUESTION($1)\n" if ($dbg_values > 1);
-                       $type = 'N';
-
-               } elsif ($cur =~ /^(:)/o) {
-                       print "COLON($1,$av_pend_colon)\n" if ($dbg_values > 1);
-
-                       substr($var, length($res), 1, $av_pend_colon);
-                       if ($av_pend_colon eq 'C' || $av_pend_colon eq 'L') {
-                               $type = 'E';
-                       } else {
-                               $type = 'N';
-                       }
-                       $av_pend_colon = 'O';
-
-               } elsif ($cur =~ /^(\[)/o) {
-                       print "CLOSE($1)\n" if ($dbg_values > 1);
-                       $type = 'N';
-
-               } elsif ($cur =~ /^(-(?![->])|\+(?!\+)|\*|\&\&|\&)/o) {
-                       my $variant;
-
-                       print "OPV($1)\n" if ($dbg_values > 1);
-                       if ($type eq 'V') {
-                               $variant = 'B';
-                       } else {
-                               $variant = 'U';
-                       }
-
-                       substr($var, length($res), 1, $variant);
-                       $type = 'N';
-
-               } elsif ($cur =~ /^($Operators)/o) {
-                       print "OP($1)\n" if ($dbg_values > 1);
-                       if ($1 ne '++' && $1 ne '--') {
-                               $type = 'N';
-                       }
-
-               } elsif ($cur =~ /(^.)/o) {
-                       print "C($1)\n" if ($dbg_values > 1);
-               }
-               if (defined $1) {
-                       $cur = substr($cur, length($1));
-                       $res .= $type x length($1);
-               }
-       }
-
-       return ($res, $var);
-}
-
-sub possible {
-       my ($possible, $line) = @_;
-       my $notPermitted = qr{(?:
-               ^(?:
-                       $Modifier|
-                       $Storage|
-                       $Type|
-                       DEFINE_\S+
-               )$|
-               ^(?:
-                       goto|
-                       return|
-                       case|
-                       else|
-                       asm|__asm__|
-                       do|
-                       \#|
-                       \#\#|
-               )(?:\s|$)|
-               ^(?:typedef|struct|enum)\b
-           )}x;
-       warn "CHECK<$possible> ($line)\n" if ($dbg_possible > 2);
-       if ($possible !~ $notPermitted) {
-               # Check for modifiers.
-               $possible =~ s/\s*$Storage\s*//g;
-               $possible =~ s/\s*$Sparse\s*//g;
-               if ($possible =~ /^\s*$/) {
-
-               } elsif ($possible =~ /\s/) {
-                       $possible =~ s/\s*$Type\s*//g;
-                       for my $modifier (split(' ', $possible)) {
-                               if ($modifier !~ $notPermitted) {
-                                       warn "MODIFIER: $modifier ($possible) ($line)\n" if ($dbg_possible);
-                                       push(@modifierList, $modifier);
-                               }
-                       }
-
-               } else {
-                       warn "POSSIBLE: $possible ($line)\n" if ($dbg_possible);
-                       push(@typeList, $possible);
-               }
-               build_types();
-       } else {
-               warn "NOTPOSS: $possible ($line)\n" if ($dbg_possible > 1);
-       }
-}
-
-my $prefix = '';
-
-sub show_type {
-       return !defined $ignore_type{$_[0]};
-}
-
-sub report {
-       if (!show_type($_[1]) ||
-           (defined $tst_only && $_[2] !~ /\Q$tst_only\E/)) {
-               return 0;
-       }
-       my $line;
-       if ($show_types) {
-               $line = "$prefix$_[0]:$_[1]: $_[2]\n";
-       } else {
-               $line = "$prefix$_[0]: $_[2]\n";
-       }
-       $line = (split('\n', $line))[0] . "\n" if ($terse);
-
-       push(our @report, $line);
-
-       return 1;
-}
-sub report_dump {
-       our @report;
-}
-
-sub ERROR {
-       if (report("ERROR", $_[0], $_[1])) {
-               our $clean = 0;
-               our $cnt_error++;
-       }
-}
-sub WARN {
-       if (report("WARNING", $_[0], $_[1])) {
-               our $clean = 0;
-               our $cnt_warn++;
-       }
-}
-sub CHK {
-       if ($check && report("CHECK", $_[0], $_[1])) {
-               our $clean = 0;
-               our $cnt_chk++;
-       }
-}
-
-sub check_absolute_file {
-       my ($absolute, $herecurr) = @_;
-       my $file = $absolute;
-
-       ##print "absolute<$absolute>\n";
-
-       # See if any suffix of this path is a path within the tree.
-       while ($file =~ s@^[^/]*/@@) {
-               if (-f "$root/$file") {
-                       ##print "file<$file>\n";
-                       last;
-               }
-       }
-       if (! -f _)  {
-               return 0;
-       }
-
-       # It is, so see if the prefix is acceptable.
-       my $prefix = $absolute;
-       substr($prefix, -length($file)) = '';
-
-       ##print "prefix<$prefix>\n";
-       if ($prefix ne ".../") {
-               WARN("USE_RELATIVE_PATH",
-                    "use relative pathname instead of absolute in changelog text\n" . $herecurr);
-       }
-}
-
-sub pos_last_openparen {
-       my ($line) = @_;
-
-       my $pos = 0;
-
-       my $opens = $line =~ tr/\(/\(/;
-       my $closes = $line =~ tr/\)/\)/;
-
-       my $last_openparen = 0;
-
-       if (($opens == 0) || ($closes >= $opens)) {
-               return -1;
-       }
-
-       my $len = length($line);
-
-       for ($pos = 0; $pos < $len; $pos++) {
-               my $string = substr($line, $pos);
-               if ($string =~ /^($FuncArg|$balanced_parens)/) {
-                       $pos += length($1) - 1;
-               } elsif (substr($line, $pos, 1) eq '(') {
-                       $last_openparen = $pos;
-               } elsif (index($string, '(') == -1) {
-                       last;
-               }
-       }
-
-       return $last_openparen + 1;
-}
-
-sub process {
-       my $filename = shift;
-
-       my $linenr=0;
-       my $prevline="";
-       my $prevrawline="";
-       my $stashline="";
-       my $stashrawline="";
-
-       my $length;
-       my $indent;
-       my $previndent=0;
-       my $stashindent=0;
-
-       our $clean = 1;
-       my $signoff = 0;
-       my $is_patch = 0;
-
-       my $in_header_lines = 1;
-       my $in_commit_log = 0;          #Scanning lines before patch
-
-       my $non_utf8_charset = 0;
-
-       our @report = ();
-       our $cnt_lines = 0;
-       our $cnt_error = 0;
-       our $cnt_warn = 0;
-       our $cnt_chk = 0;
-
-       # Trace the real file/line as we go.
-       my $realfile = '';
-       my $realline = 0;
-       my $realcnt = 0;
-       my $here = '';
-       my $in_comment = 0;
-       my $comment_edge = 0;
-       my $first_line = 0;
-       my $p1_prefix = '';
-
-       my $prev_values = 'E';
-
-       # suppression flags
-       my %suppress_ifbraces;
-       my %suppress_whiletrailers;
-       my %suppress_export;
-       my $suppress_statement = 0;
-
-       my %camelcase = ();
-
-       # Pre-scan the patch sanitizing the lines.
-       # Pre-scan the patch looking for any __setup documentation.
-       #
-       my @setup_docs = ();
-       my $setup_docs = 0;
-
-       sanitise_line_reset();
-       my $line;
-       foreach my $rawline (@rawlines) {
-               $linenr++;
-               $line = $rawline;
-
-               if ($rawline=~/^\+\+\+\s+(\S+)/) {
-                       $setup_docs = 0;
-                       if ($1 =~ m@Documentation/kernel-parameters.txt$@) {
-                               $setup_docs = 1;
-                       }
-                       #next;
-               }
-               if ($rawline=~/^\@\@ -\d+(?:,\d+)? \+(\d+)(,(\d+))? \@\@/) {
-                       $realline=$1-1;
-                       if (defined $2) {
-                               $realcnt=$3+1;
-                       } else {
-                               $realcnt=1+1;
-                       }
-                       $in_comment = 0;
-
-                       # Guestimate if this is a continuing comment.  Run
-                       # the context looking for a comment "edge".  If this
-                       # edge is a close comment then we must be in a comment
-                       # at context start.
-                       my $edge;
-                       my $cnt = $realcnt;
-                       for (my $ln = $linenr + 1; $cnt > 0; $ln++) {
-                               next if (defined $rawlines[$ln - 1] &&
-                                        $rawlines[$ln - 1] =~ /^-/);
-                               $cnt--;
-                               #print "RAW<$rawlines[$ln - 1]>\n";
-                               last if (!defined $rawlines[$ln - 1]);
-                               if ($rawlines[$ln - 1] =~ m@(/\*|\*/)@ &&
-                                   $rawlines[$ln - 1] !~ m@"[^"]*(?:/\*|\*/)[^"]*"@) {
-                                       ($edge) = $1;
-                                       last;
-                               }
-                       }
-                       if (defined $edge && $edge eq '*/') {
-                               $in_comment = 1;
-                       }
-
-                       # Guestimate if this is a continuing comment.  If this
-                       # is the start of a diff block and this line starts
-                       # ' *' then it is very likely a comment.
-                       if (!defined $edge &&
-                           $rawlines[$linenr] =~ m@^.\s*(?:\*\*+| \*)(?:\s|$)@)
-                       {
-                               $in_comment = 1;
-                       }
-
-                       ##print "COMMENT:$in_comment edge<$edge> $rawline\n";
-                       sanitise_line_reset($in_comment);
-
-               } elsif ($realcnt && $rawline =~ /^(?:\+| |$)/) {
-                       # Standardise the strings and chars within the input to
-                       # simplify matching -- only bother with positive lines.
-                       $line = sanitise_line($rawline);
-               }
-               push(@lines, $line);
-
-               if ($realcnt > 1) {
-                       $realcnt-- if ($line =~ /^(?:\+| |$)/);
-               } else {
-                       $realcnt = 0;
-               }
-
-               #print "==>$rawline\n";
-               #print "-->$line\n";
-
-               if ($setup_docs && $line =~ /^\+/) {
-                       push(@setup_docs, $line);
-               }
-       }
-
-       $prefix = '';
-
-       $realcnt = 0;
-       $linenr = 0;
-       foreach my $line (@lines) {
-               $linenr++;
-
-               my $rawline = $rawlines[$linenr - 1];
-
-#extract the line range in the file after the patch is applied
-               if ($line=~/^\@\@ -\d+(?:,\d+)? \+(\d+)(,(\d+))? \@\@/) {
-                       $is_patch = 1;
-                       $first_line = $linenr + 1;
-                       $realline=$1-1;
-                       if (defined $2) {
-                               $realcnt=$3+1;
-                       } else {
-                               $realcnt=1+1;
-                       }
-                       annotate_reset();
-                       $prev_values = 'E';
-
-                       %suppress_ifbraces = ();
-                       %suppress_whiletrailers = ();
-                       %suppress_export = ();
-                       $suppress_statement = 0;
-                       next;
-
-# track the line number as we move through the hunk, note that
-# new versions of GNU diff omit the leading space on completely
-# blank context lines so we need to count that too.
-               } elsif ($line =~ /^( |\+|$)/) {
-                       $realline++;
-                       $realcnt-- if ($realcnt != 0);
-
-                       # Measure the line length and indent.
-                       ($length, $indent) = line_stats($rawline);
-
-                       # Track the previous line.
-                       ($prevline, $stashline) = ($stashline, $line);
-                       ($previndent, $stashindent) = ($stashindent, $indent);
-                       ($prevrawline, $stashrawline) = ($stashrawline, $rawline);
-
-                       #warn "line<$line>\n";
-
-               } elsif ($realcnt == 1) {
-                       $realcnt--;
-               }
-
-               my $hunk_line = ($realcnt != 0);
-
-#make up the handle for any error we report on this line
-               $prefix = "$filename:$realline: " if ($emacs && $file);
-               $prefix = "$filename:$linenr: " if ($emacs && !$file);
-
-               $here = "#$linenr: " if (!$file);
-               $here = "#$realline: " if ($file);
-
-               # extract the filename as it passes
-               if ($line =~ /^diff --git.*?(\S+)$/) {
-                       $realfile = $1;
-                       $realfile =~ s@^([^/]*)/@@;
-                       $in_commit_log = 0;
-               } elsif ($line =~ /^\+\+\+\s+(\S+)/) {
-                       $realfile = $1;
-                       $realfile =~ s@^([^/]*)/@@;
-                       $in_commit_log = 0;
-
-                       $p1_prefix = $1;
-                       if (!$file && $tree && $p1_prefix ne '' &&
-                           -e "$root/$p1_prefix") {
-                               WARN("PATCH_PREFIX",
-                                    "patch prefix '$p1_prefix' exists, appears to be a -p0 patch\n");
-                       }
-
-                       if ($realfile =~ m@^include/asm/@) {
-                               ERROR("MODIFIED_INCLUDE_ASM",
-                                     "do not modify files in include/asm, change architecture specific files in include/asm-<architecture>\n" . "$here$rawline\n");
-                       }
-                       next;
-               }
-
-               $here .= "FILE: $realfile:$realline:" if ($realcnt != 0);
-
-               my $hereline = "$here\n$rawline\n";
-               my $herecurr = "$here\n$rawline\n";
-               my $hereprev = "$here\n$prevrawline\n$rawline\n";
-
-               $cnt_lines++ if ($realcnt != 0);
-
-# Check for incorrect file permissions
-               if ($line =~ /^new (file )?mode.*[7531]\d{0,2}$/) {
-                       my $permhere = $here . "FILE: $realfile\n";
-                       if ($realfile =~ /(Makefile|Kconfig|\.c|\.h|\.S|\.tmpl)$/) {
-                               ERROR("EXECUTE_PERMISSIONS",
-                                     "do not set execute permissions for source files\n" . $permhere);
-                       }
-               }
-
-# Check the patch for a signoff:
-               if ($line =~ /^\s*signed-off-by:/i) {
-                       $signoff++;
-                       $in_commit_log = 0;
-               }
-
-# Check signature styles
-               if (!$in_header_lines &&
-                   $line =~ /^(\s*)([a-z0-9_-]+by:|$signature_tags)(\s*)(.*)/i) {
-                       my $space_before = $1;
-                       my $sign_off = $2;
-                       my $space_after = $3;
-                       my $email = $4;
-                       my $ucfirst_sign_off = ucfirst(lc($sign_off));
-
-                       if ($sign_off !~ /$signature_tags/) {
-                               WARN("BAD_SIGN_OFF",
-                                    "Non-standard signature: $sign_off\n" . $herecurr);
-                       }
-                       if (defined $space_before && $space_before ne "") {
-                               WARN("BAD_SIGN_OFF",
-                                    "Do not use whitespace before $ucfirst_sign_off\n" . $herecurr);
-                       }
-                       if ($sign_off =~ /-by:$/i && $sign_off ne $ucfirst_sign_off) {
-                               WARN("BAD_SIGN_OFF",
-                                    "'$ucfirst_sign_off' is the preferred signature form\n" . $herecurr);
-                       }
-                       if (!defined $space_after || $space_after ne " ") {
-                               WARN("BAD_SIGN_OFF",
-                                    "Use a single space after $ucfirst_sign_off\n" . $herecurr);
-                       }
-
-                       my ($email_name, $email_address, $comment) = parse_email($email);
-                       my $suggested_email = format_email(($email_name, $email_address));
-                       if ($suggested_email eq "") {
-                               ERROR("BAD_SIGN_OFF",
-                                     "Unrecognized email address: '$email'\n" . $herecurr);
-                       } else {
-                               my $dequoted = $suggested_email;
-                               $dequoted =~ s/^"//;
-                               $dequoted =~ s/" </ </;
-                               # Don't force email to have quotes
-                               # Allow just an angle bracketed address
-                               if ("$dequoted$comment" ne $email &&
-                                   "<$email_address>$comment" ne $email &&
-                                   "$suggested_email$comment" ne $email) {
-                                       WARN("BAD_SIGN_OFF",
-                                            "email address '$email' might be better as '$suggested_email$comment'\n" . $herecurr);
-                               }
-                       }
-               }
-
-# Check for wrappage within a valid hunk of the file
-               if ($realcnt != 0 && $line !~ m{^(?:\+|-| |\\ No newline|$)}) {
-                       ERROR("CORRUPTED_PATCH",
-                             "patch seems to be corrupt (line wrapped?)\n" .
-                               $herecurr) if (!$emitted_corrupt++);
-               }
-
-# Check for absolute kernel paths.
-               if ($tree) {
-                       while ($line =~ m{(?:^|\s)(/\S*)}g) {
-                               my $file = $1;
-
-                               if ($file =~ m{^(.*?)(?::\d+)+:?$} &&
-                                   check_absolute_file($1, $herecurr)) {
-                                       #
-                               } else {
-                                       check_absolute_file($file, $herecurr);
-                               }
-                       }
-               }
-
-# UTF-8 regex found at http://www.w3.org/International/questions/qa-forms-utf-8.en.php
-               if (($realfile =~ /^$/ || $line =~ /^\+/) &&
-                   $rawline !~ m/^$UTF8*$/) {
-                       my ($utf8_prefix) = ($rawline =~ /^($UTF8*)/);
-
-                       my $blank = copy_spacing($rawline);
-                       my $ptr = substr($blank, 0, length($utf8_prefix)) . "^";
-                       my $hereptr = "$hereline$ptr\n";
-
-                       CHK("INVALID_UTF8",
-                           "Invalid UTF-8, patch and commit message should be encoded in UTF-8\n" . $hereptr);
-               }
-
-# Check if it's the start of a commit log
-# (not a header line and we haven't seen the patch filename)
-               if ($in_header_lines && $realfile =~ /^$/ &&
-                   $rawline !~ /^(commit\b|from\b|[\w-]+:).+$/i) {
-                       $in_header_lines = 0;
-                       $in_commit_log = 1;
-               }
-
-# Check if there is UTF-8 in a commit log when a mail header has explicitly
-# declined it, i.e defined some charset where it is missing.
-               if ($in_header_lines &&
-                   $rawline =~ /^Content-Type:.+charset="(.+)".*$/ &&
-                   $1 !~ /utf-8/i) {
-                       $non_utf8_charset = 1;
-               }
-
-               if ($in_commit_log && $non_utf8_charset && $realfile =~ /^$/ &&
-                   $rawline =~ /$NON_ASCII_UTF8/) {
-                       WARN("UTF8_BEFORE_PATCH",
-                           "8-bit UTF-8 used in possible commit log\n" . $herecurr);
-               }
-
-# ignore non-hunk lines and lines being removed
-               next if (!$hunk_line || $line =~ /^-/);
-
-#trailing whitespace
-               if ($line =~ /^\+.*\015/) {
-                       my $herevet = "$here\n" . cat_vet($rawline) . "\n";
-                       ERROR("DOS_LINE_ENDINGS",
-                             "DOS line endings\n" . $herevet);
-
-               } elsif ($rawline =~ /^\+.*\S\s+$/ || $rawline =~ /^\+\s+$/) {
-                       my $herevet = "$here\n" . cat_vet($rawline) . "\n";
-                       ERROR("TRAILING_WHITESPACE",
-                             "trailing whitespace\n" . $herevet);
-                       $rpt_cleaners = 1;
-               }
-
-# check for Kconfig help text having a real description
-# Only applies when adding the entry originally, after that we do not have
-# sufficient context to determine whether it is indeed long enough.
-               if ($realfile =~ /Kconfig/ &&
-                   $line =~ /.\s*config\s+/) {
-                       my $length = 0;
-                       my $cnt = $realcnt;
-                       my $ln = $linenr + 1;
-                       my $f;
-                       my $is_start = 0;
-                       my $is_end = 0;
-                       for (; $cnt > 0 && defined $lines[$ln - 1]; $ln++) {
-                               $f = $lines[$ln - 1];
-                               $cnt-- if ($lines[$ln - 1] !~ /^-/);
-                               $is_end = $lines[$ln - 1] =~ /^\+/;
-
-                               next if ($f =~ /^-/);
-
-                               if ($lines[$ln - 1] =~ /.\s*(?:bool|tristate)\s*\"/) {
-                                       $is_start = 1;
-                               } elsif ($lines[$ln - 1] =~ /.\s*(?:---)?help(?:---)?$/) {
-                                       $length = -1;
-                               }
-
-                               $f =~ s/^.//;
-                               $f =~ s/#.*//;
-                               $f =~ s/^\s+//;
-                               next if ($f =~ /^$/);
-                               if ($f =~ /^\s*config\s/) {
-                                       $is_end = 1;
-                                       last;
-                               }
-                               $length++;
-                       }
-                       WARN("CONFIG_DESCRIPTION",
-                            "please write a paragraph that describes the config symbol fully\n" . $herecurr) if ($is_start && $is_end && $length < 4);
-                       #print "is_start<$is_start> is_end<$is_end> length<$length>\n";
-               }
-
-# discourage the addition of CONFIG_EXPERIMENTAL in Kconfig.
-               if ($realfile =~ /Kconfig/ &&
-                   $line =~ /.\s*depends on\s+.*\bEXPERIMENTAL\b/) {
-                       WARN("CONFIG_EXPERIMENTAL",
-                            "Use of CONFIG_EXPERIMENTAL is deprecated. For alternatives, see https://lkml.org/lkml/2012/10/23/580\n");
-               }
-
-               if (($realfile =~ /Makefile.*/ || $realfile =~ /Kbuild.*/) &&
-                   ($line =~ /\+(EXTRA_[A-Z]+FLAGS).*/)) {
-                       my $flag = $1;
-                       my $replacement = {
-                               'EXTRA_AFLAGS' =>   'asflags-y',
-                               'EXTRA_CFLAGS' =>   'ccflags-y',
-                               'EXTRA_CPPFLAGS' => 'cppflags-y',
-                               'EXTRA_LDFLAGS' =>  'ldflags-y',
-                       };
-
-                       WARN("DEPRECATED_VARIABLE",
-                            "Use of $flag is deprecated, please use \`$replacement->{$flag} instead.\n" . $herecurr) if ($replacement->{$flag});
-               }
-
-# check we are in a valid source file if not then ignore this hunk
-               next if ($realfile !~ /\.(h|c|s|S|pl|sh)$/);
-
-#line length limit
-               if ($line =~ /^\+/ && $prevrawline !~ /\/\*\*/ &&
-                   $rawline !~ /^.\s*\*\s*\@$Ident\s/ &&
-                   !($line =~ /^\+\s*$logFunctions\s*\(\s*(?:(KERN_\S+\s*|[^"]*))?"[X\t]*"\s*(?:|,|\)\s*;)\s*$/ ||
-                   $line =~ /^\+\s*"[^"]*"\s*(?:\s*|,|\)\s*;)\s*$/) &&
-                   $length > $max_line_length)
-               {
-                       WARN("LONG_LINE",
-                            "line over $max_line_length characters\n" . $herecurr);
-               }
-
-# Check for user-visible strings broken across lines, which breaks the ability
-# to grep for the string.  Limited to strings used as parameters (those
-# following an open parenthesis), which almost completely eliminates false
-# positives, as well as warning only once per parameter rather than once per
-# line of the string.  Make an exception when the previous string ends in a
-# newline (multiple lines in one string constant) or \n\t (common in inline
-# assembly to indent the instruction on the following line).
-               if ($line =~ /^\+\s*"/ &&
-                   $prevline =~ /"\s*$/ &&
-                   $prevline =~ /\(/ &&
-                   $prevrawline !~ /\\n(?:\\t)*"\s*$/) {
-                       WARN("SPLIT_STRING",
-                            "quoted string split across lines\n" . $hereprev);
-               }
-
-# check for spaces before a quoted newline
-               if ($rawline =~ /^.*\".*\s\\n/) {
-                       WARN("QUOTED_WHITESPACE_BEFORE_NEWLINE",
-                            "unnecessary whitespace before a quoted newline\n" . $herecurr);
-               }
-
-# check for adding lines without a newline.
-               if ($line =~ /^\+/ && defined $lines[$linenr] && $lines[$linenr] =~ /^\\ No newline at end of file/) {
-                       WARN("MISSING_EOF_NEWLINE",
-                            "adding a line without newline at end of file\n" . $herecurr);
-               }
-
-# Blackfin: use hi/lo macros
-               if ($realfile =~ m@arch/blackfin/.*\.S$@) {
-                       if ($line =~ /\.[lL][[:space:]]*=.*&[[:space:]]*0x[fF][fF][fF][fF]/) {
-                               my $herevet = "$here\n" . cat_vet($line) . "\n";
-                               ERROR("LO_MACRO",
-                                     "use the LO() macro, not (... & 0xFFFF)\n" . $herevet);
-                       }
-                       if ($line =~ /\.[hH][[:space:]]*=.*>>[[:space:]]*16/) {
-                               my $herevet = "$here\n" . cat_vet($line) . "\n";
-                               ERROR("HI_MACRO",
-                                     "use the HI() macro, not (... >> 16)\n" . $herevet);
-                       }
-               }
-
-# check we are in a valid source file C or perl if not then ignore this hunk
-               next if ($realfile !~ /\.(h|c|pl)$/);
-
-# at the beginning of a line any tabs must come first and anything
-# more than 8 must use tabs.
-               if ($rawline =~ /^\+\s* \t\s*\S/ ||
-                   $rawline =~ /^\+\s*        \s*/) {
-                       my $herevet = "$here\n" . cat_vet($rawline) . "\n";
-                       ERROR("CODE_INDENT",
-                             "code indent should use tabs where possible\n" . $herevet);
-                       $rpt_cleaners = 1;
-               }
-
-# check for space before tabs.
-               if ($rawline =~ /^\+/ && $rawline =~ / \t/) {
-                       my $herevet = "$here\n" . cat_vet($rawline) . "\n";
-                       WARN("SPACE_BEFORE_TAB",
-                            "please, no space before tabs\n" . $herevet);
-               }
-
-# check for && or || at the start of a line
-               if ($rawline =~ /^\+\s*(&&|\|\|)/) {
-                       CHK("LOGICAL_CONTINUATIONS",
-                           "Logical continuations should be on the previous line\n" . $hereprev);
-               }
-
-# check multi-line statement indentation matches previous line
-               if ($^V && $^V ge 5.10.0 &&
-                   $prevline =~ /^\+(\t*)(if \(|$Ident\().*(\&\&|\|\||,)\s*$/) {
-                       $prevline =~ /^\+(\t*)(.*)$/;
-                       my $oldindent = $1;
-                       my $rest = $2;
-
-                       my $pos = pos_last_openparen($rest);
-                       if ($pos >= 0) {
-                               $line =~ /^(\+| )([ \t]*)/;
-                               my $newindent = $2;
-
-                               my $goodtabindent = $oldindent .
-                                       "\t" x ($pos / 8) .
-                                       " "  x ($pos % 8);
-                               my $goodspaceindent = $oldindent . " "  x $pos;
-
-                               if ($newindent ne $goodtabindent &&
-                                   $newindent ne $goodspaceindent) {
-                                       CHK("PARENTHESIS_ALIGNMENT",
-                                           "Alignment should match open parenthesis\n" . $hereprev);
-                               }
-                       }
-               }
-
-               if ($line =~ /^\+.*\*[ \t]*\)[ \t]+/) {
-                       CHK("SPACING",
-                           "No space is necessary after a cast\n" . $hereprev);
-               }
-
-               if ($realfile =~ m@^(drivers/net/|net/)@ &&
-                   $rawline =~ /^\+[ \t]*\/\*[ \t]*$/ &&
-                   $prevrawline =~ /^\+[ \t]*$/) {
-                       WARN("NETWORKING_BLOCK_COMMENT_STYLE",
-                            "networking block comments don't use an empty /* line, use /* Comment...\n" . $hereprev);
-               }
-
-               if ($realfile =~ m@^(drivers/net/|net/)@ &&
-                   $rawline !~ m@^\+[ \t]*\*/[ \t]*$@ &&       #trailing */
-                   $rawline !~ m@^\+.*/\*.*\*/[ \t]*$@ &&      #inline /*...*/
-                   $rawline !~ m@^\+.*\*{2,}/[ \t]*$@ &&       #trailing **/
-                   $rawline =~ m@^\+[ \t]*.+\*\/[ \t]*$@) {    #non blank */
-                       WARN("NETWORKING_BLOCK_COMMENT_STYLE",
-                            "networking block comments put the trailing */ on a separate line\n" . $herecurr);
-               }
-
-# check for spaces at the beginning of a line.
-# Exceptions:
-#  1) within comments
-#  2) indented preprocessor commands
-#  3) hanging labels
-               if ($rawline =~ /^\+ / && $line !~ /\+ *(?:$;|#|$Ident:)/)  {
-                       my $herevet = "$here\n" . cat_vet($rawline) . "\n";
-                       WARN("LEADING_SPACE",
-                            "please, no spaces at the start of a line\n" . $herevet);
-               }
-
-# check we are in a valid C source file if not then ignore this hunk
-               next if ($realfile !~ /\.(h|c)$/);
-
-# discourage the addition of CONFIG_EXPERIMENTAL in #if(def).
-               if ($line =~ /^\+\s*\#\s*if.*\bCONFIG_EXPERIMENTAL\b/) {
-                       WARN("CONFIG_EXPERIMENTAL",
-                            "Use of CONFIG_EXPERIMENTAL is deprecated. For alternatives, see https://lkml.org/lkml/2012/10/23/580\n");
-               }
-
-# check for RCS/CVS revision markers
-               if ($rawline =~ /^\+.*\$(Revision|Log|Id)(?:\$|)/) {
-                       WARN("CVS_KEYWORD",
-                            "CVS style keyword markers, these will _not_ be updated\n". $herecurr);
-               }
-
-# Blackfin: don't use __builtin_bfin_[cs]sync
-               if ($line =~ /__builtin_bfin_csync/) {
-                       my $herevet = "$here\n" . cat_vet($line) . "\n";
-                       ERROR("CSYNC",
-                             "use the CSYNC() macro in asm/blackfin.h\n" . $herevet);
-               }
-               if ($line =~ /__builtin_bfin_ssync/) {
-                       my $herevet = "$here\n" . cat_vet($line) . "\n";
-                       ERROR("SSYNC",
-                             "use the SSYNC() macro in asm/blackfin.h\n" . $herevet);
-               }
-
-# check for old HOTPLUG __dev<foo> section markings
-               if ($line =~ /\b(__dev(init|exit)(data|const|))\b/) {
-                       WARN("HOTPLUG_SECTION",
-                            "Using $1 is unnecessary\n" . $herecurr);
-               }
-
-# Check for potential 'bare' types
-               my ($stat, $cond, $line_nr_next, $remain_next, $off_next,
-                   $realline_next);
-#print "LINE<$line>\n";
-               if ($linenr >= $suppress_statement &&
-                   $realcnt && $line =~ /.\s*\S/) {
-                       ($stat, $cond, $line_nr_next, $remain_next, $off_next) =
-                               ctx_statement_block($linenr, $realcnt, 0);
-                       $stat =~ s/\n./\n /g;
-                       $cond =~ s/\n./\n /g;
-
-#print "linenr<$linenr> <$stat>\n";
-                       # If this statement has no statement boundaries within
-                       # it there is no point in retrying a statement scan
-                       # until we hit end of it.
-                       my $frag = $stat; $frag =~ s/;+\s*$//;
-                       if ($frag !~ /(?:{|;)/) {
-#print "skip<$line_nr_next>\n";
-                               $suppress_statement = $line_nr_next;
-                       }
-
-                       # Find the real next line.
-                       $realline_next = $line_nr_next;
-                       if (defined $realline_next &&
-                           (!defined $lines[$realline_next - 1] ||
-                            substr($lines[$realline_next - 1], $off_next) =~ /^\s*$/)) {
-                               $realline_next++;
-                       }
-
-                       my $s = $stat;
-                       $s =~ s/{.*$//s;
-
-                       # Ignore goto labels.
-                       if ($s =~ /$Ident:\*$/s) {
-
-                       # Ignore functions being called
-                       } elsif ($s =~ /^.\s*$Ident\s*\(/s) {
-
-                       } elsif ($s =~ /^.\s*else\b/s) {
-
-                       # declarations always start with types
-                       } elsif ($prev_values eq 'E' && $s =~ /^.\s*(?:$Storage\s+)?(?:$Inline\s+)?(?:const\s+)?((?:\s*$Ident)+?)\b(?:\s+$Sparse)?\s*\**\s*(?:$Ident|\(\*[^\)]*\))(?:\s*$Modifier)?\s*(?:;|=|,|\()/s) {
-                               my $type = $1;
-                               $type =~ s/\s+/ /g;
-                               possible($type, "A:" . $s);
-
-                       # definitions in global scope can only start with types
-                       } elsif ($s =~ /^.(?:$Storage\s+)?(?:$Inline\s+)?(?:const\s+)?($Ident)\b\s*(?!:)/s) {
-                               possible($1, "B:" . $s);
-                       }
-
-                       # any (foo ... *) is a pointer cast, and foo is a type
-                       while ($s =~ /\(($Ident)(?:\s+$Sparse)*[\s\*]+\s*\)/sg) {
-                               possible($1, "C:" . $s);
-                       }
-
-                       # Check for any sort of function declaration.
-                       # int foo(something bar, other baz);
-                       # void (*store_gdt)(x86_descr_ptr *);
-                       if ($prev_values eq 'E' && $s =~ /^(.(?:typedef\s*)?(?:(?:$Storage|$Inline)\s*)*\s*$Type\s*(?:\b$Ident|\(\*\s*$Ident\))\s*)\(/s) {
-                               my ($name_len) = length($1);
-
-                               my $ctx = $s;
-                               substr($ctx, 0, $name_len + 1, '');
-                               $ctx =~ s/\)[^\)]*$//;
-
-                               for my $arg (split(/\s*,\s*/, $ctx)) {
-                                       if ($arg =~ /^(?:const\s+)?($Ident)(?:\s+$Sparse)*\s*\**\s*(:?\b$Ident)?$/s || $arg =~ /^($Ident)$/s) {
-
-                                               possible($1, "D:" . $s);
-                                       }
-                               }
-                       }
-
-               }
-
-#
-# Checks which may be anchored in the context.
-#
-
-# Check for switch () and associated case and default
-# statements should be at the same indent.
-               if ($line=~/\bswitch\s*\(.*\)/) {
-                       my $err = '';
-                       my $sep = '';
-                       my @ctx = ctx_block_outer($linenr, $realcnt);
-                       shift(@ctx);
-                       for my $ctx (@ctx) {
-                               my ($clen, $cindent) = line_stats($ctx);
-                               if ($ctx =~ /^\+\s*(case\s+|default:)/ &&
-                                                       $indent != $cindent) {
-                                       $err .= "$sep$ctx\n";
-                                       $sep = '';
-                               } else {
-                                       $sep = "[...]\n";
-                               }
-                       }
-                       if ($err ne '') {
-                               ERROR("SWITCH_CASE_INDENT_LEVEL",
-                                     "switch and case should be at the same indent\n$hereline$err");
-                       }
-               }
-
-# if/while/etc brace do not go on next line, unless defining a do while loop,
-# or if that brace on the next line is for something else
-               if ($line =~ /(.*)\b((?:if|while|for|switch)\s*\(|do\b|else\b)/ && $line !~ /^.\s*\#/) {
-                       my $pre_ctx = "$1$2";
-
-                       my ($level, @ctx) = ctx_statement_level($linenr, $realcnt, 0);
-
-                       if ($line =~ /^\+\t{6,}/) {
-                               WARN("DEEP_INDENTATION",
-                                    "Too many leading tabs - consider code refactoring\n" . $herecurr);
-                       }
-
-                       my $ctx_cnt = $realcnt - $#ctx - 1;
-                       my $ctx = join("\n", @ctx);
-
-                       my $ctx_ln = $linenr;
-                       my $ctx_skip = $realcnt;
-
-                       while ($ctx_skip > $ctx_cnt || ($ctx_skip == $ctx_cnt &&
-                                       defined $lines[$ctx_ln - 1] &&
-                                       $lines[$ctx_ln - 1] =~ /^-/)) {
-                               ##print "SKIP<$ctx_skip> CNT<$ctx_cnt>\n";
-                               $ctx_skip-- if (!defined $lines[$ctx_ln - 1] || $lines[$ctx_ln - 1] !~ /^-/);
-                               $ctx_ln++;
-                       }
-
-                       #print "realcnt<$realcnt> ctx_cnt<$ctx_cnt>\n";
-                       #print "pre<$pre_ctx>\nline<$line>\nctx<$ctx>\nnext<$lines[$ctx_ln - 1]>\n";
-
-                       if ($ctx !~ /{\s*/ && defined($lines[$ctx_ln -1]) && $lines[$ctx_ln - 1] =~ /^\+\s*{/) {
-                               ERROR("OPEN_BRACE",
-                                     "that open brace { should be on the previous line\n" .
-                                       "$here\n$ctx\n$rawlines[$ctx_ln - 1]\n");
-                       }
-                       if ($level == 0 && $pre_ctx !~ /}\s*while\s*\($/ &&
-                           $ctx =~ /\)\s*\;\s*$/ &&
-                           defined $lines[$ctx_ln - 1])
-                       {
-                               my ($nlength, $nindent) = line_stats($lines[$ctx_ln - 1]);
-                               if ($nindent > $indent) {
-                                       WARN("TRAILING_SEMICOLON",
-                                            "trailing semicolon indicates no statements, indent implies otherwise\n" .
-                                               "$here\n$ctx\n$rawlines[$ctx_ln - 1]\n");
-                               }
-                       }
-               }
-
-# Check relative indent for conditionals and blocks.
-               if ($line =~ /\b(?:(?:if|while|for)\s*\(|do\b)/ && $line !~ /^.\s*#/ && $line !~ /\}\s*while\s*/) {
-                       ($stat, $cond, $line_nr_next, $remain_next, $off_next) =
-                               ctx_statement_block($linenr, $realcnt, 0)
-                                       if (!defined $stat);
-                       my ($s, $c) = ($stat, $cond);
-
-                       substr($s, 0, length($c), '');
-
-                       # Make sure we remove the line prefixes as we have
-                       # none on the first line, and are going to readd them
-                       # where necessary.
-                       $s =~ s/\n./\n/gs;
-
-                       # Find out how long the conditional actually is.
-                       my @newlines = ($c =~ /\n/gs);
-                       my $cond_lines = 1 + $#newlines;
-
-                       # We want to check the first line inside the block
-                       # starting at the end of the conditional, so remove:
-                       #  1) any blank line termination
-                       #  2) any opening brace { on end of the line
-                       #  3) any do (...) {
-                       my $continuation = 0;
-                       my $check = 0;
-                       $s =~ s/^.*\bdo\b//;
-                       $s =~ s/^\s*{//;
-                       if ($s =~ s/^\s*\\//) {
-                               $continuation = 1;
-                       }
-                       if ($s =~ s/^\s*?\n//) {
-                               $check = 1;
-                               $cond_lines++;
-                       }
-
-                       # Also ignore a loop construct at the end of a
-                       # preprocessor statement.
-                       if (($prevline =~ /^.\s*#\s*define\s/ ||
-                           $prevline =~ /\\\s*$/) && $continuation == 0) {
-                               $check = 0;
-                       }
-
-                       my $cond_ptr = -1;
-                       $continuation = 0;
-                       while ($cond_ptr != $cond_lines) {
-                               $cond_ptr = $cond_lines;
-
-                               # If we see an #else/#elif then the code
-                               # is not linear.
-                               if ($s =~ /^\s*\#\s*(?:else|elif)/) {
-                                       $check = 0;
-                               }
-
-                               # Ignore:
-                               #  1) blank lines, they should be at 0,
-                               #  2) preprocessor lines, and
-                               #  3) labels.
-                               if ($continuation ||
-                                   $s =~ /^\s*?\n/ ||
-                                   $s =~ /^\s*#\s*?/ ||
-                                   $s =~ /^\s*$Ident\s*:/) {
-                                       $continuation = ($s =~ /^.*?\\\n/) ? 1 : 0;
-                                       if ($s =~ s/^.*?\n//) {
-                                               $cond_lines++;
-                                       }
-                               }
-                       }
-
-                       my (undef, $sindent) = line_stats("+" . $s);
-                       my $stat_real = raw_line($linenr, $cond_lines);
-
-                       # Check if either of these lines are modified, else
-                       # this is not this patch's fault.
-                       if (!defined($stat_real) ||
-                           $stat !~ /^\+/ && $stat_real !~ /^\+/) {
-                               $check = 0;
-                       }
-                       if (defined($stat_real) && $cond_lines > 1) {
-                               $stat_real = "[...]\n$stat_real";
-                       }
-
-                       #print "line<$line> prevline<$prevline> indent<$indent> sindent<$sindent> check<$check> continuation<$continuation> s<$s> cond_lines<$cond_lines> stat_real<$stat_real> stat<$stat>\n";
-
-                       if ($check && (($sindent % 8) != 0 ||
-                           ($sindent <= $indent && $s ne ''))) {
-                               WARN("SUSPECT_CODE_INDENT",
-                                    "suspect code indent for conditional statements ($indent, $sindent)\n" . $herecurr . "$stat_real\n");
-                       }
-               }
-
-               # Track the 'values' across context and added lines.
-               my $opline = $line; $opline =~ s/^./ /;
-               my ($curr_values, $curr_vars) =
-                               annotate_values($opline . "\n", $prev_values);
-               $curr_values = $prev_values . $curr_values;
-               if ($dbg_values) {
-                       my $outline = $opline; $outline =~ s/\t/ /g;
-                       print "$linenr > .$outline\n";
-                       print "$linenr > $curr_values\n";
-                       print "$linenr >  $curr_vars\n";
-               }
-               $prev_values = substr($curr_values, -1);
-
-#ignore lines not being added
-               if ($line=~/^[^\+]/) {next;}
-
-# TEST: allow direct testing of the type matcher.
-               if ($dbg_type) {
-                       if ($line =~ /^.\s*$Declare\s*$/) {
-                               ERROR("TEST_TYPE",
-                                     "TEST: is type\n" . $herecurr);
-                       } elsif ($dbg_type > 1 && $line =~ /^.+($Declare)/) {
-                               ERROR("TEST_NOT_TYPE",
-                                     "TEST: is not type ($1 is)\n". $herecurr);
-                       }
-                       next;
-               }
-# TEST: allow direct testing of the attribute matcher.
-               if ($dbg_attr) {
-                       if ($line =~ /^.\s*$Modifier\s*$/) {
-                               ERROR("TEST_ATTR",
-                                     "TEST: is attr\n" . $herecurr);
-                       } elsif ($dbg_attr > 1 && $line =~ /^.+($Modifier)/) {
-                               ERROR("TEST_NOT_ATTR",
-                                     "TEST: is not attr ($1 is)\n". $herecurr);
-                       }
-                       next;
-               }
-
-# check for initialisation to aggregates open brace on the next line
-               if ($line =~ /^.\s*{/ &&
-                   $prevline =~ /(?:^|[^=])=\s*$/) {
-                       ERROR("OPEN_BRACE",
-                             "that open brace { should be on the previous line\n" . $hereprev);
-               }
-
-#
-# Checks which are anchored on the added line.
-#
-
-# check for malformed paths in #include statements (uses RAW line)
-               if ($rawline =~ m{^.\s*\#\s*include\s+[<"](.*)[">]}) {
-                       my $path = $1;
-                       if ($path =~ m{//}) {
-                               ERROR("MALFORMED_INCLUDE",
-                                     "malformed #include filename\n" . $herecurr);
-                       }
-                       if ($path =~ "^uapi/" && $realfile =~ m@\binclude/uapi/@) {
-                               ERROR("UAPI_INCLUDE",
-                                     "No #include in ...include/uapi/... should use a uapi/ path prefix\n" . $herecurr);
-                       }
-               }
-
-# no C99 // comments
-               if ($line =~ m{//}) {
-                       ERROR("C99_COMMENTS",
-                             "do not use C99 // comments\n" . $herecurr);
-               }
-               # Remove C99 comments.
-               $line =~ s@//.*@@;
-               $opline =~ s@//.*@@;
-
-# EXPORT_SYMBOL should immediately follow the thing it is exporting, consider
-# the whole statement.
-#print "APW <$lines[$realline_next - 1]>\n";
-               if (defined $realline_next &&
-                   exists $lines[$realline_next - 1] &&
-                   !defined $suppress_export{$realline_next} &&
-                   ($lines[$realline_next - 1] =~ /EXPORT_SYMBOL.*\((.*)\)/ ||
-                    $lines[$realline_next - 1] =~ /EXPORT_UNUSED_SYMBOL.*\((.*)\)/)) {
-                       # Handle definitions which produce identifiers with
-                       # a prefix:
-                       #   XXX(foo);
-                       #   EXPORT_SYMBOL(something_foo);
-                       my $name = $1;
-                       if ($stat =~ /^(?:.\s*}\s*\n)?.([A-Z_]+)\s*\(\s*($Ident)/ &&
-                           $name =~ /^${Ident}_$2/) {
-#print "FOO C name<$name>\n";
-                               $suppress_export{$realline_next} = 1;
-
-                       } elsif ($stat !~ /(?:
-                               \n.}\s*$|
-                               ^.DEFINE_$Ident\(\Q$name\E\)|
-                               ^.DECLARE_$Ident\(\Q$name\E\)|
-                               ^.LIST_HEAD\(\Q$name\E\)|
-                               ^.(?:$Storage\s+)?$Type\s*\(\s*\*\s*\Q$name\E\s*\)\s*\(|
-                               \b\Q$name\E(?:\s+$Attribute)*\s*(?:;|=|\[|\()
-                           )/x) {
-#print "FOO A<$lines[$realline_next - 1]> stat<$stat> name<$name>\n";
-                               $suppress_export{$realline_next} = 2;
-                       } else {
-                               $suppress_export{$realline_next} = 1;
-                       }
-               }
-               if (!defined $suppress_export{$linenr} &&
-                   $prevline =~ /^.\s*$/ &&
-                   ($line =~ /EXPORT_SYMBOL.*\((.*)\)/ ||
-                    $line =~ /EXPORT_UNUSED_SYMBOL.*\((.*)\)/)) {
-#print "FOO B <$lines[$linenr - 1]>\n";
-                       $suppress_export{$linenr} = 2;
-               }
-               if (defined $suppress_export{$linenr} &&
-                   $suppress_export{$linenr} == 2) {
-                       WARN("EXPORT_SYMBOL",
-                            "EXPORT_SYMBOL(foo); should immediately follow its function/variable\n" . $herecurr);
-               }
-
-# check for global initialisers.
-               if ($line =~ /^.$Type\s*$Ident\s*(?:\s+$Modifier)*\s*=\s*(0|NULL|false)\s*;/) {
-                       ERROR("GLOBAL_INITIALISERS",
-                             "do not initialise globals to 0 or NULL\n" .
-                               $herecurr);
-               }
-# check for static initialisers.
-               if ($line =~ /\bstatic\s.*=\s*(0|NULL|false)\s*;/) {
-                       ERROR("INITIALISED_STATIC",
-                             "do not initialise statics to 0 or NULL\n" .
-                               $herecurr);
-               }
-
-# check for static const char * arrays.
-               if ($line =~ /\bstatic\s+const\s+char\s*\*\s*(\w+)\s*\[\s*\]\s*=\s*/) {
-                       WARN("STATIC_CONST_CHAR_ARRAY",
-                            "static const char * array should probably be static const char * const\n" .
-                               $herecurr);
-               }
-
-# check for static char foo[] = "bar" declarations.
-               if ($line =~ /\bstatic\s+char\s+(\w+)\s*\[\s*\]\s*=\s*"/) {
-                       WARN("STATIC_CONST_CHAR_ARRAY",
-                            "static char array declaration should probably be static const char\n" .
-                               $herecurr);
-               }
-
-# check for declarations of struct pci_device_id
-               if ($line =~ /\bstruct\s+pci_device_id\s+\w+\s*\[\s*\]\s*\=\s*\{/) {
-                       WARN("DEFINE_PCI_DEVICE_TABLE",
-                            "Use DEFINE_PCI_DEVICE_TABLE for struct pci_device_id\n" . $herecurr);
-               }
-
-# check for new typedefs, only function parameters and sparse annotations
-# make sense.
-               if ($line =~ /\btypedef\s/ &&
-                   $line !~ /\btypedef\s+$Type\s*\(\s*\*?$Ident\s*\)\s*\(/ &&
-                   $line !~ /\btypedef\s+$Type\s+$Ident\s*\(/ &&
-                   $line !~ /\b$typeTypedefs\b/ &&
-                   $line !~ /\b__bitwise(?:__|)\b/) {
-                       WARN("NEW_TYPEDEFS",
-                            "do not add new typedefs\n" . $herecurr);
-               }
-
-# * goes on variable not on type
-               # (char*[ const])
-               while ($line =~ m{(\($NonptrType(\s*(?:$Modifier\b\s*|\*\s*)+)\))}g) {
-                       #print "AA<$1>\n";
-                       my ($from, $to) = ($2, $2);
-
-                       # Should start with a space.
-                       $to =~ s/^(\S)/ $1/;
-                       # Should not end with a space.
-                       $to =~ s/\s+$//;
-                       # '*'s should not have spaces between.
-                       while ($to =~ s/\*\s+\*/\*\*/) {
-                       }
-
-                       #print "from<$from> to<$to>\n";
-                       if ($from ne $to) {
-                               ERROR("POINTER_LOCATION",
-                                     "\"(foo$from)\" should be \"(foo$to)\"\n" .  $herecurr);
-                       }
-               }
-               while ($line =~ m{(\b$NonptrType(\s*(?:$Modifier\b\s*|\*\s*)+)($Ident))}g) {
-                       #print "BB<$1>\n";
-                       my ($from, $to, $ident) = ($2, $2, $3);
-
-                       # Should start with a space.
-                       $to =~ s/^(\S)/ $1/;
-                       # Should not end with a space.
-                       $to =~ s/\s+$//;
-                       # '*'s should not have spaces between.
-                       while ($to =~ s/\*\s+\*/\*\*/) {
-                       }
-                       # Modifiers should have spaces.
-                       $to =~ s/(\b$Modifier$)/$1 /;
-
-                       #print "from<$from> to<$to> ident<$ident>\n";
-                       if ($from ne $to && $ident !~ /^$Modifier$/) {
-                               ERROR("POINTER_LOCATION",
-                                     "\"foo${from}bar\" should be \"foo${to}bar\"\n" .  $herecurr);
-                       }
-               }
-
-# # no BUG() or BUG_ON()
-#              if ($line =~ /\b(BUG|BUG_ON)\b/) {
-#                      print "Try to use WARN_ON & Recovery code rather than BUG() or BUG_ON()\n";
-#                      print "$herecurr";
-#                      $clean = 0;
-#              }
-
-               if ($line =~ /\bLINUX_VERSION_CODE\b/) {
-                       WARN("LINUX_VERSION_CODE",
-                            "LINUX_VERSION_CODE should be avoided, code should be for the version to which it is merged\n" . $herecurr);
-               }
-
-# check for uses of printk_ratelimit
-               if ($line =~ /\bprintk_ratelimit\s*\(/) {
-                       WARN("PRINTK_RATELIMITED",
-"Prefer printk_ratelimited or pr_<level>_ratelimited to printk_ratelimit\n" . $herecurr);
-               }
-
-# printk should use KERN_* levels.  Note that follow on printk's on the
-# same line do not need a level, so we use the current block context
-# to try and find and validate the current printk.  In summary the current
-# printk includes all preceding printk's which have no newline on the end.
-# we assume the first bad printk is the one to report.
-               if ($line =~ /\bprintk\((?!KERN_)\s*"/) {
-                       my $ok = 0;
-                       for (my $ln = $linenr - 1; $ln >= $first_line; $ln--) {
-                               #print "CHECK<$lines[$ln - 1]\n";
-                               # we have a preceding printk if it ends
-                               # with "\n" ignore it, else it is to blame
-                               if ($lines[$ln - 1] =~ m{\bprintk\(}) {
-                                       if ($rawlines[$ln - 1] !~ m{\\n"}) {
-                                               $ok = 1;
-                                       }
-                                       last;
-                               }
-                       }
-                       if ($ok == 0) {
-                               WARN("PRINTK_WITHOUT_KERN_LEVEL",
-                                    "printk() should include KERN_ facility level\n" . $herecurr);
-                       }
-               }
-
-               if ($line =~ /\bprintk\s*\(\s*KERN_([A-Z]+)/) {
-                       my $orig = $1;
-                       my $level = lc($orig);
-                       $level = "warn" if ($level eq "warning");
-                       my $level2 = $level;
-                       $level2 = "dbg" if ($level eq "debug");
-                       WARN("PREFER_PR_LEVEL",
-                            "Prefer netdev_$level2(netdev, ... then dev_$level2(dev, ... then pr_$level(...  to printk(KERN_$orig ...\n" . $herecurr);
-               }
-
-               if ($line =~ /\bpr_warning\s*\(/) {
-                       WARN("PREFER_PR_LEVEL",
-                            "Prefer pr_warn(... to pr_warning(...\n" . $herecurr);
-               }
-
-               if ($line =~ /\bdev_printk\s*\(\s*KERN_([A-Z]+)/) {
-                       my $orig = $1;
-                       my $level = lc($orig);
-                       $level = "warn" if ($level eq "warning");
-                       $level = "dbg" if ($level eq "debug");
-                       WARN("PREFER_DEV_LEVEL",
-                            "Prefer dev_$level(... to dev_printk(KERN_$orig, ...\n" . $herecurr);
-               }
-
-# function brace can't be on same line, except for #defines of do while,
-# or if closed on same line
-               if (($line=~/$Type\s*$Ident\(.*\).*\s{/) and
-                   !($line=~/\#\s*define.*do\s{/) and !($line=~/}/)) {
-                       ERROR("OPEN_BRACE",
-                             "open brace '{' following function declarations go on the next line\n" . $herecurr);
-               }
-
-# open braces for enum, union and struct go on the same line.
-               if ($line =~ /^.\s*{/ &&
-                   $prevline =~ /^.\s*(?:typedef\s+)?(enum|union|struct)(?:\s+$Ident)?\s*$/) {
-                       ERROR("OPEN_BRACE",
-                             "open brace '{' following $1 go on the same line\n" . $hereprev);
-               }
-
-# missing space after union, struct or enum definition
-               if ($line =~ /^.\s*(?:typedef\s+)?(enum|union|struct)(?:\s+$Ident)?(?:\s+$Ident)?[=\{]/) {
-                   WARN("SPACING",
-                        "missing space after $1 definition\n" . $herecurr);
-               }
-
-# check for spacing round square brackets; allowed:
-#  1. with a type on the left -- int [] a;
-#  2. at the beginning of a line for slice initialisers -- [0...10] = 5,
-#  3. inside a curly brace -- = { [0...10] = 5 }
-               while ($line =~ /(.*?\s)\[/g) {
-                       my ($where, $prefix) = ($-[1], $1);
-                       if ($prefix !~ /$Type\s+$/ &&
-                           ($where != 0 || $prefix !~ /^.\s+$/) &&
-                           $prefix !~ /[{,]\s+$/) {
-                               ERROR("BRACKET_SPACE",
-                                     "space prohibited before open square bracket '['\n" . $herecurr);
-                       }
-               }
-
-# check for spaces between functions and their parentheses.
-               while ($line =~ /($Ident)\s+\(/g) {
-                       my $name = $1;
-                       my $ctx_before = substr($line, 0, $-[1]);
-                       my $ctx = "$ctx_before$name";
-
-                       # Ignore those directives where spaces _are_ permitted.
-                       if ($name =~ /^(?:
-                               if|for|while|switch|return|case|
-                               volatile|__volatile__|
-                               __attribute__|format|__extension__|
-                               asm|__asm__)$/x)
-                       {
-
-                       # cpp #define statements have non-optional spaces, ie
-                       # if there is a space between the name and the open
-                       # parenthesis it is simply not a parameter group.
-                       } elsif ($ctx_before =~ /^.\s*\#\s*define\s*$/) {
-
-                       # cpp #elif statement condition may start with a (
-                       } elsif ($ctx =~ /^.\s*\#\s*elif\s*$/) {
-
-                       # If this whole things ends with a type its most
-                       # likely a typedef for a function.
-                       } elsif ($ctx =~ /$Type$/) {
-
-                       } else {
-                               WARN("SPACING",
-                                    "space prohibited between function name and open parenthesis '('\n" . $herecurr);
-                       }
-               }
-
-# check for whitespace before a non-naked semicolon
-               if ($line =~ /^\+.*\S\s+;/) {
-                       CHK("SPACING",
-                           "space prohibited before semicolon\n" . $herecurr);
-               }
-
-# Check operator spacing.
-               if (!($line=~/\#\s*include/)) {
-                       my $ops = qr{
-                               <<=|>>=|<=|>=|==|!=|
-                               \+=|-=|\*=|\/=|%=|\^=|\|=|&=|
-                               =>|->|<<|>>|<|>|=|!|~|
-                               &&|\|\||,|\^|\+\+|--|&|\||\+|-|\*|\/|%|
-                               \?|:
-                       }x;
-                       my @elements = split(/($ops|;)/, $opline);
-                       my $off = 0;
-
-                       my $blank = copy_spacing($opline);
-
-                       for (my $n = 0; $n < $#elements; $n += 2) {
-                               $off += length($elements[$n]);
-
-                               # Pick up the preceding and succeeding characters.
-                               my $ca = substr($opline, 0, $off);
-                               my $cc = '';
-                               if (length($opline) >= ($off + length($elements[$n + 1]))) {
-                                       $cc = substr($opline, $off + length($elements[$n + 1]));
-                               }
-                               my $cb = "$ca$;$cc";
-
-                               my $a = '';
-                               $a = 'V' if ($elements[$n] ne '');
-                               $a = 'W' if ($elements[$n] =~ /\s$/);
-                               $a = 'C' if ($elements[$n] =~ /$;$/);
-                               $a = 'B' if ($elements[$n] =~ /(\[|\()$/);
-                               $a = 'O' if ($elements[$n] eq '');
-                               $a = 'E' if ($ca =~ /^\s*$/);
-
-                               my $op = $elements[$n + 1];
-
-                               my $c = '';
-                               if (defined $elements[$n + 2]) {
-                                       $c = 'V' if ($elements[$n + 2] ne '');
-                                       $c = 'W' if ($elements[$n + 2] =~ /^\s/);
-                                       $c = 'C' if ($elements[$n + 2] =~ /^$;/);
-                                       $c = 'B' if ($elements[$n + 2] =~ /^(\)|\]|;)/);
-                                       $c = 'O' if ($elements[$n + 2] eq '');
-                                       $c = 'E' if ($elements[$n + 2] =~ /^\s*\\$/);
-                               } else {
-                                       $c = 'E';
-                               }
-
-                               my $ctx = "${a}x${c}";
-
-                               my $at = "(ctx:$ctx)";
-
-                               my $ptr = substr($blank, 0, $off) . "^";
-                               my $hereptr = "$hereline$ptr\n";
-
-                               # Pull out the value of this operator.
-                               my $op_type = substr($curr_values, $off + 1, 1);
-
-                               # Get the full operator variant.
-                               my $opv = $op . substr($curr_vars, $off, 1);
-
-                               # Ignore operators passed as parameters.
-                               if ($op_type ne 'V' &&
-                                   $ca =~ /\s$/ && $cc =~ /^\s*,/) {
-
-#                              # Ignore comments
-#                              } elsif ($op =~ /^$;+$/) {
-
-                               # ; should have either the end of line or a space or \ after it
-                               } elsif ($op eq ';') {
-                                       if ($ctx !~ /.x[WEBC]/ &&
-                                           $cc !~ /^\\/ && $cc !~ /^;/) {
-                                               ERROR("SPACING",
-                                                     "space required after that '$op' $at\n" . $hereptr);
-                                       }
-
-                               # // is a comment
-                               } elsif ($op eq '//') {
-
-                               # No spaces for:
-                               #   ->
-                               #   :   when part of a bitfield
-                               } elsif ($op eq '->' || $opv eq ':B') {
-                                       if ($ctx =~ /Wx.|.xW/) {
-                                               ERROR("SPACING",
-                                                     "spaces prohibited around that '$op' $at\n" . $hereptr);
-                                       }
-
-                               # , must have a space on the right.
-                               } elsif ($op eq ',') {
-                                       if ($ctx !~ /.x[WEC]/ && $cc !~ /^}/) {
-                                               ERROR("SPACING",
-                                                     "space required after that '$op' $at\n" . $hereptr);
-                                       }
-
-                               # '*' as part of a type definition -- reported already.
-                               } elsif ($opv eq '*_') {
-                                       #warn "'*' is part of type\n";
-
-                               # unary operators should have a space before and
-                               # none after.  May be left adjacent to another
-                               # unary operator, or a cast
-                               } elsif ($op eq '!' || $op eq '~' ||
-                                        $opv eq '*U' || $opv eq '-U' ||
-                                        $opv eq '&U' || $opv eq '&&U') {
-                                       if ($ctx !~ /[WEBC]x./ && $ca !~ /(?:\)|!|~|\*|-|\&|\||\+\+|\-\-|\{)$/) {
-                                               ERROR("SPACING",
-                                                     "space required before that '$op' $at\n" . $hereptr);
-                                       }
-                                       if ($op eq '*' && $cc =~/\s*$Modifier\b/) {
-                                               # A unary '*' may be const
-
-                                       } elsif ($ctx =~ /.xW/) {
-                                               ERROR("SPACING",
-                                                     "space prohibited after that '$op' $at\n" . $hereptr);
-                                       }
-
-                               # unary ++ and unary -- are allowed no space on one side.
-                               } elsif ($op eq '++' or $op eq '--') {
-                                       if ($ctx !~ /[WEOBC]x[^W]/ && $ctx !~ /[^W]x[WOBEC]/) {
-                                               ERROR("SPACING",
-                                                     "space required one side of that '$op' $at\n" . $hereptr);
-                                       }
-                                       if ($ctx =~ /Wx[BE]/ ||
-                                           ($ctx =~ /Wx./ && $cc =~ /^;/)) {
-                                               ERROR("SPACING",
-                                                     "space prohibited before that '$op' $at\n" . $hereptr);
-                                       }
-                                       if ($ctx =~ /ExW/) {
-                                               ERROR("SPACING",
-                                                     "space prohibited after that '$op' $at\n" . $hereptr);
-                                       }
-
-
-                               # << and >> may either have or not have spaces both sides
-                               } elsif ($op eq '<<' or $op eq '>>' or
-                                        $op eq '&' or $op eq '^' or $op eq '|' or
-                                        $op eq '+' or $op eq '-' or
-                                        $op eq '*' or $op eq '/' or
-                                        $op eq '%')
-                               {
-                                       if ($ctx =~ /Wx[^WCE]|[^WCE]xW/) {
-                                               ERROR("SPACING",
-                                                     "need consistent spacing around '$op' $at\n" .
-                                                       $hereptr);
-                                       }
-
-                               # A colon needs no spaces before when it is
-                               # terminating a case value or a label.
-                               } elsif ($opv eq ':C' || $opv eq ':L') {
-                                       if ($ctx =~ /Wx./) {
-                                               ERROR("SPACING",
-                                                     "space prohibited before that '$op' $at\n" . $hereptr);
-                                       }
-
-                               # All the others need spaces both sides.
-                               } elsif ($ctx !~ /[EWC]x[CWE]/) {
-                                       my $ok = 0;
-
-                                       # Ignore email addresses <foo@bar>
-                                       if (($op eq '<' &&
-                                            $cc =~ /^\S+\@\S+>/) ||
-                                           ($op eq '>' &&
-                                            $ca =~ /<\S+\@\S+$/))
-                                       {
-                                               $ok = 1;
-                                       }
-
-                                       # Ignore ?:
-                                       if (($opv eq ':O' && $ca =~ /\?$/) ||
-                                           ($op eq '?' && $cc =~ /^:/)) {
-                                               $ok = 1;
-                                       }
-
-                                       if ($ok == 0) {
-                                               ERROR("SPACING",
-                                                     "spaces required around that '$op' $at\n" . $hereptr);
-                                       }
-                               }
-                               $off += length($elements[$n + 1]);
-                       }
-               }
-
-# check for multiple assignments
-               if ($line =~ /^.\s*$Lval\s*=\s*$Lval\s*=(?!=)/) {
-                       CHK("MULTIPLE_ASSIGNMENTS",
-                           "multiple assignments should be avoided\n" . $herecurr);
-               }
-
-## # check for multiple declarations, allowing for a function declaration
-## # continuation.
-##             if ($line =~ /^.\s*$Type\s+$Ident(?:\s*=[^,{]*)?\s*,\s*$Ident.*/ &&
-##                 $line !~ /^.\s*$Type\s+$Ident(?:\s*=[^,{]*)?\s*,\s*$Type\s*$Ident.*/) {
-##
-##                     # Remove any bracketed sections to ensure we do not
-##                     # falsly report the parameters of functions.
-##                     my $ln = $line;
-##                     while ($ln =~ s/\([^\(\)]*\)//g) {
-##                     }
-##                     if ($ln =~ /,/) {
-##                             WARN("MULTIPLE_DECLARATION",
-##                                  "declaring multiple variables together should be avoided\n" . $herecurr);
-##                     }
-##             }
-
-#need space before brace following if, while, etc
-               if (($line =~ /\(.*\){/ && $line !~ /\($Type\){/) ||
-                   $line =~ /do{/) {
-                       ERROR("SPACING",
-                             "space required before the open brace '{'\n" . $herecurr);
-               }
-
-# closing brace should have a space following it when it has anything
-# on the line
-               if ($line =~ /}(?!(?:,|;|\)))\S/) {
-                       ERROR("SPACING",
-                             "space required after that close brace '}'\n" . $herecurr);
-               }
-
-# check spacing on square brackets
-               if ($line =~ /\[\s/ && $line !~ /\[\s*$/) {
-                       ERROR("SPACING",
-                             "space prohibited after that open square bracket '['\n" . $herecurr);
-               }
-               if ($line =~ /\s\]/) {
-                       ERROR("SPACING",
-                             "space prohibited before that close square bracket ']'\n" . $herecurr);
-               }
-
-# check spacing on parentheses
-               if ($line =~ /\(\s/ && $line !~ /\(\s*(?:\\)?$/ &&
-                   $line !~ /for\s*\(\s+;/) {
-                       ERROR("SPACING",
-                             "space prohibited after that open parenthesis '('\n" . $herecurr);
-               }
-               if ($line =~ /(\s+)\)/ && $line !~ /^.\s*\)/ &&
-                   $line !~ /for\s*\(.*;\s+\)/ &&
-                   $line !~ /:\s+\)/) {
-                       ERROR("SPACING",
-                             "space prohibited before that close parenthesis ')'\n" . $herecurr);
-               }
-
-#goto labels aren't indented, allow a single space however
-               if ($line=~/^.\s+[A-Za-z\d_]+:(?![0-9]+)/ and
-                  !($line=~/^. [A-Za-z\d_]+:/) and !($line=~/^.\s+default:/)) {
-                       WARN("INDENTED_LABEL",
-                            "labels should not be indented\n" . $herecurr);
-               }
-
-# Return is not a function.
-               if (defined($stat) && $stat =~ /^.\s*return(\s*)(\(.*);/s) {
-                       my $spacing = $1;
-                       my $value = $2;
-
-                       # Flatten any parentheses
-                       $value =~ s/\(/ \(/g;
-                       $value =~ s/\)/\) /g;
-                       while ($value =~ s/\[[^\[\]]*\]/1/ ||
-                              $value !~ /(?:$Ident|-?$Constant)\s*
-                                            $Compare\s*
-                                            (?:$Ident|-?$Constant)/x &&
-                              $value =~ s/\([^\(\)]*\)/1/) {
-                       }
-#print "value<$value>\n";
-                       if ($value =~ /^\s*(?:$Ident|-?$Constant)\s*$/) {
-                               ERROR("RETURN_PARENTHESES",
-                                     "return is not a function, parentheses are not required\n" . $herecurr);
-
-                       } elsif ($spacing !~ /\s+/) {
-                               ERROR("SPACING",
-                                     "space required before the open parenthesis '('\n" . $herecurr);
-                       }
-               }
-# Return of what appears to be an errno should normally be -'ve
-               if ($line =~ /^.\s*return\s*(E[A-Z]*)\s*;/) {
-                       my $name = $1;
-                       if ($name ne 'EOF' && $name ne 'ERROR') {
-                               WARN("USE_NEGATIVE_ERRNO",
-                                    "return of an errno should typically be -ve (return -$1)\n" . $herecurr);
-                       }
-               }
-
-# Need a space before open parenthesis after if, while etc
-               if ($line=~/\b(if|while|for|switch)\(/) {
-                       ERROR("SPACING", "space required before the open parenthesis '('\n" . $herecurr);
-               }
-
-# Check for illegal assignment in if conditional -- and check for trailing
-# statements after the conditional.
-               if ($line =~ /do\s*(?!{)/) {
-                       ($stat, $cond, $line_nr_next, $remain_next, $off_next) =
-                               ctx_statement_block($linenr, $realcnt, 0)
-                                       if (!defined $stat);
-                       my ($stat_next) = ctx_statement_block($line_nr_next,
-                                               $remain_next, $off_next);
-                       $stat_next =~ s/\n./\n /g;
-                       ##print "stat<$stat> stat_next<$stat_next>\n";
-
-                       if ($stat_next =~ /^\s*while\b/) {
-                               # If the statement carries leading newlines,
-                               # then count those as offsets.
-                               my ($whitespace) =
-                                       ($stat_next =~ /^((?:\s*\n[+-])*\s*)/s);
-                               my $offset =
-                                       statement_rawlines($whitespace) - 1;
-
-                               $suppress_whiletrailers{$line_nr_next +
-                                                               $offset} = 1;
-                       }
-               }
-               if (!defined $suppress_whiletrailers{$linenr} &&
-                   $line =~ /\b(?:if|while|for)\s*\(/ && $line !~ /^.\s*#/) {
-                       my ($s, $c) = ($stat, $cond);
-
-                       if ($c =~ /\bif\s*\(.*[^<>!=]=[^=].*/s) {
-                               ERROR("ASSIGN_IN_IF",
-                                     "do not use assignment in if condition\n" . $herecurr);
-                       }
-
-                       # Find out what is on the end of the line after the
-                       # conditional.
-                       substr($s, 0, length($c), '');
-                       $s =~ s/\n.*//g;
-                       $s =~ s/$;//g;  # Remove any comments
-                       if (length($c) && $s !~ /^\s*{?\s*\\*\s*$/ &&
-                           $c !~ /}\s*while\s*/)
-                       {
-                               # Find out how long the conditional actually is.
-                               my @newlines = ($c =~ /\n/gs);
-                               my $cond_lines = 1 + $#newlines;
-                               my $stat_real = '';
-
-                               $stat_real = raw_line($linenr, $cond_lines)
-                                                       . "\n" if ($cond_lines);
-                               if (defined($stat_real) && $cond_lines > 1) {
-                                       $stat_real = "[...]\n$stat_real";
-                               }
-
-                               ERROR("TRAILING_STATEMENTS",
-                                     "trailing statements should be on next line\n" . $herecurr . $stat_real);
-                       }
-               }
-
-# Check for bitwise tests written as boolean
-               if ($line =~ /
-                       (?:
-                               (?:\[|\(|\&\&|\|\|)
-                               \s*0[xX][0-9]+\s*
-                               (?:\&\&|\|\|)
-                       |
-                               (?:\&\&|\|\|)
-                               \s*0[xX][0-9]+\s*
-                               (?:\&\&|\|\||\)|\])
-                       )/x)
-               {
-                       WARN("HEXADECIMAL_BOOLEAN_TEST",
-                            "boolean test with hexadecimal, perhaps just 1 \& or \|?\n" . $herecurr);
-               }
-
-# if and else should not have general statements after it
-               if ($line =~ /^.\s*(?:}\s*)?else\b(.*)/) {
-                       my $s = $1;
-                       $s =~ s/$;//g;  # Remove any comments
-                       if ($s !~ /^\s*(?:\sif|(?:{|)\s*\\?\s*$)/) {
-                               ERROR("TRAILING_STATEMENTS",
-                                     "trailing statements should be on next line\n" . $herecurr);
-                       }
-               }
-# if should not continue a brace
-               if ($line =~ /}\s*if\b/) {
-                       ERROR("TRAILING_STATEMENTS",
-                             "trailing statements should be on next line\n" .
-                               $herecurr);
-               }
-# case and default should not have general statements after them
-               if ($line =~ /^.\s*(?:case\s*.*|default\s*):/g &&
-                   $line !~ /\G(?:
-                       (?:\s*$;*)(?:\s*{)?(?:\s*$;*)(?:\s*\\)?\s*$|
-                       \s*return\s+
-                   )/xg)
-               {
-                       ERROR("TRAILING_STATEMENTS",
-                             "trailing statements should be on next line\n" . $herecurr);
-               }
-
-               # Check for }<nl>else {, these must be at the same
-               # indent level to be relevant to each other.
-               if ($prevline=~/}\s*$/ and $line=~/^.\s*else\s*/ and
-                                               $previndent == $indent) {
-                       ERROR("ELSE_AFTER_BRACE",
-                             "else should follow close brace '}'\n" . $hereprev);
-               }
-
-               if ($prevline=~/}\s*$/ and $line=~/^.\s*while\s*/ and
-                                               $previndent == $indent) {
-                       my ($s, $c) = ctx_statement_block($linenr, $realcnt, 0);
-
-                       # Find out what is on the end of the line after the
-                       # conditional.
-                       substr($s, 0, length($c), '');
-                       $s =~ s/\n.*//g;
-
-                       if ($s =~ /^\s*;/) {
-                               ERROR("WHILE_AFTER_BRACE",
-                                     "while should follow close brace '}'\n" . $hereprev);
-                       }
-               }
-
-#CamelCase
-               while ($line =~ m{($Constant|$Lval)}g) {
-                       my $var = $1;
-                       if ($var !~ /$Constant/ &&
-                           $var =~ /[A-Z]\w*[a-z]|[a-z]\w*[A-Z]/ &&
-                           $var !~ /"^(?:Clear|Set|TestClear|TestSet|)Page[A-Z]/ &&
-                           !defined $camelcase{$var}) {
-                               $camelcase{$var} = 1;
-                               WARN("CAMELCASE",
-                                    "Avoid CamelCase: <$var>\n" . $herecurr);
-                       }
-               }
-
-#no spaces allowed after \ in define
-               if ($line=~/\#\s*define.*\\\s$/) {
-                       WARN("WHITESPACE_AFTER_LINE_CONTINUATION",
-                            "Whitepspace after \\ makes next lines useless\n" . $herecurr);
-               }
-
-#warn if <asm/foo.h> is #included and <linux/foo.h> is available (uses RAW line)
-               if ($tree && $rawline =~ m{^.\s*\#\s*include\s*\<asm\/(.*)\.h\>}) {
-                       my $file = "$1.h";
-                       my $checkfile = "include/linux/$file";
-                       if (-f "$root/$checkfile" &&
-                           $realfile ne $checkfile &&
-                           $1 !~ /$allowed_asm_includes/)
-                       {
-                               if ($realfile =~ m{^arch/}) {
-                                       CHK("ARCH_INCLUDE_LINUX",
-                                           "Consider using #include <linux/$file> instead of <asm/$file>\n" . $herecurr);
-                               } else {
-                                       WARN("INCLUDE_LINUX",
-                                            "Use #include <linux/$file> instead of <asm/$file>\n" . $herecurr);
-                               }
-                       }
-               }
-
-# multi-statement macros should be enclosed in a do while loop, grab the
-# first statement and ensure its the whole macro if its not enclosed
-# in a known good container
-               if ($realfile !~ m@/vmlinux.lds.h$@ &&
-                   $line =~ /^.\s*\#\s*define\s*$Ident(\()?/) {
-                       my $ln = $linenr;
-                       my $cnt = $realcnt;
-                       my ($off, $dstat, $dcond, $rest);
-                       my $ctx = '';
-                       ($dstat, $dcond, $ln, $cnt, $off) =
-                               ctx_statement_block($linenr, $realcnt, 0);
-                       $ctx = $dstat;
-                       #print "dstat<$dstat> dcond<$dcond> cnt<$cnt> off<$off>\n";
-                       #print "LINE<$lines[$ln-1]> len<" . length($lines[$ln-1]) . "\n";
-
-                       $dstat =~ s/^.\s*\#\s*define\s+$Ident(?:\([^\)]*\))?\s*//;
-                       $dstat =~ s/$;//g;
-                       $dstat =~ s/\\\n.//g;
-                       $dstat =~ s/^\s*//s;
-                       $dstat =~ s/\s*$//s;
-
-                       # Flatten any parentheses and braces
-                       while ($dstat =~ s/\([^\(\)]*\)/1/ ||
-                              $dstat =~ s/\{[^\{\}]*\}/1/ ||
-                              $dstat =~ s/\[[^\[\]]*\]/1/)
-                       {
-                       }
-
-                       # Flatten any obvious string concatentation.
-                       while ($dstat =~ s/("X*")\s*$Ident/$1/ ||
-                              $dstat =~ s/$Ident\s*("X*")/$1/)
-                       {
-                       }
-
-                       my $exceptions = qr{
-                               $Declare|
-                               module_param_named|
-                               MODULE_PARM_DESC|
-                               DECLARE_PER_CPU|
-                               DEFINE_PER_CPU|
-                               __typeof__\(|
-                               union|
-                               struct|
-                               \.$Ident\s*=\s*|
-                               ^\"|\"$
-                       }x;
-                       #print "REST<$rest> dstat<$dstat> ctx<$ctx>\n";
-                       if ($dstat ne '' &&
-                           $dstat !~ /^(?:$Ident|-?$Constant),$/ &&                    # 10, // foo(),
-                           $dstat !~ /^(?:$Ident|-?$Constant);$/ &&                    # foo();
-                           $dstat !~ /^[!~-]?(?:$Ident|$Constant)$/ &&         # 10 // foo() // !foo // ~foo // -foo
-                           $dstat !~ /^'X'$/ &&                                        # character constants
-                           $dstat !~ /$exceptions/ &&
-                           $dstat !~ /^\.$Ident\s*=/ &&                                # .foo =
-                           $dstat !~ /^do\s*$Constant\s*while\s*$Constant;?$/ &&       # do {...} while (...); // do {...} while (...)
-                           $dstat !~ /^for\s*$Constant$/ &&                            # for (...)
-                           $dstat !~ /^for\s*$Constant\s+(?:$Ident|-?$Constant)$/ &&   # for (...) bar()
-                           $dstat !~ /^do\s*{/ &&                                      # do {...
-                           $dstat !~ /^\({/)                                           # ({...
-                       {
-                               $ctx =~ s/\n*$//;
-                               my $herectx = $here . "\n";
-                               my $cnt = statement_rawlines($ctx);
-
-                               for (my $n = 0; $n < $cnt; $n++) {
-                                       $herectx .= raw_line($linenr, $n) . "\n";
-                               }
-
-                               if ($dstat =~ /;/) {
-                                       ERROR("MULTISTATEMENT_MACRO_USE_DO_WHILE",
-                                             "Macros with multiple statements should be enclosed in a do - while loop\n" . "$herectx");
-                               } else {
-                                       ERROR("COMPLEX_MACRO",
-                                             "Macros with complex values should be enclosed in parenthesis\n" . "$herectx");
-                               }
-                       }
-
-# check for line continuations outside of #defines, preprocessor #, and asm
-
-               } else {
-                       if ($prevline !~ /^..*\\$/ &&
-                           $line !~ /^\+\s*\#.*\\$/ &&         # preprocessor
-                           $line !~ /^\+.*\b(__asm__|asm)\b.*\\$/ &&   # asm
-                           $line =~ /^\+.*\\$/) {
-                               WARN("LINE_CONTINUATIONS",
-                                    "Avoid unnecessary line continuations\n" . $herecurr);
-                       }
-               }
-
-# do {} while (0) macro tests:
-# single-statement macros do not need to be enclosed in do while (0) loop,
-# macro should not end with a semicolon
-               if ($^V && $^V ge 5.10.0 &&
-                   $realfile !~ m@/vmlinux.lds.h$@ &&
-                   $line =~ /^.\s*\#\s*define\s+$Ident(\()?/) {
-                       my $ln = $linenr;
-                       my $cnt = $realcnt;
-                       my ($off, $dstat, $dcond, $rest);
-                       my $ctx = '';
-                       ($dstat, $dcond, $ln, $cnt, $off) =
-                               ctx_statement_block($linenr, $realcnt, 0);
-                       $ctx = $dstat;
-
-                       $dstat =~ s/\\\n.//g;
-
-                       if ($dstat =~ /^\+\s*#\s*define\s+$Ident\s*${balanced_parens}\s*do\s*{(.*)\s*}\s*while\s*\(\s*0\s*\)\s*([;\s]*)\s*$/) {
-                               my $stmts = $2;
-                               my $semis = $3;
-
-                               $ctx =~ s/\n*$//;
-                               my $cnt = statement_rawlines($ctx);
-                               my $herectx = $here . "\n";
-
-                               for (my $n = 0; $n < $cnt; $n++) {
-                                       $herectx .= raw_line($linenr, $n) . "\n";
-                               }
-
-                               if (($stmts =~ tr/;/;/) == 1 &&
-                                   $stmts !~ /^\s*(if|while|for|switch)\b/) {
-                                       WARN("SINGLE_STATEMENT_DO_WHILE_MACRO",
-                                            "Single statement macros should not use a do {} while (0) loop\n" . "$herectx");
-                               }
-                               if (defined $semis && $semis ne "") {
-                                       WARN("DO_WHILE_MACRO_WITH_TRAILING_SEMICOLON",
-                                            "do {} while (0) macros should not be semicolon terminated\n" . "$herectx");
-                               }
-                       }
-               }
-
-# make sure symbols are always wrapped with VMLINUX_SYMBOL() ...
-# all assignments may have only one of the following with an assignment:
-#      .
-#      ALIGN(...)
-#      VMLINUX_SYMBOL(...)
-               if ($realfile eq 'vmlinux.lds.h' && $line =~ /(?:(?:^|\s)$Ident\s*=|=\s*$Ident(?:\s|$))/) {
-                       WARN("MISSING_VMLINUX_SYMBOL",
-                            "vmlinux.lds.h needs VMLINUX_SYMBOL() around C-visible symbols\n" . $herecurr);
-               }
-
-# check for redundant bracing round if etc
-               if ($line =~ /(^.*)\bif\b/ && $1 !~ /else\s*$/) {
-                       my ($level, $endln, @chunks) =
-                               ctx_statement_full($linenr, $realcnt, 1);
-                       #print "chunks<$#chunks> linenr<$linenr> endln<$endln> level<$level>\n";
-                       #print "APW: <<$chunks[1][0]>><<$chunks[1][1]>>\n";
-                       if ($#chunks > 0 && $level == 0) {
-                               my @allowed = ();
-                               my $allow = 0;
-                               my $seen = 0;
-                               my $herectx = $here . "\n";
-                               my $ln = $linenr - 1;
-                               for my $chunk (@chunks) {
-                                       my ($cond, $block) = @{$chunk};
-
-                                       # If the condition carries leading newlines, then count those as offsets.
-                                       my ($whitespace) = ($cond =~ /^((?:\s*\n[+-])*\s*)/s);
-                                       my $offset = statement_rawlines($whitespace) - 1;
-
-                                       $allowed[$allow] = 0;
-                                       #print "COND<$cond> whitespace<$whitespace> offset<$offset>\n";
-
-                                       # We have looked at and allowed this specific line.
-                                       $suppress_ifbraces{$ln + $offset} = 1;
-
-                                       $herectx .= "$rawlines[$ln + $offset]\n[...]\n";
-                                       $ln += statement_rawlines($block) - 1;
-
-                                       substr($block, 0, length($cond), '');
-
-                                       $seen++ if ($block =~ /^\s*{/);
-
-                                       #print "cond<$cond> block<$block> allowed<$allowed[$allow]>\n";
-                                       if (statement_lines($cond) > 1) {
-                                               #print "APW: ALLOWED: cond<$cond>\n";
-                                               $allowed[$allow] = 1;
-                                       }
-                                       if ($block =~/\b(?:if|for|while)\b/) {
-                                               #print "APW: ALLOWED: block<$block>\n";
-                                               $allowed[$allow] = 1;
-                                       }
-                                       if (statement_block_size($block) > 1) {
-                                               #print "APW: ALLOWED: lines block<$block>\n";
-                                               $allowed[$allow] = 1;
-                                       }
-                                       $allow++;
-                               }
-                               if ($seen) {
-                                       my $sum_allowed = 0;
-                                       foreach (@allowed) {
-                                               $sum_allowed += $_;
-                                       }
-                                       if ($sum_allowed == 0) {
-                                               WARN("BRACES",
-                                                    "braces {} are not necessary for any arm of this statement\n" . $herectx);
-                                       } elsif ($sum_allowed != $allow &&
-                                                $seen != $allow) {
-                                               CHK("BRACES",
-                                                   "braces {} should be used on all arms of this statement\n" . $herectx);
-                                       }
-                               }
-                       }
-               }
-               if (!defined $suppress_ifbraces{$linenr - 1} &&
-                                       $line =~ /\b(if|while|for|else)\b/) {
-                       my $allowed = 0;
-
-                       # Check the pre-context.
-                       if (substr($line, 0, $-[0]) =~ /(\}\s*)$/) {
-                               #print "APW: ALLOWED: pre<$1>\n";
-                               $allowed = 1;
-                       }
-
-                       my ($level, $endln, @chunks) =
-                               ctx_statement_full($linenr, $realcnt, $-[0]);
-
-                       # Check the condition.
-                       my ($cond, $block) = @{$chunks[0]};
-                       #print "CHECKING<$linenr> cond<$cond> block<$block>\n";
-                       if (defined $cond) {
-                               substr($block, 0, length($cond), '');
-                       }
-                       if (statement_lines($cond) > 1) {
-                               #print "APW: ALLOWED: cond<$cond>\n";
-                               $allowed = 1;
-                       }
-                       if ($block =~/\b(?:if|for|while)\b/) {
-                               #print "APW: ALLOWED: block<$block>\n";
-                               $allowed = 1;
-                       }
-                       if (statement_block_size($block) > 1) {
-                               #print "APW: ALLOWED: lines block<$block>\n";
-                               $allowed = 1;
-                       }
-                       # Check the post-context.
-                       if (defined $chunks[1]) {
-                               my ($cond, $block) = @{$chunks[1]};
-                               if (defined $cond) {
-                                       substr($block, 0, length($cond), '');
-                               }
-                               if ($block =~ /^\s*\{/) {
-                                       #print "APW: ALLOWED: chunk-1 block<$block>\n";
-                                       $allowed = 1;
-                               }
-                       }
-                       if ($level == 0 && $block =~ /^\s*\{/ && !$allowed) {
-                               my $herectx = $here . "\n";
-                               my $cnt = statement_rawlines($block);
-
-                               for (my $n = 0; $n < $cnt; $n++) {
-                                       $herectx .= raw_line($linenr, $n) . "\n";
-                               }
-
-                               WARN("BRACES",
-                                    "braces {} are not necessary for single statement blocks\n" . $herectx);
-                       }
-               }
-
-# check for unnecessary blank lines around braces
-               if (($line =~ /^..*}\s*$/ && $prevline =~ /^.\s*$/)) {
-                       CHK("BRACES",
-                           "Blank lines aren't necessary before a close brace '}'\n" . $hereprev);
-               }
-               if (($line =~ /^.\s*$/ && $prevline =~ /^..*{\s*$/)) {
-                       CHK("BRACES",
-                           "Blank lines aren't necessary after an open brace '{'\n" . $hereprev);
-               }
-
-# no volatiles please
-               my $asm_volatile = qr{\b(__asm__|asm)\s+(__volatile__|volatile)\b};
-               if ($line =~ /\bvolatile\b/ && $line !~ /$asm_volatile/) {
-                       WARN("VOLATILE",
-                            "Use of volatile is usually wrong: see Documentation/volatile-considered-harmful.txt\n" . $herecurr);
-               }
-
-# warn about #if 0
-               if ($line =~ /^.\s*\#\s*if\s+0\b/) {
-                       CHK("REDUNDANT_CODE",
-                           "if this code is redundant consider removing it\n" .
-                               $herecurr);
-               }
-
-# check for needless "if (<foo>) fn(<foo>)" uses
-               if ($prevline =~ /\bif\s*\(\s*($Lval)\s*\)/) {
-                       my $expr = '\s*\(\s*' . quotemeta($1) . '\s*\)\s*;';
-                       if ($line =~ /\b(kfree|usb_free_urb|debugfs_remove(?:_recursive)?)$expr/) {
-                               WARN('NEEDLESS_IF',
-                                    "$1(NULL) is safe this check is probably not required\n" . $hereprev);
-                       }
-               }
-
-# prefer usleep_range over udelay
-               if ($line =~ /\budelay\s*\(\s*(\d+)\s*\)/) {
-                       # ignore udelay's < 10, however
-                       if (! ($1 < 10) ) {
-                               CHK("USLEEP_RANGE",
-                                   "usleep_range is preferred over udelay; see Documentation/timers/timers-howto.txt\n" . $line);
-                       }
-               }
-
-# warn about unexpectedly long msleep's
-               if ($line =~ /\bmsleep\s*\((\d+)\);/) {
-                       if ($1 < 20) {
-                               WARN("MSLEEP",
-                                    "msleep < 20ms can sleep for up to 20ms; see Documentation/timers/timers-howto.txt\n" . $line);
-                       }
-               }
-
-# warn about #ifdefs in C files
-#              if ($line =~ /^.\s*\#\s*if(|n)def/ && ($realfile =~ /\.c$/)) {
-#                      print "#ifdef in C files should be avoided\n";
-#                      print "$herecurr";
-#                      $clean = 0;
-#              }
-
-# warn about spacing in #ifdefs
-               if ($line =~ /^.\s*\#\s*(ifdef|ifndef|elif)\s\s+/) {
-                       ERROR("SPACING",
-                             "exactly one space required after that #$1\n" . $herecurr);
-               }
-
-# check for spinlock_t definitions without a comment.
-               if ($line =~ /^.\s*(struct\s+mutex|spinlock_t)\s+\S+;/ ||
-                   $line =~ /^.\s*(DEFINE_MUTEX)\s*\(/) {
-                       my $which = $1;
-                       if (!ctx_has_comment($first_line, $linenr)) {
-                               CHK("UNCOMMENTED_DEFINITION",
-                                   "$1 definition without comment\n" . $herecurr);
-                       }
-               }
-# check for memory barriers without a comment.
-               if ($line =~ /\b(mb|rmb|wmb|read_barrier_depends|smp_mb|smp_rmb|smp_wmb|smp_read_barrier_depends)\(/) {
-                       if (!ctx_has_comment($first_line, $linenr)) {
-                               CHK("MEMORY_BARRIER",
-                                   "memory barrier without comment\n" . $herecurr);
-                       }
-               }
-# check of hardware specific defines
-               if ($line =~ m@^.\s*\#\s*if.*\b(__i386__|__powerpc64__|__sun__|__s390x__)\b@ && $realfile !~ m@include/asm-@) {
-                       CHK("ARCH_DEFINES",
-                           "architecture specific defines should be avoided\n" .  $herecurr);
-               }
-
-# Check that the storage class is at the beginning of a declaration
-               if ($line =~ /\b$Storage\b/ && $line !~ /^.\s*$Storage\b/) {
-                       WARN("STORAGE_CLASS",
-                            "storage class should be at the beginning of the declaration\n" . $herecurr)
-               }
-
-# check the location of the inline attribute, that it is between
-# storage class and type.
-               if ($line =~ /\b$Type\s+$Inline\b/ ||
-                   $line =~ /\b$Inline\s+$Storage\b/) {
-                       ERROR("INLINE_LOCATION",
-                             "inline keyword should sit between storage class and type\n" . $herecurr);
-               }
-
-# Check for __inline__ and __inline, prefer inline
-               if ($line =~ /\b(__inline__|__inline)\b/) {
-                       WARN("INLINE",
-                            "plain inline is preferred over $1\n" . $herecurr);
-               }
-
-# Check for __attribute__ packed, prefer __packed
-               if ($line =~ /\b__attribute__\s*\(\s*\(.*\bpacked\b/) {
-                       WARN("PREFER_PACKED",
-                            "__packed is preferred over __attribute__((packed))\n" . $herecurr);
-               }
-
-# Check for __attribute__ aligned, prefer __aligned
-               if ($line =~ /\b__attribute__\s*\(\s*\(.*aligned/) {
-                       WARN("PREFER_ALIGNED",
-                            "__aligned(size) is preferred over __attribute__((aligned(size)))\n" . $herecurr);
-               }
-
-# Check for __attribute__ format(printf, prefer __printf
-               if ($line =~ /\b__attribute__\s*\(\s*\(\s*format\s*\(\s*printf/) {
-                       WARN("PREFER_PRINTF",
-                            "__printf(string-index, first-to-check) is preferred over __attribute__((format(printf, string-index, first-to-check)))\n" . $herecurr);
-               }
-
-# Check for __attribute__ format(scanf, prefer __scanf
-               if ($line =~ /\b__attribute__\s*\(\s*\(\s*format\s*\(\s*scanf\b/) {
-                       WARN("PREFER_SCANF",
-                            "__scanf(string-index, first-to-check) is preferred over __attribute__((format(scanf, string-index, first-to-check)))\n" . $herecurr);
-               }
-
-# check for sizeof(&)
-               if ($line =~ /\bsizeof\s*\(\s*\&/) {
-                       WARN("SIZEOF_ADDRESS",
-                            "sizeof(& should be avoided\n" . $herecurr);
-               }
-
-# check for sizeof without parenthesis
-               if ($line =~ /\bsizeof\s+((?:\*\s*|)$Lval|$Type(?:\s+$Lval|))/) {
-                       WARN("SIZEOF_PARENTHESIS",
-                            "sizeof $1 should be sizeof($1)\n" . $herecurr);
-               }
-
-# check for line continuations in quoted strings with odd counts of "
-               if ($rawline =~ /\\$/ && $rawline =~ tr/"/"/ % 2) {
-                       WARN("LINE_CONTINUATIONS",
-                            "Avoid line continuations in quoted strings\n" . $herecurr);
-               }
-
-# check for struct spinlock declarations
-               if ($line =~ /^.\s*\bstruct\s+spinlock\s+\w+\s*;/) {
-                       WARN("USE_SPINLOCK_T",
-                            "struct spinlock should be spinlock_t\n" . $herecurr);
-               }
-
-# Check for misused memsets
-               if ($^V && $^V ge 5.10.0 &&
-                   defined $stat &&
-                   $stat =~ /^\+(?:.*?)\bmemset\s*\(\s*$FuncArg\s*,\s*$FuncArg\s*\,\s*$FuncArg\s*\)/s) {
-
-                       my $ms_addr = $2;
-                       my $ms_val = $7;
-                       my $ms_size = $12;
-
-                       if ($ms_size =~ /^(0x|)0$/i) {
-                               ERROR("MEMSET",
-                                     "memset to 0's uses 0 as the 2nd argument, not the 3rd\n" . "$here\n$stat\n");
-                       } elsif ($ms_size =~ /^(0x|)1$/i) {
-                               WARN("MEMSET",
-                                    "single byte memset is suspicious. Swapped 2nd/3rd argument?\n" . "$here\n$stat\n");
-                       }
-               }
-
-# typecasts on min/max could be min_t/max_t
-               if ($^V && $^V ge 5.10.0 &&
-                   defined $stat &&
-                   $stat =~ /^\+(?:.*?)\b(min|max)\s*\(\s*$FuncArg\s*,\s*$FuncArg\s*\)/) {
-                       if (defined $2 || defined $7) {
-                               my $call = $1;
-                               my $cast1 = deparenthesize($2);
-                               my $arg1 = $3;
-                               my $cast2 = deparenthesize($7);
-                               my $arg2 = $8;
-                               my $cast;
-
-                               if ($cast1 ne "" && $cast2 ne "" && $cast1 ne $cast2) {
-                                       $cast = "$cast1 or $cast2";
-                               } elsif ($cast1 ne "") {
-                                       $cast = $cast1;
-                               } else {
-                                       $cast = $cast2;
-                               }
-                               WARN("MINMAX",
-                                    "$call() should probably be ${call}_t($cast, $arg1, $arg2)\n" . "$here\n$stat\n");
-                       }
-               }
-
-# check usleep_range arguments
-               if ($^V && $^V ge 5.10.0 &&
-                   defined $stat &&
-                   $stat =~ /^\+(?:.*?)\busleep_range\s*\(\s*($FuncArg)\s*,\s*($FuncArg)\s*\)/) {
-                       my $min = $1;
-                       my $max = $7;
-                       if ($min eq $max) {
-                               WARN("USLEEP_RANGE",
-                                    "usleep_range should not use min == max args; see Documentation/timers/timers-howto.txt\n" . "$here\n$stat\n");
-                       } elsif ($min =~ /^\d+$/ && $max =~ /^\d+$/ &&
-                                $min > $max) {
-                               WARN("USLEEP_RANGE",
-                                    "usleep_range args reversed, use min then max; see Documentation/timers/timers-howto.txt\n" . "$here\n$stat\n");
-                       }
-               }
-
-# check for new externs in .c files.
-               if ($realfile =~ /\.c$/ && defined $stat &&
-                   $stat =~ /^.\s*(?:extern\s+)?$Type\s+($Ident)(\s*)\(/s)
-               {
-                       my $function_name = $1;
-                       my $paren_space = $2;
-
-                       my $s = $stat;
-                       if (defined $cond) {
-                               substr($s, 0, length($cond), '');
-                       }
-                       if ($s =~ /^\s*;/ &&
-                           $function_name ne 'uninitialized_var')
-                       {
-                               WARN("AVOID_EXTERNS",
-                                    "externs should be avoided in .c files\n" .  $herecurr);
-                       }
-
-                       if ($paren_space =~ /\n/) {
-                               WARN("FUNCTION_ARGUMENTS",
-                                    "arguments for function declarations should follow identifier\n" . $herecurr);
-                       }
-
-               } elsif ($realfile =~ /\.c$/ && defined $stat &&
-                   $stat =~ /^.\s*extern\s+/)
-               {
-                       WARN("AVOID_EXTERNS",
-                            "externs should be avoided in .c files\n" .  $herecurr);
-               }
-
-# checks for new __setup's
-               if ($rawline =~ /\b__setup\("([^"]*)"/) {
-                       my $name = $1;
-
-                       if (!grep(/$name/, @setup_docs)) {
-                               CHK("UNDOCUMENTED_SETUP",
-                                   "__setup appears un-documented -- check Documentation/kernel-parameters.txt\n" . $herecurr);
-                       }
-               }
-
-# check for pointless casting of kmalloc return
-               if ($line =~ /\*\s*\)\s*[kv][czm]alloc(_node){0,1}\b/) {
-                       WARN("UNNECESSARY_CASTS",
-                            "unnecessary cast may hide bugs, see http://c-faq.com/malloc/mallocnocast.html\n" . $herecurr);
-               }
-
-# check for alloc argument mismatch
-               if ($line =~ /\b(kcalloc|kmalloc_array)\s*\(\s*sizeof\b/) {
-                       WARN("ALLOC_ARRAY_ARGS",
-                            "$1 uses number as first arg, sizeof is generally wrong\n" . $herecurr);
-               }
-
-# check for multiple semicolons
-               if ($line =~ /;\s*;\s*$/) {
-                       WARN("ONE_SEMICOLON",
-                            "Statements terminations use 1 semicolon\n" . $herecurr);
-               }
-
-# check for switch/default statements without a break;
-               if ($^V && $^V ge 5.10.0 &&
-                   defined $stat &&
-                   $stat =~ /^\+[$;\s]*(?:case[$;\s]+\w+[$;\s]*:[$;\s]*|)*[$;\s]*\bdefault[$;\s]*:[$;\s]*;/g) {
-                       my $ctx = '';
-                       my $herectx = $here . "\n";
-                       my $cnt = statement_rawlines($stat);
-                       for (my $n = 0; $n < $cnt; $n++) {
-                               $herectx .= raw_line($linenr, $n) . "\n";
-                       }
-                       WARN("DEFAULT_NO_BREAK",
-                            "switch default: should use break\n" . $herectx);
-               }
-
-# check for gcc specific __FUNCTION__
-               if ($line =~ /__FUNCTION__/) {
-                       WARN("USE_FUNC",
-                            "__func__ should be used instead of gcc specific __FUNCTION__\n"  . $herecurr);
-               }
-
-# check for use of yield()
-               if ($line =~ /\byield\s*\(\s*\)/) {
-                       WARN("YIELD",
-                            "Using yield() is generally wrong. See yield() kernel-doc (sched/core.c)\n"  . $herecurr);
-               }
-
-# check for semaphores initialized locked
-               if ($line =~ /^.\s*sema_init.+,\W?0\W?\)/) {
-                       WARN("CONSIDER_COMPLETION",
-                            "consider using a completion\n" . $herecurr);
-               }
-
-# recommend kstrto* over simple_strto* and strict_strto*
-               if ($line =~ /\b((simple|strict)_(strto(l|ll|ul|ull)))\s*\(/) {
-                       WARN("CONSIDER_KSTRTO",
-                            "$1 is obsolete, use k$3 instead\n" . $herecurr);
-               }
-
-# check for __initcall(), use device_initcall() explicitly please
-               if ($line =~ /^.\s*__initcall\s*\(/) {
-                       WARN("USE_DEVICE_INITCALL",
-                            "please use device_initcall() instead of __initcall()\n" . $herecurr);
-               }
-
-# check for various ops structs, ensure they are const.
-               my $struct_ops = qr{acpi_dock_ops|
-                               address_space_operations|
-                               backlight_ops|
-                               block_device_operations|
-                               dentry_operations|
-                               dev_pm_ops|
-                               dma_map_ops|
-                               extent_io_ops|
-                               file_lock_operations|
-                               file_operations|
-                               hv_ops|
-                               ide_dma_ops|
-                               intel_dvo_dev_ops|
-                               item_operations|
-                               iwl_ops|
-                               kgdb_arch|
-                               kgdb_io|
-                               kset_uevent_ops|
-                               lock_manager_operations|
-                               microcode_ops|
-                               mtrr_ops|
-                               neigh_ops|
-                               nlmsvc_binding|
-                               pci_raw_ops|
-                               pipe_buf_operations|
-                               platform_hibernation_ops|
-                               platform_suspend_ops|
-                               proto_ops|
-                               rpc_pipe_ops|
-                               seq_operations|
-                               snd_ac97_build_ops|
-                               soc_pcmcia_socket_ops|
-                               stacktrace_ops|
-                               sysfs_ops|
-                               tty_operations|
-                               usb_mon_operations|
-                               wd_ops}x;
-               if ($line !~ /\bconst\b/ &&
-                   $line =~ /\bstruct\s+($struct_ops)\b/) {
-                       WARN("CONST_STRUCT",
-                            "struct $1 should normally be const\n" .
-                               $herecurr);
-               }
-
-# use of NR_CPUS is usually wrong
-# ignore definitions of NR_CPUS and usage to define arrays as likely right
-               if ($line =~ /\bNR_CPUS\b/ &&
-                   $line !~ /^.\s*\s*#\s*if\b.*\bNR_CPUS\b/ &&
-                   $line !~ /^.\s*\s*#\s*define\b.*\bNR_CPUS\b/ &&
-                   $line !~ /^.\s*$Declare\s.*\[[^\]]*NR_CPUS[^\]]*\]/ &&
-                   $line !~ /\[[^\]]*\.\.\.[^\]]*NR_CPUS[^\]]*\]/ &&
-                   $line !~ /\[[^\]]*NR_CPUS[^\]]*\.\.\.[^\]]*\]/)
-               {
-                       WARN("NR_CPUS",
-                            "usage of NR_CPUS is often wrong - consider using cpu_possible(), num_possible_cpus(), for_each_possible_cpu(), etc\n" . $herecurr);
-               }
-
-# check for %L{u,d,i} in strings
-               my $string;
-               while ($line =~ /(?:^|")([X\t]*)(?:"|$)/g) {
-                       $string = substr($rawline, $-[1], $+[1] - $-[1]);
-                       $string =~ s/%%/__/g;
-                       if ($string =~ /(?<!%)%L[udi]/) {
-                               WARN("PRINTF_L",
-                                    "\%Ld/%Lu are not-standard C, use %lld/%llu\n" . $herecurr);
-                               last;
-                       }
-               }
-
-# whine mightly about in_atomic
-               if ($line =~ /\bin_atomic\s*\(/) {
-                       if ($realfile =~ m@^drivers/@) {
-                               ERROR("IN_ATOMIC",
-                                     "do not use in_atomic in drivers\n" . $herecurr);
-                       } elsif ($realfile !~ m@^kernel/@) {
-                               WARN("IN_ATOMIC",
-                                    "use of in_atomic() is incorrect outside core kernel code\n" . $herecurr);
-                       }
-               }
-
-# check for lockdep_set_novalidate_class
-               if ($line =~ /^.\s*lockdep_set_novalidate_class\s*\(/ ||
-                   $line =~ /__lockdep_no_validate__\s*\)/ ) {
-                       if ($realfile !~ m@^kernel/lockdep@ &&
-                           $realfile !~ m@^include/linux/lockdep@ &&
-                           $realfile !~ m@^drivers/base/core@) {
-                               ERROR("LOCKDEP",
-                                     "lockdep_no_validate class is reserved for device->mutex.\n" . $herecurr);
-                       }
-               }
-
-               if ($line =~ /debugfs_create_file.*S_IWUGO/ ||
-                   $line =~ /DEVICE_ATTR.*S_IWUGO/ ) {
-                       WARN("EXPORTED_WORLD_WRITABLE",
-                            "Exporting world writable files is usually an error. Consider more restrictive permissions.\n" . $herecurr);
-               }
-       }
-
-       # If we have no input at all, then there is nothing to report on
-       # so just keep quiet.
-       if ($#rawlines == -1) {
-               exit(0);
-       }
-
-       # In mailback mode only produce a report in the negative, for
-       # things that appear to be patches.
-       if ($mailback && ($clean == 1 || !$is_patch)) {
-               exit(0);
-       }
-
-       # This is not a patch, and we are are in 'no-patch' mode so
-       # just keep quiet.
-       if (!$chk_patch && !$is_patch) {
-               exit(0);
-       }
-
-       if (!$is_patch) {
-               ERROR("NOT_UNIFIED_DIFF",
-                     "Does not appear to be a unified-diff format patch\n");
-       }
-       if ($is_patch && $chk_signoff && $signoff == 0) {
-               ERROR("MISSING_SIGN_OFF",
-                     "Missing Signed-off-by: line(s)\n");
-       }
-
-       print report_dump();
-       if ($summary && !($clean == 1 && $quiet == 1)) {
-               print "$filename " if ($summary_file);
-               print "total: $cnt_error errors, $cnt_warn warnings, " .
-                       (($check)? "$cnt_chk checks, " : "") .
-                       "$cnt_lines lines checked\n";
-               print "\n" if ($quiet == 0);
-       }
-
-       if ($quiet == 0) {
-
-               if ($^V lt 5.10.0) {
-                       print("NOTE: perl $^V is not modern enough to detect all possible issues.\n");
-                       print("An upgrade to at least perl v5.10.0 is suggested.\n\n");
-               }
-
-               # If there were whitespace errors which cleanpatch can fix
-               # then suggest that.
-               if ($rpt_cleaners) {
-                       print "NOTE: whitespace errors detected, you may wish to use scripts/cleanpatch or\n";
-                       print "      scripts/cleanfile\n\n";
-                       $rpt_cleaners = 0;
-               }
-       }
-
-       if ($quiet == 0 && keys %ignore_type) {
-           print "NOTE: Ignored message types:";
-           foreach my $ignore (sort keys %ignore_type) {
-               print " $ignore";
-           }
-           print "\n\n";
-       }
-
-       if ($clean == 1 && $quiet == 0) {
-               print "$vname has no obvious style problems and is ready for submission.\n"
-       }
-       if ($clean == 0 && $quiet == 0) {
-               print << "EOM";
-$vname has style problems, please review.
-
-If any of these errors are false positives, please report
-them to the maintainer, see boards.cfg.
-EOM
-       }
-
-       return $clean;
-}
diff --git a/tools/checkstack.pl b/tools/checkstack.pl
deleted file mode 100755 (executable)
index c1cdc0a..0000000
+++ /dev/null
@@ -1,171 +0,0 @@
-#!/usr/bin/perl
-
-#      Check the stack usage of functions
-#
-#      Copyright Joern Engel <joern@lazybastard.org>
-#      Inspired by Linus Torvalds
-#      Original idea maybe from Keith Owens
-#      s390 port and big speedup by Arnd Bergmann <arnd@bergmann-dalldorf.de>
-#      Mips port by Juan Quintela <quintela@mandrakesoft.com>
-#      IA64 port via Andreas Dilger
-#      Arm port by Holger Schurig
-#      sh64 port by Paul Mundt
-#      Random bits by Matt Mackall <mpm@selenic.com>
-#      M68k port by Geert Uytterhoeven and Andreas Schwab
-#      AVR32 port by Haavard Skinnemoen (Atmel)
-#      PARISC port by Kyle McMartin <kyle@parisc-linux.org>
-#      sparc port by Martin Habets <errandir_news@mph.eclipse.co.uk>
-#
-#      Usage:
-#      objdump -d vmlinux | scripts/checkstack.pl [arch]
-#
-#      TODO :  Port to all architectures (one regex per arch)
-
-use strict;
-
-# check for arch
-#
-# $re is used for two matches:
-# $& (whole re) matches the complete objdump line with the stack growth
-# $1 (first bracket) matches the size of the stack growth
-#
-# $dre is similar, but for dynamic stack redutions:
-# $& (whole re) matches the complete objdump line with the stack growth
-# $1 (first bracket) matches the dynamic amount of the stack growth
-#
-# use anything else and feel the pain ;)
-my (@stack, $re, $dre, $x, $xs);
-{
-       my $arch = shift;
-       if ($arch eq "") {
-               $arch = `uname -m`;
-               chomp($arch);
-       }
-
-       $x      = "[0-9a-f]";   # hex character
-       $xs     = "[0-9a-f ]";  # hex character or space
-       if ($arch eq 'arm') {
-               #c0008ffc:      e24dd064        sub     sp, sp, #100    ; 0x64
-               $re = qr/.*sub.*sp, sp, #(([0-9]{2}|[3-9])[0-9]{2})/o;
-       } elsif ($arch eq 'avr32') {
-               #8000008a:       20 1d           sub sp,4
-               #80000ca8:       fa cd 05 b0     sub sp,sp,1456
-               $re = qr/^.*sub.*sp.*,([0-9]{1,8})/o;
-       } elsif ($arch =~ /^i[3456]86$/) {
-               #c0105234:       81 ec ac 05 00 00       sub    $0x5ac,%esp
-               $re = qr/^.*[as][du][db]    \$(0x$x{1,8}),\%esp$/o;
-               $dre = qr/^.*[as][du][db]    (%.*),\%esp$/o;
-       } elsif ($arch eq 'x86_64') {
-               #    2f60:      48 81 ec e8 05 00 00    sub    $0x5e8,%rsp
-               $re = qr/^.*[as][du][db]    \$(0x$x{1,8}),\%rsp$/o;
-               $dre = qr/^.*[as][du][db]    (\%.*),\%rsp$/o;
-       } elsif ($arch eq 'ia64') {
-               #e0000000044011fc:       01 0f fc 8c     adds r12=-384,r12
-               $re = qr/.*adds.*r12=-(([0-9]{2}|[3-9])[0-9]{2}),r12/o;
-       } elsif ($arch eq 'm68k') {
-               #    2b6c:       4e56 fb70       linkw %fp,#-1168
-               #  1df770:       defc ffe4       addaw #-28,%sp
-               $re = qr/.*(?:linkw %fp,|addaw )#-([0-9]{1,4})(?:,%sp)?$/o;
-       } elsif ($arch eq 'mips64') {
-               #8800402c:       67bdfff0        daddiu  sp,sp,-16
-               $re = qr/.*daddiu.*sp,sp,-(([0-9]{2}|[3-9])[0-9]{2})/o;
-       } elsif ($arch eq 'mips') {
-               #88003254:       27bdffe0        addiu   sp,sp,-32
-               $re = qr/.*addiu.*sp,sp,-(([0-9]{2}|[3-9])[0-9]{2})/o;
-       } elsif ($arch eq 'parisc' || $arch eq 'parisc64') {
-               $re = qr/.*ldo ($x{1,8})\(sp\),sp/o;
-       } elsif ($arch eq 'ppc') {
-               #c00029f4:       94 21 ff 30     stwu    r1,-208(r1)
-               $re = qr/.*stwu.*r1,-($x{1,8})\(r1\)/o;
-       } elsif ($arch eq 'ppc64') {
-               #XXX
-               $re = qr/.*stdu.*r1,-($x{1,8})\(r1\)/o;
-       } elsif ($arch eq 'powerpc') {
-               $re = qr/.*st[dw]u.*r1,-($x{1,8})\(r1\)/o;
-       } elsif ($arch =~ /^s390x?$/) {
-               #   11160:       a7 fb ff 60             aghi   %r15,-160
-               # or
-               #  100092:       e3 f0 ff c8 ff 71       lay     %r15,-56(%r15)
-               $re = qr/.*(?:lay|ag?hi).*\%r15,-(([0-9]{2}|[3-9])[0-9]{2})
-                     (?:\(\%r15\))?$/ox;
-       } elsif ($arch =~ /^sh64$/) {
-               #XXX: we only check for the immediate case presently,
-               #     though we will want to check for the movi/sub
-               #     pair for larger users. -- PFM.
-               #a00048e0:       d4fc40f0        addi.l  r15,-240,r15
-               $re = qr/.*addi\.l.*r15,-(([0-9]{2}|[3-9])[0-9]{2}),r15/o;
-       } elsif ($arch =~ /^blackfin$/) {
-               #   0:   00 e8 38 01     LINK 0x4e0;
-               $re = qr/.*[[:space:]]LINK[[:space:]]*(0x$x{1,8})/o;
-       } elsif ($arch eq 'sparc' || $arch eq 'sparc64') {
-               # f0019d10:       9d e3 bf 90     save  %sp, -112, %sp
-               $re = qr/.*save.*%sp, -(([0-9]{2}|[3-9])[0-9]{2}), %sp/o;
-       } else {
-               print("wrong or unknown architecture \"$arch\"\n");
-               exit
-       }
-}
-
-#
-# main()
-#
-my $funcre = qr/^$x* <(.*)>:$/;
-my ($func, $file, $lastslash);
-
-while (my $line = <STDIN>) {
-       if ($line =~ m/$funcre/) {
-               $func = $1;
-       }
-       elsif ($line =~ m/(.*):\s*file format/) {
-               $file = $1;
-               $file =~ s/\.ko//;
-               $lastslash = rindex($file, "/");
-               if ($lastslash != -1) {
-                       $file = substr($file, $lastslash + 1);
-               }
-       }
-       elsif ($line =~ m/$re/) {
-               my $size = $1;
-               $size = hex($size) if ($size =~ /^0x/);
-
-               if ($size > 0xf0000000) {
-                       $size = - $size;
-                       $size += 0x80000000;
-                       $size += 0x80000000;
-               }
-               next if ($size > 0x10000000);
-
-               next if $line !~ m/^($xs*)/;
-               my $addr = $1;
-               $addr =~ s/ /0/g;
-               $addr = "0x$addr";
-
-               my $intro = "$addr $func [$file]:";
-               my $padlen = 56 - length($intro);
-               while ($padlen > 0) {
-                       $intro .= '     ';
-                       $padlen -= 8;
-               }
-               next if ($size < 100);
-               push @stack, "$intro$size\n";
-       }
-       elsif (defined $dre && $line =~ m/$dre/) {
-               my $size = "Dynamic ($1)";
-
-               next if $line !~ m/^($xs*)/;
-               my $addr = $1;
-               $addr =~ s/ /0/g;
-               $addr = "0x$addr";
-
-               my $intro = "$addr $func [$file]:";
-               my $padlen = 56 - length($intro);
-               while ($padlen > 0) {
-                       $intro .= '     ';
-                       $padlen -= 8;
-               }
-               push @stack, "$intro$size\n";
-       }
-}
-
-# Sort output by size (last field)
-print sort { ($b =~ /:\t*(\d+)$/)[0] <=> ($a =~ /:\t*(\d+)$/)[0] } @stack;
diff --git a/tools/cleanpatch b/tools/cleanpatch
deleted file mode 100755 (executable)
index 9680d03..0000000
+++ /dev/null
@@ -1,258 +0,0 @@
-#!/usr/bin/perl -w
-#
-# Clean a patch file -- or directory of patch files -- of stealth whitespace.
-# WARNING: this can be a highly destructive operation.  Use with caution.
-#
-
-use bytes;
-use File::Basename;
-
-# Default options
-$max_width = 79;
-
-# Clean up space-tab sequences, either by removing spaces or
-# replacing them with tabs.
-sub clean_space_tabs($)
-{
-    no bytes;                  # Tab alignment depends on characters
-
-    my($li) = @_;
-    my($lo) = '';
-    my $pos = 0;
-    my $nsp = 0;
-    my($i, $c);
-
-    for ($i = 0; $i < length($li); $i++) {
-       $c = substr($li, $i, 1);
-       if ($c eq "\t") {
-           my $npos = ($pos+$nsp+8) & ~7;
-           my $ntab = ($npos >> 3) - ($pos >> 3);
-           $lo .= "\t" x $ntab;
-           $pos = $npos;
-           $nsp = 0;
-       } elsif ($c eq "\n" || $c eq "\r") {
-           $lo .= " " x $nsp;
-           $pos += $nsp;
-           $nsp = 0;
-           $lo .= $c;
-           $pos = 0;
-       } elsif ($c eq " ") {
-           $nsp++;
-       } else {
-           $lo .= " " x $nsp;
-           $pos += $nsp;
-           $nsp = 0;
-           $lo .= $c;
-           $pos++;
-       }
-    }
-    $lo .= " " x $nsp;
-    return $lo;
-}
-
-# Compute the visual width of a string
-sub strwidth($) {
-    no bytes;                  # Tab alignment depends on characters
-
-    my($li) = @_;
-    my($c, $i);
-    my $pos = 0;
-    my $mlen = 0;
-
-    for ($i = 0; $i < length($li); $i++) {
-       $c = substr($li,$i,1);
-       if ($c eq "\t") {
-           $pos = ($pos+8) & ~7;
-       } elsif ($c eq "\n") {
-           $mlen = $pos if ($pos > $mlen);
-           $pos = 0;
-       } else {
-           $pos++;
-       }
-    }
-
-    $mlen = $pos if ($pos > $mlen);
-    return $mlen;
-}
-
-$name = basename($0);
-
-@files = ();
-
-while (defined($a = shift(@ARGV))) {
-    if ($a =~ /^-/) {
-       if ($a eq '-width' || $a eq '-w') {
-           $max_width = shift(@ARGV)+0;
-       } else {
-           print STDERR "Usage: $name [-width #] files...\n";
-           exit 1;
-       }
-    } else {
-       push(@files, $a);
-    }
-}
-
-foreach $f ( @files ) {
-    print STDERR "$name: $f\n";
-
-    if (! -f $f) {
-       print STDERR "$f: not a file\n";
-       next;
-    }
-
-    if (!open(FILE, '+<', $f)) {
-       print STDERR "$name: Cannot open file: $f: $!\n";
-       next;
-    }
-
-    binmode FILE;
-
-    # First, verify that it is not a binary file; consider any file
-    # with a zero byte to be a binary file.  Is there any better, or
-    # additional, heuristic that should be applied?
-    $is_binary = 0;
-
-    while (read(FILE, $data, 65536) > 0) {
-       if ($data =~ /\0/) {
-           $is_binary = 1;
-           last;
-       }
-    }
-
-    if ($is_binary) {
-       print STDERR "$name: $f: binary file\n";
-       next;
-    }
-
-    seek(FILE, 0, 0);
-
-    $in_bytes = 0;
-    $out_bytes = 0;
-    $lineno = 0;
-
-    @lines  = ();
-
-    $in_hunk = 0;
-    $err = 0;
-
-    while ( defined($line = <FILE>) ) {
-       $lineno++;
-       $in_bytes += length($line);
-
-       if (!$in_hunk) {
-           if ($line =~
-               /^\@\@\s+\-([0-9]+),([0-9]+)\s+\+([0-9]+),([0-9]+)\s\@\@/) {
-               $minus_lines = $2;
-               $plus_lines = $4;
-               if ($minus_lines || $plus_lines) {
-                   $in_hunk = 1;
-                   @hunk_lines = ($line);
-               }
-           } else {
-               push(@lines, $line);
-               $out_bytes += length($line);
-           }
-       } else {
-           # We're in a hunk
-
-           if ($line =~ /^\+/) {
-               $plus_lines--;
-
-               $text = substr($line, 1);
-               $text =~ s/[ \t\r]*$//;         # Remove trailing spaces
-               $text = clean_space_tabs($text);
-
-               $l_width = strwidth($text);
-               if ($max_width && $l_width > $max_width) {
-                   print STDERR
-                       "$f:$lineno: adds line exceeds $max_width ",
-                       "characters ($l_width)\n";
-               }
-
-               push(@hunk_lines, '+'.$text);
-           } elsif ($line =~ /^\-/) {
-               $minus_lines--;
-               push(@hunk_lines, $line);
-           } elsif ($line =~ /^ /) {
-               $plus_lines--;
-               $minus_lines--;
-               push(@hunk_lines, $line);
-           } else {
-               print STDERR "$name: $f: malformed patch\n";
-               $err = 1;
-               last;
-           }
-
-           if ($plus_lines < 0 || $minus_lines < 0) {
-               print STDERR "$name: $f: malformed patch\n";
-               $err = 1;
-               last;
-           } elsif ($plus_lines == 0 && $minus_lines == 0) {
-               # End of a hunk.  Process this hunk.
-               my $i;
-               my $l;
-               my @h = ();
-               my $adj = 0;
-               my $done = 0;
-
-               for ($i = scalar(@hunk_lines)-1; $i > 0; $i--) {
-                   $l = $hunk_lines[$i];
-                   if (!$done && $l eq "+\n") {
-                       $adj++; # Skip this line
-                   } elsif ($l =~ /^[ +]/) {
-                       $done = 1;
-                       unshift(@h, $l);
-                   } else {
-                       unshift(@h, $l);
-                   }
-               }
-
-               $l = $hunk_lines[0];  # Hunk header
-               undef @hunk_lines;    # Free memory
-
-               if ($adj) {
-                   die unless
-                       ($l =~ /^\@\@\s+\-([0-9]+),([0-9]+)\s+\+([0-9]+),([0-9]+)\s\@\@(.*)$/);
-                   my $mstart = $1;
-                   my $mlin = $2;
-                   my $pstart = $3;
-                   my $plin = $4;
-                   my $tail = $5; # doesn't include the final newline
-
-                   $l = sprintf("@@ -%d,%d +%d,%d @@%s\n",
-                                $mstart, $mlin, $pstart, $plin-$adj,
-                                $tail);
-               }
-               unshift(@h, $l);
-
-               # Transfer to the output array
-               foreach $l (@h) {
-                   $out_bytes += length($l);
-                   push(@lines, $l);
-               }
-
-               $in_hunk = 0;
-           }
-       }
-    }
-
-    if ($in_hunk) {
-       print STDERR "$name: $f: malformed patch\n";
-       $err = 1;
-    }
-
-    if (!$err) {
-       if ($in_bytes != $out_bytes) {
-           # Only write to the file if changed
-           seek(FILE, 0, 0);
-           print FILE @lines;
-
-           if ( !defined($where = tell(FILE)) ||
-                !truncate(FILE, $where) ) {
-               die "$name: Failed to truncate modified file: $f: $!\n";
-           }
-       }
-    }
-
-    close(FILE);
-}
index fd8b9f5f15420bd0a9bfb6d90cf12eafc23368d6..0a0792e503eadefe058f51db90c5fe98fcc2e1e2 100644 (file)
@@ -14,7 +14,7 @@
  * SPDX-License-Identifier:    GPL-2.0+
  */
 
-#include "mkimage.h"
+#include "imagetool.h"
 #include <image.h>
 #include <u-boot/crc.h>
 
@@ -29,7 +29,7 @@ static int image_check_image_types(uint8_t type)
                return EXIT_FAILURE;
 }
 
-static int image_check_params(struct mkimage_params *params)
+static int image_check_params(struct image_tool_params *params)
 {
        return  ((params->dflag && (params->fflag || params->lflag)) ||
                (params->fflag && (params->dflag || params->lflag)) ||
@@ -37,7 +37,7 @@ static int image_check_params(struct mkimage_params *params)
 }
 
 static int image_verify_header(unsigned char *ptr, int image_size,
-                       struct mkimage_params *params)
+                       struct image_tool_params *params)
 {
        uint32_t len;
        const unsigned char *data;
@@ -86,7 +86,7 @@ static int image_verify_header(unsigned char *ptr, int image_size,
 }
 
 static void image_set_header(void *ptr, struct stat *sbuf, int ifd,
-                               struct mkimage_params *params)
+                               struct image_tool_params *params)
 {
        uint32_t checksum;
 
@@ -117,6 +117,62 @@ static void image_set_header(void *ptr, struct stat *sbuf, int ifd,
        image_set_hcrc(hdr, checksum);
 }
 
+static int image_save_datafile(struct image_tool_params *params,
+                              ulong file_data, ulong file_len)
+{
+       int dfd;
+       const char *datafile = params->outfile;
+
+       dfd = open(datafile, O_RDWR | O_CREAT | O_TRUNC | O_BINARY,
+                  S_IRUSR | S_IWUSR);
+       if (dfd < 0) {
+               fprintf(stderr, "%s: Can't open \"%s\": %s\n",
+                       params->cmdname, datafile, strerror(errno));
+               return -1;
+       }
+
+       if (write(dfd, (void *)file_data, file_len) != (ssize_t)file_len) {
+               fprintf(stderr, "%s: Write error on \"%s\": %s\n",
+                       params->cmdname, datafile, strerror(errno));
+               close(dfd);
+               return -1;
+       }
+
+       close(dfd);
+
+       return 0;
+}
+
+static int image_extract_datafile(void *ptr, struct image_tool_params *params)
+{
+       const image_header_t *hdr = (const image_header_t *)ptr;
+       ulong file_data;
+       ulong file_len;
+
+       if (image_check_type(hdr, IH_TYPE_MULTI)) {
+               ulong idx = params->pflag;
+               ulong count;
+
+               /* get the number of data files present in the image */
+               count = image_multi_count(hdr);
+
+               /* retrieve the "data file" at the idx position */
+               image_multi_getimg(hdr, idx, &file_data, &file_len);
+
+               if ((file_len == 0) || (idx >= count)) {
+                       fprintf(stderr, "%s: No such data file %ld in \"%s\"\n",
+                               params->cmdname, idx, params->imagefile);
+                       return -1;
+               }
+       } else {
+               file_data = image_get_data(hdr);
+               file_len = image_get_size(hdr);
+       }
+
+       /* save the "data file" into the file system */
+       return image_save_datafile(params, file_data, file_len);
+}
+
 /*
  * Default image type parameters definition
  */
@@ -128,10 +184,11 @@ static struct image_type_params defimage_params = {
        .verify_header = image_verify_header,
        .print_header = image_print_contents,
        .set_header = image_set_header,
+       .extract_datafile = image_extract_datafile,
        .check_params = image_check_params,
 };
 
 void init_default_image_type(void)
 {
-       mkimage_register(&defimage_params);
+       register_image_type(&defimage_params);
 }
diff --git a/tools/dtc-version.sh b/tools/dtc-version.sh
deleted file mode 100755 (executable)
index e8c94d3..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/bin/sh
-#
-# dtc-version dtc-command
-#
-# Prints the dtc version of `dtc-command' in a canonical 4-digit form
-# such as `0222' for binutils 2.22
-#
-
-dtc="$*"
-
-if [ ${#dtc} -eq 0 ]; then
-       echo "Error: No dtc command specified."
-       printf "Usage:\n\t$0 <dtc-command>\n"
-       exit 1
-fi
-
-MAJOR=$($dtc -v | head -1 | awk '{print $NF}' | cut -d . -f 1)
-MINOR=$($dtc -v | head -1 | awk '{print $NF}' | cut -d . -f 2)
-
-printf "%02d%02d\\n" $MAJOR $MINOR
diff --git a/tools/dumpimage.c b/tools/dumpimage.c
new file mode 100644 (file)
index 0000000..542ee28
--- /dev/null
@@ -0,0 +1,305 @@
+/*
+ * Based on mkimage.c.
+ *
+ * Written by Guilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include "dumpimage.h"
+#include <image.h>
+#include <version.h>
+
+static void usage(void);
+
+/* image_type_params linked list to maintain registered image types supports */
+static struct image_type_params *dumpimage_tparams;
+
+/* parameters initialized by core will be used by the image type code */
+static struct image_tool_params params = {
+       .type = IH_TYPE_KERNEL,
+};
+
+/**
+ * dumpimage_register() - register respective image generation/list support
+ *
+ * the input struct image_type_params is checked and appended to the link
+ * list, if the input structure is already registered, issue an error
+ *
+ * @tparams: Image type parameters
+ */
+static void dumpimage_register(struct image_type_params *tparams)
+{
+       struct image_type_params **tp;
+
+       if (!tparams) {
+               fprintf(stderr, "%s: %s: Null input\n", params.cmdname,
+                       __func__);
+               exit(EXIT_FAILURE);
+       }
+
+       /* scan the linked list, check for registry and point the last one */
+       for (tp = &dumpimage_tparams; *tp != NULL; tp = &(*tp)->next) {
+               if (!strcmp((*tp)->name, tparams->name)) {
+                       fprintf(stderr, "%s: %s already registered\n",
+                               params.cmdname, tparams->name);
+                       return;
+               }
+       }
+
+       /* add input struct entry at the end of link list */
+       *tp = tparams;
+       /* mark input entry as last entry in the link list */
+       tparams->next = NULL;
+
+       debug("Registered %s\n", tparams->name);
+}
+
+/**
+ * dumpimage_get_type() - find the image type params for a given image type
+ *
+ * Scan all registered image types and check the input type_id for each
+ * supported image type
+ *
+ * @return respective image_type_params pointer. If the input type is not
+ * supported by any of registered image types, returns NULL
+ */
+static struct image_type_params *dumpimage_get_type(int type)
+{
+       struct image_type_params *curr;
+
+       for (curr = dumpimage_tparams; curr != NULL; curr = curr->next) {
+               if (curr->check_image_type) {
+                       if (!curr->check_image_type(type))
+                               return curr;
+               }
+       }
+       return NULL;
+}
+
+/*
+ * dumpimage_verify_print_header() - verifies the image header
+ *
+ * Scan registered image types and verify the image_header for each
+ * supported image type. If verification is successful, this prints
+ * the respective header.
+ *
+ * @return 0 on success, negative if input image format does not match with
+ * any of supported image types
+ */
+static int dumpimage_verify_print_header(void *ptr, struct stat *sbuf)
+{
+       int retval = -1;
+       struct image_type_params *curr;
+
+       for (curr = dumpimage_tparams; curr != NULL; curr = curr->next) {
+               if (curr->verify_header) {
+                       retval = curr->verify_header((unsigned char *)ptr,
+                                                    sbuf->st_size, &params);
+                       if (retval != 0)
+                               continue;
+                       /*
+                        * Print the image information  if verify is
+                        * successful
+                        */
+                       if (curr->print_header) {
+                               curr->print_header(ptr);
+                       } else {
+                               fprintf(stderr,
+                                       "%s: print_header undefined for %s\n",
+                                       params.cmdname, curr->name);
+                       }
+                       break;
+               }
+       }
+
+       return retval;
+}
+
+/*
+ * dumpimage_extract_datafile -
+ *
+ * It scans all registered image types,
+ * verifies image_header for each supported image type
+ * if verification is successful, it extracts the desired file,
+ * indexed by pflag, from the image
+ *
+ * returns negative if input image format does not match with any of
+ * supported image types
+ */
+static int dumpimage_extract_datafile(void *ptr, struct stat *sbuf)
+{
+       int retval = -1;
+       struct image_type_params *curr;
+
+       for (curr = dumpimage_tparams; curr != NULL; curr = curr->next) {
+               if (curr->verify_header) {
+                       retval = curr->verify_header((unsigned char *)ptr,
+                                                    sbuf->st_size, &params);
+                       if (retval != 0)
+                               continue;
+                       /*
+                        * Extract the file from the image
+                        * if verify is successful
+                        */
+                       if (curr->extract_datafile) {
+                               curr->extract_datafile(ptr, &params);
+                       } else {
+                               fprintf(stderr,
+                                       "%s: extract_datafile undefined for %s\n",
+                                       params.cmdname, curr->name);
+                       break;
+                       }
+               }
+       }
+
+       return retval;
+}
+
+int main(int argc, char **argv)
+{
+       int opt;
+       int ifd = -1;
+       struct stat sbuf;
+       char *ptr;
+       int retval = 0;
+       struct image_type_params *tparams = NULL;
+
+       /* Init all image generation/list support */
+       register_image_tool(dumpimage_register);
+
+       params.cmdname = *argv;
+
+       while ((opt = getopt(argc, argv, "li:o:p:V")) != -1) {
+               switch (opt) {
+               case 'l':
+                       params.lflag = 1;
+                       break;
+               case 'i':
+                       params.imagefile = optarg;
+                       params.iflag = 1;
+                       break;
+               case 'o':
+                       params.outfile = optarg;
+                       break;
+               case 'p':
+                       params.pflag = strtoul(optarg, &ptr, 10);
+                       if (*ptr) {
+                               fprintf(stderr,
+                                       "%s: invalid file position %s\n",
+                                       params.cmdname, *argv);
+                               exit(EXIT_FAILURE);
+                       }
+                       break;
+               case 'V':
+                       printf("dumpimage version %s\n", PLAIN_VERSION);
+                       exit(EXIT_SUCCESS);
+               default:
+                       usage();
+               }
+       }
+
+       if (optind >= argc)
+               usage();
+
+       /* set tparams as per input type_id */
+       tparams = dumpimage_get_type(params.type);
+       if (tparams == NULL) {
+               fprintf(stderr, "%s: unsupported type %s\n",
+                       params.cmdname, genimg_get_type_name(params.type));
+               exit(EXIT_FAILURE);
+       }
+
+       /*
+        * check the passed arguments parameters meets the requirements
+        * as per image type to be generated/listed
+        */
+       if (tparams->check_params) {
+               if (tparams->check_params(&params))
+                       usage();
+       }
+
+       if (params.iflag)
+               params.datafile = argv[optind];
+       else
+               params.imagefile = argv[optind];
+       if (!params.outfile)
+               params.outfile = params.datafile;
+
+       ifd = open(params.imagefile, O_RDONLY|O_BINARY);
+       if (ifd < 0) {
+               fprintf(stderr, "%s: Can't open \"%s\": %s\n",
+                       params.cmdname, params.imagefile,
+                       strerror(errno));
+               exit(EXIT_FAILURE);
+       }
+
+       if (params.lflag || params.iflag) {
+               if (fstat(ifd, &sbuf) < 0) {
+                       fprintf(stderr, "%s: Can't stat \"%s\": %s\n",
+                               params.cmdname, params.imagefile,
+                               strerror(errno));
+                       exit(EXIT_FAILURE);
+               }
+
+               if ((unsigned)sbuf.st_size < tparams->header_size) {
+                       fprintf(stderr,
+                               "%s: Bad size: \"%s\" is not valid image\n",
+                               params.cmdname, params.imagefile);
+                       exit(EXIT_FAILURE);
+               }
+
+               ptr = mmap(0, sbuf.st_size, PROT_READ, MAP_SHARED, ifd, 0);
+               if (ptr == MAP_FAILED) {
+                       fprintf(stderr, "%s: Can't read \"%s\": %s\n",
+                               params.cmdname, params.imagefile,
+                               strerror(errno));
+                       exit(EXIT_FAILURE);
+               }
+
+               /*
+                * Both calls bellow scan through dumpimage registry for all
+                * supported image types and verify the input image file
+                * header for match
+                */
+               if (params.iflag) {
+                       /*
+                        * Extract the data files from within the matched
+                        * image type. Returns the error code if not matched
+                        */
+                       retval = dumpimage_extract_datafile(ptr, &sbuf);
+               } else {
+                       /*
+                        * Print the image information for matched image type
+                        * Returns the error code if not matched
+                        */
+                       retval = dumpimage_verify_print_header(ptr, &sbuf);
+               }
+
+               (void)munmap((void *)ptr, sbuf.st_size);
+               (void)close(ifd);
+
+               return retval;
+       }
+
+       (void)close(ifd);
+
+       return EXIT_SUCCESS;
+}
+
+static void usage(void)
+{
+       fprintf(stderr, "Usage: %s -l image\n"
+               "          -l ==> list image header information\n",
+               params.cmdname);
+       fprintf(stderr,
+               "       %s -i image [-p position] [-o outfile] data_file\n"
+               "          -i ==> extract from the 'image' a specific 'data_file'"
+               ", indexed by 'position' (starting at 0)\n",
+               params.cmdname);
+       fprintf(stderr,
+               "       %s -V ==> print version information and exit\n",
+               params.cmdname);
+
+       exit(EXIT_FAILURE);
+}
diff --git a/tools/dumpimage.h b/tools/dumpimage.h
new file mode 100644 (file)
index 0000000..d78523d
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Based on mkimage.c.
+ *
+ * Written by Guilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#ifndef _DUMPIMAGE_H_
+#define _DUMPIMAGE_H_
+
+#include "os_support.h"
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <time.h>
+#include <unistd.h>
+#include <sha1.h>
+#include "fdt_host.h"
+#include "imagetool.h"
+
+#undef DUMPIMAGE_DEBUG
+
+#ifdef DUMPIMAGE_DEBUG
+#define debug(fmt, args...)    printf(fmt, ##args)
+#else
+#define debug(fmt, args...)
+#endif /* DUMPIMAGE_DEBUG */
+
+#endif /* _DUMPIMAGE_H_ */
index 0400a606785457c8711eaa2bf85b51768aa180f6..1466164f0ae067e643e5cddf54d6da26a32dc12e 100644 (file)
@@ -14,6 +14,7 @@
  * SPDX-License-Identifier:    GPL-2.0+
  */
 
+#include "imagetool.h"
 #include "mkimage.h"
 #include <image.h>
 #include <u-boot/crc.h>
@@ -21,7 +22,7 @@
 static image_header_t header;
 
 static int fit_verify_header (unsigned char *ptr, int image_size,
-                       struct mkimage_params *params)
+                       struct image_tool_params *params)
 {
        return fdt_check_header(ptr);
 }
@@ -34,7 +35,7 @@ static int fit_check_image_types (uint8_t type)
                return EXIT_FAILURE;
 }
 
-int mmap_fdt(struct mkimage_params *params, const char *fname, void **blobp,
+int mmap_fdt(struct image_tool_params *params, const char *fname, void **blobp,
                struct stat *sbuf)
 {
        void *ptr;
@@ -88,7 +89,7 @@ int mmap_fdt(struct mkimage_params *params, const char *fname, void **blobp,
  * returns:
  *     only on success, otherwise calls exit (EXIT_FAILURE);
  */
-static int fit_handle_file (struct mkimage_params *params)
+static int fit_handle_file(struct image_tool_params *params)
 {
        char tmpfile[MKIMAGE_MAX_TMPFILE_LEN];
        char cmd[MKIMAGE_MAX_DTC_CMDLINE_LEN];
@@ -184,7 +185,7 @@ err_system:
        return -1;
 }
 
-static int fit_check_params (struct mkimage_params *params)
+static int fit_check_params(struct image_tool_params *params)
 {
        return  ((params->dflag && (params->fflag || params->lflag)) ||
                (params->fflag && (params->dflag || params->lflag)) ||
@@ -205,5 +206,5 @@ static struct image_type_params fitimage_params = {
 
 void init_fit_image_type (void)
 {
-       mkimage_register (&fitimage_params);
+       register_image_type(&fitimage_params);
 }
diff --git a/tools/gcc-version.sh b/tools/gcc-version.sh
deleted file mode 100755 (executable)
index debecb5..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-#!/bin/sh
-#
-# gcc-version [-p] gcc-command
-#
-# Prints the gcc version of `gcc-command' in a canonical 4-digit form
-# such as `0295' for gcc-2.95, `0303' for gcc-3.3, etc.
-#
-# With the -p option, prints the patchlevel as well, for example `029503' for
-# gcc-2.95.3, `030301' for gcc-3.3.1, etc.
-#
-
-if [ "$1" = "-p" ] ; then
-       with_patchlevel=1;
-       shift;
-fi
-
-compiler="$*"
-
-if [ ${#compiler} -eq 0 ]; then
-       echo "Error: No compiler specified."
-       printf "Usage:\n\t$0 <gcc-command>\n"
-       exit 1
-fi
-
-MAJOR=$(echo __GNUC__ | $compiler -E -xc - | tail -n 1)
-MINOR=$(echo __GNUC_MINOR__ | $compiler -E -xc - | tail -n 1)
-if [ "x$with_patchlevel" != "x" ] ; then
-       PATCHLEVEL=$(echo __GNUC_PATCHLEVEL__ | $compiler -E -xc - | tail -n 1)
-       printf "%02d%02d%02d\\n" $MAJOR $MINOR $PATCHLEVEL
-else
-       printf "%02d%02d\\n" $MAJOR $MINOR
-fi
diff --git a/tools/imagetool.c b/tools/imagetool.c
new file mode 100644 (file)
index 0000000..29d2189
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * (C) Copyright 2013
+ *
+ * Written by Guilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include "imagetool.h"
+
+/*
+ * Callback function to register a image type within a tool
+ */
+static imagetool_register_t register_func;
+
+/*
+ * register_image_tool -
+ *
+ * The tool provides its own registration function in order to all image
+ * types initialize themselves.
+ */
+void register_image_tool(imagetool_register_t image_register)
+{
+       /*
+        * Save the image tool callback function. It will be used to register
+        * image types within that tool
+        */
+       register_func = image_register;
+
+       /* Init Freescale PBL Boot image generation/list support */
+       init_pbl_image_type();
+       /* Init Kirkwood Boot image generation/list support */
+       init_kwb_image_type();
+       /* Init Freescale imx Boot image generation/list support */
+       init_imx_image_type();
+       /* Init Freescale mxs Boot image generation/list support */
+       init_mxs_image_type();
+       /* Init FIT image generation/list support */
+       init_fit_image_type();
+       /* Init TI OMAP Boot image generation/list support */
+       init_omap_image_type();
+       /* Init Default image generation/list support */
+       init_default_image_type();
+       /* Init Davinci UBL support */
+       init_ubl_image_type();
+       /* Init Davinci AIS support */
+       init_ais_image_type();
+}
+
+/*
+ * register_image_type -
+ *
+ * Register a image type within a tool
+ */
+void register_image_type(struct image_type_params *tparams)
+{
+       register_func(tparams);
+}
diff --git a/tools/imagetool.h b/tools/imagetool.h
new file mode 100644 (file)
index 0000000..c2c9aea
--- /dev/null
@@ -0,0 +1,173 @@
+/*
+ * (C) Copyright 2013
+ *
+ * Written by Guilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#ifndef _IMAGETOOL_H_
+#define _IMAGETOOL_H_
+
+#include "os_support.h"
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <time.h>
+#include <unistd.h>
+#include <sha1.h>
+#include "fdt_host.h"
+
+#define ARRAY_SIZE(x)          (sizeof(x) / sizeof((x)[0]))
+
+#define IH_ARCH_DEFAULT                IH_ARCH_INVALID
+
+/*
+ * This structure defines all such variables those are initialized by
+ * mkimage and dumpimage main core and need to be referred by image
+ * type specific functions
+ */
+struct image_tool_params {
+       int dflag;
+       int eflag;
+       int fflag;
+       int iflag;
+       int lflag;
+       int pflag;
+       int vflag;
+       int xflag;
+       int skipcpy;
+       int os;
+       int arch;
+       int type;
+       int comp;
+       char *dtc;
+       unsigned int addr;
+       unsigned int ep;
+       char *imagename;
+       char *imagename2;
+       char *datafile;
+       char *imagefile;
+       char *cmdname;
+       const char *outfile;    /* Output filename */
+       const char *keydir;     /* Directory holding private keys */
+       const char *keydest;    /* Destination .dtb for public key */
+       const char *comment;    /* Comment to add to signature node */
+       int require_keys;       /* 1 to mark signing keys as 'required' */
+};
+
+/*
+ * image type specific variables and callback functions
+ */
+struct image_type_params {
+       /* name is an identification tag string for added support */
+       char *name;
+       /*
+        * header size is local to the specific image type to be supported,
+        * mkimage core treats this as number of bytes
+        */
+       uint32_t header_size;
+       /* Image type header pointer */
+       void *hdr;
+       /*
+        * There are several arguments that are passed on the command line
+        * and are registered as flags in image_tool_params structure.
+        * This callback function can be used to check the passed arguments
+        * are in-lined with the image type to be supported
+        *
+        * Returns 1 if parameter check is successful
+        */
+       int (*check_params) (struct image_tool_params *);
+       /*
+        * This function is used by list command (i.e. mkimage -l <filename>)
+        * image type verification code must be put here
+        *
+        * Returns 0 if image header verification is successful
+        * otherwise, returns respective negative error codes
+        */
+       int (*verify_header) (unsigned char *, int, struct image_tool_params *);
+       /* Prints image information abstracting from image header */
+       void (*print_header) (const void *);
+       /*
+        * The header or image contents need to be set as per image type to
+        * be generated using this callback function.
+        * further output file post processing (for ex. checksum calculation,
+        * padding bytes etc..) can also be done in this callback function.
+        */
+       void (*set_header) (void *, struct stat *, int,
+                                       struct image_tool_params *);
+       /*
+        * This function is used by the command to retrieve a data file from
+        * the image (i.e. dumpimage -i <image> -p <position> <data_file>).
+        * Thus the code to extract a file from an image must be put here.
+        *
+        * Returns 0 if the file was successfully retrieved from the image,
+        * or a negative value on error.
+        */
+       int (*extract_datafile) (void *, struct image_tool_params *);
+       /*
+        * Some image generation support for ex (default image type) supports
+        * more than one type_ids, this callback function is used to check
+        * whether input (-T <image_type>) is supported by registered image
+        * generation/list low level code
+        */
+       int (*check_image_type) (uint8_t);
+       /* This callback function will be executed if fflag is defined */
+       int (*fflag_handle) (struct image_tool_params *);
+       /*
+        * This callback function will be executed for variable size record
+        * It is expected to build this header in memory and return its length
+        * and a pointer to it by using image_type_params.header_size and
+        * image_type_params.hdr. The return value shall indicate if an
+        * additional padding should be used when copying the data image
+        * by returning the padding length.
+        */
+       int (*vrec_header) (struct image_tool_params *,
+               struct image_type_params *);
+       /* pointer to the next registered entry in linked list */
+       struct image_type_params *next;
+};
+
+/*
+ * Tool registration function.
+ */
+typedef void (*imagetool_register_t)(struct image_type_params *);
+
+/*
+ * Initializes all image types with the given registration callback
+ * function.
+ * An image tool uses this function to initialize all image types.
+ */
+void register_image_tool(imagetool_register_t image_register);
+
+/*
+ * Register a image type within a tool.
+ * An image type uses this function to register itself within
+ * all tools.
+ */
+void register_image_type(struct image_type_params *tparams);
+
+/*
+ * There is a c file associated with supported image type low level code
+ * for ex. default_image.c, fit_image.c
+ * init_xxx_type() is the only function referred by image tool core to avoid
+ * a single lined header file, you can define them here
+ *
+ * Supported image types init functions
+ */
+void init_default_image_type(void);
+void init_pbl_image_type(void);
+void init_ais_image_type(void);
+void init_kwb_image_type(void);
+void init_imx_image_type(void);
+void init_mxs_image_type(void);
+void init_fit_image_type(void);
+void init_ubl_image_type(void);
+void init_omap_image_type(void);
+
+void pbl_load_uboot(int fd, struct image_tool_params *mparams);
+
+#endif /* _IMAGETOOL_H_ */
index 511e3f20387757c891156b33c5b007467c410be8..18dc051c5ee67e1f98e247515bc50d56c4368736 100644 (file)
@@ -9,7 +9,7 @@
  * SPDX-License-Identifier:    GPL-2.0+
  */
 
-#include "mkimage.h"
+#include "imagetool.h"
 #include <image.h>
 #include "imximage.h"
 
@@ -520,7 +520,7 @@ static int imximage_check_image_types(uint8_t type)
 }
 
 static int imximage_verify_header(unsigned char *ptr, int image_size,
-                       struct mkimage_params *params)
+                       struct image_tool_params *params)
 {
        struct imx_header *imx_hdr = (struct imx_header *) ptr;
 
@@ -549,7 +549,7 @@ static void imximage_print_header(const void *ptr)
 }
 
 static void imximage_set_header(void *ptr, struct stat *sbuf, int ifd,
-                               struct mkimage_params *params)
+                               struct image_tool_params *params)
 {
        struct imx_header *imxhdr = (struct imx_header *)ptr;
        uint32_t dcd_len;
@@ -589,7 +589,7 @@ static void imximage_set_header(void *ptr, struct stat *sbuf, int ifd,
        }
 }
 
-int imximage_check_params(struct mkimage_params *params)
+int imximage_check_params(struct image_tool_params *params)
 {
        if (!params)
                return CFG_INVALID;
@@ -611,7 +611,7 @@ int imximage_check_params(struct mkimage_params *params)
                (params->xflag) || !(strlen(params->imagename));
 }
 
-static int imximage_generate(struct mkimage_params *params,
+static int imximage_generate(struct image_tool_params *params,
        struct image_type_params *tparams)
 {
        struct imx_header *imxhdr;
@@ -701,5 +701,5 @@ static struct image_type_params imximage_params = {
 
 void init_imx_image_type(void)
 {
-       mkimage_register(&imximage_params);
+       register_image_type(&imximage_params);
 }
index 1df6b2051e83738644dd9f9d8ff7eb84476bccbd..109d61686ec69fc958bd3b66995c83c412164eaa 100644 (file)
@@ -6,7 +6,7 @@
  * SPDX-License-Identifier:    GPL-2.0+
  */
 
-#include "mkimage.h"
+#include "imagetool.h"
 #include <image.h>
 #include "kwbimage.h"
 
@@ -54,7 +54,7 @@ static int lineno = -1;
 /*
  * Report Error if xflag is set in addition to default
  */
-static int kwbimage_check_params (struct mkimage_params *params)
+static int kwbimage_check_params(struct image_tool_params *params)
 {
        if (!strlen (params->imagename)) {
                printf ("Error:%s - Configuration file not specified, "
@@ -288,7 +288,7 @@ INVL_CMD:
 }
 
 static void kwbimage_set_header (void *ptr, struct stat *sbuf, int ifd,
-                               struct mkimage_params *params)
+                               struct image_tool_params *params)
 {
        struct kwb_header *hdr = (struct kwb_header *)ptr;
        bhr_t *mhdr = &hdr->kwb_hdr;
@@ -322,7 +322,7 @@ static void kwbimage_set_header (void *ptr, struct stat *sbuf, int ifd,
 }
 
 static int kwbimage_verify_header (unsigned char *ptr, int image_size,
-                       struct mkimage_params *params)
+                       struct image_tool_params *params)
 {
        struct kwb_header *hdr = (struct kwb_header *)ptr;
        bhr_t *mhdr = &hdr->kwb_hdr;
@@ -382,5 +382,5 @@ static struct image_type_params kwbimage_params = {
 
 void init_kwb_image_type (void)
 {
-       mkimage_register (&kwbimage_params);
+       register_image_type(&kwbimage_params);
 }
index 7f221013e38cf20fe9bad4a42d1a7aca387e9924..123d0c7d938dae609c6eea050cbdbc5a6ce96075 100644 (file)
@@ -19,7 +19,7 @@ static void usage(void);
 struct image_type_params *mkimage_tparams = NULL;
 
 /* parameters initialized by core will be used by the image type code */
-struct mkimage_params params = {
+struct image_tool_params params = {
        .os = IH_OS_LINUX,
        .arch = IH_ARCH_PPC,
        .type = IH_TYPE_KERNEL,
@@ -139,24 +139,8 @@ main (int argc, char **argv)
        struct image_type_params *tparams = NULL;
        int pad_len = 0;
 
-       /* Init Freescale PBL Boot image generation/list support */
-       init_pbl_image_type();
-       /* Init Kirkwood Boot image generation/list support */
-       init_kwb_image_type ();
-       /* Init Freescale imx Boot image generation/list support */
-       init_imx_image_type ();
-       /* Init Freescale mxs Boot image generation/list support */
-       init_mxs_image_type();
-       /* Init FIT image generation/list support */
-       init_fit_image_type ();
-       /* Init TI OMAP Boot image generation/list support */
-       init_omap_image_type();
-       /* Init Default image generation/list support */
-       init_default_image_type ();
-       /* Init Davinci UBL support */
-       init_ubl_image_type();
-       /* Init Davinci AIS support */
-       init_ais_image_type();
+       /* Init all image generation/list support */
+       register_image_tool(mkimage_register);
 
        params.cmdname = *argv;
        params.addr = params.ep = 0;
@@ -632,8 +616,7 @@ copy_file (int ifd, const char *datafile, int pad)
        (void) close (dfd);
 }
 
-void
-usage ()
+static void usage(void)
 {
        fprintf (stderr, "Usage: %s -l image\n"
                         "          -l ==> list image header information\n",
index af491544e42b5557a1e06c0afd0aef50d6fa010d..d5491b6e60ae8eddcbbf8d6e67db8ed19ab4db5c 100644 (file)
@@ -20,6 +20,7 @@
 #include <unistd.h>
 #include <sha1.h>
 #include "fdt_host.h"
+#include "imagetool.h"
 
 #undef MKIMAGE_DEBUG
 
@@ -29,8 +30,6 @@
 #define debug(fmt,args...)
 #endif /* MKIMAGE_DEBUG */
 
-#define ARRAY_SIZE(x)          (sizeof(x) / sizeof((x)[0]))
-
 static inline void *map_sysmem(ulong paddr, unsigned long len)
 {
        return (void *)(uintptr_t)paddr;
@@ -47,124 +46,4 @@ static inline ulong map_to_sysmem(void *ptr)
 #define MKIMAGE_MAX_DTC_CMDLINE_LEN    512
 #define MKIMAGE_DTC                    "dtc"   /* assume dtc is in $PATH */
 
-#define IH_ARCH_DEFAULT                IH_ARCH_INVALID
-
-/*
- * This structure defines all such variables those are initialized by
- * mkimage main core and need to be referred by image type specific
- * functions
- */
-struct mkimage_params {
-       int dflag;
-       int eflag;
-       int fflag;
-       int lflag;
-       int vflag;
-       int xflag;
-       int skipcpy;
-       int os;
-       int arch;
-       int type;
-       int comp;
-       char *dtc;
-       unsigned int addr;
-       unsigned int ep;
-       char *imagename;
-       char *imagename2;
-       char *datafile;
-       char *imagefile;
-       char *cmdname;
-       const char *keydir;     /* Directory holding private keys */
-       const char *keydest;    /* Destination .dtb for public key */
-       const char *comment;    /* Comment to add to signature node */
-       int require_keys;       /* 1 to mark signing keys as 'required' */
-};
-
-/*
- * image type specific variables and callback functions
- */
-struct image_type_params {
-       /* name is an identification tag string for added support */
-       char *name;
-       /*
-        * header size is local to the specific image type to be supported,
-        * mkimage core treats this as number of bytes
-        */
-       uint32_t header_size;
-       /* Image type header pointer */
-       void *hdr;
-       /*
-        * There are several arguments that are passed on the command line
-        * and are registered as flags in mkimage_params structure.
-        * This callback function can be used to check the passed arguments
-        * are in-lined with the image type to be supported
-        *
-        * Returns 1 if parameter check is successful
-        */
-       int (*check_params) (struct mkimage_params *);
-       /*
-        * This function is used by list command (i.e. mkimage -l <filename>)
-        * image type verification code must be put here
-        *
-        * Returns 0 if image header verification is successful
-        * otherwise, returns respective negative error codes
-        */
-       int (*verify_header) (unsigned char *, int, struct mkimage_params *);
-       /* Prints image information abstracting from image header */
-       void (*print_header) (const void *);
-       /*
-        * The header or image contents need to be set as per image type to
-        * be generated using this callback function.
-        * further output file post processing (for ex. checksum calculation,
-        * padding bytes etc..) can also be done in this callback function.
-        */
-       void (*set_header) (void *, struct stat *, int,
-                                       struct mkimage_params *);
-       /*
-        * Some image generation support for ex (default image type) supports
-        * more than one type_ids, this callback function is used to check
-        * whether input (-T <image_type>) is supported by registered image
-        * generation/list low level code
-        */
-       int (*check_image_type) (uint8_t);
-       /* This callback function will be executed if fflag is defined */
-       int (*fflag_handle) (struct mkimage_params *);
-       /*
-        * This callback function will be executed for variable size record
-        * It is expected to build this header in memory and return its length
-        * and a pointer to it by using image_type_params.header_size and
-        * image_type_params.hdr. The return value shall indicate if an
-        * additional padding should be used when copying the data image
-        * by returning the padding length.
-        */
-       int (*vrec_header) (struct mkimage_params *,
-               struct image_type_params *);
-       /* pointer to the next registered entry in linked list */
-       struct image_type_params *next;
-};
-
-/*
- * Exported functions
- */
-void mkimage_register (struct image_type_params *tparams);
-
-/*
- * There is a c file associated with supported image type low level code
- * for ex. default_image.c, fit_image.c
- * init is the only function referred by mkimage core.
- * to avoid a single lined header file, you can define them here
- *
- * Supported image types init functions
- */
-void pbl_load_uboot(int fd, struct mkimage_params *mparams);
-void init_pbl_image_type(void);
-void init_ais_image_type(void);
-void init_kwb_image_type (void);
-void init_imx_image_type (void);
-void init_mxs_image_type(void);
-void init_default_image_type (void);
-void init_fit_image_type (void);
-void init_ubl_image_type(void);
-void init_omap_image_type(void);
-
 #endif /* _MKIIMAGE_H_ */
index 7bd9deef5f0cca908ea775e9e741647faf90d07f..045b35a39b380c3e5cc5c754b894d035ed541080 100644 (file)
@@ -17,7 +17,7 @@
 
 #include <openssl/evp.h>
 
-#include "mkimage.h"
+#include "imagetool.h"
 #include "mxsimage.h"
 #include <image.h>
 
@@ -2149,11 +2149,11 @@ static int mxsimage_check_image_types(uint8_t type)
 }
 
 static void mxsimage_set_header(void *ptr, struct stat *sbuf, int ifd,
-                               struct mkimage_params *params)
+                               struct image_tool_params *params)
 {
 }
 
-int mxsimage_check_params(struct mkimage_params *params)
+int mxsimage_check_params(struct image_tool_params *params)
 {
        if (!params)
                return -1;
@@ -2194,7 +2194,7 @@ static int mxsimage_verify_print_header(char *file, int silent)
 
 char *imagefile;
 static int mxsimage_verify_header(unsigned char *ptr, int image_size,
-                       struct mkimage_params *params)
+                       struct image_tool_params *params)
 {
        struct sb_boot_image_header *hdr;
 
@@ -2292,7 +2292,7 @@ static int sb_build_image(struct sb_image_ctx *ictx,
        return 0;
 }
 
-static int mxsimage_generate(struct mkimage_params *params,
+static int mxsimage_generate(struct image_tool_params *params,
        struct image_type_params *tparams)
 {
        int ret;
@@ -2338,7 +2338,7 @@ static struct image_type_params mxsimage_params = {
 
 void init_mxs_image_type(void)
 {
-       mkimage_register(&mxsimage_params);
+       register_image_type(&mxsimage_params);
 }
 
 #else
index 8774a7e3acea56521fa9358f371da85c4df6a5d2..d59bc4d40de1f26d9c6a0691b757ec1a689ef29b 100644 (file)
@@ -14,7 +14,7 @@
  * SPDX-License-Identifier:    GPL-2.0+
  */
 
-#include "mkimage.h"
+#include "imagetool.h"
 #include <image.h>
 #include "omapimage.h"
 
@@ -69,7 +69,7 @@ static int valid_gph_load_addr(uint32_t load_addr)
 }
 
 static int omapimage_verify_header(unsigned char *ptr, int image_size,
-                       struct mkimage_params *params)
+                       struct image_tool_params *params)
 {
        struct ch_toc *toc = (struct ch_toc *)ptr;
        struct gp_header *gph = (struct gp_header *)(ptr+OMAP_CH_HDR_SIZE);
@@ -188,7 +188,7 @@ static int toc_offset(void *hdr, void *member)
 }
 
 static void omapimage_set_header(void *ptr, struct stat *sbuf, int ifd,
-                               struct mkimage_params *params)
+                               struct image_tool_params *params)
 {
        struct ch_toc *toc = (struct ch_toc *)ptr;
        struct ch_settings *chs = (struct ch_settings *)
@@ -224,7 +224,7 @@ static void omapimage_set_header(void *ptr, struct stat *sbuf, int ifd,
        }
 }
 
-int omapimage_check_params(struct mkimage_params *params)
+int omapimage_check_params(struct image_tool_params *params)
 {
        return  (params->dflag && (params->fflag || params->lflag)) ||
                (params->fflag && (params->dflag || params->lflag)) ||
@@ -247,5 +247,5 @@ static struct image_type_params omapimage_params = {
 
 void init_omap_image_type(void)
 {
-       mkimage_register(&omapimage_params);
+       register_image_type(&omapimage_params);
 }
index bac5faff9883acb727502f890f3ab8d6b0902f45..ef3d7f6296efe2fa39d01fa58cf7af31d19e5b3a 100644 (file)
@@ -3,7 +3,7 @@
  *
  * SPDX-License-Identifier:    GPL-2.0+
  */
-#include "mkimage.h"
+#include "imagetool.h"
 #include <image.h>
 #include "pblimage.h"
 
@@ -242,7 +242,7 @@ static void add_end_cmd(void)
        }
 }
 
-void pbl_load_uboot(int ifd, struct mkimage_params *params)
+void pbl_load_uboot(int ifd, struct image_tool_params *params)
 {
        FILE *fp_uboot;
        int size;
@@ -281,7 +281,7 @@ static int pblimage_check_image_types(uint8_t type)
 }
 
 static int pblimage_verify_header(unsigned char *ptr, int image_size,
-                       struct mkimage_params *params)
+                       struct image_tool_params *params)
 {
        struct pbl_header *pbl_hdr = (struct pbl_header *) ptr;
 
@@ -308,7 +308,7 @@ static void pblimage_print_header(const void *ptr)
 }
 
 static void pblimage_set_header(void *ptr, struct stat *sbuf, int ifd,
-                               struct mkimage_params *params)
+                               struct image_tool_params *params)
 {
        /*nothing need to do, pbl_load_uboot takes care of whole file. */
 }
@@ -327,5 +327,5 @@ static struct image_type_params pblimage_params = {
 void init_pbl_image_type(void)
 {
        pbl_size = 0;
-       mkimage_register(&pblimage_params);
+       register_image_type(&pblimage_params);
 }
diff --git a/tools/setlocalversion b/tools/setlocalversion
deleted file mode 100755 (executable)
index f551b4c..0000000
+++ /dev/null
@@ -1,177 +0,0 @@
-#!/bin/sh
-#
-# This scripts adds local version information from the version
-# control systems git, mercurial (hg) and subversion (svn).
-#
-# It was originally copied from the Linux kernel v3.2.0-rc4 and modified
-# to support the U-Boot build-system.
-#
-
-usage() {
-       echo "Usage: $0 [--save-scmversion] [srctree]" >&2
-       exit 1
-}
-
-scm_only=false
-srctree=.
-if test "$1" = "--save-scmversion"; then
-       scm_only=true
-       shift
-fi
-if test $# -gt 0; then
-       srctree=$1
-       shift
-fi
-if test $# -gt 0 -o ! -d "$srctree"; then
-       usage
-fi
-
-scm_version()
-{
-       local short
-       short=false
-
-       cd "$srctree"
-       if test -e .scmversion; then
-               cat .scmversion
-               return
-       fi
-       if test "$1" = "--short"; then
-               short=true
-       fi
-
-       # Check for git and a git repo.
-       if test -e .git && head=`git rev-parse --verify --short HEAD 2>/dev/null`; then
-
-               # If we are at a tagged commit (like "v2.6.30-rc6"), we ignore
-               # it, because this version is defined in the top level Makefile.
-               if [ -z "`git describe --exact-match 2>/dev/null`" ]; then
-
-                       # If only the short version is requested, don't bother
-                       # running further git commands
-                       if $short; then
-                               echo "+"
-                               return
-                       fi
-                       # If we are past a tagged commit (like
-                       # "v2.6.30-rc5-302-g72357d5"), we pretty print it.
-                       if atag="`git describe 2>/dev/null`"; then
-                               echo "$atag" | awk -F- '{printf("-%05d-%s", $(NF-1),$(NF))}'
-
-                       # If we don't have a tag at all we print -g{commitish}.
-                       else
-                               printf '%s%s' -g $head
-                       fi
-               fi
-
-               # Is this git on svn?
-               if git config --get svn-remote.svn.url >/dev/null; then
-                       printf -- '-svn%s' "`git svn find-rev $head`"
-               fi
-
-               # Update index only on r/w media
-               [ -w . ] && git update-index --refresh --unmerged > /dev/null
-
-               # Check for uncommitted changes
-               if git diff-index --name-only HEAD | grep -v "^scripts/package" \
-                   | read dummy; then
-                       printf '%s' -dirty
-               fi
-
-               # All done with git
-               return
-       fi
-
-       # Check for mercurial and a mercurial repo.
-       if test -d .hg && hgid=`hg id 2>/dev/null`; then
-               # Do we have an tagged version?  If so, latesttagdistance == 1
-               if [ "`hg log -r . --template '{latesttagdistance}'`" == "1" ]; then
-                       id=`hg log -r . --template '{latesttag}'`
-                       printf '%s%s' -hg "$id"
-               else
-                       tag=`printf '%s' "$hgid" | cut -d' ' -f2`
-                       if [ -z "$tag" -o "$tag" = tip ]; then
-                               id=`printf '%s' "$hgid" | sed 's/[+ ].*//'`
-                               printf '%s%s' -hg "$id"
-                       fi
-               fi
-
-               # Are there uncommitted changes?
-               # These are represented by + after the changeset id.
-               case "$hgid" in
-                       *+|*+\ *) printf '%s' -dirty ;;
-               esac
-
-               # All done with mercurial
-               return
-       fi
-
-       # Check for svn and a svn repo.
-       if rev=`svn info 2>/dev/null | grep '^Last Changed Rev'`; then
-               rev=`echo $rev | awk '{print $NF}'`
-               printf -- '-svn%s' "$rev"
-
-               # All done with svn
-               return
-       fi
-}
-
-collect_files()
-{
-       local file res
-
-       for file; do
-               case "$file" in
-               *\~*)
-                       continue
-                       ;;
-               esac
-               if test -e "$file"; then
-                       res="$res$(cat "$file")"
-               fi
-       done
-       echo "$res"
-}
-
-if $scm_only; then
-       if test ! -e .scmversion; then
-               res=$(scm_version)
-               echo "$res" >.scmversion
-       fi
-       exit
-fi
-
-#if test -e include/config/auto.conf; then
-#      . include/config/auto.conf
-#else
-#      echo "Error: kernelrelease not valid - run 'make prepare' to update it"
-#      exit 1
-#fi
-CONFIG_LOCALVERSION=
-CONFIG_LOCALVERSION_AUTO=y
-
-# localversion* files in the build and source directory
-res="$(collect_files localversion*)"
-if test ! "$srctree" -ef .; then
-       res="$res$(collect_files "$srctree"/localversion*)"
-fi
-
-# CONFIG_LOCALVERSION and LOCALVERSION (if set)
-res="${res}${CONFIG_LOCALVERSION}${LOCALVERSION}"
-
-# scm version string if not at a tagged commit
-if test "$CONFIG_LOCALVERSION_AUTO" = "y"; then
-       # full scm version string
-       res="$res$(scm_version)"
-else
-       # append a plus sign if the repository is not in a clean
-       # annotated or signed tagged state (as git describe only
-       # looks at signed or annotated tags - git tag -a/-s) and
-       # LOCALVERSION= is not specified
-       if test "${LOCALVERSION+set}" != "set"; then
-               scm=$(scm_version --short)
-               res="$res${scm:++}"
-       fi
-fi
-
-echo "$res"
index aafe24875892af9fb1bd9796e8f1404ee855ee15..cbbbe205dadf4d168ca5c71b2d6b2aedcf3ffb75 100644 (file)
@@ -13,7 +13,7 @@
  * SPDX-License-Identifier:    GPL-2.0+
  */
 
-#include "mkimage.h"
+#include "imagetool.h"
 #include <image.h>
 #include "ublimage.h"
 
@@ -193,7 +193,7 @@ static int ublimage_check_image_types(uint8_t type)
 }
 
 static int ublimage_verify_header(unsigned char *ptr, int image_size,
-                       struct mkimage_params *params)
+                       struct image_tool_params *params)
 {
        struct ubl_header *ubl_hdr = (struct ubl_header *)ptr;
 
@@ -211,7 +211,7 @@ static void ublimage_print_header(const void *ptr)
 }
 
 static void ublimage_set_header(void *ptr, struct stat *sbuf, int ifd,
-                               struct mkimage_params *params)
+                               struct image_tool_params *params)
 {
        struct ubl_header *ublhdr = (struct ubl_header *)ptr;
 
@@ -219,7 +219,7 @@ static void ublimage_set_header(void *ptr, struct stat *sbuf, int ifd,
        parse_cfg_file(ublhdr, params->imagename);
 }
 
-int ublimage_check_params(struct mkimage_params *params)
+int ublimage_check_params(struct image_tool_params *params)
 {
        if (!params)
                return CFG_INVALID;
@@ -257,5 +257,5 @@ static struct image_type_params ublimage_params = {
 
 void init_ubl_image_type(void)
 {
-       mkimage_register(&ublimage_params);
+       register_image_type(&ublimage_params);
 }