Merge branch 'master' of git://www.denx.de/git/u-boot-imx
authorTom Rini <trini@ti.com>
Tue, 10 Feb 2015 15:40:43 +0000 (10:40 -0500)
committerTom Rini <trini@ti.com>
Tue, 10 Feb 2015 15:40:43 +0000 (10:40 -0500)
947 files changed:
Kconfig
MAINTAINERS
Makefile
README
arch/Kconfig
arch/arc/Kconfig
arch/arc/Makefile
arch/arc/config.mk
arch/arc/cpu/arc700/Makefile [deleted file]
arch/arc/cpu/arc700/cache.c [deleted file]
arch/arc/cpu/arc700/config.mk [deleted file]
arch/arc/cpu/arc700/cpu.c [deleted file]
arch/arc/cpu/arc700/interrupts.c [deleted file]
arch/arc/cpu/arc700/reset.c [deleted file]
arch/arc/cpu/arc700/start.S [deleted file]
arch/arc/cpu/arc700/timer.c [deleted file]
arch/arc/cpu/arc700/u-boot.lds [deleted file]
arch/arc/cpu/arcv1/Makefile [new file with mode: 0644]
arch/arc/cpu/arcv1/start.S [new file with mode: 0644]
arch/arc/cpu/u-boot.lds [new file with mode: 0644]
arch/arc/include/asm/arcregs.h
arch/arc/include/asm/cache.h
arch/arc/include/asm/config.h
arch/arc/include/asm/sections.h
arch/arc/lib/Makefile
arch/arc/lib/_millicodethunk.S [new file with mode: 0644]
arch/arc/lib/cache.c [new file with mode: 0644]
arch/arc/lib/cpu.c [new file with mode: 0644]
arch/arc/lib/interrupts.c [new file with mode: 0644]
arch/arc/lib/libgcc2.c [new file with mode: 0644]
arch/arc/lib/libgcc2.h [new file with mode: 0644]
arch/arc/lib/memcmp.S
arch/arc/lib/relocate.c
arch/arc/lib/reset.c [new file with mode: 0644]
arch/arc/lib/sections.c
arch/arc/lib/timer.c [new file with mode: 0644]
arch/arm/Kconfig
arch/arm/cpu/arm926ejs/cpu.c
arch/arm/cpu/arm926ejs/davinci/spl.c
arch/arm/cpu/arm926ejs/kirkwood/cpu.c
arch/arm/cpu/armv7/am33xx/board.c
arch/arm/cpu/armv7/armada-xp/Makefile
arch/arm/cpu/armv7/armada-xp/lowlevel_spl.S [new file with mode: 0644]
arch/arm/cpu/armv7/armada-xp/spl.c [new file with mode: 0644]
arch/arm/cpu/armv7/at91/sama5d4_devices.c
arch/arm/cpu/armv7/cpu.c
arch/arm/cpu/armv7/exynos/pinmux.c
arch/arm/cpu/armv7/ls102xa/fdt.c
arch/arm/cpu/armv7/omap-common/boot-common.c
arch/arm/cpu/armv7/omap-common/clocks-common.c
arch/arm/cpu/armv7/omap-common/hwinit-common.c
arch/arm/cpu/armv7/omap3/board.c
arch/arm/cpu/armv7/omap3/clock.c
arch/arm/cpu/armv7/omap3/sdrc.c
arch/arm/cpu/armv7/omap5/hw_data.c
arch/arm/cpu/armv7/start.S
arch/arm/cpu/armv7/sunxi/Makefile
arch/arm/cpu/armv7/sunxi/board.c
arch/arm/cpu/armv7/sunxi/clock_sun6i.c
arch/arm/cpu/armv7/sunxi/clock_sun9i.c [new file with mode: 0644]
arch/arm/cpu/armv7/sunxi/rsb.c
arch/arm/cpu/armv7/uniphier/Kconfig
arch/arm/cpu/armv7/uniphier/Makefile
arch/arm/cpu/armv7/uniphier/board_early_init_f.c [new file with mode: 0644]
arch/arm/cpu/armv7/uniphier/board_postclk_init.c [deleted file]
arch/arm/cpu/armv7/uniphier/cmd_pinmon.c
arch/arm/cpu/armv7/uniphier/dram_init.c
arch/arm/cpu/armv7/uniphier/init_page_table.S [new file with mode: 0644]
arch/arm/cpu/armv7/uniphier/init_page_table.c [deleted file]
arch/arm/cpu/armv7/uniphier/ph1-ld4/Makefile
arch/arm/cpu/armv7/uniphier/ph1-ld4/board_info.c [deleted file]
arch/arm/cpu/armv7/uniphier/ph1-ld4/pll_init.c
arch/arm/cpu/armv7/uniphier/ph1-ld4/sg_init.c
arch/arm/cpu/armv7/uniphier/ph1-ld4/umc_init.c
arch/arm/cpu/armv7/uniphier/ph1-pro4/Makefile
arch/arm/cpu/armv7/uniphier/ph1-pro4/board_info.c [deleted file]
arch/arm/cpu/armv7/uniphier/ph1-pro4/boot-mode.c
arch/arm/cpu/armv7/uniphier/ph1-pro4/pll_init.c
arch/arm/cpu/armv7/uniphier/ph1-pro4/sg_init.c
arch/arm/cpu/armv7/uniphier/ph1-pro4/umc_init.c
arch/arm/cpu/armv7/uniphier/ph1-sld8/Makefile
arch/arm/cpu/armv7/uniphier/ph1-sld8/board_info.c [deleted file]
arch/arm/cpu/armv7/uniphier/ph1-sld8/pinctrl.c
arch/arm/cpu/armv7/uniphier/ph1-sld8/pll_init.c
arch/arm/cpu/armv7/uniphier/ph1-sld8/umc_init.c
arch/arm/cpu/armv7/uniphier/print_misc_info.c [new file with mode: 0644]
arch/arm/cpu/armv7/uniphier/spl.c
arch/arm/cpu/armv7/virt-v7.c
arch/arm/cpu/armv7/zynq/Makefile
arch/arm/cpu/armv7/zynq/config.mk [new file with mode: 0644]
arch/arm/cpu/armv7/zynq/cpu.c
arch/arm/cpu/armv7/zynq/ddrc.c
arch/arm/cpu/armv7/zynq/lowlevel_init.S [new file with mode: 0644]
arch/arm/cpu/armv7/zynq/slcr.c
arch/arm/cpu/armv7/zynq/spl.c
arch/arm/cpu/tegra20-common/pmu.c
arch/arm/dts/exynos4.dtsi
arch/arm/dts/exynos4210-origen.dts
arch/arm/dts/exynos4210-trats.dts
arch/arm/dts/exynos4210-universal_c210.dts
arch/arm/dts/exynos4412-odroid.dts
arch/arm/dts/exynos4412-trats2.dts
arch/arm/dts/exynos5.dtsi
arch/arm/dts/exynos5250-arndale.dts
arch/arm/dts/exynos5250-smdk5250.dts
arch/arm/dts/exynos5250-snow.dts
arch/arm/dts/exynos5420-peach-pit.dts
arch/arm/dts/exynos5422-odroidxu3.dts
arch/arm/dts/exynos5800-peach-pi.dts
arch/arm/dts/tegra114-dalmore.dts
arch/arm/dts/tegra124-jetson-tk1.dts
arch/arm/dts/tegra124-venice2.dts
arch/arm/dts/tegra20-colibri_t20_iris.dts
arch/arm/dts/tegra20-harmony.dts
arch/arm/dts/tegra20-medcom-wide.dts
arch/arm/dts/tegra20-paz00.dts
arch/arm/dts/tegra20-seaboard.dts
arch/arm/dts/tegra20-tamonten.dtsi
arch/arm/dts/tegra20-tec.dts
arch/arm/dts/tegra20-trimslice.dts
arch/arm/dts/tegra20-ventana.dts
arch/arm/dts/tegra20-whistler.dts
arch/arm/dts/tegra30-apalis.dts
arch/arm/dts/tegra30-beaver.dts
arch/arm/dts/tegra30-cardhu.dts
arch/arm/dts/tegra30-colibri.dts
arch/arm/dts/tegra30-tamonten.dtsi
arch/arm/dts/uniphier-ph1-ld4-ref.dts
arch/arm/dts/uniphier-ph1-pro4-ref.dts
arch/arm/dts/uniphier-ph1-sld3-ref.dts
arch/arm/dts/uniphier-ph1-sld8-ref.dts
arch/arm/dts/uniphier-ref-daughter.dtsi [new file with mode: 0644]
arch/arm/include/asm/arch-armada-xp/config.h
arch/arm/include/asm/arch-armada-xp/cpu.h
arch/arm/include/asm/arch-at91/atmel_usba_udc.h
arch/arm/include/asm/arch-exynos/pinmux.h
arch/arm/include/asm/arch-ls102xa/config.h
arch/arm/include/asm/arch-ls102xa/gpio.h [new file with mode: 0644]
arch/arm/include/asm/arch-ls102xa/immap_ls102xa.h
arch/arm/include/asm/arch-omap3/mem.h
arch/arm/include/asm/arch-omap3/mmc_host_def.h
arch/arm/include/asm/arch-omap3/mux.h
arch/arm/include/asm/arch-omap3/sys_proto.h
arch/arm/include/asm/arch-omap5/clock.h
arch/arm/include/asm/arch-pantheon/gpio.h [new file with mode: 0644]
arch/arm/include/asm/arch-rmobile/r8a7790.h
arch/arm/include/asm/arch-rmobile/r8a7791.h
arch/arm/include/asm/arch-rmobile/r8a7793.h
arch/arm/include/asm/arch-rmobile/r8a7794.h
arch/arm/include/asm/arch-rmobile/rcar-base.h
arch/arm/include/asm/arch-rmobile/sh_sdhi.h [new file with mode: 0644]
arch/arm/include/asm/arch-sunxi/clock.h
arch/arm/include/asm/arch-sunxi/clock_sun4i.h
arch/arm/include/asm/arch-sunxi/clock_sun6i.h
arch/arm/include/asm/arch-sunxi/clock_sun9i.h [new file with mode: 0644]
arch/arm/include/asm/arch-sunxi/cpu.h
arch/arm/include/asm/arch-sunxi/cpu_sun4i.h [new file with mode: 0644]
arch/arm/include/asm/arch-sunxi/cpu_sun9i.h [new file with mode: 0644]
arch/arm/include/asm/arch-sunxi/display.h
arch/arm/include/asm/arch-sunxi/dram_sun4i.h
arch/arm/include/asm/arch-sunxi/gpio.h
arch/arm/include/asm/arch-sunxi/mmc.h
arch/arm/include/asm/arch-sunxi/rsb.h
arch/arm/include/asm/arch-sunxi/usbc.h
arch/arm/include/asm/arch-tegra/tegra_mmc.h
arch/arm/include/asm/arch-tegra20/display.h
arch/arm/include/asm/arch-uniphier/boot-device.h
arch/arm/include/asm/arch-uniphier/ddrphy-regs.h
arch/arm/include/asm/arch-uniphier/gpio.h [deleted file]
arch/arm/include/asm/arch-uniphier/sg-regs.h
arch/arm/include/asm/arch-zynq/gpio.h
arch/arm/include/asm/arch-zynq/hardware.h
arch/arm/include/asm/arch-zynq/sys_proto.h
arch/arm/include/asm/u-boot-arm.h
arch/arm/lib/cache.c
arch/arm/lib/spl.c
arch/arm/mvebu-common/Makefile
arch/arm/mvebu-common/serdes/Makefile [new file with mode: 0644]
arch/arm/mvebu-common/serdes/board_env_spec.h [new file with mode: 0644]
arch/arm/mvebu-common/serdes/high_speed_env_lib.c [new file with mode: 0644]
arch/arm/mvebu-common/serdes/high_speed_env_spec.c [new file with mode: 0644]
arch/arm/mvebu-common/serdes/high_speed_env_spec.h [new file with mode: 0644]
arch/arm/mvebu-common/u-boot-spl.lds [new file with mode: 0644]
arch/blackfin/cpu/cpu.c
arch/microblaze/config.mk
arch/microblaze/cpu/exception.c
arch/microblaze/cpu/interrupts.c
arch/microblaze/cpu/irq.S
arch/microblaze/cpu/spl.c
arch/microblaze/cpu/start.S
arch/microblaze/cpu/u-boot-spl.lds
arch/microblaze/cpu/u-boot.lds
arch/microblaze/include/asm/asm.h
arch/microblaze/include/asm/config.h
arch/microblaze/include/asm/microblaze_intc.h
arch/microblaze/include/asm/u-boot.h
arch/microblaze/lib/Makefile
arch/microblaze/lib/board.c [deleted file]
arch/mips/Kconfig
arch/mips/Makefile
arch/mips/cpu/Makefile [new file with mode: 0644]
arch/mips/cpu/cpu.c [new file with mode: 0644]
arch/mips/cpu/interrupts.c [new file with mode: 0644]
arch/mips/cpu/mips32/Makefile [deleted file]
arch/mips/cpu/mips32/au1x00/Makefile [deleted file]
arch/mips/cpu/mips32/au1x00/au1x00_eth.c [deleted file]
arch/mips/cpu/mips32/au1x00/au1x00_ide.c [deleted file]
arch/mips/cpu/mips32/au1x00/au1x00_serial.c [deleted file]
arch/mips/cpu/mips32/au1x00/au1x00_usb_ohci.c [deleted file]
arch/mips/cpu/mips32/au1x00/au1x00_usb_ohci.h [deleted file]
arch/mips/cpu/mips32/au1x00/config.mk [deleted file]
arch/mips/cpu/mips32/cache.S [deleted file]
arch/mips/cpu/mips32/cpu.c [deleted file]
arch/mips/cpu/mips32/interrupts.c [deleted file]
arch/mips/cpu/mips32/start.S [deleted file]
arch/mips/cpu/mips32/time.c [deleted file]
arch/mips/cpu/mips64/Makefile [deleted file]
arch/mips/cpu/mips64/cache.S [deleted file]
arch/mips/cpu/mips64/cpu.c [deleted file]
arch/mips/cpu/mips64/interrupts.c [deleted file]
arch/mips/cpu/mips64/start.S [deleted file]
arch/mips/cpu/mips64/time.c [deleted file]
arch/mips/cpu/start.S [new file with mode: 0644]
arch/mips/cpu/time.c [new file with mode: 0644]
arch/mips/include/asm/cacheops.h
arch/mips/include/asm/config.h
arch/mips/include/asm/malta.h
arch/mips/lib/Makefile
arch/mips/lib/bootm.c
arch/mips/lib/cache.c [new file with mode: 0644]
arch/mips/lib/cache_init.S [new file with mode: 0644]
arch/mips/mach-au1x00/Makefile [new file with mode: 0644]
arch/mips/mach-au1x00/au1x00_eth.c [new file with mode: 0644]
arch/mips/mach-au1x00/au1x00_ide.c [new file with mode: 0644]
arch/mips/mach-au1x00/au1x00_serial.c [new file with mode: 0644]
arch/mips/mach-au1x00/au1x00_usb_ohci.c [new file with mode: 0644]
arch/mips/mach-au1x00/au1x00_usb_ohci.h [new file with mode: 0644]
arch/mips/mach-au1x00/config.mk [new file with mode: 0644]
arch/nds32/include/asm/u-boot-nds32.h
arch/powerpc/cpu/mpc5xxx/Kconfig
arch/powerpc/cpu/mpc5xxx/pci_mpc5200.c
arch/powerpc/cpu/mpc83xx/Kconfig
arch/powerpc/cpu/mpc85xx/Kconfig
arch/powerpc/cpu/mpc85xx/b4860_ids.c
arch/powerpc/cpu/mpc85xx/cpu_init.c
arch/powerpc/cpu/mpc85xx/fsl_corenet2_serdes.c
arch/powerpc/cpu/mpc85xx/t1024_serdes.c
arch/powerpc/cpu/mpc85xx/t1040_serdes.c
arch/powerpc/cpu/mpc8xxx/cpu.c
arch/powerpc/cpu/mpc8xxx/fdt.c
arch/powerpc/cpu/ppc4xx/Kconfig
arch/powerpc/include/asm/arch-mpc85xx/gpio.h [new file with mode: 0644]
arch/powerpc/include/asm/config.h
arch/powerpc/include/asm/fsl_secure_boot.h
arch/powerpc/include/asm/fsl_serdes.h
arch/powerpc/lib/board.c
arch/sandbox/cpu/start.c
arch/sandbox/dts/sandbox.dts
arch/sandbox/include/asm/u-boot-sandbox.h
arch/x86/cpu/coreboot/Makefile
arch/x86/cpu/coreboot/coreboot.c
arch/x86/cpu/coreboot/ipchecksum.c [deleted file]
arch/x86/cpu/coreboot/tables.c
arch/x86/cpu/cpu.c
arch/x86/cpu/ivybridge/Kconfig
arch/x86/cpu/ivybridge/Makefile
arch/x86/cpu/ivybridge/mrccache.c [new file with mode: 0644]
arch/x86/cpu/ivybridge/sdram.c
arch/x86/cpu/mtrr.c
arch/x86/cpu/start16.S
arch/x86/dts/chromebook_link.dts
arch/x86/include/asm/arch-coreboot/ipchecksum.h [deleted file]
arch/x86/include/asm/arch-ivybridge/mrccache.h [new file with mode: 0644]
arch/x86/include/asm/global_data.h
arch/x86/include/asm/mtrr.h
arch/x86/include/asm/u-boot-x86.h
arch/x86/lib/init_helpers.c
arch/x86/lib/interrupts.c
board/BuS/eb_cpux9k2/cpux9k2.c
board/Marvell/db-mv784mp-gp/binary.0 [deleted file]
board/Marvell/db-mv784mp-gp/kwbimage.cfg
board/armltd/vexpress64/Kconfig
board/armltd/vexpress64/MAINTAINERS
board/atmel/sama5d4_xplained/sama5d4_xplained.c
board/atmel/sama5d4ek/sama5d4ek.c
board/avionic-design/common/tamonten-ng.c
board/compulab/cm_fx6/spl.c
board/dave/PPChameleonEVB/Kconfig [deleted file]
board/dave/PPChameleonEVB/MAINTAINERS [deleted file]
board/dave/PPChameleonEVB/Makefile [deleted file]
board/dave/PPChameleonEVB/PPChameleonEVB.c [deleted file]
board/dave/PPChameleonEVB/flash.c [deleted file]
board/dave/PPChameleonEVB/nand.c [deleted file]
board/dave/PPChameleonEVB/u-boot.lds [deleted file]
board/esd/cpci5200/Kconfig [deleted file]
board/esd/cpci5200/MAINTAINERS [deleted file]
board/esd/cpci5200/Makefile [deleted file]
board/esd/cpci5200/cpci5200.c [deleted file]
board/esd/cpci5200/mt46v16m16-75.h [deleted file]
board/esd/cpci5200/strataflash.c [deleted file]
board/esd/mecp5200/Kconfig [deleted file]
board/esd/mecp5200/MAINTAINERS [deleted file]
board/esd/mecp5200/Makefile [deleted file]
board/esd/mecp5200/mecp5200.c [deleted file]
board/esd/mecp5200/mt46v16m16-75.h [deleted file]
board/esd/pf5200/Kconfig [deleted file]
board/esd/pf5200/MAINTAINERS [deleted file]
board/esd/pf5200/Makefile [deleted file]
board/esd/pf5200/flash.c [deleted file]
board/esd/pf5200/mt46v16m16-75.h [deleted file]
board/esd/pf5200/pf5200.c [deleted file]
board/freescale/c29xpcie/MAINTAINERS
board/freescale/common/pq-mds-pib.c
board/freescale/corenet_ds/MAINTAINERS
board/freescale/ls1021aqds/MAINTAINERS
board/freescale/ls1021aqds/Makefile
board/freescale/ls1021aqds/dcu.c [new file with mode: 0644]
board/freescale/ls1021aqds/ddr.c
board/freescale/ls1021aqds/ls1021aqds.c
board/freescale/ls1021aqds/ls1021aqds_qixis.h
board/freescale/ls1021atwr/MAINTAINERS
board/freescale/ls1021atwr/ls1021atwr.c
board/freescale/mpc8360emds/Kconfig [deleted file]
board/freescale/mpc8360emds/MAINTAINERS [deleted file]
board/freescale/mpc8360emds/Makefile [deleted file]
board/freescale/mpc8360emds/README [deleted file]
board/freescale/mpc8360emds/mpc8360emds.c [deleted file]
board/freescale/mpc8360emds/pci.c [deleted file]
board/freescale/mpc8360erdk/Kconfig [deleted file]
board/freescale/mpc8360erdk/MAINTAINERS [deleted file]
board/freescale/mpc8360erdk/Makefile [deleted file]
board/freescale/mpc8360erdk/mpc8360erdk.c [deleted file]
board/freescale/mpc8360erdk/nand.c [deleted file]
board/freescale/mpc837xerdb/MAINTAINERS
board/freescale/p1_p2_rdb/Kconfig [deleted file]
board/freescale/p1_p2_rdb/MAINTAINERS [deleted file]
board/freescale/p1_p2_rdb/Makefile [deleted file]
board/freescale/p1_p2_rdb/README [deleted file]
board/freescale/p1_p2_rdb/ddr.c [deleted file]
board/freescale/p1_p2_rdb/law.c [deleted file]
board/freescale/p1_p2_rdb/p1_p2_rdb.c [deleted file]
board/freescale/p1_p2_rdb/pci.c [deleted file]
board/freescale/p1_p2_rdb/spl.c [deleted file]
board/freescale/p1_p2_rdb/spl_minimal.c [deleted file]
board/freescale/p1_p2_rdb/tlb.c [deleted file]
board/freescale/p2020come/Kconfig [deleted file]
board/freescale/p2020come/MAINTAINERS [deleted file]
board/freescale/p2020come/Makefile [deleted file]
board/freescale/p2020come/ddr.c [deleted file]
board/freescale/p2020come/law.c [deleted file]
board/freescale/p2020come/p2020come.c [deleted file]
board/freescale/p2020come/tlb.c [deleted file]
board/freescale/p2020ds/Kconfig [deleted file]
board/freescale/p2020ds/MAINTAINERS [deleted file]
board/freescale/p2020ds/Makefile [deleted file]
board/freescale/p2020ds/ddr.c [deleted file]
board/freescale/p2020ds/law.c [deleted file]
board/freescale/p2020ds/p2020ds.c [deleted file]
board/freescale/p2020ds/tlb.c [deleted file]
board/freescale/t102xqds/ddr.c
board/freescale/t102xqds/t102xqds.c
board/freescale/t102xrdb/cpld.h
board/freescale/t102xrdb/ddr.c
board/freescale/t102xrdb/eth_t102xrdb.c
board/freescale/t102xrdb/spl.c
board/freescale/t102xrdb/t102xrdb.c
board/freescale/t1040qds/ddr.c
board/freescale/t1040qds/eth.c
board/freescale/t1040qds/t1040qds.c
board/freescale/t104xrdb/MAINTAINERS
board/freescale/t104xrdb/eth.c
board/freescale/t4rdb/eth.c
board/freescale/t4rdb/t4_rcw.cfg
board/icecube/Kconfig [deleted file]
board/icecube/MAINTAINERS [deleted file]
board/icecube/Makefile [deleted file]
board/icecube/README [deleted file]
board/icecube/README.Lite5200B_low_power [deleted file]
board/icecube/flash.c [deleted file]
board/icecube/icecube.c [deleted file]
board/icecube/mt46v16m16-75.h [deleted file]
board/icecube/mt46v32m16.h [deleted file]
board/icecube/mt48lc16m16a2-75.h [deleted file]
board/imgtec/malta/malta.c
board/iomega/iconnect/kwbimage.cfg
board/isee/igep00x0/igep00x0.c
board/isee/igep00x0/igep00x0.h
board/maxbcm/binary.0 [deleted file]
board/maxbcm/kwbimage.cfg
board/maxbcm/maxbcm.c
board/nvidia/cardhu/cardhu.c
board/nvidia/dalmore/dalmore.c
board/nvidia/whistler/whistler.c
board/pm520/Kconfig [deleted file]
board/pm520/MAINTAINERS [deleted file]
board/pm520/Makefile [deleted file]
board/pm520/flash.c [deleted file]
board/pm520/mt46v16m16-75.h [deleted file]
board/pm520/mt48lc16m16a2-75.h [deleted file]
board/pm520/pm520.c [deleted file]
board/raidsonic/ib62x0/kwbimage.cfg
board/samsung/odroid/odroid.c
board/sandbox/README.sandbox
board/siemens/corvus/board.c
board/siemens/taurus/taurus.c
board/sunxi/Kconfig
board/sunxi/MAINTAINERS
board/sunxi/Makefile
board/sunxi/board.c
board/sunxi/dram_a10_olinuxino_l.c [deleted file]
board/sunxi/dram_a10s_olinuxino_m.c [deleted file]
board/sunxi/dram_a13_oli_micro.c [deleted file]
board/sunxi/dram_a13_olinuxino.c [deleted file]
board/sunxi/dram_a20_olinuxino_l.c [deleted file]
board/sunxi/dram_a20_olinuxino_l2.c [deleted file]
board/sunxi/dram_bananapi.c [deleted file]
board/sunxi/dram_cubieboard.c [deleted file]
board/sunxi/dram_cubieboard2.c [deleted file]
board/sunxi/dram_cubietruck.c [deleted file]
board/sunxi/dram_linksprite_pcduino3.c [deleted file]
board/sunxi/dram_r7dongle.c [deleted file]
board/sunxi/dram_sun4i_360_1024_iow16.c [deleted file]
board/sunxi/dram_sun4i_360_1024_iow8.c [deleted file]
board/sunxi/dram_sun4i_360_512.c [deleted file]
board/sunxi/dram_sun4i_384_1024_iow8.c [deleted file]
board/sunxi/dram_sun4i_408_1024_iow8.c [deleted file]
board/sunxi/dram_sun4i_auto.c [new file with mode: 0644]
board/sunxi/dram_sun5i_auto.c [new file with mode: 0644]
board/sunxi/dram_sun7i_384_1024_iow16.c [deleted file]
board/sunxi/dram_sun7i_384_512_busw16_iow16.c [deleted file]
board/sunxi/dram_timings_sun4i.h [new file with mode: 0644]
board/sunxi/gmac.c
board/synopsys/Kconfig
board/synopsys/MAINTAINERS
board/synopsys/axs101/Kconfig
board/toradex/apalis_t30/apalis_t30.c
board/total5200/Kconfig [deleted file]
board/total5200/MAINTAINERS [deleted file]
board/total5200/Makefile [deleted file]
board/total5200/mt48lc16m16a2-75.h [deleted file]
board/total5200/mt48lc32m16a2-75.h [deleted file]
board/total5200/sdram.c [deleted file]
board/total5200/sdram.h [deleted file]
board/total5200/total5200.c [deleted file]
board/woodburn/woodburn.c
board/xilinx/microblaze-generic/microblaze-generic.c
board/xilinx/zynq/board.c
common/Makefile
common/board_f.c
common/board_info.c [new file with mode: 0644]
common/board_r.c
common/cmd_bdinfo.c
common/cmd_bootm.c
common/cmd_demo.c
common/cmd_fpga.c
common/cmd_fs.c
common/cmd_gettime.c
common/cmd_i2c.c
common/cmd_load.c
common/cmd_mmc.c
common/cmd_part.c
common/cmd_usb.c
common/cmd_ximg.c
common/console.c
common/exports.c
common/hash.c
common/image-fit.c
common/image-sig.c
common/image.c
common/lcd.c
common/spl/spl.c
common/usb.c
common/usb_kbd.c
configs/A10-OLinuXino-Lime_defconfig
configs/A10s-OLinuXino-M_defconfig
configs/A13-OLinuXinoM_defconfig
configs/A13-OLinuXino_defconfig
configs/A20-OLinuXino-Lime2_defconfig
configs/A20-OLinuXino-Lime_defconfig
configs/A20-OLinuXino_MICRO_defconfig
configs/Auxtek-T004_defconfig
configs/Bananapi_defconfig
configs/Bananapro_defconfig
configs/C29XPCIE_NOR_SECBOOT_defconfig [new file with mode: 0644]
configs/C29XPCIE_SPIFLASH_SECBOOT_defconfig [new file with mode: 0644]
configs/CATcenter_25_defconfig [deleted file]
configs/CATcenter_33_defconfig [deleted file]
configs/CATcenter_defconfig [deleted file]
configs/CSQ_CS908_defconfig
configs/Chuwi_V7_CW0825_defconfig [new file with mode: 0644]
configs/Colombus_defconfig
configs/Cubieboard2_defconfig
configs/Cubieboard_defconfig
configs/Cubietruck_defconfig
configs/Hummingbird_A31_defconfig
configs/Hyundai_A7HD_defconfig [new file with mode: 0644]
configs/Inet_86VS_defconfig [new file with mode: 0644]
configs/Ippo_q8h_v1_2_defconfig
configs/Ippo_q8h_v5_defconfig
configs/Linksprite_pcDuino3_Nano_defconfig [new file with mode: 0644]
configs/Linksprite_pcDuino3_defconfig
configs/Linksprite_pcDuino3_fdt_defconfig
configs/Linksprite_pcDuino_defconfig
configs/Lite5200_LOWBOOT08_defconfig [deleted file]
configs/Lite5200_LOWBOOT_defconfig [deleted file]
configs/Lite5200_defconfig [deleted file]
configs/MPC8360EMDS_33_ATM_defconfig [deleted file]
configs/MPC8360EMDS_33_HOST_33_defconfig [deleted file]
configs/MPC8360EMDS_33_HOST_66_defconfig [deleted file]
configs/MPC8360EMDS_33_SLAVE_defconfig [deleted file]
configs/MPC8360EMDS_33_defconfig [deleted file]
configs/MPC8360EMDS_66_ATM_defconfig [deleted file]
configs/MPC8360EMDS_66_HOST_33_defconfig [deleted file]
configs/MPC8360EMDS_66_HOST_66_defconfig [deleted file]
configs/MPC8360EMDS_66_SLAVE_defconfig [deleted file]
configs/MPC8360EMDS_66_defconfig [deleted file]
configs/MPC8360ERDK_33_defconfig [deleted file]
configs/MPC8360ERDK_defconfig [deleted file]
configs/MSI_Primo73_defconfig
configs/MSI_Primo81_defconfig
configs/Marsboard_A10_defconfig [new file with mode: 0644]
configs/Mele_A1000G_defconfig [deleted file]
configs/Mele_A1000_defconfig
configs/Mele_M3_defconfig
configs/Mele_M5_defconfig [new file with mode: 0644]
configs/Mele_M9_defconfig
configs/Mini-X-1Gb_defconfig [deleted file]
configs/Mini-X_defconfig
configs/P1011RDB_36BIT_SDCARD_defconfig [deleted file]
configs/P1011RDB_36BIT_SPIFLASH_defconfig [deleted file]
configs/P1011RDB_36BIT_defconfig [deleted file]
configs/P1011RDB_NAND_defconfig [deleted file]
configs/P1011RDB_SDCARD_defconfig [deleted file]
configs/P1011RDB_SPIFLASH_defconfig [deleted file]
configs/P1011RDB_defconfig [deleted file]
configs/P1020RDB_36BIT_SDCARD_defconfig [deleted file]
configs/P1020RDB_36BIT_SPIFLASH_defconfig [deleted file]
configs/P1020RDB_36BIT_defconfig [deleted file]
configs/P1020RDB_NAND_defconfig [deleted file]
configs/P1020RDB_SDCARD_defconfig [deleted file]
configs/P1020RDB_SPIFLASH_defconfig [deleted file]
configs/P1020RDB_defconfig [deleted file]
configs/P2010RDB_36BIT_SDCARD_defconfig [deleted file]
configs/P2010RDB_36BIT_SPIFLASH_defconfig [deleted file]
configs/P2010RDB_36BIT_defconfig [deleted file]
configs/P2010RDB_NAND_defconfig [deleted file]
configs/P2010RDB_SDCARD_defconfig [deleted file]
configs/P2010RDB_SPIFLASH_defconfig [deleted file]
configs/P2010RDB_defconfig [deleted file]
configs/P2020COME_SDCARD_defconfig [deleted file]
configs/P2020COME_SPIFLASH_defconfig [deleted file]
configs/P2020DS_36BIT_defconfig [deleted file]
configs/P2020DS_DDR2_defconfig [deleted file]
configs/P2020DS_SDCARD_defconfig [deleted file]
configs/P2020DS_SPIFLASH_defconfig [deleted file]
configs/P2020DS_defconfig [deleted file]
configs/P2020RDB_36BIT_SDCARD_defconfig [deleted file]
configs/P2020RDB_36BIT_SPIFLASH_defconfig [deleted file]
configs/P2020RDB_36BIT_defconfig [deleted file]
configs/P2020RDB_NAND_defconfig [deleted file]
configs/P2020RDB_SDCARD_defconfig [deleted file]
configs/P2020RDB_SPIFLASH_defconfig [deleted file]
configs/P2020RDB_defconfig [deleted file]
configs/P5040DS_SECURE_BOOT_defconfig [new file with mode: 0644]
configs/PM520_DDR_defconfig [deleted file]
configs/PM520_ROMBOOT_DDR_defconfig [deleted file]
configs/PM520_ROMBOOT_defconfig [deleted file]
configs/PM520_defconfig [deleted file]
configs/PPChameleonEVB_BA_25_defconfig [deleted file]
configs/PPChameleonEVB_BA_33_defconfig [deleted file]
configs/PPChameleonEVB_HI_25_defconfig [deleted file]
configs/PPChameleonEVB_HI_33_defconfig [deleted file]
configs/PPChameleonEVB_ME_25_defconfig [deleted file]
configs/PPChameleonEVB_ME_33_defconfig [deleted file]
configs/PPChameleonEVB_defconfig [deleted file]
configs/T1024QDS_defconfig [new file with mode: 0644]
configs/T1042RDB_SECURE_BOOT_defconfig [new file with mode: 0644]
configs/TZX-Q8-713B7_defconfig [new file with mode: 0644]
configs/Total5200_Rev2_defconfig [deleted file]
configs/Total5200_Rev2_lowboot_defconfig [deleted file]
configs/Total5200_defconfig [deleted file]
configs/Total5200_lowboot_defconfig [deleted file]
configs/am335x_boneblack_vboot_defconfig
configs/arcangel4-be_defconfig
configs/arcangel4_defconfig
configs/axm_defconfig
configs/axs101_defconfig
configs/ba10_tv_box_defconfig
configs/chromebook_link_defconfig
configs/cpci5200_defconfig [deleted file]
configs/db-mv784mp-gp_defconfig
configs/i12-tvbox_defconfig
configs/icecube_5200_DDR_LOWBOOT08_defconfig [deleted file]
configs/icecube_5200_DDR_LOWBOOT_defconfig [deleted file]
configs/icecube_5200_DDR_defconfig [deleted file]
configs/icecube_5200_LOWBOOT08_defconfig [deleted file]
configs/icecube_5200_LOWBOOT_defconfig [deleted file]
configs/icecube_5200_defconfig [deleted file]
configs/ids8313_defconfig
configs/lite5200b_LOWBOOT_defconfig [deleted file]
configs/lite5200b_PM_defconfig [deleted file]
configs/lite5200b_defconfig [deleted file]
configs/ls1021aqds_nor_lpuart_defconfig [new file with mode: 0644]
configs/ls1021atwr_nor_lpuart_defconfig [new file with mode: 0644]
configs/maxbcm_defconfig
configs/mecp5200_defconfig [deleted file]
configs/mk802_a10s_defconfig [new file with mode: 0644]
configs/mk802_defconfig [new file with mode: 0644]
configs/mk802ii_defconfig [new file with mode: 0644]
configs/pf5200_defconfig [deleted file]
configs/ph1_ld4_defconfig
configs/ph1_pro4_defconfig
configs/ph1_sld8_defconfig
configs/qt840a_defconfig [deleted file]
configs/r7-tv-dongle_defconfig
configs/sandbox_defconfig
configs/sunxi_Gemei_G9_defconfig [new file with mode: 0644]
configs/tb100_defconfig
configs/vexpress_aemv8a_defconfig
configs/vexpress_aemv8a_juno_defconfig [new file with mode: 0644]
configs/vexpress_aemv8a_semi_defconfig
configs/zynq_microzed_defconfig
configs/zynq_zc70x_defconfig
configs/zynq_zc770_xm010_defconfig
configs/zynq_zc770_xm012_defconfig
configs/zynq_zc770_xm013_defconfig
configs/zynq_zed_defconfig
configs/zynq_zybo_defconfig
doc/README.distro [new file with mode: 0644]
doc/README.scrapyard
doc/README.standalone
doc/README.t1040-l2switch [new file with mode: 0644]
doc/README.uniphier [new file with mode: 0644]
doc/device-tree-bindings/gpio/gpio-samsung.txt [new file with mode: 0644]
doc/device-tree-bindings/gpio/gpio.txt [new file with mode: 0644]
doc/device-tree-bindings/gpio/nvidia,tegra20-gpio.txt [new file with mode: 0644]
doc/device-tree-bindings/i2c/i2c.txt [new file with mode: 0644]
doc/driver-model/README.txt
doc/driver-model/spi-howto.txt
doc/uImage.FIT/source_file_format.txt
doc/uImage.FIT/verified-boot.txt
drivers/bios_emulator/atibios.c
drivers/bios_emulator/include/x86emu/debug.h
drivers/bios_emulator/x86emu/ops.c
drivers/block/ahci.c
drivers/core/device-remove.c
drivers/core/device.c
drivers/core/root.c
drivers/core/uclass.c
drivers/crypto/Kconfig
drivers/crypto/Makefile
drivers/crypto/fsl/Kconfig [new file with mode: 0644]
drivers/crypto/fsl/Makefile
drivers/crypto/fsl/fsl_rsa.c [new file with mode: 0644]
drivers/crypto/fsl/jobdesc.c
drivers/crypto/fsl/jobdesc.h
drivers/crypto/fsl/rsa_caam.h [new file with mode: 0644]
drivers/crypto/fsl/sec.c [new file with mode: 0644]
drivers/crypto/rsa_mod_exp/Kconfig [new file with mode: 0644]
drivers/crypto/rsa_mod_exp/Makefile [new file with mode: 0644]
drivers/crypto/rsa_mod_exp/mod_exp_sw.c [new file with mode: 0644]
drivers/crypto/rsa_mod_exp/mod_exp_uclass.c [new file with mode: 0644]
drivers/ddr/fsl/fsl_ddr_gen4.c
drivers/ddr/mvebu/Makefile [new file with mode: 0644]
drivers/ddr/mvebu/ddr3_axp.h [new file with mode: 0644]
drivers/ddr/mvebu/ddr3_axp_config.h [new file with mode: 0644]
drivers/ddr/mvebu/ddr3_axp_mc_static.h [new file with mode: 0644]
drivers/ddr/mvebu/ddr3_axp_training_static.h [new file with mode: 0644]
drivers/ddr/mvebu/ddr3_axp_vars.h [new file with mode: 0644]
drivers/ddr/mvebu/ddr3_dfs.c [new file with mode: 0644]
drivers/ddr/mvebu/ddr3_dqs.c [new file with mode: 0644]
drivers/ddr/mvebu/ddr3_hw_training.c [new file with mode: 0644]
drivers/ddr/mvebu/ddr3_hw_training.h [new file with mode: 0644]
drivers/ddr/mvebu/ddr3_init.c [new file with mode: 0644]
drivers/ddr/mvebu/ddr3_init.h [new file with mode: 0644]
drivers/ddr/mvebu/ddr3_patterns_64bit.h [new file with mode: 0644]
drivers/ddr/mvebu/ddr3_pbs.c [new file with mode: 0644]
drivers/ddr/mvebu/ddr3_read_leveling.c [new file with mode: 0644]
drivers/ddr/mvebu/ddr3_sdram.c [new file with mode: 0644]
drivers/ddr/mvebu/ddr3_spd.c [new file with mode: 0644]
drivers/ddr/mvebu/ddr3_write_leveling.c [new file with mode: 0644]
drivers/ddr/mvebu/xor.c [new file with mode: 0644]
drivers/ddr/mvebu/xor.h [new file with mode: 0644]
drivers/ddr/mvebu/xor_regs.h [new file with mode: 0644]
drivers/demo/demo-shape.c
drivers/demo/demo-uclass.c
drivers/fpga/fpga.c
drivers/fpga/xilinx.c
drivers/gpio/gpio-uclass.c
drivers/gpio/s5p_gpio.c
drivers/gpio/sandbox.c
drivers/gpio/tegra_gpio.c
drivers/i2c/Kconfig
drivers/i2c/Makefile
drivers/i2c/i2c-uclass-compat.c [new file with mode: 0644]
drivers/i2c/i2c-uclass.c
drivers/i2c/i2c-uniphier-f.c [new file with mode: 0644]
drivers/i2c/i2c-uniphier.c [new file with mode: 0644]
drivers/i2c/s3c24x0_i2c.c
drivers/i2c/sandbox_i2c.c
drivers/i2c/tegra_i2c.c
drivers/misc/cros_ec.c
drivers/misc/cros_ec_i2c.c
drivers/misc/cros_ec_spi.c
drivers/mmc/Kconfig
drivers/mmc/Makefile
drivers/mmc/mmc.c
drivers/mmc/omap_hsmmc.c
drivers/mmc/s5p_sdhci.c
drivers/mmc/sh_sdhi.c [new file with mode: 0644]
drivers/mmc/sunxi_mmc.c
drivers/mmc/tegra_mmc.c
drivers/mmc/zynq_sdhci.c
drivers/mtd/nand/nand_base.c
drivers/mtd/nand/tegra_nand.c
drivers/mtd/spi/sandbox.c
drivers/mtd/spi/sf_probe.c
drivers/mtd/ubi/build.c
drivers/net/Makefile
drivers/net/designware.c
drivers/net/e1000.c
drivers/net/fm/eth.c
drivers/net/fm/t1040.c
drivers/net/mpc5xxx_fec.c
drivers/net/mvgbe.c
drivers/net/phy/Makefile
drivers/net/phy/aquantia.c [new file with mode: 0644]
drivers/net/phy/micrel.c
drivers/net/phy/phy.c
drivers/net/smc91111.h
drivers/net/tsec.c
drivers/net/vsc9953.c [new file with mode: 0644]
drivers/net/xilinx_ll_temac.c
drivers/net/zynq_gem.c
drivers/pci/pci_auto.c
drivers/pci/pci_rom.c
drivers/pci/pci_tegra.c
drivers/power/Kconfig
drivers/power/as3722.c
drivers/power/axp209.c
drivers/power/axp221.c
drivers/power/tps6586x.c
drivers/rtc/mc146818.c
drivers/serial/serial-uclass.c
drivers/serial/serial_zynq.c
drivers/spi/cadence_qspi.c
drivers/spi/designware_spi.c
drivers/spi/exynos_spi.c
drivers/spi/ich.c
drivers/spi/sandbox_spi.c
drivers/spi/soft_spi.c
drivers/spi/spi-uclass.c
drivers/spi/tegra114_spi.c
drivers/spi/tegra20_sflash.c
drivers/spi/tegra20_slink.c
drivers/usb/eth/asix88179.c
drivers/usb/gadget/composite.c
drivers/usb/gadget/f_dfu.c
drivers/usb/gadget/pxa25x_udc.c
drivers/usb/host/ehci-exynos.c
drivers/usb/host/ehci-hcd.c
drivers/usb/host/ehci-tegra.c
drivers/usb/host/xhci-exynos5.c
drivers/usb/musb-new/Makefile
drivers/usb/musb-new/musb_host.c
drivers/usb/musb-new/musb_host.h
drivers/usb/musb-new/musb_regs.h
drivers/usb/musb-new/musb_uboot.c
drivers/usb/musb-new/sunxi.c [new file with mode: 0644]
drivers/usb/musb-new/usb-compat.h
drivers/video/Kconfig
drivers/video/Makefile
drivers/video/cfb_console.c
drivers/video/hitachi_tx18d42vm_lcd.c [new file with mode: 0644]
drivers/video/hitachi_tx18d42vm_lcd.h [new file with mode: 0644]
drivers/video/sed13806.c
drivers/video/ssd2828.c [new file with mode: 0644]
drivers/video/ssd2828.h [new file with mode: 0644]
drivers/video/sunxi_display.c
drivers/video/tegra.c
drivers/video/vesa_fb.c [new file with mode: 0644]
drivers/video/x86_fb.c [deleted file]
examples/standalone/stubs.c
fs/fs.c
fs/ubifs/Makefile
fs/ubifs/gc.c [new file with mode: 0644]
fs/ubifs/replay.c
fs/ubifs/super.c
fs/ubifs/tnc.c
fs/ubifs/ubifs.c
fs/ubifs/ubifs.h
include/_exports.h
include/asm-generic/atomic-long.h [new file with mode: 0644]
include/asm-generic/global_data.h
include/asm-generic/gpio.h
include/axp221.h
include/common.h
include/config_distro_bootcmd.h
include/configs/BSC9131RDB.h
include/configs/BSC9132QDS.h
include/configs/C29XPCIE.h
include/configs/CATcenter.h [deleted file]
include/configs/IceCube.h [deleted file]
include/configs/MPC8360EMDS.h [deleted file]
include/configs/MPC8360ERDK.h [deleted file]
include/configs/MPC837XERDB.h
include/configs/P1_P2_RDB.h [deleted file]
include/configs/P2020COME.h [deleted file]
include/configs/P2020DS.h [deleted file]
include/configs/PM520.h [deleted file]
include/configs/PPChameleonEVB.h [deleted file]
include/configs/T102xQDS.h
include/configs/T102xRDB.h
include/configs/T1040QDS.h
include/configs/T104xRDB.h
include/configs/Total5200.h [deleted file]
include/configs/am335x_evm.h
include/configs/arcangel4-be.h [deleted file]
include/configs/arcangel4.h
include/configs/arndale.h
include/configs/axs101.h
include/configs/bct-brettl2.h
include/configs/chromebook_link.h
include/configs/corvus.h
include/configs/cpci5200.h [deleted file]
include/configs/db-mv784mp-gp.h
include/configs/dockstar.h
include/configs/exynos5-common.h
include/configs/exynos5250-common.h
include/configs/goflexhome.h
include/configs/guruplug.h
include/configs/ib62x0.h
include/configs/ibf-dsp561.h
include/configs/iconnect.h
include/configs/ids8313.h
include/configs/ip04.h
include/configs/ls1021aqds.h
include/configs/ls1021atwr.h
include/configs/malta.h
include/configs/maxbcm.h
include/configs/mecp5200.h [deleted file]
include/configs/microblaze-generic.h
include/configs/nokia_rx51.h
include/configs/odroid.h
include/configs/omap3_igep00x0.h
include/configs/pf5200.h [deleted file]
include/configs/pogo_e02.h
include/configs/sama5d3_xplained.h
include/configs/sama5d4_xplained.h
include/configs/sama5d4ek.h
include/configs/sandbox.h
include/configs/sheevaplug.h
include/configs/smdk5250.h
include/configs/snapper9260.h
include/configs/snow.h
include/configs/sun4i.h
include/configs/sun5i.h
include/configs/sun6i.h
include/configs/sun7i.h
include/configs/sun8i.h
include/configs/sunxi-common.h
include/configs/taurus.h
include/configs/tb100.h
include/configs/ti_am335x_common.h
include/configs/uniphier.h
include/configs/vexpress_aemv8a.h
include/configs/vexpress_common.h
include/configs/x86-common.h
include/configs/zynq-common.h
include/cros_ec.h
include/dm-demo.h
include/dm/device.h
include/dm/test.h
include/dm/uclass-id.h
include/dm/uclass-internal.h
include/dm/uclass.h
include/exports.h
include/fdtdec.h
include/fpga.h
include/fs.h
include/fsl_ddr.h
include/hash.h
include/i2c.h
include/image.h
include/linker_lists.h
include/linux/compat.h
include/mipi_display.h [new file with mode: 0644]
include/mmc.h
include/net.h
include/netdev.h
include/pci.h
include/pci_rom.h
include/phy.h
include/rtc.h
include/sdhci.h
include/spartan2.h
include/spartan3.h
include/spi.h
include/u-boot/rsa-checksum.h
include/u-boot/rsa-mod-exp.h [new file with mode: 0644]
include/usb.h
include/vbe.h
include/virtex2.h
include/vsc9953.h [new file with mode: 0644]
include/zynqpl.h
lib/Kconfig
lib/fdtdec.c
lib/rsa/Kconfig [new file with mode: 0644]
lib/rsa/Makefile
lib/rsa/rsa-checksum.c
lib/rsa/rsa-mod-exp.c [new file with mode: 0644]
lib/rsa/rsa-verify.c
net/Makefile
net/checksum.c [new file with mode: 0644]
scripts/Makefile.spl
test/dm/bus.c
test/dm/core.c
test/dm/gpio.c
test/dm/i2c.c
test/dm/spi.c
test/dm/test-dm.sh
test/dm/test-fdt.c
test/dm/test.dts
test/image/test-imagetools.sh
tools/Makefile
tools/aisimage.c
tools/atmelimage.c
tools/default_image.c
tools/dumpimage.c
tools/fit_image.c
tools/gpimage-common.c
tools/gpimage.c
tools/imagetool.c
tools/imagetool.h
tools/imagetool.lds [new file with mode: 0644]
tools/imximage.c
tools/kwbimage.c
tools/mkimage.c
tools/mxsimage.c
tools/omapimage.c
tools/patman/README
tools/patman/gitutil.py
tools/patman/patchstream.py
tools/patman/series.py
tools/pblimage.c
tools/socfpgaimage.c
tools/ublimage.c

diff --git a/Kconfig b/Kconfig
index 4157da3c68485540597b7e8993d6786676ac5d25..9af31e3e77a2e36e7b0cd72384b6d4081c132a54 100644 (file)
--- a/Kconfig
+++ b/Kconfig
@@ -116,8 +116,9 @@ config FIT_VERBOSE
        depends on FIT
 
 config FIT_SIGNATURE
-       bool "Enabel signature verification of FIT uImages"
+       bool "Enable signature verification of FIT uImages"
        depends on FIT
+       select RSA
        help
          This option enables signature verification of FIT uImages,
          using a hash signed and verified using RSA.
@@ -138,7 +139,7 @@ config SYS_EXTRA_OPTIONS
          new boards should not use this option.
 
 config SYS_TEXT_BASE
-       depends on SPARC
+       depends on SPARC || ARC
        hex "Text Base"
        help
          TODO: Move CONFIG_SYS_TEXT_BASE for all the architecture
index 1f7735922d6d464476d19dd16419bf8595853829..74a56ecf4ffb88983ad1b0ded502a90169c310d4 100644 (file)
@@ -170,7 +170,7 @@ T:  git git://git.denx.de/u-boot-uniphier.git
 F:     arch/arm/cpu/armv7/uniphier/
 F:     arch/arm/include/asm/arch-uniphier/
 F:     configs/ph1_*_defconfig
-F:     drivers/serial/serial_uniphier.c
+N:     uniphier
 
 ARM ZYNQ
 M:     Michal Simek <monstr@monstr.eu>
index 36a9a283b051527df532d16c5f4dd69c9be3556c..76bae8b6d500bb2f5dfb83b0355af3fefbe321cd 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
 VERSION = 2015
-PATCHLEVEL = 01
+PATCHLEVEL = 04
 SUBLEVEL =
-EXTRAVERSION =
+EXTRAVERSION = -rc1
 NAME =
 
 # *DOCUMENTATION*
@@ -776,6 +776,13 @@ ifneq ($(CONFIG_SYS_GENERIC_BOARD),y)
        @echo "See doc/README.generic-board for further information"
        @echo "===================================================="
 endif
+ifeq ($(CONFIG_DM_I2C_COMPAT),y)
+       @echo "===================== WARNING ======================"
+       @echo "This board uses CONFIG_DM_I2C_COMPAT. Please remove"
+       @echo "(possibly in a subsequent patch in your series)"
+       @echo "before sending patches to the mailing list."
+       @echo "===================================================="
+endif
 
 PHONY += dtbs
 dtbs dts/dt.dtb: checkdtc u-boot
@@ -849,12 +856,18 @@ MKIMAGEFLAGS_u-boot.img = -A $(ARCH) -T firmware -C none -O u-boot \
 MKIMAGEFLAGS_u-boot.kwb = -n $(srctree)/$(CONFIG_SYS_KWD_CONFIG:"%"=%) \
        -T kwbimage -a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_TEXT_BASE)
 
+MKIMAGEFLAGS_u-boot-spl.kwb = -n $(srctree)/$(CONFIG_SYS_KWD_CONFIG:"%"=%) \
+       -T kwbimage -a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_TEXT_BASE)
+
 MKIMAGEFLAGS_u-boot.pbl = -n $(srctree)/$(CONFIG_SYS_FSL_PBL_RCW:"%"=%) \
                -R $(srctree)/$(CONFIG_SYS_FSL_PBL_PBI:"%"=%) -T pblimage
 
 u-boot.img u-boot.kwb u-boot.pbl: u-boot.bin FORCE
        $(call if_changed,mkimage)
 
+u-boot-spl.kwb: u-boot.img spl/u-boot-spl.bin FORCE
+       $(call if_changed,mkimage)
+
 MKIMAGEFLAGS_u-boot-dtb.img = $(MKIMAGEFLAGS_u-boot.img)
 
 u-boot-dtb.img: u-boot-dtb.bin FORCE
@@ -1278,7 +1291,7 @@ CLEAN_DIRS  += $(MODVERDIR) \
                        $(filter-out include, $(shell ls -1 $d 2>/dev/null))))
 
 CLEAN_FILES += include/bmp_logo.h include/bmp_logo_data.h \
-              u-boot* MLO* SPL System.map
+              boot* u-boot* MLO* SPL System.map
 
 # Directories & files removed with 'make mrproper'
 MRPROPER_DIRS  += include/config include/generated spl tpl \
diff --git a/README b/README
index fefa71c0a6c5f3adf8ed437e6956227a0e502e8b..a28ff133ee057c17af79a397e44325328f82dedf 100644 (file)
--- a/README
+++ b/README
@@ -3176,8 +3176,13 @@ CBFS (Coreboot Filesystem) support
                This enables the RSA algorithm used for FIT image verification
                in U-Boot. See doc/uImage.FIT/signature.txt for more information.
 
+               The Modular Exponentiation algorithm in RSA is implemented using
+               driver model. So CONFIG_DM needs to be enabled by default for this
+               library to function.
+
                The signing part is build into mkimage regardless of this
-               option.
+               option. The software based modular exponentiation is built into
+               mkimage irrespective of this option.
 
 - bootcount support:
                CONFIG_BOOTCOUNT_LIMIT
@@ -5899,9 +5904,10 @@ 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'
+       tools/dumpimage -i image -T type -p position data_file
+         -i ==> extract from the 'image' a specific 'data_file'
+         -T ==> set image type to 'type'
+         -p ==> 'position' (starting at 0) of the 'data_file' inside the 'image'
 
 
 Installing a Linux Image:
index f63cc5a7e9440416c351e612eb5c8615693aa037..132123bcaf1c8da5c2e029508dc3a60dca2e2531 100644 (file)
@@ -4,6 +4,7 @@ choice
 
 config ARC
        bool "ARC architecture"
+       select HAVE_PRIVATE_LIBGCC
 
 config ARM
        bool "ARM architecture"
index d3ef58be043c20d43f4807c8aa74e8f1ff8d48dc..a8dc4e2336da12aeef0c696be61267688492d925 100644 (file)
@@ -4,6 +4,77 @@ menu "ARC architecture"
 config SYS_ARCH
        default "arc"
 
+config USE_PRIVATE_LIBGCC
+       default y
+
+config SYS_CPU
+       default "arcv1"
+
+choice
+       prompt "CPU selection"
+       default CPU_ARC770D
+
+config CPU_ARC750D
+       bool "ARC 750D"
+       select ARC_MMU_V2
+       help
+         Choose this option to build an U-Boot for ARC750D CPU.
+
+config CPU_ARC770D
+       bool "ARC 770D"
+       select ARC_MMU_V3
+       help
+         Choose this option to build an U-Boot for ARC770D CPU.
+
+endchoice
+
+choice
+       prompt "MMU Version"
+       default ARC_MMU_V3 if CPU_ARC770D
+       default ARC_MMU_V2 if CPU_ARC750D
+
+config ARC_MMU_V2
+       bool "MMU v2"
+       depends on CPU_ARC750D
+       help
+         Fixed the deficiency of v1 - possible thrashing in memcpy sceanrio
+         when 2 D-TLB and 1 I-TLB entries index into same 2way set.
+
+config ARC_MMU_V3
+       bool "MMU v3"
+       depends on CPU_ARC770D
+       help
+         Introduced with ARC700 4.10: New Features
+         Variable Page size (1k-16k), var JTLB size 128 x (2 or 4)
+         Shared Address Spaces (SASID)
+
+endchoice
+
+config CPU_BIG_ENDIAN
+       bool "Enable Big Endian Mode"
+       default n
+       help
+         Build kernel for Big Endian Mode of ARC CPU
+
+config SYS_ICACHE_OFF
+       bool "Do not use Instruction Cache"
+       default n
+
+config SYS_DCACHE_OFF
+       bool "Do not use Data Cache"
+       default n
+
+config ARC_CACHE_LINE_SHIFT
+       int "Cache Line Length (as power of 2)"
+       range 5 7
+       default "6"
+       depends on !SYS_DCACHE_OFF || !SYS_DCACHE_OFF
+       help
+         Starting with ARC700 4.9, Cache line length is configurable,
+         This option specifies "N", with Line-len = 2 power N
+         So line lengths of 32, 64, 128 are specified by 5,6,7, respectively
+         Linux only supports same line lengths for I and D caches.
+
 choice
        prompt "Target select"
 
@@ -13,9 +84,6 @@ config TARGET_TB100
 config TARGET_ARCANGEL4
        bool "Support arcangel4"
 
-config TARGET_ARCANGEL4_BE
-       bool "Support arcangel4-be"
-
 config TARGET_AXS101
        bool "Support axs101"
 
index 03ea6dbae0d73d8a61e327af0e9e132b70c7028c..a59231e70ebe7a9c092b4f25ab30cf91a38ca37e 100644 (file)
@@ -2,8 +2,6 @@
 # SPDX-License-Identifier:     GPL-2.0+
 #
 
-head-y := arch/arc/cpu/$(CPU)/start.o
-
 libs-y += arch/arc/cpu/$(CPU)/
 libs-y += arch/arc/lib/
 
index e408800a919b36bc4bd64252c6b4b4602bf62118..f1e81b689502e94126c74d78c6c6bfa670e5478b 100644 (file)
@@ -4,23 +4,40 @@
 # SPDX-License-Identifier:     GPL-2.0+
 #
 
-ifndef CONFIG_SYS_BIG_ENDIAN
+ifndef CONFIG_CPU_BIG_ENDIAN
 CONFIG_SYS_LITTLE_ENDIAN = 1
+else
+CONFIG_SYS_BIG_ENDIAN = 1
 endif
 
 ifdef CONFIG_SYS_LITTLE_ENDIAN
 ARC_CROSS_COMPILE := arc-buildroot-linux-uclibc-
+PLATFORM_LDFLAGS += -EL
+PLATFORM_CPPFLAGS += -mlittle-endian
 endif
 
 ifdef CONFIG_SYS_BIG_ENDIAN
 ARC_CROSS_COMPILE := arceb-buildroot-linux-uclibc-
 PLATFORM_LDFLAGS += -EB
+PLATFORM_CPPFLAGS += -mbig-endian
 endif
 
 ifeq ($(CROSS_COMPILE),)
 CROSS_COMPILE := $(ARC_CROSS_COMPILE)
 endif
 
+ifdef CONFIG_ARC_MMU_VER
+CONFIG_MMU = 1
+endif
+
+ifdef CONFIG_CPU_ARC750D
+PLATFORM_CPPFLAGS += -marc700
+endif
+
+ifdef CONFIG_CPU_ARC770D
+PLATFORM_CPPFLAGS += -marc700 -mlock -mswape
+endif
+
 PLATFORM_CPPFLAGS += -ffixed-r25 -D__ARC__ -gdwarf-2
 
 # Needed for relocation
diff --git a/arch/arc/cpu/arc700/Makefile b/arch/arc/cpu/arc700/Makefile
deleted file mode 100644 (file)
index cdc5002..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-#
-# Copyright (C) 2013-2014 Synopsys, Inc. All rights reserved.
-#
-# SPDX-License-Identifier:     GPL-2.0+
-#
-
-extra-y        += start.o
-
-obj-y  += cache.o
-obj-y  += cpu.o
-obj-y  += interrupts.o
-obj-y  += reset.o
-obj-y  += timer.o
diff --git a/arch/arc/cpu/arc700/cache.c b/arch/arc/cpu/arc700/cache.c
deleted file mode 100644 (file)
index 39d522d..0000000
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Copyright (C) 2013-2014 Synopsys, Inc. All rights reserved.
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#include <config.h>
-#include <asm/arcregs.h>
-
-/* Bit values in IC_CTRL */
-#define IC_CTRL_CACHE_DISABLE  (1 << 0)
-
-/* Bit values in DC_CTRL */
-#define DC_CTRL_CACHE_DISABLE  (1 << 0)
-#define DC_CTRL_INV_MODE_FLUSH (1 << 6)
-#define DC_CTRL_FLUSH_STATUS   (1 << 8)
-
-int icache_status(void)
-{
-       return (read_aux_reg(ARC_AUX_IC_CTRL) & IC_CTRL_CACHE_DISABLE) !=
-              IC_CTRL_CACHE_DISABLE;
-}
-
-void icache_enable(void)
-{
-       write_aux_reg(ARC_AUX_IC_CTRL, read_aux_reg(ARC_AUX_IC_CTRL) &
-                     ~IC_CTRL_CACHE_DISABLE);
-}
-
-void icache_disable(void)
-{
-       write_aux_reg(ARC_AUX_IC_CTRL, read_aux_reg(ARC_AUX_IC_CTRL) |
-                     IC_CTRL_CACHE_DISABLE);
-}
-
-void invalidate_icache_all(void)
-{
-#ifndef CONFIG_SYS_ICACHE_OFF
-       /* Any write to IC_IVIC register triggers invalidation of entire I$ */
-       write_aux_reg(ARC_AUX_IC_IVIC, 1);
-#endif /* CONFIG_SYS_ICACHE_OFF */
-}
-
-int dcache_status(void)
-{
-       return (read_aux_reg(ARC_AUX_DC_CTRL) & DC_CTRL_CACHE_DISABLE) !=
-               DC_CTRL_CACHE_DISABLE;
-}
-
-void dcache_enable(void)
-{
-       write_aux_reg(ARC_AUX_DC_CTRL, read_aux_reg(ARC_AUX_DC_CTRL) &
-                     ~(DC_CTRL_INV_MODE_FLUSH | DC_CTRL_CACHE_DISABLE));
-}
-
-void dcache_disable(void)
-{
-       write_aux_reg(ARC_AUX_DC_CTRL, read_aux_reg(ARC_AUX_DC_CTRL) |
-                     DC_CTRL_CACHE_DISABLE);
-}
-
-void flush_dcache_all(void)
-{
-       /* Do flush of entire cache */
-       write_aux_reg(ARC_AUX_DC_FLSH, 1);
-
-       /* Wait flush end */
-       while (read_aux_reg(ARC_AUX_DC_CTRL) & DC_CTRL_FLUSH_STATUS)
-               ;
-}
-
-#ifndef CONFIG_SYS_DCACHE_OFF
-static void dcache_flush_line(unsigned addr)
-{
-#if (CONFIG_ARC_MMU_VER > 2)
-       write_aux_reg(ARC_AUX_DC_PTAG, addr);
-#endif
-       write_aux_reg(ARC_AUX_DC_FLDL, addr);
-
-       /* Wait flush end */
-       while (read_aux_reg(ARC_AUX_DC_CTRL) & DC_CTRL_FLUSH_STATUS)
-               ;
-
-#ifndef CONFIG_SYS_ICACHE_OFF
-       /*
-        * Invalidate I$ for addresses range just flushed from D$.
-        * If we try to execute data flushed above it will be valid/correct
-        */
-#if (CONFIG_ARC_MMU_VER > 2)
-       write_aux_reg(ARC_AUX_IC_PTAG, addr);
-#endif
-       write_aux_reg(ARC_AUX_IC_IVIL, addr);
-#endif /* CONFIG_SYS_ICACHE_OFF */
-}
-#endif /* CONFIG_SYS_DCACHE_OFF */
-
-void flush_dcache_range(unsigned long start, unsigned long end)
-{
-#ifndef CONFIG_SYS_DCACHE_OFF
-       unsigned int addr;
-
-       start = start & (~(CONFIG_SYS_CACHELINE_SIZE - 1));
-       end = end & (~(CONFIG_SYS_CACHELINE_SIZE - 1));
-
-       for (addr = start; addr <= end; addr += CONFIG_SYS_CACHELINE_SIZE)
-               dcache_flush_line(addr);
-#endif /* CONFIG_SYS_DCACHE_OFF */
-}
-
-void invalidate_dcache_range(unsigned long start, unsigned long end)
-{
-#ifndef CONFIG_SYS_DCACHE_OFF
-       unsigned int addr;
-
-       start = start & (~(CONFIG_SYS_CACHELINE_SIZE - 1));
-       end = end & (~(CONFIG_SYS_CACHELINE_SIZE - 1));
-
-       for (addr = start; addr <= end; addr += CONFIG_SYS_CACHELINE_SIZE) {
-#if (CONFIG_ARC_MMU_VER > 2)
-               write_aux_reg(ARC_AUX_DC_PTAG, addr);
-#endif
-               write_aux_reg(ARC_AUX_DC_IVDL, addr);
-       }
-#endif /* CONFIG_SYS_DCACHE_OFF */
-}
-
-void invalidate_dcache_all(void)
-{
-#ifndef CONFIG_SYS_DCACHE_OFF
-       /* Write 1 to DC_IVDC register triggers invalidation of entire D$ */
-       write_aux_reg(ARC_AUX_DC_IVDC, 1);
-#endif /* CONFIG_SYS_DCACHE_OFF */
-}
-
-void flush_cache(unsigned long start, unsigned long size)
-{
-       flush_dcache_range(start, start + size);
-}
diff --git a/arch/arc/cpu/arc700/config.mk b/arch/arc/cpu/arc700/config.mk
deleted file mode 100644 (file)
index 3206ff4..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-#
-# Copyright (C) 2013-2014 Synopsys, Inc. All rights reserved.
-#
-# SPDX-License-Identifier:     GPL-2.0+
-#
-
-PLATFORM_CPPFLAGS += -mA7
diff --git a/arch/arc/cpu/arc700/cpu.c b/arch/arc/cpu/arc700/cpu.c
deleted file mode 100644 (file)
index 50634b8..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2013-2014 Synopsys, Inc. All rights reserved.
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#include <common.h>
-#include <asm/arcregs.h>
-#include <asm/cache.h>
-
-DECLARE_GLOBAL_DATA_PTR;
-
-int arch_cpu_init(void)
-{
-#ifdef CONFIG_SYS_ICACHE_OFF
-       icache_disable();
-#else
-       icache_enable();
-       invalidate_icache_all();
-#endif
-
-       flush_dcache_all();
-#ifdef CONFIG_SYS_DCACHE_OFF
-       dcache_disable();
-#else
-       dcache_enable();
-#endif
-       timer_init();
-
-/* In simulation (ISS) "CHIPID" and "ARCNUM" are all "ff" */
-       if ((read_aux_reg(ARC_AUX_IDENTITY) & 0xffffff00) == 0xffffff00)
-               gd->arch.running_on_hw = 0;
-       else
-               gd->arch.running_on_hw = 1;
-
-       gd->cpu_clk = CONFIG_SYS_CLK_FREQ;
-       gd->ram_size = CONFIG_SYS_SDRAM_SIZE;
-
-       return 0;
-}
-
-int arch_early_init_r(void)
-{
-       gd->bd->bi_memstart = CONFIG_SYS_SDRAM_BASE;
-       gd->bd->bi_memsize = CONFIG_SYS_SDRAM_SIZE;
-       return 0;
-}
diff --git a/arch/arc/cpu/arc700/interrupts.c b/arch/arc/cpu/arc700/interrupts.c
deleted file mode 100644 (file)
index d93a6eb..0000000
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * Copyright (C) 2013-2014 Synopsys, Inc. All rights reserved.
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#include <common.h>
-#include <asm/arcregs.h>
-#include <asm/ptrace.h>
-
-/* Bit values in STATUS32 */
-#define E1_MASK                (1 << 1)        /* Level 1 interrupts enable */
-#define E2_MASK                (1 << 2)        /* Level 2 interrupts enable */
-
-int interrupt_init(void)
-{
-       return 0;
-}
-
-/*
- * returns true if interrupts had been enabled before we disabled them
- */
-int disable_interrupts(void)
-{
-       int status = read_aux_reg(ARC_AUX_STATUS32);
-       int state = (status | E1_MASK | E2_MASK) ? 1 : 0;
-
-       status &= ~(E1_MASK | E2_MASK);
-       /* STATUS32 register is updated indirectly with "FLAG" instruction */
-       __asm__("flag %0" : : "r" (status));
-       return state;
-}
-
-void enable_interrupts(void)
-{
-       unsigned int status = read_aux_reg(ARC_AUX_STATUS32);
-
-       status |= E1_MASK | E2_MASK;
-       /* STATUS32 register is updated indirectly with "FLAG" instruction */
-       __asm__("flag %0" : : "r" (status));
-}
-
-static void print_reg_file(long *reg_rev, int start_num)
-{
-       unsigned int i;
-
-       /* Print 3 registers per line */
-       for (i = start_num; i < start_num + 25; i++) {
-               printf("r%02u: 0x%08lx\t", i, (unsigned long)*reg_rev);
-               if (((i + 1) % 3) == 0)
-                       printf("\n");
-
-               /* Because pt_regs has registers reversed */
-               reg_rev--;
-       }
-
-       /* Add new-line if none was inserted in the end of loop above */
-       if (((i + 1) % 3) != 0)
-               printf("\n");
-}
-
-void show_regs(struct pt_regs *regs)
-{
-       printf("RET:\t0x%08lx\nBLINK:\t0x%08lx\nSTAT32:\t0x%08lx\n",
-              regs->ret, regs->blink, regs->status32);
-       printf("GP: 0x%08lx\t r25: 0x%08lx\t\n", regs->r26, regs->r25);
-       printf("BTA: 0x%08lx\t SP: 0x%08lx\t FP: 0x%08lx\n", regs->bta,
-              regs->sp, regs->fp);
-       printf("LPS: 0x%08lx\tLPE: 0x%08lx\tLPC: 0x%08lx\n", regs->lp_start,
-              regs->lp_end, regs->lp_count);
-
-       print_reg_file(&(regs->r0), 0);
-}
-
-void bad_mode(struct pt_regs *regs)
-{
-       if (regs)
-               show_regs(regs);
-
-       panic("Resetting CPU ...\n");
-}
-
-void do_memory_error(unsigned long address, struct pt_regs *regs)
-{
-       printf("Memory error exception @ 0x%lx\n", address);
-       bad_mode(regs);
-}
-
-void do_instruction_error(unsigned long address, struct pt_regs *regs)
-{
-       printf("Instruction error exception @ 0x%lx\n", address);
-       bad_mode(regs);
-}
-
-void do_machine_check_fault(unsigned long address, struct pt_regs *regs)
-{
-       printf("Machine check exception @ 0x%lx\n", address);
-       bad_mode(regs);
-}
-
-void do_interrupt_handler(void)
-{
-       printf("Interrupt fired\n");
-       bad_mode(0);
-}
-
-void do_itlb_miss(struct pt_regs *regs)
-{
-       printf("I TLB miss exception\n");
-       bad_mode(regs);
-}
-
-void do_dtlb_miss(struct pt_regs *regs)
-{
-       printf("D TLB miss exception\n");
-       bad_mode(regs);
-}
-
-void do_tlb_prot_violation(unsigned long address, struct pt_regs *regs)
-{
-       printf("TLB protection violation or misaligned access @ 0x%lx\n",
-              address);
-       bad_mode(regs);
-}
-
-void do_privilege_violation(struct pt_regs *regs)
-{
-       printf("Privilege violation exception\n");
-       bad_mode(regs);
-}
-
-void do_trap(struct pt_regs *regs)
-{
-       printf("Trap exception\n");
-       bad_mode(regs);
-}
-
-void do_extension(struct pt_regs *regs)
-{
-       printf("Extension instruction exception\n");
-       bad_mode(regs);
-}
diff --git a/arch/arc/cpu/arc700/reset.c b/arch/arc/cpu/arc700/reset.c
deleted file mode 100644 (file)
index 98ebf1d..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Copyright (C) 2013-2014 Synopsys, Inc. All rights reserved.
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#include <command.h>
-#include <common.h>
-
-int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
-{
-       printf("Put your restart handler here\n");
-
-#ifdef DEBUG
-       /* Stop debug session here */
-       __asm__("brk");
-#endif
-       return 0;
-}
diff --git a/arch/arc/cpu/arc700/start.S b/arch/arc/cpu/arc700/start.S
deleted file mode 100644 (file)
index 563513b..0000000
+++ /dev/null
@@ -1,241 +0,0 @@
-/*
- * Copyright (C) 2013-2014 Synopsys, Inc. All rights reserved.
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#include <asm-offsets.h>
-#include <config.h>
-#include <asm/arcregs.h>
-
-/*
- * Note on the LD/ST addressing modes with address register write-back
- *
- * LD.a same as LD.aw
- *
- * LD.a    reg1, [reg2, x]  => Pre Incr
- *      Eff Addr for load = [reg2 + x]
- *
- * LD.ab   reg1, [reg2, x]  => Post Incr
- *      Eff Addr for load = [reg2]
- */
-
-.macro PUSH reg
-       st.a    \reg, [%sp, -4]
-.endm
-
-.macro PUSHAX aux
-       lr      %r9, [\aux]
-       PUSH    %r9
-.endm
-
-.macro  SAVE_R1_TO_R24
-       PUSH    %r1
-       PUSH    %r2
-       PUSH    %r3
-       PUSH    %r4
-       PUSH    %r5
-       PUSH    %r6
-       PUSH    %r7
-       PUSH    %r8
-       PUSH    %r9
-       PUSH    %r10
-       PUSH    %r11
-       PUSH    %r12
-       PUSH    %r13
-       PUSH    %r14
-       PUSH    %r15
-       PUSH    %r16
-       PUSH    %r17
-       PUSH    %r18
-       PUSH    %r19
-       PUSH    %r20
-       PUSH    %r21
-       PUSH    %r22
-       PUSH    %r23
-       PUSH    %r24
-.endm
-
-.macro SAVE_ALL_SYS
-
-       st      %r0, [%sp]
-       lr      %r0, [%ecr]
-       st      %r0, [%sp, 8]   /* ECR */
-       st      %sp, [%sp, 4]
-
-       SAVE_R1_TO_R24
-       PUSH    %r25
-       PUSH    %gp
-       PUSH    %fp
-       PUSH    %blink
-       PUSHAX  %eret
-       PUSHAX  %erstatus
-       PUSH    %lp_count
-       PUSHAX  %lp_end
-       PUSHAX  %lp_start
-       PUSHAX  %erbta
-.endm
-
-.align 4
-.globl _start
-_start:
-       /* Critical system events */
-       j       reset                   /* 0 - 0x000 */
-       j       memory_error            /* 1 - 0x008 */
-       j       instruction_error       /* 2 - 0x010 */
-
-       /* Device interrupts */
-.rept  29
-       j       interrupt_handler       /* 3:31 - 0x018:0xF8 */
-.endr
-       /* Exceptions */
-       j       EV_MachineCheck         /* 0x100, Fatal Machine check  (0x20) */
-       j       EV_TLBMissI             /* 0x108, Intruction TLB miss  (0x21) */
-       j       EV_TLBMissD             /* 0x110, Data TLB miss        (0x22) */
-       j       EV_TLBProtV             /* 0x118, Protection Violation (0x23)
-                                                       or Misaligned Access  */
-       j       EV_PrivilegeV           /* 0x120, Privilege Violation  (0x24) */
-       j       EV_Trap                 /* 0x128, Trap exception       (0x25) */
-       j       EV_Extension            /* 0x130, Extn Intruction Excp (0x26) */
-
-memory_error:
-       SAVE_ALL_SYS
-       lr      %r0, [%efa]
-       mov     %r1, %sp
-       j       do_memory_error
-
-instruction_error:
-       SAVE_ALL_SYS
-       lr      %r0, [%efa]
-       mov     %r1, %sp
-       j       do_instruction_error
-
-interrupt_handler:
-       /* Todo - save and restore CPU context when interrupts will be in use */
-       bl      do_interrupt_handler
-       rtie
-
-EV_MachineCheck:
-       SAVE_ALL_SYS
-       lr      %r0, [%efa]
-       mov     %r1, %sp
-       j       do_machine_check_fault
-
-EV_TLBMissI:
-       SAVE_ALL_SYS
-       mov     %r0, %sp
-       j       do_itlb_miss
-
-EV_TLBMissD:
-       SAVE_ALL_SYS
-       mov     %r0, %sp
-       j       do_dtlb_miss
-
-EV_TLBProtV:
-       SAVE_ALL_SYS
-       lr      %r0, [%efa]
-       mov     %r1, %sp
-       j       do_tlb_prot_violation
-
-EV_PrivilegeV:
-       SAVE_ALL_SYS
-       mov     %r0, %sp
-       j       do_privilege_violation
-
-EV_Trap:
-       SAVE_ALL_SYS
-       mov     %r0, %sp
-       j       do_trap
-
-EV_Extension:
-       SAVE_ALL_SYS
-       mov     %r0, %sp
-       j       do_extension
-
-
-reset:
-       /* Setup interrupt vector base that matches "__text_start" */
-       sr      __text_start, [ARC_AUX_INTR_VEC_BASE]
-
-       /* Setup stack pointer */
-       mov     %sp, CONFIG_SYS_INIT_SP_ADDR
-       mov     %fp, %sp
-
-       /* Clear bss */
-       mov     %r0, __bss_start
-       mov     %r1, __bss_end
-
-clear_bss:
-       st.ab   0, [%r0, 4]
-       brlt    %r0, %r1, clear_bss
-
-       /* Zero the one and only argument of "board_init_f" */
-       mov_s   %r0, 0
-       j       board_init_f
-
-/*
- * void relocate_code (addr_sp, gd, addr_moni)
- *
- * This "function" does not return, instead it continues in RAM
- * after relocating the monitor code.
- *
- * r0 = start_addr_sp
- * r1 = new__gd
- * r2 = relocaddr
- */
-.align 4
-.globl relocate_code
-relocate_code:
-       /*
-        * r0-r12 might be clobbered by C functions
-        * so we use r13-r16 for storage here
-        */
-       mov     %r13, %r0               /* save addr_sp */
-       mov     %r14, %r1               /* save addr of gd */
-       mov     %r15, %r2               /* save addr of destination */
-
-       mov     %r16, %r2               /* %r9 - relocation offset */
-       sub     %r16, %r16, __image_copy_start
-
-/* Set up the stack */
-stack_setup:
-       mov     %sp, %r13
-       mov     %fp, %sp
-
-/* Check if monitor is loaded right in place for relocation */
-       mov     %r0, __image_copy_start
-       cmp     %r0, %r15               /* skip relocation if code loaded */
-       bz      do_board_init_r         /* in target location already */
-
-/* Copy data (__image_copy_start - __image_copy_end) to new location */
-       mov     %r1, %r15
-       mov     %r2, __image_copy_end
-       sub     %r2, %r2, %r0           /* r3 <- amount of bytes to copy */
-       asr     %r2, %r2, 2             /* r3 <- amount of words to copy */
-       mov     %lp_count, %r2
-       lp      copy_end
-       ld.ab   %r2,[%r0,4]
-       st.ab   %r2,[%r1,4]
-copy_end:
-
-/* Fix relocations related issues */
-       bl      do_elf_reloc_fixups
-#ifndef CONFIG_SYS_ICACHE_OFF
-       bl      invalidate_icache_all
-#endif
-#ifndef CONFIG_SYS_DCACHE_OFF
-       bl      flush_dcache_all
-#endif
-
-/* Update position of intterupt vector table */
-       lr      %r0, [ARC_AUX_INTR_VEC_BASE]    /* Read current position */
-       add     %r0, %r0, %r16                  /* Update address */
-       sr      %r0, [ARC_AUX_INTR_VEC_BASE]    /* Write new position */
-
-do_board_init_r:
-/* Prepare for exection of "board_init_r" in relocated monitor */
-       mov     %r2, board_init_r       /* old address of "board_init_r()" */
-       add     %r2, %r2, %r16          /* new address of "board_init_r()" */
-       mov     %r0, %r14               /* 1-st parameter: gd_t */
-       mov     %r1, %r15               /* 2-nd parameter: dest_addr */
-       j       [%r2]
diff --git a/arch/arc/cpu/arc700/timer.c b/arch/arc/cpu/arc700/timer.c
deleted file mode 100644 (file)
index a0acbbc..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright (C) 2013-2014 Synopsys, Inc. All rights reserved.
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#include <asm/arcregs.h>
-
-#define NH_MODE        (1 << 1)        /* Disable timer if CPU is halted */
-
-int timer_init(void)
-{
-       write_aux_reg(ARC_AUX_TIMER0_CTRL, NH_MODE);
-       /* Set max value for counter/timer */
-       write_aux_reg(ARC_AUX_TIMER0_LIMIT, 0xffffffff);
-       /* Set initial count value and restart counter/timer */
-       write_aux_reg(ARC_AUX_TIMER0_CNT, 0);
-       return 0;
-}
-
-unsigned long timer_read_counter(void)
-{
-       return read_aux_reg(ARC_AUX_TIMER0_CNT);
-}
diff --git a/arch/arc/cpu/arc700/u-boot.lds b/arch/arc/cpu/arc700/u-boot.lds
deleted file mode 100644 (file)
index 2d01b21..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (C) 2013-2014 Synopsys, Inc. All rights reserved.
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-OUTPUT_FORMAT("elf32-littlearc", "elf32-littlearc", "elf32-littlearc")
-OUTPUT_ARCH(arc)
-ENTRY(_start)
-SECTIONS
-{
-       . = ALIGN(4);
-       .text : {
-               *(.__text_start)
-               *(.__image_copy_start)
-               CPUDIR/start.o (.text*)
-               *(.text*)
-       }
-
-       . = ALIGN(4);
-       .text_end :
-       {
-               *(.__text_end)
-       }
-
-       . = ALIGN(4);
-       .rodata : {
-               *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*)))
-       }
-
-       . = ALIGN(4);
-       .data : {
-               *(.data*)
-       }
-
-       . = ALIGN(4);
-       .u_boot_list : {
-               KEEP(*(SORT(.u_boot_list*)));
-       }
-
-       . = ALIGN(4);
-       .rel_dyn_start : {
-               *(.__rel_dyn_start)
-       }
-
-       .rela.dyn : {
-               *(.rela.dyn)
-       }
-
-       .rel_dyn_end : {
-               *(.__rel_dyn_end)
-       }
-
-       . = ALIGN(4);
-       .bss_start : {
-               *(.__bss_start);
-       }
-
-       .bss : {
-               *(.bss*)
-       }
-
-       .bss_end : {
-               *(.__bss_end);
-       }
-
-       . = ALIGN(4);
-       .image_copy_end : {
-               *(.__image_copy_end)
-               *(.__init_end)
-       }
-}
diff --git a/arch/arc/cpu/arcv1/Makefile b/arch/arc/cpu/arcv1/Makefile
new file mode 100644 (file)
index 0000000..3704ebe
--- /dev/null
@@ -0,0 +1,7 @@
+#
+# Copyright (C) 2013-2014 Synopsys, Inc. All rights reserved.
+#
+# SPDX-License-Identifier:     GPL-2.0+
+#
+
+obj-y += start.o
diff --git a/arch/arc/cpu/arcv1/start.S b/arch/arc/cpu/arcv1/start.S
new file mode 100644 (file)
index 0000000..01cfba4
--- /dev/null
@@ -0,0 +1,254 @@
+/*
+ * Copyright (C) 2013-2014 Synopsys, Inc. All rights reserved.
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <asm-offsets.h>
+#include <config.h>
+#include <asm/arcregs.h>
+
+/*
+ * Note on the LD/ST addressing modes with address register write-back
+ *
+ * LD.a same as LD.aw
+ *
+ * LD.a    reg1, [reg2, x]  => Pre Incr
+ *      Eff Addr for load = [reg2 + x]
+ *
+ * LD.ab   reg1, [reg2, x]  => Post Incr
+ *      Eff Addr for load = [reg2]
+ */
+
+.macro PUSH reg
+       st.a    \reg, [%sp, -4]
+.endm
+
+.macro PUSHAX aux
+       lr      %r9, [\aux]
+       PUSH    %r9
+.endm
+
+.macro  SAVE_R1_TO_R24
+       PUSH    %r1
+       PUSH    %r2
+       PUSH    %r3
+       PUSH    %r4
+       PUSH    %r5
+       PUSH    %r6
+       PUSH    %r7
+       PUSH    %r8
+       PUSH    %r9
+       PUSH    %r10
+       PUSH    %r11
+       PUSH    %r12
+       PUSH    %r13
+       PUSH    %r14
+       PUSH    %r15
+       PUSH    %r16
+       PUSH    %r17
+       PUSH    %r18
+       PUSH    %r19
+       PUSH    %r20
+       PUSH    %r21
+       PUSH    %r22
+       PUSH    %r23
+       PUSH    %r24
+.endm
+
+.macro SAVE_ALL_SYS
+       /* saving %r0 to reg->r0 in advance since we read %ecr into it */
+       st      %r0, [%sp, -8]
+       lr      %r0, [%ecr]     /* all stack addressing is manual so far */
+       st      %r0, [%sp]
+       st      %sp, [%sp, -4]
+       /* now move %sp to reg->r0 position so we can do "push" automatically */
+       sub     %sp, %sp, 8
+
+       SAVE_R1_TO_R24
+       PUSH    %r25
+       PUSH    %gp
+       PUSH    %fp
+       PUSH    %blink
+       PUSHAX  %eret
+       PUSHAX  %erstatus
+       PUSH    %lp_count
+       PUSHAX  %lp_end
+       PUSHAX  %lp_start
+       PUSHAX  %erbta
+.endm
+
+.macro SAVE_EXCEPTION_SOURCE
+#ifdef CONFIG_MMU
+       /* If MMU exists exception faulting address is loaded in EFA reg */
+       lr      %r0, [%efa]
+#else
+       /* Otherwise in ERET (exception return) reg */
+       lr      %r0, [%eret]
+#endif
+.endm
+
+.section .ivt, "ax",@progbits
+.align 4
+_ivt:
+       /* Critical system events */
+       j       _start                  /* 0 - 0x000 */
+       j       memory_error            /* 1 - 0x008 */
+       j       instruction_error       /* 2 - 0x010 */
+
+       /* Device interrupts */
+.rept  29
+       j       interrupt_handler       /* 3:31 - 0x018:0xF8 */
+.endr
+       /* Exceptions */
+       j       EV_MachineCheck         /* 0x100, Fatal Machine check  (0x20) */
+       j       EV_TLBMissI             /* 0x108, Intruction TLB miss  (0x21) */
+       j       EV_TLBMissD             /* 0x110, Data TLB miss        (0x22) */
+       j       EV_TLBProtV             /* 0x118, Protection Violation (0x23)
+                                                       or Misaligned Access  */
+       j       EV_PrivilegeV           /* 0x120, Privilege Violation  (0x24) */
+       j       EV_Trap                 /* 0x128, Trap exception       (0x25) */
+       j       EV_Extension            /* 0x130, Extn Intruction Excp (0x26) */
+
+.text
+.globl _start
+_start:
+       /* Setup interrupt vector base that matches "__text_start" */
+       sr      __ivt_start, [ARC_AUX_INTR_VEC_BASE]
+
+       /* Setup stack pointer */
+       mov     %sp, CONFIG_SYS_INIT_SP_ADDR
+       mov     %fp, %sp
+
+       /* Clear bss */
+       mov     %r0, __bss_start
+       mov     %r1, __bss_end
+
+clear_bss:
+       st.ab   0, [%r0, 4]
+       brlt    %r0, %r1, clear_bss
+
+       /* Zero the one and only argument of "board_init_f" */
+       mov_s   %r0, 0
+       j       board_init_f
+
+memory_error:
+       SAVE_ALL_SYS
+       SAVE_EXCEPTION_SOURCE
+       mov     %r1, %sp
+       j       do_memory_error
+
+instruction_error:
+       SAVE_ALL_SYS
+       SAVE_EXCEPTION_SOURCE
+       mov     %r1, %sp
+       j       do_instruction_error
+
+interrupt_handler:
+       /* Todo - save and restore CPU context when interrupts will be in use */
+       bl      do_interrupt_handler
+       rtie
+
+EV_MachineCheck:
+       SAVE_ALL_SYS
+       SAVE_EXCEPTION_SOURCE
+       mov     %r1, %sp
+       j       do_machine_check_fault
+
+EV_TLBMissI:
+       SAVE_ALL_SYS
+       mov     %r0, %sp
+       j       do_itlb_miss
+
+EV_TLBMissD:
+       SAVE_ALL_SYS
+       mov     %r0, %sp
+       j       do_dtlb_miss
+
+EV_TLBProtV:
+       SAVE_ALL_SYS
+       SAVE_EXCEPTION_SOURCE
+       mov     %r1, %sp
+       j       do_tlb_prot_violation
+
+EV_PrivilegeV:
+       SAVE_ALL_SYS
+       mov     %r0, %sp
+       j       do_privilege_violation
+
+EV_Trap:
+       SAVE_ALL_SYS
+       mov     %r0, %sp
+       j       do_trap
+
+EV_Extension:
+       SAVE_ALL_SYS
+       mov     %r0, %sp
+       j       do_extension
+
+/*
+ * void relocate_code (addr_sp, gd, addr_moni)
+ *
+ * This "function" does not return, instead it continues in RAM
+ * after relocating the monitor code.
+ *
+ * r0 = start_addr_sp
+ * r1 = new__gd
+ * r2 = relocaddr
+ */
+.align 4
+.globl relocate_code
+relocate_code:
+       /*
+        * r0-r12 might be clobbered by C functions
+        * so we use r13-r16 for storage here
+        */
+       mov     %r13, %r0               /* save addr_sp */
+       mov     %r14, %r1               /* save addr of gd */
+       mov     %r15, %r2               /* save addr of destination */
+
+       mov     %r16, %r2               /* %r9 - relocation offset */
+       sub     %r16, %r16, __image_copy_start
+
+/* Set up the stack */
+stack_setup:
+       mov     %sp, %r13
+       mov     %fp, %sp
+
+/* Check if monitor is loaded right in place for relocation */
+       mov     %r0, __image_copy_start
+       cmp     %r0, %r15               /* skip relocation if code loaded */
+       bz      do_board_init_r         /* in target location already */
+
+/* Copy data (__image_copy_start - __image_copy_end) to new location */
+       mov     %r1, %r15
+       mov     %r2, __image_copy_end
+       sub     %r2, %r2, %r0           /* r3 <- amount of bytes to copy */
+       asr     %r2, %r2, 2             /* r3 <- amount of words to copy */
+       mov     %lp_count, %r2
+       lp      copy_end
+       ld.ab   %r2,[%r0,4]
+       st.ab   %r2,[%r1,4]
+copy_end:
+
+/* Fix relocations related issues */
+       bl      do_elf_reloc_fixups
+#ifndef CONFIG_SYS_ICACHE_OFF
+       bl      invalidate_icache_all
+#endif
+#ifndef CONFIG_SYS_DCACHE_OFF
+       bl      flush_dcache_all
+#endif
+
+/* Update position of intterupt vector table */
+       lr      %r0, [ARC_AUX_INTR_VEC_BASE]    /* Read current position */
+       add     %r0, %r0, %r16                  /* Update address */
+       sr      %r0, [ARC_AUX_INTR_VEC_BASE]    /* Write new position */
+
+do_board_init_r:
+/* Prepare for exection of "board_init_r" in relocated monitor */
+       mov     %r2, board_init_r       /* old address of "board_init_r()" */
+       add     %r2, %r2, %r16          /* new address of "board_init_r()" */
+       mov     %r0, %r14               /* 1-st parameter: gd_t */
+       mov     %r1, %r15               /* 2-nd parameter: dest_addr */
+       j       [%r2]
diff --git a/arch/arc/cpu/u-boot.lds b/arch/arc/cpu/u-boot.lds
new file mode 100644 (file)
index 0000000..ccddbf7
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2013-2014 Synopsys, Inc. All rights reserved.
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+OUTPUT_FORMAT("elf32-littlearc", "elf32-littlearc", "elf32-littlearc")
+OUTPUT_ARCH(arc)
+ENTRY(_start)
+SECTIONS
+{
+       . = ALIGN(4);
+       .text : {
+               *(.__text_start)
+               *(.__image_copy_start)
+               *(.text*)
+       }
+
+       . = ALIGN(4);
+       .text_end :
+       {
+               *(.__text_end)
+       }
+
+       . = ALIGN(1024);
+       .ivt_start : {
+               *(.__ivt_start)
+       }
+
+       .ivt :
+       {
+               *(.ivt)
+       }
+
+       .ivt_end : {
+               *(.__ivt_end)
+       }
+
+       . = ALIGN(4);
+       .rodata : {
+               *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*)))
+       }
+
+       . = ALIGN(4);
+       .data : {
+               *(.data*)
+       }
+
+       . = ALIGN(4);
+       .u_boot_list : {
+               KEEP(*(SORT(.u_boot_list*)));
+       }
+
+       . = ALIGN(4);
+       .rel_dyn_start : {
+               *(.__rel_dyn_start)
+       }
+
+       .rela.dyn : {
+               *(.rela.dyn)
+       }
+
+       .rel_dyn_end : {
+               *(.__rel_dyn_end)
+       }
+
+       . = ALIGN(4);
+       .bss_start : {
+               *(.__bss_start);
+       }
+
+       .bss : {
+               *(.bss*)
+       }
+
+       .bss_end : {
+               *(.__bss_end);
+       }
+
+       . = ALIGN(4);
+       .image_copy_end : {
+               *(.__image_copy_end)
+               *(.__init_end)
+       }
+}
index 5d48d11bab6b76e2878b69e2ecb7742dd90beca2..6a36a81c0f1545680089b9ad3c8d03ace0bff613 100644 (file)
@@ -7,6 +7,8 @@
 #ifndef _ASM_ARC_ARCREGS_H
 #define _ASM_ARC_ARCREGS_H
 
+#include <asm/cache.h>
+
 /*
  * ARC architecture has additional address space - auxiliary registers.
  * These registers are mostly used for configuration purposes.
 #define ARC_AUX_IC_IVIC                0x10
 #define ARC_AUX_IC_CTRL                0x11
 #define ARC_AUX_IC_IVIL                0x19
-#if (CONFIG_ARC_MMU_VER > 2)
+#if (CONFIG_ARC_MMU_VER == 3)
 #define ARC_AUX_IC_PTAG                0x1E
 #endif
+#define ARC_BCR_IC_BUILD       0x77
 
 /* Timer related auxiliary registers */
 #define ARC_AUX_TIMER0_CNT     0x21    /* Timer 0 count */
 #define ARC_AUX_DC_IVDL                0x4A
 #define ARC_AUX_DC_FLSH                0x4B
 #define ARC_AUX_DC_FLDL                0x4C
-#if (CONFIG_ARC_MMU_VER > 2)
+#if (CONFIG_ARC_MMU_VER == 3)
 #define ARC_AUX_DC_PTAG                0x5C
 #endif
+#define ARC_BCR_DC_BUILD       0x72
 
 #ifndef __ASSEMBLY__
 /* Accessors for auxiliary registers */
index 16e7568ef04bed4f7d51a19dbc269e4d3b950252..27259612217265ae950ec165dc34fab310657ab8 100644 (file)
@@ -9,15 +9,18 @@
 
 #include <config.h>
 
-/*
- * The current upper bound for ARC L1 data cache line sizes is 128 bytes.
- * We use that value for aligning DMA buffers unless the board config has
- * specified an alternate cache line size.
- */
-#ifdef CONFIG_SYS_CACHELINE_SIZE
-#define ARCH_DMA_MINALIGN      CONFIG_SYS_CACHELINE_SIZE
+#ifdef CONFIG_ARC_CACHE_LINE_SHIFT
+#define CONFIG_SYS_CACHELINE_SIZE      (1 << CONFIG_ARC_CACHE_LINE_SHIFT)
+#define ARCH_DMA_MINALIGN              CONFIG_SYS_CACHELINE_SIZE
 #else
-#define ARCH_DMA_MINALIGN      128
+/* Satisfy users of ARCH_DMA_MINALIGN */
+#define ARCH_DMA_MINALIGN              128
+#endif
+
+#if defined(CONFIG_ARC_MMU_V2)
+#define CONFIG_ARC_MMU_VER 2
+#elif defined(CONFIG_ARC_MMU_V3)
+#define CONFIG_ARC_MMU_VER 3
 #endif
 
 #endif /* __ASM_ARC_CACHE_H */
index e5be078c19704776e9cb986d4bf2951e6d5a6335..b4e9099fb165ec14b3815bb062604428c44702f0 100644 (file)
@@ -7,8 +7,10 @@
 #ifndef __ASM_ARC_CONFIG_H_
 #define __ASM_ARC_CONFIG_H_
 
+#define CONFIG_SYS_GENERIC_BOARD
 #define CONFIG_SYS_GENERIC_GLOBAL_DATA
 #define CONFIG_SYS_BOOT_RAMDISK_HIGH
+#define CONFIG_ARCH_EARLY_INIT_R
 
 #define CONFIG_LMB
 
index 18484a17f216e1bbce10c3b4b7ceae79e5e4595c..b8f2a859fd9a17aff0db8b97decaa39faf2e556f 100644 (file)
@@ -10,5 +10,8 @@
 #include <asm-generic/sections.h>
 
 extern ulong __text_end;
+extern ulong __ivt_start;
+extern ulong __ivt_end;
+extern ulong __image_copy_start;
 
 #endif /* __ASM_ARC_SECTIONS_H */
index 7675f855d5a964c56bd9c0c67f3d4a34c98659a7..b8028c91e11df045b29048521631191fe7cfd180 100644 (file)
@@ -4,6 +4,9 @@
 # SPDX-License-Identifier:     GPL-2.0+
 #
 
+obj-y += cache.o
+obj-y += cpu.o
+obj-y += interrupts.o
 obj-y += sections.o
 obj-y += relocate.o
 obj-y += strchr-700.o
@@ -13,4 +16,9 @@ obj-y += strlen.o
 obj-y += memcmp.o
 obj-y += memcpy-700.o
 obj-y += memset.o
+obj-y += reset.o
+obj-y += timer.o
+
 obj-$(CONFIG_CMD_BOOTM) += bootm.o
+
+lib-$(CONFIG_USE_PRIVATE_LIBGCC) += _millicodethunk.o libgcc2.o
diff --git a/arch/arc/lib/_millicodethunk.S b/arch/arc/lib/_millicodethunk.S
new file mode 100644 (file)
index 0000000..b332416
--- /dev/null
@@ -0,0 +1,226 @@
+/*
+ * Copyright (C) 1995, 1997, 2007-2013 Free Software Foundation, Inc.
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+ /* ANSI concatenation macros.  */
+
+ #define CONCAT1(a, b) CONCAT2(a, b)
+ #define CONCAT2(a, b) a ## b
+
+ /* Use the right prefix for global labels.  */
+
+ #define SYM(x) CONCAT1 (__USER_LABEL_PREFIX__, x)
+
+#ifndef WORKING_ASSEMBLER
+#define abs_l abs
+#define asl_l asl
+#define mov_l mov
+#endif
+
+#define FUNC(X)         .type SYM(X),@function
+#define HIDDEN_FUNC(X) FUNC(X)` .hidden X
+#define ENDFUNC0(X)     .Lfe_##X: .size X,.Lfe_##X-X
+#define ENDFUNC(X)      ENDFUNC0(X)
+
+       .section .text
+       .align 4
+       .global SYM(__st_r13_to_r15)
+       .global SYM(__st_r13_to_r16)
+       .global SYM(__st_r13_to_r17)
+       .global SYM(__st_r13_to_r18)
+       .global SYM(__st_r13_to_r19)
+       .global SYM(__st_r13_to_r20)
+       .global SYM(__st_r13_to_r21)
+       .global SYM(__st_r13_to_r22)
+       .global SYM(__st_r13_to_r23)
+       .global SYM(__st_r13_to_r24)
+       .global SYM(__st_r13_to_r25)
+       HIDDEN_FUNC(__st_r13_to_r15)
+       HIDDEN_FUNC(__st_r13_to_r16)
+       HIDDEN_FUNC(__st_r13_to_r17)
+       HIDDEN_FUNC(__st_r13_to_r18)
+       HIDDEN_FUNC(__st_r13_to_r19)
+       HIDDEN_FUNC(__st_r13_to_r20)
+       HIDDEN_FUNC(__st_r13_to_r21)
+       HIDDEN_FUNC(__st_r13_to_r22)
+       HIDDEN_FUNC(__st_r13_to_r23)
+       HIDDEN_FUNC(__st_r13_to_r24)
+       HIDDEN_FUNC(__st_r13_to_r25)
+       .align 4
+SYM(__st_r13_to_r25):
+       st r25, [sp,48]
+SYM(__st_r13_to_r24):
+       st r24, [sp,44]
+SYM(__st_r13_to_r23):
+       st r23, [sp,40]
+SYM(__st_r13_to_r22):
+       st r22, [sp,36]
+SYM(__st_r13_to_r21):
+       st r21, [sp,32]
+SYM(__st_r13_to_r20):
+       st r20, [sp,28]
+SYM(__st_r13_to_r19):
+       st r19, [sp,24]
+SYM(__st_r13_to_r18):
+       st r18, [sp,20]
+SYM(__st_r13_to_r17):
+       st r17, [sp,16]
+SYM(__st_r13_to_r16):
+       st r16, [sp,12]
+SYM(__st_r13_to_r15):
+#ifdef __ARC700__
+       st r15, [sp,8] ; minimum function size to avoid stall: 6 bytes.
+#else
+       st_s r15, [sp,8]
+#endif
+       st_s r14, [sp,4]
+       j_s.d [%blink]
+       st_s r13, [sp,0]
+       ENDFUNC(__st_r13_to_r15)
+       ENDFUNC(__st_r13_to_r16)
+       ENDFUNC(__st_r13_to_r17)
+       ENDFUNC(__st_r13_to_r18)
+       ENDFUNC(__st_r13_to_r19)
+       ENDFUNC(__st_r13_to_r20)
+       ENDFUNC(__st_r13_to_r21)
+       ENDFUNC(__st_r13_to_r22)
+       ENDFUNC(__st_r13_to_r23)
+       ENDFUNC(__st_r13_to_r24)
+       ENDFUNC(__st_r13_to_r25)
+
+       .section .text
+       .align 4
+;      ==================================
+;      the loads
+
+       .global SYM(__ld_r13_to_r15)
+       .global SYM(__ld_r13_to_r16)
+       .global SYM(__ld_r13_to_r17)
+       .global SYM(__ld_r13_to_r18)
+       .global SYM(__ld_r13_to_r19)
+       .global SYM(__ld_r13_to_r20)
+       .global SYM(__ld_r13_to_r21)
+       .global SYM(__ld_r13_to_r22)
+       .global SYM(__ld_r13_to_r23)
+       .global SYM(__ld_r13_to_r24)
+       .global SYM(__ld_r13_to_r25)
+       HIDDEN_FUNC(__ld_r13_to_r15)
+       HIDDEN_FUNC(__ld_r13_to_r16)
+       HIDDEN_FUNC(__ld_r13_to_r17)
+       HIDDEN_FUNC(__ld_r13_to_r18)
+       HIDDEN_FUNC(__ld_r13_to_r19)
+       HIDDEN_FUNC(__ld_r13_to_r20)
+       HIDDEN_FUNC(__ld_r13_to_r21)
+       HIDDEN_FUNC(__ld_r13_to_r22)
+       HIDDEN_FUNC(__ld_r13_to_r23)
+       HIDDEN_FUNC(__ld_r13_to_r24)
+       HIDDEN_FUNC(__ld_r13_to_r25)
+SYM(__ld_r13_to_r25):
+       ld r25, [sp,48]
+SYM(__ld_r13_to_r24):
+       ld r24, [sp,44]
+SYM(__ld_r13_to_r23):
+       ld r23, [sp,40]
+SYM(__ld_r13_to_r22):
+       ld r22, [sp,36]
+SYM(__ld_r13_to_r21):
+       ld r21, [sp,32]
+SYM(__ld_r13_to_r20):
+       ld r20, [sp,28]
+SYM(__ld_r13_to_r19):
+       ld r19, [sp,24]
+SYM(__ld_r13_to_r18):
+       ld r18, [sp,20]
+SYM(__ld_r13_to_r17):
+       ld r17, [sp,16]
+SYM(__ld_r13_to_r16):
+       ld r16, [sp,12]
+SYM(__ld_r13_to_r15):
+#ifdef __ARC700__
+       ld r15, [sp,8] ; minimum function size to avoid stall: 6 bytes.
+#else
+       ld_s r15, [sp,8]
+#endif
+       ld_s r14, [sp,4]
+       j_s.d [%blink]
+       ld_s r13, [sp,0]
+       ENDFUNC(__ld_r13_to_r15)
+       ENDFUNC(__ld_r13_to_r16)
+       ENDFUNC(__ld_r13_to_r17)
+       ENDFUNC(__ld_r13_to_r18)
+       ENDFUNC(__ld_r13_to_r19)
+       ENDFUNC(__ld_r13_to_r20)
+       ENDFUNC(__ld_r13_to_r21)
+       ENDFUNC(__ld_r13_to_r22)
+       ENDFUNC(__ld_r13_to_r23)
+       ENDFUNC(__ld_r13_to_r24)
+       ENDFUNC(__ld_r13_to_r25)
+
+       .global SYM(__ld_r13_to_r14_ret)
+       .global SYM(__ld_r13_to_r15_ret)
+       .global SYM(__ld_r13_to_r16_ret)
+       .global SYM(__ld_r13_to_r17_ret)
+       .global SYM(__ld_r13_to_r18_ret)
+       .global SYM(__ld_r13_to_r19_ret)
+       .global SYM(__ld_r13_to_r20_ret)
+       .global SYM(__ld_r13_to_r21_ret)
+       .global SYM(__ld_r13_to_r22_ret)
+       .global SYM(__ld_r13_to_r23_ret)
+       .global SYM(__ld_r13_to_r24_ret)
+       .global SYM(__ld_r13_to_r25_ret)
+       HIDDEN_FUNC(__ld_r13_to_r14_ret)
+       HIDDEN_FUNC(__ld_r13_to_r15_ret)
+       HIDDEN_FUNC(__ld_r13_to_r16_ret)
+       HIDDEN_FUNC(__ld_r13_to_r17_ret)
+       HIDDEN_FUNC(__ld_r13_to_r18_ret)
+       HIDDEN_FUNC(__ld_r13_to_r19_ret)
+       HIDDEN_FUNC(__ld_r13_to_r20_ret)
+       HIDDEN_FUNC(__ld_r13_to_r21_ret)
+       HIDDEN_FUNC(__ld_r13_to_r22_ret)
+       HIDDEN_FUNC(__ld_r13_to_r23_ret)
+       HIDDEN_FUNC(__ld_r13_to_r24_ret)
+       HIDDEN_FUNC(__ld_r13_to_r25_ret)
+       .section .text
+       .align 4
+SYM(__ld_r13_to_r25_ret):
+       ld r25, [sp,48]
+SYM(__ld_r13_to_r24_ret):
+       ld r24, [sp,44]
+SYM(__ld_r13_to_r23_ret):
+       ld r23, [sp,40]
+SYM(__ld_r13_to_r22_ret):
+       ld r22, [sp,36]
+SYM(__ld_r13_to_r21_ret):
+       ld r21, [sp,32]
+SYM(__ld_r13_to_r20_ret):
+       ld r20, [sp,28]
+SYM(__ld_r13_to_r19_ret):
+       ld r19, [sp,24]
+SYM(__ld_r13_to_r18_ret):
+       ld r18, [sp,20]
+SYM(__ld_r13_to_r17_ret):
+       ld r17, [sp,16]
+SYM(__ld_r13_to_r16_ret):
+       ld r16, [sp,12]
+SYM(__ld_r13_to_r15_ret):
+       ld r15, [sp,8]
+SYM(__ld_r13_to_r14_ret):
+       ld blink,[sp,r12]
+       ld_s r14, [sp,4]
+       ld.ab r13, [sp,r12]
+       j_s.d [%blink]
+       add_s sp,sp,4
+       ENDFUNC(__ld_r13_to_r14_ret)
+       ENDFUNC(__ld_r13_to_r15_ret)
+       ENDFUNC(__ld_r13_to_r16_ret)
+       ENDFUNC(__ld_r13_to_r17_ret)
+       ENDFUNC(__ld_r13_to_r18_ret)
+       ENDFUNC(__ld_r13_to_r19_ret)
+       ENDFUNC(__ld_r13_to_r20_ret)
+       ENDFUNC(__ld_r13_to_r21_ret)
+       ENDFUNC(__ld_r13_to_r22_ret)
+       ENDFUNC(__ld_r13_to_r23_ret)
+       ENDFUNC(__ld_r13_to_r24_ret)
+       ENDFUNC(__ld_r13_to_r25_ret)
diff --git a/arch/arc/lib/cache.c b/arch/arc/lib/cache.c
new file mode 100644 (file)
index 0000000..a227723
--- /dev/null
@@ -0,0 +1,168 @@
+/*
+ * Copyright (C) 2013-2014 Synopsys, Inc. All rights reserved.
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <config.h>
+#include <asm/arcregs.h>
+#include <asm/cache.h>
+
+/* Bit values in IC_CTRL */
+#define IC_CTRL_CACHE_DISABLE  (1 << 0)
+
+/* Bit values in DC_CTRL */
+#define DC_CTRL_CACHE_DISABLE  (1 << 0)
+#define DC_CTRL_INV_MODE_FLUSH (1 << 6)
+#define DC_CTRL_FLUSH_STATUS   (1 << 8)
+#define CACHE_VER_NUM_MASK     0xF
+
+int icache_status(void)
+{
+       /* If no cache in CPU exit immediately */
+       if (!(read_aux_reg(ARC_BCR_IC_BUILD) & CACHE_VER_NUM_MASK))
+               return 0;
+
+       return (read_aux_reg(ARC_AUX_IC_CTRL) & IC_CTRL_CACHE_DISABLE) !=
+              IC_CTRL_CACHE_DISABLE;
+}
+
+void icache_enable(void)
+{
+       /* If no cache in CPU exit immediately */
+       if (!(read_aux_reg(ARC_BCR_IC_BUILD) & CACHE_VER_NUM_MASK))
+               return;
+
+       write_aux_reg(ARC_AUX_IC_CTRL, read_aux_reg(ARC_AUX_IC_CTRL) &
+                     ~IC_CTRL_CACHE_DISABLE);
+}
+
+void icache_disable(void)
+{
+       /* If no cache in CPU exit immediately */
+       if (!(read_aux_reg(ARC_BCR_IC_BUILD) & CACHE_VER_NUM_MASK))
+               return;
+
+       write_aux_reg(ARC_AUX_IC_CTRL, read_aux_reg(ARC_AUX_IC_CTRL) |
+                     IC_CTRL_CACHE_DISABLE);
+}
+
+void invalidate_icache_all(void)
+{
+#ifndef CONFIG_SYS_ICACHE_OFF
+       /* Any write to IC_IVIC register triggers invalidation of entire I$ */
+       write_aux_reg(ARC_AUX_IC_IVIC, 1);
+#endif /* CONFIG_SYS_ICACHE_OFF */
+}
+
+int dcache_status(void)
+{
+       /* If no cache in CPU exit immediately */
+       if (!(read_aux_reg(ARC_BCR_DC_BUILD) & CACHE_VER_NUM_MASK))
+               return 0;
+
+       return (read_aux_reg(ARC_AUX_DC_CTRL) & DC_CTRL_CACHE_DISABLE) !=
+               DC_CTRL_CACHE_DISABLE;
+}
+
+void dcache_enable(void)
+{
+       /* If no cache in CPU exit immediately */
+       if (!(read_aux_reg(ARC_BCR_DC_BUILD) & CACHE_VER_NUM_MASK))
+               return;
+
+       write_aux_reg(ARC_AUX_DC_CTRL, read_aux_reg(ARC_AUX_DC_CTRL) &
+                     ~(DC_CTRL_INV_MODE_FLUSH | DC_CTRL_CACHE_DISABLE));
+}
+
+void dcache_disable(void)
+{
+       /* If no cache in CPU exit immediately */
+       if (!(read_aux_reg(ARC_BCR_DC_BUILD) & CACHE_VER_NUM_MASK))
+               return;
+
+       write_aux_reg(ARC_AUX_DC_CTRL, read_aux_reg(ARC_AUX_DC_CTRL) |
+                     DC_CTRL_CACHE_DISABLE);
+}
+
+void flush_dcache_all(void)
+{
+       /* If no cache in CPU exit immediately */
+       if (!(read_aux_reg(ARC_BCR_DC_BUILD) & CACHE_VER_NUM_MASK))
+               return;
+
+       /* Do flush of entire cache */
+       write_aux_reg(ARC_AUX_DC_FLSH, 1);
+
+       /* Wait flush end */
+       while (read_aux_reg(ARC_AUX_DC_CTRL) & DC_CTRL_FLUSH_STATUS)
+               ;
+}
+
+#ifndef CONFIG_SYS_DCACHE_OFF
+static void dcache_flush_line(unsigned addr)
+{
+#if (CONFIG_ARC_MMU_VER == 3)
+       write_aux_reg(ARC_AUX_DC_PTAG, addr);
+#endif
+       write_aux_reg(ARC_AUX_DC_FLDL, addr);
+
+       /* Wait flush end */
+       while (read_aux_reg(ARC_AUX_DC_CTRL) & DC_CTRL_FLUSH_STATUS)
+               ;
+
+#ifndef CONFIG_SYS_ICACHE_OFF
+       /*
+        * Invalidate I$ for addresses range just flushed from D$.
+        * If we try to execute data flushed above it will be valid/correct
+        */
+#if (CONFIG_ARC_MMU_VER == 3)
+       write_aux_reg(ARC_AUX_IC_PTAG, addr);
+#endif
+       write_aux_reg(ARC_AUX_IC_IVIL, addr);
+#endif /* CONFIG_SYS_ICACHE_OFF */
+}
+#endif /* CONFIG_SYS_DCACHE_OFF */
+
+void flush_dcache_range(unsigned long start, unsigned long end)
+{
+#ifndef CONFIG_SYS_DCACHE_OFF
+       unsigned int addr;
+
+       start = start & (~(CONFIG_SYS_CACHELINE_SIZE - 1));
+       end = end & (~(CONFIG_SYS_CACHELINE_SIZE - 1));
+
+       for (addr = start; addr <= end; addr += CONFIG_SYS_CACHELINE_SIZE)
+               dcache_flush_line(addr);
+#endif /* CONFIG_SYS_DCACHE_OFF */
+}
+
+void invalidate_dcache_range(unsigned long start, unsigned long end)
+{
+#ifndef CONFIG_SYS_DCACHE_OFF
+       unsigned int addr;
+
+       start = start & (~(CONFIG_SYS_CACHELINE_SIZE - 1));
+       end = end & (~(CONFIG_SYS_CACHELINE_SIZE - 1));
+
+       for (addr = start; addr <= end; addr += CONFIG_SYS_CACHELINE_SIZE) {
+#if (CONFIG_ARC_MMU_VER == 3)
+               write_aux_reg(ARC_AUX_DC_PTAG, addr);
+#endif
+               write_aux_reg(ARC_AUX_DC_IVDL, addr);
+       }
+#endif /* CONFIG_SYS_DCACHE_OFF */
+}
+
+void invalidate_dcache_all(void)
+{
+#ifndef CONFIG_SYS_DCACHE_OFF
+       /* Write 1 to DC_IVDC register triggers invalidation of entire D$ */
+       write_aux_reg(ARC_AUX_DC_IVDC, 1);
+#endif /* CONFIG_SYS_DCACHE_OFF */
+}
+
+void flush_cache(unsigned long start, unsigned long size)
+{
+       flush_dcache_range(start, start + size);
+}
diff --git a/arch/arc/lib/cpu.c b/arch/arc/lib/cpu.c
new file mode 100644 (file)
index 0000000..50634b8
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2013-2014 Synopsys, Inc. All rights reserved.
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <common.h>
+#include <asm/arcregs.h>
+#include <asm/cache.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+int arch_cpu_init(void)
+{
+#ifdef CONFIG_SYS_ICACHE_OFF
+       icache_disable();
+#else
+       icache_enable();
+       invalidate_icache_all();
+#endif
+
+       flush_dcache_all();
+#ifdef CONFIG_SYS_DCACHE_OFF
+       dcache_disable();
+#else
+       dcache_enable();
+#endif
+       timer_init();
+
+/* In simulation (ISS) "CHIPID" and "ARCNUM" are all "ff" */
+       if ((read_aux_reg(ARC_AUX_IDENTITY) & 0xffffff00) == 0xffffff00)
+               gd->arch.running_on_hw = 0;
+       else
+               gd->arch.running_on_hw = 1;
+
+       gd->cpu_clk = CONFIG_SYS_CLK_FREQ;
+       gd->ram_size = CONFIG_SYS_SDRAM_SIZE;
+
+       return 0;
+}
+
+int arch_early_init_r(void)
+{
+       gd->bd->bi_memstart = CONFIG_SYS_SDRAM_BASE;
+       gd->bd->bi_memsize = CONFIG_SYS_SDRAM_SIZE;
+       return 0;
+}
diff --git a/arch/arc/lib/interrupts.c b/arch/arc/lib/interrupts.c
new file mode 100644 (file)
index 0000000..d7cab3b
--- /dev/null
@@ -0,0 +1,143 @@
+/*
+ * Copyright (C) 2013-2014 Synopsys, Inc. All rights reserved.
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <common.h>
+#include <asm/arcregs.h>
+#include <asm/ptrace.h>
+
+/* Bit values in STATUS32 */
+#define E1_MASK                (1 << 1)        /* Level 1 interrupts enable */
+#define E2_MASK                (1 << 2)        /* Level 2 interrupts enable */
+
+int interrupt_init(void)
+{
+       return 0;
+}
+
+/*
+ * returns true if interrupts had been enabled before we disabled them
+ */
+int disable_interrupts(void)
+{
+       int status = read_aux_reg(ARC_AUX_STATUS32);
+       int state = (status & (E1_MASK | E2_MASK)) ? 1 : 0;
+
+       status &= ~(E1_MASK | E2_MASK);
+       /* STATUS32 register is updated indirectly with "FLAG" instruction */
+       __asm__("flag %0" : : "r" (status));
+       return state;
+}
+
+void enable_interrupts(void)
+{
+       unsigned int status = read_aux_reg(ARC_AUX_STATUS32);
+
+       status |= E1_MASK | E2_MASK;
+       /* STATUS32 register is updated indirectly with "FLAG" instruction */
+       __asm__("flag %0" : : "r" (status));
+}
+
+static void print_reg_file(long *reg_rev, int start_num)
+{
+       unsigned int i;
+
+       /* Print 3 registers per line */
+       for (i = start_num; i < start_num + 25; i++) {
+               printf("r%02u: 0x%08lx\t", i, (unsigned long)*reg_rev);
+               if (((i + 1) % 3) == 0)
+                       printf("\n");
+
+               /* Because pt_regs has registers reversed */
+               reg_rev--;
+       }
+
+       /* Add new-line if none was inserted in the end of loop above */
+       if (((i + 1) % 3) != 0)
+               printf("\n");
+}
+
+void show_regs(struct pt_regs *regs)
+{
+       printf("ECR:\t0x%08lx\n", regs->ecr);
+       printf("RET:\t0x%08lx\nBLINK:\t0x%08lx\nSTAT32:\t0x%08lx\n",
+              regs->ret, regs->blink, regs->status32);
+       printf("GP: 0x%08lx\t r25: 0x%08lx\t\n", regs->r26, regs->r25);
+       printf("BTA: 0x%08lx\t SP: 0x%08lx\t FP: 0x%08lx\n", regs->bta,
+              regs->sp, regs->fp);
+       printf("LPS: 0x%08lx\tLPE: 0x%08lx\tLPC: 0x%08lx\n", regs->lp_start,
+              regs->lp_end, regs->lp_count);
+
+       print_reg_file(&(regs->r0), 0);
+}
+
+void bad_mode(struct pt_regs *regs)
+{
+       if (regs)
+               show_regs(regs);
+
+       panic("Resetting CPU ...\n");
+}
+
+void do_memory_error(unsigned long address, struct pt_regs *regs)
+{
+       printf("Memory error exception @ 0x%lx\n", address);
+       bad_mode(regs);
+}
+
+void do_instruction_error(unsigned long address, struct pt_regs *regs)
+{
+       printf("Instruction error exception @ 0x%lx\n", address);
+       bad_mode(regs);
+}
+
+void do_machine_check_fault(unsigned long address, struct pt_regs *regs)
+{
+       printf("Machine check exception @ 0x%lx\n", address);
+       bad_mode(regs);
+}
+
+void do_interrupt_handler(void)
+{
+       printf("Interrupt fired\n");
+       bad_mode(0);
+}
+
+void do_itlb_miss(struct pt_regs *regs)
+{
+       printf("I TLB miss exception\n");
+       bad_mode(regs);
+}
+
+void do_dtlb_miss(struct pt_regs *regs)
+{
+       printf("D TLB miss exception\n");
+       bad_mode(regs);
+}
+
+void do_tlb_prot_violation(unsigned long address, struct pt_regs *regs)
+{
+       printf("TLB protection violation or misaligned access @ 0x%lx\n",
+              address);
+       bad_mode(regs);
+}
+
+void do_privilege_violation(struct pt_regs *regs)
+{
+       printf("Privilege violation exception\n");
+       bad_mode(regs);
+}
+
+void do_trap(struct pt_regs *regs)
+{
+       printf("Trap exception\n");
+       bad_mode(regs);
+}
+
+void do_extension(struct pt_regs *regs)
+{
+       printf("Extension instruction exception\n");
+       bad_mode(regs);
+}
diff --git a/arch/arc/lib/libgcc2.c b/arch/arc/lib/libgcc2.c
new file mode 100644 (file)
index 0000000..d5ad327
--- /dev/null
@@ -0,0 +1,161 @@
+/*
+ * Copyright (C) 1989-2013 Free Software Foundation, Inc.
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include "libgcc2.h"
+
+DWtype
+__ashldi3(DWtype u, shift_count_type b)
+{
+       if (b == 0)
+               return u;
+
+       const DWunion uu = {.ll = u};
+       const shift_count_type bm = W_TYPE_SIZE - b;
+       DWunion w;
+
+       if (bm <= 0) {
+               w.s.low = 0;
+               w.s.high = (UWtype)uu.s.low << -bm;
+       } else {
+               const UWtype carries = (UWtype) uu.s.low >> bm;
+
+               w.s.low = (UWtype)uu.s.low << b;
+               w.s.high = ((UWtype)uu.s.high << b) | carries;
+       }
+
+       return w.ll;
+}
+
+DWtype
+__ashrdi3(DWtype u, shift_count_type b)
+{
+       if (b == 0)
+               return u;
+
+       const DWunion uu = {.ll = u};
+       const shift_count_type bm = W_TYPE_SIZE - b;
+       DWunion w;
+
+       if (bm <= 0) {
+               /* w.s.high = 1..1 or 0..0 */
+               w.s.high = uu.s.high >> (W_TYPE_SIZE - 1);
+               w.s.low = uu.s.high >> -bm;
+       } else {
+               const UWtype carries = (UWtype) uu.s.high << bm;
+
+               w.s.high = uu.s.high >> b;
+               w.s.low = ((UWtype)uu.s.low >> b) | carries;
+       }
+
+       return w.ll;
+}
+
+DWtype
+__lshrdi3(DWtype u, shift_count_type b)
+{
+       if (b == 0)
+               return u;
+
+       const DWunion uu = {.ll = u};
+       const shift_count_type bm = W_TYPE_SIZE - b;
+       DWunion w;
+
+       if (bm <= 0) {
+               w.s.high = 0;
+               w.s.low = (UWtype)uu.s.high >> -bm;
+       } else {
+               const UWtype carries = (UWtype)uu.s.high << bm;
+
+               w.s.high = (UWtype)uu.s.high >> b;
+               w.s.low = ((UWtype)uu.s.low >> b) | carries;
+       }
+
+       return w.ll;
+}
+
+unsigned long
+udivmodsi4(unsigned long num, unsigned long den, int modwanted)
+{
+       unsigned long bit = 1;
+       unsigned long res = 0;
+
+       while (den < num && bit && !(den & (1L<<31))) {
+               den <<= 1;
+               bit <<= 1;
+       }
+
+       while (bit) {
+               if (num >= den) {
+                       num -= den;
+                       res |= bit;
+               }
+               bit >>= 1;
+               den >>= 1;
+       }
+
+       if (modwanted)
+               return num;
+
+       return res;
+}
+
+long
+__divsi3(long a, long b)
+{
+       int neg = 0;
+       long res;
+
+       if (a < 0) {
+               a = -a;
+               neg = !neg;
+       }
+
+       if (b < 0) {
+               b = -b;
+               neg = !neg;
+       }
+
+       res = udivmodsi4(a, b, 0);
+
+       if (neg)
+               res = -res;
+
+       return res;
+}
+
+long
+__modsi3(long a, long b)
+{
+       int neg = 0;
+       long res;
+
+       if (a < 0) {
+               a = -a;
+               neg = 1;
+       }
+
+       if (b < 0)
+               b = -b;
+
+       res = udivmodsi4(a, b, 1);
+
+       if (neg)
+               res = -res;
+
+       return res;
+}
+
+long
+__udivsi3(long a, long b)
+{
+       return udivmodsi4(a, b, 0);
+}
+
+long
+__umodsi3(long a, long b)
+{
+       return udivmodsi4(a, b, 1);
+}
diff --git a/arch/arc/lib/libgcc2.h b/arch/arc/lib/libgcc2.h
new file mode 100644 (file)
index 0000000..8813c3b
--- /dev/null
@@ -0,0 +1,132 @@
+/*
+ * Copyright (C) 1989-2013 Free Software Foundation, Inc.
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#ifndef __ASM_LIBGCC_H
+#define __ASM_LIBGCC_H
+
+#define UNITS_PER_WORD 4       /* for ARC */
+#define BITS_PER_UNIT 8                /* for ARC */
+
+#define W_TYPE_SIZE (4 * BITS_PER_UNIT)
+
+#define MIN_UNITS_PER_WORD UNITS_PER_WORD
+
+/* Work out the largest "word" size that we can deal with on this target.  */
+#if MIN_UNITS_PER_WORD > 4
+# define LIBGCC2_MAX_UNITS_PER_WORD 8
+#elif (MIN_UNITS_PER_WORD > 2 \
+       || (MIN_UNITS_PER_WORD > 1 && __SIZEOF_LONG_LONG__ > 4))
+# define LIBGCC2_MAX_UNITS_PER_WORD 4
+#else
+# define LIBGCC2_MAX_UNITS_PER_WORD MIN_UNITS_PER_WORD
+#endif
+
+/* Work out what word size we are using for this compilation.
+   The value can be set on the command line.  */
+#ifndef LIBGCC2_UNITS_PER_WORD
+#define LIBGCC2_UNITS_PER_WORD LIBGCC2_MAX_UNITS_PER_WORD
+#endif
+
+typedef                 int QItype     __attribute__ ((mode (QI)));
+typedef unsigned int UQItype   __attribute__ ((mode (QI)));
+typedef                 int HItype     __attribute__ ((mode (HI)));
+typedef unsigned int UHItype   __attribute__ ((mode (HI)));
+#if MIN_UNITS_PER_WORD > 1
+/* These typedefs are usually forbidden on dsp's with UNITS_PER_WORD 1.  */
+typedef         int SItype     __attribute__ ((mode (SI)));
+typedef unsigned int USItype   __attribute__ ((mode (SI)));
+#if __SIZEOF_LONG_LONG__ > 4
+/* These typedefs are usually forbidden on archs with UNITS_PER_WORD 2.  */
+typedef                 int DItype     __attribute__ ((mode (DI)));
+typedef unsigned int UDItype   __attribute__ ((mode (DI)));
+#if MIN_UNITS_PER_WORD > 4
+/* These typedefs are usually forbidden on archs with UNITS_PER_WORD 4.  */
+typedef                 int TItype     __attribute__ ((mode (TI)));
+typedef unsigned int UTItype   __attribute__ ((mode (TI)));
+#endif
+#endif
+#endif
+
+#if LIBGCC2_UNITS_PER_WORD == 8
+#define W_TYPE_SIZE (8 * BITS_PER_UNIT)
+#define Wtype  DItype
+#define UWtype UDItype
+#define HWtype DItype
+#define UHWtype        UDItype
+#define DWtype TItype
+#define UDWtype        UTItype
+#ifdef LIBGCC2_GNU_PREFIX
+#define __NW(a,b)      __gnu_ ## a ## di ## b
+#define __NDW(a,b)     __gnu_ ## a ## ti ## b
+#else
+#define __NW(a,b)      __ ## a ## di ## b
+#define __NDW(a,b)     __ ## a ## ti ## b
+#endif
+#elif LIBGCC2_UNITS_PER_WORD == 4
+#define W_TYPE_SIZE (4 * BITS_PER_UNIT)
+#define Wtype  SItype
+#define UWtype USItype
+#define HWtype SItype
+#define UHWtype        USItype
+#define DWtype DItype
+#define UDWtype        UDItype
+#ifdef LIBGCC2_GNU_PREFIX
+#define __NW(a,b)      __gnu_ ## a ## si ## b
+#define __NDW(a,b)     __gnu_ ## a ## di ## b
+#else
+#define __NW(a,b)      __ ## a ## si ## b
+#define __NDW(a,b)     __ ## a ## di ## b
+#endif
+#elif LIBGCC2_UNITS_PER_WORD == 2
+#define W_TYPE_SIZE (2 * BITS_PER_UNIT)
+#define Wtype  HItype
+#define UWtype UHItype
+#define HWtype HItype
+#define UHWtype        UHItype
+#define DWtype SItype
+#define UDWtype        USItype
+#ifdef LIBGCC2_GNU_PREFIX
+#define __NW(a,b)      __gnu_ ## a ## hi ## b
+#define __NDW(a,b)     __gnu_ ## a ## si ## b
+#else
+#define __NW(a,b)      __ ## a ## hi ## b
+#define __NDW(a,b)     __ ## a ## si ## b
+#endif
+#else
+#define W_TYPE_SIZE BITS_PER_UNIT
+#define Wtype  QItype
+#define UWtype  UQItype
+#define HWtype QItype
+#define UHWtype        UQItype
+#define DWtype HItype
+#define UDWtype        UHItype
+#ifdef LIBGCC2_GNU_PREFIX
+#define __NW(a,b)      __gnu_ ## a ## qi ## b
+#define __NDW(a,b)     __gnu_ ## a ## hi ## b
+#else
+#define __NW(a,b)      __ ## a ## qi ## b
+#define __NDW(a,b)     __ ## a ## hi ## b
+#endif
+#endif
+
+typedef int shift_count_type __attribute__((mode (__libgcc_shift_count__)));
+
+#if __BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__
+       struct DWstruct {Wtype high, low;};
+#else
+       struct DWstruct {Wtype low, high;};
+#endif
+
+/* We need this union to unpack/pack DImode values, since we don't have
+   any arithmetic yet.  Incoming DImode parameters are stored into the
+   `ll' field, and the unpacked result is read from the struct `s'.  */
+
+typedef union {
+       struct DWstruct s;
+       DWtype ll;
+} DWunion;
+
+#endif /* __ASM_LIBGCC_H */
index fa5aac5f6743ee83a2f7a79e8a84811710ea2127..87bccab51d74c92f0239237cfe12eefa2c6864c6 100644 (file)
@@ -29,6 +29,7 @@ memcmp:
        ld.a    %r4, [%r0, 8]
        ld.a    %r5, [%r1, 8]
        brne    WORD2, %r12, .Lodd
+       nop
 .Loop_end:
        asl_s   SHIFT, SHIFT, 3
        bhs_s   .Last_cmp
@@ -105,6 +106,7 @@ memcmp:
        ldb.a   %r4, [%r0, 2]
        ldb.a   %r5, [%r1, 2]
        brne    %r3, %r12, .Lbyte_odd
+       nop
 .Lbyte_end:
        bcc     .Lbyte_even
        brne    %r4, %r5, .Lbyte_even
index 2482bcdffcc33103e913a5dc8ee33e0923278b18..7797782563bb7f6dc736440fa6fa7aa0818a9e5a 100644 (file)
@@ -26,7 +26,7 @@ int do_elf_reloc_fixups(void)
                offset_ptr_rom = (Elf32_Addr *)re_src->r_offset;
 
                /* Check that the location of the relocation is in .text */
-               if (offset_ptr_rom >= (Elf32_Addr *)CONFIG_SYS_TEXT_BASE &&
+               if (offset_ptr_rom >= (Elf32_Addr *)&__image_copy_start &&
                    offset_ptr_rom > last_offset) {
                        unsigned int val;
                        /* Switch to the in-RAM version */
@@ -44,29 +44,22 @@ int do_elf_reloc_fixups(void)
 #ifdef __LITTLE_ENDIAN__
                        /* If location in ".text" section swap value */
                        if ((unsigned int)offset_ptr_rom <
-                           (unsigned int)&__text_end)
+                           (unsigned int)&__ivt_end)
                                val = (val << 16) | (val >> 16);
 #endif
 
-                       /* Check that the target points into .text */
-                       if (val >= CONFIG_SYS_TEXT_BASE && val <=
-                           (unsigned int)&__bss_end) {
+                       /* Check that the target points into executable */
+                       if (val >= (unsigned int)&__image_copy_start && val <=
+                           (unsigned int)&__image_copy_end) {
                                val += gd->reloc_off;
 #ifdef __LITTLE_ENDIAN__
                                /* If location in ".text" section swap value */
                                if ((unsigned int)offset_ptr_rom <
-                                   (unsigned int)&__text_end)
+                                   (unsigned int)&__ivt_end)
                                        val = (val << 16) | (val >> 16);
 #endif
                                memcpy(offset_ptr_ram, &val, sizeof(int));
-                       } else {
-                               debug("   %p: rom reloc %x, ram %p, value %x, limit %x\n",
-                                     re_src, re_src->r_offset, offset_ptr_ram,
-                                     val, (unsigned int)&__bss_end);
                        }
-               } else {
-                       debug("   %p: rom reloc %x, last %p\n", re_src,
-                             re_src->r_offset, last_offset);
                }
                last_offset = offset_ptr_rom;
 
diff --git a/arch/arc/lib/reset.c b/arch/arc/lib/reset.c
new file mode 100644 (file)
index 0000000..98ebf1d
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2013-2014 Synopsys, Inc. All rights reserved.
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <command.h>
+#include <common.h>
+
+int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
+{
+       printf("Put your restart handler here\n");
+
+#ifdef DEBUG
+       /* Stop debug session here */
+       __asm__("brk");
+#endif
+       return 0;
+}
index b0b46a4e9aeeffdc62c8afaabba74151f17f363a..a72c6946d53e5913b619b4178340e5401191b276 100644 (file)
@@ -19,3 +19,5 @@ char __rel_dyn_end[0] __attribute__((section(".__rel_dyn_end")));
 char __text_start[0] __attribute__((section(".__text_start")));
 char __text_end[0] __attribute__((section(".__text_end")));
 char __init_end[0] __attribute__((section(".__init_end")));
+char __ivt_start[0] __attribute__((section(".__ivt_start")));
+char __ivt_end[0] __attribute__((section(".__ivt_end")));
diff --git a/arch/arc/lib/timer.c b/arch/arc/lib/timer.c
new file mode 100644 (file)
index 0000000..a0acbbc
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2013-2014 Synopsys, Inc. All rights reserved.
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <asm/arcregs.h>
+
+#define NH_MODE        (1 << 1)        /* Disable timer if CPU is halted */
+
+int timer_init(void)
+{
+       write_aux_reg(ARC_AUX_TIMER0_CTRL, NH_MODE);
+       /* Set max value for counter/timer */
+       write_aux_reg(ARC_AUX_TIMER0_LIMIT, 0xffffffff);
+       /* Set initial count value and restart counter/timer */
+       write_aux_reg(ARC_AUX_TIMER0_CNT, 0);
+       return 0;
+}
+
+unsigned long timer_read_counter(void)
+{
+       return read_aux_reg(ARC_AUX_TIMER0_CNT);
+}
index 7df6221c0fada6988c6178ef9e3f72a654e5dfaa..2a83f265a710b74824df68c76d797329446e5083 100644 (file)
@@ -51,6 +51,13 @@ config SYS_CPU
         default "sa1100" if CPU_SA1100
        default "armv8" if ARM64
 
+config SEMIHOSTING
+       bool "support boot from semihosting"
+       help
+         In emulated environments, semihosting is a way for
+         the hosted environment to call out to the emulator to
+         retrieve files from the host machine.
+
 choice
        prompt "Target select"
 
@@ -229,10 +236,12 @@ config KIRKWOOD
 config TARGET_DB_MV784MP_GP
        bool "Support db-mv784mp-gp"
        select CPU_V7
+       select SUPPORT_SPL
 
 config TARGET_MAXBCM
        bool "Support maxbcm"
        select CPU_V7
+       select SUPPORT_SPL
 
 config TARGET_DEVKIT3250
        bool "Support devkit3250"
@@ -732,10 +741,19 @@ config TEGRA
        select CPU_ARM720T if SPL_BUILD
        select CPU_V7 if !SPL_BUILD
 
-config TARGET_VEXPRESS_AEMV8A
+config TARGET_VEXPRESS64_AEMV8A
        bool "Support vexpress_aemv8a"
        select ARM64
 
+config TARGET_VEXPRESS64_BASE_FVP
+       bool "Support Versatile Express ARMv8a FVP BASE model"
+       select ARM64
+       select SEMIHOSTING
+
+config TARGET_VEXPRESS64_JUNO
+       bool "Support Versatile Express Juno Development Platform"
+       select ARM64
+
 config TARGET_LS2085A_EMU
        bool "Support ls2085a_emu"
        select ARM64
index e37e87b68d14d394dfdb9980cbca40345f5ccc52..a90ce3047bd27f2f100512ce6239073ac6c92fa9 100644 (file)
@@ -45,7 +45,9 @@ int cleanup_before_linux (void)
 /* flush I/D-cache */
 static void cache_flush (void)
 {
+#if !(defined(CONFIG_SYS_ICACHE_OFF) && defined(CONFIG_SYS_DCACHE_OFF))
        unsigned long i = 0;
 
        asm ("mcr p15, 0, %0, c7, c7, 0": :"r" (i));
+#endif
 }
index 59b304efcb7cc0d0059d8b15dea52fbfa4d29738..49349da1792972e7783fe309858768bd8500879b 100644 (file)
@@ -34,29 +34,14 @@ void putc(char c)
 }
 #endif /* CONFIG_SPL_LIBCOMMON_SUPPORT */
 
-void board_init_f(ulong dummy)
+void spl_board_init(void)
 {
-       /* First, setup our stack pointer. */
-       asm volatile("mov sp, %0\n" : : "r"(CONFIG_SPL_STACK));
-
-       /* Second, perform our low-level init. */
 #ifdef CONFIG_SOC_DM365
        dm36x_lowlevel_init(0);
 #endif
 #ifdef CONFIG_SOC_DA8XX
        arch_cpu_init();
 #endif
-
-       /* Third, we clear the BSS. */
-       memset(__bss_start, 0, __bss_end - __bss_start);
-
-       /* Finally, setup gd and move to the next step. */
-       gd = &gdata;
-       board_init_r(NULL, 0);
-}
-
-void spl_board_init(void)
-{
        preloader_console_init();
 }
 
index 9e412bbb04d585c949f321ddd04032a652a92e00..4c9d3fde47f58af4915676505bd0cb80d2cd1f45 100644 (file)
@@ -181,7 +181,7 @@ static void kw_sysrst_check(void)
 #if defined(CONFIG_DISPLAY_CPUINFO)
 int print_cpuinfo(void)
 {
-       char *rev;
+       char *rev = "??";
        u16 devid = (readl(KW_REG_PCIE_DEVID) >> 16) & 0xffff;
        u8 revid = readl(KW_REG_PCIE_REVID) & 0xff;
 
@@ -192,7 +192,13 @@ int print_cpuinfo(void)
 
        switch (revid) {
        case 0:
-               rev = "Z0";
+               if (devid == 0x6281)
+                       rev = "Z0";
+               else if (devid == 0x6282)
+                       rev = "A0";
+               break;
+       case 1:
+               rev = "A1";
                break;
        case 2:
                rev = "A0";
@@ -201,7 +207,6 @@ int print_cpuinfo(void)
                rev = "A1";
                break;
        default:
-               rev = "??";
                break;
        }
 
index eaf09d1a627746e0aea1c1317aa6a8ea390693ad..81477aa7b0c3fc9e432a248ca632fc0672a693db 100644 (file)
@@ -284,14 +284,6 @@ void s_init(void)
         */
 #ifdef CONFIG_NOR_BOOT
        enable_norboot_pin_mux();
-#endif
-       /*
-        * Save the boot parameters passed from romcode.
-        * We cannot delay the saving further than this,
-        * to prevent overwrites.
-        */
-#ifdef CONFIG_SPL_BUILD
-       save_omap_boot_params();
 #endif
        watchdog_disable();
        set_uart_mux_conf();
@@ -301,9 +293,6 @@ void s_init(void)
        gd->baudrate = CONFIG_BAUDRATE;
        serial_init();
        gd->have_console = 1;
-#elif defined(CONFIG_SPL_BUILD)
-       gd = &gdata;
-       preloader_console_init();
 #endif
 #if defined(CONFIG_SPL_AM33XX_ENABLE_RTC32K_OSC)
        /* Enable RTC32K clock */
index 885dcee2e192f84e47d3602b5e8cc4df888a4aa7..737159ba12ae1a3c69872c0062b8dd1e17e15dc3 100644 (file)
@@ -5,3 +5,5 @@
 #
 
 obj-y  = cpu.o
+obj-$(CONFIG_SPL_BUILD) += spl.o
+obj-$(CONFIG_SPL_BUILD) += lowlevel_spl.o
diff --git a/arch/arm/cpu/armv7/armada-xp/lowlevel_spl.S b/arch/arm/cpu/armv7/armada-xp/lowlevel_spl.S
new file mode 100644 (file)
index 0000000..1febd7b
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <config.h>
+#include <version.h>
+#include <linux/linkage.h>
+
+ENTRY(save_boot_params)
+       bx      lr
+ENDPROC(save_boot_params)
+
+/*
+ * cache_inv - invalidate Cache line
+ * r0 - dest
+ */
+       .global cache_inv
+       .type  cache_inv, %function
+       cache_inv:
+
+       stmfd   sp!, {r1-r12}
+
+       mcr     p15, 0, r0, c7, c6, 1
+
+       ldmfd   sp!, {r1-r12}
+       bx      lr
+
+
+/*
+ * flush_l1_v6 - l1 cache clean invalidate
+ * r0 - dest
+ */
+       .global flush_l1_v6
+       .type   flush_l1_v6, %function
+       flush_l1_v6:
+
+       stmfd   sp!, {r1-r12}
+
+       mcr     p15, 0, r0, c7, c10, 5  /* @ data memory barrier */
+       mcr     p15, 0, r0, c7, c14, 1  /* @ clean & invalidate D line */
+       mcr     p15, 0, r0, c7, c10, 4  /* @ data sync barrier */
+
+       ldmfd   sp!, {r1-r12}
+       bx      lr
+
+
+/*
+ * flush_l1_v7 - l1 cache clean invalidate
+ * r0 - dest
+ */
+       .global flush_l1_v7
+       .type   flush_l1_v7, %function
+       flush_l1_v7:
+
+       stmfd   sp!, {r1-r12}
+
+       dmb                             /* @data memory barrier */
+       mcr     p15, 0, r0, c7, c14, 1  /* @ clean & invalidate D line */
+       dsb                             /* @data sync barrier */
+
+       ldmfd   sp!, {r1-r12}
+       bx      lr
diff --git a/arch/arm/cpu/armv7/armada-xp/spl.c b/arch/arm/cpu/armv7/armada-xp/spl.c
new file mode 100644 (file)
index 0000000..402e520
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2014 Stefan Roese <sr@denx.de>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <common.h>
+#include <spl.h>
+#include <asm/io.h>
+#include <asm/arch/cpu.h>
+#include <asm/arch/soc.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+u32 spl_boot_device(void)
+{
+       /* Right now only booting via SPI NOR flash is supported */
+       return BOOT_DEVICE_SPI;
+}
+
+void board_init_f(ulong dummy)
+{
+       /* Set global data pointer */
+       gd = &gdata;
+
+       /* Linux expects the internal registers to be at 0xf1000000 */
+       arch_cpu_init();
+
+       preloader_console_init();
+
+       /* First init the serdes PHY's */
+       serdes_phy_config();
+
+       /* Setup DDR */
+       ddr3_init();
+
+       board_init_r(NULL, 0);
+}
index 2708097300d30b27ee945f32e12c4a7f9908acca..7469825565892e1df715c87c320c0738e030cce1 100644 (file)
@@ -6,6 +6,10 @@
  */
 
 #include <common.h>
+#include <asm/io.h>
+#include <asm/arch/at91_common.h>
+#include <asm/arch/at91_pmc.h>
+#include <asm/arch/clk.h>
 #include <asm/arch/sama5d4.h>
 
 char *get_cpu_name()
@@ -28,3 +32,15 @@ char *get_cpu_name()
        else
                return "Unknown CPU type";
 }
+
+#ifdef CONFIG_USB_GADGET_ATMEL_USBA
+void at91_udp_hw_init(void)
+{
+       struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
+
+       /* Enable UPLL clock */
+       writel(AT91_PMC_UPLLEN | AT91_PMC_BIASEN, &pmc->uckr);
+       /* Enable UDPHS clock */
+       at91_periph_clk_enable(ATMEL_ID_UDPHS);
+}
+#endif
index 01cdb7ee76b7f13aaeb1c396e9f7a5e0829fbeeb..c56417dd2f1ec81d8fa1088d8c12fc0aaf6c3848 100644 (file)
@@ -53,7 +53,7 @@ int cleanup_before_linux(void)
         * After D-cache is flushed and before it is disabled there may
         * be some new valid entries brought into the cache. We are sure
         * that these lines are not dirty and will not affect our execution.
-        * (because unwinding the call-stack and setting a bit in CP15 SCTRL
+        * (because unwinding the call-stack and setting a bit in CP15 SCTLR
         * is all we did during this. We have not pushed anything on to the
         * stack. Neither have we affected any static data)
         * So just invalidate the entire d-cache again to avoid coherency
index 94d02970516e9efce5065852bf73182647dfd9de..be43e224fa37074bf2a939ad3e486f3268833910 100644 (file)
@@ -266,22 +266,33 @@ static void exynos5_sromc_config(int flags)
 
 static void exynos5_i2c_config(int peripheral, int flags)
 {
+       int func01, func23;
+
+        /* High-Speed I2C */
+       if (flags & PINMUX_FLAG_HS_MODE) {
+               func01 = 4;
+               func23 = 4;
+       } else {
+               func01 = 2;
+               func23 = 3;
+       }
+
        switch (peripheral) {
        case PERIPH_ID_I2C0:
-               gpio_cfg_pin(EXYNOS5_GPIO_B30, S5P_GPIO_FUNC(0x2));
-               gpio_cfg_pin(EXYNOS5_GPIO_B31, S5P_GPIO_FUNC(0x2));
+               gpio_cfg_pin(EXYNOS5_GPIO_B30, S5P_GPIO_FUNC(func01));
+               gpio_cfg_pin(EXYNOS5_GPIO_B31, S5P_GPIO_FUNC(func01));
                break;
        case PERIPH_ID_I2C1:
-               gpio_cfg_pin(EXYNOS5_GPIO_B32, S5P_GPIO_FUNC(0x2));
-               gpio_cfg_pin(EXYNOS5_GPIO_B33, S5P_GPIO_FUNC(0x2));
+               gpio_cfg_pin(EXYNOS5_GPIO_B32, S5P_GPIO_FUNC(func01));
+               gpio_cfg_pin(EXYNOS5_GPIO_B33, S5P_GPIO_FUNC(func01));
                break;
        case PERIPH_ID_I2C2:
-               gpio_cfg_pin(EXYNOS5_GPIO_A06, S5P_GPIO_FUNC(0x3));
-               gpio_cfg_pin(EXYNOS5_GPIO_A07, S5P_GPIO_FUNC(0x3));
+               gpio_cfg_pin(EXYNOS5_GPIO_A06, S5P_GPIO_FUNC(func23));
+               gpio_cfg_pin(EXYNOS5_GPIO_A07, S5P_GPIO_FUNC(func23));
                break;
        case PERIPH_ID_I2C3:
-               gpio_cfg_pin(EXYNOS5_GPIO_A12, S5P_GPIO_FUNC(0x3));
-               gpio_cfg_pin(EXYNOS5_GPIO_A13, S5P_GPIO_FUNC(0x3));
+               gpio_cfg_pin(EXYNOS5_GPIO_A12, S5P_GPIO_FUNC(func23));
+               gpio_cfg_pin(EXYNOS5_GPIO_A13, S5P_GPIO_FUNC(func23));
                break;
        case PERIPH_ID_I2C4:
                gpio_cfg_pin(EXYNOS5_GPIO_A20, S5P_GPIO_FUNC(0x3));
index 989780d27348d54542a236e095f99a166e47545c..71a175392fd1c063e9149187694c0d7b8eb9f249 100644 (file)
@@ -15,6 +15,8 @@
 #include <fsl_esdhc.h>
 #endif
 #include <tsec.h>
+#include <asm/arch/immap_ls102xa.h>
+#include <fsl_sec.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -77,9 +79,24 @@ void ft_cpu_setup(void *blob, bd_t *bd)
        int off;
        int val;
        const char *sysclk_path;
+       struct ccsr_gur __iomem *gur = (void *)(CONFIG_SYS_FSL_GUTS_ADDR);
+       unsigned int svr;
+       svr = in_be32(&gur->svr);
 
        unsigned long busclk = get_bus_freq(0);
 
+       /* delete crypto node if not on an E-processor */
+       if (!IS_E_PROCESSOR(svr))
+               fdt_fixup_crypto_node(blob, 0);
+#if CONFIG_SYS_FSL_SEC_COMPAT >= 4
+       else {
+               ccsr_sec_t __iomem *sec;
+
+               sec = (void __iomem *)CONFIG_SYS_FSL_SEC_ADDR;
+               fdt_fixup_crypto_node(blob, sec_in32(&sec->secvid_ms));
+       }
+#endif
+
        fdt_fixup_ethernet(blob);
 
        off = fdt_node_offset_by_prop_value(blob, -1, "device_type", "cpu", 4);
@@ -107,6 +124,25 @@ void ft_cpu_setup(void *blob, bd_t *bd)
        do_fixup_by_compat_u32(blob, "fsl,qoriq-sysclk-2.0",
                               "clock-frequency", CONFIG_SYS_CLK_FREQ, 1);
 
+#if defined(CONFIG_DEEP_SLEEP) && defined(CONFIG_SD_BOOT)
+#define UBOOT_HEAD_LEN 0x1000
+       /*
+        * Reserved memory in SD boot deep sleep case.
+        * Second stage uboot binary and malloc space should be reserved.
+        * If the memory they occupied has not been reserved, then this
+        * space would be used by kernel and overwritten in uboot when
+        * deep sleep resume, which cause deep sleep failed.
+        * Since second uboot binary has a head, that space need to be
+        * reserved either(assuming its size is less than 0x1000).
+        */
+       off = fdt_add_mem_rsv(blob, CONFIG_SYS_TEXT_BASE - UBOOT_HEAD_LEN,
+                       CONFIG_SYS_MONITOR_LEN + CONFIG_SYS_SPL_MALLOC_SIZE +
+                       UBOOT_HEAD_LEN);
+       if (off < 0)
+               printf("Failed to reserve memory for SD boot deep sleep: %s\n",
+                      fdt_strerror(off));
+#endif
+
 #if defined(CONFIG_FSL_ESDHC)
        fdt_fixup_esdhc(blob, bd);
 #endif
@@ -133,4 +169,17 @@ void ft_cpu_setup(void *blob, bd_t *bd)
 
        do_fixup_by_compat_u32(blob, "fsl, ls1021a-flexcan",
                               "clock-frequency", busclk / 2, 1);
+
+#ifdef CONFIG_QSPI_BOOT
+       off = fdt_node_offset_by_compat_reg(blob, FSL_IFC_COMPAT,
+                                           CONFIG_SYS_IFC_ADDR);
+       fdt_set_node_status(blob, off, FDT_STATUS_DISABLED, 0);
+#else
+       off = fdt_node_offset_by_compat_reg(blob, FSL_QSPI_COMPAT,
+                                           QSPI0_BASE_ADDR);
+       fdt_set_node_status(blob, off, FDT_STATUS_DISABLED, 0);
+       off = fdt_node_offset_by_compat_reg(blob, FSL_DSPI_COMPAT,
+                                           DSPI1_BASE_ADDR);
+       fdt_set_node_status(blob, off, FDT_STATUS_DISABLED, 0);
+#endif
 }
index 00a108212a7294c40e26ee0e12056a19510b3b0c..17500f2315ee9d3d5a8a5868c3e3e75f46a7148b 100644 (file)
@@ -106,6 +106,16 @@ u32 spl_boot_mode(void)
 
 void spl_board_init(void)
 {
+       /*
+        * Save the boot parameters passed from romcode.
+        * We cannot delay the saving further than this,
+        * to prevent overwrites.
+        */
+       save_omap_boot_params();
+
+       /* Prepare console output */
+       preloader_console_init();
+
 #ifdef CONFIG_SPL_NAND_SUPPORT
        gpmc_init();
 #endif
index 8e7411d43781186bee0ceed9159394bafec63e6b..03674e609ffce42c28eea7ee88539308a65b5c73 100644 (file)
@@ -437,12 +437,15 @@ void do_scale_vcore(u32 vcore_reg, u32 volt_mv, struct pmic_data *pmic)
 {
        u32 offset_code;
        u32 offset = volt_mv;
+#ifndef        CONFIG_DRA7XX
        int ret = 0;
+#endif
 
        if (!volt_mv)
                return;
 
        pmic->pmic_bus_init();
+#ifndef        CONFIG_DRA7XX
        /* See if we can first get the GPIO if needed */
        if (pmic->gpio_en)
                ret = gpio_request(pmic->gpio, "PMIC_GPIO");
@@ -456,7 +459,7 @@ void do_scale_vcore(u32 vcore_reg, u32 volt_mv, struct pmic_data *pmic)
        /* Pull the GPIO low to select SET0 register, while we program SET1 */
        if (pmic->gpio_en)
                gpio_direction_output(pmic->gpio, 0);
-
+#endif
        /* convert to uV for better accuracy in the calculations */
        offset *= 1000;
 
@@ -467,9 +470,10 @@ void do_scale_vcore(u32 vcore_reg, u32 volt_mv, struct pmic_data *pmic)
 
        if (pmic->pmic_write(pmic->i2c_slave_addr, vcore_reg, offset_code))
                printf("Scaling voltage failed for 0x%x\n", vcore_reg);
-
+#ifndef        CONFIG_DRA7XX
        if (pmic->gpio_en)
                gpio_direction_output(pmic->gpio, 1);
+#endif
 }
 
 static u32 optimize_vcore_voltage(struct volts const *v)
@@ -505,13 +509,79 @@ static u32 optimize_vcore_voltage(struct volts const *v)
 }
 
 /*
- * Setup the voltages for vdd_mpu, vdd_core, and vdd_iva
- * We set the maximum voltages allowed here because Smart-Reflex is not
- * enabled in bootloader. Voltage initialization in the kernel will set
- * these to the nominal values after enabling Smart-Reflex
+ * Setup the voltages for the main SoC core power domains.
+ * We start with the maximum voltages allowed here, as set in the corresponding
+ * vcores_data struct, and then scale (usually down) to the fused values that
+ * are retrieved from the SoC. The scaling happens only if the efuse.reg fields
+ * are initialised.
+ * Rail grouping is supported for the DRA7xx SoCs only, therefore the code is
+ * compiled conditionally. Note that the new code writes the scaled (or zeroed)
+ * values back to the vcores_data struct for eventual reuse. Zero values mean
+ * that the corresponding rails are not controlled separately, and are not sent
+ * to the PMIC.
  */
 void scale_vcores(struct vcores_data const *vcores)
 {
+#if defined(CONFIG_DRA7XX)
+       int i;
+       struct volts *pv = (struct volts *)vcores;
+       struct volts *px;
+
+       for (i=0; i<(sizeof(struct vcores_data)/sizeof(struct volts)); i++) {
+               debug("%d -> ", pv->value);
+               if (pv->value) {
+                       /* Handle non-empty members only */
+                       pv->value = optimize_vcore_voltage(pv);
+                       px = (struct volts *)vcores;
+                       while (px < pv) {
+                               /*
+                                * Scan already handled non-empty members to see
+                                * if we have a group and find the max voltage,
+                                * which is set to the first occurance of the
+                                * particular SMPS; the other group voltages are
+                                * zeroed.
+                                */
+                               if (px->value) {
+                                       if ((pv->pmic->i2c_slave_addr ==
+                                            px->pmic->i2c_slave_addr) &&
+                                           (pv->addr == px->addr)) {
+                                               /* Same PMIC, same SMPS */
+                                               if (pv->value > px->value)
+                                                       px->value = pv->value;
+
+                                               pv->value = 0;
+                                       }
+                               }
+                               px++;
+                       }
+               }
+               debug("%d\n", pv->value);
+               pv++;
+       }
+
+       debug("cor: %d\n", vcores->core.value);
+       do_scale_vcore(vcores->core.addr, vcores->core.value, vcores->core.pmic);
+       debug("mpu: %d\n", vcores->mpu.value);
+       do_scale_vcore(vcores->mpu.addr, vcores->mpu.value, vcores->mpu.pmic);
+       /* Configure MPU ABB LDO after scale */
+       abb_setup((*ctrl)->control_std_fuse_opp_vdd_mpu_2,
+                 (*ctrl)->control_wkup_ldovbb_mpu_voltage_ctrl,
+                 (*prcm)->prm_abbldo_mpu_setup,
+                 (*prcm)->prm_abbldo_mpu_ctrl,
+                 (*prcm)->prm_irqstatus_mpu_2,
+                 OMAP_ABB_MPU_TXDONE_MASK,
+                 OMAP_ABB_FAST_OPP);
+
+       /* The .mm member is not used for the DRA7xx */
+
+       debug("gpu: %d\n", vcores->gpu.value);
+       do_scale_vcore(vcores->gpu.addr, vcores->gpu.value, vcores->gpu.pmic);
+       debug("eve: %d\n", vcores->eve.value);
+       do_scale_vcore(vcores->eve.addr, vcores->eve.value, vcores->eve.pmic);
+       debug("iva: %d\n", vcores->iva.value);
+       do_scale_vcore(vcores->iva.addr, vcores->iva.value, vcores->iva.pmic);
+       /* Might need udelay(1000) here if debug is enabled to see all prints */
+#else
        u32 val;
 
        val = optimize_vcore_voltage(&vcores->core);
@@ -540,6 +610,7 @@ void scale_vcores(struct vcores_data const *vcores)
 
        val = optimize_vcore_voltage(&vcores->iva);
        do_scale_vcore(vcores->iva.addr, val, vcores->iva.pmic);
+#endif
 }
 
 static inline void enable_clock_domain(u32 const clkctrl_reg, u32 enable_mode)
index dd52e938a9508171ff27dd909c0590f1c1ca7e22..cb35c198f1802edc71215f0bb170dc0407ae1e17 100644 (file)
@@ -111,14 +111,6 @@ int arch_cpu_init(void)
  */
 void s_init(void)
 {
-       /*
-        * Save the boot parameters passed from romcode.
-        * We cannot delay the saving further than this,
-        * to prevent overwrites.
-        */
-#ifdef CONFIG_SPL_BUILD
-       save_omap_boot_params();
-#endif
        init_omap_revision();
        hw_data_init();
 
@@ -133,9 +125,6 @@ void s_init(void)
        srcomp_enable();
        setup_clocks_for_console();
 
-       gd = &gdata;
-
-       preloader_console_init();
        do_io_settings();
 #endif
        prcm_init();
index 53a9e5d77df736f210f3310b8e8bae1ffe44ba16..90d6ae7bb5f5e8c43ef31b6477195875fdb1d1ab 100644 (file)
@@ -119,6 +119,7 @@ int board_mmc_init(bd_t *bis)
 
 void spl_board_init(void)
 {
+       preloader_console_init();
 #if defined(CONFIG_SPL_NAND_SUPPORT) || defined(CONFIG_SPL_ONENAND_SUPPORT)
        gpmc_init();
 #endif
@@ -264,14 +265,6 @@ void s_init(void)
        ehci_clocks_enable();
 #endif
 
-#ifdef CONFIG_SPL_BUILD
-       gd = &gdata;
-
-       preloader_console_init();
-
-       timer_init();
-#endif
-
        if (!in_sdram)
                mem_init();
 }
index 529ad9a942448fa66ba1d2c86c11a66f84572d88..006969e780b332ccab15c4da7d8826efb1ba84b9 100644 (file)
@@ -732,11 +732,20 @@ void per_clocks_enable(void)
        setbits_le32(&prcm_base->iclken_per, 0x08);     /* ICKen GPT2 */
        setbits_le32(&prcm_base->fclken_per, 0x08);     /* FCKen GPT2 */
 
+       /* Enable GP9 timer. */
+       setbits_le32(&prcm_base->clksel_per, 0x80);     /* GPT9 = 32kHz clk */
+       setbits_le32(&prcm_base->iclken_per, 0x400);    /* ICKen GPT9 */
+       setbits_le32(&prcm_base->fclken_per, 0x400);    /* FCKen GPT9 */
+
 #ifdef CONFIG_SYS_NS16550
        /* Enable UART1 clocks */
        setbits_le32(&prcm_base->fclken1_core, 0x00002000);
        setbits_le32(&prcm_base->iclken1_core, 0x00002000);
 
+       /* Enable UART2 clocks */
+       setbits_le32(&prcm_base->fclken1_core, 0x00004000);
+       setbits_le32(&prcm_base->iclken1_core, 0x00004000);
+
        /* UART 3 Clocks */
        setbits_le32(&prcm_base->fclken_per, 0x00000800);
        setbits_le32(&prcm_base->iclken_per, 0x00000800);
index 7a291318ab0722e67b6a4c1624c9de260a9e5855..4f15ac9cb5518f55174fb0e1bb97fb3cbd38ca1d 100644 (file)
@@ -135,6 +135,9 @@ void do_sdrc_init(u32 cs, u32 early)
        sdrc_actim_base0 = (struct sdrc_actim *)SDRC_ACTIM_CTRL0_BASE;
        sdrc_actim_base1 = (struct sdrc_actim *)SDRC_ACTIM_CTRL1_BASE;
 
+       /* set some default timings */
+       timings.sharing = SDRC_SHARING;
+
        /*
         * When called in the early context this may be SPL and we will
         * need to set all of the timings.  This ends up being board
@@ -145,6 +148,7 @@ void do_sdrc_init(u32 cs, u32 early)
         * setup CS1.
         */
 #ifdef CONFIG_SPL_BUILD
+       /* set/modify board-specific timings */
        get_board_mem_timings(&timings);
 #endif
        if (early) {
@@ -155,7 +159,7 @@ void do_sdrc_init(u32 cs, u32 early)
                writel(0, &sdrc_base->sysconfig);
 
                /* setup sdrc to ball mux */
-               writel(SDRC_SHARING, &sdrc_base->sharing);
+               writel(timings.sharing, &sdrc_base->sharing);
 
                /* Disable Power Down of CKE because of 1 CKE on combo part */
                writel(WAKEUPPROC | SRFRONRESET | PAGEPOLICY_HIGH,
index 95f16866e6cbd9e043dcdf969a937e648bbd13a8..b9734fea8febaea9cf3cd805c4090a038d5337e0 100644 (file)
@@ -320,6 +320,7 @@ struct pmic_data palmas = {
        .pmic_write     = omap_vc_bypass_send_value,
 };
 
+/* The TPS659038 and TPS65917 are software-compatible, use common struct */
 struct pmic_data tps659038 = {
        .base_offset = PALMAS_SMPS_BASE_VOLT_UV,
        .step = 10000, /* 10 mV represented in uV */
@@ -394,34 +395,38 @@ struct vcores_data dra752_volts = {
 };
 
 struct vcores_data dra722_volts = {
-       .mpu.value      = 1000,
+       .mpu.value      = VDD_MPU_DRA72x,
        .mpu.efuse.reg  = STD_FUSE_OPP_VMIN_MPU_NOM,
-       .mpu.efuse.reg_bits     = DRA752_EFUSE_REGBITS,
-       .mpu.addr       = 0x23,
+       .mpu.efuse.reg_bits = DRA752_EFUSE_REGBITS,
+       .mpu.addr       = TPS65917_REG_ADDR_SMPS1,
        .mpu.pmic       = &tps659038,
 
-       .eve.value      = 1000,
-       .eve.efuse.reg  = STD_FUSE_OPP_VMIN_DSPEVE_NOM,
-       .eve.efuse.reg_bits     = DRA752_EFUSE_REGBITS,
-       .eve.addr       = 0x2f,
-       .eve.pmic       = &tps659038,
+       .core.value     = VDD_CORE_DRA72x,
+       .core.efuse.reg = STD_FUSE_OPP_VMIN_CORE_NOM,
+       .core.efuse.reg_bits = DRA752_EFUSE_REGBITS,
+       .core.addr      = TPS65917_REG_ADDR_SMPS2,
+       .core.pmic      = &tps659038,
 
-       .gpu.value      = 1000,
+       /*
+        * The DSPEVE, GPU and IVA rails are usually grouped on DRA72x
+        * designs and powered by TPS65917 SMPS3, as on the J6Eco EVM.
+        */
+       .gpu.value      = VDD_GPU_DRA72x,
        .gpu.efuse.reg  = STD_FUSE_OPP_VMIN_GPU_NOM,
-       .gpu.efuse.reg_bits     = DRA752_EFUSE_REGBITS,
-       .gpu.addr       = 0x2f,
+       .gpu.efuse.reg_bits = DRA752_EFUSE_REGBITS,
+       .gpu.addr       = TPS65917_REG_ADDR_SMPS3,
        .gpu.pmic       = &tps659038,
 
-       .core.value     = 1000,
-       .core.efuse.reg = STD_FUSE_OPP_VMIN_CORE_NOM,
-       .core.efuse.reg_bits = DRA752_EFUSE_REGBITS,
-       .core.addr      = 0x27,
-       .core.pmic      = &tps659038,
+       .eve.value      = VDD_EVE_DRA72x,
+       .eve.efuse.reg  = STD_FUSE_OPP_VMIN_DSPEVE_NOM,
+       .eve.efuse.reg_bits = DRA752_EFUSE_REGBITS,
+       .eve.addr       = TPS65917_REG_ADDR_SMPS3,
+       .eve.pmic       = &tps659038,
 
-       .iva.value      = 1000,
+       .iva.value      = VDD_IVA_DRA72x,
        .iva.efuse.reg  = STD_FUSE_OPP_VMIN_IVA_NOM,
-       .iva.efuse.reg_bits     = DRA752_EFUSE_REGBITS,
-       .iva.addr       = 0x2f,
+       .iva.efuse.reg_bits = DRA752_EFUSE_REGBITS,
+       .iva.addr       = TPS65917_REG_ADDR_SMPS3,
        .iva.pmic       = &tps659038,
 };
 
index fdc05b942f15bb80415c295faba6832e689d8b01..70048c10aee6736117e078931b75c4b6ba7756a5 100644 (file)
@@ -52,10 +52,10 @@ reset:
  * Continue to use ROM code vector only in OMAP4 spl)
  */
 #if !(defined(CONFIG_OMAP44XX) && defined(CONFIG_SPL_BUILD))
-       /* Set V=0 in CP15 SCTRL register - for VBAR to point to vector */
-       mrc     p15, 0, r0, c1, c0, 0   @ Read CP15 SCTRL Register
+       /* Set V=0 in CP15 SCTLR register - for VBAR to point to vector */
+       mrc     p15, 0, r0, c1, c0, 0   @ Read CP15 SCTLR Register
        bic     r0, #CR_V               @ V = 0
-       mcr     p15, 0, r0, c1, c0, 0   @ Write CP15 SCTRL Register
+       mcr     p15, 0, r0, c1, c0, 0   @ Write CP15 SCTLR Register
 
        /* Set vector address in CP15 VBAR register */
        ldr     r0, =_start
index 1720f7db01ddf7594a53acf43aed660caf178705..48db7442f4f0b771a6f1865a611aa9cb45975d3d 100644 (file)
@@ -15,13 +15,16 @@ obj-y       += pinmux.o
 obj-y  += usbc.o
 obj-$(CONFIG_MACH_SUN6I)       += prcm.o
 obj-$(CONFIG_MACH_SUN8I)       += prcm.o
+obj-$(CONFIG_MACH_SUN9I)       += prcm.o
 obj-$(CONFIG_MACH_SUN6I)       += p2wi.o
 obj-$(CONFIG_MACH_SUN8I)       += rsb.o
+obj-$(CONFIG_MACH_SUN9I)       += rsb.o
 obj-$(CONFIG_MACH_SUN4I)       += clock_sun4i.o
 obj-$(CONFIG_MACH_SUN5I)       += clock_sun4i.o
 obj-$(CONFIG_MACH_SUN6I)       += clock_sun6i.o
 obj-$(CONFIG_MACH_SUN7I)       += clock_sun4i.o
 obj-$(CONFIG_MACH_SUN8I)       += clock_sun6i.o
+obj-$(CONFIG_MACH_SUN9I)       += clock_sun9i.o
 
 ifndef CONFIG_SPL_BUILD
 ifdef CONFIG_ARMV7_PSCI
index bc98c564f9828fe5580a7e39c04b1e57f638f852..6e28bcd040686a3cc2c36b72cb5f7ff1234da796 100644 (file)
 
 #include <linux/compiler.h>
 
-#ifdef CONFIG_SPL_BUILD
-/* Pointer to the global data structure for SPL */
-DECLARE_GLOBAL_DATA_PTR;
-
-/* The sunxi internal brom will try to loader external bootloader
- * from mmc0, nand flash, mmc2.
- * Unfortunately we can't check how SPL was loaded so assume
- * it's always the first SD/MMC controller
- */
-u32 spl_boot_device(void)
-{
-       return BOOT_DEVICE_MMC1;
-}
-
-/* No confirmation data available in SPL yet. Hardcode bootmode */
-u32 spl_boot_mode(void)
-{
-       return MMCSD_MODE_RAW;
-}
-#endif
-
-int gpio_init(void)
+static int gpio_init(void)
 {
 #if CONFIG_CONS_INDEX == 1 && defined(CONFIG_UART0_PORT_F)
 #if defined(CONFIG_MACH_SUN4I) || defined(CONFIG_MACH_SUN7I)
@@ -86,36 +65,9 @@ int gpio_init(void)
        return 0;
 }
 
-void reset_cpu(ulong addr)
-{
-#if defined(CONFIG_MACH_SUN4I) || defined(CONFIG_MACH_SUN5I) || defined(CONFIG_MACH_SUN7I)
-       static const struct sunxi_wdog *wdog =
-                &((struct sunxi_timer_reg *)SUNXI_TIMER_BASE)->wdog;
-
-       /* Set the watchdog for its shortest interval (.5s) and wait */
-       writel(WDT_MODE_RESET_EN | WDT_MODE_EN, &wdog->mode);
-       writel(WDT_CTRL_KEY | WDT_CTRL_RESTART, &wdog->ctl);
-
-       while (1) {
-               /* sun5i sometimes gets stuck without this */
-               writel(WDT_MODE_RESET_EN | WDT_MODE_EN, &wdog->mode);
-       }
-#else /* CONFIG_MACH_SUN6I || CONFIG_MACH_SUN8I || .. */
-       static const struct sunxi_wdog *wdog =
-                ((struct sunxi_timer_reg *)SUNXI_TIMER_BASE)->wdog;
-
-       /* Set the watchdog for its shortest interval (.5s) and wait */
-       writel(WDT_CFG_RESET, &wdog->cfg);
-       writel(WDT_MODE_EN, &wdog->mode);
-       writel(WDT_CTRL_KEY | WDT_CTRL_RESTART, &wdog->ctl);
-#endif
-}
-
-/* do some early init */
 void s_init(void)
 {
-#if defined CONFIG_SPL_BUILD && \
-               (defined CONFIG_MACH_SUN6I || defined CONFIG_MACH_SUN8I)
+#if defined CONFIG_MACH_SUN6I || defined CONFIG_MACH_SUN8I
        /* Magic (undocmented) value taken from boot0, without this DRAM
         * access gets messed up (seems cache related) */
        setbits_le32(SUNXI_SRAMC_BASE + 0x44, 0x1800);
@@ -133,9 +85,27 @@ void s_init(void)
        timer_init();
        gpio_init();
        i2c_init_board();
+}
 
 #ifdef CONFIG_SPL_BUILD
-       gd = &gdata;
+/* The sunxi internal brom will try to loader external bootloader
+ * from mmc0, nand flash, mmc2.
+ * Unfortunately we can't check how SPL was loaded so assume
+ * it's always the first SD/MMC controller
+ */
+u32 spl_boot_device(void)
+{
+       return BOOT_DEVICE_MMC1;
+}
+
+/* No confirmation data available in SPL yet. Hardcode bootmode */
+u32 spl_boot_mode(void)
+{
+       return MMCSD_MODE_RAW;
+}
+
+void board_init_f(ulong dummy)
+{
        preloader_console_init();
 
 #ifdef CONFIG_SPL_I2C_SUPPORT
@@ -143,6 +113,36 @@ void s_init(void)
        i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
 #endif
        sunxi_board_init();
+
+       /* Clear the BSS. */
+       memset(__bss_start, 0, __bss_end - __bss_start);
+
+       board_init_r(NULL, 0);
+}
+#endif
+
+void reset_cpu(ulong addr)
+{
+#if defined(CONFIG_MACH_SUN4I) || defined(CONFIG_MACH_SUN5I) || defined(CONFIG_MACH_SUN7I)
+       static const struct sunxi_wdog *wdog =
+                &((struct sunxi_timer_reg *)SUNXI_TIMER_BASE)->wdog;
+
+       /* Set the watchdog for its shortest interval (.5s) and wait */
+       writel(WDT_MODE_RESET_EN | WDT_MODE_EN, &wdog->mode);
+       writel(WDT_CTRL_KEY | WDT_CTRL_RESTART, &wdog->ctl);
+
+       while (1) {
+               /* sun5i sometimes gets stuck without this */
+               writel(WDT_MODE_RESET_EN | WDT_MODE_EN, &wdog->mode);
+       }
+#else /* CONFIG_MACH_SUN6I || CONFIG_MACH_SUN8I || .. */
+       static const struct sunxi_wdog *wdog =
+                ((struct sunxi_timer_reg *)SUNXI_TIMER_BASE)->wdog;
+
+       /* Set the watchdog for its shortest interval (.5s) and wait */
+       writel(WDT_CFG_RESET, &wdog->cfg);
+       writel(WDT_MODE_EN, &wdog->mode);
+       writel(WDT_CTRL_KEY | WDT_CTRL_RESTART, &wdog->ctl);
 #endif
 }
 
index d7a7040b72c70a27948841c038d4312b0cda46d2..e2a78676b1654fc6fece0f6fe9058957fe04c595 100644 (file)
@@ -45,10 +45,10 @@ void clock_init_safe(void)
 
 void clock_init_uart(void)
 {
+#if CONFIG_CONS_INDEX < 5
        struct sunxi_ccm_reg *const ccm =
                (struct sunxi_ccm_reg *)SUNXI_CCM_BASE;
 
-#if CONFIG_CONS_INDEX < 5
        /* uart clock source is apb2 */
        writel(APB2_CLK_SRC_OSC24M|
               APB2_CLK_RATE_N_1|
@@ -68,9 +68,6 @@ void clock_init_uart(void)
        /* enable R_PIO and R_UART clocks, and de-assert resets */
        prcm_apb0_enable(PRCM_APB0_GATE_PIO | PRCM_APB0_GATE_UART);
 #endif
-
-       /* Dup with clock_init_safe(), drop once sun6i SPL support lands */
-       writel(PLL6_CFG_DEFAULT, &ccm->pll6_cfg);
 }
 
 int clock_twi_onoff(int port, int state)
diff --git a/arch/arm/cpu/armv7/sunxi/clock_sun9i.c b/arch/arm/cpu/armv7/sunxi/clock_sun9i.c
new file mode 100644 (file)
index 0000000..27179ba
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * sun9i specific clock code
+ *
+ * (C) Copyright 2015 Hans de Goede <hdegoede@redhat.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <common.h>
+#include <asm/io.h>
+#include <asm/arch/clock.h>
+#include <asm/arch/prcm.h>
+#include <asm/arch/sys_proto.h>
+
+void clock_init_uart(void)
+{
+       struct sunxi_ccm_reg *const ccm =
+               (struct sunxi_ccm_reg *)SUNXI_CCM_BASE;
+
+       /* open the clock for uart */
+       setbits_le32(&ccm->apb1_gate,
+                    CLK_GATE_OPEN << (APB1_GATE_UART_SHIFT +
+                                      CONFIG_CONS_INDEX - 1));
+       /* deassert uart reset */
+       setbits_le32(&ccm->apb1_reset_cfg,
+                    1 << (APB1_RESET_UART_SHIFT +
+                          CONFIG_CONS_INDEX - 1));
+
+       /* Dup with clock_init_safe(), drop once sun9i SPL support lands */
+       writel(PLL4_CFG_DEFAULT, &ccm->pll4_periph0_cfg);
+}
+
+int clock_twi_onoff(int port, int state)
+{
+       struct sunxi_ccm_reg *const ccm =
+               (struct sunxi_ccm_reg *)SUNXI_CCM_BASE;
+
+       if (port > 4)
+               return -1;
+
+       /* set the apb reset and clock gate for twi */
+       if (state) {
+               setbits_le32(&ccm->apb1_gate,
+                            CLK_GATE_OPEN << (APB1_GATE_TWI_SHIFT + port));
+               setbits_le32(&ccm->apb1_reset_cfg,
+                            1 << (APB1_RESET_UART_SHIFT + port));
+       } else {
+               clrbits_le32(&ccm->apb1_reset_cfg,
+                            1 << (APB1_RESET_UART_SHIFT + port));
+               clrbits_le32(&ccm->apb1_gate,
+                            CLK_GATE_OPEN << (APB1_GATE_TWI_SHIFT + port));
+       }
+
+       return 0;
+}
+
+unsigned int clock_get_pll4_periph0(void)
+{
+       struct sunxi_ccm_reg *const ccm =
+               (struct sunxi_ccm_reg *)SUNXI_CCM_BASE;
+       uint32_t rval = readl(&ccm->pll4_periph0_cfg);
+       int n = ((rval & CCM_PLL4_CTRL_N_MASK) >> CCM_PLL4_CTRL_N_SHIFT);
+       int p = ((rval & CCM_PLL4_CTRL_P_MASK) >> CCM_PLL4_CTRL_P_SHIFT);
+       int m = ((rval & CCM_PLL4_CTRL_M_MASK) >> CCM_PLL4_CTRL_M_SHIFT) + 1;
+       const int k = 1;
+
+       return ((24000000 * n * k) >> p) / m;
+}
index b72bb9db519f18f3b27d79f939c07a183061ece8..b00befb30119bf547a56270a106359f5bf61c81c 100644 (file)
 #include <asm/arch/prcm.h>
 #include <asm/arch/rsb.h>
 
+static int rsb_set_device_mode(void);
+
 static void rsb_cfg_io(void)
 {
+#ifdef CONFIG_MACH_SUN8I
        sunxi_gpio_set_cfgpin(SUNXI_GPL(0), SUN8I_GPL0_R_RSB_SCK);
        sunxi_gpio_set_cfgpin(SUNXI_GPL(1), SUN8I_GPL1_R_RSB_SDA);
        sunxi_gpio_set_pull(SUNXI_GPL(0), 1);
        sunxi_gpio_set_pull(SUNXI_GPL(1), 1);
        sunxi_gpio_set_drv(SUNXI_GPL(0), 2);
        sunxi_gpio_set_drv(SUNXI_GPL(1), 2);
+#elif defined CONFIG_MACH_SUN9I
+       sunxi_gpio_set_cfgpin(SUNXI_GPN(0), SUN9I_GPN0_R_RSB_SCK);
+       sunxi_gpio_set_cfgpin(SUNXI_GPN(1), SUN9I_GPN1_R_RSB_SDA);
+       sunxi_gpio_set_pull(SUNXI_GPN(0), 1);
+       sunxi_gpio_set_pull(SUNXI_GPN(1), 1);
+       sunxi_gpio_set_drv(SUNXI_GPN(0), 2);
+       sunxi_gpio_set_drv(SUNXI_GPN(1), 2);
+#else
+#error unsupported MACH_SUNXI
+#endif
 }
 
 static void rsb_set_clk(void)
@@ -42,7 +55,7 @@ static void rsb_set_clk(void)
        writel((cd_odly << 8) | div, &rsb->ccr);
 }
 
-void rsb_init(void)
+int rsb_init(void)
 {
        struct sunxi_rsb_reg * const rsb =
                (struct sunxi_rsb_reg *)SUNXI_RSB_BASE;
@@ -54,6 +67,8 @@ void rsb_init(void)
 
        writel(RSB_CTRL_SOFT_RST, &rsb->ctrl);
        rsb_set_clk();
+
+       return rsb_set_device_mode();
 }
 
 static int rsb_await_trans(void)
@@ -88,13 +103,14 @@ static int rsb_await_trans(void)
        return ret;
 }
 
-int rsb_set_device_mode(u32 device_mode_data)
+static int rsb_set_device_mode(void)
 {
        struct sunxi_rsb_reg * const rsb =
                (struct sunxi_rsb_reg *)SUNXI_RSB_BASE;
        unsigned long tmo = timer_get_us() + 1000000;
 
-       writel(RSB_DMCR_DEVICE_MODE_START | device_mode_data, &rsb->dmcr);
+       writel(RSB_DMCR_DEVICE_MODE_START | RSB_DMCR_DEVICE_MODE_DATA,
+              &rsb->dmcr);
 
        while (readl(&rsb->dmcr) & RSB_DMCR_DEVICE_MODE_START) {
                if (timer_get_us() > tmo)
index 0556e4b3509e6b1e8b50d69bb98add96c1fef4f0..5c5a84fe56c4fc0da0f68f8cc028fa672ed90a01 100644 (file)
@@ -50,21 +50,12 @@ endchoice
 
 config CMD_PINMON
        bool "Enable boot mode pins monitor command"
-       depends on !SPL_BUILD
        default y
        help
          The command "pinmon" shows the state of the boot mode pins.
          The boot mode pins are latched when the system reset is deasserted
          and determine which device the system should load a boot image from.
 
-config SOC_INIT
-       bool
-       default SPL_BUILD
-
-config DRAM_INIT
-       bool
-       default SPL_BUILD
-
 config CMD_DDRPHY_DUMP
        bool "Enable dump command of DDR PHY parameters"
        depends on !SPL_BUILD
@@ -74,7 +65,7 @@ config CMD_DDRPHY_DUMP
 
 choice
        prompt "DDR3 Frequency select"
-       depends on DRAM_INIT
+       depends on SPL_BUILD
 
 config DDR_FREQ_1600
        bool "DDR3 1600"
index 05462320b58c749125f27945639df9e10ad52808..df418dd3c4b8104c11ae1acfdfb36d7e19d2c6ab 100644 (file)
@@ -2,23 +2,32 @@
 # SPDX-License-Identifier:     GPL-2.0+
 #
 
-obj-$(CONFIG_SPL_BUILD) += lowlevel_init.o init_page_table.o
-obj-$(CONFIG_SPL_BUILD) += spl.o
+ifdef CONFIG_SPL_BUILD
 
-obj-y += timer.o
-obj-y += reset.o
-obj-y += cache_uniphier.o
-obj-$(CONFIG_BOARD_POSTCLK_INIT) += board_postclk_init.o
-obj-y += dram_init.o
-obj-$(CONFIG_DRAM_INIT) += ddrphy_training.o
+obj-y += lowlevel_init.o
+obj-y += init_page_table.o
+obj-y += spl.o
+obj-y += ddrphy_training.o
+
+else
+
+obj-$(CONFIG_BOARD_EARLY_INIT_F) += board_early_init_f.o
 obj-$(CONFIG_DISPLAY_CPUINFO) += cpu_info.o
+obj-$(CONFIG_MISC_INIT_F) += print_misc_info.o
+obj-y += dram_init.o
+obj-y += board_common.o
 obj-$(CONFIG_BOARD_EARLY_INIT_R) += board_early_init_r.o
 obj-$(CONFIG_BOARD_LATE_INIT) += board_late_init.o
+obj-y += reset.o
+obj-y += cache_uniphier.o
 obj-$(CONFIG_UNIPHIER_SMP) += smp.o
 obj-$(CONFIG_CMD_PINMON) += cmd_pinmon.o
 obj-$(CONFIG_CMD_DDRPHY_DUMP) += cmd_ddrphy.o
 
-obj-y += board_common.o
+endif
+
+obj-y += timer.o
+
 obj-$(CONFIG_PFC_MICRO_SUPPORT_CARD) += support_card.o
 obj-$(CONFIG_DCC_MICRO_SUPPORT_CARD) += support_card.o
 
diff --git a/arch/arm/cpu/armv7/uniphier/board_early_init_f.c b/arch/arm/cpu/armv7/uniphier/board_early_init_f.c
new file mode 100644 (file)
index 0000000..d25bbae
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2012-2015 Panasonic Corporation
+ *   Author: Masahiro Yamada <yamada.m@jp.panasonic.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <asm/arch/led.h>
+#include <asm/arch/board.h>
+
+void pin_init(void);
+
+int board_early_init_f(void)
+{
+       led_write(U, 0, , );
+
+       pin_init();
+
+       led_write(U, 1, , );
+
+       return 0;
+}
diff --git a/arch/arm/cpu/armv7/uniphier/board_postclk_init.c b/arch/arm/cpu/armv7/uniphier/board_postclk_init.c
deleted file mode 100644 (file)
index 89e44bb..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2012-2014 Panasonic Corporation
- *   Author: Masahiro Yamada <yamada.m@jp.panasonic.com>
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#include <linux/compiler.h>
-#include <asm/arch/led.h>
-#include <asm/arch/board.h>
-
-void __weak bcu_init(void)
-{
-};
-void sbc_init(void);
-void sg_init(void);
-void pll_init(void);
-void pin_init(void);
-void clkrst_init(void);
-
-int board_postclk_init(void)
-{
-#ifdef CONFIG_SOC_INIT
-       bcu_init();
-
-       sbc_init();
-
-       sg_init();
-
-       uniphier_board_reset();
-
-       pll_init();
-
-       uniphier_board_init();
-
-       led_write(B, 1, , );
-
-       clkrst_init();
-
-       led_write(B, 2, , );
-#endif
-       pin_init();
-
-       led_write(B, 3, , );
-
-       return 0;
-}
index 3561b40a33196deed9568fcf5fd57ddc1675c07b..3c1b32597646b94a8c7f20be000a4feaff3eb750 100644 (file)
 
 static int do_pinmon(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
-       struct boot_device_info *table;
-       u32 mode_sel, n = 0;
-
-       mode_sel = get_boot_mode_sel();
+       int mode_sel, i;
 
        printf("Boot Swap: %s\n\n", boot_is_swapped() ? "ON" : "OFF");
 
+       mode_sel = get_boot_mode_sel();
+
        puts("Boot Mode Pin:\n");
 
-       for (table = boot_device_table; strlen(table->info); table++) {
-               printf(" %c %02x %s\n", n == mode_sel ? '*' : ' ', n,
-                      table->info);
-               n++;
-       }
+       for (i = 0; boot_device_table[i].info; i++)
+               printf(" %c %02x %s\n", i == mode_sel ? '*' : ' ', i,
+                      boot_device_table[i].info);
 
        return 0;
 }
index 7de657b7af91d53bddd4639cc77b8603f0548d60..4b8c938b5ead10b2362b2a7b956315e6cff6f42a 100644 (file)
@@ -1,37 +1,16 @@
 /*
- * Copyright (C) 2012-2014 Panasonic Corporation
+ * Copyright (C) 2012-2015 Panasonic Corporation
  *   Author: Masahiro Yamada <yamada.m@jp.panasonic.com>
  *
  * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <common.h>
-#include <asm/arch/led.h>
-
-int umc_init(void);
-void enable_dpll_ssc(void);
 
 int dram_init(void)
 {
        DECLARE_GLOBAL_DATA_PTR;
        gd->ram_size = CONFIG_SYS_SDRAM_SIZE;
 
-#ifdef CONFIG_DRAM_INIT
-       led_write(B, 4, , );
-
-       {
-               int res;
-
-               res = umc_init();
-               if (res < 0)
-                       return res;
-       }
-       led_write(B, 5, , );
-
-       enable_dpll_ssc();
-#endif
-
-       led_write(B, 6, , );
-
        return 0;
 }
diff --git a/arch/arm/cpu/armv7/uniphier/init_page_table.S b/arch/arm/cpu/armv7/uniphier/init_page_table.S
new file mode 100644 (file)
index 0000000..2638bcd
--- /dev/null
@@ -0,0 +1,26 @@
+#include <config.h>
+#include <linux/linkage.h>
+
+/* page table */
+#define NR_SECTIONS    4096
+#define SECTION_SHIFT  20
+#define DEVICE 0x00002002 /* Non-shareable Device */
+#define NORMAL 0x0000000e /* Normal Memory Write-Back, No Write-Allocate */
+
+#define TEXT_SECTION   ((CONFIG_SPL_TEXT_BASE) >> (SECTION_SHIFT))
+#define STACK_SECTION  ((CONFIG_SYS_INIT_SP_ADDR) >> (SECTION_SHIFT))
+
+       .section ".rodata"
+       .align 14
+ENTRY(init_page_table)
+       section = 0
+       .rept NR_SECTIONS
+       .if section == TEXT_SECTION || section == STACK_SECTION
+       attr = NORMAL
+       .else
+       attr = DEVICE
+       .endif
+       .word (section << SECTION_SHIFT) | attr
+       section = section + 1
+       .endr
+END(init_page_table)
diff --git a/arch/arm/cpu/armv7/uniphier/init_page_table.c b/arch/arm/cpu/armv7/uniphier/init_page_table.c
deleted file mode 100644 (file)
index febb3c8..0000000
+++ /dev/null
@@ -1,1069 +0,0 @@
-/*
- * Copyright (C) 2012-2014 Panasonic Corporation
- *   Author: Masahiro Yamada <yamada.m@jp.panasonic.com>
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#include <common.h>
-
-/* encoding without TEX remap */
-#define NO_MAP 0x00000000 /* No Map */
-#define DEVICE 0x00002002 /* Non-shareable Device */
-#define NORMAL 0x0000000e /* Normal Memory Write-Back, No Write-Allocate */
-
-#define SSC    NORMAL  /* System Cache: Normal */
-#define EXT    DEVICE  /* External Bus: Device */
-#define REG    DEVICE  /* IO Register: Device */
-#define DDR    DEVICE  /* DDR SDRAM: Device */
-
-#define IS_SPL_TEXT_AREA(x)    ((x) == ((CONFIG_SPL_TEXT_BASE) >> 20))
-
-#define IS_INIT_STACK_AREA(x)  ((x) == ((CONFIG_SYS_INIT_SP_ADDR) >> 20))
-
-#define IS_SSC(x)              ((IS_SPL_TEXT_AREA(x)) || \
-                                       (IS_INIT_STACK_AREA(x)))
-#define IS_EXT(x)              ((x) < 0x100)
-
-/* 0x20000000-0x2fffffff, 0xf0000000-0xffffffff are only used by PH1-sLD3 */
-#define IS_REG(x)              (0x200 <= (x) && (x) < 0x300) || \
-                               (0x500 <= (x) && (x) < 0x700) || \
-                               (0xf00 <= (x))
-
-#define IS_DDR(x)              (0x800 <= (x) && (x) < 0xf00)
-
-#define MMU_FLAGS(x)           (IS_SSC(x)) ? SSC : \
-                                       (IS_EXT(x)) ? EXT : \
-                                               (IS_REG(x)) ? REG : \
-                                                       (IS_DDR(x)) ? DDR : \
-                                                               NO_MAP
-
-#define TBL_ENTRY(x)           (((x) << 20) | (MMU_FLAGS(x)))
-
-const u32 __aligned(PGTABLE_SIZE) init_page_table[PGTABLE_SIZE / sizeof(u32)]
-                                                                       = {
-       TBL_ENTRY(0x000), TBL_ENTRY(0x001), TBL_ENTRY(0x002), TBL_ENTRY(0x003),
-       TBL_ENTRY(0x004), TBL_ENTRY(0x005), TBL_ENTRY(0x006), TBL_ENTRY(0x007),
-       TBL_ENTRY(0x008), TBL_ENTRY(0x009), TBL_ENTRY(0x00a), TBL_ENTRY(0x00b),
-       TBL_ENTRY(0x00c), TBL_ENTRY(0x00d), TBL_ENTRY(0x00e), TBL_ENTRY(0x00f),
-       TBL_ENTRY(0x010), TBL_ENTRY(0x011), TBL_ENTRY(0x012), TBL_ENTRY(0x013),
-       TBL_ENTRY(0x014), TBL_ENTRY(0x015), TBL_ENTRY(0x016), TBL_ENTRY(0x017),
-       TBL_ENTRY(0x018), TBL_ENTRY(0x019), TBL_ENTRY(0x01a), TBL_ENTRY(0x01b),
-       TBL_ENTRY(0x01c), TBL_ENTRY(0x01d), TBL_ENTRY(0x01e), TBL_ENTRY(0x01f),
-       TBL_ENTRY(0x020), TBL_ENTRY(0x021), TBL_ENTRY(0x022), TBL_ENTRY(0x023),
-       TBL_ENTRY(0x024), TBL_ENTRY(0x025), TBL_ENTRY(0x026), TBL_ENTRY(0x027),
-       TBL_ENTRY(0x028), TBL_ENTRY(0x029), TBL_ENTRY(0x02a), TBL_ENTRY(0x02b),
-       TBL_ENTRY(0x02c), TBL_ENTRY(0x02d), TBL_ENTRY(0x02e), TBL_ENTRY(0x02f),
-       TBL_ENTRY(0x030), TBL_ENTRY(0x031), TBL_ENTRY(0x032), TBL_ENTRY(0x033),
-       TBL_ENTRY(0x034), TBL_ENTRY(0x035), TBL_ENTRY(0x036), TBL_ENTRY(0x037),
-       TBL_ENTRY(0x038), TBL_ENTRY(0x039), TBL_ENTRY(0x03a), TBL_ENTRY(0x03b),
-       TBL_ENTRY(0x03c), TBL_ENTRY(0x03d), TBL_ENTRY(0x03e), TBL_ENTRY(0x03f),
-       TBL_ENTRY(0x040), TBL_ENTRY(0x041), TBL_ENTRY(0x042), TBL_ENTRY(0x043),
-       TBL_ENTRY(0x044), TBL_ENTRY(0x045), TBL_ENTRY(0x046), TBL_ENTRY(0x047),
-       TBL_ENTRY(0x048), TBL_ENTRY(0x049), TBL_ENTRY(0x04a), TBL_ENTRY(0x04b),
-       TBL_ENTRY(0x04c), TBL_ENTRY(0x04d), TBL_ENTRY(0x04e), TBL_ENTRY(0x04f),
-       TBL_ENTRY(0x050), TBL_ENTRY(0x051), TBL_ENTRY(0x052), TBL_ENTRY(0x053),
-       TBL_ENTRY(0x054), TBL_ENTRY(0x055), TBL_ENTRY(0x056), TBL_ENTRY(0x057),
-       TBL_ENTRY(0x058), TBL_ENTRY(0x059), TBL_ENTRY(0x05a), TBL_ENTRY(0x05b),
-       TBL_ENTRY(0x05c), TBL_ENTRY(0x05d), TBL_ENTRY(0x05e), TBL_ENTRY(0x05f),
-       TBL_ENTRY(0x060), TBL_ENTRY(0x061), TBL_ENTRY(0x062), TBL_ENTRY(0x063),
-       TBL_ENTRY(0x064), TBL_ENTRY(0x065), TBL_ENTRY(0x066), TBL_ENTRY(0x067),
-       TBL_ENTRY(0x068), TBL_ENTRY(0x069), TBL_ENTRY(0x06a), TBL_ENTRY(0x06b),
-       TBL_ENTRY(0x06c), TBL_ENTRY(0x06d), TBL_ENTRY(0x06e), TBL_ENTRY(0x06f),
-       TBL_ENTRY(0x070), TBL_ENTRY(0x071), TBL_ENTRY(0x072), TBL_ENTRY(0x073),
-       TBL_ENTRY(0x074), TBL_ENTRY(0x075), TBL_ENTRY(0x076), TBL_ENTRY(0x077),
-       TBL_ENTRY(0x078), TBL_ENTRY(0x079), TBL_ENTRY(0x07a), TBL_ENTRY(0x07b),
-       TBL_ENTRY(0x07c), TBL_ENTRY(0x07d), TBL_ENTRY(0x07e), TBL_ENTRY(0x07f),
-       TBL_ENTRY(0x080), TBL_ENTRY(0x081), TBL_ENTRY(0x082), TBL_ENTRY(0x083),
-       TBL_ENTRY(0x084), TBL_ENTRY(0x085), TBL_ENTRY(0x086), TBL_ENTRY(0x087),
-       TBL_ENTRY(0x088), TBL_ENTRY(0x089), TBL_ENTRY(0x08a), TBL_ENTRY(0x08b),
-       TBL_ENTRY(0x08c), TBL_ENTRY(0x08d), TBL_ENTRY(0x08e), TBL_ENTRY(0x08f),
-       TBL_ENTRY(0x090), TBL_ENTRY(0x091), TBL_ENTRY(0x092), TBL_ENTRY(0x093),
-       TBL_ENTRY(0x094), TBL_ENTRY(0x095), TBL_ENTRY(0x096), TBL_ENTRY(0x097),
-       TBL_ENTRY(0x098), TBL_ENTRY(0x099), TBL_ENTRY(0x09a), TBL_ENTRY(0x09b),
-       TBL_ENTRY(0x09c), TBL_ENTRY(0x09d), TBL_ENTRY(0x09e), TBL_ENTRY(0x09f),
-       TBL_ENTRY(0x0a0), TBL_ENTRY(0x0a1), TBL_ENTRY(0x0a2), TBL_ENTRY(0x0a3),
-       TBL_ENTRY(0x0a4), TBL_ENTRY(0x0a5), TBL_ENTRY(0x0a6), TBL_ENTRY(0x0a7),
-       TBL_ENTRY(0x0a8), TBL_ENTRY(0x0a9), TBL_ENTRY(0x0aa), TBL_ENTRY(0x0ab),
-       TBL_ENTRY(0x0ac), TBL_ENTRY(0x0ad), TBL_ENTRY(0x0ae), TBL_ENTRY(0x0af),
-       TBL_ENTRY(0x0b0), TBL_ENTRY(0x0b1), TBL_ENTRY(0x0b2), TBL_ENTRY(0x0b3),
-       TBL_ENTRY(0x0b4), TBL_ENTRY(0x0b5), TBL_ENTRY(0x0b6), TBL_ENTRY(0x0b7),
-       TBL_ENTRY(0x0b8), TBL_ENTRY(0x0b9), TBL_ENTRY(0x0ba), TBL_ENTRY(0x0bb),
-       TBL_ENTRY(0x0bc), TBL_ENTRY(0x0bd), TBL_ENTRY(0x0be), TBL_ENTRY(0x0bf),
-       TBL_ENTRY(0x0c0), TBL_ENTRY(0x0c1), TBL_ENTRY(0x0c2), TBL_ENTRY(0x0c3),
-       TBL_ENTRY(0x0c4), TBL_ENTRY(0x0c5), TBL_ENTRY(0x0c6), TBL_ENTRY(0x0c7),
-       TBL_ENTRY(0x0c8), TBL_ENTRY(0x0c9), TBL_ENTRY(0x0ca), TBL_ENTRY(0x0cb),
-       TBL_ENTRY(0x0cc), TBL_ENTRY(0x0cd), TBL_ENTRY(0x0ce), TBL_ENTRY(0x0cf),
-       TBL_ENTRY(0x0d0), TBL_ENTRY(0x0d1), TBL_ENTRY(0x0d2), TBL_ENTRY(0x0d3),
-       TBL_ENTRY(0x0d4), TBL_ENTRY(0x0d5), TBL_ENTRY(0x0d6), TBL_ENTRY(0x0d7),
-       TBL_ENTRY(0x0d8), TBL_ENTRY(0x0d9), TBL_ENTRY(0x0da), TBL_ENTRY(0x0db),
-       TBL_ENTRY(0x0dc), TBL_ENTRY(0x0dd), TBL_ENTRY(0x0de), TBL_ENTRY(0x0df),
-       TBL_ENTRY(0x0e0), TBL_ENTRY(0x0e1), TBL_ENTRY(0x0e2), TBL_ENTRY(0x0e3),
-       TBL_ENTRY(0x0e4), TBL_ENTRY(0x0e5), TBL_ENTRY(0x0e6), TBL_ENTRY(0x0e7),
-       TBL_ENTRY(0x0e8), TBL_ENTRY(0x0e9), TBL_ENTRY(0x0ea), TBL_ENTRY(0x0eb),
-       TBL_ENTRY(0x0ec), TBL_ENTRY(0x0ed), TBL_ENTRY(0x0ee), TBL_ENTRY(0x0ef),
-       TBL_ENTRY(0x0f0), TBL_ENTRY(0x0f1), TBL_ENTRY(0x0f2), TBL_ENTRY(0x0f3),
-       TBL_ENTRY(0x0f4), TBL_ENTRY(0x0f5), TBL_ENTRY(0x0f6), TBL_ENTRY(0x0f7),
-       TBL_ENTRY(0x0f8), TBL_ENTRY(0x0f9), TBL_ENTRY(0x0fa), TBL_ENTRY(0x0fb),
-       TBL_ENTRY(0x0fc), TBL_ENTRY(0x0fd), TBL_ENTRY(0x0fe), TBL_ENTRY(0x0ff),
-       TBL_ENTRY(0x100), TBL_ENTRY(0x101), TBL_ENTRY(0x102), TBL_ENTRY(0x103),
-       TBL_ENTRY(0x104), TBL_ENTRY(0x105), TBL_ENTRY(0x106), TBL_ENTRY(0x107),
-       TBL_ENTRY(0x108), TBL_ENTRY(0x109), TBL_ENTRY(0x10a), TBL_ENTRY(0x10b),
-       TBL_ENTRY(0x10c), TBL_ENTRY(0x10d), TBL_ENTRY(0x10e), TBL_ENTRY(0x10f),
-       TBL_ENTRY(0x110), TBL_ENTRY(0x111), TBL_ENTRY(0x112), TBL_ENTRY(0x113),
-       TBL_ENTRY(0x114), TBL_ENTRY(0x115), TBL_ENTRY(0x116), TBL_ENTRY(0x117),
-       TBL_ENTRY(0x118), TBL_ENTRY(0x119), TBL_ENTRY(0x11a), TBL_ENTRY(0x11b),
-       TBL_ENTRY(0x11c), TBL_ENTRY(0x11d), TBL_ENTRY(0x11e), TBL_ENTRY(0x11f),
-       TBL_ENTRY(0x120), TBL_ENTRY(0x121), TBL_ENTRY(0x122), TBL_ENTRY(0x123),
-       TBL_ENTRY(0x124), TBL_ENTRY(0x125), TBL_ENTRY(0x126), TBL_ENTRY(0x127),
-       TBL_ENTRY(0x128), TBL_ENTRY(0x129), TBL_ENTRY(0x12a), TBL_ENTRY(0x12b),
-       TBL_ENTRY(0x12c), TBL_ENTRY(0x12d), TBL_ENTRY(0x12e), TBL_ENTRY(0x12f),
-       TBL_ENTRY(0x130), TBL_ENTRY(0x131), TBL_ENTRY(0x132), TBL_ENTRY(0x133),
-       TBL_ENTRY(0x134), TBL_ENTRY(0x135), TBL_ENTRY(0x136), TBL_ENTRY(0x137),
-       TBL_ENTRY(0x138), TBL_ENTRY(0x139), TBL_ENTRY(0x13a), TBL_ENTRY(0x13b),
-       TBL_ENTRY(0x13c), TBL_ENTRY(0x13d), TBL_ENTRY(0x13e), TBL_ENTRY(0x13f),
-       TBL_ENTRY(0x140), TBL_ENTRY(0x141), TBL_ENTRY(0x142), TBL_ENTRY(0x143),
-       TBL_ENTRY(0x144), TBL_ENTRY(0x145), TBL_ENTRY(0x146), TBL_ENTRY(0x147),
-       TBL_ENTRY(0x148), TBL_ENTRY(0x149), TBL_ENTRY(0x14a), TBL_ENTRY(0x14b),
-       TBL_ENTRY(0x14c), TBL_ENTRY(0x14d), TBL_ENTRY(0x14e), TBL_ENTRY(0x14f),
-       TBL_ENTRY(0x150), TBL_ENTRY(0x151), TBL_ENTRY(0x152), TBL_ENTRY(0x153),
-       TBL_ENTRY(0x154), TBL_ENTRY(0x155), TBL_ENTRY(0x156), TBL_ENTRY(0x157),
-       TBL_ENTRY(0x158), TBL_ENTRY(0x159), TBL_ENTRY(0x15a), TBL_ENTRY(0x15b),
-       TBL_ENTRY(0x15c), TBL_ENTRY(0x15d), TBL_ENTRY(0x15e), TBL_ENTRY(0x15f),
-       TBL_ENTRY(0x160), TBL_ENTRY(0x161), TBL_ENTRY(0x162), TBL_ENTRY(0x163),
-       TBL_ENTRY(0x164), TBL_ENTRY(0x165), TBL_ENTRY(0x166), TBL_ENTRY(0x167),
-       TBL_ENTRY(0x168), TBL_ENTRY(0x169), TBL_ENTRY(0x16a), TBL_ENTRY(0x16b),
-       TBL_ENTRY(0x16c), TBL_ENTRY(0x16d), TBL_ENTRY(0x16e), TBL_ENTRY(0x16f),
-       TBL_ENTRY(0x170), TBL_ENTRY(0x171), TBL_ENTRY(0x172), TBL_ENTRY(0x173),
-       TBL_ENTRY(0x174), TBL_ENTRY(0x175), TBL_ENTRY(0x176), TBL_ENTRY(0x177),
-       TBL_ENTRY(0x178), TBL_ENTRY(0x179), TBL_ENTRY(0x17a), TBL_ENTRY(0x17b),
-       TBL_ENTRY(0x17c), TBL_ENTRY(0x17d), TBL_ENTRY(0x17e), TBL_ENTRY(0x17f),
-       TBL_ENTRY(0x180), TBL_ENTRY(0x181), TBL_ENTRY(0x182), TBL_ENTRY(0x183),
-       TBL_ENTRY(0x184), TBL_ENTRY(0x185), TBL_ENTRY(0x186), TBL_ENTRY(0x187),
-       TBL_ENTRY(0x188), TBL_ENTRY(0x189), TBL_ENTRY(0x18a), TBL_ENTRY(0x18b),
-       TBL_ENTRY(0x18c), TBL_ENTRY(0x18d), TBL_ENTRY(0x18e), TBL_ENTRY(0x18f),
-       TBL_ENTRY(0x190), TBL_ENTRY(0x191), TBL_ENTRY(0x192), TBL_ENTRY(0x193),
-       TBL_ENTRY(0x194), TBL_ENTRY(0x195), TBL_ENTRY(0x196), TBL_ENTRY(0x197),
-       TBL_ENTRY(0x198), TBL_ENTRY(0x199), TBL_ENTRY(0x19a), TBL_ENTRY(0x19b),
-       TBL_ENTRY(0x19c), TBL_ENTRY(0x19d), TBL_ENTRY(0x19e), TBL_ENTRY(0x19f),
-       TBL_ENTRY(0x1a0), TBL_ENTRY(0x1a1), TBL_ENTRY(0x1a2), TBL_ENTRY(0x1a3),
-       TBL_ENTRY(0x1a4), TBL_ENTRY(0x1a5), TBL_ENTRY(0x1a6), TBL_ENTRY(0x1a7),
-       TBL_ENTRY(0x1a8), TBL_ENTRY(0x1a9), TBL_ENTRY(0x1aa), TBL_ENTRY(0x1ab),
-       TBL_ENTRY(0x1ac), TBL_ENTRY(0x1ad), TBL_ENTRY(0x1ae), TBL_ENTRY(0x1af),
-       TBL_ENTRY(0x1b0), TBL_ENTRY(0x1b1), TBL_ENTRY(0x1b2), TBL_ENTRY(0x1b3),
-       TBL_ENTRY(0x1b4), TBL_ENTRY(0x1b5), TBL_ENTRY(0x1b6), TBL_ENTRY(0x1b7),
-       TBL_ENTRY(0x1b8), TBL_ENTRY(0x1b9), TBL_ENTRY(0x1ba), TBL_ENTRY(0x1bb),
-       TBL_ENTRY(0x1bc), TBL_ENTRY(0x1bd), TBL_ENTRY(0x1be), TBL_ENTRY(0x1bf),
-       TBL_ENTRY(0x1c0), TBL_ENTRY(0x1c1), TBL_ENTRY(0x1c2), TBL_ENTRY(0x1c3),
-       TBL_ENTRY(0x1c4), TBL_ENTRY(0x1c5), TBL_ENTRY(0x1c6), TBL_ENTRY(0x1c7),
-       TBL_ENTRY(0x1c8), TBL_ENTRY(0x1c9), TBL_ENTRY(0x1ca), TBL_ENTRY(0x1cb),
-       TBL_ENTRY(0x1cc), TBL_ENTRY(0x1cd), TBL_ENTRY(0x1ce), TBL_ENTRY(0x1cf),
-       TBL_ENTRY(0x1d0), TBL_ENTRY(0x1d1), TBL_ENTRY(0x1d2), TBL_ENTRY(0x1d3),
-       TBL_ENTRY(0x1d4), TBL_ENTRY(0x1d5), TBL_ENTRY(0x1d6), TBL_ENTRY(0x1d7),
-       TBL_ENTRY(0x1d8), TBL_ENTRY(0x1d9), TBL_ENTRY(0x1da), TBL_ENTRY(0x1db),
-       TBL_ENTRY(0x1dc), TBL_ENTRY(0x1dd), TBL_ENTRY(0x1de), TBL_ENTRY(0x1df),
-       TBL_ENTRY(0x1e0), TBL_ENTRY(0x1e1), TBL_ENTRY(0x1e2), TBL_ENTRY(0x1e3),
-       TBL_ENTRY(0x1e4), TBL_ENTRY(0x1e5), TBL_ENTRY(0x1e6), TBL_ENTRY(0x1e7),
-       TBL_ENTRY(0x1e8), TBL_ENTRY(0x1e9), TBL_ENTRY(0x1ea), TBL_ENTRY(0x1eb),
-       TBL_ENTRY(0x1ec), TBL_ENTRY(0x1ed), TBL_ENTRY(0x1ee), TBL_ENTRY(0x1ef),
-       TBL_ENTRY(0x1f0), TBL_ENTRY(0x1f1), TBL_ENTRY(0x1f2), TBL_ENTRY(0x1f3),
-       TBL_ENTRY(0x1f4), TBL_ENTRY(0x1f5), TBL_ENTRY(0x1f6), TBL_ENTRY(0x1f7),
-       TBL_ENTRY(0x1f8), TBL_ENTRY(0x1f9), TBL_ENTRY(0x1fa), TBL_ENTRY(0x1fb),
-       TBL_ENTRY(0x1fc), TBL_ENTRY(0x1fd), TBL_ENTRY(0x1fe), TBL_ENTRY(0x1ff),
-       TBL_ENTRY(0x200), TBL_ENTRY(0x201), TBL_ENTRY(0x202), TBL_ENTRY(0x203),
-       TBL_ENTRY(0x204), TBL_ENTRY(0x205), TBL_ENTRY(0x206), TBL_ENTRY(0x207),
-       TBL_ENTRY(0x208), TBL_ENTRY(0x209), TBL_ENTRY(0x20a), TBL_ENTRY(0x20b),
-       TBL_ENTRY(0x20c), TBL_ENTRY(0x20d), TBL_ENTRY(0x20e), TBL_ENTRY(0x20f),
-       TBL_ENTRY(0x210), TBL_ENTRY(0x211), TBL_ENTRY(0x212), TBL_ENTRY(0x213),
-       TBL_ENTRY(0x214), TBL_ENTRY(0x215), TBL_ENTRY(0x216), TBL_ENTRY(0x217),
-       TBL_ENTRY(0x218), TBL_ENTRY(0x219), TBL_ENTRY(0x21a), TBL_ENTRY(0x21b),
-       TBL_ENTRY(0x21c), TBL_ENTRY(0x21d), TBL_ENTRY(0x21e), TBL_ENTRY(0x21f),
-       TBL_ENTRY(0x220), TBL_ENTRY(0x221), TBL_ENTRY(0x222), TBL_ENTRY(0x223),
-       TBL_ENTRY(0x224), TBL_ENTRY(0x225), TBL_ENTRY(0x226), TBL_ENTRY(0x227),
-       TBL_ENTRY(0x228), TBL_ENTRY(0x229), TBL_ENTRY(0x22a), TBL_ENTRY(0x22b),
-       TBL_ENTRY(0x22c), TBL_ENTRY(0x22d), TBL_ENTRY(0x22e), TBL_ENTRY(0x22f),
-       TBL_ENTRY(0x230), TBL_ENTRY(0x231), TBL_ENTRY(0x232), TBL_ENTRY(0x233),
-       TBL_ENTRY(0x234), TBL_ENTRY(0x235), TBL_ENTRY(0x236), TBL_ENTRY(0x237),
-       TBL_ENTRY(0x238), TBL_ENTRY(0x239), TBL_ENTRY(0x23a), TBL_ENTRY(0x23b),
-       TBL_ENTRY(0x23c), TBL_ENTRY(0x23d), TBL_ENTRY(0x23e), TBL_ENTRY(0x23f),
-       TBL_ENTRY(0x240), TBL_ENTRY(0x241), TBL_ENTRY(0x242), TBL_ENTRY(0x243),
-       TBL_ENTRY(0x244), TBL_ENTRY(0x245), TBL_ENTRY(0x246), TBL_ENTRY(0x247),
-       TBL_ENTRY(0x248), TBL_ENTRY(0x249), TBL_ENTRY(0x24a), TBL_ENTRY(0x24b),
-       TBL_ENTRY(0x24c), TBL_ENTRY(0x24d), TBL_ENTRY(0x24e), TBL_ENTRY(0x24f),
-       TBL_ENTRY(0x250), TBL_ENTRY(0x251), TBL_ENTRY(0x252), TBL_ENTRY(0x253),
-       TBL_ENTRY(0x254), TBL_ENTRY(0x255), TBL_ENTRY(0x256), TBL_ENTRY(0x257),
-       TBL_ENTRY(0x258), TBL_ENTRY(0x259), TBL_ENTRY(0x25a), TBL_ENTRY(0x25b),
-       TBL_ENTRY(0x25c), TBL_ENTRY(0x25d), TBL_ENTRY(0x25e), TBL_ENTRY(0x25f),
-       TBL_ENTRY(0x260), TBL_ENTRY(0x261), TBL_ENTRY(0x262), TBL_ENTRY(0x263),
-       TBL_ENTRY(0x264), TBL_ENTRY(0x265), TBL_ENTRY(0x266), TBL_ENTRY(0x267),
-       TBL_ENTRY(0x268), TBL_ENTRY(0x269), TBL_ENTRY(0x26a), TBL_ENTRY(0x26b),
-       TBL_ENTRY(0x26c), TBL_ENTRY(0x26d), TBL_ENTRY(0x26e), TBL_ENTRY(0x26f),
-       TBL_ENTRY(0x270), TBL_ENTRY(0x271), TBL_ENTRY(0x272), TBL_ENTRY(0x273),
-       TBL_ENTRY(0x274), TBL_ENTRY(0x275), TBL_ENTRY(0x276), TBL_ENTRY(0x277),
-       TBL_ENTRY(0x278), TBL_ENTRY(0x279), TBL_ENTRY(0x27a), TBL_ENTRY(0x27b),
-       TBL_ENTRY(0x27c), TBL_ENTRY(0x27d), TBL_ENTRY(0x27e), TBL_ENTRY(0x27f),
-       TBL_ENTRY(0x280), TBL_ENTRY(0x281), TBL_ENTRY(0x282), TBL_ENTRY(0x283),
-       TBL_ENTRY(0x284), TBL_ENTRY(0x285), TBL_ENTRY(0x286), TBL_ENTRY(0x287),
-       TBL_ENTRY(0x288), TBL_ENTRY(0x289), TBL_ENTRY(0x28a), TBL_ENTRY(0x28b),
-       TBL_ENTRY(0x28c), TBL_ENTRY(0x28d), TBL_ENTRY(0x28e), TBL_ENTRY(0x28f),
-       TBL_ENTRY(0x290), TBL_ENTRY(0x291), TBL_ENTRY(0x292), TBL_ENTRY(0x293),
-       TBL_ENTRY(0x294), TBL_ENTRY(0x295), TBL_ENTRY(0x296), TBL_ENTRY(0x297),
-       TBL_ENTRY(0x298), TBL_ENTRY(0x299), TBL_ENTRY(0x29a), TBL_ENTRY(0x29b),
-       TBL_ENTRY(0x29c), TBL_ENTRY(0x29d), TBL_ENTRY(0x29e), TBL_ENTRY(0x29f),
-       TBL_ENTRY(0x2a0), TBL_ENTRY(0x2a1), TBL_ENTRY(0x2a2), TBL_ENTRY(0x2a3),
-       TBL_ENTRY(0x2a4), TBL_ENTRY(0x2a5), TBL_ENTRY(0x2a6), TBL_ENTRY(0x2a7),
-       TBL_ENTRY(0x2a8), TBL_ENTRY(0x2a9), TBL_ENTRY(0x2aa), TBL_ENTRY(0x2ab),
-       TBL_ENTRY(0x2ac), TBL_ENTRY(0x2ad), TBL_ENTRY(0x2ae), TBL_ENTRY(0x2af),
-       TBL_ENTRY(0x2b0), TBL_ENTRY(0x2b1), TBL_ENTRY(0x2b2), TBL_ENTRY(0x2b3),
-       TBL_ENTRY(0x2b4), TBL_ENTRY(0x2b5), TBL_ENTRY(0x2b6), TBL_ENTRY(0x2b7),
-       TBL_ENTRY(0x2b8), TBL_ENTRY(0x2b9), TBL_ENTRY(0x2ba), TBL_ENTRY(0x2bb),
-       TBL_ENTRY(0x2bc), TBL_ENTRY(0x2bd), TBL_ENTRY(0x2be), TBL_ENTRY(0x2bf),
-       TBL_ENTRY(0x2c0), TBL_ENTRY(0x2c1), TBL_ENTRY(0x2c2), TBL_ENTRY(0x2c3),
-       TBL_ENTRY(0x2c4), TBL_ENTRY(0x2c5), TBL_ENTRY(0x2c6), TBL_ENTRY(0x2c7),
-       TBL_ENTRY(0x2c8), TBL_ENTRY(0x2c9), TBL_ENTRY(0x2ca), TBL_ENTRY(0x2cb),
-       TBL_ENTRY(0x2cc), TBL_ENTRY(0x2cd), TBL_ENTRY(0x2ce), TBL_ENTRY(0x2cf),
-       TBL_ENTRY(0x2d0), TBL_ENTRY(0x2d1), TBL_ENTRY(0x2d2), TBL_ENTRY(0x2d3),
-       TBL_ENTRY(0x2d4), TBL_ENTRY(0x2d5), TBL_ENTRY(0x2d6), TBL_ENTRY(0x2d7),
-       TBL_ENTRY(0x2d8), TBL_ENTRY(0x2d9), TBL_ENTRY(0x2da), TBL_ENTRY(0x2db),
-       TBL_ENTRY(0x2dc), TBL_ENTRY(0x2dd), TBL_ENTRY(0x2de), TBL_ENTRY(0x2df),
-       TBL_ENTRY(0x2e0), TBL_ENTRY(0x2e1), TBL_ENTRY(0x2e2), TBL_ENTRY(0x2e3),
-       TBL_ENTRY(0x2e4), TBL_ENTRY(0x2e5), TBL_ENTRY(0x2e6), TBL_ENTRY(0x2e7),
-       TBL_ENTRY(0x2e8), TBL_ENTRY(0x2e9), TBL_ENTRY(0x2ea), TBL_ENTRY(0x2eb),
-       TBL_ENTRY(0x2ec), TBL_ENTRY(0x2ed), TBL_ENTRY(0x2ee), TBL_ENTRY(0x2ef),
-       TBL_ENTRY(0x2f0), TBL_ENTRY(0x2f1), TBL_ENTRY(0x2f2), TBL_ENTRY(0x2f3),
-       TBL_ENTRY(0x2f4), TBL_ENTRY(0x2f5), TBL_ENTRY(0x2f6), TBL_ENTRY(0x2f7),
-       TBL_ENTRY(0x2f8), TBL_ENTRY(0x2f9), TBL_ENTRY(0x2fa), TBL_ENTRY(0x2fb),
-       TBL_ENTRY(0x2fc), TBL_ENTRY(0x2fd), TBL_ENTRY(0x2fe), TBL_ENTRY(0x2ff),
-       TBL_ENTRY(0x300), TBL_ENTRY(0x301), TBL_ENTRY(0x302), TBL_ENTRY(0x303),
-       TBL_ENTRY(0x304), TBL_ENTRY(0x305), TBL_ENTRY(0x306), TBL_ENTRY(0x307),
-       TBL_ENTRY(0x308), TBL_ENTRY(0x309), TBL_ENTRY(0x30a), TBL_ENTRY(0x30b),
-       TBL_ENTRY(0x30c), TBL_ENTRY(0x30d), TBL_ENTRY(0x30e), TBL_ENTRY(0x30f),
-       TBL_ENTRY(0x310), TBL_ENTRY(0x311), TBL_ENTRY(0x312), TBL_ENTRY(0x313),
-       TBL_ENTRY(0x314), TBL_ENTRY(0x315), TBL_ENTRY(0x316), TBL_ENTRY(0x317),
-       TBL_ENTRY(0x318), TBL_ENTRY(0x319), TBL_ENTRY(0x31a), TBL_ENTRY(0x31b),
-       TBL_ENTRY(0x31c), TBL_ENTRY(0x31d), TBL_ENTRY(0x31e), TBL_ENTRY(0x31f),
-       TBL_ENTRY(0x320), TBL_ENTRY(0x321), TBL_ENTRY(0x322), TBL_ENTRY(0x323),
-       TBL_ENTRY(0x324), TBL_ENTRY(0x325), TBL_ENTRY(0x326), TBL_ENTRY(0x327),
-       TBL_ENTRY(0x328), TBL_ENTRY(0x329), TBL_ENTRY(0x32a), TBL_ENTRY(0x32b),
-       TBL_ENTRY(0x32c), TBL_ENTRY(0x32d), TBL_ENTRY(0x32e), TBL_ENTRY(0x32f),
-       TBL_ENTRY(0x330), TBL_ENTRY(0x331), TBL_ENTRY(0x332), TBL_ENTRY(0x333),
-       TBL_ENTRY(0x334), TBL_ENTRY(0x335), TBL_ENTRY(0x336), TBL_ENTRY(0x337),
-       TBL_ENTRY(0x338), TBL_ENTRY(0x339), TBL_ENTRY(0x33a), TBL_ENTRY(0x33b),
-       TBL_ENTRY(0x33c), TBL_ENTRY(0x33d), TBL_ENTRY(0x33e), TBL_ENTRY(0x33f),
-       TBL_ENTRY(0x340), TBL_ENTRY(0x341), TBL_ENTRY(0x342), TBL_ENTRY(0x343),
-       TBL_ENTRY(0x344), TBL_ENTRY(0x345), TBL_ENTRY(0x346), TBL_ENTRY(0x347),
-       TBL_ENTRY(0x348), TBL_ENTRY(0x349), TBL_ENTRY(0x34a), TBL_ENTRY(0x34b),
-       TBL_ENTRY(0x34c), TBL_ENTRY(0x34d), TBL_ENTRY(0x34e), TBL_ENTRY(0x34f),
-       TBL_ENTRY(0x350), TBL_ENTRY(0x351), TBL_ENTRY(0x352), TBL_ENTRY(0x353),
-       TBL_ENTRY(0x354), TBL_ENTRY(0x355), TBL_ENTRY(0x356), TBL_ENTRY(0x357),
-       TBL_ENTRY(0x358), TBL_ENTRY(0x359), TBL_ENTRY(0x35a), TBL_ENTRY(0x35b),
-       TBL_ENTRY(0x35c), TBL_ENTRY(0x35d), TBL_ENTRY(0x35e), TBL_ENTRY(0x35f),
-       TBL_ENTRY(0x360), TBL_ENTRY(0x361), TBL_ENTRY(0x362), TBL_ENTRY(0x363),
-       TBL_ENTRY(0x364), TBL_ENTRY(0x365), TBL_ENTRY(0x366), TBL_ENTRY(0x367),
-       TBL_ENTRY(0x368), TBL_ENTRY(0x369), TBL_ENTRY(0x36a), TBL_ENTRY(0x36b),
-       TBL_ENTRY(0x36c), TBL_ENTRY(0x36d), TBL_ENTRY(0x36e), TBL_ENTRY(0x36f),
-       TBL_ENTRY(0x370), TBL_ENTRY(0x371), TBL_ENTRY(0x372), TBL_ENTRY(0x373),
-       TBL_ENTRY(0x374), TBL_ENTRY(0x375), TBL_ENTRY(0x376), TBL_ENTRY(0x377),
-       TBL_ENTRY(0x378), TBL_ENTRY(0x379), TBL_ENTRY(0x37a), TBL_ENTRY(0x37b),
-       TBL_ENTRY(0x37c), TBL_ENTRY(0x37d), TBL_ENTRY(0x37e), TBL_ENTRY(0x37f),
-       TBL_ENTRY(0x380), TBL_ENTRY(0x381), TBL_ENTRY(0x382), TBL_ENTRY(0x383),
-       TBL_ENTRY(0x384), TBL_ENTRY(0x385), TBL_ENTRY(0x386), TBL_ENTRY(0x387),
-       TBL_ENTRY(0x388), TBL_ENTRY(0x389), TBL_ENTRY(0x38a), TBL_ENTRY(0x38b),
-       TBL_ENTRY(0x38c), TBL_ENTRY(0x38d), TBL_ENTRY(0x38e), TBL_ENTRY(0x38f),
-       TBL_ENTRY(0x390), TBL_ENTRY(0x391), TBL_ENTRY(0x392), TBL_ENTRY(0x393),
-       TBL_ENTRY(0x394), TBL_ENTRY(0x395), TBL_ENTRY(0x396), TBL_ENTRY(0x397),
-       TBL_ENTRY(0x398), TBL_ENTRY(0x399), TBL_ENTRY(0x39a), TBL_ENTRY(0x39b),
-       TBL_ENTRY(0x39c), TBL_ENTRY(0x39d), TBL_ENTRY(0x39e), TBL_ENTRY(0x39f),
-       TBL_ENTRY(0x3a0), TBL_ENTRY(0x3a1), TBL_ENTRY(0x3a2), TBL_ENTRY(0x3a3),
-       TBL_ENTRY(0x3a4), TBL_ENTRY(0x3a5), TBL_ENTRY(0x3a6), TBL_ENTRY(0x3a7),
-       TBL_ENTRY(0x3a8), TBL_ENTRY(0x3a9), TBL_ENTRY(0x3aa), TBL_ENTRY(0x3ab),
-       TBL_ENTRY(0x3ac), TBL_ENTRY(0x3ad), TBL_ENTRY(0x3ae), TBL_ENTRY(0x3af),
-       TBL_ENTRY(0x3b0), TBL_ENTRY(0x3b1), TBL_ENTRY(0x3b2), TBL_ENTRY(0x3b3),
-       TBL_ENTRY(0x3b4), TBL_ENTRY(0x3b5), TBL_ENTRY(0x3b6), TBL_ENTRY(0x3b7),
-       TBL_ENTRY(0x3b8), TBL_ENTRY(0x3b9), TBL_ENTRY(0x3ba), TBL_ENTRY(0x3bb),
-       TBL_ENTRY(0x3bc), TBL_ENTRY(0x3bd), TBL_ENTRY(0x3be), TBL_ENTRY(0x3bf),
-       TBL_ENTRY(0x3c0), TBL_ENTRY(0x3c1), TBL_ENTRY(0x3c2), TBL_ENTRY(0x3c3),
-       TBL_ENTRY(0x3c4), TBL_ENTRY(0x3c5), TBL_ENTRY(0x3c6), TBL_ENTRY(0x3c7),
-       TBL_ENTRY(0x3c8), TBL_ENTRY(0x3c9), TBL_ENTRY(0x3ca), TBL_ENTRY(0x3cb),
-       TBL_ENTRY(0x3cc), TBL_ENTRY(0x3cd), TBL_ENTRY(0x3ce), TBL_ENTRY(0x3cf),
-       TBL_ENTRY(0x3d0), TBL_ENTRY(0x3d1), TBL_ENTRY(0x3d2), TBL_ENTRY(0x3d3),
-       TBL_ENTRY(0x3d4), TBL_ENTRY(0x3d5), TBL_ENTRY(0x3d6), TBL_ENTRY(0x3d7),
-       TBL_ENTRY(0x3d8), TBL_ENTRY(0x3d9), TBL_ENTRY(0x3da), TBL_ENTRY(0x3db),
-       TBL_ENTRY(0x3dc), TBL_ENTRY(0x3dd), TBL_ENTRY(0x3de), TBL_ENTRY(0x3df),
-       TBL_ENTRY(0x3e0), TBL_ENTRY(0x3e1), TBL_ENTRY(0x3e2), TBL_ENTRY(0x3e3),
-       TBL_ENTRY(0x3e4), TBL_ENTRY(0x3e5), TBL_ENTRY(0x3e6), TBL_ENTRY(0x3e7),
-       TBL_ENTRY(0x3e8), TBL_ENTRY(0x3e9), TBL_ENTRY(0x3ea), TBL_ENTRY(0x3eb),
-       TBL_ENTRY(0x3ec), TBL_ENTRY(0x3ed), TBL_ENTRY(0x3ee), TBL_ENTRY(0x3ef),
-       TBL_ENTRY(0x3f0), TBL_ENTRY(0x3f1), TBL_ENTRY(0x3f2), TBL_ENTRY(0x3f3),
-       TBL_ENTRY(0x3f4), TBL_ENTRY(0x3f5), TBL_ENTRY(0x3f6), TBL_ENTRY(0x3f7),
-       TBL_ENTRY(0x3f8), TBL_ENTRY(0x3f9), TBL_ENTRY(0x3fa), TBL_ENTRY(0x3fb),
-       TBL_ENTRY(0x3fc), TBL_ENTRY(0x3fd), TBL_ENTRY(0x3fe), TBL_ENTRY(0x3ff),
-       TBL_ENTRY(0x400), TBL_ENTRY(0x401), TBL_ENTRY(0x402), TBL_ENTRY(0x403),
-       TBL_ENTRY(0x404), TBL_ENTRY(0x405), TBL_ENTRY(0x406), TBL_ENTRY(0x407),
-       TBL_ENTRY(0x408), TBL_ENTRY(0x409), TBL_ENTRY(0x40a), TBL_ENTRY(0x40b),
-       TBL_ENTRY(0x40c), TBL_ENTRY(0x40d), TBL_ENTRY(0x40e), TBL_ENTRY(0x40f),
-       TBL_ENTRY(0x410), TBL_ENTRY(0x411), TBL_ENTRY(0x412), TBL_ENTRY(0x413),
-       TBL_ENTRY(0x414), TBL_ENTRY(0x415), TBL_ENTRY(0x416), TBL_ENTRY(0x417),
-       TBL_ENTRY(0x418), TBL_ENTRY(0x419), TBL_ENTRY(0x41a), TBL_ENTRY(0x41b),
-       TBL_ENTRY(0x41c), TBL_ENTRY(0x41d), TBL_ENTRY(0x41e), TBL_ENTRY(0x41f),
-       TBL_ENTRY(0x420), TBL_ENTRY(0x421), TBL_ENTRY(0x422), TBL_ENTRY(0x423),
-       TBL_ENTRY(0x424), TBL_ENTRY(0x425), TBL_ENTRY(0x426), TBL_ENTRY(0x427),
-       TBL_ENTRY(0x428), TBL_ENTRY(0x429), TBL_ENTRY(0x42a), TBL_ENTRY(0x42b),
-       TBL_ENTRY(0x42c), TBL_ENTRY(0x42d), TBL_ENTRY(0x42e), TBL_ENTRY(0x42f),
-       TBL_ENTRY(0x430), TBL_ENTRY(0x431), TBL_ENTRY(0x432), TBL_ENTRY(0x433),
-       TBL_ENTRY(0x434), TBL_ENTRY(0x435), TBL_ENTRY(0x436), TBL_ENTRY(0x437),
-       TBL_ENTRY(0x438), TBL_ENTRY(0x439), TBL_ENTRY(0x43a), TBL_ENTRY(0x43b),
-       TBL_ENTRY(0x43c), TBL_ENTRY(0x43d), TBL_ENTRY(0x43e), TBL_ENTRY(0x43f),
-       TBL_ENTRY(0x440), TBL_ENTRY(0x441), TBL_ENTRY(0x442), TBL_ENTRY(0x443),
-       TBL_ENTRY(0x444), TBL_ENTRY(0x445), TBL_ENTRY(0x446), TBL_ENTRY(0x447),
-       TBL_ENTRY(0x448), TBL_ENTRY(0x449), TBL_ENTRY(0x44a), TBL_ENTRY(0x44b),
-       TBL_ENTRY(0x44c), TBL_ENTRY(0x44d), TBL_ENTRY(0x44e), TBL_ENTRY(0x44f),
-       TBL_ENTRY(0x450), TBL_ENTRY(0x451), TBL_ENTRY(0x452), TBL_ENTRY(0x453),
-       TBL_ENTRY(0x454), TBL_ENTRY(0x455), TBL_ENTRY(0x456), TBL_ENTRY(0x457),
-       TBL_ENTRY(0x458), TBL_ENTRY(0x459), TBL_ENTRY(0x45a), TBL_ENTRY(0x45b),
-       TBL_ENTRY(0x45c), TBL_ENTRY(0x45d), TBL_ENTRY(0x45e), TBL_ENTRY(0x45f),
-       TBL_ENTRY(0x460), TBL_ENTRY(0x461), TBL_ENTRY(0x462), TBL_ENTRY(0x463),
-       TBL_ENTRY(0x464), TBL_ENTRY(0x465), TBL_ENTRY(0x466), TBL_ENTRY(0x467),
-       TBL_ENTRY(0x468), TBL_ENTRY(0x469), TBL_ENTRY(0x46a), TBL_ENTRY(0x46b),
-       TBL_ENTRY(0x46c), TBL_ENTRY(0x46d), TBL_ENTRY(0x46e), TBL_ENTRY(0x46f),
-       TBL_ENTRY(0x470), TBL_ENTRY(0x471), TBL_ENTRY(0x472), TBL_ENTRY(0x473),
-       TBL_ENTRY(0x474), TBL_ENTRY(0x475), TBL_ENTRY(0x476), TBL_ENTRY(0x477),
-       TBL_ENTRY(0x478), TBL_ENTRY(0x479), TBL_ENTRY(0x47a), TBL_ENTRY(0x47b),
-       TBL_ENTRY(0x47c), TBL_ENTRY(0x47d), TBL_ENTRY(0x47e), TBL_ENTRY(0x47f),
-       TBL_ENTRY(0x480), TBL_ENTRY(0x481), TBL_ENTRY(0x482), TBL_ENTRY(0x483),
-       TBL_ENTRY(0x484), TBL_ENTRY(0x485), TBL_ENTRY(0x486), TBL_ENTRY(0x487),
-       TBL_ENTRY(0x488), TBL_ENTRY(0x489), TBL_ENTRY(0x48a), TBL_ENTRY(0x48b),
-       TBL_ENTRY(0x48c), TBL_ENTRY(0x48d), TBL_ENTRY(0x48e), TBL_ENTRY(0x48f),
-       TBL_ENTRY(0x490), TBL_ENTRY(0x491), TBL_ENTRY(0x492), TBL_ENTRY(0x493),
-       TBL_ENTRY(0x494), TBL_ENTRY(0x495), TBL_ENTRY(0x496), TBL_ENTRY(0x497),
-       TBL_ENTRY(0x498), TBL_ENTRY(0x499), TBL_ENTRY(0x49a), TBL_ENTRY(0x49b),
-       TBL_ENTRY(0x49c), TBL_ENTRY(0x49d), TBL_ENTRY(0x49e), TBL_ENTRY(0x49f),
-       TBL_ENTRY(0x4a0), TBL_ENTRY(0x4a1), TBL_ENTRY(0x4a2), TBL_ENTRY(0x4a3),
-       TBL_ENTRY(0x4a4), TBL_ENTRY(0x4a5), TBL_ENTRY(0x4a6), TBL_ENTRY(0x4a7),
-       TBL_ENTRY(0x4a8), TBL_ENTRY(0x4a9), TBL_ENTRY(0x4aa), TBL_ENTRY(0x4ab),
-       TBL_ENTRY(0x4ac), TBL_ENTRY(0x4ad), TBL_ENTRY(0x4ae), TBL_ENTRY(0x4af),
-       TBL_ENTRY(0x4b0), TBL_ENTRY(0x4b1), TBL_ENTRY(0x4b2), TBL_ENTRY(0x4b3),
-       TBL_ENTRY(0x4b4), TBL_ENTRY(0x4b5), TBL_ENTRY(0x4b6), TBL_ENTRY(0x4b7),
-       TBL_ENTRY(0x4b8), TBL_ENTRY(0x4b9), TBL_ENTRY(0x4ba), TBL_ENTRY(0x4bb),
-       TBL_ENTRY(0x4bc), TBL_ENTRY(0x4bd), TBL_ENTRY(0x4be), TBL_ENTRY(0x4bf),
-       TBL_ENTRY(0x4c0), TBL_ENTRY(0x4c1), TBL_ENTRY(0x4c2), TBL_ENTRY(0x4c3),
-       TBL_ENTRY(0x4c4), TBL_ENTRY(0x4c5), TBL_ENTRY(0x4c6), TBL_ENTRY(0x4c7),
-       TBL_ENTRY(0x4c8), TBL_ENTRY(0x4c9), TBL_ENTRY(0x4ca), TBL_ENTRY(0x4cb),
-       TBL_ENTRY(0x4cc), TBL_ENTRY(0x4cd), TBL_ENTRY(0x4ce), TBL_ENTRY(0x4cf),
-       TBL_ENTRY(0x4d0), TBL_ENTRY(0x4d1), TBL_ENTRY(0x4d2), TBL_ENTRY(0x4d3),
-       TBL_ENTRY(0x4d4), TBL_ENTRY(0x4d5), TBL_ENTRY(0x4d6), TBL_ENTRY(0x4d7),
-       TBL_ENTRY(0x4d8), TBL_ENTRY(0x4d9), TBL_ENTRY(0x4da), TBL_ENTRY(0x4db),
-       TBL_ENTRY(0x4dc), TBL_ENTRY(0x4dd), TBL_ENTRY(0x4de), TBL_ENTRY(0x4df),
-       TBL_ENTRY(0x4e0), TBL_ENTRY(0x4e1), TBL_ENTRY(0x4e2), TBL_ENTRY(0x4e3),
-       TBL_ENTRY(0x4e4), TBL_ENTRY(0x4e5), TBL_ENTRY(0x4e6), TBL_ENTRY(0x4e7),
-       TBL_ENTRY(0x4e8), TBL_ENTRY(0x4e9), TBL_ENTRY(0x4ea), TBL_ENTRY(0x4eb),
-       TBL_ENTRY(0x4ec), TBL_ENTRY(0x4ed), TBL_ENTRY(0x4ee), TBL_ENTRY(0x4ef),
-       TBL_ENTRY(0x4f0), TBL_ENTRY(0x4f1), TBL_ENTRY(0x4f2), TBL_ENTRY(0x4f3),
-       TBL_ENTRY(0x4f4), TBL_ENTRY(0x4f5), TBL_ENTRY(0x4f6), TBL_ENTRY(0x4f7),
-       TBL_ENTRY(0x4f8), TBL_ENTRY(0x4f9), TBL_ENTRY(0x4fa), TBL_ENTRY(0x4fb),
-       TBL_ENTRY(0x4fc), TBL_ENTRY(0x4fd), TBL_ENTRY(0x4fe), TBL_ENTRY(0x4ff),
-       TBL_ENTRY(0x500), TBL_ENTRY(0x501), TBL_ENTRY(0x502), TBL_ENTRY(0x503),
-       TBL_ENTRY(0x504), TBL_ENTRY(0x505), TBL_ENTRY(0x506), TBL_ENTRY(0x507),
-       TBL_ENTRY(0x508), TBL_ENTRY(0x509), TBL_ENTRY(0x50a), TBL_ENTRY(0x50b),
-       TBL_ENTRY(0x50c), TBL_ENTRY(0x50d), TBL_ENTRY(0x50e), TBL_ENTRY(0x50f),
-       TBL_ENTRY(0x510), TBL_ENTRY(0x511), TBL_ENTRY(0x512), TBL_ENTRY(0x513),
-       TBL_ENTRY(0x514), TBL_ENTRY(0x515), TBL_ENTRY(0x516), TBL_ENTRY(0x517),
-       TBL_ENTRY(0x518), TBL_ENTRY(0x519), TBL_ENTRY(0x51a), TBL_ENTRY(0x51b),
-       TBL_ENTRY(0x51c), TBL_ENTRY(0x51d), TBL_ENTRY(0x51e), TBL_ENTRY(0x51f),
-       TBL_ENTRY(0x520), TBL_ENTRY(0x521), TBL_ENTRY(0x522), TBL_ENTRY(0x523),
-       TBL_ENTRY(0x524), TBL_ENTRY(0x525), TBL_ENTRY(0x526), TBL_ENTRY(0x527),
-       TBL_ENTRY(0x528), TBL_ENTRY(0x529), TBL_ENTRY(0x52a), TBL_ENTRY(0x52b),
-       TBL_ENTRY(0x52c), TBL_ENTRY(0x52d), TBL_ENTRY(0x52e), TBL_ENTRY(0x52f),
-       TBL_ENTRY(0x530), TBL_ENTRY(0x531), TBL_ENTRY(0x532), TBL_ENTRY(0x533),
-       TBL_ENTRY(0x534), TBL_ENTRY(0x535), TBL_ENTRY(0x536), TBL_ENTRY(0x537),
-       TBL_ENTRY(0x538), TBL_ENTRY(0x539), TBL_ENTRY(0x53a), TBL_ENTRY(0x53b),
-       TBL_ENTRY(0x53c), TBL_ENTRY(0x53d), TBL_ENTRY(0x53e), TBL_ENTRY(0x53f),
-       TBL_ENTRY(0x540), TBL_ENTRY(0x541), TBL_ENTRY(0x542), TBL_ENTRY(0x543),
-       TBL_ENTRY(0x544), TBL_ENTRY(0x545), TBL_ENTRY(0x546), TBL_ENTRY(0x547),
-       TBL_ENTRY(0x548), TBL_ENTRY(0x549), TBL_ENTRY(0x54a), TBL_ENTRY(0x54b),
-       TBL_ENTRY(0x54c), TBL_ENTRY(0x54d), TBL_ENTRY(0x54e), TBL_ENTRY(0x54f),
-       TBL_ENTRY(0x550), TBL_ENTRY(0x551), TBL_ENTRY(0x552), TBL_ENTRY(0x553),
-       TBL_ENTRY(0x554), TBL_ENTRY(0x555), TBL_ENTRY(0x556), TBL_ENTRY(0x557),
-       TBL_ENTRY(0x558), TBL_ENTRY(0x559), TBL_ENTRY(0x55a), TBL_ENTRY(0x55b),
-       TBL_ENTRY(0x55c), TBL_ENTRY(0x55d), TBL_ENTRY(0x55e), TBL_ENTRY(0x55f),
-       TBL_ENTRY(0x560), TBL_ENTRY(0x561), TBL_ENTRY(0x562), TBL_ENTRY(0x563),
-       TBL_ENTRY(0x564), TBL_ENTRY(0x565), TBL_ENTRY(0x566), TBL_ENTRY(0x567),
-       TBL_ENTRY(0x568), TBL_ENTRY(0x569), TBL_ENTRY(0x56a), TBL_ENTRY(0x56b),
-       TBL_ENTRY(0x56c), TBL_ENTRY(0x56d), TBL_ENTRY(0x56e), TBL_ENTRY(0x56f),
-       TBL_ENTRY(0x570), TBL_ENTRY(0x571), TBL_ENTRY(0x572), TBL_ENTRY(0x573),
-       TBL_ENTRY(0x574), TBL_ENTRY(0x575), TBL_ENTRY(0x576), TBL_ENTRY(0x577),
-       TBL_ENTRY(0x578), TBL_ENTRY(0x579), TBL_ENTRY(0x57a), TBL_ENTRY(0x57b),
-       TBL_ENTRY(0x57c), TBL_ENTRY(0x57d), TBL_ENTRY(0x57e), TBL_ENTRY(0x57f),
-       TBL_ENTRY(0x580), TBL_ENTRY(0x581), TBL_ENTRY(0x582), TBL_ENTRY(0x583),
-       TBL_ENTRY(0x584), TBL_ENTRY(0x585), TBL_ENTRY(0x586), TBL_ENTRY(0x587),
-       TBL_ENTRY(0x588), TBL_ENTRY(0x589), TBL_ENTRY(0x58a), TBL_ENTRY(0x58b),
-       TBL_ENTRY(0x58c), TBL_ENTRY(0x58d), TBL_ENTRY(0x58e), TBL_ENTRY(0x58f),
-       TBL_ENTRY(0x590), TBL_ENTRY(0x591), TBL_ENTRY(0x592), TBL_ENTRY(0x593),
-       TBL_ENTRY(0x594), TBL_ENTRY(0x595), TBL_ENTRY(0x596), TBL_ENTRY(0x597),
-       TBL_ENTRY(0x598), TBL_ENTRY(0x599), TBL_ENTRY(0x59a), TBL_ENTRY(0x59b),
-       TBL_ENTRY(0x59c), TBL_ENTRY(0x59d), TBL_ENTRY(0x59e), TBL_ENTRY(0x59f),
-       TBL_ENTRY(0x5a0), TBL_ENTRY(0x5a1), TBL_ENTRY(0x5a2), TBL_ENTRY(0x5a3),
-       TBL_ENTRY(0x5a4), TBL_ENTRY(0x5a5), TBL_ENTRY(0x5a6), TBL_ENTRY(0x5a7),
-       TBL_ENTRY(0x5a8), TBL_ENTRY(0x5a9), TBL_ENTRY(0x5aa), TBL_ENTRY(0x5ab),
-       TBL_ENTRY(0x5ac), TBL_ENTRY(0x5ad), TBL_ENTRY(0x5ae), TBL_ENTRY(0x5af),
-       TBL_ENTRY(0x5b0), TBL_ENTRY(0x5b1), TBL_ENTRY(0x5b2), TBL_ENTRY(0x5b3),
-       TBL_ENTRY(0x5b4), TBL_ENTRY(0x5b5), TBL_ENTRY(0x5b6), TBL_ENTRY(0x5b7),
-       TBL_ENTRY(0x5b8), TBL_ENTRY(0x5b9), TBL_ENTRY(0x5ba), TBL_ENTRY(0x5bb),
-       TBL_ENTRY(0x5bc), TBL_ENTRY(0x5bd), TBL_ENTRY(0x5be), TBL_ENTRY(0x5bf),
-       TBL_ENTRY(0x5c0), TBL_ENTRY(0x5c1), TBL_ENTRY(0x5c2), TBL_ENTRY(0x5c3),
-       TBL_ENTRY(0x5c4), TBL_ENTRY(0x5c5), TBL_ENTRY(0x5c6), TBL_ENTRY(0x5c7),
-       TBL_ENTRY(0x5c8), TBL_ENTRY(0x5c9), TBL_ENTRY(0x5ca), TBL_ENTRY(0x5cb),
-       TBL_ENTRY(0x5cc), TBL_ENTRY(0x5cd), TBL_ENTRY(0x5ce), TBL_ENTRY(0x5cf),
-       TBL_ENTRY(0x5d0), TBL_ENTRY(0x5d1), TBL_ENTRY(0x5d2), TBL_ENTRY(0x5d3),
-       TBL_ENTRY(0x5d4), TBL_ENTRY(0x5d5), TBL_ENTRY(0x5d6), TBL_ENTRY(0x5d7),
-       TBL_ENTRY(0x5d8), TBL_ENTRY(0x5d9), TBL_ENTRY(0x5da), TBL_ENTRY(0x5db),
-       TBL_ENTRY(0x5dc), TBL_ENTRY(0x5dd), TBL_ENTRY(0x5de), TBL_ENTRY(0x5df),
-       TBL_ENTRY(0x5e0), TBL_ENTRY(0x5e1), TBL_ENTRY(0x5e2), TBL_ENTRY(0x5e3),
-       TBL_ENTRY(0x5e4), TBL_ENTRY(0x5e5), TBL_ENTRY(0x5e6), TBL_ENTRY(0x5e7),
-       TBL_ENTRY(0x5e8), TBL_ENTRY(0x5e9), TBL_ENTRY(0x5ea), TBL_ENTRY(0x5eb),
-       TBL_ENTRY(0x5ec), TBL_ENTRY(0x5ed), TBL_ENTRY(0x5ee), TBL_ENTRY(0x5ef),
-       TBL_ENTRY(0x5f0), TBL_ENTRY(0x5f1), TBL_ENTRY(0x5f2), TBL_ENTRY(0x5f3),
-       TBL_ENTRY(0x5f4), TBL_ENTRY(0x5f5), TBL_ENTRY(0x5f6), TBL_ENTRY(0x5f7),
-       TBL_ENTRY(0x5f8), TBL_ENTRY(0x5f9), TBL_ENTRY(0x5fa), TBL_ENTRY(0x5fb),
-       TBL_ENTRY(0x5fc), TBL_ENTRY(0x5fd), TBL_ENTRY(0x5fe), TBL_ENTRY(0x5ff),
-       TBL_ENTRY(0x600), TBL_ENTRY(0x601), TBL_ENTRY(0x602), TBL_ENTRY(0x603),
-       TBL_ENTRY(0x604), TBL_ENTRY(0x605), TBL_ENTRY(0x606), TBL_ENTRY(0x607),
-       TBL_ENTRY(0x608), TBL_ENTRY(0x609), TBL_ENTRY(0x60a), TBL_ENTRY(0x60b),
-       TBL_ENTRY(0x60c), TBL_ENTRY(0x60d), TBL_ENTRY(0x60e), TBL_ENTRY(0x60f),
-       TBL_ENTRY(0x610), TBL_ENTRY(0x611), TBL_ENTRY(0x612), TBL_ENTRY(0x613),
-       TBL_ENTRY(0x614), TBL_ENTRY(0x615), TBL_ENTRY(0x616), TBL_ENTRY(0x617),
-       TBL_ENTRY(0x618), TBL_ENTRY(0x619), TBL_ENTRY(0x61a), TBL_ENTRY(0x61b),
-       TBL_ENTRY(0x61c), TBL_ENTRY(0x61d), TBL_ENTRY(0x61e), TBL_ENTRY(0x61f),
-       TBL_ENTRY(0x620), TBL_ENTRY(0x621), TBL_ENTRY(0x622), TBL_ENTRY(0x623),
-       TBL_ENTRY(0x624), TBL_ENTRY(0x625), TBL_ENTRY(0x626), TBL_ENTRY(0x627),
-       TBL_ENTRY(0x628), TBL_ENTRY(0x629), TBL_ENTRY(0x62a), TBL_ENTRY(0x62b),
-       TBL_ENTRY(0x62c), TBL_ENTRY(0x62d), TBL_ENTRY(0x62e), TBL_ENTRY(0x62f),
-       TBL_ENTRY(0x630), TBL_ENTRY(0x631), TBL_ENTRY(0x632), TBL_ENTRY(0x633),
-       TBL_ENTRY(0x634), TBL_ENTRY(0x635), TBL_ENTRY(0x636), TBL_ENTRY(0x637),
-       TBL_ENTRY(0x638), TBL_ENTRY(0x639), TBL_ENTRY(0x63a), TBL_ENTRY(0x63b),
-       TBL_ENTRY(0x63c), TBL_ENTRY(0x63d), TBL_ENTRY(0x63e), TBL_ENTRY(0x63f),
-       TBL_ENTRY(0x640), TBL_ENTRY(0x641), TBL_ENTRY(0x642), TBL_ENTRY(0x643),
-       TBL_ENTRY(0x644), TBL_ENTRY(0x645), TBL_ENTRY(0x646), TBL_ENTRY(0x647),
-       TBL_ENTRY(0x648), TBL_ENTRY(0x649), TBL_ENTRY(0x64a), TBL_ENTRY(0x64b),
-       TBL_ENTRY(0x64c), TBL_ENTRY(0x64d), TBL_ENTRY(0x64e), TBL_ENTRY(0x64f),
-       TBL_ENTRY(0x650), TBL_ENTRY(0x651), TBL_ENTRY(0x652), TBL_ENTRY(0x653),
-       TBL_ENTRY(0x654), TBL_ENTRY(0x655), TBL_ENTRY(0x656), TBL_ENTRY(0x657),
-       TBL_ENTRY(0x658), TBL_ENTRY(0x659), TBL_ENTRY(0x65a), TBL_ENTRY(0x65b),
-       TBL_ENTRY(0x65c), TBL_ENTRY(0x65d), TBL_ENTRY(0x65e), TBL_ENTRY(0x65f),
-       TBL_ENTRY(0x660), TBL_ENTRY(0x661), TBL_ENTRY(0x662), TBL_ENTRY(0x663),
-       TBL_ENTRY(0x664), TBL_ENTRY(0x665), TBL_ENTRY(0x666), TBL_ENTRY(0x667),
-       TBL_ENTRY(0x668), TBL_ENTRY(0x669), TBL_ENTRY(0x66a), TBL_ENTRY(0x66b),
-       TBL_ENTRY(0x66c), TBL_ENTRY(0x66d), TBL_ENTRY(0x66e), TBL_ENTRY(0x66f),
-       TBL_ENTRY(0x670), TBL_ENTRY(0x671), TBL_ENTRY(0x672), TBL_ENTRY(0x673),
-       TBL_ENTRY(0x674), TBL_ENTRY(0x675), TBL_ENTRY(0x676), TBL_ENTRY(0x677),
-       TBL_ENTRY(0x678), TBL_ENTRY(0x679), TBL_ENTRY(0x67a), TBL_ENTRY(0x67b),
-       TBL_ENTRY(0x67c), TBL_ENTRY(0x67d), TBL_ENTRY(0x67e), TBL_ENTRY(0x67f),
-       TBL_ENTRY(0x680), TBL_ENTRY(0x681), TBL_ENTRY(0x682), TBL_ENTRY(0x683),
-       TBL_ENTRY(0x684), TBL_ENTRY(0x685), TBL_ENTRY(0x686), TBL_ENTRY(0x687),
-       TBL_ENTRY(0x688), TBL_ENTRY(0x689), TBL_ENTRY(0x68a), TBL_ENTRY(0x68b),
-       TBL_ENTRY(0x68c), TBL_ENTRY(0x68d), TBL_ENTRY(0x68e), TBL_ENTRY(0x68f),
-       TBL_ENTRY(0x690), TBL_ENTRY(0x691), TBL_ENTRY(0x692), TBL_ENTRY(0x693),
-       TBL_ENTRY(0x694), TBL_ENTRY(0x695), TBL_ENTRY(0x696), TBL_ENTRY(0x697),
-       TBL_ENTRY(0x698), TBL_ENTRY(0x699), TBL_ENTRY(0x69a), TBL_ENTRY(0x69b),
-       TBL_ENTRY(0x69c), TBL_ENTRY(0x69d), TBL_ENTRY(0x69e), TBL_ENTRY(0x69f),
-       TBL_ENTRY(0x6a0), TBL_ENTRY(0x6a1), TBL_ENTRY(0x6a2), TBL_ENTRY(0x6a3),
-       TBL_ENTRY(0x6a4), TBL_ENTRY(0x6a5), TBL_ENTRY(0x6a6), TBL_ENTRY(0x6a7),
-       TBL_ENTRY(0x6a8), TBL_ENTRY(0x6a9), TBL_ENTRY(0x6aa), TBL_ENTRY(0x6ab),
-       TBL_ENTRY(0x6ac), TBL_ENTRY(0x6ad), TBL_ENTRY(0x6ae), TBL_ENTRY(0x6af),
-       TBL_ENTRY(0x6b0), TBL_ENTRY(0x6b1), TBL_ENTRY(0x6b2), TBL_ENTRY(0x6b3),
-       TBL_ENTRY(0x6b4), TBL_ENTRY(0x6b5), TBL_ENTRY(0x6b6), TBL_ENTRY(0x6b7),
-       TBL_ENTRY(0x6b8), TBL_ENTRY(0x6b9), TBL_ENTRY(0x6ba), TBL_ENTRY(0x6bb),
-       TBL_ENTRY(0x6bc), TBL_ENTRY(0x6bd), TBL_ENTRY(0x6be), TBL_ENTRY(0x6bf),
-       TBL_ENTRY(0x6c0), TBL_ENTRY(0x6c1), TBL_ENTRY(0x6c2), TBL_ENTRY(0x6c3),
-       TBL_ENTRY(0x6c4), TBL_ENTRY(0x6c5), TBL_ENTRY(0x6c6), TBL_ENTRY(0x6c7),
-       TBL_ENTRY(0x6c8), TBL_ENTRY(0x6c9), TBL_ENTRY(0x6ca), TBL_ENTRY(0x6cb),
-       TBL_ENTRY(0x6cc), TBL_ENTRY(0x6cd), TBL_ENTRY(0x6ce), TBL_ENTRY(0x6cf),
-       TBL_ENTRY(0x6d0), TBL_ENTRY(0x6d1), TBL_ENTRY(0x6d2), TBL_ENTRY(0x6d3),
-       TBL_ENTRY(0x6d4), TBL_ENTRY(0x6d5), TBL_ENTRY(0x6d6), TBL_ENTRY(0x6d7),
-       TBL_ENTRY(0x6d8), TBL_ENTRY(0x6d9), TBL_ENTRY(0x6da), TBL_ENTRY(0x6db),
-       TBL_ENTRY(0x6dc), TBL_ENTRY(0x6dd), TBL_ENTRY(0x6de), TBL_ENTRY(0x6df),
-       TBL_ENTRY(0x6e0), TBL_ENTRY(0x6e1), TBL_ENTRY(0x6e2), TBL_ENTRY(0x6e3),
-       TBL_ENTRY(0x6e4), TBL_ENTRY(0x6e5), TBL_ENTRY(0x6e6), TBL_ENTRY(0x6e7),
-       TBL_ENTRY(0x6e8), TBL_ENTRY(0x6e9), TBL_ENTRY(0x6ea), TBL_ENTRY(0x6eb),
-       TBL_ENTRY(0x6ec), TBL_ENTRY(0x6ed), TBL_ENTRY(0x6ee), TBL_ENTRY(0x6ef),
-       TBL_ENTRY(0x6f0), TBL_ENTRY(0x6f1), TBL_ENTRY(0x6f2), TBL_ENTRY(0x6f3),
-       TBL_ENTRY(0x6f4), TBL_ENTRY(0x6f5), TBL_ENTRY(0x6f6), TBL_ENTRY(0x6f7),
-       TBL_ENTRY(0x6f8), TBL_ENTRY(0x6f9), TBL_ENTRY(0x6fa), TBL_ENTRY(0x6fb),
-       TBL_ENTRY(0x6fc), TBL_ENTRY(0x6fd), TBL_ENTRY(0x6fe), TBL_ENTRY(0x6ff),
-       TBL_ENTRY(0x700), TBL_ENTRY(0x701), TBL_ENTRY(0x702), TBL_ENTRY(0x703),
-       TBL_ENTRY(0x704), TBL_ENTRY(0x705), TBL_ENTRY(0x706), TBL_ENTRY(0x707),
-       TBL_ENTRY(0x708), TBL_ENTRY(0x709), TBL_ENTRY(0x70a), TBL_ENTRY(0x70b),
-       TBL_ENTRY(0x70c), TBL_ENTRY(0x70d), TBL_ENTRY(0x70e), TBL_ENTRY(0x70f),
-       TBL_ENTRY(0x710), TBL_ENTRY(0x711), TBL_ENTRY(0x712), TBL_ENTRY(0x713),
-       TBL_ENTRY(0x714), TBL_ENTRY(0x715), TBL_ENTRY(0x716), TBL_ENTRY(0x717),
-       TBL_ENTRY(0x718), TBL_ENTRY(0x719), TBL_ENTRY(0x71a), TBL_ENTRY(0x71b),
-       TBL_ENTRY(0x71c), TBL_ENTRY(0x71d), TBL_ENTRY(0x71e), TBL_ENTRY(0x71f),
-       TBL_ENTRY(0x720), TBL_ENTRY(0x721), TBL_ENTRY(0x722), TBL_ENTRY(0x723),
-       TBL_ENTRY(0x724), TBL_ENTRY(0x725), TBL_ENTRY(0x726), TBL_ENTRY(0x727),
-       TBL_ENTRY(0x728), TBL_ENTRY(0x729), TBL_ENTRY(0x72a), TBL_ENTRY(0x72b),
-       TBL_ENTRY(0x72c), TBL_ENTRY(0x72d), TBL_ENTRY(0x72e), TBL_ENTRY(0x72f),
-       TBL_ENTRY(0x730), TBL_ENTRY(0x731), TBL_ENTRY(0x732), TBL_ENTRY(0x733),
-       TBL_ENTRY(0x734), TBL_ENTRY(0x735), TBL_ENTRY(0x736), TBL_ENTRY(0x737),
-       TBL_ENTRY(0x738), TBL_ENTRY(0x739), TBL_ENTRY(0x73a), TBL_ENTRY(0x73b),
-       TBL_ENTRY(0x73c), TBL_ENTRY(0x73d), TBL_ENTRY(0x73e), TBL_ENTRY(0x73f),
-       TBL_ENTRY(0x740), TBL_ENTRY(0x741), TBL_ENTRY(0x742), TBL_ENTRY(0x743),
-       TBL_ENTRY(0x744), TBL_ENTRY(0x745), TBL_ENTRY(0x746), TBL_ENTRY(0x747),
-       TBL_ENTRY(0x748), TBL_ENTRY(0x749), TBL_ENTRY(0x74a), TBL_ENTRY(0x74b),
-       TBL_ENTRY(0x74c), TBL_ENTRY(0x74d), TBL_ENTRY(0x74e), TBL_ENTRY(0x74f),
-       TBL_ENTRY(0x750), TBL_ENTRY(0x751), TBL_ENTRY(0x752), TBL_ENTRY(0x753),
-       TBL_ENTRY(0x754), TBL_ENTRY(0x755), TBL_ENTRY(0x756), TBL_ENTRY(0x757),
-       TBL_ENTRY(0x758), TBL_ENTRY(0x759), TBL_ENTRY(0x75a), TBL_ENTRY(0x75b),
-       TBL_ENTRY(0x75c), TBL_ENTRY(0x75d), TBL_ENTRY(0x75e), TBL_ENTRY(0x75f),
-       TBL_ENTRY(0x760), TBL_ENTRY(0x761), TBL_ENTRY(0x762), TBL_ENTRY(0x763),
-       TBL_ENTRY(0x764), TBL_ENTRY(0x765), TBL_ENTRY(0x766), TBL_ENTRY(0x767),
-       TBL_ENTRY(0x768), TBL_ENTRY(0x769), TBL_ENTRY(0x76a), TBL_ENTRY(0x76b),
-       TBL_ENTRY(0x76c), TBL_ENTRY(0x76d), TBL_ENTRY(0x76e), TBL_ENTRY(0x76f),
-       TBL_ENTRY(0x770), TBL_ENTRY(0x771), TBL_ENTRY(0x772), TBL_ENTRY(0x773),
-       TBL_ENTRY(0x774), TBL_ENTRY(0x775), TBL_ENTRY(0x776), TBL_ENTRY(0x777),
-       TBL_ENTRY(0x778), TBL_ENTRY(0x779), TBL_ENTRY(0x77a), TBL_ENTRY(0x77b),
-       TBL_ENTRY(0x77c), TBL_ENTRY(0x77d), TBL_ENTRY(0x77e), TBL_ENTRY(0x77f),
-       TBL_ENTRY(0x780), TBL_ENTRY(0x781), TBL_ENTRY(0x782), TBL_ENTRY(0x783),
-       TBL_ENTRY(0x784), TBL_ENTRY(0x785), TBL_ENTRY(0x786), TBL_ENTRY(0x787),
-       TBL_ENTRY(0x788), TBL_ENTRY(0x789), TBL_ENTRY(0x78a), TBL_ENTRY(0x78b),
-       TBL_ENTRY(0x78c), TBL_ENTRY(0x78d), TBL_ENTRY(0x78e), TBL_ENTRY(0x78f),
-       TBL_ENTRY(0x790), TBL_ENTRY(0x791), TBL_ENTRY(0x792), TBL_ENTRY(0x793),
-       TBL_ENTRY(0x794), TBL_ENTRY(0x795), TBL_ENTRY(0x796), TBL_ENTRY(0x797),
-       TBL_ENTRY(0x798), TBL_ENTRY(0x799), TBL_ENTRY(0x79a), TBL_ENTRY(0x79b),
-       TBL_ENTRY(0x79c), TBL_ENTRY(0x79d), TBL_ENTRY(0x79e), TBL_ENTRY(0x79f),
-       TBL_ENTRY(0x7a0), TBL_ENTRY(0x7a1), TBL_ENTRY(0x7a2), TBL_ENTRY(0x7a3),
-       TBL_ENTRY(0x7a4), TBL_ENTRY(0x7a5), TBL_ENTRY(0x7a6), TBL_ENTRY(0x7a7),
-       TBL_ENTRY(0x7a8), TBL_ENTRY(0x7a9), TBL_ENTRY(0x7aa), TBL_ENTRY(0x7ab),
-       TBL_ENTRY(0x7ac), TBL_ENTRY(0x7ad), TBL_ENTRY(0x7ae), TBL_ENTRY(0x7af),
-       TBL_ENTRY(0x7b0), TBL_ENTRY(0x7b1), TBL_ENTRY(0x7b2), TBL_ENTRY(0x7b3),
-       TBL_ENTRY(0x7b4), TBL_ENTRY(0x7b5), TBL_ENTRY(0x7b6), TBL_ENTRY(0x7b7),
-       TBL_ENTRY(0x7b8), TBL_ENTRY(0x7b9), TBL_ENTRY(0x7ba), TBL_ENTRY(0x7bb),
-       TBL_ENTRY(0x7bc), TBL_ENTRY(0x7bd), TBL_ENTRY(0x7be), TBL_ENTRY(0x7bf),
-       TBL_ENTRY(0x7c0), TBL_ENTRY(0x7c1), TBL_ENTRY(0x7c2), TBL_ENTRY(0x7c3),
-       TBL_ENTRY(0x7c4), TBL_ENTRY(0x7c5), TBL_ENTRY(0x7c6), TBL_ENTRY(0x7c7),
-       TBL_ENTRY(0x7c8), TBL_ENTRY(0x7c9), TBL_ENTRY(0x7ca), TBL_ENTRY(0x7cb),
-       TBL_ENTRY(0x7cc), TBL_ENTRY(0x7cd), TBL_ENTRY(0x7ce), TBL_ENTRY(0x7cf),
-       TBL_ENTRY(0x7d0), TBL_ENTRY(0x7d1), TBL_ENTRY(0x7d2), TBL_ENTRY(0x7d3),
-       TBL_ENTRY(0x7d4), TBL_ENTRY(0x7d5), TBL_ENTRY(0x7d6), TBL_ENTRY(0x7d7),
-       TBL_ENTRY(0x7d8), TBL_ENTRY(0x7d9), TBL_ENTRY(0x7da), TBL_ENTRY(0x7db),
-       TBL_ENTRY(0x7dc), TBL_ENTRY(0x7dd), TBL_ENTRY(0x7de), TBL_ENTRY(0x7df),
-       TBL_ENTRY(0x7e0), TBL_ENTRY(0x7e1), TBL_ENTRY(0x7e2), TBL_ENTRY(0x7e3),
-       TBL_ENTRY(0x7e4), TBL_ENTRY(0x7e5), TBL_ENTRY(0x7e6), TBL_ENTRY(0x7e7),
-       TBL_ENTRY(0x7e8), TBL_ENTRY(0x7e9), TBL_ENTRY(0x7ea), TBL_ENTRY(0x7eb),
-       TBL_ENTRY(0x7ec), TBL_ENTRY(0x7ed), TBL_ENTRY(0x7ee), TBL_ENTRY(0x7ef),
-       TBL_ENTRY(0x7f0), TBL_ENTRY(0x7f1), TBL_ENTRY(0x7f2), TBL_ENTRY(0x7f3),
-       TBL_ENTRY(0x7f4), TBL_ENTRY(0x7f5), TBL_ENTRY(0x7f6), TBL_ENTRY(0x7f7),
-       TBL_ENTRY(0x7f8), TBL_ENTRY(0x7f9), TBL_ENTRY(0x7fa), TBL_ENTRY(0x7fb),
-       TBL_ENTRY(0x7fc), TBL_ENTRY(0x7fd), TBL_ENTRY(0x7fe), TBL_ENTRY(0x7ff),
-       TBL_ENTRY(0x800), TBL_ENTRY(0x801), TBL_ENTRY(0x802), TBL_ENTRY(0x803),
-       TBL_ENTRY(0x804), TBL_ENTRY(0x805), TBL_ENTRY(0x806), TBL_ENTRY(0x807),
-       TBL_ENTRY(0x808), TBL_ENTRY(0x809), TBL_ENTRY(0x80a), TBL_ENTRY(0x80b),
-       TBL_ENTRY(0x80c), TBL_ENTRY(0x80d), TBL_ENTRY(0x80e), TBL_ENTRY(0x80f),
-       TBL_ENTRY(0x810), TBL_ENTRY(0x811), TBL_ENTRY(0x812), TBL_ENTRY(0x813),
-       TBL_ENTRY(0x814), TBL_ENTRY(0x815), TBL_ENTRY(0x816), TBL_ENTRY(0x817),
-       TBL_ENTRY(0x818), TBL_ENTRY(0x819), TBL_ENTRY(0x81a), TBL_ENTRY(0x81b),
-       TBL_ENTRY(0x81c), TBL_ENTRY(0x81d), TBL_ENTRY(0x81e), TBL_ENTRY(0x81f),
-       TBL_ENTRY(0x820), TBL_ENTRY(0x821), TBL_ENTRY(0x822), TBL_ENTRY(0x823),
-       TBL_ENTRY(0x824), TBL_ENTRY(0x825), TBL_ENTRY(0x826), TBL_ENTRY(0x827),
-       TBL_ENTRY(0x828), TBL_ENTRY(0x829), TBL_ENTRY(0x82a), TBL_ENTRY(0x82b),
-       TBL_ENTRY(0x82c), TBL_ENTRY(0x82d), TBL_ENTRY(0x82e), TBL_ENTRY(0x82f),
-       TBL_ENTRY(0x830), TBL_ENTRY(0x831), TBL_ENTRY(0x832), TBL_ENTRY(0x833),
-       TBL_ENTRY(0x834), TBL_ENTRY(0x835), TBL_ENTRY(0x836), TBL_ENTRY(0x837),
-       TBL_ENTRY(0x838), TBL_ENTRY(0x839), TBL_ENTRY(0x83a), TBL_ENTRY(0x83b),
-       TBL_ENTRY(0x83c), TBL_ENTRY(0x83d), TBL_ENTRY(0x83e), TBL_ENTRY(0x83f),
-       TBL_ENTRY(0x840), TBL_ENTRY(0x841), TBL_ENTRY(0x842), TBL_ENTRY(0x843),
-       TBL_ENTRY(0x844), TBL_ENTRY(0x845), TBL_ENTRY(0x846), TBL_ENTRY(0x847),
-       TBL_ENTRY(0x848), TBL_ENTRY(0x849), TBL_ENTRY(0x84a), TBL_ENTRY(0x84b),
-       TBL_ENTRY(0x84c), TBL_ENTRY(0x84d), TBL_ENTRY(0x84e), TBL_ENTRY(0x84f),
-       TBL_ENTRY(0x850), TBL_ENTRY(0x851), TBL_ENTRY(0x852), TBL_ENTRY(0x853),
-       TBL_ENTRY(0x854), TBL_ENTRY(0x855), TBL_ENTRY(0x856), TBL_ENTRY(0x857),
-       TBL_ENTRY(0x858), TBL_ENTRY(0x859), TBL_ENTRY(0x85a), TBL_ENTRY(0x85b),
-       TBL_ENTRY(0x85c), TBL_ENTRY(0x85d), TBL_ENTRY(0x85e), TBL_ENTRY(0x85f),
-       TBL_ENTRY(0x860), TBL_ENTRY(0x861), TBL_ENTRY(0x862), TBL_ENTRY(0x863),
-       TBL_ENTRY(0x864), TBL_ENTRY(0x865), TBL_ENTRY(0x866), TBL_ENTRY(0x867),
-       TBL_ENTRY(0x868), TBL_ENTRY(0x869), TBL_ENTRY(0x86a), TBL_ENTRY(0x86b),
-       TBL_ENTRY(0x86c), TBL_ENTRY(0x86d), TBL_ENTRY(0x86e), TBL_ENTRY(0x86f),
-       TBL_ENTRY(0x870), TBL_ENTRY(0x871), TBL_ENTRY(0x872), TBL_ENTRY(0x873),
-       TBL_ENTRY(0x874), TBL_ENTRY(0x875), TBL_ENTRY(0x876), TBL_ENTRY(0x877),
-       TBL_ENTRY(0x878), TBL_ENTRY(0x879), TBL_ENTRY(0x87a), TBL_ENTRY(0x87b),
-       TBL_ENTRY(0x87c), TBL_ENTRY(0x87d), TBL_ENTRY(0x87e), TBL_ENTRY(0x87f),
-       TBL_ENTRY(0x880), TBL_ENTRY(0x881), TBL_ENTRY(0x882), TBL_ENTRY(0x883),
-       TBL_ENTRY(0x884), TBL_ENTRY(0x885), TBL_ENTRY(0x886), TBL_ENTRY(0x887),
-       TBL_ENTRY(0x888), TBL_ENTRY(0x889), TBL_ENTRY(0x88a), TBL_ENTRY(0x88b),
-       TBL_ENTRY(0x88c), TBL_ENTRY(0x88d), TBL_ENTRY(0x88e), TBL_ENTRY(0x88f),
-       TBL_ENTRY(0x890), TBL_ENTRY(0x891), TBL_ENTRY(0x892), TBL_ENTRY(0x893),
-       TBL_ENTRY(0x894), TBL_ENTRY(0x895), TBL_ENTRY(0x896), TBL_ENTRY(0x897),
-       TBL_ENTRY(0x898), TBL_ENTRY(0x899), TBL_ENTRY(0x89a), TBL_ENTRY(0x89b),
-       TBL_ENTRY(0x89c), TBL_ENTRY(0x89d), TBL_ENTRY(0x89e), TBL_ENTRY(0x89f),
-       TBL_ENTRY(0x8a0), TBL_ENTRY(0x8a1), TBL_ENTRY(0x8a2), TBL_ENTRY(0x8a3),
-       TBL_ENTRY(0x8a4), TBL_ENTRY(0x8a5), TBL_ENTRY(0x8a6), TBL_ENTRY(0x8a7),
-       TBL_ENTRY(0x8a8), TBL_ENTRY(0x8a9), TBL_ENTRY(0x8aa), TBL_ENTRY(0x8ab),
-       TBL_ENTRY(0x8ac), TBL_ENTRY(0x8ad), TBL_ENTRY(0x8ae), TBL_ENTRY(0x8af),
-       TBL_ENTRY(0x8b0), TBL_ENTRY(0x8b1), TBL_ENTRY(0x8b2), TBL_ENTRY(0x8b3),
-       TBL_ENTRY(0x8b4), TBL_ENTRY(0x8b5), TBL_ENTRY(0x8b6), TBL_ENTRY(0x8b7),
-       TBL_ENTRY(0x8b8), TBL_ENTRY(0x8b9), TBL_ENTRY(0x8ba), TBL_ENTRY(0x8bb),
-       TBL_ENTRY(0x8bc), TBL_ENTRY(0x8bd), TBL_ENTRY(0x8be), TBL_ENTRY(0x8bf),
-       TBL_ENTRY(0x8c0), TBL_ENTRY(0x8c1), TBL_ENTRY(0x8c2), TBL_ENTRY(0x8c3),
-       TBL_ENTRY(0x8c4), TBL_ENTRY(0x8c5), TBL_ENTRY(0x8c6), TBL_ENTRY(0x8c7),
-       TBL_ENTRY(0x8c8), TBL_ENTRY(0x8c9), TBL_ENTRY(0x8ca), TBL_ENTRY(0x8cb),
-       TBL_ENTRY(0x8cc), TBL_ENTRY(0x8cd), TBL_ENTRY(0x8ce), TBL_ENTRY(0x8cf),
-       TBL_ENTRY(0x8d0), TBL_ENTRY(0x8d1), TBL_ENTRY(0x8d2), TBL_ENTRY(0x8d3),
-       TBL_ENTRY(0x8d4), TBL_ENTRY(0x8d5), TBL_ENTRY(0x8d6), TBL_ENTRY(0x8d7),
-       TBL_ENTRY(0x8d8), TBL_ENTRY(0x8d9), TBL_ENTRY(0x8da), TBL_ENTRY(0x8db),
-       TBL_ENTRY(0x8dc), TBL_ENTRY(0x8dd), TBL_ENTRY(0x8de), TBL_ENTRY(0x8df),
-       TBL_ENTRY(0x8e0), TBL_ENTRY(0x8e1), TBL_ENTRY(0x8e2), TBL_ENTRY(0x8e3),
-       TBL_ENTRY(0x8e4), TBL_ENTRY(0x8e5), TBL_ENTRY(0x8e6), TBL_ENTRY(0x8e7),
-       TBL_ENTRY(0x8e8), TBL_ENTRY(0x8e9), TBL_ENTRY(0x8ea), TBL_ENTRY(0x8eb),
-       TBL_ENTRY(0x8ec), TBL_ENTRY(0x8ed), TBL_ENTRY(0x8ee), TBL_ENTRY(0x8ef),
-       TBL_ENTRY(0x8f0), TBL_ENTRY(0x8f1), TBL_ENTRY(0x8f2), TBL_ENTRY(0x8f3),
-       TBL_ENTRY(0x8f4), TBL_ENTRY(0x8f5), TBL_ENTRY(0x8f6), TBL_ENTRY(0x8f7),
-       TBL_ENTRY(0x8f8), TBL_ENTRY(0x8f9), TBL_ENTRY(0x8fa), TBL_ENTRY(0x8fb),
-       TBL_ENTRY(0x8fc), TBL_ENTRY(0x8fd), TBL_ENTRY(0x8fe), TBL_ENTRY(0x8ff),
-       TBL_ENTRY(0x900), TBL_ENTRY(0x901), TBL_ENTRY(0x902), TBL_ENTRY(0x903),
-       TBL_ENTRY(0x904), TBL_ENTRY(0x905), TBL_ENTRY(0x906), TBL_ENTRY(0x907),
-       TBL_ENTRY(0x908), TBL_ENTRY(0x909), TBL_ENTRY(0x90a), TBL_ENTRY(0x90b),
-       TBL_ENTRY(0x90c), TBL_ENTRY(0x90d), TBL_ENTRY(0x90e), TBL_ENTRY(0x90f),
-       TBL_ENTRY(0x910), TBL_ENTRY(0x911), TBL_ENTRY(0x912), TBL_ENTRY(0x913),
-       TBL_ENTRY(0x914), TBL_ENTRY(0x915), TBL_ENTRY(0x916), TBL_ENTRY(0x917),
-       TBL_ENTRY(0x918), TBL_ENTRY(0x919), TBL_ENTRY(0x91a), TBL_ENTRY(0x91b),
-       TBL_ENTRY(0x91c), TBL_ENTRY(0x91d), TBL_ENTRY(0x91e), TBL_ENTRY(0x91f),
-       TBL_ENTRY(0x920), TBL_ENTRY(0x921), TBL_ENTRY(0x922), TBL_ENTRY(0x923),
-       TBL_ENTRY(0x924), TBL_ENTRY(0x925), TBL_ENTRY(0x926), TBL_ENTRY(0x927),
-       TBL_ENTRY(0x928), TBL_ENTRY(0x929), TBL_ENTRY(0x92a), TBL_ENTRY(0x92b),
-       TBL_ENTRY(0x92c), TBL_ENTRY(0x92d), TBL_ENTRY(0x92e), TBL_ENTRY(0x92f),
-       TBL_ENTRY(0x930), TBL_ENTRY(0x931), TBL_ENTRY(0x932), TBL_ENTRY(0x933),
-       TBL_ENTRY(0x934), TBL_ENTRY(0x935), TBL_ENTRY(0x936), TBL_ENTRY(0x937),
-       TBL_ENTRY(0x938), TBL_ENTRY(0x939), TBL_ENTRY(0x93a), TBL_ENTRY(0x93b),
-       TBL_ENTRY(0x93c), TBL_ENTRY(0x93d), TBL_ENTRY(0x93e), TBL_ENTRY(0x93f),
-       TBL_ENTRY(0x940), TBL_ENTRY(0x941), TBL_ENTRY(0x942), TBL_ENTRY(0x943),
-       TBL_ENTRY(0x944), TBL_ENTRY(0x945), TBL_ENTRY(0x946), TBL_ENTRY(0x947),
-       TBL_ENTRY(0x948), TBL_ENTRY(0x949), TBL_ENTRY(0x94a), TBL_ENTRY(0x94b),
-       TBL_ENTRY(0x94c), TBL_ENTRY(0x94d), TBL_ENTRY(0x94e), TBL_ENTRY(0x94f),
-       TBL_ENTRY(0x950), TBL_ENTRY(0x951), TBL_ENTRY(0x952), TBL_ENTRY(0x953),
-       TBL_ENTRY(0x954), TBL_ENTRY(0x955), TBL_ENTRY(0x956), TBL_ENTRY(0x957),
-       TBL_ENTRY(0x958), TBL_ENTRY(0x959), TBL_ENTRY(0x95a), TBL_ENTRY(0x95b),
-       TBL_ENTRY(0x95c), TBL_ENTRY(0x95d), TBL_ENTRY(0x95e), TBL_ENTRY(0x95f),
-       TBL_ENTRY(0x960), TBL_ENTRY(0x961), TBL_ENTRY(0x962), TBL_ENTRY(0x963),
-       TBL_ENTRY(0x964), TBL_ENTRY(0x965), TBL_ENTRY(0x966), TBL_ENTRY(0x967),
-       TBL_ENTRY(0x968), TBL_ENTRY(0x969), TBL_ENTRY(0x96a), TBL_ENTRY(0x96b),
-       TBL_ENTRY(0x96c), TBL_ENTRY(0x96d), TBL_ENTRY(0x96e), TBL_ENTRY(0x96f),
-       TBL_ENTRY(0x970), TBL_ENTRY(0x971), TBL_ENTRY(0x972), TBL_ENTRY(0x973),
-       TBL_ENTRY(0x974), TBL_ENTRY(0x975), TBL_ENTRY(0x976), TBL_ENTRY(0x977),
-       TBL_ENTRY(0x978), TBL_ENTRY(0x979), TBL_ENTRY(0x97a), TBL_ENTRY(0x97b),
-       TBL_ENTRY(0x97c), TBL_ENTRY(0x97d), TBL_ENTRY(0x97e), TBL_ENTRY(0x97f),
-       TBL_ENTRY(0x980), TBL_ENTRY(0x981), TBL_ENTRY(0x982), TBL_ENTRY(0x983),
-       TBL_ENTRY(0x984), TBL_ENTRY(0x985), TBL_ENTRY(0x986), TBL_ENTRY(0x987),
-       TBL_ENTRY(0x988), TBL_ENTRY(0x989), TBL_ENTRY(0x98a), TBL_ENTRY(0x98b),
-       TBL_ENTRY(0x98c), TBL_ENTRY(0x98d), TBL_ENTRY(0x98e), TBL_ENTRY(0x98f),
-       TBL_ENTRY(0x990), TBL_ENTRY(0x991), TBL_ENTRY(0x992), TBL_ENTRY(0x993),
-       TBL_ENTRY(0x994), TBL_ENTRY(0x995), TBL_ENTRY(0x996), TBL_ENTRY(0x997),
-       TBL_ENTRY(0x998), TBL_ENTRY(0x999), TBL_ENTRY(0x99a), TBL_ENTRY(0x99b),
-       TBL_ENTRY(0x99c), TBL_ENTRY(0x99d), TBL_ENTRY(0x99e), TBL_ENTRY(0x99f),
-       TBL_ENTRY(0x9a0), TBL_ENTRY(0x9a1), TBL_ENTRY(0x9a2), TBL_ENTRY(0x9a3),
-       TBL_ENTRY(0x9a4), TBL_ENTRY(0x9a5), TBL_ENTRY(0x9a6), TBL_ENTRY(0x9a7),
-       TBL_ENTRY(0x9a8), TBL_ENTRY(0x9a9), TBL_ENTRY(0x9aa), TBL_ENTRY(0x9ab),
-       TBL_ENTRY(0x9ac), TBL_ENTRY(0x9ad), TBL_ENTRY(0x9ae), TBL_ENTRY(0x9af),
-       TBL_ENTRY(0x9b0), TBL_ENTRY(0x9b1), TBL_ENTRY(0x9b2), TBL_ENTRY(0x9b3),
-       TBL_ENTRY(0x9b4), TBL_ENTRY(0x9b5), TBL_ENTRY(0x9b6), TBL_ENTRY(0x9b7),
-       TBL_ENTRY(0x9b8), TBL_ENTRY(0x9b9), TBL_ENTRY(0x9ba), TBL_ENTRY(0x9bb),
-       TBL_ENTRY(0x9bc), TBL_ENTRY(0x9bd), TBL_ENTRY(0x9be), TBL_ENTRY(0x9bf),
-       TBL_ENTRY(0x9c0), TBL_ENTRY(0x9c1), TBL_ENTRY(0x9c2), TBL_ENTRY(0x9c3),
-       TBL_ENTRY(0x9c4), TBL_ENTRY(0x9c5), TBL_ENTRY(0x9c6), TBL_ENTRY(0x9c7),
-       TBL_ENTRY(0x9c8), TBL_ENTRY(0x9c9), TBL_ENTRY(0x9ca), TBL_ENTRY(0x9cb),
-       TBL_ENTRY(0x9cc), TBL_ENTRY(0x9cd), TBL_ENTRY(0x9ce), TBL_ENTRY(0x9cf),
-       TBL_ENTRY(0x9d0), TBL_ENTRY(0x9d1), TBL_ENTRY(0x9d2), TBL_ENTRY(0x9d3),
-       TBL_ENTRY(0x9d4), TBL_ENTRY(0x9d5), TBL_ENTRY(0x9d6), TBL_ENTRY(0x9d7),
-       TBL_ENTRY(0x9d8), TBL_ENTRY(0x9d9), TBL_ENTRY(0x9da), TBL_ENTRY(0x9db),
-       TBL_ENTRY(0x9dc), TBL_ENTRY(0x9dd), TBL_ENTRY(0x9de), TBL_ENTRY(0x9df),
-       TBL_ENTRY(0x9e0), TBL_ENTRY(0x9e1), TBL_ENTRY(0x9e2), TBL_ENTRY(0x9e3),
-       TBL_ENTRY(0x9e4), TBL_ENTRY(0x9e5), TBL_ENTRY(0x9e6), TBL_ENTRY(0x9e7),
-       TBL_ENTRY(0x9e8), TBL_ENTRY(0x9e9), TBL_ENTRY(0x9ea), TBL_ENTRY(0x9eb),
-       TBL_ENTRY(0x9ec), TBL_ENTRY(0x9ed), TBL_ENTRY(0x9ee), TBL_ENTRY(0x9ef),
-       TBL_ENTRY(0x9f0), TBL_ENTRY(0x9f1), TBL_ENTRY(0x9f2), TBL_ENTRY(0x9f3),
-       TBL_ENTRY(0x9f4), TBL_ENTRY(0x9f5), TBL_ENTRY(0x9f6), TBL_ENTRY(0x9f7),
-       TBL_ENTRY(0x9f8), TBL_ENTRY(0x9f9), TBL_ENTRY(0x9fa), TBL_ENTRY(0x9fb),
-       TBL_ENTRY(0x9fc), TBL_ENTRY(0x9fd), TBL_ENTRY(0x9fe), TBL_ENTRY(0x9ff),
-       TBL_ENTRY(0xa00), TBL_ENTRY(0xa01), TBL_ENTRY(0xa02), TBL_ENTRY(0xa03),
-       TBL_ENTRY(0xa04), TBL_ENTRY(0xa05), TBL_ENTRY(0xa06), TBL_ENTRY(0xa07),
-       TBL_ENTRY(0xa08), TBL_ENTRY(0xa09), TBL_ENTRY(0xa0a), TBL_ENTRY(0xa0b),
-       TBL_ENTRY(0xa0c), TBL_ENTRY(0xa0d), TBL_ENTRY(0xa0e), TBL_ENTRY(0xa0f),
-       TBL_ENTRY(0xa10), TBL_ENTRY(0xa11), TBL_ENTRY(0xa12), TBL_ENTRY(0xa13),
-       TBL_ENTRY(0xa14), TBL_ENTRY(0xa15), TBL_ENTRY(0xa16), TBL_ENTRY(0xa17),
-       TBL_ENTRY(0xa18), TBL_ENTRY(0xa19), TBL_ENTRY(0xa1a), TBL_ENTRY(0xa1b),
-       TBL_ENTRY(0xa1c), TBL_ENTRY(0xa1d), TBL_ENTRY(0xa1e), TBL_ENTRY(0xa1f),
-       TBL_ENTRY(0xa20), TBL_ENTRY(0xa21), TBL_ENTRY(0xa22), TBL_ENTRY(0xa23),
-       TBL_ENTRY(0xa24), TBL_ENTRY(0xa25), TBL_ENTRY(0xa26), TBL_ENTRY(0xa27),
-       TBL_ENTRY(0xa28), TBL_ENTRY(0xa29), TBL_ENTRY(0xa2a), TBL_ENTRY(0xa2b),
-       TBL_ENTRY(0xa2c), TBL_ENTRY(0xa2d), TBL_ENTRY(0xa2e), TBL_ENTRY(0xa2f),
-       TBL_ENTRY(0xa30), TBL_ENTRY(0xa31), TBL_ENTRY(0xa32), TBL_ENTRY(0xa33),
-       TBL_ENTRY(0xa34), TBL_ENTRY(0xa35), TBL_ENTRY(0xa36), TBL_ENTRY(0xa37),
-       TBL_ENTRY(0xa38), TBL_ENTRY(0xa39), TBL_ENTRY(0xa3a), TBL_ENTRY(0xa3b),
-       TBL_ENTRY(0xa3c), TBL_ENTRY(0xa3d), TBL_ENTRY(0xa3e), TBL_ENTRY(0xa3f),
-       TBL_ENTRY(0xa40), TBL_ENTRY(0xa41), TBL_ENTRY(0xa42), TBL_ENTRY(0xa43),
-       TBL_ENTRY(0xa44), TBL_ENTRY(0xa45), TBL_ENTRY(0xa46), TBL_ENTRY(0xa47),
-       TBL_ENTRY(0xa48), TBL_ENTRY(0xa49), TBL_ENTRY(0xa4a), TBL_ENTRY(0xa4b),
-       TBL_ENTRY(0xa4c), TBL_ENTRY(0xa4d), TBL_ENTRY(0xa4e), TBL_ENTRY(0xa4f),
-       TBL_ENTRY(0xa50), TBL_ENTRY(0xa51), TBL_ENTRY(0xa52), TBL_ENTRY(0xa53),
-       TBL_ENTRY(0xa54), TBL_ENTRY(0xa55), TBL_ENTRY(0xa56), TBL_ENTRY(0xa57),
-       TBL_ENTRY(0xa58), TBL_ENTRY(0xa59), TBL_ENTRY(0xa5a), TBL_ENTRY(0xa5b),
-       TBL_ENTRY(0xa5c), TBL_ENTRY(0xa5d), TBL_ENTRY(0xa5e), TBL_ENTRY(0xa5f),
-       TBL_ENTRY(0xa60), TBL_ENTRY(0xa61), TBL_ENTRY(0xa62), TBL_ENTRY(0xa63),
-       TBL_ENTRY(0xa64), TBL_ENTRY(0xa65), TBL_ENTRY(0xa66), TBL_ENTRY(0xa67),
-       TBL_ENTRY(0xa68), TBL_ENTRY(0xa69), TBL_ENTRY(0xa6a), TBL_ENTRY(0xa6b),
-       TBL_ENTRY(0xa6c), TBL_ENTRY(0xa6d), TBL_ENTRY(0xa6e), TBL_ENTRY(0xa6f),
-       TBL_ENTRY(0xa70), TBL_ENTRY(0xa71), TBL_ENTRY(0xa72), TBL_ENTRY(0xa73),
-       TBL_ENTRY(0xa74), TBL_ENTRY(0xa75), TBL_ENTRY(0xa76), TBL_ENTRY(0xa77),
-       TBL_ENTRY(0xa78), TBL_ENTRY(0xa79), TBL_ENTRY(0xa7a), TBL_ENTRY(0xa7b),
-       TBL_ENTRY(0xa7c), TBL_ENTRY(0xa7d), TBL_ENTRY(0xa7e), TBL_ENTRY(0xa7f),
-       TBL_ENTRY(0xa80), TBL_ENTRY(0xa81), TBL_ENTRY(0xa82), TBL_ENTRY(0xa83),
-       TBL_ENTRY(0xa84), TBL_ENTRY(0xa85), TBL_ENTRY(0xa86), TBL_ENTRY(0xa87),
-       TBL_ENTRY(0xa88), TBL_ENTRY(0xa89), TBL_ENTRY(0xa8a), TBL_ENTRY(0xa8b),
-       TBL_ENTRY(0xa8c), TBL_ENTRY(0xa8d), TBL_ENTRY(0xa8e), TBL_ENTRY(0xa8f),
-       TBL_ENTRY(0xa90), TBL_ENTRY(0xa91), TBL_ENTRY(0xa92), TBL_ENTRY(0xa93),
-       TBL_ENTRY(0xa94), TBL_ENTRY(0xa95), TBL_ENTRY(0xa96), TBL_ENTRY(0xa97),
-       TBL_ENTRY(0xa98), TBL_ENTRY(0xa99), TBL_ENTRY(0xa9a), TBL_ENTRY(0xa9b),
-       TBL_ENTRY(0xa9c), TBL_ENTRY(0xa9d), TBL_ENTRY(0xa9e), TBL_ENTRY(0xa9f),
-       TBL_ENTRY(0xaa0), TBL_ENTRY(0xaa1), TBL_ENTRY(0xaa2), TBL_ENTRY(0xaa3),
-       TBL_ENTRY(0xaa4), TBL_ENTRY(0xaa5), TBL_ENTRY(0xaa6), TBL_ENTRY(0xaa7),
-       TBL_ENTRY(0xaa8), TBL_ENTRY(0xaa9), TBL_ENTRY(0xaaa), TBL_ENTRY(0xaab),
-       TBL_ENTRY(0xaac), TBL_ENTRY(0xaad), TBL_ENTRY(0xaae), TBL_ENTRY(0xaaf),
-       TBL_ENTRY(0xab0), TBL_ENTRY(0xab1), TBL_ENTRY(0xab2), TBL_ENTRY(0xab3),
-       TBL_ENTRY(0xab4), TBL_ENTRY(0xab5), TBL_ENTRY(0xab6), TBL_ENTRY(0xab7),
-       TBL_ENTRY(0xab8), TBL_ENTRY(0xab9), TBL_ENTRY(0xaba), TBL_ENTRY(0xabb),
-       TBL_ENTRY(0xabc), TBL_ENTRY(0xabd), TBL_ENTRY(0xabe), TBL_ENTRY(0xabf),
-       TBL_ENTRY(0xac0), TBL_ENTRY(0xac1), TBL_ENTRY(0xac2), TBL_ENTRY(0xac3),
-       TBL_ENTRY(0xac4), TBL_ENTRY(0xac5), TBL_ENTRY(0xac6), TBL_ENTRY(0xac7),
-       TBL_ENTRY(0xac8), TBL_ENTRY(0xac9), TBL_ENTRY(0xaca), TBL_ENTRY(0xacb),
-       TBL_ENTRY(0xacc), TBL_ENTRY(0xacd), TBL_ENTRY(0xace), TBL_ENTRY(0xacf),
-       TBL_ENTRY(0xad0), TBL_ENTRY(0xad1), TBL_ENTRY(0xad2), TBL_ENTRY(0xad3),
-       TBL_ENTRY(0xad4), TBL_ENTRY(0xad5), TBL_ENTRY(0xad6), TBL_ENTRY(0xad7),
-       TBL_ENTRY(0xad8), TBL_ENTRY(0xad9), TBL_ENTRY(0xada), TBL_ENTRY(0xadb),
-       TBL_ENTRY(0xadc), TBL_ENTRY(0xadd), TBL_ENTRY(0xade), TBL_ENTRY(0xadf),
-       TBL_ENTRY(0xae0), TBL_ENTRY(0xae1), TBL_ENTRY(0xae2), TBL_ENTRY(0xae3),
-       TBL_ENTRY(0xae4), TBL_ENTRY(0xae5), TBL_ENTRY(0xae6), TBL_ENTRY(0xae7),
-       TBL_ENTRY(0xae8), TBL_ENTRY(0xae9), TBL_ENTRY(0xaea), TBL_ENTRY(0xaeb),
-       TBL_ENTRY(0xaec), TBL_ENTRY(0xaed), TBL_ENTRY(0xaee), TBL_ENTRY(0xaef),
-       TBL_ENTRY(0xaf0), TBL_ENTRY(0xaf1), TBL_ENTRY(0xaf2), TBL_ENTRY(0xaf3),
-       TBL_ENTRY(0xaf4), TBL_ENTRY(0xaf5), TBL_ENTRY(0xaf6), TBL_ENTRY(0xaf7),
-       TBL_ENTRY(0xaf8), TBL_ENTRY(0xaf9), TBL_ENTRY(0xafa), TBL_ENTRY(0xafb),
-       TBL_ENTRY(0xafc), TBL_ENTRY(0xafd), TBL_ENTRY(0xafe), TBL_ENTRY(0xaff),
-       TBL_ENTRY(0xb00), TBL_ENTRY(0xb01), TBL_ENTRY(0xb02), TBL_ENTRY(0xb03),
-       TBL_ENTRY(0xb04), TBL_ENTRY(0xb05), TBL_ENTRY(0xb06), TBL_ENTRY(0xb07),
-       TBL_ENTRY(0xb08), TBL_ENTRY(0xb09), TBL_ENTRY(0xb0a), TBL_ENTRY(0xb0b),
-       TBL_ENTRY(0xb0c), TBL_ENTRY(0xb0d), TBL_ENTRY(0xb0e), TBL_ENTRY(0xb0f),
-       TBL_ENTRY(0xb10), TBL_ENTRY(0xb11), TBL_ENTRY(0xb12), TBL_ENTRY(0xb13),
-       TBL_ENTRY(0xb14), TBL_ENTRY(0xb15), TBL_ENTRY(0xb16), TBL_ENTRY(0xb17),
-       TBL_ENTRY(0xb18), TBL_ENTRY(0xb19), TBL_ENTRY(0xb1a), TBL_ENTRY(0xb1b),
-       TBL_ENTRY(0xb1c), TBL_ENTRY(0xb1d), TBL_ENTRY(0xb1e), TBL_ENTRY(0xb1f),
-       TBL_ENTRY(0xb20), TBL_ENTRY(0xb21), TBL_ENTRY(0xb22), TBL_ENTRY(0xb23),
-       TBL_ENTRY(0xb24), TBL_ENTRY(0xb25), TBL_ENTRY(0xb26), TBL_ENTRY(0xb27),
-       TBL_ENTRY(0xb28), TBL_ENTRY(0xb29), TBL_ENTRY(0xb2a), TBL_ENTRY(0xb2b),
-       TBL_ENTRY(0xb2c), TBL_ENTRY(0xb2d), TBL_ENTRY(0xb2e), TBL_ENTRY(0xb2f),
-       TBL_ENTRY(0xb30), TBL_ENTRY(0xb31), TBL_ENTRY(0xb32), TBL_ENTRY(0xb33),
-       TBL_ENTRY(0xb34), TBL_ENTRY(0xb35), TBL_ENTRY(0xb36), TBL_ENTRY(0xb37),
-       TBL_ENTRY(0xb38), TBL_ENTRY(0xb39), TBL_ENTRY(0xb3a), TBL_ENTRY(0xb3b),
-       TBL_ENTRY(0xb3c), TBL_ENTRY(0xb3d), TBL_ENTRY(0xb3e), TBL_ENTRY(0xb3f),
-       TBL_ENTRY(0xb40), TBL_ENTRY(0xb41), TBL_ENTRY(0xb42), TBL_ENTRY(0xb43),
-       TBL_ENTRY(0xb44), TBL_ENTRY(0xb45), TBL_ENTRY(0xb46), TBL_ENTRY(0xb47),
-       TBL_ENTRY(0xb48), TBL_ENTRY(0xb49), TBL_ENTRY(0xb4a), TBL_ENTRY(0xb4b),
-       TBL_ENTRY(0xb4c), TBL_ENTRY(0xb4d), TBL_ENTRY(0xb4e), TBL_ENTRY(0xb4f),
-       TBL_ENTRY(0xb50), TBL_ENTRY(0xb51), TBL_ENTRY(0xb52), TBL_ENTRY(0xb53),
-       TBL_ENTRY(0xb54), TBL_ENTRY(0xb55), TBL_ENTRY(0xb56), TBL_ENTRY(0xb57),
-       TBL_ENTRY(0xb58), TBL_ENTRY(0xb59), TBL_ENTRY(0xb5a), TBL_ENTRY(0xb5b),
-       TBL_ENTRY(0xb5c), TBL_ENTRY(0xb5d), TBL_ENTRY(0xb5e), TBL_ENTRY(0xb5f),
-       TBL_ENTRY(0xb60), TBL_ENTRY(0xb61), TBL_ENTRY(0xb62), TBL_ENTRY(0xb63),
-       TBL_ENTRY(0xb64), TBL_ENTRY(0xb65), TBL_ENTRY(0xb66), TBL_ENTRY(0xb67),
-       TBL_ENTRY(0xb68), TBL_ENTRY(0xb69), TBL_ENTRY(0xb6a), TBL_ENTRY(0xb6b),
-       TBL_ENTRY(0xb6c), TBL_ENTRY(0xb6d), TBL_ENTRY(0xb6e), TBL_ENTRY(0xb6f),
-       TBL_ENTRY(0xb70), TBL_ENTRY(0xb71), TBL_ENTRY(0xb72), TBL_ENTRY(0xb73),
-       TBL_ENTRY(0xb74), TBL_ENTRY(0xb75), TBL_ENTRY(0xb76), TBL_ENTRY(0xb77),
-       TBL_ENTRY(0xb78), TBL_ENTRY(0xb79), TBL_ENTRY(0xb7a), TBL_ENTRY(0xb7b),
-       TBL_ENTRY(0xb7c), TBL_ENTRY(0xb7d), TBL_ENTRY(0xb7e), TBL_ENTRY(0xb7f),
-       TBL_ENTRY(0xb80), TBL_ENTRY(0xb81), TBL_ENTRY(0xb82), TBL_ENTRY(0xb83),
-       TBL_ENTRY(0xb84), TBL_ENTRY(0xb85), TBL_ENTRY(0xb86), TBL_ENTRY(0xb87),
-       TBL_ENTRY(0xb88), TBL_ENTRY(0xb89), TBL_ENTRY(0xb8a), TBL_ENTRY(0xb8b),
-       TBL_ENTRY(0xb8c), TBL_ENTRY(0xb8d), TBL_ENTRY(0xb8e), TBL_ENTRY(0xb8f),
-       TBL_ENTRY(0xb90), TBL_ENTRY(0xb91), TBL_ENTRY(0xb92), TBL_ENTRY(0xb93),
-       TBL_ENTRY(0xb94), TBL_ENTRY(0xb95), TBL_ENTRY(0xb96), TBL_ENTRY(0xb97),
-       TBL_ENTRY(0xb98), TBL_ENTRY(0xb99), TBL_ENTRY(0xb9a), TBL_ENTRY(0xb9b),
-       TBL_ENTRY(0xb9c), TBL_ENTRY(0xb9d), TBL_ENTRY(0xb9e), TBL_ENTRY(0xb9f),
-       TBL_ENTRY(0xba0), TBL_ENTRY(0xba1), TBL_ENTRY(0xba2), TBL_ENTRY(0xba3),
-       TBL_ENTRY(0xba4), TBL_ENTRY(0xba5), TBL_ENTRY(0xba6), TBL_ENTRY(0xba7),
-       TBL_ENTRY(0xba8), TBL_ENTRY(0xba9), TBL_ENTRY(0xbaa), TBL_ENTRY(0xbab),
-       TBL_ENTRY(0xbac), TBL_ENTRY(0xbad), TBL_ENTRY(0xbae), TBL_ENTRY(0xbaf),
-       TBL_ENTRY(0xbb0), TBL_ENTRY(0xbb1), TBL_ENTRY(0xbb2), TBL_ENTRY(0xbb3),
-       TBL_ENTRY(0xbb4), TBL_ENTRY(0xbb5), TBL_ENTRY(0xbb6), TBL_ENTRY(0xbb7),
-       TBL_ENTRY(0xbb8), TBL_ENTRY(0xbb9), TBL_ENTRY(0xbba), TBL_ENTRY(0xbbb),
-       TBL_ENTRY(0xbbc), TBL_ENTRY(0xbbd), TBL_ENTRY(0xbbe), TBL_ENTRY(0xbbf),
-       TBL_ENTRY(0xbc0), TBL_ENTRY(0xbc1), TBL_ENTRY(0xbc2), TBL_ENTRY(0xbc3),
-       TBL_ENTRY(0xbc4), TBL_ENTRY(0xbc5), TBL_ENTRY(0xbc6), TBL_ENTRY(0xbc7),
-       TBL_ENTRY(0xbc8), TBL_ENTRY(0xbc9), TBL_ENTRY(0xbca), TBL_ENTRY(0xbcb),
-       TBL_ENTRY(0xbcc), TBL_ENTRY(0xbcd), TBL_ENTRY(0xbce), TBL_ENTRY(0xbcf),
-       TBL_ENTRY(0xbd0), TBL_ENTRY(0xbd1), TBL_ENTRY(0xbd2), TBL_ENTRY(0xbd3),
-       TBL_ENTRY(0xbd4), TBL_ENTRY(0xbd5), TBL_ENTRY(0xbd6), TBL_ENTRY(0xbd7),
-       TBL_ENTRY(0xbd8), TBL_ENTRY(0xbd9), TBL_ENTRY(0xbda), TBL_ENTRY(0xbdb),
-       TBL_ENTRY(0xbdc), TBL_ENTRY(0xbdd), TBL_ENTRY(0xbde), TBL_ENTRY(0xbdf),
-       TBL_ENTRY(0xbe0), TBL_ENTRY(0xbe1), TBL_ENTRY(0xbe2), TBL_ENTRY(0xbe3),
-       TBL_ENTRY(0xbe4), TBL_ENTRY(0xbe5), TBL_ENTRY(0xbe6), TBL_ENTRY(0xbe7),
-       TBL_ENTRY(0xbe8), TBL_ENTRY(0xbe9), TBL_ENTRY(0xbea), TBL_ENTRY(0xbeb),
-       TBL_ENTRY(0xbec), TBL_ENTRY(0xbed), TBL_ENTRY(0xbee), TBL_ENTRY(0xbef),
-       TBL_ENTRY(0xbf0), TBL_ENTRY(0xbf1), TBL_ENTRY(0xbf2), TBL_ENTRY(0xbf3),
-       TBL_ENTRY(0xbf4), TBL_ENTRY(0xbf5), TBL_ENTRY(0xbf6), TBL_ENTRY(0xbf7),
-       TBL_ENTRY(0xbf8), TBL_ENTRY(0xbf9), TBL_ENTRY(0xbfa), TBL_ENTRY(0xbfb),
-       TBL_ENTRY(0xbfc), TBL_ENTRY(0xbfd), TBL_ENTRY(0xbfe), TBL_ENTRY(0xbff),
-       TBL_ENTRY(0xc00), TBL_ENTRY(0xc01), TBL_ENTRY(0xc02), TBL_ENTRY(0xc03),
-       TBL_ENTRY(0xc04), TBL_ENTRY(0xc05), TBL_ENTRY(0xc06), TBL_ENTRY(0xc07),
-       TBL_ENTRY(0xc08), TBL_ENTRY(0xc09), TBL_ENTRY(0xc0a), TBL_ENTRY(0xc0b),
-       TBL_ENTRY(0xc0c), TBL_ENTRY(0xc0d), TBL_ENTRY(0xc0e), TBL_ENTRY(0xc0f),
-       TBL_ENTRY(0xc10), TBL_ENTRY(0xc11), TBL_ENTRY(0xc12), TBL_ENTRY(0xc13),
-       TBL_ENTRY(0xc14), TBL_ENTRY(0xc15), TBL_ENTRY(0xc16), TBL_ENTRY(0xc17),
-       TBL_ENTRY(0xc18), TBL_ENTRY(0xc19), TBL_ENTRY(0xc1a), TBL_ENTRY(0xc1b),
-       TBL_ENTRY(0xc1c), TBL_ENTRY(0xc1d), TBL_ENTRY(0xc1e), TBL_ENTRY(0xc1f),
-       TBL_ENTRY(0xc20), TBL_ENTRY(0xc21), TBL_ENTRY(0xc22), TBL_ENTRY(0xc23),
-       TBL_ENTRY(0xc24), TBL_ENTRY(0xc25), TBL_ENTRY(0xc26), TBL_ENTRY(0xc27),
-       TBL_ENTRY(0xc28), TBL_ENTRY(0xc29), TBL_ENTRY(0xc2a), TBL_ENTRY(0xc2b),
-       TBL_ENTRY(0xc2c), TBL_ENTRY(0xc2d), TBL_ENTRY(0xc2e), TBL_ENTRY(0xc2f),
-       TBL_ENTRY(0xc30), TBL_ENTRY(0xc31), TBL_ENTRY(0xc32), TBL_ENTRY(0xc33),
-       TBL_ENTRY(0xc34), TBL_ENTRY(0xc35), TBL_ENTRY(0xc36), TBL_ENTRY(0xc37),
-       TBL_ENTRY(0xc38), TBL_ENTRY(0xc39), TBL_ENTRY(0xc3a), TBL_ENTRY(0xc3b),
-       TBL_ENTRY(0xc3c), TBL_ENTRY(0xc3d), TBL_ENTRY(0xc3e), TBL_ENTRY(0xc3f),
-       TBL_ENTRY(0xc40), TBL_ENTRY(0xc41), TBL_ENTRY(0xc42), TBL_ENTRY(0xc43),
-       TBL_ENTRY(0xc44), TBL_ENTRY(0xc45), TBL_ENTRY(0xc46), TBL_ENTRY(0xc47),
-       TBL_ENTRY(0xc48), TBL_ENTRY(0xc49), TBL_ENTRY(0xc4a), TBL_ENTRY(0xc4b),
-       TBL_ENTRY(0xc4c), TBL_ENTRY(0xc4d), TBL_ENTRY(0xc4e), TBL_ENTRY(0xc4f),
-       TBL_ENTRY(0xc50), TBL_ENTRY(0xc51), TBL_ENTRY(0xc52), TBL_ENTRY(0xc53),
-       TBL_ENTRY(0xc54), TBL_ENTRY(0xc55), TBL_ENTRY(0xc56), TBL_ENTRY(0xc57),
-       TBL_ENTRY(0xc58), TBL_ENTRY(0xc59), TBL_ENTRY(0xc5a), TBL_ENTRY(0xc5b),
-       TBL_ENTRY(0xc5c), TBL_ENTRY(0xc5d), TBL_ENTRY(0xc5e), TBL_ENTRY(0xc5f),
-       TBL_ENTRY(0xc60), TBL_ENTRY(0xc61), TBL_ENTRY(0xc62), TBL_ENTRY(0xc63),
-       TBL_ENTRY(0xc64), TBL_ENTRY(0xc65), TBL_ENTRY(0xc66), TBL_ENTRY(0xc67),
-       TBL_ENTRY(0xc68), TBL_ENTRY(0xc69), TBL_ENTRY(0xc6a), TBL_ENTRY(0xc6b),
-       TBL_ENTRY(0xc6c), TBL_ENTRY(0xc6d), TBL_ENTRY(0xc6e), TBL_ENTRY(0xc6f),
-       TBL_ENTRY(0xc70), TBL_ENTRY(0xc71), TBL_ENTRY(0xc72), TBL_ENTRY(0xc73),
-       TBL_ENTRY(0xc74), TBL_ENTRY(0xc75), TBL_ENTRY(0xc76), TBL_ENTRY(0xc77),
-       TBL_ENTRY(0xc78), TBL_ENTRY(0xc79), TBL_ENTRY(0xc7a), TBL_ENTRY(0xc7b),
-       TBL_ENTRY(0xc7c), TBL_ENTRY(0xc7d), TBL_ENTRY(0xc7e), TBL_ENTRY(0xc7f),
-       TBL_ENTRY(0xc80), TBL_ENTRY(0xc81), TBL_ENTRY(0xc82), TBL_ENTRY(0xc83),
-       TBL_ENTRY(0xc84), TBL_ENTRY(0xc85), TBL_ENTRY(0xc86), TBL_ENTRY(0xc87),
-       TBL_ENTRY(0xc88), TBL_ENTRY(0xc89), TBL_ENTRY(0xc8a), TBL_ENTRY(0xc8b),
-       TBL_ENTRY(0xc8c), TBL_ENTRY(0xc8d), TBL_ENTRY(0xc8e), TBL_ENTRY(0xc8f),
-       TBL_ENTRY(0xc90), TBL_ENTRY(0xc91), TBL_ENTRY(0xc92), TBL_ENTRY(0xc93),
-       TBL_ENTRY(0xc94), TBL_ENTRY(0xc95), TBL_ENTRY(0xc96), TBL_ENTRY(0xc97),
-       TBL_ENTRY(0xc98), TBL_ENTRY(0xc99), TBL_ENTRY(0xc9a), TBL_ENTRY(0xc9b),
-       TBL_ENTRY(0xc9c), TBL_ENTRY(0xc9d), TBL_ENTRY(0xc9e), TBL_ENTRY(0xc9f),
-       TBL_ENTRY(0xca0), TBL_ENTRY(0xca1), TBL_ENTRY(0xca2), TBL_ENTRY(0xca3),
-       TBL_ENTRY(0xca4), TBL_ENTRY(0xca5), TBL_ENTRY(0xca6), TBL_ENTRY(0xca7),
-       TBL_ENTRY(0xca8), TBL_ENTRY(0xca9), TBL_ENTRY(0xcaa), TBL_ENTRY(0xcab),
-       TBL_ENTRY(0xcac), TBL_ENTRY(0xcad), TBL_ENTRY(0xcae), TBL_ENTRY(0xcaf),
-       TBL_ENTRY(0xcb0), TBL_ENTRY(0xcb1), TBL_ENTRY(0xcb2), TBL_ENTRY(0xcb3),
-       TBL_ENTRY(0xcb4), TBL_ENTRY(0xcb5), TBL_ENTRY(0xcb6), TBL_ENTRY(0xcb7),
-       TBL_ENTRY(0xcb8), TBL_ENTRY(0xcb9), TBL_ENTRY(0xcba), TBL_ENTRY(0xcbb),
-       TBL_ENTRY(0xcbc), TBL_ENTRY(0xcbd), TBL_ENTRY(0xcbe), TBL_ENTRY(0xcbf),
-       TBL_ENTRY(0xcc0), TBL_ENTRY(0xcc1), TBL_ENTRY(0xcc2), TBL_ENTRY(0xcc3),
-       TBL_ENTRY(0xcc4), TBL_ENTRY(0xcc5), TBL_ENTRY(0xcc6), TBL_ENTRY(0xcc7),
-       TBL_ENTRY(0xcc8), TBL_ENTRY(0xcc9), TBL_ENTRY(0xcca), TBL_ENTRY(0xccb),
-       TBL_ENTRY(0xccc), TBL_ENTRY(0xccd), TBL_ENTRY(0xcce), TBL_ENTRY(0xccf),
-       TBL_ENTRY(0xcd0), TBL_ENTRY(0xcd1), TBL_ENTRY(0xcd2), TBL_ENTRY(0xcd3),
-       TBL_ENTRY(0xcd4), TBL_ENTRY(0xcd5), TBL_ENTRY(0xcd6), TBL_ENTRY(0xcd7),
-       TBL_ENTRY(0xcd8), TBL_ENTRY(0xcd9), TBL_ENTRY(0xcda), TBL_ENTRY(0xcdb),
-       TBL_ENTRY(0xcdc), TBL_ENTRY(0xcdd), TBL_ENTRY(0xcde), TBL_ENTRY(0xcdf),
-       TBL_ENTRY(0xce0), TBL_ENTRY(0xce1), TBL_ENTRY(0xce2), TBL_ENTRY(0xce3),
-       TBL_ENTRY(0xce4), TBL_ENTRY(0xce5), TBL_ENTRY(0xce6), TBL_ENTRY(0xce7),
-       TBL_ENTRY(0xce8), TBL_ENTRY(0xce9), TBL_ENTRY(0xcea), TBL_ENTRY(0xceb),
-       TBL_ENTRY(0xcec), TBL_ENTRY(0xced), TBL_ENTRY(0xcee), TBL_ENTRY(0xcef),
-       TBL_ENTRY(0xcf0), TBL_ENTRY(0xcf1), TBL_ENTRY(0xcf2), TBL_ENTRY(0xcf3),
-       TBL_ENTRY(0xcf4), TBL_ENTRY(0xcf5), TBL_ENTRY(0xcf6), TBL_ENTRY(0xcf7),
-       TBL_ENTRY(0xcf8), TBL_ENTRY(0xcf9), TBL_ENTRY(0xcfa), TBL_ENTRY(0xcfb),
-       TBL_ENTRY(0xcfc), TBL_ENTRY(0xcfd), TBL_ENTRY(0xcfe), TBL_ENTRY(0xcff),
-       TBL_ENTRY(0xd00), TBL_ENTRY(0xd01), TBL_ENTRY(0xd02), TBL_ENTRY(0xd03),
-       TBL_ENTRY(0xd04), TBL_ENTRY(0xd05), TBL_ENTRY(0xd06), TBL_ENTRY(0xd07),
-       TBL_ENTRY(0xd08), TBL_ENTRY(0xd09), TBL_ENTRY(0xd0a), TBL_ENTRY(0xd0b),
-       TBL_ENTRY(0xd0c), TBL_ENTRY(0xd0d), TBL_ENTRY(0xd0e), TBL_ENTRY(0xd0f),
-       TBL_ENTRY(0xd10), TBL_ENTRY(0xd11), TBL_ENTRY(0xd12), TBL_ENTRY(0xd13),
-       TBL_ENTRY(0xd14), TBL_ENTRY(0xd15), TBL_ENTRY(0xd16), TBL_ENTRY(0xd17),
-       TBL_ENTRY(0xd18), TBL_ENTRY(0xd19), TBL_ENTRY(0xd1a), TBL_ENTRY(0xd1b),
-       TBL_ENTRY(0xd1c), TBL_ENTRY(0xd1d), TBL_ENTRY(0xd1e), TBL_ENTRY(0xd1f),
-       TBL_ENTRY(0xd20), TBL_ENTRY(0xd21), TBL_ENTRY(0xd22), TBL_ENTRY(0xd23),
-       TBL_ENTRY(0xd24), TBL_ENTRY(0xd25), TBL_ENTRY(0xd26), TBL_ENTRY(0xd27),
-       TBL_ENTRY(0xd28), TBL_ENTRY(0xd29), TBL_ENTRY(0xd2a), TBL_ENTRY(0xd2b),
-       TBL_ENTRY(0xd2c), TBL_ENTRY(0xd2d), TBL_ENTRY(0xd2e), TBL_ENTRY(0xd2f),
-       TBL_ENTRY(0xd30), TBL_ENTRY(0xd31), TBL_ENTRY(0xd32), TBL_ENTRY(0xd33),
-       TBL_ENTRY(0xd34), TBL_ENTRY(0xd35), TBL_ENTRY(0xd36), TBL_ENTRY(0xd37),
-       TBL_ENTRY(0xd38), TBL_ENTRY(0xd39), TBL_ENTRY(0xd3a), TBL_ENTRY(0xd3b),
-       TBL_ENTRY(0xd3c), TBL_ENTRY(0xd3d), TBL_ENTRY(0xd3e), TBL_ENTRY(0xd3f),
-       TBL_ENTRY(0xd40), TBL_ENTRY(0xd41), TBL_ENTRY(0xd42), TBL_ENTRY(0xd43),
-       TBL_ENTRY(0xd44), TBL_ENTRY(0xd45), TBL_ENTRY(0xd46), TBL_ENTRY(0xd47),
-       TBL_ENTRY(0xd48), TBL_ENTRY(0xd49), TBL_ENTRY(0xd4a), TBL_ENTRY(0xd4b),
-       TBL_ENTRY(0xd4c), TBL_ENTRY(0xd4d), TBL_ENTRY(0xd4e), TBL_ENTRY(0xd4f),
-       TBL_ENTRY(0xd50), TBL_ENTRY(0xd51), TBL_ENTRY(0xd52), TBL_ENTRY(0xd53),
-       TBL_ENTRY(0xd54), TBL_ENTRY(0xd55), TBL_ENTRY(0xd56), TBL_ENTRY(0xd57),
-       TBL_ENTRY(0xd58), TBL_ENTRY(0xd59), TBL_ENTRY(0xd5a), TBL_ENTRY(0xd5b),
-       TBL_ENTRY(0xd5c), TBL_ENTRY(0xd5d), TBL_ENTRY(0xd5e), TBL_ENTRY(0xd5f),
-       TBL_ENTRY(0xd60), TBL_ENTRY(0xd61), TBL_ENTRY(0xd62), TBL_ENTRY(0xd63),
-       TBL_ENTRY(0xd64), TBL_ENTRY(0xd65), TBL_ENTRY(0xd66), TBL_ENTRY(0xd67),
-       TBL_ENTRY(0xd68), TBL_ENTRY(0xd69), TBL_ENTRY(0xd6a), TBL_ENTRY(0xd6b),
-       TBL_ENTRY(0xd6c), TBL_ENTRY(0xd6d), TBL_ENTRY(0xd6e), TBL_ENTRY(0xd6f),
-       TBL_ENTRY(0xd70), TBL_ENTRY(0xd71), TBL_ENTRY(0xd72), TBL_ENTRY(0xd73),
-       TBL_ENTRY(0xd74), TBL_ENTRY(0xd75), TBL_ENTRY(0xd76), TBL_ENTRY(0xd77),
-       TBL_ENTRY(0xd78), TBL_ENTRY(0xd79), TBL_ENTRY(0xd7a), TBL_ENTRY(0xd7b),
-       TBL_ENTRY(0xd7c), TBL_ENTRY(0xd7d), TBL_ENTRY(0xd7e), TBL_ENTRY(0xd7f),
-       TBL_ENTRY(0xd80), TBL_ENTRY(0xd81), TBL_ENTRY(0xd82), TBL_ENTRY(0xd83),
-       TBL_ENTRY(0xd84), TBL_ENTRY(0xd85), TBL_ENTRY(0xd86), TBL_ENTRY(0xd87),
-       TBL_ENTRY(0xd88), TBL_ENTRY(0xd89), TBL_ENTRY(0xd8a), TBL_ENTRY(0xd8b),
-       TBL_ENTRY(0xd8c), TBL_ENTRY(0xd8d), TBL_ENTRY(0xd8e), TBL_ENTRY(0xd8f),
-       TBL_ENTRY(0xd90), TBL_ENTRY(0xd91), TBL_ENTRY(0xd92), TBL_ENTRY(0xd93),
-       TBL_ENTRY(0xd94), TBL_ENTRY(0xd95), TBL_ENTRY(0xd96), TBL_ENTRY(0xd97),
-       TBL_ENTRY(0xd98), TBL_ENTRY(0xd99), TBL_ENTRY(0xd9a), TBL_ENTRY(0xd9b),
-       TBL_ENTRY(0xd9c), TBL_ENTRY(0xd9d), TBL_ENTRY(0xd9e), TBL_ENTRY(0xd9f),
-       TBL_ENTRY(0xda0), TBL_ENTRY(0xda1), TBL_ENTRY(0xda2), TBL_ENTRY(0xda3),
-       TBL_ENTRY(0xda4), TBL_ENTRY(0xda5), TBL_ENTRY(0xda6), TBL_ENTRY(0xda7),
-       TBL_ENTRY(0xda8), TBL_ENTRY(0xda9), TBL_ENTRY(0xdaa), TBL_ENTRY(0xdab),
-       TBL_ENTRY(0xdac), TBL_ENTRY(0xdad), TBL_ENTRY(0xdae), TBL_ENTRY(0xdaf),
-       TBL_ENTRY(0xdb0), TBL_ENTRY(0xdb1), TBL_ENTRY(0xdb2), TBL_ENTRY(0xdb3),
-       TBL_ENTRY(0xdb4), TBL_ENTRY(0xdb5), TBL_ENTRY(0xdb6), TBL_ENTRY(0xdb7),
-       TBL_ENTRY(0xdb8), TBL_ENTRY(0xdb9), TBL_ENTRY(0xdba), TBL_ENTRY(0xdbb),
-       TBL_ENTRY(0xdbc), TBL_ENTRY(0xdbd), TBL_ENTRY(0xdbe), TBL_ENTRY(0xdbf),
-       TBL_ENTRY(0xdc0), TBL_ENTRY(0xdc1), TBL_ENTRY(0xdc2), TBL_ENTRY(0xdc3),
-       TBL_ENTRY(0xdc4), TBL_ENTRY(0xdc5), TBL_ENTRY(0xdc6), TBL_ENTRY(0xdc7),
-       TBL_ENTRY(0xdc8), TBL_ENTRY(0xdc9), TBL_ENTRY(0xdca), TBL_ENTRY(0xdcb),
-       TBL_ENTRY(0xdcc), TBL_ENTRY(0xdcd), TBL_ENTRY(0xdce), TBL_ENTRY(0xdcf),
-       TBL_ENTRY(0xdd0), TBL_ENTRY(0xdd1), TBL_ENTRY(0xdd2), TBL_ENTRY(0xdd3),
-       TBL_ENTRY(0xdd4), TBL_ENTRY(0xdd5), TBL_ENTRY(0xdd6), TBL_ENTRY(0xdd7),
-       TBL_ENTRY(0xdd8), TBL_ENTRY(0xdd9), TBL_ENTRY(0xdda), TBL_ENTRY(0xddb),
-       TBL_ENTRY(0xddc), TBL_ENTRY(0xddd), TBL_ENTRY(0xdde), TBL_ENTRY(0xddf),
-       TBL_ENTRY(0xde0), TBL_ENTRY(0xde1), TBL_ENTRY(0xde2), TBL_ENTRY(0xde3),
-       TBL_ENTRY(0xde4), TBL_ENTRY(0xde5), TBL_ENTRY(0xde6), TBL_ENTRY(0xde7),
-       TBL_ENTRY(0xde8), TBL_ENTRY(0xde9), TBL_ENTRY(0xdea), TBL_ENTRY(0xdeb),
-       TBL_ENTRY(0xdec), TBL_ENTRY(0xded), TBL_ENTRY(0xdee), TBL_ENTRY(0xdef),
-       TBL_ENTRY(0xdf0), TBL_ENTRY(0xdf1), TBL_ENTRY(0xdf2), TBL_ENTRY(0xdf3),
-       TBL_ENTRY(0xdf4), TBL_ENTRY(0xdf5), TBL_ENTRY(0xdf6), TBL_ENTRY(0xdf7),
-       TBL_ENTRY(0xdf8), TBL_ENTRY(0xdf9), TBL_ENTRY(0xdfa), TBL_ENTRY(0xdfb),
-       TBL_ENTRY(0xdfc), TBL_ENTRY(0xdfd), TBL_ENTRY(0xdfe), TBL_ENTRY(0xdff),
-       TBL_ENTRY(0xe00), TBL_ENTRY(0xe01), TBL_ENTRY(0xe02), TBL_ENTRY(0xe03),
-       TBL_ENTRY(0xe04), TBL_ENTRY(0xe05), TBL_ENTRY(0xe06), TBL_ENTRY(0xe07),
-       TBL_ENTRY(0xe08), TBL_ENTRY(0xe09), TBL_ENTRY(0xe0a), TBL_ENTRY(0xe0b),
-       TBL_ENTRY(0xe0c), TBL_ENTRY(0xe0d), TBL_ENTRY(0xe0e), TBL_ENTRY(0xe0f),
-       TBL_ENTRY(0xe10), TBL_ENTRY(0xe11), TBL_ENTRY(0xe12), TBL_ENTRY(0xe13),
-       TBL_ENTRY(0xe14), TBL_ENTRY(0xe15), TBL_ENTRY(0xe16), TBL_ENTRY(0xe17),
-       TBL_ENTRY(0xe18), TBL_ENTRY(0xe19), TBL_ENTRY(0xe1a), TBL_ENTRY(0xe1b),
-       TBL_ENTRY(0xe1c), TBL_ENTRY(0xe1d), TBL_ENTRY(0xe1e), TBL_ENTRY(0xe1f),
-       TBL_ENTRY(0xe20), TBL_ENTRY(0xe21), TBL_ENTRY(0xe22), TBL_ENTRY(0xe23),
-       TBL_ENTRY(0xe24), TBL_ENTRY(0xe25), TBL_ENTRY(0xe26), TBL_ENTRY(0xe27),
-       TBL_ENTRY(0xe28), TBL_ENTRY(0xe29), TBL_ENTRY(0xe2a), TBL_ENTRY(0xe2b),
-       TBL_ENTRY(0xe2c), TBL_ENTRY(0xe2d), TBL_ENTRY(0xe2e), TBL_ENTRY(0xe2f),
-       TBL_ENTRY(0xe30), TBL_ENTRY(0xe31), TBL_ENTRY(0xe32), TBL_ENTRY(0xe33),
-       TBL_ENTRY(0xe34), TBL_ENTRY(0xe35), TBL_ENTRY(0xe36), TBL_ENTRY(0xe37),
-       TBL_ENTRY(0xe38), TBL_ENTRY(0xe39), TBL_ENTRY(0xe3a), TBL_ENTRY(0xe3b),
-       TBL_ENTRY(0xe3c), TBL_ENTRY(0xe3d), TBL_ENTRY(0xe3e), TBL_ENTRY(0xe3f),
-       TBL_ENTRY(0xe40), TBL_ENTRY(0xe41), TBL_ENTRY(0xe42), TBL_ENTRY(0xe43),
-       TBL_ENTRY(0xe44), TBL_ENTRY(0xe45), TBL_ENTRY(0xe46), TBL_ENTRY(0xe47),
-       TBL_ENTRY(0xe48), TBL_ENTRY(0xe49), TBL_ENTRY(0xe4a), TBL_ENTRY(0xe4b),
-       TBL_ENTRY(0xe4c), TBL_ENTRY(0xe4d), TBL_ENTRY(0xe4e), TBL_ENTRY(0xe4f),
-       TBL_ENTRY(0xe50), TBL_ENTRY(0xe51), TBL_ENTRY(0xe52), TBL_ENTRY(0xe53),
-       TBL_ENTRY(0xe54), TBL_ENTRY(0xe55), TBL_ENTRY(0xe56), TBL_ENTRY(0xe57),
-       TBL_ENTRY(0xe58), TBL_ENTRY(0xe59), TBL_ENTRY(0xe5a), TBL_ENTRY(0xe5b),
-       TBL_ENTRY(0xe5c), TBL_ENTRY(0xe5d), TBL_ENTRY(0xe5e), TBL_ENTRY(0xe5f),
-       TBL_ENTRY(0xe60), TBL_ENTRY(0xe61), TBL_ENTRY(0xe62), TBL_ENTRY(0xe63),
-       TBL_ENTRY(0xe64), TBL_ENTRY(0xe65), TBL_ENTRY(0xe66), TBL_ENTRY(0xe67),
-       TBL_ENTRY(0xe68), TBL_ENTRY(0xe69), TBL_ENTRY(0xe6a), TBL_ENTRY(0xe6b),
-       TBL_ENTRY(0xe6c), TBL_ENTRY(0xe6d), TBL_ENTRY(0xe6e), TBL_ENTRY(0xe6f),
-       TBL_ENTRY(0xe70), TBL_ENTRY(0xe71), TBL_ENTRY(0xe72), TBL_ENTRY(0xe73),
-       TBL_ENTRY(0xe74), TBL_ENTRY(0xe75), TBL_ENTRY(0xe76), TBL_ENTRY(0xe77),
-       TBL_ENTRY(0xe78), TBL_ENTRY(0xe79), TBL_ENTRY(0xe7a), TBL_ENTRY(0xe7b),
-       TBL_ENTRY(0xe7c), TBL_ENTRY(0xe7d), TBL_ENTRY(0xe7e), TBL_ENTRY(0xe7f),
-       TBL_ENTRY(0xe80), TBL_ENTRY(0xe81), TBL_ENTRY(0xe82), TBL_ENTRY(0xe83),
-       TBL_ENTRY(0xe84), TBL_ENTRY(0xe85), TBL_ENTRY(0xe86), TBL_ENTRY(0xe87),
-       TBL_ENTRY(0xe88), TBL_ENTRY(0xe89), TBL_ENTRY(0xe8a), TBL_ENTRY(0xe8b),
-       TBL_ENTRY(0xe8c), TBL_ENTRY(0xe8d), TBL_ENTRY(0xe8e), TBL_ENTRY(0xe8f),
-       TBL_ENTRY(0xe90), TBL_ENTRY(0xe91), TBL_ENTRY(0xe92), TBL_ENTRY(0xe93),
-       TBL_ENTRY(0xe94), TBL_ENTRY(0xe95), TBL_ENTRY(0xe96), TBL_ENTRY(0xe97),
-       TBL_ENTRY(0xe98), TBL_ENTRY(0xe99), TBL_ENTRY(0xe9a), TBL_ENTRY(0xe9b),
-       TBL_ENTRY(0xe9c), TBL_ENTRY(0xe9d), TBL_ENTRY(0xe9e), TBL_ENTRY(0xe9f),
-       TBL_ENTRY(0xea0), TBL_ENTRY(0xea1), TBL_ENTRY(0xea2), TBL_ENTRY(0xea3),
-       TBL_ENTRY(0xea4), TBL_ENTRY(0xea5), TBL_ENTRY(0xea6), TBL_ENTRY(0xea7),
-       TBL_ENTRY(0xea8), TBL_ENTRY(0xea9), TBL_ENTRY(0xeaa), TBL_ENTRY(0xeab),
-       TBL_ENTRY(0xeac), TBL_ENTRY(0xead), TBL_ENTRY(0xeae), TBL_ENTRY(0xeaf),
-       TBL_ENTRY(0xeb0), TBL_ENTRY(0xeb1), TBL_ENTRY(0xeb2), TBL_ENTRY(0xeb3),
-       TBL_ENTRY(0xeb4), TBL_ENTRY(0xeb5), TBL_ENTRY(0xeb6), TBL_ENTRY(0xeb7),
-       TBL_ENTRY(0xeb8), TBL_ENTRY(0xeb9), TBL_ENTRY(0xeba), TBL_ENTRY(0xebb),
-       TBL_ENTRY(0xebc), TBL_ENTRY(0xebd), TBL_ENTRY(0xebe), TBL_ENTRY(0xebf),
-       TBL_ENTRY(0xec0), TBL_ENTRY(0xec1), TBL_ENTRY(0xec2), TBL_ENTRY(0xec3),
-       TBL_ENTRY(0xec4), TBL_ENTRY(0xec5), TBL_ENTRY(0xec6), TBL_ENTRY(0xec7),
-       TBL_ENTRY(0xec8), TBL_ENTRY(0xec9), TBL_ENTRY(0xeca), TBL_ENTRY(0xecb),
-       TBL_ENTRY(0xecc), TBL_ENTRY(0xecd), TBL_ENTRY(0xece), TBL_ENTRY(0xecf),
-       TBL_ENTRY(0xed0), TBL_ENTRY(0xed1), TBL_ENTRY(0xed2), TBL_ENTRY(0xed3),
-       TBL_ENTRY(0xed4), TBL_ENTRY(0xed5), TBL_ENTRY(0xed6), TBL_ENTRY(0xed7),
-       TBL_ENTRY(0xed8), TBL_ENTRY(0xed9), TBL_ENTRY(0xeda), TBL_ENTRY(0xedb),
-       TBL_ENTRY(0xedc), TBL_ENTRY(0xedd), TBL_ENTRY(0xede), TBL_ENTRY(0xedf),
-       TBL_ENTRY(0xee0), TBL_ENTRY(0xee1), TBL_ENTRY(0xee2), TBL_ENTRY(0xee3),
-       TBL_ENTRY(0xee4), TBL_ENTRY(0xee5), TBL_ENTRY(0xee6), TBL_ENTRY(0xee7),
-       TBL_ENTRY(0xee8), TBL_ENTRY(0xee9), TBL_ENTRY(0xeea), TBL_ENTRY(0xeeb),
-       TBL_ENTRY(0xeec), TBL_ENTRY(0xeed), TBL_ENTRY(0xeee), TBL_ENTRY(0xeef),
-       TBL_ENTRY(0xef0), TBL_ENTRY(0xef1), TBL_ENTRY(0xef2), TBL_ENTRY(0xef3),
-       TBL_ENTRY(0xef4), TBL_ENTRY(0xef5), TBL_ENTRY(0xef6), TBL_ENTRY(0xef7),
-       TBL_ENTRY(0xef8), TBL_ENTRY(0xef9), TBL_ENTRY(0xefa), TBL_ENTRY(0xefb),
-       TBL_ENTRY(0xefc), TBL_ENTRY(0xefd), TBL_ENTRY(0xefe), TBL_ENTRY(0xeff),
-       TBL_ENTRY(0xf00), TBL_ENTRY(0xf01), TBL_ENTRY(0xf02), TBL_ENTRY(0xf03),
-       TBL_ENTRY(0xf04), TBL_ENTRY(0xf05), TBL_ENTRY(0xf06), TBL_ENTRY(0xf07),
-       TBL_ENTRY(0xf08), TBL_ENTRY(0xf09), TBL_ENTRY(0xf0a), TBL_ENTRY(0xf0b),
-       TBL_ENTRY(0xf0c), TBL_ENTRY(0xf0d), TBL_ENTRY(0xf0e), TBL_ENTRY(0xf0f),
-       TBL_ENTRY(0xf10), TBL_ENTRY(0xf11), TBL_ENTRY(0xf12), TBL_ENTRY(0xf13),
-       TBL_ENTRY(0xf14), TBL_ENTRY(0xf15), TBL_ENTRY(0xf16), TBL_ENTRY(0xf17),
-       TBL_ENTRY(0xf18), TBL_ENTRY(0xf19), TBL_ENTRY(0xf1a), TBL_ENTRY(0xf1b),
-       TBL_ENTRY(0xf1c), TBL_ENTRY(0xf1d), TBL_ENTRY(0xf1e), TBL_ENTRY(0xf1f),
-       TBL_ENTRY(0xf20), TBL_ENTRY(0xf21), TBL_ENTRY(0xf22), TBL_ENTRY(0xf23),
-       TBL_ENTRY(0xf24), TBL_ENTRY(0xf25), TBL_ENTRY(0xf26), TBL_ENTRY(0xf27),
-       TBL_ENTRY(0xf28), TBL_ENTRY(0xf29), TBL_ENTRY(0xf2a), TBL_ENTRY(0xf2b),
-       TBL_ENTRY(0xf2c), TBL_ENTRY(0xf2d), TBL_ENTRY(0xf2e), TBL_ENTRY(0xf2f),
-       TBL_ENTRY(0xf30), TBL_ENTRY(0xf31), TBL_ENTRY(0xf32), TBL_ENTRY(0xf33),
-       TBL_ENTRY(0xf34), TBL_ENTRY(0xf35), TBL_ENTRY(0xf36), TBL_ENTRY(0xf37),
-       TBL_ENTRY(0xf38), TBL_ENTRY(0xf39), TBL_ENTRY(0xf3a), TBL_ENTRY(0xf3b),
-       TBL_ENTRY(0xf3c), TBL_ENTRY(0xf3d), TBL_ENTRY(0xf3e), TBL_ENTRY(0xf3f),
-       TBL_ENTRY(0xf40), TBL_ENTRY(0xf41), TBL_ENTRY(0xf42), TBL_ENTRY(0xf43),
-       TBL_ENTRY(0xf44), TBL_ENTRY(0xf45), TBL_ENTRY(0xf46), TBL_ENTRY(0xf47),
-       TBL_ENTRY(0xf48), TBL_ENTRY(0xf49), TBL_ENTRY(0xf4a), TBL_ENTRY(0xf4b),
-       TBL_ENTRY(0xf4c), TBL_ENTRY(0xf4d), TBL_ENTRY(0xf4e), TBL_ENTRY(0xf4f),
-       TBL_ENTRY(0xf50), TBL_ENTRY(0xf51), TBL_ENTRY(0xf52), TBL_ENTRY(0xf53),
-       TBL_ENTRY(0xf54), TBL_ENTRY(0xf55), TBL_ENTRY(0xf56), TBL_ENTRY(0xf57),
-       TBL_ENTRY(0xf58), TBL_ENTRY(0xf59), TBL_ENTRY(0xf5a), TBL_ENTRY(0xf5b),
-       TBL_ENTRY(0xf5c), TBL_ENTRY(0xf5d), TBL_ENTRY(0xf5e), TBL_ENTRY(0xf5f),
-       TBL_ENTRY(0xf60), TBL_ENTRY(0xf61), TBL_ENTRY(0xf62), TBL_ENTRY(0xf63),
-       TBL_ENTRY(0xf64), TBL_ENTRY(0xf65), TBL_ENTRY(0xf66), TBL_ENTRY(0xf67),
-       TBL_ENTRY(0xf68), TBL_ENTRY(0xf69), TBL_ENTRY(0xf6a), TBL_ENTRY(0xf6b),
-       TBL_ENTRY(0xf6c), TBL_ENTRY(0xf6d), TBL_ENTRY(0xf6e), TBL_ENTRY(0xf6f),
-       TBL_ENTRY(0xf70), TBL_ENTRY(0xf71), TBL_ENTRY(0xf72), TBL_ENTRY(0xf73),
-       TBL_ENTRY(0xf74), TBL_ENTRY(0xf75), TBL_ENTRY(0xf76), TBL_ENTRY(0xf77),
-       TBL_ENTRY(0xf78), TBL_ENTRY(0xf79), TBL_ENTRY(0xf7a), TBL_ENTRY(0xf7b),
-       TBL_ENTRY(0xf7c), TBL_ENTRY(0xf7d), TBL_ENTRY(0xf7e), TBL_ENTRY(0xf7f),
-       TBL_ENTRY(0xf80), TBL_ENTRY(0xf81), TBL_ENTRY(0xf82), TBL_ENTRY(0xf83),
-       TBL_ENTRY(0xf84), TBL_ENTRY(0xf85), TBL_ENTRY(0xf86), TBL_ENTRY(0xf87),
-       TBL_ENTRY(0xf88), TBL_ENTRY(0xf89), TBL_ENTRY(0xf8a), TBL_ENTRY(0xf8b),
-       TBL_ENTRY(0xf8c), TBL_ENTRY(0xf8d), TBL_ENTRY(0xf8e), TBL_ENTRY(0xf8f),
-       TBL_ENTRY(0xf90), TBL_ENTRY(0xf91), TBL_ENTRY(0xf92), TBL_ENTRY(0xf93),
-       TBL_ENTRY(0xf94), TBL_ENTRY(0xf95), TBL_ENTRY(0xf96), TBL_ENTRY(0xf97),
-       TBL_ENTRY(0xf98), TBL_ENTRY(0xf99), TBL_ENTRY(0xf9a), TBL_ENTRY(0xf9b),
-       TBL_ENTRY(0xf9c), TBL_ENTRY(0xf9d), TBL_ENTRY(0xf9e), TBL_ENTRY(0xf9f),
-       TBL_ENTRY(0xfa0), TBL_ENTRY(0xfa1), TBL_ENTRY(0xfa2), TBL_ENTRY(0xfa3),
-       TBL_ENTRY(0xfa4), TBL_ENTRY(0xfa5), TBL_ENTRY(0xfa6), TBL_ENTRY(0xfa7),
-       TBL_ENTRY(0xfa8), TBL_ENTRY(0xfa9), TBL_ENTRY(0xfaa), TBL_ENTRY(0xfab),
-       TBL_ENTRY(0xfac), TBL_ENTRY(0xfad), TBL_ENTRY(0xfae), TBL_ENTRY(0xfaf),
-       TBL_ENTRY(0xfb0), TBL_ENTRY(0xfb1), TBL_ENTRY(0xfb2), TBL_ENTRY(0xfb3),
-       TBL_ENTRY(0xfb4), TBL_ENTRY(0xfb5), TBL_ENTRY(0xfb6), TBL_ENTRY(0xfb7),
-       TBL_ENTRY(0xfb8), TBL_ENTRY(0xfb9), TBL_ENTRY(0xfba), TBL_ENTRY(0xfbb),
-       TBL_ENTRY(0xfbc), TBL_ENTRY(0xfbd), TBL_ENTRY(0xfbe), TBL_ENTRY(0xfbf),
-       TBL_ENTRY(0xfc0), TBL_ENTRY(0xfc1), TBL_ENTRY(0xfc2), TBL_ENTRY(0xfc3),
-       TBL_ENTRY(0xfc4), TBL_ENTRY(0xfc5), TBL_ENTRY(0xfc6), TBL_ENTRY(0xfc7),
-       TBL_ENTRY(0xfc8), TBL_ENTRY(0xfc9), TBL_ENTRY(0xfca), TBL_ENTRY(0xfcb),
-       TBL_ENTRY(0xfcc), TBL_ENTRY(0xfcd), TBL_ENTRY(0xfce), TBL_ENTRY(0xfcf),
-       TBL_ENTRY(0xfd0), TBL_ENTRY(0xfd1), TBL_ENTRY(0xfd2), TBL_ENTRY(0xfd3),
-       TBL_ENTRY(0xfd4), TBL_ENTRY(0xfd5), TBL_ENTRY(0xfd6), TBL_ENTRY(0xfd7),
-       TBL_ENTRY(0xfd8), TBL_ENTRY(0xfd9), TBL_ENTRY(0xfda), TBL_ENTRY(0xfdb),
-       TBL_ENTRY(0xfdc), TBL_ENTRY(0xfdd), TBL_ENTRY(0xfde), TBL_ENTRY(0xfdf),
-       TBL_ENTRY(0xfe0), TBL_ENTRY(0xfe1), TBL_ENTRY(0xfe2), TBL_ENTRY(0xfe3),
-       TBL_ENTRY(0xfe4), TBL_ENTRY(0xfe5), TBL_ENTRY(0xfe6), TBL_ENTRY(0xfe7),
-       TBL_ENTRY(0xfe8), TBL_ENTRY(0xfe9), TBL_ENTRY(0xfea), TBL_ENTRY(0xfeb),
-       TBL_ENTRY(0xfec), TBL_ENTRY(0xfed), TBL_ENTRY(0xfee), TBL_ENTRY(0xfef),
-       TBL_ENTRY(0xff0), TBL_ENTRY(0xff1), TBL_ENTRY(0xff2), TBL_ENTRY(0xff3),
-       TBL_ENTRY(0xff4), TBL_ENTRY(0xff5), TBL_ENTRY(0xff6), TBL_ENTRY(0xff7),
-       TBL_ENTRY(0xff8), TBL_ENTRY(0xff9), TBL_ENTRY(0xffa), TBL_ENTRY(0xffb),
-       TBL_ENTRY(0xffc), TBL_ENTRY(0xffd), TBL_ENTRY(0xffe), TBL_ENTRY(0xfff),
-};
index 07529061213e6be38ca5e7de7fa0ddda86c93c70..72f46636fd5d60aa39f689c9f3f2c3a5807b1147 100644 (file)
@@ -2,11 +2,13 @@
 # SPDX-License-Identifier:     GPL-2.0+
 #
 
-obj-$(CONFIG_DISPLAY_BOARDINFO) += board_info.o
+ifdef CONFIG_SPL_BUILD
+obj-$(CONFIG_DEBUG_LL) += lowlevel_debug.o
+obj-y += bcu_init.o sbc_init.o sg_init.o pll_init.o clkrst_init.o \
+       pll_spectrum.o umc_init.o ddrphy_init.o
+else
+obj-$(CONFIG_BOARD_EARLY_INIT_F) += pinctrl.o
 obj-$(if $(CONFIG_OF_CONTROL),,y) += platdevice.o
+endif
+
 obj-y += boot-mode.o
-obj-$(CONFIG_DEBUG_LL) += lowlevel_debug.o
-obj-$(CONFIG_SOC_INIT) += bcu_init.o sbc_init.o sg_init.o pll_init.o \
-                                                               clkrst_init.o
-obj-$(CONFIG_BOARD_POSTCLK_INIT) += pinctrl.o
-obj-$(CONFIG_DRAM_INIT) += pll_spectrum.o umc_init.o ddrphy_init.o
diff --git a/arch/arm/cpu/armv7/uniphier/ph1-ld4/board_info.c b/arch/arm/cpu/armv7/uniphier/ph1-ld4/board_info.c
deleted file mode 100644 (file)
index 27d772e..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * Copyright (C) 2012-2014 Panasonic Corporation
- *   Author: Masahiro Yamada <yamada.m@jp.panasonic.com>
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#include <common.h>
-#include <asm/arch/board.h>
-
-int checkboard(void)
-{
-       puts("Board: PH1-LD4 Board\n");
-
-       return check_support_card();
-}
index 68b9d5ff2798d4e9210ec1313c9ea94dd08c8f3d..b83582fee798b5677088caf2f312d1a0ffc94e5f 100644 (file)
@@ -11,7 +11,7 @@
 
 #undef DPLL_SSC_RATE_1PER
 
-void dpll_init(void)
+static void dpll_init(void)
 {
        u32 tmp;
 
@@ -42,7 +42,7 @@ void dpll_init(void)
        writel(tmp, SC_DPLLCTRL2);
 }
 
-void upll_init(void)
+static void upll_init(void)
 {
        u32 tmp, clk_mode_upll, clk_mode_axosel;
 
@@ -82,7 +82,7 @@ void upll_init(void)
        writel(tmp, SC_UPLLCTRL);
 }
 
-void vpll_init(void)
+static void vpll_init(void)
 {
        u32 tmp, clk_mode_axosel;
 
index b4dd799a884bef80a99b351571650ee2081f4bb6..2cc5df608f833151e82cc27d2d15183815dbb5a0 100644 (file)
@@ -21,7 +21,7 @@ void sg_init(void)
 #endif
        writel(tmp, SG_MEMCONF);
 
-       /* Input ports must be enabled deasserting reset of cores */
+       /* Input ports must be enabled before deasserting reset of cores */
        tmp = readl(SG_IECTRL);
        tmp |= 0x1;
        writel(tmp, SG_IECTRL);
index 87889160a7058c39cdd8c32cea9ec8b82eddbe03..bbc3dcb3da8b4593e77889ea947a848d0171a880 100644 (file)
@@ -9,7 +9,7 @@
 #include <asm/arch/umc-regs.h>
 #include <asm/arch/ddrphy-regs.h>
 
-static inline void umc_start_ssif(void __iomem *ssif_base)
+static void umc_start_ssif(void __iomem *ssif_base)
 {
        writel(0x00000000, ssif_base + 0x0000b004);
        writel(0xffffffff, ssif_base + 0x0000c004);
@@ -43,8 +43,8 @@ static inline void umc_start_ssif(void __iomem *ssif_base)
        writel(0x00000001, ssif_base + UMC_DMDRST);
 }
 
-void umc_dramcont_init(void __iomem *dramcont, void __iomem *ca_base,
-                      int size, int freq)
+static void umc_dramcont_init(void __iomem *dramcont, void __iomem *ca_base,
+                             int size, int freq)
 {
        if (freq == 1333) {
                writel(0x45990b11, dramcont + UMC_CMDCTLA);
@@ -119,7 +119,7 @@ void umc_dramcont_init(void __iomem *dramcont, void __iomem *ca_base,
        writel(0x00000520, dramcont + UMC_DFICUPDCTLA);
 }
 
-static inline int umc_init_sub(int freq, int size_ch0, int size_ch1)
+static int umc_init_sub(int freq, int size_ch0, int size_ch1)
 {
        void __iomem *ssif_base = (void __iomem *)UMC_SSIF_BASE;
        void __iomem *ca_base0 = (void __iomem *)UMC_CA_BASE(0);
index 8206e2a3542774e0133525825c95e7238f3a1657..e330fda1ed44a7f420744011525c98b59cf33b9e 100644 (file)
@@ -2,10 +2,13 @@
 # SPDX-License-Identifier:     GPL-2.0+
 #
 
-obj-$(CONFIG_DISPLAY_BOARDINFO) += board_info.o
+ifdef CONFIG_SPL_BUILD
+obj-$(CONFIG_DEBUG_LL) += lowlevel_debug.o
+obj-y += sbc_init.o sg_init.o pll_init.o clkrst_init.o \
+       pll_spectrum.o umc_init.o ddrphy_init.o
+else
+obj-$(CONFIG_BOARD_EARLY_INIT_F) += pinctrl.o
 obj-$(if $(CONFIG_OF_CONTROL),,y) += platdevice.o
+endif
+
 obj-y += boot-mode.o
-obj-$(CONFIG_DEBUG_LL) += lowlevel_debug.o
-obj-$(CONFIG_SOC_INIT) += sbc_init.o sg_init.o pll_init.o clkrst_init.o
-obj-$(CONFIG_BOARD_POSTCLK_INIT) += pinctrl.o
-obj-$(CONFIG_DRAM_INIT) += pll_spectrum.o umc_init.o ddrphy_init.o
diff --git a/arch/arm/cpu/armv7/uniphier/ph1-pro4/board_info.c b/arch/arm/cpu/armv7/uniphier/ph1-pro4/board_info.c
deleted file mode 100644 (file)
index 325a4f6..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * Copyright (C) 2012-2014 Panasonic Corporation
- *   Author: Masahiro Yamada <yamada.m@jp.panasonic.com>
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#include <common.h>
-#include <asm/arch/board.h>
-
-int checkboard(void)
-{
-       puts("Board: PH1-Pro4 Board\n");
-
-       return check_support_card();
-}
index 33bccff2a5e05ffe616f1c7a8a3a65ef1770b737..c31b74badd26968550dd6a2f09074c4b4bb7d343 100644 (file)
@@ -45,17 +45,17 @@ struct boot_device_info boot_device_table[] = {
        {BOOT_DEVICE_NONE, "Reserved"},
        {BOOT_DEVICE_NONE, "Reserved"},
        {BOOT_DEVICE_NONE, "Reserved"},
-       {BOOT_DEVICE_NONE, ""}
+       { /* sentinel */ }
 };
 
-u32 get_boot_mode_sel(void)
+int get_boot_mode_sel(void)
 {
        return (readl(SG_PINMON0) >> 1) & 0x1f;
 }
 
 u32 spl_boot_device(void)
 {
-       u32 boot_mode;
+       int boot_mode;
 
        if (boot_is_swapped())
                return BOOT_DEVICE_NOR;
index 2dcc0892cc7b7a0557da6cdb2cd05d9cb54f6500..1db90f88a0e7c99badc3a089462929ce998fd191 100644 (file)
@@ -11,7 +11,7 @@
 
 #undef DPLL_SSC_RATE_1PER
 
-void dpll_init(void)
+static void dpll_init(void)
 {
        u32 tmp;
 
@@ -46,7 +46,7 @@ void dpll_init(void)
        writel(tmp, SC_DPLLCTRL2);
 }
 
-void stop_mpll(void)
+static void stop_mpll(void)
 {
        u32 tmp;
 
@@ -62,7 +62,7 @@ void stop_mpll(void)
                ;
 }
 
-void vpll_init(void)
+static void vpll_init(void)
 {
        u32 tmp, clk_mode_axosel;
 
index b4dd799a884bef80a99b351571650ee2081f4bb6..b7c4b1096963ec72dcd195058af33d0ebc1acfcc 100644 (file)
@@ -21,8 +21,8 @@ void sg_init(void)
 #endif
        writel(tmp, SG_MEMCONF);
 
-       /* Input ports must be enabled deasserting reset of cores */
+       /* Input ports must be enabled before deasserting reset of cores */
        tmp = readl(SG_IECTRL);
-       tmp |= 0x1;
+       tmp |= 1 << 6;
        writel(tmp, SG_IECTRL);
 }
index 1973ab04c25e122dc96a826a4b946a60f1bd02ba..2d1bde6f13fcac14f61d2cffb3214f0204fb91a4 100644 (file)
@@ -9,7 +9,7 @@
 #include <asm/arch/umc-regs.h>
 #include <asm/arch/ddrphy-regs.h>
 
-static inline void umc_start_ssif(void __iomem *ssif_base)
+static void umc_start_ssif(void __iomem *ssif_base)
 {
        writel(0x00000001, ssif_base + 0x0000b004);
        writel(0xffffffff, ssif_base + 0x0000c004);
@@ -52,8 +52,8 @@ static inline void umc_start_ssif(void __iomem *ssif_base)
        writel(0x00000001, ssif_base + UMC_DMDRST);
 }
 
-void umc_dramcont_init(void __iomem *dramcont, void __iomem *ca_base,
-                      int size, int freq)
+static void umc_dramcont_init(void __iomem *dramcont, void __iomem *ca_base,
+                             int size, int freq)
 {
        writel(0x66bb0f17, dramcont + UMC_CMDCTLA);
        writel(0x18c6aa44, dramcont + UMC_CMDCTLB);
@@ -88,7 +88,7 @@ void umc_dramcont_init(void __iomem *dramcont, void __iomem *ca_base,
        writel(0x80000020, dramcont + UMC_DFICUPDCTLA);
 }
 
-static inline int umc_init_sub(int freq, int size_ch0, int size_ch1)
+static int umc_init_sub(int freq, int size_ch0, int size_ch1)
 {
        void __iomem *ssif_base = (void __iomem *)UMC_SSIF_BASE;
        void __iomem *ca_base0 = (void __iomem *)UMC_CA_BASE(0);
index 07529061213e6be38ca5e7de7fa0ddda86c93c70..72f46636fd5d60aa39f689c9f3f2c3a5807b1147 100644 (file)
@@ -2,11 +2,13 @@
 # SPDX-License-Identifier:     GPL-2.0+
 #
 
-obj-$(CONFIG_DISPLAY_BOARDINFO) += board_info.o
+ifdef CONFIG_SPL_BUILD
+obj-$(CONFIG_DEBUG_LL) += lowlevel_debug.o
+obj-y += bcu_init.o sbc_init.o sg_init.o pll_init.o clkrst_init.o \
+       pll_spectrum.o umc_init.o ddrphy_init.o
+else
+obj-$(CONFIG_BOARD_EARLY_INIT_F) += pinctrl.o
 obj-$(if $(CONFIG_OF_CONTROL),,y) += platdevice.o
+endif
+
 obj-y += boot-mode.o
-obj-$(CONFIG_DEBUG_LL) += lowlevel_debug.o
-obj-$(CONFIG_SOC_INIT) += bcu_init.o sbc_init.o sg_init.o pll_init.o \
-                                                               clkrst_init.o
-obj-$(CONFIG_BOARD_POSTCLK_INIT) += pinctrl.o
-obj-$(CONFIG_DRAM_INIT) += pll_spectrum.o umc_init.o ddrphy_init.o
diff --git a/arch/arm/cpu/armv7/uniphier/ph1-sld8/board_info.c b/arch/arm/cpu/armv7/uniphier/ph1-sld8/board_info.c
deleted file mode 100644 (file)
index 15dc289..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * Copyright (C) 2012-2014 Panasonic Corporation
- *   Author: Masahiro Yamada <yamada.m@jp.panasonic.com>
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#include <common.h>
-#include <asm/arch/board.h>
-
-int checkboard(void)
-{
-       puts("Board: PH1-sLD8 Board\n");
-
-       return check_support_card();
-}
index 2b6403f88fc7dc3113c2acf6226c4a08cdfdbf6a..5e80335b581ff25c0e28ad6a4e19f5ddd4fa0109 100644 (file)
@@ -26,6 +26,15 @@ void pin_init(void)
        sg_set_pinsel(111, 1);  /* SBI0 -> RXD3 */
 #endif
 
+#ifdef CONFIG_SYS_I2C_UNIPHIER
+       {
+               u32 tmp;
+               tmp = readl(SG_IECTRL);
+               tmp |= 0xc00; /* enable SCL0, SDA0, SCL1, SDA1 */
+               writel(tmp, SG_IECTRL);
+       }
+#endif
+
 #ifdef CONFIG_NAND_DENALI
        sg_set_pinsel(15, 0);   /* XNFRE_GB -> XNFRE_GB */
        sg_set_pinsel(16, 0);   /* XNFWE_GB -> XNFWE_GB */
index 4d87053430eb771429583368b483adbe5677ee5b..4b82700f44f2686e73cefaa452a6541651024435 100644 (file)
@@ -9,7 +9,7 @@
 #include <asm/arch/sc-regs.h>
 #include <asm/arch/sg-regs.h>
 
-void dpll_init(void)
+static void dpll_init(void)
 {
        u32 tmp;
        /*
@@ -54,7 +54,7 @@ void dpll_init(void)
        writel(tmp, SC_DPLLCTRL2);
 }
 
-void upll_init(void)
+static void upll_init(void)
 {
        u32 tmp, clk_mode_upll, clk_mode_axosel;
 
@@ -94,7 +94,7 @@ void upll_init(void)
        writel(tmp, SC_UPLLCTRL);
 }
 
-void vpll_init(void)
+static void vpll_init(void)
 {
        u32 tmp, clk_mode_axosel;
 
index 2e0f9aeaa5e6300baffdc4ee75252adaf9c1777c..2fbc73ab03e4746f5711bb68b6ba74b3f5880fc8 100644 (file)
@@ -9,7 +9,7 @@
 #include <asm/arch/umc-regs.h>
 #include <asm/arch/ddrphy-regs.h>
 
-static inline void umc_start_ssif(void __iomem *ssif_base)
+static void umc_start_ssif(void __iomem *ssif_base)
 {
        writel(0x00000000, ssif_base + 0x0000b004);
        writel(0xffffffff, ssif_base + 0x0000c004);
@@ -43,8 +43,8 @@ static inline void umc_start_ssif(void __iomem *ssif_base)
        writel(0x00000001, ssif_base + UMC_DMDRST);
 }
 
-void umc_dramcont_init(void __iomem *dramcont, void __iomem *ca_base,
-                      int size, int freq)
+static void umc_dramcont_init(void __iomem *dramcont, void __iomem *ca_base,
+                             int size, int freq)
 {
 #ifdef CONFIG_DDR_STANDARD
        writel(0x55990b11, dramcont + UMC_CMDCTLA);
@@ -99,7 +99,7 @@ void umc_dramcont_init(void __iomem *dramcont, void __iomem *ca_base,
        writel(0x00000520, dramcont + UMC_DFICUPDCTLA);
 }
 
-static inline int umc_init_sub(int freq, int size_ch0, int size_ch1)
+static int umc_init_sub(int freq, int size_ch0, int size_ch1)
 {
        void __iomem *ssif_base = (void __iomem *)UMC_SSIF_BASE;
        void __iomem *ca_base0 = (void __iomem *)UMC_CA_BASE(0);
diff --git a/arch/arm/cpu/armv7/uniphier/print_misc_info.c b/arch/arm/cpu/armv7/uniphier/print_misc_info.c
new file mode 100644 (file)
index 0000000..69cfab5
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Copyright (C) 2015 Panasonic Corporation
+ *   Author: Masahiro Yamada <yamada.m@jp.panasonic.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <asm/arch/board.h>
+
+int misc_init_f(void)
+{
+       return check_support_card();
+}
index 40d28adaf336bfe5f4405fc5eb68d3982d9ea97c..8a4eafc266a03dd0ea20092aab7885a5ac91395c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013-2014 Panasonic Corporation
+ * Copyright (C) 2013-2015 Panasonic Corporation
  *   Author: Masahiro Yamada <yamada.m@jp.panasonic.com>
  *
  * SPDX-License-Identifier:    GPL-2.0+
@@ -7,11 +7,53 @@
 
 #include <common.h>
 #include <spl.h>
+#include <linux/compiler.h>
+#include <asm/arch/led.h>
+#include <asm/arch/board.h>
+
+void __weak bcu_init(void)
+{
+};
+void sbc_init(void);
+void sg_init(void);
+void pll_init(void);
+void pin_init(void);
+void clkrst_init(void);
+int umc_init(void);
+void enable_dpll_ssc(void);
 
 void spl_board_init(void)
 {
-#if defined(CONFIG_BOARD_POSTCLK_INIT)
-       board_postclk_init();
-#endif
-       dram_init();
+       bcu_init();
+
+       sbc_init();
+
+       sg_init();
+
+       uniphier_board_reset();
+
+       pll_init();
+
+       uniphier_board_init();
+
+       led_write(L, 0, , );
+
+       clkrst_init();
+
+       led_write(L, 1, , );
+
+       {
+               int res;
+
+               res = umc_init();
+               if (res < 0) {
+                       while (1)
+                               ;
+               }
+       }
+       led_write(L, 2, , );
+
+       enable_dpll_ssc();
+
+       led_write(L, 3, , );
 }
index 651ca4015d04456df3fa172adb9924af2552c4b5..b69fd37c189c51f338ad7f1cbf766404952fc36d 100644 (file)
@@ -15,8 +15,6 @@
 #include <asm/io.h>
 #include <asm/secure.h>
 
-unsigned long gic_dist_addr;
-
 static unsigned int read_id_pfr1(void)
 {
        unsigned int reg;
@@ -68,6 +66,12 @@ static void kick_secondary_cpus_gic(unsigned long gicdaddr)
 
 void __weak smp_kick_all_cpus(void)
 {
+       unsigned long gic_dist_addr;
+
+       gic_dist_addr = get_gicd_base_address();
+       if (gic_dist_addr == -1)
+               return;
+
        kick_secondary_cpus_gic(gic_dist_addr);
 }
 
@@ -75,6 +79,7 @@ int armv7_init_nonsec(void)
 {
        unsigned int reg;
        unsigned itlinesnr, i;
+       unsigned long gic_dist_addr;
 
        /* check whether the CPU supports the security extensions */
        reg = read_id_pfr1();
index 3363a3c71b9837270e8b5ccfdcc360dc911da0fa..901f2ce4cbb79c73720252b7a54f040ae70a3b7f 100644 (file)
@@ -13,4 +13,5 @@ obj-y += cpu.o
 obj-y  += ddrc.o
 obj-y  += slcr.o
 obj-y  += clk.o
+obj-y  += lowlevel_init.o
 obj-$(CONFIG_SPL_BUILD)        += spl.o
diff --git a/arch/arm/cpu/armv7/zynq/config.mk b/arch/arm/cpu/armv7/zynq/config.mk
new file mode 100644 (file)
index 0000000..778a377
--- /dev/null
@@ -0,0 +1,7 @@
+#
+# Copyright (C) 2013 - 2015 Xilinx, Inc. All rights reserved.
+#
+# SPDX-License-Identifier:      GPL-2.0
+#
+# Allow NEON instructions (needed for lowlevel_init.S with GNU toolchain)
+PLATFORM_RELFLAGS += -mfpu=neon
index 816d0c5da7a5c69104c5458939bf799256e04229..914b1feb6833310144d229c307b8130218d00f02 100644 (file)
 #include <asm/arch/sys_proto.h>
 #include <asm/arch/hardware.h>
 
-void lowlevel_init(void)
-{
-}
-
 #define ZYNQ_SILICON_VER_MASK  0xF0000000
 #define ZYNQ_SILICON_VER_SHIFT 28
 
index d74f8dbbc45dfb9f6440ea38fa44552404f436ef..5b20accbcb172d7e0e40dc7c92933f5123e1485a 100644 (file)
@@ -42,6 +42,8 @@ void zynq_ddrc_init(void)
                 */
                /* cppcheck-suppress nullPointer */
                memset((void *)0, 0, 1 * 1024 * 1024);
+
+               gd->ram_size /= 2;
        } else {
                puts("ECC disabled ");
        }
diff --git a/arch/arm/cpu/armv7/zynq/lowlevel_init.S b/arch/arm/cpu/armv7/zynq/lowlevel_init.S
new file mode 100644 (file)
index 0000000..6d714b7
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2013 Xilinx, Inc. All rights reserved.
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <asm-offsets.h>
+#include <config.h>
+#include <linux/linkage.h>
+
+ENTRY(lowlevel_init)
+
+       /* Enable the the VFP */
+       mrc     p15, 0, r1, c1, c0, 2
+       orr     r1, r1, #(0x3 << 20)
+       orr     r1, r1, #(0x3 << 20)
+       mcr     p15, 0, r1, c1, c0, 2
+       isb
+       fmrx    r1, FPEXC
+       orr     r1,r1, #(1<<30)
+       fmxr    FPEXC, r1
+
+       /* Move back to caller */
+       mov     pc, lr
+
+ENDPROC(lowlevel_init)
index 934ccc31c86fd80723afa6c89be03c5651600cb9..2521589c07e9cf0c07a2f59990a521aafcfea7c8 100644 (file)
@@ -132,7 +132,7 @@ void zynq_slcr_devcfg_disable(void)
        zynq_slcr_unlock();
 
        /* Disable AXI interface by asserting FPGA resets */
-       writel(0xFFFFFFFF, &slcr_base->fpga_rst_ctrl);
+       writel(0xF, &slcr_base->fpga_rst_ctrl);
 
        /* Set Level Shifters DT618760 */
        writel(0xA, &slcr_base->lvl_shftr_en);
index 31627f970efbec334262c0dcfc54e10a9794a668..b80c35794a90797801cd0989da783d30376fcf2f 100644 (file)
@@ -20,9 +20,6 @@ void board_init_f(ulong dummy)
        /* Clear the BSS. */
        memset(__bss_start, 0, __bss_end - __bss_start);
 
-       /* Set global data pointer. */
-       gd = &gdata;
-
        preloader_console_init();
        arch_cpu_init();
        board_init_r(NULL, 0);
@@ -46,12 +43,21 @@ u32 spl_boot_device(void)
                mode = BOOT_DEVICE_SPI;
                break;
 #endif
+       case ZYNQ_BM_NAND:
+               mode = BOOT_DEVICE_NAND;
+               break;
+       case ZYNQ_BM_NOR:
+               mode = BOOT_DEVICE_NOR;
+               break;
 #ifdef CONFIG_SPL_MMC_SUPPORT
        case ZYNQ_BM_SD:
                puts("mmc boot\n");
                mode = BOOT_DEVICE_MMC1;
                break;
 #endif
+       case ZYNQ_BM_JTAG:
+               mode = BOOT_DEVICE_RAM;
+               break;
        default:
                puts("Unsupported boot mode selected\n");
                hang();
index 36a76a24d971e7d012570cc7ad7e3c16a2a1a4f5..a774246a2779435b47376b4f7e2cb093a59a991d 100644 (file)
@@ -52,7 +52,7 @@ int pmu_set_nominal(void)
                debug("%s: Cannot find DVC I2C bus\n", __func__);
                return ret;
        }
-       ret = i2c_get_chip(bus, PMI_I2C_ADDRESS, &dev);
+       ret = i2c_get_chip(bus, PMI_I2C_ADDRESS, 1, &dev);
        if (ret) {
                debug("%s: Cannot find DVC I2C chip\n", __func__);
                return ret;
index 77fad48fb4bd72614d575660af1ae81d2188f9c1..7de227cc01aaae4fde1d817b9dd2670e57fe6ba5 100644 (file)
                #address-cells = <1>;
                #size-cells = <0>;
                compatible = "samsung,s3c2440-i2c";
-               interrupts = <0 0 0>;
+               reg = <0x13860000 0x100>;
+               interrupts = <0 56 0>;
        };
 
        i2c@13870000 {
                #address-cells = <1>;
                #size-cells = <0>;
                compatible = "samsung,s3c2440-i2c";
-               interrupts = <1 1 0>;
+               reg = <0x13870000 0x100>;
+               interrupts = <1 57 0>;
        };
 
        i2c@13880000 {
                #address-cells = <1>;
                #size-cells = <0>;
                compatible = "samsung,s3c2440-i2c";
-               interrupts = <2 2 0>;
+               reg = <0x13880000 0x100>;
+               interrupts = <2 58 0>;
        };
 
        i2c@13890000 {
                #address-cells = <1>;
                #size-cells = <0>;
                compatible = "samsung,s3c2440-i2c";
-               interrupts = <3 3 0>;
+               reg = <0x13890000 0x100>;
+               interrupts = <3 59 0>;
        };
 
        i2c@138a0000 {
                #address-cells = <1>;
                #size-cells = <0>;
                compatible = "samsung,s3c2440-i2c";
-               interrupts = <4 4 0>;
+               reg = <0x138a0000 0x100>;
+               interrupts = <4 60 0>;
        };
 
        i2c@138b0000 {
                #address-cells = <1>;
                #size-cells = <0>;
                compatible = "samsung,s3c2440-i2c";
-               interrupts = <5 5 0>;
+               reg = <0x138b0000 0x100>;
+               interrupts = <5 61 0>;
        };
 
        i2c@138c0000 {
                #address-cells = <1>;
                #size-cells = <0>;
                compatible = "samsung,s3c2440-i2c";
-               interrupts = <6 6 0>;
+               reg = <0x138c0000 0x100>;
+               interrupts = <6 62 0>;
        };
 
        i2c@138d0000 {
                #address-cells = <1>;
                #size-cells = <0>;
                compatible = "samsung,s3c2440-i2c";
-               interrupts = <7 7 0>;
+               reg = <0x138d0000 0x100>;
+               interrupts = <7 63 0>;
        };
 
        sdhci@12510000 {
                interrupts = <0 131 0>;
        };
 
-       gpio: gpio {
-               gpio-controller;
-               #gpio-cells = <2>;
-
-               interrupt-controller;
-               #interrupt-cells = <2>;
-       };
 };
index dd2476c1a39e35f74beb2f21d2cde8a44dcdbd04..3f877615844e107262316dead327905335f862d0 100644 (file)
@@ -36,7 +36,7 @@
        sdhci@12530000 {
                samsung,bus-width = <4>;
                samsung,timing = <1 2 3>;
-               cd-gpios = <&gpio 0xA2 0>;
+               cd-gpios = <&gpk2 2 0>;
        };
 
        sdhci@12540000 {
index 8c7a2c3a78792e777ae2b2019ddb8b1eb0e26989..36d02df3b078a4dd6da6197f779ff609b38ac881 100644 (file)
        sdhci@12510000 {
                samsung,bus-width = <8>;
                samsung,timing = <1 3 3>;
-               pwr-gpios = <&gpio 146 0>;
+               pwr-gpios = <&gpk0 2 0>;
        };
 
        sdhci@12520000 {
        sdhci@12530000 {
                samsung,bus-width = <4>;
                samsung,timing = <1 2 3>;
-               cd-gpios = <&gpio 284 0>;
+               cd-gpios = <&gpx3 4 0>;
        };
 
        sdhci@12540000 {
index 808c3f7cc3a2adc0183428fe3f0035169794aa85..16948c93422725571ab05f2f7ed6e8977cb38571 100644 (file)
@@ -24,7 +24,7 @@
        sdhci@12510000 {
                samsung,bus-width = <8>;
                samsung,timing = <1 3 3>;
-               pwr-gpios = <&gpio 146 0>;
+               pwr-gpios = <&gpk0 2 0>;
        };
 
        sdhci@12520000 {
@@ -34,7 +34,7 @@
        sdhci@12530000 {
                samsung,bus-width = <4>;
                samsung,timing = <1 2 3>;
-               cd-gpios = <&gpio 284 0>;
+               cd-gpios = <&gpx3 4 0>;
        };
 
        sdhci@12540000 {
 
        soft-spi {
                compatible = "u-boot,soft-spi";
-               cs-gpio = <&gpio 235 0>;        /* Y43 */
-               sclk-gpio = <&gpio 225 0>;      /* Y31 */
-               mosi-gpio = <&gpio 227 0>;      /* Y33 */
-               miso-gpio = <&gpio 224 0>;      /* Y30 */
+               cs-gpio = <&gpy4 3 0>;
+               sclk-gpio = <&gpy3 1 0>;
+               mosi-gpio = <&gpy3 3 0>;
+               miso-gpio = <&gpy3 0 0>;
                spi-delay-us = <1>;
                #address-cells = <1>;
                #size-cells = <0>;
index c78efec64957ea53e801df849da005f06e56d36c..00a2917596fcbb99ba932db0a36ca0676f3c4ef7 100644 (file)
 
        aliases {
                i2c0 = "/i2c@13860000";
+               i2c1 = "/i2c@13870000";
+               i2c2 = "/i2c@13880000";
+               i2c3 = "/i2c@13890000";
+               i2c4 = "/i2c@138a0000";
+               i2c5 = "/i2c@138b0000";
+               i2c6 = "/i2c@138c0000";
+               i2c7 = "/i2c@138d0000";
                serial0 = "/serial@13800000";
                console = "/serial@13810000";
                mmc2 = "sdhci@12530000";
@@ -51,7 +58,7 @@
        sdhci@12530000 {
                samsung,bus-width = <4>;
                samsung,timing = <1 2 3>;
-               cd-gpios = <&gpio 122 0>;
+               cd-gpios = <&gpk2 2 0>;
        };
 
        sdhci@12540000 {
index 60e4515a7e7a8833a2c1c62da90bf54fed404a03..dd238df13fe69dc36ba4057717be82b3009f55e1 100644 (file)
        sdhci@12510000 {
                samsung,bus-width = <8>;
                samsung,timing = <1 3 3>;
-               pwr-gpios = <&gpio 0x6a 0>;
+               pwr-gpios = <&gpk0 4 0>;
                status = "disabled";
        };
 
        sdhci@12530000 {
                samsung,bus-width = <4>;
                samsung,timing = <1 2 3>;
-               cd-gpios = <&gpio 0x7a 0>;
+               cd-gpios = <&gpk2 2 0>;
        };
 
        sdhci@12540000 {
        dwmmc@12550000 {
                samsung,bus-width = <8>;
                samsung,timing = <2 1 0>;
-               pwr-gpios = <&gpio 0x6a 0>;
+               pwr-gpios = <&gpk0 4 0>;
                fifoth_val = <0x203f0040>;
                bus_hz = <400000000>;
                div = <0x3>;
index e53906892c82de8b0ba922927fff25c64c859045..238acb80a2393a2b6eb204582ec1c4d75be9518f 100644 (file)
@@ -6,6 +6,7 @@
  */
 
 #include "skeleton.dtsi"
+#include <dt-bindings/gpio/gpio.h>
 
 / {
        compatible = "samsung,exynos5";
                u-boot,dm-pre-reloc;
                id = <3>;
        };
-
-       gpio: gpio {
-       };
 };
index 202f2ea6ed9157767b3ef1d5e1b0f059f54a648b..21c0a214ea5207967a141170fb35f9b26e2a7e18 100644 (file)
        compatible = "samsung,arndale", "samsung,exynos5250";
 
        aliases {
+               i2c0 = "/i2c@12c60000";
+               i2c1 = "/i2c@12c70000";
+               i2c2 = "/i2c@12c80000";
+               i2c3 = "/i2c@12c90000";
+               i2c4 = "/i2c@12ca0000";
+               i2c5 = "/i2c@12cb0000";
+               i2c6 = "/i2c@12cc0000";
+               i2c7 = "/i2c@12cd0000";
                serial0 = "/serial@12C20000";
                console = "/serial@12C20000";
        };
index 885040920c077cad8aa26f8360daed79bc4d0d81..9273562bc54cf6bb73840c28a0c2853bcbe4ac59 100644 (file)
        };
 
        ehci@12110000 {
-               samsung,vbus-gpio = <&gpio 0x316 0>; /* X26 */
+               samsung,vbus-gpio = <&gpx2 6 GPIO_ACTIVE_HIGH>;
        };
 };
index bac501516fd257861f69c2b645553d0f2f920a33..7d8be69d73b7d14c522451bcf9ad552e4a74a97e 100644 (file)
@@ -44,7 +44,8 @@
                        reg = <0x1e>;
                        compatible = "google,cros-ec";
                        i2c-max-frequency = <100000>;
-                       ec-interrupt = <&gpio 182 1>;
+                       u-boot,i2c-offset-len = <0>;
+                       ec-interrupt = <&gpx1 6 GPIO_ACTIVE_LOW>;
                };
 
                power-regulator@48 {
@@ -68,7 +69,7 @@
                        reg = <0>;
                        compatible = "google,cros-ec";
                        spi-max-frequency = <5000000>;
-                       ec-interrupt = <&gpio 182 1>;
+                       ec-interrupt = <&gpx1 6 GPIO_ACTIVE_LOW>;
                        optimise-flash-write;
                        status = "disabled";
                };
@@ -76,7 +77,7 @@
 
        sound@3830000 {
                samsung,codec-type = "max98095";
-               codec-enable-gpio = <&gpio 0xb7 0>;
+               codec-enable-gpio = <&gpx1 7 GPIO_ACTIVE_HIGH>;
        };
 
        sound@12d60000 {
        };
 
        ehci@12110000 {
-               samsung,vbus-gpio = <&gpio 0xb1 0>; /* X11 */
+               samsung,vbus-gpio = <&gpx1 1 GPIO_ACTIVE_HIGH>;
        };
 
        xhci@12000000 {
-               samsung,vbus-gpio = <&gpio 0xbf 0>; /* X27 */
+               samsung,vbus-gpio = <&gpx2 7 GPIO_ACTIVE_HIGH>;
        };
 
        tmu@10060000 {
index d1d87350be306fb48b88e32d6e9ded69b3adef32..b801de9787531b3f6b29f4326375afd31ca5977d 100644 (file)
@@ -17,7 +17,7 @@
                "google,peach", "samsung,exynos5420", "samsung,exynos5";
 
        config {
-               google,bad-wake-gpios = <&gpio 0x56 0>; /* gpx0-6 */
+               google,bad-wake-gpios = <&gpx0 6 GPIO_ACTIVE_HIGH>;
                hwid = "PIT TEST A-A 7848";
                lazy-init = <1>;
        };
                        spi-half-duplex;
                        spi-max-timeout-ms = <1100>;
                        spi-frame-header = <0xec>;
-                       ec-interrupt = <&gpio 93 1>; /* GPX1_5 */
+                       ec-interrupt = <&gpx1 5 GPIO_ACTIVE_LOW>;
 
                        /*
                         * This describes the flash memory within the EC. Note
        };
 
        xhci@12000000 {
-               samsung,vbus-gpio = <&gpio 0x40 0>; /* H00 */
+               samsung,vbus-gpio = <&gph0 0 GPIO_ACTIVE_HIGH>;
        };
 
        xhci@12400000 {
-               samsung,vbus-gpio = <&gpio 0x41 0>; /* H01 */
+               samsung,vbus-gpio = <&gph0 1 GPIO_ACTIVE_HIGH>;
        };
 
        fimd@14400000 {
index 79a7acd7df77d67e36c2e2e3dc88871342b74522..8f4663733cc712b6621709de75c8cb77c4110021 100644 (file)
@@ -32,7 +32,7 @@
        };
 
        ehci@12110000 {
-               samsung,vbus-gpio = <&gpio 0x66 0>; /* X26 */
+               samsung,vbus-gpio = <&gpx2 6 GPIO_ACTIVE_HIGH>;
        };
 
        serial@12C20000 {
index e7c380f83beba0381b6d36ab09111056ab7492d6..e4bc100995c3112b2749f5bf96d4a449debbeaf5 100644 (file)
@@ -17,7 +17,7 @@
                "google,peach", "samsung,exynos5800", "samsung,exynos5";
 
        config {
-               google,bad-wake-gpios = <&gpio 0x56 0>; /* gpx0-6 */
+               google,bad-wake-gpios = <&gpx0 6 GPIO_ACTIVE_HIGH>;
                hwid = "PIT TEST A-A 7848";
                lazy-init = <1>;
        };
@@ -32,7 +32,7 @@
                mem-manuf = "samsung";
                mem-type = "ddr3";
                clock-frequency = <800000000>;
-               arm-frequency = <1700000000>;
+               arm-frequency = <900000000>;
        };
 
        tmu@10060000 {
                        spi-half-duplex;
                        spi-max-timeout-ms = <1100>;
                        spi-frame-header = <0xec>;
-                       ec-interrupt = <&gpio 93 1>; /* GPX1_5 */
+                       ec-interrupt = <&gpx1 5 GPIO_ACTIVE_LOW>;
 
                        /*
                         * This describes the flash memory within the EC. Note
        };
 
        xhci@12000000 {
-               samsung,vbus-gpio = <&gpio 0x40 0>; /* H00 */
+               samsung,vbus-gpio = <&gph0 0 GPIO_ACTIVE_HIGH>;
        };
 
        xhci@12400000 {
-               samsung,vbus-gpio = <&gpio 0x41 0>; /* H01 */
+               samsung,vbus-gpio = <&gph0 1 GPIO_ACTIVE_HIGH>;
        };
 
        fimd@14400000 {
index 81ad212e71291906f6d3b16ea020cc41e68ee727..51ff266d760a69c56d12bd69b021b3c7ed5de8c0 100644 (file)
@@ -57,7 +57,7 @@
        };
 
        sdhci@78000400 {
-               cd-gpios = <&gpio 170 1>; /* gpio PV2 */
+               cd-gpios = <&gpio TEGRA_GPIO(V, 2) GPIO_ACTIVE_LOW>;
                bus-width = <4>;
                status = "okay";
        };
@@ -68,8 +68,7 @@
        };
 
        usb@7d008000 {
-               /* SPDIF_IN: USB_VBUS_EN1 */
-               nvidia,vbus-gpio = <&gpio 86 0>;
+               nvidia,vbus-gpio = <&gpio TEGRA_GPIO(K, 6) GPIO_ACTIVE_HIGH>;
                status = "okay";
        };
 };
index 51fef54d570e2ebc6fc510cbf86fdab7ed04c3fa..e7b66d81a499e683bba22b21110798f75dcb9918 100644 (file)
 
        sdhci@700b0400 {
                status = "okay";
-               cd-gpios = <&gpio 170 1>; /* gpio PV2 */
-               power-gpios = <&gpio 136 0>; /* gpio PR0 */
+               cd-gpios = <&gpio TEGRA_GPIO(V, 2) GPIO_ACTIVE_LOW>;
+               power-gpios = <&gpio TEGRA_GPIO(R, 0) GPIO_ACTIVE_HIGH>;
+               wp-gpios = <&gpio TEGRA_GPIO(Q, 4) GPIO_ACTIVE_HIGH>;
                bus-width = <4>;
        };
 
        usb@7d000000 {
                status = "okay";
                dr_mode = "otg";
-               nvidia,vbus-gpio = <&gpio 108 0>; /* gpio PN4, USB_VBUS_EN0 */
+               nvidia,vbus-gpio = <&gpio TEGRA_GPIO(N, 4) GPIO_ACTIVE_HIGH>;
        };
 
        usb@7d008000 {
                status = "okay";
-               nvidia,vbus-gpio = <&gpio 109 0>; /* gpio PN5, USB_VBUS_EN1 */
+               nvidia,vbus-gpio = <&gpio TEGRA_GPIO(N, 5) GPIO_ACTIVE_HIGH>;
        };
 
        regulators {
index f7ccfc5ddd4bf29a6b6f1c86354b55c67513721e..9e93cf90c76e68c8780a1014e4af7439f5b12cf6 100644 (file)
@@ -72,8 +72,9 @@
 
        sdhci@700b0400 {
                status = "okay";
-               cd-gpios = <&gpio 170 0>; /* gpio PV2 */
-               power-gpios = <&gpio 136 0>; /* gpio PR0 */
+               cd-gpios = <&gpio TEGRA_GPIO(V, 2) GPIO_ACTIVE_HIGH>;
+               power-gpios = <&gpio TEGRA_GPIO(R, 0) GPIO_ACTIVE_HIGH>;
+               wp-gpios = <&gpio TEGRA_GPIO(Q, 4) GPIO_ACTIVE_LOW>;
                bus-width = <4>;
        };
 
        usb@7d000000 {
                status = "okay";
                dr_mode = "otg";
-               nvidia,vbus-gpio = <&gpio 108 0>; /* gpio PN4, USB_VBUS_EN0 */
+               nvidia,vbus-gpio = <&gpio TEGRA_GPIO(N, 4) GPIO_ACTIVE_HIGH>;
        };
 
        usb@7d008000 {
                status = "okay";
-               nvidia,vbus-gpio = <&gpio 109 0>; /* gpio PN5, USB_VBUS_EN1 */
+               nvidia,vbus-gpio = <&gpio TEGRA_GPIO(N, 5) GPIO_ACTIVE_HIGH>;
        };
 };
index 7cf08f4101f3ae072cda3abc37e55e44a500e101..3131b9201b7029f012c3e4f80df83663c4697d94 100644 (file)
        };
 
        usb@c5004000 {
-               nvidia,phy-reset-gpio = <&gpio 169 0>; /* PV1 */
-               nvidia,vbus-gpio = <&gpio 217 0>; /* PBB1 */
+               nvidia,phy-reset-gpio = <&gpio TEGRA_GPIO(V, 1) GPIO_ACTIVE_HIGH>;
+               nvidia,vbus-gpio = <&gpio TEGRA_GPIO(BB, 1) GPIO_ACTIVE_HIGH>;
        };
 
        usb@c5008000 {
-               nvidia,vbus-gpio = <&gpio 178 1>; /* PW2 low-active */
+               nvidia,vbus-gpio = <&gpio TEGRA_GPIO(W, 2) GPIO_ACTIVE_LOW>;
        };
 
        nand-controller@70008000 {
-               nvidia,wp-gpios = <&gpio 144 0>; /* PS0 */
+               nvidia,wp-gpios = <&gpio TEGRA_GPIO(S, 0) GPIO_ACTIVE_HIGH>;
                nvidia,width = <8>;
                nvidia,timing = <15 100 25 80 25 10 15 10 100>;
 
@@ -43,7 +43,7 @@
 
        sdhci@c8000600 {
                status = "okay";
-               cd-gpios = <&gpio 23 1>; /* gpio PC7 */
+               cd-gpios = <&gpio TEGRA_GPIO(C, 7) GPIO_ACTIVE_LOW>;
                bus-width = <4>;
        };
 };
index 982a14c61c498ff26409b99abb9a61c07586d332..e6e42295e216620e7ad28dbd3ad0245410de30b4 100644 (file)
@@ -37,7 +37,7 @@
        };
 
        nand-controller@70008000 {
-               nvidia,wp-gpios = <&gpio 23 0>;         /* PC7 */
+               nvidia,wp-gpios = <&gpio TEGRA_GPIO(C, 7) GPIO_ACTIVE_HIGH>;
                nvidia,width = <8>;
                nvidia,timing = <26 100 20 80 20 10 12 10 70>;
                nand@0 {
        };
 
        usb@c5004000 {
-               nvidia,phy-reset-gpio = <&gpio 169 0>; /* gpio PV1 */
+               nvidia,phy-reset-gpio = <&gpio TEGRA_GPIO(V, 1) 0>;
        };
 
        sdhci@c8000200 {
                status = "okay";
-               cd-gpios = <&gpio 69 1>; /* gpio PI5 */
-               wp-gpios = <&gpio 57 0>; /* gpio PH1 */
-               power-gpios = <&gpio 155 0>; /* gpio PT3 */
+               cd-gpios = <&gpio TEGRA_GPIO(I, 5) GPIO_ACTIVE_LOW>;
+               wp-gpios = <&gpio TEGRA_GPIO(H, 1) GPIO_ACTIVE_HIGH>;
+               power-gpios = <&gpio TEGRA_GPIO(T, 3) GPIO_ACTIVE_HIGH>;
                bus-width = <4>;
        };
 
        sdhci@c8000600 {
                status = "okay";
-               cd-gpios = <&gpio 58 1>; /* gpio PH2 */
-               wp-gpios = <&gpio 59 0>; /* gpio PH3 */
-               power-gpios = <&gpio 70 0>; /* gpio PI6 */
+               cd-gpios = <&gpio TEGRA_GPIO(H, 2) GPIO_ACTIVE_LOW>;
+               wp-gpios = <&gpio TEGRA_GPIO(H, 3) GPIO_ACTIVE_HIGH>;
+               power-gpios = <&gpio TEGRA_GPIO(I, 6) GPIO_ACTIVE_HIGH>;
                bus-width = <8>;
        };
 
                vsyncx-active-high;
                nvidia,bits-per-pixel = <16>;
                nvidia,pwm = <&pwm 0 0>;
-               nvidia,backlight-enable-gpios = <&gpio 13 0>;   /* PB5 */
-               nvidia,lvds-shutdown-gpios = <&gpio 10 0>;      /* PB2 */
-               nvidia,backlight-vdd-gpios = <&gpio 176 0>;     /* PW0 */
-               nvidia,panel-vdd-gpios = <&gpio 22 0>;          /* PC6 */
+               nvidia,backlight-enable-gpios = <&gpio TEGRA_GPIO(B, 5)
+                                                       GPIO_ACTIVE_HIGH>;
+               nvidia,lvds-shutdown-gpios = <&gpio TEGRA_GPIO(B, 2)
+                                                       GPIO_ACTIVE_HIGH>;
+               nvidia,backlight-vdd-gpios = <&gpio TEGRA_GPIO(W, 0)
+                                                       GPIO_ACTIVE_HIGH>;
+               nvidia,panel-vdd-gpios = <&gpio TEGRA_GPIO(C, 6)
+                                                       GPIO_ACTIVE_HIGH>;
                nvidia,panel-timings = <0 0 200 0 0>;
        };
 };
index be2ed42dbd74e67233f145a48f483977a36b7e92..b6b57abdef94f9b2f79a7a44c860bab3919c8e3e 100644 (file)
 
                nvidia,bits-per-pixel = <16>;
                nvidia,pwm = <&pwm 0 500000>;
-               nvidia,backlight-enable-gpios = <&gpio 13 0>; /* PB5 */
-               nvidia,backlight-vdd-gpios = <&gpio 176 0>; /* PW0 */
-               nvidia,lvds-shutdown-gpios = <&gpio 10 0>; /* PB2 */
+               nvidia,backlight-enable-gpios = <&gpio TEGRA_GPIO(B, 5)
+                                                       GPIO_ACTIVE_HIGH>;
+               nvidia,lvds-shutdown-gpios = <&gpio TEGRA_GPIO(B, 2)
+                                                       GPIO_ACTIVE_HIGH>;
+               nvidia,backlight-vdd-gpios = <&gpio TEGRA_GPIO(W, 0)
+                                                       GPIO_ACTIVE_HIGH>;
                nvidia,panel-timings = <0 0 0 0>;
        };
 };
index 9d735b5e6bf6541b3dbfb0974cc3ee668d129d02..16381c3a4c78777e39812e205361797aee3d984b 100644 (file)
@@ -61,9 +61,9 @@
 
        sdhci@c8000000 {
                status = "okay";
-               cd-gpios = <&gpio 173 1>; /* gpio PV5 */
-               wp-gpios = <&gpio 57 0>; /* gpio PH1 */
-               power-gpios = <&gpio 169 0>; /* gpio PV1 */
+               cd-gpios = <&gpio TEGRA_GPIO(V, 5) GPIO_ACTIVE_LOW>;
+               wp-gpios = <&gpio TEGRA_GPIO(H, 1) GPIO_ACTIVE_HIGH>;
+               power-gpios = <&gpio TEGRA_GPIO(V, 1) GPIO_ACTIVE_HIGH>;
                bus-width = <4>;
        };
 
                hsync-active-high;
                nvidia,bits-per-pixel = <16>;
                nvidia,pwm = <&pwm 0 0>;
-               nvidia,backlight-enable-gpios = <&gpio 164 0>;  /* PU4 */
-               nvidia,lvds-shutdown-gpios = <&gpio 102 0>;     /* PM6 */
-               nvidia,backlight-vdd-gpios = <&gpio 176 0>;     /* PW0 */
-               nvidia,panel-vdd-gpios = <&gpio 4 0>;           /* PA4 */
+               nvidia,backlight-enable-gpios = <&gpio TEGRA_GPIO(U, 4)
+                                                       GPIO_ACTIVE_HIGH>;
+               nvidia,lvds-shutdown-gpios = <&gpio TEGRA_GPIO(M, 6)
+                                                       GPIO_ACTIVE_HIGH>;
+               nvidia,backlight-vdd-gpios = <&gpio TEGRA_GPIO(W, 0)
+                                                       GPIO_ACTIVE_HIGH>;
+               nvidia,panel-vdd-gpios = <&gpio TEGRA_GPIO(A, 4)
+                                                       GPIO_ACTIVE_HIGH>;
                nvidia,panel-timings = <400 4 203 17 15>;
        };
 };
index 43b9911c896a0aed9dbc6bca8f0e3532b8093cf5..10f399284ae189ca9bee5c5d438dba3c7085bebc 100644 (file)
@@ -65,7 +65,7 @@
        };
 
        nand-controller@70008000 {
-               nvidia,wp-gpios = <&gpio 59 0>;         /* PH3 */
+               nvidia,wp-gpios = <&gpio TEGRA_GPIO(H, 3) GPIO_ACTIVE_HIGH>;
                nvidia,width = <8>;
                nvidia,timing = <26 100 20 80 20 10 12 10 70>;
                nand@0 {
        };
 
        usb@c5000000 {
-               nvidia,vbus-gpio = <&gpio 24 0>; /* PD0 */
+               nvidia,vbus-gpio = <&gpio TEGRA_GPIO(D, 0) GPIO_ACTIVE_HIGH>;
                dr_mode = "otg";
        };
 
 
        sdhci@c8000400 {
                status = "okay";
-               cd-gpios = <&gpio 69 1>; /* gpio PI5 */
-               wp-gpios = <&gpio 57 0>; /* gpio PH1 */
-               power-gpios = <&gpio 70 0>; /* gpio PI6 */
+               cd-gpios = <&gpio TEGRA_GPIO(I, 5) GPIO_ACTIVE_LOW>;
+               wp-gpios = <&gpio TEGRA_GPIO(H, 1) GPIO_ACTIVE_HIGH>;
+               power-gpios = <&gpio TEGRA_GPIO(I, 6) GPIO_ACTIVE_HIGH>;
                bus-width = <4>;
        };
 
                hsync-active-high;
                nvidia,bits-per-pixel = <16>;
                nvidia,pwm = <&pwm 2 0>;
-               nvidia,backlight-enable-gpios = <&gpio 28 0>;   /* PD4 */
-               nvidia,lvds-shutdown-gpios = <&gpio 10 0>;      /* PB2 */
-               nvidia,backlight-vdd-gpios = <&gpio 176 0>;     /* PW0 */
-               nvidia,panel-vdd-gpios = <&gpio 22 0>;          /* PC6 */
+               nvidia,backlight-enable-gpios = <&gpio TEGRA_GPIO(D, 4)
+                                                       GPIO_ACTIVE_HIGH>;
+               nvidia,lvds-shutdown-gpios = <&gpio TEGRA_GPIO(B, 2)
+                                                       GPIO_ACTIVE_HIGH>;
+               nvidia,backlight-vdd-gpios = <&gpio TEGRA_GPIO(W, 0)
+                                                       GPIO_ACTIVE_HIGH>;
+               nvidia,panel-vdd-gpios = <&gpio TEGRA_GPIO(C, 6)
+                                                       GPIO_ACTIVE_HIGH>;
                nvidia,panel-timings = <400 4 203 17 15>;
        };
 };
index f379622c944963cba0a0c568cac440bc1dc35eb3..78449e613379dc12ebc8914fdd5f8957c8150ac0 100644 (file)
@@ -14,7 +14,8 @@
                        pll-supply = <&hdmi_pll_reg>;
 
                        nvidia,ddc-i2c-bus = <&hdmi_ddc>;
-                       nvidia,hpd-gpio = <&gpio 111 0>; /* PN7 */
+                       nvidia,hpd-gpio = <&gpio TEGRA_GPIO(N, 7)
+                               GPIO_ACTIVE_HIGH>;
                };
        };
 
        };
 
        nand-controller@70008000 {
-               nvidia,wp-gpios = <&gpio 23 0>; /* PC7 */
+               nvidia,wp-gpios = <&gpio TEGRA_GPIO(C, 7) GPIO_ACTIVE_HIGH>;
                nvidia,width = <8>;
                nvidia,timing = <26 100 20 80 20 10 12 10 70>;
 
        };
 
        sdhci@c8000600 {
-               cd-gpios = <&gpio 58 1>; /* gpio PH2 */
-               wp-gpios = <&gpio 59 0>; /* gpio PH3 */
+               cd-gpios = <&gpio TEGRA_GPIO(H, 2) GPIO_ACTIVE_LOW>;
+               wp-gpios = <&gpio TEGRA_GPIO(H, 3) GPIO_ACTIVE_HIGH>;
                bus-width = <4>;
                status = "okay";
        };
index e99bd447c1b72bc71bb36a1bc06abec3a0ff93eb..94ba6dc2d41d65e6e9c85873594ccefea979f54d 100644 (file)
 
                nvidia,bits-per-pixel = <16>;
                nvidia,pwm = <&pwm 0 500000>;
-               nvidia,backlight-enable-gpios = <&gpio 13 0>; /* PB5 */
-               nvidia,backlight-vdd-gpios = <&gpio 176 0>; /* PW0 */
-               nvidia,lvds-shutdown-gpios = <&gpio 10 0>; /* PB2 */
+               nvidia,backlight-enable-gpios = <&gpio TEGRA_GPIO(B, 5)
+                                                       GPIO_ACTIVE_HIGH>;
+               nvidia,lvds-shutdown-gpios = <&gpio TEGRA_GPIO(B, 2)
+                                                       GPIO_ACTIVE_HIGH>;
+               nvidia,backlight-vdd-gpios = <&gpio TEGRA_GPIO(W, 0)
+                                                       GPIO_ACTIVE_HIGH>;
                nvidia,panel-timings = <0 0 0 0>;
        };
 };
index 1637cbd58e32ec4e6f7a4eaf526b348d2fc64f45..27b118f212ad7bec41953dd6e2c18c8da8c431b9 100644 (file)
@@ -62,7 +62,7 @@
        };
 
        usb@c5000000 {
-               nvidia,vbus-gpio = <&gpio 170 0>; /* PV2 */
+               nvidia,vbus-gpio = <&gpio TEGRA_GPIO(V, 2) GPIO_ACTIVE_HIGH>;
        };
 
        usb@c5004000 {
@@ -76,8 +76,8 @@
 
        sdhci@c8000600 {
                status = "okay";
-               cd-gpios = <&gpio 121 1>; /* gpio PP1 */
-               wp-gpios = <&gpio 122 0>; /* gpio PP2 */
+               cd-gpios = <&gpio TEGRA_GPIO(P, 1) GPIO_ACTIVE_LOW>;
+               wp-gpios = <&gpio TEGRA_GPIO(P, 2) GPIO_ACTIVE_HIGH>;
                bus-width = <4>;
        };
 
                        regulator-min-microvolt = <5000000>;
                        regulator-max-microvolt = <5000000>;
                        enable-active-high;
-                       gpio = <&gpio TEGRA_GPIO(V, 2) 0>;
+                       gpio = <&gpio TEGRA_GPIO(V, 2) GPIO_ACTIVE_HIGH>;
                        regulator-always-on;
                        regulator-boot-on;
                };
index 68122039180a378c7b20f9f31dbe77ab37a0ed82..939e567d1334f8de272f8a35d4cec7ba142783a6 100644 (file)
@@ -61,9 +61,9 @@
 
        sdhci@c8000400 {
                status = "okay";
-               cd-gpios = <&gpio 69 1>; /* gpio PI5 */
-               wp-gpios = <&gpio 57 0>; /* gpio PH1 */
-               power-gpios = <&gpio 70 0>; /* gpio PI6 */
+               cd-gpios = <&gpio TEGRA_GPIO(I, 5) GPIO_ACTIVE_LOW>;
+               wp-gpios = <&gpio TEGRA_GPIO(H, 1) GPIO_ACTIVE_HIGH>;
+               power-gpios = <&gpio TEGRA_GPIO(I, 6) GPIO_ACTIVE_HIGH>;
                bus-width = <4>;
        };
 
                vsync-active-high;
                nvidia,bits-per-pixel = <16>;
                nvidia,pwm = <&pwm 2 0>;
-               nvidia,backlight-enable-gpios = <&gpio 28 0>;   /* PD4 */
-               nvidia,lvds-shutdown-gpios = <&gpio 10 0>;      /* PB2 */
-               nvidia,backlight-vdd-gpios = <&gpio 176 0>;     /* PW0 */
-               nvidia,panel-vdd-gpios = <&gpio 22 0>;          /* PC6 */
+               nvidia,backlight-enable-gpios = <&gpio TEGRA_GPIO(D, 4)
+                                                       GPIO_ACTIVE_HIGH>;
+               nvidia,lvds-shutdown-gpios = <&gpio TEGRA_GPIO(B, 2)
+                                                       GPIO_ACTIVE_HIGH>;
+               nvidia,backlight-vdd-gpios = <&gpio TEGRA_GPIO(W, 0)
+                                                       GPIO_ACTIVE_HIGH>;
+               nvidia,panel-vdd-gpios = <&gpio TEGRA_GPIO(C, 6)
+                                                       GPIO_ACTIVE_HIGH>;
                nvidia,panel-timings = <0 0 200 0 0>;
        };
 };
index 4fd2496dbc57f07e5c42771814c0ac5df04a34aa..c4a28eb427deff1bb0c79ada0d1fa857f8acd3da 100644 (file)
@@ -66,7 +66,7 @@
 
        sdhci@c8000400 {
                status = "okay";
-               wp-gpios = <&gpio 173 0>; /* gpio PV5 */
+               wp-gpios = <&gpio TEGRA_GPIO(V, 5) GPIO_ACTIVE_HIGH>;
                bus-width = <8>;
        };
 
index 5bad3e77698ce81f9ad3f2aef9e6a5052e5b5bf4..15db0f275b6d3740caa1756e9394de6c93764674 100644 (file)
        sdhci@78000000 {
                status = "okay";
                bus-width = <4>;
-               cd-gpios = <&gpio 229 1>; /* PCC5, SD1_CD# */
+               cd-gpios = <&gpio TEGRA_GPIO(CC, 5) GPIO_ACTIVE_HIGH>;
        };
 
        sdhci@78000400 {
                status = "okay";
                bus-width = <8>;
-               cd-gpios = <&gpio 171 1>; /* PV3, MMC1_CD# */
+               cd-gpios = <&gpio TEGRA_GPIO(V, 3) GPIO_ACTIVE_HIGH>;
        };
 
        sdhci@78000600 {
        usb@7d000000 {
                status = "okay";
                dr_mode = "peripheral";
-               nvidia,vbus-gpio = <&gpio 157 0>;       /* PT5, USBO1_EN */
+               nvidia,vbus-gpio = <&gpio TEGRA_GPIO(T, 5) GPIO_ACTIVE_HIGH>;
        };
 
        /* EHCI instance 1: USB2_DP/N -> USBH2_DP/N */
        usb@7d004000 {
                status = "okay";
-               nvidia,vbus-gpio = <&gpio 233 0>;       /* PDD1, USBH_EN */
+               nvidia,vbus-gpio = <&gpio TEGRA_GPIO(DD, 1) GPIO_ACTIVE_HIGH>;
                phy_type = "utmi";
        };
 
        /* EHCI instance 2: USB3_DP/N -> USBH3_DP/N */
        usb@7d008000 {
                status = "okay";
-               nvidia,vbus-gpio = <&gpio 233 0>;       /* PDD1, USBH_EN */
+               nvidia,vbus-gpio = <&gpio TEGRA_GPIO(DD, 1) GPIO_ACTIVE_HIGH>;
        };
 
        regulators {
index 5903af68384b80f6c0f8373a6e3a1b8b420e69fa..ae836363ab5242550886196ea1d7a884218a83e6 100644 (file)
 
        sdhci@78000000 {
                status = "okay";
-               cd-gpios = <&gpio 69 1>; /* gpio PI5 */
-               wp-gpios = <&gpio 155 0>; /* gpio PT3 */
-               power-gpios = <&gpio 31 0>; /* gpio PD7 */
+               cd-gpios = <&gpio TEGRA_GPIO(I, 5) GPIO_ACTIVE_LOW>;
+               wp-gpios = <&gpio TEGRA_GPIO(T, 3) GPIO_ACTIVE_HIGH>;
+               power-gpios = <&gpio TEGRA_GPIO(D, 7) GPIO_ACTIVE_HIGH>;
                bus-width = <4>;
        };
 
        usb@7d000000 {
                status = "okay";
                dr_mode = "otg";
-               nvidia,vbus-gpio = <&gpio 238 0>; /* gpio DD6, PEX_L1_CLKREQ */
+               nvidia,vbus-gpio = <&gpio TEGRA_GPIO(DD, 6) GPIO_ACTIVE_HIGH>;
        };
 
        usb@7d008000 {
-               nvidia,vbus-gpio = <&gpio 236 0>; /* PDD4 */
+               nvidia,vbus-gpio = <&gpio TEGRA_GPIO(DD, 4) GPIO_ACTIVE_HIGH>;
                status = "okay";
        };
 
index e13d0fb467137766fcfe5677ca1cf64d889a82de..23ca141df2a55b9634a5e034a3a5c7dfddde79a4 100644 (file)
 
        sdhci@78000000 {
                status = "okay";
-               cd-gpios = <&gpio 69 1>; /* gpio PI5 */
-               wp-gpios = <&gpio 155 0>; /* gpio PT3 */
-               power-gpios = <&gpio 31 0>; /* gpio PD7 */
+               cd-gpios = <&gpio TEGRA_GPIO(I, 5) GPIO_ACTIVE_LOW>;
+               wp-gpios = <&gpio TEGRA_GPIO(T, 3) GPIO_ACTIVE_HIGH>;
+               power-gpios = <&gpio TEGRA_GPIO(D, 7) GPIO_ACTIVE_HIGH>;
                bus-width = <4>;
        };
 
        };
 
        usb@7d008000 {
-               nvidia,vbus-gpio = <&gpio 236 0>;       /* PDD4 */
+               nvidia,vbus-gpio = <&gpio TEGRA_GPIO(DD, 4) GPIO_ACTIVE_HIGH>;
                status = "okay";
        };
 
index 37b6abd52f05480018af45c46458b56aa4fd664f..6cd1902f11bcb563b8daab2ee7792325f9913628 100644 (file)
@@ -64,7 +64,7 @@
        sdhci@78000200 {
                status = "okay";
                bus-width = <4>;
-               cd-gpios = <&gpio 23 1>; /* PC7, MMCD */
+               cd-gpios = <&gpio TEGRA_GPIO(C, 7) GPIO_ACTIVE_LOW>;
        };
 
        sdhci@78000600 {
        usb@7d004000 {
                status = "okay";
                phy_type = "utmi";
-               nvidia,vbus-gpio = <&gpio 234 0>;       /* PDD2, VBUS_LAN */
+               nvidia,vbus-gpio = <&gpio TEGRA_GPIO(DD, 2) GPIO_ACTIVE_HIGH>;
        };
 
        /* EHCI instance 2: USB3_DP/N -> USBH_P/N */
        usb@7d008000 {
                status = "okay";
-               nvidia,vbus-gpio = <&gpio 178 1>;       /* PW2, USBH_PEN */
+               nvidia,vbus-gpio = <&gpio TEGRA_GPIO(W, 2) GPIO_ACTIVE_LOW>;
        };
 };
index c73afef34ada174178a4aeaeb19b40ef11544842..8eff627f3d0ba546309d2127323aa2bbbe5aca99 100644 (file)
@@ -55,8 +55,8 @@
 
        /* SD slot on the base board */
        sdhci@78000400 {
-               cd-gpios = <&gpio 69 1>; /* gpio PI5 */
-               wp-gpios = <&gpio 67 0>; /* gpio PI3 */
+               cd-gpios = <&gpio TEGRA_GPIO(I, 5) GPIO_ACTIVE_LOW>;
+               wp-gpios = <&gpio TEGRA_GPIO(I, 3) GPIO_ACTIVE_HIGH>;
                bus-width = <4>;
        };
 
index 6855878c29110d3e5092c79bba9eada22b3296a8..d479be1d4d6ebdf155915be5ad8d125bf0e419bb 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Device Tree Source for UniPhier PH1-LD4 Reference Board
  *
- * Copyright (C) 2014 Panasonic Corporation
+ * Copyright (C) 2014-2015 Panasonic Corporation
  *   Author: Masahiro Yamada <yamada.m@jp.panasonic.com>
  *
  * SPDX-License-Identifier:    GPL-2.0+
@@ -9,6 +9,7 @@
 
 /dts-v1/;
 /include/ "uniphier-ph1-ld4.dtsi"
+/include/ "uniphier-ref-daughter.dtsi"
 
 / {
        model = "Panasonic UniPhier PH1-LD4 Reference Board";
 
 &i2c0 {
        status = "okay";
-       eeprom {
-               compatible = "i2c-eeprom";
-               reg = <0x50>;
-       };
 };
 
 &usb0 {
index 1227b628d19fcbeb24047a869c25b0e5930ca47f..d9e7a8c52b8c7445e52e3f6c112b099bb2b0ed79 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Device Tree Source for UniPhier PH1-Pro4 Reference Board
  *
- * Copyright (C) 2014 Panasonic Corporation
+ * Copyright (C) 2014-2015 Panasonic Corporation
  *   Author: Masahiro Yamada <yamada.m@jp.panasonic.com>
  *
  * SPDX-License-Identifier:    GPL-2.0+
@@ -9,6 +9,7 @@
 
 /dts-v1/;
 /include/ "uniphier-ph1-pro4.dtsi"
+/include/ "uniphier-ref-daughter.dtsi"
 
 / {
        model = "Panasonic UniPhier PH1-Pro4 Reference Board";
 
 &i2c0 {
        status = "okay";
-       eeprom {
-               compatible = "i2c-eeprom";
-               reg = <0x50>;
-       };
 };
 
 &usb0 {
index fefc592589e80735dde855a4aab238ff388bdd41..8a7f90ac78dc76b6946a9136e46b1e0222ce69a0 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Device Tree Source for UniPhier PH1-sLD3 Reference Board
  *
- * Copyright (C) 2014 Panasonic Corporation
+ * Copyright (C) 2014-2015 Panasonic Corporation
  *   Author: Masahiro Yamada <yamada.m@jp.panasonic.com>
  *
  * SPDX-License-Identifier:    GPL-2.0+
@@ -9,6 +9,7 @@
 
 /dts-v1/;
 /include/ "uniphier-ph1-sld3.dtsi"
+/include/ "uniphier-ref-daughter.dtsi"
 
 / {
        model = "Panasonic UniPhier PH1-sLD3 Reference Board";
 
 &i2c0 {
        status = "okay";
-       eeprom {
-               compatible = "i2c-eeprom";
-               reg = <0x50>;
-       };
 };
 
 &usb0 {
index 9b6d95c4808437e6fc1d1ca5d208a0ea067ac330..0cb9c47b6570b71e8ee96c69aa7f9b1cd9c973a3 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Device Tree Source for UniPhier PH1-sLD8 Reference Board
  *
- * Copyright (C) 2014 Panasonic Corporation
+ * Copyright (C) 2014-2015 Panasonic Corporation
  *   Author: Masahiro Yamada <yamada.m@jp.panasonic.com>
  *
  * SPDX-License-Identifier:    GPL-2.0+
@@ -9,6 +9,7 @@
 
 /dts-v1/;
 /include/ "uniphier-ph1-sld8.dtsi"
+/include/ "uniphier-ref-daughter.dtsi"
 
 / {
        model = "Panasonic UniPhier PH1-sLD8 Reference Board";
 
 &i2c0 {
        status = "okay";
-       eeprom {
-               compatible = "i2c-eeprom";
-               reg = <0x50>;
-       };
 };
 
 &usb0 {
diff --git a/arch/arm/dts/uniphier-ref-daughter.dtsi b/arch/arm/dts/uniphier-ref-daughter.dtsi
new file mode 100644 (file)
index 0000000..0145b51
--- /dev/null
@@ -0,0 +1,16 @@
+/*
+ * Device Tree Source for UniPhier Reference Daughter Board
+ *
+ * Copyright (C) 2014-2015 Panasonic Corporation
+ *   Author: Masahiro Yamada <yamada.m@jp.panasonic.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+&i2c0 {
+       eeprom {
+               compatible = "i2c-eeprom";
+               reg = <0x50>;
+               u-boot,i2c-offset-len = <2>;
+       };
+};
index 00ee775a45150655840a137e7ec8ce5a4a7b6ed7..f9fd4246099a6d28d8dff9759e0424eb3e7a1db3 100644 (file)
 #endif /* CONFIG_SYS_KWD_CONFIG */
 
 /* Add target to build it automatically upon "make" */
+#ifdef CONFIG_SPL
+#define CONFIG_BUILD_TARGET    "u-boot-spl.kwb"
+#else
 #define CONFIG_BUILD_TARGET    "u-boot.kwb"
+#endif
 
 /* end of 16M scrubbed by training in bootrom */
 #define CONFIG_SYS_INIT_SP_ADDR                0x00FF0000
index 6b60c21ceb8e7391d98fca49f2a883535258c0ac..4f5ff96d844990b2ee04cd8e938d9ee2bb5e010b 100644 (file)
@@ -96,6 +96,9 @@ struct kwgpio_registers {
        u32 irq_level;
 };
 
+/* Needed for dynamic (board-specific) mbus configuration */
+extern struct mvebu_mbus_state mbus_state;
+
 /*
  * functions
  */
@@ -103,5 +106,18 @@ unsigned int mvebu_sdram_bar(enum memory_bank bank);
 unsigned int mvebu_sdram_bs(enum memory_bank bank);
 void mvebu_sdram_size_adjust(enum memory_bank bank);
 int mvebu_mbus_probe(struct mbus_win windows[], int count);
+
+/*
+ * Highspeed SERDES PHY config init, ported from bin_hdr
+ * to mainline U-Boot
+ */
+int serdes_phy_config(void);
+
+/*
+ * DDR3 init / training code ported from Marvell bin_hdr. Now
+ * available in mainline U-Boot in:
+ * drivers/ddr/mvebu/
+ */
+int ddr3_init(void);
 #endif /* __ASSEMBLY__ */
 #endif /* _ARMADA_XP_CPU_H */
index 6f540d23af6330337cf6235d07dd4cb300072e06..38b5012fce5cc17b828310b9c352677ab5bba060 100644 (file)
@@ -31,7 +31,7 @@ static struct usba_ep_data usba_udc_ep[] = {
        EP("ep5", 5, 1024, 3, 1, 1),
        EP("ep6", 6, 1024, 3, 1, 1),
 };
-#elif defined(CONFIG_SAMA5D3)
+#elif defined(CONFIG_SAMA5D3) || defined(CONFIG_SAMA5D4)
 static struct usba_ep_data usba_udc_ep[] = {
        EP("ep0", 0, 64, 1, 0, 0),
        EP("ep1", 1, 1024, 3, 1, 0),
index 0b91ef658ca96a0b259f661c7f3cd10bd5520eb5..d0ae7575dae098bd01cb45ed92eee978d6b4768b 100644 (file)
@@ -23,6 +23,9 @@ enum {
        /* Flags for SROM controller */
        PINMUX_FLAG_BANK        = 3 << 0,       /* bank number (0-3) */
        PINMUX_FLAG_16BIT       = 1 << 2,       /* 16-bit width */
+
+       /* Flags for I2C */
+       PINMUX_FLAG_HS_MODE     = 1 << 1,       /* I2C High Speed Mode */
 };
 
 /**
index 5e934da79738a1b62ff289f81b662b0d9dba77b0..791551841c71ac81b7e203ce0da9af3992102a47 100644 (file)
 #define CONFIG_SYS_FSL_DDR_VER                 FSL_DDR_VER_5_0
 #define CONFIG_SYS_FSL_SEC_COMPAT              5
 #define CONFIG_USB_MAX_CONTROLLER_COUNT                1
+#define CONFIG_SYS_FSL_ERRATUM_A008378
 #else
 #error SoC not defined
 #endif
 
+#define FSL_IFC_COMPAT         "fsl,ifc"
+#define FSL_QSPI_COMPAT                "fsl,ls1-qspi"
+#define FSL_DSPI_COMPAT                "fsl,vf610-dspi"
+
 #endif /* _ASM_ARMV7_LS102XA_CONFIG_ */
diff --git a/arch/arm/include/asm/arch-ls102xa/gpio.h b/arch/arm/include/asm/arch-ls102xa/gpio.h
new file mode 100644 (file)
index 0000000..b704436
--- /dev/null
@@ -0,0 +1,15 @@
+/*
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+/*
+ * Dummy header file to enable CONFIG_OF_CONTROL.
+ * If CONFIG_OF_CONTROL is enabled, lib/fdtdec.c is compiled.
+ * It includes <asm/arch/gpio.h> via <asm/gpio.h>, so those SoCs that enable
+ * OF_CONTROL must have arch/gpio.h.
+ */
+
+#ifndef __ASM_ARCH_LS102XA_GPIO_H_
+#define __ASM_ARCH_LS102XA_GPIO_H_
+
+#endif
index 697d4ca4894b373d51bc7a44ad73b62402935519..f70d568d467841784e77f4b89e8c9fef77038c42 100644 (file)
@@ -105,6 +105,8 @@ struct ccsr_gur {
 
 #define SCFG_ETSECDMAMCR_LE_BD_FR      0xf8001a0f
 #define SCFG_ETSECCMCR_GE2_CLK125      0x04000000
+#define SCFG_ETSECCMCR_GE0_CLK125      0x00000000
+#define SCFG_ETSECCMCR_GE1_CLK125      0x08000000
 #define SCFG_PIXCLKCR_PXCKEN           0x80000000
 #define SCFG_QSPI_CLKSEL               0xc0100000
 
@@ -456,6 +458,8 @@ struct ccsr_ddr {
 #define CCI400_CTRLORD_TERM_BARRIER    0x00000008
 #define CCI400_CTRLORD_EN_BARRIER      0
 #define CCI400_SHAORD_NON_SHAREABLE    0x00000002
+#define CCI400_DVM_MESSAGE_REQ_EN      0x00000002
+#define CCI400_SNOOP_REQ_EN            0x00000001
 
 /* CCI-400 registers */
 struct ccsr_cci400 {
index 0b78c1ca60ffd7a84c25f4c7a320a990e8fd91a5..3ce270c5c97404f8505b529e1ac97dce5bc13b34 100644 (file)
@@ -249,6 +249,49 @@ enum {
 #define MICRON_RASWIDTH_200    14
 #define MICRON_V_MCFG_200(size)        MCFG((size), MICRON_RASWIDTH_200)
 
+/* Samsung K4X51163PG - FGC6 (165MHz optimized) 6.06ns - from 2010.90 src */
+#define SAMSUNG_TDAL_165       5
+#define SAMSUNG_TDPL_165       2
+#define SAMSUNG_TRRD_165       2
+#define SAMSUNG_TRCD_165       3
+#define SAMSUNG_TRP_165                3
+#define SAMSUNG_TRAS_165       7
+#define SAMSUNG_TRC_165                10
+#define SAMSUNG_TRFC_165       12
+
+#define SAMSUNG_V_ACTIMA_165   \
+               ACTIM_CTRLA(SAMSUNG_TRFC_165, SAMSUNG_TRC_165,          \
+                               SAMSUNG_TRAS_165, SAMSUNG_TRP_165,      \
+                               SAMSUNG_TRCD_165, SAMSUNG_TRRD_165,     \
+                               SAMSUNG_TDPL_165, SAMSUNG_TDAL_165)
+
+#define SAMSUNG_TWTR_165       1
+#define SAMSUNG_TCKE_165       2
+#define SAMSUNG_XSR_165                20
+#define SAMSUNG_TXP_165                5
+
+#define SAMSUNG_V_ACTIMB_165   \
+               ACTIM_CTRLB(SAMSUNG_TWTR_165, SAMSUNG_TCKE_165, \
+                               SAMSUNG_TXP_165, SAMSUNG_XSR_165)
+
+#define SAMSUNG_RASWIDTH_165   14
+#define SAMSUNG_V_MCFG_165(size) \
+       V_MCFG_RASWIDTH(SAMSUNG_RASWIDTH_165) | V_MCFG_CASWIDTH_10B | \
+       V_MCFG_ADDRMUXLEGACY_FLEX | V_MCFG_RAMSIZE(size) | \
+       V_MCFG_BANKALLOCATION_RBC | V_MCFG_RAMTYPE_DDR
+
+/* TODO: find which register these were taken from */
+
+#define SAMSUNG_BL_165                         0x2
+#define SAMSUNG_SIL_165                                0x0
+#define SAMSUNG_CASL_165                       0x3
+#define SAMSUNG_WBST_165                       0x0
+#define SAMSUNG_V_MR_165                       ((SAMSUNG_WBST_165 << 9) | \
+               (SAMSUNG_CASL_165 << 4) | (SAMSUNG_SIL_165 << 3) | \
+               (SAMSUNG_BL_165))
+
+#define SAMSUNG_SHARING 0x00003700
+
 /* NUMONYX part of IGEP v2 (165MHz optimized) 6.06ns */
 #define NUMONYX_TDAL_165       6       /* Twr/Tck + Trp/tck            */
                                        /* 15/6 + 18/6 = 5.5 -> 6       */
index 0ba621a1b8231f29a0e050b00f786ff59a826ccf..9f2896c4b91f632bad7501e1698852bcbc0afc2a 100644 (file)
@@ -51,6 +51,7 @@ typedef struct t2 {
 #define PBIASLITEPWRDNZ0               (1 << 1)
 #define PBIASSPEEDCTRL0                        (1 << 2)
 #define PBIASLITEPWRDNZ1               (1 << 9)
+#define PBIASLITEVMODE0                        (1 << 0)
 
 #define CTLPROGIO1SPEEDCTRL            (1 << 20)
 
index eba4a5c7f0cf712a2ed822f22d7467f2b2396de0..3277b407d19769eafda7b07367be58c5d1d0d464 100644 (file)
  * PTU  - Pull type Up
  * DIS  - Pull type selection is inactive
  * EN   - Pull type selection is active
+ * SB_LOW - Standby mode configuration: Output low-level
+ * SB_HI - Standby mode configuration: Output high-level
+ * SB_HIZ - Standby mode configuration: Output hi-impedence
+ * SB_PD - Standby mode pull-down enabled
+ * SB_PU - Standby mode pull-up enabled
+ * WKEN - Wakeup input enabled
  * M0   - Mode 0
  */
 
 #define EN     (1 << 3)
 #define DIS    (0 << 3)
 
+#define SB_LOW (1 << 9)
+#define SB_HI (5 << 9)
+#define SB_HIZ (2 << 9)
+#define SB_PD (1 << 12)
+#define SB_PU (3 << 12)
+#define WKEN (1 << 14)
+
 #define M0     0
 #define M1     1
 #define M2     2
@@ -36,8 +49,8 @@
 #define M7     7
 
 /*
- * To get the actual address the offset has to added
- * with OMAP34XX_CTRL_BASE to get the actual address
+ * To get the actual address the offset has to be added
+ * to OMAP34XX_CTRL_BASE
  */
 
 /*SDRC*/
 #define CONTROL_PADCONF_SDRC_DQS1      0x0074
 #define CONTROL_PADCONF_SDRC_DQS2      0x0076
 #define CONTROL_PADCONF_SDRC_DQS3      0x0078
+#define CONTROL_PADCONF_SDRC_BA0       0x05A0
+#define CONTROL_PADCONF_SDRC_BA1       0x05A2
+#define CONTROL_PADCONF_SDRC_A0                0x05A4
+#define CONTROL_PADCONF_SDRC_A1                0x05A6
+#define CONTROL_PADCONF_SDRC_A2                0x05A8
+#define CONTROL_PADCONF_SDRC_A3                0x05AA
+#define CONTROL_PADCONF_SDRC_A4                0x05AC
+#define CONTROL_PADCONF_SDRC_A5                0x05AE
+#define CONTROL_PADCONF_SDRC_A6                0x05B0
+#define CONTROL_PADCONF_SDRC_A7                0x05B2
+#define CONTROL_PADCONF_SDRC_A8                0x05B4
+#define CONTROL_PADCONF_SDRC_A9                0x05B6
+#define CONTROL_PADCONF_SDRC_A10       0x05B8
+#define CONTROL_PADCONF_SDRC_A11       0x05BA
+#define CONTROL_PADCONF_SDRC_A12       0x05BC
+#define CONTROL_PADCONF_SDRC_A13       0x05BE
+#define CONTROL_PADCONF_SDRC_A14       0x05C0
+#define CONTROL_PADCONF_SDRC_NCS0      0x05C2
+#define CONTROL_PADCONF_SDRC_NCS1      0x05C4
+#define CONTROL_PADCONF_SDRC_NCLK      0x05C6
+#define CONTROL_PADCONF_SDRC_NRAS      0x05C8
+#define CONTROL_PADCONF_SDRC_NCAS      0x05CA
+#define CONTROL_PADCONF_SDRC_NWE       0x05CC
+#define CONTROL_PADCONF_SDRC_DM0       0x05CE
+#define CONTROL_PADCONF_SDRC_DM1       0x05D0
+#define CONTROL_PADCONF_SDRC_DM2       0x05D2
+#define CONTROL_PADCONF_SDRC_DM3       0x05D4
 /*GPMC*/
 #define CONTROL_PADCONF_GPMC_A1                0x007A
 #define CONTROL_PADCONF_GPMC_A2                0x007C
 #define CONTROL_PADCONF_GPMC_A8                0x0088
 #define CONTROL_PADCONF_GPMC_A9                0x008A
 #define CONTROL_PADCONF_GPMC_A10       0x008C
+#define CONTROL_PADCONF_GPMC_A11       0x0264
 #define CONTROL_PADCONF_GPMC_D0                0x008E
 #define CONTROL_PADCONF_GPMC_D1                0x0090
 #define CONTROL_PADCONF_GPMC_D2                0x0092
 #define CONTROL_PADCONF_ETK_D13_ES2    0x05F6
 #define CONTROL_PADCONF_ETK_D14_ES2    0x05F8
 #define CONTROL_PADCONF_ETK_D15_ES2    0x05FA
+#define CONTROL_PADCONF_JTAG_RTCK      0x0A4E
+#define CONTROL_PADCONF_JTAG_TDO       0x0A50
 /*Die to Die */
 #define CONTROL_PADCONF_D2D_MCAD0      0x01E4
 #define CONTROL_PADCONF_D2D_MCAD1      0x01E6
 #define CONTROL_PADCONF_SYS_BOOT8      0x0226
 
 /* AM/DM37xx specific */
+#define CONTROL_PADCONF_GPIO112                0x0134
+#define CONTROL_PADCONF_GPIO113                0x0136
+#define CONTROL_PADCONF_GPIO114                0x0138
+#define CONTROL_PADCONF_GPIO115                0x013A
 #define CONTROL_PADCONF_GPIO127                0x0A54
 #define CONTROL_PADCONF_GPIO126                0x0A56
 #define CONTROL_PADCONF_GPIO128                0x0A58
index 34bd8c509aac924b6886b4a34fe0fe36cba38427..bcf92fbe658b8a360bc24f39ee336652e7f23a14 100644 (file)
@@ -23,6 +23,7 @@ struct emu_hal_params {
 
 /* Board SDRC timing values */
 struct board_sdrc_timings {
+       u32 sharing;
        u32 mcfg;
        u32 ctrla;
        u32 ctrlb;
index 0dc584b8ce68a6d38ba8a711b68fa3bd7842652a..f8e5630bcb4214a44cddf180296eb6b38bc7db0c 100644 (file)
 #define VDD_MPU_ES2_LOW 880
 #define VDD_MM_ES2_LOW 880
 
-/* TPS659038 Voltage settings in mv for OPP_NOMINAL */
-#define VDD_MPU_DRA752         1090
+/* DRA74x/75x voltage settings in mv for OPP_NOM per DM */
+#define VDD_MPU_DRA752         1100
 #define VDD_EVE_DRA752         1060
 #define VDD_GPU_DRA752         1060
-#define VDD_CORE_DRA752                1030
+#define VDD_CORE_DRA752                1060
 #define VDD_IVA_DRA752         1060
 
+/* DRA72x voltage settings in mv for OPP_NOM per DM */
+#define VDD_MPU_DRA72x         1100
+#define VDD_EVE_DRA72x         1060
+#define VDD_GPU_DRA72x         1060
+#define VDD_CORE_DRA72x                1060
+#define VDD_IVA_DRA72x         1060
+
 /* Efuse register offsets for DRA7xx platform */
 #define DRA752_EFUSE_BASE      0x4A002000
 #define DRA752_EFUSE_REGBITS   16
 #define TPS659038_REG_ADDR_SMPS7               0x33
 #define TPS659038_REG_ADDR_SMPS8               0x37
 
+/* TPS65917 */
+#define TPS65917_I2C_SLAVE_ADDR                0x58
+#define TPS65917_REG_ADDR_SMPS1                0x23
+#define TPS65917_REG_ADDR_SMPS2                0x27
+#define TPS65917_REG_ADDR_SMPS3                0x2F
+
+
 /* TPS */
 #define TPS62361_I2C_SLAVE_ADDR                0x60
 #define TPS62361_REG_ADDR_SET0         0x0
diff --git a/arch/arm/include/asm/arch-pantheon/gpio.h b/arch/arm/include/asm/arch-pantheon/gpio.h
new file mode 100644 (file)
index 0000000..e69de29
index 132d58c117a7b8af76b216455b4d4ee2e00edb94..748b80254602d1c5e816b7b2c668836d364bdb0c 100644 (file)
 #define MSTP10_BITS    0xFFFEFFE0
 #define MSTP11_BITS    0x00000000
 
+/* SDHI */
+#define CONFIG_SYS_SH_SDHI1_BASE 0xEE120000
+#define CONFIG_SYS_SH_SDHI2_BASE 0xEE140000
+#define CONFIG_SYS_SH_SDHI3_BASE 0xEE160000
+#define CONFIG_SYS_SH_SDHI_NR_CHANNEL 4
+
 #define R8A7790_CUT_ES2X       2
 #define IS_R8A7790_ES2()       \
        (rmobile_get_cpu_rev_integer() == R8A7790_CUT_ES2X)
index d2cbcd761dceee6d459c0a34aefd7afb83b1d299..1d06b651f4852e2f5f82e50a94a0e1654fcf88ba 100644 (file)
 /* SH-I2C */
 #define CONFIG_SYS_I2C_SH_BASE2        0xE60B0000
 
+/* SDHI */
+#define CONFIG_SYS_SH_SDHI1_BASE 0xEE140000
+#define CONFIG_SYS_SH_SDHI2_BASE 0xEE160000
+#define CONFIG_SYS_SH_SDHI_NR_CHANNEL 3
+
 #define DBSC3_1_QOS_R0_BASE    0xE67A1000
 #define DBSC3_1_QOS_R1_BASE    0xE67A1100
 #define DBSC3_1_QOS_R2_BASE    0xE67A1200
index 1abdeb7450b31ec0a4b3e682ca3cc2547829b64f..3efc62a1a90c6f18786cb382b35c19adbf442682 100644 (file)
 /* SH-I2C */
 #define CONFIG_SYS_I2C_SH_BASE2        0xE60B0000
 
+/* SDHI */
+#define CONFIG_SYS_SH_SDHI1_BASE 0xEE140000
+#define CONFIG_SYS_SH_SDHI2_BASE 0xEE160000
+#define CONFIG_SYS_SH_SDHI_NR_CHANNEL 3
+
 #define DBSC3_1_QOS_R0_BASE    0xE67A1000
 #define DBSC3_1_QOS_R1_BASE    0xE67A1100
 #define DBSC3_1_QOS_R2_BASE    0xE67A1200
index d7c9004772aa1912332e817438b220fe2c13cb01..6d11fa479b7d7340629bed8718f871020418f5f1 100644 (file)
@@ -27,4 +27,9 @@
 #define MSTP10_BITS    0xFFFEFFE0
 #define MSTP11_BITS    0x000001C0
 
+/* SDHI */
+#define CONFIG_SYS_SH_SDHI1_BASE 0xEE140000
+#define CONFIG_SYS_SH_SDHI2_BASE 0xEE160000
+#define CONFIG_SYS_SH_SDHI_NR_CHANNEL 3
+
 #endif /* __ASM_ARCH_R8A7794_H */
index 23c4bba6edec412378aabe636f58f1f660fa50a3..d594cd77c176532a79fb5629369ed72886bd476c 100644 (file)
@@ -82,6 +82,9 @@
 #define CONFIG_SYS_RCAR_I2C2_BASE      0xE6530000
 #define CONFIG_SYS_RCAR_I2C3_BASE      0xE6540000
 
+/* SDHI */
+#define CONFIG_SYS_SH_SDHI0_BASE       0xEE100000
+
 #define S3C_BASE               0xE6784000
 #define S3C_INT_BASE           0xE6784A00
 #define S3C_MEDIA_BASE         0xE6784B00
diff --git a/arch/arm/include/asm/arch-rmobile/sh_sdhi.h b/arch/arm/include/asm/arch-rmobile/sh_sdhi.h
new file mode 100644 (file)
index 0000000..057bf3f
--- /dev/null
@@ -0,0 +1,168 @@
+/*
+ * drivers/mmc/sh-sdhi.h
+ *
+ * SD/MMC driver for Reneas rmobile ARM SoCs
+ *
+ * Copyright (C) 2013-2014 Renesas Electronics Corporation
+ * Copyright (C) 2008-2009 Renesas Solutions Corp.
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#ifndef _SH_SDHI_H
+#define _SH_SDHI_H
+
+#define SDHI_CMD                       (0x0000 >> 1)
+#define SDHI_PORTSEL                   (0x0004 >> 1)
+#define SDHI_ARG0                      (0x0008 >> 1)
+#define SDHI_ARG1                      (0x000C >> 1)
+#define SDHI_STOP                      (0x0010 >> 1)
+#define SDHI_SECCNT                    (0x0014 >> 1)
+#define SDHI_RSP00                     (0x0018 >> 1)
+#define SDHI_RSP01                     (0x001C >> 1)
+#define SDHI_RSP02                     (0x0020 >> 1)
+#define SDHI_RSP03                     (0x0024 >> 1)
+#define SDHI_RSP04                     (0x0028 >> 1)
+#define SDHI_RSP05                     (0x002C >> 1)
+#define SDHI_RSP06                     (0x0030 >> 1)
+#define SDHI_RSP07                     (0x0034 >> 1)
+#define SDHI_INFO1                     (0x0038 >> 1)
+#define SDHI_INFO2                     (0x003C >> 1)
+#define SDHI_INFO1_MASK                        (0x0040 >> 1)
+#define SDHI_INFO2_MASK                        (0x0044 >> 1)
+#define SDHI_CLK_CTRL                  (0x0048 >> 1)
+#define SDHI_SIZE                      (0x004C >> 1)
+#define SDHI_OPTION                    (0x0050 >> 1)
+#define SDHI_ERR_STS1                  (0x0058 >> 1)
+#define SDHI_ERR_STS2                  (0x005C >> 1)
+#define SDHI_BUF0                      (0x0060 >> 1)
+#define SDHI_SDIO_MODE                 (0x0068 >> 1)
+#define SDHI_SDIO_INFO1                        (0x006C >> 1)
+#define SDHI_SDIO_INFO1_MASK           (0x0070 >> 1)
+#define SDHI_CC_EXT_MODE               (0x01B0 >> 1)
+#define SDHI_SOFT_RST                  (0x01C0 >> 1)
+#define SDHI_VERSION                   (0x01C4 >> 1)
+#define SDHI_HOST_MODE                 (0x01C8 >> 1)
+#define SDHI_SDIF_MODE                 (0x01CC >> 1)
+#define SDHI_EXT_SWAP                  (0x01E0 >> 1)
+#define SDHI_SD_DMACR                  (0x0324 >> 1)
+
+/* SDHI CMD VALUE */
+#define CMD_MASK                       0x0000ffff
+#define SDHI_APP                       0x0040
+#define SDHI_SD_APP_SEND_SCR           0x0073
+#define SDHI_SD_SWITCH                 0x1C06
+
+/* SDHI_PORTSEL */
+#define USE_1PORT                      (1 << 8) /* 1 port */
+
+/* SDHI_ARG */
+#define ARG0_MASK                      0x0000ffff
+#define ARG1_MASK                      0x0000ffff
+
+/* SDHI_STOP */
+#define STOP_SEC_ENABLE                        (1 << 8)
+
+/* SDHI_INFO1 */
+#define INFO1_RESP_END                 (1 << 0)
+#define INFO1_ACCESS_END               (1 << 2)
+#define INFO1_CARD_RE                  (1 << 3)
+#define INFO1_CARD_IN                  (1 << 4)
+#define INFO1_ISD0CD                   (1 << 5)
+#define INFO1_WRITE_PRO                        (1 << 7)
+#define INFO1_DATA3_CARD_RE            (1 << 8)
+#define INFO1_DATA3_CARD_IN            (1 << 9)
+#define INFO1_DATA3                    (1 << 10)
+
+/* SDHI_INFO2 */
+#define INFO2_CMD_ERROR                        (1 << 0)
+#define INFO2_CRC_ERROR                        (1 << 1)
+#define INFO2_END_ERROR                        (1 << 2)
+#define INFO2_TIMEOUT                  (1 << 3)
+#define INFO2_BUF_ILL_WRITE            (1 << 4)
+#define INFO2_BUF_ILL_READ             (1 << 5)
+#define INFO2_RESP_TIMEOUT             (1 << 6)
+#define INFO2_SDDAT0                   (1 << 7)
+#define INFO2_BRE_ENABLE               (1 << 8)
+#define INFO2_BWE_ENABLE               (1 << 9)
+#define INFO2_CBUSY                    (1 << 14)
+#define INFO2_ILA                      (1 << 15)
+#define INFO2_ALL_ERR                  (0x807f)
+
+/* SDHI_INFO1_MASK */
+#define INFO1M_RESP_END                        (1 << 0)
+#define INFO1M_ACCESS_END              (1 << 2)
+#define INFO1M_CARD_RE                 (1 << 3)
+#define INFO1M_CARD_IN                 (1 << 4)
+#define INFO1M_DATA3_CARD_RE           (1 << 8)
+#define INFO1M_DATA3_CARD_IN           (1 << 9)
+#define INFO1M_ALL                     (0xffff)
+#define INFO1M_SET                     (INFO1M_RESP_END |      \
+                                       INFO1M_ACCESS_END |     \
+                                       INFO1M_DATA3_CARD_RE |  \
+                                       INFO1M_DATA3_CARD_IN)
+
+/* SDHI_INFO2_MASK */
+#define INFO2M_CMD_ERROR               (1 << 0)
+#define INFO2M_CRC_ERROR               (1 << 1)
+#define INFO2M_END_ERROR               (1 << 2)
+#define INFO2M_TIMEOUT                 (1 << 3)
+#define INFO2M_BUF_ILL_WRITE           (1 << 4)
+#define INFO2M_BUF_ILL_READ            (1 << 5)
+#define INFO2M_RESP_TIMEOUT            (1 << 6)
+#define INFO2M_BRE_ENABLE              (1 << 8)
+#define INFO2M_BWE_ENABLE              (1 << 9)
+#define INFO2M_ILA                     (1 << 15)
+#define INFO2M_ALL                     (0xffff)
+#define INFO2M_ALL_ERR                 (0x807f)
+
+/* SDHI_CLK_CTRL */
+#define CLK_ENABLE                     (1 << 8)
+
+/* SDHI_OPTION */
+#define OPT_BUS_WIDTH_1                        (1 << 15)       /* bus width = 1 bit */
+
+/* SDHI_ERR_STS1 */
+#define ERR_STS1_CRC_ERROR             ((1 << 11) | (1 << 10) | (1 << 9) | \
+                                       (1 << 8) | (1 << 5))
+#define ERR_STS1_CMD_ERROR             ((1 << 4) | (1 << 3) | (1 << 2) | \
+                                       (1 << 1) | (1 << 0))
+
+/* SDHI_ERR_STS2 */
+#define ERR_STS2_RES_TIMEOUT           (1 << 0)
+#define ERR_STS2_RES_STOP_TIMEOUT      ((1 << 0) | (1 << 1))
+#define ERR_STS2_SYS_ERROR             ((1 << 6) | (1 << 5) | (1 << 4) | \
+                                       (1 << 3) | (1 << 2) | (1 << 1) | \
+                                       (1 << 0))
+
+/* SDHI_SDIO_MODE */
+#define SDIO_MODE_ON                   (1 << 0)
+#define SDIO_MODE_OFF                  (0 << 0)
+
+/* SDHI_SDIO_INFO1 */
+#define SDIO_INFO1_IOIRQ               (1 << 0)
+#define SDIO_INFO1_EXPUB52             (1 << 14)
+#define SDIO_INFO1_EXWT                        (1 << 15)
+
+/* SDHI_SDIO_INFO1_MASK */
+#define SDIO_INFO1M_CLEAR              ((1 << 1) | (1 << 2))
+#define SDIO_INFO1M_ON                 ((1 << 15) | (1 << 14) | (1 << 2) | \
+                                        (1 << 1) | (1 << 0))
+
+/* SDHI_EXT_SWAP */
+#define SET_SWAP                       ((1 << 6) | (1 << 7))   /* SWAP */
+
+/* SDHI_SOFT_RST */
+#define SOFT_RST_ON                    (0 << 0)
+#define SOFT_RST_OFF                   (1 << 0)
+
+#define        CLKDEV_SD_DATA                  25000000        /* 25 MHz */
+#define CLKDEV_HS_DATA                 50000000        /* 50 MHz */
+#define CLKDEV_MMC_DATA                        20000000        /* 20MHz */
+#define        CLKDEV_INIT                     400000          /* 100 - 400 KHz */
+
+/* For quirk */
+#define SH_SDHI_QUIRK_16BIT_BUF                (1)
+int sh_sdhi_init(unsigned long addr, int ch, unsigned long quirks);
+
+#endif /* _SH_SDHI_H */
index 505c363e46e1af460837262cff52a8d379f83e1f..3e5d99908192e6b8e99fbada1835281006481fe2 100644 (file)
@@ -17,6 +17,8 @@
 /* clock control module regs definition */
 #if defined(CONFIG_MACH_SUN6I) || defined(CONFIG_MACH_SUN8I)
 #include <asm/arch/clock_sun6i.h>
+#elif defined(CONFIG_MACH_SUN9I)
+#include <asm/arch/clock_sun9i.h>
 #else
 #include <asm/arch/clock_sun4i.h>
 #endif
 #ifndef __ASSEMBLY__
 int clock_init(void);
 int clock_twi_onoff(int port, int state);
-void clock_set_pll1(unsigned int hz);
-void clock_set_pll3(unsigned int hz);
-unsigned int clock_get_pll5p(void);
-unsigned int clock_get_pll6(void);
 void clock_set_de_mod_clock(u32 *clk_cfg, unsigned int hz);
 void clock_init_safe(void);
 void clock_init_uart(void);
index 84a9a2bdbc312e6e97a41887b2a35632ddb23bfe..d297ed0f73e434cabcb1345e7c439bcb1639b70e 100644 (file)
@@ -186,6 +186,7 @@ struct sunxi_ccm_reg {
 
 /* ahb clock gate bit offset (second register) */
 #define AHB_GATE_OFFSET_GMAC           17
+#define AHB_GATE_OFFSET_DE_FE0         14
 #define AHB_GATE_OFFSET_DE_BE0         12
 #define AHB_GATE_OFFSET_HDMI           11
 #define AHB_GATE_OFFSET_LCD1           5
@@ -266,7 +267,10 @@ struct sunxi_ccm_reg {
 #define CCM_MMC_CTRL_PLL5              (0x2 << 24)
 #define CCM_MMC_CTRL_ENABLE            (0x1 << 31)
 
+#define CCM_DRAM_GATE_OFFSET_DE_FE1    24 /* Note the order of FE1 and */
+#define CCM_DRAM_GATE_OFFSET_DE_FE0    25 /* FE0 is swapped ! */
 #define CCM_DRAM_GATE_OFFSET_DE_BE0    26
+#define CCM_DRAM_GATE_OFFSET_DE_BE1    27
 
 #define CCM_LCD_CH0_CTRL_PLL3          (0 << 24)
 #define CCM_LCD_CH0_CTRL_PLL7          (1 << 24)
@@ -301,6 +305,8 @@ struct sunxi_ccm_reg {
 #define CCM_GMAC_CTRL_TX_CLK_SRC_INT_RGMII 0x2
 #define CCM_GMAC_CTRL_GPIT_MII (0x0 << 2)
 #define CCM_GMAC_CTRL_GPIT_RGMII (0x1 << 2)
+#define CCM_GMAC_CTRL_RX_CLK_DELAY(x)  ((x) << 5)
+#define CCM_GMAC_CTRL_TX_CLK_DELAY(x)  ((x) << 10)
 
 #define CCM_USB_CTRL_PHY0_RST (0x1 << 0)
 #define CCM_USB_CTRL_PHY1_RST (0x1 << 1)
@@ -320,4 +326,11 @@ struct sunxi_ccm_reg {
 #define CCM_DE_CTRL_RST                        (1 << 30)
 #define CCM_DE_CTRL_GATE               (1 << 31)
 
+#ifndef __ASSEMBLY__
+void clock_set_pll1(unsigned int hz);
+void clock_set_pll3(unsigned int hz);
+unsigned int clock_get_pll5p(void);
+unsigned int clock_get_pll6(void);
+#endif
+
 #endif /* _SUNXI_CLOCK_SUN4I_H */
index 4711260c1eef58196d40c46f856c3805012a2824..8a803851e481cea87a7b40c3bc4252a79a5b0fe6 100644 (file)
@@ -243,6 +243,8 @@ struct sunxi_ccm_reg {
 #define CCM_GMAC_CTRL_TX_CLK_SRC_INT_RGMII 0x2
 #define CCM_GMAC_CTRL_GPIT_MII         (0x0 << 2)
 #define CCM_GMAC_CTRL_GPIT_RGMII       (0x1 << 2)
+#define CCM_GMAC_CTRL_RX_CLK_DELAY(x)  ((x) << 5)
+#define CCM_GMAC_CTRL_TX_CLK_DELAY(x)  ((x) << 10)
 
 #define MDFS_CLK_DEFAULT               0x81000002 /* PLL6 / 3 */
 
@@ -320,6 +322,11 @@ struct sunxi_ccm_reg {
 #define CCM_DE_CTRL_PLL10              (5 << 24)
 #define CCM_DE_CTRL_GATE               (1 << 31)
 
+#ifndef __ASSEMBLY__
+void clock_set_pll1(unsigned int hz);
+void clock_set_pll3(unsigned int hz);
 void clock_set_pll5(unsigned int clk, bool sigma_delta_enable);
+unsigned int clock_get_pll6(void);
+#endif
 
 #endif /* _SUNXI_CLOCK_SUN6I_H */
diff --git a/arch/arm/include/asm/arch-sunxi/clock_sun9i.h b/arch/arm/include/asm/arch-sunxi/clock_sun9i.h
new file mode 100644 (file)
index 0000000..c506b0a
--- /dev/null
@@ -0,0 +1,139 @@
+/*
+ * sun9i clock register definitions
+ *
+ * (C) Copyright 2015 Hans de Goede <hdegoede@redhat.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#ifndef _SUNXI_CLOCK_SUN9I_H
+#define _SUNXI_CLOCK_SUN9I_H
+
+struct sunxi_ccm_reg {
+       u32 pll1_c0_cfg;        /* 0x00 c0cpu# pll configuration */
+       u32 pll2_c1_cfg;        /* 0x04 c1cpu# pll configuration */
+       u32 pll3_audio_cfg;     /* 0x08 audio pll configuration */
+       u32 pll4_periph0_cfg;   /* 0x0c peripheral0 pll configuration */
+       u32 pll5_ve_cfg;        /* 0x10 videoengine pll configuration */
+       u32 pll6_ddr_cfg;       /* 0x14 ddr pll configuration */
+       u32 pll7_video0_cfg;    /* 0x18 video0 pll configuration */
+       u32 pll8_video1_cfg;    /* 0x1c video1 pll configuration */
+       u32 pll9_gpu_cfg;       /* 0x20 gpu pll configuration */
+       u32 pll10_de_cfg;       /* 0x24 displayengine pll configuration */
+       u32 pll11_isp_cfg;      /* 0x28 isp pll6 ontrol */
+       u32 pll12_periph1_cfg;  /* 0x2c peripheral1 pll configuration */
+       u8 reserved1[0x20];     /* 0x30 */
+       u32 cpu_clk_source;     /* 0x50 cpu clk source configuration */
+       u32 c0_cfg;             /* 0x54 cpu cluster 0 clock configuration */
+       u32 c1_cfg;             /* 0x58 cpu cluster 1 clock configuration */
+       u32 gtbus_cfg;          /* 0x5c gtbus clock configuration */
+       u32 ahb0_cfg;           /* 0x60 ahb0 clock configuration */
+       u32 ahb1_cfg;           /* 0x64 ahb1 clock configuration */
+       u32 ahb2_cfg;           /* 0x68 ahb2 clock configuration */
+       u8 reserved2[0x04];     /* 0x6c */
+       u32 apb0_cfg;           /* 0x70 apb0 clock configuration */
+       u32 apb1_cfg;           /* 0x74 apb1 clock configuration */
+       u32 cci400_cfg;         /* 0x78 cci400 clock configuration */
+       u8 reserved3[0x04];     /* 0x7c */
+       u32 ats_cfg;            /* 0x80 ats clock configuration */
+       u32 trace_cfg;          /* 0x84 trace clock configuration */
+       u8 reserved4[0xf8];     /* 0x88 */
+       u32 clk_output_a;       /* 0x180 clk_output_a */
+       u32 clk_output_b;       /* 0x184 clk_output_a */
+       u8 reserved5[0x278];    /* 0x188 */
+
+       u32 nand0_clk_cfg0;     /* 0x400 nand0 clock configuration0 */
+       u32 nand0_clk_cfg1;     /* 0x404 nand1 clock configuration */
+       u8 reserved6[0x08];     /* 0x408 */
+       u32 sd0_clk_cfg;        /* 0x410 sd0 clock configuration */
+       u32 sd1_clk_cfg;        /* 0x414 sd1 clock configuration */
+       u32 sd2_clk_cfg;        /* 0x418 sd2 clock configuration */
+       u32 sd3_clk_cfg;        /* 0x41c sd3 clock configuration */
+       u8 reserved7[0x08];     /* 0x420 */
+       u32 ts_clk_cfg;         /* 0x428 transport stream clock cfg */
+       u32 ss_clk_cfg;         /* 0x42c security system clock cfg */
+       u32 spi0_clk_cfg;       /* 0x430 spi0 clock configuration */
+       u32 spi1_clk_cfg;       /* 0x434 spi1 clock configuration */
+       u32 spi2_clk_cfg;       /* 0x438 spi2 clock configuration */
+       u32 spi3_clk_cfg;       /* 0x43c spi3 clock configuration */
+       u8 reserved8[0x50];     /* 0x440 */
+       u32 de_clk_cfg;         /* 0x490 display engine clock configuration */
+       u8 reserved9[0x04];     /* 0x494 */
+       u32 mp_clk_cfg;         /* 0x498 mp clock configuration */
+       u32 lcd0_clk_cfg;       /* 0x49c LCD0 module clock */
+       u32 lcd1_clk_cfg;       /* 0x4a0 LCD1 module clock */
+       u8 reserved10[0x1c];    /* 0x4a4 */
+       u32 csi_isp_clk_cfg;    /* 0x4c0 CSI ISP module clock */
+       u32 csi0_clk_cfg;       /* 0x4c4 CSI0 module clock */
+       u32 csi1_clk_cfg;       /* 0x4c8 CSI1 module clock */
+       u32 fd_clk_cfg;         /* 0x4cc FD module clock */
+       u32 ve_clk_cfg;         /* 0x4d0 VE module clock */
+       u32 avs_clk_cfg;        /* 0x4d4 AVS module clock */
+       u8 reserved11[0x18];    /* 0x4d8 */
+       u32 gpu_core_clk_cfg;   /* 0x4f0 GPU core clock config */
+       u32 gpu_mem_clk_cfg;    /* 0x4f4 GPU memory clock config */
+       u32 gpu_axi_clk_cfg;    /* 0x4f8 GPU AXI clock config */
+       u8 reserved12[0x10];    /* 0x4fc */
+       u32 gp_adc_clk_cfg;     /* 0x50c General Purpose ADC clk config */
+       u8 reserved13[0x70];    /* 0x510 */
+
+       u32 ahb_gate0;          /* 0x580 AHB0 Gating Register */
+       u32 ahb_gate1;          /* 0x584 AHB1 Gating Register */
+       u32 ahb_gate2;          /* 0x588 AHB2 Gating Register */
+       u8 reserved14[0x04];    /* 0x58c */
+       u32 apb0_gate;          /* 0x590 APB0 Clock Gating Register */
+       u32 apb1_gate;          /* 0x594 APB1 Clock Gating Register */
+       u8 reserved15[0x08];    /* 0x598 */
+       u32 ahb_reset0_cfg;     /* 0x5a0 AHB0 Software Reset Register */
+       u32 ahb_reset1_cfg;     /* 0x5a4 AHB1 Software Reset Register */
+       u32 ahb_reset2_cfg;     /* 0x5a8 AHB2 Software Reset Register */
+       u8 reserved16[0x04];    /* 0x5ac */
+       u32 apb0_reset_cfg;     /* 0x5b0 Bus Software Reset Register 3 */
+       u32 apb1_reset_cfg;     /* 0x5b4 Bus Software Reset Register 4 */
+};
+
+/* pll4_periph0_cfg */
+#define PLL4_CFG_DEFAULT               0x90002800 /* 960 MHz */
+
+#define CCM_PLL4_CTRL_N_SHIFT          8
+#define CCM_PLL4_CTRL_N_MASK           (0xff << CCM_PLL4_CTRL_N_SHIFT)
+#define CCM_PLL4_CTRL_P_SHIFT          16
+#define CCM_PLL4_CTRL_P_MASK           (0x1 << CCM_PLL4_CTRL_P_SHIFT)
+#define CCM_PLL4_CTRL_M_SHIFT          18
+#define CCM_PLL4_CTRL_M_MASK           (0x1 << CCM_PLL4_CTRL_M_SHIFT)
+
+/* sd#_clk_cfg fields */
+#define CCM_MMC_CTRL_M(x)              ((x) - 1)
+#define CCM_MMC_CTRL_OCLK_DLY(x)       ((x) << 8)
+#define CCM_MMC_CTRL_N(x)              ((x) << 16)
+#define CCM_MMC_CTRL_SCLK_DLY(x)       ((x) << 20)
+#define CCM_MMC_CTRL_OSCM24            (0 << 24)
+#define CCM_MMC_CTRL_PLL_PERIPH0       (1 << 24)
+#define CCM_MMC_CTRL_ENABLE            (1 << 31)
+
+/* ahb_gate0 fields */
+/* On sun9i all sdc-s share their ahb gate, so ignore (x) */
+#define AHB_GATE_OFFSET_MMC(x)         8
+
+/* apb1_gate fields */
+#define APB1_GATE_UART_SHIFT           16
+#define APB1_GATE_UART_MASK            (0xff << APB1_GATE_UART_SHIFT)
+#define APB1_GATE_TWI_SHIFT            0
+#define APB1_GATE_TWI_MASK             (0xf << APB1_GATE_TWI_SHIFT)
+
+/* ahb_reset0_cfg fields */
+/* On sun9i all sdc-s share their ahb reset, so ignore (x) */
+#define AHB_RESET_OFFSET_MMC(x)                8
+
+/* apb1_reset_cfg fields */
+#define APB1_RESET_UART_SHIFT          16
+#define APB1_RESET_UART_MASK           (0xff << APB1_RESET_UART_SHIFT)
+#define APB1_RESET_TWI_SHIFT           0
+#define APB1_RESET_TWI_MASK            (0xf << APB1_RESET_TWI_SHIFT)
+
+
+#ifndef __ASSEMBLY__
+unsigned int clock_get_pll4_periph0(void);
+#endif
+
+#endif /* _SUNXI_CLOCK_SUN9I_H */
index 82b3d4676fd7fd51f952882d2c054d53c9e8d87e..73583ed445a57bbdb3863e826056921e0cd25f9e 100644 (file)
@@ -1,7 +1,5 @@
 /*
- * (C) Copyright 2007-2011
- * Allwinner Technology Co., Ltd. <www.allwinnertech.com>
- * Tom Cubie <tangliang@allwinnertech.com>
+ * (C) Copyright 2015 Hans de Goede <hdegoede@redhat.com>
  *
  * SPDX-License-Identifier:    GPL-2.0+
  */
 #ifndef _SUNXI_CPU_H
 #define _SUNXI_CPU_H
 
-#define SUNXI_SRAM_A1_BASE             0x00000000
-#define SUNXI_SRAM_A1_SIZE             (16 * 1024)     /* 16 kiB */
-
-#define SUNXI_SRAM_A2_BASE             0x00004000      /* 16 kiB */
-#define SUNXI_SRAM_A3_BASE             0x00008000      /* 13 kiB */
-#define SUNXI_SRAM_A4_BASE             0x0000b400      /* 3 kiB */
-#define SUNXI_SRAM_D_BASE              0x00010000      /* 4 kiB */
-#define SUNXI_SRAM_B_BASE              0x00020000      /* 64 kiB (secure) */
-
-#define SUNXI_SRAMC_BASE               0x01c00000
-#define SUNXI_DRAMC_BASE               0x01c01000
-#define SUNXI_DMA_BASE                 0x01c02000
-#define SUNXI_NFC_BASE                 0x01c03000
-#define SUNXI_TS_BASE                  0x01c04000
-#define SUNXI_SPI0_BASE                        0x01c05000
-#define SUNXI_SPI1_BASE                        0x01c06000
-#define SUNXI_MS_BASE                  0x01c07000
-#define SUNXI_TVD_BASE                 0x01c08000
-#define SUNXI_CSI0_BASE                        0x01c09000
-#define SUNXI_TVE0_BASE                        0x01c0a000
-#define SUNXI_EMAC_BASE                        0x01c0b000
-#define SUNXI_LCD0_BASE                        0x01c0C000
-#define SUNXI_LCD1_BASE                        0x01c0d000
-#define SUNXI_VE_BASE                  0x01c0e000
-#define SUNXI_MMC0_BASE                        0x01c0f000
-#define SUNXI_MMC1_BASE                        0x01c10000
-#define SUNXI_MMC2_BASE                        0x01c11000
-#define SUNXI_MMC3_BASE                        0x01c12000
-#if !defined CONFIG_MACH_SUN6I && !defined CONFIG_MACH_SUN8I
-#define SUNXI_USB0_BASE                        0x01c13000
-#define SUNXI_USB1_BASE                        0x01c14000
-#endif
-#define SUNXI_SS_BASE                  0x01c15000
-#define SUNXI_HDMI_BASE                        0x01c16000
-#define SUNXI_SPI2_BASE                        0x01c17000
-#define SUNXI_SATA_BASE                        0x01c18000
-#if !defined CONFIG_MACH_SUN6I && !defined CONFIG_MACH_SUN8I
-#define SUNXI_PATA_BASE                        0x01c19000
-#define SUNXI_ACE_BASE                 0x01c1a000
-#define SUNXI_TVE1_BASE                        0x01c1b000
-#define SUNXI_USB2_BASE                        0x01c1c000
+#if defined(CONFIG_MACH_SUN9I)
+#include <asm/arch/cpu_sun9i.h>
 #else
-#define SUNXI_USB0_BASE                        0x01c19000
-#define SUNXI_USB1_BASE                        0x01c1a000
-#define SUNXI_USB2_BASE                        0x01c1b000
+#include <asm/arch/cpu_sun4i.h>
 #endif
-#define SUNXI_CSI1_BASE                        0x01c1d000
-#define SUNXI_TZASC_BASE               0x01c1e000
-#define SUNXI_SPI3_BASE                        0x01c1f000
-
-#define SUNXI_CCM_BASE                 0x01c20000
-#define SUNXI_INTC_BASE                        0x01c20400
-#define SUNXI_PIO_BASE                 0x01c20800
-#define SUNXI_TIMER_BASE               0x01c20c00
-#define SUNXI_SPDIF_BASE               0x01c21000
-#define SUNXI_AC97_BASE                        0x01c21400
-#define SUNXI_IR0_BASE                 0x01c21800
-#define SUNXI_IR1_BASE                 0x01c21c00
-
-#define SUNXI_IIS_BASE                 0x01c22400
-#define SUNXI_LRADC_BASE               0x01c22800
-#define SUNXI_AD_DA_BASE               0x01c22c00
-#define SUNXI_KEYPAD_BASE              0x01c23000
-#define SUNXI_TZPC_BASE                        0x01c23400
-#define SUNXI_SID_BASE                 0x01c23800
-#define SUNXI_SJTAG_BASE               0x01c23c00
-
-#define SUNXI_TP_BASE                  0x01c25000
-#define SUNXI_PMU_BASE                 0x01c25400
-#define SUN7I_CPUCFG_BASE              0x01c25c00
-
-#define SUNXI_UART0_BASE               0x01c28000
-#define SUNXI_UART1_BASE               0x01c28400
-#define SUNXI_UART2_BASE               0x01c28800
-#define SUNXI_UART3_BASE               0x01c28c00
-#define SUNXI_UART4_BASE               0x01c29000
-#define SUNXI_UART5_BASE               0x01c29400
-#define SUNXI_UART6_BASE               0x01c29800
-#define SUNXI_UART7_BASE               0x01c29c00
-#define SUNXI_PS2_0_BASE               0x01c2a000
-#define SUNXI_PS2_1_BASE               0x01c2a400
-
-#define SUNXI_TWI0_BASE                        0x01c2ac00
-#define SUNXI_TWI1_BASE                        0x01c2b000
-#define SUNXI_TWI2_BASE                        0x01c2b400
-
-#define SUNXI_CAN_BASE                 0x01c2bc00
-
-#define SUNXI_SCR_BASE                 0x01c2c400
-
-#ifndef CONFIG_MACH_SUN6I
-#define SUNXI_GPS_BASE                 0x01c30000
-#define SUNXI_MALI400_BASE             0x01c40000
-#define SUNXI_GMAC_BASE                        0x01c50000
-#else
-#define SUNXI_GMAC_BASE                        0x01c30000
-#endif
-
-#define SUNXI_DRAM_COM_BASE            0x01c62000
-#define SUNXI_DRAM_CTL0_BASE           0x01c63000
-#define SUNXI_DRAM_CTL1_BASE           0x01c64000
-#define SUNXI_DRAM_PHY0_BASE           0x01c65000
-#define SUNXI_DRAM_PHY1_BASE           0x01c66000
-
-/* module sram */
-#define SUNXI_SRAM_C_BASE              0x01d00000
-
-#define SUNXI_DE_FE0_BASE              0x01e00000
-#define SUNXI_DE_FE1_BASE              0x01e20000
-#define SUNXI_DE_BE0_BASE              0x01e60000
-#define SUNXI_DE_BE1_BASE              0x01e40000
-#define SUNXI_MP_BASE                  0x01e80000
-#define SUNXI_AVG_BASE                 0x01ea0000
-
-#define SUNXI_RTC_BASE                 0x01f00000
-#define SUNXI_PRCM_BASE                        0x01f01400
-#define SUN6I_CPUCFG_BASE              0x01f01c00
-#define SUNXI_R_UART_BASE              0x01f02800
-#define SUNXI_R_PIO_BASE               0x01f02c00
-#define SUN6I_P2WI_BASE                        0x01f03400
-#define SUNXI_RSB_BASE                 0x01f03400
-
-/* CoreSight Debug Module */
-#define SUNXI_CSDM_BASE                        0x3f500000
-
-#define SUNXI_DDRII_DDRIII_BASE                0x40000000      /* 2 GiB */
-
-#define SUNXI_BROM_BASE                        0xffff0000      /* 32 kiB */
-
-#define SUNXI_CPU_CFG                  (SUNXI_TIMER_BASE + 0x13c)
-
-/* SS bonding ids used for cpu identification */
-#define SUNXI_SS_BOND_ID_A31           4
-#define SUNXI_SS_BOND_ID_A31S          5
-
-#ifndef __ASSEMBLY__
-void sunxi_board_init(void);
-void sunxi_reset(void);
-int sunxi_get_ss_bonding_id(void);
-int sunxi_get_sid(unsigned int *sid);
-#endif /* __ASSEMBLY__ */
 
-#endif /* _CPU_H */
+#endif /* _SUNXI_CPU_H */
diff --git a/arch/arm/include/asm/arch-sunxi/cpu_sun4i.h b/arch/arm/include/asm/arch-sunxi/cpu_sun4i.h
new file mode 100644 (file)
index 0000000..dae6069
--- /dev/null
@@ -0,0 +1,154 @@
+/*
+ * (C) Copyright 2007-2011
+ * Allwinner Technology Co., Ltd. <www.allwinnertech.com>
+ * Tom Cubie <tangliang@allwinnertech.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#ifndef _SUNXI_CPU_SUN4I_H
+#define _SUNXI_CPU_SUN4I_H
+
+#define SUNXI_SRAM_A1_BASE             0x00000000
+#define SUNXI_SRAM_A1_SIZE             (16 * 1024)     /* 16 kiB */
+
+#define SUNXI_SRAM_A2_BASE             0x00004000      /* 16 kiB */
+#define SUNXI_SRAM_A3_BASE             0x00008000      /* 13 kiB */
+#define SUNXI_SRAM_A4_BASE             0x0000b400      /* 3 kiB */
+#define SUNXI_SRAM_D_BASE              0x00010000      /* 4 kiB */
+#define SUNXI_SRAM_B_BASE              0x00020000      /* 64 kiB (secure) */
+
+#define SUNXI_SRAMC_BASE               0x01c00000
+#define SUNXI_DRAMC_BASE               0x01c01000
+#define SUNXI_DMA_BASE                 0x01c02000
+#define SUNXI_NFC_BASE                 0x01c03000
+#define SUNXI_TS_BASE                  0x01c04000
+#define SUNXI_SPI0_BASE                        0x01c05000
+#define SUNXI_SPI1_BASE                        0x01c06000
+#define SUNXI_MS_BASE                  0x01c07000
+#define SUNXI_TVD_BASE                 0x01c08000
+#define SUNXI_CSI0_BASE                        0x01c09000
+#define SUNXI_TVE0_BASE                        0x01c0a000
+#define SUNXI_EMAC_BASE                        0x01c0b000
+#define SUNXI_LCD0_BASE                        0x01c0C000
+#define SUNXI_LCD1_BASE                        0x01c0d000
+#define SUNXI_VE_BASE                  0x01c0e000
+#define SUNXI_MMC0_BASE                        0x01c0f000
+#define SUNXI_MMC1_BASE                        0x01c10000
+#define SUNXI_MMC2_BASE                        0x01c11000
+#define SUNXI_MMC3_BASE                        0x01c12000
+#if !defined CONFIG_MACH_SUN6I && !defined CONFIG_MACH_SUN8I
+#define SUNXI_USB0_BASE                        0x01c13000
+#define SUNXI_USB1_BASE                        0x01c14000
+#endif
+#define SUNXI_SS_BASE                  0x01c15000
+#define SUNXI_HDMI_BASE                        0x01c16000
+#define SUNXI_SPI2_BASE                        0x01c17000
+#define SUNXI_SATA_BASE                        0x01c18000
+#if !defined CONFIG_MACH_SUN6I && !defined CONFIG_MACH_SUN8I
+#define SUNXI_PATA_BASE                        0x01c19000
+#define SUNXI_ACE_BASE                 0x01c1a000
+#define SUNXI_TVE1_BASE                        0x01c1b000
+#define SUNXI_USB2_BASE                        0x01c1c000
+#else
+#define SUNXI_USB0_BASE                        0x01c19000
+#define SUNXI_USB1_BASE                        0x01c1a000
+#define SUNXI_USB2_BASE                        0x01c1b000
+#endif
+#define SUNXI_CSI1_BASE                        0x01c1d000
+#define SUNXI_TZASC_BASE               0x01c1e000
+#define SUNXI_SPI3_BASE                        0x01c1f000
+
+#define SUNXI_CCM_BASE                 0x01c20000
+#define SUNXI_INTC_BASE                        0x01c20400
+#define SUNXI_PIO_BASE                 0x01c20800
+#define SUNXI_TIMER_BASE               0x01c20c00
+#define SUNXI_SPDIF_BASE               0x01c21000
+#define SUNXI_AC97_BASE                        0x01c21400
+#define SUNXI_IR0_BASE                 0x01c21800
+#define SUNXI_IR1_BASE                 0x01c21c00
+
+#define SUNXI_IIS_BASE                 0x01c22400
+#define SUNXI_LRADC_BASE               0x01c22800
+#define SUNXI_AD_DA_BASE               0x01c22c00
+#define SUNXI_KEYPAD_BASE              0x01c23000
+#define SUNXI_TZPC_BASE                        0x01c23400
+#define SUNXI_SID_BASE                 0x01c23800
+#define SUNXI_SJTAG_BASE               0x01c23c00
+
+#define SUNXI_TP_BASE                  0x01c25000
+#define SUNXI_PMU_BASE                 0x01c25400
+#define SUN7I_CPUCFG_BASE              0x01c25c00
+
+#define SUNXI_UART0_BASE               0x01c28000
+#define SUNXI_UART1_BASE               0x01c28400
+#define SUNXI_UART2_BASE               0x01c28800
+#define SUNXI_UART3_BASE               0x01c28c00
+#define SUNXI_UART4_BASE               0x01c29000
+#define SUNXI_UART5_BASE               0x01c29400
+#define SUNXI_UART6_BASE               0x01c29800
+#define SUNXI_UART7_BASE               0x01c29c00
+#define SUNXI_PS2_0_BASE               0x01c2a000
+#define SUNXI_PS2_1_BASE               0x01c2a400
+
+#define SUNXI_TWI0_BASE                        0x01c2ac00
+#define SUNXI_TWI1_BASE                        0x01c2b000
+#define SUNXI_TWI2_BASE                        0x01c2b400
+
+#define SUNXI_CAN_BASE                 0x01c2bc00
+
+#define SUNXI_SCR_BASE                 0x01c2c400
+
+#ifndef CONFIG_MACH_SUN6I
+#define SUNXI_GPS_BASE                 0x01c30000
+#define SUNXI_MALI400_BASE             0x01c40000
+#define SUNXI_GMAC_BASE                        0x01c50000
+#else
+#define SUNXI_GMAC_BASE                        0x01c30000
+#endif
+
+#define SUNXI_DRAM_COM_BASE            0x01c62000
+#define SUNXI_DRAM_CTL0_BASE           0x01c63000
+#define SUNXI_DRAM_CTL1_BASE           0x01c64000
+#define SUNXI_DRAM_PHY0_BASE           0x01c65000
+#define SUNXI_DRAM_PHY1_BASE           0x01c66000
+
+/* module sram */
+#define SUNXI_SRAM_C_BASE              0x01d00000
+
+#define SUNXI_DE_FE0_BASE              0x01e00000
+#define SUNXI_DE_FE1_BASE              0x01e20000
+#define SUNXI_DE_BE0_BASE              0x01e60000
+#define SUNXI_DE_BE1_BASE              0x01e40000
+#define SUNXI_MP_BASE                  0x01e80000
+#define SUNXI_AVG_BASE                 0x01ea0000
+
+#define SUNXI_RTC_BASE                 0x01f00000
+#define SUNXI_PRCM_BASE                        0x01f01400
+#define SUN6I_CPUCFG_BASE              0x01f01c00
+#define SUNXI_R_UART_BASE              0x01f02800
+#define SUNXI_R_PIO_BASE               0x01f02c00
+#define SUN6I_P2WI_BASE                        0x01f03400
+#define SUNXI_RSB_BASE                 0x01f03400
+
+/* CoreSight Debug Module */
+#define SUNXI_CSDM_BASE                        0x3f500000
+
+#define SUNXI_DDRII_DDRIII_BASE                0x40000000      /* 2 GiB */
+
+#define SUNXI_BROM_BASE                        0xffff0000      /* 32 kiB */
+
+#define SUNXI_CPU_CFG                  (SUNXI_TIMER_BASE + 0x13c)
+
+/* SS bonding ids used for cpu identification */
+#define SUNXI_SS_BOND_ID_A31           4
+#define SUNXI_SS_BOND_ID_A31S          5
+
+#ifndef __ASSEMBLY__
+void sunxi_board_init(void);
+void sunxi_reset(void);
+int sunxi_get_ss_bonding_id(void);
+int sunxi_get_sid(unsigned int *sid);
+#endif /* __ASSEMBLY__ */
+
+#endif /* _SUNXI_CPU_SUN4I_H */
diff --git a/arch/arm/include/asm/arch-sunxi/cpu_sun9i.h b/arch/arm/include/asm/arch-sunxi/cpu_sun9i.h
new file mode 100644 (file)
index 0000000..04889c5
--- /dev/null
@@ -0,0 +1,109 @@
+/*
+ * (C) Copyright 2015 Hans de Goede <hdegoede@redhat.com>
+ * (C) Copyright 2007-2013
+ * Allwinner Technology Co., Ltd. <www.allwinnertech.com>
+ * Jerry Wang <wangflord@allwinnertech.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#ifndef _SUNXI_CPU_SUN9I_H
+#define _SUNXI_CPU_SUN9I_H
+
+#define REGS_AHB0_BASE                 0x01C00000
+#define REGS_AHB1_BASE                 0x00800000
+#define REGS_AHB2_BASE                 0x03000000
+#define REGS_APB0_BASE                 0x06000000
+#define REGS_APB1_BASE                 0x07000000
+#define REGS_RCPUS_BASE                        0x08000000
+
+#define SUNXI_SRAM_D_BASE              0x08100000
+
+/* AHB0 Module */
+#define SUNXI_NFC_BASE                 (REGS_AHB0_BASE + 0x3000)
+#define SUNXI_TSC_BASE                 (REGS_AHB0_BASE + 0x4000)
+
+#define SUNXI_MMC0_BASE                        (REGS_AHB0_BASE + 0x0f000)
+#define SUNXI_MMC1_BASE                        (REGS_AHB0_BASE + 0x10000)
+#define SUNXI_MMC2_BASE                        (REGS_AHB0_BASE + 0x11000)
+#define SUNXI_MMC3_BASE                        (REGS_AHB0_BASE + 0x12000)
+#define SUNXI_MMC_COMMON_BASE          (REGS_AHB0_BASE + 0x13000)
+
+#define SUNXI_SPI0_BASE                        (REGS_AHB0_BASE + 0x1A000)
+#define SUNXI_SPI1_BASE                        (REGS_AHB0_BASE + 0x1B000)
+#define SUNXI_SPI2_BASE                        (REGS_AHB0_BASE + 0x1C000)
+#define SUNXI_SPI3_BASE                        (REGS_AHB0_BASE + 0x1D000)
+
+#define SUNXI_GIC400_BASE              (REGS_AHB0_BASE + 0x40000)
+#define SUNXI_ARMA9_GIC_BASE           (REGS_AHB0_BASE + 0x41000)
+#define SUNXI_ARMA9_CPUIF_BASE         (REGS_AHB0_BASE + 0x42000)
+
+/* AHB1 Module */
+#define SUNXI_DMA_BASE                 (REGS_AHB1_BASE + 0x002000)
+#define SUNXI_USBOTG_BASE              (REGS_AHB1_BASE + 0x100000)
+#define SUNXI_USBEHCI0_BASE            (REGS_AHB1_BASE + 0x200000)
+#define SUNXI_USBEHCI1_BASE            (REGS_AHB1_BASE + 0x201000)
+#define SUNXI_USBEHCI2_BASE            (REGS_AHB1_BASE + 0x202000)
+
+/* AHB2 Module */
+#define SUNXI_DE_SYS_BASE              (REGS_AHB2_BASE + 0x000000)
+#define SUNXI_DISP_SYS_BASE            (REGS_AHB2_BASE + 0x010000)
+#define SUNXI_DE_FE0_BASE              (REGS_AHB2_BASE + 0x100000)
+#define SUNXI_DE_FE1_BASE              (REGS_AHB2_BASE + 0x140000)
+#define SUNXI_DE_FE2_BASE              (REGS_AHB2_BASE + 0x180000)
+
+#define SUNXI_DE_BE0_BASE              (REGS_AHB2_BASE + 0x200000)
+#define SUNXI_DE_BE1_BASE              (REGS_AHB2_BASE + 0x240000)
+#define SUNXI_DE_BE2_BASE              (REGS_AHB2_BASE + 0x280000)
+
+#define SUNXI_DE_DEU0_BASE             (REGS_AHB2_BASE + 0x300000)
+#define SUNXI_DE_DEU1_BASE             (REGS_AHB2_BASE + 0x340000)
+#define SUNXI_DE_DRC0_BASE             (REGS_AHB2_BASE + 0x400000)
+#define SUNXI_DE_DRC1_BASE             (REGS_AHB2_BASE + 0x440000)
+
+#define SUNXI_LCD0_BASE                        (REGS_AHB2_BASE + 0xC00000)
+#define SUNXI_LCD1_BASE                        (REGS_AHB2_BASE + 0xC10000)
+#define SUNXI_LCD2_BASE                        (REGS_AHB2_BASE + 0xC20000)
+#define SUNXI_MIPI_DSI0_BASE           (REGS_AHB2_BASE + 0xC40000)
+/* Also seen as SUNXI_MIPI_DSI0_DPHY_BASE 0x01ca1000 */
+#define SUNXI_MIPI_DSI0_DPHY_BASE      (REGS_AHB2_BASE + 0xC40100)
+#define SUNXI_HDMI_BASE                        (REGS_AHB2_BASE + 0xD00000)
+
+/* APB0 Module */
+#define SUNXI_CCM_BASE                 (REGS_APB0_BASE + 0x0000)
+#define SUNXI_CCMMODULE_BASE           (REGS_APB0_BASE + 0x0400)
+#define SUNXI_PIO_BASE                 (REGS_APB0_BASE + 0x0800)
+#define SUNXI_TIMER_BASE               (REGS_APB0_BASE + 0x0C00)
+#define SUNXI_PWM_BASE                 (REGS_APB0_BASE + 0x1400)
+#define SUNXI_LRADC_BASE               (REGS_APB0_BASE + 0x1800)
+
+/* APB1 Module */
+#define SUNXI_UART0_BASE               (REGS_APB1_BASE + 0x0000)
+#define SUNXI_UART1_BASE               (REGS_APB1_BASE + 0x0400)
+#define SUNXI_UART2_BASE               (REGS_APB1_BASE + 0x0800)
+#define SUNXI_UART3_BASE               (REGS_APB1_BASE + 0x0C00)
+#define SUNXI_UART4_BASE               (REGS_APB1_BASE + 0x1000)
+#define SUNXI_UART5_BASE               (REGS_APB1_BASE + 0x1400)
+#define SUNXI_TWI0_BASE                        (REGS_APB1_BASE + 0x2800)
+#define SUNXI_TWI1_BASE                        (REGS_APB1_BASE + 0x2C00)
+#define SUNXI_TWI2_BASE                        (REGS_APB1_BASE + 0x3000)
+#define SUNXI_TWI3_BASE                        (REGS_APB1_BASE + 0x3400)
+#define SUNXI_TWI4_BASE                        (REGS_APB1_BASE + 0x3800)
+
+/* RCPUS Module */
+#define SUNXI_PRCM_BASE                        (REGS_RCPUS_BASE + 0x1400)
+#define SUNXI_R_UART_BASE              (REGS_RCPUS_BASE + 0x2800)
+#define SUNXI_R_PIO_BASE               (REGS_RCPUS_BASE + 0x2c00)
+#define SUNXI_RSB_BASE                 (REGS_RCPUS_BASE + 0x3400)
+
+/* Misc. */
+#define SUNXI_BROM_BASE                        0xFFFF0000 /* 32K */
+#define SUNXI_CPU_CFG                  (SUNXI_TIMER_BASE + 0x13c)
+
+#ifndef __ASSEMBLY__
+void sunxi_board_init(void);
+void sunxi_reset(void);
+int sunxi_get_sid(unsigned int *sid);
+#endif
+
+#endif /* _SUNXI_CPU_SUN9I_H */
index 2ac8a879dfb6feb5dd298c23322c87063b63d858..5e9425320366d96e44a1512baba2780108e66095 100644 (file)
@@ -9,6 +9,107 @@
 #ifndef _SUNXI_DISPLAY_H
 #define _SUNXI_DISPLAY_H
 
+struct sunxi_de_fe_reg {
+       u32 enable;                     /* 0x000 */
+       u32 frame_ctrl;                 /* 0x004 */
+       u32 bypass;                     /* 0x008 */
+       u32 algorithm_sel;              /* 0x00c */
+       u32 line_int_ctrl;              /* 0x010 */
+       u8 res0[0x0c];                  /* 0x014 */
+       u32 ch0_addr;                   /* 0x020 */
+       u32 ch1_addr;                   /* 0x024 */
+       u32 ch2_addr;                   /* 0x028 */
+       u32 field_sequence;             /* 0x02c */
+       u32 ch0_offset;                 /* 0x030 */
+       u32 ch1_offset;                 /* 0x034 */
+       u32 ch2_offset;                 /* 0x038 */
+       u8 res1[0x04];                  /* 0x03c */
+       u32 ch0_stride;                 /* 0x040 */
+       u32 ch1_stride;                 /* 0x044 */
+       u32 ch2_stride;                 /* 0x048 */
+       u32 input_fmt;                  /* 0x04c */
+       u32 ch3_addr;                   /* 0x050 */
+       u32 ch4_addr;                   /* 0x054 */
+       u32 ch5_addr;                   /* 0x058 */
+       u32 output_fmt;                 /* 0x05c */
+       u32 int_enable;                 /* 0x060 */
+       u32 int_status;                 /* 0x064 */
+       u32 status;                     /* 0x068 */
+       u8 res2[0x04];                  /* 0x06c */
+       u32 csc_coef00;                 /* 0x070 */
+       u32 csc_coef01;                 /* 0x074 */
+       u32 csc_coef02;                 /* 0x078 */
+       u32 csc_coef03;                 /* 0x07c */
+       u32 csc_coef10;                 /* 0x080 */
+       u32 csc_coef11;                 /* 0x084 */
+       u32 csc_coef12;                 /* 0x088 */
+       u32 csc_coef13;                 /* 0x08c */
+       u32 csc_coef20;                 /* 0x090 */
+       u32 csc_coef21;                 /* 0x094 */
+       u32 csc_coef22;                 /* 0x098 */
+       u32 csc_coef23;                 /* 0x09c */
+       u32 deinterlace_ctrl;           /* 0x0a0 */
+       u32 deinterlace_diag;           /* 0x0a4 */
+       u32 deinterlace_tempdiff;       /* 0x0a8 */
+       u32 deinterlace_sawtooth;       /* 0x0ac */
+       u32 deinterlace_spatcomp;       /* 0x0b0 */
+       u32 deinterlace_burstlen;       /* 0x0b4 */
+       u32 deinterlace_preluma;        /* 0x0b8 */
+       u32 deinterlace_tile_addr;      /* 0x0bc */
+       u32 deinterlace_tile_stride;    /* 0x0c0 */
+       u8 res3[0x0c];                  /* 0x0c4 */
+       u32 wb_stride_enable;           /* 0x0d0 */
+       u32 ch3_stride;                 /* 0x0d4 */
+       u32 ch4_stride;                 /* 0x0d8 */
+       u32 ch5_stride;                 /* 0x0dc */
+       u32 fe_3d_ctrl;                 /* 0x0e0 */
+       u32 fe_3d_ch0_addr;             /* 0x0e4 */
+       u32 fe_3d_ch1_addr;             /* 0x0e8 */
+       u32 fe_3d_ch2_addr;             /* 0x0ec */
+       u32 fe_3d_ch0_offset;           /* 0x0f0 */
+       u32 fe_3d_ch1_offset;           /* 0x0f4 */
+       u32 fe_3d_ch2_offset;           /* 0x0f8 */
+       u8 res4[0x04];                  /* 0x0fc */
+       u32 ch0_insize;                 /* 0x100 */
+       u32 ch0_outsize;                /* 0x104 */
+       u32 ch0_horzfact;               /* 0x108 */
+       u32 ch0_vertfact;               /* 0x10c */
+       u32 ch0_horzphase;              /* 0x110 */
+       u32 ch0_vertphase0;             /* 0x114 */
+       u32 ch0_vertphase1;             /* 0x118 */
+       u8 res5[0x04];                  /* 0x11c */
+       u32 ch0_horztapoffset0;         /* 0x120 */
+       u32 ch0_horztapoffset1;         /* 0x124 */
+       u32 ch0_verttapoffset;          /* 0x128 */
+       u8 res6[0xd4];                  /* 0x12c */
+       u32 ch1_insize;                 /* 0x200 */
+       u32 ch1_outsize;                /* 0x204 */
+       u32 ch1_horzfact;               /* 0x208 */
+       u32 ch1_vertfact;               /* 0x20c */
+       u32 ch1_horzphase;              /* 0x210 */
+       u32 ch1_vertphase0;             /* 0x214 */
+       u32 ch1_vertphase1;             /* 0x218 */
+       u8 res7[0x04];                  /* 0x21c */
+       u32 ch1_horztapoffset0;         /* 0x220 */
+       u32 ch1_horztapoffset1;         /* 0x224 */
+       u32 ch1_verttapoffset;          /* 0x228 */
+       u8 res8[0x1d4];                 /* 0x22c */
+       u32 ch0_horzcoef0[32];          /* 0x400 */
+       u32 ch0_horzcoef1[32];          /* 0x480 */
+       u32 ch0_vertcoef[32];           /* 0x500 */
+       u8 res9[0x80];                  /* 0x580 */
+       u32 ch1_horzcoef0[32];          /* 0x600 */
+       u32 ch1_horzcoef1[32];          /* 0x680 */
+       u32 ch1_vertcoef[32];           /* 0x700 */
+       u8 res10[0x280];                /* 0x780 */
+       u32 vpp_enable;                 /* 0xa00 */
+       u32 vpp_dcti;                   /* 0xa04 */
+       u32 vpp_lp1;                    /* 0xa08 */
+       u32 vpp_lp2;                    /* 0xa0c */
+       u32 vpp_wle;                    /* 0xa10 */
+       u32 vpp_ble;                    /* 0xa14 */
+};
+
 struct sunxi_de_be_reg {
        u8 res0[0x800];                 /* 0x000 */
        u32 mode;                       /* 0x800 */
@@ -209,6 +310,20 @@ struct sunxi_tve_reg {
        u32 cfg2;                       /* 0x13c */
 };
 
+/*
+ * DE-FE register constants.
+ */
+#define SUNXI_DE_FE_WIDTH(x)                   (((x) - 1) << 0)
+#define SUNXI_DE_FE_HEIGHT(y)                  (((y) - 1) << 16)
+#define SUNXI_DE_FE_FACTOR_INT(n)              ((n) << 16)
+#define SUNXI_DE_FE_ENABLE_EN                  (1 << 0)
+#define SUNXI_DE_FE_FRAME_CTRL_REG_RDY         (1 << 0)
+#define SUNXI_DE_FE_FRAME_CTRL_COEF_RDY                (1 << 1)
+#define SUNXI_DE_FE_FRAME_CTRL_FRM_START       (1 << 16)
+#define SUNXI_DE_FE_BYPASS_CSC_BYPASS          (1 << 1)
+#define SUNXI_DE_FE_INPUT_FMT_ARGB8888         0x00000151
+#define SUNXI_DE_FE_OUTPUT_FMT_ARGB8888                0x00000002
+
 /*
  * DE-BE register constants.
  */
@@ -219,6 +334,7 @@ struct sunxi_tve_reg {
 #define SUNXI_DE_BE_MODE_LAYER0_ENABLE         (1 << 8)
 #define SUNXI_DE_BE_LAYER_STRIDE(x)            ((x) << 5)
 #define SUNXI_DE_BE_REG_CTRL_LOAD_REGS         (1 << 0)
+#define SUNXI_DE_BE_LAYER_ATTR0_SRC_FE0                0x00000002
 #define SUNXI_DE_BE_LAYER_ATTR1_FMT_XRGB8888   (0x09 << 8)
 
 /*
@@ -249,9 +365,7 @@ struct sunxi_tve_reg {
 #define SUNXI_LCDC_TCON0_TIMING_V_TOTAL(n)     (((n) * 2) << 16)
 #define SUNXI_LCDC_TCON0_LVDS_INTF_BITWIDTH(n) ((n) << 26)
 #define SUNXI_LCDC_TCON0_LVDS_INTF_ENABLE      (1 << 31)
-#define SUNXI_LCDC_TCON0_IO_POL_DCLK_PHASE0    (0 << 28)
-#define SUNXI_LCDC_TCON0_IO_POL_DCLK_PHASE60   (1 << 28)
-#define SUNXI_LCDC_TCON0_IO_POL_DCLK_PHASE120  (2 << 28)
+#define SUNXI_LCDC_TCON0_IO_POL_DCLK_PHASE(x)  ((x) << 28)
 #define SUNXI_LCDC_TCON1_CTRL_CLK_DELAY(n)     (((n) & 0x1f) << 4)
 #define SUNXI_LCDC_TCON1_CTRL_ENABLE           (1 << 31)
 #define SUNXI_LCDC_TCON1_TIMING_H_BP(n)                (((n) - 1) << 0)
index 6c1ec5be8620e71f0343da7fa978cef5bb3922f6..40c385a5bc8025e5dc1ca48ffc441bf5440e5ffc 100644 (file)
@@ -76,7 +76,7 @@ struct dram_para {
        u32 cas;
        u32 zq;
        u32 odt_en;
-       u32 size;
+       u32 size; /* For compat with dram.c files from u-boot-sunxi, unused */
        u32 tpr0;
        u32 tpr1;
        u32 tpr2;
index 71cc879c2bb0ebf77e2dd7da5b7a6ee3b668ba12..f2c247d79fc7ee68de1bc32e3272c2da561b4965 100644 (file)
  *
  * sun8i has 1 bank:
  * PL0 - PL11
+ *
+ * sun9i has 3 banks:
+ * PL0 - PL9  | PM0 - PM15  | PN0 - PN1
  */
 #define SUNXI_GPIO_L   11
 #define SUNXI_GPIO_M   12
+#define SUNXI_GPIO_N   13
 
 struct sunxi_gpio {
        u32 cfg[4];
@@ -114,6 +118,7 @@ enum sunxi_gpio_number {
        SUNXI_GPIO_I_START = SUNXI_GPIO_NEXT(SUNXI_GPIO_H),
        SUNXI_GPIO_L_START = 352,
        SUNXI_GPIO_M_START = SUNXI_GPIO_NEXT(SUNXI_GPIO_L),
+       SUNXI_GPIO_N_START = SUNXI_GPIO_NEXT(SUNXI_GPIO_M),
        SUNXI_GPIO_AXP0_START = 1024,
 };
 
@@ -129,6 +134,7 @@ enum sunxi_gpio_number {
 #define SUNXI_GPI(_nr) (SUNXI_GPIO_I_START + (_nr))
 #define SUNXI_GPL(_nr) (SUNXI_GPIO_L_START + (_nr))
 #define SUNXI_GPM(_nr) (SUNXI_GPIO_M_START + (_nr))
+#define SUNXI_GPN(_nr) (SUNXI_GPIO_N_START + (_nr))
 
 #define SUNXI_GPAXP0(_nr)      (SUNXI_GPIO_AXP0_START + (_nr))
 
@@ -187,6 +193,9 @@ enum sunxi_gpio_number {
 #define SUN8I_GPL2_R_UART_TX   2
 #define SUN8I_GPL3_R_UART_RX   2
 
+#define SUN9I_GPN0_R_RSB_SCK   3
+#define SUN9I_GPN1_R_RSB_SDA    3
+
 /* GPIO pin pull-up/down config */
 #define SUNXI_GPIO_PULL_DISABLE        0
 #define SUNXI_GPIO_PULL_UP     1
index 537f1455643cc5ffae3d998599f3b941d2244568..74833b51d1285e12db5865946eb6a34526c645bf 100644 (file)
@@ -43,10 +43,11 @@ struct sunxi_mmc {
        u32 chda;               /* 0x90 */
        u32 cbda;               /* 0x94 */
        u32 res1[26];
-#if defined(CONFIG_MACH_SUN6I) || defined(CONFIG_MACH_SUN8I)
+#if defined(CONFIG_MACH_SUN6I) || defined(CONFIG_MACH_SUN8I) || \
+    defined(CONFIG_MACH_SUN9I)
        u32 res2[64];
 #endif
-       u32 fifo;               /* 0x100 (0x200 on sun6i) FIFO access address */
+       u32 fifo;               /* 0x100 / 0x200 FIFO access address */
 };
 
 #define SUNXI_MMC_CLK_POWERSAVE                (0x1 << 17)
@@ -123,5 +124,8 @@ struct sunxi_mmc {
 #define SUNXI_MMC_IDIE_TXIRQ           (0x1 << 0)
 #define SUNXI_MMC_IDIE_RXIRQ           (0x1 << 1)
 
+#define SUNXI_MMC_COMMON_CLK_GATE              (1 << 16)
+#define SUNXI_MMC_COMMON_RESET                 (1 << 18)
+
 struct mmc *sunxi_mmc_init(int sdc_no);
 #endif /* _SUNXI_MMC_H */
index 95a595ab8d418c6c9275eb0cf77399352a1ec1c5..a8934667c4c7b50b0af2aabc40cfec1703826440 100644 (file)
@@ -37,6 +37,7 @@ struct sunxi_rsb_reg {
 #define RSB_STAT_TERR_INT              (1 << 1)
 #define RSB_STAT_LBSY_INT              (1 << 2)
 
+#define RSB_DMCR_DEVICE_MODE_DATA      0x7c3e00
 #define RSB_DMCR_DEVICE_MODE_START     (1 << 31)
 
 #define RSB_CMD_BYTE_WRITE             0x4e
@@ -46,8 +47,7 @@ struct sunxi_rsb_reg {
 #define RSB_DEVADDR_RUNTIME_ADDR(x)    ((x) << 16)
 #define RSB_DEVADDR_DEVICE_ADDR(x)     ((x) << 0)
 
-void rsb_init(void);
-int rsb_set_device_mode(u32 device_mode_data);
+int rsb_init(void);
 int rsb_set_device_address(u16 device_addr, u16 runtime_addr);
 int rsb_write(const u16 runtime_device_addr, const u8 reg_addr, u8 data);
 int rsb_read(const u16 runtime_device_addr, const u8 reg_addr, u8 *data);
index 8d2097336c4288d64cef37fdde88fb5c653e2b7e..cb538cdc7d4c9f632279ead2505d4e1591e1c823 100644 (file)
@@ -11,6 +11,8 @@
  * SPDX-License-Identifier:    GPL-2.0+
  */
 
+extern const struct musb_platform_ops sunxi_musb_ops;
+
 void *sunxi_usbc_get_io_base(int index);
 int sunxi_usbc_request_resources(int index);
 int sunxi_usbc_free_resources(int index);
index 84e7b5553de16cb5ea8f5965079ec169d2459022..a20bdaa6187257a8fdd912d8e509e68ba27aac93 100644 (file)
@@ -10,6 +10,7 @@
 #define __TEGRA_MMC_H_
 
 #include <fdtdec.h>
+#include <asm/gpio.h>
 
 /* for mmc_config definition */
 #include <mmc.h>
@@ -134,9 +135,9 @@ struct mmc_host {
        int enabled;            /* 1 to enable, 0 to disable */
        int width;              /* Bus Width, 1, 4 or 8 */
        enum periph_id mmc_id;  /* Peripheral ID: PERIPH_ID_... */
-       struct fdt_gpio_state cd_gpio;          /* Change Detect GPIO */
-       struct fdt_gpio_state pwr_gpio;         /* Power GPIO */
-       struct fdt_gpio_state wp_gpio;          /* Write Protect GPIO */
+       struct gpio_desc cd_gpio;       /* Change Detect GPIO */
+       struct gpio_desc pwr_gpio;      /* Power GPIO */
+       struct gpio_desc wp_gpio;       /* Write Protect GPIO */
        unsigned int version;   /* SDHCI spec. version */
        unsigned int clock;     /* Current clock (MHz) */
        struct mmc_config cfg;  /* mmc configuration */
index a04c84e54b2251d54edbb017e216ded626c88bd4..6feeda3ba83ec42674f589f4dbd4fb1e3948774d 100644 (file)
@@ -10,6 +10,7 @@
 
 #include <asm/arch/dc.h>
 #include <fdtdec.h>
+#include <asm/gpio.h>
 
 /* This holds information about a window which can be displayed */
 struct disp_ctl_win {
@@ -72,10 +73,10 @@ struct fdt_panel_config {
        int pwm_channel;                /* PWM channel to use for backlight */
        enum lcd_cache_t cache_type;
 
-       struct fdt_gpio_state backlight_en;     /* GPIO for backlight enable */
-       struct fdt_gpio_state lvds_shutdown;    /* GPIO for lvds shutdown */
-       struct fdt_gpio_state backlight_vdd;    /* GPIO for backlight vdd */
-       struct fdt_gpio_state panel_vdd;        /* GPIO for panel vdd */
+       struct gpio_desc backlight_en;  /* GPIO for backlight enable */
+       struct gpio_desc lvds_shutdown; /* GPIO for lvds shutdown */
+       struct gpio_desc backlight_vdd; /* GPIO for backlight vdd */
+       struct gpio_desc panel_vdd;     /* GPIO for panel vdd */
        /*
         * Panel required timings
         * Timing 1: delay between panel_vdd-rise and data-rise
index 6987f5766960a7c4ab65f50973bf001f1f62d366..7a10f1c5b2c89db6a9f30f0552632cbf9c060f24 100644 (file)
@@ -8,7 +8,7 @@
 #ifndef _ASM_BOOT_DEVICE_H_
 #define _ASM_BOOT_DEVICE_H_
 
-u32 get_boot_mode_sel(void);
+int get_boot_mode_sel(void);
 
 struct boot_device_info {
        u32 type;
index 484559c6cd39936e86e56a29ff89bae514a2857f..6b7d600a9c624cab1c71f46659badb1db3a1aad0 100644 (file)
@@ -72,7 +72,7 @@ struct ddrphy {
                u32 gtr;        /* General Timing Register */
                u32 rsv[3];     /* Reserved */
        } dx[9];
-} __packed;
+};
 
 #endif /* __ASSEMBLY__ */
 
diff --git a/arch/arm/include/asm/arch-uniphier/gpio.h b/arch/arm/include/asm/arch-uniphier/gpio.h
deleted file mode 100644 (file)
index 1fc4e19..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-/*
- * Dummy header file to enable CONFIG_OF_CONTROL.
- * If CONFIG_OF_CONTROL is enabled, lib/fdtdec.c is compiled.
- * It includes <asm/arch/gpio.h> via <asm/gpio.h>, so those SoCs that enable
- * OF_CONTROL must have arch/gpio.h even if GPIO is not supported.
- */
index fa5e6ae0f2d822f3f559dcba42c53ad3282c4ff2..4ae67c8adb652f4b7afad39d144a861c3b9a661c 100644 (file)
 /* Memory Configuration */
 #define SG_MEMCONF                     (SG_CTRL_BASE | 0x0400)
 
-#define SG_MEMCONF_CH0_SIZE_64MB       ((0x0 << 10) | (0x01 << 0))
-#define SG_MEMCONF_CH0_SIZE_128MB      ((0x0 << 10) | (0x02 << 0))
-#define SG_MEMCONF_CH0_SIZE_256MB      ((0x0 << 10) | (0x03 << 0))
-#define SG_MEMCONF_CH0_SIZE_512MB      ((0x1 << 10) | (0x00 << 0))
-#define SG_MEMCONF_CH0_SIZE_1024MB     ((0x1 << 10) | (0x01 << 0))
+#define SG_MEMCONF_CH0_SZ_64M          ((0x0 << 10) | (0x01 << 0))
+#define SG_MEMCONF_CH0_SZ_128M         ((0x0 << 10) | (0x02 << 0))
+#define SG_MEMCONF_CH0_SZ_256M         ((0x0 << 10) | (0x03 << 0))
+#define SG_MEMCONF_CH0_SZ_512M         ((0x1 << 10) | (0x00 << 0))
+#define SG_MEMCONF_CH0_SZ_1G           ((0x1 << 10) | (0x01 << 0))
 #define SG_MEMCONF_CH0_NUM_1           (0x1 << 8)
 #define SG_MEMCONF_CH0_NUM_2           (0x0 << 8)
 
-#define SG_MEMCONF_CH1_SIZE_64MB       ((0x0 << 11) | (0x01 << 2))
-#define SG_MEMCONF_CH1_SIZE_128MB      ((0x0 << 11) | (0x02 << 2))
-#define SG_MEMCONF_CH1_SIZE_256MB      ((0x0 << 11) | (0x03 << 2))
-#define SG_MEMCONF_CH1_SIZE_512MB      ((0x1 << 11) | (0x00 << 2))
-#define SG_MEMCONF_CH1_SIZE_1024MB     ((0x1 << 11) | (0x01 << 2))
+#define SG_MEMCONF_CH1_SZ_64M          ((0x0 << 11) | (0x01 << 2))
+#define SG_MEMCONF_CH1_SZ_128M         ((0x0 << 11) | (0x02 << 2))
+#define SG_MEMCONF_CH1_SZ_256M         ((0x0 << 11) | (0x03 << 2))
+#define SG_MEMCONF_CH1_SZ_512M         ((0x1 << 11) | (0x00 << 2))
+#define SG_MEMCONF_CH1_SZ_1G           ((0x1 << 11) | (0x01 << 2))
 #define SG_MEMCONF_CH1_NUM_1           (0x1 << 9)
 #define SG_MEMCONF_CH1_NUM_2           (0x0 << 9)
 
+#define SG_MEMCONF_CH2_SZ_64M          ((0x0 << 26) | (0x01 << 16))
+#define SG_MEMCONF_CH2_SZ_128M         ((0x0 << 26) | (0x02 << 16))
+#define SG_MEMCONF_CH2_SZ_256M         ((0x0 << 26) | (0x03 << 16))
+#define SG_MEMCONF_CH2_SZ_512M         ((0x1 << 26) | (0x00 << 16))
+#define SG_MEMCONF_CH2_NUM_1           (0x1 << 24)
+#define SG_MEMCONF_CH2_NUM_2           (0x0 << 24)
+
 #define SG_MEMCONF_SPARSEMEM           (0x1 << 4)
 
 /* Pin Control */
 #else
 
 #include <linux/types.h>
+#include <linux/sizes.h>
 #include <asm/io.h>
 
 static inline void sg_set_pinsel(int n, int value)
@@ -111,24 +119,24 @@ static inline void sg_set_pinsel(int n, int value)
 
 static inline u32 sg_memconf_val_ch0(unsigned long size, int num)
 {
-       int size_mb = (size >> 20) / num;
+       int size_mb = size / num;
        u32 ret;
 
        switch (size_mb) {
-       case 64:
-               ret = SG_MEMCONF_CH0_SIZE_64MB;
+       case SZ_64M:
+               ret = SG_MEMCONF_CH0_SZ_64M;
                break;
-       case 128:
-               ret = SG_MEMCONF_CH0_SIZE_128MB;
+       case SZ_128M:
+               ret = SG_MEMCONF_CH0_SZ_128M;
                break;
-       case 256:
-               ret = SG_MEMCONF_CH0_SIZE_256MB;
+       case SZ_256M:
+               ret = SG_MEMCONF_CH0_SZ_256M;
                break;
-       case 512:
-               ret = SG_MEMCONF_CH0_SIZE_512MB;
+       case SZ_512M:
+               ret = SG_MEMCONF_CH0_SZ_512M;
                break;
-       case 1024:
-               ret = SG_MEMCONF_CH0_SIZE_1024MB;
+       case SZ_1G:
+               ret = SG_MEMCONF_CH0_SZ_1G;
                break;
        default:
                BUG();
@@ -151,24 +159,24 @@ static inline u32 sg_memconf_val_ch0(unsigned long size, int num)
 
 static inline u32 sg_memconf_val_ch1(unsigned long size, int num)
 {
-       int size_mb = (size >> 20) / num;
+       int size_mb = size / num;
        u32 ret;
 
        switch (size_mb) {
-       case 64:
-               ret = SG_MEMCONF_CH1_SIZE_64MB;
+       case SZ_64M:
+               ret = SG_MEMCONF_CH1_SZ_64M;
                break;
-       case 128:
-               ret = SG_MEMCONF_CH1_SIZE_128MB;
+       case SZ_128M:
+               ret = SG_MEMCONF_CH1_SZ_128M;
                break;
-       case 256:
-               ret = SG_MEMCONF_CH1_SIZE_256MB;
+       case SZ_256M:
+               ret = SG_MEMCONF_CH1_SZ_256M;
                break;
-       case 512:
-               ret = SG_MEMCONF_CH1_SIZE_512MB;
+       case SZ_512M:
+               ret = SG_MEMCONF_CH1_SZ_512M;
                break;
-       case 1024:
-               ret = SG_MEMCONF_CH1_SIZE_1024MB;
+       case SZ_1G:
+               ret = SG_MEMCONF_CH1_SZ_1G;
                break;
        default:
                BUG();
@@ -188,6 +196,43 @@ static inline u32 sg_memconf_val_ch1(unsigned long size, int num)
        }
        return ret;
 }
+
+static inline u32 sg_memconf_val_ch2(unsigned long size, int num)
+{
+       int size_mb = size / num;
+       u32 ret;
+
+       switch (size_mb) {
+       case SZ_64M:
+               ret = SG_MEMCONF_CH2_SZ_64M;
+               break;
+       case SZ_128M:
+               ret = SG_MEMCONF_CH2_SZ_128M;
+               break;
+       case SZ_256M:
+               ret = SG_MEMCONF_CH2_SZ_256M;
+               break;
+       case SZ_512M:
+               ret = SG_MEMCONF_CH2_SZ_512M;
+               break;
+       default:
+               BUG();
+               break;
+       }
+
+       switch (num) {
+       case 1:
+               ret |= SG_MEMCONF_CH2_NUM_1;
+               break;
+       case 2:
+               ret |= SG_MEMCONF_CH2_NUM_2;
+               break;
+       default:
+               BUG();
+               break;
+       }
+       return ret;
+}
 #endif /* __ASSEMBLY__ */
 
 #endif /* ARCH_SG_REGS_H */
index 2dbba756d737f6674ed050edad6bd212ffefb65b..a26ae872933ef1ad8309e3bac55d76637cd3edc2 100644 (file)
@@ -7,19 +7,4 @@
 #ifndef _ZYNQ_GPIO_H
 #define _ZYNQ_GPIO_H
 
-inline int gpio_get_value(unsigned gpio)
-{
-       return 0;
-}
-
-inline int gpio_set_value(unsigned gpio, int val)
-{
-       return 0;
-}
-
-inline int gpio_request(unsigned gpio, const char *label)
-{
-       return 0;
-}
-
 #endif /* _ZYNQ_GPIO_H */
index 2aede0c552c62a4956028afd36a03ce411d5d55b..e2e0b7321ad44e3eeb22116ae449be1e008d1c34 100644 (file)
@@ -21,6 +21,9 @@
 #define ZYNQ_I2C_BASEADDR1             0xE0005000
 #define ZYNQ_SPI_BASEADDR0             0xE0006000
 #define ZYNQ_SPI_BASEADDR1             0xE0007000
+#define ZYNQ_QSPI_BASEADDR             0xE000D000
+#define ZYNQ_SMC_BASEADDR              0xE000E000
+#define ZYNQ_NAND_BASEADDR             0xE1000000
 #define ZYNQ_DDRC_BASEADDR             0xF8006000
 #define ZYNQ_EFUSE_BASEADDR            0xF800D000
 #define ZYNQ_USB_BASEADDR0             0xE0002000
@@ -28,7 +31,9 @@
 
 /* Bootmode setting values */
 #define ZYNQ_BM_MASK           0x7
+#define ZYNQ_BM_QSPI           0x1
 #define ZYNQ_BM_NOR            0x2
+#define ZYNQ_BM_NAND           0x4
 #define ZYNQ_BM_SD             0x5
 #define ZYNQ_BM_JTAG           0x0
 
index 89c47f3bd3fa2b87bbea973515b61c8e185ae806..9d50e2478f619c2b7d59506e7e6fda64bfc0bc2a 100644 (file)
@@ -20,7 +20,7 @@ extern void zynq_ddrc_init(void);
 extern unsigned int zynq_get_silicon_version(void);
 
 /* Driver extern functions */
-extern int zynq_sdhci_init(u32 regbase);
+extern int zynq_sdhci_init(phys_addr_t regbase);
 extern int zynq_sdhci_of_init(const void *blob);
 
 extern void ps7_init(void);
index f97f3dd1496aa54f7ca0667d0ebea299c95d50e7..414042d4039b52b626eeae689b0b5a0e31d59fc5 100644 (file)
@@ -36,7 +36,6 @@ int   arch_early_init_r(void);
 
 /* board/.../... */
 int    board_init(void);
-int    dram_init (void);
 void   dram_init_banksize (void);
 
 /* cpu/.../interrupt.c */
index 9cedeac6d641eb7b8548fb8571bcd6a261388fdb..74cfde637c1c433f3f834cdfbdac48b05ff78b6a 100644 (file)
@@ -25,10 +25,12 @@ __weak void flush_cache(unsigned long start, unsigned long size)
 #endif /* CONFIG_CPU_ARM1136 */
 
 #ifdef CONFIG_CPU_ARM926EJS
+#if !(defined(CONFIG_SYS_ICACHE_OFF) && defined(CONFIG_SYS_DCACHE_OFF))
        /* test and clean, page 2-23 of arm926ejs manual */
        asm("0: mrc p15, 0, r15, c7, c10, 3\n\t" "bne 0b\n" : : : "memory");
        /* disable write buffer as well (page 2-22) */
        asm("mcr p15, 0, %0, c7, c10, 4" : : "r" (0));
+#endif
 #endif /* CONFIG_CPU_ARM926EJS */
        return;
 }
index dfcc596815432b4357114f6aef01b11a66596e04..c41850aaeee533a927042d54abd0202f41b2d561 100644 (file)
 
 /* Pointer to as well as the global data structure for SPL */
 DECLARE_GLOBAL_DATA_PTR;
+
+/*
+ * WARNING: This is going away very soon. Don't use it and don't submit
+ * pafches that rely on it. The global_data area is set up in crt0.S.
+ */
 gd_t gdata __attribute__ ((section(".data")));
 
 /*
@@ -28,7 +33,7 @@ void __weak board_init_f(ulong dummy)
        /* Clear the BSS. */
        memset(__bss_start, 0, __bss_end - __bss_start);
 
-       /* Set global data pointer. */
+       /* TODO: Remove settings of the global data pointer here */
        gd = &gdata;
 
        board_init_r(NULL, 0);
index 9dcab6958c5de92c03fc8d6d189ac7a110d1fa6e..de243feaab51e1a2c86b4ebb15b5f8c5ef55d8fc 100644 (file)
@@ -10,3 +10,5 @@ obj-y = dram.o
 obj-y  += gpio.o
 obj-$(CONFIG_ARMADA_XP) += mbus.o
 obj-y  += timer.o
+
+obj-y  += serdes/
diff --git a/arch/arm/mvebu-common/serdes/Makefile b/arch/arm/mvebu-common/serdes/Makefile
new file mode 100644 (file)
index 0000000..a380fee
--- /dev/null
@@ -0,0 +1,6 @@
+#
+# SPDX-License-Identifier:     GPL-2.0+
+#
+
+obj-$(CONFIG_SPL_BUILD)        = high_speed_env_lib.o
+obj-$(CONFIG_SPL_BUILD)        += high_speed_env_spec.o
diff --git a/arch/arm/mvebu-common/serdes/board_env_spec.h b/arch/arm/mvebu-common/serdes/board_env_spec.h
new file mode 100644 (file)
index 0000000..36e0ed8
--- /dev/null
@@ -0,0 +1,262 @@
+/*
+ * Copyright (C) Marvell International Ltd. and its affiliates
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#ifndef __BOARD_ENV_SPEC
+#define __BOARD_ENV_SPEC
+
+/* Board specific configuration */
+
+/* KW40 */
+#define MV_6710_DEV_ID                 0x6710
+
+#define MV_6710_Z1_REV                 0x0
+#define MV_6710_Z1_ID                  ((MV_6710_DEV_ID << 16) | MV_6710_Z1_REV)
+#define MV_6710_Z1_NAME                        "MV6710 Z1"
+
+/* Armada XP Family */
+#define MV_78130_DEV_ID                        0x7813
+#define MV_78160_DEV_ID                        0x7816
+#define MV_78230_DEV_ID                        0x7823
+#define MV_78260_DEV_ID                        0x7826
+#define MV_78460_DEV_ID                        0x7846
+#define MV_78000_DEV_ID                        0x7888
+
+#define MV_FPGA_DEV_ID                 0x2107
+
+#define MV_78XX0_Z1_REV                        0x0
+
+/* boards ID numbers */
+#define BOARD_ID_BASE                  0x0
+
+/* New board ID numbers */
+#define DB_88F78XX0_BP_ID              (BOARD_ID_BASE)
+#define RD_78460_SERVER_ID             (DB_88F78XX0_BP_ID + 1)
+#define DB_78X60_PCAC_ID               (RD_78460_SERVER_ID + 1)
+#define FPGA_88F78XX0_ID               (DB_78X60_PCAC_ID + 1)
+#define DB_88F78XX0_BP_REV2_ID         (FPGA_88F78XX0_ID + 1)
+#define RD_78460_NAS_ID                        (DB_88F78XX0_BP_REV2_ID + 1)
+#define DB_78X60_AMC_ID                        (RD_78460_NAS_ID + 1)
+#define DB_78X60_PCAC_REV2_ID          (DB_78X60_AMC_ID + 1)
+#define RD_78460_SERVER_REV2_ID                (DB_78X60_PCAC_REV2_ID + 1)
+#define DB_784MP_GP_ID                 (RD_78460_SERVER_REV2_ID + 1)
+#define RD_78460_CUSTOMER_ID           (DB_784MP_GP_ID + 1)
+#define MV_MAX_BOARD_ID                        (RD_78460_CUSTOMER_ID + 1)
+#define INVALID_BAORD_ID               0xFFFFFFFF
+
+/* Sample at Reset */
+#define MPP_SAMPLE_AT_RESET(id)                (0x18230 + (id * 4))
+
+/* BIOS Modes related defines */
+
+#define SAR0_BOOTWIDTH_OFFSET          3
+#define SAR0_BOOTWIDTH_MASK            (0x3 << SAR0_BOOTWIDTH_OFFSET)
+#define SAR0_BOOTSRC_OFFSET            5
+#define SAR0_BOOTSRC_MASK              (0xF << SAR0_BOOTSRC_OFFSET)
+
+#define SAR0_L2_SIZE_OFFSET            19
+#define SAR0_L2_SIZE_MASK              (0x3 << SAR0_L2_SIZE_OFFSET)
+#define SAR0_CPU_FREQ_OFFSET           21
+#define SAR0_CPU_FREQ_MASK             (0x7 << SAR0_CPU_FREQ_OFFSET)
+#define SAR0_FABRIC_FREQ_OFFSET                24
+#define SAR0_FABRIC_FREQ_MASK          (0xF << SAR0_FABRIC_FREQ_OFFSET)
+#define SAR0_CPU0CORE_OFFSET           31
+#define SAR0_CPU0CORE_MASK             (0x1 << SAR0_CPU0CORE_OFFSET)
+#define SAR1_CPU0CORE_OFFSET           0
+#define SAR1_CPU0CORE_MASK             (0x1 << SAR1_CPU0CORE_OFFSET)
+
+#define PEX_CLK_100MHZ_OFFSET          2
+#define PEX_CLK_100MHZ_MASK            (0x1 << PEX_CLK_100MHZ_OFFSET)
+
+#define SAR1_FABRIC_MODE_OFFSET                19
+#define SAR1_FABRIC_MODE_MASK          (0x1 << SAR1_FABRIC_MODE_OFFSET)
+#define SAR1_CPU_MODE_OFFSET           20
+#define SAR1_CPU_MODE_MASK             (0x1 << SAR1_CPU_MODE_OFFSET)
+
+#define SAR_CPU_FAB_GET(cpu, fab)      (((cpu & 0x7) << 21) | ((fab & 0xF) << 24))
+
+
+#define CORE_AVS_CONTROL_0REG          0x18300
+#define CORE_AVS_CONTROL_2REG          0x18308
+#define CPU_AVS_CONTROL2_REG           0x20868
+#define CPU_AVS_CONTROL0_REG           0x20860
+#define GENERAL_PURPOSE_RESERVED0_REG  0x182E0
+
+#define MSAR_TCLK_OFFS                 28
+#define MSAR_TCLK_MASK                 (0x1 << MSAR_TCLK_OFFS)
+
+
+/* Controler environment registers offsets */
+#define GEN_PURP_RES_1_REG             0x182F4
+#define GEN_PURP_RES_2_REG             0x182F8
+
+/* registers offsets */
+#define MV_GPP_REGS_OFFSET(unit)       (0x18100 + ((unit) * 0x40))
+#define MPP_CONTROL_REG(id)            (0x18000 + (id * 4))
+#define MV_GPP_REGS_BASE(unit)         (MV_GPP_REGS_OFFSET(unit))
+#define MV_GPP_REGS_BASE_0             (MV_GPP_REGS_OFFSET_0)
+
+#define GPP_DATA_OUT_REG(grp)          (MV_GPP_REGS_BASE(grp) + 0x00)
+#define GPP_DATA_OUT_REG_0             (MV_GPP_REGS_BASE_0 + 0x00)     /* Used in .S files */
+#define GPP_DATA_OUT_EN_REG(grp)       (MV_GPP_REGS_BASE(grp) + 0x04)
+#define GPP_BLINK_EN_REG(grp)          (MV_GPP_REGS_BASE(grp) + 0x08)
+#define GPP_DATA_IN_POL_REG(grp)       (MV_GPP_REGS_BASE(grp) + 0x0C)
+#define GPP_DATA_IN_REG(grp)           (MV_GPP_REGS_BASE(grp) + 0x10)
+#define GPP_INT_CAUSE_REG(grp)         (MV_GPP_REGS_BASE(grp) + 0x14)
+#define GPP_INT_MASK_REG(grp)          (MV_GPP_REGS_BASE(grp) + 0x18)
+#define GPP_INT_LVL_REG(grp)           (MV_GPP_REGS_BASE(grp) + 0x1C)
+#define GPP_OUT_SET_REG(grp)           (0x18130 + ((grp) * 0x40))
+#define GPP_64_66_DATA_OUT_SET_REG     0x181A4
+#define GPP_OUT_CLEAR_REG(grp)         (0x18134 + ((grp) * 0x40))
+#define GPP_64_66_DATA_OUT_CLEAR_REG   0x181B0
+#define GPP_FUNC_SELECT_REG            (MV_GPP_REGS_BASE(0) + 0x40)
+
+#define MV_GPP66                       (1 << 2)
+
+/* Relevant for MV78XX0 */
+#define GPP_DATA_OUT_SET_REG           (MV_GPP_REGS_BASE(0) + 0x20)
+#define GPP_DATA_OUT_CLEAR_REG         (MV_GPP_REGS_BASE(0) + 0x24)
+
+/* This define describes the maximum number of supported PEX Interfaces */
+#define MV_PEX_MAX_IF                  10
+#define MV_PEX_MAX_UNIT                        4
+
+#define MV_SERDES_NUM_TO_PEX_NUM(num)  ((num < 8) ? (num) : (8 + (num / 12)))
+
+#define PEX_PHY_ACCESS_REG(unit)       (0x40000 + ((unit) % 2 * 0x40000) + \
+                                        ((unit)/2 * 0x2000) + 0x1B00)
+
+#define SATA_BASE_REG(port)            (0xA2000 + (port)*0x2000)
+
+#define SATA_PWR_PLL_CTRL_REG(port)    (SATA_BASE_REG(port) + 0x804)
+#define SATA_DIG_LP_ENA_REG(port)      (SATA_BASE_REG(port) + 0x88C)
+#define SATA_REF_CLK_SEL_REG(port)     (SATA_BASE_REG(port) + 0x918)
+#define SATA_COMPHY_CTRL_REG(port)     (SATA_BASE_REG(port) + 0x920)
+#define SATA_LP_PHY_EXT_CTRL_REG(port) (SATA_BASE_REG(port) + 0x058)
+#define SATA_LP_PHY_EXT_STAT_REG(port) (SATA_BASE_REG(port) + 0x05C)
+#define SATA_IMP_TX_SSC_CTRL_REG(port) (SATA_BASE_REG(port) + 0x810)
+#define SATA_GEN_1_SET_0_REG(port)     (SATA_BASE_REG(port) + 0x834)
+#define SATA_GEN_1_SET_1_REG(port)     (SATA_BASE_REG(port) + 0x838)
+#define SATA_GEN_2_SET_0_REG(port)     (SATA_BASE_REG(port) + 0x83C)
+#define SATA_GEN_2_SET_1_REG(port)     (SATA_BASE_REG(port) + 0x840)
+
+#define MV_ETH_BASE_ADDR               (0x72000)
+#define MV_ETH_REGS_OFFSET(port)       (MV_ETH_BASE_ADDR - ((port) / 2) * \
+                                        0x40000 + ((port) % 2) * 0x4000)
+#define MV_ETH_REGS_BASE(port)         MV_ETH_REGS_OFFSET(port)
+
+
+#define SGMII_PWR_PLL_CTRL_REG(port)   (MV_ETH_REGS_BASE(port) + 0xE04)
+#define SGMII_DIG_LP_ENA_REG(port)     (MV_ETH_REGS_BASE(port) + 0xE8C)
+#define SGMII_REF_CLK_SEL_REG(port)    (MV_ETH_REGS_BASE(port) + 0xF18)
+#define SGMII_SERDES_CFG_REG(port)     (MV_ETH_REGS_BASE(port) + 0x4A0)
+#define SGMII_SERDES_STAT_REG(port)    (MV_ETH_REGS_BASE(port) + 0x4A4)
+#define SGMII_COMPHY_CTRL_REG(port)    (MV_ETH_REGS_BASE(port) + 0xF20)
+#define QSGMII_GEN_1_SETTING_REG(port) (MV_ETH_REGS_BASE(port) + 0xE38)
+#define QSGMII_SERDES_CFG_REG(port)    (MV_ETH_REGS_BASE(port) + 0x4a0)
+
+#define SERDES_LINE_MUX_REG_0_7                0x18270
+#define SERDES_LINE_MUX_REG_8_15       0x18274
+#define QSGMII_CONTROL_1_REG           0x18404
+
+/* SOC_CTRL_REG fields */
+#define SCR_PEX_ENA_OFFS(pex)          ((pex) & 0x3)
+#define SCR_PEX_ENA_MASK(pex)          (1 << pex)
+
+#define PCIE0_QUADX1_EN                        (1<<7)
+#define PCIE1_QUADX1_EN                        (1<<8)
+
+#define SCR_PEX_4BY1_OFFS(pex)         ((pex) + 7)
+#define SCR_PEX_4BY1_MASK(pex)         (1 << SCR_PEX_4BY1_OFFS(pex))
+
+#define PCIE1_CLK_OUT_EN_OFF           5
+#define PCIE1_CLK_OUT_EN_MASK          (1 << PCIE1_CLK_OUT_EN_OFF)
+
+#define PCIE0_CLK_OUT_EN_OFF           4
+#define PCIE0_CLK_OUT_EN_MASK          (1 << PCIE0_CLK_OUT_EN_OFF)
+
+#define SCR_PEX0_4BY1_OFFS             7
+#define SCR_PEX0_4BY1_MASK             (1 << SCR_PEX0_4BY1_OFFS)
+
+#define SCR_PEX1_4BY1_OFFS             8
+#define SCR_PEX1_4BY1_MASK             (1 << SCR_PEX1_4BY1_OFFS)
+
+
+#define MV_MISC_REGS_OFFSET            (0x18200)
+#define MV_MISC_REGS_BASE              (MV_MISC_REGS_OFFSET)
+#define SOC_CTRL_REG                   (MV_MISC_REGS_BASE + 0x4)
+
+/*
+ * PCI Express Control and Status Registers
+ */
+#define MAX_PEX_DEVICES                        32
+#define MAX_PEX_FUNCS                  8
+#define MAX_PEX_BUSSES                 256
+
+#define PXSR_PEX_BUS_NUM_OFFS          8       /* Bus Number Indication */
+#define PXSR_PEX_BUS_NUM_MASK          (0xff << PXSR_PEX_BUS_NUM_OFFS)
+
+#define PXSR_PEX_DEV_NUM_OFFS          16      /* Device Number Indication */
+#define PXSR_PEX_DEV_NUM_MASK          (0x1f << PXSR_PEX_DEV_NUM_OFFS)
+
+#define PXSR_DL_DOWN                   0x1     /* DL_Down indication. */
+#define PXCAR_CONFIG_EN                        (1 << 31)
+#define PEX_STATUS_AND_COMMAND         0x004
+#define PXSAC_MABORT                   (1 << 29) /* Recieved Master Abort */
+
+/* PCI Express Configuration Address Register */
+
+/* PEX_CFG_ADDR_REG (PXCAR) */
+#define PXCAR_REG_NUM_OFFS             2
+#define PXCAR_REG_NUM_MAX              0x3F
+#define PXCAR_REG_NUM_MASK             (PXCAR_REG_NUM_MAX << PXCAR_REG_NUM_OFFS)
+#define PXCAR_FUNC_NUM_OFFS            8
+#define PXCAR_FUNC_NUM_MAX             0x7
+#define PXCAR_FUNC_NUM_MASK            (PXCAR_FUNC_NUM_MAX << PXCAR_FUNC_NUM_OFFS)
+#define PXCAR_DEVICE_NUM_OFFS          11
+#define PXCAR_DEVICE_NUM_MAX           0x1F
+#define PXCAR_DEVICE_NUM_MASK          (PXCAR_DEVICE_NUM_MAX << PXCAR_DEVICE_NUM_OFFS)
+#define PXCAR_BUS_NUM_OFFS             16
+#define PXCAR_BUS_NUM_MAX              0xFF
+#define PXCAR_BUS_NUM_MASK             (PXCAR_BUS_NUM_MAX << PXCAR_BUS_NUM_OFFS)
+#define PXCAR_EXT_REG_NUM_OFFS         24
+#define PXCAR_EXT_REG_NUM_MAX          0xF
+
+#define PXCAR_REAL_EXT_REG_NUM_OFFS     8
+#define PXCAR_REAL_EXT_REG_NUM_MASK     (0xF << PXCAR_REAL_EXT_REG_NUM_OFFS)
+
+
+#define PEX_CAPABILITIES_REG(if)       ((MV_PEX_IF_REGS_BASE(if)) + 0x60)
+#define PEX_LINK_CAPABILITIES_REG(if)  ((MV_PEX_IF_REGS_BASE(if)) + 0x6C)
+#define PEX_LINK_CTRL_STATUS_REG(if)   ((MV_PEX_IF_REGS_BASE(if)) + 0x70)
+#define PEX_LINK_CTRL_STATUS2_REG(if)  ((MV_PEX_IF_REGS_BASE(if)) + 0x90)
+#define PEX_CTRL_REG(if)               ((MV_PEX_IF_REGS_BASE(if)) + 0x1A00)
+#define PEX_STATUS_REG(if)             ((MV_PEX_IF_REGS_BASE(if)) + 0x1A04)
+#define PEX_COMPLT_TMEOUT_REG(if)      ((MV_PEX_IF_REGS_BASE(if)) + 0x1A10)
+#define PEX_PWR_MNG_EXT_REG(if)                ((MV_PEX_IF_REGS_BASE(if)) + 0x1A18)
+#define PEX_FLOW_CTRL_REG(if)          ((MV_PEX_IF_REGS_BASE(if)) + 0x1A20)
+#define PEX_DYNMC_WIDTH_MNG_REG(if)    ((MV_PEX_IF_REGS_BASE(if)) + 0x1A30)
+#define PEX_ROOT_CMPLX_SSPL_REG(if)    ((MV_PEX_IF_REGS_BASE(if)) + 0x1A0C)
+#define PEX_RAM_PARITY_CTRL_REG(if)    ((MV_PEX_IF_REGS_BASE(if)) + 0x1A50)
+#define PEX_DBG_CTRL_REG(if)           ((MV_PEX_IF_REGS_BASE(if)) + 0x1A60)
+#define PEX_DBG_STATUS_REG(if)         ((MV_PEX_IF_REGS_BASE(if)) + 0x1A64)
+
+#define PXLCSR_NEG_LNK_GEN_OFFS                16      /* Negotiated Link GEN */
+#define PXLCSR_NEG_LNK_GEN_MASK                (0xf << PXLCSR_NEG_LNK_GEN_OFFS)
+#define PXLCSR_NEG_LNK_GEN_1_1         (0x1 << PXLCSR_NEG_LNK_GEN_OFFS)
+#define PXLCSR_NEG_LNK_GEN_2_0         (0x2 << PXLCSR_NEG_LNK_GEN_OFFS)
+
+#define PEX_CFG_ADDR_REG(if)           ((MV_PEX_IF_REGS_BASE(if)) + 0x18F8)
+#define PEX_CFG_DATA_REG(if)           ((MV_PEX_IF_REGS_BASE(if)) + 0x18FC)
+#define PEX_CAUSE_REG(if)              ((MV_PEX_IF_REGS_BASE(if)) + 0x1900)
+
+#define PEX_CAPABILITY_REG             0x60
+#define PEX_DEV_CAPABILITY_REG         0x64
+#define PEX_DEV_CTRL_STAT_REG          0x68
+#define PEX_LINK_CAPABILITY_REG                0x6C
+#define PEX_LINK_CTRL_STAT_REG         0x70
+#define PEX_LINK_CTRL_STAT_2_REG       0x90
+
+#endif /* __BOARD_ENV_SPEC */
diff --git a/arch/arm/mvebu-common/serdes/high_speed_env_lib.c b/arch/arm/mvebu-common/serdes/high_speed_env_lib.c
new file mode 100644 (file)
index 0000000..702273a
--- /dev/null
@@ -0,0 +1,1572 @@
+/*
+ * Copyright (C) Marvell International Ltd. and its affiliates
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#include <common.h>
+#include <i2c.h>
+#include <spl.h>
+#include <asm/io.h>
+#include <asm/arch/cpu.h>
+#include <asm/arch/soc.h>
+
+#include "high_speed_env_spec.h"
+#include "board_env_spec.h"
+
+#define        SERDES_VERION   "2.1.5"
+#define ENDED_OK       "High speed PHY - Ended Successfully\n"
+
+static const u8 serdes_cfg[][SERDES_LAST_UNIT] = BIN_SERDES_CFG;
+
+extern MV_BIN_SERDES_CFG *serdes_info_tbl[];
+
+extern u8 rd78460gp_twsi_dev[];
+extern u8 db88f78xx0rev2_twsi_dev[];
+
+u32 pex_cfg_read(u32 pex_if, u32 bus, u32 dev, u32 func, u32 offs);
+int pex_local_bus_num_set(u32 pex_if, u32 bus_num);
+int pex_local_dev_num_set(u32 pex_if, u32 dev_num);
+
+#define MV_BOARD_PEX_MODULE_ADDR               0x23
+#define MV_BOARD_PEX_MODULE_ID                 1
+#define MV_BOARD_ETM_MODULE_ID                 2
+
+#define        PEX_MODULE_DETECT               1
+#define        ETM_MODULE_DETECT               2
+
+#define PEX_MODE_GET(satr)             ((satr & 0x6) >> 1)
+#define PEX_CAPABILITY_GET(satr)       (satr & 1)
+#define MV_PEX_UNIT_TO_IF(pex_unit)    ((pex_unit < 3) ? (pex_unit * 4) : 9)
+
+/* Static parametes */
+static int config_module;
+static int switch_module;
+
+/* Local function */
+static u32 board_id_get(void)
+{
+#if defined(CONFIG_DB_88F78X60)
+       return DB_88F78XX0_BP_ID;
+#elif defined(CONFIG_RD_88F78460_SERVER)
+       return RD_78460_SERVER_ID;
+#elif defined(CONFIG_RD_78460_SERVER_REV2)
+       return RD_78460_SERVER_REV2_ID;
+#elif defined(CONFIG_DB_78X60_PCAC)
+       return DB_78X60_PCAC_ID;
+#elif defined(CONFIG_DB_88F78X60_REV2)
+       return DB_88F78XX0_BP_REV2_ID;
+#elif defined(CONFIG_RD_78460_NAS)
+       return RD_78460_NAS_ID;
+#elif defined(CONFIG_DB_78X60_AMC)
+       return DB_78X60_AMC_ID;
+#elif defined(CONFIG_DB_78X60_PCAC_REV2)
+       return DB_78X60_PCAC_REV2_ID;
+#elif defined(CONFIG_DB_784MP_GP)
+       return DB_784MP_GP_ID;
+#elif defined(CONFIG_RD_78460_CUSTOMER)
+       return RD_78460_CUSTOMER_ID;
+#else
+       /*
+        * Return 0 here for custom board as this should not be used
+        * for custom boards.
+        */
+       return 0;
+#endif
+}
+
+static u8 board_sat_r_get(u8 dev_num, u8 reg)
+{
+       u8 data;
+       u8 *dev;
+       u32 board_id = board_id_get();
+       int ret;
+
+       i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
+
+       switch (board_id) {
+       case DB_784MP_GP_ID:
+               dev = rd78460gp_twsi_dev;
+
+               break;
+       case DB_88F78XX0_BP_ID:
+       case DB_88F78XX0_BP_REV2_ID:
+               dev = db88f78xx0rev2_twsi_dev;
+               break;
+
+       case DB_78X60_PCAC_ID:
+       case FPGA_88F78XX0_ID:
+       case DB_78X60_PCAC_REV2_ID:
+       case RD_78460_SERVER_REV2_ID:
+       default:
+               return 0;
+       }
+
+       /* Read MPP module ID */
+       ret = i2c_read(dev[dev_num], 0, 1, (u8 *)&data, 1);
+       if (ret)
+               return MV_ERROR;
+
+       return data;
+}
+
+static int board_modules_scan(void)
+{
+       u8 val;
+       u32 board_id = board_id_get();
+       int ret;
+
+       /* Perform scan only for DB board */
+       if ((board_id == DB_88F78XX0_BP_ID) ||
+           (board_id == DB_88F78XX0_BP_REV2_ID)) {
+               /* reset modules flags */
+               config_module = 0;
+
+               i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
+
+               /* SERDES module (only PEX model is supported now) */
+               ret = i2c_read(MV_BOARD_PEX_MODULE_ADDR, 0, 1, (u8 *)&val, 1);
+               if (ret)
+                       return MV_ERROR;
+
+               if (val == MV_BOARD_PEX_MODULE_ID)
+                       config_module = PEX_MODULE_DETECT;
+               if (val == MV_BOARD_ETM_MODULE_ID)
+                       config_module = ETM_MODULE_DETECT;
+       } else if (board_id == RD_78460_NAS_ID) {
+               switch_module = 0;
+               if ((reg_read(GPP_DATA_IN_REG(2)) & MV_GPP66) == 0x0)
+                       switch_module = 1;
+       }
+
+       return MV_OK;
+}
+
+u32 pex_max_unit_get(void)
+{
+       /*
+        * TODO:
+        * Right now only MV78460 is supported. Other SoC's might need
+        * a different value here.
+        */
+       return MV_PEX_MAX_UNIT;
+}
+
+u32 pex_max_if_get(void)
+{
+       /*
+        * TODO:
+        * Right now only MV78460 is supported. Other SoC's might need
+        * a different value here.
+        */
+       return MV_PEX_MAX_IF;
+}
+
+u8 board_cpu_freq_get(void)
+{
+       u32 sar;
+       u32 sar_msb;
+
+       sar = reg_read(MPP_SAMPLE_AT_RESET(0));
+       sar_msb = reg_read(MPP_SAMPLE_AT_RESET(1));
+       return ((sar_msb & 0x100000) >> 17) | ((sar & 0xe00000) >> 21);
+}
+
+__weak MV_BIN_SERDES_CFG *board_serdes_cfg_get(u8 pex_mode)
+{
+       u32 board_id;
+       u32 serdes_cfg_val = 0; /* default */
+
+       board_id = board_id_get();
+
+       switch (board_id) {
+       case DB_784MP_GP_ID:
+               serdes_cfg_val = 0;
+               break;
+       }
+
+       return &serdes_info_tbl[board_id - BOARD_ID_BASE][serdes_cfg_val];
+}
+
+u16 ctrl_model_get(void)
+{
+       /* Right now only MV78460 supported */
+       return MV_78460_DEV_ID;
+}
+
+u32 get_line_cfg(u32 line_num, MV_BIN_SERDES_CFG *info)
+{
+       if (line_num < 8)
+               return (info->line0_7 >> (line_num << 2)) & 0xF;
+       else
+               return (info->line8_15 >> ((line_num - 8) << 2)) & 0xF;
+}
+
+int serdes_phy_config(void)
+{
+       int status = MV_OK;
+       u32 line_cfg;
+       u8 line_num;
+       /* addr/value for each line @ every setup step */
+       u32 addr[16][11], val[16][11];
+       u8 pex_unit, pex_line_num;
+       u8 sgmii_port = 0;
+       u32 tmp;
+       u32 in_direct;
+       u8 max_serdes_lines;
+       MV_BIN_SERDES_CFG *info;
+       u8 satr11;
+       u8 sata_port;
+       u8 freq;
+       u8 device_rev;
+       u32 rx_high_imp_mode;
+       u16 ctrl_mode;
+       u32 board_id = board_id_get();
+       u32 pex_if;
+       u32 pex_if_num;
+
+       /*
+        * TODO:
+        * Right now we only support the MV78460 with 16 serdes lines
+        */
+       max_serdes_lines = 16;
+       if (max_serdes_lines == 0)
+               return MV_OK;
+
+       switch (board_id) {
+       case DB_78X60_AMC_ID:
+       case DB_78X60_PCAC_REV2_ID:
+       case RD_78460_CUSTOMER_ID:
+       case RD_78460_SERVER_ID:
+       case RD_78460_SERVER_REV2_ID:
+       case DB_78X60_PCAC_ID:
+               satr11 = (0x1 << 1) | 1;
+               break;
+       case FPGA_88F78XX0_ID:
+       case RD_78460_NAS_ID:
+               satr11 = (0x0 << 1) | 1;
+               break;
+       case DB_88F78XX0_BP_REV2_ID:
+       case DB_784MP_GP_ID:
+       case DB_88F78XX0_BP_ID:
+               satr11 = board_sat_r_get(1, 1);
+               if ((u8) MV_ERROR == (u8) satr11)
+                       return MV_ERROR;
+               break;
+       }
+
+       board_modules_scan();
+       memset(addr, 0, sizeof(addr));
+       memset(val, 0, sizeof(val));
+
+       /* Check if DRAM is already initialized  */
+       if (reg_read(REG_BOOTROM_ROUTINE_ADDR) &
+           (1 << REG_BOOTROM_ROUTINE_DRAM_INIT_OFFS)) {
+               DEBUG_INIT_S("High speed PHY - Version: ");
+               DEBUG_INIT_S(SERDES_VERION);
+               DEBUG_INIT_S(" - 2nd boot - Skip\n");
+               return MV_OK;
+       }
+       DEBUG_INIT_S("High speed PHY - Version: ");
+       DEBUG_INIT_S(SERDES_VERION);
+       DEBUG_INIT_S(" (COM-PHY-V20)\n");
+
+       /*
+        * AVS :  disable AVS for frequency less than 1333
+        */
+       freq = board_cpu_freq_get();
+       device_rev = mv_ctrl_rev_get();
+
+       if (device_rev == 2) {  /*   for B0 only */
+               u32 cpu_avs;
+               u8 fabric_freq;
+               cpu_avs = reg_read(CPU_AVS_CONTROL2_REG);
+               DEBUG_RD_REG(CPU_AVS_CONTROL2_REG, cpu_avs);
+               cpu_avs &= ~(1 << 9);
+
+               if ((0x4 == freq) || (0xB == freq)) {
+                       u32 tmp2;
+
+                       tmp2 = reg_read(CPU_AVS_CONTROL0_REG);
+                       DEBUG_RD_REG(CPU_AVS_CONTROL0_REG, tmp2);
+                       /* cpu upper limit = 1.1V  cpu lower limit = 0.9125V  */
+                       tmp2 |= 0x0FF;
+                       reg_write(CPU_AVS_CONTROL0_REG, tmp2);
+                       DEBUG_WR_REG(CPU_AVS_CONTROL0_REG, tmp2);
+                       cpu_avs |= (1 << 9);    /* cpu avs enable */
+                       cpu_avs |= (1 << 18);   /* AvsAvddDetEn enable  */
+                       fabric_freq = (reg_read(MPP_SAMPLE_AT_RESET(0)) &
+                                      SAR0_FABRIC_FREQ_MASK) >> SAR0_FABRIC_FREQ_OFFSET;
+                       if ((0xB == freq) && (5 == fabric_freq)) {
+                               u32 core_avs;
+
+                               core_avs = reg_read(CORE_AVS_CONTROL_0REG);
+                               DEBUG_RD_REG(CORE_AVS_CONTROL_0REG, core_avs);
+
+                               /*
+                                * Set core lower limit = 0.9V &
+                                * core upper limit = 0.9125V
+                                */
+                               core_avs &= ~(0xff);
+                               core_avs |= 0x0E;
+                               reg_write(CORE_AVS_CONTROL_0REG, core_avs);
+                               DEBUG_WR_REG(CORE_AVS_CONTROL_0REG, core_avs);
+
+                               core_avs = reg_read(CORE_AVS_CONTROL_2REG);
+                               DEBUG_RD_REG(CORE_AVS_CONTROL_2REG, core_avs);
+                               core_avs |= (1 << 9);   /*  core AVS enable  */
+                               reg_write(CORE_AVS_CONTROL_2REG, core_avs);
+                               DEBUG_WR_REG(CORE_AVS_CONTROL_2REG, core_avs);
+
+                               tmp2 = reg_read(GENERAL_PURPOSE_RESERVED0_REG);
+                               DEBUG_RD_REG(GENERAL_PURPOSE_RESERVED0_REG,
+                                            tmp2);
+                               tmp2 |= 0x1;    /*  AvsCoreAvddDetEn enable   */
+                               reg_write(GENERAL_PURPOSE_RESERVED0_REG, tmp2);
+                               DEBUG_WR_REG(GENERAL_PURPOSE_RESERVED0_REG,
+                                            tmp2);
+                       }
+               }
+               reg_write(CPU_AVS_CONTROL2_REG, cpu_avs);
+               DEBUG_WR_REG(CPU_AVS_CONTROL2_REG, cpu_avs);
+       }
+
+       info = board_serdes_cfg_get(PEX_MODE_GET(satr11));
+       DEBUG_INIT_FULL_S("info->line0_7= 0x");
+       DEBUG_INIT_FULL_D(info->line0_7, 8);
+       DEBUG_INIT_FULL_S("   info->line8_15= 0x");
+       DEBUG_INIT_FULL_D(info->line8_15, 8);
+       DEBUG_INIT_FULL_S("\n");
+
+       if (info == NULL) {
+               DEBUG_INIT_S("Hight speed PHY Error #1\n");
+               return MV_ERROR;
+       }
+
+       if (config_module & ETM_MODULE_DETECT) {        /* step 0.9 ETM */
+               DEBUG_INIT_FULL_S("ETM module detect Step 0.9:\n");
+               reg_write(SERDES_LINE_MUX_REG_0_7, 0x11111111);
+               DEBUG_WR_REG(SERDES_LINE_MUX_REG_0_7, 0x11111111);
+               info->pex_mode[1] = PEX_BUS_DISABLED;   /* pex unit 1 is configure for ETM */
+               mdelay(100);
+               reg_write(PEX_PHY_ACCESS_REG(1), (0x002 << 16) | 0xf44d);       /* SETM0 - start calibration         */
+               DEBUG_WR_REG(PEX_PHY_ACCESS_REG(1), (0x002 << 16) | 0xf44d);    /* SETM0 - start calibration         */
+               reg_write(PEX_PHY_ACCESS_REG(1), (0x302 << 16) | 0xf44d);       /* SETM1 - start calibration         */
+               DEBUG_WR_REG(PEX_PHY_ACCESS_REG(1), (0x302 << 16) | 0xf44d);    /* SETM1 - start calibration         */
+               reg_write(PEX_PHY_ACCESS_REG(1), (0x001 << 16) | 0xf801);       /* SETM0 - SATA mode & 25MHz ref clk */
+               DEBUG_WR_REG(PEX_PHY_ACCESS_REG(1), (0x001 << 16) | 0xf801);    /* SETM0 - SATA mode & 25MHz ref clk */
+               reg_write(PEX_PHY_ACCESS_REG(1), (0x301 << 16) | 0xf801);       /* SETM1 - SATA mode & 25MHz ref clk */
+               DEBUG_WR_REG(PEX_PHY_ACCESS_REG(1), (0x301 << 16) | 0xf801);    /* SETM1 - SATA mode & 25MHz ref clk */
+               reg_write(PEX_PHY_ACCESS_REG(1), (0x011 << 16) | 0x0BFF);       /* SETM0 - G3 full swing AMP         */
+               DEBUG_WR_REG(PEX_PHY_ACCESS_REG(1), (0x011 << 16) | 0x0BFF);    /* SETM0 - G3 full swing AMP         */
+               reg_write(PEX_PHY_ACCESS_REG(1), (0x311 << 16) | 0x0BFF);       /* SETM1 - G3 full swing AMP         */
+               DEBUG_WR_REG(PEX_PHY_ACCESS_REG(1), (0x311 << 16) | 0x0BFF);    /* SETM1 - G3 full swing AMP         */
+               reg_write(PEX_PHY_ACCESS_REG(1), (0x023 << 16) | 0x0800);       /* SETM0 - 40 data bit width         */
+               DEBUG_WR_REG(PEX_PHY_ACCESS_REG(1), (0x023 << 16) | 0x0800);    /* SETM0 - 40 data bit width         */
+               reg_write(PEX_PHY_ACCESS_REG(1), (0x323 << 16) | 0x0800);       /* SETM1 - 40 data bit width         */
+               DEBUG_WR_REG(PEX_PHY_ACCESS_REG(1), (0x323 << 16) | 0x0800);    /* SETM1 - 40 data bit width         */
+               reg_write(PEX_PHY_ACCESS_REG(1), (0x046 << 16) | 0x0400);       /* lane0(serdes4)                    */
+               DEBUG_WR_REG(PEX_PHY_ACCESS_REG(1), (0x046 << 16) | 0x0400);    /* lane0(serdes4)                    */
+               reg_write(PEX_PHY_ACCESS_REG(1), (0x346 << 16) | 0x0400);       /* lane3(serdes7)                    */
+               DEBUG_WR_REG(PEX_PHY_ACCESS_REG(1), (0x346 << 16) | 0x0400);    /* lane3(serdes7)                    */
+       }
+
+       /* STEP -1 [PEX-Only] First phase of PEX-PIPE Configuration: */
+       DEBUG_INIT_FULL_S("Step 1: First phase of PEX-PIPE Configuration\n");
+       for (pex_unit = 0; pex_unit < pex_max_unit_get(); pex_unit++) {
+               if (info->pex_mode[pex_unit] == PEX_BUS_DISABLED)
+                       continue;
+
+               /* 1.   GLOB_CLK_CTRL Reset and Clock Control */
+               reg_write(PEX_PHY_ACCESS_REG(pex_unit), (0xC1 << 16) | 0x25);
+               DEBUG_WR_REG(PEX_PHY_ACCESS_REG(pex_unit), (0xC1 << 16) | 0x25);
+
+               /* 2.   GLOB_TEST_CTRL Test Mode Control */
+               if (info->pex_mode[pex_unit] == PEX_BUS_MODE_X4) {
+                       reg_write(PEX_PHY_ACCESS_REG(pex_unit),
+                                 (0xC2 << 16) | 0x200);
+                       DEBUG_WR_REG(PEX_PHY_ACCESS_REG(pex_unit),
+                                    (0xC2 << 16) | 0x200);
+               }
+
+               /* 3.   GLOB_CLK_SRC_LO Clock Source Low */
+               if (info->pex_mode[pex_unit] == PEX_BUS_MODE_X1) {
+                       reg_write(PEX_PHY_ACCESS_REG(pex_unit),
+                                 (0xC3 << 16) | 0x0F);
+                       DEBUG_WR_REG(PEX_PHY_ACCESS_REG(pex_unit),
+                                    (0xC3 << 16) | 0x0F);
+               }
+
+               reg_write(PEX_PHY_ACCESS_REG(pex_unit), (0xC5 << 16) | 0x11F);
+               DEBUG_WR_REG(PEX_PHY_ACCESS_REG(pex_unit),
+                            (0xC5 << 16) | 0x11F);
+       }
+
+       /*
+        * 2 Configure the desire PIN_PHY_GEN and do power down to the PU_PLL,
+        * PU_RX,PU_TX. (bits[12:5])
+        */
+       DEBUG_INIT_FULL_S("Step 2: Configure the desire PIN_PHY_GEN\n");
+       for (line_num = 0; line_num < max_serdes_lines; line_num++) {
+               line_cfg = get_line_cfg(line_num, info);
+               if (line_cfg == serdes_cfg[line_num][SERDES_UNIT_UNCONNECTED])
+                       continue;
+               if (line_cfg == serdes_cfg[line_num][SERDES_UNIT_PEX])
+                       continue;
+               if (line_cfg == serdes_cfg[line_num][SERDES_UNIT_SATA]) {
+                       switch (line_num) {
+                       case 4:
+                       case 6:
+                               sata_port = 0;
+                               break;
+                       case 5:
+                               sata_port = 1;
+                               break;
+                       default:
+                               DEBUG_INIT_C
+                                   ("SATA port error for serdes line: ",
+                                    line_num, 2);
+                               return MV_ERROR;
+                       }
+                       tmp = reg_read(SATA_LP_PHY_EXT_CTRL_REG(sata_port));
+                       DEBUG_RD_REG(SATA_LP_PHY_EXT_CTRL_REG(sata_port), tmp);
+                       tmp &= ~((0x1ff << 5) | 0x7);
+                       tmp |= ((info->bus_speed & (1 << line_num)) != 0) ?
+                               (0x11 << 5) : 0x0;
+
+                       reg_write(SATA_LP_PHY_EXT_CTRL_REG(sata_port), tmp);
+                       DEBUG_WR_REG(SATA_LP_PHY_EXT_CTRL_REG(sata_port), tmp);
+               }
+
+               if (line_cfg == serdes_cfg[line_num][SERDES_UNIT_QSGMII]) {
+                       /*
+                        * 4) Configure the desire PIN_PHY_GEN and do power
+                        * down to the PU_PLL,PU_RX,PU_TX. (bits[12:5])
+                        */
+                       tmp = reg_read(SGMII_SERDES_CFG_REG(0));
+                       DEBUG_RD_REG(SGMII_SERDES_CFG_REG(0), tmp);
+                       tmp &= ~((0x1ff << 5) | 0x7);
+                       tmp |= 0x660;
+                       reg_write(SGMII_SERDES_CFG_REG(0), tmp);
+                       DEBUG_WR_REG(SGMII_SERDES_CFG_REG(0), tmp);
+                       continue;
+               }
+
+               if (line_cfg == serdes_cfg[line_num][SERDES_UNIT_SGMII0])
+                       sgmii_port = 0;
+               else if (line_cfg == serdes_cfg[line_num][SERDES_UNIT_SGMII1])
+                       sgmii_port = 1;
+               else if (line_cfg == serdes_cfg[line_num][SERDES_UNIT_SGMII2])
+                       sgmii_port = 2;
+               else if (line_cfg == serdes_cfg[line_num][SERDES_UNIT_SGMII3])
+                       sgmii_port = 3;
+               else
+                       continue;
+
+               tmp = reg_read(SGMII_SERDES_CFG_REG(sgmii_port));
+               DEBUG_RD_REG(SGMII_SERDES_CFG_REG(sgmii_port), tmp);
+               tmp &= ~((0x1ff << 5) | 0x7);
+               tmp |= (((info->bus_speed & (1 << line_num)) != 0) ?
+                       (0x88 << 5) : (0x66 << 5));
+               reg_write(SGMII_SERDES_CFG_REG(sgmii_port), tmp);
+               DEBUG_WR_REG(SGMII_SERDES_CFG_REG(sgmii_port), tmp);
+       }
+
+       /* Step 3 - QSGMII enable */
+       DEBUG_INIT_FULL_S("Step 3 QSGMII enable\n");
+       for (line_num = 0; line_num < max_serdes_lines; line_num++) {
+               line_cfg = get_line_cfg(line_num, info);
+               if (line_cfg == serdes_cfg[line_num][SERDES_UNIT_QSGMII]) {
+                       /* QSGMII Active bit set to true */
+                       tmp = reg_read(QSGMII_CONTROL_1_REG);
+                       DEBUG_RD_REG(QSGMII_CONTROL_1_REG, tmp);
+                       tmp |= (1 << 30);
+#ifdef ERRATA_GL_6572255
+                       tmp |= (1 << 27);
+#endif
+                       reg_write(QSGMII_CONTROL_1_REG, tmp);
+                       DEBUG_WR_REG(QSGMII_CONTROL_1_REG, tmp);
+               }
+       }
+
+       /* Step 4 - configure SERDES MUXes */
+       DEBUG_INIT_FULL_S("Step 4: Configure SERDES MUXes\n");
+       if (config_module & ETM_MODULE_DETECT) {
+               reg_write(SERDES_LINE_MUX_REG_0_7, 0x40041111);
+               DEBUG_WR_REG(SERDES_LINE_MUX_REG_0_7, 0x40041111);
+       } else {
+               reg_write(SERDES_LINE_MUX_REG_0_7, info->line0_7);
+               DEBUG_WR_REG(SERDES_LINE_MUX_REG_0_7, info->line0_7);
+       }
+       reg_write(SERDES_LINE_MUX_REG_8_15, info->line8_15);
+       DEBUG_WR_REG(SERDES_LINE_MUX_REG_8_15, info->line8_15);
+
+       /* Step 5: Activate the RX High Impedance Mode  */
+       DEBUG_INIT_FULL_S("Step 5: Activate the RX High Impedance Mode\n");
+       rx_high_imp_mode = 0x8080;
+       if (device_rev == 2)    /*   for B0 only */
+               rx_high_imp_mode |= 4;
+
+       for (line_num = 0; line_num < max_serdes_lines; line_num++) {
+               /* for each serdes lane */
+               DEBUG_INIT_FULL_S("SERDES  ");
+               DEBUG_INIT_FULL_D_10(line_num, 2);
+               line_cfg = get_line_cfg(line_num, info);
+               if (line_cfg == serdes_cfg[line_num][SERDES_UNIT_UNCONNECTED]) {
+                       DEBUG_INIT_FULL_S(" unconnected ***\n");
+                       continue;
+               }
+               if (line_cfg == serdes_cfg[line_num][SERDES_UNIT_PEX]) {
+                       pex_unit = line_num >> 2;
+                       pex_line_num = line_num % 4;
+                       DEBUG_INIT_FULL_S(" - PEX unit ");
+                       DEBUG_INIT_FULL_D_10(pex_unit, 1);
+                       DEBUG_INIT_FULL_S(" line=  ");
+                       DEBUG_INIT_FULL_D_10(pex_line_num, 1);
+                       DEBUG_INIT_FULL_S("\n");
+
+                       /* Needed for PEX_PHY_ACCESS_REG macro */
+                       if ((line_num > 7) &&
+                           (info->pex_mode[3] == PEX_BUS_MODE_X8))
+                               /* lines 8 - 15 are belong to PEX3 in x8 mode */
+                               pex_unit = 3;
+
+                       if (info->pex_mode[pex_unit] == PEX_BUS_DISABLED)
+                               continue;
+
+                       /*
+                        * 8)  Activate the RX High Impedance Mode field
+                        * (bit [2]) in register /PCIe_USB Control (Each MAC
+                        * contain different Access to reach its
+                        * Serdes-Regfile).
+                        * [PEX-Only] Set bit[12]: The analog part latches idle
+                        * if PU_TX = 1 and PU_PLL =1.
+                        */
+
+                       /* Termination enable */
+                       if (info->pex_mode[pex_unit] == PEX_BUS_MODE_X1) {
+                               in_direct = (0x48 << 16) | (pex_line_num << 24) |
+                                       0x1000 | rx_high_imp_mode;      /* x1 */
+                       } else if ((info->pex_mode[pex_unit] ==
+                                   PEX_BUS_MODE_X4) && (pex_line_num == 0))
+                               in_direct = (0x48 << 16) | (pex_line_num << 24) |
+                                       0x1000 | (rx_high_imp_mode & 0xff);     /* x4 */
+                       else
+                               in_direct = 0;
+
+                       if (in_direct) {
+                               reg_write(PEX_PHY_ACCESS_REG(pex_unit),
+                                         in_direct);
+                               DEBUG_WR_REG(PEX_PHY_ACCESS_REG(pex_unit),
+                                            in_direct);
+                       }
+
+                       continue;
+               }
+
+               if (line_cfg == serdes_cfg[line_num][SERDES_UNIT_SATA]) {
+                       /*
+                        * port 0 for serdes lines 4,6,  and port 1 for
+                        * serdes lines 5
+                        */
+                       sata_port = line_num & 1;
+                       DEBUG_INIT_FULL_S(" - SATA port  ");
+                       DEBUG_INIT_FULL_D_10(sata_port, 2);
+                       DEBUG_INIT_FULL_S("\n");
+                       reg_write(SATA_COMPHY_CTRL_REG(sata_port),
+                                 rx_high_imp_mode);
+                       DEBUG_WR_REG(SATA_COMPHY_CTRL_REG(sata_port),
+                                    rx_high_imp_mode);
+                       continue;
+               }
+
+               if (line_cfg == serdes_cfg[line_num][SERDES_UNIT_QSGMII]) {
+                       DEBUG_INIT_FULL_S(" - QSGMII\n");
+                       reg_write(SGMII_COMPHY_CTRL_REG(0), rx_high_imp_mode);
+                       DEBUG_WR_REG(SGMII_COMPHY_CTRL_REG(0),
+                                    rx_high_imp_mode);
+                       continue;
+               }
+
+               if (line_cfg == serdes_cfg[line_num][SERDES_UNIT_SGMII0])
+                       sgmii_port = 0;
+               else if (line_cfg == serdes_cfg[line_num][SERDES_UNIT_SGMII1])
+                       sgmii_port = 1;
+               else if (line_cfg == serdes_cfg[line_num][SERDES_UNIT_SGMII2])
+                       sgmii_port = 2;
+               else if (line_cfg == serdes_cfg[line_num][SERDES_UNIT_SGMII3])
+                       sgmii_port = 3;
+               else
+                       continue;
+               DEBUG_INIT_FULL_S(" - SGMII port  ");
+               DEBUG_INIT_FULL_D_10(sgmii_port, 2);
+               DEBUG_INIT_FULL_S("\n");
+               reg_write(SGMII_COMPHY_CTRL_REG(sgmii_port), rx_high_imp_mode);
+               DEBUG_WR_REG(SGMII_COMPHY_CTRL_REG(sgmii_port),
+                            rx_high_imp_mode);
+       }                       /* for each serdes lane */
+
+       /* Step 6 [PEX-Only] PEX-Main configuration (X4 or X1): */
+       DEBUG_INIT_FULL_S("Step 6: [PEX-Only] PEX-Main configuration (X4 or X1)\n");
+       tmp = reg_read(SOC_CTRL_REG);
+       DEBUG_RD_REG(SOC_CTRL_REG, tmp);
+       tmp &= 0x200;
+       if (info->pex_mode[0] == PEX_BUS_MODE_X1)
+               tmp |= PCIE0_QUADX1_EN;
+       if (info->pex_mode[1] == PEX_BUS_MODE_X1)
+               tmp |= PCIE1_QUADX1_EN;
+       if (((reg_read(MPP_SAMPLE_AT_RESET(0)) & PEX_CLK_100MHZ_MASK) >>
+            PEX_CLK_100MHZ_OFFSET) == 0x1)
+               tmp |= (PCIE0_CLK_OUT_EN_MASK | PCIE1_CLK_OUT_EN_MASK);
+
+       reg_write(SOC_CTRL_REG, tmp);
+       DEBUG_WR_REG(SOC_CTRL_REG, tmp);
+
+       /* 6.2 PCI Express Link Capabilities */
+       DEBUG_INIT_FULL_S("Step 6.2: [PEX-Only] PCI Express Link Capabilities\n");
+
+       for (line_num = 0; line_num < max_serdes_lines; line_num++) {
+               line_cfg = get_line_cfg(line_num, info);
+
+               if (line_cfg == serdes_cfg[line_num][SERDES_UNIT_PEX]) {
+                       /*
+                        * PCI Express Control
+                        * 0xX1A00 [0]:
+                        * 0x0 X4-Link.
+                        * 0x1 X1-Link
+                        */
+                       pex_unit = line_num >> 2;
+                       pex_if = MV_SERDES_NUM_TO_PEX_NUM(line_num);
+                       if (info->pex_mode[pex_unit] == PEX_BUS_DISABLED)
+                               continue;
+
+                       /*  set Common Clock Configuration */
+                       tmp = reg_read(PEX_LINK_CTRL_STATUS_REG(pex_if));
+                       DEBUG_RD_REG(PEX_LINK_CTRL_STATUS_REG(pex_if), tmp);
+                       tmp |= (1 << 6);
+                       reg_write(PEX_LINK_CTRL_STATUS_REG(pex_if), tmp);
+                       DEBUG_WR_REG(PEX_LINK_CTRL_STATUS_REG(pex_if), tmp);
+
+                       tmp = reg_read(PEX_LINK_CAPABILITIES_REG(pex_if));
+                       DEBUG_RD_REG(PEX_LINK_CAPABILITIES_REG(pex_if), tmp);
+                       tmp &= ~(0x3FF);
+                       if (info->pex_mode[pex_unit] == PEX_BUS_MODE_X1)
+                               tmp |= (0x1 << 4);
+                       if (info->pex_mode[pex_unit] == PEX_BUS_MODE_X4)
+                               tmp |= (0x4 << 4);
+                       if (0 == PEX_CAPABILITY_GET(satr11))
+                               tmp |= 0x1;
+                       else
+                               tmp |= 0x2;
+                       DEBUG_INIT_FULL_S("Step 6.2: PEX ");
+                       DEBUG_INIT_FULL_D(pex_if, 1);
+                       DEBUG_INIT_FULL_C(" set GEN", (tmp & 3), 1);
+                       reg_write(PEX_LINK_CAPABILITIES_REG(pex_if), tmp);
+                       DEBUG_WR_REG(PEX_LINK_CAPABILITIES_REG(pex_if), tmp);
+
+                       /*
+                        * If pex is X4, no need to pass thru the other
+                        * 3X1 serdes lines
+                        */
+                       if (info->pex_mode[pex_unit] == PEX_BUS_MODE_X4)
+                               line_num += 3;
+               }
+       }
+
+       /*
+        * Step 7 [PEX-X4 Only] To create PEX-Link that contain 4-lanes you
+        * need to config the register SOC_Misc/General Purpose2
+        * (Address= 182F8)
+        */
+       DEBUG_INIT_FULL_S("Step 7: [PEX-X4 Only] To create PEX-Link\n");
+       tmp = reg_read(GEN_PURP_RES_2_REG);
+       DEBUG_RD_REG(GEN_PURP_RES_2_REG, tmp);
+
+       tmp &= 0xFFFF0000;
+       if (info->pex_mode[0] == PEX_BUS_MODE_X4)
+               tmp |= 0x0000000F;
+
+       if (info->pex_mode[1] == PEX_BUS_MODE_X4)
+               tmp |= 0x000000F0;
+
+       if (info->pex_mode[2] == PEX_BUS_MODE_X4)
+               tmp |= 0x00000F00;
+
+       if (info->pex_mode[3] == PEX_BUS_MODE_X4)
+               tmp |= 0x0000F000;
+
+       reg_write(GEN_PURP_RES_2_REG, tmp);
+       DEBUG_WR_REG(GEN_PURP_RES_2_REG, tmp);
+
+       /* Steps  8 , 9 ,10 - use prepared REG addresses and values */
+       DEBUG_INIT_FULL_S("Steps 7,8,9,10 and 11\n");
+
+       /* Prepare PHY parameters for each step according to  MUX selection */
+       for (line_num = 0; line_num < max_serdes_lines; line_num++) {
+               /* for each serdes lane */
+
+               line_cfg = get_line_cfg(line_num, info);
+
+               if (line_cfg == serdes_cfg[line_num][SERDES_UNIT_UNCONNECTED])
+                       continue;
+
+               if (line_cfg == serdes_cfg[line_num][SERDES_UNIT_PEX]) {
+                       pex_unit = line_num >> 2;
+                       pex_line_num = line_num % 4;
+
+                       if (info->pex_mode[pex_unit] == PEX_BUS_DISABLED)
+                               continue;
+                       /*
+                        * 8)   Configure the desire PHY_MODE (bits [7:5])
+                        * and REF_FREF_SEL (bits[4:0]) in the register Power
+                        * and PLL Control (Each MAC contain different Access
+                        * to reach its Serdes-Regfile).
+                        */
+                       if (((info->pex_mode[pex_unit] == PEX_BUS_MODE_X4) &&
+                            (0 == pex_line_num))
+                           || ((info->pex_mode[pex_unit] == PEX_BUS_MODE_X1))) {
+                               reg_write(PEX_PHY_ACCESS_REG(pex_unit),
+                                         (0x01 << 16) | (pex_line_num << 24) |
+                                         0xFC60);
+                               DEBUG_WR_REG(PEX_PHY_ACCESS_REG(pex_unit),
+                                            (0x01 << 16) | (pex_line_num << 24)
+                                            | 0xFC60);
+                               /*
+                                * Step 8.1: [PEX-Only] Configure Max PLL Rate
+                                * (bit 8 in  KVCO Calibration Control and
+                                * bits[10:9] in
+                                */
+                               /* Use Maximum PLL Rate(Bit 8) */
+                               reg_write(PEX_PHY_ACCESS_REG(pex_unit),
+                                         (0x02 << 16) | (1 << 31) |
+                                         (pex_line_num << 24)); /* read command */
+                               DEBUG_WR_REG(PEX_PHY_ACCESS_REG(pex_unit),
+                                            (0x02 << 16) | (1 << 31) |
+                                            (pex_line_num << 24));
+                               tmp = reg_read(PEX_PHY_ACCESS_REG(pex_unit));
+                               DEBUG_RD_REG(PEX_PHY_ACCESS_REG(pex_unit), tmp);
+                               tmp &= ~(1 << 31);
+                               tmp |= (1 << 8);
+                               reg_write(PEX_PHY_ACCESS_REG(pex_unit), tmp);
+                               DEBUG_WR_REG(PEX_PHY_ACCESS_REG(pex_unit), tmp);
+
+                               /* Use Maximum PLL Rate(Bits [10:9]) */
+                               reg_write(PEX_PHY_ACCESS_REG(pex_unit),
+                                         (0x81 << 16) | (1 << 31) |
+                                         (pex_line_num << 24)); /* read command */
+                               DEBUG_WR_REG(PEX_PHY_ACCESS_REG(pex_unit),
+                                            (0x81 << 16) | (1 << 31) |
+                                            (pex_line_num << 24));
+                               tmp = reg_read(PEX_PHY_ACCESS_REG(pex_unit));
+                               DEBUG_RD_REG(PEX_PHY_ACCESS_REG(pex_unit), tmp);
+                               tmp &= ~(1 << 31);
+                               tmp |= (3 << 9);
+                               reg_write(PEX_PHY_ACCESS_REG(pex_unit), tmp);
+                               DEBUG_WR_REG(PEX_PHY_ACCESS_REG(pex_unit), tmp);
+                       }
+
+                       continue;
+               }
+
+               if (line_cfg == serdes_cfg[line_num][SERDES_UNIT_SATA]) {
+                       /*
+                        * Port 0 for serdes lines 4,6,  and port 1 for serdes
+                        * lines 5
+                        */
+                       sata_port = line_num & 1;
+
+                       /*
+                        * 8) Configure the desire PHY_MODE (bits [7:5]) and
+                        * REF_FREF_SEL (bits[4:0]) in the register Power
+                        * and PLL Control (Each MAC contain different Access
+                        * to reach its Serdes-Regfile).
+                        */
+                       reg_write(SATA_PWR_PLL_CTRL_REG(sata_port), 0xF801);
+                       DEBUG_WR_REG(SATA_PWR_PLL_CTRL_REG(sata_port), 0xF801);
+
+                       /*  9)  Configure the desire SEL_BITS  */
+                       reg_write(SATA_DIG_LP_ENA_REG(sata_port), 0x400);
+                       DEBUG_WR_REG(SATA_DIG_LP_ENA_REG(sata_port), 0x400);
+
+                       /* 10)  Configure the desire REFCLK_SEL */
+
+                       reg_write(SATA_REF_CLK_SEL_REG(sata_port), 0x400);
+                       DEBUG_WR_REG(SATA_REF_CLK_SEL_REG(sata_port), 0x400);
+
+                       /* 11)  Power up to the PU_PLL,PU_RX,PU_TX.   */
+                       tmp = reg_read(SATA_LP_PHY_EXT_CTRL_REG(sata_port));
+                       DEBUG_RD_REG(SATA_LP_PHY_EXT_CTRL_REG(sata_port), tmp);
+                       tmp |= 7;
+                       reg_write(SATA_LP_PHY_EXT_CTRL_REG(sata_port), tmp);
+                       DEBUG_WR_REG(SATA_LP_PHY_EXT_CTRL_REG(sata_port), tmp);
+
+                       continue;
+               }
+
+               if (line_cfg == serdes_cfg[line_num][SERDES_UNIT_QSGMII]) {
+                       /*
+                        * 8)   Configure the desire PHY_MODE (bits [7:5])
+                        * and REF_FREF_SEL (bits[4:0]) in the register
+                        */
+                       reg_write(SGMII_PWR_PLL_CTRL_REG(0), 0xF881);
+                       DEBUG_WR_REG(SGMII_PWR_PLL_CTRL_REG(0), 0xF881);
+
+                       /*
+                        * 9)   Configure the desire SEL_BITS (bits [11:0]
+                        * in register
+                        */
+                       reg_write(SGMII_DIG_LP_ENA_REG(0), 0x400);
+                       DEBUG_WR_REG(SGMII_DIG_LP_ENA_REG(0), 0x400);
+
+                       /*
+                        * 10)  Configure the desire REFCLK_SEL (bit [10])
+                        * in register
+                        */
+                       reg_write(SGMII_REF_CLK_SEL_REG(0), 0x400);
+                       DEBUG_WR_REG(SGMII_REF_CLK_SEL_REG(0), 0x400);
+
+                       /* 11)  Power up to the PU_PLL,PU_RX,PU_TX.  */
+                       tmp = reg_read(SGMII_SERDES_CFG_REG(0));
+                       DEBUG_RD_REG(SGMII_SERDES_CFG_REG(0), tmp);
+                       tmp |= 7;
+                       reg_write(SGMII_SERDES_CFG_REG(0), tmp);
+                       DEBUG_WR_REG(SGMII_SERDES_CFG_REG(0), tmp);
+                       continue;
+               }
+
+               if (line_cfg == serdes_cfg[line_num][SERDES_UNIT_SGMII0])
+                       sgmii_port = 0;
+               else if (line_cfg == serdes_cfg[line_num][SERDES_UNIT_SGMII1])
+                       sgmii_port = 1;
+               else if (line_cfg == serdes_cfg[line_num][SERDES_UNIT_SGMII2])
+                       sgmii_port = 2;
+               else if (line_cfg == serdes_cfg[line_num][SERDES_UNIT_SGMII3])
+                       sgmii_port = 3;
+               else
+                       continue;
+
+               /*
+                * 8)   Configure the desire PHY_MODE (bits [7:5]) and
+                * REF_FREF_SEL (bits[4:0]) in the register
+                */
+               reg_write(SGMII_PWR_PLL_CTRL_REG(sgmii_port), 0xF881);
+               DEBUG_WR_REG(SGMII_PWR_PLL_CTRL_REG(sgmii_port), 0xF881);
+
+               /* 9)   Configure the desire SEL_BITS (bits [11:0] in register */
+               reg_write(SGMII_DIG_LP_ENA_REG(sgmii_port), 0);
+               DEBUG_WR_REG(SGMII_DIG_LP_ENA_REG(sgmii_port), 0);
+
+               /* 10)  Configure the desire REFCLK_SEL (bit [10]) in register  */
+               reg_write(SGMII_REF_CLK_SEL_REG(sgmii_port), 0x400);
+               DEBUG_WR_REG(SGMII_REF_CLK_SEL_REG(sgmii_port), 0x400);
+
+               /* 11)  Power up to the PU_PLL,PU_RX,PU_TX.  */
+               tmp = reg_read(SGMII_SERDES_CFG_REG(sgmii_port));
+               DEBUG_RD_REG(SGMII_SERDES_CFG_REG(sgmii_port), tmp);
+               tmp |= 7;
+               reg_write(SGMII_SERDES_CFG_REG(sgmii_port), tmp);
+               DEBUG_WR_REG(SGMII_SERDES_CFG_REG(sgmii_port), tmp);
+
+       }                       /* for each serdes lane */
+
+       /* Step 12 [PEX-Only] Last phase of PEX-PIPE Configuration */
+       DEBUG_INIT_FULL_S("Steps 12: [PEX-Only] Last phase of PEX-PIPE Configuration\n");
+       for (line_num = 0; line_num < max_serdes_lines; line_num++) {
+               /* for each serdes lane */
+
+               line_cfg = get_line_cfg(line_num, info);
+
+               if (line_cfg == serdes_cfg[line_num][SERDES_UNIT_UNCONNECTED])
+                       continue;
+
+               if (line_cfg == serdes_cfg[line_num][SERDES_UNIT_PEX]) {
+                       pex_unit = line_num >> 2;
+                       pex_line_num = line_num % 4;
+                       if (0 == pex_line_num) {
+                               reg_write(PEX_PHY_ACCESS_REG(pex_unit),
+                                         (0xC1 << 16) | 0x24);
+                               DEBUG_WR_REG(PEX_PHY_ACCESS_REG(pex_unit),
+                                            (0xC1 << 16) | 0x24);
+                       }
+               }
+       }
+
+       /*--------------------------------------------------------------*/
+       /* Step 13: Wait 15ms before checking results */
+       DEBUG_INIT_FULL_S("Steps 13: Wait 15ms before checking results");
+       mdelay(15);
+       tmp = 20;
+       while (tmp) {
+               status = MV_OK;
+               for (line_num = 0; line_num < max_serdes_lines; line_num++) {
+                       u32 tmp;
+                       line_cfg = get_line_cfg(line_num, info);
+                       if (line_cfg ==
+                           serdes_cfg[line_num][SERDES_UNIT_UNCONNECTED])
+                               continue;
+
+                       if (line_cfg == serdes_cfg[line_num][SERDES_UNIT_PEX])
+                               continue;
+
+                       if (line_cfg == serdes_cfg[line_num][SERDES_UNIT_SATA]) {
+                               /*
+                                * Port 0 for serdes lines 4,6,  and port 1
+                                * for serdes lines 5
+                                */
+                               sata_port = line_num & 1;
+
+                               tmp =
+                                   reg_read(SATA_LP_PHY_EXT_STAT_REG
+                                            (sata_port));
+                               DEBUG_RD_REG(SATA_LP_PHY_EXT_STAT_REG
+                                            (sata_port), tmp);
+                               if ((tmp & 0x7) != 0x7)
+                                       status = MV_ERROR;
+                               continue;
+                       }
+
+                       if (line_cfg ==
+                           serdes_cfg[line_num][SERDES_UNIT_QSGMII]) {
+                               tmp = reg_read(SGMII_SERDES_STAT_REG(0));
+                               DEBUG_RD_REG(SGMII_SERDES_STAT_REG(0), tmp);
+                               if ((tmp & 0x7) != 0x7)
+                                       status = MV_ERROR;
+                               continue;
+                       }
+
+                       if (line_cfg ==
+                           serdes_cfg[line_num][SERDES_UNIT_SGMII0])
+                               sgmii_port = 0;
+                       else if (line_cfg ==
+                                serdes_cfg[line_num][SERDES_UNIT_SGMII1])
+                               sgmii_port = 1;
+                       else if (line_cfg ==
+                                serdes_cfg[line_num][SERDES_UNIT_SGMII2])
+                               sgmii_port = 2;
+                       else if (line_cfg ==
+                                serdes_cfg[line_num][SERDES_UNIT_SGMII3])
+                               sgmii_port = 3;
+                       else
+                               continue;
+
+                       tmp = reg_read(SGMII_SERDES_STAT_REG(sgmii_port));
+                       DEBUG_RD_REG(SGMII_SERDES_STAT_REG(sgmii_port), tmp);
+                       if ((tmp & 0x7) != 0x7)
+                               status = MV_ERROR;
+               }
+
+               if (status == MV_OK)
+                       break;
+               mdelay(5);
+               tmp--;
+       }
+
+       /*
+        * Step14 [PEX-Only]  In order to configure RC/EP mode please write
+        * to register 0x0060 bits
+        */
+       DEBUG_INIT_FULL_S("Steps 14: [PEX-Only]  In order to configure\n");
+       for (pex_unit = 0; pex_unit < pex_max_unit_get(); pex_unit++) {
+               if (info->pex_mode[pex_unit] == PEX_BUS_DISABLED)
+                       continue;
+               tmp =
+                   reg_read(PEX_CAPABILITIES_REG(MV_PEX_UNIT_TO_IF(pex_unit)));
+               DEBUG_RD_REG(PEX_CAPABILITIES_REG(MV_PEX_UNIT_TO_IF(pex_unit)),
+                            tmp);
+               tmp &= ~(0xf << 20);
+               if (info->pex_type == MV_PEX_ROOT_COMPLEX)
+                       tmp |= (0x4 << 20);
+               else
+                       tmp |= (0x1 << 20);
+               reg_write(PEX_CAPABILITIES_REG(MV_PEX_UNIT_TO_IF(pex_unit)),
+                         tmp);
+               DEBUG_WR_REG(PEX_CAPABILITIES_REG(MV_PEX_UNIT_TO_IF(pex_unit)),
+                            tmp);
+       }
+
+       /*
+        * Step 15 [PEX-Only] Only for EP mode set to Zero bits 19 and 16 of
+        * register 0x1a60
+        */
+       DEBUG_INIT_FULL_S("Steps 15: [PEX-Only]  In order to configure\n");
+       for (pex_unit = 0; pex_unit < pex_max_unit_get(); pex_unit++) {
+               if (info->pex_mode[pex_unit] == PEX_BUS_DISABLED)
+                       continue;
+               if (info->pex_type == MV_PEX_END_POINT) {
+                       tmp =
+                           reg_read(PEX_DBG_CTRL_REG
+                                    (MV_PEX_UNIT_TO_IF(pex_unit)));
+                       DEBUG_RD_REG(PEX_DBG_CTRL_REG
+                                    (MV_PEX_UNIT_TO_IF(pex_unit)), tmp);
+                       tmp &= 0xfff6ffff;
+                       reg_write(PEX_DBG_CTRL_REG(MV_PEX_UNIT_TO_IF(pex_unit)),
+                                 tmp);
+                       DEBUG_WR_REG(PEX_DBG_CTRL_REG
+                                    (MV_PEX_UNIT_TO_IF(pex_unit)), tmp);
+               }
+       }
+
+       if (info->serdes_m_phy_change) {
+               MV_SERDES_CHANGE_M_PHY *serdes_m_phy_change;
+               u32 bus_speed;
+               for (line_num = 0; line_num < max_serdes_lines; line_num++) {
+                       line_cfg = get_line_cfg(line_num, info);
+                       if (line_cfg ==
+                           serdes_cfg[line_num][SERDES_UNIT_UNCONNECTED])
+                               continue;
+                       serdes_m_phy_change = info->serdes_m_phy_change;
+                       bus_speed = info->bus_speed & (1 << line_num);
+                       while (serdes_m_phy_change->type !=
+                              SERDES_UNIT_UNCONNECTED) {
+                               switch (serdes_m_phy_change->type) {
+                               case SERDES_UNIT_PEX:
+                                       if (line_cfg != SERDES_UNIT_PEX)
+                                               break;
+                                       pex_unit = line_num >> 2;
+                                       pex_line_num = line_num % 4;
+                                       if (info->pex_mode[pex_unit] ==
+                                           PEX_BUS_DISABLED)
+                                               break;
+                                       if ((info->pex_mode[pex_unit] ==
+                                            PEX_BUS_MODE_X4) && pex_line_num)
+                                               break;
+
+                                       if (bus_speed) {
+                                               reg_write(PEX_PHY_ACCESS_REG
+                                                         (pex_unit),
+                                                         (pex_line_num << 24) |
+                                                         serdes_m_phy_change->val_hi_speed);
+                                               DEBUG_WR_REG(PEX_PHY_ACCESS_REG
+                                                            (pex_unit),
+                                                            (pex_line_num <<
+                                                             24) |
+                                                            serdes_m_phy_change->val_hi_speed);
+                                       } else {
+                                               reg_write(PEX_PHY_ACCESS_REG
+                                                         (pex_unit),
+                                                         (pex_line_num << 24) |
+                                                         serdes_m_phy_change->val_low_speed);
+                                               DEBUG_WR_REG(PEX_PHY_ACCESS_REG
+                                                            (pex_unit),
+                                                            (pex_line_num <<
+                                                             24) |
+                                                            serdes_m_phy_change->val_low_speed);
+                                       }
+                                       break;
+                               case SERDES_UNIT_SATA:
+                                       if (line_cfg != SERDES_UNIT_SATA)
+                                               break;
+                                       /*
+                                        * Port 0 for serdes lines 4,6,  and
+                                        * port 1 for serdes lines 5
+                                        */
+                                       sata_port = line_num & 1;
+                                       if (bus_speed) {
+                                               reg_write(SATA_BASE_REG
+                                                         (sata_port) |
+                                                         serdes_m_phy_change->reg_hi_speed,
+                                                         serdes_m_phy_change->val_hi_speed);
+                                               DEBUG_WR_REG(SATA_BASE_REG
+                                                            (sata_port) |
+                                                            serdes_m_phy_change->reg_hi_speed,
+                                                            serdes_m_phy_change->val_hi_speed);
+                                       } else {
+                                               reg_write(SATA_BASE_REG
+                                                         (sata_port) |
+                                                         serdes_m_phy_change->reg_low_speed,
+                                                         serdes_m_phy_change->val_low_speed);
+                                               DEBUG_WR_REG(SATA_BASE_REG
+                                                            (sata_port) |
+                                                            serdes_m_phy_change->reg_low_speed,
+                                                            serdes_m_phy_change->val_low_speed);
+                                       }
+                                       break;
+                               case SERDES_UNIT_SGMII0:
+                               case SERDES_UNIT_SGMII1:
+                               case SERDES_UNIT_SGMII2:
+                               case SERDES_UNIT_SGMII3:
+                                       if (line_cfg == serdes_cfg[line_num]
+                                           [SERDES_UNIT_SGMII0])
+                                               sgmii_port = 0;
+                                       else if (line_cfg ==
+                                                serdes_cfg[line_num]
+                                                [SERDES_UNIT_SGMII1])
+                                               sgmii_port = 1;
+                                       else if (line_cfg ==
+                                                serdes_cfg[line_num]
+                                                [SERDES_UNIT_SGMII2])
+                                               sgmii_port = 2;
+                                       else if (line_cfg ==
+                                                serdes_cfg[line_num]
+                                                [SERDES_UNIT_SGMII3])
+                                               sgmii_port = 3;
+                                       else
+                                               break;
+                                       if (bus_speed) {
+                                               reg_write(MV_ETH_REGS_BASE
+                                                         (sgmii_port) |
+                                                         serdes_m_phy_change->reg_hi_speed,
+                                                         serdes_m_phy_change->val_hi_speed);
+                                               DEBUG_WR_REG(MV_ETH_REGS_BASE
+                                                            (sgmii_port) |
+                                                            serdes_m_phy_change->reg_hi_speed,
+                                                            serdes_m_phy_change->val_hi_speed);
+                                       } else {
+                                               reg_write(MV_ETH_REGS_BASE
+                                                         (sgmii_port) |
+                                                         serdes_m_phy_change->reg_low_speed,
+                                                         serdes_m_phy_change->val_low_speed);
+                                               DEBUG_WR_REG(MV_ETH_REGS_BASE
+                                                            (sgmii_port) |
+                                                            serdes_m_phy_change->reg_low_speed,
+                                                            serdes_m_phy_change->val_low_speed);
+                                       }
+                                       break;
+                               case SERDES_UNIT_QSGMII:
+                                       if (line_cfg != SERDES_UNIT_QSGMII)
+                                               break;
+                                       if (bus_speed) {
+                                               reg_write
+                                                   (serdes_m_phy_change->reg_hi_speed,
+                                                    serdes_m_phy_change->val_hi_speed);
+                                               DEBUG_WR_REG
+                                                   (serdes_m_phy_change->reg_hi_speed,
+                                                    serdes_m_phy_change->val_hi_speed);
+                                       } else {
+                                               reg_write
+                                                   (serdes_m_phy_change->reg_low_speed,
+                                                    serdes_m_phy_change->val_low_speed);
+                                               DEBUG_WR_REG
+                                                   (serdes_m_phy_change->reg_low_speed,
+                                                    serdes_m_phy_change->val_low_speed);
+                                       }
+                                       break;
+                               default:
+                                       break;
+                               }
+                               serdes_m_phy_change++;
+                       }
+               }
+       }
+
+       /* Step 16 [PEX-Only] Training Enable */
+       DEBUG_INIT_FULL_S("Steps 16: [PEX-Only] Training Enable");
+       tmp = reg_read(SOC_CTRL_REG);
+       DEBUG_RD_REG(SOC_CTRL_REG, tmp);
+       tmp &= ~(0x0F);
+       for (pex_unit = 0; pex_unit < pex_max_unit_get(); pex_unit++) {
+               reg_write(PEX_CAUSE_REG(pex_unit), 0);
+               DEBUG_WR_REG(PEX_CAUSE_REG(pex_unit), 0);
+               if (info->pex_mode[pex_unit] != PEX_BUS_DISABLED)
+                       tmp |= (0x1 << pex_unit);
+       }
+       reg_write(SOC_CTRL_REG, tmp);
+       DEBUG_WR_REG(SOC_CTRL_REG, tmp);
+
+       /* Step 17: Speed change to target speed and width */
+       {
+               u32 tmp_reg, tmp_pex_reg;
+               u32 addr;
+               u32 first_busno, next_busno;
+               u32 max_link_width = 0;
+               u32 neg_link_width = 0;
+               pex_if_num = pex_max_if_get();
+               mdelay(150);
+               DEBUG_INIT_FULL_C("step 17: max_if= 0x", pex_if_num, 1);
+               next_busno = 0;
+               for (pex_if = 0; pex_if < pex_if_num; pex_if++) {
+                       line_num = (pex_if <= 8) ? pex_if : 12;
+                       line_cfg = get_line_cfg(line_num, info);
+                       if (line_cfg != serdes_cfg[line_num][SERDES_UNIT_PEX])
+                               continue;
+                       pex_unit = (pex_if < 9) ? (pex_if >> 2) : 3;
+                       DEBUG_INIT_FULL_S("step 17:  PEX");
+                       DEBUG_INIT_FULL_D(pex_if, 1);
+                       DEBUG_INIT_FULL_C("  pex_unit= ", pex_unit, 1);
+
+                       if (info->pex_mode[pex_unit] == PEX_BUS_DISABLED) {
+                               DEBUG_INIT_FULL_C("PEX disabled interface ",
+                                                 pex_if, 1);
+                               if (pex_if < 8)
+                                       pex_if += 3;
+                               continue;
+                       }
+                       first_busno = next_busno;
+                       if ((info->pex_type == MV_PEX_END_POINT) &&
+                           (0 == pex_if)) {
+                               if ((pex_if < 8) && (info->pex_mode[pex_unit] ==
+                                                    PEX_BUS_MODE_X4))
+                                       pex_if += 3;
+                               continue;
+                       }
+
+                       tmp = reg_read(PEX_DBG_STATUS_REG(pex_if));
+                       DEBUG_RD_REG(PEX_DBG_STATUS_REG(pex_if), tmp);
+                       if ((tmp & 0x7f) == 0x7e) {
+                               next_busno++;
+                               tmp = reg_read(PEX_LINK_CAPABILITIES_REG(pex_if));
+                               max_link_width = tmp;
+                               DEBUG_RD_REG((PEX_LINK_CAPABILITIES_REG
+                                             (pex_if)), tmp);
+                               max_link_width = ((max_link_width >> 4) & 0x3F);
+                               neg_link_width =
+                                   reg_read(PEX_LINK_CTRL_STATUS_REG(pex_if));
+                               DEBUG_RD_REG((PEX_LINK_CTRL_STATUS_REG(pex_if)),
+                                            neg_link_width);
+                               neg_link_width = ((neg_link_width >> 20) & 0x3F);
+                               if (max_link_width > neg_link_width) {
+                                       tmp &= ~(0x3F << 4);
+                                       tmp |= (neg_link_width << 4);
+                                       reg_write(PEX_LINK_CAPABILITIES_REG
+                                                 (pex_if), tmp);
+                                       DEBUG_WR_REG((PEX_LINK_CAPABILITIES_REG
+                                                     (pex_if)), tmp);
+                                       mdelay(1);      /* wait 1ms before reading  capability for speed */
+                                       DEBUG_INIT_S("PEX");
+                                       DEBUG_INIT_D(pex_if, 1);
+                                       DEBUG_INIT_C(": change width to X",
+                                                    neg_link_width, 1);
+                               }
+                               tmp_pex_reg =
+                                   reg_read((PEX_CFG_DIRECT_ACCESS
+                                             (pex_if,
+                                              PEX_LINK_CAPABILITY_REG)));
+                               DEBUG_RD_REG((PEX_CFG_DIRECT_ACCESS
+                                             (pex_if,
+                                              PEX_LINK_CAPABILITY_REG)),
+                                            tmp_pex_reg);
+                               tmp_pex_reg &= (0xF);
+                               if (tmp_pex_reg == 0x2) {
+                                       tmp_reg =
+                                           (reg_read
+                                            (PEX_CFG_DIRECT_ACCESS
+                                             (pex_if,
+                                              PEX_LINK_CTRL_STAT_REG)) &
+                                            0xF0000) >> 16;
+                                       DEBUG_RD_REG(PEX_CFG_DIRECT_ACCESS
+                                                    (pex_if,
+                                                     PEX_LINK_CTRL_STAT_REG),
+                                                    tmp_pex_reg);
+                                       /* check if the link established is GEN1 */
+                                       if (tmp_reg == 0x1) {
+                                               pex_local_bus_num_set(pex_if,
+                                                                     first_busno);
+                                               pex_local_dev_num_set(pex_if,
+                                                                     1);
+
+                                               DEBUG_INIT_FULL_S("** Link is Gen1, check the EP capability\n");
+                                               /* link is Gen1, check the EP capability */
+                                               addr =
+                                                   pex_cfg_read(pex_if,
+                                                                first_busno, 0,
+                                                                0,
+                                                                0x34) & 0xFF;
+                                               DEBUG_INIT_FULL_C("pex_cfg_read: return addr=0x%x",
+                                                    addr, 4);
+                                               if (addr == 0xff) {
+                                                       DEBUG_INIT_FULL_C("pex_cfg_read: return 0xff -->PEX (%d): Detected No Link.",
+                                                                         pex_if, 1);
+                                                       continue;
+                                               }
+                                               while ((pex_cfg_read
+                                                       (pex_if, first_busno, 0,
+                                                        0,
+                                                        addr) & 0xFF) !=
+                                                      0x10) {
+                                                       addr =
+                                                           (pex_cfg_read
+                                                            (pex_if,
+                                                             first_busno, 0, 0,
+                                                             addr) & 0xFF00) >>
+                                                           8;
+                                               }
+                                               if ((pex_cfg_read
+                                                    (pex_if, first_busno, 0, 0,
+                                                     addr + 0xC) & 0xF) >=
+                                                   0x2) {
+                                                       tmp =
+                                                           reg_read
+                                                           (PEX_LINK_CTRL_STATUS2_REG
+                                                            (pex_if));
+                                                       DEBUG_RD_REG
+                                                           (PEX_LINK_CTRL_STATUS2_REG
+                                                            (pex_if), tmp);
+                                                       tmp &= ~(0x1 | 1 << 1);
+                                                       tmp |= (1 << 1);
+                                                       reg_write
+                                                           (PEX_LINK_CTRL_STATUS2_REG
+                                                            (pex_if), tmp);
+                                                       DEBUG_WR_REG
+                                                           (PEX_LINK_CTRL_STATUS2_REG
+                                                            (pex_if), tmp);
+
+                                                       tmp =
+                                                           reg_read
+                                                           (PEX_CTRL_REG
+                                                            (pex_if));
+                                                       DEBUG_RD_REG
+                                                           (PEX_CTRL_REG
+                                                            (pex_if), tmp);
+                                                       tmp |= (1 << 10);
+                                                       reg_write(PEX_CTRL_REG
+                                                                 (pex_if),
+                                                                 tmp);
+                                                       DEBUG_WR_REG
+                                                           (PEX_CTRL_REG
+                                                            (pex_if), tmp);
+                                                       mdelay(10);     /* We need to wait 10ms before reading the PEX_DBG_STATUS_REG in order not to read the status of the former state */
+                                                       DEBUG_INIT_FULL_S
+                                                           ("Gen2 client!\n");
+                                               } else {
+                                                       DEBUG_INIT_FULL_S
+                                                           ("GEN1 client!\n");
+                                               }
+                                       }
+                               }
+                       } else {
+                               DEBUG_INIT_FULL_S("PEX");
+                               DEBUG_INIT_FULL_D(pex_if, 1);
+                               DEBUG_INIT_FULL_S(" : Detected No Link. Status Reg(0x");
+                               DEBUG_INIT_FULL_D(PEX_DBG_STATUS_REG(pex_if),
+                                                 8);
+                               DEBUG_INIT_FULL_C(") = 0x", tmp, 8);
+                       }
+
+                       if ((pex_if < 8) &&
+                           (info->pex_mode[pex_unit] == PEX_BUS_MODE_X4))
+                               pex_if += 3;
+               }
+       }
+
+       /* Step 18: update pex DEVICE ID */
+       {
+               u32 devId;
+               pex_if_num = pex_max_if_get();
+               ctrl_mode = ctrl_model_get();
+               for (pex_if = 0; pex_if < pex_if_num; pex_if++) {
+                       pex_unit = (pex_if < 9) ? (pex_if >> 2) : 3;
+                       if (info->pex_mode[pex_unit] == PEX_BUS_DISABLED) {
+                               if ((pex_if < 8) &&
+                                   (info->pex_mode[pex_unit] == PEX_BUS_MODE_X4))
+                                       pex_if += 3;
+                               continue;
+                       }
+
+                       devId = reg_read(PEX_CFG_DIRECT_ACCESS(
+                                                pex_if, PEX_DEVICE_AND_VENDOR_ID));
+                       devId &= 0xFFFF;
+                       devId |= ((ctrl_mode << 16) & 0xffff0000);
+                       DEBUG_INIT_S("Update Device ID PEX");
+                       DEBUG_INIT_D(pex_if, 1);
+                       DEBUG_INIT_D(devId, 8);
+                       DEBUG_INIT_S("\n");
+                       reg_write(PEX_CFG_DIRECT_ACCESS
+                                 (pex_if, PEX_DEVICE_AND_VENDOR_ID), devId);
+                       if ((pex_if < 8) &&
+                           (info->pex_mode[pex_unit] == PEX_BUS_MODE_X4))
+                               pex_if += 3;
+               }
+               DEBUG_INIT_S("Update PEX Device ID 0x");
+               DEBUG_INIT_D(ctrl_mode, 4);
+               DEBUG_INIT_S("0\n");
+       }
+       tmp = reg_read(PEX_DBG_STATUS_REG(0));
+       DEBUG_RD_REG(PEX_DBG_STATUS_REG(0), tmp);
+
+       DEBUG_INIT_S(ENDED_OK);
+       return MV_OK;
+}
+
+/* PEX configuration space read write */
+
+/*
+ * pex_cfg_read - Read from configuration space
+ *
+ * DESCRIPTION:
+ *       This function performs a 32 bit read from PEX configuration space.
+ *       It supports both type 0 and type 1 of Configuration Transactions
+ *       (local and over bridge). In order to read from local bus segment, use
+ *       bus number retrieved from mvPexLocalBusNumGet(). Other bus numbers
+ *       will result configuration transaction of type 1 (over bridge).
+ *
+ * INPUT:
+ *       pex_if   - PEX interface number.
+ *       bus     - PEX segment bus number.
+ *       dev     - PEX device number.
+ *       func    - Function number.
+ *       offss - Register offset.
+ *
+ * OUTPUT:
+ *       None.
+ *
+ * RETURN:
+ *       32bit register data, 0xffffffff on error
+ *
+ */
+u32 pex_cfg_read(u32 pex_if, u32 bus, u32 dev, u32 func, u32 offs)
+{
+       u32 pex_data = 0;
+       u32 local_dev, local_bus;
+       u32 val;
+
+       if (pex_if >= MV_PEX_MAX_IF)
+               return 0xFFFFFFFF;
+
+       if (dev >= MAX_PEX_DEVICES) {
+               DEBUG_INIT_C("pex_cfg_read: ERR. device number illigal ", dev,
+                            1);
+               return 0xFFFFFFFF;
+       }
+
+       if (func >= MAX_PEX_FUNCS) {
+               DEBUG_INIT_C("pex_cfg_read: ERR. function num illigal ", func,
+                            1);
+               return 0xFFFFFFFF;
+       }
+
+       if (bus >= MAX_PEX_BUSSES) {
+               DEBUG_INIT_C("pex_cfg_read: ERR. bus number illigal ", bus, 1);
+               return MV_ERROR;
+       }
+       val = reg_read(PEX_STATUS_REG(pex_if));
+
+       local_dev =
+           ((val & PXSR_PEX_DEV_NUM_MASK) >> PXSR_PEX_DEV_NUM_OFFS);
+       local_bus =
+           ((val & PXSR_PEX_BUS_NUM_MASK) >> PXSR_PEX_BUS_NUM_OFFS);
+
+       /* Speed up the process. In case on no link, return MV_ERROR */
+       if ((dev != local_dev) || (bus != local_bus)) {
+               pex_data = reg_read(PEX_STATUS_REG(pex_if));
+
+               if ((pex_data & PXSR_DL_DOWN))
+                       return MV_ERROR;
+       }
+
+       /*
+        * In PCI Express we have only one device number
+        * and this number is the first number we encounter else that the
+        * local_dev spec pex define return on config read/write on any device
+        */
+       if (bus == local_bus) {
+               if (local_dev == 0) {
+                       /*
+                        * If local dev is 0 then the first number we encounter
+                        * after 0 is 1
+                        */
+                       if ((dev != 1) && (dev != local_dev))
+                               return MV_ERROR;
+               } else {
+                       /*
+                        * If local dev is not 0 then the first number we
+                        * encounter is 0
+                        */
+                       if ((dev != 0) && (dev != local_dev))
+                               return MV_ERROR;
+               }
+       }
+
+       /* Creating PEX address to be passed */
+       pex_data = (bus << PXCAR_BUS_NUM_OFFS);
+       pex_data |= (dev << PXCAR_DEVICE_NUM_OFFS);
+       pex_data |= (func << PXCAR_FUNC_NUM_OFFS);
+       pex_data |= (offs & PXCAR_REG_NUM_MASK);        /* lgacy register space */
+       /* extended register space */
+       pex_data |= (((offs & PXCAR_REAL_EXT_REG_NUM_MASK) >>
+                    PXCAR_REAL_EXT_REG_NUM_OFFS) << PXCAR_EXT_REG_NUM_OFFS);
+
+       pex_data |= PXCAR_CONFIG_EN;
+
+       /* Write the address to the PEX configuration address register */
+       reg_write(PEX_CFG_ADDR_REG(pex_if), pex_data);
+
+       /*
+        * In order to let the PEX controller absorbed the address of the read
+        * transaction we perform a validity check that the address was written
+        */
+       if (pex_data != reg_read(PEX_CFG_ADDR_REG(pex_if)))
+               return MV_ERROR;
+
+       /* cleaning Master Abort */
+       reg_bit_set(PEX_CFG_DIRECT_ACCESS(pex_if, PEX_STATUS_AND_COMMAND),
+                   PXSAC_MABORT);
+       /* Read the Data returned in the PEX Data register */
+       pex_data = reg_read(PEX_CFG_DATA_REG(pex_if));
+
+       DEBUG_INIT_FULL_C(" --> ", pex_data, 4);
+
+       return pex_data;
+}
+
+/*
+ * pex_local_bus_num_set - Set PEX interface local bus number.
+ *
+ * DESCRIPTION:
+ *       This function sets given PEX interface its local bus number.
+ *       Note: In case the PEX interface is PEX-X, the information is read-only.
+ *
+ * INPUT:
+ *       pex_if  - PEX interface number.
+ *       bus_num - Bus number.
+ *
+ * OUTPUT:
+ *       None.
+ *
+ * RETURN:
+ *       MV_NOT_ALLOWED in case PEX interface is PEX-X.
+ *             MV_BAD_PARAM on bad parameters ,
+ *       otherwise MV_OK
+ *
+ */
+int pex_local_bus_num_set(u32 pex_if, u32 bus_num)
+{
+       u32 val;
+
+       if (bus_num >= MAX_PEX_BUSSES) {
+               DEBUG_INIT_C("pex_local_bus_num_set: ERR. bus number illigal %d\n",
+                    bus_num, 4);
+               return MV_ERROR;
+       }
+
+       val = reg_read(PEX_STATUS_REG(pex_if));
+       val &= ~PXSR_PEX_BUS_NUM_MASK;
+       val |= (bus_num << PXSR_PEX_BUS_NUM_OFFS) & PXSR_PEX_BUS_NUM_MASK;
+       reg_write(PEX_STATUS_REG(pex_if), val);
+
+       return MV_OK;
+}
+
+/*
+ * pex_local_dev_num_set - Set PEX interface local device number.
+ *
+ * DESCRIPTION:
+ *       This function sets given PEX interface its local device number.
+ *       Note: In case the PEX interface is PEX-X, the information is read-only.
+ *
+ * INPUT:
+ *       pex_if  - PEX interface number.
+ *       dev_num - Device number.
+ *
+ * OUTPUT:
+ *       None.
+ *
+ * RETURN:
+ *       MV_NOT_ALLOWED in case PEX interface is PEX-X.
+ *             MV_BAD_PARAM on bad parameters ,
+ *       otherwise MV_OK
+ *
+ */
+int pex_local_dev_num_set(u32 pex_if, u32 dev_num)
+{
+       u32 val;
+
+       if (pex_if >= MV_PEX_MAX_IF)
+               return MV_BAD_PARAM;
+
+       val = reg_read(PEX_STATUS_REG(pex_if));
+       val &= ~PXSR_PEX_DEV_NUM_MASK;
+       val |= (dev_num << PXSR_PEX_DEV_NUM_OFFS) & PXSR_PEX_DEV_NUM_MASK;
+       reg_write(PEX_STATUS_REG(pex_if), val);
+
+       return MV_OK;
+}
diff --git a/arch/arm/mvebu-common/serdes/high_speed_env_spec.c b/arch/arm/mvebu-common/serdes/high_speed_env_spec.c
new file mode 100644 (file)
index 0000000..115ec2c
--- /dev/null
@@ -0,0 +1,185 @@
+/*
+ * Copyright (C) Marvell International Ltd. and its affiliates
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#include <common.h>
+#include <i2c.h>
+#include <spl.h>
+#include <asm/io.h>
+#include <asm/arch/cpu.h>
+#include <asm/arch/soc.h>
+
+#include "high_speed_env_spec.h"
+
+MV_SERDES_CHANGE_M_PHY serdes_change_m_phy[] = {
+       /* SERDES TYPE, Low REG OFFS, Low REG VALUE, Hi REG OFS, Hi REG VALUE */
+       {
+               /* PEX: Change of Slew Rate port0   */
+               SERDES_UNIT_PEX, 0x0,
+               (0x0F << 16) | 0x2a21, 0x0, (0x0F << 16) | 0x2a21
+       }, {
+               /* PEX: Change PLL BW port0                   */
+               SERDES_UNIT_PEX, 0x0,
+               (0x4F << 16) | 0x6219, 0x0, (0x4F << 16) | 0x6219
+       }, {
+               /* SATA: Slew rate change port 0  */
+               SERDES_UNIT_SATA, 0x0083C, 0x8a31, 0x0083C, 0x8a31
+       }, {
+               /* SATA: Slew rate change port 0  */
+               SERDES_UNIT_SATA, 0x00834, 0xc928, 0x00834, 0xc928
+       }, {
+               /* SATA: Slew rate change port 0  */
+               SERDES_UNIT_SATA, 0x00838, 0x30f0, 0x00838, 0x30f0
+       }, {
+               /* SATA: Slew rate change port 0  */
+               SERDES_UNIT_SATA, 0x00840, 0x30f5, 0x00840, 0x30f5
+       }, {
+               /* SGMII: FFE setting Port0         */
+               SERDES_UNIT_SGMII0, 0x00E18, 0x989F, 0x00E18, 0x989F
+       }, {
+               /* SGMII: SELMUP and SELMUF Port0   */
+               SERDES_UNIT_SGMII0, 0x00E38, 0x10FA, 0x00E38, 0x10FA
+       }, {
+               /* SGMII: Amplitude new setting gen2 Port3 */
+               SERDES_UNIT_SGMII0, 0x00E34, 0xC968, 0x00E34, 0xC66C
+       }, {
+               /* QSGMII: Amplitude and slew rate change  */
+               SERDES_UNIT_QSGMII, 0x72E34, 0xaa58, 0x72E34, 0xaa58
+       }, {
+               /* QSGMII: SELMUP and SELMUF               */
+               SERDES_UNIT_QSGMII, 0x72e38, 0x10aF, 0x72e38, 0x10aF
+       }, {
+               /* QSGMII: 0x72e18                         */
+               SERDES_UNIT_QSGMII, 0x72e18, 0x98AC, 0x72e18, 0x98AC
+       }, {
+               /* Null terminated */
+               SERDES_UNIT_UNCONNECTED, 0, 0
+       }
+};
+
+MV_BIN_SERDES_CFG db88f78xx0_serdes_cfg[] = {
+       /* Z1B */
+       {MV_PEX_ROOT_COMPLEX, 0x32221111, 0x11111111,
+        {PEX_BUS_MODE_X1, PEX_BUS_DISABLED, PEX_BUS_MODE_X4, PEX_BUS_MODE_X4},
+        0x0030, serdes_change_m_phy},                  /* Default */
+       {MV_PEX_ROOT_COMPLEX, 0x31211111, 0x11111111,
+        {PEX_BUS_MODE_X1, PEX_BUS_MODE_X1, PEX_BUS_MODE_X4, PEX_BUS_MODE_X4},
+        0x0030, serdes_change_m_phy},                  /* PEX module */
+       /* Z1A */
+       {MV_PEX_ROOT_COMPLEX, 0x32220000, 0x00000000,
+        {PEX_BUS_DISABLED, PEX_BUS_DISABLED, PEX_BUS_DISABLED,
+         PEX_BUS_DISABLED}, 0x0030, serdes_change_m_phy}, /* Default - Z1A */
+       {MV_PEX_ROOT_COMPLEX, 0x31210000, 0x00000000,
+        {PEX_BUS_DISABLED, PEX_BUS_MODE_X1, PEX_BUS_DISABLED, PEX_BUS_DISABLED},
+        0x0030, serdes_change_m_phy}   /* PEX module - Z1A */
+};
+
+MV_BIN_SERDES_CFG db88f78xx0rev2_serdes_cfg[] = {
+       /* A0 */
+       {MV_PEX_ROOT_COMPLEX, 0x33221111, 0x11111111,
+        {PEX_BUS_MODE_X1, PEX_BUS_DISABLED, PEX_BUS_MODE_X4, PEX_BUS_MODE_X4},
+        0x0030, serdes_change_m_phy}, /* Default: No Pex module, PEX0 x1, disabled */
+       {MV_PEX_ROOT_COMPLEX, 0x33211111, 0x11111111,
+        {PEX_BUS_MODE_X1, PEX_BUS_MODE_X1, PEX_BUS_MODE_X4, PEX_BUS_MODE_X4},
+        0x0030, serdes_change_m_phy}, /* Pex module, PEX0 x1, PEX1 x1 */
+       {MV_PEX_ROOT_COMPLEX, 0x33221111, 0x11111111,
+        {PEX_BUS_MODE_X4, PEX_BUS_DISABLED, PEX_BUS_MODE_X4, PEX_BUS_MODE_X4},
+        0x0030, serdes_change_m_phy}, /* no Pex module, PEX0 x4, PEX1 disabled */
+       {MV_PEX_ROOT_COMPLEX, 0x33211111, 0x11111111,
+        {PEX_BUS_MODE_X4, PEX_BUS_MODE_X1, PEX_BUS_MODE_X4, PEX_BUS_MODE_X4},
+        0x0030, serdes_change_m_phy}, /* Pex module, PEX0 x4, PEX1 x1 */
+       {MV_PEX_ROOT_COMPLEX, 0x11111111, 0x11111111,
+        {PEX_BUS_MODE_X1, PEX_BUS_MODE_X4, PEX_BUS_MODE_X4, PEX_BUS_MODE_X4},
+        0x0030, serdes_change_m_phy}, /* Pex module, PEX0 x1, PEX1 x4 */
+       {MV_PEX_ROOT_COMPLEX, 0x11111111, 0x11111111,
+        {PEX_BUS_MODE_X4, PEX_BUS_MODE_X4, PEX_BUS_MODE_X4, PEX_BUS_MODE_X4},
+        0x0030, serdes_change_m_phy}, /* Pex module, PEX0 x4, PEX1 x4 */
+};
+
+MV_BIN_SERDES_CFG rd78460nas_serdes_cfg[] = {
+       {MV_PEX_ROOT_COMPLEX, 0x00223001, 0x11111111,
+        {PEX_BUS_MODE_X1, PEX_BUS_DISABLED, PEX_BUS_MODE_X4, PEX_BUS_MODE_X4},
+        0x0030, serdes_change_m_phy}, /* Default */
+       {MV_PEX_ROOT_COMPLEX, 0x33320201, 0x11111111,
+        {PEX_BUS_MODE_X1, PEX_BUS_DISABLED, PEX_BUS_MODE_X4, PEX_BUS_MODE_X4},
+        0x00f4, serdes_change_m_phy}, /* Switch module */
+};
+
+MV_BIN_SERDES_CFG rd78460_serdes_cfg[] = {
+       {MV_PEX_ROOT_COMPLEX, 0x22321111, 0x00000000,
+        {PEX_BUS_MODE_X4, PEX_BUS_DISABLED, PEX_BUS_DISABLED, PEX_BUS_DISABLED},
+        0x0010, serdes_change_m_phy}, /* CPU0 */
+       {MV_PEX_ROOT_COMPLEX, 0x00321111, 0x00000000,
+        {PEX_BUS_MODE_X4, PEX_BUS_DISABLED, PEX_BUS_DISABLED, PEX_BUS_DISABLED},
+        0x0010, serdes_change_m_phy} /* CPU1-3 */
+};
+
+MV_BIN_SERDES_CFG rd78460server_rev2_serdes_cfg[] = {
+       {MV_PEX_ROOT_COMPLEX, 0x00321111, 0x00000000,
+        {PEX_BUS_MODE_X4, PEX_BUS_DISABLED, PEX_BUS_DISABLED, PEX_BUS_DISABLED},
+        0x0010, serdes_change_m_phy}, /* CPU0 */
+       {MV_PEX_ROOT_COMPLEX, 0x00321111, 0x00000000,
+        {PEX_BUS_MODE_X4, PEX_BUS_DISABLED, PEX_BUS_DISABLED, PEX_BUS_DISABLED},
+        0x0010, serdes_change_m_phy} /* CPU1-3 */
+};
+
+MV_BIN_SERDES_CFG db78X60pcac_serdes_cfg[] = {
+       {MV_PEX_END_POINT, 0x22321111, 0x00000000,
+        {PEX_BUS_MODE_X4, PEX_BUS_DISABLED, PEX_BUS_DISABLED, PEX_BUS_DISABLED},
+        0x0010, serdes_change_m_phy}   /* Default */
+};
+
+MV_BIN_SERDES_CFG db78X60pcacrev2_serdes_cfg[] = {
+       {MV_PEX_END_POINT, 0x23321111, 0x00000000,
+        {PEX_BUS_MODE_X4, PEX_BUS_DISABLED, PEX_BUS_DISABLED, PEX_BUS_DISABLED},
+        0x0010, serdes_change_m_phy}   /* Default */
+};
+
+MV_BIN_SERDES_CFG fpga88f78xx0_serdes_cfg[] = {
+       {MV_PEX_ROOT_COMPLEX, 0x00000000, 0x00000000,
+        {PEX_BUS_DISABLED, PEX_BUS_DISABLED, PEX_BUS_DISABLED, PEX_BUS_DISABLED},
+        0x0000, serdes_change_m_phy}   /* No PEX in FPGA */
+};
+
+MV_BIN_SERDES_CFG db78X60amc_serdes_cfg[] = {
+       {MV_PEX_ROOT_COMPLEX, 0x33111111, 0x00010001,
+        {PEX_BUS_MODE_X4, PEX_BUS_MODE_X1, PEX_BUS_MODE_X1, PEX_BUS_MODE_X1},
+        0x0030, serdes_change_m_phy}   /* Default */
+};
+
+/*
+ * ARMADA-XP CUSTOMER BOARD
+ */
+MV_BIN_SERDES_CFG rd78460customer_serdes_cfg[] = {
+       {MV_PEX_ROOT_COMPLEX, 0x00223001, 0x11111111,
+        {PEX_BUS_MODE_X1, PEX_BUS_DISABLED, PEX_BUS_MODE_X4, PEX_BUS_MODE_X4},
+        0x00000030, serdes_change_m_phy}, /* Default */
+       {MV_PEX_ROOT_COMPLEX, 0x33320201, 0x11111111,
+        {PEX_BUS_MODE_X1, PEX_BUS_DISABLED, PEX_BUS_MODE_X4, PEX_BUS_MODE_X4},
+        0x00000030, serdes_change_m_phy}, /* Switch module */
+};
+
+MV_BIN_SERDES_CFG rd78460AXP_GP_serdes_cfg[] = {
+       {MV_PEX_ROOT_COMPLEX, 0x00223001, 0x11111111,
+        {PEX_BUS_MODE_X1, PEX_BUS_DISABLED, PEX_BUS_MODE_X4, PEX_BUS_MODE_X4},
+        0x0030, serdes_change_m_phy}   /* Default */
+};
+
+MV_BIN_SERDES_CFG *serdes_info_tbl[] = {
+       db88f78xx0_serdes_cfg,
+       rd78460_serdes_cfg,
+       db78X60pcac_serdes_cfg,
+       fpga88f78xx0_serdes_cfg,
+       db88f78xx0rev2_serdes_cfg,
+       rd78460nas_serdes_cfg,
+       db78X60amc_serdes_cfg,
+       db78X60pcacrev2_serdes_cfg,
+       rd78460server_rev2_serdes_cfg,
+       rd78460AXP_GP_serdes_cfg,
+       rd78460customer_serdes_cfg
+};
+
+u8 rd78460gp_twsi_dev[] = { 0x4C, 0x4D, 0x4E };
+u8 db88f78xx0rev2_twsi_dev[] = { 0x4C, 0x4D, 0x4E, 0x4F };
diff --git a/arch/arm/mvebu-common/serdes/high_speed_env_spec.h b/arch/arm/mvebu-common/serdes/high_speed_env_spec.h
new file mode 100644 (file)
index 0000000..e5aa1b0
--- /dev/null
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) Marvell International Ltd. and its affiliates
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#ifndef __HIGHSPEED_ENV_SPEC_H
+#define __HIGHSPEED_ENV_SPEC_H
+
+#include "../../../drivers/ddr/mvebu/ddr3_hw_training.h"
+
+typedef enum {
+       SERDES_UNIT_UNCONNECTED = 0x0,
+       SERDES_UNIT_PEX         = 0x1,
+       SERDES_UNIT_SATA        = 0x2,
+       SERDES_UNIT_SGMII0      = 0x3,
+       SERDES_UNIT_SGMII1      = 0x4,
+       SERDES_UNIT_SGMII2      = 0x5,
+       SERDES_UNIT_SGMII3      = 0x6,
+       SERDES_UNIT_QSGMII      = 0x7,
+       SERDES_UNIT_SETM        = 0x8,
+       SERDES_LAST_UNIT
+} MV_BIN_SERDES_UNIT_INDX;
+
+
+typedef enum {
+       PEX_BUS_DISABLED        = 0,
+       PEX_BUS_MODE_X1         = 1,
+       PEX_BUS_MODE_X4         = 2,
+       PEX_BUS_MODE_X8         = 3
+} MV_PEX_UNIT_CFG;
+
+typedef enum pex_type {
+       MV_PEX_ROOT_COMPLEX,    /* root complex device */
+       MV_PEX_END_POINT        /* end point device */
+} MV_PEX_TYPE;
+
+typedef struct serdes_change_m_phy {
+       MV_BIN_SERDES_UNIT_INDX type;
+       u32 reg_low_speed;
+       u32 val_low_speed;
+       u32 reg_hi_speed;
+       u32 val_hi_speed;
+} MV_SERDES_CHANGE_M_PHY;
+
+/*
+ * Configuration per SERDES line. Each nibble is MV_SERDES_LINE_TYPE
+ */
+typedef struct board_serdes_conf {
+       MV_PEX_TYPE pex_type; /* MV_PEX_ROOT_COMPLEX MV_PEX_END_POINT */
+       u32 line0_7; /* Lines 0 to 7 SERDES MUX one nibble per line */
+       u32 line8_15; /* Lines 8 to 15 SERDES MUX one nibble per line */
+       MV_PEX_UNIT_CFG pex_mode[4];
+
+       /*
+        * Bus speed - one bit per SERDES line:
+        *              Low speed (0)           High speed (1)
+        * PEX          2.5 G (10 bit)          5 G (20 bit)
+        * SATA         1.5 G                   3 G
+        * SGMII        1.25 Gbps               3.125 Gbps
+        */
+       u32     bus_speed;
+
+       MV_SERDES_CHANGE_M_PHY *serdes_m_phy_change;
+} MV_BIN_SERDES_CFG;
+
+
+#define BIN_SERDES_CFG {       \
+       {0, 1, -1 , -1, -1, -1, -1, -1, -1}, /* Lane 0 */       \
+       {0, 1, -1 , -1, -1, -1, -1, -1,  2}, /* Lane 1 */       \
+       {0, 1, -1 ,  2, -1, -1, -1, -1,  3}, /* Lane 2 */       \
+       {0, 1, -1 , -1,  2, -1, -1,  3, -1}, /* Lane 3 */       \
+       {0, 1,  2 , -1, -1,  3, -1, -1,  4}, /* Lane 4 */       \
+       {0, 1,  2 , -1,  3, -1, -1,  4, -1}, /* Lane 5 */       \
+       {0, 1,  2 ,  4, -1,  3, -1, -1, -1}, /* Lane 6 */       \
+       {0, 1, -1 ,  2, -1, -1,  3, -1,  4}, /* Lane 7*/        \
+       {0, 1, -1 , -1, -1, -1, -1, -1, -1}, /* Lane 8 */       \
+       {0, 1, -1 , -1, -1, -1, -1, -1, -1}, /* Lane 9 */       \
+       {0, 1, -1 , -1, -1, -1, -1, -1, -1}, /* Lane 10 */      \
+       {0, 1, -1 , -1, -1, -1, -1, -1, -1}, /* Lane 11 */      \
+       {0, 1, -1 , -1, -1, -1, -1, -1, -1}, /* Lane 12 */      \
+       {0, 1, -1 , -1, -1, -1, -1, -1, -1}, /* Lane 13 */      \
+       {0, 1, -1 , -1, -1, -1, -1, -1, -1}, /* Lane 14 */      \
+       {0, 1, -1 , -1, -1, -1, -1, -1, -1}, /* Lane 15 */      \
+}
+
+#endif /* __HIGHSPEED_ENV_SPEC_H */
diff --git a/arch/arm/mvebu-common/u-boot-spl.lds b/arch/arm/mvebu-common/u-boot-spl.lds
new file mode 100644 (file)
index 0000000..eee1db4
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * (C) Copyright 2002
+ * Gary Jennejohn, DENX Software Engineering, <garyj@denx.de>
+ *
+ * (C) Copyright 2010
+ * Texas Instruments, <www.ti.com>
+ *     Aneesh V <aneesh@ti.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+MEMORY { .sram : ORIGIN = CONFIG_SPL_TEXT_BASE,\
+               LENGTH = CONFIG_SPL_MAX_SIZE }
+MEMORY { .sdram : ORIGIN = CONFIG_SPL_BSS_START_ADDR, \
+               LENGTH = CONFIG_SPL_BSS_MAX_SIZE }
+
+OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
+OUTPUT_ARCH(arm)
+ENTRY(_start)
+SECTIONS
+{
+       .text      :
+       {
+               __start = .;
+               arch/arm/cpu/armv7/start.o      (.text*)
+               *(.text*)
+               *(.vectors)
+       } >.sram
+
+       . = ALIGN(4);
+       .rodata : { *(SORT_BY_ALIGNMENT(.rodata*)) } >.sram
+
+       . = ALIGN(4);
+       .data : { *(SORT_BY_ALIGNMENT(.data*)) } >.sram
+
+       . = ALIGN(4);
+       .u_boot_list : {
+               KEEP(*(SORT(.u_boot_list*_i2c_*)));
+       } >.sram
+
+       . = ALIGN(4);
+       __image_copy_end = .;
+
+       .end :
+       {
+               *(.__end)
+       }
+
+       .bss :
+       {
+               . = ALIGN(4);
+               __bss_start = .;
+               *(.bss*)
+               . = ALIGN(4);
+               __bss_end = .;
+       } >.sdram
+}
index b7f118801d10b812bfea29a1a905b47498bb131a..91aa5cc89c387d90800c1146a77c6e1f196061ae 100644 (file)
@@ -24,6 +24,7 @@
 
 #include "cpu.h"
 #include "initcode.h"
+#include "exports.h"
 
 ulong bfin_poweron_retx;
 DECLARE_GLOBAL_DATA_PTR;
@@ -121,7 +122,7 @@ static void display_global_data(void)
        printf(" |-ram_size: %lx\n", gd->ram_size);
        printf(" |-env_addr: %lx\n", gd->env_addr);
        printf(" |-env_valid: %lx\n", gd->env_valid);
-       printf(" |-jt(%p): %p\n", gd->jt, *(gd->jt));
+       printf(" |-jt(%p): %p\n", gd->jt, gd->jt->get_version);
        printf(" \\-bd: %p\n", gd->bd);
        printf("   |-bi_boot_params: %lx\n", bd->bi_boot_params);
        printf("   |-bi_memstart: %lx\n", bd->bi_memstart);
index 98bbf794fa7d736cbefa735d90ea1f0b790bcad0..2b817be61a5dc254915886d603169ce89c046932 100644 (file)
@@ -15,3 +15,8 @@ endif
 CONFIG_STANDALONE_LOAD_ADDR ?= 0x80F00000
 
 PLATFORM_CPPFLAGS += -ffixed-r31 -D__microblaze__
+
+ifeq ($(CONFIG_SPL_BUILD),)
+PLATFORM_CPPFLAGS += -fPIC
+endif
+__HAVE_ARCH_GENERIC_BOARD := y
index 227842f6a483a585a36574fa5857557c00affc61..aa34f45befe1ec5817f5c0485ccf8a996f12f38a 100644 (file)
@@ -13,49 +13,52 @@ void _hw_exception_handler (void)
 {
        int address = 0;
        int state = 0;
+
        /* loading address of exception EAR */
-       MFS (address, rear);
+       MFS(address, rear);
        /* loading excetpion state register ESR */
-       MFS (state, resr);
-       printf ("Hardware exception at 0x%x address\n", address);
+       MFS(state, resr);
+       printf("Hardware exception at 0x%x address\n", address);
+       R17(address);
+       printf("Return address from exception 0x%x\n", address);
        switch (state & 0x1f) { /* mask on exception cause */
        case 0x1:
-               puts ("Unaligned data access exception\n");
+               puts("Unaligned data access exception\n");
                break;
        case 0x2:
-               puts ("Illegal op-code exception\n");
+               puts("Illegal op-code exception\n");
                break;
        case 0x3:
-               puts ("Instruction bus error exception\n");
+               puts("Instruction bus error exception\n");
                break;
        case 0x4:
-               puts ("Data bus error exception\n");
+               puts("Data bus error exception\n");
                break;
        case 0x5:
-               puts ("Divide by zero exception\n");
+               puts("Divide by zero exception\n");
                break;
 #ifdef MICROBLAZE_V5
        case 0x7:
                puts("Priviledged or stack protection violation exception\n");
                break;
        case 0x1000:
-               puts ("Exception in delay slot\n");
+               puts("Exception in delay slot\n");
                break;
 #endif
        default:
-               puts ("Undefined cause\n");
+               puts("Undefined cause\n");
                break;
        }
-       printf ("Unaligned %sword access\n", ((state & 0x800) ? "" : "half"));
-       printf ("Unaligned %s access\n", ((state & 0x400) ? "store" : "load"));
-       printf ("Register R%x\n", (state & 0x3E) >> 5);
-       hang ();
+       printf("Unaligned %sword access\n", ((state & 0x800) ? "" : "half"));
+       printf("Unaligned %s access\n", ((state & 0x400) ? "store" : "load"));
+       printf("Register R%x\n", (state & 0x3E) >> 5);
+       hang();
 }
 
 #ifdef CONFIG_SYS_USR_EXCEP
 void _exception_handler (void)
 {
-       puts ("User vector_exception\n");
-       hang ();
+       puts("User vector_exception\n");
+       hang();
 }
 #endif
index 9364e2fa9c9b0fb1e810ad2d2f88a6cd7deafdd0..b6d6610f2fd70ec6f3410b42c27a9d2013572183 100644 (file)
 #include <asm/microblaze_intc.h>
 #include <asm/asm.h>
 
-#undef DEBUG_INT
-
 void enable_interrupts(void)
 {
+       debug("Enable interrupts for the whole CPU\n");
        MSRSET(0x2);
 }
 
@@ -50,12 +49,11 @@ static void enable_one_interrupt(int irq)
        offset <<= irq;
        mask = intc->ier;
        intc->ier = (mask | offset);
-#ifdef DEBUG_INT
-       printf("Enable one interrupt irq %x - mask %x,ier %x\n", offset, mask,
-               intc->ier);
-       printf("INTC isr %x, ier %x, iar %x, mer %x\n", intc->isr, intc->ier,
-               intc->iar, intc->mer);
-#endif
+
+       debug("Enable one interrupt irq %x - mask %x,ier %x\n", offset, mask,
+             intc->ier);
+       debug("INTC isr %x, ier %x, iar %x, mer %x\n", intc->isr, intc->ier,
+             intc->iar, intc->mer);
 }
 
 static void disable_one_interrupt(int irq)
@@ -66,12 +64,11 @@ static void disable_one_interrupt(int irq)
        offset <<= irq;
        mask = intc->ier;
        intc->ier = (mask & ~offset);
-#ifdef DEBUG_INT
-       printf("Disable one interrupt irq %x - mask %x,ier %x\n", irq, mask,
-               intc->ier);
-       printf("INTC isr %x, ier %x, iar %x, mer %x\n", intc->isr, intc->ier,
-               intc->iar, intc->mer);
-#endif
+
+       debug("Disable one interrupt irq %x - mask %x,ier %x\n", irq, mask,
+             intc->ier);
+       debug("INTC isr %x, ier %x, iar %x, mer %x\n", intc->isr, intc->ier,
+             intc->iar, intc->mer);
 }
 
 int install_interrupt_handler(int irq, interrupt_handler_t *hdlr, void *arg)
@@ -88,12 +85,12 @@ int install_interrupt_handler(int irq, interrupt_handler_t *hdlr, void *arg)
                act->handler = hdlr;
                act->arg = arg;
                act->count = 0;
-               enable_one_interrupt (irq);
+               enable_one_interrupt(irq);
                return 0;
        }
 
        /* Disable */
-       act->handler = (interrupt_handler_t *) def_hdlr;
+       act->handler = (interrupt_handler_t *)def_hdlr;
        act->arg = (void *)irq;
        disable_one_interrupt(irq);
        return 1;
@@ -107,18 +104,17 @@ static void intc_init(void)
        intc->iar = 0xFFFFFFFF;
        /* XIntc_Start - hw_interrupt enable and all interrupt enable */
        intc->mer = 0x3;
-#ifdef DEBUG_INT
-       printf("INTC isr %x, ier %x, iar %x, mer %x\n", intc->isr, intc->ier,
-               intc->iar, intc->mer);
-#endif
+
+       debug("INTC isr %x, ier %x, iar %x, mer %x\n", intc->isr, intc->ier,
+             intc->iar, intc->mer);
 }
 
-int interrupts_init(void)
+int interrupt_init(void)
 {
        int i;
 
 #if defined(CONFIG_SYS_INTC_0_ADDR) && defined(CONFIG_SYS_INTC_0_NUM)
-       intc = (microblaze_intc_t *) (CONFIG_SYS_INTC_0_ADDR);
+       intc = (microblaze_intc_t *)CONFIG_SYS_INTC_0_ADDR;
        irq_no = CONFIG_SYS_INTC_0_NUM;
 #endif
        if (irq_no) {
@@ -130,7 +126,7 @@ int interrupts_init(void)
 
                /* initialize irq list */
                for (i = 0; i < irq_no; i++) {
-                       vecs[i].handler = (interrupt_handler_t *) def_hdlr;
+                       vecs[i].handler = (interrupt_handler_t *)def_hdlr;
                        vecs[i].arg = (void *)i;
                        vecs[i].count = 0;
                }
@@ -147,31 +143,29 @@ void interrupt_handler(void)
 {
        int irqs = intc->ivr;   /* find active interrupt */
        int mask = 1;
-#ifdef DEBUG_INT
        int value;
-       printf ("INTC isr %x, ier %x, iar %x, mer %x\n", intc->isr, intc->ier,
-               intc->iar, intc->mer);
-       R14(value);
-       printf ("Interrupt handler on %x line, r14 %x\n", irqs, value);
-#endif
        struct irq_action *act = vecs + irqs;
 
-#ifdef DEBUG_INT
-       printf
-           ("Jumping to interrupt handler rutine addr %x,count %x,arg %x\n",
-            act->handler, act->count, act->arg);
+       debug("INTC isr %x, ier %x, iar %x, mer %x\n", intc->isr, intc->ier,
+             intc->iar, intc->mer);
+#ifdef DEBUG
+       R14(value);
 #endif
-       act->handler (act->arg);
+       debug("Interrupt handler on %x line, r14 %x\n", irqs, value);
+
+       debug("Jumping to interrupt handler rutine addr %x,count %x,arg %x\n",
+             (u32)act->handler, act->count, (u32)act->arg);
+       act->handler(act->arg);
        act->count++;
 
        intc->iar = mask << irqs;
 
-#ifdef DEBUG_INT
-       printf ("Dump INTC reg, isr %x, ier %x, iar %x, mer %x\n", intc->isr,
-               intc->ier, intc->iar, intc->mer);
+       debug("Dump INTC reg, isr %x, ier %x, iar %x, mer %x\n", intc->isr,
+             intc->ier, intc->iar, intc->mer);
+#ifdef DEBUG
        R14(value);
-       printf ("Interrupt handler on %x line, r14 %x\n", irqs, value);
 #endif
+       debug("Interrupt handler on %x line, r14 %x\n", irqs, value);
 }
 
 #if defined(CONFIG_CMD_IRQ)
@@ -186,10 +180,10 @@ int do_irqinfo(cmd_tbl_t *cmdtp, int flag, int argc, const char *argv[])
                      "-----------------------------\n");
 
                for (i = 0; i < irq_no; i++) {
-                       if (act->handler != (interrupt_handler_t *) def_hdlr) {
+                       if (act->handler != (interrupt_handler_t *)def_hdlr) {
                                printf("%02d  %08x  %08x  %d\n", i,
-                                       (int)act->handler, (int)act->arg,
-                                                               act->count);
+                                      (int)act->handler, (int)act->arg,
+                                      act->count);
                        }
                        act++;
                }
index 24015898b0aa172f798f3468781abf55b7311499..5cfe1516bfcd65fd82f8843b2271ada36990add8 100644 (file)
        .text
        .global _interrupt_handler
 _interrupt_handler:
-       swi     r2, r1, -4
-       swi     r3, r1, -8
-       swi     r4, r1, -12
-       swi     r5, r1, -16
-       swi     r6, r1, -20
-       swi     r7, r1, -24
-       swi     r8, r1, -28
-       swi     r9, r1, -32
-       swi     r10, r1, -36
-       swi     r11, r1, -40
-       swi     r12, r1, -44
-       swi     r13, r1, -48
-       swi     r14, r1, -52
-       swi     r15, r1, -56
-       swi     r16, r1, -60
-       swi     r17, r1, -64
-       swi     r18, r1, -68
-       swi     r19, r1, -72
-       swi     r20, r1, -76
-       swi     r21, r1, -80
-       swi     r22, r1, -84
-       swi     r23, r1, -88
-       swi     r24, r1, -92
-       swi     r25, r1, -96
-       swi     r26, r1, -100
-       swi     r27, r1, -104
-       swi     r28, r1, -108
-       swi     r29, r1, -112
-       swi     r30, r1, -116
-       swi     r31, r1, -120
        addik   r1, r1, -124
+       swi     r2, r1, 4
+       swi     r3, r1, 8
+       swi     r4, r1, 12
+       swi     r5, r1, 16
+       swi     r6, r1, 20
+       swi     r7, r1, 24
+       swi     r8, r1, 28
+       swi     r9, r1, 32
+       swi     r10, r1, 36
+       swi     r11, r1, 40
+       swi     r12, r1, 44
+       swi     r13, r1, 48
+       swi     r14, r1, 52
+       swi     r15, r1, 56
+       swi     r16, r1, 60
+       swi     r17, r1, 64
+       swi     r18, r1, 68
+       swi     r19, r1, 72
+       swi     r20, r1, 76
+       swi     r21, r1, 80
+       swi     r22, r1, 84
+       swi     r23, r1, 88
+       swi     r24, r1, 92
+       swi     r25, r1, 96
+       swi     r26, r1, 100
+       swi     r27, r1, 104
+       swi     r28, r1, 108
+       swi     r29, r1, 112
+       swi     r30, r1, 116
+       swi     r31, r1, 120
        brlid   r15, interrupt_handler
        nop
+       lwi     r31, r1, 120
+       lwi     r30, r1, 116
+       lwi     r29, r1, 112
+       lwi     r28, r1, 108
+       lwi     r27, r1, 104
+       lwi     r26, r1, 100
+       lwi     r25, r1, 96
+       lwi     r24, r1, 92
+       lwi     r23, r1, 88
+       lwi     r22, r1, 84
+       lwi     r21, r1, 80
+       lwi     r20, r1, 76
+       lwi     r19, r1, 72
+       lwi     r18, r1, 68
+       lwi     r17, r1, 64
+       lwi     r16, r1, 60
+       lwi     r15, r1, 56
+       lwi     r14, r1, 52
+       lwi     r13, r1, 48
+       lwi     r12, r1, 44
+       lwi     r11, r1, 40
+       lwi     r10, r1, 36
+       lwi     r9, r1, 32
+       lwi     r8, r1, 28
+       lwi     r7, r1, 24
+       lwi     r6, r1, 20
+       lwi     r5, r1, 16
+       lwi     r4, r1, 12
+       lwi     r3, r1, 8
+       lwi     r2, r1, 4
        addik   r1, r1, 124
-       lwi     r31, r1, -120
-       lwi     r30, r1, -116
-       lwi     r29, r1, -112
-       lwi     r28, r1, -108
-       lwi     r27, r1, -104
-       lwi     r26, r1, -100
-       lwi     r25, r1, -96
-       lwi     r24, r1, -92
-       lwi     r23, r1, -88
-       lwi     r22, r1, -84
-       lwi     r21, r1, -80
-       lwi     r20, r1, -76
-       lwi     r19, r1, -72
-       lwi     r18, r1, -68
-       lwi     r17, r1, -64
-       lwi     r16, r1, -60
-       lwi     r15, r1, -56
-       lwi     r14, r1, -52
-       lwi     r13, r1, -48
-       lwi     r12, r1, -44
-       lwi     r11, r1, -40
-       lwi     r10, r1, -36
-       lwi     r9, r1, -32
-       lwi     r8, r1, -28
-       lwi     r7, r1, -24
-       lwi     r6, r1, -20
-       lwi     r5, r1, -16
-       lwi     r4, r1, -12
-       lwi     r3, r1, -8
-       lwi     r2, r1, -4
-
        rtid    r14, 0
        nop
        .size _interrupt_handler,.-_interrupt_handler
index 091226133e4fa2c1ae7a2182622951ae8eb74d05..2cc0a2da89e16e48c8c8786e892aeece71af02fa 100644 (file)
@@ -25,8 +25,6 @@ u32 spl_boot_device(void)
 /* Board initialization after bss clearance */
 void spl_board_init(void)
 {
-       gd = (gd_t *)CONFIG_SPL_STACK_ADDR;
-
        /* enable console uart printing */
        preloader_console_init();
 }
index 1757bbfa94b9df4950bcf826bc66b22a243ad9da..953d3a15eef21c391f611bf01b346d187d79246f 100644 (file)
@@ -23,11 +23,19 @@ _start:
 
        mts     rmsr, r0        /* disable cache */
 
+       addi    r8, r0, __end
+       mts     rslr, r8
 #if defined(CONFIG_SPL_BUILD)
        addi    r1, r0, CONFIG_SPL_STACK_ADDR
+       mts     rshr, r1
        addi    r1, r1, -4      /* Decrement SP to top of memory */
+#else
+#if defined(CONFIG_SYS_MALLOC_F_LEN)
+       addi    r1, r0, CONFIG_SYS_INIT_SP_OFFSET - CONFIG_SYS_MALLOC_F_LEN
 #else
        addi    r1, r0, CONFIG_SYS_INIT_SP_OFFSET
+#endif
+       mts     rshr, r1
        addi    r1, r1, -4      /* Decrement SP to top of memory */
 
        /* Find-out if u-boot is running on BIG/LITTLE endian platform
@@ -125,12 +133,12 @@ _start:
        /* Flush cache before enable cache */
        addik   r5, r0, 0
        addik   r6, r0, XILINX_DCACHE_BYTE_SIZE
-flush: bralid r15, flush_cache
+       bralid r15, flush_cache
        nop
 
        /* enable instruction and data cache */
        mfs     r12, rmsr
-       ori     r12, r12, 0xa0
+       ori     r12, r12, 0x1a0
        mts     rmsr, r12
 
 clear_bss:
@@ -146,12 +154,28 @@ clear_bss:
        bnei    r6, 2b
 3:     /* jumping to board_init */
 #ifndef CONFIG_SPL_BUILD
+       or      r5, r0, r0      /* flags - empty */
+       addi    r31, r0, _gd
+#if defined(CONFIG_SYS_MALLOC_F_LEN)
+       addi    r6, r0, CONFIG_SYS_INIT_SP_OFFSET
+       swi     r6, r31, GD_MALLOC_BASE
+#endif
        brai    board_init_f
 #else
+       addi    r31, r0, _gd
+#if defined(CONFIG_SYS_MALLOC_F_LEN)
+       addi    r6, r0, CONFIG_SPL_STACK_ADDR
+       swi     r6, r31, GD_MALLOC_BASE
+#endif
        brai    board_init_r
 #endif
 1:     bri     1b
 
+ .section .bss
+.align 4
+_gd:
+         .space  GENERATED_GBL_DATA_SIZE
+
 #ifndef CONFIG_SPL_BUILD
 /*
  * Read 16bit little endian
@@ -185,4 +209,108 @@ out16:    bslli   r3, r6, 8
        rtsd    r15, 8
        or      r0, r0, r0
        .end    out16
+
+/*
+ * Relocate u-boot
+ */
+       .text
+       .global relocate_code
+       .ent    relocate_code
+       .align  2
+relocate_code:
+       /*
+        * r5 - start_addr_sp
+        * r6 - new_gd
+        * r7 - reloc_addr
+        */
+       addi    r1, r5, 0 /* Start to use new SP */
+       addi    r31, r6, 0 /* Start to use new GD */
+
+       add     r23, r0, r7 /* Move reloc addr to r23 */
+       /* Relocate text and data - r12 temp value */
+       addi    r21, r0, _start
+       addi    r22, r0, __end - 4 /* Include BSS too */
+
+       rsub    r6, r21, r22
+       or      r5, r0, r0
+1:     lw      r12, r21, r5 /* Load u-boot data */
+       sw      r12, r23, r5 /* Write zero to loc */
+       cmp     r12, r5, r6 /* Check if we have reach the end */
+       bneid   r12, 1b
+       addi    r5, r5, 4 /* Increment to next loc - relocate code */
+
+       /* R23 points to the base address. */
+       add     r23, r0, r7 /* Move reloc addr to r23 */
+       addi    r24, r0, CONFIG_SYS_TEXT_BASE /* Get reloc offset */
+       rsub    r23, r24, r23 /* keep - this is already here gd->reloc_off */
+
+       addik   r6, r0, 0x2 /* BIG/LITTLE endian offset */
+       lwi     r7, r0, 0x28
+       swi     r6, r0, 0x28 /* used first unused MB vector */
+       lbui    r10, r0, 0x28 /* used first unused MB vector */
+       swi     r7, r0, 0x28
+
+#ifdef CONFIG_SYS_USR_EXCEP
+       addik   r6, r0, _exception_handler
+       addk    r6, r6, r23 /* add offset */
+       sw      r6, r1, r0
+       lhu     r7, r1, r10
+       rsubi   r8, r10, 0xa
+       sh      r7, r0, r8
+       rsubi   r8, r10, 0xe
+       sh      r6, r0, r8
+#endif
+       addik   r6, r0, _hw_exception_handler
+       addk    r6, r6, r23 /* add offset */
+       sw      r6, r1, r0
+       lhu     r7, r1, r10
+       rsubi   r8, r10, 0x22
+       sh      r7, r0, r8
+       rsubi   r8, r10, 0x26
+       sh      r6, r0, r8
+
+       addik   r6, r0, _interrupt_handler
+       addk    r6, r6, r23 /* add offset */
+       sw      r6, r1, r0
+       lhu     r7, r1, r10
+       rsubi   r8, r10, 0x12
+       sh      r7, r0, r8
+       rsubi   r8, r10, 0x16
+       sh      r6, r0, r8
+
+       /* Check if GOT exist */
+       addik   r21, r23, _got_start
+       addik   r22, r23, _got_end
+       cmpu    r12, r21, r22
+       beqi    r12, 2f /* No GOT table - jump over */
+
+       /* Skip last 3 entries plus 1 because of loop boundary below */
+       addik   r22, r22, -0x10
+
+        /* Relocate the GOT. */
+3:     lw      r12, r21, r0 /* Load entry */
+       addk    r12, r12, r23 /* Add reloc offset */
+       sw      r12, r21, r0 /* Save entry back */
+
+       cmpu    r12, r21, r22 /* Check if this cross boundary */
+       bneid   r12, 3b
+       addik   r21. r21, 4
+
+       /* Update pointer to GOT */
+       mfs     r20, rpc
+       addik   r20, r20, _GLOBAL_OFFSET_TABLE_ + 8
+       addk    r20, r20, r23
+
+       /* Flush caches to ensure consistency */
+       addik   r5, r0, 0
+       addik   r6, r0, XILINX_DCACHE_BYTE_SIZE
+       bralid  r15, flush_cache
+       nop
+
+2:     addi    r5, r31, 0 /* gd is initialized in board_r.c */
+       addi    r6, r0, CONFIG_SYS_TEXT_BASE
+       addi    r12, r23, board_init_r
+       bra     r12 /* Jump to relocated code */
+
+       .end    relocate_code
 #endif
index 96353cd96ca7903c08ea0f9fb1db8fadf83cfd59..c60336ca5ca839ab0bef3ed39a188e4eb6792808 100644 (file)
@@ -37,6 +37,12 @@ SECTIONS
                __data_end = .;
        }
 
+       . = ALIGN(4);
+       .u_boot_list : {
+               KEEP(*(SORT(.u_boot_list*)));
+       }
+       __init_end = . ;
+
        .bss ALIGN(0x4):
        {
                __bss_start = .;
index fdad20753d3244ad10ac7a7ae8513cc2bc0b7bdf..2502a0db2b147716bc0f99e92df2f00c46c4274c 100644 (file)
@@ -29,17 +29,23 @@ SECTIONS
        .data ALIGN(0x4):
        {
                __data_start = .;
-#ifdef CONFIG_OF_EMBED
-               dts/built-in.o (.data)
-#endif
                *(.data)
                __data_end = .;
        }
 
+       .got ALIGN(4):
+       {
+               _got_start = .;
+               *(.got*)
+               . = ALIGN(4);
+               _got_end = .;
+       }
+
        . = ALIGN(4);
        .u_boot_list : {
                KEEP(*(SORT(.u_boot_list*)));
        }
+       __init_end = . ;
 
        .bss ALIGN(0x4):
        {
index c1c3b03985795a966dff2d821b79bb19ead98d39..11f3dd0f0ec026acba812efffc8351114bf2a334 100644 (file)
 #define R14(val) \
        __asm__ __volatile__ ("addi %0, r14, 0":"=r" (val));
 
+/* get return address from interrupt */
+#define R17(val) \
+       __asm__ __volatile__ ("addi %0, r17, 0" : "=r" (val));
+
 #define NOP    __asm__ __volatile__ ("nop");
 
 /* use machine status registe USE_MSR_REG */
index cd29734789449b2cd0a0a006a821af9cf897e0d1..32fd636b61dfc3ff4f89e764e32ffa958182fc99 100644 (file)
@@ -7,4 +7,11 @@
 #ifndef _ASM_CONFIG_H_
 #define _ASM_CONFIG_H_
 
+#ifndef CONFIG_SPL_BUILD
+#define CONFIG_NEEDS_MANUAL_RELOC
+#endif
+
+#define CONFIG_NR_DRAM_BANKS   1
+#define CONFIG_SYS_GENERIC_BOARD
+
 #endif
index 0fb9207882fe23064cdbab55fceb2669bc6f38ac..65868386b0d87a98b8b9987eef11bbfaca218354 100644 (file)
@@ -34,5 +34,3 @@ struct irq_action {
  */
 int install_interrupt_handler(int irq, interrupt_handler_t *hdlr,
                                       void *arg);
-
-int interrupts_init(void);
index 54d415ebb5bd22320f63f5cac66da3a06b708d9b..66f8f952c9d0ad78070effbdf91f1e52bf178d2f 100644 (file)
 #ifndef _U_BOOT_H_
 #define _U_BOOT_H_
 
-typedef struct bd_info {
-       unsigned long   bi_memstart;    /* start of DRAM memory */
-       phys_size_t     bi_memsize;     /* size  of DRAM memory in bytes */
-       unsigned long   bi_flashstart;  /* start of FLASH memory */
-       unsigned long   bi_flashsize;   /* size  of FLASH memory */
-       unsigned long   bi_flashoffset; /* reserved area for startup monitor */
-       unsigned long   bi_sramstart;   /* start of SRAM memory */
-       unsigned long   bi_sramsize;    /* size  of SRAM memory */
-       ulong           bi_boot_params; /* where this board expects params */
-} bd_t;
+#include <asm-generic/u-boot.h>
 
 /* For image.h:image_check_target_arch() */
 #define IH_ARCH_DEFAULT IH_ARCH_MICROBLAZE
index 339dd153a0fdec9c29d17400c8254e1b3ef6d212..0289d0cd609a9bec2ccab14b6a2f2e1bae6dc933 100644 (file)
@@ -5,6 +5,5 @@
 # SPDX-License-Identifier:     GPL-2.0+
 #
 
-obj-y  += board.o
 obj-$(CONFIG_CMD_BOOTM) += bootm.o
 obj-y  += muldi3.o
diff --git a/arch/microblaze/lib/board.c b/arch/microblaze/lib/board.c
deleted file mode 100644 (file)
index 600c80a..0000000
+++ /dev/null
@@ -1,201 +0,0 @@
-/*
- * (C) Copyright 2007 Michal Simek
- * (C) Copyright 2004 Atmark Techno, Inc.
- *
- * Michal  SIMEK <monstr@monstr.eu>
- * Yasushi SHOJI <yashi@atmark-techno.com>
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#include <common.h>
-#include <command.h>
-#include <malloc.h>
-#include <version.h>
-#include <watchdog.h>
-#include <stdio_dev.h>
-#include <serial.h>
-#include <net.h>
-#include <spi.h>
-#include <linux/compiler.h>
-#include <asm/processor.h>
-#include <asm/microblaze_intc.h>
-#include <fdtdec.h>
-
-DECLARE_GLOBAL_DATA_PTR;
-
-static int display_banner(void)
-{
-       printf("\n\n%s\n\n", version_string);
-       return 0;
-}
-
-/*
- * All attempts to come up with a "common" initialization sequence
- * that works for all boards and architectures failed: some of the
- * requirements are just _too_ different. To get rid of the resulting
- * mess of board dependend #ifdef'ed code we now make the whole
- * initialization sequence configurable to the user.
- *
- * The requirements for any new initalization function is simple: it
- * receives a pointer to the "global data" structure as it's only
- * argument, and returns an integer return code, where 0 means
- * "continue" and != 0 means "fatal error, hang the system".
- */
-typedef int (init_fnc_t) (void);
-
-init_fnc_t *init_sequence[] = {
-       env_init,
-#ifdef CONFIG_OF_CONTROL
-       fdtdec_check_fdt,
-#endif
-       serial_init,
-#ifndef CONFIG_SPL_BUILD
-       console_init_f,
-#endif
-       display_banner,
-#ifndef CONFIG_SPL_BUILD
-       interrupts_init,
-       timer_init,
-#endif
-       NULL,
-};
-
-unsigned long monitor_flash_len;
-
-void board_init_f(ulong not_used)
-{
-       bd_t *bd;
-       init_fnc_t **init_fnc_ptr;
-       gd = (gd_t *)(CONFIG_SYS_SDRAM_BASE + CONFIG_SYS_GBL_DATA_OFFSET);
-       bd = (bd_t *)(CONFIG_SYS_SDRAM_BASE + CONFIG_SYS_GBL_DATA_OFFSET
-                                               - GENERATED_BD_INFO_SIZE);
-#if defined(CONFIG_CMD_FLASH) && !defined(CONFIG_SPL_BUILD)
-       ulong flash_size = 0;
-#endif
-       asm ("nop");    /* FIXME gd is not initialize - wait */
-       memset((void *)gd, 0, GENERATED_GBL_DATA_SIZE);
-       memset((void *)bd, 0, GENERATED_BD_INFO_SIZE);
-       gd->bd = bd;
-       gd->baudrate = CONFIG_BAUDRATE;
-       bd->bi_memstart = CONFIG_SYS_SDRAM_BASE;
-       bd->bi_memsize = CONFIG_SYS_SDRAM_SIZE;
-       gd->flags |= GD_FLG_RELOC;      /* tell others: relocation done */
-
-       monitor_flash_len = __end - __text_start;
-
-#ifdef CONFIG_OF_EMBED
-       /* Get a pointer to the FDT */
-       gd->fdt_blob = __dtb_dt_begin;
-#elif defined CONFIG_OF_SEPARATE
-       /* FDT is at end of image */
-       gd->fdt_blob = (void *)__end;
-#endif
-
-#ifndef CONFIG_SPL_BUILD
-       /* Allow the early environment to override the fdt address */
-       gd->fdt_blob = (void *)getenv_ulong("fdtcontroladdr", 16,
-                                               (uintptr_t)gd->fdt_blob);
-#endif
-
-       /*
-        * The Malloc area is immediately below the monitor copy in DRAM
-        * aka CONFIG_SYS_MONITOR_BASE - Note there is no need for reloc_off
-        * as our monitory code is run from SDRAM
-        */
-       mem_malloc_init(CONFIG_SYS_MALLOC_BASE, CONFIG_SYS_MALLOC_LEN);
-
-       serial_initialize();
-
-#ifdef CONFIG_XILINX_TB_WATCHDOG
-       hw_watchdog_init();
-#endif
-       for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
-               WATCHDOG_RESET();
-               if ((*init_fnc_ptr) () != 0)
-                       hang();
-       }
-
-#ifndef CONFIG_SPL_BUILD
-#ifdef CONFIG_OF_CONTROL
-       /* For now, put this check after the console is ready */
-       if (fdtdec_prepare_fdt())
-               panic("** No FDT - please see doc/README.fdt-control");
-       else
-               printf("DTB: 0x%x\n", (u32)gd->fdt_blob);
-#endif
-
-       puts("SDRAM :\n");
-       printf("\t\tIcache:%s\n", icache_status() ? "ON" : "OFF");
-       printf("\t\tDcache:%s\n", dcache_status() ? "ON" : "OFF");
-       printf("\tU-Boot Start:0x%08x\n", CONFIG_SYS_TEXT_BASE);
-
-#if defined(CONFIG_CMD_FLASH)
-       puts("Flash: ");
-       bd->bi_flashstart = CONFIG_SYS_FLASH_BASE;
-       flash_size = flash_init();
-       if (bd->bi_flashstart && flash_size > 0) {
-# ifdef CONFIG_SYS_FLASH_CHECKSUM
-               print_size(flash_size, "");
-               /*
-                * Compute and print flash CRC if flashchecksum is set to 'y'
-                *
-                * NOTE: Maybe we should add some WATCHDOG_RESET()? XXX
-                */
-               if (getenv_yesno("flashchecksum") == 1) {
-                       printf("  CRC: %08X",
-                              crc32(0, (const u8 *)bd->bi_flashstart,
-                                    flash_size)
-                       );
-               }
-               putc('\n');
-# else /* !CONFIG_SYS_FLASH_CHECKSUM */
-               print_size(flash_size, "\n");
-# endif /* CONFIG_SYS_FLASH_CHECKSUM */
-               bd->bi_flashsize = flash_size;
-               bd->bi_flashoffset = bd->bi_flashstart + flash_size;
-       } else {
-               puts("Flash init FAILED");
-               bd->bi_flashstart = 0;
-               bd->bi_flashsize = 0;
-               bd->bi_flashoffset = 0;
-       }
-#endif
-
-#ifdef CONFIG_SPI
-       spi_init();
-#endif
-
-       /* relocate environment function pointers etc. */
-       env_relocate();
-
-       /* Initialize stdio devices */
-       stdio_init();
-
-       /* Initialize the jump table for applications */
-       jumptable_init();
-
-       /* Initialize the console (after the relocation and devices init) */
-       console_init_r();
-
-       board_init();
-
-       /* Initialize from environment */
-       load_addr = getenv_ulong("loadaddr", 16, load_addr);
-
-#if defined(CONFIG_CMD_NET)
-       printf("Net:   ");
-       eth_initialize(gd->bd);
-
-       uchar enetaddr[6];
-       eth_getenv_enetaddr("ethaddr", enetaddr);
-       printf("MAC:   %pM\n", enetaddr);
-#endif
-
-       /* main_loop */
-       for (;;) {
-               WATCHDOG_RESET();
-               main_loop();
-       }
-#endif /* CONFIG_SPL_BUILD */
-}
index 4991da2226505dd73c18d9df472d3f786e442046..bc4283d2f13b551cb747d796794286eabbd83027 100644 (file)
@@ -29,12 +29,14 @@ config TARGET_MALTA
        select SUPPORTS_LITTLE_ENDIAN
        select SUPPORTS_CPU_MIPS32_R1
        select SUPPORTS_CPU_MIPS32_R2
+       select SWAP_IO_SPACE
 
 config TARGET_VCT
        bool "Support vct"
        select SUPPORTS_BIG_ENDIAN
        select SUPPORTS_CPU_MIPS32_R1
        select SUPPORTS_CPU_MIPS32_R2
+       select SYS_MIPS_CACHE_INIT_RAM_LOAD
 
 config TARGET_DBAU1X00
        bool "Support dbau1x00"
@@ -42,12 +44,14 @@ config TARGET_DBAU1X00
        select SUPPORTS_LITTLE_ENDIAN
        select SUPPORTS_CPU_MIPS32_R1
        select SUPPORTS_CPU_MIPS32_R2
+       select SYS_MIPS_CACHE_INIT_RAM_LOAD
 
 config TARGET_PB1X00
        bool "Support pb1x00"
        select SUPPORTS_LITTLE_ENDIAN
        select SUPPORTS_CPU_MIPS32_R1
        select SUPPORTS_CPU_MIPS32_R2
+       select SYS_MIPS_CACHE_INIT_RAM_LOAD
 
 
 endchoice
@@ -116,6 +120,39 @@ config CPU_MIPS64_R2
 
 endchoice
 
+menu "OS boot interface"
+
+config MIPS_BOOT_CMDLINE_LEGACY
+       bool "Hand over legacy command line to Linux kernel"
+       default y
+       help
+         Enable this option if you want U-Boot to hand over the Yamon-style
+         command line to the kernel. All bootargs will be prepared as argc/argv
+         compatible list. The argument count (argc) is stored in register $a0.
+         The address of the argument list (argv) is stored in register $a1.
+
+config MIPS_BOOT_ENV_LEGACY
+       bool "Hand over legacy environment to Linux kernel"
+       default y
+       help
+         Enable this option if you want U-Boot to hand over the Yamon-style
+         environment to the kernel. Information like memory size, initrd
+         address and size will be prepared as zero-terminated key/value list.
+         The address of the enviroment is stored in register $a2.
+
+config MIPS_BOOT_FDT
+       bool "Hand over a flattened device tree to Linux kernel (INCOMPLETE)"
+       default n
+       help
+         Enable this option if you want U-Boot to hand over a flattened
+         device tree to the kernel.
+
+         Note: the final hand over to the kernel is not yet implemented. After
+               the community agreed on the MIPS boot interface for device trees,
+               the corresponding code will be added.
+
+endmenu
+
 config SUPPORTS_BIG_ENDIAN
        bool
 
@@ -134,12 +171,26 @@ config SUPPORTS_CPU_MIPS64_R1
 config SUPPORTS_CPU_MIPS64_R2
        bool
 
+config CPU_MIPS32
+       bool
+       default y if CPU_MIPS32_R1 || CPU_MIPS32_R2
+
+config CPU_MIPS64
+       bool
+       default y if CPU_MIPS64_R1 || CPU_MIPS64_R2
+
 config 32BIT
        bool
 
 config 64BIT
        bool
 
+config SWAP_IO_SPACE
+       bool
+
+config SYS_MIPS_CACHE_INIT_RAM_LOAD
+       bool
+
 endif
 
 endmenu
index 1907b57229c1486d95e1b3338fb804df5917f7ca..43f0f5c5046b0361dfd20b8e5058edd046bbf5ad 100644 (file)
@@ -2,7 +2,9 @@
 # SPDX-License-Identifier:     GPL-2.0+
 #
 
-head-y := arch/mips/cpu/$(CPU)/start.o
+head-y := arch/mips/cpu/start.o
 
-libs-y += arch/mips/cpu/$(CPU)/
+libs-y += arch/mips/cpu/
 libs-y += arch/mips/lib/
+
+libs-$(CONFIG_SOC_AU1X00) += arch/mips/mach-au1x00/
diff --git a/arch/mips/cpu/Makefile b/arch/mips/cpu/Makefile
new file mode 100644 (file)
index 0000000..fc6b455
--- /dev/null
@@ -0,0 +1,9 @@
+#
+# SPDX-License-Identifier:     GPL-2.0+
+#
+
+extra-y        = start.o
+
+obj-y += time.o
+obj-y += interrupts.o
+obj-y += cpu.o
diff --git a/arch/mips/cpu/cpu.c b/arch/mips/cpu/cpu.c
new file mode 100644 (file)
index 0000000..8d3b2f5
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * (C) Copyright 2003
+ * Wolfgang Denk, DENX Software Engineering, <wd@denx.de>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <common.h>
+#include <command.h>
+#include <netdev.h>
+#include <linux/compiler.h>
+#include <asm/mipsregs.h>
+#include <asm/reboot.h>
+
+void __weak _machine_restart(void)
+{
+       fprintf(stderr, "*** reset failed ***\n");
+
+       while (1)
+               /* NOP */;
+}
+
+int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+       _machine_restart();
+
+       return 0;
+}
+
+void write_one_tlb(int index, u32 pagemask, u32 hi, u32 low0, u32 low1)
+{
+       write_c0_entrylo0(low0);
+       write_c0_pagemask(pagemask);
+       write_c0_entrylo1(low1);
+       write_c0_entryhi(hi);
+       write_c0_index(index);
+       tlb_write_indexed();
+}
diff --git a/arch/mips/cpu/interrupts.c b/arch/mips/cpu/interrupts.c
new file mode 100644 (file)
index 0000000..275fcf5
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * (C) Copyright 2003
+ * Wolfgang Denk, DENX Software Engineering, <wd@denx.de>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <common.h>
+
+int interrupt_init(void)
+{
+       return 0;
+}
+
+void enable_interrupts(void)
+{
+}
+
+int disable_interrupts(void)
+{
+       return 0;
+}
diff --git a/arch/mips/cpu/mips32/Makefile b/arch/mips/cpu/mips32/Makefile
deleted file mode 100644 (file)
index fa82dd3..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-#
-# (C) Copyright 2003-2006
-# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
-#
-# SPDX-License-Identifier:     GPL-2.0+
-#
-
-extra-y        = start.o
-obj-y  = cache.o
-obj-y  += cpu.o interrupts.o time.o
-
-obj-$(CONFIG_SOC_AU1X00) += au1x00/
diff --git a/arch/mips/cpu/mips32/au1x00/Makefile b/arch/mips/cpu/mips32/au1x00/Makefile
deleted file mode 100644 (file)
index c5643e7..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-#
-# (C) Copyright 2011
-# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
-#
-# SPDX-License-Identifier:     GPL-2.0+
-#
-
-obj-y  = au1x00_eth.o au1x00_serial.o au1x00_usb_ohci.o au1x00_ide.o
diff --git a/arch/mips/cpu/mips32/au1x00/au1x00_eth.c b/arch/mips/cpu/mips32/au1x00/au1x00_eth.c
deleted file mode 100644 (file)
index 4770f56..0000000
+++ /dev/null
@@ -1,296 +0,0 @@
-/* Only eth0 supported for now
- *
- * (C) Copyright 2003
- * Thomas.Lange@corelatus.se
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-#include <config.h>
-
-#if defined(CONFIG_SYS_DISCOVER_PHY)
-#error "PHY not supported yet"
-/* We just assume that we are running 100FD for now */
-/* We all use switches, right? ;-) */
-#endif
-
-/* I assume ethernet behaves like au1000 */
-
-#ifdef CONFIG_SOC_AU1000
-/* Base address differ between cpu:s */
-#define ETH0_BASE AU1000_ETH0_BASE
-#define MAC0_ENABLE AU1000_MAC0_ENABLE
-#else
-#ifdef CONFIG_SOC_AU1100
-#define ETH0_BASE AU1100_ETH0_BASE
-#define MAC0_ENABLE AU1100_MAC0_ENABLE
-#else
-#ifdef CONFIG_SOC_AU1500
-#define ETH0_BASE AU1500_ETH0_BASE
-#define MAC0_ENABLE AU1500_MAC0_ENABLE
-#else
-#ifdef CONFIG_SOC_AU1550
-#define ETH0_BASE AU1550_ETH0_BASE
-#define MAC0_ENABLE AU1550_MAC0_ENABLE
-#else
-#error "No valid cpu set"
-#endif
-#endif
-#endif
-#endif
-
-#include <common.h>
-#include <malloc.h>
-#include <net.h>
-#include <command.h>
-#include <asm/io.h>
-#include <asm/au1x00.h>
-
-#if defined(CONFIG_CMD_MII)
-#include <miiphy.h>
-#endif
-
-/* Ethernet Transmit and Receive Buffers */
-#define DBUF_LENGTH  1520
-#define PKT_MAXBUF_SIZE                1518
-
-static char txbuf[DBUF_LENGTH];
-
-static int next_tx;
-static int next_rx;
-
-/* 4 rx and 4 tx fifos */
-#define NO_OF_FIFOS 4
-
-typedef struct{
-       u32 status;
-       u32 addr;
-       u32 len; /* Only used for tx */
-       u32 not_used;
-} mac_fifo_t;
-
-mac_fifo_t mac_fifo[NO_OF_FIFOS];
-
-#define MAX_WAIT 1000
-
-#if defined(CONFIG_CMD_MII)
-int  au1x00_miiphy_read(const char *devname, unsigned char addr,
-               unsigned char reg, unsigned short * value)
-{
-       volatile u32 *mii_control_reg = (volatile u32*)(ETH0_BASE+MAC_MII_CNTRL);
-       volatile u32 *mii_data_reg = (volatile u32*)(ETH0_BASE+MAC_MII_DATA);
-       u32 mii_control;
-       unsigned int timedout = 20;
-
-       while (*mii_control_reg & MAC_MII_BUSY) {
-               udelay(1000);
-               if (--timedout == 0) {
-                       printf("au1x00_eth: miiphy_read busy timeout!!\n");
-                       return -1;
-               }
-       }
-
-       mii_control = MAC_SET_MII_SELECT_REG(reg) |
-               MAC_SET_MII_SELECT_PHY(addr) | MAC_MII_READ;
-
-       *mii_control_reg = mii_control;
-
-       timedout = 20;
-       while (*mii_control_reg & MAC_MII_BUSY) {
-               udelay(1000);
-               if (--timedout == 0) {
-                       printf("au1x00_eth: miiphy_read busy timeout!!\n");
-                       return -1;
-               }
-       }
-       *value = *mii_data_reg;
-       return 0;
-}
-
-int  au1x00_miiphy_write(const char *devname, unsigned char addr,
-               unsigned char reg, unsigned short value)
-{
-       volatile u32 *mii_control_reg = (volatile u32*)(ETH0_BASE+MAC_MII_CNTRL);
-       volatile u32 *mii_data_reg = (volatile u32*)(ETH0_BASE+MAC_MII_DATA);
-       u32 mii_control;
-       unsigned int timedout = 20;
-
-       while (*mii_control_reg & MAC_MII_BUSY) {
-               udelay(1000);
-               if (--timedout == 0) {
-                       printf("au1x00_eth: miiphy_write busy timeout!!\n");
-                       return -1;
-               }
-       }
-
-       mii_control = MAC_SET_MII_SELECT_REG(reg) |
-               MAC_SET_MII_SELECT_PHY(addr) | MAC_MII_WRITE;
-
-       *mii_data_reg = value;
-       *mii_control_reg = mii_control;
-       return 0;
-}
-#endif
-
-static int au1x00_send(struct eth_device *dev, void *packet, int length)
-{
-       volatile mac_fifo_t *fifo_tx =
-               (volatile mac_fifo_t*)(MAC0_TX_DMA_ADDR+MAC_TX_BUFF0_STATUS);
-       int i;
-       int res;
-
-       /* tx fifo should always be idle */
-       fifo_tx[next_tx].len = length;
-       fifo_tx[next_tx].addr = (virt_to_phys(packet))|TX_DMA_ENABLE;
-       au_sync();
-
-       udelay(1);
-       i=0;
-       while(!(fifo_tx[next_tx].addr&TX_T_DONE)){
-               if(i>MAX_WAIT){
-                       printf("TX timeout\n");
-                       break;
-               }
-               udelay(1);
-               i++;
-       }
-
-       /* Clear done bit */
-       fifo_tx[next_tx].addr = 0;
-       fifo_tx[next_tx].len = 0;
-       au_sync();
-
-       res = fifo_tx[next_tx].status;
-
-       next_tx++;
-       if(next_tx>=NO_OF_FIFOS){
-               next_tx=0;
-       }
-       return(res);
-}
-
-static int au1x00_recv(struct eth_device* dev){
-       volatile mac_fifo_t *fifo_rx =
-               (volatile mac_fifo_t*)(MAC0_RX_DMA_ADDR+MAC_RX_BUFF0_STATUS);
-
-       int length;
-       u32 status;
-
-       for(;;){
-               if(!(fifo_rx[next_rx].addr&RX_T_DONE)){
-                       /* Nothing has been received */
-                       return(-1);
-               }
-
-               status = fifo_rx[next_rx].status;
-
-               length = status&0x3FFF;
-
-               if(status&RX_ERROR){
-                       printf("Rx error 0x%x\n", status);
-               }
-               else{
-                       /* Pass the packet up to the protocol layers. */
-                       NetReceive(NetRxPackets[next_rx], length - 4);
-               }
-
-               fifo_rx[next_rx].addr = (virt_to_phys(NetRxPackets[next_rx]))|RX_DMA_ENABLE;
-
-               next_rx++;
-               if(next_rx>=NO_OF_FIFOS){
-                       next_rx=0;
-               }
-       } /* for */
-
-       return(0); /* Does anyone use this? */
-}
-
-static int au1x00_init(struct eth_device* dev, bd_t * bd){
-
-       volatile u32 *macen = (volatile u32*)MAC0_ENABLE;
-       volatile u32 *mac_ctrl = (volatile u32*)(ETH0_BASE+MAC_CONTROL);
-       volatile u32 *mac_addr_high = (volatile u32*)(ETH0_BASE+MAC_ADDRESS_HIGH);
-       volatile u32 *mac_addr_low = (volatile u32*)(ETH0_BASE+MAC_ADDRESS_LOW);
-       volatile u32 *mac_mcast_high = (volatile u32*)(ETH0_BASE+MAC_MCAST_HIGH);
-       volatile u32 *mac_mcast_low = (volatile u32*)(ETH0_BASE+MAC_MCAST_LOW);
-       volatile mac_fifo_t *fifo_tx =
-               (volatile mac_fifo_t*)(MAC0_TX_DMA_ADDR+MAC_TX_BUFF0_STATUS);
-       volatile mac_fifo_t *fifo_rx =
-               (volatile mac_fifo_t*)(MAC0_RX_DMA_ADDR+MAC_RX_BUFF0_STATUS);
-       int i;
-
-       next_tx = TX_GET_DMA_BUFFER(fifo_tx[0].addr);
-       next_rx = RX_GET_DMA_BUFFER(fifo_rx[0].addr);
-
-       /* We have to enable clocks before releasing reset */
-       *macen = MAC_EN_CLOCK_ENABLE;
-       udelay(10);
-
-       /* Enable MAC0 */
-       /* We have to release reset before accessing registers */
-       *macen = MAC_EN_CLOCK_ENABLE|MAC_EN_RESET0|
-               MAC_EN_RESET1|MAC_EN_RESET2;
-       udelay(10);
-
-       for(i=0;i<NO_OF_FIFOS;i++){
-               fifo_tx[i].len = 0;
-               fifo_tx[i].addr = virt_to_phys(&txbuf[0]);
-               fifo_rx[i].addr = (virt_to_phys(NetRxPackets[i]))|RX_DMA_ENABLE;
-       }
-
-       /* Put mac addr in little endian */
-#define ea eth_get_dev()->enetaddr
-       *mac_addr_high  =       (ea[5] <<  8) | (ea[4]      ) ;
-       *mac_addr_low   =       (ea[3] << 24) | (ea[2] << 16) |
-               (ea[1] <<  8) | (ea[0]      ) ;
-#undef ea
-       *mac_mcast_low = 0;
-       *mac_mcast_high = 0;
-
-       /* Make sure the MAC buffer is in the correct endian mode */
-#ifdef __LITTLE_ENDIAN
-       *mac_ctrl = MAC_FULL_DUPLEX;
-       udelay(1);
-       *mac_ctrl = MAC_FULL_DUPLEX|MAC_RX_ENABLE|MAC_TX_ENABLE;
-#else
-       *mac_ctrl = MAC_BIG_ENDIAN|MAC_FULL_DUPLEX;
-       udelay(1);
-       *mac_ctrl = MAC_BIG_ENDIAN|MAC_FULL_DUPLEX|MAC_RX_ENABLE|MAC_TX_ENABLE;
-#endif
-
-       return(1);
-}
-
-static void au1x00_halt(struct eth_device* dev){
-       volatile u32 *macen = (volatile u32*)MAC0_ENABLE;
-
-       /* Put MAC0 in reset */
-       *macen = 0;
-}
-
-int au1x00_enet_initialize(bd_t *bis){
-       struct eth_device* dev;
-
-       if ((dev = (struct eth_device*)malloc(sizeof *dev)) == NULL) {
-               puts ("malloc failed\n");
-               return -1;
-       }
-
-       memset(dev, 0, sizeof *dev);
-
-       sprintf(dev->name, "Au1X00 ethernet");
-       dev->iobase = 0;
-       dev->priv   = 0;
-       dev->init   = au1x00_init;
-       dev->halt   = au1x00_halt;
-       dev->send   = au1x00_send;
-       dev->recv   = au1x00_recv;
-
-       eth_register(dev);
-
-#if defined(CONFIG_CMD_MII)
-       miiphy_register(dev->name,
-               au1x00_miiphy_read, au1x00_miiphy_write);
-#endif
-
-       return 1;
-}
diff --git a/arch/mips/cpu/mips32/au1x00/au1x00_ide.c b/arch/mips/cpu/mips32/au1x00/au1x00_ide.c
deleted file mode 100644 (file)
index ba0b35d..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * (C) Copyright 2000-2011
- * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#include <common.h>
-#include <ide.h>
-
-/* AU1X00 swaps data in big-endian mode, enforce little-endian function */
-void ide_input_swap_data(int dev, ulong *sect_buf, int words)
-{
-       ide_input_data(dev, sect_buf, words);
-}
diff --git a/arch/mips/cpu/mips32/au1x00/au1x00_serial.c b/arch/mips/cpu/mips32/au1x00/au1x00_serial.c
deleted file mode 100644 (file)
index 0463508..0000000
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * AU1X00 UART support
- *
- * Hardcoded to UART 0 for now
- * Speed and options also hardcoded to 115200 8N1
- *
- *  Copyright (c) 2003 Thomas.Lange@corelatus.se
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#include <config.h>
-#include <common.h>
-#include <asm/au1x00.h>
-#include <serial.h>
-#include <linux/compiler.h>
-
-/******************************************************************************
-*
-* serial_init - initialize a channel
-*
-* This routine initializes the number of data bits, parity
-* and set the selected baud rate. Interrupts are disabled.
-* Set the modem control signals if the option is selected.
-*
-* RETURNS: N/A
-*/
-
-static int au1x00_serial_init(void)
-{
-       volatile u32 *uart_fifoctl = (volatile u32*)(UART0_ADDR+UART_FCR);
-       volatile u32 *uart_enable = (volatile u32*)(UART0_ADDR+UART_ENABLE);
-
-       /* Enable clocks first */
-       *uart_enable = UART_EN_CE;
-
-       /* Then release reset */
-       /* Must release reset before setting other regs */
-       *uart_enable = UART_EN_CE|UART_EN_E;
-
-       /* Activate fifos, reset tx and rx */
-       /* Set tx trigger level to 12 */
-       *uart_fifoctl = UART_FCR_ENABLE_FIFO|UART_FCR_CLEAR_RCVR|
-               UART_FCR_CLEAR_XMIT|UART_FCR_T_TRIGGER_12;
-
-       serial_setbrg();
-
-       return 0;
-}
-
-
-static void au1x00_serial_setbrg(void)
-{
-       volatile u32 *uart_clk = (volatile u32*)(UART0_ADDR+UART_CLK);
-       volatile u32 *uart_lcr = (volatile u32*)(UART0_ADDR+UART_LCR);
-       volatile u32 *sys_powerctrl = (u32 *)SYS_POWERCTRL;
-       int sd;
-       int divisorx2;
-
-       /* sd is system clock divisor                   */
-       /* see section 10.4.5 in au1550 datasheet       */
-       sd = (*sys_powerctrl & 0x03) + 2;
-
-       /* calulate 2x baudrate and round */
-       divisorx2 = ((CONFIG_SYS_MIPS_TIMER_FREQ/(sd * 16 * CONFIG_BAUDRATE)));
-
-       if (divisorx2 & 0x01)
-               divisorx2 = divisorx2 + 1;
-
-       *uart_clk = divisorx2 / 2;
-
-       /* Set parity, stop bits and word length to 8N1 */
-       *uart_lcr = UART_LCR_WLEN8;
-}
-
-static void au1x00_serial_putc(const char c)
-{
-       volatile u32 *uart_lsr = (volatile u32*)(UART0_ADDR+UART_LSR);
-       volatile u32 *uart_tx = (volatile u32*)(UART0_ADDR+UART_TX);
-
-       if (c == '\n')
-               au1x00_serial_putc('\r');
-
-       /* Wait for fifo to shift out some bytes */
-       while((*uart_lsr&UART_LSR_THRE)==0);
-
-       *uart_tx = (u32)c;
-}
-
-static int au1x00_serial_getc(void)
-{
-       volatile u32 *uart_rx = (volatile u32*)(UART0_ADDR+UART_RX);
-       char c;
-
-       while (!serial_tstc());
-
-       c = (*uart_rx&0xFF);
-       return c;
-}
-
-static int au1x00_serial_tstc(void)
-{
-       volatile u32 *uart_lsr = (volatile u32*)(UART0_ADDR+UART_LSR);
-
-       if(*uart_lsr&UART_LSR_DR){
-               /* Data in rfifo */
-               return(1);
-       }
-       return 0;
-}
-
-static struct serial_device au1x00_serial_drv = {
-       .name   = "au1x00_serial",
-       .start  = au1x00_serial_init,
-       .stop   = NULL,
-       .setbrg = au1x00_serial_setbrg,
-       .putc   = au1x00_serial_putc,
-       .puts   = default_serial_puts,
-       .getc   = au1x00_serial_getc,
-       .tstc   = au1x00_serial_tstc,
-};
-
-void au1x00_serial_initialize(void)
-{
-       serial_register(&au1x00_serial_drv);
-}
-
-__weak struct serial_device *default_serial_console(void)
-{
-       return &au1x00_serial_drv;
-}
diff --git a/arch/mips/cpu/mips32/au1x00/au1x00_usb_ohci.c b/arch/mips/cpu/mips32/au1x00/au1x00_usb_ohci.c
deleted file mode 100644 (file)
index 74bdb77..0000000
+++ /dev/null
@@ -1,1609 +0,0 @@
-/*
- * URB OHCI HCD (Host Controller Driver) for USB on the AU1x00.
- *
- * (C) Copyright 2003
- * Gary Jennejohn, DENX Software Engineering <garyj@denx.de>
- *
- * SPDX-License-Identifier:    GPL-2.0+
- * Note: Part of this code has been derived from linux
- *
- */
-/*
- * IMPORTANT NOTES
- * 1 - this driver is intended for use with USB Mass Storage Devices
- *     (BBB) ONLY. There is NO support for Interrupt or Isochronous pipes!
- */
-
-#include <config.h>
-
-#ifdef CONFIG_USB_OHCI
-
-/* #include <pci.h> no PCI on the AU1x00 */
-
-#include <common.h>
-#include <malloc.h>
-#include <asm/io.h>
-#include <asm/au1x00.h>
-#include <usb.h>
-#include "au1x00_usb_ohci.h"
-
-#define OHCI_USE_NPS           /* force NoPowerSwitching mode */
-#define OHCI_VERBOSE_DEBUG     /* not always helpful */
-#define OHCI_FILL_TRACE
-
-#define USBH_ENABLE_BE (1<<0)
-#define USBH_ENABLE_C  (1<<1)
-#define USBH_ENABLE_E  (1<<2)
-#define USBH_ENABLE_CE (1<<3)
-#define USBH_ENABLE_RD (1<<4)
-
-#ifdef __LITTLE_ENDIAN
-#define USBH_ENABLE_INIT (USBH_ENABLE_CE | USBH_ENABLE_E | USBH_ENABLE_C)
-#else
-#define USBH_ENABLE_INIT (USBH_ENABLE_CE | USBH_ENABLE_E | USBH_ENABLE_C | USBH_ENABLE_BE)
-#endif
-
-
-/* For initializing controller (mask in an HCFS mode too) */
-#define OHCI_CONTROL_INIT \
-       (OHCI_CTRL_CBSR & 0x3) | OHCI_CTRL_IE | OHCI_CTRL_PLE
-
-#undef readl
-#undef writel
-
-#define readl(a)     au_readl((long)(a))
-#define writel(v,a)  au_writel((v),(int)(a))
-
-#define DEBUG
-#ifdef DEBUG
-#define dbg(format, arg...) printf("DEBUG: " format "\n", ## arg)
-#else
-#define dbg(format, arg...) do {} while(0)
-#endif /* DEBUG */
-#define err(format, arg...) printf("ERROR: " format "\n", ## arg)
-#define SHOW_INFO
-#ifdef SHOW_INFO
-#define info(format, arg...) printf("INFO: " format "\n", ## arg)
-#else
-#define info(format, arg...) do {} while(0)
-#endif
-
-#define m16_swap(x) swap_16(x)
-#define m32_swap(x) swap_32(x)
-
-/* global ohci_t */
-static ohci_t gohci;
-/* this must be aligned to a 256 byte boundary */
-struct ohci_hcca ghcca[1];
-/* a pointer to the aligned storage */
-struct ohci_hcca *phcca;
-/* this allocates EDs for all possible endpoints */
-struct ohci_device ohci_dev;
-/* urb_priv */
-urb_priv_t urb_priv;
-/* RHSC flag */
-int got_rhsc;
-/* device which was disconnected */
-struct usb_device *devgone;
-
-/*-------------------------------------------------------------------------*/
-
-/* AMD-756 (D2 rev) reports corrupt register contents in some cases.
- * The erratum (#4) description is incorrect.  AMD's workaround waits
- * till some bits (mostly reserved) are clear; ok for all revs.
- */
-#define OHCI_QUIRK_AMD756 0xabcd
-#define read_roothub(hc, register, mask) ({ \
-       u32 temp = readl (&hc->regs->roothub.register); \
-       if (hc->flags & OHCI_QUIRK_AMD756) \
-               while (temp & mask) \
-                       temp = readl (&hc->regs->roothub.register); \
-       temp; })
-
-static u32 roothub_a (struct ohci *hc)
-       { return read_roothub (hc, a, 0xfc0fe000); }
-static inline u32 roothub_b (struct ohci *hc)
-       { return readl (&hc->regs->roothub.b); }
-static inline u32 roothub_status (struct ohci *hc)
-       { return readl (&hc->regs->roothub.status); }
-static u32 roothub_portstatus (struct ohci *hc, int i)
-       { return read_roothub (hc, portstatus [i], 0xffe0fce0); }
-
-
-/* forward declaration */
-static int hc_interrupt (void);
-static void
-td_submit_job (struct usb_device * dev, unsigned long pipe, void * buffer,
-       int transfer_len, struct devrequest * setup, urb_priv_t * urb, int interval);
-
-/*-------------------------------------------------------------------------*
- * URB support functions
- *-------------------------------------------------------------------------*/
-
-/* free HCD-private data associated with this URB */
-
-static void urb_free_priv (urb_priv_t * urb)
-{
-       int             i;
-       int             last;
-       struct td       * td;
-
-       last = urb->length - 1;
-       if (last >= 0) {
-               for (i = 0; i <= last; i++) {
-                       td = urb->td[i];
-                       if (td) {
-                               td->usb_dev = NULL;
-                               urb->td[i] = NULL;
-                       }
-               }
-       }
-}
-
-/*-------------------------------------------------------------------------*/
-
-#ifdef DEBUG
-static int sohci_get_current_frame_number (struct usb_device * dev);
-
-/* debug| print the main components of an URB
- * small: 0) header + data packets 1) just header */
-
-static void pkt_print (struct usb_device * dev, unsigned long pipe, void * buffer,
-       int transfer_len, struct devrequest * setup, char * str, int small)
-{
-       urb_priv_t * purb = &urb_priv;
-
-       dbg("%s URB:[%4x] dev:%2d,ep:%2d-%c,type:%s,len:%d/%d stat:%#lx",
-                       str,
-                       sohci_get_current_frame_number (dev),
-                       usb_pipedevice (pipe),
-                       usb_pipeendpoint (pipe),
-                       usb_pipeout (pipe)? 'O': 'I',
-                       usb_pipetype (pipe) < 2? (usb_pipeint (pipe)? "INTR": "ISOC"):
-                               (usb_pipecontrol (pipe)? "CTRL": "BULK"),
-                       purb->actual_length,
-                       transfer_len, dev->status);
-#ifdef OHCI_VERBOSE_DEBUG
-       if (!small) {
-               int i, len;
-
-               if (usb_pipecontrol (pipe)) {
-                       printf (__FILE__ ": cmd(8):");
-                       for (i = 0; i < 8 ; i++)
-                               printf (" %02x", ((__u8 *) setup) [i]);
-                       printf ("\n");
-               }
-               if (transfer_len > 0 && buffer) {
-                       printf (__FILE__ ": data(%d/%d):",
-                               purb->actual_length,
-                               transfer_len);
-                       len = usb_pipeout (pipe)?
-                                       transfer_len: purb->actual_length;
-                       for (i = 0; i < 16 && i < len; i++)
-                               printf (" %02x", ((__u8 *) buffer) [i]);
-                       printf ("%s\n", i < len? "...": "");
-               }
-       }
-#endif
-}
-
-/* just for debugging; prints non-empty branches of the int ed tree inclusive iso eds*/
-void ep_print_int_eds (ohci_t *ohci, char * str) {
-       int i, j;
-        __u32 * ed_p;
-       for (i= 0; i < 32; i++) {
-               j = 5;
-               ed_p = &(ohci->hcca->int_table [i]);
-               if (*ed_p == 0)
-                   continue;
-               printf (__FILE__ ": %s branch int %2d(%2x):", str, i, i);
-               while (*ed_p != 0 && j--) {
-                       ed_t *ed = (ed_t *)m32_swap(ed_p);
-                       printf (" ed: %4x;", ed->hwINFO);
-                       ed_p = &ed->hwNextED;
-               }
-               printf ("\n");
-       }
-}
-
-static void ohci_dump_intr_mask (char *label, __u32 mask)
-{
-       dbg ("%s: 0x%08x%s%s%s%s%s%s%s%s%s",
-               label,
-               mask,
-               (mask & OHCI_INTR_MIE) ? " MIE" : "",
-               (mask & OHCI_INTR_OC) ? " OC" : "",
-               (mask & OHCI_INTR_RHSC) ? " RHSC" : "",
-               (mask & OHCI_INTR_FNO) ? " FNO" : "",
-               (mask & OHCI_INTR_UE) ? " UE" : "",
-               (mask & OHCI_INTR_RD) ? " RD" : "",
-               (mask & OHCI_INTR_SF) ? " SF" : "",
-               (mask & OHCI_INTR_WDH) ? " WDH" : "",
-               (mask & OHCI_INTR_SO) ? " SO" : ""
-               );
-}
-
-static void maybe_print_eds (char *label, __u32 value)
-{
-       ed_t *edp = (ed_t *)value;
-
-       if (value) {
-               dbg ("%s %08x", label, value);
-               dbg ("%08x", edp->hwINFO);
-               dbg ("%08x", edp->hwTailP);
-               dbg ("%08x", edp->hwHeadP);
-               dbg ("%08x", edp->hwNextED);
-       }
-}
-
-static char * hcfs2string (int state)
-{
-       switch (state) {
-               case OHCI_USB_RESET:    return "reset";
-               case OHCI_USB_RESUME:   return "resume";
-               case OHCI_USB_OPER:     return "operational";
-               case OHCI_USB_SUSPEND:  return "suspend";
-       }
-       return "?";
-}
-
-/* dump control and status registers */
-static void ohci_dump_status (ohci_t *controller)
-{
-       struct ohci_regs        *regs = controller->regs;
-       __u32                   temp;
-
-       temp = readl (&regs->revision) & 0xff;
-       if (temp != 0x10)
-               dbg ("spec %d.%d", (temp >> 4), (temp & 0x0f));
-
-       temp = readl (&regs->control);
-       dbg ("control: 0x%08x%s%s%s HCFS=%s%s%s%s%s CBSR=%d", temp,
-               (temp & OHCI_CTRL_RWE) ? " RWE" : "",
-               (temp & OHCI_CTRL_RWC) ? " RWC" : "",
-               (temp & OHCI_CTRL_IR) ? " IR" : "",
-               hcfs2string (temp & OHCI_CTRL_HCFS),
-               (temp & OHCI_CTRL_BLE) ? " BLE" : "",
-               (temp & OHCI_CTRL_CLE) ? " CLE" : "",
-               (temp & OHCI_CTRL_IE) ? " IE" : "",
-               (temp & OHCI_CTRL_PLE) ? " PLE" : "",
-               temp & OHCI_CTRL_CBSR
-               );
-
-       temp = readl (&regs->cmdstatus);
-       dbg ("cmdstatus: 0x%08x SOC=%d%s%s%s%s", temp,
-               (temp & OHCI_SOC) >> 16,
-               (temp & OHCI_OCR) ? " OCR" : "",
-               (temp & OHCI_BLF) ? " BLF" : "",
-               (temp & OHCI_CLF) ? " CLF" : "",
-               (temp & OHCI_HCR) ? " HCR" : ""
-               );
-
-       ohci_dump_intr_mask ("intrstatus", readl (&regs->intrstatus));
-       ohci_dump_intr_mask ("intrenable", readl (&regs->intrenable));
-
-       maybe_print_eds ("ed_periodcurrent", readl (&regs->ed_periodcurrent));
-
-       maybe_print_eds ("ed_controlhead", readl (&regs->ed_controlhead));
-       maybe_print_eds ("ed_controlcurrent", readl (&regs->ed_controlcurrent));
-
-       maybe_print_eds ("ed_bulkhead", readl (&regs->ed_bulkhead));
-       maybe_print_eds ("ed_bulkcurrent", readl (&regs->ed_bulkcurrent));
-
-       maybe_print_eds ("donehead", readl (&regs->donehead));
-}
-
-static void ohci_dump_roothub (ohci_t *controller, int verbose)
-{
-       __u32                   temp, ndp, i;
-
-       temp = roothub_a (controller);
-       ndp = (temp & RH_A_NDP);
-
-       if (verbose) {
-               dbg ("roothub.a: %08x POTPGT=%d%s%s%s%s%s NDP=%d", temp,
-                       ((temp & RH_A_POTPGT) >> 24) & 0xff,
-                       (temp & RH_A_NOCP) ? " NOCP" : "",
-                       (temp & RH_A_OCPM) ? " OCPM" : "",
-                       (temp & RH_A_DT) ? " DT" : "",
-                       (temp & RH_A_NPS) ? " NPS" : "",
-                       (temp & RH_A_PSM) ? " PSM" : "",
-                       ndp
-                       );
-               temp = roothub_b (controller);
-               dbg ("roothub.b: %08x PPCM=%04x DR=%04x",
-                       temp,
-                       (temp & RH_B_PPCM) >> 16,
-                       (temp & RH_B_DR)
-                       );
-               temp = roothub_status (controller);
-               dbg ("roothub.status: %08x%s%s%s%s%s%s",
-                       temp,
-                       (temp & RH_HS_CRWE) ? " CRWE" : "",
-                       (temp & RH_HS_OCIC) ? " OCIC" : "",
-                       (temp & RH_HS_LPSC) ? " LPSC" : "",
-                       (temp & RH_HS_DRWE) ? " DRWE" : "",
-                       (temp & RH_HS_OCI) ? " OCI" : "",
-                       (temp & RH_HS_LPS) ? " LPS" : ""
-                       );
-       }
-
-       for (i = 0; i < ndp; i++) {
-               temp = roothub_portstatus (controller, i);
-               dbg ("roothub.portstatus [%d] = 0x%08x%s%s%s%s%s%s%s%s%s%s%s%s",
-                       i,
-                       temp,
-                       (temp & RH_PS_PRSC) ? " PRSC" : "",
-                       (temp & RH_PS_OCIC) ? " OCIC" : "",
-                       (temp & RH_PS_PSSC) ? " PSSC" : "",
-                       (temp & RH_PS_PESC) ? " PESC" : "",
-                       (temp & RH_PS_CSC) ? " CSC" : "",
-
-                       (temp & RH_PS_LSDA) ? " LSDA" : "",
-                       (temp & RH_PS_PPS) ? " PPS" : "",
-                       (temp & RH_PS_PRS) ? " PRS" : "",
-                       (temp & RH_PS_POCI) ? " POCI" : "",
-                       (temp & RH_PS_PSS) ? " PSS" : "",
-
-                       (temp & RH_PS_PES) ? " PES" : "",
-                       (temp & RH_PS_CCS) ? " CCS" : ""
-                       );
-       }
-}
-
-static void ohci_dump (ohci_t *controller, int verbose)
-{
-       dbg ("OHCI controller usb-%s state", controller->slot_name);
-
-       /* dumps some of the state we know about */
-       ohci_dump_status (controller);
-       if (verbose)
-               ep_print_int_eds (controller, "hcca");
-       dbg ("hcca frame #%04x", controller->hcca->frame_no);
-       ohci_dump_roothub (controller, 1);
-}
-
-
-#endif /* DEBUG */
-
-/*-------------------------------------------------------------------------*
- * Interface functions (URB)
- *-------------------------------------------------------------------------*/
-
-/* get a transfer request */
-
-int sohci_submit_job(struct usb_device *dev, unsigned long pipe, void *buffer,
-               int transfer_len, struct devrequest *setup, int interval)
-{
-       ohci_t *ohci;
-       ed_t * ed;
-       urb_priv_t *purb_priv;
-       int i, size = 0;
-
-       ohci = &gohci;
-
-       /* when controller's hung, permit only roothub cleanup attempts
-        * such as powering down ports */
-       if (ohci->disabled) {
-               err("sohci_submit_job: EPIPE");
-               return -1;
-       }
-
-       /* every endpoint has a ed, locate and fill it */
-       if (!(ed = ep_add_ed (dev, pipe))) {
-               err("sohci_submit_job: ENOMEM");
-               return -1;
-       }
-
-       /* for the private part of the URB we need the number of TDs (size) */
-       switch (usb_pipetype (pipe)) {
-               case PIPE_BULK: /* one TD for every 4096 Byte */
-                       size = (transfer_len - 1) / 4096 + 1;
-                       break;
-               case PIPE_CONTROL: /* 1 TD for setup, 1 for ACK and 1 for every 4096 B */
-                       size = (transfer_len == 0)? 2:
-                                               (transfer_len - 1) / 4096 + 3;
-                       break;
-       }
-
-       if (size >= (N_URB_TD - 1)) {
-               err("need %d TDs, only have %d", size, N_URB_TD);
-               return -1;
-       }
-       purb_priv = &urb_priv;
-       purb_priv->pipe = pipe;
-
-       /* fill the private part of the URB */
-       purb_priv->length = size;
-       purb_priv->ed = ed;
-       purb_priv->actual_length = 0;
-
-       /* allocate the TDs */
-       /* note that td[0] was allocated in ep_add_ed */
-       for (i = 0; i < size; i++) {
-               purb_priv->td[i] = td_alloc (dev);
-               if (!purb_priv->td[i]) {
-                       purb_priv->length = i;
-                       urb_free_priv (purb_priv);
-                       err("sohci_submit_job: ENOMEM");
-                       return -1;
-               }
-       }
-
-       if (ed->state == ED_NEW || (ed->state & ED_DEL)) {
-               urb_free_priv (purb_priv);
-               err("sohci_submit_job: EINVAL");
-               return -1;
-       }
-
-       /* link the ed into a chain if is not already */
-       if (ed->state != ED_OPER)
-               ep_link (ohci, ed);
-
-       /* fill the TDs and link it to the ed */
-       td_submit_job(dev, pipe, buffer, transfer_len, setup, purb_priv, interval);
-
-       return 0;
-}
-
-/*-------------------------------------------------------------------------*/
-
-#ifdef DEBUG
-/* tell us the current USB frame number */
-
-static int sohci_get_current_frame_number (struct usb_device *usb_dev)
-{
-       ohci_t *ohci = &gohci;
-
-       return m16_swap (ohci->hcca->frame_no);
-}
-#endif
-
-/*-------------------------------------------------------------------------*
- * ED handling functions
- *-------------------------------------------------------------------------*/
-
-/* link an ed into one of the HC chains */
-
-static int ep_link (ohci_t *ohci, ed_t *edi)
-{
-       volatile ed_t *ed = edi;
-
-       ed->state = ED_OPER;
-
-       switch (ed->type) {
-       case PIPE_CONTROL:
-               ed->hwNextED = 0;
-               if (ohci->ed_controltail == NULL) {
-                       writel ((long)ed, &ohci->regs->ed_controlhead);
-               } else {
-                       ohci->ed_controltail->hwNextED = m32_swap (ed);
-               }
-               ed->ed_prev = ohci->ed_controltail;
-               if (!ohci->ed_controltail && !ohci->ed_rm_list[0] &&
-                       !ohci->ed_rm_list[1] && !ohci->sleeping) {
-                       ohci->hc_control |= OHCI_CTRL_CLE;
-                       writel (ohci->hc_control, &ohci->regs->control);
-               }
-               ohci->ed_controltail = edi;
-               break;
-
-       case PIPE_BULK:
-               ed->hwNextED = 0;
-               if (ohci->ed_bulktail == NULL) {
-                       writel ((long)ed, &ohci->regs->ed_bulkhead);
-               } else {
-                       ohci->ed_bulktail->hwNextED = m32_swap (ed);
-               }
-               ed->ed_prev = ohci->ed_bulktail;
-               if (!ohci->ed_bulktail && !ohci->ed_rm_list[0] &&
-                       !ohci->ed_rm_list[1] && !ohci->sleeping) {
-                       ohci->hc_control |= OHCI_CTRL_BLE;
-                       writel (ohci->hc_control, &ohci->regs->control);
-               }
-               ohci->ed_bulktail = edi;
-               break;
-       }
-       return 0;
-}
-
-/*-------------------------------------------------------------------------*/
-
-/* unlink an ed from one of the HC chains.
- * just the link to the ed is unlinked.
- * the link from the ed still points to another operational ed or 0
- * so the HC can eventually finish the processing of the unlinked ed */
-
-static int ep_unlink (ohci_t *ohci, ed_t *ed)
-{
-       ed->hwINFO |= m32_swap (OHCI_ED_SKIP);
-
-       switch (ed->type) {
-       case PIPE_CONTROL:
-               if (ed->ed_prev == NULL) {
-                       if (!ed->hwNextED) {
-                               ohci->hc_control &= ~OHCI_CTRL_CLE;
-                               writel (ohci->hc_control, &ohci->regs->control);
-                       }
-                       writel (m32_swap (*((__u32 *)&ed->hwNextED)), &ohci->regs->ed_controlhead);
-               } else {
-                       ed->ed_prev->hwNextED = ed->hwNextED;
-               }
-               if (ohci->ed_controltail == ed) {
-                       ohci->ed_controltail = ed->ed_prev;
-               } else {
-                       ((ed_t *)m32_swap (*((__u32 *)&ed->hwNextED)))->ed_prev = ed->ed_prev;
-               }
-               break;
-
-       case PIPE_BULK:
-               if (ed->ed_prev == NULL) {
-                       if (!ed->hwNextED) {
-                               ohci->hc_control &= ~OHCI_CTRL_BLE;
-                               writel (ohci->hc_control, &ohci->regs->control);
-                       }
-                       writel (m32_swap (*((__u32 *)&ed->hwNextED)), &ohci->regs->ed_bulkhead);
-               } else {
-                       ed->ed_prev->hwNextED = ed->hwNextED;
-               }
-               if (ohci->ed_bulktail == ed) {
-                       ohci->ed_bulktail = ed->ed_prev;
-               } else {
-                       ((ed_t *)m32_swap (*((__u32 *)&ed->hwNextED)))->ed_prev = ed->ed_prev;
-               }
-               break;
-       }
-       ed->state = ED_UNLINK;
-       return 0;
-}
-
-
-/*-------------------------------------------------------------------------*/
-
-/* add/reinit an endpoint; this should be done once at the usb_set_configuration command,
- * but the USB stack is a little bit stateless so we do it at every transaction
- * if the state of the ed is ED_NEW then a dummy td is added and the state is changed to ED_UNLINK
- * in all other cases the state is left unchanged
- * the ed info fields are setted anyway even though most of them should not change */
-
-static ed_t * ep_add_ed (struct usb_device *usb_dev, unsigned long pipe)
-{
-       td_t *td;
-       ed_t *ed_ret;
-       volatile ed_t *ed;
-
-       ed = ed_ret = &ohci_dev.ed[(usb_pipeendpoint (pipe) << 1) |
-                       (usb_pipecontrol (pipe)? 0: usb_pipeout (pipe))];
-
-       if ((ed->state & ED_DEL) || (ed->state & ED_URB_DEL)) {
-               err("ep_add_ed: pending delete");
-               /* pending delete request */
-               return NULL;
-       }
-
-       if (ed->state == ED_NEW) {
-               ed->hwINFO = m32_swap (OHCI_ED_SKIP); /* skip ed */
-               /* dummy td; end of td list for ed */
-               td = td_alloc (usb_dev);
-               ed->hwTailP = m32_swap (td);
-               ed->hwHeadP = ed->hwTailP;
-               ed->state = ED_UNLINK;
-               ed->type = usb_pipetype (pipe);
-               ohci_dev.ed_cnt++;
-       }
-
-       ed->hwINFO = m32_swap (usb_pipedevice (pipe)
-                       | usb_pipeendpoint (pipe) << 7
-                       | (usb_pipeisoc (pipe)? 0x8000: 0)
-                       | (usb_pipecontrol (pipe)? 0: (usb_pipeout (pipe)? 0x800: 0x1000))
-                       | (usb_dev->speed == USB_SPEED_LOW) << 13
-                       | usb_maxpacket (usb_dev, pipe) << 16);
-
-       return ed_ret;
-}
-
-/*-------------------------------------------------------------------------*
- * TD handling functions
- *-------------------------------------------------------------------------*/
-
-/* enqueue next TD for this URB (OHCI spec 5.2.8.2) */
-
-static void td_fill (ohci_t *ohci, unsigned int info,
-       void *data, int len,
-       struct usb_device *dev, int index, urb_priv_t *urb_priv)
-{
-       volatile td_t  *td, *td_pt;
-#ifdef OHCI_FILL_TRACE
-       int i;
-#endif
-
-       if (index > urb_priv->length) {
-               err("index > length");
-               return;
-       }
-       /* use this td as the next dummy */
-       td_pt = urb_priv->td [index];
-       td_pt->hwNextTD = 0;
-
-       /* fill the old dummy TD */
-       td = urb_priv->td [index] = (td_t *)(m32_swap (urb_priv->ed->hwTailP) & ~0xf);
-
-       td->ed = urb_priv->ed;
-       td->next_dl_td = NULL;
-       td->index = index;
-       td->data = (__u32)data;
-#ifdef OHCI_FILL_TRACE
-       if (1 || (usb_pipebulk(urb_priv->pipe) &&
-                               usb_pipeout(urb_priv->pipe))) {
-               for (i = 0; i < len; i++)
-               printf("td->data[%d] %#2x\n",i, ((unsigned char *)(td->data+0x80000000))[i]);
-       }
-#endif
-       if (!len)
-               data = 0;
-
-       td->hwINFO = m32_swap (info);
-       td->hwCBP = m32_swap (data);
-       if (data)
-               td->hwBE = m32_swap (data + len - 1);
-       else
-               td->hwBE = 0;
-       td->hwNextTD = m32_swap (td_pt);
-       td->hwPSW [0] = m16_swap (((__u32)data & 0x0FFF) | 0xE000);
-
-       /* append to queue */
-       td->ed->hwTailP = td->hwNextTD;
-}
-
-/*-------------------------------------------------------------------------*/
-
-/* prepare all TDs of a transfer */
-
-#define kseg_to_phys(x)          ((void *)((__u32)(x) - 0x80000000))
-
-static void td_submit_job (struct usb_device *dev, unsigned long pipe, void *buffer,
-       int transfer_len, struct devrequest *setup, urb_priv_t *urb, int interval)
-{
-       ohci_t *ohci = &gohci;
-       int data_len = transfer_len;
-       void *data;
-       int cnt = 0;
-       __u32 info = 0;
-       unsigned int toggle = 0;
-
-       /* OHCI handles the DATA-toggles itself, we just use the USB-toggle bits for reseting */
-       if(usb_gettoggle(dev, usb_pipeendpoint(pipe), usb_pipeout(pipe))) {
-               toggle = TD_T_TOGGLE;
-       } else {
-               toggle = TD_T_DATA0;
-               usb_settoggle(dev, usb_pipeendpoint(pipe), usb_pipeout(pipe), 1);
-       }
-       urb->td_cnt = 0;
-       if (data_len)
-               data = kseg_to_phys(buffer);
-       else
-               data = 0;
-
-       switch (usb_pipetype (pipe)) {
-       case PIPE_BULK:
-               info = usb_pipeout (pipe)?
-                       TD_CC | TD_DP_OUT : TD_CC | TD_DP_IN ;
-               while(data_len > 4096) {
-                       td_fill (ohci, info | (cnt? TD_T_TOGGLE:toggle), data, 4096, dev, cnt, urb);
-                       data += 4096; data_len -= 4096; cnt++;
-               }
-               info = usb_pipeout (pipe)?
-                       TD_CC | TD_DP_OUT : TD_CC | TD_R | TD_DP_IN ;
-               td_fill (ohci, info | (cnt? TD_T_TOGGLE:toggle), data, data_len, dev, cnt, urb);
-               cnt++;
-
-               if (!ohci->sleeping)
-                       writel (OHCI_BLF, &ohci->regs->cmdstatus); /* start bulk list */
-               break;
-
-       case PIPE_CONTROL:
-               info = TD_CC | TD_DP_SETUP | TD_T_DATA0;
-               td_fill (ohci, info, kseg_to_phys(setup), 8, dev, cnt++, urb);
-               if (data_len > 0) {
-                       info = usb_pipeout (pipe)?
-                               TD_CC | TD_R | TD_DP_OUT | TD_T_DATA1 : TD_CC | TD_R | TD_DP_IN | TD_T_DATA1;
-                       /* NOTE:  mishandles transfers >8K, some >4K */
-                       td_fill (ohci, info, data, data_len, dev, cnt++, urb);
-               }
-               info = usb_pipeout (pipe)?
-                       TD_CC | TD_DP_IN | TD_T_DATA1: TD_CC | TD_DP_OUT | TD_T_DATA1;
-               td_fill (ohci, info, data, 0, dev, cnt++, urb);
-               if (!ohci->sleeping)
-                       writel (OHCI_CLF, &ohci->regs->cmdstatus); /* start Control list */
-               break;
-       }
-       if (urb->length != cnt)
-               dbg("TD LENGTH %d != CNT %d", urb->length, cnt);
-}
-
-/*-------------------------------------------------------------------------*
- * Done List handling functions
- *-------------------------------------------------------------------------*/
-
-
-/* calculate the transfer length and update the urb */
-
-static void dl_transfer_length(td_t * td)
-{
-       __u32 tdINFO, tdBE, tdCBP;
-       urb_priv_t *lurb_priv = &urb_priv;
-
-       tdINFO = m32_swap (td->hwINFO);
-       tdBE   = m32_swap (td->hwBE);
-       tdCBP  = m32_swap (td->hwCBP);
-
-
-       if (!(usb_pipecontrol(lurb_priv->pipe) &&
-           ((td->index == 0) || (td->index == lurb_priv->length - 1)))) {
-               if (tdBE != 0) {
-                       if (td->hwCBP == 0)
-                               lurb_priv->actual_length += tdBE - td->data + 1;
-                       else
-                               lurb_priv->actual_length += tdCBP - td->data;
-               }
-       }
-}
-
-/*-------------------------------------------------------------------------*/
-
-/* replies to the request have to be on a FIFO basis so
- * we reverse the reversed done-list */
-
-static td_t * dl_reverse_done_list (ohci_t *ohci)
-{
-       __u32 td_list_hc;
-       td_t *td_rev = NULL;
-       td_t *td_list = NULL;
-       urb_priv_t *lurb_priv = NULL;
-
-       td_list_hc = m32_swap (ohci->hcca->done_head) & 0xfffffff0;
-       ohci->hcca->done_head = 0;
-
-       while (td_list_hc) {
-               td_list = (td_t *)td_list_hc;
-
-               if (TD_CC_GET (m32_swap (td_list->hwINFO))) {
-                       lurb_priv = &urb_priv;
-                       dbg(" USB-error/status: %x : %p",
-                                       TD_CC_GET (m32_swap (td_list->hwINFO)), td_list);
-                       if (td_list->ed->hwHeadP & m32_swap (0x1)) {
-                               if (lurb_priv && ((td_list->index + 1) < lurb_priv->length)) {
-                                       td_list->ed->hwHeadP =
-                                               (lurb_priv->td[lurb_priv->length - 1]->hwNextTD & m32_swap (0xfffffff0)) |
-                                                                       (td_list->ed->hwHeadP & m32_swap (0x2));
-                                       lurb_priv->td_cnt += lurb_priv->length - td_list->index - 1;
-                               } else
-                                       td_list->ed->hwHeadP &= m32_swap (0xfffffff2);
-                       }
-               }
-
-               td_list->next_dl_td = td_rev;
-               td_rev = td_list;
-               td_list_hc = m32_swap (td_list->hwNextTD) & 0xfffffff0;
-       }
-       return td_list;
-}
-
-/*-------------------------------------------------------------------------*/
-
-/* td done list */
-static int dl_done_list (ohci_t *ohci, td_t *td_list)
-{
-       td_t *td_list_next = NULL;
-       ed_t *ed;
-       int cc = 0;
-       int stat = 0;
-       /* urb_t *urb; */
-       urb_priv_t *lurb_priv;
-       __u32 tdINFO, edHeadP, edTailP;
-
-       while (td_list) {
-               td_list_next = td_list->next_dl_td;
-
-               lurb_priv = &urb_priv;
-               tdINFO = m32_swap (td_list->hwINFO);
-
-               ed = td_list->ed;
-
-               dl_transfer_length(td_list);
-
-               /* error code of transfer */
-               cc = TD_CC_GET (tdINFO);
-               if (cc != 0) {
-                       dbg("ConditionCode %#x", cc);
-                       stat = cc_to_error[cc];
-               }
-
-               if (ed->state != ED_NEW) {
-                       edHeadP = m32_swap (ed->hwHeadP) & 0xfffffff0;
-                       edTailP = m32_swap (ed->hwTailP);
-
-                       /* unlink eds if they are not busy */
-                       if ((edHeadP == edTailP) && (ed->state == ED_OPER))
-                               ep_unlink (ohci, ed);
-               }
-
-               td_list = td_list_next;
-       }
-       return stat;
-}
-
-/*-------------------------------------------------------------------------*
- * Virtual Root Hub
- *-------------------------------------------------------------------------*/
-
-#include <usbroothubdes.h>
-
-/* Hub class-specific descriptor is constructed dynamically */
-
-
-/*-------------------------------------------------------------------------*/
-
-#define OK(x)                  len = (x); break
-#ifdef DEBUG
-#define WR_RH_STAT(x)          {info("WR:status %#8x", (x));writel((x), &gohci.regs->roothub.status);}
-#define WR_RH_PORTSTAT(x)      {info("WR:portstatus[%d] %#8x", wIndex-1, (x));writel((x), &gohci.regs->roothub.portstatus[wIndex-1]);}
-#else
-#define WR_RH_STAT(x)          writel((x), &gohci.regs->roothub.status)
-#define WR_RH_PORTSTAT(x)      writel((x), &gohci.regs->roothub.portstatus[wIndex-1])
-#endif
-#define RD_RH_STAT             roothub_status(&gohci)
-#define RD_RH_PORTSTAT         roothub_portstatus(&gohci,wIndex-1)
-
-/* request to virtual root hub */
-
-int rh_check_port_status(ohci_t *controller)
-{
-       __u32 temp, ndp, i;
-       int res;
-
-       res = -1;
-       temp = roothub_a (controller);
-       ndp = (temp & RH_A_NDP);
-       for (i = 0; i < ndp; i++) {
-               temp = roothub_portstatus (controller, i);
-               /* check for a device disconnect */
-               if (((temp & (RH_PS_PESC | RH_PS_CSC)) ==
-                       (RH_PS_PESC | RH_PS_CSC)) &&
-                       ((temp & RH_PS_CCS) == 0)) {
-                       res = i;
-                       break;
-               }
-       }
-       return res;
-}
-
-static int ohci_submit_rh_msg(struct usb_device *dev, unsigned long pipe,
-               void *buffer, int transfer_len, struct devrequest *cmd)
-{
-       void * data = buffer;
-       int leni = transfer_len;
-       int len = 0;
-       int stat = 0;
-       __u32 datab[4];
-       __u8 *data_buf = (__u8 *)datab;
-       __u16 bmRType_bReq;
-       __u16 wValue;
-       __u16 wIndex;
-       __u16 wLength;
-
-#ifdef DEBUG
-urb_priv.actual_length = 0;
-pkt_print(dev, pipe, buffer, transfer_len, cmd, "SUB(rh)", usb_pipein(pipe));
-#else
-       mdelay(1);
-#endif
-       if (usb_pipeint(pipe)) {
-               info("Root-Hub submit IRQ: NOT implemented");
-               return 0;
-       }
-
-       bmRType_bReq  = cmd->requesttype | (cmd->request << 8);
-       wValue        = m16_swap (cmd->value);
-       wIndex        = m16_swap (cmd->index);
-       wLength       = m16_swap (cmd->length);
-
-       info("Root-Hub: adr: %2x cmd(%1x): %08x %04x %04x %04x",
-               dev->devnum, 8, bmRType_bReq, wValue, wIndex, wLength);
-
-       switch (bmRType_bReq) {
-       /* Request Destination:
-          without flags: Device,
-          RH_INTERFACE: interface,
-          RH_ENDPOINT: endpoint,
-          RH_CLASS means HUB here,
-          RH_OTHER | RH_CLASS  almost ever means HUB_PORT here
-       */
-
-       case RH_GET_STATUS:
-                       *(__u16 *) data_buf = m16_swap (1); OK (2);
-       case RH_GET_STATUS | RH_INTERFACE:
-                       *(__u16 *) data_buf = m16_swap (0); OK (2);
-       case RH_GET_STATUS | RH_ENDPOINT:
-                       *(__u16 *) data_buf = m16_swap (0); OK (2);
-       case RH_GET_STATUS | RH_CLASS:
-                       *(__u32 *) data_buf = m32_swap (
-                               RD_RH_STAT & ~(RH_HS_CRWE | RH_HS_DRWE));
-                       OK (4);
-       case RH_GET_STATUS | RH_OTHER | RH_CLASS:
-                       *(__u32 *) data_buf = m32_swap (RD_RH_PORTSTAT); OK (4);
-
-       case RH_CLEAR_FEATURE | RH_ENDPOINT:
-               switch (wValue) {
-                       case (RH_ENDPOINT_STALL): OK (0);
-               }
-               break;
-
-       case RH_CLEAR_FEATURE | RH_CLASS:
-               switch (wValue) {
-                       case RH_C_HUB_LOCAL_POWER:
-                               OK(0);
-                       case (RH_C_HUB_OVER_CURRENT):
-                                       WR_RH_STAT(RH_HS_OCIC); OK (0);
-               }
-               break;
-
-       case RH_CLEAR_FEATURE | RH_OTHER | RH_CLASS:
-               switch (wValue) {
-                       case (RH_PORT_ENABLE):
-                                       WR_RH_PORTSTAT (RH_PS_CCS ); OK (0);
-                       case (RH_PORT_SUSPEND):
-                                       WR_RH_PORTSTAT (RH_PS_POCI); OK (0);
-                       case (RH_PORT_POWER):
-                                       WR_RH_PORTSTAT (RH_PS_LSDA); OK (0);
-                       case (RH_C_PORT_CONNECTION):
-                                       WR_RH_PORTSTAT (RH_PS_CSC ); OK (0);
-                       case (RH_C_PORT_ENABLE):
-                                       WR_RH_PORTSTAT (RH_PS_PESC); OK (0);
-                       case (RH_C_PORT_SUSPEND):
-                                       WR_RH_PORTSTAT (RH_PS_PSSC); OK (0);
-                       case (RH_C_PORT_OVER_CURRENT):
-                                       WR_RH_PORTSTAT (RH_PS_OCIC); OK (0);
-                       case (RH_C_PORT_RESET):
-                                       WR_RH_PORTSTAT (RH_PS_PRSC); OK (0);
-               }
-               break;
-
-       case RH_SET_FEATURE | RH_OTHER | RH_CLASS:
-               switch (wValue) {
-                       case (RH_PORT_SUSPEND):
-                                       WR_RH_PORTSTAT (RH_PS_PSS ); OK (0);
-                       case (RH_PORT_RESET): /* BUG IN HUP CODE *********/
-                                       if (RD_RH_PORTSTAT & RH_PS_CCS)
-                                           WR_RH_PORTSTAT (RH_PS_PRS);
-                                       OK (0);
-                       case (RH_PORT_POWER):
-                                       WR_RH_PORTSTAT (RH_PS_PPS ); OK (0);
-                       case (RH_PORT_ENABLE): /* BUG IN HUP CODE *********/
-                                       if (RD_RH_PORTSTAT & RH_PS_CCS)
-                                           WR_RH_PORTSTAT (RH_PS_PES );
-                                       OK (0);
-               }
-               break;
-
-       case RH_SET_ADDRESS: gohci.rh.devnum = wValue; OK(0);
-
-       case RH_GET_DESCRIPTOR:
-               switch ((wValue & 0xff00) >> 8) {
-                       case (0x01): /* device descriptor */
-                               len = min_t(unsigned int,
-                                         leni,
-                                         min_t(unsigned int,
-                                             sizeof (root_hub_dev_des),
-                                             wLength));
-                               data_buf = root_hub_dev_des; OK(len);
-                       case (0x02): /* configuration descriptor */
-                               len = min_t(unsigned int,
-                                         leni,
-                                         min_t(unsigned int,
-                                             sizeof (root_hub_config_des),
-                                             wLength));
-                               data_buf = root_hub_config_des; OK(len);
-                       case (0x03): /* string descriptors */
-                               if(wValue==0x0300) {
-                                       len = min_t(unsigned int,
-                                                 leni,
-                                                 min_t(unsigned int,
-                                                     sizeof (root_hub_str_index0),
-                                                     wLength));
-                                       data_buf = root_hub_str_index0;
-                                       OK(len);
-                               }
-                               if(wValue==0x0301) {
-                                       len = min_t(unsigned int,
-                                                 leni,
-                                                 min_t(unsigned int,
-                                                     sizeof (root_hub_str_index1),
-                                                     wLength));
-                                       data_buf = root_hub_str_index1;
-                                       OK(len);
-                       }
-                       default:
-                               stat = USB_ST_STALLED;
-               }
-               break;
-
-       case RH_GET_DESCRIPTOR | RH_CLASS:
-           {
-                   __u32 temp = roothub_a (&gohci);
-
-                   data_buf [0] = 9;           /* min length; */
-                   data_buf [1] = 0x29;
-                   data_buf [2] = temp & RH_A_NDP;
-                   data_buf [3] = 0;
-                   if (temp & RH_A_PSM)        /* per-port power switching? */
-                       data_buf [3] |= 0x1;
-                   if (temp & RH_A_NOCP)       /* no overcurrent reporting? */
-                       data_buf [3] |= 0x10;
-                   else if (temp & RH_A_OCPM)  /* per-port overcurrent reporting? */
-                       data_buf [3] |= 0x8;
-
-                   /* corresponds to data_buf[4-7] */
-                   datab [1] = 0;
-                   data_buf [5] = (temp & RH_A_POTPGT) >> 24;
-                   temp = roothub_b (&gohci);
-                   data_buf [7] = temp & RH_B_DR;
-                   if (data_buf [2] < 7) {
-                       data_buf [8] = 0xff;
-                   } else {
-                       data_buf [0] += 2;
-                       data_buf [8] = (temp & RH_B_DR) >> 8;
-                       data_buf [10] = data_buf [9] = 0xff;
-                   }
-
-                   len = min_t(unsigned int, leni,
-                             min_t(unsigned int, data_buf [0], wLength));
-                   OK (len);
-               }
-
-       case RH_GET_CONFIGURATION:      *(__u8 *) data_buf = 0x01; OK (1);
-
-       case RH_SET_CONFIGURATION:      WR_RH_STAT (0x10000); OK (0);
-
-       default:
-               dbg ("unsupported root hub command");
-               stat = USB_ST_STALLED;
-       }
-
-#ifdef DEBUG
-       ohci_dump_roothub (&gohci, 1);
-#else
-       mdelay(1);
-#endif
-
-       len = min_t(int, len, leni);
-       if (data != data_buf)
-           memcpy (data, data_buf, len);
-       dev->act_len = len;
-       dev->status = stat;
-
-#ifdef DEBUG
-       if (transfer_len)
-               urb_priv.actual_length = transfer_len;
-       pkt_print(dev, pipe, buffer, transfer_len, cmd, "RET(rh)", 0/*usb_pipein(pipe)*/);
-#else
-       mdelay(1);
-#endif
-
-       return stat;
-}
-
-/*-------------------------------------------------------------------------*/
-
-/* common code for handling submit messages - used for all but root hub */
-/* accesses. */
-int submit_common_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
-               int transfer_len, struct devrequest *setup, int interval)
-{
-       int stat = 0;
-       int maxsize = usb_maxpacket(dev, pipe);
-       int timeout;
-
-       /* device pulled? Shortcut the action. */
-       if (devgone == dev) {
-               dev->status = USB_ST_CRC_ERR;
-               return 0;
-       }
-
-#ifdef DEBUG
-       urb_priv.actual_length = 0;
-       pkt_print(dev, pipe, buffer, transfer_len, setup, "SUB", usb_pipein(pipe));
-#else
-       mdelay(1);
-#endif
-       if (!maxsize) {
-               err("submit_common_message: pipesize for pipe %lx is zero",
-                       pipe);
-               return -1;
-       }
-
-       if (sohci_submit_job(dev, pipe, buffer, transfer_len, setup, interval) < 0) {
-               err("sohci_submit_job failed");
-               return -1;
-       }
-
-       mdelay(10);
-       /* ohci_dump_status(&gohci); */
-
-       /* allow more time for a BULK device to react - some are slow */
-#define BULK_TO         5000   /* timeout in milliseconds */
-       if (usb_pipebulk(pipe))
-               timeout = BULK_TO;
-       else
-               timeout = 100;
-
-       timeout *= 4;
-       /* wait for it to complete */
-       for (;;) {
-               /* check whether the controller is done */
-               stat = hc_interrupt();
-               if (stat < 0) {
-                       stat = USB_ST_CRC_ERR;
-                       break;
-               }
-               if (stat >= 0 && stat != 0xff) {
-                       /* 0xff is returned for an SF-interrupt */
-                       break;
-               }
-               if (--timeout) {
-                       udelay(250); /* mdelay(1); */
-               } else {
-                       err("CTL:TIMEOUT ");
-                       stat = USB_ST_CRC_ERR;
-                       break;
-               }
-       }
-       /* we got an Root Hub Status Change interrupt */
-       if (got_rhsc) {
-#ifdef DEBUG
-               ohci_dump_roothub (&gohci, 1);
-#endif
-               got_rhsc = 0;
-               /* abuse timeout */
-               timeout = rh_check_port_status(&gohci);
-               if (timeout >= 0) {
-#if 0 /* this does nothing useful, but leave it here in case that changes */
-                       /* the called routine adds 1 to the passed value */
-                       usb_hub_port_connect_change(gohci.rh.dev, timeout - 1);
-#endif
-                       /*
-                        * XXX
-                        * This is potentially dangerous because it assumes
-                        * that only one device is ever plugged in!
-                        */
-                       devgone = dev;
-               }
-       }
-
-       dev->status = stat;
-       dev->act_len = transfer_len;
-
-#ifdef DEBUG
-       pkt_print(dev, pipe, buffer, transfer_len, setup, "RET(ctlr)", usb_pipein(pipe));
-#else
-       mdelay(1);
-#endif
-
-       /* free TDs in urb_priv */
-       urb_free_priv (&urb_priv);
-       return 0;
-}
-
-/* submit routines called from usb.c */
-int submit_bulk_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
-               int transfer_len)
-{
-       info("submit_bulk_msg");
-       return submit_common_msg(dev, pipe, buffer, transfer_len, NULL, 0);
-}
-
-int submit_control_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
-               int transfer_len, struct devrequest *setup)
-{
-       int maxsize = usb_maxpacket(dev, pipe);
-
-       info("submit_control_msg");
-#ifdef DEBUG
-       urb_priv.actual_length = 0;
-       pkt_print(dev, pipe, buffer, transfer_len, setup, "SUB", usb_pipein(pipe));
-#else
-       mdelay(1);
-#endif
-       if (!maxsize) {
-               err("submit_control_message: pipesize for pipe %lx is zero",
-                       pipe);
-               return -1;
-       }
-       if (((pipe >> 8) & 0x7f) == gohci.rh.devnum) {
-               gohci.rh.dev = dev;
-               /* root hub - redirect */
-               return ohci_submit_rh_msg(dev, pipe, buffer, transfer_len,
-                       setup);
-       }
-
-       return submit_common_msg(dev, pipe, buffer, transfer_len, setup, 0);
-}
-
-int submit_int_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
-               int transfer_len, int interval)
-{
-       info("submit_int_msg");
-       return -1;
-}
-
-/*-------------------------------------------------------------------------*
- * HC functions
- *-------------------------------------------------------------------------*/
-
-/* reset the HC and BUS */
-
-static int hc_reset (ohci_t *ohci)
-{
-       int timeout = 30;
-       int smm_timeout = 50; /* 0,5 sec */
-
-       if (readl (&ohci->regs->control) & OHCI_CTRL_IR) { /* SMM owns the HC */
-               writel (OHCI_OCR, &ohci->regs->cmdstatus); /* request ownership */
-               info("USB HC TakeOver from SMM");
-               while (readl (&ohci->regs->control) & OHCI_CTRL_IR) {
-                       mdelay (10);
-                       if (--smm_timeout == 0) {
-                               err("USB HC TakeOver failed!");
-                               return -1;
-                       }
-               }
-       }
-
-       /* Disable HC interrupts */
-       writel (OHCI_INTR_MIE, &ohci->regs->intrdisable);
-
-       dbg("USB HC reset_hc usb-%s: ctrl = 0x%X ;",
-               ohci->slot_name,
-               readl (&ohci->regs->control));
-
-       /* Reset USB (needed by some controllers) */
-       writel (0, &ohci->regs->control);
-
-       /* HC Reset requires max 10 us delay */
-       writel (OHCI_HCR,  &ohci->regs->cmdstatus);
-       while ((readl (&ohci->regs->cmdstatus) & OHCI_HCR) != 0) {
-               if (--timeout == 0) {
-                       err("USB HC reset timed out!");
-                       return -1;
-               }
-               udelay (1);
-       }
-       return 0;
-}
-
-/*-------------------------------------------------------------------------*/
-
-/* Start an OHCI controller, set the BUS operational
- * enable interrupts
- * connect the virtual root hub */
-
-static int hc_start (ohci_t * ohci)
-{
-       __u32 mask;
-       unsigned int fminterval;
-
-       ohci->disabled = 1;
-
-       /* Tell the controller where the control and bulk lists are
-        * The lists are empty now. */
-
-       writel (0, &ohci->regs->ed_controlhead);
-       writel (0, &ohci->regs->ed_bulkhead);
-
-       writel ((__u32)ohci->hcca, &ohci->regs->hcca); /* a reset clears this */
-
-       fminterval = 0x2edf;
-       writel ((fminterval * 9) / 10, &ohci->regs->periodicstart);
-       fminterval |= ((((fminterval - 210) * 6) / 7) << 16);
-       writel (fminterval, &ohci->regs->fminterval);
-       writel (0x628, &ohci->regs->lsthresh);
-
-       /* start controller operations */
-       ohci->hc_control = OHCI_CONTROL_INIT | OHCI_USB_OPER;
-       ohci->disabled = 0;
-       writel (ohci->hc_control, &ohci->regs->control);
-
-       /* disable all interrupts */
-       mask = (OHCI_INTR_SO | OHCI_INTR_WDH | OHCI_INTR_SF | OHCI_INTR_RD |
-                       OHCI_INTR_UE | OHCI_INTR_FNO | OHCI_INTR_RHSC |
-                       OHCI_INTR_OC | OHCI_INTR_MIE);
-       writel (mask, &ohci->regs->intrdisable);
-       /* clear all interrupts */
-       mask &= ~OHCI_INTR_MIE;
-       writel (mask, &ohci->regs->intrstatus);
-       /* Choose the interrupts we care about now  - but w/o MIE */
-       mask = OHCI_INTR_RHSC | OHCI_INTR_UE | OHCI_INTR_WDH | OHCI_INTR_SO;
-       writel (mask, &ohci->regs->intrenable);
-
-#ifdef OHCI_USE_NPS
-       /* required for AMD-756 and some Mac platforms */
-       writel ((roothub_a (ohci) | RH_A_NPS) & ~RH_A_PSM,
-               &ohci->regs->roothub.a);
-       writel (RH_HS_LPSC, &ohci->regs->roothub.status);
-#endif /* OHCI_USE_NPS */
-
-       /* POTPGT delay is bits 24-31, in 2 ms units. */
-       mdelay ((roothub_a (ohci) >> 23) & 0x1fe);
-
-       /* connect the virtual root hub */
-       ohci->rh.devnum = 0;
-
-       return 0;
-}
-
-/*-------------------------------------------------------------------------*/
-
-/* an interrupt happens */
-
-static int
-hc_interrupt (void)
-{
-       ohci_t *ohci = &gohci;
-       struct ohci_regs *regs = ohci->regs;
-       int ints;
-       int stat = -1;
-
-       if ((ohci->hcca->done_head != 0) && !(m32_swap (ohci->hcca->done_head) & 0x01)) {
-               ints =  OHCI_INTR_WDH;
-       } else {
-               ints = readl (&regs->intrstatus);
-       }
-
-       /* dbg("Interrupt: %x frame: %x", ints, le16_to_cpu (ohci->hcca->frame_no)); */
-
-       if (ints & OHCI_INTR_RHSC) {
-               got_rhsc = 1;
-       }
-
-       if (ints & OHCI_INTR_UE) {
-               ohci->disabled++;
-               err ("OHCI Unrecoverable Error, controller usb-%s disabled",
-                       ohci->slot_name);
-               /* e.g. due to PCI Master/Target Abort */
-
-#ifdef DEBUG
-               ohci_dump (ohci, 1);
-#else
-       mdelay(1);
-#endif
-               /* FIXME: be optimistic, hope that bug won't repeat often. */
-               /* Make some non-interrupt context restart the controller. */
-               /* Count and limit the retries though; either hardware or */
-               /* software errors can go forever... */
-               hc_reset (ohci);
-               return -1;
-       }
-
-       if (ints & OHCI_INTR_WDH) {
-               mdelay(1);
-               writel (OHCI_INTR_WDH, &regs->intrdisable);
-               stat = dl_done_list (&gohci, dl_reverse_done_list (&gohci));
-               writel (OHCI_INTR_WDH, &regs->intrenable);
-       }
-
-       if (ints & OHCI_INTR_SO) {
-               dbg("USB Schedule overrun\n");
-               writel (OHCI_INTR_SO, &regs->intrenable);
-               stat = -1;
-       }
-
-       /* FIXME:  this assumes SOF (1/ms) interrupts don't get lost... */
-       if (ints & OHCI_INTR_SF) {
-               unsigned int frame = m16_swap (ohci->hcca->frame_no) & 1;
-               mdelay(1);
-               writel (OHCI_INTR_SF, &regs->intrdisable);
-               if (ohci->ed_rm_list[frame] != NULL)
-                       writel (OHCI_INTR_SF, &regs->intrenable);
-               stat = 0xff;
-       }
-
-       writel (ints, &regs->intrstatus);
-       return stat;
-}
-
-/*-------------------------------------------------------------------------*/
-
-/*-------------------------------------------------------------------------*/
-
-/* De-allocate all resources.. */
-
-static void hc_release_ohci (ohci_t *ohci)
-{
-       dbg ("USB HC release ohci usb-%s", ohci->slot_name);
-
-       if (!ohci->disabled)
-               hc_reset (ohci);
-}
-
-/*-------------------------------------------------------------------------*/
-
-#define __read_32bit_c0_register(source, sel)                          \
-({ int __res;                                                          \
-       if (sel == 0)                                                   \
-               __asm__ __volatile__(                                   \
-                       "mfc0\t%0, " #source "\n\t"                     \
-                       : "=r" (__res));                                \
-       else                                                            \
-               __asm__ __volatile__(                                   \
-                       ".set\tmips32\n\t"                              \
-                       "mfc0\t%0, " #source ", " #sel "\n\t"           \
-                       ".set\tmips0\n\t"                               \
-                       : "=r" (__res));                                \
-       __res;                                                          \
-})
-
-#define read_c0_prid()         __read_32bit_c0_register($15, 0)
-
-/*
- * low level initalisation routine, called from usb.c
- */
-static char ohci_inited = 0;
-
-int usb_lowlevel_init(int index, enum usb_init_type init, void **controller)
-{
-       u32 pin_func;
-       u32 sys_freqctrl, sys_clksrc;
-       u32 prid = read_c0_prid();
-
-       dbg("in usb_lowlevel_init\n");
-
-       /* zero and disable FREQ2 */
-       sys_freqctrl = au_readl(SYS_FREQCTRL0);
-       sys_freqctrl &= ~0xFFF00000;
-       au_writel(sys_freqctrl, SYS_FREQCTRL0);
-
-       /* zero and disable USBH/USBD clocks */
-       sys_clksrc = au_readl(SYS_CLKSRC);
-       sys_clksrc &= ~0x00007FE0;
-       au_writel(sys_clksrc, SYS_CLKSRC);
-
-       sys_freqctrl = au_readl(SYS_FREQCTRL0);
-       sys_freqctrl &= ~0xFFF00000;
-
-       sys_clksrc = au_readl(SYS_CLKSRC);
-       sys_clksrc &= ~0x00007FE0;
-
-       switch (prid & 0x000000FF) {
-       case 0x00: /* DA */
-       case 0x01: /* HA */
-       case 0x02: /* HB */
-               /* CPU core freq to 48MHz to slow it way down... */
-               au_writel(4, SYS_CPUPLL);
-
-               /*
-                * Setup 48MHz FREQ2 from CPUPLL for USB Host
-                */
-               /* FRDIV2=3 -> div by 8 of 384MHz -> 48MHz */
-               sys_freqctrl |= ((3<<22) | (1<<21) | (0<<20));
-               au_writel(sys_freqctrl, SYS_FREQCTRL0);
-
-               /* CPU core freq to 384MHz */
-               au_writel(0x20, SYS_CPUPLL);
-
-               printf("Au1000: 48MHz OHCI workaround enabled\n");
-               break;
-
-       default:  /* HC and newer */
-               /* FREQ2 = aux/2 = 48 MHz */
-               sys_freqctrl |= ((0<<22) | (1<<21) | (1<<20));
-               au_writel(sys_freqctrl, SYS_FREQCTRL0);
-               break;
-       }
-
-       /*
-        * Route 48MHz FREQ2 into USB Host and/or Device
-        */
-       sys_clksrc |= ((4<<12) | (0<<11) | (0<<10));
-       au_writel(sys_clksrc, SYS_CLKSRC);
-
-       /* configure pins GPIO[14:9] as GPIO */
-       pin_func = au_readl(SYS_PINFUNC) & (u32)(~0x8080);
-
-       au_writel(pin_func, SYS_PINFUNC);
-       au_writel(0x2800, SYS_TRIOUTCLR);
-       au_writel(0x0030, SYS_OUTPUTCLR);
-
-       dbg("OHCI board setup complete\n");
-
-       /* enable host controller */
-       au_writel(USBH_ENABLE_CE, USB_HOST_CONFIG);
-       udelay(1000);
-       au_writel(USBH_ENABLE_INIT, USB_HOST_CONFIG);
-       udelay(1000);
-
-       /* wait for reset complete (read register twice; see au1500 errata) */
-       while (au_readl(USB_HOST_CONFIG),
-              !(au_readl(USB_HOST_CONFIG) & USBH_ENABLE_RD))
-               udelay(1000);
-
-       dbg("OHCI clock running\n");
-
-       memset (&gohci, 0, sizeof (ohci_t));
-       memset (&urb_priv, 0, sizeof (urb_priv_t));
-
-       /* align the storage */
-       if ((__u32)&ghcca[0] & 0xff) {
-               err("HCCA not aligned!!");
-               return -1;
-       }
-       phcca = &ghcca[0];
-       info("aligned ghcca %p", phcca);
-       memset(&ohci_dev, 0, sizeof(struct ohci_device));
-       if ((__u32)&ohci_dev.ed[0] & 0x7) {
-               err("EDs not aligned!!");
-               return -1;
-       }
-       memset(gtd, 0, sizeof(td_t) * (NUM_TD + 1));
-       if ((__u32)gtd & 0x7) {
-               err("TDs not aligned!!");
-               return -1;
-       }
-       ptd = gtd;
-       gohci.hcca = phcca;
-       memset (phcca, 0, sizeof (struct ohci_hcca));
-
-       gohci.disabled = 1;
-       gohci.sleeping = 0;
-       gohci.irq = -1;
-       gohci.regs = (struct ohci_regs *)(USB_OHCI_BASE | 0xA0000000);
-
-       gohci.flags = 0;
-       gohci.slot_name = "au1x00";
-
-       dbg("OHCI revision: 0x%08x\n"
-              "  RH: a: 0x%08x b: 0x%08x\n",
-              readl(&gohci.regs->revision),
-              readl(&gohci.regs->roothub.a), readl(&gohci.regs->roothub.b));
-
-       if (hc_reset (&gohci) < 0)
-               goto errout;
-
-       /* FIXME this is a second HC reset; why?? */
-       writel (gohci.hc_control = OHCI_USB_RESET, &gohci.regs->control);
-       mdelay (10);
-
-       if (hc_start (&gohci) < 0)
-               goto errout;
-
-#ifdef DEBUG
-       ohci_dump (&gohci, 1);
-#else
-       mdelay(1);
-#endif
-       ohci_inited = 1;
-       return 0;
-
-  errout:
-       err("OHCI initialization error\n");
-       hc_release_ohci (&gohci);
-       /* Initialization failed */
-       au_writel(readl(USB_HOST_CONFIG) & ~USBH_ENABLE_CE, USB_HOST_CONFIG);
-       return -1;
-}
-
-int usb_lowlevel_stop(int index)
-{
-       /* this gets called really early - before the controller has */
-       /* even been initialized! */
-       if (!ohci_inited)
-               return 0;
-       /* TODO release any interrupts, etc. */
-       /* call hc_release_ohci() here ? */
-       hc_reset (&gohci);
-       /* may not want to do this */
-       /* Disable clock */
-       au_writel(readl(USB_HOST_CONFIG) & ~USBH_ENABLE_CE, USB_HOST_CONFIG);
-       return 0;
-}
-
-#endif /* CONFIG_USB_OHCI */
diff --git a/arch/mips/cpu/mips32/au1x00/au1x00_usb_ohci.h b/arch/mips/cpu/mips32/au1x00/au1x00_usb_ohci.h
deleted file mode 100644 (file)
index bb9f351..0000000
+++ /dev/null
@@ -1,416 +0,0 @@
-/*
- * URB OHCI HCD (Host Controller Driver) for USB.
- *
- * (C) Copyright 1999 Roman Weissgaerber <weissg@vienna.at>
- * (C) Copyright 2000-2001 David Brownell <dbrownell@users.sourceforge.net>
- *
- * usb-ohci.h
- */
-
-
-static int cc_to_error[16] = {
-
-/* mapping of the OHCI CC status to error codes */
-       /* No  Error  */        0,
-       /* CRC Error  */        USB_ST_CRC_ERR,
-       /* Bit Stuff  */        USB_ST_BIT_ERR,
-       /* Data Togg  */        USB_ST_CRC_ERR,
-       /* Stall      */        USB_ST_STALLED,
-       /* DevNotResp */        -1,
-       /* PIDCheck   */        USB_ST_BIT_ERR,
-       /* UnExpPID   */        USB_ST_BIT_ERR,
-       /* DataOver   */        USB_ST_BUF_ERR,
-       /* DataUnder  */        USB_ST_BUF_ERR,
-       /* reservd    */        -1,
-       /* reservd    */        -1,
-       /* BufferOver */        USB_ST_BUF_ERR,
-       /* BuffUnder  */        USB_ST_BUF_ERR,
-       /* Not Access */        -1,
-       /* Not Access */        -1
-};
-
-/* ED States */
-
-#define ED_NEW         0x00
-#define ED_UNLINK      0x01
-#define ED_OPER                0x02
-#define ED_DEL         0x04
-#define ED_URB_DEL     0x08
-
-/* usb_ohci_ed */
-struct ed {
-       __u32 hwINFO;
-       __u32 hwTailP;
-       __u32 hwHeadP;
-       __u32 hwNextED;
-
-       struct ed *ed_prev;
-       __u8 int_period;
-       __u8 int_branch;
-       __u8 int_load;
-       __u8 int_interval;
-       __u8 state;
-       __u8 type;
-       __u16 last_iso;
-       struct ed *ed_rm_list;
-
-       struct usb_device *usb_dev;
-       __u32 unused[3];
-} __attribute__((aligned(16)));
-typedef struct ed ed_t;
-
-
-/* TD info field */
-#define TD_CC                  0xf0000000
-#define TD_CC_GET(td_p)                ((td_p >>28) & 0x0f)
-#define TD_CC_SET(td_p, cc)    (td_p) = ((td_p) & 0x0fffffff) | (((cc) & 0x0f) << 28)
-#define TD_EC                  0x0C000000
-#define TD_T                   0x03000000
-#define TD_T_DATA0             0x02000000
-#define TD_T_DATA1             0x03000000
-#define TD_T_TOGGLE            0x00000000
-#define TD_R                   0x00040000
-#define TD_DI                  0x00E00000
-#define TD_DI_SET(X)           (((X) & 0x07)<< 21)
-#define TD_DP                  0x00180000
-#define TD_DP_SETUP            0x00000000
-#define TD_DP_IN               0x00100000
-#define TD_DP_OUT              0x00080000
-
-#define TD_ISO                 0x00010000
-#define TD_DEL                 0x00020000
-
-/* CC Codes */
-#define TD_CC_NOERROR          0x00
-#define TD_CC_CRC              0x01
-#define TD_CC_BITSTUFFING      0x02
-#define TD_CC_DATATOGGLEM      0x03
-#define TD_CC_STALL            0x04
-#define TD_DEVNOTRESP          0x05
-#define TD_PIDCHECKFAIL                0x06
-#define TD_UNEXPECTEDPID       0x07
-#define TD_DATAOVERRUN         0x08
-#define TD_DATAUNDERRUN                0x09
-#define TD_BUFFEROVERRUN       0x0C
-#define TD_BUFFERUNDERRUN      0x0D
-#define TD_NOTACCESSED         0x0F
-
-
-#define MAXPSW 1
-
-struct td {
-       __u32 hwINFO;
-       __u32 hwCBP;            /* Current Buffer Pointer */
-       __u32 hwNextTD;         /* Next TD Pointer */
-       __u32 hwBE;             /* Memory Buffer End Pointer */
-
-       __u16 hwPSW[MAXPSW];
-       __u8 unused;
-       __u8 index;
-       struct ed *ed;
-       struct td *next_dl_td;
-       struct usb_device *usb_dev;
-       int transfer_len;
-       __u32 data;
-
-       __u32 unused2[2];
-} __attribute__((aligned(32)));
-typedef struct td td_t;
-
-#define OHCI_ED_SKIP   (1 << 14)
-
-/*
- * The HCCA (Host Controller Communications Area) is a 256 byte
- * structure defined in the OHCI spec. that the host controller is
- * told the base address of.  It must be 256-byte aligned.
- */
-
-#define NUM_INTS 32    /* part of the OHCI standard */
-struct ohci_hcca {
-       __u32   int_table[NUM_INTS];    /* Interrupt ED table */
-       __u16   frame_no;               /* current frame number */
-       __u16   pad1;                   /* set to 0 on each frame_no change */
-       __u32   done_head;              /* info returned for an interrupt */
-       u8              reserved_for_hc[116];
-} __attribute__((aligned(256)));
-
-
-/*
- * Maximum number of root hub ports.
- */
-#define MAX_ROOT_PORTS 15      /* maximum OHCI root hub ports */
-
-/*
- * This is the structure of the OHCI controller's memory mapped I/O
- * region.  This is Memory Mapped I/O. You must use the readl() and
- * writel() macros defined in asm/io.h to access these!!
- */
-struct ohci_regs {
-       /* control and status registers */
-       __u32   revision;
-       __u32   control;
-       __u32   cmdstatus;
-       __u32   intrstatus;
-       __u32   intrenable;
-       __u32   intrdisable;
-       /* memory pointers */
-       __u32   hcca;
-       __u32   ed_periodcurrent;
-       __u32   ed_controlhead;
-       __u32   ed_controlcurrent;
-       __u32   ed_bulkhead;
-       __u32   ed_bulkcurrent;
-       __u32   donehead;
-       /* frame counters */
-       __u32   fminterval;
-       __u32   fmremaining;
-       __u32   fmnumber;
-       __u32   periodicstart;
-       __u32   lsthresh;
-       /* Root hub ports */
-       struct  ohci_roothub_regs {
-               __u32   a;
-               __u32   b;
-               __u32   status;
-               __u32   portstatus[MAX_ROOT_PORTS];
-       } roothub;
-} __attribute__((aligned(32)));
-
-
-/* OHCI CONTROL AND STATUS REGISTER MASKS */
-
-/*
- * HcControl (control) register masks
- */
-#define OHCI_CTRL_CBSR (3 << 0)        /* control/bulk service ratio */
-#define OHCI_CTRL_PLE  (1 << 2)        /* periodic list enable */
-#define OHCI_CTRL_IE   (1 << 3)        /* isochronous enable */
-#define OHCI_CTRL_CLE  (1 << 4)        /* control list enable */
-#define OHCI_CTRL_BLE  (1 << 5)        /* bulk list enable */
-#define OHCI_CTRL_HCFS (3 << 6)        /* host controller functional state */
-#define OHCI_CTRL_IR   (1 << 8)        /* interrupt routing */
-#define OHCI_CTRL_RWC  (1 << 9)        /* remote wakeup connected */
-#define OHCI_CTRL_RWE  (1 << 10)       /* remote wakeup enable */
-
-/* pre-shifted values for HCFS */
-#      define OHCI_USB_RESET   (0 << 6)
-#      define OHCI_USB_RESUME  (1 << 6)
-#      define OHCI_USB_OPER    (2 << 6)
-#      define OHCI_USB_SUSPEND (3 << 6)
-
-/*
- * HcCommandStatus (cmdstatus) register masks
- */
-#define OHCI_HCR       (1 << 0)        /* host controller reset */
-#define OHCI_CLF       (1 << 1)        /* control list filled */
-#define OHCI_BLF       (1 << 2)        /* bulk list filled */
-#define OHCI_OCR       (1 << 3)        /* ownership change request */
-#define OHCI_SOC       (3 << 16)       /* scheduling overrun count */
-
-/*
- * masks used with interrupt registers:
- * HcInterruptStatus (intrstatus)
- * HcInterruptEnable (intrenable)
- * HcInterruptDisable (intrdisable)
- */
-#define OHCI_INTR_SO   (1 << 0)        /* scheduling overrun */
-#define OHCI_INTR_WDH  (1 << 1)        /* writeback of done_head */
-#define OHCI_INTR_SF   (1 << 2)        /* start frame */
-#define OHCI_INTR_RD   (1 << 3)        /* resume detect */
-#define OHCI_INTR_UE   (1 << 4)        /* unrecoverable error */
-#define OHCI_INTR_FNO  (1 << 5)        /* frame number overflow */
-#define OHCI_INTR_RHSC (1 << 6)        /* root hub status change */
-#define OHCI_INTR_OC   (1 << 30)       /* ownership change */
-#define OHCI_INTR_MIE  (1 << 31)       /* master interrupt enable */
-
-
-/* Virtual Root HUB */
-struct virt_root_hub {
-       int devnum; /* Address of Root Hub endpoint */
-       void *dev;  /* was urb */
-       void *int_addr;
-       int send;
-       int interval;
-};
-
-/* USB HUB CONSTANTS (not OHCI-specific; see hub.h) */
-
-/* destination of request */
-#define RH_INTERFACE           0x01
-#define RH_ENDPOINT            0x02
-#define RH_OTHER               0x03
-
-#define RH_CLASS               0x20
-#define RH_VENDOR              0x40
-
-/* Requests: bRequest << 8 | bmRequestType */
-#define RH_GET_STATUS          0x0080
-#define RH_CLEAR_FEATURE       0x0100
-#define RH_SET_FEATURE         0x0300
-#define RH_SET_ADDRESS         0x0500
-#define RH_GET_DESCRIPTOR      0x0680
-#define RH_SET_DESCRIPTOR      0x0700
-#define RH_GET_CONFIGURATION   0x0880
-#define RH_SET_CONFIGURATION   0x0900
-#define RH_GET_STATE           0x0280
-#define RH_GET_INTERFACE       0x0A80
-#define RH_SET_INTERFACE       0x0B00
-#define RH_SYNC_FRAME          0x0C80
-/* Our Vendor Specific Request */
-#define RH_SET_EP              0x2000
-
-
-/* Hub port features */
-#define RH_PORT_CONNECTION     0x00
-#define RH_PORT_ENABLE         0x01
-#define RH_PORT_SUSPEND                0x02
-#define RH_PORT_OVER_CURRENT   0x03
-#define RH_PORT_RESET          0x04
-#define RH_PORT_POWER          0x08
-#define RH_PORT_LOW_SPEED      0x09
-
-#define RH_C_PORT_CONNECTION   0x10
-#define RH_C_PORT_ENABLE       0x11
-#define RH_C_PORT_SUSPEND      0x12
-#define RH_C_PORT_OVER_CURRENT 0x13
-#define RH_C_PORT_RESET                0x14
-
-/* Hub features */
-#define RH_C_HUB_LOCAL_POWER   0x00
-#define RH_C_HUB_OVER_CURRENT  0x01
-
-#define RH_DEVICE_REMOTE_WAKEUP 0x00
-#define RH_ENDPOINT_STALL      0x01
-
-#define RH_ACK                 0x01
-#define RH_REQ_ERR             -1
-#define RH_NACK                        0x00
-
-
-/* OHCI ROOT HUB REGISTER MASKS */
-
-/* roothub.portstatus [i] bits */
-#define RH_PS_CCS              0x00000001      /* current connect status */
-#define RH_PS_PES              0x00000002      /* port enable status*/
-#define RH_PS_PSS              0x00000004      /* port suspend status */
-#define RH_PS_POCI             0x00000008      /* port over current indicator */
-#define RH_PS_PRS              0x00000010      /* port reset status */
-#define RH_PS_PPS              0x00000100      /* port power status */
-#define RH_PS_LSDA             0x00000200      /* low speed device attached */
-#define RH_PS_CSC              0x00010000      /* connect status change */
-#define RH_PS_PESC             0x00020000      /* port enable status change */
-#define RH_PS_PSSC             0x00040000      /* port suspend status change */
-#define RH_PS_OCIC             0x00080000      /* over current indicator change */
-#define RH_PS_PRSC             0x00100000      /* port reset status change */
-
-/* roothub.status bits */
-#define RH_HS_LPS              0x00000001      /* local power status */
-#define RH_HS_OCI              0x00000002      /* over current indicator */
-#define RH_HS_DRWE             0x00008000      /* device remote wakeup enable */
-#define RH_HS_LPSC             0x00010000      /* local power status change */
-#define RH_HS_OCIC             0x00020000      /* over current indicator change */
-#define RH_HS_CRWE             0x80000000      /* clear remote wakeup enable */
-
-/* roothub.b masks */
-#define RH_B_DR                        0x0000ffff      /* device removable flags */
-#define RH_B_PPCM              0xffff0000      /* port power control mask */
-
-/* roothub.a masks */
-#define        RH_A_NDP                (0xff << 0)     /* number of downstream ports */
-#define        RH_A_PSM                (1 << 8)        /* power switching mode */
-#define        RH_A_NPS                (1 << 9)        /* no power switching */
-#define        RH_A_DT                 (1 << 10)       /* device type (mbz) */
-#define        RH_A_OCPM               (1 << 11)       /* over current protection mode */
-#define        RH_A_NOCP               (1 << 12)       /* no over current protection */
-#define        RH_A_POTPGT             (0xff << 24)    /* power on to power good time */
-
-/* urb */
-#define N_URB_TD 48
-typedef struct
-{
-       ed_t *ed;
-       __u16 length;           /* number of tds associated with this request */
-       __u16 td_cnt;           /* number of tds already serviced */
-       int   state;
-       unsigned long pipe;
-       int actual_length;
-       td_t *td[N_URB_TD];     /* list pointer to all corresponding TDs associated with this request */
-} urb_priv_t;
-#define URB_DEL 1
-
-/*
- * This is the full ohci controller description
- *
- * Note how the "proper" USB information is just
- * a subset of what the full implementation needs. (Linus)
- */
-
-
-typedef struct ohci {
-       struct ohci_hcca *hcca;         /* hcca */
-       /*dma_addr_t hcca_dma;*/
-
-       int irq;
-       int disabled;                   /* e.g. got a UE, we're hung */
-       int sleeping;
-       unsigned long flags;            /* for HC bugs */
-
-       struct ohci_regs *regs;         /* OHCI controller's memory */
-
-       ed_t *ed_rm_list[2];            /* lists of all endpoints to be removed */
-       ed_t *ed_bulktail;              /* last endpoint of bulk list */
-       ed_t *ed_controltail;           /* last endpoint of control list */
-       int intrstatus;
-       __u32 hc_control;               /* copy of the hc control reg */
-       struct usb_device *dev[32];
-       struct virt_root_hub rh;
-
-       const char      *slot_name;
-} ohci_t;
-
-#define NUM_EDS 8              /* num of preallocated endpoint descriptors */
-
-struct ohci_device {
-       ed_t    ed[NUM_EDS];
-       int ed_cnt;
-};
-
-/* hcd */
-/* endpoint */
-static int ep_link(ohci_t * ohci, ed_t * ed);
-static int ep_unlink(ohci_t * ohci, ed_t * ed);
-static ed_t * ep_add_ed(struct usb_device * usb_dev, unsigned long pipe);
-
-/*-------------------------------------------------------------------------*/
-
-/* we need more TDs than EDs */
-#define NUM_TD 64
-
-/* +1 so we can align the storage */
-td_t gtd[NUM_TD+1];
-/* pointers to aligned storage */
-td_t *ptd;
-
-/* TDs ... */
-static inline struct td *
-td_alloc (struct usb_device *usb_dev)
-{
-       int i;
-       struct td       *td;
-
-       td = NULL;
-       for (i = 0; i < NUM_TD; i++) {
-               if (ptd[i].usb_dev == NULL) {
-                       td = &ptd[i];
-                       td->usb_dev = usb_dev;
-                       break;
-               }
-       }
-       return td;
-}
-
-static inline void
-ed_free (struct ed *ed)
-{
-       ed->usb_dev = NULL;
-}
diff --git a/arch/mips/cpu/mips32/au1x00/config.mk b/arch/mips/cpu/mips32/au1x00/config.mk
deleted file mode 100644 (file)
index 5c89129..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-#
-# (C) Copyright 2011
-# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
-#
-# SPDX-License-Identifier:     GPL-2.0+
-#
-
-PLATFORM_CPPFLAGS += -mtune=4kc
diff --git a/arch/mips/cpu/mips32/cache.S b/arch/mips/cpu/mips32/cache.S
deleted file mode 100644 (file)
index 22bd844..0000000
+++ /dev/null
@@ -1,281 +0,0 @@
-/*
- *  Cache-handling routined for MIPS CPUs
- *
- *  Copyright (c) 2003 Wolfgang Denk <wd@denx.de>
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#include <asm-offsets.h>
-#include <config.h>
-#include <asm/asm.h>
-#include <asm/regdef.h>
-#include <asm/mipsregs.h>
-#include <asm/addrspace.h>
-#include <asm/cacheops.h>
-
-#ifndef CONFIG_SYS_MIPS_CACHE_MODE
-#define CONFIG_SYS_MIPS_CACHE_MODE CONF_CM_CACHABLE_NONCOHERENT
-#endif
-
-#define RA             t9
-
-#define INDEX_BASE     CKSEG0
-
-       .macro  cache_op op addr
-       .set    push
-       .set    noreorder
-       .set    mips3
-       cache   \op, 0(\addr)
-       .set    pop
-       .endm
-
-       .macro  f_fill64 dst, offset, val
-       LONG_S  \val, (\offset +  0 * LONGSIZE)(\dst)
-       LONG_S  \val, (\offset +  1 * LONGSIZE)(\dst)
-       LONG_S  \val, (\offset +  2 * LONGSIZE)(\dst)
-       LONG_S  \val, (\offset +  3 * LONGSIZE)(\dst)
-       LONG_S  \val, (\offset +  4 * LONGSIZE)(\dst)
-       LONG_S  \val, (\offset +  5 * LONGSIZE)(\dst)
-       LONG_S  \val, (\offset +  6 * LONGSIZE)(\dst)
-       LONG_S  \val, (\offset +  7 * LONGSIZE)(\dst)
-#if LONGSIZE == 4
-       LONG_S  \val, (\offset +  8 * LONGSIZE)(\dst)
-       LONG_S  \val, (\offset +  9 * LONGSIZE)(\dst)
-       LONG_S  \val, (\offset + 10 * LONGSIZE)(\dst)
-       LONG_S  \val, (\offset + 11 * LONGSIZE)(\dst)
-       LONG_S  \val, (\offset + 12 * LONGSIZE)(\dst)
-       LONG_S  \val, (\offset + 13 * LONGSIZE)(\dst)
-       LONG_S  \val, (\offset + 14 * LONGSIZE)(\dst)
-       LONG_S  \val, (\offset + 15 * LONGSIZE)(\dst)
-#endif
-       .endm
-
-/*
- * mips_init_icache(uint PRId, ulong icache_size, unchar icache_linesz)
- */
-LEAF(mips_init_icache)
-       blez            a1, 9f
-       mtc0            zero, CP0_TAGLO
-       /* clear tag to invalidate */
-       PTR_LI          t0, INDEX_BASE
-       PTR_ADDU        t1, t0, a1
-1:     cache_op        INDEX_STORE_TAG_I t0
-       PTR_ADDU        t0, a2
-       bne             t0, t1, 1b
-       /* fill once, so data field parity is correct */
-       PTR_LI          t0, INDEX_BASE
-2:     cache_op        FILL t0
-       PTR_ADDU        t0, a2
-       bne             t0, t1, 2b
-       /* invalidate again - prudent but not strictly neccessary */
-       PTR_LI          t0, INDEX_BASE
-1:     cache_op        INDEX_STORE_TAG_I t0
-       PTR_ADDU        t0, a2
-       bne             t0, t1, 1b
-9:     jr              ra
-       END(mips_init_icache)
-
-/*
- * mips_init_dcache(uint PRId, ulong dcache_size, unchar dcache_linesz)
- */
-LEAF(mips_init_dcache)
-       blez            a1, 9f
-       mtc0            zero, CP0_TAGLO
-       /* clear all tags */
-       PTR_LI          t0, INDEX_BASE
-       PTR_ADDU        t1, t0, a1
-1:     cache_op        INDEX_STORE_TAG_D t0
-       PTR_ADDU        t0, a2
-       bne             t0, t1, 1b
-       /* load from each line (in cached space) */
-       PTR_LI          t0, INDEX_BASE
-2:     LONG_L          zero, 0(t0)
-       PTR_ADDU        t0, a2
-       bne             t0, t1, 2b
-       /* clear all tags */
-       PTR_LI          t0, INDEX_BASE
-1:     cache_op        INDEX_STORE_TAG_D t0
-       PTR_ADDU        t0, a2
-       bne             t0, t1, 1b
-9:     jr              ra
-       END(mips_init_dcache)
-
-/*
- * mips_cache_reset - low level initialisation of the primary caches
- *
- * This routine initialises the primary caches to ensure that they have good
- * parity.  It must be called by the ROM before any cached locations are used
- * to prevent the possibility of data with bad parity being written to memory.
- *
- * To initialise the instruction cache it is essential that a source of data
- * with good parity is available. This routine will initialise an area of
- * memory starting at location zero to be used as a source of parity.
- *
- * RETURNS: N/A
- *
- */
-NESTED(mips_cache_reset, 0, ra)
-       move    RA, ra
-
-#if !defined(CONFIG_SYS_ICACHE_SIZE) || !defined(CONFIG_SYS_DCACHE_SIZE) || \
-    !defined(CONFIG_SYS_CACHELINE_SIZE)
-       /* read Config1 for use below */
-       mfc0    t5, CP0_CONFIG, 1
-#endif
-
-#ifdef CONFIG_SYS_CACHELINE_SIZE
-       li      t7, CONFIG_SYS_CACHELINE_SIZE
-       li      t8, CONFIG_SYS_CACHELINE_SIZE
-#else
-       /* Detect I-cache line size. */
-       srl     t8, t5, MIPS_CONF1_IL_SHIFT
-       andi    t8, t8, (MIPS_CONF1_IL >> MIPS_CONF1_IL_SHIFT)
-       beqz    t8, 1f
-       li      t6, 2
-       sllv    t8, t6, t8
-
-1:     /* Detect D-cache line size. */
-       srl     t7, t5, MIPS_CONF1_DL_SHIFT
-       andi    t7, t7, (MIPS_CONF1_DL >> MIPS_CONF1_DL_SHIFT)
-       beqz    t7, 1f
-       li      t6, 2
-       sllv    t7, t6, t7
-1:
-#endif
-
-#ifdef CONFIG_SYS_ICACHE_SIZE
-       li      t2, CONFIG_SYS_ICACHE_SIZE
-#else
-       /* Detect I-cache size. */
-       srl     t6, t5, MIPS_CONF1_IS_SHIFT
-       andi    t6, t6, (MIPS_CONF1_IS >> MIPS_CONF1_IS_SHIFT)
-       li      t4, 32
-       xori    t2, t6, 0x7
-       beqz    t2, 1f
-       addi    t6, t6, 1
-       sllv    t4, t4, t6
-1:     /* At this point t4 == I-cache sets. */
-       mul     t2, t4, t8
-       srl     t6, t5, MIPS_CONF1_IA_SHIFT
-       andi    t6, t6, (MIPS_CONF1_IA >> MIPS_CONF1_IA_SHIFT)
-       addi    t6, t6, 1
-       /* At this point t6 == I-cache ways. */
-       mul     t2, t2, t6
-#endif
-
-#ifdef CONFIG_SYS_DCACHE_SIZE
-       li      t3, CONFIG_SYS_DCACHE_SIZE
-#else
-       /* Detect D-cache size. */
-       srl     t6, t5, MIPS_CONF1_DS_SHIFT
-       andi    t6, t6, (MIPS_CONF1_DS >> MIPS_CONF1_DS_SHIFT)
-       li      t4, 32
-       xori    t3, t6, 0x7
-       beqz    t3, 1f
-       addi    t6, t6, 1
-       sllv    t4, t4, t6
-1:     /* At this point t4 == I-cache sets. */
-       mul     t3, t4, t7
-       srl     t6, t5, MIPS_CONF1_DA_SHIFT
-       andi    t6, t6, (MIPS_CONF1_DA >> MIPS_CONF1_DA_SHIFT)
-       addi    t6, t6, 1
-       /* At this point t6 == I-cache ways. */
-       mul     t3, t3, t6
-#endif
-
-       /* Determine the largest L1 cache size */
-#if defined(CONFIG_SYS_ICACHE_SIZE) && defined(CONFIG_SYS_DCACHE_SIZE)
-#if CONFIG_SYS_ICACHE_SIZE > CONFIG_SYS_DCACHE_SIZE
-       li      v0, CONFIG_SYS_ICACHE_SIZE
-#else
-       li      v0, CONFIG_SYS_DCACHE_SIZE
-#endif
-#else
-       move    v0, t2
-       sltu    t1, t2, t3
-       movn    v0, t3, t1
-#endif
-       /*
-        * Now clear that much memory starting from zero.
-        */
-       PTR_LI          a0, CKSEG1
-       PTR_ADDU        a1, a0, v0
-2:     PTR_ADDIU       a0, 64
-       f_fill64        a0, -64, zero
-       bne             a0, a1, 2b
-
-       /*
-        * The caches are probably in an indeterminate state,
-        * so we force good parity into them by doing an
-        * invalidate, load/fill, invalidate for each line.
-        */
-
-       /*
-        * Assume bottom of RAM will generate good parity for the cache.
-        */
-
-       /*
-        * Initialize the I-cache first,
-        */
-       move    a1, t2
-       move    a2, t8
-       PTR_LA  v1, mips_init_icache
-       jalr    v1
-
-       /*
-        * then initialize D-cache.
-        */
-       move    a1, t3
-       move    a2, t7
-       PTR_LA  v1, mips_init_dcache
-       jalr    v1
-
-       jr      RA
-       END(mips_cache_reset)
-
-/*
- * dcache_status - get cache status
- *
- * RETURNS: 0 - cache disabled; 1 - cache enabled
- *
- */
-LEAF(dcache_status)
-       mfc0    t0, CP0_CONFIG
-       li      t1, CONF_CM_UNCACHED
-       andi    t0, t0, CONF_CM_CMASK
-       move    v0, zero
-       beq     t0, t1, 2f
-       li      v0, 1
-2:     jr      ra
-       END(dcache_status)
-
-/*
- * dcache_disable - disable cache
- *
- * RETURNS: N/A
- *
- */
-LEAF(dcache_disable)
-       mfc0    t0, CP0_CONFIG
-       li      t1, -8
-       and     t0, t0, t1
-       ori     t0, t0, CONF_CM_UNCACHED
-       mtc0    t0, CP0_CONFIG
-       jr      ra
-       END(dcache_disable)
-
-/*
- * dcache_enable - enable cache
- *
- * RETURNS: N/A
- *
- */
-LEAF(dcache_enable)
-       mfc0    t0, CP0_CONFIG
-       ori     t0, CONF_CM_CMASK
-       xori    t0, CONF_CM_CMASK
-       ori     t0, CONFIG_SYS_MIPS_CACHE_MODE
-       mtc0    t0, CP0_CONFIG
-       jr      ra
-       END(dcache_enable)
diff --git a/arch/mips/cpu/mips32/cpu.c b/arch/mips/cpu/mips32/cpu.c
deleted file mode 100644 (file)
index 278865b..0000000
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * (C) Copyright 2003
- * Wolfgang Denk, DENX Software Engineering, <wd@denx.de>
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#include <common.h>
-#include <command.h>
-#include <netdev.h>
-#include <asm/mipsregs.h>
-#include <asm/cacheops.h>
-#include <asm/reboot.h>
-
-#define cache_op(op,addr)                                              \
-       __asm__ __volatile__(                                           \
-       "       .set    push                                    \n"     \
-       "       .set    noreorder                               \n"     \
-       "       .set    mips3\n\t                               \n"     \
-       "       cache   %0, %1                                  \n"     \
-       "       .set    pop                                     \n"     \
-       :                                                               \
-       : "i" (op), "R" (*(unsigned char *)(addr)))
-
-void __attribute__((weak)) _machine_restart(void)
-{
-}
-
-int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
-{
-       _machine_restart();
-
-       fprintf(stderr, "*** reset failed ***\n");
-       return 0;
-}
-
-#ifdef CONFIG_SYS_CACHELINE_SIZE
-
-static inline unsigned long icache_line_size(void)
-{
-       return CONFIG_SYS_CACHELINE_SIZE;
-}
-
-static inline unsigned long dcache_line_size(void)
-{
-       return CONFIG_SYS_CACHELINE_SIZE;
-}
-
-#else /* !CONFIG_SYS_CACHELINE_SIZE */
-
-static inline unsigned long icache_line_size(void)
-{
-       unsigned long conf1, il;
-       conf1 = read_c0_config1();
-       il = (conf1 & MIPS_CONF1_IL) >> MIPS_CONF1_IL_SHIFT;
-       if (!il)
-               return 0;
-       return 2 << il;
-}
-
-static inline unsigned long dcache_line_size(void)
-{
-       unsigned long conf1, dl;
-       conf1 = read_c0_config1();
-       dl = (conf1 & MIPS_CONF1_DL) >> MIPS_CONF1_DL_SHIFT;
-       if (!dl)
-               return 0;
-       return 2 << dl;
-}
-
-#endif /* !CONFIG_SYS_CACHELINE_SIZE */
-
-void flush_cache(ulong start_addr, ulong size)
-{
-       unsigned long ilsize = icache_line_size();
-       unsigned long dlsize = dcache_line_size();
-       unsigned long addr, aend;
-
-       /* aend will be miscalculated when size is zero, so we return here */
-       if (size == 0)
-               return;
-
-       addr = start_addr & ~(dlsize - 1);
-       aend = (start_addr + size - 1) & ~(dlsize - 1);
-
-       if (ilsize == dlsize) {
-               /* flush I-cache & D-cache simultaneously */
-               while (1) {
-                       cache_op(HIT_WRITEBACK_INV_D, addr);
-                       cache_op(HIT_INVALIDATE_I, addr);
-                       if (addr == aend)
-                               break;
-                       addr += dlsize;
-               }
-               return;
-       }
-
-       /* flush D-cache */
-       while (1) {
-               cache_op(HIT_WRITEBACK_INV_D, addr);
-               if (addr == aend)
-                       break;
-               addr += dlsize;
-       }
-
-       /* flush I-cache */
-       addr = start_addr & ~(ilsize - 1);
-       aend = (start_addr + size - 1) & ~(ilsize - 1);
-       while (1) {
-               cache_op(HIT_INVALIDATE_I, addr);
-               if (addr == aend)
-                       break;
-               addr += ilsize;
-       }
-}
-
-void flush_dcache_range(ulong start_addr, ulong stop)
-{
-       unsigned long lsize = dcache_line_size();
-       unsigned long addr = start_addr & ~(lsize - 1);
-       unsigned long aend = (stop - 1) & ~(lsize - 1);
-
-       while (1) {
-               cache_op(HIT_WRITEBACK_INV_D, addr);
-               if (addr == aend)
-                       break;
-               addr += lsize;
-       }
-}
-
-void invalidate_dcache_range(ulong start_addr, ulong stop)
-{
-       unsigned long lsize = dcache_line_size();
-       unsigned long addr = start_addr & ~(lsize - 1);
-       unsigned long aend = (stop - 1) & ~(lsize - 1);
-
-       while (1) {
-               cache_op(HIT_INVALIDATE_D, addr);
-               if (addr == aend)
-                       break;
-               addr += lsize;
-       }
-}
-
-void write_one_tlb(int index, u32 pagemask, u32 hi, u32 low0, u32 low1)
-{
-       write_c0_entrylo0(low0);
-       write_c0_pagemask(pagemask);
-       write_c0_entrylo1(low1);
-       write_c0_entryhi(hi);
-       write_c0_index(index);
-       tlb_write_indexed();
-}
-
-int cpu_eth_init(bd_t *bis)
-{
-#ifdef CONFIG_SOC_AU1X00
-       au1x00_enet_initialize(bis);
-#endif
-       return 0;
-}
diff --git a/arch/mips/cpu/mips32/interrupts.c b/arch/mips/cpu/mips32/interrupts.c
deleted file mode 100644 (file)
index 275fcf5..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * (C) Copyright 2003
- * Wolfgang Denk, DENX Software Engineering, <wd@denx.de>
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#include <common.h>
-
-int interrupt_init(void)
-{
-       return 0;
-}
-
-void enable_interrupts(void)
-{
-}
-
-int disable_interrupts(void)
-{
-       return 0;
-}
diff --git a/arch/mips/cpu/mips32/start.S b/arch/mips/cpu/mips32/start.S
deleted file mode 100644 (file)
index 384ea26..0000000
+++ /dev/null
@@ -1,270 +0,0 @@
-/*
- *  Startup Code for MIPS32 CPU-core
- *
- *  Copyright (c) 2003 Wolfgang Denk <wd@denx.de>
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#include <asm-offsets.h>
-#include <config.h>
-#include <asm/regdef.h>
-#include <asm/mipsregs.h>
-
-#ifndef CONFIG_SYS_MIPS_CACHE_MODE
-#define CONFIG_SYS_MIPS_CACHE_MODE CONF_CM_CACHABLE_NONCOHERENT
-#endif
-
-       /*
-        * For the moment disable interrupts, mark the kernel mode and
-        * set ST0_KX so that the CPU does not spit fire when using
-        * 64-bit addresses.
-        */
-       .macro  setup_c0_status set clr
-       .set    push
-       mfc0    t0, CP0_STATUS
-       or      t0, ST0_CU0 | \set | 0x1f | \clr
-       xor     t0, 0x1f | \clr
-       mtc0    t0, CP0_STATUS
-       .set    noreorder
-       sll     zero, 3                         # ehb
-       .set    pop
-       .endm
-
-       .set noreorder
-
-       .globl _start
-       .text
-_start:
-       /* U-boot entry point */
-       b       reset
-        nop
-
-       .org 0x10
-#if defined(CONFIG_SYS_XWAY_EBU_BOOTCFG)
-       /*
-        * Almost all Lantiq XWAY SoC devices have an external bus unit (EBU) to
-        * access external NOR flashes. If the board boots from NOR flash the
-        * internal BootROM does a blind read at address 0xB0000010 to read the
-        * initial configuration for that EBU in order to access the flash
-        * device with correct parameters. This config option is board-specific.
-        */
-       .word CONFIG_SYS_XWAY_EBU_BOOTCFG
-       .word 0x0
-#elif defined(CONFIG_MALTA)
-       /*
-        * Linux expects the Board ID here.
-        */
-       .word 0x00000420        # 0x420 (Malta Board with CoreLV)
-       .word 0x00000000
-#endif
-
-       .org 0x200
-       /* TLB refill, 32 bit task */
-1:     b       1b
-        nop
-
-       .org 0x280
-       /* XTLB refill, 64 bit task */
-1:     b       1b
-        nop
-
-       .org 0x300
-       /* Cache error exception */
-1:     b       1b
-        nop
-
-       .org 0x380
-       /* General exception */
-1:     b       1b
-        nop
-
-       .org 0x400
-       /* Catch interrupt exceptions */
-1:     b       1b
-        nop
-
-       .org 0x480
-       /* EJTAG debug exception */
-1:     b       1b
-        nop
-
-       .align 4
-reset:
-
-       /* Clear watch registers */
-       mtc0    zero, CP0_WATCHLO
-       mtc0    zero, CP0_WATCHHI
-
-       /* WP(Watch Pending), SW0/1 should be cleared */
-       mtc0    zero, CP0_CAUSE
-
-       setup_c0_status 0 0
-
-       /* Init Timer */
-       mtc0    zero, CP0_COUNT
-       mtc0    zero, CP0_COMPARE
-
-#ifndef CONFIG_SKIP_LOWLEVEL_INIT
-       /* CONFIG0 register */
-       li      t0, CONF_CM_UNCACHED
-       mtc0    t0, CP0_CONFIG
-#endif
-
-       /* Initialize $gp */
-       bal     1f
-        nop
-       .word   _gp
-1:
-       lw      gp, 0(ra)
-
-#ifndef CONFIG_SKIP_LOWLEVEL_INIT
-       /* Initialize any external memory */
-       la      t9, lowlevel_init
-       jalr    t9
-        nop
-
-       /* Initialize caches... */
-       la      t9, mips_cache_reset
-       jalr    t9
-        nop
-
-       /* ... and enable them */
-       li      t0, CONFIG_SYS_MIPS_CACHE_MODE
-       mtc0    t0, CP0_CONFIG
-#endif
-
-       /* Set up temporary stack */
-       li      sp, CONFIG_SYS_SDRAM_BASE + CONFIG_SYS_INIT_SP_OFFSET
-       move    fp, sp
-
-       la      t9, board_init_f
-       jr      t9
-        move   ra, zero
-
-/*
- * void relocate_code (addr_sp, gd, addr_moni)
- *
- * This "function" does not return, instead it continues in RAM
- * after relocating the monitor code.
- *
- * a0 = addr_sp
- * a1 = gd
- * a2 = destination address
- */
-       .globl  relocate_code
-       .ent    relocate_code
-relocate_code:
-       move    sp, a0                  # set new stack pointer
-       move    fp, sp
-
-       move    s0, a1                  # save gd in s0
-       move    s2, a2                  # save destination address in s2
-
-       li      t0, CONFIG_SYS_MONITOR_BASE
-       sub     s1, s2, t0              # s1 <-- relocation offset
-
-       la      t3, in_ram
-       lw      t2, -12(t3)             # t2 <-- __image_copy_end
-       move    t1, a2
-
-       add     gp, s1                  # adjust gp
-
-       /*
-        * t0 = source address
-        * t1 = target address
-        * t2 = source end address
-        */
-1:
-       lw      t3, 0(t0)
-       sw      t3, 0(t1)
-       addu    t0, 4
-       blt     t0, t2, 1b
-        addu   t1, 4
-
-       /* If caches were enabled, we would have to flush them here. */
-       sub     a1, t1, s2              # a1 <-- size
-       la      t9, flush_cache
-       jalr    t9
-        move   a0, s2                  # a0 <-- destination address
-
-       /* Jump to where we've relocated ourselves */
-       addi    t0, s2, in_ram - _start
-       jr      t0
-        nop
-
-       .word   __rel_dyn_end
-       .word   __rel_dyn_start
-       .word   __image_copy_end
-       .word   _GLOBAL_OFFSET_TABLE_
-       .word   num_got_entries
-
-in_ram:
-       /*
-        * Now we want to update GOT.
-        *
-        * GOT[0] is reserved. GOT[1] is also reserved for the dynamic object
-        * generated by GNU ld. Skip these reserved entries from relocation.
-        */
-       lw      t3, -4(t0)              # t3 <-- num_got_entries
-       lw      t8, -8(t0)              # t8 <-- _GLOBAL_OFFSET_TABLE_
-       add     t8, s1                  # t8 now holds relocated _G_O_T_
-       addi    t8, t8, 8               # skipping first two entries
-       li      t2, 2
-1:
-       lw      t1, 0(t8)
-       beqz    t1, 2f
-        add    t1, s1
-       sw      t1, 0(t8)
-2:
-       addi    t2, 1
-       blt     t2, t3, 1b
-        addi   t8, 4
-
-       /* Update dynamic relocations */
-       lw      t1, -16(t0)             # t1 <-- __rel_dyn_start
-       lw      t2, -20(t0)             # t2 <-- __rel_dyn_end
-
-       b       2f                      # skip first reserved entry
-        addi   t1, 8
-
-1:
-       lw      t8, -4(t1)              # t8 <-- relocation info
-
-       li      t3, 3
-       bne     t8, t3, 2f              # skip non R_MIPS_REL32 entries
-        nop
-
-       lw      t3, -8(t1)              # t3 <-- location to fix up in FLASH
-
-       lw      t8, 0(t3)               # t8 <-- original pointer
-       add     t8, s1                  # t8 <-- adjusted pointer
-
-       add     t3, s1                  # t3 <-- location to fix up in RAM
-       sw      t8, 0(t3)
-
-2:
-       blt     t1, t2, 1b
-        addi   t1, 8                   # each rel.dyn entry is 8 bytes
-
-       /*
-        * Clear BSS
-        *
-        * GOT is now relocated. Thus __bss_start and __bss_end can be
-        * accessed directly via $gp.
-        */
-       la      t1, __bss_start         # t1 <-- __bss_start
-       la      t2, __bss_end           # t2 <-- __bss_end
-
-1:
-       sw      zero, 0(t1)
-       blt     t1, t2, 1b
-        addi   t1, 4
-
-       move    a0, s0                  # a0 <-- gd
-       move    a1, s2
-       la      t9, board_init_r
-       jr      t9
-        move   ra, zero
-
-       .end    relocate_code
diff --git a/arch/mips/cpu/mips32/time.c b/arch/mips/cpu/mips32/time.c
deleted file mode 100644 (file)
index 386f45a..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * (C) Copyright 2003
- * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#include <common.h>
-#include <asm/mipsregs.h>
-
-static unsigned long timestamp;
-
-/* how many counter cycles in a jiffy */
-#define CYCLES_PER_JIFFY       \
-       (CONFIG_SYS_MIPS_TIMER_FREQ + CONFIG_SYS_HZ / 2) / CONFIG_SYS_HZ
-
-/*
- * timer without interrupts
- */
-
-int timer_init(void)
-{
-       /* Set up the timer for the first expiration. */
-       write_c0_compare(read_c0_count() + CYCLES_PER_JIFFY);
-
-       return 0;
-}
-
-ulong get_timer(ulong base)
-{
-       unsigned int count;
-       unsigned int expirelo = read_c0_compare();
-
-       /* Check to see if we have missed any timestamps. */
-       count = read_c0_count();
-       while ((count - expirelo) < 0x7fffffff) {
-               expirelo += CYCLES_PER_JIFFY;
-               timestamp++;
-       }
-       write_c0_compare(expirelo);
-
-       return timestamp - base;
-}
-
-void __udelay(unsigned long usec)
-{
-       unsigned int tmo;
-
-       tmo = read_c0_count() + (usec * (CONFIG_SYS_MIPS_TIMER_FREQ / 1000000));
-       while ((tmo - read_c0_count()) < 0x7fffffff)
-               /*NOP*/;
-}
-
-/*
- * This function is derived from PowerPC code (read timebase as long long).
- * On MIPS it just returns the timer value.
- */
-unsigned long long get_ticks(void)
-{
-       return get_timer(0);
-}
-
-/*
- * This function is derived from PowerPC code (timebase clock frequency).
- * On MIPS it returns the number of timer ticks per second.
- */
-ulong get_tbclk(void)
-{
-       return CONFIG_SYS_HZ;
-}
diff --git a/arch/mips/cpu/mips64/Makefile b/arch/mips/cpu/mips64/Makefile
deleted file mode 100644 (file)
index 899c319..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-#
-# (C) Copyright 2003-2006
-# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
-#
-# SPDX-License-Identifier:     GPL-2.0+
-#
-
-extra-y        = start.o
-obj-y  = cpu.o interrupts.o time.o cache.o
diff --git a/arch/mips/cpu/mips64/cache.S b/arch/mips/cpu/mips64/cache.S
deleted file mode 100644 (file)
index 36d8688..0000000
+++ /dev/null
@@ -1,213 +0,0 @@
-/*
- *  Cache-handling routined for MIPS CPUs
- *
- *  Copyright (c) 2003 Wolfgang Denk <wd@denx.de>
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#include <asm-offsets.h>
-#include <config.h>
-#include <asm/asm.h>
-#include <asm/regdef.h>
-#include <asm/mipsregs.h>
-#include <asm/addrspace.h>
-#include <asm/cacheops.h>
-
-#define RA             t9
-
-/*
- * 16kB is the maximum size of instruction and data caches on MIPS 4K,
- * 64kB is on 4KE, 24K, 5K, etc. Set bigger size for convenience.
- *
- * Note that the above size is the maximum size of primary cache. U-Boot
- * doesn't have L2 cache support for now.
- */
-#define MIPS_MAX_CACHE_SIZE    0x10000
-
-#define INDEX_BASE     CKSEG0
-
-       .macro  cache_op op addr
-       .set    push
-       .set    noreorder
-       .set    mips3
-       cache   \op, 0(\addr)
-       .set    pop
-       .endm
-
-       .macro  f_fill64 dst, offset, val
-       LONG_S  \val, (\offset +  0 * LONGSIZE)(\dst)
-       LONG_S  \val, (\offset +  1 * LONGSIZE)(\dst)
-       LONG_S  \val, (\offset +  2 * LONGSIZE)(\dst)
-       LONG_S  \val, (\offset +  3 * LONGSIZE)(\dst)
-       LONG_S  \val, (\offset +  4 * LONGSIZE)(\dst)
-       LONG_S  \val, (\offset +  5 * LONGSIZE)(\dst)
-       LONG_S  \val, (\offset +  6 * LONGSIZE)(\dst)
-       LONG_S  \val, (\offset +  7 * LONGSIZE)(\dst)
-#if LONGSIZE == 4
-       LONG_S  \val, (\offset +  8 * LONGSIZE)(\dst)
-       LONG_S  \val, (\offset +  9 * LONGSIZE)(\dst)
-       LONG_S  \val, (\offset + 10 * LONGSIZE)(\dst)
-       LONG_S  \val, (\offset + 11 * LONGSIZE)(\dst)
-       LONG_S  \val, (\offset + 12 * LONGSIZE)(\dst)
-       LONG_S  \val, (\offset + 13 * LONGSIZE)(\dst)
-       LONG_S  \val, (\offset + 14 * LONGSIZE)(\dst)
-       LONG_S  \val, (\offset + 15 * LONGSIZE)(\dst)
-#endif
-       .endm
-
-/*
- * mips_init_icache(uint PRId, ulong icache_size, unchar icache_linesz)
- */
-LEAF(mips_init_icache)
-       blez            a1, 9f
-       mtc0            zero, CP0_TAGLO
-       /* clear tag to invalidate */
-       PTR_LI          t0, INDEX_BASE
-       PTR_ADDU        t1, t0, a1
-1:     cache_op        INDEX_STORE_TAG_I t0
-       PTR_ADDU        t0, a2
-       bne             t0, t1, 1b
-       /* fill once, so data field parity is correct */
-       PTR_LI          t0, INDEX_BASE
-2:     cache_op        FILL t0
-       PTR_ADDU        t0, a2
-       bne             t0, t1, 2b
-       /* invalidate again - prudent but not strictly neccessary */
-       PTR_LI          t0, INDEX_BASE
-1:     cache_op        INDEX_STORE_TAG_I t0
-       PTR_ADDU        t0, a2
-       bne             t0, t1, 1b
-9:     jr              ra
-       END(mips_init_icache)
-
-/*
- * mips_init_dcache(uint PRId, ulong dcache_size, unchar dcache_linesz)
- */
-LEAF(mips_init_dcache)
-       blez            a1, 9f
-       mtc0            zero, CP0_TAGLO
-       /* clear all tags */
-       PTR_LI          t0, INDEX_BASE
-       PTR_ADDU        t1, t0, a1
-1:     cache_op        INDEX_STORE_TAG_D t0
-       PTR_ADDU        t0, a2
-       bne             t0, t1, 1b
-       /* load from each line (in cached space) */
-       PTR_LI          t0, INDEX_BASE
-2:     LONG_L          zero, 0(t0)
-       PTR_ADDU        t0, a2
-       bne             t0, t1, 2b
-       /* clear all tags */
-       PTR_LI          t0, INDEX_BASE
-1:     cache_op        INDEX_STORE_TAG_D t0
-       PTR_ADDU        t0, a2
-       bne             t0, t1, 1b
-9:     jr              ra
-       END(mips_init_dcache)
-
-/*
- * mips_cache_reset - low level initialisation of the primary caches
- *
- * This routine initialises the primary caches to ensure that they have good
- * parity.  It must be called by the ROM before any cached locations are used
- * to prevent the possibility of data with bad parity being written to memory.
- *
- * To initialise the instruction cache it is essential that a source of data
- * with good parity is available. This routine will initialise an area of
- * memory starting at location zero to be used as a source of parity.
- *
- * RETURNS: N/A
- *
- */
-NESTED(mips_cache_reset, 0, ra)
-       move    RA, ra
-       li      t2, CONFIG_SYS_ICACHE_SIZE
-       li      t3, CONFIG_SYS_DCACHE_SIZE
-       li      t8, CONFIG_SYS_CACHELINE_SIZE
-
-       li      v0, MIPS_MAX_CACHE_SIZE
-
-       /*
-        * Now clear that much memory starting from zero.
-        */
-       PTR_LI          a0, CKSEG1
-       PTR_ADDU        a1, a0, v0
-2:     PTR_ADDIU       a0, 64
-       f_fill64        a0, -64, zero
-       bne             a0, a1, 2b
-
-       /*
-        * The caches are probably in an indeterminate state,
-        * so we force good parity into them by doing an
-        * invalidate, load/fill, invalidate for each line.
-        */
-
-       /*
-        * Assume bottom of RAM will generate good parity for the cache.
-        */
-
-       /*
-        * Initialize the I-cache first,
-        */
-       move    a1, t2
-       move    a2, t8
-       PTR_LA  v1, mips_init_icache
-       jalr    v1
-
-       /*
-        * then initialize D-cache.
-        */
-       move    a1, t3
-       move    a2, t8
-       PTR_LA  v1, mips_init_dcache
-       jalr    v1
-
-       jr      RA
-       END(mips_cache_reset)
-
-/*
- * dcache_status - get cache status
- *
- * RETURNS: 0 - cache disabled; 1 - cache enabled
- *
- */
-LEAF(dcache_status)
-       mfc0    t0, CP0_CONFIG
-       li      t1, CONF_CM_UNCACHED
-       andi    t0, t0, CONF_CM_CMASK
-       move    v0, zero
-       beq     t0, t1, 2f
-       li      v0, 1
-2:     jr      ra
-       END(dcache_status)
-
-/*
- * dcache_disable - disable cache
- *
- * RETURNS: N/A
- *
- */
-LEAF(dcache_disable)
-       mfc0    t0, CP0_CONFIG
-       li      t1, -8
-       and     t0, t0, t1
-       ori     t0, t0, CONF_CM_UNCACHED
-       mtc0    t0, CP0_CONFIG
-       jr      ra
-       END(dcache_disable)
-
-/*
- * dcache_enable - enable cache
- *
- * RETURNS: N/A
- *
- */
-LEAF(dcache_enable)
-       mfc0    t0, CP0_CONFIG
-       ori     t0, CONF_CM_CMASK
-       xori    t0, CONF_CM_CMASK
-       ori     t0, CONF_CM_CACHABLE_NONCOHERENT
-       mtc0    t0, CP0_CONFIG
-       jr      ra
-       END(dcache_enable)
diff --git a/arch/mips/cpu/mips64/cpu.c b/arch/mips/cpu/mips64/cpu.c
deleted file mode 100644 (file)
index 9f45cfc..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * (C) Copyright 2003
- * Wolfgang Denk, DENX Software Engineering, <wd@denx.de>
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#include <common.h>
-#include <command.h>
-#include <netdev.h>
-#include <asm/mipsregs.h>
-#include <asm/cacheops.h>
-#include <asm/reboot.h>
-
-#define cache_op(op, addr)                                             \
-       __asm__ __volatile__(                                           \
-       "       .set    push\n"                                         \
-       "       .set    noreorder\n"                                    \
-       "       .set    mips64\n"                                       \
-       "       cache   %0, %1\n"                                       \
-       "       .set    pop\n"                                          \
-       :                                                               \
-       : "i" (op), "R" (*(unsigned char *)(addr)))
-
-void __attribute__((weak)) _machine_restart(void)
-{
-       fprintf(stderr, "*** reset failed ***\n");
-
-       while (1)
-               /* NOP */;
-}
-
-int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
-{
-       _machine_restart();
-
-       return 0;
-}
-
-void flush_cache(ulong start_addr, ulong size)
-{
-       unsigned long lsize = CONFIG_SYS_CACHELINE_SIZE;
-       unsigned long addr = start_addr & ~(lsize - 1);
-       unsigned long aend = (start_addr + size - 1) & ~(lsize - 1);
-
-       /* aend will be miscalculated when size is zero, so we return here */
-       if (size == 0)
-               return;
-
-       while (1) {
-               cache_op(HIT_WRITEBACK_INV_D, addr);
-               cache_op(HIT_INVALIDATE_I, addr);
-               if (addr == aend)
-                       break;
-               addr += lsize;
-       }
-}
-
-void flush_dcache_range(ulong start_addr, ulong stop)
-{
-       unsigned long lsize = CONFIG_SYS_CACHELINE_SIZE;
-       unsigned long addr = start_addr & ~(lsize - 1);
-       unsigned long aend = (stop - 1) & ~(lsize - 1);
-
-       while (1) {
-               cache_op(HIT_WRITEBACK_INV_D, addr);
-               if (addr == aend)
-                       break;
-               addr += lsize;
-       }
-}
-
-void invalidate_dcache_range(ulong start_addr, ulong stop)
-{
-       unsigned long lsize = CONFIG_SYS_CACHELINE_SIZE;
-       unsigned long addr = start_addr & ~(lsize - 1);
-       unsigned long aend = (stop - 1) & ~(lsize - 1);
-
-       while (1) {
-               cache_op(HIT_INVALIDATE_D, addr);
-               if (addr == aend)
-                       break;
-               addr += lsize;
-       }
-}
-
-void write_one_tlb(int index, u32 pagemask, u32 hi, u32 low0, u32 low1)
-{
-       write_c0_entrylo0(low0);
-       write_c0_pagemask(pagemask);
-       write_c0_entrylo1(low1);
-       write_c0_entryhi(hi);
-       write_c0_index(index);
-       tlb_write_indexed();
-}
diff --git a/arch/mips/cpu/mips64/interrupts.c b/arch/mips/cpu/mips64/interrupts.c
deleted file mode 100644 (file)
index 275fcf5..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * (C) Copyright 2003
- * Wolfgang Denk, DENX Software Engineering, <wd@denx.de>
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#include <common.h>
-
-int interrupt_init(void)
-{
-       return 0;
-}
-
-void enable_interrupts(void)
-{
-}
-
-int disable_interrupts(void)
-{
-       return 0;
-}
diff --git a/arch/mips/cpu/mips64/start.S b/arch/mips/cpu/mips64/start.S
deleted file mode 100644 (file)
index 6ff714e..0000000
+++ /dev/null
@@ -1,264 +0,0 @@
-/*
- *  Startup Code for MIPS64 CPU-core
- *
- *  Copyright (c) 2003 Wolfgang Denk <wd@denx.de>
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#include <asm-offsets.h>
-#include <config.h>
-#include <asm/regdef.h>
-#include <asm/mipsregs.h>
-
-#ifndef CONFIG_SYS_MIPS_CACHE_MODE
-#define CONFIG_SYS_MIPS_CACHE_MODE CONF_CM_CACHABLE_NONCOHERENT
-#endif
-
-#ifdef CONFIG_SYS_LITTLE_ENDIAN
-#define MIPS64_R_INFO(ssym, r_type3, r_type2, r_type) \
-       (((r_type) << 24) | ((r_type2) << 16) | ((r_type3) << 8) | (ssym))
-#else
-#define MIPS64_R_INFO(ssym, r_type3, r_type2, r_type) \
-       ((r_type) | ((r_type2) << 8) | ((r_type3) << 16) | (ssym) << 24)
-#endif
-
-       /*
-        * For the moment disable interrupts, mark the kernel mode and
-        * set ST0_KX so that the CPU does not spit fire when using
-        * 64-bit addresses.
-        */
-       .macro  setup_c0_status set clr
-       .set    push
-       mfc0    t0, CP0_STATUS
-       or      t0, ST0_CU0 | \set | 0x1f | \clr
-       xor     t0, 0x1f | \clr
-       mtc0    t0, CP0_STATUS
-       .set    noreorder
-       sll     zero, 3                         # ehb
-       .set    pop
-       .endm
-
-       .set noreorder
-
-       .globl _start
-       .text
-_start:
-       /* U-boot entry point */
-       b       reset
-        nop
-
-       .org 0x200
-       /* TLB refill, 32 bit task */
-1:     b       1b
-        nop
-
-       .org 0x280
-       /* XTLB refill, 64 bit task */
-1:     b       1b
-        nop
-
-       .org 0x300
-       /* Cache error exception */
-1:     b       1b
-        nop
-
-       .org 0x380
-       /* General exception */
-1:     b       1b
-        nop
-
-       .org 0x400
-       /* Catch interrupt exceptions */
-1:     b       1b
-        nop
-
-       .org 0x480
-       /* EJTAG debug exception */
-1:     b       1b
-        nop
-
-       .align 4
-reset:
-
-       /* Clear watch registers */
-       dmtc0   zero, CP0_WATCHLO
-       dmtc0   zero, CP0_WATCHHI
-
-       /* WP(Watch Pending), SW0/1 should be cleared */
-       mtc0    zero, CP0_CAUSE
-
-       setup_c0_status ST0_KX 0
-
-       /* Init Timer */
-       mtc0    zero, CP0_COUNT
-       mtc0    zero, CP0_COMPARE
-
-#ifndef CONFIG_SKIP_LOWLEVEL_INIT
-       /* CONFIG0 register */
-       dli     t0, CONF_CM_UNCACHED
-       mtc0    t0, CP0_CONFIG
-#endif
-
-       /*
-        * Initialize $gp, force 8 byte alignment of bal instruction to forbid
-        * the compiler to put nop's between bal and _gp. This is required to
-        * keep _gp and ra aligned to 8 byte.
-        */
-       .align  3
-       bal     1f
-        nop
-       .dword  _gp
-1:
-       ld      gp, 0(ra)
-
-#ifndef CONFIG_SKIP_LOWLEVEL_INIT
-       /* Initialize any external memory */
-       dla     t9, lowlevel_init
-       jalr    t9
-        nop
-
-       /* Initialize caches... */
-       dla     t9, mips_cache_reset
-       jalr    t9
-        nop
-
-       /* ... and enable them */
-       dli     t0, CONFIG_SYS_MIPS_CACHE_MODE
-       mtc0    t0, CP0_CONFIG
-#endif
-
-       /* Set up temporary stack */
-       dli     sp, CONFIG_SYS_SDRAM_BASE + CONFIG_SYS_INIT_SP_OFFSET
-       move    fp, sp
-
-       dla     t9, board_init_f
-       jr      t9
-        move   ra, zero
-
-/*
- * void relocate_code (addr_sp, gd, addr_moni)
- *
- * This "function" does not return, instead it continues in RAM
- * after relocating the monitor code.
- *
- * a0 = addr_sp
- * a1 = gd
- * a2 = destination address
- */
-       .globl  relocate_code
-       .ent    relocate_code
-relocate_code:
-       move    sp, a0                  # set new stack pointer
-       move    fp, sp
-
-       move    s0, a1                  # save gd in s0
-       move    s2, a2                  # save destination address in s2
-
-       dli     t0, CONFIG_SYS_MONITOR_BASE
-       dsub    s1, s2, t0              # s1 <-- relocation offset
-
-       dla     t3, in_ram
-       ld      t2, -24(t3)             # t2 <-- __image_copy_end
-       move    t1, a2
-
-       dadd    gp, s1                  # adjust gp
-
-       /*
-        * t0 = source address
-        * t1 = target address
-        * t2 = source end address
-        */
-1:
-       lw      t3, 0(t0)
-       sw      t3, 0(t1)
-       daddu   t0, 4
-       blt     t0, t2, 1b
-        daddu  t1, 4
-
-       /* If caches were enabled, we would have to flush them here. */
-       dsub    a1, t1, s2              # a1 <-- size
-       dla     t9, flush_cache
-       jalr    t9
-        move   a0, s2                  # a0 <-- destination address
-
-       /* Jump to where we've relocated ourselves */
-       daddi   t0, s2, in_ram - _start
-       jr      t0
-        nop
-
-       .dword  __rel_dyn_end
-       .dword  __rel_dyn_start
-       .dword  __image_copy_end
-       .dword  _GLOBAL_OFFSET_TABLE_
-       .dword  num_got_entries
-
-in_ram:
-       /*
-        * Now we want to update GOT.
-        *
-        * GOT[0] is reserved. GOT[1] is also reserved for the dynamic object
-        * generated by GNU ld. Skip these reserved entries from relocation.
-        */
-       ld      t3, -8(t0)              # t3 <-- num_got_entries
-       ld      t8, -16(t0)             # t8 <-- _GLOBAL_OFFSET_TABLE_
-       dadd    t8, s1                  # t8 now holds relocated _G_O_T_
-       daddi   t8, t8, 16              # skipping first two entries
-       dli     t2, 2
-1:
-       ld      t1, 0(t8)
-       beqz    t1, 2f
-        dadd   t1, s1
-       sd      t1, 0(t8)
-2:
-       daddi   t2, 1
-       blt     t2, t3, 1b
-        daddi  t8, 8
-
-       /* Update dynamic relocations */
-       ld      t1, -32(t0)             # t1 <-- __rel_dyn_start
-       ld      t2, -40(t0)             # t2 <-- __rel_dyn_end
-
-       b       2f                      # skip first reserved entry
-        daddi  t1, 16
-
-1:
-       lw      t8, -4(t1)              # t8 <-- relocation info
-
-       dli     t3, MIPS64_R_INFO(0x00, 0x00, 0x12, 0x03)
-       bne     t8, t3, 2f              # skip non R_MIPS_REL32 entries
-        nop
-
-       ld      t3, -16(t1)             # t3 <-- location to fix up in FLASH
-
-       ld      t8, 0(t3)               # t8 <-- original pointer
-       dadd    t8, s1                  # t8 <-- adjusted pointer
-
-       dadd    t3, s1                  # t3 <-- location to fix up in RAM
-       sd      t8, 0(t3)
-
-2:
-       blt     t1, t2, 1b
-        daddi  t1, 16                  # each rel.dyn entry is 16 bytes
-
-       /*
-        * Clear BSS
-        *
-        * GOT is now relocated. Thus __bss_start and __bss_end can be
-        * accessed directly via $gp.
-        */
-       dla     t1, __bss_start         # t1 <-- __bss_start
-       dla     t2, __bss_end           # t2 <-- __bss_end
-
-1:
-       sd      zero, 0(t1)
-       blt     t1, t2, 1b
-        daddi  t1, 8
-
-       move    a0, s0                  # a0 <-- gd
-       move    a1, s2
-       dla     t9, board_init_r
-       jr      t9
-        move   ra, zero
-
-       .end    relocate_code
diff --git a/arch/mips/cpu/mips64/time.c b/arch/mips/cpu/mips64/time.c
deleted file mode 100644 (file)
index 0497acf..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * (C) Copyright 2003
- * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#include <common.h>
-#include <asm/mipsregs.h>
-
-static unsigned long timestamp;
-
-/* how many counter cycles in a jiffy */
-#define CYCLES_PER_JIFFY        \
-       (CONFIG_SYS_MIPS_TIMER_FREQ + CONFIG_SYS_HZ / 2) / CONFIG_SYS_HZ
-
-/*
- * timer without interrupts
- */
-
-int timer_init(void)
-{
-       /* Set up the timer for the first expiration. */
-       write_c0_compare(read_c0_count() + CYCLES_PER_JIFFY);
-
-       return 0;
-}
-
-ulong get_timer(ulong base)
-{
-       unsigned int count;
-       unsigned int expirelo = read_c0_compare();
-
-       /* Check to see if we have missed any timestamps. */
-       count = read_c0_count();
-       while ((count - expirelo) < 0x7fffffff) {
-               expirelo += CYCLES_PER_JIFFY;
-               timestamp++;
-       }
-       write_c0_compare(expirelo);
-
-       return timestamp - base;
-}
-
-void __udelay(unsigned long usec)
-{
-       unsigned int tmo;
-
-       tmo = read_c0_count() + (usec * (CONFIG_SYS_MIPS_TIMER_FREQ / 1000000));
-       while ((tmo - read_c0_count()) < 0x7fffffff)
-               /*NOP*/;
-}
-
-/*
- * This function is derived from PowerPC code (read timebase as long long).
- * On MIPS it just returns the timer value.
- */
-unsigned long long get_ticks(void)
-{
-       return get_timer(0);
-}
-
-/*
- * This function is derived from PowerPC code (timebase clock frequency).
- * On MIPS it returns the number of timer ticks per second.
- */
-ulong get_tbclk(void)
-{
-       return CONFIG_SYS_HZ;
-}
diff --git a/arch/mips/cpu/start.S b/arch/mips/cpu/start.S
new file mode 100644 (file)
index 0000000..3b5b622
--- /dev/null
@@ -0,0 +1,320 @@
+/*
+ *  Startup Code for MIPS32 CPU-core
+ *
+ *  Copyright (c) 2003 Wolfgang Denk <wd@denx.de>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <asm-offsets.h>
+#include <config.h>
+#include <asm/asm.h>
+#include <asm/regdef.h>
+#include <asm/mipsregs.h>
+
+#ifndef CONFIG_SYS_MIPS_CACHE_MODE
+#define CONFIG_SYS_MIPS_CACHE_MODE CONF_CM_CACHABLE_NONCOHERENT
+#endif
+
+#ifndef CONFIG_SYS_INIT_SP_ADDR
+#define CONFIG_SYS_INIT_SP_ADDR        (CONFIG_SYS_SDRAM_BASE + \
+                               CONFIG_SYS_INIT_SP_OFFSET)
+#endif
+
+#ifdef CONFIG_32BIT
+# define MIPS_RELOC    3
+# define STATUS_SET    0
+#endif
+
+#ifdef CONFIG_64BIT
+# ifdef CONFIG_SYS_LITTLE_ENDIAN
+#  define MIPS64_R_INFO(ssym, r_type3, r_type2, r_type) \
+       (((r_type) << 24) | ((r_type2) << 16) | ((r_type3) << 8) | (ssym))
+# else
+#  define MIPS64_R_INFO(ssym, r_type3, r_type2, r_type) \
+       ((r_type) | ((r_type2) << 8) | ((r_type3) << 16) | (ssym) << 24)
+# endif
+# define MIPS_RELOC    MIPS64_R_INFO(0x00, 0x00, 0x12, 0x03)
+# define STATUS_SET    ST0_KX
+#endif
+
+       /*
+        * For the moment disable interrupts, mark the kernel mode and
+        * set ST0_KX so that the CPU does not spit fire when using
+        * 64-bit addresses.
+        */
+       .macro  setup_c0_status set clr
+       .set    push
+       mfc0    t0, CP0_STATUS
+       or      t0, ST0_CU0 | \set | 0x1f | \clr
+       xor     t0, 0x1f | \clr
+       mtc0    t0, CP0_STATUS
+       .set    noreorder
+       sll     zero, 3                         # ehb
+       .set    pop
+       .endm
+
+       .set noreorder
+
+       .globl _start
+       .text
+_start:
+       /* U-boot entry point */
+       b       reset
+        nop
+
+       .org 0x10
+#if defined(CONFIG_SYS_XWAY_EBU_BOOTCFG)
+       /*
+        * Almost all Lantiq XWAY SoC devices have an external bus unit (EBU) to
+        * access external NOR flashes. If the board boots from NOR flash the
+        * internal BootROM does a blind read at address 0xB0000010 to read the
+        * initial configuration for that EBU in order to access the flash
+        * device with correct parameters. This config option is board-specific.
+        */
+       .word CONFIG_SYS_XWAY_EBU_BOOTCFG
+       .word 0x0
+#elif defined(CONFIG_MALTA)
+       /*
+        * Linux expects the Board ID here.
+        */
+       .word 0x00000420        # 0x420 (Malta Board with CoreLV)
+       .word 0x00000000
+#endif
+
+       .org 0x200
+       /* TLB refill, 32 bit task */
+1:     b       1b
+        nop
+
+       .org 0x280
+       /* XTLB refill, 64 bit task */
+1:     b       1b
+        nop
+
+       .org 0x300
+       /* Cache error exception */
+1:     b       1b
+        nop
+
+       .org 0x380
+       /* General exception */
+1:     b       1b
+        nop
+
+       .org 0x400
+       /* Catch interrupt exceptions */
+1:     b       1b
+        nop
+
+       .org 0x480
+       /* EJTAG debug exception */
+1:     b       1b
+        nop
+
+       .align 4
+reset:
+
+       /* Clear watch registers */
+       MTC0    zero, CP0_WATCHLO
+       MTC0    zero, CP0_WATCHHI
+
+       /* WP(Watch Pending), SW0/1 should be cleared */
+       mtc0    zero, CP0_CAUSE
+
+       setup_c0_status STATUS_SET 0
+
+       /* Init Timer */
+       mtc0    zero, CP0_COUNT
+       mtc0    zero, CP0_COMPARE
+
+#ifndef CONFIG_SKIP_LOWLEVEL_INIT
+       /* CONFIG0 register */
+       li      t0, CONF_CM_UNCACHED
+       mtc0    t0, CP0_CONFIG
+#endif
+
+       /*
+        * Initialize $gp, force pointer sized alignment of bal instruction to
+        * forbid the compiler to put nop's between bal and _gp. This is
+        * required to keep _gp and ra aligned to 8 byte.
+        */
+       .align  PTRLOG
+       bal     1f
+        nop
+       PTR     _gp
+1:
+       PTR_L   gp, 0(ra)
+
+#ifndef CONFIG_SKIP_LOWLEVEL_INIT
+       /* Initialize any external memory */
+       PTR_LA  t9, lowlevel_init
+       jalr    t9
+        nop
+
+       /* Initialize caches... */
+       PTR_LA  t9, mips_cache_reset
+       jalr    t9
+        nop
+
+       /* ... and enable them */
+       li      t0, CONFIG_SYS_MIPS_CACHE_MODE
+       mtc0    t0, CP0_CONFIG
+#endif
+
+       /* Set up temporary stack */
+       PTR_LI  t0, -16
+       PTR_LI  t1, CONFIG_SYS_INIT_SP_ADDR
+       and     sp, t1, t0              # force 16 byte alignment
+       PTR_SUB sp, sp, GD_SIZE         # reserve space for gd
+       and     sp, sp, t0              # force 16 byte alignment
+       move    k0, sp                  # save gd pointer
+#ifdef CONFIG_SYS_MALLOC_F_LEN
+       PTR_LI  t2, CONFIG_SYS_MALLOC_F_LEN
+       PTR_SUB sp, sp, t2              # reserve space for early malloc
+       and     sp, sp, t0              # force 16 byte alignment
+#endif
+       move    fp, sp
+
+       /* Clear gd */
+       move    t0, k0
+1:
+       sw      zero, 0(t0)
+       blt     t0, t1, 1b
+        PTR_ADDI t0, 4
+
+#ifdef CONFIG_SYS_MALLOC_F_LEN
+       PTR_ADDU t0, k0, GD_MALLOC_BASE # gd->malloc_base offset
+       sw      sp, 0(t0)
+#endif
+
+       PTR_LA  t9, board_init_f
+       jr      t9
+        move   ra, zero
+
+/*
+ * void relocate_code (addr_sp, gd, addr_moni)
+ *
+ * This "function" does not return, instead it continues in RAM
+ * after relocating the monitor code.
+ *
+ * a0 = addr_sp
+ * a1 = gd
+ * a2 = destination address
+ */
+       .globl  relocate_code
+       .ent    relocate_code
+relocate_code:
+       move    sp, a0                  # set new stack pointer
+       move    fp, sp
+
+       move    s0, a1                  # save gd in s0
+       move    s2, a2                  # save destination address in s2
+
+       PTR_LI  t0, CONFIG_SYS_MONITOR_BASE
+       PTR_SUB s1, s2, t0              # s1 <-- relocation offset
+
+       PTR_LA  t3, in_ram
+       PTR_L   t2, -(3 * PTRSIZE)(t3)  # t2 <-- __image_copy_end
+       move    t1, a2
+
+       PTR_ADD gp, s1                  # adjust gp
+
+       /*
+        * t0 = source address
+        * t1 = target address
+        * t2 = source end address
+        */
+1:
+       lw      t3, 0(t0)
+       sw      t3, 0(t1)
+       PTR_ADDU t0, 4
+       blt     t0, t2, 1b
+        PTR_ADDU t1, 4
+
+       /* If caches were enabled, we would have to flush them here. */
+       PTR_SUB a1, t1, s2              # a1 <-- size
+       PTR_LA  t9, flush_cache
+       jalr    t9
+        move   a0, s2                  # a0 <-- destination address
+
+       /* Jump to where we've relocated ourselves */
+       PTR_ADDI t0, s2, in_ram - _start
+       jr      t0
+        nop
+
+       PTR     __rel_dyn_end
+       PTR     __rel_dyn_start
+       PTR     __image_copy_end
+       PTR     _GLOBAL_OFFSET_TABLE_
+       PTR     num_got_entries
+
+in_ram:
+       /*
+        * Now we want to update GOT.
+        *
+        * GOT[0] is reserved. GOT[1] is also reserved for the dynamic object
+        * generated by GNU ld. Skip these reserved entries from relocation.
+        */
+       PTR_L   t3, -(1 * PTRSIZE)(t0)  # t3 <-- num_got_entries
+       PTR_L   t8, -(2 * PTRSIZE)(t0)  # t8 <-- _GLOBAL_OFFSET_TABLE_
+       PTR_ADD t8, s1                  # t8 now holds relocated _G_O_T_
+       PTR_ADDI t8, t8, 2 * PTRSIZE    # skipping first two entries
+       PTR_LI  t2, 2
+1:
+       PTR_L   t1, 0(t8)
+       beqz    t1, 2f
+        PTR_ADD t1, s1
+       PTR_S   t1, 0(t8)
+2:
+       PTR_ADDI t2, 1
+       blt     t2, t3, 1b
+        PTR_ADDI t8, PTRSIZE
+
+       /* Update dynamic relocations */
+       PTR_L   t1, -(4 * PTRSIZE)(t0)  # t1 <-- __rel_dyn_start
+       PTR_L   t2, -(5 * PTRSIZE)(t0)  # t2 <-- __rel_dyn_end
+
+       b       2f                      # skip first reserved entry
+        PTR_ADDI t1, 2 * PTRSIZE
+
+1:
+       lw      t8, -4(t1)              # t8 <-- relocation info
+
+       PTR_LI  t3, MIPS_RELOC
+       bne     t8, t3, 2f              # skip non-MIPS_RELOC entries
+        nop
+
+       PTR_L   t3, -(2 * PTRSIZE)(t1)  # t3 <-- location to fix up in FLASH
+
+       PTR_L   t8, 0(t3)               # t8 <-- original pointer
+       PTR_ADD t8, s1                  # t8 <-- adjusted pointer
+
+       PTR_ADD t3, s1                  # t3 <-- location to fix up in RAM
+       PTR_S   t8, 0(t3)
+
+2:
+       blt     t1, t2, 1b
+        PTR_ADDI t1, 2 * PTRSIZE       # each rel.dyn entry is 2*PTRSIZE bytes
+
+       /*
+        * Clear BSS
+        *
+        * GOT is now relocated. Thus __bss_start and __bss_end can be
+        * accessed directly via $gp.
+        */
+       PTR_LA  t1, __bss_start         # t1 <-- __bss_start
+       PTR_LA  t2, __bss_end           # t2 <-- __bss_end
+
+1:
+       PTR_S   zero, 0(t1)
+       blt     t1, t2, 1b
+        PTR_ADDI t1, PTRSIZE
+
+       move    a0, s0                  # a0 <-- gd
+       move    a1, s2
+       PTR_LA  t9, board_init_r
+       jr      t9
+        move   ra, zero
+
+       .end    relocate_code
diff --git a/arch/mips/cpu/time.c b/arch/mips/cpu/time.c
new file mode 100644 (file)
index 0000000..553da5f
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+ * (C) Copyright 2003
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <common.h>
+#include <asm/mipsregs.h>
+
+unsigned long notrace timer_read_counter(void)
+{
+       return read_c0_count();
+}
+
+ulong notrace get_tbclk(void)
+{
+       return CONFIG_SYS_MIPS_TIMER_FREQ;
+}
index 6464250d8486ec6261c1c6066dd7bb104dd61ee9..75ec380980f7653b1505d1316eae20329704cbb3 100644 (file)
 #ifndef        __ASM_CACHEOPS_H
 #define        __ASM_CACHEOPS_H
 
+#ifndef __ASSEMBLY__
+
+static inline void mips_cache(int op, const volatile void *addr)
+{
+#ifdef __GCC_HAVE_BUILTIN_MIPS_CACHE
+       __builtin_mips_cache(op, addr);
+#else
+       __asm__ __volatile__("cache %0, %1" : : "i"(op), "R"(addr))
+#endif
+}
+
+#endif /* !__ASSEMBLY__ */
+
 /*
  * Cache Operations available on all MIPS processors with R4000-style caches
  */
index 1c8a42bd2f6ea8233e019100ea4560be5ef17984..3a891ba62727511706291cf292b0fb23b7ec2a02 100644 (file)
@@ -7,8 +7,6 @@
 #ifndef _ASM_CONFIG_H_
 #define _ASM_CONFIG_H_
 
-#define CONFIG_SYS_GENERIC_GLOBAL_DATA
-
 #define CONFIG_LMB
 #define CONFIG_SYS_BOOT_RAMDISK_HIGH
 
index 9e7c045aacf79f121847191f0748fb95998590bf..d9ffc1558dbfa392db6b3c0eef40fd4bebb4aa59 100644 (file)
@@ -64,4 +64,9 @@
 
 #define PCI_CFG_PIIX4_GENCFG_SERIRQ    (1 << 16)
 
+#define PCI_CFG_PIIX4_IDETIM_PRI       0x40
+#define PCI_CFG_PIIX4_IDETIM_SEC       0x42
+
+#define PCI_CFG_PIIX4_IDETIM_IDE       (1 << 15)
+
 #endif /* _MIPS_ASM_MALTA_H */
index 7f9b6536afa84ab8e7ff2947bec24518caae95b5..ac536da674d3958063f35f8e4bc76ae4c777f3d5 100644 (file)
@@ -5,6 +5,8 @@
 # SPDX-License-Identifier:     GPL-2.0+
 #
 
+obj-y  += cache.o
+obj-y  += cache_init.o
 obj-y  += io.o
 
 obj-$(CONFIG_CMD_BOOTM) += bootm.o
index e0722d20d1e876122939117163071e4ecd525b26..d9d8396e63b24b90838970c3256408a3c633f56b 100644 (file)
@@ -7,6 +7,7 @@
 
 #include <common.h>
 #include <image.h>
+#include <fdt_support.h>
 #include <asm/addrspace.h>
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -20,6 +21,18 @@ DECLARE_GLOBAL_DATA_PTR;
 #define mips_boot_malta                0
 #endif
 
+#if defined(CONFIG_MIPS_BOOT_CMDLINE_LEGACY)
+#define mips_boot_cmdline_legacy       1
+#else
+#define mips_boot_cmdline_legacy       0
+#endif
+
+#if defined(CONFIG_MIPS_BOOT_ENV_LEGACY)
+#define mips_boot_env_legacy   1
+#else
+#define mips_boot_env_legacy   0
+#endif
+
 static int linux_argc;
 static char **linux_argv;
 static char *linux_argp;
@@ -60,9 +73,39 @@ static int boot_setup_linux(bootm_headers_t *images)
        if (ret)
                return ret;
 
+#if defined(CONFIG_MIPS_BOOT_FDT) && defined(CONFIG_OF_LIBFDT)
+       if (images->ft_len) {
+               boot_fdt_add_mem_rsv_regions(&images->lmb, images->ft_addr);
+
+               ret = boot_relocate_fdt(&images->lmb, &images->ft_addr,
+                       &images->ft_len);
+               if (ret)
+                       return ret;
+       }
+#endif
+
        return 0;
 }
 
+static void boot_setup_fdt(bootm_headers_t *images)
+{
+#if defined(CONFIG_MIPS_BOOT_FDT) && defined(CONFIG_OF_LIBFDT)
+       u64 mem_start = 0;
+       u64 mem_size = gd->ram_size;
+
+       debug("## setup FDT\n");
+
+       fdt_chosen(images->ft_addr, 1);
+       fdt_fixup_memory_banks(images->ft_addr, &mem_start, &mem_size, 1);
+       fdt_fixup_ethernet(images->ft_addr);
+       fdt_initrd(images->ft_addr, images->initrd_start, images->initrd_end, 1);
+
+#if defined(CONFIG_OF_BOARD_SETUP)
+       ft_board_setup(images->ft_addr, gd->bd);
+#endif
+#endif
+}
+
 static void linux_cmdline_init(void)
 {
        linux_argc = 1;
@@ -92,7 +135,7 @@ static void linux_cmdline_dump(void)
                debug("   arg %03d: %s\n", i, linux_argv[i]);
 }
 
-static void boot_cmdline_linux(bootm_headers_t *images)
+static void linux_cmdline_legacy(bootm_headers_t *images)
 {
        const char *bootargs, *next, *quote;
 
@@ -130,8 +173,40 @@ static void boot_cmdline_linux(bootm_headers_t *images)
 
                bootargs = next;
        }
+}
 
-       linux_cmdline_dump();
+static void linux_cmdline_append(bootm_headers_t *images)
+{
+       char buf[24];
+       ulong mem, rd_start, rd_size;
+
+       /* append mem */
+       mem = gd->ram_size >> 20;
+       sprintf(buf, "mem=%luM", mem);
+       linux_cmdline_set(buf, strlen(buf));
+
+       /* append rd_start and rd_size */
+       rd_start = images->initrd_start;
+       rd_size = images->initrd_end - images->initrd_start;
+
+       if (rd_size) {
+               sprintf(buf, "rd_start=0x%08lX", rd_start);
+               linux_cmdline_set(buf, strlen(buf));
+               sprintf(buf, "rd_size=0x%lX", rd_size);
+               linux_cmdline_set(buf, strlen(buf));
+       }
+}
+
+static void boot_cmdline_linux(bootm_headers_t *images)
+{
+       if (mips_boot_cmdline_legacy && !images->ft_len) {
+               linux_cmdline_legacy(images);
+
+               if (!mips_boot_env_legacy)
+                       linux_cmdline_append(images);
+
+               linux_cmdline_dump();
+       }
 }
 
 static void linux_env_init(void)
@@ -165,7 +240,7 @@ static void linux_env_set(const char *env_name, const char *env_val)
        }
 }
 
-static void boot_prep_linux(bootm_headers_t *images)
+static void linux_env_legacy(bootm_headers_t *images)
 {
        char env_buf[12];
        const char *cp;
@@ -213,6 +288,15 @@ static void boot_prep_linux(bootm_headers_t *images)
        }
 }
 
+static void boot_prep_linux(bootm_headers_t *images)
+{
+       if (mips_boot_env_legacy && !images->ft_len)
+               linux_env_legacy(images);
+
+       if (images->ft_len)
+               boot_setup_fdt(images);
+}
+
 static void boot_jump_linux(bootm_headers_t *images)
 {
        typedef void __noreturn (*kernel_entry_t)(int, ulong, ulong, ulong);
@@ -226,8 +310,12 @@ static void boot_jump_linux(bootm_headers_t *images)
        if (mips_boot_malta)
                linux_extra = gd->ram_size;
 
-       /* we assume that the kernel is in place */
-       printf("\nStarting kernel ...\n\n");
+#ifdef CONFIG_BOOTSTAGE_FDT
+       bootstage_fdt_add_report();
+#endif
+#ifdef CONFIG_BOOTSTAGE_REPORT
+       bootstage_report();
+#endif
 
        kernel(linux_argc, (ulong)linux_argv, (ulong)linux_env, linux_extra);
 }
diff --git a/arch/mips/lib/cache.c b/arch/mips/lib/cache.c
new file mode 100644 (file)
index 0000000..e245614
--- /dev/null
@@ -0,0 +1,118 @@
+/*
+ * (C) Copyright 2003
+ * Wolfgang Denk, DENX Software Engineering, <wd@denx.de>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <common.h>
+#include <asm/cacheops.h>
+#include <asm/mipsregs.h>
+
+#ifdef CONFIG_SYS_CACHELINE_SIZE
+
+static inline unsigned long icache_line_size(void)
+{
+       return CONFIG_SYS_CACHELINE_SIZE;
+}
+
+static inline unsigned long dcache_line_size(void)
+{
+       return CONFIG_SYS_CACHELINE_SIZE;
+}
+
+#else /* !CONFIG_SYS_CACHELINE_SIZE */
+
+static inline unsigned long icache_line_size(void)
+{
+       unsigned long conf1, il;
+       conf1 = read_c0_config1();
+       il = (conf1 & MIPS_CONF1_IL) >> MIPS_CONF1_IL_SHIFT;
+       if (!il)
+               return 0;
+       return 2 << il;
+}
+
+static inline unsigned long dcache_line_size(void)
+{
+       unsigned long conf1, dl;
+       conf1 = read_c0_config1();
+       dl = (conf1 & MIPS_CONF1_DL) >> MIPS_CONF1_DL_SHIFT;
+       if (!dl)
+               return 0;
+       return 2 << dl;
+}
+
+#endif /* !CONFIG_SYS_CACHELINE_SIZE */
+
+void flush_cache(ulong start_addr, ulong size)
+{
+       unsigned long ilsize = icache_line_size();
+       unsigned long dlsize = dcache_line_size();
+       const void *addr, *aend;
+
+       /* aend will be miscalculated when size is zero, so we return here */
+       if (size == 0)
+               return;
+
+       addr = (const void *)(start_addr & ~(dlsize - 1));
+       aend = (const void *)((start_addr + size - 1) & ~(dlsize - 1));
+
+       if (ilsize == dlsize) {
+               /* flush I-cache & D-cache simultaneously */
+               while (1) {
+                       mips_cache(HIT_WRITEBACK_INV_D, addr);
+                       mips_cache(HIT_INVALIDATE_I, addr);
+                       if (addr == aend)
+                               break;
+                       addr += dlsize;
+               }
+               return;
+       }
+
+       /* flush D-cache */
+       while (1) {
+               mips_cache(HIT_WRITEBACK_INV_D, addr);
+               if (addr == aend)
+                       break;
+               addr += dlsize;
+       }
+
+       /* flush I-cache */
+       addr = (const void *)(start_addr & ~(ilsize - 1));
+       aend = (const void *)((start_addr + size - 1) & ~(ilsize - 1));
+       while (1) {
+               mips_cache(HIT_INVALIDATE_I, addr);
+               if (addr == aend)
+                       break;
+               addr += ilsize;
+       }
+}
+
+void flush_dcache_range(ulong start_addr, ulong stop)
+{
+       unsigned long lsize = dcache_line_size();
+       const void *addr = (const void *)(start_addr & ~(lsize - 1));
+       const void *aend = (const void *)((stop - 1) & ~(lsize - 1));
+
+       while (1) {
+               mips_cache(HIT_WRITEBACK_INV_D, addr);
+               if (addr == aend)
+                       break;
+               addr += lsize;
+       }
+}
+
+void invalidate_dcache_range(ulong start_addr, ulong stop)
+{
+       unsigned long lsize = dcache_line_size();
+       const void *addr = (const void *)(start_addr & ~(lsize - 1));
+       const void *aend = (const void *)((stop - 1) & ~(lsize - 1));
+
+       while (1) {
+               mips_cache(HIT_INVALIDATE_D, addr);
+               if (addr == aend)
+                       break;
+               addr += lsize;
+       }
+}
diff --git a/arch/mips/lib/cache_init.S b/arch/mips/lib/cache_init.S
new file mode 100644 (file)
index 0000000..137d728
--- /dev/null
@@ -0,0 +1,241 @@
+/*
+ *  Cache-handling routined for MIPS CPUs
+ *
+ *  Copyright (c) 2003 Wolfgang Denk <wd@denx.de>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <asm-offsets.h>
+#include <config.h>
+#include <asm/asm.h>
+#include <asm/regdef.h>
+#include <asm/mipsregs.h>
+#include <asm/addrspace.h>
+#include <asm/cacheops.h>
+
+#ifndef CONFIG_SYS_MIPS_CACHE_MODE
+#define CONFIG_SYS_MIPS_CACHE_MODE CONF_CM_CACHABLE_NONCOHERENT
+#endif
+
+#define INDEX_BASE     CKSEG0
+
+       .macro  f_fill64 dst, offset, val
+       LONG_S  \val, (\offset +  0 * LONGSIZE)(\dst)
+       LONG_S  \val, (\offset +  1 * LONGSIZE)(\dst)
+       LONG_S  \val, (\offset +  2 * LONGSIZE)(\dst)
+       LONG_S  \val, (\offset +  3 * LONGSIZE)(\dst)
+       LONG_S  \val, (\offset +  4 * LONGSIZE)(\dst)
+       LONG_S  \val, (\offset +  5 * LONGSIZE)(\dst)
+       LONG_S  \val, (\offset +  6 * LONGSIZE)(\dst)
+       LONG_S  \val, (\offset +  7 * LONGSIZE)(\dst)
+#if LONGSIZE == 4
+       LONG_S  \val, (\offset +  8 * LONGSIZE)(\dst)
+       LONG_S  \val, (\offset +  9 * LONGSIZE)(\dst)
+       LONG_S  \val, (\offset + 10 * LONGSIZE)(\dst)
+       LONG_S  \val, (\offset + 11 * LONGSIZE)(\dst)
+       LONG_S  \val, (\offset + 12 * LONGSIZE)(\dst)
+       LONG_S  \val, (\offset + 13 * LONGSIZE)(\dst)
+       LONG_S  \val, (\offset + 14 * LONGSIZE)(\dst)
+       LONG_S  \val, (\offset + 15 * LONGSIZE)(\dst)
+#endif
+       .endm
+
+       .macro cache_loop       curr, end, line_sz, op
+10:    cache           \op, 0(\curr)
+       PTR_ADDU        \curr, \curr, \line_sz
+       bne             \curr, \end, 10b
+       .endm
+
+       .macro  l1_info         sz, line_sz, off
+       .set    push
+       .set    noat
+
+       mfc0    $1, CP0_CONFIG, 1
+
+       /* detect line size */
+       srl     \line_sz, $1, \off + MIPS_CONF1_DL_SHIFT - MIPS_CONF1_DA_SHIFT
+       andi    \line_sz, \line_sz, (MIPS_CONF1_DL >> MIPS_CONF1_DL_SHIFT)
+       move    \sz, zero
+       beqz    \line_sz, 10f
+       li      \sz, 2
+       sllv    \line_sz, \sz, \line_sz
+
+       /* detect associativity */
+       srl     \sz, $1, \off + MIPS_CONF1_DA_SHIFT - MIPS_CONF1_DA_SHIFT
+       andi    \sz, \sz, (MIPS_CONF1_DA >> MIPS_CONF1_DA_SHIFT)
+       addi    \sz, \sz, 1
+
+       /* sz *= line_sz */
+       mul     \sz, \sz, \line_sz
+
+       /* detect log32(sets) */
+       srl     $1, $1, \off + MIPS_CONF1_DS_SHIFT - MIPS_CONF1_DA_SHIFT
+       andi    $1, $1, (MIPS_CONF1_DS >> MIPS_CONF1_DS_SHIFT)
+       addiu   $1, $1, 1
+       andi    $1, $1, 0x7
+
+       /* sz <<= log32(sets) */
+       sllv    \sz, \sz, $1
+
+       /* sz *= 32 */
+       li      $1, 32
+       mul     \sz, \sz, $1
+10:
+       .set    pop
+       .endm
+/*
+ * mips_cache_reset - low level initialisation of the primary caches
+ *
+ * This routine initialises the primary caches to ensure that they have good
+ * parity.  It must be called by the ROM before any cached locations are used
+ * to prevent the possibility of data with bad parity being written to memory.
+ *
+ * To initialise the instruction cache it is essential that a source of data
+ * with good parity is available. This routine will initialise an area of
+ * memory starting at location zero to be used as a source of parity.
+ *
+ * RETURNS: N/A
+ *
+ */
+LEAF(mips_cache_reset)
+#ifdef CONFIG_SYS_ICACHE_SIZE
+       li      t2, CONFIG_SYS_ICACHE_SIZE
+       li      t8, CONFIG_SYS_CACHELINE_SIZE
+#else
+       l1_info t2, t8, MIPS_CONF1_IA_SHIFT
+#endif
+
+#ifdef CONFIG_SYS_DCACHE_SIZE
+       li      t3, CONFIG_SYS_DCACHE_SIZE
+       li      t9, CONFIG_SYS_CACHELINE_SIZE
+#else
+       l1_info t3, t9, MIPS_CONF1_DA_SHIFT
+#endif
+
+#ifdef CONFIG_SYS_MIPS_CACHE_INIT_RAM_LOAD
+
+       /* Determine the largest L1 cache size */
+#if defined(CONFIG_SYS_ICACHE_SIZE) && defined(CONFIG_SYS_DCACHE_SIZE)
+#if CONFIG_SYS_ICACHE_SIZE > CONFIG_SYS_DCACHE_SIZE
+       li      v0, CONFIG_SYS_ICACHE_SIZE
+#else
+       li      v0, CONFIG_SYS_DCACHE_SIZE
+#endif
+#else
+       move    v0, t2
+       sltu    t1, t2, t3
+       movn    v0, t3, t1
+#endif
+       /*
+        * Now clear that much memory starting from zero.
+        */
+       PTR_LI          a0, CKSEG1
+       PTR_ADDU        a1, a0, v0
+2:     PTR_ADDIU       a0, 64
+       f_fill64        a0, -64, zero
+       bne             a0, a1, 2b
+
+#endif /* CONFIG_SYS_MIPS_CACHE_INIT_RAM_LOAD */
+
+       /*
+        * The TagLo registers used depend upon the CPU implementation, but the
+        * architecture requires that it is safe for software to write to both
+        * TagLo selects 0 & 2 covering supported cases.
+        */
+       mtc0            zero, CP0_TAGLO
+       mtc0            zero, CP0_TAGLO, 2
+
+       /*
+        * The caches are probably in an indeterminate state, so we force good
+        * parity into them by doing an invalidate for each line. If
+        * CONFIG_SYS_MIPS_CACHE_INIT_RAM_LOAD is set then we'll proceed to
+        * perform a load/fill & a further invalidate for each line, assuming
+        * that the bottom of RAM (having just been cleared) will generate good
+        * parity for the cache.
+        */
+
+       /*
+        * Initialize the I-cache first,
+        */
+       blez            t2, 1f
+       PTR_LI          t0, INDEX_BASE
+       PTR_ADDU        t1, t0, t2
+       /* clear tag to invalidate */
+       cache_loop      t0, t1, t8, INDEX_STORE_TAG_I
+#ifdef CONFIG_SYS_MIPS_CACHE_INIT_RAM_LOAD
+       /* fill once, so data field parity is correct */
+       PTR_LI          t0, INDEX_BASE
+       cache_loop      t0, t1, t8, FILL
+       /* invalidate again - prudent but not strictly neccessary */
+       PTR_LI          t0, INDEX_BASE
+       cache_loop      t0, t1, t8, INDEX_STORE_TAG_I
+#endif
+
+       /*
+        * then initialize D-cache.
+        */
+1:     blez            t3, 3f
+       PTR_LI          t0, INDEX_BASE
+       PTR_ADDU        t1, t0, t3
+       /* clear all tags */
+       cache_loop      t0, t1, t9, INDEX_STORE_TAG_D
+#ifdef CONFIG_SYS_MIPS_CACHE_INIT_RAM_LOAD
+       /* load from each line (in cached space) */
+       PTR_LI          t0, INDEX_BASE
+2:     LONG_L          zero, 0(t0)
+       PTR_ADDU        t0, t9
+       bne             t0, t1, 2b
+       /* clear all tags */
+       PTR_LI          t0, INDEX_BASE
+       cache_loop      t0, t1, t9, INDEX_STORE_TAG_D
+#endif
+
+3:     jr      ra
+       END(mips_cache_reset)
+
+/*
+ * dcache_status - get cache status
+ *
+ * RETURNS: 0 - cache disabled; 1 - cache enabled
+ *
+ */
+LEAF(dcache_status)
+       mfc0    t0, CP0_CONFIG
+       li      t1, CONF_CM_UNCACHED
+       andi    t0, t0, CONF_CM_CMASK
+       move    v0, zero
+       beq     t0, t1, 2f
+       li      v0, 1
+2:     jr      ra
+       END(dcache_status)
+
+/*
+ * dcache_disable - disable cache
+ *
+ * RETURNS: N/A
+ *
+ */
+LEAF(dcache_disable)
+       mfc0    t0, CP0_CONFIG
+       li      t1, -8
+       and     t0, t0, t1
+       ori     t0, t0, CONF_CM_UNCACHED
+       mtc0    t0, CP0_CONFIG
+       jr      ra
+       END(dcache_disable)
+
+/*
+ * dcache_enable - enable cache
+ *
+ * RETURNS: N/A
+ *
+ */
+LEAF(dcache_enable)
+       mfc0    t0, CP0_CONFIG
+       ori     t0, CONF_CM_CMASK
+       xori    t0, CONF_CM_CMASK
+       ori     t0, CONFIG_SYS_MIPS_CACHE_MODE
+       mtc0    t0, CP0_CONFIG
+       jr      ra
+       END(dcache_enable)
diff --git a/arch/mips/mach-au1x00/Makefile b/arch/mips/mach-au1x00/Makefile
new file mode 100644 (file)
index 0000000..c5643e7
--- /dev/null
@@ -0,0 +1,8 @@
+#
+# (C) Copyright 2011
+# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+#
+# SPDX-License-Identifier:     GPL-2.0+
+#
+
+obj-y  = au1x00_eth.o au1x00_serial.o au1x00_usb_ohci.o au1x00_ide.o
diff --git a/arch/mips/mach-au1x00/au1x00_eth.c b/arch/mips/mach-au1x00/au1x00_eth.c
new file mode 100644 (file)
index 0000000..39c5b6b
--- /dev/null
@@ -0,0 +1,302 @@
+/* Only eth0 supported for now
+ *
+ * (C) Copyright 2003
+ * Thomas.Lange@corelatus.se
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+#include <config.h>
+
+#if defined(CONFIG_SYS_DISCOVER_PHY)
+#error "PHY not supported yet"
+/* We just assume that we are running 100FD for now */
+/* We all use switches, right? ;-) */
+#endif
+
+/* I assume ethernet behaves like au1000 */
+
+#ifdef CONFIG_SOC_AU1000
+/* Base address differ between cpu:s */
+#define ETH0_BASE AU1000_ETH0_BASE
+#define MAC0_ENABLE AU1000_MAC0_ENABLE
+#else
+#ifdef CONFIG_SOC_AU1100
+#define ETH0_BASE AU1100_ETH0_BASE
+#define MAC0_ENABLE AU1100_MAC0_ENABLE
+#else
+#ifdef CONFIG_SOC_AU1500
+#define ETH0_BASE AU1500_ETH0_BASE
+#define MAC0_ENABLE AU1500_MAC0_ENABLE
+#else
+#ifdef CONFIG_SOC_AU1550
+#define ETH0_BASE AU1550_ETH0_BASE
+#define MAC0_ENABLE AU1550_MAC0_ENABLE
+#else
+#error "No valid cpu set"
+#endif
+#endif
+#endif
+#endif
+
+#include <common.h>
+#include <malloc.h>
+#include <net.h>
+#include <command.h>
+#include <asm/io.h>
+#include <asm/au1x00.h>
+
+#if defined(CONFIG_CMD_MII)
+#include <miiphy.h>
+#endif
+
+/* Ethernet Transmit and Receive Buffers */
+#define DBUF_LENGTH  1520
+#define PKT_MAXBUF_SIZE                1518
+
+static char txbuf[DBUF_LENGTH];
+
+static int next_tx;
+static int next_rx;
+
+/* 4 rx and 4 tx fifos */
+#define NO_OF_FIFOS 4
+
+typedef struct{
+       u32 status;
+       u32 addr;
+       u32 len; /* Only used for tx */
+       u32 not_used;
+} mac_fifo_t;
+
+mac_fifo_t mac_fifo[NO_OF_FIFOS];
+
+#define MAX_WAIT 1000
+
+#if defined(CONFIG_CMD_MII)
+int  au1x00_miiphy_read(const char *devname, unsigned char addr,
+               unsigned char reg, unsigned short * value)
+{
+       volatile u32 *mii_control_reg = (volatile u32*)(ETH0_BASE+MAC_MII_CNTRL);
+       volatile u32 *mii_data_reg = (volatile u32*)(ETH0_BASE+MAC_MII_DATA);
+       u32 mii_control;
+       unsigned int timedout = 20;
+
+       while (*mii_control_reg & MAC_MII_BUSY) {
+               udelay(1000);
+               if (--timedout == 0) {
+                       printf("au1x00_eth: miiphy_read busy timeout!!\n");
+                       return -1;
+               }
+       }
+
+       mii_control = MAC_SET_MII_SELECT_REG(reg) |
+               MAC_SET_MII_SELECT_PHY(addr) | MAC_MII_READ;
+
+       *mii_control_reg = mii_control;
+
+       timedout = 20;
+       while (*mii_control_reg & MAC_MII_BUSY) {
+               udelay(1000);
+               if (--timedout == 0) {
+                       printf("au1x00_eth: miiphy_read busy timeout!!\n");
+                       return -1;
+               }
+       }
+       *value = *mii_data_reg;
+       return 0;
+}
+
+int  au1x00_miiphy_write(const char *devname, unsigned char addr,
+               unsigned char reg, unsigned short value)
+{
+       volatile u32 *mii_control_reg = (volatile u32*)(ETH0_BASE+MAC_MII_CNTRL);
+       volatile u32 *mii_data_reg = (volatile u32*)(ETH0_BASE+MAC_MII_DATA);
+       u32 mii_control;
+       unsigned int timedout = 20;
+
+       while (*mii_control_reg & MAC_MII_BUSY) {
+               udelay(1000);
+               if (--timedout == 0) {
+                       printf("au1x00_eth: miiphy_write busy timeout!!\n");
+                       return -1;
+               }
+       }
+
+       mii_control = MAC_SET_MII_SELECT_REG(reg) |
+               MAC_SET_MII_SELECT_PHY(addr) | MAC_MII_WRITE;
+
+       *mii_data_reg = value;
+       *mii_control_reg = mii_control;
+       return 0;
+}
+#endif
+
+static int au1x00_send(struct eth_device *dev, void *packet, int length)
+{
+       volatile mac_fifo_t *fifo_tx =
+               (volatile mac_fifo_t*)(MAC0_TX_DMA_ADDR+MAC_TX_BUFF0_STATUS);
+       int i;
+       int res;
+
+       /* tx fifo should always be idle */
+       fifo_tx[next_tx].len = length;
+       fifo_tx[next_tx].addr = (virt_to_phys(packet))|TX_DMA_ENABLE;
+       au_sync();
+
+       udelay(1);
+       i=0;
+       while(!(fifo_tx[next_tx].addr&TX_T_DONE)){
+               if(i>MAX_WAIT){
+                       printf("TX timeout\n");
+                       break;
+               }
+               udelay(1);
+               i++;
+       }
+
+       /* Clear done bit */
+       fifo_tx[next_tx].addr = 0;
+       fifo_tx[next_tx].len = 0;
+       au_sync();
+
+       res = fifo_tx[next_tx].status;
+
+       next_tx++;
+       if(next_tx>=NO_OF_FIFOS){
+               next_tx=0;
+       }
+       return(res);
+}
+
+static int au1x00_recv(struct eth_device* dev){
+       volatile mac_fifo_t *fifo_rx =
+               (volatile mac_fifo_t*)(MAC0_RX_DMA_ADDR+MAC_RX_BUFF0_STATUS);
+
+       int length;
+       u32 status;
+
+       for(;;){
+               if(!(fifo_rx[next_rx].addr&RX_T_DONE)){
+                       /* Nothing has been received */
+                       return(-1);
+               }
+
+               status = fifo_rx[next_rx].status;
+
+               length = status&0x3FFF;
+
+               if(status&RX_ERROR){
+                       printf("Rx error 0x%x\n", status);
+               }
+               else{
+                       /* Pass the packet up to the protocol layers. */
+                       NetReceive(NetRxPackets[next_rx], length - 4);
+               }
+
+               fifo_rx[next_rx].addr = (virt_to_phys(NetRxPackets[next_rx]))|RX_DMA_ENABLE;
+
+               next_rx++;
+               if(next_rx>=NO_OF_FIFOS){
+                       next_rx=0;
+               }
+       } /* for */
+
+       return(0); /* Does anyone use this? */
+}
+
+static int au1x00_init(struct eth_device* dev, bd_t * bd){
+
+       volatile u32 *macen = (volatile u32*)MAC0_ENABLE;
+       volatile u32 *mac_ctrl = (volatile u32*)(ETH0_BASE+MAC_CONTROL);
+       volatile u32 *mac_addr_high = (volatile u32*)(ETH0_BASE+MAC_ADDRESS_HIGH);
+       volatile u32 *mac_addr_low = (volatile u32*)(ETH0_BASE+MAC_ADDRESS_LOW);
+       volatile u32 *mac_mcast_high = (volatile u32*)(ETH0_BASE+MAC_MCAST_HIGH);
+       volatile u32 *mac_mcast_low = (volatile u32*)(ETH0_BASE+MAC_MCAST_LOW);
+       volatile mac_fifo_t *fifo_tx =
+               (volatile mac_fifo_t*)(MAC0_TX_DMA_ADDR+MAC_TX_BUFF0_STATUS);
+       volatile mac_fifo_t *fifo_rx =
+               (volatile mac_fifo_t*)(MAC0_RX_DMA_ADDR+MAC_RX_BUFF0_STATUS);
+       int i;
+
+       next_tx = TX_GET_DMA_BUFFER(fifo_tx[0].addr);
+       next_rx = RX_GET_DMA_BUFFER(fifo_rx[0].addr);
+
+       /* We have to enable clocks before releasing reset */
+       *macen = MAC_EN_CLOCK_ENABLE;
+       udelay(10);
+
+       /* Enable MAC0 */
+       /* We have to release reset before accessing registers */
+       *macen = MAC_EN_CLOCK_ENABLE|MAC_EN_RESET0|
+               MAC_EN_RESET1|MAC_EN_RESET2;
+       udelay(10);
+
+       for(i=0;i<NO_OF_FIFOS;i++){
+               fifo_tx[i].len = 0;
+               fifo_tx[i].addr = virt_to_phys(&txbuf[0]);
+               fifo_rx[i].addr = (virt_to_phys(NetRxPackets[i]))|RX_DMA_ENABLE;
+       }
+
+       /* Put mac addr in little endian */
+#define ea eth_get_dev()->enetaddr
+       *mac_addr_high  =       (ea[5] <<  8) | (ea[4]      ) ;
+       *mac_addr_low   =       (ea[3] << 24) | (ea[2] << 16) |
+               (ea[1] <<  8) | (ea[0]      ) ;
+#undef ea
+       *mac_mcast_low = 0;
+       *mac_mcast_high = 0;
+
+       /* Make sure the MAC buffer is in the correct endian mode */
+#ifdef __LITTLE_ENDIAN
+       *mac_ctrl = MAC_FULL_DUPLEX;
+       udelay(1);
+       *mac_ctrl = MAC_FULL_DUPLEX|MAC_RX_ENABLE|MAC_TX_ENABLE;
+#else
+       *mac_ctrl = MAC_BIG_ENDIAN|MAC_FULL_DUPLEX;
+       udelay(1);
+       *mac_ctrl = MAC_BIG_ENDIAN|MAC_FULL_DUPLEX|MAC_RX_ENABLE|MAC_TX_ENABLE;
+#endif
+
+       return(1);
+}
+
+static void au1x00_halt(struct eth_device* dev){
+       volatile u32 *macen = (volatile u32*)MAC0_ENABLE;
+
+       /* Put MAC0 in reset */
+       *macen = 0;
+}
+
+int au1x00_enet_initialize(bd_t *bis){
+       struct eth_device* dev;
+
+       if ((dev = (struct eth_device*)malloc(sizeof *dev)) == NULL) {
+               puts ("malloc failed\n");
+               return -1;
+       }
+
+       memset(dev, 0, sizeof *dev);
+
+       sprintf(dev->name, "Au1X00 ethernet");
+       dev->iobase = 0;
+       dev->priv   = 0;
+       dev->init   = au1x00_init;
+       dev->halt   = au1x00_halt;
+       dev->send   = au1x00_send;
+       dev->recv   = au1x00_recv;
+
+       eth_register(dev);
+
+#if defined(CONFIG_CMD_MII)
+       miiphy_register(dev->name,
+               au1x00_miiphy_read, au1x00_miiphy_write);
+#endif
+
+       return 1;
+}
+
+int cpu_eth_init(bd_t *bis)
+{
+       au1x00_enet_initialize(bis);
+       return 0;
+}
diff --git a/arch/mips/mach-au1x00/au1x00_ide.c b/arch/mips/mach-au1x00/au1x00_ide.c
new file mode 100644 (file)
index 0000000..ba0b35d
--- /dev/null
@@ -0,0 +1,15 @@
+/*
+ * (C) Copyright 2000-2011
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <common.h>
+#include <ide.h>
+
+/* AU1X00 swaps data in big-endian mode, enforce little-endian function */
+void ide_input_swap_data(int dev, ulong *sect_buf, int words)
+{
+       ide_input_data(dev, sect_buf, words);
+}
diff --git a/arch/mips/mach-au1x00/au1x00_serial.c b/arch/mips/mach-au1x00/au1x00_serial.c
new file mode 100644 (file)
index 0000000..0463508
--- /dev/null
@@ -0,0 +1,131 @@
+/*
+ * AU1X00 UART support
+ *
+ * Hardcoded to UART 0 for now
+ * Speed and options also hardcoded to 115200 8N1
+ *
+ *  Copyright (c) 2003 Thomas.Lange@corelatus.se
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <config.h>
+#include <common.h>
+#include <asm/au1x00.h>
+#include <serial.h>
+#include <linux/compiler.h>
+
+/******************************************************************************
+*
+* serial_init - initialize a channel
+*
+* This routine initializes the number of data bits, parity
+* and set the selected baud rate. Interrupts are disabled.
+* Set the modem control signals if the option is selected.
+*
+* RETURNS: N/A
+*/
+
+static int au1x00_serial_init(void)
+{
+       volatile u32 *uart_fifoctl = (volatile u32*)(UART0_ADDR+UART_FCR);
+       volatile u32 *uart_enable = (volatile u32*)(UART0_ADDR+UART_ENABLE);
+
+       /* Enable clocks first */
+       *uart_enable = UART_EN_CE;
+
+       /* Then release reset */
+       /* Must release reset before setting other regs */
+       *uart_enable = UART_EN_CE|UART_EN_E;
+
+       /* Activate fifos, reset tx and rx */
+       /* Set tx trigger level to 12 */
+       *uart_fifoctl = UART_FCR_ENABLE_FIFO|UART_FCR_CLEAR_RCVR|
+               UART_FCR_CLEAR_XMIT|UART_FCR_T_TRIGGER_12;
+
+       serial_setbrg();
+
+       return 0;
+}
+
+
+static void au1x00_serial_setbrg(void)
+{
+       volatile u32 *uart_clk = (volatile u32*)(UART0_ADDR+UART_CLK);
+       volatile u32 *uart_lcr = (volatile u32*)(UART0_ADDR+UART_LCR);
+       volatile u32 *sys_powerctrl = (u32 *)SYS_POWERCTRL;
+       int sd;
+       int divisorx2;
+
+       /* sd is system clock divisor                   */
+       /* see section 10.4.5 in au1550 datasheet       */
+       sd = (*sys_powerctrl & 0x03) + 2;
+
+       /* calulate 2x baudrate and round */
+       divisorx2 = ((CONFIG_SYS_MIPS_TIMER_FREQ/(sd * 16 * CONFIG_BAUDRATE)));
+
+       if (divisorx2 & 0x01)
+               divisorx2 = divisorx2 + 1;
+
+       *uart_clk = divisorx2 / 2;
+
+       /* Set parity, stop bits and word length to 8N1 */
+       *uart_lcr = UART_LCR_WLEN8;
+}
+
+static void au1x00_serial_putc(const char c)
+{
+       volatile u32 *uart_lsr = (volatile u32*)(UART0_ADDR+UART_LSR);
+       volatile u32 *uart_tx = (volatile u32*)(UART0_ADDR+UART_TX);
+
+       if (c == '\n')
+               au1x00_serial_putc('\r');
+
+       /* Wait for fifo to shift out some bytes */
+       while((*uart_lsr&UART_LSR_THRE)==0);
+
+       *uart_tx = (u32)c;
+}
+
+static int au1x00_serial_getc(void)
+{
+       volatile u32 *uart_rx = (volatile u32*)(UART0_ADDR+UART_RX);
+       char c;
+
+       while (!serial_tstc());
+
+       c = (*uart_rx&0xFF);
+       return c;
+}
+
+static int au1x00_serial_tstc(void)
+{
+       volatile u32 *uart_lsr = (volatile u32*)(UART0_ADDR+UART_LSR);
+
+       if(*uart_lsr&UART_LSR_DR){
+               /* Data in rfifo */
+               return(1);
+       }
+       return 0;
+}
+
+static struct serial_device au1x00_serial_drv = {
+       .name   = "au1x00_serial",
+       .start  = au1x00_serial_init,
+       .stop   = NULL,
+       .setbrg = au1x00_serial_setbrg,
+       .putc   = au1x00_serial_putc,
+       .puts   = default_serial_puts,
+       .getc   = au1x00_serial_getc,
+       .tstc   = au1x00_serial_tstc,
+};
+
+void au1x00_serial_initialize(void)
+{
+       serial_register(&au1x00_serial_drv);
+}
+
+__weak struct serial_device *default_serial_console(void)
+{
+       return &au1x00_serial_drv;
+}
diff --git a/arch/mips/mach-au1x00/au1x00_usb_ohci.c b/arch/mips/mach-au1x00/au1x00_usb_ohci.c
new file mode 100644 (file)
index 0000000..74bdb77
--- /dev/null
@@ -0,0 +1,1609 @@
+/*
+ * URB OHCI HCD (Host Controller Driver) for USB on the AU1x00.
+ *
+ * (C) Copyright 2003
+ * Gary Jennejohn, DENX Software Engineering <garyj@denx.de>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ * Note: Part of this code has been derived from linux
+ *
+ */
+/*
+ * IMPORTANT NOTES
+ * 1 - this driver is intended for use with USB Mass Storage Devices
+ *     (BBB) ONLY. There is NO support for Interrupt or Isochronous pipes!
+ */
+
+#include <config.h>
+
+#ifdef CONFIG_USB_OHCI
+
+/* #include <pci.h> no PCI on the AU1x00 */
+
+#include <common.h>
+#include <malloc.h>
+#include <asm/io.h>
+#include <asm/au1x00.h>
+#include <usb.h>
+#include "au1x00_usb_ohci.h"
+
+#define OHCI_USE_NPS           /* force NoPowerSwitching mode */
+#define OHCI_VERBOSE_DEBUG     /* not always helpful */
+#define OHCI_FILL_TRACE
+
+#define USBH_ENABLE_BE (1<<0)
+#define USBH_ENABLE_C  (1<<1)
+#define USBH_ENABLE_E  (1<<2)
+#define USBH_ENABLE_CE (1<<3)
+#define USBH_ENABLE_RD (1<<4)
+
+#ifdef __LITTLE_ENDIAN
+#define USBH_ENABLE_INIT (USBH_ENABLE_CE | USBH_ENABLE_E | USBH_ENABLE_C)
+#else
+#define USBH_ENABLE_INIT (USBH_ENABLE_CE | USBH_ENABLE_E | USBH_ENABLE_C | USBH_ENABLE_BE)
+#endif
+
+
+/* For initializing controller (mask in an HCFS mode too) */
+#define OHCI_CONTROL_INIT \
+       (OHCI_CTRL_CBSR & 0x3) | OHCI_CTRL_IE | OHCI_CTRL_PLE
+
+#undef readl
+#undef writel
+
+#define readl(a)     au_readl((long)(a))
+#define writel(v,a)  au_writel((v),(int)(a))
+
+#define DEBUG
+#ifdef DEBUG
+#define dbg(format, arg...) printf("DEBUG: " format "\n", ## arg)
+#else
+#define dbg(format, arg...) do {} while(0)
+#endif /* DEBUG */
+#define err(format, arg...) printf("ERROR: " format "\n", ## arg)
+#define SHOW_INFO
+#ifdef SHOW_INFO
+#define info(format, arg...) printf("INFO: " format "\n", ## arg)
+#else
+#define info(format, arg...) do {} while(0)
+#endif
+
+#define m16_swap(x) swap_16(x)
+#define m32_swap(x) swap_32(x)
+
+/* global ohci_t */
+static ohci_t gohci;
+/* this must be aligned to a 256 byte boundary */
+struct ohci_hcca ghcca[1];
+/* a pointer to the aligned storage */
+struct ohci_hcca *phcca;
+/* this allocates EDs for all possible endpoints */
+struct ohci_device ohci_dev;
+/* urb_priv */
+urb_priv_t urb_priv;
+/* RHSC flag */
+int got_rhsc;
+/* device which was disconnected */
+struct usb_device *devgone;
+
+/*-------------------------------------------------------------------------*/
+
+/* AMD-756 (D2 rev) reports corrupt register contents in some cases.
+ * The erratum (#4) description is incorrect.  AMD's workaround waits
+ * till some bits (mostly reserved) are clear; ok for all revs.
+ */
+#define OHCI_QUIRK_AMD756 0xabcd
+#define read_roothub(hc, register, mask) ({ \
+       u32 temp = readl (&hc->regs->roothub.register); \
+       if (hc->flags & OHCI_QUIRK_AMD756) \
+               while (temp & mask) \
+                       temp = readl (&hc->regs->roothub.register); \
+       temp; })
+
+static u32 roothub_a (struct ohci *hc)
+       { return read_roothub (hc, a, 0xfc0fe000); }
+static inline u32 roothub_b (struct ohci *hc)
+       { return readl (&hc->regs->roothub.b); }
+static inline u32 roothub_status (struct ohci *hc)
+       { return readl (&hc->regs->roothub.status); }
+static u32 roothub_portstatus (struct ohci *hc, int i)
+       { return read_roothub (hc, portstatus [i], 0xffe0fce0); }
+
+
+/* forward declaration */
+static int hc_interrupt (void);
+static void
+td_submit_job (struct usb_device * dev, unsigned long pipe, void * buffer,
+       int transfer_len, struct devrequest * setup, urb_priv_t * urb, int interval);
+
+/*-------------------------------------------------------------------------*
+ * URB support functions
+ *-------------------------------------------------------------------------*/
+
+/* free HCD-private data associated with this URB */
+
+static void urb_free_priv (urb_priv_t * urb)
+{
+       int             i;
+       int             last;
+       struct td       * td;
+
+       last = urb->length - 1;
+       if (last >= 0) {
+               for (i = 0; i <= last; i++) {
+                       td = urb->td[i];
+                       if (td) {
+                               td->usb_dev = NULL;
+                               urb->td[i] = NULL;
+                       }
+               }
+       }
+}
+
+/*-------------------------------------------------------------------------*/
+
+#ifdef DEBUG
+static int sohci_get_current_frame_number (struct usb_device * dev);
+
+/* debug| print the main components of an URB
+ * small: 0) header + data packets 1) just header */
+
+static void pkt_print (struct usb_device * dev, unsigned long pipe, void * buffer,
+       int transfer_len, struct devrequest * setup, char * str, int small)
+{
+       urb_priv_t * purb = &urb_priv;
+
+       dbg("%s URB:[%4x] dev:%2d,ep:%2d-%c,type:%s,len:%d/%d stat:%#lx",
+                       str,
+                       sohci_get_current_frame_number (dev),
+                       usb_pipedevice (pipe),
+                       usb_pipeendpoint (pipe),
+                       usb_pipeout (pipe)? 'O': 'I',
+                       usb_pipetype (pipe) < 2? (usb_pipeint (pipe)? "INTR": "ISOC"):
+                               (usb_pipecontrol (pipe)? "CTRL": "BULK"),
+                       purb->actual_length,
+                       transfer_len, dev->status);
+#ifdef OHCI_VERBOSE_DEBUG
+       if (!small) {
+               int i, len;
+
+               if (usb_pipecontrol (pipe)) {
+                       printf (__FILE__ ": cmd(8):");
+                       for (i = 0; i < 8 ; i++)
+                               printf (" %02x", ((__u8 *) setup) [i]);
+                       printf ("\n");
+               }
+               if (transfer_len > 0 && buffer) {
+                       printf (__FILE__ ": data(%d/%d):",
+                               purb->actual_length,
+                               transfer_len);
+                       len = usb_pipeout (pipe)?
+                                       transfer_len: purb->actual_length;
+                       for (i = 0; i < 16 && i < len; i++)
+                               printf (" %02x", ((__u8 *) buffer) [i]);
+                       printf ("%s\n", i < len? "...": "");
+               }
+       }
+#endif
+}
+
+/* just for debugging; prints non-empty branches of the int ed tree inclusive iso eds*/
+void ep_print_int_eds (ohci_t *ohci, char * str) {
+       int i, j;
+        __u32 * ed_p;
+       for (i= 0; i < 32; i++) {
+               j = 5;
+               ed_p = &(ohci->hcca->int_table [i]);
+               if (*ed_p == 0)
+                   continue;
+               printf (__FILE__ ": %s branch int %2d(%2x):", str, i, i);
+               while (*ed_p != 0 && j--) {
+                       ed_t *ed = (ed_t *)m32_swap(ed_p);
+                       printf (" ed: %4x;", ed->hwINFO);
+                       ed_p = &ed->hwNextED;
+               }
+               printf ("\n");
+       }
+}
+
+static void ohci_dump_intr_mask (char *label, __u32 mask)
+{
+       dbg ("%s: 0x%08x%s%s%s%s%s%s%s%s%s",
+               label,
+               mask,
+               (mask & OHCI_INTR_MIE) ? " MIE" : "",
+               (mask & OHCI_INTR_OC) ? " OC" : "",
+               (mask & OHCI_INTR_RHSC) ? " RHSC" : "",
+               (mask & OHCI_INTR_FNO) ? " FNO" : "",
+               (mask & OHCI_INTR_UE) ? " UE" : "",
+               (mask & OHCI_INTR_RD) ? " RD" : "",
+               (mask & OHCI_INTR_SF) ? " SF" : "",
+               (mask & OHCI_INTR_WDH) ? " WDH" : "",
+               (mask & OHCI_INTR_SO) ? " SO" : ""
+               );
+}
+
+static void maybe_print_eds (char *label, __u32 value)
+{
+       ed_t *edp = (ed_t *)value;
+
+       if (value) {
+               dbg ("%s %08x", label, value);
+               dbg ("%08x", edp->hwINFO);
+               dbg ("%08x", edp->hwTailP);
+               dbg ("%08x", edp->hwHeadP);
+               dbg ("%08x", edp->hwNextED);
+       }
+}
+
+static char * hcfs2string (int state)
+{
+       switch (state) {
+               case OHCI_USB_RESET:    return "reset";
+               case OHCI_USB_RESUME:   return "resume";
+               case OHCI_USB_OPER:     return "operational";
+               case OHCI_USB_SUSPEND:  return "suspend";
+       }
+       return "?";
+}
+
+/* dump control and status registers */
+static void ohci_dump_status (ohci_t *controller)
+{
+       struct ohci_regs        *regs = controller->regs;
+       __u32                   temp;
+
+       temp = readl (&regs->revision) & 0xff;
+       if (temp != 0x10)
+               dbg ("spec %d.%d", (temp >> 4), (temp & 0x0f));
+
+       temp = readl (&regs->control);
+       dbg ("control: 0x%08x%s%s%s HCFS=%s%s%s%s%s CBSR=%d", temp,
+               (temp & OHCI_CTRL_RWE) ? " RWE" : "",
+               (temp & OHCI_CTRL_RWC) ? " RWC" : "",
+               (temp & OHCI_CTRL_IR) ? " IR" : "",
+               hcfs2string (temp & OHCI_CTRL_HCFS),
+               (temp & OHCI_CTRL_BLE) ? " BLE" : "",
+               (temp & OHCI_CTRL_CLE) ? " CLE" : "",
+               (temp & OHCI_CTRL_IE) ? " IE" : "",
+               (temp & OHCI_CTRL_PLE) ? " PLE" : "",
+               temp & OHCI_CTRL_CBSR
+               );
+
+       temp = readl (&regs->cmdstatus);
+       dbg ("cmdstatus: 0x%08x SOC=%d%s%s%s%s", temp,
+               (temp & OHCI_SOC) >> 16,
+               (temp & OHCI_OCR) ? " OCR" : "",
+               (temp & OHCI_BLF) ? " BLF" : "",
+               (temp & OHCI_CLF) ? " CLF" : "",
+               (temp & OHCI_HCR) ? " HCR" : ""
+               );
+
+       ohci_dump_intr_mask ("intrstatus", readl (&regs->intrstatus));
+       ohci_dump_intr_mask ("intrenable", readl (&regs->intrenable));
+
+       maybe_print_eds ("ed_periodcurrent", readl (&regs->ed_periodcurrent));
+
+       maybe_print_eds ("ed_controlhead", readl (&regs->ed_controlhead));
+       maybe_print_eds ("ed_controlcurrent", readl (&regs->ed_controlcurrent));
+
+       maybe_print_eds ("ed_bulkhead", readl (&regs->ed_bulkhead));
+       maybe_print_eds ("ed_bulkcurrent", readl (&regs->ed_bulkcurrent));
+
+       maybe_print_eds ("donehead", readl (&regs->donehead));
+}
+
+static void ohci_dump_roothub (ohci_t *controller, int verbose)
+{
+       __u32                   temp, ndp, i;
+
+       temp = roothub_a (controller);
+       ndp = (temp & RH_A_NDP);
+
+       if (verbose) {
+               dbg ("roothub.a: %08x POTPGT=%d%s%s%s%s%s NDP=%d", temp,
+                       ((temp & RH_A_POTPGT) >> 24) & 0xff,
+                       (temp & RH_A_NOCP) ? " NOCP" : "",
+                       (temp & RH_A_OCPM) ? " OCPM" : "",
+                       (temp & RH_A_DT) ? " DT" : "",
+                       (temp & RH_A_NPS) ? " NPS" : "",
+                       (temp & RH_A_PSM) ? " PSM" : "",
+                       ndp
+                       );
+               temp = roothub_b (controller);
+               dbg ("roothub.b: %08x PPCM=%04x DR=%04x",
+                       temp,
+                       (temp & RH_B_PPCM) >> 16,
+                       (temp & RH_B_DR)
+                       );
+               temp = roothub_status (controller);
+               dbg ("roothub.status: %08x%s%s%s%s%s%s",
+                       temp,
+                       (temp & RH_HS_CRWE) ? " CRWE" : "",
+                       (temp & RH_HS_OCIC) ? " OCIC" : "",
+                       (temp & RH_HS_LPSC) ? " LPSC" : "",
+                       (temp & RH_HS_DRWE) ? " DRWE" : "",
+                       (temp & RH_HS_OCI) ? " OCI" : "",
+                       (temp & RH_HS_LPS) ? " LPS" : ""
+                       );
+       }
+
+       for (i = 0; i < ndp; i++) {
+               temp = roothub_portstatus (controller, i);
+               dbg ("roothub.portstatus [%d] = 0x%08x%s%s%s%s%s%s%s%s%s%s%s%s",
+                       i,
+                       temp,
+                       (temp & RH_PS_PRSC) ? " PRSC" : "",
+                       (temp & RH_PS_OCIC) ? " OCIC" : "",
+                       (temp & RH_PS_PSSC) ? " PSSC" : "",
+                       (temp & RH_PS_PESC) ? " PESC" : "",
+                       (temp & RH_PS_CSC) ? " CSC" : "",
+
+                       (temp & RH_PS_LSDA) ? " LSDA" : "",
+                       (temp & RH_PS_PPS) ? " PPS" : "",
+                       (temp & RH_PS_PRS) ? " PRS" : "",
+                       (temp & RH_PS_POCI) ? " POCI" : "",
+                       (temp & RH_PS_PSS) ? " PSS" : "",
+
+                       (temp & RH_PS_PES) ? " PES" : "",
+                       (temp & RH_PS_CCS) ? " CCS" : ""
+                       );
+       }
+}
+
+static void ohci_dump (ohci_t *controller, int verbose)
+{
+       dbg ("OHCI controller usb-%s state", controller->slot_name);
+
+       /* dumps some of the state we know about */
+       ohci_dump_status (controller);
+       if (verbose)
+               ep_print_int_eds (controller, "hcca");
+       dbg ("hcca frame #%04x", controller->hcca->frame_no);
+       ohci_dump_roothub (controller, 1);
+}
+
+
+#endif /* DEBUG */
+
+/*-------------------------------------------------------------------------*
+ * Interface functions (URB)
+ *-------------------------------------------------------------------------*/
+
+/* get a transfer request */
+
+int sohci_submit_job(struct usb_device *dev, unsigned long pipe, void *buffer,
+               int transfer_len, struct devrequest *setup, int interval)
+{
+       ohci_t *ohci;
+       ed_t * ed;
+       urb_priv_t *purb_priv;
+       int i, size = 0;
+
+       ohci = &gohci;
+
+       /* when controller's hung, permit only roothub cleanup attempts
+        * such as powering down ports */
+       if (ohci->disabled) {
+               err("sohci_submit_job: EPIPE");
+               return -1;
+       }
+
+       /* every endpoint has a ed, locate and fill it */
+       if (!(ed = ep_add_ed (dev, pipe))) {
+               err("sohci_submit_job: ENOMEM");
+               return -1;
+       }
+
+       /* for the private part of the URB we need the number of TDs (size) */
+       switch (usb_pipetype (pipe)) {
+               case PIPE_BULK: /* one TD for every 4096 Byte */
+                       size = (transfer_len - 1) / 4096 + 1;
+                       break;
+               case PIPE_CONTROL: /* 1 TD for setup, 1 for ACK and 1 for every 4096 B */
+                       size = (transfer_len == 0)? 2:
+                                               (transfer_len - 1) / 4096 + 3;
+                       break;
+       }
+
+       if (size >= (N_URB_TD - 1)) {
+               err("need %d TDs, only have %d", size, N_URB_TD);
+               return -1;
+       }
+       purb_priv = &urb_priv;
+       purb_priv->pipe = pipe;
+
+       /* fill the private part of the URB */
+       purb_priv->length = size;
+       purb_priv->ed = ed;
+       purb_priv->actual_length = 0;
+
+       /* allocate the TDs */
+       /* note that td[0] was allocated in ep_add_ed */
+       for (i = 0; i < size; i++) {
+               purb_priv->td[i] = td_alloc (dev);
+               if (!purb_priv->td[i]) {
+                       purb_priv->length = i;
+                       urb_free_priv (purb_priv);
+                       err("sohci_submit_job: ENOMEM");
+                       return -1;
+               }
+       }
+
+       if (ed->state == ED_NEW || (ed->state & ED_DEL)) {
+               urb_free_priv (purb_priv);
+               err("sohci_submit_job: EINVAL");
+               return -1;
+       }
+
+       /* link the ed into a chain if is not already */
+       if (ed->state != ED_OPER)
+               ep_link (ohci, ed);
+
+       /* fill the TDs and link it to the ed */
+       td_submit_job(dev, pipe, buffer, transfer_len, setup, purb_priv, interval);
+
+       return 0;
+}
+
+/*-------------------------------------------------------------------------*/
+
+#ifdef DEBUG
+/* tell us the current USB frame number */
+
+static int sohci_get_current_frame_number (struct usb_device *usb_dev)
+{
+       ohci_t *ohci = &gohci;
+
+       return m16_swap (ohci->hcca->frame_no);
+}
+#endif
+
+/*-------------------------------------------------------------------------*
+ * ED handling functions
+ *-------------------------------------------------------------------------*/
+
+/* link an ed into one of the HC chains */
+
+static int ep_link (ohci_t *ohci, ed_t *edi)
+{
+       volatile ed_t *ed = edi;
+
+       ed->state = ED_OPER;
+
+       switch (ed->type) {
+       case PIPE_CONTROL:
+               ed->hwNextED = 0;
+               if (ohci->ed_controltail == NULL) {
+                       writel ((long)ed, &ohci->regs->ed_controlhead);
+               } else {
+                       ohci->ed_controltail->hwNextED = m32_swap (ed);
+               }
+               ed->ed_prev = ohci->ed_controltail;
+               if (!ohci->ed_controltail && !ohci->ed_rm_list[0] &&
+                       !ohci->ed_rm_list[1] && !ohci->sleeping) {
+                       ohci->hc_control |= OHCI_CTRL_CLE;
+                       writel (ohci->hc_control, &ohci->regs->control);
+               }
+               ohci->ed_controltail = edi;
+               break;
+
+       case PIPE_BULK:
+               ed->hwNextED = 0;
+               if (ohci->ed_bulktail == NULL) {
+                       writel ((long)ed, &ohci->regs->ed_bulkhead);
+               } else {
+                       ohci->ed_bulktail->hwNextED = m32_swap (ed);
+               }
+               ed->ed_prev = ohci->ed_bulktail;
+               if (!ohci->ed_bulktail && !ohci->ed_rm_list[0] &&
+                       !ohci->ed_rm_list[1] && !ohci->sleeping) {
+                       ohci->hc_control |= OHCI_CTRL_BLE;
+                       writel (ohci->hc_control, &ohci->regs->control);
+               }
+               ohci->ed_bulktail = edi;
+               break;
+       }
+       return 0;
+}
+
+/*-------------------------------------------------------------------------*/
+
+/* unlink an ed from one of the HC chains.
+ * just the link to the ed is unlinked.
+ * the link from the ed still points to another operational ed or 0
+ * so the HC can eventually finish the processing of the unlinked ed */
+
+static int ep_unlink (ohci_t *ohci, ed_t *ed)
+{
+       ed->hwINFO |= m32_swap (OHCI_ED_SKIP);
+
+       switch (ed->type) {
+       case PIPE_CONTROL:
+               if (ed->ed_prev == NULL) {
+                       if (!ed->hwNextED) {
+                               ohci->hc_control &= ~OHCI_CTRL_CLE;
+                               writel (ohci->hc_control, &ohci->regs->control);
+                       }
+                       writel (m32_swap (*((__u32 *)&ed->hwNextED)), &ohci->regs->ed_controlhead);
+               } else {
+                       ed->ed_prev->hwNextED = ed->hwNextED;
+               }
+               if (ohci->ed_controltail == ed) {
+                       ohci->ed_controltail = ed->ed_prev;
+               } else {
+                       ((ed_t *)m32_swap (*((__u32 *)&ed->hwNextED)))->ed_prev = ed->ed_prev;
+               }
+               break;
+
+       case PIPE_BULK:
+               if (ed->ed_prev == NULL) {
+                       if (!ed->hwNextED) {
+                               ohci->hc_control &= ~OHCI_CTRL_BLE;
+                               writel (ohci->hc_control, &ohci->regs->control);
+                       }
+                       writel (m32_swap (*((__u32 *)&ed->hwNextED)), &ohci->regs->ed_bulkhead);
+               } else {
+                       ed->ed_prev->hwNextED = ed->hwNextED;
+               }
+               if (ohci->ed_bulktail == ed) {
+                       ohci->ed_bulktail = ed->ed_prev;
+               } else {
+                       ((ed_t *)m32_swap (*((__u32 *)&ed->hwNextED)))->ed_prev = ed->ed_prev;
+               }
+               break;
+       }
+       ed->state = ED_UNLINK;
+       return 0;
+}
+
+
+/*-------------------------------------------------------------------------*/
+
+/* add/reinit an endpoint; this should be done once at the usb_set_configuration command,
+ * but the USB stack is a little bit stateless so we do it at every transaction
+ * if the state of the ed is ED_NEW then a dummy td is added and the state is changed to ED_UNLINK
+ * in all other cases the state is left unchanged
+ * the ed info fields are setted anyway even though most of them should not change */
+
+static ed_t * ep_add_ed (struct usb_device *usb_dev, unsigned long pipe)
+{
+       td_t *td;
+       ed_t *ed_ret;
+       volatile ed_t *ed;
+
+       ed = ed_ret = &ohci_dev.ed[(usb_pipeendpoint (pipe) << 1) |
+                       (usb_pipecontrol (pipe)? 0: usb_pipeout (pipe))];
+
+       if ((ed->state & ED_DEL) || (ed->state & ED_URB_DEL)) {
+               err("ep_add_ed: pending delete");
+               /* pending delete request */
+               return NULL;
+       }
+
+       if (ed->state == ED_NEW) {
+               ed->hwINFO = m32_swap (OHCI_ED_SKIP); /* skip ed */
+               /* dummy td; end of td list for ed */
+               td = td_alloc (usb_dev);
+               ed->hwTailP = m32_swap (td);
+               ed->hwHeadP = ed->hwTailP;
+               ed->state = ED_UNLINK;
+               ed->type = usb_pipetype (pipe);
+               ohci_dev.ed_cnt++;
+       }
+
+       ed->hwINFO = m32_swap (usb_pipedevice (pipe)
+                       | usb_pipeendpoint (pipe) << 7
+                       | (usb_pipeisoc (pipe)? 0x8000: 0)
+                       | (usb_pipecontrol (pipe)? 0: (usb_pipeout (pipe)? 0x800: 0x1000))
+                       | (usb_dev->speed == USB_SPEED_LOW) << 13
+                       | usb_maxpacket (usb_dev, pipe) << 16);
+
+       return ed_ret;
+}
+
+/*-------------------------------------------------------------------------*
+ * TD handling functions
+ *-------------------------------------------------------------------------*/
+
+/* enqueue next TD for this URB (OHCI spec 5.2.8.2) */
+
+static void td_fill (ohci_t *ohci, unsigned int info,
+       void *data, int len,
+       struct usb_device *dev, int index, urb_priv_t *urb_priv)
+{
+       volatile td_t  *td, *td_pt;
+#ifdef OHCI_FILL_TRACE
+       int i;
+#endif
+
+       if (index > urb_priv->length) {
+               err("index > length");
+               return;
+       }
+       /* use this td as the next dummy */
+       td_pt = urb_priv->td [index];
+       td_pt->hwNextTD = 0;
+
+       /* fill the old dummy TD */
+       td = urb_priv->td [index] = (td_t *)(m32_swap (urb_priv->ed->hwTailP) & ~0xf);
+
+       td->ed = urb_priv->ed;
+       td->next_dl_td = NULL;
+       td->index = index;
+       td->data = (__u32)data;
+#ifdef OHCI_FILL_TRACE
+       if (1 || (usb_pipebulk(urb_priv->pipe) &&
+                               usb_pipeout(urb_priv->pipe))) {
+               for (i = 0; i < len; i++)
+               printf("td->data[%d] %#2x\n",i, ((unsigned char *)(td->data+0x80000000))[i]);
+       }
+#endif
+       if (!len)
+               data = 0;
+
+       td->hwINFO = m32_swap (info);
+       td->hwCBP = m32_swap (data);
+       if (data)
+               td->hwBE = m32_swap (data + len - 1);
+       else
+               td->hwBE = 0;
+       td->hwNextTD = m32_swap (td_pt);
+       td->hwPSW [0] = m16_swap (((__u32)data & 0x0FFF) | 0xE000);
+
+       /* append to queue */
+       td->ed->hwTailP = td->hwNextTD;
+}
+
+/*-------------------------------------------------------------------------*/
+
+/* prepare all TDs of a transfer */
+
+#define kseg_to_phys(x)          ((void *)((__u32)(x) - 0x80000000))
+
+static void td_submit_job (struct usb_device *dev, unsigned long pipe, void *buffer,
+       int transfer_len, struct devrequest *setup, urb_priv_t *urb, int interval)
+{
+       ohci_t *ohci = &gohci;
+       int data_len = transfer_len;
+       void *data;
+       int cnt = 0;
+       __u32 info = 0;
+       unsigned int toggle = 0;
+
+       /* OHCI handles the DATA-toggles itself, we just use the USB-toggle bits for reseting */
+       if(usb_gettoggle(dev, usb_pipeendpoint(pipe), usb_pipeout(pipe))) {
+               toggle = TD_T_TOGGLE;
+       } else {
+               toggle = TD_T_DATA0;
+               usb_settoggle(dev, usb_pipeendpoint(pipe), usb_pipeout(pipe), 1);
+       }
+       urb->td_cnt = 0;
+       if (data_len)
+               data = kseg_to_phys(buffer);
+       else
+               data = 0;
+
+       switch (usb_pipetype (pipe)) {
+       case PIPE_BULK:
+               info = usb_pipeout (pipe)?
+                       TD_CC | TD_DP_OUT : TD_CC | TD_DP_IN ;
+               while(data_len > 4096) {
+                       td_fill (ohci, info | (cnt? TD_T_TOGGLE:toggle), data, 4096, dev, cnt, urb);
+                       data += 4096; data_len -= 4096; cnt++;
+               }
+               info = usb_pipeout (pipe)?
+                       TD_CC | TD_DP_OUT : TD_CC | TD_R | TD_DP_IN ;
+               td_fill (ohci, info | (cnt? TD_T_TOGGLE:toggle), data, data_len, dev, cnt, urb);
+               cnt++;
+
+               if (!ohci->sleeping)
+                       writel (OHCI_BLF, &ohci->regs->cmdstatus); /* start bulk list */
+               break;
+
+       case PIPE_CONTROL:
+               info = TD_CC | TD_DP_SETUP | TD_T_DATA0;
+               td_fill (ohci, info, kseg_to_phys(setup), 8, dev, cnt++, urb);
+               if (data_len > 0) {
+                       info = usb_pipeout (pipe)?
+                               TD_CC | TD_R | TD_DP_OUT | TD_T_DATA1 : TD_CC | TD_R | TD_DP_IN | TD_T_DATA1;
+                       /* NOTE:  mishandles transfers >8K, some >4K */
+                       td_fill (ohci, info, data, data_len, dev, cnt++, urb);
+               }
+               info = usb_pipeout (pipe)?
+                       TD_CC | TD_DP_IN | TD_T_DATA1: TD_CC | TD_DP_OUT | TD_T_DATA1;
+               td_fill (ohci, info, data, 0, dev, cnt++, urb);
+               if (!ohci->sleeping)
+                       writel (OHCI_CLF, &ohci->regs->cmdstatus); /* start Control list */
+               break;
+       }
+       if (urb->length != cnt)
+               dbg("TD LENGTH %d != CNT %d", urb->length, cnt);
+}
+
+/*-------------------------------------------------------------------------*
+ * Done List handling functions
+ *-------------------------------------------------------------------------*/
+
+
+/* calculate the transfer length and update the urb */
+
+static void dl_transfer_length(td_t * td)
+{
+       __u32 tdINFO, tdBE, tdCBP;
+       urb_priv_t *lurb_priv = &urb_priv;
+
+       tdINFO = m32_swap (td->hwINFO);
+       tdBE   = m32_swap (td->hwBE);
+       tdCBP  = m32_swap (td->hwCBP);
+
+
+       if (!(usb_pipecontrol(lurb_priv->pipe) &&
+           ((td->index == 0) || (td->index == lurb_priv->length - 1)))) {
+               if (tdBE != 0) {
+                       if (td->hwCBP == 0)
+                               lurb_priv->actual_length += tdBE - td->data + 1;
+                       else
+                               lurb_priv->actual_length += tdCBP - td->data;
+               }
+       }
+}
+
+/*-------------------------------------------------------------------------*/
+
+/* replies to the request have to be on a FIFO basis so
+ * we reverse the reversed done-list */
+
+static td_t * dl_reverse_done_list (ohci_t *ohci)
+{
+       __u32 td_list_hc;
+       td_t *td_rev = NULL;
+       td_t *td_list = NULL;
+       urb_priv_t *lurb_priv = NULL;
+
+       td_list_hc = m32_swap (ohci->hcca->done_head) & 0xfffffff0;
+       ohci->hcca->done_head = 0;
+
+       while (td_list_hc) {
+               td_list = (td_t *)td_list_hc;
+
+               if (TD_CC_GET (m32_swap (td_list->hwINFO))) {
+                       lurb_priv = &urb_priv;
+                       dbg(" USB-error/status: %x : %p",
+                                       TD_CC_GET (m32_swap (td_list->hwINFO)), td_list);
+                       if (td_list->ed->hwHeadP & m32_swap (0x1)) {
+                               if (lurb_priv && ((td_list->index + 1) < lurb_priv->length)) {
+                                       td_list->ed->hwHeadP =
+                                               (lurb_priv->td[lurb_priv->length - 1]->hwNextTD & m32_swap (0xfffffff0)) |
+                                                                       (td_list->ed->hwHeadP & m32_swap (0x2));
+                                       lurb_priv->td_cnt += lurb_priv->length - td_list->index - 1;
+                               } else
+                                       td_list->ed->hwHeadP &= m32_swap (0xfffffff2);
+                       }
+               }
+
+               td_list->next_dl_td = td_rev;
+               td_rev = td_list;
+               td_list_hc = m32_swap (td_list->hwNextTD) & 0xfffffff0;
+       }
+       return td_list;
+}
+
+/*-------------------------------------------------------------------------*/
+
+/* td done list */
+static int dl_done_list (ohci_t *ohci, td_t *td_list)
+{
+       td_t *td_list_next = NULL;
+       ed_t *ed;
+       int cc = 0;
+       int stat = 0;
+       /* urb_t *urb; */
+       urb_priv_t *lurb_priv;
+       __u32 tdINFO, edHeadP, edTailP;
+
+       while (td_list) {
+               td_list_next = td_list->next_dl_td;
+
+               lurb_priv = &urb_priv;
+               tdINFO = m32_swap (td_list->hwINFO);
+
+               ed = td_list->ed;
+
+               dl_transfer_length(td_list);
+
+               /* error code of transfer */
+               cc = TD_CC_GET (tdINFO);
+               if (cc != 0) {
+                       dbg("ConditionCode %#x", cc);
+                       stat = cc_to_error[cc];
+               }
+
+               if (ed->state != ED_NEW) {
+                       edHeadP = m32_swap (ed->hwHeadP) & 0xfffffff0;
+                       edTailP = m32_swap (ed->hwTailP);
+
+                       /* unlink eds if they are not busy */
+                       if ((edHeadP == edTailP) && (ed->state == ED_OPER))
+                               ep_unlink (ohci, ed);
+               }
+
+               td_list = td_list_next;
+       }
+       return stat;
+}
+
+/*-------------------------------------------------------------------------*
+ * Virtual Root Hub
+ *-------------------------------------------------------------------------*/
+
+#include <usbroothubdes.h>
+
+/* Hub class-specific descriptor is constructed dynamically */
+
+
+/*-------------------------------------------------------------------------*/
+
+#define OK(x)                  len = (x); break
+#ifdef DEBUG
+#define WR_RH_STAT(x)          {info("WR:status %#8x", (x));writel((x), &gohci.regs->roothub.status);}
+#define WR_RH_PORTSTAT(x)      {info("WR:portstatus[%d] %#8x", wIndex-1, (x));writel((x), &gohci.regs->roothub.portstatus[wIndex-1]);}
+#else
+#define WR_RH_STAT(x)          writel((x), &gohci.regs->roothub.status)
+#define WR_RH_PORTSTAT(x)      writel((x), &gohci.regs->roothub.portstatus[wIndex-1])
+#endif
+#define RD_RH_STAT             roothub_status(&gohci)
+#define RD_RH_PORTSTAT         roothub_portstatus(&gohci,wIndex-1)
+
+/* request to virtual root hub */
+
+int rh_check_port_status(ohci_t *controller)
+{
+       __u32 temp, ndp, i;
+       int res;
+
+       res = -1;
+       temp = roothub_a (controller);
+       ndp = (temp & RH_A_NDP);
+       for (i = 0; i < ndp; i++) {
+               temp = roothub_portstatus (controller, i);
+               /* check for a device disconnect */
+               if (((temp & (RH_PS_PESC | RH_PS_CSC)) ==
+                       (RH_PS_PESC | RH_PS_CSC)) &&
+                       ((temp & RH_PS_CCS) == 0)) {
+                       res = i;
+                       break;
+               }
+       }
+       return res;
+}
+
+static int ohci_submit_rh_msg(struct usb_device *dev, unsigned long pipe,
+               void *buffer, int transfer_len, struct devrequest *cmd)
+{
+       void * data = buffer;
+       int leni = transfer_len;
+       int len = 0;
+       int stat = 0;
+       __u32 datab[4];
+       __u8 *data_buf = (__u8 *)datab;
+       __u16 bmRType_bReq;
+       __u16 wValue;
+       __u16 wIndex;
+       __u16 wLength;
+
+#ifdef DEBUG
+urb_priv.actual_length = 0;
+pkt_print(dev, pipe, buffer, transfer_len, cmd, "SUB(rh)", usb_pipein(pipe));
+#else
+       mdelay(1);
+#endif
+       if (usb_pipeint(pipe)) {
+               info("Root-Hub submit IRQ: NOT implemented");
+               return 0;
+       }
+
+       bmRType_bReq  = cmd->requesttype | (cmd->request << 8);
+       wValue        = m16_swap (cmd->value);
+       wIndex        = m16_swap (cmd->index);
+       wLength       = m16_swap (cmd->length);
+
+       info("Root-Hub: adr: %2x cmd(%1x): %08x %04x %04x %04x",
+               dev->devnum, 8, bmRType_bReq, wValue, wIndex, wLength);
+
+       switch (bmRType_bReq) {
+       /* Request Destination:
+          without flags: Device,
+          RH_INTERFACE: interface,
+          RH_ENDPOINT: endpoint,
+          RH_CLASS means HUB here,
+          RH_OTHER | RH_CLASS  almost ever means HUB_PORT here
+       */
+
+       case RH_GET_STATUS:
+                       *(__u16 *) data_buf = m16_swap (1); OK (2);
+       case RH_GET_STATUS | RH_INTERFACE:
+                       *(__u16 *) data_buf = m16_swap (0); OK (2);
+       case RH_GET_STATUS | RH_ENDPOINT:
+                       *(__u16 *) data_buf = m16_swap (0); OK (2);
+       case RH_GET_STATUS | RH_CLASS:
+                       *(__u32 *) data_buf = m32_swap (
+                               RD_RH_STAT & ~(RH_HS_CRWE | RH_HS_DRWE));
+                       OK (4);
+       case RH_GET_STATUS | RH_OTHER | RH_CLASS:
+                       *(__u32 *) data_buf = m32_swap (RD_RH_PORTSTAT); OK (4);
+
+       case RH_CLEAR_FEATURE | RH_ENDPOINT:
+               switch (wValue) {
+                       case (RH_ENDPOINT_STALL): OK (0);
+               }
+               break;
+
+       case RH_CLEAR_FEATURE | RH_CLASS:
+               switch (wValue) {
+                       case RH_C_HUB_LOCAL_POWER:
+                               OK(0);
+                       case (RH_C_HUB_OVER_CURRENT):
+                                       WR_RH_STAT(RH_HS_OCIC); OK (0);
+               }
+               break;
+
+       case RH_CLEAR_FEATURE | RH_OTHER | RH_CLASS:
+               switch (wValue) {
+                       case (RH_PORT_ENABLE):
+                                       WR_RH_PORTSTAT (RH_PS_CCS ); OK (0);
+                       case (RH_PORT_SUSPEND):
+                                       WR_RH_PORTSTAT (RH_PS_POCI); OK (0);
+                       case (RH_PORT_POWER):
+                                       WR_RH_PORTSTAT (RH_PS_LSDA); OK (0);
+                       case (RH_C_PORT_CONNECTION):
+                                       WR_RH_PORTSTAT (RH_PS_CSC ); OK (0);
+                       case (RH_C_PORT_ENABLE):
+                                       WR_RH_PORTSTAT (RH_PS_PESC); OK (0);
+                       case (RH_C_PORT_SUSPEND):
+                                       WR_RH_PORTSTAT (RH_PS_PSSC); OK (0);
+                       case (RH_C_PORT_OVER_CURRENT):
+                                       WR_RH_PORTSTAT (RH_PS_OCIC); OK (0);
+                       case (RH_C_PORT_RESET):
+                                       WR_RH_PORTSTAT (RH_PS_PRSC); OK (0);
+               }
+               break;
+
+       case RH_SET_FEATURE | RH_OTHER | RH_CLASS:
+               switch (wValue) {
+                       case (RH_PORT_SUSPEND):
+                                       WR_RH_PORTSTAT (RH_PS_PSS ); OK (0);
+                       case (RH_PORT_RESET): /* BUG IN HUP CODE *********/
+                                       if (RD_RH_PORTSTAT & RH_PS_CCS)
+                                           WR_RH_PORTSTAT (RH_PS_PRS);
+                                       OK (0);
+                       case (RH_PORT_POWER):
+                                       WR_RH_PORTSTAT (RH_PS_PPS ); OK (0);
+                       case (RH_PORT_ENABLE): /* BUG IN HUP CODE *********/
+                                       if (RD_RH_PORTSTAT & RH_PS_CCS)
+                                           WR_RH_PORTSTAT (RH_PS_PES );
+                                       OK (0);
+               }
+               break;
+
+       case RH_SET_ADDRESS: gohci.rh.devnum = wValue; OK(0);
+
+       case RH_GET_DESCRIPTOR:
+               switch ((wValue & 0xff00) >> 8) {
+                       case (0x01): /* device descriptor */
+                               len = min_t(unsigned int,
+                                         leni,
+                                         min_t(unsigned int,
+                                             sizeof (root_hub_dev_des),
+                                             wLength));
+                               data_buf = root_hub_dev_des; OK(len);
+                       case (0x02): /* configuration descriptor */
+                               len = min_t(unsigned int,
+                                         leni,
+                                         min_t(unsigned int,
+                                             sizeof (root_hub_config_des),
+                                             wLength));
+                               data_buf = root_hub_config_des; OK(len);
+                       case (0x03): /* string descriptors */
+                               if(wValue==0x0300) {
+                                       len = min_t(unsigned int,
+                                                 leni,
+                                                 min_t(unsigned int,
+                                                     sizeof (root_hub_str_index0),
+                                                     wLength));
+                                       data_buf = root_hub_str_index0;
+                                       OK(len);
+                               }
+                               if(wValue==0x0301) {
+                                       len = min_t(unsigned int,
+                                                 leni,
+                                                 min_t(unsigned int,
+                                                     sizeof (root_hub_str_index1),
+                                                     wLength));
+                                       data_buf = root_hub_str_index1;
+                                       OK(len);
+                       }
+                       default:
+                               stat = USB_ST_STALLED;
+               }
+               break;
+
+       case RH_GET_DESCRIPTOR | RH_CLASS:
+           {
+                   __u32 temp = roothub_a (&gohci);
+
+                   data_buf [0] = 9;           /* min length; */
+                   data_buf [1] = 0x29;
+                   data_buf [2] = temp & RH_A_NDP;
+                   data_buf [3] = 0;
+                   if (temp & RH_A_PSM)        /* per-port power switching? */
+                       data_buf [3] |= 0x1;
+                   if (temp & RH_A_NOCP)       /* no overcurrent reporting? */
+                       data_buf [3] |= 0x10;
+                   else if (temp & RH_A_OCPM)  /* per-port overcurrent reporting? */
+                       data_buf [3] |= 0x8;
+
+                   /* corresponds to data_buf[4-7] */
+                   datab [1] = 0;
+                   data_buf [5] = (temp & RH_A_POTPGT) >> 24;
+                   temp = roothub_b (&gohci);
+                   data_buf [7] = temp & RH_B_DR;
+                   if (data_buf [2] < 7) {
+                       data_buf [8] = 0xff;
+                   } else {
+                       data_buf [0] += 2;
+                       data_buf [8] = (temp & RH_B_DR) >> 8;
+                       data_buf [10] = data_buf [9] = 0xff;
+                   }
+
+                   len = min_t(unsigned int, leni,
+                             min_t(unsigned int, data_buf [0], wLength));
+                   OK (len);
+               }
+
+       case RH_GET_CONFIGURATION:      *(__u8 *) data_buf = 0x01; OK (1);
+
+       case RH_SET_CONFIGURATION:      WR_RH_STAT (0x10000); OK (0);
+
+       default:
+               dbg ("unsupported root hub command");
+               stat = USB_ST_STALLED;
+       }
+
+#ifdef DEBUG
+       ohci_dump_roothub (&gohci, 1);
+#else
+       mdelay(1);
+#endif
+
+       len = min_t(int, len, leni);
+       if (data != data_buf)
+           memcpy (data, data_buf, len);
+       dev->act_len = len;
+       dev->status = stat;
+
+#ifdef DEBUG
+       if (transfer_len)
+               urb_priv.actual_length = transfer_len;
+       pkt_print(dev, pipe, buffer, transfer_len, cmd, "RET(rh)", 0/*usb_pipein(pipe)*/);
+#else
+       mdelay(1);
+#endif
+
+       return stat;
+}
+
+/*-------------------------------------------------------------------------*/
+
+/* common code for handling submit messages - used for all but root hub */
+/* accesses. */
+int submit_common_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
+               int transfer_len, struct devrequest *setup, int interval)
+{
+       int stat = 0;
+       int maxsize = usb_maxpacket(dev, pipe);
+       int timeout;
+
+       /* device pulled? Shortcut the action. */
+       if (devgone == dev) {
+               dev->status = USB_ST_CRC_ERR;
+               return 0;
+       }
+
+#ifdef DEBUG
+       urb_priv.actual_length = 0;
+       pkt_print(dev, pipe, buffer, transfer_len, setup, "SUB", usb_pipein(pipe));
+#else
+       mdelay(1);
+#endif
+       if (!maxsize) {
+               err("submit_common_message: pipesize for pipe %lx is zero",
+                       pipe);
+               return -1;
+       }
+
+       if (sohci_submit_job(dev, pipe, buffer, transfer_len, setup, interval) < 0) {
+               err("sohci_submit_job failed");
+               return -1;
+       }
+
+       mdelay(10);
+       /* ohci_dump_status(&gohci); */
+
+       /* allow more time for a BULK device to react - some are slow */
+#define BULK_TO         5000   /* timeout in milliseconds */
+       if (usb_pipebulk(pipe))
+               timeout = BULK_TO;
+       else
+               timeout = 100;
+
+       timeout *= 4;
+       /* wait for it to complete */
+       for (;;) {
+               /* check whether the controller is done */
+               stat = hc_interrupt();
+               if (stat < 0) {
+                       stat = USB_ST_CRC_ERR;
+                       break;
+               }
+               if (stat >= 0 && stat != 0xff) {
+                       /* 0xff is returned for an SF-interrupt */
+                       break;
+               }
+               if (--timeout) {
+                       udelay(250); /* mdelay(1); */
+               } else {
+                       err("CTL:TIMEOUT ");
+                       stat = USB_ST_CRC_ERR;
+                       break;
+               }
+       }
+       /* we got an Root Hub Status Change interrupt */
+       if (got_rhsc) {
+#ifdef DEBUG
+               ohci_dump_roothub (&gohci, 1);
+#endif
+               got_rhsc = 0;
+               /* abuse timeout */
+               timeout = rh_check_port_status(&gohci);
+               if (timeout >= 0) {
+#if 0 /* this does nothing useful, but leave it here in case that changes */
+                       /* the called routine adds 1 to the passed value */
+                       usb_hub_port_connect_change(gohci.rh.dev, timeout - 1);
+#endif
+                       /*
+                        * XXX
+                        * This is potentially dangerous because it assumes
+                        * that only one device is ever plugged in!
+                        */
+                       devgone = dev;
+               }
+       }
+
+       dev->status = stat;
+       dev->act_len = transfer_len;
+
+#ifdef DEBUG
+       pkt_print(dev, pipe, buffer, transfer_len, setup, "RET(ctlr)", usb_pipein(pipe));
+#else
+       mdelay(1);
+#endif
+
+       /* free TDs in urb_priv */
+       urb_free_priv (&urb_priv);
+       return 0;
+}
+
+/* submit routines called from usb.c */
+int submit_bulk_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
+               int transfer_len)
+{
+       info("submit_bulk_msg");
+       return submit_common_msg(dev, pipe, buffer, transfer_len, NULL, 0);
+}
+
+int submit_control_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
+               int transfer_len, struct devrequest *setup)
+{
+       int maxsize = usb_maxpacket(dev, pipe);
+
+       info("submit_control_msg");
+#ifdef DEBUG
+       urb_priv.actual_length = 0;
+       pkt_print(dev, pipe, buffer, transfer_len, setup, "SUB", usb_pipein(pipe));
+#else
+       mdelay(1);
+#endif
+       if (!maxsize) {
+               err("submit_control_message: pipesize for pipe %lx is zero",
+                       pipe);
+               return -1;
+       }
+       if (((pipe >> 8) & 0x7f) == gohci.rh.devnum) {
+               gohci.rh.dev = dev;
+               /* root hub - redirect */
+               return ohci_submit_rh_msg(dev, pipe, buffer, transfer_len,
+                       setup);
+       }
+
+       return submit_common_msg(dev, pipe, buffer, transfer_len, setup, 0);
+}
+
+int submit_int_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
+               int transfer_len, int interval)
+{
+       info("submit_int_msg");
+       return -1;
+}
+
+/*-------------------------------------------------------------------------*
+ * HC functions
+ *-------------------------------------------------------------------------*/
+
+/* reset the HC and BUS */
+
+static int hc_reset (ohci_t *ohci)
+{
+       int timeout = 30;
+       int smm_timeout = 50; /* 0,5 sec */
+
+       if (readl (&ohci->regs->control) & OHCI_CTRL_IR) { /* SMM owns the HC */
+               writel (OHCI_OCR, &ohci->regs->cmdstatus); /* request ownership */
+               info("USB HC TakeOver from SMM");
+               while (readl (&ohci->regs->control) & OHCI_CTRL_IR) {
+                       mdelay (10);
+                       if (--smm_timeout == 0) {
+                               err("USB HC TakeOver failed!");
+                               return -1;
+                       }
+               }
+       }
+
+       /* Disable HC interrupts */
+       writel (OHCI_INTR_MIE, &ohci->regs->intrdisable);
+
+       dbg("USB HC reset_hc usb-%s: ctrl = 0x%X ;",
+               ohci->slot_name,
+               readl (&ohci->regs->control));
+
+       /* Reset USB (needed by some controllers) */
+       writel (0, &ohci->regs->control);
+
+       /* HC Reset requires max 10 us delay */
+       writel (OHCI_HCR,  &ohci->regs->cmdstatus);
+       while ((readl (&ohci->regs->cmdstatus) & OHCI_HCR) != 0) {
+               if (--timeout == 0) {
+                       err("USB HC reset timed out!");
+                       return -1;
+               }
+               udelay (1);
+       }
+       return 0;
+}
+
+/*-------------------------------------------------------------------------*/
+
+/* Start an OHCI controller, set the BUS operational
+ * enable interrupts
+ * connect the virtual root hub */
+
+static int hc_start (ohci_t * ohci)
+{
+       __u32 mask;
+       unsigned int fminterval;
+
+       ohci->disabled = 1;
+
+       /* Tell the controller where the control and bulk lists are
+        * The lists are empty now. */
+
+       writel (0, &ohci->regs->ed_controlhead);
+       writel (0, &ohci->regs->ed_bulkhead);
+
+       writel ((__u32)ohci->hcca, &ohci->regs->hcca); /* a reset clears this */
+
+       fminterval = 0x2edf;
+       writel ((fminterval * 9) / 10, &ohci->regs->periodicstart);
+       fminterval |= ((((fminterval - 210) * 6) / 7) << 16);
+       writel (fminterval, &ohci->regs->fminterval);
+       writel (0x628, &ohci->regs->lsthresh);
+
+       /* start controller operations */
+       ohci->hc_control = OHCI_CONTROL_INIT | OHCI_USB_OPER;
+       ohci->disabled = 0;
+       writel (ohci->hc_control, &ohci->regs->control);
+
+       /* disable all interrupts */
+       mask = (OHCI_INTR_SO | OHCI_INTR_WDH | OHCI_INTR_SF | OHCI_INTR_RD |
+                       OHCI_INTR_UE | OHCI_INTR_FNO | OHCI_INTR_RHSC |
+                       OHCI_INTR_OC | OHCI_INTR_MIE);
+       writel (mask, &ohci->regs->intrdisable);
+       /* clear all interrupts */
+       mask &= ~OHCI_INTR_MIE;
+       writel (mask, &ohci->regs->intrstatus);
+       /* Choose the interrupts we care about now  - but w/o MIE */
+       mask = OHCI_INTR_RHSC | OHCI_INTR_UE | OHCI_INTR_WDH | OHCI_INTR_SO;
+       writel (mask, &ohci->regs->intrenable);
+
+#ifdef OHCI_USE_NPS
+       /* required for AMD-756 and some Mac platforms */
+       writel ((roothub_a (ohci) | RH_A_NPS) & ~RH_A_PSM,
+               &ohci->regs->roothub.a);
+       writel (RH_HS_LPSC, &ohci->regs->roothub.status);
+#endif /* OHCI_USE_NPS */
+
+       /* POTPGT delay is bits 24-31, in 2 ms units. */
+       mdelay ((roothub_a (ohci) >> 23) & 0x1fe);
+
+       /* connect the virtual root hub */
+       ohci->rh.devnum = 0;
+
+       return 0;
+}
+
+/*-------------------------------------------------------------------------*/
+
+/* an interrupt happens */
+
+static int
+hc_interrupt (void)
+{
+       ohci_t *ohci = &gohci;
+       struct ohci_regs *regs = ohci->regs;
+       int ints;
+       int stat = -1;
+
+       if ((ohci->hcca->done_head != 0) && !(m32_swap (ohci->hcca->done_head) & 0x01)) {
+               ints =  OHCI_INTR_WDH;
+       } else {
+               ints = readl (&regs->intrstatus);
+       }
+
+       /* dbg("Interrupt: %x frame: %x", ints, le16_to_cpu (ohci->hcca->frame_no)); */
+
+       if (ints & OHCI_INTR_RHSC) {
+               got_rhsc = 1;
+       }
+
+       if (ints & OHCI_INTR_UE) {
+               ohci->disabled++;
+               err ("OHCI Unrecoverable Error, controller usb-%s disabled",
+                       ohci->slot_name);
+               /* e.g. due to PCI Master/Target Abort */
+
+#ifdef DEBUG
+               ohci_dump (ohci, 1);
+#else
+       mdelay(1);
+#endif
+               /* FIXME: be optimistic, hope that bug won't repeat often. */
+               /* Make some non-interrupt context restart the controller. */
+               /* Count and limit the retries though; either hardware or */
+               /* software errors can go forever... */
+               hc_reset (ohci);
+               return -1;
+       }
+
+       if (ints & OHCI_INTR_WDH) {
+               mdelay(1);
+               writel (OHCI_INTR_WDH, &regs->intrdisable);
+               stat = dl_done_list (&gohci, dl_reverse_done_list (&gohci));
+               writel (OHCI_INTR_WDH, &regs->intrenable);
+       }
+
+       if (ints & OHCI_INTR_SO) {
+               dbg("USB Schedule overrun\n");
+               writel (OHCI_INTR_SO, &regs->intrenable);
+               stat = -1;
+       }
+
+       /* FIXME:  this assumes SOF (1/ms) interrupts don't get lost... */
+       if (ints & OHCI_INTR_SF) {
+               unsigned int frame = m16_swap (ohci->hcca->frame_no) & 1;
+               mdelay(1);
+               writel (OHCI_INTR_SF, &regs->intrdisable);
+               if (ohci->ed_rm_list[frame] != NULL)
+                       writel (OHCI_INTR_SF, &regs->intrenable);
+               stat = 0xff;
+       }
+
+       writel (ints, &regs->intrstatus);
+       return stat;
+}
+
+/*-------------------------------------------------------------------------*/
+
+/*-------------------------------------------------------------------------*/
+
+/* De-allocate all resources.. */
+
+static void hc_release_ohci (ohci_t *ohci)
+{
+       dbg ("USB HC release ohci usb-%s", ohci->slot_name);
+
+       if (!ohci->disabled)
+               hc_reset (ohci);
+}
+
+/*-------------------------------------------------------------------------*/
+
+#define __read_32bit_c0_register(source, sel)                          \
+({ int __res;                                                          \
+       if (sel == 0)                                                   \
+               __asm__ __volatile__(                                   \
+                       "mfc0\t%0, " #source "\n\t"                     \
+                       : "=r" (__res));                                \
+       else                                                            \
+               __asm__ __volatile__(                                   \
+                       ".set\tmips32\n\t"                              \
+                       "mfc0\t%0, " #source ", " #sel "\n\t"           \
+                       ".set\tmips0\n\t"                               \
+                       : "=r" (__res));                                \
+       __res;                                                          \
+})
+
+#define read_c0_prid()         __read_32bit_c0_register($15, 0)
+
+/*
+ * low level initalisation routine, called from usb.c
+ */
+static char ohci_inited = 0;
+
+int usb_lowlevel_init(int index, enum usb_init_type init, void **controller)
+{
+       u32 pin_func;
+       u32 sys_freqctrl, sys_clksrc;
+       u32 prid = read_c0_prid();
+
+       dbg("in usb_lowlevel_init\n");
+
+       /* zero and disable FREQ2 */
+       sys_freqctrl = au_readl(SYS_FREQCTRL0);
+       sys_freqctrl &= ~0xFFF00000;
+       au_writel(sys_freqctrl, SYS_FREQCTRL0);
+
+       /* zero and disable USBH/USBD clocks */
+       sys_clksrc = au_readl(SYS_CLKSRC);
+       sys_clksrc &= ~0x00007FE0;
+       au_writel(sys_clksrc, SYS_CLKSRC);
+
+       sys_freqctrl = au_readl(SYS_FREQCTRL0);
+       sys_freqctrl &= ~0xFFF00000;
+
+       sys_clksrc = au_readl(SYS_CLKSRC);
+       sys_clksrc &= ~0x00007FE0;
+
+       switch (prid & 0x000000FF) {
+       case 0x00: /* DA */
+       case 0x01: /* HA */
+       case 0x02: /* HB */
+               /* CPU core freq to 48MHz to slow it way down... */
+               au_writel(4, SYS_CPUPLL);
+
+               /*
+                * Setup 48MHz FREQ2 from CPUPLL for USB Host
+                */
+               /* FRDIV2=3 -> div by 8 of 384MHz -> 48MHz */
+               sys_freqctrl |= ((3<<22) | (1<<21) | (0<<20));
+               au_writel(sys_freqctrl, SYS_FREQCTRL0);
+
+               /* CPU core freq to 384MHz */
+               au_writel(0x20, SYS_CPUPLL);
+
+               printf("Au1000: 48MHz OHCI workaround enabled\n");
+               break;
+
+       default:  /* HC and newer */
+               /* FREQ2 = aux/2 = 48 MHz */
+               sys_freqctrl |= ((0<<22) | (1<<21) | (1<<20));
+               au_writel(sys_freqctrl, SYS_FREQCTRL0);
+               break;
+       }
+
+       /*
+        * Route 48MHz FREQ2 into USB Host and/or Device
+        */
+       sys_clksrc |= ((4<<12) | (0<<11) | (0<<10));
+       au_writel(sys_clksrc, SYS_CLKSRC);
+
+       /* configure pins GPIO[14:9] as GPIO */
+       pin_func = au_readl(SYS_PINFUNC) & (u32)(~0x8080);
+
+       au_writel(pin_func, SYS_PINFUNC);
+       au_writel(0x2800, SYS_TRIOUTCLR);
+       au_writel(0x0030, SYS_OUTPUTCLR);
+
+       dbg("OHCI board setup complete\n");
+
+       /* enable host controller */
+       au_writel(USBH_ENABLE_CE, USB_HOST_CONFIG);
+       udelay(1000);
+       au_writel(USBH_ENABLE_INIT, USB_HOST_CONFIG);
+       udelay(1000);
+
+       /* wait for reset complete (read register twice; see au1500 errata) */
+       while (au_readl(USB_HOST_CONFIG),
+              !(au_readl(USB_HOST_CONFIG) & USBH_ENABLE_RD))
+               udelay(1000);
+
+       dbg("OHCI clock running\n");
+
+       memset (&gohci, 0, sizeof (ohci_t));
+       memset (&urb_priv, 0, sizeof (urb_priv_t));
+
+       /* align the storage */
+       if ((__u32)&ghcca[0] & 0xff) {
+               err("HCCA not aligned!!");
+               return -1;
+       }
+       phcca = &ghcca[0];
+       info("aligned ghcca %p", phcca);
+       memset(&ohci_dev, 0, sizeof(struct ohci_device));
+       if ((__u32)&ohci_dev.ed[0] & 0x7) {
+               err("EDs not aligned!!");
+               return -1;
+       }
+       memset(gtd, 0, sizeof(td_t) * (NUM_TD + 1));
+       if ((__u32)gtd & 0x7) {
+               err("TDs not aligned!!");
+               return -1;
+       }
+       ptd = gtd;
+       gohci.hcca = phcca;
+       memset (phcca, 0, sizeof (struct ohci_hcca));
+
+       gohci.disabled = 1;
+       gohci.sleeping = 0;
+       gohci.irq = -1;
+       gohci.regs = (struct ohci_regs *)(USB_OHCI_BASE | 0xA0000000);
+
+       gohci.flags = 0;
+       gohci.slot_name = "au1x00";
+
+       dbg("OHCI revision: 0x%08x\n"
+              "  RH: a: 0x%08x b: 0x%08x\n",
+              readl(&gohci.regs->revision),
+              readl(&gohci.regs->roothub.a), readl(&gohci.regs->roothub.b));
+
+       if (hc_reset (&gohci) < 0)
+               goto errout;
+
+       /* FIXME this is a second HC reset; why?? */
+       writel (gohci.hc_control = OHCI_USB_RESET, &gohci.regs->control);
+       mdelay (10);
+
+       if (hc_start (&gohci) < 0)
+               goto errout;
+
+#ifdef DEBUG
+       ohci_dump (&gohci, 1);
+#else
+       mdelay(1);
+#endif
+       ohci_inited = 1;
+       return 0;
+
+  errout:
+       err("OHCI initialization error\n");
+       hc_release_ohci (&gohci);
+       /* Initialization failed */
+       au_writel(readl(USB_HOST_CONFIG) & ~USBH_ENABLE_CE, USB_HOST_CONFIG);
+       return -1;
+}
+
+int usb_lowlevel_stop(int index)
+{
+       /* this gets called really early - before the controller has */
+       /* even been initialized! */
+       if (!ohci_inited)
+               return 0;
+       /* TODO release any interrupts, etc. */
+       /* call hc_release_ohci() here ? */
+       hc_reset (&gohci);
+       /* may not want to do this */
+       /* Disable clock */
+       au_writel(readl(USB_HOST_CONFIG) & ~USBH_ENABLE_CE, USB_HOST_CONFIG);
+       return 0;
+}
+
+#endif /* CONFIG_USB_OHCI */
diff --git a/arch/mips/mach-au1x00/au1x00_usb_ohci.h b/arch/mips/mach-au1x00/au1x00_usb_ohci.h
new file mode 100644 (file)
index 0000000..bb9f351
--- /dev/null
@@ -0,0 +1,416 @@
+/*
+ * URB OHCI HCD (Host Controller Driver) for USB.
+ *
+ * (C) Copyright 1999 Roman Weissgaerber <weissg@vienna.at>
+ * (C) Copyright 2000-2001 David Brownell <dbrownell@users.sourceforge.net>
+ *
+ * usb-ohci.h
+ */
+
+
+static int cc_to_error[16] = {
+
+/* mapping of the OHCI CC status to error codes */
+       /* No  Error  */        0,
+       /* CRC Error  */        USB_ST_CRC_ERR,
+       /* Bit Stuff  */        USB_ST_BIT_ERR,
+       /* Data Togg  */        USB_ST_CRC_ERR,
+       /* Stall      */        USB_ST_STALLED,
+       /* DevNotResp */        -1,
+       /* PIDCheck   */        USB_ST_BIT_ERR,
+       /* UnExpPID   */        USB_ST_BIT_ERR,
+       /* DataOver   */        USB_ST_BUF_ERR,
+       /* DataUnder  */        USB_ST_BUF_ERR,
+       /* reservd    */        -1,
+       /* reservd    */        -1,
+       /* BufferOver */        USB_ST_BUF_ERR,
+       /* BuffUnder  */        USB_ST_BUF_ERR,
+       /* Not Access */        -1,
+       /* Not Access */        -1
+};
+
+/* ED States */
+
+#define ED_NEW         0x00
+#define ED_UNLINK      0x01
+#define ED_OPER                0x02
+#define ED_DEL         0x04
+#define ED_URB_DEL     0x08
+
+/* usb_ohci_ed */
+struct ed {
+       __u32 hwINFO;
+       __u32 hwTailP;
+       __u32 hwHeadP;
+       __u32 hwNextED;
+
+       struct ed *ed_prev;
+       __u8 int_period;
+       __u8 int_branch;
+       __u8 int_load;
+       __u8 int_interval;
+       __u8 state;
+       __u8 type;
+       __u16 last_iso;
+       struct ed *ed_rm_list;
+
+       struct usb_device *usb_dev;
+       __u32 unused[3];
+} __attribute__((aligned(16)));
+typedef struct ed ed_t;
+
+
+/* TD info field */
+#define TD_CC                  0xf0000000
+#define TD_CC_GET(td_p)                ((td_p >>28) & 0x0f)
+#define TD_CC_SET(td_p, cc)    (td_p) = ((td_p) & 0x0fffffff) | (((cc) & 0x0f) << 28)
+#define TD_EC                  0x0C000000
+#define TD_T                   0x03000000
+#define TD_T_DATA0             0x02000000
+#define TD_T_DATA1             0x03000000
+#define TD_T_TOGGLE            0x00000000
+#define TD_R                   0x00040000
+#define TD_DI                  0x00E00000
+#define TD_DI_SET(X)           (((X) & 0x07)<< 21)
+#define TD_DP                  0x00180000
+#define TD_DP_SETUP            0x00000000
+#define TD_DP_IN               0x00100000
+#define TD_DP_OUT              0x00080000
+
+#define TD_ISO                 0x00010000
+#define TD_DEL                 0x00020000
+
+/* CC Codes */
+#define TD_CC_NOERROR          0x00
+#define TD_CC_CRC              0x01
+#define TD_CC_BITSTUFFING      0x02
+#define TD_CC_DATATOGGLEM      0x03
+#define TD_CC_STALL            0x04
+#define TD_DEVNOTRESP          0x05
+#define TD_PIDCHECKFAIL                0x06
+#define TD_UNEXPECTEDPID       0x07
+#define TD_DATAOVERRUN         0x08
+#define TD_DATAUNDERRUN                0x09
+#define TD_BUFFEROVERRUN       0x0C
+#define TD_BUFFERUNDERRUN      0x0D
+#define TD_NOTACCESSED         0x0F
+
+
+#define MAXPSW 1
+
+struct td {
+       __u32 hwINFO;
+       __u32 hwCBP;            /* Current Buffer Pointer */
+       __u32 hwNextTD;         /* Next TD Pointer */
+       __u32 hwBE;             /* Memory Buffer End Pointer */
+
+       __u16 hwPSW[MAXPSW];
+       __u8 unused;
+       __u8 index;
+       struct ed *ed;
+       struct td *next_dl_td;
+       struct usb_device *usb_dev;
+       int transfer_len;
+       __u32 data;
+
+       __u32 unused2[2];
+} __attribute__((aligned(32)));
+typedef struct td td_t;
+
+#define OHCI_ED_SKIP   (1 << 14)
+
+/*
+ * The HCCA (Host Controller Communications Area) is a 256 byte
+ * structure defined in the OHCI spec. that the host controller is
+ * told the base address of.  It must be 256-byte aligned.
+ */
+
+#define NUM_INTS 32    /* part of the OHCI standard */
+struct ohci_hcca {
+       __u32   int_table[NUM_INTS];    /* Interrupt ED table */
+       __u16   frame_no;               /* current frame number */
+       __u16   pad1;                   /* set to 0 on each frame_no change */
+       __u32   done_head;              /* info returned for an interrupt */
+       u8              reserved_for_hc[116];
+} __attribute__((aligned(256)));
+
+
+/*
+ * Maximum number of root hub ports.
+ */
+#define MAX_ROOT_PORTS 15      /* maximum OHCI root hub ports */
+
+/*
+ * This is the structure of the OHCI controller's memory mapped I/O
+ * region.  This is Memory Mapped I/O. You must use the readl() and
+ * writel() macros defined in asm/io.h to access these!!
+ */
+struct ohci_regs {
+       /* control and status registers */
+       __u32   revision;
+       __u32   control;
+       __u32   cmdstatus;
+       __u32   intrstatus;
+       __u32   intrenable;
+       __u32   intrdisable;
+       /* memory pointers */
+       __u32   hcca;
+       __u32   ed_periodcurrent;
+       __u32   ed_controlhead;
+       __u32   ed_controlcurrent;
+       __u32   ed_bulkhead;
+       __u32   ed_bulkcurrent;
+       __u32   donehead;
+       /* frame counters */
+       __u32   fminterval;
+       __u32   fmremaining;
+       __u32   fmnumber;
+       __u32   periodicstart;
+       __u32   lsthresh;
+       /* Root hub ports */
+       struct  ohci_roothub_regs {
+               __u32   a;
+               __u32   b;
+               __u32   status;
+               __u32   portstatus[MAX_ROOT_PORTS];
+       } roothub;
+} __attribute__((aligned(32)));
+
+
+/* OHCI CONTROL AND STATUS REGISTER MASKS */
+
+/*
+ * HcControl (control) register masks
+ */
+#define OHCI_CTRL_CBSR (3 << 0)        /* control/bulk service ratio */
+#define OHCI_CTRL_PLE  (1 << 2)        /* periodic list enable */
+#define OHCI_CTRL_IE   (1 << 3)        /* isochronous enable */
+#define OHCI_CTRL_CLE  (1 << 4)        /* control list enable */
+#define OHCI_CTRL_BLE  (1 << 5)        /* bulk list enable */
+#define OHCI_CTRL_HCFS (3 << 6)        /* host controller functional state */
+#define OHCI_CTRL_IR   (1 << 8)        /* interrupt routing */
+#define OHCI_CTRL_RWC  (1 << 9)        /* remote wakeup connected */
+#define OHCI_CTRL_RWE  (1 << 10)       /* remote wakeup enable */
+
+/* pre-shifted values for HCFS */
+#      define OHCI_USB_RESET   (0 << 6)
+#      define OHCI_USB_RESUME  (1 << 6)
+#      define OHCI_USB_OPER    (2 << 6)
+#      define OHCI_USB_SUSPEND (3 << 6)
+
+/*
+ * HcCommandStatus (cmdstatus) register masks
+ */
+#define OHCI_HCR       (1 << 0)        /* host controller reset */
+#define OHCI_CLF       (1 << 1)        /* control list filled */
+#define OHCI_BLF       (1 << 2)        /* bulk list filled */
+#define OHCI_OCR       (1 << 3)        /* ownership change request */
+#define OHCI_SOC       (3 << 16)       /* scheduling overrun count */
+
+/*
+ * masks used with interrupt registers:
+ * HcInterruptStatus (intrstatus)
+ * HcInterruptEnable (intrenable)
+ * HcInterruptDisable (intrdisable)
+ */
+#define OHCI_INTR_SO   (1 << 0)        /* scheduling overrun */
+#define OHCI_INTR_WDH  (1 << 1)        /* writeback of done_head */
+#define OHCI_INTR_SF   (1 << 2)        /* start frame */
+#define OHCI_INTR_RD   (1 << 3)        /* resume detect */
+#define OHCI_INTR_UE   (1 << 4)        /* unrecoverable error */
+#define OHCI_INTR_FNO  (1 << 5)        /* frame number overflow */
+#define OHCI_INTR_RHSC (1 << 6)        /* root hub status change */
+#define OHCI_INTR_OC   (1 << 30)       /* ownership change */
+#define OHCI_INTR_MIE  (1 << 31)       /* master interrupt enable */
+
+
+/* Virtual Root HUB */
+struct virt_root_hub {
+       int devnum; /* Address of Root Hub endpoint */
+       void *dev;  /* was urb */
+       void *int_addr;
+       int send;
+       int interval;
+};
+
+/* USB HUB CONSTANTS (not OHCI-specific; see hub.h) */
+
+/* destination of request */
+#define RH_INTERFACE           0x01
+#define RH_ENDPOINT            0x02
+#define RH_OTHER               0x03
+
+#define RH_CLASS               0x20
+#define RH_VENDOR              0x40
+
+/* Requests: bRequest << 8 | bmRequestType */
+#define RH_GET_STATUS          0x0080
+#define RH_CLEAR_FEATURE       0x0100
+#define RH_SET_FEATURE         0x0300
+#define RH_SET_ADDRESS         0x0500
+#define RH_GET_DESCRIPTOR      0x0680
+#define RH_SET_DESCRIPTOR      0x0700
+#define RH_GET_CONFIGURATION   0x0880
+#define RH_SET_CONFIGURATION   0x0900
+#define RH_GET_STATE           0x0280
+#define RH_GET_INTERFACE       0x0A80
+#define RH_SET_INTERFACE       0x0B00
+#define RH_SYNC_FRAME          0x0C80
+/* Our Vendor Specific Request */
+#define RH_SET_EP              0x2000
+
+
+/* Hub port features */
+#define RH_PORT_CONNECTION     0x00
+#define RH_PORT_ENABLE         0x01
+#define RH_PORT_SUSPEND                0x02
+#define RH_PORT_OVER_CURRENT   0x03
+#define RH_PORT_RESET          0x04
+#define RH_PORT_POWER          0x08
+#define RH_PORT_LOW_SPEED      0x09
+
+#define RH_C_PORT_CONNECTION   0x10
+#define RH_C_PORT_ENABLE       0x11
+#define RH_C_PORT_SUSPEND      0x12
+#define RH_C_PORT_OVER_CURRENT 0x13
+#define RH_C_PORT_RESET                0x14
+
+/* Hub features */
+#define RH_C_HUB_LOCAL_POWER   0x00
+#define RH_C_HUB_OVER_CURRENT  0x01
+
+#define RH_DEVICE_REMOTE_WAKEUP 0x00
+#define RH_ENDPOINT_STALL      0x01
+
+#define RH_ACK                 0x01
+#define RH_REQ_ERR             -1
+#define RH_NACK                        0x00
+
+
+/* OHCI ROOT HUB REGISTER MASKS */
+
+/* roothub.portstatus [i] bits */
+#define RH_PS_CCS              0x00000001      /* current connect status */
+#define RH_PS_PES              0x00000002      /* port enable status*/
+#define RH_PS_PSS              0x00000004      /* port suspend status */
+#define RH_PS_POCI             0x00000008      /* port over current indicator */
+#define RH_PS_PRS              0x00000010      /* port reset status */
+#define RH_PS_PPS              0x00000100      /* port power status */
+#define RH_PS_LSDA             0x00000200      /* low speed device attached */
+#define RH_PS_CSC              0x00010000      /* connect status change */
+#define RH_PS_PESC             0x00020000      /* port enable status change */
+#define RH_PS_PSSC             0x00040000      /* port suspend status change */
+#define RH_PS_OCIC             0x00080000      /* over current indicator change */
+#define RH_PS_PRSC             0x00100000      /* port reset status change */
+
+/* roothub.status bits */
+#define RH_HS_LPS              0x00000001      /* local power status */
+#define RH_HS_OCI              0x00000002      /* over current indicator */
+#define RH_HS_DRWE             0x00008000      /* device remote wakeup enable */
+#define RH_HS_LPSC             0x00010000      /* local power status change */
+#define RH_HS_OCIC             0x00020000      /* over current indicator change */
+#define RH_HS_CRWE             0x80000000      /* clear remote wakeup enable */
+
+/* roothub.b masks */
+#define RH_B_DR                        0x0000ffff      /* device removable flags */
+#define RH_B_PPCM              0xffff0000      /* port power control mask */
+
+/* roothub.a masks */
+#define        RH_A_NDP                (0xff << 0)     /* number of downstream ports */
+#define        RH_A_PSM                (1 << 8)        /* power switching mode */
+#define        RH_A_NPS                (1 << 9)        /* no power switching */
+#define        RH_A_DT                 (1 << 10)       /* device type (mbz) */
+#define        RH_A_OCPM               (1 << 11)       /* over current protection mode */
+#define        RH_A_NOCP               (1 << 12)       /* no over current protection */
+#define        RH_A_POTPGT             (0xff << 24)    /* power on to power good time */
+
+/* urb */
+#define N_URB_TD 48
+typedef struct
+{
+       ed_t *ed;
+       __u16 length;           /* number of tds associated with this request */
+       __u16 td_cnt;           /* number of tds already serviced */
+       int   state;
+       unsigned long pipe;
+       int actual_length;
+       td_t *td[N_URB_TD];     /* list pointer to all corresponding TDs associated with this request */
+} urb_priv_t;
+#define URB_DEL 1
+
+/*
+ * This is the full ohci controller description
+ *
+ * Note how the "proper" USB information is just
+ * a subset of what the full implementation needs. (Linus)
+ */
+
+
+typedef struct ohci {
+       struct ohci_hcca *hcca;         /* hcca */
+       /*dma_addr_t hcca_dma;*/
+
+       int irq;
+       int disabled;                   /* e.g. got a UE, we're hung */
+       int sleeping;
+       unsigned long flags;            /* for HC bugs */
+
+       struct ohci_regs *regs;         /* OHCI controller's memory */
+
+       ed_t *ed_rm_list[2];            /* lists of all endpoints to be removed */
+       ed_t *ed_bulktail;              /* last endpoint of bulk list */
+       ed_t *ed_controltail;           /* last endpoint of control list */
+       int intrstatus;
+       __u32 hc_control;               /* copy of the hc control reg */
+       struct usb_device *dev[32];
+       struct virt_root_hub rh;
+
+       const char      *slot_name;
+} ohci_t;
+
+#define NUM_EDS 8              /* num of preallocated endpoint descriptors */
+
+struct ohci_device {
+       ed_t    ed[NUM_EDS];
+       int ed_cnt;
+};
+
+/* hcd */
+/* endpoint */
+static int ep_link(ohci_t * ohci, ed_t * ed);
+static int ep_unlink(ohci_t * ohci, ed_t * ed);
+static ed_t * ep_add_ed(struct usb_device * usb_dev, unsigned long pipe);
+
+/*-------------------------------------------------------------------------*/
+
+/* we need more TDs than EDs */
+#define NUM_TD 64
+
+/* +1 so we can align the storage */
+td_t gtd[NUM_TD+1];
+/* pointers to aligned storage */
+td_t *ptd;
+
+/* TDs ... */
+static inline struct td *
+td_alloc (struct usb_device *usb_dev)
+{
+       int i;
+       struct td       *td;
+
+       td = NULL;
+       for (i = 0; i < NUM_TD; i++) {
+               if (ptd[i].usb_dev == NULL) {
+                       td = &ptd[i];
+                       td->usb_dev = usb_dev;
+                       break;
+               }
+       }
+       return td;
+}
+
+static inline void
+ed_free (struct ed *ed)
+{
+       ed->usb_dev = NULL;
+}
diff --git a/arch/mips/mach-au1x00/config.mk b/arch/mips/mach-au1x00/config.mk
new file mode 100644 (file)
index 0000000..5c89129
--- /dev/null
@@ -0,0 +1,8 @@
+#
+# (C) Copyright 2011
+# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+#
+# SPDX-License-Identifier:     GPL-2.0+
+#
+
+PLATFORM_CPPFLAGS += -mtune=4kc
index b07908692a920740f5e76db508749a42fb84630d..dee5f43ae1552d67de77b7d7d4aee0768eb124d0 100644 (file)
@@ -22,7 +22,6 @@ int   cleanup_before_linux(void);
 
 /* board/.../... */
 int    board_init(void);
-int    dram_init(void);
 
 /* cpu/.../interrupt.c */
 void   reset_timer_masked(void);
index e2e9cb77b0a7bf47cdd665e916de86266365ba1e..9da00dad735d77294d1090a154924a55ae1e7774 100644 (file)
@@ -26,9 +26,6 @@ config TARGET_CM5200
 config TARGET_GALAXY5200
        bool "Support galaxy5200"
 
-config TARGET_ICECUBE
-       bool "Support IceCube"
-
 config TARGET_INKA4X0
        bool "Support inka4x0"
 
@@ -44,24 +41,9 @@ config TARGET_MOTIONPRO
 config TARGET_MUNICES
        bool "Support munices"
 
-config TARGET_PM520
-       bool "Support PM520"
-
-config TARGET_TOTAL5200
-       bool "Support Total5200"
-
 config TARGET_V38B
        bool "Support v38b"
 
-config TARGET_CPCI5200
-       bool "Support cpci5200"
-
-config TARGET_MECP5200
-       bool "Support mecp5200"
-
-config TARGET_PF5200
-       bool "Support pf5200"
-
 config TARGET_O2D
        bool "Support O2D"
 
@@ -105,11 +87,7 @@ source "board/a4m072/Kconfig"
 source "board/bc3450/Kconfig"
 source "board/canmb/Kconfig"
 source "board/cm5200/Kconfig"
-source "board/esd/cpci5200/Kconfig"
-source "board/esd/mecp5200/Kconfig"
-source "board/esd/pf5200/Kconfig"
 source "board/galaxy5200/Kconfig"
-source "board/icecube/Kconfig"
 source "board/ifm/o2dnt2/Kconfig"
 source "board/inka4x0/Kconfig"
 source "board/intercontrol/digsy_mtc/Kconfig"
@@ -118,8 +96,6 @@ source "board/jupiter/Kconfig"
 source "board/motionpro/Kconfig"
 source "board/munices/Kconfig"
 source "board/phytec/pcm030/Kconfig"
-source "board/pm520/Kconfig"
-source "board/total5200/Kconfig"
 source "board/tqc/tqm5200/Kconfig"
 source "board/v38b/Kconfig"
 
index a89d5fd7a64cfe9faeac18f6f7d63bb4a66bae53..70b7e6e6cb4e00aa78ca74c9c8cee39abc5dcae0 100644 (file)
@@ -33,21 +33,7 @@ static int mpc5200_read_config_dword(struct pci_controller *hose,
        *(volatile u32 *)MPC5XXX_PCI_CAR = (1 << 31) | dev | offset;
        eieio();
        udelay(10);
-#if (defined CONFIG_PF5200 || defined CONFIG_CPCI5200)
-       if (dev & 0x00ff0000) {
-               u32 val;
-               val  = in_le16((volatile u16 *)(CONFIG_PCI_IO_PHYS+2));
-               udelay(10);
-               val = val << 16;
-               val |= in_le16((volatile u16 *)(CONFIG_PCI_IO_PHYS+0));
-               *value = val;
-       } else {
-               *value = in_le32((volatile u32 *)CONFIG_PCI_IO_PHYS);
-       }
-       udelay(10);
-#else
        *value = in_le32((volatile u32 *)CONFIG_PCI_IO_PHYS);
-#endif
        eieio();
        *(volatile u32 *)MPC5XXX_PCI_CAR = 0;
        udelay(10);
index 69a600cc4237c25e82a34db4955cad385cd70670..4d6cb0964bad2364cf064c59c78092993ee5279b 100644 (file)
@@ -41,12 +41,6 @@ config TARGET_MPC8349EMDS
 config TARGET_MPC8349ITX
        bool "Support MPC8349ITX"
 
-config TARGET_MPC8360EMDS
-       bool "Support MPC8360EMDS"
-
-config TARGET_MPC8360ERDK
-       bool "Support MPC8360ERDK"
-
 config TARGET_MPC837XEMDS
        bool "Support MPC837XEMDS"
 
@@ -81,8 +75,6 @@ source "board/freescale/mpc8323erdb/Kconfig"
 source "board/freescale/mpc832xemds/Kconfig"
 source "board/freescale/mpc8349emds/Kconfig"
 source "board/freescale/mpc8349itx/Kconfig"
-source "board/freescale/mpc8360emds/Kconfig"
-source "board/freescale/mpc8360erdk/Kconfig"
 source "board/freescale/mpc837xemds/Kconfig"
 source "board/freescale/mpc837xerdb/Kconfig"
 source "board/ids/ids8313/Kconfig"
index 7501eb4b82c5dff55d1f64b902bcb1c9353d104b..adb5bd378ce5a56eac394122263de1b3c5eba937 100644 (file)
@@ -85,11 +85,6 @@ config TARGET_P1022DS
 config TARGET_P1023RDB
        bool "Support P1023RDB"
 
-config TARGET_P1_P2_RDB
-       bool "Support P1_P2_RDB"
-       select SUPPORT_SPL
-       select SUPPORT_TPL
-
 config TARGET_P1_P2_RDB_PC
        bool "Support p1_p2_rdb_pc"
        select SUPPORT_SPL
@@ -98,12 +93,6 @@ config TARGET_P1_P2_RDB_PC
 config TARGET_P1_TWR
        bool "Support p1_twr"
 
-config TARGET_P2020COME
-       bool "Support P2020COME"
-
-config TARGET_P2020DS
-       bool "Support P2020DS"
-
 config TARGET_P2041RDB
        bool "Support P2041RDB"
 
@@ -184,11 +173,8 @@ source "board/freescale/mpc8572ds/Kconfig"
 source "board/freescale/p1010rdb/Kconfig"
 source "board/freescale/p1022ds/Kconfig"
 source "board/freescale/p1023rdb/Kconfig"
-source "board/freescale/p1_p2_rdb/Kconfig"
 source "board/freescale/p1_p2_rdb_pc/Kconfig"
 source "board/freescale/p1_twr/Kconfig"
-source "board/freescale/p2020come/Kconfig"
-source "board/freescale/p2020ds/Kconfig"
 source "board/freescale/p2041rdb/Kconfig"
 source "board/freescale/qemu-ppce500/Kconfig"
 source "board/freescale/t102xqds/Kconfig"
index 598f7bd92ee960c75e62628df52ec51634e79869..fd7f5fa7e135c165db7146f0fcc46dffc107704a 100644 (file)
@@ -57,7 +57,7 @@ struct liodn_id_table liodn_tbl[] = {
 
        SET_USB_LIODN(1, "fsl-usb2-dr", 553),
 
-       SET_PCI_LIODN(CONFIG_SYS_FSL_PCIE_COMPAT, 1, 148),
+       SET_PCI_LIODN_BASE(CONFIG_SYS_FSL_PCIE_COMPAT, 1, 148),
 
        SET_DMA_LIODN(1, "fsl,elo3-dma", 147),
        SET_DMA_LIODN(2, "fsl,elo3-dma", 227),
index 85d32fc6128558ac8e169dc391b40b54c8d7b7e4..4cf8853b723af3093bf3db16145fb78b70376763 100644 (file)
@@ -424,7 +424,6 @@ void fsl_erratum_a007212_workaround(void)
 
 ulong cpu_init_f(void)
 {
-       ulong flag = 0;
        extern void m8560_cpm_reset (void);
 #if defined(CONFIG_SYS_DCSRBAR_PHYS) || \
        (defined(CONFIG_SECURE_BOOT) && defined(CONFIG_FSL_CORENET))
@@ -499,18 +498,11 @@ ulong cpu_init_f(void)
        in_be32(&gur->dcsrcr);
 #endif
 
-#ifdef CONFIG_SYS_DCSRBAR_PHYS
-#ifdef CONFIG_DEEP_SLEEP
-       /* disable the console if boot from deep sleep */
-       if (in_be32(&gur->scrtsr[0]) & (1 << 3))
-               flag = GD_FLG_SILENT | GD_FLG_DISABLE_CONSOLE;
-#endif
-#endif
 #ifdef CONFIG_SYS_FSL_ERRATUM_A007212
        fsl_erratum_a007212_workaround();
 #endif
 
-       return flag;
+       return 0;
 }
 
 /* Implement a dummy function for those platforms w/o SERDES */
index 5cfae470697ea1877f65d5795a5bc0ee892676a1..acb1353e5d207360e8f7c4e7caaeb25219d5f2ea 100644 (file)
 #include "fsl_corenet2_serdes.h"
 
 #ifdef CONFIG_SYS_FSL_SRDS_1
-static u64 serdes1_prtcl_map;
+static u8 serdes1_prtcl_map[SERDES_PRCTL_COUNT];
 #endif
 #ifdef CONFIG_SYS_FSL_SRDS_2
-static u64 serdes2_prtcl_map;
+static u8 serdes2_prtcl_map[SERDES_PRCTL_COUNT];
 #endif
 #ifdef CONFIG_SYS_FSL_SRDS_3
-static u64 serdes3_prtcl_map;
+static u8 serdes3_prtcl_map[SERDES_PRCTL_COUNT];
 #endif
 #ifdef CONFIG_SYS_FSL_SRDS_4
-static u64 serdes4_prtcl_map;
+static u8 serdes4_prtcl_map[SERDES_PRCTL_COUNT];
 #endif
 
 #ifdef DEBUG
@@ -78,24 +78,30 @@ static const char *serdes_prtcl_str[] = {
        [INTERLAKEN] = "INTERLAKEN",
        [QSGMII_SW1_A] = "QSGMII_SW1_A",
        [QSGMII_SW1_B] = "QSGMII_SW1_B",
+       [SGMII_SW1_MAC1] = "SGMII_SW1_MAC1",
+       [SGMII_SW1_MAC2] = "SGMII_SW1_MAC2",
+       [SGMII_SW1_MAC3] = "SGMII_SW1_MAC3",
+       [SGMII_SW1_MAC4] = "SGMII_SW1_MAC4",
+       [SGMII_SW1_MAC5] = "SGMII_SW1_MAC5",
+       [SGMII_SW1_MAC6] = "SGMII_SW1_MAC6",
 };
 #endif
 
 int is_serdes_configured(enum srds_prtcl device)
 {
-       u64 ret = 0;
+       int ret = 0;
 
 #ifdef CONFIG_SYS_FSL_SRDS_1
-       ret |= (1ULL << device) & serdes1_prtcl_map;
+       ret |= serdes1_prtcl_map[device];
 #endif
 #ifdef CONFIG_SYS_FSL_SRDS_2
-       ret |= (1ULL << device) & serdes2_prtcl_map;
+       ret |= serdes2_prtcl_map[device];
 #endif
 #ifdef CONFIG_SYS_FSL_SRDS_3
-       ret |= (1ULL << device) & serdes3_prtcl_map;
+       ret |= serdes3_prtcl_map[device];
 #endif
 #ifdef CONFIG_SYS_FSL_SRDS_4
-       ret |= (1ULL << device) & serdes4_prtcl_map;
+       ret |= serdes4_prtcl_map[device];
 #endif
 
        return !!ret;
@@ -171,12 +177,14 @@ int serdes_get_first_lane(u32 sd, enum srds_prtcl device)
 #define BCAP_OVD_MASK          0x10000000
 #define BYP_CAL_MASK           0x02000000
 
-u64 serdes_init(u32 sd, u32 sd_addr, u32 sd_prctl_mask, u32 sd_prctl_shift)
+void serdes_init(u32 sd, u32 sd_addr, u32 sd_prctl_mask, u32 sd_prctl_shift,
+               u8 serdes_prtcl_map[SERDES_PRCTL_COUNT])
 {
        ccsr_gur_t *gur = (void __iomem *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
-       u64 serdes_prtcl_map = 0;
        u32 cfg;
        int lane;
+
+       memset(serdes_prtcl_map, 0, sizeof(serdes_prtcl_map));
 #ifdef CONFIG_SYS_FSL_ERRATUM_A007186
        struct ccsr_sfp_regs  __iomem *sfp_regs =
                        (struct ccsr_sfp_regs __iomem *)(CONFIG_SYS_SFP_ADDR);
@@ -312,38 +320,43 @@ u64 serdes_init(u32 sd, u32 sd_addr, u32 sd_prctl_mask, u32 sd_prctl_shift)
 
        for (lane = 0; lane < SRDS_MAX_LANES; lane++) {
                enum srds_prtcl lane_prtcl = serdes_get_prtcl(sd, cfg, lane);
-               serdes_prtcl_map |= (1ULL << lane_prtcl);
+               if (unlikely(lane_prtcl >= SERDES_PRCTL_COUNT))
+                       debug("Unknown SerDes lane protocol %d\n", lane_prtcl);
+               else
+                       serdes_prtcl_map[lane_prtcl] = 1;
        }
-
-       return serdes_prtcl_map;
 }
 
 void fsl_serdes_init(void)
 {
 
 #ifdef CONFIG_SYS_FSL_SRDS_1
-       serdes1_prtcl_map = serdes_init(FSL_SRDS_1,
-               CONFIG_SYS_FSL_CORENET_SERDES_ADDR,
-               FSL_CORENET2_RCWSR4_SRDS1_PRTCL,
-               FSL_CORENET2_RCWSR4_SRDS1_PRTCL_SHIFT);
+       serdes_init(FSL_SRDS_1,
+                   CONFIG_SYS_FSL_CORENET_SERDES_ADDR,
+                   FSL_CORENET2_RCWSR4_SRDS1_PRTCL,
+                   FSL_CORENET2_RCWSR4_SRDS1_PRTCL_SHIFT,
+                   serdes1_prtcl_map);
 #endif
 #ifdef CONFIG_SYS_FSL_SRDS_2
-       serdes2_prtcl_map = serdes_init(FSL_SRDS_2,
-               CONFIG_SYS_FSL_CORENET_SERDES_ADDR + FSL_SRDS_2 * 0x1000,
-               FSL_CORENET2_RCWSR4_SRDS2_PRTCL,
-               FSL_CORENET2_RCWSR4_SRDS2_PRTCL_SHIFT);
+       serdes_init(FSL_SRDS_2,
+                   CONFIG_SYS_FSL_CORENET_SERDES_ADDR + FSL_SRDS_2 * 0x1000,
+                   FSL_CORENET2_RCWSR4_SRDS2_PRTCL,
+                   FSL_CORENET2_RCWSR4_SRDS2_PRTCL_SHIFT,
+                   serdes2_prtcl_map);
 #endif
 #ifdef CONFIG_SYS_FSL_SRDS_3
-       serdes3_prtcl_map = serdes_init(FSL_SRDS_3,
-               CONFIG_SYS_FSL_CORENET_SERDES_ADDR + FSL_SRDS_3 * 0x1000,
-               FSL_CORENET2_RCWSR4_SRDS3_PRTCL,
-               FSL_CORENET2_RCWSR4_SRDS3_PRTCL_SHIFT);
+       serdes_init(FSL_SRDS_3,
+                   CONFIG_SYS_FSL_CORENET_SERDES_ADDR + FSL_SRDS_3 * 0x1000,
+                   FSL_CORENET2_RCWSR4_SRDS3_PRTCL,
+                   FSL_CORENET2_RCWSR4_SRDS3_PRTCL_SHIFT,
+                   serdes3_prtcl_map);
 #endif
 #ifdef CONFIG_SYS_FSL_SRDS_4
-       serdes4_prtcl_map = serdes_init(FSL_SRDS_4,
-               CONFIG_SYS_FSL_CORENET_SERDES_ADDR + FSL_SRDS_4 * 0x1000,
-               FSL_CORENET2_RCWSR4_SRDS4_PRTCL,
-               FSL_CORENET2_RCWSR4_SRDS4_PRTCL_SHIFT);
+       serdes_init(FSL_SRDS_4,
+                   CONFIG_SYS_FSL_CORENET_SERDES_ADDR + FSL_SRDS_4 * 0x1000,
+                   FSL_CORENET2_RCWSR4_SRDS4_PRTCL,
+                   FSL_CORENET2_RCWSR4_SRDS4_PRTCL_SHIFT,
+                   serdes4_prtcl_map);
 #endif
 
 }
index 7dc8385aa6a59297d5ac067c00696cbb2bc16074..2ba314a7f67043c5774c6e269efff25cb66a7f05 100644 (file)
@@ -11,6 +11,7 @@
 
 
 static u8 serdes_cfg_tbl[][4] = {
+       [0x40] = {PCIE1, PCIE1, PCIE1, PCIE1},
        [0xD5] = {QSGMII_FM1_A, PCIE3, PCIE2, PCIE1},
        [0xD6] = {QSGMII_FM1_A, PCIE3, PCIE2, SATA1},
        [0x95] = {XFI_FM1_MAC1, PCIE3, PCIE2, PCIE1},
@@ -20,6 +21,7 @@ static u8 serdes_cfg_tbl[][4] = {
        [0x56] = {PCIE1, PCIE3, PCIE2, SATA1},
        [0x5A] = {PCIE1, PCIE3, SGMII_FM1_DTSEC2, SATA1},
        [0x5B] = {PCIE1, PCIE3, SGMII_FM1_DTSEC2, SGMII_FM1_DTSEC1},
+       [0x5F] = {PCIE1, PCIE3, SGMII_2500_FM1_DTSEC2, SGMII_2500_FM1_DTSEC1},
        [0x6A] = {PCIE1, SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC2, SATA1},
        [0x6B] = {PCIE1, SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC2, SGMII_FM1_DTSEC1},
        [0x6F] = {PCIE1, SGMII_FM1_DTSEC3, SGMII_2500_FM1_DTSEC2,
index d86bb2737246201e14a63508f2a6c8b3ab0b4015..d5dccd5cf22c7e957831944bcb260c60486f9dd7 100644 (file)
@@ -33,10 +33,10 @@ static u8 serdes_cfg_tbl[][SRDS_MAX_LANES] = {
                PCIE2, PCIE2, SGMII_FM1_DTSEC4, SGMII_FM1_DTSEC5},
        [0x87] = {PCIE1, SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2,
                PCIE2, PCIE3, PCIE4, SGMII_FM1_DTSEC5},
-       [0x89] = {PCIE1, QSGMII_SW1_A, QSGMII_SW1_A, QSGMII_SW1_A,
-               PCIE2, PCIE3, QSGMII_SW1_B, SATA1},
-       [0x8D] = {PCIE1, QSGMII_SW1_A, QSGMII_SW1_A, QSGMII_SW1_A,
-               PCIE2, QSGMII_SW1_B, QSGMII_SW1_B, QSGMII_SW1_B},
+       [0x89] = {PCIE1, SGMII_SW1_MAC3, SGMII_SW1_MAC1, SGMII_SW1_MAC2,
+               PCIE2, PCIE3, SGMII_SW1_MAC4, SATA1},
+       [0x8D] = {PCIE1, SGMII_SW1_MAC3, SGMII_SW1_MAC1, SGMII_SW1_MAC2,
+               PCIE2, SGMII_SW1_MAC6, SGMII_SW1_MAC4, SGMII_SW1_MAC5},
        [0x8F] = {PCIE1, SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2,
                AURORA, NONE, SGMII_FM1_DTSEC4, SGMII_FM1_DTSEC5},
        [0xA5] = {PCIE1, SGMII_FM1_DTSEC3, SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2,
index 2d28eb26552af73833018bd17660910dd9df1245..c92589fb9dd50e992fa02a83b5bfbd0fc8581d8d 100644 (file)
@@ -15,6 +15,7 @@
 #include <netdev.h>
 #include <asm/cache.h>
 #include <asm/io.h>
+#include <vsc9953.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -271,5 +272,9 @@ int cpu_eth_init(bd_t *bis)
 #ifdef CONFIG_FMAN_ENET
        fm_standard_init(bis);
 #endif
+
+#ifdef CONFIG_VSC9953
+       vsc9953_init(bis);
+#endif
        return 0;
 }
index 1c63f93f4d45c46c07ea14de0fab61ff141a9e50..9cc1676b6029494679b6d8c9ab5bd367bebee54f 100644 (file)
@@ -73,176 +73,6 @@ void ft_fixup_num_cores(void *blob) {
 }
 #endif /* defined(CONFIG_MPC85xx) || defined(CONFIG_MPC86xx) */
 
-/*
- * update crypto node properties to a specified revision of the SEC
- * called with sec_rev == 0 if not on an E processor
- */
-#if CONFIG_SYS_FSL_SEC_COMPAT == 2 /* SEC 2.x/3.x */
-void fdt_fixup_crypto_node(void *blob, int sec_rev)
-{
-       static const struct sec_rev_prop {
-               u32 sec_rev;
-               u32 num_channels;
-               u32 channel_fifo_len;
-               u32 exec_units_mask;
-               u32 descriptor_types_mask;
-       } sec_rev_prop_list [] = {
-               { 0x0200, 4, 24, 0x07e, 0x01010ebf }, /* SEC 2.0 */
-               { 0x0201, 4, 24, 0x0fe, 0x012b0ebf }, /* SEC 2.1 */
-               { 0x0202, 1, 24, 0x04c, 0x0122003f }, /* SEC 2.2 */
-               { 0x0204, 4, 24, 0x07e, 0x012b0ebf }, /* SEC 2.4 */
-               { 0x0300, 4, 24, 0x9fe, 0x03ab0ebf }, /* SEC 3.0 */
-               { 0x0301, 4, 24, 0xbfe, 0x03ab0ebf }, /* SEC 3.1 */
-               { 0x0303, 4, 24, 0x97c, 0x03a30abf }, /* SEC 3.3 */
-       };
-       static char compat_strlist[ARRAY_SIZE(sec_rev_prop_list) *
-                                  sizeof("fsl,secX.Y")];
-       int crypto_node, sec_idx, err;
-       char *p;
-       u32 val;
-
-       /* locate crypto node based on lowest common compatible */
-       crypto_node = fdt_node_offset_by_compatible(blob, -1, "fsl,sec2.0");
-       if (crypto_node == -FDT_ERR_NOTFOUND)
-               return;
-
-       /* delete it if not on an E-processor */
-       if (crypto_node > 0 && !sec_rev) {
-               fdt_del_node(blob, crypto_node);
-               return;
-       }
-
-       /* else we got called for possible uprev */
-       for (sec_idx = 0; sec_idx < ARRAY_SIZE(sec_rev_prop_list); sec_idx++)
-               if (sec_rev_prop_list[sec_idx].sec_rev == sec_rev)
-                       break;
-
-       if (sec_idx == ARRAY_SIZE(sec_rev_prop_list)) {
-               puts("warning: unknown SEC revision number\n");
-               return;
-       }
-
-       val = cpu_to_fdt32(sec_rev_prop_list[sec_idx].num_channels);
-       err = fdt_setprop(blob, crypto_node, "fsl,num-channels", &val, 4);
-       if (err < 0)
-               printf("WARNING: could not set crypto property: %s\n",
-                      fdt_strerror(err));
-
-       val = cpu_to_fdt32(sec_rev_prop_list[sec_idx].descriptor_types_mask);
-       err = fdt_setprop(blob, crypto_node, "fsl,descriptor-types-mask", &val, 4);
-       if (err < 0)
-               printf("WARNING: could not set crypto property: %s\n",
-                      fdt_strerror(err));
-
-       val = cpu_to_fdt32(sec_rev_prop_list[sec_idx].exec_units_mask);
-       err = fdt_setprop(blob, crypto_node, "fsl,exec-units-mask", &val, 4);
-       if (err < 0)
-               printf("WARNING: could not set crypto property: %s\n",
-                      fdt_strerror(err));
-
-       val = cpu_to_fdt32(sec_rev_prop_list[sec_idx].channel_fifo_len);
-       err = fdt_setprop(blob, crypto_node, "fsl,channel-fifo-len", &val, 4);
-       if (err < 0)
-               printf("WARNING: could not set crypto property: %s\n",
-                      fdt_strerror(err));
-
-       val = 0;
-       while (sec_idx >= 0) {
-               p = compat_strlist + val;
-               val += sprintf(p, "fsl,sec%d.%d",
-                       (sec_rev_prop_list[sec_idx].sec_rev & 0xff00) >> 8,
-                       sec_rev_prop_list[sec_idx].sec_rev & 0x00ff) + 1;
-               sec_idx--;
-       }
-       err = fdt_setprop(blob, crypto_node, "compatible", &compat_strlist, val);
-       if (err < 0)
-               printf("WARNING: could not set crypto property: %s\n",
-                      fdt_strerror(err));
-}
-#elif CONFIG_SYS_FSL_SEC_COMPAT >= 4  /* SEC4 */
-static u8 caam_get_era(void)
-{
-       static const struct {
-               u16 ip_id;
-               u8 maj_rev;
-               u8 era;
-       } caam_eras[] = {
-               {0x0A10, 1, 1},
-               {0x0A10, 2, 2},
-               {0x0A12, 1, 3},
-               {0x0A14, 1, 3},
-               {0x0A14, 2, 4},
-               {0x0A16, 1, 4},
-               {0x0A10, 3, 4},
-               {0x0A11, 1, 4},
-               {0x0A18, 1, 4},
-               {0x0A11, 2, 5},
-               {0x0A12, 2, 5},
-               {0x0A13, 1, 5},
-               {0x0A1C, 1, 5}
-       };
-
-       ccsr_sec_t __iomem *sec = (void __iomem *)CONFIG_SYS_FSL_SEC_ADDR;
-       u32 secvid_ms = sec_in32(&sec->secvid_ms);
-       u32 ccbvid = sec_in32(&sec->ccbvid);
-       u16 ip_id = (secvid_ms & SEC_SECVID_MS_IPID_MASK) >>
-                               SEC_SECVID_MS_IPID_SHIFT;
-       u8 maj_rev = (secvid_ms & SEC_SECVID_MS_MAJ_REV_MASK) >>
-                               SEC_SECVID_MS_MAJ_REV_SHIFT;
-       u8 era = (ccbvid & SEC_CCBVID_ERA_MASK) >> SEC_CCBVID_ERA_SHIFT;
-
-       int i;
-
-       if (era)        /* This is '0' prior to CAAM ERA-6 */
-               return era;
-
-       for (i = 0; i < ARRAY_SIZE(caam_eras); i++)
-               if (caam_eras[i].ip_id == ip_id &&
-                   caam_eras[i].maj_rev == maj_rev)
-                       return caam_eras[i].era;
-
-       return 0;
-}
-
-static void fdt_fixup_crypto_era(void *blob, u32 era)
-{
-       int err;
-       int crypto_node;
-
-       crypto_node = fdt_path_offset(blob, "crypto");
-       if (crypto_node < 0) {
-               printf("WARNING: Missing crypto node\n");
-               return;
-       }
-
-       err = fdt_setprop(blob, crypto_node, "fsl,sec-era", &era,
-                         sizeof(era));
-       if (err < 0) {
-               printf("ERROR: could not set fsl,sec-era property: %s\n",
-                      fdt_strerror(err));
-       }
-}
-
-void fdt_fixup_crypto_node(void *blob, int sec_rev)
-{
-       u8 era;
-
-       if (!sec_rev) {
-               fdt_del_node_and_alias(blob, "crypto");
-               return;
-       }
-
-       /* Add SEC ERA information in compatible */
-       era = caam_get_era();
-       if (era) {
-               fdt_fixup_crypto_era(blob, era);
-       } else {
-               printf("WARNING: Unable to get ERA for CAAM rev: %d\n",
-                       sec_rev);
-       }
-}
-#endif
-
 int fdt_fixup_phy_connection(void *blob, int offset, phy_interface_t phyc)
 {
        return fdt_setprop_string(blob, offset, "phy-connection-type",
index a40ae3b38af5d000f713f2c3a17a1ab5bf444eb9..5db5e346271d54f71e220315dd5e660112306bdf 100644 (file)
@@ -101,12 +101,6 @@ config TARGET_FX12MM
 config TARGET_V5FX30TEVAL
        bool "Support v5fx30teval"
 
-config TARGET_CATCENTER
-       bool "Support CATcenter"
-
-config TARGET_PPCHAMELEONEVB
-       bool "Support PPChameleonEVB"
-
 config TARGET_CPCI2DP
        bool "Support CPCI2DP"
 
@@ -199,7 +193,6 @@ source "board/avnet/fx12mm/Kconfig"
 source "board/avnet/v5fx30teval/Kconfig"
 source "board/csb272/Kconfig"
 source "board/csb472/Kconfig"
-source "board/dave/PPChameleonEVB/Kconfig"
 source "board/esd/cpci2dp/Kconfig"
 source "board/esd/cpci405/Kconfig"
 source "board/esd/plu405/Kconfig"
diff --git a/arch/powerpc/include/asm/arch-mpc85xx/gpio.h b/arch/powerpc/include/asm/arch-mpc85xx/gpio.h
new file mode 100644 (file)
index 0000000..8beed30
--- /dev/null
@@ -0,0 +1,15 @@
+/*
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+/*
+ * Dummy header file to enable CONFIG_OF_CONTROL.
+ * If CONFIG_OF_CONTROL is enabled, lib/fdtdec.c is compiled.
+ * It includes <asm/arch/gpio.h> via <asm/gpio.h>, so those SoCs that enable
+ * OF_CONTROL must have arch/gpio.h.
+ */
+
+#ifndef __ASM_ARCH_MX85XX_GPIO_H
+#define __ASM_ARCH_MX85XX_GPIO_H
+
+#endif
index 423a6fb8dc6419d3ef4020086777a9a3510a2011..65496d0d90a9a5c9a34e660257fca8bf6200ccae 100644 (file)
@@ -75,6 +75,7 @@
  * SEC (crypto unit) major compatible version determination
  */
 #if defined(CONFIG_MPC83xx)
+#define CONFIG_SYS_FSL_SEC_BE
 #define CONFIG_SYS_FSL_SEC_COMPAT      2
 #endif
 
index 14c6fc3cfec2eba879a9c0ed3d3b0faa84f92a5e..b4c0c99b39d68f0d812e91fff94f291cc9cbffe4 100644 (file)
@@ -12,6 +12,8 @@
 #define CONFIG_SYS_PBI_FLASH_BASE              0xc0000000
 #elif defined(CONFIG_BSC9132QDS)
 #define CONFIG_SYS_PBI_FLASH_BASE              0xc8000000
+#elif defined(CONFIG_C29XPCIE)
+#define CONFIG_SYS_PBI_FLASH_BASE              0xcc000000
 #else
 #define CONFIG_SYS_PBI_FLASH_BASE              0xce000000
 #endif
index 8e0e190003872928bc3814e028388a9b6e025029..45e248eba18e4713d1454ab99159339463ce18e1 100644 (file)
@@ -87,6 +87,13 @@ enum srds_prtcl {
        SGMII_2500_FM2_DTSEC6,
        SGMII_2500_FM2_DTSEC9,
        SGMII_2500_FM2_DTSEC10,
+       SGMII_SW1_MAC1,
+       SGMII_SW1_MAC2,
+       SGMII_SW1_MAC3,
+       SGMII_SW1_MAC4,
+       SGMII_SW1_MAC5,
+       SGMII_SW1_MAC6,
+       SERDES_PRCTL_COUNT      /* Keep this item the last one */
 };
 
 enum srds {
index e6d5355f261fd9b6e4bd521fa141ccd61db22860..91645d36ee9afcaad5138d55bfaa5ac407fd969b 100644 (file)
@@ -346,13 +346,6 @@ void board_init_f(ulong bootflag)
 #ifdef CONFIG_PRAM
        ulong reg;
 #endif
-#ifdef CONFIG_DEEP_SLEEP
-       const ccsr_gur_t *gur = (void __iomem *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
-       struct ccsr_scfg *scfg = (void *)CONFIG_SYS_MPC85xx_SCFG;
-       u32 start_addr;
-       typedef void (*func_t)(void);
-       func_t kernel_resume;
-#endif
 
        /* Pointer is writable since we allocated a register for it */
        gd = (gd_t *) (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_GBL_DATA_OFFSET);
@@ -372,20 +365,6 @@ void board_init_f(ulong bootflag)
                if ((*init_fnc_ptr) () != 0)
                        hang();
 
-#ifdef CONFIG_DEEP_SLEEP
-       /* Jump to kernel in deep sleep case */
-       if (in_be32(&gur->scrtsr[0]) & (1 << 3)) {
-               l2cache_init();
-#if defined(CONFIG_RAMBOOT_PBL)
-               disable_cpc_sram();
-#endif
-               enable_cpc();
-               start_addr = in_be32(&scfg->sparecr[1]);
-               kernel_resume = (func_t)start_addr;
-               kernel_resume();
-       }
-#endif
-
 #ifdef CONFIG_POST
        post_bootmode_init();
        post_run(NULL, POST_ROM | post_bootmode_get(NULL));
index 42353d80a847bc51eade86f414e72238a8a4916f..097f29a2901b7348171359c596ba53036a738d0f 100644 (file)
@@ -6,6 +6,7 @@
 #include <common.h>
 #include <os.h>
 #include <cli.h>
+#include <malloc.h>
 #include <asm/getopt.h>
 #include <asm/io.h>
 #include <asm/sections.h>
@@ -102,6 +103,25 @@ 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");
 
+static int sandbox_cmdline_cb_default_fdt(struct sandbox_state *state,
+                                         const char *arg)
+{
+       const char *fmt = "%s.dtb";
+       char *fname;
+       int len;
+
+       len = strlen(state->argv[0]) + strlen(fmt) + 1;
+       fname = os_malloc(len);
+       if (!fname)
+               return -ENOMEM;
+       snprintf(fname, len, fmt, state->argv[0]);
+       state->fdt_fname = fname;
+
+       return 0;
+}
+SANDBOX_CMDLINE_OPT_SHORT(default_fdt, 'D', 0,
+               "Use the default u-boot.dtb control FDT in U-Boot directory");
+
 static int sandbox_cmdline_cb_interactive(struct sandbox_state *state,
                                          const char *arg)
 {
index 11748aec7990e1ff40f9d625842a154d8d278cc1..9ce31bf075832af6d62248a9bc05184969231093 100644 (file)
@@ -19,6 +19,7 @@
                colour = "cyan";
                sides = <3>;
                character = <83>;
+               light-gpios = <&gpio_a 2>, <&gpio_b 6 0>;
        };
        square {
                compatible = "demo-shape";
 
        cros-ec-keyb {
                compatible = "google,cros-ec-keyb";
-               google,key-rows = <8>;
-               google,key-columns = <13>;
-               google,repeat-delay-ms = <240>;
-               google,repeat-rate-ms = <30>;
+               keypad,num-rows = <8>;
+               keypad,num-columns = <13>;
                google,ghost-filter;
                /*
                 * Keymap entries take the form of 0xRRCCKKKK where
                        0x070b0067 0x070c0069>;
        };
 
-       gpio_a: gpios {
+       gpio_a: gpios@0 {
                gpio-controller;
                compatible = "sandbox,gpio";
                #gpio-cells = <1>;
                num-gpios = <20>;
        };
 
+       gpio_b: gpios@1 {
+               gpio-controller;
+               compatible = "sandbox,gpio";
+               #gpio-cells = <2>;
+               gpio-bank-name = "b";
+               num-gpios = <10>;
+       };
+
        i2c@0 {
                #address-cells = <1>;
                #size-cells = <0>;
index d2f1b6566d7051afe75c1199a57c929fabcd0ae3..770ab5c9cc07ec6fa497bd3d7b631072b8e10f5d 100644 (file)
@@ -17,7 +17,6 @@
 
 /* board/.../... */
 int board_init(void);
-int dram_init(void);
 
 /* start.c */
 int sandbox_early_getopt_check(void);
index 35e6cdd74164fde67a1f95a06a0fe831927842ba..b6e870a7cbd4a95234a37eeca1acdd69ffc40037 100644 (file)
@@ -16,7 +16,6 @@
 obj-y += car.o
 obj-y += coreboot.o
 obj-y += tables.o
-obj-y += ipchecksum.o
 obj-y += sdram.o
 obj-y += timestamp.o
 obj-$(CONFIG_PCI) += pci.o
index 6d06d5af19e5f7f38ce19676f97a0ac25d1803cc..4cdd0d403530a17d3ac8dd9135d2564563aacf21 100644 (file)
@@ -99,3 +99,8 @@ void panic_puts(const char *str)
        while (*str)
                NS16550_putc(port, *str++);
 }
+
+int misc_init_r(void)
+{
+       return 0;
+}
diff --git a/arch/x86/cpu/coreboot/ipchecksum.c b/arch/x86/cpu/coreboot/ipchecksum.c
deleted file mode 100644 (file)
index 3340872..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * This file is part of the libpayload project.
- *
- * It has originally been taken from the FreeBSD project.
- *
- * Copyright (c) 2001 Charles Mott <cm@linktel.net>
- * Copyright (c) 2008 coresystems GmbH
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <linux/types.h>
-#include <linux/compiler.h>
-#include <asm/arch/ipchecksum.h>
-
-unsigned short ipchksum(const void *vptr, unsigned long nbytes)
-{
-       int sum, oddbyte;
-       const unsigned short *ptr = vptr;
-
-       sum = 0;
-       while (nbytes > 1) {
-               sum += *ptr++;
-               nbytes -= 2;
-       }
-       if (nbytes == 1) {
-               oddbyte = 0;
-               ((u8 *)&oddbyte)[0] = *(u8 *) ptr;
-               ((u8 *)&oddbyte)[1] = 0;
-               sum += oddbyte;
-       }
-       sum = (sum >> 16) + (sum & 0xffff);
-       sum += (sum >> 16);
-       return ~sum;
-}
index 92b75286b188f3e9f383582e05efb96cf578cc7c..2b12b19ba27750f41eca97201d1f41f5fabfda5c 100644 (file)
@@ -8,7 +8,7 @@
  */
 
 #include <common.h>
-#include <asm/arch/ipchecksum.h>
+#include <net.h>
 #include <asm/arch/sysinfo.h>
 #include <asm/arch/tables.h>
 
@@ -131,11 +131,11 @@ static int cb_parse_header(void *addr, int len, struct sysinfo_t *info)
                return 0;
 
        /* Make sure the checksums match. */
-       if (ipchksum((u16 *) header, sizeof(*header)) != 0)
+       if (!ip_checksum_ok(header, sizeof(*header)))
                return -1;
 
-       if (ipchksum((u16 *) (ptr + sizeof(*header)),
-                    header->table_bytes) != header->table_checksum)
+       if (compute_ip_checksum(ptr + sizeof(*header), header->table_bytes) !=
+           header->table_checksum)
                return -1;
 
        /* Now, walk the tables. */
index 30e50696984eb7be9778b571b3c32fc586a2a302..ed7905c1d7cf24c9ad9350bcd38b3ff9c9c9c727 100644 (file)
@@ -223,6 +223,11 @@ static bool has_cpuid(void)
        return flag_is_changeable_p(X86_EFLAGS_ID);
 }
 
+static bool has_mtrr(void)
+{
+       return cpuid_edx(0x00000001) & (1 << 12) ? true : false;
+}
+
 static int build_vendor_name(char *vendor_name)
 {
        struct cpuid_result result;
@@ -318,6 +323,8 @@ int x86_cpu_init_f(void)
                gd->arch.x86_model = c.x86_model;
                gd->arch.x86_mask = c.x86_mask;
                gd->arch.x86_device = cpu.device;
+
+               gd->arch.has_mtrr = has_mtrr();
        }
 
        return 0;
index afca9579da29065bab64312c429b6a073039311f..e4595be3aeba81a9efee5d786929c0037143c1b1 100644 (file)
@@ -26,20 +26,6 @@ config CACHE_MRC_SIZE_KB
        int
        default 256
 
-config MRC_CACHE_BASE
-       hex
-       default 0xff800000
-
-config MRC_CACHE_LOCATION
-       hex
-       depends on !CHROMEOS
-       default 0x1ec000
-
-config MRC_CACHE_SIZE
-       hex
-       depends on !CHROMEOS
-       default 0x10000
-
 config DCACHE_RAM_BASE
        hex
        default 0xff7f0000
@@ -64,20 +50,6 @@ config CACHE_MRC_SIZE_KB
        int
        default 512
 
-config MRC_CACHE_BASE
-       hex
-       default 0xff800000
-
-config MRC_CACHE_LOCATION
-       hex
-       depends on !CHROMEOS
-       default 0x370000
-
-config MRC_CACHE_SIZE
-       hex
-       depends on !CHROMEOS
-       default 0x10000
-
 config DCACHE_RAM_BASE
        hex
        default 0xff7e0000
index 0c7efaec7ceed9c9d43aeb40b4cb5c2470d5d646..3576b83266b5b19e598408218920a21eec5a0f13 100644 (file)
@@ -14,6 +14,7 @@ obj-y += lpc.o
 obj-y += me_status.o
 obj-y += model_206ax.o
 obj-y += microcode_intel.o
+obj-y += mrccache.o
 obj-y += northbridge.o
 obj-y += pch.o
 obj-y += pci.o
diff --git a/arch/x86/cpu/ivybridge/mrccache.c b/arch/x86/cpu/ivybridge/mrccache.c
new file mode 100644 (file)
index 0000000..0f1a64b
--- /dev/null
@@ -0,0 +1,156 @@
+/*
+ * From Coreboot src/southbridge/intel/bd82x6x/mrccache.c
+ *
+ * Copyright (C) 2014 Google Inc.
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#include <common.h>
+#include <errno.h>
+#include <fdtdec.h>
+#include <net.h>
+#include <spi.h>
+#include <spi_flash.h>
+#include <asm/arch/mrccache.h>
+#include <asm/arch/sandybridge.h>
+
+static struct mrc_data_container *next_mrc_block(
+       struct mrc_data_container *mrc_cache)
+{
+       /* MRC data blocks are aligned within the region */
+       u32 mrc_size = sizeof(*mrc_cache) + mrc_cache->data_size;
+       if (mrc_size & (MRC_DATA_ALIGN - 1UL)) {
+               mrc_size &= ~(MRC_DATA_ALIGN - 1UL);
+               mrc_size += MRC_DATA_ALIGN;
+       }
+
+       u8 *region_ptr = (u8 *)mrc_cache;
+       region_ptr += mrc_size;
+       return (struct mrc_data_container *)region_ptr;
+}
+
+static int is_mrc_cache(struct mrc_data_container *cache)
+{
+       return cache && (cache->signature == MRC_DATA_SIGNATURE);
+}
+
+/*
+ * Find the largest index block in the MRC cache. Return NULL if none is
+ * found.
+ */
+struct mrc_data_container *mrccache_find_current(struct fmap_entry *entry)
+{
+       struct mrc_data_container *cache, *next;
+       ulong base_addr, end_addr;
+       uint id;
+
+       base_addr = (1ULL << 32) - CONFIG_ROM_SIZE + entry->offset;
+       end_addr = base_addr + entry->length;
+       cache = NULL;
+
+       /* Search for the last filled entry in the region */
+       for (id = 0, next = (struct mrc_data_container *)base_addr;
+            is_mrc_cache(next);
+            id++) {
+               cache = next;
+               next = next_mrc_block(next);
+               if ((ulong)next >= end_addr)
+                       break;
+       }
+
+       if (id-- == 0) {
+               debug("%s: No valid MRC cache found.\n", __func__);
+               return NULL;
+       }
+
+       /* Verify checksum */
+       if (cache->checksum != compute_ip_checksum(cache->data,
+                                                  cache->data_size)) {
+               printf("%s: MRC cache checksum mismatch\n", __func__);
+               return NULL;
+       }
+
+       debug("%s: picked entry %u from cache block\n", __func__, id);
+
+       return cache;
+}
+
+/**
+ * find_next_mrc_cache() - get next cache entry
+ *
+ * @entry:     MRC cache flash area
+ * @cache:     Entry to start from
+ *
+ * @return next cache entry if found, NULL if we got to the end
+ */
+static struct mrc_data_container *find_next_mrc_cache(struct fmap_entry *entry,
+               struct mrc_data_container *cache)
+{
+       ulong base_addr, end_addr;
+
+       base_addr = (1ULL << 32) - CONFIG_ROM_SIZE + entry->offset;
+       end_addr = base_addr + entry->length;
+
+       cache = next_mrc_block(cache);
+       if ((ulong)cache >= end_addr) {
+               /* Crossed the boundary */
+               cache = NULL;
+               debug("%s: no available entries found\n", __func__);
+       } else {
+               debug("%s: picked next entry from cache block at %p\n",
+                     __func__, cache);
+       }
+
+       return cache;
+}
+
+int mrccache_update(struct spi_flash *sf, struct fmap_entry *entry,
+                   struct mrc_data_container *cur)
+{
+       struct mrc_data_container *cache;
+       ulong offset;
+       ulong base_addr;
+       int ret;
+
+       /* Find the last used block */
+       base_addr = (1ULL << 32) - CONFIG_ROM_SIZE + entry->offset;
+       debug("Updating MRC cache data\n");
+       cache = mrccache_find_current(entry);
+       if (cache && (cache->data_size == cur->data_size) &&
+           (!memcmp(cache, cur, cache->data_size + sizeof(*cur)))) {
+               debug("MRC data in flash is up to date. No update\n");
+               return -EEXIST;
+       }
+
+       /* Move to the next block, which will be the first unused block */
+       if (cache)
+               cache = find_next_mrc_cache(entry, cache);
+
+       /*
+        * If we have got to the end, erase the entire mrc-cache area and start
+        * again at block 0.
+        */
+       if (!cache) {
+               debug("Erasing the MRC cache region of %x bytes at %x\n",
+                     entry->length, entry->offset);
+
+               ret = spi_flash_erase(sf, entry->offset, entry->length);
+               if (ret) {
+                       debug("Failed to erase flash region\n");
+                       return ret;
+               }
+               cache = (struct mrc_data_container *)base_addr;
+       }
+
+       /* Write the data out */
+       offset = (ulong)cache - base_addr + entry->offset;
+       debug("Write MRC cache update to flash at %lx\n", offset);
+       ret = spi_flash_write(sf, offset, cur->data_size + sizeof(*cur), cur);
+       if (ret) {
+               debug("Failed to write to SPI flash\n");
+               return ret;
+       }
+
+       return 0;
+}
index 95047359ffaca080dfaf3820d0d8c16ceefc9dfe..49634485f3e249cdba4ac793537506baac1ba2bb 100644 (file)
 #include <errno.h>
 #include <fdtdec.h>
 #include <malloc.h>
+#include <net.h>
+#include <rtc.h>
+#include <spi.h>
+#include <spi_flash.h>
 #include <asm/processor.h>
 #include <asm/gpio.h>
 #include <asm/global_data.h>
 #include <asm/mtrr.h>
 #include <asm/pci.h>
 #include <asm/arch/me.h>
+#include <asm/arch/mrccache.h>
 #include <asm/arch/pei_data.h>
 #include <asm/arch/pch.h>
 #include <asm/post.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
+#define CMOS_OFFSET_MRC_SEED           152
+#define CMOS_OFFSET_MRC_SEED_S3                156
+#define CMOS_OFFSET_MRC_SEED_CHK       160
+
 /*
  * This function looks for the highest region of memory lower than 4GB which
  * has enough space for U-Boot where U-Boot is aligned on a page boundary.
@@ -80,6 +89,202 @@ void dram_init_banksize(void)
        }
 }
 
+static int get_mrc_entry(struct spi_flash **sfp, struct fmap_entry *entry)
+{
+       const void *blob = gd->fdt_blob;
+       int node, spi_node, mrc_node;
+       int upto;
+
+       /* Find the flash chip within the SPI controller node */
+       upto = 0;
+       spi_node = fdtdec_next_alias(blob, "spi", COMPAT_INTEL_ICH_SPI, &upto);
+       if (spi_node < 0)
+               return -ENOENT;
+       node = fdt_first_subnode(blob, spi_node);
+       if (node < 0)
+               return -ECHILD;
+
+       /* Find the place where we put the MRC cache */
+       mrc_node = fdt_subnode_offset(blob, node, "rw-mrc-cache");
+       if (mrc_node < 0)
+               return -EPERM;
+
+       if (fdtdec_read_fmap_entry(blob, mrc_node, "rm-mrc-cache", entry))
+               return -EINVAL;
+
+       if (sfp) {
+               *sfp = spi_flash_probe_fdt(blob, node, spi_node);
+               if (!*sfp)
+                       return -EBADF;
+       }
+
+       return 0;
+}
+
+static int read_seed_from_cmos(struct pei_data *pei_data)
+{
+       u16 c1, c2, checksum, seed_checksum;
+
+       /*
+        * Read scrambler seeds from CMOS RAM. We don't want to store them in
+        * SPI flash since they change on every boot and that would wear down
+        * the flash too much. So we store these in CMOS and the large MRC
+        * data in SPI flash.
+        */
+       pei_data->scrambler_seed = rtc_read32(CMOS_OFFSET_MRC_SEED);
+       debug("Read scrambler seed    0x%08x from CMOS 0x%02x\n",
+             pei_data->scrambler_seed, CMOS_OFFSET_MRC_SEED);
+
+       pei_data->scrambler_seed_s3 = rtc_read32(CMOS_OFFSET_MRC_SEED_S3);
+       debug("Read S3 scrambler seed 0x%08x from CMOS 0x%02x\n",
+             pei_data->scrambler_seed_s3, CMOS_OFFSET_MRC_SEED_S3);
+
+       /* Compute seed checksum and compare */
+       c1 = compute_ip_checksum((u8 *)&pei_data->scrambler_seed,
+                                sizeof(u32));
+       c2 = compute_ip_checksum((u8 *)&pei_data->scrambler_seed_s3,
+                                sizeof(u32));
+       checksum = add_ip_checksums(sizeof(u32), c1, c2);
+
+       seed_checksum = rtc_read8(CMOS_OFFSET_MRC_SEED_CHK);
+       seed_checksum |= rtc_read8(CMOS_OFFSET_MRC_SEED_CHK + 1) << 8;
+
+       if (checksum != seed_checksum) {
+               debug("%s: invalid seed checksum\n", __func__);
+               pei_data->scrambler_seed = 0;
+               pei_data->scrambler_seed_s3 = 0;
+               return -EINVAL;
+       }
+
+       return 0;
+}
+
+static int prepare_mrc_cache(struct pei_data *pei_data)
+{
+       struct mrc_data_container *mrc_cache;
+       struct fmap_entry entry;
+       int ret;
+
+       ret = read_seed_from_cmos(pei_data);
+       if (ret)
+               return ret;
+       ret = get_mrc_entry(NULL, &entry);
+       if (ret)
+               return ret;
+       mrc_cache = mrccache_find_current(&entry);
+       if (!mrc_cache)
+               return -ENOENT;
+
+       /*
+        * TODO(sjg@chromium.org): Skip this for now as it causes boot
+        * problems
+        */
+       if (0) {
+               pei_data->mrc_input = mrc_cache->data;
+               pei_data->mrc_input_len = mrc_cache->data_size;
+       }
+       debug("%s: at %p, size %x checksum %04x\n", __func__,
+             pei_data->mrc_input, pei_data->mrc_input_len,
+             mrc_cache->checksum);
+
+       return 0;
+}
+
+static int build_mrc_data(struct mrc_data_container **datap)
+{
+       struct mrc_data_container *data;
+       int orig_len;
+       int output_len;
+
+       orig_len = gd->arch.mrc_output_len;
+       output_len = ALIGN(orig_len, 16);
+       data = malloc(output_len + sizeof(*data));
+       if (!data)
+               return -ENOMEM;
+       data->signature = MRC_DATA_SIGNATURE;
+       data->data_size = output_len;
+       data->reserved = 0;
+       memcpy(data->data, gd->arch.mrc_output, orig_len);
+
+       /* Zero the unused space in aligned buffer. */
+       if (output_len > orig_len)
+               memset(data->data + orig_len, 0, output_len - orig_len);
+
+       data->checksum = compute_ip_checksum(data->data, output_len);
+       *datap = data;
+
+       return 0;
+}
+
+static int write_seeds_to_cmos(struct pei_data *pei_data)
+{
+       u16 c1, c2, checksum;
+
+       /* Save the MRC seed values to CMOS */
+       rtc_write32(CMOS_OFFSET_MRC_SEED, pei_data->scrambler_seed);
+       debug("Save scrambler seed    0x%08x to CMOS 0x%02x\n",
+             pei_data->scrambler_seed, CMOS_OFFSET_MRC_SEED);
+
+       rtc_write32(CMOS_OFFSET_MRC_SEED_S3, pei_data->scrambler_seed_s3);
+       debug("Save s3 scrambler seed 0x%08x to CMOS 0x%02x\n",
+             pei_data->scrambler_seed_s3, CMOS_OFFSET_MRC_SEED_S3);
+
+       /* Save a simple checksum of the seed values */
+       c1 = compute_ip_checksum((u8 *)&pei_data->scrambler_seed,
+                                sizeof(u32));
+       c2 = compute_ip_checksum((u8 *)&pei_data->scrambler_seed_s3,
+                                sizeof(u32));
+       checksum = add_ip_checksums(sizeof(u32), c1, c2);
+
+       rtc_write8(CMOS_OFFSET_MRC_SEED_CHK, checksum & 0xff);
+       rtc_write8(CMOS_OFFSET_MRC_SEED_CHK + 1, (checksum >> 8) & 0xff);
+
+       return 0;
+}
+
+static int sdram_save_mrc_data(void)
+{
+       struct mrc_data_container *data;
+       struct fmap_entry entry;
+       struct spi_flash *sf;
+       int ret;
+
+       if (!gd->arch.mrc_output_len)
+               return 0;
+       debug("Saving %d bytes of MRC output data to SPI flash\n",
+             gd->arch.mrc_output_len);
+
+       ret = get_mrc_entry(&sf, &entry);
+       if (ret)
+               goto err_entry;
+       ret = build_mrc_data(&data);
+       if (ret)
+               goto err_data;
+       ret = mrccache_update(sf, &entry, data);
+       if (!ret)
+               debug("Saved MRC data with checksum %04x\n", data->checksum);
+
+       free(data);
+err_data:
+       spi_flash_free(sf);
+err_entry:
+       if (ret)
+               debug("%s: Failed: %d\n", __func__, ret);
+       return ret;
+}
+
+/* Use this hook to save our SDRAM parameters */
+int misc_init_r(void)
+{
+       int ret;
+
+       ret = sdram_save_mrc_data();
+       if (ret)
+               printf("Unable to save MRC data: %d\n", ret);
+
+       return 0;
+}
+
 static const char *const ecc_decoder[] = {
        "inactive",
        "active on IO",
@@ -142,6 +347,11 @@ static asmlinkage void console_tx_byte(unsigned char byte)
 #endif
 }
 
+static int recovery_mode_enabled(void)
+{
+       return false;
+}
+
 /**
  * Find the PEI executable in the ROM and execute it.
  *
@@ -166,6 +376,17 @@ int sdram_initialise(struct pei_data *pei_data)
 
        debug("Starting UEFI PEI System Agent\n");
 
+       /*
+        * Do not pass MRC data in for recovery mode boot,
+        * Always pass it in for S3 resume.
+        */
+       if (!recovery_mode_enabled() ||
+           pei_data->boot_mode == PEI_BOOT_RESUME) {
+               ret = prepare_mrc_cache(pei_data);
+               if (ret)
+                       debug("prepare_mrc_cache failed: %d\n", ret);
+       }
+
        /* If MRC data is not found we cannot continue S3 resume. */
        if (pei_data->boot_mode == PEI_BOOT_RESUME && !pei_data->mrc_input) {
                debug("Giving up in sdram_initialize: No MRC data\n");
@@ -216,6 +437,8 @@ int sdram_initialise(struct pei_data *pei_data)
        debug("System Agent Version %d.%d.%d Build %d\n",
              version >> 24 , (version >> 16) & 0xff,
              (version >> 8) & 0xff, version & 0xff);
+       debug("MCR output data length %#x at %p\n", pei_data->mrc_output_len,
+             pei_data->mrc_output);
 
        /*
         * Send ME init done for SandyBridge here.  This is done inside the
@@ -231,6 +454,36 @@ int sdram_initialise(struct pei_data *pei_data)
        post_system_agent_init(pei_data);
        report_memory_config();
 
+       /* S3 resume: don't save scrambler seed or MRC data */
+       if (pei_data->boot_mode != PEI_BOOT_RESUME) {
+               /*
+                * This will be copied to SDRAM in reserve_arch(), then written
+                * to SPI flash in sdram_save_mrc_data()
+                */
+               gd->arch.mrc_output = (char *)pei_data->mrc_output;
+               gd->arch.mrc_output_len = pei_data->mrc_output_len;
+               ret = write_seeds_to_cmos(pei_data);
+               if (ret)
+                       debug("Failed to write seeds to CMOS: %d\n", ret);
+       }
+
+       return 0;
+}
+
+int reserve_arch(void)
+{
+       u16 checksum;
+
+       checksum = compute_ip_checksum(gd->arch.mrc_output,
+                                      gd->arch.mrc_output_len);
+       debug("Saving %d bytes for MRC output data, checksum %04x\n",
+             gd->arch.mrc_output_len, checksum);
+       gd->start_addr_sp -= gd->arch.mrc_output_len;
+       memcpy((void *)gd->start_addr_sp, gd->arch.mrc_output,
+              gd->arch.mrc_output_len);
+       gd->arch.mrc_output = (char *)gd->start_addr_sp;
+       gd->start_addr_sp &= ~0xf;
+
        return 0;
 }
 
index d5a825d1815edbee282d4b12a7c90b4dedc3c09c..5d36b3e0204d63cd9a15d2829cd9c96d48100fe2 100644 (file)
 #include <asm/msr.h>
 #include <asm/mtrr.h>
 
+DECLARE_GLOBAL_DATA_PTR;
+
 /* Prepare to adjust MTRRs */
 void mtrr_open(struct mtrr_state *state)
 {
+       if (!gd->arch.has_mtrr)
+               return;
+
        state->enable_cache = dcache_status();
 
        if (state->enable_cache)
@@ -31,6 +36,9 @@ void mtrr_open(struct mtrr_state *state)
 /* Clean up after adjusting MTRRs, and enable them */
 void mtrr_close(struct mtrr_state *state)
 {
+       if (!gd->arch.has_mtrr)
+               return;
+
        wrmsrl(MTRR_DEF_TYPE_MSR, state->deftype | MTRR_DEF_TYPE_EN);
        if (state->enable_cache)
                enable_caches();
@@ -43,6 +51,9 @@ int mtrr_commit(bool do_caches)
        uint64_t mask;
        int i;
 
+       if (!gd->arch.has_mtrr)
+               return -ENOSYS;
+
        mtrr_open(&state);
        for (i = 0; i < gd->arch.mtrr_req_count; i++, req++) {
                mask = ~(req->size - 1);
@@ -64,6 +75,9 @@ int mtrr_add_request(int type, uint64_t start, uint64_t size)
        struct mtrr_request *req;
        uint64_t mask;
 
+       if (!gd->arch.has_mtrr)
+               return -ENOSYS;
+
        if (gd->arch.mtrr_req_count == MAX_MTRR_REQUESTS)
                return -ENOSPC;
        req = &gd->arch.mtrr_req[gd->arch.mtrr_req_count++];
index 9550502e9ae8f58e79f24929945058a006924d4a..826e2b43615dbfd6775cd22ec08d58266a26913b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  U-boot - x86 Startup Code
+ *  U-Boot - x86 Startup Code
  *
  * (C) Copyright 2008-2011
  * Graeme Russ, <graeme.russ@gmail.com>
@@ -28,7 +28,7 @@ start16:
        movl    $GD_FLG_COLD_BOOT, %ebx
 
        xorl    %eax, %eax
-       movl    %eax, %cr3    /* Invalidate TLB */
+       movl    %eax, %cr3      /* Invalidate TLB */
 
        /* Turn off cache (this might require a 486-class CPU) */
        movl    %cr0, %eax
@@ -49,7 +49,7 @@ o32 cs        lgdt    gdt_ptr
        jmp     ff
 ff:
 
-       /* Finally restore BIST and jump to the 32bit initialization code */
+       /* Finally restore BIST and jump to the 32-bit initialization code */
        movw    $code32start, %ax
        movw    %ax, %bp
        movl    %ecx, %eax
@@ -64,17 +64,17 @@ idt_ptr:
        .word   0               /* limit */
        .long   0               /* base */
 
-/*
- * The following Global Descriptor Table is just enough to get us into
- * 'Flat Protected Mode' - It will be discarded as soon as the final
- * GDT is setup in a safe location in RAM
- */
+       /*
       * The following Global Descriptor Table is just enough to get us into
       * 'Flat Protected Mode' - It will be discarded as soon as the final
       * GDT is setup in a safe location in RAM
       */
 gdt_ptr:
        .word   0x1f            /* limit (31 bytes = 4 GDT entries - 1) */
        .long   BOOT_SEG + gdt  /* base */
 
-/* Some CPUs are picky about GDT alignment... */
-.align 16
+       /* Some CPUs are picky about GDT alignment... */
+       .align  16
 gdt:
        /*
         * The GDT table ...
index 9490b169fb52a3e30c48adca4bef6ffdb148d1f3..45ada610b348e84fd2b80f463a3aaedd6d6ebc88 100644 (file)
@@ -7,6 +7,10 @@
        model = "Google Link";
        compatible = "google,link", "intel,celeron-ivybridge";
 
+       aliases {
+               spi0 = "/spi";
+       };
+
        config {
               silent_console = <0>;
        };
        spi {
                #address-cells = <1>;
                #size-cells = <0>;
-               compatible = "intel,ich9";
+               compatible = "intel,ich-spi";
                spi-flash@0 {
+                       #size-cells = <1>;
+                       #address-cells = <1>;
                        reg = <0>;
                        compatible = "winbond,w25q64", "spi-flash";
                        memory-map = <0xff800000 0x00800000>;
+                       rw-mrc-cache {
+                               label = "rw-mrc-cache";
+                               /* Alignment: 4k (for updating) */
+                               reg = <0x003e0000 0x00010000>;
+                               type = "wiped";
+                               wipe-value = [ff];
+                       };
                };
        };
 
diff --git a/arch/x86/include/asm/arch-coreboot/ipchecksum.h b/arch/x86/include/asm/arch-coreboot/ipchecksum.h
deleted file mode 100644 (file)
index 1d73b4d..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * This file is part of the libpayload project.
- *
- * It has originally been taken from the FreeBSD project.
- *
- * Copyright (c) 2001 Charles Mott <cm@linktel.net>
- * Copyright (c) 2008 coresystems GmbH
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef _COREBOOT_IPCHECKSUM_H
-#define _COREBOOT_IPCHECKSUM_H
-
-unsigned short ipchksum(const void *vptr, unsigned long nbytes);
-
-#endif
diff --git a/arch/x86/include/asm/arch-ivybridge/mrccache.h b/arch/x86/include/asm/arch-ivybridge/mrccache.h
new file mode 100644 (file)
index 0000000..968b2ef
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2014 Google, Inc
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#ifndef _ASM_ARCH_MRCCACHE_H
+#define _ASM_ARCH_MRCCACHE_H
+
+#define MRC_DATA_ALIGN         0x1000
+#define MRC_DATA_SIGNATURE     (('M' << 0) | ('R' << 8) | ('C' << 16) | \
+                                       ('D'<<24))
+
+__packed struct mrc_data_container {
+       u32     signature;      /* "MRCD" */
+       u32     data_size;      /* Size of the 'data' field */
+       u32     checksum;       /* IP style checksum */
+       u32     reserved;       /* For header alignment */
+       u8      data[0];        /* Variable size, platform/run time dependent */
+};
+
+struct fmap_entry;
+struct spi_flash;
+
+/**
+ * mrccache_find_current() - find the latest MRC cache record
+ *
+ * This searches the MRC cache region looking for the latest record to use
+ * for setting up SDRAM
+ *
+ * @entry:     Information about the position and size of the MRC cache
+ * @return pointer to latest record, or NULL if none
+ */
+struct mrc_data_container *mrccache_find_current(struct fmap_entry *entry);
+
+/**
+ * mrccache_update() - update the MRC cache with a new record
+ *
+ * This writes a new record to the end of the MRC cache. If the new record is
+ * the same as the latest record then the write is skipped
+ *
+ * @sf:                SPI flash to write to
+ * @entry:     Position and size of MRC cache in SPI flash
+ * @cur:       Record to write
+ * @return 0 if updated, -EEXIST if the record is the same as the latest
+ * record, other error if SPI write failed
+ */
+int mrccache_update(struct spi_flash *sf, struct fmap_entry *entry,
+                   struct mrc_data_container *cur);
+
+#endif
index 24e305239b2164c5a91cdbd73b8bbadd655557f3..5ee06eb70d97da4323ed00e66a3d718f759c9631 100644 (file)
@@ -44,11 +44,11 @@ struct mtrr_request {
 
 /* Architecture-specific global data */
 struct arch_global_data {
-       struct global_data *gd_addr;            /* Location of Global Data */
-       uint8_t  x86;                   /* CPU family */
-       uint8_t  x86_vendor;            /* CPU vendor */
-       uint8_t  x86_model;
-       uint8_t  x86_mask;
+       struct global_data *gd_addr;    /* Location of Global Data */
+       uint8_t x86;                    /* CPU family */
+       uint8_t x86_vendor;             /* CPU vendor */
+       uint8_t x86_model;
+       uint8_t x86_mask;
        uint32_t x86_device;
        uint64_t tsc_base;              /* Initial value returned by rdtsc() */
        uint32_t tsc_base_kclocks;      /* Initial tsc as a kclocks value */
@@ -60,10 +60,14 @@ struct arch_global_data {
        const struct pch_gpio_map *gpio_map;    /* board GPIO map */
        struct memory_info meminfo;     /* Memory information */
 #ifdef CONFIG_HAVE_FSP
-       void    *hob_list;              /* FSP HOB list */
+       void *hob_list;                 /* FSP HOB list */
 #endif
        struct mtrr_request mtrr_req[MAX_MTRR_REQUESTS];
        int mtrr_req_count;
+       int has_mtrr;
+       /* MRC training data to save for the next boot */
+       char *mrc_output;
+       unsigned int mrc_output_len;
 };
 
 #endif
index 3c1174043cf6f1c62c60db6cdce5d13ec6d887b3..fda4eae10d8f1262a67ed46aae5e6656b679bba2 100644 (file)
@@ -65,7 +65,6 @@ void mtrr_open(struct mtrr_state *state);
  *
  * @state:     Structure from mtrr_open()
  */
-/*  */
 void mtrr_close(struct mtrr_state *state);
 
 /**
@@ -76,6 +75,8 @@ void mtrr_close(struct mtrr_state *state);
  * @type:      Requested type (MTRR_TYPE_)
  * @start:     Start address
  * @size:      Size
+ *
+ * @return:    0 on success, non-zero on failure
  */
 int mtrr_add_request(int type, uint64_t start, uint64_t size);
 
@@ -86,6 +87,8 @@ int mtrr_add_request(int type, uint64_t start, uint64_t size);
  * It must be called with caches disabled.
  *
  * @do_caches: true if caches are currently on
+ *
+ * @return:    0 on success, non-zero on failure
  */
 int mtrr_commit(bool do_caches);
 
index 36145cb0a81552fe78aa5409100b22d93d097cb1..c24846b3ed50b49a3010d62dd87d9b93b0646d08 100644 (file)
@@ -26,15 +26,9 @@ unsigned long get_tbclk_mhz(void);
 void timer_set_base(uint64_t base);
 int pcat_timer_init(void);
 
-/* Architecture specific DRAM init */
-int dram_init(void);
-
 /* cpu/.../interrupts.c */
 int cpu_init_interrupts(void);
 
-/* board/.../... */
-int dram_init(void);
-
 int cleanup_before_linux(void);
 int x86_cleanup_before_linux(void);
 void x86_enable_caches(void);
@@ -70,4 +64,6 @@ uint64_t timer_get_tsc(void);
 
 void quick_ram_check(void);
 
+#define PCI_VGA_RAM_IMAGE_START                0xc0000
+
 #endif /* _U_BOOT_I386_H_ */
index fc211d9d5c4924e6ed924154777e534c60177322..5097ca274a147f0965fc0935db69301945bc092a 100644 (file)
@@ -7,6 +7,7 @@
 #include <common.h>
 #include <fdtdec.h>
 #include <spi.h>
+#include <asm/errno.h>
 #include <asm/mtrr.h>
 #include <asm/sections.h>
 
@@ -71,7 +72,8 @@ int init_cache_f_r(void)
        int ret;
 
        ret = mtrr_commit(false);
-       if (ret)
+       /* If MTRR MSR is not implemented by the processor, just ignore it */
+       if (ret && ret != -ENOSYS)
                return ret;
 #endif
        /* Initialise the CPU cache(s) */
index 6bb22d25e8d8edd69f880abb2469ed6b6232e750..146ad11fb5373f3223d4ece682af0cf4ce4f8f83 100644 (file)
@@ -130,7 +130,7 @@ int do_irqinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
        printf("Interrupt-Information:\n");
        printf("Nr  Routine   Arg       Count\n");
 
-       for (irq = 0; irq <= CONFIG_SYS_NUM_IRQS; irq++) {
+       for (irq = 0; irq < CONFIG_SYS_NUM_IRQS; irq++) {
                if (irq_handlers[irq].handler != NULL) {
                        printf("%02d  %08lx  %08lx  %d\n",
                                        irq,
index 5e4778e97881dd35f6793ae108c3e82019938108..76ad7c443bb9285db808c6df97d02461e94a62ed 100644 (file)
@@ -98,7 +98,7 @@ int misc_init_r(void)
                                puts("Error: invalid MAC at EEPROM\n");
                }
        }
-       gd->jt[XF_do_reset] = (void *) do_reset;
+       gd->jt->do_reset = do_reset;
 
 #ifdef CONFIG_STATUS_LED
        status_led_set(STATUS_LED_BOOT, STATUS_LED_BLINKING);
diff --git a/board/Marvell/db-mv784mp-gp/binary.0 b/board/Marvell/db-mv784mp-gp/binary.0
deleted file mode 100644 (file)
index 17bfad9..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
---------
-WARNING:
---------
-This file should contain the bin_hdr generated by the original Marvell
-U-Boot implementation. As this is currently not included in this
-U-Boot version, we have added this placeholder, so that the U-Boot
-image can be generated without errors.
-
-If you have a known to be working bin_hdr for your board, then you
-just need to replace this text file here with the binary header
-and recompile U-Boot.
-
-In a few weeks, mainline U-Boot will get support to generate the
-bin_hdr with the DDR training code itself. By implementing this code
-as SPL U-Boot. Then this file will not be needed any more and will
-get removed.
-
index d7ef4071dd06809018a92bb23b97ba66bc1059a4..cc057925566c584d66b0dc73207f5a62523ad2f6 100644 (file)
@@ -9,4 +9,4 @@ VERSION         1
 BOOT_FROM      spi
 
 # Binary Header (bin_hdr) with DDR3 training code
-BINARY board/Marvell/db-mv784mp-gp/binary.0 0000005b 00000068
+BINARY spl/u-boot-spl.bin 0000005b 00000068
index 7ebea6317f70f320928a9d7705bfed878330a10f..7d5e7bee8b9a9c4c9a9bfc0280a898e9dfff6986 100644 (file)
@@ -1,4 +1,30 @@
-if TARGET_VEXPRESS_AEMV8A
+if TARGET_VEXPRESS64_AEMV8A
+
+config SYS_BOARD
+       default "vexpress64"
+
+config SYS_VENDOR
+       default "armltd"
+
+config SYS_CONFIG_NAME
+       default "vexpress_aemv8a"
+
+endif
+
+if TARGET_VEXPRESS64_BASE_FVP
+
+config SYS_BOARD
+       default "vexpress64"
+
+config SYS_VENDOR
+       default "armltd"
+
+config SYS_CONFIG_NAME
+       default "vexpress_aemv8a"
+
+endif
+
+if TARGET_VEXPRESS64_JUNO
 
 config SYS_BOARD
        default "vexpress64"
index 66c8dffa163420a647a5c65ae2f3d9817039a196..0ba044d7ff8711816df1ba8028de0df3aacc41bb 100644 (file)
@@ -9,3 +9,8 @@ VEXPRESS_AEMV8A_SEMI BOARD
 M:     Linus Walleij <linus.walleij@linaro.org>
 S:     Maintained
 F:     configs/vexpress_aemv8a_semi_defconfig
+
+JUNO DEVELOPMENT PLATFORM BOARD
+M:     Linus Walleij <linus.walleij@linaro.org>
+S:     Maintained
+F:     configs/vexpress_aemv8a_juno_defconfig
index 2758c5cbcd6ff777d6ca923a8cf092fbf689894b..1c5b92c8b580b7d5a433e95505e98fe1ed4117cc 100644 (file)
@@ -10,6 +10,7 @@
 #include <asm/arch/at91_common.h>
 #include <asm/arch/at91_pmc.h>
 #include <asm/arch/at91_rstc.h>
+#include <asm/arch/atmel_usba_udc.h>
 #include <asm/arch/gpio.h>
 #include <asm/arch/clk.h>
 #include <asm/arch/sama5d3_smc.h>
@@ -294,6 +295,9 @@ int board_init(void)
 #ifdef CONFIG_CMD_USB
        sama5d4_xplained_usb_hw_init();
 #endif
+#ifdef CONFIG_USB_GADGET_ATMEL_USBA
+       at91_udp_hw_init();
+#endif
 
        return 0;
 }
@@ -313,5 +317,12 @@ int board_eth_init(bd_t *bis)
        rc = macb_eth_initialize(0, (void *)ATMEL_BASE_GMAC0, 0x00);
 #endif
 
+#ifdef CONFIG_USB_GADGET_ATMEL_USBA
+       usba_udc_probe(&pdata);
+#ifdef CONFIG_USB_ETH_RNDIS
+       usb_eth_initialize(bis);
+#endif
+#endif
+
        return rc;
 }
index d3039c021af08f2724c63567b2016a0802bf3234..d8ff648957413c2ee618ea231d7a3a4aa96dfb41 100644 (file)
@@ -10,6 +10,7 @@
 #include <asm/arch/at91_common.h>
 #include <asm/arch/at91_pmc.h>
 #include <asm/arch/at91_rstc.h>
+#include <asm/arch/atmel_usba_udc.h>
 #include <asm/arch/gpio.h>
 #include <asm/arch/clk.h>
 #include <asm/arch/sama5d3_smc.h>
@@ -293,6 +294,9 @@ int board_init(void)
 #ifdef CONFIG_CMD_USB
        sama5d4ek_usb_hw_init();
 #endif
+#ifdef CONFIG_USB_GADGET_ATMEL_USBA
+       at91_udp_hw_init();
+#endif
 
        return 0;
 }
@@ -312,5 +316,12 @@ int board_eth_init(bd_t *bis)
        rc = macb_eth_initialize(0, (void *)ATMEL_BASE_GMAC0, 0x00);
 #endif
 
+#ifdef CONFIG_USB_GADGET_ATMEL_USBA
+       usba_udc_probe(&pdata);
+#ifdef CONFIG_USB_ETH_RNDIS
+       usb_eth_initialize(bis);
+#endif
+#endif
+
        return rc;
 }
index 86a0844273d64a28bb361709ed1107871c9d6c99..1704627112642027a42bf1f8f13bfd8436808d09 100644 (file)
@@ -55,12 +55,12 @@ void pmu_write(uchar reg, uchar data)
        struct udevice *dev;
        int ret;
 
-       ret = i2c_get_chip_for_busnum(4, PMU_I2C_ADDRESS, &dev);
+       ret = i2c_get_chip_for_busnum(4, PMU_I2C_ADDRESS, 1, &dev);
        if (ret) {
                debug("%s: Cannot find PMIC I2C chip\n", __func__);
                return;
        }
-       i2c_write(dev, reg, &data, 1);
+       dm_i2c_write(dev, reg, &data, 1);
 }
 
 /*
index 6fe937b4180fba98add32988d9820cc73d96680f..5b4b76f5b7329ca7b99e2da04272848a10f01fb4 100644 (file)
@@ -313,7 +313,6 @@ void board_init_f(ulong dummy)
 {
        struct mxc_ccm_reg *mxc_ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR;
 
-       gd = &gdata;
        /*
         * We don't use DMA in SPL, but we do need it in U-Boot. U-Boot
         * initializes DMA very early (before all board code), so the only
diff --git a/board/dave/PPChameleonEVB/Kconfig b/board/dave/PPChameleonEVB/Kconfig
deleted file mode 100644 (file)
index bfe0011..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-if TARGET_CATCENTER
-
-config SYS_BOARD
-       default "PPChameleonEVB"
-
-config SYS_VENDOR
-       default "dave"
-
-config SYS_CONFIG_NAME
-       default "CATcenter"
-
-endif
-
-if TARGET_PPCHAMELEONEVB
-
-config SYS_BOARD
-       default "PPChameleonEVB"
-
-config SYS_VENDOR
-       default "dave"
-
-config SYS_CONFIG_NAME
-       default "PPChameleonEVB"
-
-endif
diff --git a/board/dave/PPChameleonEVB/MAINTAINERS b/board/dave/PPChameleonEVB/MAINTAINERS
deleted file mode 100644 (file)
index d43c6d0..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-PPCHAMELEONEVB BOARD
-#M:    -
-S:     Maintained
-F:     board/dave/PPChameleonEVB/
-F:     include/configs/CATcenter.h
-F:     configs/CATcenter_defconfig
-F:     configs/CATcenter_25_defconfig
-F:     configs/CATcenter_33_defconfig
-
-PPCHAMELEONEVB BOARD
-M:     Andrea "llandre" Marson <andrea.marson@dave-tech.it>
-S:     Maintained
-F:     include/configs/PPChameleonEVB.h
-F:     configs/PPChameleonEVB_defconfig
-F:     configs/PPChameleonEVB_BA_25_defconfig
-F:     configs/PPChameleonEVB_BA_33_defconfig
-F:     configs/PPChameleonEVB_HI_25_defconfig
-F:     configs/PPChameleonEVB_HI_33_defconfig
-F:     configs/PPChameleonEVB_ME_25_defconfig
-F:     configs/PPChameleonEVB_ME_33_defconfig
diff --git a/board/dave/PPChameleonEVB/Makefile b/board/dave/PPChameleonEVB/Makefile
deleted file mode 100644 (file)
index 31edc4a..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-#
-# (C) Copyright 2000-2006
-# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
-#
-# SPDX-License-Identifier:     GPL-2.0+
-#
-
-obj-y  = PPChameleonEVB.o flash.o nand.o
diff --git a/board/dave/PPChameleonEVB/PPChameleonEVB.c b/board/dave/PPChameleonEVB/PPChameleonEVB.c
deleted file mode 100644 (file)
index c9ab50e..0000000
+++ /dev/null
@@ -1,231 +0,0 @@
-/*
- * (C) Copyright 2003
- * DAVE Srl
- * http://www.dave-tech.it
- * http://www.wawnet.biz
- * mailto:info@wawnet.biz
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#include <common.h>
-#include <asm/processor.h>
-#include <command.h>
-#include <malloc.h>
-
-DECLARE_GLOBAL_DATA_PTR;
-
-/* ------------------------------------------------------------------------- */
-
-int board_early_init_f (void)
-{
-       out32(GPIO0_OR, CONFIG_SYS_NAND0_CE);                 /* set initial outputs     */
-       out32(GPIO0_OR, CONFIG_SYS_NAND1_CE);                 /* set initial outputs     */
-
-       /*
-        * IRQ 0-15  405GP internally generated; active high; level sensitive
-        * IRQ 16    405GP internally generated; active low; level sensitive
-        * IRQ 17-24 RESERVED
-        * IRQ 25 (EXT IRQ 0)
-        * IRQ 26 (EXT IRQ 1)
-        * IRQ 27 (EXT IRQ 2)
-        * IRQ 28 (EXT IRQ 3)
-        * IRQ 29 (EXT IRQ 4)
-        * IRQ 30 (EXT IRQ 5)
-        * IRQ 31 (EXT IRQ 6)
-        */
-       mtdcr(UIC0SR, 0xFFFFFFFF);       /* clear all ints */
-       mtdcr(UIC0ER, 0x00000000);       /* disable all ints */
-       mtdcr(UIC0CR, 0x00000000);       /* set all to be non-critical*/
-       mtdcr(UIC0PR, 0xFFFFFF80);       /* set int polarities */
-       mtdcr(UIC0TR, 0x10000000);       /* set int trigger levels */
-       mtdcr(UIC0VCR, 0x00000001);      /* set vect base=0,INT0 highest priority*/
-       mtdcr(UIC0SR, 0xFFFFFFFF);       /* clear all ints */
-
-       /*
-        * EBC Configuration Register: set ready timeout to 512 ebc-clks -> ca. 15 us
-        */
-#if 1 /* test-only */
-       mtebc (EBC0_CFG, 0xa8400000); /* ebc always driven */
-#else
-       mtebc (EBC0_CFG, 0x28400000); /* ebc in high-z */
-#endif
-       return 0;
-}
-
-/* ------------------------------------------------------------------------- */
-
-int misc_init_f (void)
-{
-       return 0;  /* dummy implementation */
-}
-
-extern flash_info_t flash_info[];      /* info for FLASH chips */
-
-int misc_init_r (void)
-{
-       /* adjust flash start and size as well as the offset */
-       gd->bd->bi_flashstart = 0 - flash_info[0].size;
-       gd->bd->bi_flashoffset= flash_info[0].size - CONFIG_SYS_MONITOR_LEN;
-#if 0
-       volatile unsigned short *fpga_mode =
-               (unsigned short *)((ulong)CONFIG_SYS_FPGA_BASE_ADDR + CONFIG_SYS_FPGA_CTRL);
-       volatile unsigned char *duart0_mcr =
-               (unsigned char *)((ulong)DUART0_BA + 4);
-       volatile unsigned char *duart1_mcr =
-               (unsigned char *)((ulong)DUART1_BA + 4);
-
-       bd_t *bd = gd->bd;
-       char *  tmp;                    /* Temporary char pointer      */
-       unsigned char *dst;
-       ulong len = sizeof(fpgadata);
-       int status;
-       int index;
-       int i;
-       unsigned long CPC0_CR0Reg;
-
-       dst = malloc(CONFIG_SYS_FPGA_MAX_SIZE);
-       if (gunzip (dst, CONFIG_SYS_FPGA_MAX_SIZE, (uchar *)fpgadata, &len) != 0) {
-               printf ("GUNZIP ERROR - must RESET board to recover\n");
-               do_reset (NULL, 0, 0, NULL);
-       }
-
-       status = fpga_boot(dst, len);
-       if (status != 0) {
-               printf("\nFPGA: Booting failed ");
-               switch (status) {
-               case ERROR_FPGA_PRG_INIT_LOW:
-                       printf("(Timeout: INIT not low after asserting PROGRAM*)\n ");
-                       break;
-               case ERROR_FPGA_PRG_INIT_HIGH:
-                       printf("(Timeout: INIT not high after deasserting PROGRAM*)\n ");
-                       break;
-               case ERROR_FPGA_PRG_DONE:
-                       printf("(Timeout: DONE not high after programming FPGA)\n ");
-                       break;
-               }
-
-               /* display infos on fpgaimage */
-               index = 15;
-               for (i=0; i<4; i++) {
-                       len = dst[index];
-                       printf("FPGA: %s\n", &(dst[index+1]));
-                       index += len+3;
-               }
-               putc ('\n');
-               /* delayed reboot */
-               for (i=20; i>0; i--) {
-                       printf("Rebooting in %2d seconds \r",i);
-                       for (index=0;index<1000;index++)
-                               udelay(1000);
-               }
-               putc ('\n');
-               do_reset(NULL, 0, 0, NULL);
-       }
-
-       puts("FPGA:  ");
-
-       /* display infos on fpgaimage */
-       index = 15;
-       for (i=0; i<4; i++) {
-               len = dst[index];
-               printf("%s ", &(dst[index+1]));
-               index += len+3;
-       }
-       putc ('\n');
-
-       free(dst);
-
-       /*
-        * Reset FPGA via FPGA_DATA pin
-        */
-       SET_FPGA(FPGA_PRG | FPGA_CLK);
-       udelay(1000); /* wait 1ms */
-       SET_FPGA(FPGA_PRG | FPGA_CLK | FPGA_DATA);
-       udelay(1000); /* wait 1ms */
-#endif
-
-#if 0
-       /*
-        * Enable power on PS/2 interface
-        */
-       *fpga_mode |= CONFIG_SYS_FPGA_CTRL_PS2_RESET;
-
-       /*
-        * Enable interrupts in exar duart mcr[3]
-        */
-       *duart0_mcr = 0x08;
-       *duart1_mcr = 0x08;
-#endif
-       return (0);
-}
-
-/*
- * Check Board Identity:
- */
-
-int checkboard (void)
-{
-       char str[64];
-       int i = getenv_f("serial#", str, sizeof(str));
-
-       puts ("Board: ");
-
-       if (i == -1) {
-               puts ("### No HW ID - assuming PPChameleonEVB");
-       } else {
-               puts(str);
-       }
-
-       putc ('\n');
-
-       return 0;
-}
-
-/* ------------------------------------------------------------------------- */
-
-int testdram (void)
-{
-       /* TODO: XXX XXX XXX */
-       printf ("test: 16 MB - ok\n");
-
-       return (0);
-}
-
-/* ------------------------------------------------------------------------- */
-
-#ifdef CONFIG_CFB_CONSOLE
-# ifdef CONFIG_CONSOLE_EXTRA_INFO
-# include <video_fb.h>
-extern GraphicDevice smi;
-
-void video_get_info_str (int line_number, char *info)
-{
-       uint pvr = get_pvr ();
-
-       /* init video info strings for graphic console */
-       switch (line_number) {
-       case 1:
-               switch (pvr) {
-               case PVR_405EP_RB:
-                       sprintf (info, " AMCC PowerPC 405EP Rev. B");
-                       break;
-               default:
-                       sprintf (info, " AMCC PowerPC 405EP Rev. <unknown>");
-                       break;
-               }
-               return;
-       case 2:
-               sprintf (info, " DAVE Srl PPChameleonEVB - www.dave-tech.it");
-               return;
-       case 3:
-               sprintf (info, " %s", smi.modeIdent);
-               return;
-       }
-
-       /* no more info lines */
-       *info = 0;
-       return;
-}
-# endif        /* CONFIG_CONSOLE_EXTRA_INFO */
-#endif /* CONFIG_CFB_CONSOLE */
diff --git a/board/dave/PPChameleonEVB/flash.c b/board/dave/PPChameleonEVB/flash.c
deleted file mode 100644 (file)
index 771151b..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * (C) Copyright 2001
- * Stefan Roese, esd gmbh germany, stefan.roese@esd-electronics.com
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#include <common.h>
-#include <asm/ppc4xx.h>
-#include <asm/processor.h>
-
-/*
- * include common flash code (for esd boards)
- */
-#include "../common/flash.c"
-
-/*-----------------------------------------------------------------------
- * Functions
- */
-static ulong flash_get_size (vu_long * addr, flash_info_t * info);
-static void flash_get_offsets (ulong base, flash_info_t * info);
-
-/*-----------------------------------------------------------------------
- */
-
-unsigned long flash_init (void)
-{
-#ifdef __DEBUG_START_FROM_SRAM__
-       return CONFIG_SYS_DUMMY_FLASH_SIZE;
-#else
-       unsigned long size;
-       int i;
-       uint pbcr;
-       unsigned long base;
-       int size_val = 0;
-
-       debug("[%s, %d] Entering ...\n", __FUNCTION__, __LINE__);
-       debug("[%s, %d] flash_info = 0x%p ...\n", __func__, __LINE__,
-                                               flash_info);
-
-       /* Init: no FLASHes known */
-       for (i=0; i<CONFIG_SYS_MAX_FLASH_BANKS; ++i) {
-               flash_info[i].flash_id = FLASH_UNKNOWN;
-       }
-
-       /* Static FLASH Bank configuration here - FIXME XXX */
-
-       debug("[%s, %d] Calling flash_get_size ...\n", __FUNCTION__, __LINE__);
-       size = flash_get_size((vu_long *)FLASH_BASE0_PRELIM, &flash_info[0]);
-
-       if (flash_info[0].flash_id == FLASH_UNKNOWN) {
-               printf ("## Unknown FLASH on Bank 0 - Size = 0x%08lx = %ld MB\n",
-                       size, size<<20);
-       }
-
-       debug("[%s, %d] Test point ...\n", __FUNCTION__, __LINE__);
-
-       /* Setup offsets */
-       flash_get_offsets (-size, &flash_info[0]);
-       debug("[%s, %d] Test point ...\n", __FUNCTION__, __LINE__);
-
-       /* Re-do sizing to get full correct info */
-       mtdcr(EBC0_CFGADDR, PB0CR);
-       pbcr = mfdcr(EBC0_CFGDATA);
-       mtdcr(EBC0_CFGADDR, PB0CR);
-       base = -size;
-       switch (size) {
-       case 1 << 20:
-               size_val = 0;
-               break;
-       case 2 << 20:
-               size_val = 1;
-               break;
-       case 4 << 20:
-               size_val = 2;
-               break;
-       case 8 << 20:
-               size_val = 3;
-               break;
-       case 16 << 20:
-               size_val = 4;
-               break;
-       }
-       pbcr = (pbcr & 0x0001ffff) | base | (size_val << 17);
-       mtdcr(EBC0_CFGDATA, pbcr);
-       debug("[%s, %d] Test point ...\n", __FUNCTION__, __LINE__);
-
-       /* Monitor protection ON by default */
-       (void)flash_protect(FLAG_PROTECT_SET,
-                           -CONFIG_SYS_MONITOR_LEN,
-                           0xffffffff,
-                           &flash_info[0]);
-
-       debug("[%s, %d] Test point ...\n", __FUNCTION__, __LINE__);
-       flash_info[0].size  = size;
-
-       return (size);
-#endif
-}
diff --git a/board/dave/PPChameleonEVB/nand.c b/board/dave/PPChameleonEVB/nand.c
deleted file mode 100644 (file)
index a191a0c..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * (C) Copyright 2006 DENX Software Engineering
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#include <common.h>
-#include <asm/io.h>
-
-#if defined(CONFIG_CMD_NAND)
-
-#include <nand.h>
-
-/*
- * hardware specific access to control-lines
- * function borrowed from Linux 2.6 (drivers/mtd/nand/ppchameleonevb.c)
- */
-static void ppchameleonevb_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int ctrl)
-{
-       struct nand_chip *this = mtd->priv;
-       ulong base = (ulong) this->IO_ADDR_W;
-
-       if (ctrl & NAND_CTRL_CHANGE) {
-               if ( ctrl & NAND_CLE )
-                       MACRO_NAND_CTL_SETCLE((unsigned long)base);
-               else
-                       MACRO_NAND_CTL_CLRCLE((unsigned long)base);
-               if ( ctrl & NAND_ALE )
-                       MACRO_NAND_CTL_CLRCLE((unsigned long)base);
-               else
-                       MACRO_NAND_CTL_CLRALE((unsigned long)base);
-               if ( ctrl & NAND_NCE )
-                       MACRO_NAND_ENABLE_CE((unsigned long)base);
-               else
-                       MACRO_NAND_DISABLE_CE((unsigned long)base);
-       }
-
-       if (cmd != NAND_CMD_NONE)
-               writeb(cmd, this->IO_ADDR_W);
-}
-
-
-/*
- * read device ready pin
- * function +/- borrowed from Linux 2.6 (drivers/mtd/nand/ppchameleonevb.c)
- */
-static int ppchameleonevb_device_ready(struct mtd_info *mtdinfo)
-{
-       struct nand_chip *this = mtdinfo->priv;
-       ulong rb_gpio_pin;
-
-       /* use the base addr to find out which chip are we dealing with */
-       switch((ulong) this->IO_ADDR_W) {
-       case CONFIG_SYS_NAND0_BASE:
-               rb_gpio_pin = CONFIG_SYS_NAND0_RDY;
-               break;
-       case CONFIG_SYS_NAND1_BASE:
-               rb_gpio_pin = CONFIG_SYS_NAND1_RDY;
-               break;
-       default: /* this should never happen */
-               return 0;
-               break;
-       }
-
-       if (in32(GPIO0_IR) & rb_gpio_pin)
-               return 1;
-       return 0;
-}
-
-
-/*
- * Board-specific NAND initialization. The following members of the
- * argument are board-specific (per include/linux/mtd/nand.h):
- * - IO_ADDR_R?: address to read the 8 I/O lines of the flash device
- * - IO_ADDR_W?: address to write the 8 I/O lines of the flash device
- * - cmd_ctrl: hardwarespecific function for accesing control-lines
- * - dev_ready: hardwarespecific function for  accesing device ready/busy line
- * - enable_hwecc?: function to enable (reset)  hardware ecc generator. Must
- *   only be provided if a hardware ECC is available
- * - ecc.mode: mode of ecc, see defines
- * - chip_delay: chip dependent delay for transfering data from array to
- *   read regs (tR)
- * - options: various chip options. They can partly be set to inform
- *   nand_scan about special functionality. See the defines for further
- *   explanation
- * Members with a "?" were not set in the merged testing-NAND branch,
- * so they are not set here either.
- */
-int board_nand_init(struct nand_chip *nand)
-{
-
-       nand->cmd_ctrl = ppchameleonevb_hwcontrol;
-       nand->dev_ready = ppchameleonevb_device_ready;
-       nand->ecc.mode = NAND_ECC_SOFT;
-       nand->chip_delay = NAND_BIG_DELAY_US;
-       nand->options = NAND_SAMSUNG_LP_OPTIONS;
-       return 0;
-}
-#endif
diff --git a/board/dave/PPChameleonEVB/u-boot.lds b/board/dave/PPChameleonEVB/u-boot.lds
deleted file mode 100644 (file)
index 94b7076..0000000
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Copyright 2007-2009 Freescale Semiconductor, Inc.
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#include "config.h"
-
-#ifndef RESET_VECTOR_ADDRESS
-#define RESET_VECTOR_ADDRESS   0xfffffffc
-#endif
-
-OUTPUT_ARCH(powerpc)
-
-PHDRS
-{
-  text PT_LOAD;
-  bss PT_LOAD;
-}
-
-SECTIONS
-{
-  /* Read-only sections, merged into text segment: */
-  . = + SIZEOF_HEADERS;
-  .text      :
-  {
-    *(.text*)
-   } :text
-    _etext = .;
-    PROVIDE (etext = .);
-    .rodata    :
-   {
-    *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*)))
-  } :text
-
-  /* Read-write section, merged into data segment: */
-  . = (. + 0x00FF) & 0xFFFFFF00;
-  _erotext = .;
-  PROVIDE (erotext = .);
-  .reloc   :
-  {
-    _GOT2_TABLE_ = .;
-    KEEP(*(.got2))
-    KEEP(*(.got))
-    PROVIDE(_GLOBAL_OFFSET_TABLE_ = . + 4);
-    _FIXUP_TABLE_ = .;
-    KEEP(*(.fixup))
-  }
-  __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >> 2;
-  __fixup_entries = (. - _FIXUP_TABLE_) >> 2;
-
-  .data    :
-  {
-    *(.data*)
-    *(.sdata*)
-  }
-  _edata  =  .;
-  PROVIDE (edata = .);
-
-  . = .;
-
-  . = ALIGN(4);
-  .u_boot_list : {
-       KEEP(*(SORT(.u_boot_list*)));
-  }
-
-  . = .;
-  __start___ex_table = .;
-  __ex_table : { *(__ex_table) }
-  __stop___ex_table = .;
-
-  . = ALIGN(256);
-  __init_begin = .;
-  .text.init : { *(.text.init) }
-  .data.init : { *(.data.init) }
-  . = ALIGN(256);
-  __init_end = .;
-
-  ppcenv_assert = ASSERT(. < 0xFFFF8000, ".bss section too big, overlaps .ppcenv section. Please update your confguration: CONFIG_SYS_MONITOR_BASE, CONFIG_SYS_MONITOR_LEN and CONFIG_SYS_TEXT_BASE may need to be modified.");
-  . = 0xFFFF8000;
-  .ppcenv :
-  {
-    common/env_embedded.o(.ppcenv);
-  }
-
-  .resetvec RESET_VECTOR_ADDRESS :
-  {
-    KEEP(*(.resetvec))
-  } :text = 0xffff
-
-  . = RESET_VECTOR_ADDRESS + 0x4;
-
-  /*
-   * Make sure that the bss segment isn't linked at 0x0, otherwise its
-   * address won't be updated during relocation fixups.  Note that
-   * this is a temporary fix.  Code to dynamically the fixup the bss
-   * location will be added in the future.  When the bss relocation
-   * fixup code is present this workaround should be removed.
-   */
-#if (RESET_VECTOR_ADDRESS == 0xfffffffc)
-  . |= 0x10;
-#endif
-
-  __bss_start = .;
-  .bss (NOLOAD)       :
-  {
-   *(.bss*)
-   *(.sbss*)
-   *(COMMON)
-  } :bss
-
-  . = ALIGN(4);
-  __bss_end = . ;
-  PROVIDE (end = .);
-}
diff --git a/board/esd/cpci5200/Kconfig b/board/esd/cpci5200/Kconfig
deleted file mode 100644 (file)
index ddd9418..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-if TARGET_CPCI5200
-
-config SYS_BOARD
-       default "cpci5200"
-
-config SYS_VENDOR
-       default "esd"
-
-config SYS_CONFIG_NAME
-       default "cpci5200"
-
-endif
diff --git a/board/esd/cpci5200/MAINTAINERS b/board/esd/cpci5200/MAINTAINERS
deleted file mode 100644 (file)
index 184d3cc..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-CPCI5200 BOARD
-M:     Reinhard Arlt <reinhard.arlt@esd-electronics.com>
-S:     Maintained
-F:     board/esd/cpci5200/
-F:     include/configs/cpci5200.h
-F:     configs/cpci5200_defconfig
diff --git a/board/esd/cpci5200/Makefile b/board/esd/cpci5200/Makefile
deleted file mode 100644 (file)
index 8421f54..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-#
-# (C) Copyright 2003-2006
-# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
-#
-# SPDX-License-Identifier:     GPL-2.0+
-#
-
-# Objects for Xilinx JTAG programming (CPLD)
-# CPLD  = ../common/xilinx_jtag/lenval.o \
-#        ../common/xilinx_jtag/micro.o \
-#        ../common/xilinx_jtag/ports.o
-
-# obj-y        = cpci5200.o flash.o $(CPLD)
-obj-y  = cpci5200.o strataflash.o
diff --git a/board/esd/cpci5200/cpci5200.c b/board/esd/cpci5200/cpci5200.c
deleted file mode 100644 (file)
index 8bded0b..0000000
+++ /dev/null
@@ -1,284 +0,0 @@
-/*
- * (C) Copyright 2003
- * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
- *
- * (C) Copyright 2004
- * Mark Jonas, Freescale Semiconductor, mark.jonas@motorola.com.
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-/*
- * cpci5200.c - main board support/init for the esd cpci5200.
- */
-
-#include <common.h>
-#include <mpc5xxx.h>
-#include <pci.h>
-#include <command.h>
-#include <netdev.h>
-
-#include "mt46v16m16-75.h"
-
-void init_ata_reset(void);
-
-static void sdram_start(int hi_addr)
-{
-       long hi_addr_bit = hi_addr ? 0x01000000 : 0;
-
-       /* unlock mode register */
-       *(vu_long *) MPC5XXX_SDRAM_CTRL =
-           SDRAM_CONTROL | 0x80000000 | hi_addr_bit;
-       __asm__ volatile ("sync");
-
-       /* precharge all banks */
-       *(vu_long *) MPC5XXX_SDRAM_CTRL =
-           SDRAM_CONTROL | 0x80000002 | hi_addr_bit;
-       __asm__ volatile ("sync");
-
-       /* set mode register: extended mode */
-       *(vu_long *) MPC5XXX_SDRAM_MODE = SDRAM_EMODE;
-       __asm__ volatile ("sync");
-
-       /* set mode register: reset DLL */
-       *(vu_long *) MPC5XXX_SDRAM_MODE = SDRAM_MODE | 0x04000000;
-       __asm__ volatile ("sync");
-
-       /* precharge all banks */
-       *(vu_long *) MPC5XXX_SDRAM_CTRL =
-           SDRAM_CONTROL | 0x80000002 | hi_addr_bit;
-       __asm__ volatile ("sync");
-
-       /* auto refresh */
-       *(vu_long *) MPC5XXX_SDRAM_CTRL =
-           SDRAM_CONTROL | 0x80000004 | hi_addr_bit;
-       __asm__ volatile ("sync");
-
-       /* set mode register */
-       *(vu_long *) MPC5XXX_SDRAM_MODE = SDRAM_MODE;
-       __asm__ volatile ("sync");
-
-       /* normal operation */
-       *(vu_long *) MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | hi_addr_bit;
-       __asm__ volatile ("sync");
-}
-
-/*
- * ATTENTION: Although partially referenced initdram does NOT make real use
- *            use of CONFIG_SYS_SDRAM_BASE. The code does not work if CONFIG_SYS_SDRAM_BASE
- *            is something else than 0x00000000.
- */
-
-phys_size_t initdram(int board_type)
-{
-       ulong dramsize = 0;
-       ulong test1, test2;
-
-       /* setup SDRAM chip selects */
-       *(vu_long *) MPC5XXX_SDRAM_CS0CFG = 0x0000001e; /* 2G at 0x0 */
-       *(vu_long *) MPC5XXX_SDRAM_CS1CFG = 0x80000000; /* disabled */
-       __asm__ volatile ("sync");
-
-       /* setup config registers */
-       *(vu_long *) MPC5XXX_SDRAM_CONFIG1 = SDRAM_CONFIG1;
-       *(vu_long *) MPC5XXX_SDRAM_CONFIG2 = SDRAM_CONFIG2;
-       __asm__ volatile ("sync");
-
-       /* set tap delay */
-       *(vu_long *) MPC5XXX_CDM_PORCFG = SDRAM_TAPDELAY;
-       __asm__ volatile ("sync");
-
-       /* find RAM size using SDRAM CS0 only */
-       sdram_start(0);
-       test1 = get_ram_size((long *) CONFIG_SYS_SDRAM_BASE, 0x80000000);
-       sdram_start(1);
-       test2 = get_ram_size((long *) CONFIG_SYS_SDRAM_BASE, 0x80000000);
-
-       if (test1 > test2) {
-               sdram_start(0);
-               dramsize = test1;
-       } else {
-               dramsize = test2;
-       }
-
-       /* memory smaller than 1MB is impossible */
-       if (dramsize < (1 << 20)) {
-               dramsize = 0;
-       }
-
-       /* set SDRAM CS0 size according to the amount of RAM found */
-       if (dramsize > 0) {
-               *(vu_long *) MPC5XXX_SDRAM_CS0CFG =
-                   0x13 + __builtin_ffs(dramsize >> 20) - 1;
-               /* let SDRAM CS1 start right after CS0 */
-               *(vu_long *) MPC5XXX_SDRAM_CS1CFG = dramsize + 0x0000001e;      /* 2G */
-       } else {
-#if 0
-               *(vu_long *) MPC5XXX_SDRAM_CS0CFG = 0;  /* disabled */
-               /* let SDRAM CS1 start right after CS0 */
-               *(vu_long *) MPC5XXX_SDRAM_CS1CFG = dramsize + 0x0000001e;      /* 2G */
-#else
-               *(vu_long *) MPC5XXX_SDRAM_CS0CFG =
-                   0x13 + __builtin_ffs(0x08000000 >> 20) - 1;
-               /* let SDRAM CS1 start right after CS0 */
-               *(vu_long *) MPC5XXX_SDRAM_CS1CFG = 0x08000000 + 0x0000001e;    /* 2G */
-#endif
-       }
-
-#if 0
-       /* find RAM size using SDRAM CS1 only */
-       sdram_start(0);
-       get_ram_size((ulong *) (CONFIG_SYS_SDRAM_BASE + dramsize), 0x80000000);
-       sdram_start(1);
-       get_ram_size((ulong *) (CONFIG_SYS_SDRAM_BASE + dramsize), 0x80000000);
-       sdram_start(0);
-#endif
-       /* set SDRAM CS1 size according to the amount of RAM found */
-
-       *(vu_long *) MPC5XXX_SDRAM_CS1CFG = dramsize;   /* disabled */
-
-       init_ata_reset();
-       return (dramsize);
-}
-
-int checkboard(void)
-{
-       puts("Board: esd CPCI5200 (cpci5200)\n");
-       return 0;
-}
-
-void flash_preinit(void)
-{
-       /*
-        * Now, when we are in RAM, enable flash write
-        * access for detection process.
-        * Note that CS_BOOT cannot be cleared when
-        * executing in flash.
-        */
-       *(vu_long *) MPC5XXX_BOOTCS_CFG &= ~0x1;        /* clear RO */
-}
-
-void flash_afterinit(ulong size)
-{
-       if (size == 0x02000000) {
-               /* adjust mapping */
-               *(vu_long *) MPC5XXX_BOOTCS_START =
-                   *(vu_long *) MPC5XXX_CS0_START =
-                   START_REG(CONFIG_SYS_BOOTCS_START | size);
-               *(vu_long *) MPC5XXX_BOOTCS_STOP =
-                   *(vu_long *) MPC5XXX_CS0_STOP =
-                   STOP_REG(CONFIG_SYS_BOOTCS_START | size, size);
-       }
-}
-
-#ifdef CONFIG_PCI
-static struct pci_controller hose;
-
-extern void pci_mpc5xxx_init(struct pci_controller *);
-
-void pci_init_board(void) {
-       pci_mpc5xxx_init(&hose);
-}
-#endif
-
-#if defined(CONFIG_CMD_IDE) && defined (CONFIG_IDE_RESET)
-
-void init_ide_reset(void)
-{
-       debug("init_ide_reset\n");
-
-       /* Configure PSC1_4 as GPIO output for ATA reset */
-       *(vu_long *) MPC5XXX_WU_GPIO_ENABLE |= GPIO_PSC1_4;
-       *(vu_long *) MPC5XXX_WU_GPIO_DIR |= GPIO_PSC1_4;
-}
-
-void ide_set_reset(int idereset)
-{
-       debug("ide_reset(%d)\n", idereset);
-
-       if (idereset) {
-               *(vu_long *) MPC5XXX_WU_GPIO_DATA_O &= ~GPIO_PSC1_4;
-       } else {
-               *(vu_long *) MPC5XXX_WU_GPIO_DATA_O |= GPIO_PSC1_4;
-       }
-}
-#endif
-
-#define MPC5XXX_SIMPLEIO_GPIO_ENABLE       (MPC5XXX_GPIO + 0x0004)
-#define MPC5XXX_SIMPLEIO_GPIO_DIR          (MPC5XXX_GPIO + 0x000C)
-#define MPC5XXX_SIMPLEIO_GPIO_DATA_OUTPUT  (MPC5XXX_GPIO + 0x0010)
-#define MPC5XXX_SIMPLEIO_GPIO_DATA_INPUT   (MPC5XXX_GPIO + 0x0014)
-
-#define MPC5XXX_INTERRUPT_GPIO_ENABLE      (MPC5XXX_GPIO + 0x0020)
-#define MPC5XXX_INTERRUPT_GPIO_DIR         (MPC5XXX_GPIO + 0x0028)
-#define MPC5XXX_INTERRUPT_GPIO_DATA_OUTPUT (MPC5XXX_GPIO + 0x002C)
-#define MPC5XXX_INTERRUPT_GPIO_STATUS      (MPC5XXX_GPIO + 0x003C)
-
-#define GPIO_WU6       0x40000000UL
-#define GPIO_USB0       0x00010000UL
-#define GPIO_USB9       0x08000000UL
-#define GPIO_USB9S      0x00080000UL
-
-void init_ata_reset(void)
-{
-       debug("init_ata_reset\n");
-
-       /* Configure GPIO_WU6 as GPIO output for ATA reset */
-       *(vu_long *) MPC5XXX_WU_GPIO_DATA_O |= GPIO_WU6;
-       *(vu_long *) MPC5XXX_WU_GPIO_ENABLE |= GPIO_WU6;
-       *(vu_long *) MPC5XXX_WU_GPIO_DIR |= GPIO_WU6;
-       __asm__ volatile ("sync");
-
-       *(vu_long *) MPC5XXX_SIMPLEIO_GPIO_DATA_OUTPUT &= ~GPIO_USB0;
-       *(vu_long *) MPC5XXX_SIMPLEIO_GPIO_ENABLE |= GPIO_USB0;
-       *(vu_long *) MPC5XXX_SIMPLEIO_GPIO_DIR |= GPIO_USB0;
-       __asm__ volatile ("sync");
-
-       *(vu_long *) MPC5XXX_INTERRUPT_GPIO_DATA_OUTPUT &= ~GPIO_USB9;
-       *(vu_long *) MPC5XXX_INTERRUPT_GPIO_ENABLE &= ~GPIO_USB9;
-       __asm__ volatile ("sync");
-
-       if ((*(vu_long *) MPC5XXX_INTERRUPT_GPIO_STATUS & GPIO_USB9S) == 0) {
-               *(vu_long *) MPC5XXX_SIMPLEIO_GPIO_DATA_OUTPUT |= GPIO_USB0;
-               __asm__ volatile ("sync");
-       }
-}
-
-int board_eth_init(bd_t *bis)
-{
-       return pci_eth_init(bis);
-}
-
-int do_writepci(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
-{
-       unsigned int addr;
-       unsigned int size;
-       int i;
-       volatile unsigned long *ptr;
-
-       addr = simple_strtol(argv[1], NULL, 16);
-       size = simple_strtol(argv[2], NULL, 16);
-
-       printf("\nWriting at addr %08x, size %08x.\n", addr, size);
-
-       while (1) {
-               ptr = (volatile unsigned long *)addr;
-               for (i = 0; i < (size >> 2); i++) {
-                       *ptr++ = i;
-               }
-
-               /* Abort if ctrl-c was pressed */
-               if (ctrlc()) {
-                       puts("\nAbort\n");
-                       return 0;
-               }
-               putc('.');
-       }
-       return 0;
-}
-
-U_BOOT_CMD(writepci, 3, 1, do_writepci,
-          "Write some data to pcibus",
-          "<addr> <size>\n"
-          ""
-);
diff --git a/board/esd/cpci5200/mt46v16m16-75.h b/board/esd/cpci5200/mt46v16m16-75.h
deleted file mode 100644 (file)
index 63a4032..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * (C) Copyright 2004
- * Mark Jonas, Freescale Semiconductor, mark.jonas@motorola.com.
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#define SDRAM_DDR      1       /* is DDR */
-
-/* Settings for XLB = 132 MHz */
-#define SDRAM_MODE     0x018D0000
-#define SDRAM_EMODE    0x40090000
-#define SDRAM_CONTROL  0x705f0f00
-#define SDRAM_CONFIG1  0x73722930
-#define SDRAM_CONFIG2  0x47770000
-#define SDRAM_TAPDELAY 0x10000000
diff --git a/board/esd/cpci5200/strataflash.c b/board/esd/cpci5200/strataflash.c
deleted file mode 100644 (file)
index 7dc2e58..0000000
+++ /dev/null
@@ -1,786 +0,0 @@
-/*
- * (C) Copyright 2002
- * Brad Kemp, Seranoa Networks, Brad.Kemp@seranoa.com
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#include <common.h>
-#include <asm/processor.h>
-#include <asm/cache.h>
-
-#undef  DEBUG_FLASH
-/*
- * This file implements a Common Flash Interface (CFI) driver for U-Boot.
- * The width of the port and the width of the chips are determined at initialization.
- * These widths are used to calculate the address for access CFI data structures.
- * It has been tested on an Intel Strataflash implementation.
- *
- * References
- * JEDEC Standard JESD68 - Common Flash Interface (CFI)
- * JEDEC Standard JEP137-A Common Flash Interface (CFI) ID Codes
- * Intel Application Note 646 Common Flash Interface (CFI) and Command Sets
- * Intel 290667-008 3 Volt Intel StrataFlash Memory datasheet
- *
- * TODO
- * Use Primary Extended Query table (PRI) and Alternate Algorithm Query Table (ALT) to determine if protection is available
- * Add support for other command sets Use the PRI and ALT to determine command set
- * Verify erase and program timeouts.
- */
-
-#define FLASH_CMD_CFI                  0x98
-#define FLASH_CMD_READ_ID              0x90
-#define FLASH_CMD_RESET                        0xff
-#define FLASH_CMD_BLOCK_ERASE          0x20
-#define FLASH_CMD_ERASE_CONFIRM                0xD0
-#define FLASH_CMD_WRITE                        0x40
-#define FLASH_CMD_PROTECT              0x60
-#define FLASH_CMD_PROTECT_SET          0x01
-#define FLASH_CMD_PROTECT_CLEAR                0xD0
-#define FLASH_CMD_CLEAR_STATUS         0x50
-#define FLASH_CMD_WRITE_TO_BUFFER       0xE8
-#define FLASH_CMD_WRITE_BUFFER_CONFIRM  0xD0
-
-#define FLASH_STATUS_DONE              0x80
-#define FLASH_STATUS_ESS               0x40
-#define FLASH_STATUS_ECLBS             0x20
-#define FLASH_STATUS_PSLBS             0x10
-#define FLASH_STATUS_VPENS             0x08
-#define FLASH_STATUS_PSS               0x04
-#define FLASH_STATUS_DPS               0x02
-#define FLASH_STATUS_R                 0x01
-#define FLASH_STATUS_PROTECT           0x01
-
-#define FLASH_OFFSET_CFI               0x55
-#define FLASH_OFFSET_CFI_RESP          0x10
-#define FLASH_OFFSET_WTOUT             0x1F
-#define FLASH_OFFSET_WBTOUT             0x20
-#define FLASH_OFFSET_ETOUT             0x21
-#define FLASH_OFFSET_CETOUT             0x22
-#define FLASH_OFFSET_WMAX_TOUT         0x23
-#define FLASH_OFFSET_WBMAX_TOUT         0x24
-#define FLASH_OFFSET_EMAX_TOUT         0x25
-#define FLASH_OFFSET_CEMAX_TOUT         0x26
-#define FLASH_OFFSET_SIZE              0x27
-#define FLASH_OFFSET_INTERFACE          0x28
-#define FLASH_OFFSET_BUFFER_SIZE        0x2A
-#define FLASH_OFFSET_NUM_ERASE_REGIONS 0x2C
-#define FLASH_OFFSET_ERASE_REGIONS     0x2D
-#define FLASH_OFFSET_PROTECT           0x02
-#define FLASH_OFFSET_USER_PROTECTION    0x85
-#define FLASH_OFFSET_INTEL_PROTECTION   0x81
-
-#define FLASH_MAN_CFI                  0x01000000
-
-typedef union {
-       unsigned char c;
-       unsigned short w;
-       unsigned long l;
-} cfiword_t;
-
-typedef union {
-       unsigned char *cp;
-       unsigned short *wp;
-       unsigned long *lp;
-} cfiptr_t;
-
-#define NUM_ERASE_REGIONS 4
-
-flash_info_t flash_info[CONFIG_SYS_MAX_FLASH_BANKS];   /* info for FLASH chips        */
-
-/*-----------------------------------------------------------------------
- * Functions
- */
-
-static void flash_add_byte(flash_info_t * info, cfiword_t * cword, uchar c);
-static void flash_make_cmd(flash_info_t * info, uchar cmd, void *cmdbuf);
-static void flash_write_cmd(flash_info_t * info, int sect, uchar offset,
-                           uchar cmd);
-static int flash_isequal(flash_info_t * info, int sect, uchar offset,
-                        uchar cmd);
-static int flash_isset(flash_info_t * info, int sect, uchar offset, uchar cmd);
-static int flash_detect_cfi(flash_info_t * info);
-static ulong flash_get_size(ulong base, int banknum);
-static int flash_write_cfiword(flash_info_t * info, ulong dest,
-                              cfiword_t cword);
-static int flash_full_status_check(flash_info_t * info, ulong sector,
-                                  ulong tout, char *prompt);
-#ifdef CONFIG_SYS_FLASH_USE_BUFFER_WRITE
-static int flash_write_cfibuffer(flash_info_t * info, ulong dest, uchar * cp,
-                                int len);
-#endif
-/*-----------------------------------------------------------------------
- * create an address based on the offset and the port width
- */
-inline uchar *flash_make_addr(flash_info_t * info, int sect, int offset)
-{
-       return ((uchar *) (info->start[sect] + (offset * info->portwidth)));
-}
-
-/*-----------------------------------------------------------------------
- * read a character at a port width address
- */
-inline uchar flash_read_uchar(flash_info_t * info, uchar offset)
-{
-       uchar *cp;
-       cp = flash_make_addr(info, 0, offset);
-       return (cp[info->portwidth - 1]);
-}
-
-/*-----------------------------------------------------------------------
- * read a short word by swapping for ppc format.
- */
-ushort flash_read_ushort(flash_info_t * info, int sect, uchar offset)
-{
-       uchar *addr;
-
-       addr = flash_make_addr(info, sect, offset);
-       return ((addr[(2 * info->portwidth) - 1] << 8) |
-               addr[info->portwidth - 1]);
-
-}
-
-/*-----------------------------------------------------------------------
- * read a long word by picking the least significant byte of each maiximum
- * port size word. Swap for ppc format.
- */
-ulong flash_read_long(flash_info_t * info, int sect, uchar offset)
-{
-       uchar *addr;
-
-       addr = flash_make_addr(info, sect, offset);
-       return ((addr[(2 * info->portwidth) - 1] << 24) |
-               (addr[(info->portwidth) - 1] << 16) |
-               (addr[(4 * info->portwidth) - 1] << 8) |
-               addr[(3 * info->portwidth) - 1]);
-
-}
-
-/*-----------------------------------------------------------------------
- */
-unsigned long flash_init(void)
-{
-       unsigned long size;
-       int i;
-       unsigned long address;
-
-       /* The flash is positioned back to back, with the demultiplexing of the chip
-        * based on the A24 address line.
-        *
-        */
-
-       address = CONFIG_SYS_FLASH_BASE;
-       size = 0;
-
-       /* Init: no FLASHes known */
-       for (i = 0; i < CONFIG_SYS_MAX_FLASH_BANKS; ++i) {
-               flash_info[i].flash_id = FLASH_UNKNOWN;
-               size += flash_info[i].size = flash_get_size(address, i);
-               address += CONFIG_SYS_FLASH_INCREMENT;
-               if (flash_info[i].flash_id == FLASH_UNKNOWN) {
-                       printf
-                           ("## Unknown FLASH on Bank %d - Size = 0x%08lx = %ld MB\n",
-                            i, flash_info[0].size, flash_info[i].size << 20);
-               }
-       }
-
-#if 0                          /* test-only */
-       /* Monitor protection ON by default */
-#if (CONFIG_SYS_MONITOR_BASE >= CONFIG_SYS_FLASH_BASE)
-       for (i = 0;
-            flash_info[0].start[i] < CONFIG_SYS_MONITOR_BASE + monitor_flash_len - 1;
-            i++)
-               (void)flash_real_protect(&flash_info[0], i, 1);
-#endif
-#endif
-
-       return (size);
-}
-
-/*-----------------------------------------------------------------------
- */
-int flash_erase(flash_info_t * info, int s_first, int s_last)
-{
-       int rcode = 0;
-       int prot;
-       int sect;
-
-       if (info->flash_id != FLASH_MAN_CFI) {
-               printf("Can't erase unknown flash type - aborted\n");
-               return 1;
-       }
-       if ((s_first < 0) || (s_first > s_last)) {
-               printf("- no sectors to erase\n");
-               return 1;
-       }
-
-       prot = 0;
-       for (sect = s_first; sect <= s_last; ++sect) {
-               if (info->protect[sect]) {
-                       prot++;
-               }
-       }
-       if (prot) {
-               printf("- Warning: %d protected sectors will not be erased!\n",
-                      prot);
-       } else {
-               printf("\n");
-       }
-
-       for (sect = s_first; sect <= s_last; sect++) {
-               if (info->protect[sect] == 0) { /* not protected */
-                       flash_write_cmd(info, sect, 0, FLASH_CMD_CLEAR_STATUS);
-                       flash_write_cmd(info, sect, 0, FLASH_CMD_BLOCK_ERASE);
-                       flash_write_cmd(info, sect, 0, FLASH_CMD_ERASE_CONFIRM);
-
-                       if (flash_full_status_check
-                           (info, sect, info->erase_blk_tout, "erase")) {
-                               rcode = 1;
-                       } else
-                               printf(".");
-               }
-       }
-       printf(" done\n");
-       return rcode;
-}
-
-/*-----------------------------------------------------------------------
- */
-void flash_print_info(flash_info_t * info)
-{
-       int i;
-
-       if (info->flash_id != FLASH_MAN_CFI) {
-               printf("missing or unknown FLASH type\n");
-               return;
-       }
-
-       printf("CFI conformant FLASH (%d x %d)",
-              (info->portwidth << 3), (info->chipwidth << 3));
-       printf("  Size: %ld MB in %d Sectors\n",
-              info->size >> 20, info->sector_count);
-       printf
-           (" Erase timeout %ld ms, write timeout %ld ms, buffer write timeout %ld ms, buffer size %d\n",
-            info->erase_blk_tout, info->write_tout, info->buffer_write_tout,
-            info->buffer_size);
-
-       printf("  Sector Start Addresses:");
-       for (i = 0; i < info->sector_count; ++i) {
-               if ((i % 5) == 0)
-                       printf("\n");
-               printf(" %08lX%5s",
-                      info->start[i], info->protect[i] ? " (RO)" : " ");
-       }
-       printf("\n");
-       return;
-}
-
-/*-----------------------------------------------------------------------
- * Copy memory to flash, returns:
- * 0 - OK
- * 1 - write timeout
- * 2 - Flash not erased
- */
-int write_buff(flash_info_t * info, uchar * src, ulong addr, ulong cnt)
-{
-       ulong wp;
-       ulong cp;
-       int aln;
-       cfiword_t cword;
-       int i, rc;
-
-       /* get lower aligned address */
-       wp = (addr & ~(info->portwidth - 1));
-
-       /* handle unaligned start */
-       if ((aln = addr - wp) != 0) {
-               cword.l = 0;
-               cp = wp;
-               for (i = 0; i < aln; ++i, ++cp)
-                       flash_add_byte(info, &cword, (*(uchar *) cp));
-
-               for (; (i < info->portwidth) && (cnt > 0); i++) {
-                       flash_add_byte(info, &cword, *src++);
-                       cnt--;
-                       cp++;
-               }
-               for (; (cnt == 0) && (i < info->portwidth); ++i, ++cp)
-                       flash_add_byte(info, &cword, (*(uchar *) cp));
-               if ((rc = flash_write_cfiword(info, wp, cword)) != 0)
-                       return rc;
-               wp = cp;
-       }
-#ifdef CONFIG_SYS_FLASH_USE_BUFFER_WRITE
-       while (cnt >= info->portwidth) {
-               i = info->buffer_size > cnt ? cnt : info->buffer_size;
-               if ((rc = flash_write_cfibuffer(info, wp, src, i)) != ERR_OK)
-                       return rc;
-               wp += i;
-               src += i;
-               cnt -= i;
-       }
-#else
-       /* handle the aligned part */
-       while (cnt >= info->portwidth) {
-               cword.l = 0;
-               for (i = 0; i < info->portwidth; i++) {
-                       flash_add_byte(info, &cword, *src++);
-               }
-               if ((rc = flash_write_cfiword(info, wp, cword)) != 0)
-                       return rc;
-               wp += info->portwidth;
-               cnt -= info->portwidth;
-       }
-#endif                         /* CONFIG_SYS_FLASH_USE_BUFFER_WRITE */
-       if (cnt == 0) {
-               return (0);
-       }
-
-       /*
-        * handle unaligned tail bytes
-        */
-       cword.l = 0;
-       for (i = 0, cp = wp; (i < info->portwidth) && (cnt > 0); ++i, ++cp) {
-               flash_add_byte(info, &cword, *src++);
-               --cnt;
-       }
-       for (; i < info->portwidth; ++i, ++cp) {
-               flash_add_byte(info, &cword, (*(uchar *) cp));
-       }
-
-       return flash_write_cfiword(info, wp, cword);
-}
-
-/*-----------------------------------------------------------------------
- */
-int flash_real_protect(flash_info_t * info, long sector, int prot)
-{
-       int retcode = 0;
-
-       flash_write_cmd(info, sector, 0, FLASH_CMD_CLEAR_STATUS);
-       flash_write_cmd(info, sector, 0, FLASH_CMD_PROTECT);
-       if (prot)
-               flash_write_cmd(info, sector, 0, FLASH_CMD_PROTECT_SET);
-       else
-               flash_write_cmd(info, sector, 0, FLASH_CMD_PROTECT_CLEAR);
-
-       if ((retcode =
-            flash_full_status_check(info, sector, info->erase_blk_tout,
-                                    prot ? "protect" : "unprotect")) == 0) {
-
-               info->protect[sector] = prot;
-               /* Intel's unprotect unprotects all locking */
-               if (prot == 0) {
-                       int i;
-                       for (i = 0; i < info->sector_count; i++) {
-                               if (info->protect[i])
-                                       flash_real_protect(info, i, 1);
-                       }
-               }
-       }
-
-       return retcode;
-}
-
-/*-----------------------------------------------------------------------
- *  wait for XSR.7 to be set. Time out with an error if it does not.
- *  This routine does not set the flash to read-array mode.
- */
-static int flash_status_check(flash_info_t * info, ulong sector, ulong tout,
-                             char *prompt)
-{
-       ulong start;
-
-       /* Wait for command completion */
-       start = get_timer(0);
-       while (!flash_isset(info, sector, 0, FLASH_STATUS_DONE)) {
-               if (get_timer(start) > info->erase_blk_tout) {
-                       printf("Flash %s timeout at address %lx\n", prompt,
-                              info->start[sector]);
-                       flash_write_cmd(info, sector, 0, FLASH_CMD_RESET);
-                       return ERR_TIMOUT;
-               }
-       }
-       return ERR_OK;
-}
-
-/*-----------------------------------------------------------------------
- * Wait for XSR.7 to be set, if it times out print an error, otherwise do a full status check.
- * This routine sets the flash to read-array mode.
- */
-static int flash_full_status_check(flash_info_t * info, ulong sector,
-                                  ulong tout, char *prompt)
-{
-       int retcode;
-       retcode = flash_status_check(info, sector, tout, prompt);
-       if ((retcode == ERR_OK)
-           && !flash_isequal(info, sector, 0, FLASH_STATUS_DONE)) {
-               retcode = ERR_INVAL;
-               printf("Flash %s error at address %lx\n", prompt,
-                      info->start[sector]);
-               if (flash_isset
-                   (info, sector, 0,
-                    FLASH_STATUS_ECLBS | FLASH_STATUS_PSLBS)) {
-                       printf("Command Sequence Error.\n");
-               } else if (flash_isset(info, sector, 0, FLASH_STATUS_ECLBS)) {
-                       printf("Block Erase Error.\n");
-                       retcode = ERR_NOT_ERASED;
-               } else if (flash_isset(info, sector, 0, FLASH_STATUS_PSLBS)) {
-                       printf("Locking Error\n");
-               }
-               if (flash_isset(info, sector, 0, FLASH_STATUS_DPS)) {
-                       printf("Block locked.\n");
-                       retcode = ERR_PROTECTED;
-               }
-               if (flash_isset(info, sector, 0, FLASH_STATUS_VPENS))
-                       printf("Vpp Low Error.\n");
-       }
-       flash_write_cmd(info, sector, 0, FLASH_CMD_RESET);
-       return retcode;
-}
-
-/*-----------------------------------------------------------------------
- */
-static void flash_add_byte(flash_info_t * info, cfiword_t * cword, uchar c)
-{
-       switch (info->portwidth) {
-       case FLASH_CFI_8BIT:
-               cword->c = c;
-               break;
-       case FLASH_CFI_16BIT:
-               cword->w = (cword->w << 8) | c;
-               break;
-       case FLASH_CFI_32BIT:
-               cword->l = (cword->l << 8) | c;
-       }
-}
-
-/*-----------------------------------------------------------------------
- * make a proper sized command based on the port and chip widths
- */
-static void flash_make_cmd(flash_info_t * info, uchar cmd, void *cmdbuf)
-{
-       int i;
-       uchar *cp = (uchar *) cmdbuf;
-       for (i = 0; i < info->portwidth; i++)
-               *cp++ = ((i + 1) % info->chipwidth) ? '\0' : cmd;
-}
-
-/*
- * Write a proper sized command to the correct address
- */
-static void flash_write_cmd(flash_info_t * info, int sect, uchar offset,
-                           uchar cmd)
-{
-
-       volatile cfiptr_t addr;
-       cfiword_t cword;
-       addr.cp = flash_make_addr(info, sect, offset);
-       flash_make_cmd(info, cmd, &cword);
-       switch (info->portwidth) {
-       case FLASH_CFI_8BIT:
-               *addr.cp = cword.c;
-               break;
-       case FLASH_CFI_16BIT:
-               *addr.wp = cword.w;
-               break;
-       case FLASH_CFI_32BIT:
-               *addr.lp = cword.l;
-               break;
-       }
-}
-
-/*-----------------------------------------------------------------------
- */
-static int flash_isequal(flash_info_t * info, int sect, uchar offset, uchar cmd)
-{
-       cfiptr_t cptr;
-       cfiword_t cword;
-       int retval;
-       cptr.cp = flash_make_addr(info, sect, offset);
-       flash_make_cmd(info, cmd, &cword);
-       switch (info->portwidth) {
-       case FLASH_CFI_8BIT:
-               retval = (cptr.cp[0] == cword.c);
-               break;
-       case FLASH_CFI_16BIT:
-               retval = (cptr.wp[0] == cword.w);
-               break;
-       case FLASH_CFI_32BIT:
-               retval = (cptr.lp[0] == cword.l);
-               break;
-       default:
-               retval = 0;
-               break;
-       }
-       return retval;
-}
-
-/*-----------------------------------------------------------------------
- */
-static int flash_isset(flash_info_t * info, int sect, uchar offset, uchar cmd)
-{
-       cfiptr_t cptr;
-       cfiword_t cword;
-       int retval;
-       cptr.cp = flash_make_addr(info, sect, offset);
-       flash_make_cmd(info, cmd, &cword);
-       switch (info->portwidth) {
-       case FLASH_CFI_8BIT:
-               retval = ((cptr.cp[0] & cword.c) == cword.c);
-               break;
-       case FLASH_CFI_16BIT:
-               retval = ((cptr.wp[0] & cword.w) == cword.w);
-               break;
-       case FLASH_CFI_32BIT:
-               retval = ((cptr.lp[0] & cword.l) == cword.l);
-               break;
-       default:
-               retval = 0;
-               break;
-       }
-       return retval;
-}
-
-/*-----------------------------------------------------------------------
- * detect if flash is compatible with the Common Flash Interface (CFI)
- * http://www.jedec.org/download/search/jesd68.pdf
- *
- */
-static int flash_detect_cfi(flash_info_t * info)
-{
-
-       for (info->portwidth = FLASH_CFI_8BIT;
-            info->portwidth <= FLASH_CFI_32BIT; info->portwidth <<= 1) {
-               for (info->chipwidth = FLASH_CFI_BY8;
-                    info->chipwidth <= info->portwidth;
-                    info->chipwidth <<= 1) {
-                       flash_write_cmd(info, 0, 0, FLASH_CMD_RESET);
-                       flash_write_cmd(info, 0, FLASH_OFFSET_CFI,
-                                       FLASH_CMD_CFI);
-                       if (flash_isequal(info, 0, FLASH_OFFSET_CFI_RESP, 'Q')
-                           && flash_isequal(info, 0, FLASH_OFFSET_CFI_RESP + 1,
-                                            'R')
-                           && flash_isequal(info, 0, FLASH_OFFSET_CFI_RESP + 2,
-                                            'Y'))
-                               return 1;
-               }
-       }
-       return 0;
-}
-
-/*
- * The following code cannot be run from FLASH!
- *
- */
-static ulong flash_get_size(ulong base, int banknum)
-{
-       flash_info_t *info = &flash_info[banknum];
-       int i, j;
-       int sect_cnt;
-       unsigned long sector;
-       unsigned long tmp;
-       int size_ratio = 0;
-       uchar num_erase_regions;
-       int erase_region_size;
-       int erase_region_count;
-
-       info->start[0] = base;
-#if 0
-       invalidate_dcache_range(base, base + 0x400);
-#endif
-       if (flash_detect_cfi(info)) {
-
-               size_ratio = info->portwidth / info->chipwidth;
-               num_erase_regions =
-                   flash_read_uchar(info, FLASH_OFFSET_NUM_ERASE_REGIONS);
-
-               sect_cnt = 0;
-               sector = base;
-               for (i = 0; i < num_erase_regions; i++) {
-                       if (i > NUM_ERASE_REGIONS) {
-                               printf("%d erase regions found, only %d used\n",
-                                      num_erase_regions, NUM_ERASE_REGIONS);
-                               break;
-                       }
-                       tmp =
-                           flash_read_long(info, 0,
-                                           FLASH_OFFSET_ERASE_REGIONS);
-                       erase_region_size =
-                           (tmp & 0xffff) ? ((tmp & 0xffff) * 256) : 128;
-                       tmp >>= 16;
-                       erase_region_count = (tmp & 0xffff) + 1;
-                       for (j = 0; j < erase_region_count; j++) {
-                               info->start[sect_cnt] = sector;
-                               sector += (erase_region_size * size_ratio);
-                               info->protect[sect_cnt] =
-                                   flash_isset(info, sect_cnt,
-                                               FLASH_OFFSET_PROTECT,
-                                               FLASH_STATUS_PROTECT);
-                               sect_cnt++;
-                       }
-               }
-
-               info->sector_count = sect_cnt;
-               /* multiply the size by the number of chips */
-               info->size =
-                   (1 << flash_read_uchar(info, FLASH_OFFSET_SIZE)) *
-                   size_ratio;
-               info->buffer_size =
-                   (1 << flash_read_ushort(info, 0, FLASH_OFFSET_BUFFER_SIZE));
-               tmp = 1 << flash_read_uchar(info, FLASH_OFFSET_ETOUT);
-               info->erase_blk_tout =
-                   (tmp *
-                    (1 << flash_read_uchar(info, FLASH_OFFSET_EMAX_TOUT)));
-               tmp = 1 << flash_read_uchar(info, FLASH_OFFSET_WBTOUT);
-               info->buffer_write_tout =
-                   (tmp *
-                    (1 << flash_read_uchar(info, FLASH_OFFSET_WBMAX_TOUT)));
-               tmp = 1 << flash_read_uchar(info, FLASH_OFFSET_WTOUT);
-               info->write_tout =
-                   (tmp *
-                    (1 << flash_read_uchar(info, FLASH_OFFSET_WMAX_TOUT))) /
-                   1000;
-               info->flash_id = FLASH_MAN_CFI;
-       }
-
-       flash_write_cmd(info, 0, 0, FLASH_CMD_RESET);
-#ifdef DEBUG_FLASH
-       printf("portwidth=%d chipwidth=%d\n", info->portwidth, info->chipwidth);        /* test-only */
-#endif
-#ifdef DEBUG_FLASH
-       printf("found %d erase regions\n", num_erase_regions);
-#endif
-#ifdef DEBUG_FLASH
-       printf("size=%08x sectors=%08x \n", info->size, info->sector_count);
-#endif
-       return (info->size);
-}
-
-/*-----------------------------------------------------------------------
- */
-static int flash_write_cfiword(flash_info_t * info, ulong dest, cfiword_t cword)
-{
-
-       cfiptr_t cptr;
-       int flag;
-
-       cptr.cp = (uchar *)dest;
-
-       /* Check if Flash is (sufficiently) erased */
-       switch (info->portwidth) {
-       case FLASH_CFI_8BIT:
-               flag = ((cptr.cp[0] & cword.c) == cword.c);
-               break;
-       case FLASH_CFI_16BIT:
-               flag = ((cptr.wp[0] & cword.w) == cword.w);
-               break;
-       case FLASH_CFI_32BIT:
-               flag = ((cptr.lp[0] & cword.l) == cword.l);
-               break;
-       default:
-               return 2;
-       }
-       if (!flag)
-               return 2;
-
-       /* Disable interrupts which might cause a timeout here */
-       flag = disable_interrupts();
-
-       flash_write_cmd(info, 0, 0, FLASH_CMD_CLEAR_STATUS);
-       flash_write_cmd(info, 0, 0, FLASH_CMD_WRITE);
-
-       switch (info->portwidth) {
-       case FLASH_CFI_8BIT:
-               cptr.cp[0] = cword.c;
-               break;
-       case FLASH_CFI_16BIT:
-               cptr.wp[0] = cword.w;
-               break;
-       case FLASH_CFI_32BIT:
-               cptr.lp[0] = cword.l;
-               break;
-       }
-
-       /* re-enable interrupts if necessary */
-       if (flag)
-               enable_interrupts();
-
-       return flash_full_status_check(info, 0, info->write_tout, "write");
-}
-
-#ifdef CONFIG_SYS_FLASH_USE_BUFFER_WRITE
-
-/* loop through the sectors from the highest address
- * when the passed address is greater or equal to the sector address
- * we have a match
- */
-static int find_sector(flash_info_t * info, ulong addr)
-{
-       int sector;
-       for (sector = info->sector_count - 1; sector >= 0; sector--) {
-               if (addr >= info->start[sector])
-                       break;
-       }
-       return sector;
-}
-
-static int flash_write_cfibuffer(flash_info_t * info, ulong dest, uchar * cp,
-                                int len)
-{
-
-       int sector;
-       int cnt;
-       int retcode;
-       volatile cfiptr_t src;
-       volatile cfiptr_t dst;
-
-       src.cp = cp;
-       dst.cp = (uchar *) dest;
-       sector = find_sector(info, dest);
-       flash_write_cmd(info, sector, 0, FLASH_CMD_CLEAR_STATUS);
-       flash_write_cmd(info, sector, 0, FLASH_CMD_WRITE_TO_BUFFER);
-       if ((retcode = flash_status_check(info, sector, info->buffer_write_tout,
-                                         "write to buffer")) == ERR_OK) {
-               switch (info->portwidth) {
-               case FLASH_CFI_8BIT:
-                       cnt = len;
-                       break;
-               case FLASH_CFI_16BIT:
-                       cnt = len >> 1;
-                       break;
-               case FLASH_CFI_32BIT:
-                       cnt = len >> 2;
-                       break;
-               default:
-                       return ERR_INVAL;
-                       break;
-               }
-               flash_write_cmd(info, sector, 0, (uchar) cnt - 1);
-               while (cnt-- > 0) {
-                       switch (info->portwidth) {
-                       case FLASH_CFI_8BIT:
-                               *dst.cp++ = *src.cp++;
-                               break;
-                       case FLASH_CFI_16BIT:
-                               *dst.wp++ = *src.wp++;
-                               break;
-                       case FLASH_CFI_32BIT:
-                               *dst.lp++ = *src.lp++;
-                               break;
-                       default:
-                               return ERR_INVAL;
-                               break;
-                       }
-               }
-               flash_write_cmd(info, sector, 0,
-                               FLASH_CMD_WRITE_BUFFER_CONFIRM);
-               retcode =
-                   flash_full_status_check(info, sector,
-                                           info->buffer_write_tout,
-                                           "buffer write");
-       }
-       flash_write_cmd(info, sector, 0, FLASH_CMD_CLEAR_STATUS);
-       return retcode;
-}
-#endif                         /* CONFIG_SYS_USE_FLASH_BUFFER_WRITE */
diff --git a/board/esd/mecp5200/Kconfig b/board/esd/mecp5200/Kconfig
deleted file mode 100644 (file)
index cfd5307..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-if TARGET_MECP5200
-
-config SYS_BOARD
-       default "mecp5200"
-
-config SYS_VENDOR
-       default "esd"
-
-config SYS_CONFIG_NAME
-       default "mecp5200"
-
-endif
diff --git a/board/esd/mecp5200/MAINTAINERS b/board/esd/mecp5200/MAINTAINERS
deleted file mode 100644 (file)
index 05b7824..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-MECP5200 BOARD
-M:     Reinhard Arlt <reinhard.arlt@esd-electronics.com>
-S:     Maintained
-F:     board/esd/mecp5200/
-F:     include/configs/mecp5200.h
-F:     configs/mecp5200_defconfig
diff --git a/board/esd/mecp5200/Makefile b/board/esd/mecp5200/Makefile
deleted file mode 100644 (file)
index 3d66c9f..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-#
-# (C) Copyright 2003-2006
-# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
-#
-# SPDX-License-Identifier:     GPL-2.0+
-#
-
-obj-y  = mecp5200.o
diff --git a/board/esd/mecp5200/mecp5200.c b/board/esd/mecp5200/mecp5200.c
deleted file mode 100644 (file)
index 17a70a9..0000000
+++ /dev/null
@@ -1,251 +0,0 @@
-/*
- * (C) Copyright 2003
- * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
- *
- * (C) Copyright 2004
- * Mark Jonas, Freescale Semiconductor, mark.jonas@motorola.com.
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-/*
- * pf5200.c - main board support/init for the esd pf5200.
- */
-
-#include <common.h>
-#include <mpc5xxx.h>
-#include <pci.h>
-#include <command.h>
-#include <netdev.h>
-
-#include "mt46v16m16-75.h"
-
-void init_power_switch(void);
-
-static void sdram_start(int hi_addr)
-{
-       long hi_addr_bit = hi_addr ? 0x01000000 : 0;
-
-       /* unlock mode register */
-       *(vu_long *) MPC5XXX_SDRAM_CTRL =
-           SDRAM_CONTROL | 0x80000000 | hi_addr_bit;
-       __asm__ volatile ("sync");
-
-       /* precharge all banks */
-       *(vu_long *) MPC5XXX_SDRAM_CTRL =
-           SDRAM_CONTROL | 0x80000002 | hi_addr_bit;
-       __asm__ volatile ("sync");
-
-       /* set mode register: extended mode */
-       *(vu_long *) MPC5XXX_SDRAM_MODE = SDRAM_EMODE;
-       __asm__ volatile ("sync");
-
-       /* set mode register: reset DLL */
-       *(vu_long *) MPC5XXX_SDRAM_MODE = SDRAM_MODE | 0x04000000;
-       __asm__ volatile ("sync");
-
-       /* precharge all banks */
-       *(vu_long *) MPC5XXX_SDRAM_CTRL =
-           SDRAM_CONTROL | 0x80000002 | hi_addr_bit;
-       __asm__ volatile ("sync");
-
-       /* auto refresh */
-       *(vu_long *) MPC5XXX_SDRAM_CTRL =
-           SDRAM_CONTROL | 0x80000004 | hi_addr_bit;
-       __asm__ volatile ("sync");
-
-       /* set mode register */
-       *(vu_long *) MPC5XXX_SDRAM_MODE = SDRAM_MODE;
-       __asm__ volatile ("sync");
-
-       /* normal operation */
-       *(vu_long *) MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | hi_addr_bit;
-       __asm__ volatile ("sync");
-}
-
-/*
- * ATTENTION: Although partially referenced initdram does NOT make real use
- *            use of CONFIG_SYS_SDRAM_BASE. The code does not work if CONFIG_SYS_SDRAM_BASE
- *            is something else than 0x00000000.
- */
-
-phys_size_t initdram(int board_type)
-{
-       ulong dramsize = 0;
-       ulong test1, test2;
-
-       /* setup SDRAM chip selects */
-       *(vu_long *) MPC5XXX_SDRAM_CS0CFG = 0x0000001e; /* 2G at 0x0 */
-       *(vu_long *) MPC5XXX_SDRAM_CS1CFG = 0x80000000; /* disabled */
-       __asm__ volatile ("sync");
-
-       /* setup config registers */
-       *(vu_long *) MPC5XXX_SDRAM_CONFIG1 = SDRAM_CONFIG1;
-       *(vu_long *) MPC5XXX_SDRAM_CONFIG2 = SDRAM_CONFIG2;
-       __asm__ volatile ("sync");
-
-       /* set tap delay */
-       *(vu_long *) MPC5XXX_CDM_PORCFG = SDRAM_TAPDELAY;
-       __asm__ volatile ("sync");
-
-       /* find RAM size using SDRAM CS0 only */
-       sdram_start(0);
-       test1 = get_ram_size(CONFIG_SYS_SDRAM_BASE, 0x80000000);
-       sdram_start(1);
-       test2 = get_ram_size(CONFIG_SYS_SDRAM_BASE, 0x80000000);
-
-       if (test1 > test2) {
-               sdram_start(0);
-               dramsize = test1;
-       } else {
-               dramsize = test2;
-       }
-
-       /* memory smaller than 1MB is impossible */
-       if (dramsize < (1 << 20))
-               dramsize = 0;
-
-       /* set SDRAM CS0 size according to the amount of RAM found */
-       if (dramsize > 0) {
-               *(vu_long *) MPC5XXX_SDRAM_CS0CFG =
-                   0x13 + __builtin_ffs(dramsize >> 20) - 1;
-               /* let SDRAM CS1 start right after CS0 */
-               *(vu_long *) MPC5XXX_SDRAM_CS1CFG = dramsize + 0x0000001e;      /* 2G */
-       } else {
-#if 0
-               *(vu_long *) MPC5XXX_SDRAM_CS0CFG = 0;  /* disabled */
-               /* let SDRAM CS1 start right after CS0 */
-               *(vu_long *) MPC5XXX_SDRAM_CS1CFG = dramsize + 0x0000001e;      /* 2G */
-#else
-               *(vu_long *) MPC5XXX_SDRAM_CS0CFG =
-                   0x13 + __builtin_ffs(0x08000000 >> 20) - 1;
-               /* let SDRAM CS1 start right after CS0 */
-               *(vu_long *) MPC5XXX_SDRAM_CS1CFG = 0x08000000 + 0x0000001e;    /* 2G */
-#endif
-       }
-
-#if 0
-       /* find RAM size using SDRAM CS1 only */
-       sdram_start(0);
-       get_ram_size((ulong *) (CONFIG_SYS_SDRAM_BASE + dramsize), 0x80000000);
-       sdram_start(1);
-       get_ram_size((ulong *) (CONFIG_SYS_SDRAM_BASE + dramsize), 0x80000000);
-       sdram_start(0);
-#endif
-       /* set SDRAM CS1 size according to the amount of RAM found */
-
-       *(vu_long *) MPC5XXX_SDRAM_CS1CFG = dramsize;   /* disabled */
-
-       init_power_switch();
-       return (dramsize);
-}
-
-int checkboard(void)
-{
-       puts("Board: esd CPX CPU5200 (mecp5200)\n");
-       return 0;
-}
-
-void flash_preinit(void)
-{
-       /*
-        * Now, when we are in RAM, enable flash write
-        * access for detection process.
-        * Note that CS_BOOT cannot be cleared when
-        * executing in flash.
-        */
-       *(vu_long *) MPC5XXX_BOOTCS_CFG &= ~0x1;        /* clear RO */
-}
-
-void flash_afterinit(ulong size)
-{
-       if (size == CONFIG_SYS_FLASH_SIZE) {
-               /* adjust mapping */
-               *(vu_long *) MPC5XXX_BOOTCS_START =
-                   *(vu_long *) MPC5XXX_CS0_START =
-                   START_REG(CONFIG_SYS_BOOTCS_START | size);
-               *(vu_long *) MPC5XXX_BOOTCS_STOP =
-                   *(vu_long *) MPC5XXX_CS0_STOP =
-                   STOP_REG(CONFIG_SYS_BOOTCS_START | size, size);
-       }
-}
-
-#ifdef CONFIG_PCI
-static struct pci_controller hose;
-
-extern void pci_mpc5xxx_init(struct pci_controller *);
-
-void pci_init_board(void)
-{
-       pci_mpc5xxx_init(&hose);
-}
-#endif
-
-#if defined(CONFIG_CMD_IDE) && defined(CONFIG_IDE_RESET)
-
-#define GPIO_PSC1_4    0x01000000UL
-
-void init_ide_reset(void)
-{
-       debug("init_ide_reset\n");
-
-       /* Configure PSC1_4 as GPIO output for ATA reset */
-       *(vu_long *) MPC5XXX_WU_GPIO_ENABLE |= GPIO_PSC1_4;
-       *(vu_long *) MPC5XXX_WU_GPIO_DIR |= GPIO_PSC1_4;
-}
-
-void ide_set_reset(int idereset)
-{
-       debug("ide_reset(%d)\n", idereset);
-
-       if (idereset)
-               *(vu_long *) MPC5XXX_WU_GPIO_DATA_O &= ~GPIO_PSC1_4;
-       else
-               *(vu_long *) MPC5XXX_WU_GPIO_DATA_O |= GPIO_PSC1_4;
-}
-#endif
-
-#define MPC5XXX_SIMPLEIO_GPIO_ENABLE       (MPC5XXX_GPIO + 0x0004)
-#define MPC5XXX_SIMPLEIO_GPIO_DIR          (MPC5XXX_GPIO + 0x000C)
-#define MPC5XXX_SIMPLEIO_GPIO_DATA_OUTPUT  (MPC5XXX_GPIO + 0x0010)
-#define MPC5XXX_SIMPLEIO_GPIO_DATA_INPUT   (MPC5XXX_GPIO + 0x0014)
-
-#define MPC5XXX_INTERRUPT_GPIO_ENABLE      (MPC5XXX_GPIO + 0x0020)
-#define MPC5XXX_INTERRUPT_GPIO_DIR         (MPC5XXX_GPIO + 0x0028)
-#define MPC5XXX_INTERRUPT_GPIO_DATA_OUTPUT (MPC5XXX_GPIO + 0x002C)
-#define MPC5XXX_INTERRUPT_GPIO_STATUS      (MPC5XXX_GPIO + 0x003C)
-
-#define GPIO_WU6       0x40000000UL
-#define GPIO_USB0       0x00010000UL
-#define GPIO_USB9       0x08000000UL
-#define GPIO_USB9S      0x00080000UL
-
-void init_power_switch(void)
-{
-       debug("init_power_switch\n");
-
-       /* Configure GPIO_WU6 as GPIO output for ATA reset */
-       *(vu_long *) MPC5XXX_WU_GPIO_DATA_O |= GPIO_WU6;
-       *(vu_long *) MPC5XXX_WU_GPIO_ENABLE |= GPIO_WU6;
-       *(vu_long *) MPC5XXX_WU_GPIO_DIR |= GPIO_WU6;
-       __asm__ volatile ("sync");
-
-       *(vu_long *) MPC5XXX_SIMPLEIO_GPIO_DATA_OUTPUT &= ~GPIO_USB0;
-       *(vu_long *) MPC5XXX_SIMPLEIO_GPIO_ENABLE |= GPIO_USB0;
-       *(vu_long *) MPC5XXX_SIMPLEIO_GPIO_DIR |= GPIO_USB0;
-       __asm__ volatile ("sync");
-
-       *(vu_long *) MPC5XXX_INTERRUPT_GPIO_DATA_OUTPUT &= ~GPIO_USB9;
-       *(vu_long *) MPC5XXX_INTERRUPT_GPIO_ENABLE &= ~GPIO_USB9;
-       __asm__ volatile ("sync");
-
-       if ((*(vu_long *) MPC5XXX_INTERRUPT_GPIO_STATUS & GPIO_USB9S) == 0) {
-               *(vu_long *) MPC5XXX_SIMPLEIO_GPIO_DATA_OUTPUT |= GPIO_USB0;
-               __asm__ volatile ("sync");
-       }
-}
-
-int board_eth_init(bd_t *bis)
-{
-       return pci_eth_init(bis);
-}
diff --git a/board/esd/mecp5200/mt46v16m16-75.h b/board/esd/mecp5200/mt46v16m16-75.h
deleted file mode 100644 (file)
index 63a4032..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * (C) Copyright 2004
- * Mark Jonas, Freescale Semiconductor, mark.jonas@motorola.com.
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#define SDRAM_DDR      1       /* is DDR */
-
-/* Settings for XLB = 132 MHz */
-#define SDRAM_MODE     0x018D0000
-#define SDRAM_EMODE    0x40090000
-#define SDRAM_CONTROL  0x705f0f00
-#define SDRAM_CONFIG1  0x73722930
-#define SDRAM_CONFIG2  0x47770000
-#define SDRAM_TAPDELAY 0x10000000
diff --git a/board/esd/pf5200/Kconfig b/board/esd/pf5200/Kconfig
deleted file mode 100644 (file)
index c596e7a..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-if TARGET_PF5200
-
-config SYS_BOARD
-       default "pf5200"
-
-config SYS_VENDOR
-       default "esd"
-
-config SYS_CONFIG_NAME
-       default "pf5200"
-
-endif
diff --git a/board/esd/pf5200/MAINTAINERS b/board/esd/pf5200/MAINTAINERS
deleted file mode 100644 (file)
index b6e624e..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-PF5200 BOARD
-M:     Reinhard Arlt <reinhard.arlt@esd-electronics.com>
-S:     Maintained
-F:     board/esd/pf5200/
-F:     include/configs/pf5200.h
-F:     configs/pf5200_defconfig
diff --git a/board/esd/pf5200/Makefile b/board/esd/pf5200/Makefile
deleted file mode 100644 (file)
index a54289c..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-#
-# (C) Copyright 2003-2006
-# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
-#
-# SPDX-License-Identifier:     GPL-2.0+
-#
-
-# Objects for Xilinx JTAG programming (CPLD)
-# CPLD  = ../common/xilinx_jtag/lenval.o \
-#        ../common/xilinx_jtag/micro.o \
-#        ../common/xilinx_jtag/ports.o
-
-# obj-y        = pf5200.o flash.o $(CPLD)
-obj-y  = pf5200.o flash.o
diff --git a/board/esd/pf5200/flash.c b/board/esd/pf5200/flash.c
deleted file mode 100644 (file)
index e1b13bf..0000000
+++ /dev/null
@@ -1,445 +0,0 @@
-/*
- * (C) Copyright 2003
- * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#include <common.h>
-
-flash_info_t flash_info[CONFIG_SYS_MAX_FLASH_BANKS];   /* info for FLASH chips */
-
-typedef unsigned short FLASH_PORT_WIDTH;
-typedef volatile unsigned short FLASH_PORT_WIDTHV;
-
-#define FLASH_ID_MASK           0x00FF
-
-#define FPW                     FLASH_PORT_WIDTH
-#define FPWV                    FLASH_PORT_WIDTHV
-
-#define FLASH_CYCLE1            0x0555
-#define FLASH_CYCLE2            0x0aaa
-#define FLASH_ID1               0x00
-#define FLASH_ID2               0x01
-#define FLASH_ID3               0x0E
-#define FLASH_ID4               0x0F
-
-/*-----------------------------------------------------------------------
- * Functions
- */
-static ulong flash_get_size(FPWV * addr, flash_info_t * info);
-static void flash_reset(flash_info_t * info);
-static int write_word_amd(flash_info_t * info, FPWV * dest, FPW data);
-static flash_info_t *flash_get_info(ulong base);
-
-/*-----------------------------------------------------------------------
- * flash_init()
- *
- * sets up flash_info and returns size of FLASH (bytes)
- */
-unsigned long flash_init(void)
-{
-       unsigned long size = 0;
-       int i = 0;
-       extern void flash_preinit(void);
-       extern void flash_afterinit(uint, ulong, ulong);
-
-       ulong flashbase = CONFIG_SYS_FLASH_BASE;
-
-       flash_preinit();
-
-       /* There is only ONE FLASH device */
-       memset(&flash_info[i], 0, sizeof(flash_info_t));
-       flash_info[i].size = flash_get_size((FPW *) flashbase, &flash_info[i]);
-       size += flash_info[i].size;
-
-#if CONFIG_SYS_MONITOR_BASE >= CONFIG_SYS_FLASH_BASE
-       /* monitor protection ON by default */
-       flash_protect(FLAG_PROTECT_SET, CONFIG_SYS_MONITOR_BASE,
-                     CONFIG_SYS_MONITOR_BASE + monitor_flash_len - 1,
-                     flash_get_info(CONFIG_SYS_MONITOR_BASE));
-#endif
-
-#ifdef  CONFIG_ENV_IS_IN_FLASH
-       /* ENV protection ON by default */
-       flash_protect(FLAG_PROTECT_SET, CONFIG_ENV_ADDR,
-                     CONFIG_ENV_ADDR + CONFIG_ENV_SIZE - 1,
-                     flash_get_info(CONFIG_ENV_ADDR));
-#endif
-
-       flash_afterinit(i, flash_info[i].start[0], flash_info[i].size);
-       return size ? size : 1;
-}
-
-/*-----------------------------------------------------------------------
- */
-static void flash_reset(flash_info_t * info) {
-       FPWV *base = (FPWV *) (info->start[0]);
-
-       /* Put FLASH back in read mode */
-       if ((info->flash_id & FLASH_VENDMASK) == FLASH_MAN_INTEL) {
-               *base = (FPW) 0x00FF00FF;       /* Intel Read Mode */
-       } else if ((info->flash_id & FLASH_VENDMASK) == FLASH_MAN_AMD) {
-               *base = (FPW) 0x00F000F0;       /* AMD Read Mode */
-       }
-}
-
-/*-----------------------------------------------------------------------
- */
-
-static flash_info_t *flash_get_info(ulong base) {
-       int i;
-       flash_info_t *info;
-
-       for (i = 0; i < CONFIG_SYS_MAX_FLASH_BANKS; i++) {
-               info = &flash_info[i];
-               if ((info->size) && (info->start[0] <= base)
-                   && (base <= info->start[0] + info->size - 1)) {
-                       break;
-               }
-       }
-       return (i == CONFIG_SYS_MAX_FLASH_BANKS ? 0 : info);
-}
-
-/*-----------------------------------------------------------------------
- */
-
-void flash_print_info(flash_info_t * info) {
-       int i;
-       char *fmt;
-
-       if (info->flash_id == FLASH_UNKNOWN) {
-               printf("missing or unknown FLASH type\n");
-               return;
-       }
-
-       switch (info->flash_id & FLASH_VENDMASK) {
-       case FLASH_MAN_AMD:
-               printf("AMD ");
-               break;
-       default:
-               printf("Unknown Vendor ");
-               break;
-       }
-
-       switch (info->flash_id & FLASH_TYPEMASK) {
-       case FLASH_AMLV256U:
-               fmt = "29LV256M (256 Mbit)\n";
-               break;
-       default:
-               fmt = "Unknown Chip Type\n";
-               break;
-       }
-
-       printf(fmt);
-       printf("  Size: %ld MB in %d Sectors\n", info->size >> 20,
-              info->sector_count);
-       printf("  Sector Start Addresses:");
-
-       for (i = 0; i < info->sector_count; ++i) {
-               ulong size;
-               int erased;
-               ulong *flash = (unsigned long *)info->start[i];
-
-               if ((i % 5) == 0) {
-                       printf("\n   ");
-               }
-
-               /*
-                * Check if whole sector is erased
-                */
-               size =
-                   (i !=
-                    (info->sector_count - 1)) ? (info->start[i + 1] -
-                                                 info->start[i]) >> 2 : (info->
-                                                                         start
-                                                                         [0] +
-                                                                         info->
-                                                                         size -
-                                                                         info->
-                                                                         start
-                                                                         [i])
-                   >> 2;
-
-               for (flash = (unsigned long *)info->start[i], erased = 1;
-                    (flash != (unsigned long *)info->start[i] + size)
-                    && erased; flash++) {
-                       erased = *flash == ~0x0UL;
-               }
-               printf(" %08lX %s %s", info->start[i], erased ? "E" : " ",
-                      info->protect[i] ? "(RO)" : "    ");
-       }
-
-       printf("\n");
-}
-
-/*-----------------------------------------------------------------------
- */
-
-/*
- * The following code cannot be run from FLASH!
- */
-
-ulong flash_get_size(FPWV * addr, flash_info_t * info) {
-       int i;
-
-       /* Write auto select command: read Manufacturer ID                     */
-       /* Write auto select command sequence and test FLASH answer            */
-       addr[FLASH_CYCLE1] = (FPW) 0x00AA00AA;  /* for AMD, Intel ignores this */
-       addr[FLASH_CYCLE2] = (FPW) 0x00550055;  /* for AMD, Intel ignores this */
-       addr[FLASH_CYCLE1] = (FPW) 0x00900090;  /* selects Intel or AMD        */
-
-       /* The manufacturer codes are only 1 byte, so just use 1 byte.         */
-       /* This works for any bus width and any FLASH device width.            */
-       udelay(100);
-       switch (addr[FLASH_ID1] & 0x00ff) {
-       case (uchar) AMD_MANUFACT:
-               info->flash_id = FLASH_MAN_AMD;
-               break;
-       default:
-               printf("unknown vendor=%x ", addr[FLASH_ID1] & 0xff);
-               info->flash_id = FLASH_UNKNOWN;
-               info->sector_count = 0;
-               info->size = 0;
-               break;
-       }
-
-       /* Check 16 bits or 32 bits of ID so work on 32 or 16 bit bus.     */
-       if (info->flash_id != FLASH_UNKNOWN) {
-               switch ((FPW) addr[FLASH_ID2]) {
-               case (FPW) AMD_ID_MIRROR:
-                       /* MIRROR BIT FLASH, read more ID bytes */
-                       if ((FPW) addr[FLASH_ID3] == (FPW) AMD_ID_LV256U_2
-                           && (FPW) addr[FLASH_ID4] == (FPW) AMD_ID_LV256U_3) {
-                               /* attention: only the first 16 MB will be used in u-boot */
-                               info->flash_id += FLASH_AMLV256U;
-                               info->sector_count = 512;
-                               info->size = 0x02000000;
-                               for (i = 0; i < info->sector_count; i++) {
-                                       info->start[i] =
-                                           (ulong) addr + 0x10000 * i;
-                               }
-                               break;
-                       }
-                       /* fall thru to here ! */
-               default:
-                       printf("unknown AMD device=%x %x %x",
-                              (FPW) addr[FLASH_ID2], (FPW) addr[FLASH_ID3],
-                              (FPW) addr[FLASH_ID4]);
-                       info->flash_id = FLASH_UNKNOWN;
-                       info->sector_count = 0;
-                       info->size = 0x800000;
-                       break;
-               }
-
-               /* Put FLASH back in read mode */
-               flash_reset(info);
-       }
-       return (info->size);
-}
-
-/*-----------------------------------------------------------------------
- */
-
-int flash_erase(flash_info_t * info, int s_first, int s_last) {
-       FPWV *addr;
-       int flag, prot, sect;
-       int intel = (info->flash_id & FLASH_VENDMASK) == FLASH_MAN_INTEL;
-       ulong start, now, last;
-       int rcode = 0;
-
-       if ((s_first < 0) || (s_first > s_last)) {
-               if (info->flash_id == FLASH_UNKNOWN) {
-                       printf("- missing\n");
-               } else {
-                       printf("- no sectors to erase\n");
-               }
-               return 1;
-       }
-
-       switch (info->flash_id & FLASH_TYPEMASK) {
-       case FLASH_AMLV256U:
-               break;
-       case FLASH_UNKNOWN:
-       default:
-               printf("Can't erase unknown flash type %08lx - aborted\n",
-                      info->flash_id);
-               return 1;
-       }
-
-       prot = 0;
-       for (sect = s_first; sect <= s_last; ++sect) {
-               if (info->protect[sect]) {
-                       prot++;
-               }
-       }
-
-       if (prot) {
-               printf("- Warning: %d protected sectors will not be erased!\n",
-                      prot);
-       } else {
-               printf("\n");
-       }
-
-       last = get_timer(0);
-
-       /* Start erase on unprotected sectors */
-       for (sect = s_first; sect <= s_last && rcode == 0; sect++) {
-               if (info->protect[sect] != 0) { /* protected, skip it */
-                       continue;
-               }
-               /* Disable interrupts which might cause a timeout here */
-               flag = disable_interrupts();
-
-               addr = (FPWV *) (info->start[sect]);
-               if (intel) {
-                       *addr = (FPW) 0x00500050;       /* clear status register */
-                       *addr = (FPW) 0x00200020;       /* erase setup */
-                       *addr = (FPW) 0x00D000D0;       /* erase confirm */
-               } else {
-                       /* must be AMD style if not Intel */
-                       FPWV *base;     /* first address in bank */
-
-                       base = (FPWV *) (info->start[0]);
-                       base[FLASH_CYCLE1] = (FPW) 0x00AA00AA;  /* unlock */
-                       base[FLASH_CYCLE2] = (FPW) 0x00550055;  /* unlock */
-                       base[FLASH_CYCLE1] = (FPW) 0x00800080;  /* erase mode */
-                       base[FLASH_CYCLE1] = (FPW) 0x00AA00AA;  /* unlock */
-                       base[FLASH_CYCLE2] = (FPW) 0x00550055;  /* unlock */
-                       *addr = (FPW) 0x00300030;       /* erase sector */
-               }
-
-               /* re-enable interrupts if necessary */
-               if (flag) {
-                       enable_interrupts();
-               }
-               start = get_timer(0);
-
-               /* wait at least 50us for AMD, 80us for Intel. */
-               /* Let's wait 1 ms.                            */
-               udelay(1000);
-
-               while ((*addr & (FPW) 0x00800080) != (FPW) 0x00800080) {
-                       if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) {
-                               printf("Timeout\n");
-                               if (intel) {
-                                       /* suspend erase        */
-                                       *addr = (FPW) 0x00B000B0;
-                               }
-                               flash_reset(info);      /* reset to read mode */
-                               rcode = 1;      /* failed */
-                               break;
-                       }
-                       /* show that we're waiting */
-                       if ((get_timer(last)) > CONFIG_SYS_HZ) {
-                               /* every second */
-                               putc('.');
-                               last = get_timer(0);
-                       }
-               }
-               /* show that we're waiting */
-               if ((get_timer(last)) > CONFIG_SYS_HZ) {
-                       /* every second */
-                       putc('.');
-                       last = get_timer(0);
-               }
-               flash_reset(info);      /* reset to read mode */
-       }
-       printf(" done\n");
-       return (rcode);
-}
-
-/*-----------------------------------------------------------------------
- * Copy memory to flash, returns:
- * 0 - OK
- * 1 - write timeout
- * 2 - Flash not erased
- */
-int write_buff(flash_info_t * info, uchar * src, ulong addr, ulong cnt)
-{
-       FPW data = 0;           /* 16 or 32 bit word, matches flash bus width on MPC8XX */
-       int bytes;              /* number of bytes to program in current word         */
-       int left;               /* number of bytes left to program                    */
-       int i, res;
-
-       for (left = cnt, res = 0;
-            left > 0 && res == 0;
-            addr += sizeof(data), left -= sizeof(data) - bytes) {
-
-               bytes = addr & (sizeof(data) - 1);
-               addr &= ~(sizeof(data) - 1);
-
-               /* combine source and destination data so can program
-                * an entire word of 16 or 32 bits
-                */
-               for (i = 0; i < sizeof(data); i++) {
-                       data <<= 8;
-                       if (i < bytes || i - bytes >= left)
-                               data += *((uchar *) addr + i);
-                       else
-                               data += *src++;
-               }
-
-               /* write one word to the flash */
-               switch (info->flash_id & FLASH_VENDMASK) {
-               case FLASH_MAN_AMD:
-                       res = write_word_amd(info, (FPWV *) addr, data);
-                       break;
-               default:
-                       /* unknown flash type, error! */
-                       printf("missing or unknown FLASH type\n");
-                       res = 1;        /* not really a timeout, but gives error */
-                       break;
-               }
-       }
-       return (res);
-}
-
-/*-----------------------------------------------------------------------
- * Write a word to Flash for AMD FLASH
- * A word is 16 or 32 bits, whichever the bus width of the flash bank
- * (not an individual chip) is.
- *
- * returns:
- * 0 - OK
- * 1 - write timeout
- * 2 - Flash not erased
- */
-static int write_word_amd(flash_info_t * info, FPWV * dest, FPW data) {
-       ulong start;
-       int flag;
-       int res = 0;            /* result, assume success       */
-       FPWV *base;             /* first address in flash bank  */
-
-       /* Check if Flash is (sufficiently) erased */
-       if ((*dest & data) != data) {
-               return (2);
-       }
-
-       base = (FPWV *) (info->start[0]);
-
-       /* Disable interrupts which might cause a timeout here */
-       flag = disable_interrupts();
-
-       base[FLASH_CYCLE1] = (FPW) 0x00AA00AA;  /* unlock */
-       base[FLASH_CYCLE2] = (FPW) 0x00550055;  /* unlock */
-       base[FLASH_CYCLE1] = (FPW) 0x00A000A0;  /* selects program mode */
-
-       *dest = data;           /* start programming the data   */
-
-       /* re-enable interrupts if necessary */
-       if (flag) {
-               enable_interrupts();
-       }
-       start = get_timer(0);
-
-       /* data polling for D7 */
-       while (res == 0
-              && (*dest & (FPW) 0x00800080) != (data & (FPW) 0x00800080)) {
-               if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) {
-                       *dest = (FPW) 0x00F000F0;       /* reset bank */
-                       res = 1;
-               }
-       }
-       return (res);
-}
diff --git a/board/esd/pf5200/mt46v16m16-75.h b/board/esd/pf5200/mt46v16m16-75.h
deleted file mode 100644 (file)
index 63a4032..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * (C) Copyright 2004
- * Mark Jonas, Freescale Semiconductor, mark.jonas@motorola.com.
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#define SDRAM_DDR      1       /* is DDR */
-
-/* Settings for XLB = 132 MHz */
-#define SDRAM_MODE     0x018D0000
-#define SDRAM_EMODE    0x40090000
-#define SDRAM_CONTROL  0x705f0f00
-#define SDRAM_CONFIG1  0x73722930
-#define SDRAM_CONFIG2  0x47770000
-#define SDRAM_TAPDELAY 0x10000000
diff --git a/board/esd/pf5200/pf5200.c b/board/esd/pf5200/pf5200.c
deleted file mode 100644 (file)
index 7a9ed22..0000000
+++ /dev/null
@@ -1,357 +0,0 @@
-/*
- * (C) Copyright 2003
- * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
- *
- * (C) Copyright 2004
- * Mark Jonas, Freescale Semiconductor, mark.jonas@motorola.com.
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-/*
- * pf5200.c - main board support/init for the esd pf5200.
- */
-
-#include <common.h>
-#include <mpc5xxx.h>
-#include <pci.h>
-#include <command.h>
-#include <netdev.h>
-
-#include "mt46v16m16-75.h"
-
-void init_power_switch(void);
-
-static void sdram_start(int hi_addr)
-{
-       long hi_addr_bit = hi_addr ? 0x01000000 : 0;
-
-       /* unlock mode register */
-       *(vu_long *) MPC5XXX_SDRAM_CTRL =
-           SDRAM_CONTROL | 0x80000000 | hi_addr_bit;
-       __asm__ volatile ("sync");
-
-       /* precharge all banks */
-       *(vu_long *) MPC5XXX_SDRAM_CTRL =
-           SDRAM_CONTROL | 0x80000002 | hi_addr_bit;
-       __asm__ volatile ("sync");
-
-       /* set mode register: extended mode */
-       *(vu_long *) MPC5XXX_SDRAM_MODE = SDRAM_EMODE;
-       __asm__ volatile ("sync");
-
-       /* set mode register: reset DLL */
-       *(vu_long *) MPC5XXX_SDRAM_MODE = SDRAM_MODE | 0x04000000;
-       __asm__ volatile ("sync");
-
-       /* precharge all banks */
-       *(vu_long *) MPC5XXX_SDRAM_CTRL =
-           SDRAM_CONTROL | 0x80000002 | hi_addr_bit;
-       __asm__ volatile ("sync");
-
-       /* auto refresh */
-       *(vu_long *) MPC5XXX_SDRAM_CTRL =
-           SDRAM_CONTROL | 0x80000004 | hi_addr_bit;
-       __asm__ volatile ("sync");
-
-       /* set mode register */
-       *(vu_long *) MPC5XXX_SDRAM_MODE = SDRAM_MODE;
-       __asm__ volatile ("sync");
-
-       /* normal operation */
-       *(vu_long *) MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | hi_addr_bit;
-       __asm__ volatile ("sync");
-}
-
-/*
- * ATTENTION: Although partially referenced initdram does NOT make real use
- *            use of CONFIG_SYS_SDRAM_BASE. The code does not work if CONFIG_SYS_SDRAM_BASE
- *            is something else than 0x00000000.
- */
-
-phys_size_t initdram(int board_type)
-{
-       ulong dramsize = 0;
-       ulong test1, test2;
-
-       /* setup SDRAM chip selects */
-       *(vu_long *) MPC5XXX_SDRAM_CS0CFG = 0x0000001e; /* 2G at 0x0 */
-       *(vu_long *) MPC5XXX_SDRAM_CS1CFG = 0x80000000; /* disabled */
-       __asm__ volatile ("sync");
-
-       /* setup config registers */
-       *(vu_long *) MPC5XXX_SDRAM_CONFIG1 = SDRAM_CONFIG1;
-       *(vu_long *) MPC5XXX_SDRAM_CONFIG2 = SDRAM_CONFIG2;
-       __asm__ volatile ("sync");
-
-       /* set tap delay */
-       *(vu_long *) MPC5XXX_CDM_PORCFG = SDRAM_TAPDELAY;
-       __asm__ volatile ("sync");
-
-       /* find RAM size using SDRAM CS0 only */
-       sdram_start(0);
-       test1 = get_ram_size((long *) CONFIG_SYS_SDRAM_BASE, 0x80000000);
-       sdram_start(1);
-       test2 = get_ram_size((long *) CONFIG_SYS_SDRAM_BASE, 0x80000000);
-
-       if (test1 > test2) {
-               sdram_start(0);
-               dramsize = test1;
-       } else {
-               dramsize = test2;
-       }
-
-       /* memory smaller than 1MB is impossible */
-       if (dramsize < (1 << 20)) {
-               dramsize = 0;
-       }
-
-       /* set SDRAM CS0 size according to the amount of RAM found */
-       if (dramsize > 0) {
-               *(vu_long *) MPC5XXX_SDRAM_CS0CFG =
-                   0x13 + __builtin_ffs(dramsize >> 20) - 1;
-               /* let SDRAM CS1 start right after CS0 */
-               *(vu_long *) MPC5XXX_SDRAM_CS1CFG = dramsize + 0x0000001e;      /* 2G */
-       } else {
-#if 0
-               *(vu_long *) MPC5XXX_SDRAM_CS0CFG = 0;  /* disabled */
-               /* let SDRAM CS1 start right after CS0 */
-               *(vu_long *) MPC5XXX_SDRAM_CS1CFG = dramsize + 0x0000001e;      /* 2G */
-#else
-               *(vu_long *) MPC5XXX_SDRAM_CS0CFG =
-                   0x13 + __builtin_ffs(0x08000000 >> 20) - 1;
-               /* let SDRAM CS1 start right after CS0 */
-               *(vu_long *) MPC5XXX_SDRAM_CS1CFG = 0x08000000 + 0x0000001e;    /* 2G */
-#endif
-       }
-
-#if 0
-       /* find RAM size using SDRAM CS1 only */
-       sdram_start(0);
-       get_ram_size((ulong *) (CONFIG_SYS_SDRAM_BASE + dramsize), 0x80000000);
-       sdram_start(1);
-       get_ram_size((ulong *) (CONFIG_SYS_SDRAM_BASE + dramsize), 0x80000000);
-       sdram_start(0);
-#endif
-       /* set SDRAM CS1 size according to the amount of RAM found */
-
-       *(vu_long *) MPC5XXX_SDRAM_CS1CFG = dramsize;   /* disabled */
-
-       init_power_switch();
-       return (dramsize);
-}
-
-int checkboard(void)
-{
-       puts("Board: esd ParaFinder (pf5200)\n");
-       return 0;
-}
-
-void flash_preinit(void)
-{
-       /*
-        * Now, when we are in RAM, enable flash write
-        * access for detection process.
-        * Note that CS_BOOT cannot be cleared when
-        * executing in flash.
-        */
-       *(vu_long *) MPC5XXX_BOOTCS_CFG &= ~0x1;        /* clear RO */
-}
-
-void flash_afterinit(ulong size)
-{
-       if (size == 0x02000000) {
-               /* adjust mapping */
-               *(vu_long *) MPC5XXX_BOOTCS_START =
-                   *(vu_long *) MPC5XXX_CS0_START =
-                   START_REG(CONFIG_SYS_BOOTCS_START | size);
-               *(vu_long *) MPC5XXX_BOOTCS_STOP =
-                   *(vu_long *) MPC5XXX_CS0_STOP =
-                   STOP_REG(CONFIG_SYS_BOOTCS_START | size, size);
-       }
-}
-
-#ifdef CONFIG_PCI
-static struct pci_controller hose;
-
-extern void pci_mpc5xxx_init(struct pci_controller *);
-
-void pci_init_board(void) {
-       pci_mpc5xxx_init(&hose);
-}
-#endif
-
-#if defined(CONFIG_CMD_IDE) && defined(CONFIG_IDE_RESET)
-
-void init_ide_reset(void)
-{
-       debug("init_ide_reset\n");
-
-       /* Configure PSC1_4 as GPIO output for ATA reset */
-       *(vu_long *) MPC5XXX_WU_GPIO_ENABLE |= GPIO_PSC1_4;
-       *(vu_long *) MPC5XXX_WU_GPIO_DIR |= GPIO_PSC1_4;
-}
-
-void ide_set_reset(int idereset)
-{
-       debug("ide_reset(%d)\n", idereset);
-
-       if (idereset) {
-               *(vu_long *) MPC5XXX_WU_GPIO_DATA_O &= ~GPIO_PSC1_4;
-       } else {
-               *(vu_long *) MPC5XXX_WU_GPIO_DATA_O |= GPIO_PSC1_4;
-       }
-}
-#endif
-
-#define MPC5XXX_SIMPLEIO_GPIO_ENABLE       (MPC5XXX_GPIO + 0x0004)
-#define MPC5XXX_SIMPLEIO_GPIO_DIR          (MPC5XXX_GPIO + 0x000C)
-#define MPC5XXX_SIMPLEIO_GPIO_DATA_OUTPUT  (MPC5XXX_GPIO + 0x0010)
-#define MPC5XXX_SIMPLEIO_GPIO_DATA_INPUT   (MPC5XXX_GPIO + 0x0014)
-
-#define MPC5XXX_INTERRUPT_GPIO_ENABLE      (MPC5XXX_GPIO + 0x0020)
-#define MPC5XXX_INTERRUPT_GPIO_DIR         (MPC5XXX_GPIO + 0x0028)
-#define MPC5XXX_INTERRUPT_GPIO_DATA_OUTPUT (MPC5XXX_GPIO + 0x002C)
-#define MPC5XXX_INTERRUPT_GPIO_STATUS      (MPC5XXX_GPIO + 0x003C)
-
-#define GPIO_WU6       0x40000000UL
-#define GPIO_USB0       0x00010000UL
-#define GPIO_USB9       0x08000000UL
-#define GPIO_USB9S      0x00080000UL
-
-void init_power_switch(void)
-{
-       debug("init_power_switch\n");
-
-       /* Configure GPIO_WU6 as GPIO output for ATA reset */
-       *(vu_long *) MPC5XXX_WU_GPIO_DATA_O |= GPIO_WU6;
-       *(vu_long *) MPC5XXX_WU_GPIO_ENABLE |= GPIO_WU6;
-       *(vu_long *) MPC5XXX_WU_GPIO_DIR |= GPIO_WU6;
-       __asm__ volatile ("sync");
-
-       *(vu_long *) MPC5XXX_SIMPLEIO_GPIO_DATA_OUTPUT &= ~GPIO_USB0;
-       *(vu_long *) MPC5XXX_SIMPLEIO_GPIO_ENABLE |= GPIO_USB0;
-       *(vu_long *) MPC5XXX_SIMPLEIO_GPIO_DIR |= GPIO_USB0;
-       __asm__ volatile ("sync");
-
-       *(vu_long *) MPC5XXX_INTERRUPT_GPIO_DATA_OUTPUT &= ~GPIO_USB9;
-       *(vu_long *) MPC5XXX_INTERRUPT_GPIO_ENABLE &= ~GPIO_USB9;
-       __asm__ volatile ("sync");
-
-       if ((*(vu_long *) MPC5XXX_INTERRUPT_GPIO_STATUS & GPIO_USB9S) == 0) {
-               *(vu_long *) MPC5XXX_SIMPLEIO_GPIO_DATA_OUTPUT |= GPIO_USB0;
-               __asm__ volatile ("sync");
-       }
-       *(vu_char *) CONFIG_SYS_CS1_START = 0x02;       /* Red Power LED on */
-       __asm__ volatile ("sync");
-
-       *(vu_char *) (CONFIG_SYS_CS1_START + 1) = 0x02; /* Disable driver for KB11 */
-       __asm__ volatile ("sync");
-}
-
-int board_eth_init(bd_t *bis)
-{
-       return pci_eth_init(bis);
-}
-
-void power_set_reset(int power)
-{
-       debug("ide_set_reset(%d)\n", power);
-
-       if (power) {
-               *(vu_long *) MPC5XXX_WU_GPIO_DATA_O &= ~GPIO_WU6;
-               *(vu_long *) MPC5XXX_INTERRUPT_GPIO_DATA_OUTPUT &= ~GPIO_USB9;
-       } else {
-               *(vu_long *) MPC5XXX_WU_GPIO_DATA_O |= GPIO_WU6;
-               if ((*(vu_long *) MPC5XXX_INTERRUPT_GPIO_STATUS & GPIO_USB9S) ==
-                   0) {
-                       *(vu_long *) MPC5XXX_SIMPLEIO_GPIO_DATA_OUTPUT |=
-                           GPIO_USB0;
-               }
-
-       }
-}
-
-int do_poweroff(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
-{
-       power_set_reset(1);
-       return (0);
-}
-
-U_BOOT_CMD(poweroff, 1, 1, do_poweroff, "Switch off power", "");
-
-int phypower(int flag)
-{
-       u32 addr;
-       vu_long *reg;
-       int status;
-       pci_dev_t dev;
-
-       dev = PCI_BDF(0, 0x18, 0);
-       status = pci_read_config_dword(dev, PCI_BASE_ADDRESS_1, &addr);
-       if (status == 0) {
-               reg = (vu_long *) (addr + 0x00000040);
-               *reg |= 0x40000000;
-               __asm__ volatile ("sync");
-
-               reg = (vu_long *) (addr + 0x001000c);
-               *reg |= 0x20000000;
-               __asm__ volatile ("sync");
-
-               reg = (vu_long *) (addr + 0x0010004);
-               if (flag != 0) {
-                       *reg &= ~0x20000000;
-               } else {
-                       *reg |= 0x20000000;
-               }
-               __asm__ volatile ("sync");
-       }
-       return (status);
-}
-
-int do_phypower(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
-{
-       if (argv[1][0] == '0')
-               (void)phypower(0);
-       else
-               (void)phypower(1);
-
-       return (0);
-}
-
-U_BOOT_CMD(phypower, 2, 2, do_phypower,
-          "Switch power of ethernet phy", "");
-
-int do_writepci(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
-{
-       unsigned int addr;
-       unsigned int size;
-       int i;
-       volatile unsigned long *ptr;
-
-       addr = simple_strtol(argv[1], NULL, 16);
-       size = simple_strtol(argv[2], NULL, 16);
-
-       printf("\nWriting at addr %08x, size %08x.\n", addr, size);
-
-       while (1) {
-               ptr = (volatile unsigned long *)addr;
-               for (i = 0; i < (size >> 2); i++) {
-                       *ptr++ = i;
-               }
-
-               /* Abort if ctrl-c was pressed */
-               if (ctrlc()) {
-                       puts("\nAbort\n");
-                       return 0;
-               }
-               putc('.');
-       }
-       return 0;
-}
-
-U_BOOT_CMD(writepci, 3, 1, do_writepci,
-       "Write some data to pcibus",
-       "<addr> <size>\n"
-       ""
-);
index db2e5e3bd321c33fddbd5f7e92e620347810bde2..33088396f572f790df27f4f358478dcf524f11d2 100644 (file)
@@ -6,3 +6,5 @@ F:      include/configs/C29XPCIE.h
 F:     configs/C29XPCIE_defconfig
 F:     configs/C29XPCIE_NAND_defconfig
 F:     configs/C29XPCIE_SPIFLASH_defconfig
+F:     configs/C29XPCIE_NOR_SECBOOT_defconfig
+F:     configs/C29XPCIE_SPIFLASH_SECBOOT_defconfig
index 5f7a67d057d57938c66145c2d522a803d619257a..1eb37866e3d0d2f815f81519feca8a11f6870f3c 100644 (file)
@@ -63,7 +63,7 @@ int pib_init(void)
 #endif
 
 #if defined(CONFIG_PQ_MDS_PIB_ATM)
-#if defined(CONFIG_MPC8360EMDS) || defined(CONFIG_MPC8569MDS)
+#if defined(CONFIG_MPC8569MDS)
        val8 = 0;
        i2c_write(0x20, 0x6, 1, &val8, 1);
        i2c_write(0x20, 0x7, 1, &val8, 1);
index c8ca6746f19164a27caabbf72c007b5ae4f99e91..745847cdbaa34802faffe39f64e2660db5ebd417 100644 (file)
@@ -27,3 +27,4 @@ F:    configs/P5040DS_defconfig
 F:     configs/P5040DS_NAND_defconfig
 F:     configs/P5040DS_SDCARD_defconfig
 F:     configs/P5040DS_SPIFLASH_defconfig
+F:     configs/P5040DS_SECURE_BOOT_defconfig
index 638833dc4126fd0a8dbdfde9fbedd020bcc1b736..661526b99330ecb5093ae2b0bcd55b6d3d40ca47 100644 (file)
@@ -6,6 +6,7 @@ F:      include/configs/ls1021aqds.h
 F:     configs/ls1021aqds_nor_defconfig
 F:     configs/ls1021aqds_ddr4_nor_defconfig
 F:     configs/ls1021aqds_nor_SECURE_BOOT_defconfig
+F:     configs/ls1021aqds_nor_lpuart_defconfig
 F:     configs/ls1021aqds_sdcard_defconfig
 F:     configs/ls1021aqds_qspi_defconfig
 F:     configs/ls1021aqds_nand_defconfig
index 3b6903c83bcd8b64bda657f041fe778d3687d4d2..ab0234412cb88b7d3c9537eea771c327190383ea 100644 (file)
@@ -7,3 +7,4 @@
 obj-y += ls1021aqds.o
 obj-y += ddr.o
 obj-y += eth.o
+obj-$(CONFIG_FSL_DCU_FB) += dcu.o
diff --git a/board/freescale/ls1021aqds/dcu.c b/board/freescale/ls1021aqds/dcu.c
new file mode 100644 (file)
index 0000000..90f5bc0
--- /dev/null
@@ -0,0 +1,92 @@
+/*
+ * Copyright 2014 Freescale Semiconductor, Inc.
+ *
+ * FSL DCU Framebuffer driver
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <asm/io.h>
+#include <common.h>
+#include <fsl_dcu_fb.h>
+#include <i2c.h>
+#include "div64.h"
+#include "../common/diu_ch7301.h"
+#include "ls1021aqds_qixis.h"
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static int select_i2c_ch_pca9547(u8 ch)
+{
+       int ret;
+
+       ret = i2c_write(I2C_MUX_PCA_ADDR_PRI, 0, 1, &ch, 1);
+       if (ret) {
+               puts("PCA: failed to select proper channel\n");
+               return ret;
+       }
+
+       return 0;
+}
+
+unsigned int dcu_set_pixel_clock(unsigned int pixclock)
+{
+       unsigned long long div;
+
+       div = (unsigned long long)(gd->bus_clk / 1000);
+       div *= (unsigned long long)pixclock;
+       do_div(div, 1000000000);
+
+       return div;
+}
+
+int platform_dcu_init(unsigned int xres, unsigned int yres,
+                     const char *port,
+                     struct fb_videomode *dcu_fb_videomode)
+{
+       const char *name;
+       unsigned int pixel_format;
+       int ret;
+       u8 ch;
+
+       /* Mux I2C3+I2C4 as HSYNC+VSYNC */
+       ret = i2c_read(CONFIG_SYS_I2C_QIXIS_ADDR, QIXIS_DCU_BRDCFG5,
+                      1, &ch, 1);
+       if (ret) {
+               printf("Error: failed to read I2C @%02x\n",
+                      CONFIG_SYS_I2C_QIXIS_ADDR);
+               return ret;
+       }
+       ch &= 0x1F;
+       ch |= 0xA0;
+       ret = i2c_write(CONFIG_SYS_I2C_QIXIS_ADDR, QIXIS_DCU_BRDCFG5,
+                       1, &ch, 1);
+       if (ret) {
+               printf("Error: failed to write I2C @%02x\n",
+                      CONFIG_SYS_I2C_QIXIS_ADDR);
+               return ret;
+       }
+
+       if (strncmp(port, "hdmi", 4) == 0) {
+               unsigned long pixval;
+
+               name = "HDMI";
+
+               pixval = 1000000000 / dcu_fb_videomode->pixclock;
+               pixval *= 1000;
+
+               i2c_set_bus_num(CONFIG_SYS_I2C_DVI_BUS_NUM);
+               select_i2c_ch_pca9547(I2C_MUX_CH_CH7301);
+               diu_set_dvi_encoder(pixval);
+               select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT);
+       } else {
+               return 0;
+       }
+
+       printf("DCU: Switching to %s monitor @ %ux%u\n", name, xres, yres);
+
+       pixel_format = 32;
+       fsl_dcu_init(xres, yres, pixel_format);
+
+       return 0;
+}
index a539ff97913ded4a98b3e95ca0ea9cafc8f05175..6435bf9ad18f2db0da555004f3ca7808f47edf32 100644 (file)
@@ -7,6 +7,7 @@
 #include <common.h>
 #include <fsl_ddr_sdram.h>
 #include <fsl_ddr_dimm_params.h>
+#include <asm/io.h>
 #include "ddr.h"
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -149,6 +150,17 @@ int fsl_ddr_get_dimm_params(dimm_params_t *pdimm,
 }
 #endif
 
+#if defined(CONFIG_DEEP_SLEEP)
+void board_mem_sleep_setup(void)
+{
+       void __iomem *qixis_base = (void *)QIXIS_BASE;
+
+       /* does not provide HW signals for power management */
+       clrbits_8(qixis_base + 0x21, 0x2);
+       udelay(1);
+}
+#endif
+
 phys_size_t initdram(int board_type)
 {
        phys_size_t dram_size;
@@ -159,6 +171,11 @@ phys_size_t initdram(int board_type)
 #else
        dram_size =  fsl_ddr_sdram_size();
 #endif
+
+#if defined(CONFIG_DEEP_SLEEP) && !defined(CONFIG_SPL_BUILD)
+       fsl_dp_resume();
+#endif
+
        return dram_size;
 }
 
index f08e54f178605f8ee7b867aea2eaf3988cb9917c..20eade46514114ee6432f0bedf4e10af7c99b060 100644 (file)
@@ -20,6 +20,7 @@
 #include <fsl_sec.h>
 #include <spl.h>
 
+#include "../common/sleep.h"
 #include "../common/qixis.h"
 #include "ls1021aqds_qixis.h"
 #ifdef CONFIG_U_QE
@@ -48,6 +49,12 @@ enum {
        MUX_TYPE_SD_PC_SG_SG,
 };
 
+enum {
+       GE0_CLK125,
+       GE2_CLK125,
+       GE1_CLK125,
+};
+
 int checkboard(void)
 {
 #ifndef CONFIG_QSPI_BOOT
@@ -177,7 +184,6 @@ int board_early_init_f(void)
 
 #ifdef CONFIG_TSEC_ENET
        out_be32(&scfg->etsecdmamcr, SCFG_ETSECDMAMCR_LE_BD_FR);
-       out_be32(&scfg->etsecmcr, SCFG_ETSECCMCR_GE2_CLK125);
 #endif
 
 #ifdef CONFIG_FSL_IFC
@@ -188,6 +194,24 @@ int board_early_init_f(void)
        out_be32(&scfg->qspi_cfg, SCFG_QSPI_CLKSEL);
 #endif
 
+#ifdef CONFIG_FSL_DCU_FB
+       out_be32(&scfg->pixclkcr, SCFG_PIXCLKCR_PXCKEN);
+#endif
+
+       /*
+        * Enable snoop requests and DVM message requests for
+        * Slave insterface S4 (A7 core cluster)
+        */
+       out_le32(&cci->slave[4].snoop_ctrl,
+                CCI400_DVM_MESSAGE_REQ_EN | CCI400_SNOOP_REQ_EN);
+
+       /*
+        * Set CCI-400 Slave interface S1, S2 Shareable Override Register
+        * All transactions are treated as non-shareable
+        */
+       out_le32(&cci->slave[1].sha_ord, CCI400_SHAORD_NON_SHAREABLE);
+       out_le32(&cci->slave[2].sha_ord, CCI400_SHAORD_NON_SHAREABLE);
+
        /* Workaround for the issue that DDR could not respond to
         * barrier transaction which is generated by executing DSB/ISB
         * instruction. Set CCI-400 control override register to
@@ -195,6 +219,11 @@ int board_early_init_f(void)
         * allow barrier transaction to DDR again */
        out_le32(&cci->ctrl_ord, CCI400_CTRLORD_TERM_BARRIER);
 
+#if defined(CONFIG_DEEP_SLEEP)
+       if (is_warm_boot())
+               fsl_dp_disable_console();
+#endif
+
        return 0;
 }
 
@@ -219,9 +248,6 @@ void board_init_f(ulong dummy)
                 pinctl);
 #endif
 
-       /* Set global data pointer */
-       gd = &gdata;
-
        /* Clear the BSS */
        memset(__bss_start, 0, __bss_end - __bss_start);
 
@@ -231,6 +257,11 @@ void board_init_f(ulong dummy)
 
        get_clocks();
 
+#if defined(CONFIG_DEEP_SLEEP)
+       if (is_warm_boot())
+               fsl_dp_disable_console();
+#endif
+
        preloader_console_init();
 
 #ifdef CONFIG_SPL_I2C_SUPPORT
@@ -244,6 +275,32 @@ void board_init_f(ulong dummy)
 }
 #endif
 
+void config_etseccm_source(int etsec_gtx_125_mux)
+{
+       struct ccsr_scfg *scfg = (struct ccsr_scfg *)CONFIG_SYS_FSL_SCFG_ADDR;
+
+       switch (etsec_gtx_125_mux) {
+       case GE0_CLK125:
+               out_be32(&scfg->etsecmcr, SCFG_ETSECCMCR_GE0_CLK125);
+               debug("etseccm set to GE0_CLK125\n");
+               break;
+
+       case GE2_CLK125:
+               out_be32(&scfg->etsecmcr, SCFG_ETSECCMCR_GE2_CLK125);
+               debug("etseccm set to GE2_CLK125\n");
+               break;
+
+       case GE1_CLK125:
+               out_be32(&scfg->etsecmcr, SCFG_ETSECCMCR_GE1_CLK125);
+               debug("etseccm set to GE1_CLK125\n");
+               break;
+
+       default:
+               printf("Error! trying to set etseccm to invalid value\n");
+               break;
+       }
+}
+
 int config_board_mux(int ctrl_type)
 {
        u8 reg12, reg14;
@@ -253,6 +310,7 @@ int config_board_mux(int ctrl_type)
 
        switch (ctrl_type) {
        case MUX_TYPE_CAN:
+               config_etseccm_source(GE2_CLK125);
                reg14 = SET_EC_MUX_SEL(reg14, PIN_MUX_SEL_CAN);
                break;
        case MUX_TYPE_IIC2:
@@ -262,6 +320,7 @@ int config_board_mux(int ctrl_type)
                reg14 = SET_EC_MUX_SEL(reg14, PIN_MUX_SEL_RGMII);
                break;
        case MUX_TYPE_SAI:
+               config_etseccm_source(GE2_CLK125);
                reg14 = SET_EC_MUX_SEL(reg14, PIN_MUX_SEL_SAI);
                break;
        case MUX_TYPE_SDHC:
@@ -474,13 +533,6 @@ int board_init(void)
        /* Set CCI-400 control override register to
         * enable barrier transaction */
        out_le32(&cci->ctrl_ord, CCI400_CTRLORD_EN_BARRIER);
-       /*
-        * Set CCI-400 Slave interface S0, S1, S2 Shareable Override Register
-        * All transactions are treated as non-shareable
-        */
-       out_le32(&cci->slave[0].sha_ord, CCI400_SHAORD_NON_SHAREABLE);
-       out_le32(&cci->slave[1].sha_ord, CCI400_SHAORD_NON_SHAREABLE);
-       out_le32(&cci->slave[2].sha_ord, CCI400_SHAORD_NON_SHAREABLE);
 
        select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT);
 
@@ -503,6 +555,21 @@ int board_init(void)
        return 0;
 }
 
+#if defined(CONFIG_DEEP_SLEEP)
+void board_sleep_prepare(void)
+{
+       struct ccsr_cci400 __iomem *cci = (void *)CONFIG_SYS_CCI400_ADDR;
+
+       /* Set CCI-400 control override register to
+        * enable barrier transaction */
+       out_le32(&cci->ctrl_ord, CCI400_CTRLORD_EN_BARRIER);
+
+#ifdef CONFIG_LS102XA_NS_ACCESS
+       enable_devices_ns_access(ns_dev, ARRAY_SIZE(ns_dev));
+#endif
+}
+#endif
+
 int ft_board_setup(void *blob, bd_t *bd)
 {
        ft_cpu_setup(blob, bd);
index 09b3be2f9c2447a48b20a23553a9f2cba4af4f04..8e482eb0b075f07e7a197c08bb75c7549ec4bfce 100644 (file)
@@ -32,4 +32,6 @@
 
 #define QIXIS_SRDS1CLK_100             0x0
 
+#define QIXIS_DCU_BRDCFG5              0x55
+
 #endif
index 91767065faa36f0f2540d2263ea882305020fb55..e9f6f0a973a15ea6761a734b4690a0b3b028eb79 100644 (file)
@@ -5,5 +5,6 @@ F:      board/freescale/ls1021atwr/
 F:     include/configs/ls1021atwr.h
 F:     configs/ls1021atwr_nor_defconfig
 F:     configs/ls1021atwr_nor_SECURE_BOOT_defconfig
+F:     configs/ls1021atwr_nor_lpuart_defconfig
 F:     configs/ls1021atwr_sdcard_defconfig
 F:     configs/ls1021atwr_qspi_defconfig
index 8ab229ddf09040eafdb1a4289fac1d5504aa8fb1..bc8b00686c7c79831f6cf1ceb6b27ec04458909c 100644 (file)
@@ -263,6 +263,7 @@ int config_serdes_mux(void)
 int board_early_init_f(void)
 {
        struct ccsr_scfg *scfg = (struct ccsr_scfg *)CONFIG_SYS_FSL_SCFG_ADDR;
+       struct ccsr_cci400 *cci = (struct ccsr_cci400 *)CONFIG_SYS_CCI400_ADDR;
 
 #ifdef CONFIG_TSEC_ENET
        out_be32(&scfg->etsecdmamcr, SCFG_ETSECDMAMCR_LE_BD_FR);
@@ -281,15 +282,26 @@ int board_early_init_f(void)
        out_be32(&scfg->qspi_cfg, SCFG_QSPI_CLKSEL);
 #endif
 
+       /*
+        * Enable snoop requests and DVM message requests for
+        * Slave insterface S4 (A7 core cluster)
+        */
+       out_le32(&cci->slave[4].snoop_ctrl,
+                CCI400_DVM_MESSAGE_REQ_EN | CCI400_SNOOP_REQ_EN);
+
+       /*
+        * Set CCI-400 Slave interface S1, S2 Shareable Override Register
+        * All transactions are treated as non-shareable
+        */
+       out_le32(&cci->slave[1].sha_ord, CCI400_SHAORD_NON_SHAREABLE);
+       out_le32(&cci->slave[2].sha_ord, CCI400_SHAORD_NON_SHAREABLE);
+
        return 0;
 }
 
 #ifdef CONFIG_SPL_BUILD
 void board_init_f(ulong dummy)
 {
-       /* Set global data pointer */
-       gd = &gdata;
-
        /* Clear the BSS */
        memset(__bss_start, 0, __bss_end - __bss_start);
 
@@ -408,16 +420,6 @@ struct smmu_stream_id dev_stream_id[] = {
 
 int board_init(void)
 {
-       struct ccsr_cci400 *cci = (struct ccsr_cci400 *)CONFIG_SYS_CCI400_ADDR;
-
-       /*
-        * Set CCI-400 Slave interface S0, S1, S2 Shareable Override Register
-        * All transactions are treated as non-shareable
-        */
-       out_le32(&cci->slave[0].sha_ord, CCI400_SHAORD_NON_SHAREABLE);
-       out_le32(&cci->slave[1].sha_ord, CCI400_SHAORD_NON_SHAREABLE);
-       out_le32(&cci->slave[2].sha_ord, CCI400_SHAORD_NON_SHAREABLE);
-
 #ifndef CONFIG_SYS_FSL_NO_SERDES
        fsl_serdes_init();
 #ifndef CONFIG_QSPI_BOOT
diff --git a/board/freescale/mpc8360emds/Kconfig b/board/freescale/mpc8360emds/Kconfig
deleted file mode 100644 (file)
index 3f4f95c..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-if TARGET_MPC8360EMDS
-
-config SYS_BOARD
-       default "mpc8360emds"
-
-config SYS_VENDOR
-       default "freescale"
-
-config SYS_CONFIG_NAME
-       default "MPC8360EMDS"
-
-endif
diff --git a/board/freescale/mpc8360emds/MAINTAINERS b/board/freescale/mpc8360emds/MAINTAINERS
deleted file mode 100644 (file)
index 91ff2ef..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-MPC8360EMDS BOARD
-M:     Dave Liu <daveliu@freescale.com>
-S:     Maintained
-F:     board/freescale/mpc8360emds/
-F:     include/configs/MPC8360EMDS.h
-F:     configs/MPC8360EMDS_33_defconfig
-F:     configs/MPC8360EMDS_33_ATM_defconfig
-F:     configs/MPC8360EMDS_33_HOST_33_defconfig
-F:     configs/MPC8360EMDS_33_HOST_66_defconfig
-F:     configs/MPC8360EMDS_33_SLAVE_defconfig
-F:     configs/MPC8360EMDS_66_defconfig
-F:     configs/MPC8360EMDS_66_ATM_defconfig
-F:     configs/MPC8360EMDS_66_HOST_33_defconfig
-F:     configs/MPC8360EMDS_66_HOST_66_defconfig
-F:     configs/MPC8360EMDS_66_SLAVE_defconfig
diff --git a/board/freescale/mpc8360emds/Makefile b/board/freescale/mpc8360emds/Makefile
deleted file mode 100644 (file)
index e8332ce..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-#
-# (C) Copyright 2006
-# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
-#
-# SPDX-License-Identifier:     GPL-2.0+
-#
-
-obj-y += mpc8360emds.o
-obj-$(CONFIG_PCI) += pci.o
diff --git a/board/freescale/mpc8360emds/README b/board/freescale/mpc8360emds/README
deleted file mode 100644 (file)
index 6afa753..0000000
+++ /dev/null
@@ -1,155 +0,0 @@
-Freescale MPC8360EMDS Board
------------------------------------------
-1.     Board Switches and Jumpers
-1.0    There are four Dual-In-Line Packages(DIP) Switches on MPC8360EMDS board
-       For some reason, the HW designers describe the switch settings
-       in terms of 0 and 1, and then map that to physical switches where
-       the label "On" refers to logic 0 and "Off" is logic 1.
-
-       Switch bits are numbered 1 through, like, 4 6 8 or 10, but the
-       bits may contribute to signals that are numbered based at 0,
-       and some of those signals may be high-bit-number-0 too.  Heed
-       well the names and labels and do not get confused.
-
-               "Off" == 1
-               "On"  == 0
-
-       SW18 is switch 18 as silk-screened onto the board.
-       SW4[8] is the bit labeled 8 on Switch 4.
-       SW2[1:6] refers to bits labeled 1 through 6 in order on switch 2.
-       SW3[7:1] refers to bits labeled 7 through 1 in order on switch 3.
-       SW3[1:8]= 0000_0001 refers to bits labeled 1 through 6 is set as "On"
-               and bits labeled 8 is set as "Off".
-
-1.1    There are three type boards for MPC8360E silicon up to now, They are
-
-       * MPC8360E-MDS-PB PROTO (a.k.a 8360SYS PROTOTYPE)
-       * MPC8360E-MDS-PB PILOT (a.k.a 8360SYS PILOT)
-       * MPC8360EA-MDS-PB PROTO (a.k.a 8360SYS2 PROTOTYPE)
-
-1.2    For all the MPC8360EMDS Board
-
-       First, make sure the board default setting is consistent with the
-       document shipped with your board. Then apply the following setting:
-       SW3[1-8]= 0000_0100  (HRCW setting value is performed on local bus)
-       SW4[1-8]= 0011_0000  (Flash boot on local bus)
-       SW9[1-8]= 0110_0110  (PCI Mode enabled. HRCW is read from FLASH)
-       SW10[1-8]= 0000_1000  (core PLL setting)
-       SW11[1-8]= 0000_0100 (SW11 is on the another side of the board)
-       JP6 1-2
-       on board Oscillator: 66M
-
-1.3    Since different board/chip rev. combinations have AC timing issues,
-       u-boot forces RGMII-ID (RGMII with Internal Delay) mode on by default
-       by the patch (mpc83xx: Disable G1TXCLK, G2TXCLK h/w buffers).
-
-       When the rev2.x silicon mount on these boards, and if you are using
-       u-boot version after this patch, to make the ethernet interfaces usable,
-       and to enable RGMII-ID on your board, you have to setup the jumpers
-       correctly.
-
-       * MPC8360E-MDS-PB PROTO
-         nothing to do
-       * MPC8360E-MDS-PB PILOT
-         JP9 and JP8 should be ON
-       * MPC8360EA-MDS-PB PROTO
-         JP2 and JP3 should be ON
-
-2.     Memory Map
-
-2.1.   The memory map should look pretty much like this:
-
-       0x0000_0000     0x7fff_ffff     DDR                     2G
-       0x8000_0000     0x8fff_ffff     PCI MEM prefetch        256M
-       0x9000_0000     0x9fff_ffff     PCI MEM non-prefetch    256M
-       0xc000_0000     0xdfff_ffff     Empty                   512M
-       0xe000_0000     0xe01f_ffff     Int Mem Reg Space       2M
-       0xe020_0000     0xe02f_ffff     Empty                   1M
-       0xe030_0000     0xe03f_ffff     PCI IO                  1M
-       0xe040_0000     0xefff_ffff     Empty                   252M
-       0xf000_0000     0xf3ff_ffff     Local Bus SDRAM         64M
-       0xf400_0000     0xf7ff_ffff     Empty                   64M
-       0xf800_0000     0xf800_7fff     BCSR on CS1             32K
-       0xf800_8000     0xf800_ffff     PIB CS4                 32K
-       0xf801_0000     0xf801_7fff     PIB CS5                 32K
-       0xfe00_0000     0xfeff_ffff     FLASH on CS0            16M
-
-
-3. Definitions
-
-3.1 Explanation of NEW definitions in:
-
-       include/configs/MPC8360EMDS.h
-
-    CONFIG_MPC83xx         MPC83xx family for both MPC8349 and MPC8360
-    CONFIG_MPC8360         MPC8360 specific
-    CONFIG_MPC8360EMDS     MPC8360EMDS board specific
-
-4. Compilation
-
-       MPC8360EMDS shipped with 33.33MHz or 66MHz oscillator(check U41 chip).
-
-       Assuming you're using BASH shell:
-
-               export CROSS_COMPILE=your-cross-compile-prefix
-               cd u-boot
-               make distclean
-               make MPC8360EMDS_XX_config
-               make
-
-       MPC8360EMDS support ATM, PCI in host and slave mode.
-
-       To make u-boot support ATM :
-       1) Make MPC8360EMDS_XX_ATM_config
-
-       To make u-boot support PCI host 66M :
-       1) DIP SW support PCI mode as described in Section 1.1.
-       2) Make MPC8360EMDS_XX_HOST_66_config
-
-       To make u-boot support PCI host 33M :
-       1) DIP SW setting is similar as Section 1.1, except for SW3[4] is 1
-       2) Make MPC8360EMDS_XX_HOST_33_config
-
-       To make u-boot support PCI slave 66M :
-       1) DIP SW setting is similar as Section 1.1, except for SW9[3] is 1
-       2) Make MPC8360EMDS_XX_SLAVE_config
-
-       (where XX is:
-          33 - 33.33MHz oscillator
-          66 - 66MHz oscillator)
-
-5. Downloading and Flashing Images
-
-5.0 Download over serial line using Kermit:
-
-       loadb
-       [Drop to kermit:
-           ^\c
-           send <u-boot-bin-image>
-           c
-       ]
-
-
-    Or via tftp:
-
-       tftp 10000 u-boot.bin
-
-5.1 Reflash U-boot Image using U-boot
-
-       tftp 20000 u-boot.bin
-       protect off fef00000 fef3ffff
-       erase fef00000 fef3ffff
-
-       cp.b 20000 fef00000 xxxx
-
-       or
-
-       cp.b 20000 fef00000 3ffff
-
-
-You have to supply the correct byte count with 'xxxx' from the TFTP result log.
-Maybe 3ffff will work too, that corresponds to the erased sectors.
-
-
-6. Notes
-       1) The console baudrate for MPC8360EMDS is 115200bps.
diff --git a/board/freescale/mpc8360emds/mpc8360emds.c b/board/freescale/mpc8360emds/mpc8360emds.c
deleted file mode 100644 (file)
index f0a55f8..0000000
+++ /dev/null
@@ -1,453 +0,0 @@
-/*
- * Copyright (C) 2006,2010-2011 Freescale Semiconductor, Inc.
- * Dave Liu <daveliu@freescale.com>
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#include <common.h>
-#include <ioports.h>
-#include <mpc83xx.h>
-#include <i2c.h>
-#include <miiphy.h>
-#include <phy.h>
-#include <fsl_mdio.h>
-#if defined(CONFIG_PCI)
-#include <pci.h>
-#endif
-#include <spd_sdram.h>
-#include <asm/mmu.h>
-#include <asm/io.h>
-#include <asm/mmu.h>
-#if defined(CONFIG_OF_LIBFDT)
-#include <libfdt.h>
-#endif
-#include <hwconfig.h>
-#include <fdt_support.h>
-#if defined(CONFIG_PQ_MDS_PIB)
-#include "../common/pq-mds-pib.h"
-#endif
-#include "../../../drivers/qe/uec.h"
-
-const qe_iop_conf_t qe_iop_conf_tab[] = {
-       /* GETH1 */
-       {0,  3, 1, 0, 1}, /* TxD0 */
-       {0,  4, 1, 0, 1}, /* TxD1 */
-       {0,  5, 1, 0, 1}, /* TxD2 */
-       {0,  6, 1, 0, 1}, /* TxD3 */
-       {1,  6, 1, 0, 3}, /* TxD4 */
-       {1,  7, 1, 0, 1}, /* TxD5 */
-       {1,  9, 1, 0, 2}, /* TxD6 */
-       {1, 10, 1, 0, 2}, /* TxD7 */
-       {0,  9, 2, 0, 1}, /* RxD0 */
-       {0, 10, 2, 0, 1}, /* RxD1 */
-       {0, 11, 2, 0, 1}, /* RxD2 */
-       {0, 12, 2, 0, 1}, /* RxD3 */
-       {0, 13, 2, 0, 1}, /* RxD4 */
-       {1,  1, 2, 0, 2}, /* RxD5 */
-       {1,  0, 2, 0, 2}, /* RxD6 */
-       {1,  4, 2, 0, 2}, /* RxD7 */
-       {0,  7, 1, 0, 1}, /* TX_EN */
-       {0,  8, 1, 0, 1}, /* TX_ER */
-       {0, 15, 2, 0, 1}, /* RX_DV */
-       {0, 16, 2, 0, 1}, /* RX_ER */
-       {0,  0, 2, 0, 1}, /* RX_CLK */
-       {2,  9, 1, 0, 3}, /* GTX_CLK - CLK10 */
-       {2,  8, 2, 0, 1}, /* GTX125 - CLK9 */
-       /* GETH2 */
-       {0, 17, 1, 0, 1}, /* TxD0 */
-       {0, 18, 1, 0, 1}, /* TxD1 */
-       {0, 19, 1, 0, 1}, /* TxD2 */
-       {0, 20, 1, 0, 1}, /* TxD3 */
-       {1,  2, 1, 0, 1}, /* TxD4 */
-       {1,  3, 1, 0, 2}, /* TxD5 */
-       {1,  5, 1, 0, 3}, /* TxD6 */
-       {1,  8, 1, 0, 3}, /* TxD7 */
-       {0, 23, 2, 0, 1}, /* RxD0 */
-       {0, 24, 2, 0, 1}, /* RxD1 */
-       {0, 25, 2, 0, 1}, /* RxD2 */
-       {0, 26, 2, 0, 1}, /* RxD3 */
-       {0, 27, 2, 0, 1}, /* RxD4 */
-       {1, 12, 2, 0, 2}, /* RxD5 */
-       {1, 13, 2, 0, 3}, /* RxD6 */
-       {1, 11, 2, 0, 2}, /* RxD7 */
-       {0, 21, 1, 0, 1}, /* TX_EN */
-       {0, 22, 1, 0, 1}, /* TX_ER */
-       {0, 29, 2, 0, 1}, /* RX_DV */
-       {0, 30, 2, 0, 1}, /* RX_ER */
-       {0, 31, 2, 0, 1}, /* RX_CLK */
-       {2,  2, 1, 0, 2}, /* GTX_CLK = CLK10 */
-       {2,  3, 2, 0, 1}, /* GTX125 - CLK4 */
-
-       {0,  1, 3, 0, 2}, /* MDIO */
-       {0,  2, 1, 0, 1}, /* MDC */
-
-       {5,  0, 1, 0, 2}, /* UART2_SOUT */
-       {5,  1, 2, 0, 3}, /* UART2_CTS */
-       {5,  2, 1, 0, 1}, /* UART2_RTS */
-       {5,  3, 2, 0, 2}, /* UART2_SIN */
-
-       {0,  0, 0, 0, QE_IOP_TAB_END}, /* END of table */
-};
-
-/* Handle "mpc8360ea rev.2.1 erratum 2: RGMII Timing"? */
-static int board_handle_erratum2(void)
-{
-       const immap_t *immr = (immap_t *)CONFIG_SYS_IMMR;
-
-       return REVID_MAJOR(immr->sysconf.spridr) == 2 &&
-              REVID_MINOR(immr->sysconf.spridr) == 1;
-}
-
-int board_early_init_f(void)
-{
-       const immap_t *immr = (immap_t *)CONFIG_SYS_IMMR;
-       u8 *bcsr = (u8 *)CONFIG_SYS_BCSR;
-
-       /* Enable flash write */
-       bcsr[0xa] &= ~0x04;
-
-       /* Disable G1TXCLK, G2TXCLK h/w buffers (rev.2.x h/w bug workaround) */
-       if (REVID_MAJOR(immr->sysconf.spridr) == 2)
-               bcsr[0xe] = 0x30;
-
-       /* Enable second UART */
-       bcsr[0x9] &= ~0x01;
-
-       if (board_handle_erratum2()) {
-               void *immap = (immap_t *)(CONFIG_SYS_IMMR + 0x14a8);
-
-               /*
-                * IMMR + 0x14A8[4:5] = 11 (clk delay for UCC 2)
-                * IMMR + 0x14A8[18:19] = 11 (clk delay for UCC 1)
-                */
-               setbits_be32(immap, 0x0c003000);
-
-               /*
-                * IMMR + 0x14AC[20:27] = 10101010
-                * (data delay for both UCC's)
-                */
-               clrsetbits_be32(immap + 4, 0xff0, 0xaa0);
-       }
-       return 0;
-}
-
-int board_early_init_r(void)
-{
-       gd_t *gd;
-#ifdef CONFIG_PQ_MDS_PIB
-       pib_init();
-#endif
-       /*
-        * BAT6 is used for SDRAM when DDR size is 512MB or larger than 256MB
-        * So re-setup PCI MEM space used BAT5 after relocated to DDR
-        */
-       gd = (gd_t *)(CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_GBL_DATA_OFFSET);
-       if (gd->ram_size > CONFIG_MAX_MEM_MAPPED) {
-               write_bat(DBAT5, CONFIG_SYS_DBAT6U, CONFIG_SYS_DBAT6L);
-               write_bat(IBAT5, CONFIG_SYS_IBAT6U, CONFIG_SYS_IBAT6L);
-       }
-
-       return 0;
-}
-
-#ifdef CONFIG_UEC_ETH
-static uec_info_t uec_info[] = {
-#ifdef CONFIG_UEC_ETH1
-       STD_UEC_INFO(1),
-#endif
-#ifdef CONFIG_UEC_ETH2
-       STD_UEC_INFO(2),
-#endif
-};
-
-int board_eth_init(bd_t *bd)
-{
-       if (board_handle_erratum2()) {
-               int i;
-
-               for (i = 0; i < ARRAY_SIZE(uec_info); i++) {
-                       uec_info[i].enet_interface_type =
-                               PHY_INTERFACE_MODE_RGMII_RXID;
-                       uec_info[i].speed = SPEED_1000;
-               }
-       }
-       return uec_eth_init(bd, uec_info, ARRAY_SIZE(uec_info));
-}
-#endif /* CONFIG_UEC_ETH */
-
-#if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER)
-extern void ddr_enable_ecc(unsigned int dram_size);
-#endif
-int fixed_sdram(void);
-static int sdram_init(unsigned int base);
-
-phys_size_t initdram(int board_type)
-{
-       volatile immap_t *im = (immap_t *) CONFIG_SYS_IMMR;
-       u32 msize = 0;
-       u32 lbc_sdram_size;
-
-       if ((im->sysconf.immrbar & IMMRBAR_BASE_ADDR) != (u32) im)
-               return -1;
-
-       /* DDR SDRAM - Main SODIMM */
-       im->sysconf.ddrlaw[0].bar = CONFIG_SYS_DDR_BASE & LAWBAR_BAR;
-#if defined(CONFIG_SPD_EEPROM)
-       msize = spd_sdram();
-#else
-       msize = fixed_sdram();
-#endif
-
-#if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER)
-       /*
-        * Initialize DDR ECC byte
-        */
-       ddr_enable_ecc(msize * 1024 * 1024);
-#endif
-       /*
-        * Initialize SDRAM if it is on local bus.
-        */
-       lbc_sdram_size = sdram_init(msize * 1024 * 1024);
-       if (!msize)
-               msize = lbc_sdram_size;
-
-       /* return total bus SDRAM size(bytes)  -- DDR */
-       return (msize * 1024 * 1024);
-}
-
-#if !defined(CONFIG_SPD_EEPROM)
-/*************************************************************************
- *  fixed sdram init -- doesn't use serial presence detect.
- ************************************************************************/
-int fixed_sdram(void)
-{
-       volatile immap_t *im = (immap_t *) CONFIG_SYS_IMMR;
-       u32 msize = CONFIG_SYS_DDR_SIZE;
-       u32 ddr_size = msize << 20;
-       u32 ddr_size_log2 = __ilog2(ddr_size);
-       u32 half_ddr_size = ddr_size >> 1;
-
-       im->sysconf.ddrlaw[0].bar =
-               CONFIG_SYS_DDR_SDRAM_BASE & 0xfffff000;
-       im->sysconf.ddrlaw[0].ar =
-               LAWAR_EN | ((ddr_size_log2 - 1) & LAWAR_SIZE);
-#if (CONFIG_SYS_DDR_SIZE != 256)
-#warning Currenly any ddr size other than 256 is not supported
-#endif
-#ifdef CONFIG_DDR_II
-       im->ddr.csbnds[0].csbnds = CONFIG_SYS_DDR_CS0_BNDS;
-       im->ddr.cs_config[0] = CONFIG_SYS_DDR_CS0_CONFIG;
-       im->ddr.timing_cfg_0 = CONFIG_SYS_DDR_TIMING_0;
-       im->ddr.timing_cfg_1 = CONFIG_SYS_DDR_TIMING_1;
-       im->ddr.timing_cfg_2 = CONFIG_SYS_DDR_TIMING_2;
-       im->ddr.timing_cfg_3 = CONFIG_SYS_DDR_TIMING_3;
-       im->ddr.sdram_cfg = CONFIG_SYS_DDR_SDRAM_CFG;
-       im->ddr.sdram_cfg2 = CONFIG_SYS_DDR_SDRAM_CFG2;
-       im->ddr.sdram_mode = CONFIG_SYS_DDR_MODE;
-       im->ddr.sdram_mode2 = CONFIG_SYS_DDR_MODE2;
-       im->ddr.sdram_interval = CONFIG_SYS_DDR_INTERVAL;
-       im->ddr.sdram_clk_cntl = CONFIG_SYS_DDR_CLK_CNTL;
-#else
-
-#if ((CONFIG_SYS_DDR_SDRAM_BASE & 0x00FFFFFF) != 0)
-#warning Chip select bounds is only configurable in 16MB increments
-#endif
-       im->ddr.csbnds[0].csbnds =
-               ((CONFIG_SYS_DDR_SDRAM_BASE >> CSBNDS_SA_SHIFT) & CSBNDS_SA) |
-               (((CONFIG_SYS_DDR_SDRAM_BASE + half_ddr_size - 1) >>
-                               CSBNDS_EA_SHIFT) & CSBNDS_EA);
-       im->ddr.csbnds[1].csbnds =
-               (((CONFIG_SYS_DDR_SDRAM_BASE + half_ddr_size) >>
-                               CSBNDS_SA_SHIFT) & CSBNDS_SA) |
-               (((CONFIG_SYS_DDR_SDRAM_BASE + ddr_size - 1) >>
-                               CSBNDS_EA_SHIFT) & CSBNDS_EA);
-
-       im->ddr.cs_config[0] = CONFIG_SYS_DDR_CS0_CONFIG;
-       im->ddr.cs_config[1] = CONFIG_SYS_DDR_CS1_CONFIG;
-
-       im->ddr.cs_config[2] = 0;
-       im->ddr.cs_config[3] = 0;
-
-       im->ddr.timing_cfg_1 = CONFIG_SYS_DDR_TIMING_1;
-       im->ddr.timing_cfg_2 = CONFIG_SYS_DDR_TIMING_2;
-       im->ddr.sdram_cfg = CONFIG_SYS_DDR_CONTROL;
-
-       im->ddr.sdram_mode = CONFIG_SYS_DDR_MODE;
-       im->ddr.sdram_interval = CONFIG_SYS_DDR_INTERVAL;
-#endif
-       udelay(200);
-       im->ddr.sdram_cfg |= SDRAM_CFG_MEM_EN;
-
-       return msize;
-}
-#endif                         /*!CONFIG_SYS_SPD_EEPROM */
-
-int checkboard(void)
-{
-       puts("Board: Freescale MPC8360EMDS\n");
-       return 0;
-}
-
-/*
- * if MPC8360EMDS is soldered with SDRAM
- */
-#ifdef CONFIG_SYS_LB_SDRAM
-/*
- * Initialize SDRAM memory on the Local Bus.
- */
-
-static int sdram_init(unsigned int base)
-{
-       volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
-       fsl_lbc_t *lbc = LBC_BASE_ADDR;
-       const int sdram_size = CONFIG_SYS_LBC_SDRAM_SIZE * 1024 * 1024;
-       int rem = base % sdram_size;
-       uint *sdram_addr;
-
-       /* window base address should be aligned to the window size */
-       if (rem)
-               base = base - rem + sdram_size;
-
-       /*
-        * Setup BAT6 for SDRAM when DDR size is 512MB or larger than 256MB
-        * After relocated to DDR, reuse BAT5 for PCI MEM space
-        */
-       if (base > CONFIG_MAX_MEM_MAPPED) {
-               unsigned long batl = base | BATL_PP_10 | BATL_MEMCOHERENCE;
-               unsigned long batu = base | BATU_BL_64M | BATU_VS | BATU_VP;
-
-               /* Setup the BAT6 for SDRAM */
-               write_bat(DBAT6, batu, batl);
-               write_bat(IBAT6, batu, batl);
-       }
-
-       sdram_addr = (uint *)base;
-       /*
-        * Setup SDRAM Base and Option Registers
-        */
-       set_lbc_br(2, base | CONFIG_SYS_BR2);
-       set_lbc_or(2, CONFIG_SYS_OR2);
-       immap->sysconf.lblaw[2].bar = base;
-       immap->sysconf.lblaw[2].ar = CONFIG_SYS_LBLAWAR2;
-
-       /*setup mtrpt, lsrt and lbcr for LB bus */
-       lbc->lbcr = CONFIG_SYS_LBC_LBCR;
-       lbc->mrtpr = CONFIG_SYS_LBC_MRTPR;
-       lbc->lsrt = CONFIG_SYS_LBC_LSRT;
-       asm("sync");
-
-       /*
-        * Configure the SDRAM controller Machine Mode Register.
-        */
-       lbc->lsdmr = CONFIG_SYS_LBC_LSDMR_5;    /* Normal Operation */
-       lbc->lsdmr = CONFIG_SYS_LBC_LSDMR_1;    /* Precharge All Banks */
-       asm("sync");
-       *sdram_addr = 0xff;
-       udelay(100);
-
-       /*
-        * We need do 8 times auto refresh operation.
-        */
-       lbc->lsdmr = CONFIG_SYS_LBC_LSDMR_2;
-       asm("sync");
-       *sdram_addr = 0xff;     /* 1 times */
-       udelay(100);
-       *sdram_addr = 0xff;     /* 2 times */
-       udelay(100);
-       *sdram_addr = 0xff;     /* 3 times */
-       udelay(100);
-       *sdram_addr = 0xff;     /* 4 times */
-       udelay(100);
-       *sdram_addr = 0xff;     /* 5 times */
-       udelay(100);
-       *sdram_addr = 0xff;     /* 6 times */
-       udelay(100);
-       *sdram_addr = 0xff;     /* 7 times */
-       udelay(100);
-       *sdram_addr = 0xff;     /* 8 times */
-       udelay(100);
-
-       /* Mode register write operation */
-       lbc->lsdmr = CONFIG_SYS_LBC_LSDMR_4;
-       asm("sync");
-       *(sdram_addr + 0xcc) = 0xff;
-       udelay(100);
-
-       /* Normal operation */
-       lbc->lsdmr = CONFIG_SYS_LBC_LSDMR_5 | 0x40000000;
-       asm("sync");
-       *sdram_addr = 0xff;
-       udelay(100);
-
-       /*
-        * In non-aligned case we don't [normally] use that memory because
-        * there is a hole.
-        */
-       if (rem)
-               return 0;
-       return CONFIG_SYS_LBC_SDRAM_SIZE;
-}
-#else
-static int sdram_init(unsigned int base) { return 0; }
-#endif
-
-#if defined(CONFIG_OF_BOARD_SETUP)
-static void ft_board_fixup_qe_usb(void *blob, bd_t *bd)
-{
-       if (!hwconfig_subarg_cmp("qe_usb", "mode", "peripheral"))
-               return;
-
-       do_fixup_by_compat(blob, "fsl,mpc8323-qe-usb", "mode",
-                          "peripheral", sizeof("peripheral"), 1);
-}
-
-int ft_board_setup(void *blob, bd_t *bd)
-{
-       ft_cpu_setup(blob, bd);
-#ifdef CONFIG_PCI
-       ft_pci_setup(blob, bd);
-#endif
-       ft_board_fixup_qe_usb(blob, bd);
-       /*
-        * mpc8360ea pb mds errata 2: RGMII timing
-        * if on mpc8360ea rev. 2.1,
-        * change both ucc phy-connection-types from rgmii-id to rgmii-rxid
-        */
-       if (board_handle_erratum2()) {
-               int nodeoffset;
-               const char *prop;
-               int path;
-
-               nodeoffset = fdt_path_offset(blob, "/aliases");
-               if (nodeoffset >= 0) {
-#if defined(CONFIG_HAS_ETH0)
-                       /* fixup UCC 1 if using rgmii-id mode */
-                       prop = fdt_getprop(blob, nodeoffset, "ethernet0", NULL);
-                       if (prop) {
-                               path = fdt_path_offset(blob, prop);
-                               prop = fdt_getprop(blob, path,
-                                                  "phy-connection-type", 0);
-                               if (prop && (strcmp(prop, "rgmii-id") == 0))
-                                       fdt_fixup_phy_connection(blob, path,
-                                               PHY_INTERFACE_MODE_RGMII_RXID);
-                       }
-#endif
-#if defined(CONFIG_HAS_ETH1)
-                       /* fixup UCC 2 if using rgmii-id mode */
-                       prop = fdt_getprop(blob, nodeoffset, "ethernet1", NULL);
-                       if (prop) {
-                               path = fdt_path_offset(blob, prop);
-                               prop = fdt_getprop(blob, path,
-                                                  "phy-connection-type", 0);
-                               if (prop && (strcmp(prop, "rgmii-id") == 0))
-                                       fdt_fixup_phy_connection(blob, path,
-                                               PHY_INTERFACE_MODE_RGMII_RXID);
-                       }
-#endif
-               }
-       }
-
-       return 0;
-}
-#endif
diff --git a/board/freescale/mpc8360emds/pci.c b/board/freescale/mpc8360emds/pci.c
deleted file mode 100644 (file)
index 71244df..0000000
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * Copyright (C) 2006-2009 Freescale Semiconductor, Inc.
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-/*
- * PCI Configuration space access support for MPC83xx PCI Bridge
- */
-
-#include <asm/mmu.h>
-#include <asm/io.h>
-#include <common.h>
-#include <mpc83xx.h>
-#include <pci.h>
-#include <i2c.h>
-#include <asm/fsl_i2c.h>
-#include "../common/pq-mds-pib.h"
-
-DECLARE_GLOBAL_DATA_PTR;
-
-static struct pci_region pci1_regions[] = {
-       {
-               bus_start: CONFIG_SYS_PCI1_MEM_BASE,
-               phys_start: CONFIG_SYS_PCI1_MEM_PHYS,
-               size: CONFIG_SYS_PCI1_MEM_SIZE,
-               flags: PCI_REGION_MEM | PCI_REGION_PREFETCH
-       },
-       {
-               bus_start: CONFIG_SYS_PCI1_IO_BASE,
-               phys_start: CONFIG_SYS_PCI1_IO_PHYS,
-               size: CONFIG_SYS_PCI1_IO_SIZE,
-               flags: PCI_REGION_IO
-       },
-       {
-               bus_start: CONFIG_SYS_PCI1_MMIO_BASE,
-               phys_start: CONFIG_SYS_PCI1_MMIO_PHYS,
-               size: CONFIG_SYS_PCI1_MMIO_SIZE,
-               flags: PCI_REGION_MEM
-       },
-};
-
-#ifdef CONFIG_MPC83XX_PCI2
-static struct pci_region pci2_regions[] = {
-       {
-               bus_start: CONFIG_SYS_PCI2_MEM_BASE,
-               phys_start: CONFIG_SYS_PCI2_MEM_PHYS,
-               size: CONFIG_SYS_PCI2_MEM_SIZE,
-               flags: PCI_REGION_MEM | PCI_REGION_PREFETCH
-       },
-       {
-               bus_start: CONFIG_SYS_PCI2_IO_BASE,
-               phys_start: CONFIG_SYS_PCI2_IO_PHYS,
-               size: CONFIG_SYS_PCI2_IO_SIZE,
-               flags: PCI_REGION_IO
-       },
-       {
-               bus_start: CONFIG_SYS_PCI2_MMIO_BASE,
-               phys_start: CONFIG_SYS_PCI2_MMIO_PHYS,
-               size: CONFIG_SYS_PCI2_MMIO_SIZE,
-               flags: PCI_REGION_MEM
-       },
-};
-#endif
-
-void pci_init_board(void)
-#ifdef CONFIG_PCISLAVE
-{
-       volatile immap_t *immr = (volatile immap_t *)CONFIG_SYS_IMMR;
-       volatile law83xx_t *pci_law = immr->sysconf.pcilaw;
-       volatile pcictrl83xx_t *pci_ctrl = &immr->pci_ctrl[0];
-       struct pci_region *reg[] = { pci1_regions };
-
-       /* Configure PCI Local Access Windows */
-       pci_law[0].bar = CONFIG_SYS_PCI1_MEM_PHYS & LAWBAR_BAR;
-       pci_law[0].ar = LAWAR_EN | LAWAR_SIZE_512M;
-
-       pci_law[1].bar = CONFIG_SYS_PCI1_IO_PHYS & LAWBAR_BAR;
-       pci_law[1].ar = LAWAR_EN | LAWAR_SIZE_1M;
-
-       mpc83xx_pci_init(1, reg);
-
-       /*
-        * Configure PCI Inbound Translation Windows
-        */
-       pci_ctrl[0].pitar0 = 0x0;
-       pci_ctrl[0].pibar0 = 0x0;
-       pci_ctrl[0].piwar0 = PIWAR_EN | PIWAR_RTT_SNOOP |
-           PIWAR_WTT_SNOOP | PIWAR_IWS_4K;
-
-       pci_ctrl[0].pitar1 = 0x0;
-       pci_ctrl[0].pibar1 = 0x0;
-       pci_ctrl[0].piebar1 = 0x0;
-       pci_ctrl[0].piwar1 &= ~PIWAR_EN;
-
-       pci_ctrl[0].pitar2 = 0x0;
-       pci_ctrl[0].pibar2 = 0x0;
-       pci_ctrl[0].piebar2 = 0x0;
-       pci_ctrl[0].piwar2 &= ~PIWAR_EN;
-
-       /* Unlock the configuration bit */
-       mpc83xx_pcislave_unlock(0);
-       printf("PCI:   Agent mode enabled\n");
-}
-#else
-{
-       volatile immap_t *immr = (volatile immap_t *)CONFIG_SYS_IMMR;
-       volatile clk83xx_t *clk = (volatile clk83xx_t *)&immr->clk;
-       volatile law83xx_t *pci_law = immr->sysconf.pcilaw;
-#ifndef CONFIG_MPC83XX_PCI2
-       struct pci_region *reg[] = { pci1_regions };
-#else
-       struct pci_region *reg[] = { pci1_regions, pci2_regions };
-#endif
-
-       /* initialize the PCA9555PW IO expander on the PIB board */
-       pib_init();
-
-#if defined(CONFIG_PCI_66M)
-       clk->occr = OCCR_PCICOE0 | OCCR_PCICOE1 | OCCR_PCICOE2;
-       printf("PCI clock is 66MHz\n");
-#elif defined(CONFIG_PCI_33M)
-       clk->occr = OCCR_PCICOE0 | OCCR_PCICOE1 | OCCR_PCICOE2 |
-           OCCR_PCICD0 | OCCR_PCICD1 | OCCR_PCICD2 | OCCR_PCICR;
-       printf("PCI clock is 33MHz\n");
-#else
-       clk->occr = OCCR_PCICOE0 | OCCR_PCICOE1 | OCCR_PCICOE2;
-       printf("PCI clock is 66MHz\n");
-#endif
-       udelay(2000);
-
-       /* Configure PCI Local Access Windows */
-       pci_law[0].bar = CONFIG_SYS_PCI1_MEM_PHYS & LAWBAR_BAR;
-       pci_law[0].ar = LAWAR_EN | LAWAR_SIZE_512M;
-
-       pci_law[1].bar = CONFIG_SYS_PCI1_IO_PHYS & LAWBAR_BAR;
-       pci_law[1].ar = LAWAR_EN | LAWAR_SIZE_1M;
-
-       udelay(2000);
-
-#ifndef CONFIG_MPC83XX_PCI2
-       mpc83xx_pci_init(1, reg);
-#else
-       mpc83xx_pci_init(2, reg);
-#endif
-}
-#endif                         /* CONFIG_PCISLAVE */
diff --git a/board/freescale/mpc8360erdk/Kconfig b/board/freescale/mpc8360erdk/Kconfig
deleted file mode 100644 (file)
index 5c9be7c..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-if TARGET_MPC8360ERDK
-
-config SYS_BOARD
-       default "mpc8360erdk"
-
-config SYS_VENDOR
-       default "freescale"
-
-config SYS_CONFIG_NAME
-       default "MPC8360ERDK"
-
-endif
diff --git a/board/freescale/mpc8360erdk/MAINTAINERS b/board/freescale/mpc8360erdk/MAINTAINERS
deleted file mode 100644 (file)
index e5b5995..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-MPC8360ERDK BOARD
-#M:    Anton Vorontsov <avorontsov@ru.mvista.com>
-S:     Orphan (since 2014-03)
-F:     board/freescale/mpc8360erdk/
-F:     include/configs/MPC8360ERDK.h
-F:     configs/MPC8360ERDK_defconfig
-F:     configs/MPC8360ERDK_33_defconfig
diff --git a/board/freescale/mpc8360erdk/Makefile b/board/freescale/mpc8360erdk/Makefile
deleted file mode 100644 (file)
index e2235c2..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-#
-# (C) Copyright 2006
-# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
-#
-# SPDX-License-Identifier:     GPL-2.0+
-#
-
-obj-y += mpc8360erdk.o
-obj-$(CONFIG_CMD_NAND) += nand.o
diff --git a/board/freescale/mpc8360erdk/mpc8360erdk.c b/board/freescale/mpc8360erdk/mpc8360erdk.c
deleted file mode 100644 (file)
index 478f820..0000000
+++ /dev/null
@@ -1,350 +0,0 @@
-/*
- * Copyright (C) 2006 Freescale Semiconductor, Inc.
- *                    Dave Liu <daveliu@freescale.com>
- *
- * Copyright (C) 2007 Logic Product Development, Inc.
- *                    Peter Barada <peterb@logicpd.com>
- *
- * Copyright (C) 2007 MontaVista Software, Inc.
- *                    Anton Vorontsov <avorontsov@ru.mvista.com>
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#include <common.h>
-#include <ioports.h>
-#include <mpc83xx.h>
-#include <i2c.h>
-#include <miiphy.h>
-#include <asm/io.h>
-#include <asm/mmu.h>
-#include <pci.h>
-#include <libfdt.h>
-
-const qe_iop_conf_t qe_iop_conf_tab[] = {
-       /* MDIO */
-       {0,  1, 3, 0, 2}, /* MDIO */
-       {0,  2, 1, 0, 1}, /* MDC */
-
-       /* UCC1 - UEC (Gigabit) */
-       {0,  3, 1, 0, 1}, /* TxD0 */
-       {0,  4, 1, 0, 1}, /* TxD1 */
-       {0,  5, 1, 0, 1}, /* TxD2 */
-       {0,  6, 1, 0, 1}, /* TxD3 */
-       {0,  9, 2, 0, 1}, /* RxD0 */
-       {0, 10, 2, 0, 1}, /* RxD1 */
-       {0, 11, 2, 0, 1}, /* RxD2 */
-       {0, 12, 2, 0, 1}, /* RxD3 */
-       {0,  7, 1, 0, 1}, /* TX_EN */
-       {0,  8, 1, 0, 1}, /* TX_ER */
-       {0, 15, 2, 0, 1}, /* RX_DV */
-       {0,  0, 2, 0, 1}, /* RX_CLK */
-       {2,  9, 1, 0, 3}, /* GTX_CLK - CLK10 */
-       {2,  8, 2, 0, 1}, /* GTX125 - CLK9 */
-
-       /* UCC2 - UEC (Gigabit) */
-       {0, 17, 1, 0, 1}, /* TxD0 */
-       {0, 18, 1, 0, 1}, /* TxD1 */
-       {0, 19, 1, 0, 1}, /* TxD2 */
-       {0, 20, 1, 0, 1}, /* TxD3 */
-       {0, 23, 2, 0, 1}, /* RxD0 */
-       {0, 24, 2, 0, 1}, /* RxD1 */
-       {0, 25, 2, 0, 1}, /* RxD2 */
-       {0, 26, 2, 0, 1}, /* RxD3 */
-       {0, 21, 1, 0, 1}, /* TX_EN */
-       {0, 22, 1, 0, 1}, /* TX_ER */
-       {0, 29, 2, 0, 1}, /* RX_DV */
-       {0, 31, 2, 0, 1}, /* RX_CLK */
-       {2,  2, 1, 0, 2}, /* GTX_CLK - CLK10 */
-       {2,  3, 2, 0, 1}, /* GTX125 - CLK4 */
-
-       /* UCC7 - UEC */
-       {4,  0, 1, 0, 1}, /* TxD0 */
-       {4,  1, 1, 0, 1}, /* TxD1 */
-       {4,  2, 1, 0, 1}, /* TxD2 */
-       {4,  3, 1, 0, 1}, /* TxD3 */
-       {4,  6, 2, 0, 1}, /* RxD0 */
-       {4,  7, 2, 0, 1}, /* RxD1 */
-       {4,  8, 2, 0, 1}, /* RxD2 */
-       {4,  9, 2, 0, 1}, /* RxD3 */
-       {4,  4, 1, 0, 1}, /* TX_EN */
-       {4,  5, 1, 0, 1}, /* TX_ER */
-       {4, 12, 2, 0, 1}, /* RX_DV */
-       {4, 13, 2, 0, 1}, /* RX_ER */
-       {4, 10, 2, 0, 1}, /* COL */
-       {4, 11, 2, 0, 1}, /* CRS */
-       {2, 18, 2, 0, 1}, /* TX_CLK - CLK19 */
-       {2, 19, 2, 0, 1}, /* RX_CLK - CLK20 */
-
-       /* UCC4 - UEC */
-       {1, 14, 1, 0, 1}, /* TxD0 */
-       {1, 15, 1, 0, 1}, /* TxD1 */
-       {1, 16, 1, 0, 1}, /* TxD2 */
-       {1, 17, 1, 0, 1}, /* TxD3 */
-       {1, 20, 2, 0, 1}, /* RxD0 */
-       {1, 21, 2, 0, 1}, /* RxD1 */
-       {1, 22, 2, 0, 1}, /* RxD2 */
-       {1, 23, 2, 0, 1}, /* RxD3 */
-       {1, 18, 1, 0, 1}, /* TX_EN */
-       {1, 19, 1, 0, 2}, /* TX_ER */
-       {1, 26, 2, 0, 1}, /* RX_DV */
-       {1, 27, 2, 0, 1}, /* RX_ER */
-       {1, 24, 2, 0, 1}, /* COL */
-       {1, 25, 2, 0, 1}, /* CRS */
-       {2,  6, 2, 0, 1}, /* TX_CLK - CLK7 */
-       {2,  7, 2, 0, 1}, /* RX_CLK - CLK8 */
-
-       /* PCI1 */
-       {5,  4, 2, 0, 3}, /* PCI_M66EN */
-       {5,  5, 1, 0, 3}, /* PCI_INTA */
-       {5,  6, 1, 0, 3}, /* PCI_RSTO */
-       {5,  7, 3, 0, 3}, /* PCI_C_BE0 */
-       {5,  8, 3, 0, 3}, /* PCI_C_BE1 */
-       {5,  9, 3, 0, 3}, /* PCI_C_BE2 */
-       {5, 10, 3, 0, 3}, /* PCI_C_BE3 */
-       {5, 11, 3, 0, 3}, /* PCI_PAR */
-       {5, 12, 3, 0, 3}, /* PCI_FRAME */
-       {5, 13, 3, 0, 3}, /* PCI_TRDY */
-       {5, 14, 3, 0, 3}, /* PCI_IRDY */
-       {5, 15, 3, 0, 3}, /* PCI_STOP */
-       {5, 16, 3, 0, 3}, /* PCI_DEVSEL */
-       {5, 17, 0, 0, 0}, /* PCI_IDSEL */
-       {5, 18, 3, 0, 3}, /* PCI_SERR */
-       {5, 19, 3, 0, 3}, /* PCI_PERR */
-       {5, 20, 3, 0, 3}, /* PCI_REQ0 */
-       {5, 21, 2, 0, 3}, /* PCI_REQ1 */
-       {5, 22, 2, 0, 3}, /* PCI_GNT2 */
-       {5, 23, 3, 0, 3}, /* PCI_GNT0 */
-       {5, 24, 1, 0, 3}, /* PCI_GNT1 */
-       {5, 25, 1, 0, 3}, /* PCI_GNT2 */
-       {5, 26, 0, 0, 0}, /* PCI_CLK0 */
-       {5, 27, 0, 0, 0}, /* PCI_CLK1 */
-       {5, 28, 0, 0, 0}, /* PCI_CLK2 */
-       {5, 29, 0, 0, 3}, /* PCI_SYNC_OUT */
-       {6,  0, 3, 0, 3}, /* PCI_AD0 */
-       {6,  1, 3, 0, 3}, /* PCI_AD1 */
-       {6,  2, 3, 0, 3}, /* PCI_AD2 */
-       {6,  3, 3, 0, 3}, /* PCI_AD3 */
-       {6,  4, 3, 0, 3}, /* PCI_AD4 */
-       {6,  5, 3, 0, 3}, /* PCI_AD5 */
-       {6,  6, 3, 0, 3}, /* PCI_AD6 */
-       {6,  7, 3, 0, 3}, /* PCI_AD7 */
-       {6,  8, 3, 0, 3}, /* PCI_AD8 */
-       {6,  9, 3, 0, 3}, /* PCI_AD9 */
-       {6, 10, 3, 0, 3}, /* PCI_AD10 */
-       {6, 11, 3, 0, 3}, /* PCI_AD11 */
-       {6, 12, 3, 0, 3}, /* PCI_AD12 */
-       {6, 13, 3, 0, 3}, /* PCI_AD13 */
-       {6, 14, 3, 0, 3}, /* PCI_AD14 */
-       {6, 15, 3, 0, 3}, /* PCI_AD15 */
-       {6, 16, 3, 0, 3}, /* PCI_AD16 */
-       {6, 17, 3, 0, 3}, /* PCI_AD17 */
-       {6, 18, 3, 0, 3}, /* PCI_AD18 */
-       {6, 19, 3, 0, 3}, /* PCI_AD19 */
-       {6, 20, 3, 0, 3}, /* PCI_AD20 */
-       {6, 21, 3, 0, 3}, /* PCI_AD21 */
-       {6, 22, 3, 0, 3}, /* PCI_AD22 */
-       {6, 23, 3, 0, 3}, /* PCI_AD23 */
-       {6, 24, 3, 0, 3}, /* PCI_AD24 */
-       {6, 25, 3, 0, 3}, /* PCI_AD25 */
-       {6, 26, 3, 0, 3}, /* PCI_AD26 */
-       {6, 27, 3, 0, 3}, /* PCI_AD27 */
-       {6, 28, 3, 0, 3}, /* PCI_AD28 */
-       {6, 29, 3, 0, 3}, /* PCI_AD29 */
-       {6, 30, 3, 0, 3}, /* PCI_AD30 */
-       {6, 31, 3, 0, 3}, /* PCI_AD31 */
-
-       /* NAND */
-       {4, 18, 2, 0, 0}, /* NAND_RYnBY */
-
-       /* DUART - UART2 */
-       {5,  0, 1, 0, 2}, /* UART2_SOUT */
-       {5,  2, 1, 0, 1}, /* UART2_RTS */
-       {5,  3, 2, 0, 2}, /* UART2_SIN */
-       {5,  1, 2, 0, 3}, /* UART2_CTS */
-
-       /* UCC5 - UART3 */
-       {3,  0, 1, 0, 1}, /* UART3_TX */
-       {3,  4, 1, 0, 1}, /* UART3_RTS */
-       {3,  6, 2, 0, 1}, /* UART3_RX */
-       {3, 12, 2, 0, 0}, /* UART3_CTS */
-       {3, 13, 2, 0, 0}, /* UCC5_CD */
-
-       /* UCC6 - UART4 */
-       {3, 14, 1, 0, 1}, /* UART4_TX */
-       {3, 18, 1, 0, 1}, /* UART4_RTS */
-       {3, 20, 2, 0, 1}, /* UART4_RX */
-       {3, 26, 2, 0, 0}, /* UART4_CTS */
-       {3, 27, 2, 0, 0}, /* UCC6_CD */
-
-       /* Fujitsu MB86277 (MINT) graphics controller */
-       {0, 30, 1, 0, 0}, /* nSRESET_GRAPHICS */
-       {1,  5, 1, 0, 0}, /* nXRST_GRAPHICS */
-       {1,  7, 1, 0, 0}, /* LVDS_BKLT_CTR */
-       {2, 16, 1, 0, 0}, /* LVDS_BKLT_EN */
-
-       /* AD7843 ADC/Touchscreen controller */
-       {4, 14, 1, 0, 0}, /* SPI_nCS0 */
-       {4, 28, 3, 0, 3}, /* SPI_MOSI */
-       {4, 29, 3, 0, 3}, /* SPI_MISO */
-       {4, 30, 3, 0, 3}, /* SPI_CLK */
-
-       /* Freescale QUICC Engine USB Host Controller (FHCI) */
-       {1,  2, 1, 0, 3}, /* USBOE */
-       {1,  3, 1, 0, 3}, /* USBTP */
-       {1,  8, 1, 0, 1}, /* USBTN */
-       {1,  9, 2, 1, 3}, /* USBRP */
-       {1, 10, 2, 0, 3}, /* USBRXD */
-       {1, 11, 2, 1, 3}, /* USBRN */
-       {2, 20, 2, 0, 1}, /* CLK21 */
-       {4, 20, 1, 0, 0}, /* SPEED */
-       {4, 21, 1, 0, 0}, /* SUSPND */
-
-       /* END of table */
-       {0,  0, 0, 0, QE_IOP_TAB_END},
-};
-
-int board_early_init_r(void)
-{
-       void *reg = (void *)(CONFIG_SYS_IMMR + 0x14a8);
-       u32 val;
-
-       /*
-        * Because of errata in the UCCs, we have to write to the reserved
-        * registers to slow the clocks down.
-        */
-       val = in_be32(reg);
-       /* UCC1 */
-       val |= 0x00003000;
-       /* UCC2 */
-       val |= 0x0c000000;
-       out_be32(reg, val);
-
-       return 0;
-}
-
-int fixed_sdram(void)
-{
-       volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR;
-       u32 msize = 0;
-       u32 ddr_size;
-       u32 ddr_size_log2;
-
-       msize = CONFIG_SYS_DDR_SIZE;
-       for (ddr_size = msize << 20, ddr_size_log2 = 0;
-            (ddr_size > 1); ddr_size = ddr_size >> 1, ddr_size_log2++) {
-               if (ddr_size & 1)
-                       return -1;
-       }
-
-       im->sysconf.ddrlaw[0].ar =
-           LAWAR_EN | ((ddr_size_log2 - 1) & LAWAR_SIZE);
-
-       im->ddr.csbnds[0].csbnds = CONFIG_SYS_DDR_CS0_BNDS;
-       im->ddr.cs_config[0] = CONFIG_SYS_DDR_CS0_CONFIG;
-       im->ddr.timing_cfg_0 = CONFIG_SYS_DDR_TIMING_0;
-       im->ddr.timing_cfg_1 = CONFIG_SYS_DDR_TIMING_1;
-       im->ddr.timing_cfg_2 = CONFIG_SYS_DDR_TIMING_2;
-       im->ddr.timing_cfg_3 = CONFIG_SYS_DDR_TIMING_3;
-       im->ddr.sdram_cfg = CONFIG_SYS_DDR_SDRAM_CFG;
-       im->ddr.sdram_cfg2 = CONFIG_SYS_DDR_SDRAM_CFG2;
-       im->ddr.sdram_mode = CONFIG_SYS_DDR_MODE;
-       im->ddr.sdram_mode2 = CONFIG_SYS_DDR_MODE2;
-       im->ddr.sdram_interval = CONFIG_SYS_DDR_INTERVAL;
-       im->ddr.sdram_clk_cntl = CONFIG_SYS_DDR_CLK_CNTL;
-       udelay(200);
-       im->ddr.sdram_cfg |= SDRAM_CFG_MEM_EN;
-
-       return msize;
-}
-
-phys_size_t initdram(int board_type)
-{
-#if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER)
-       extern void ddr_enable_ecc(unsigned int dram_size);
-#endif
-       volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR;
-       u32 msize = 0;
-
-       if ((im->sysconf.immrbar & IMMRBAR_BASE_ADDR) != (u32)im)
-               return -1;
-
-       /* DDR SDRAM - Main SODIMM */
-       im->sysconf.ddrlaw[0].bar = CONFIG_SYS_DDR_BASE & LAWBAR_BAR;
-       msize = fixed_sdram();
-
-#if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER)
-       /*
-        * Initialize DDR ECC byte
-        */
-       ddr_enable_ecc(msize * 1024 * 1024);
-#endif
-
-       /* return total bus SDRAM size(bytes)  -- DDR */
-       return (msize * 1024 * 1024);
-}
-
-int checkboard(void)
-{
-       puts("Board: Freescale/Logic MPC8360ERDK\n");
-       return 0;
-}
-
-static struct pci_region pci_regions[] = {
-       {
-               .bus_start = CONFIG_SYS_PCI1_MEM_BASE,
-               .phys_start = CONFIG_SYS_PCI1_MEM_PHYS,
-               .size = CONFIG_SYS_PCI1_MEM_SIZE,
-               .flags = PCI_REGION_MEM | PCI_REGION_PREFETCH,
-       },
-       {
-               .bus_start = CONFIG_SYS_PCI1_MMIO_BASE,
-               .phys_start = CONFIG_SYS_PCI1_MMIO_PHYS,
-               .size = CONFIG_SYS_PCI1_MMIO_SIZE,
-               .flags = PCI_REGION_MEM,
-       },
-       {
-               .bus_start = CONFIG_SYS_PCI1_IO_BASE,
-               .phys_start = CONFIG_SYS_PCI1_IO_PHYS,
-               .size = CONFIG_SYS_PCI1_IO_SIZE,
-               .flags = PCI_REGION_IO,
-       },
-};
-
-void pci_init_board(void)
-{
-       volatile immap_t *immr = (volatile immap_t *)CONFIG_SYS_IMMR;
-       volatile clk83xx_t *clk = (volatile clk83xx_t *)&immr->clk;
-       volatile law83xx_t *pci_law = immr->sysconf.pcilaw;
-       struct pci_region *reg[] = { pci_regions, };
-
-#if defined(CONFIG_PCI_33M)
-       clk->occr = OCCR_PCICOE0 | OCCR_PCICOE1 | OCCR_PCICOE2 |
-                   OCCR_PCICD0 | OCCR_PCICD1 | OCCR_PCICD2 | OCCR_PCICR;
-       printf("PCI clock is 33MHz\n");
-#else
-       clk->occr = OCCR_PCICOE0 | OCCR_PCICOE1 | OCCR_PCICOE2;
-       printf("PCI clock is 66MHz\n");
-#endif
-
-       udelay(2000);
-
-       /* Configure PCI Local Access Windows */
-       pci_law[0].bar = CONFIG_SYS_PCI1_MEM_PHYS & LAWBAR_BAR;
-       pci_law[0].ar = LBLAWAR_EN | LBLAWAR_512MB;
-
-       pci_law[1].bar = CONFIG_SYS_PCI1_IO_PHYS & LAWBAR_BAR;
-       pci_law[1].ar = LBLAWAR_EN | LBLAWAR_1MB;
-
-       mpc83xx_pci_init(1, reg);
-}
-
-#if defined(CONFIG_OF_BOARD_SETUP)
-int ft_board_setup(void *blob, bd_t *bd)
-{
-       ft_cpu_setup(blob, bd);
-       ft_pci_setup(blob, bd);
-
-       return 0;
-}
-#endif
diff --git a/board/freescale/mpc8360erdk/nand.c b/board/freescale/mpc8360erdk/nand.c
deleted file mode 100644 (file)
index 237c0c4..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * MPC8360E-RDK support for the NAND on FSL UPM
- *
- * Copyright (C) 2007 MontaVista Software, Inc.
- *                    Anton Vorontsov <avorontsov@ru.mvista.com>
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#include <config.h>
-#include <common.h>
-#include <asm/io.h>
-#include <asm/immap_83xx.h>
-#include <linux/mtd/mtd.h>
-#include <linux/mtd/fsl_upm.h>
-#include <nand.h>
-
-static struct immap *im = (struct immap *)CONFIG_SYS_IMMR;
-
-static const u32 upm_array[] = {
-       0x0ff03c30, 0x0ff03c30, 0x0ff03c34, 0x0ff33c30, /* Words  0 to  3 */
-       0xfff33c31, 0xfffffc30, 0xfffffc30, 0xfffffc30, /* Words  4 to  7 */
-       0x0faf3c30, 0x0faf3c30, 0x0faf3c30, 0x0fff3c34, /* Words  8 to 11 */
-       0xffff3c31, 0xfffffc30, 0xfffffc30, 0xfffffc30, /* Words 12 to 15 */
-       0x0fa3fc30, 0x0fa3fc30, 0x0fa3fc30, 0x0ff3fc34, /* Words 16 to 19 */
-       0xfff3fc31, 0xfffffc30, 0xfffffc30, 0xfffffc30, /* Words 20 to 23 */
-       0x0ff33c30, 0x0fa33c30, 0x0fa33c34, 0x0ff33c30, /* Words 24 to 27 */
-       0xfff33c31, 0xfff0fc30, 0xfff0fc30, 0xfff0fc30, /* Words 28 to 31 */
-       0xfff3fc30, 0xfff3fc30, 0xfff6fc30, 0xfffcfc30, /* Words 32 to 35 */
-       0xfffcfc30, 0xfffcfc30, 0xfffcfc30, 0xfffcfc30, /* Words 36 to 39 */
-       0xfffcfc30, 0xfffcfc30, 0xfffcfc30, 0xfffcfc30, /* Words 40 to 43 */
-       0xfffdfc30, 0xfffffc30, 0xfffffc30, 0xfffffc31, /* Words 44 to 47 */
-       0xfffffc30, 0xfffffc00, 0xfffffc00, 0xfffffc00, /* Words 48 to 51 */
-       0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00, /* Words 52 to 55 */
-       0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc01, /* Words 56 to 59 */
-       0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc01, /* Words 60 to 63 */
-};
-
-static void upm_setup(struct fsl_upm *upm)
-{
-       int i;
-
-       /* write upm array */
-       out_be32(upm->mxmr, MxMR_OP_WARR);
-
-       for (i = 0; i < 64; i++) {
-               out_be32(upm->mdr, upm_array[i]);
-               out_8(upm->io_addr, 0x0);
-       }
-
-       /* normal operation */
-       out_be32(upm->mxmr, MxMR_OP_NORM);
-       while (in_be32(upm->mxmr) != MxMR_OP_NORM)
-               eieio();
-}
-
-static int dev_ready(int chip_nr)
-{
-       if (in_be32(&im->qepio.ioport[4].pdat) & 0x00002000) {
-               debug("nand ready\n");
-               return 1;
-       }
-
-       debug("nand busy\n");
-       return 0;
-}
-
-static struct fsl_upm_nand fun = {
-       .upm = {
-               .io_addr = (void *)CONFIG_SYS_NAND_BASE,
-       },
-       .width = 8,
-       .upm_cmd_offset = 8,
-       .upm_addr_offset = 16,
-       .dev_ready = dev_ready,
-       .wait_flags = FSL_UPM_WAIT_RUN_PATTERN,
-       .chip_delay = 50,
-};
-
-int board_nand_init(struct nand_chip *nand)
-{
-       fun.upm.mxmr = &im->im_lbc.mamr;
-       fun.upm.mdr = &im->im_lbc.mdr;
-       fun.upm.mar = &im->im_lbc.mar;
-
-       upm_setup(&fun.upm);
-
-       return fsl_upm_nand_init(nand, &fun);
-}
index 8592a2c3c1852d2ce551fde351d18e2085083fca..81b4eed5edea8f535f4ea614254348f58a617540 100644 (file)
@@ -1,6 +1,6 @@
 MPC837XERDB BOARD
-#M:    Joe D'Abbraccio <ljd015@freescale.com>
-S:     Orphan (since 2014-06)
+M:     Sinan Akman <sinan@writeme.com>
+S:     Maintained
 F:     board/freescale/mpc837xerdb/
 F:     include/configs/MPC837XERDB.h
 F:     configs/MPC837XERDB_defconfig
diff --git a/board/freescale/p1_p2_rdb/Kconfig b/board/freescale/p1_p2_rdb/Kconfig
deleted file mode 100644 (file)
index d7ad35d..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-if TARGET_P1_P2_RDB
-
-config SYS_BOARD
-       default "p1_p2_rdb"
-
-config SYS_VENDOR
-       default "freescale"
-
-config SYS_CONFIG_NAME
-       default "P1_P2_RDB"
-
-endif
diff --git a/board/freescale/p1_p2_rdb/MAINTAINERS b/board/freescale/p1_p2_rdb/MAINTAINERS
deleted file mode 100644 (file)
index aabf587..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-P1_P2_RDB BOARD
-#M:    -
-S:     Maintained
-F:     board/freescale/p1_p2_rdb/
-F:     include/configs/P1_P2_RDB.h
-F:     configs/P1011RDB_defconfig
-F:     configs/P1011RDB_36BIT_defconfig
-F:     configs/P1011RDB_36BIT_SDCARD_defconfig
-F:     configs/P1011RDB_36BIT_SPIFLASH_defconfig
-F:     configs/P1011RDB_NAND_defconfig
-F:     configs/P1011RDB_SDCARD_defconfig
-F:     configs/P1011RDB_SPIFLASH_defconfig
-F:     configs/P1020RDB_defconfig
-F:     configs/P1020RDB_36BIT_defconfig
-F:     configs/P1020RDB_36BIT_SDCARD_defconfig
-F:     configs/P1020RDB_36BIT_SPIFLASH_defconfig
-F:     configs/P1020RDB_NAND_defconfig
-F:     configs/P1020RDB_SDCARD_defconfig
-F:     configs/P1020RDB_SPIFLASH_defconfig
-F:     configs/P2010RDB_defconfig
-F:     configs/P2010RDB_36BIT_defconfig
-F:     configs/P2010RDB_36BIT_SDCARD_defconfig
-F:     configs/P2010RDB_36BIT_SPIFLASH_defconfig
-F:     configs/P2010RDB_NAND_defconfig
-F:     configs/P2010RDB_SDCARD_defconfig
-F:     configs/P2010RDB_SPIFLASH_defconfig
-F:     configs/P2020RDB_36BIT_defconfig
-F:     configs/P2020RDB_36BIT_SDCARD_defconfig
-F:     configs/P2020RDB_36BIT_SPIFLASH_defconfig
-F:     configs/P2020RDB_NAND_defconfig
-F:     configs/P2020RDB_SDCARD_defconfig
-F:     configs/P2020RDB_SPIFLASH_defconfig
-
-P2020RDB BOARD
-M:     Poonam Aggrwal <poonam.aggrwal@freescale.com>
-S:     Maintained
-F:     configs/P2020RDB_defconfig
diff --git a/board/freescale/p1_p2_rdb/Makefile b/board/freescale/p1_p2_rdb/Makefile
deleted file mode 100644 (file)
index a97bf45..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-#
-# Copyright 2009 Freescale Semiconductor, Inc.
-#
-# SPDX-License-Identifier:     GPL-2.0+
-#
-
-MINIMAL=
-
-ifdef CONFIG_SPL_BUILD
-ifdef CONFIG_SPL_INIT_MINIMAL
-MINIMAL=y
-endif
-endif
-
-ifdef MINIMAL
-
-obj-y  += spl_minimal.o tlb.o law.o
-
-else
-ifdef CONFIG_SPL_BUILD
-obj-y += spl.o
-else
-obj-y  += p1_p2_rdb.o
-obj-$(CONFIG_PCI)  += pci.o
-endif
-obj-y  += ddr.o
-obj-y  += law.o
-obj-y  += tlb.o
-
-endif
diff --git a/board/freescale/p1_p2_rdb/README b/board/freescale/p1_p2_rdb/README
deleted file mode 100644 (file)
index cd66e58..0000000
+++ /dev/null
@@ -1,145 +0,0 @@
-Overview
---------
-P2020RDB is a Low End Dual core platform supporting the P2020 processor
-of QorIQ series. P2020 is an e500 based dual core SOC.
-
-Building U-boot
------------
-To build the u-boot for P2020RDB:
-       make P2020RDB_config
-       make
-
-NOR Flash Banks
------------
-RDB board for P2020 has two flash banks. They are both present on boot.
-
-Booting by default is always from the boot bank at 0xef00_0000.
-
-Memory Map
-----------
-0xef00_0000 - 0xef7f_ffff      Alternate bank          8MB
-0xe800_0000 - 0xefff_ffff      Boot bank               8MB
-
-0xef74_0000 - 0xef7f_ffff      Alternate u-boot address        768KB
-0xeff4_0000 - 0xefff_ffff      Boot u-boot address             768KB
-
-Switch settings to boot from the NOR flash banks
-------------------------------------------------
-SW4[8]=0 default NOR Flash bank
-SW4[8]=1 Alternate NOR Flash bank
-
-Flashing Images
----------------
-To place a new u-boot image in the alternate flash bank and then boot
-with that new image temporarily, use this:
-       tftp 1000000 u-boot.bin
-       erase ef740000 ef7fffff
-       cp.b 1000000 ef740000 c0000
-
-Now to boot from the alternate bank change the SW4[8] from 0 to 1.
-
-To program the image in the boot flash bank:
-       tftp 1000000 u-boot.bin
-       protect off all
-       erase eff40000 ffffffff
-       cp.b 1000000 eff40000 c0000
-
-Using the Device Tree Source File
----------------------------------
-To create the DTB (Device Tree Binary) image file,
-use a command similar to this:
-
-       dtc -b 0 -f -I dts -O dtb p2020rdb.dts > p2020rdb.dtb
-
-Likely, that .dts file will come from here;
-
-       linux-2.6/arch/powerpc/boot/dts/p2020rdb.dts
-
-Booting Linux
--------------
-Place a linux uImage in the TFTP disk area.
-
-       tftp 1000000 uImage.p2020rdb
-       tftp 2000000 rootfs.ext2.gz.uboot
-       tftp c00000 p2020rdb.dtb
-       bootm 1000000 2000000 c00000
-
-Implementing AMP(Asymmetric MultiProcessing)
----------------------------------------------
-1. Build kernel image for core0:
-
-       a. $ make 85xx/p1_p2_rdb_defconfig
-
-       b. $ make menuconfig
-          - un-select "Processor support"->
-               "Symetric multi-processing support"
-
-       c. $ make uImage
-
-       d. $ cp arch/powerpc/boot/uImage /tftpboot/uImage.core0
-
-2. Build kernel image for core1:
-
-       a. $ make 85xx/p1_p2_rdb_defconfig
-
-       b. $ make menuconfig
-          - Un-select "Processor support"->
-               "Symetric multi-processing support"
-          - Select "Advanced setup" ->
-               "Prompt for advanced kernel configuration options"
-               - Select
-                       "Set physical address where the kernel is loaded"
-                       and set it to 0x20000000, assuming core1 will
-                       start from 512MB.
-               - Select "Set custom page offset address"
-               - Select "Set custom kernel base address"
-               - Select "Set maximum low memory"
-          - "Exit" and save the selection.
-
-       c. $ make uImage
-
-       d. $ cp arch/powerpc/boot/uImage /tftpboot/uImage.core1
-
-3. Create dtb for core0:
-
-       $ dtc -I dts -O dtb -f -b 0
-                arch/powerpc/boot/dts/p2020rdb_camp_core0.dts >
-                /tftpboot/p2020rdb_camp_core0.dtb
-
-4. Create dtb for core1:
-
-       $ dtc -I dts -O dtb -f -b 1
-                arch/powerpc/boot/dts/p2020rdb_camp_core1.dts >
-                /tftpboot/p2020rdb_camp_core1.dtb
-
-5. Bring up two cores separately:
-
-       a. Power on the board, under u-boot prompt:
-               => setenv <serverip>
-               => setenv <ipaddr>
-               => setenv bootargs root=/dev/ram rw console=ttyS0,115200
-       b. Bring up core1's kernel first:
-               => setenv bootm_low 0x20000000
-               => setenv bootm_size 0x10000000
-               => tftp 21000000 uImage.core1
-               => tftp 22000000 ramdiskfile
-               => tftp 20c00000 p2020rdb_camp_core1.dtb
-               => interrupts off
-               => bootm start 21000000 22000000 20c00000
-               => bootm loados
-               => bootm ramdisk
-               => bootm fdt
-               => fdt boardsetup
-               => fdt chosen $initrd_start $initrd_end
-               => bootm prep
-               => cpu 1 release $bootm_low - $fdtaddr -
-       c. Bring up core0's kernel(on the same u-boot console):
-               => setenv bootm_low 0
-               => setenv bootm_size 0x20000000
-               => tftp 1000000 uImage.core0
-               => tftp 2000000 ramdiskfile
-               => tftp c00000 p2020rdb_camp_core0.dtb
-               => bootm 1000000 2000000 c00000
-
-Please note only core0 will run u-boot, core1 starts kernel directly
-after "cpu release" command is issued.
diff --git a/board/freescale/p1_p2_rdb/ddr.c b/board/freescale/p1_p2_rdb/ddr.c
deleted file mode 100644 (file)
index 98ee5f1..0000000
+++ /dev/null
@@ -1,221 +0,0 @@
-/*
- * Copyright 2009, 2011 Freescale Semiconductor, Inc.
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#include <common.h>
-#include <asm/mmu.h>
-#include <asm/immap_85xx.h>
-#include <asm/processor.h>
-#include <fsl_ddr_sdram.h>
-#include <asm/io.h>
-#include <asm/fsl_law.h>
-
-DECLARE_GLOBAL_DATA_PTR;
-
-#define CONFIG_SYS_DDR_CS0_BNDS                0x0000003F
-#define CONFIG_SYS_DDR_CS0_CONFIG      0x80014202
-#define CONFIG_SYS_DDR_CS0_CONFIG_2    0x00000000
-#define CONFIG_SYS_DDR_INIT_ADDR       0x00000000
-#define CONFIG_SYS_DDR_INIT_EXT_ADDR   0x00000000
-#define CONFIG_SYS_DDR_MODE_CONTROL    0x00000000
-#define CONFIG_SYS_DDR_ZQ_CONTROL      0x00000000
-#define CONFIG_SYS_DDR_WRLVL_CONTROL   0x00000000
-#define CONFIG_SYS_DDR_SR_CNTR         0x00000000
-#define CONFIG_SYS_DDR_RCW_1           0x00000000
-#define CONFIG_SYS_DDR_RCW_2           0x00000000
-#define CONFIG_SYS_DDR_CONTROL         0x43000000      /* Type = DDR2*/
-#define CONFIG_SYS_DDR_CONTROL_2       0x24401000
-#define CONFIG_SYS_DDR_TIMING_4                0x00000000
-#define CONFIG_SYS_DDR_TIMING_5                0x00000000
-
-#define CONFIG_SYS_DDR_TIMING_3_400    0x00010000
-#define CONFIG_SYS_DDR_TIMING_0_400    0x00260802
-#define CONFIG_SYS_DDR_TIMING_1_400    0x39355322
-#define CONFIG_SYS_DDR_TIMING_2_400    0x1f9048ca
-#define CONFIG_SYS_DDR_CLK_CTRL_400    0x02800000
-#define CONFIG_SYS_DDR_MODE_1_400      0x00480432
-#define CONFIG_SYS_DDR_MODE_2_400      0x00000000
-#define CONFIG_SYS_DDR_INTERVAL_400    0x06180100
-
-#define CONFIG_SYS_DDR_TIMING_3_533    0x00020000
-#define CONFIG_SYS_DDR_TIMING_0_533    0x00260802
-#define CONFIG_SYS_DDR_TIMING_1_533    0x4c47c432
-#define CONFIG_SYS_DDR_TIMING_2_533    0x0f9848ce
-#define CONFIG_SYS_DDR_CLK_CTRL_533    0x02800000
-#define CONFIG_SYS_DDR_MODE_1_533      0x00040642
-#define CONFIG_SYS_DDR_MODE_2_533      0x00000000
-#define CONFIG_SYS_DDR_INTERVAL_533    0x08200100
-
-#define CONFIG_SYS_DDR_TIMING_3_667    0x00030000
-#define CONFIG_SYS_DDR_TIMING_0_667    0x55770802
-#define CONFIG_SYS_DDR_TIMING_1_667    0x5f599543
-#define CONFIG_SYS_DDR_TIMING_2_667    0x0fa074d1
-#define CONFIG_SYS_DDR_CLK_CTRL_667    0x03000000
-#define CONFIG_SYS_DDR_MODE_1_667      0x00040852
-#define CONFIG_SYS_DDR_MODE_2_667      0x00000000
-#define CONFIG_SYS_DDR_INTERVAL_667    0x0a280100
-
-#define CONFIG_SYS_DDR_TIMING_3_800    0x00040000
-#define CONFIG_SYS_DDR_TIMING_0_800    0x00770802
-#define CONFIG_SYS_DDR_TIMING_1_800    0x6f6b6543
-#define CONFIG_SYS_DDR_TIMING_2_800    0x0fa074d1
-#define CONFIG_SYS_DDR_CLK_CTRL_800    0x02800000
-#define CONFIG_SYS_DDR_MODE_1_800      0x00040852
-#define CONFIG_SYS_DDR_MODE_2_800      0x00000000
-#define CONFIG_SYS_DDR_INTERVAL_800    0x0c300100
-
-fsl_ddr_cfg_regs_t ddr_cfg_regs_400 = {
-       .cs[0].bnds = CONFIG_SYS_DDR_CS0_BNDS,
-       .cs[0].config = CONFIG_SYS_DDR_CS0_CONFIG,
-       .cs[0].config_2 = CONFIG_SYS_DDR_CS0_CONFIG_2,
-       .timing_cfg_3 = CONFIG_SYS_DDR_TIMING_3_400,
-       .timing_cfg_0 = CONFIG_SYS_DDR_TIMING_0_400,
-       .timing_cfg_1 = CONFIG_SYS_DDR_TIMING_1_400,
-       .timing_cfg_2 = CONFIG_SYS_DDR_TIMING_2_400,
-       .ddr_sdram_cfg = CONFIG_SYS_DDR_CONTROL,
-       .ddr_sdram_cfg_2 = CONFIG_SYS_DDR_CONTROL_2,
-       .ddr_sdram_mode = CONFIG_SYS_DDR_MODE_1_400,
-       .ddr_sdram_mode_2 = CONFIG_SYS_DDR_MODE_2_400,
-       .ddr_sdram_md_cntl = CONFIG_SYS_DDR_MODE_CONTROL,
-       .ddr_sdram_interval = CONFIG_SYS_DDR_INTERVAL_400,
-       .ddr_data_init = CONFIG_MEM_INIT_VALUE,
-       .ddr_sdram_clk_cntl = CONFIG_SYS_DDR_CLK_CTRL_400,
-       .ddr_init_addr = CONFIG_SYS_DDR_INIT_ADDR,
-       .ddr_init_ext_addr = CONFIG_SYS_DDR_INIT_EXT_ADDR,
-       .timing_cfg_4 = CONFIG_SYS_DDR_TIMING_4,
-       .timing_cfg_5 = CONFIG_SYS_DDR_TIMING_5,
-       .ddr_zq_cntl = CONFIG_SYS_DDR_ZQ_CONTROL,
-       .ddr_wrlvl_cntl = CONFIG_SYS_DDR_WRLVL_CONTROL,
-       .ddr_sr_cntr = CONFIG_SYS_DDR_SR_CNTR,
-       .ddr_sdram_rcw_1 = CONFIG_SYS_DDR_RCW_1,
-       .ddr_sdram_rcw_2 = CONFIG_SYS_DDR_RCW_2
-};
-
-fsl_ddr_cfg_regs_t ddr_cfg_regs_533 = {
-       .cs[0].bnds = CONFIG_SYS_DDR_CS0_BNDS,
-       .cs[0].config = CONFIG_SYS_DDR_CS0_CONFIG,
-       .cs[0].config_2 = CONFIG_SYS_DDR_CS0_CONFIG_2,
-       .timing_cfg_3 = CONFIG_SYS_DDR_TIMING_3_533,
-       .timing_cfg_0 = CONFIG_SYS_DDR_TIMING_0_533,
-       .timing_cfg_1 = CONFIG_SYS_DDR_TIMING_1_533,
-       .timing_cfg_2 = CONFIG_SYS_DDR_TIMING_2_533,
-       .ddr_sdram_cfg = CONFIG_SYS_DDR_CONTROL,
-       .ddr_sdram_cfg_2 = CONFIG_SYS_DDR_CONTROL_2,
-       .ddr_sdram_mode = CONFIG_SYS_DDR_MODE_1_533,
-       .ddr_sdram_mode_2 = CONFIG_SYS_DDR_MODE_2_533,
-       .ddr_sdram_md_cntl = CONFIG_SYS_DDR_MODE_CONTROL,
-       .ddr_sdram_interval = CONFIG_SYS_DDR_INTERVAL_533,
-       .ddr_data_init = CONFIG_MEM_INIT_VALUE,
-       .ddr_sdram_clk_cntl = CONFIG_SYS_DDR_CLK_CTRL_533,
-       .ddr_init_addr = CONFIG_SYS_DDR_INIT_ADDR,
-       .ddr_init_ext_addr = CONFIG_SYS_DDR_INIT_EXT_ADDR,
-       .timing_cfg_4 = CONFIG_SYS_DDR_TIMING_4,
-       .timing_cfg_5 = CONFIG_SYS_DDR_TIMING_5,
-       .ddr_zq_cntl = CONFIG_SYS_DDR_ZQ_CONTROL,
-       .ddr_wrlvl_cntl = CONFIG_SYS_DDR_WRLVL_CONTROL,
-       .ddr_sr_cntr = CONFIG_SYS_DDR_SR_CNTR,
-       .ddr_sdram_rcw_1 = CONFIG_SYS_DDR_RCW_1,
-       .ddr_sdram_rcw_2 = CONFIG_SYS_DDR_RCW_2
-};
-
-fsl_ddr_cfg_regs_t ddr_cfg_regs_667 = {
-       .cs[0].bnds = CONFIG_SYS_DDR_CS0_BNDS,
-       .cs[0].config = CONFIG_SYS_DDR_CS0_CONFIG,
-       .cs[0].config_2 = CONFIG_SYS_DDR_CS0_CONFIG_2,
-       .timing_cfg_3 = CONFIG_SYS_DDR_TIMING_3_667,
-       .timing_cfg_0 = CONFIG_SYS_DDR_TIMING_0_667,
-       .timing_cfg_1 = CONFIG_SYS_DDR_TIMING_1_667,
-       .timing_cfg_2 = CONFIG_SYS_DDR_TIMING_2_667,
-       .ddr_sdram_cfg = CONFIG_SYS_DDR_CONTROL,
-       .ddr_sdram_cfg_2 = CONFIG_SYS_DDR_CONTROL_2,
-       .ddr_sdram_mode = CONFIG_SYS_DDR_MODE_1_667,
-       .ddr_sdram_mode_2 = CONFIG_SYS_DDR_MODE_2_667,
-       .ddr_sdram_md_cntl = CONFIG_SYS_DDR_MODE_CONTROL,
-       .ddr_sdram_interval = CONFIG_SYS_DDR_INTERVAL_667,
-       .ddr_data_init = CONFIG_MEM_INIT_VALUE,
-       .ddr_sdram_clk_cntl = CONFIG_SYS_DDR_CLK_CTRL_667,
-       .ddr_init_addr = CONFIG_SYS_DDR_INIT_ADDR,
-       .ddr_init_ext_addr = CONFIG_SYS_DDR_INIT_EXT_ADDR,
-       .timing_cfg_4 = CONFIG_SYS_DDR_TIMING_4,
-       .timing_cfg_5 = CONFIG_SYS_DDR_TIMING_5,
-       .ddr_zq_cntl = CONFIG_SYS_DDR_ZQ_CONTROL,
-       .ddr_wrlvl_cntl = CONFIG_SYS_DDR_WRLVL_CONTROL,
-       .ddr_sr_cntr = CONFIG_SYS_DDR_SR_CNTR,
-       .ddr_sdram_rcw_1 = CONFIG_SYS_DDR_RCW_1,
-       .ddr_sdram_rcw_2 = CONFIG_SYS_DDR_RCW_2
-};
-
-fsl_ddr_cfg_regs_t ddr_cfg_regs_800 = {
-       .cs[0].bnds = CONFIG_SYS_DDR_CS0_BNDS,
-       .cs[0].config = CONFIG_SYS_DDR_CS0_CONFIG,
-       .cs[0].config_2 = CONFIG_SYS_DDR_CS0_CONFIG_2,
-       .timing_cfg_3 = CONFIG_SYS_DDR_TIMING_3_800,
-       .timing_cfg_0 = CONFIG_SYS_DDR_TIMING_0_800,
-       .timing_cfg_1 = CONFIG_SYS_DDR_TIMING_1_800,
-       .timing_cfg_2 = CONFIG_SYS_DDR_TIMING_2_800,
-       .ddr_sdram_cfg = CONFIG_SYS_DDR_CONTROL,
-       .ddr_sdram_cfg_2 = CONFIG_SYS_DDR_CONTROL_2,
-       .ddr_sdram_mode = CONFIG_SYS_DDR_MODE_1_800,
-       .ddr_sdram_mode_2 = CONFIG_SYS_DDR_MODE_2_800,
-       .ddr_sdram_md_cntl = CONFIG_SYS_DDR_MODE_CONTROL,
-       .ddr_sdram_interval = CONFIG_SYS_DDR_INTERVAL_800,
-       .ddr_data_init = CONFIG_MEM_INIT_VALUE,
-       .ddr_sdram_clk_cntl = CONFIG_SYS_DDR_CLK_CTRL_800,
-       .ddr_init_addr = CONFIG_SYS_DDR_INIT_ADDR,
-       .ddr_init_ext_addr = CONFIG_SYS_DDR_INIT_EXT_ADDR,
-       .timing_cfg_4 = CONFIG_SYS_DDR_TIMING_4,
-       .timing_cfg_5 = CONFIG_SYS_DDR_TIMING_5,
-       .ddr_zq_cntl = CONFIG_SYS_DDR_ZQ_CONTROL,
-       .ddr_wrlvl_cntl = CONFIG_SYS_DDR_WRLVL_CONTROL,
-       .ddr_sr_cntr = CONFIG_SYS_DDR_SR_CNTR,
-       .ddr_sdram_rcw_1 = CONFIG_SYS_DDR_RCW_1,
-       .ddr_sdram_rcw_2 = CONFIG_SYS_DDR_RCW_2
-};
-
-/*
- * Fixed sdram init -- doesn't use serial presence detect.
- */
-
-phys_size_t fixed_sdram (void)
-{
-       fsl_ddr_cfg_regs_t ddr_cfg_regs;
-       size_t ddr_size;
-       struct cpu_type *cpu;
-       ulong ddr_freq, ddr_freq_mhz;
-
-       cpu = gd->arch.cpu;
-
-       ddr_size = CONFIG_SYS_SDRAM_SIZE * 1024 * 1024;
-
-#if defined(CONFIG_SYS_RAMBOOT)
-       return ddr_size;
-#endif
-       ddr_freq = get_ddr_freq(0);
-       ddr_freq_mhz = ddr_freq / 1000000;
-
-       printf("Configuring DDR for %ld T/s data rate\n", ddr_freq);
-
-       if(ddr_freq_mhz <= 400)
-               memcpy(&ddr_cfg_regs, &ddr_cfg_regs_400, sizeof(ddr_cfg_regs));
-       else if(ddr_freq_mhz <= 533)
-               memcpy(&ddr_cfg_regs, &ddr_cfg_regs_533, sizeof(ddr_cfg_regs));
-       else if(ddr_freq_mhz <= 667)
-               memcpy(&ddr_cfg_regs, &ddr_cfg_regs_667, sizeof(ddr_cfg_regs));
-       else if(ddr_freq_mhz <= 800)
-               memcpy(&ddr_cfg_regs, &ddr_cfg_regs_800, sizeof(ddr_cfg_regs));
-       else
-               panic("Unsupported DDR data rate %ld T/s\n", ddr_freq);
-
-       /* P1020 and it's derivatives support max 32bit DDR width */
-       if (cpu->soc_ver == SVR_P1020 || cpu->soc_ver == SVR_P1011) {
-               ddr_cfg_regs.ddr_sdram_cfg |= SDRAM_CFG_32_BE;
-               ddr_cfg_regs.cs[0].bnds = 0x0000001F;
-       }
-
-       fsl_ddr_set_memctl_regs(&ddr_cfg_regs, 0, 0);
-
-       set_ddr_laws(0, ddr_size, LAW_TRGT_IF_DDR_1);
-       return ddr_size;
-}
diff --git a/board/freescale/p1_p2_rdb/law.c b/board/freescale/p1_p2_rdb/law.c
deleted file mode 100644 (file)
index b60a27f..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * Copyright 2009-2010 Freescale Semiconductor, Inc.
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#include <common.h>
-#include <asm/fsl_law.h>
-#include <asm/mmu.h>
-
-struct law_entry law_table[] = {
-       SET_LAW(CONFIG_SYS_FLASH_BASE_PHYS, LAW_SIZE_16M, LAW_TRGT_IF_LBC),
-       SET_LAW(CONFIG_SYS_VSC7385_BASE_PHYS, LAW_SIZE_128K, LAW_TRGT_IF_LBC),
-       SET_LAW(CONFIG_SYS_NAND_BASE_PHYS, LAW_SIZE_1M, LAW_TRGT_IF_LBC),
-};
-
-int num_law_entries = ARRAY_SIZE(law_table);
diff --git a/board/freescale/p1_p2_rdb/p1_p2_rdb.c b/board/freescale/p1_p2_rdb/p1_p2_rdb.c
deleted file mode 100644 (file)
index 61ed466..0000000
+++ /dev/null
@@ -1,303 +0,0 @@
-/*
- * Copyright 2009-2011 Freescale Semiconductor, Inc.
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#include <common.h>
-#include <command.h>
-#include <asm/processor.h>
-#include <asm/mmu.h>
-#include <asm/cache.h>
-#include <asm/immap_85xx.h>
-#include <asm/fsl_serdes.h>
-#include <asm/io.h>
-#include <miiphy.h>
-#include <libfdt.h>
-#include <fdt_support.h>
-#include <fsl_mdio.h>
-#include <tsec.h>
-#include <vsc7385.h>
-#include <netdev.h>
-#include <rtc.h>
-#include <i2c.h>
-#include <hwconfig.h>
-
-DECLARE_GLOBAL_DATA_PTR;
-
-#define VSC7385_RST_SET                0x00080000
-#define SLIC_RST_SET           0x00040000
-#define SGMII_PHY_RST_SET      0x00020000
-#define PCIE_RST_SET           0x00010000
-#define RGMII_PHY_RST_SET      0x02000000
-
-#define USB_RST_CLR            0x04000000
-#define USB2_PORT_OUT_EN        0x01000000
-
-#define GPIO_DIR               0x060f0000
-
-#define BOARD_PERI_RST_SET     VSC7385_RST_SET | SLIC_RST_SET | \
-                               SGMII_PHY_RST_SET | PCIE_RST_SET | \
-                               RGMII_PHY_RST_SET
-
-#define SYSCLK_MASK    0x00200000
-#define BOARDREV_MASK  0x10100000
-#define BOARDREV_C     0x00100000
-#define BOARDREV_D     0x00000000
-
-#define SYSCLK_66      66666666
-#define SYSCLK_100     100000000
-
-unsigned long get_board_sys_clk(ulong dummy)
-{
-       volatile ccsr_gpio_t *pgpio = (void *)(CONFIG_SYS_MPC85xx_GPIO_ADDR);
-       u32 val_gpdat, sysclk_gpio;
-
-       val_gpdat = in_be32(&pgpio->gpdat);
-       sysclk_gpio = val_gpdat & SYSCLK_MASK;
-
-       if(sysclk_gpio == 0)
-               return SYSCLK_66;
-       else
-               return SYSCLK_100;
-
-       return 0;
-}
-
-#ifdef CONFIG_MMC
-int board_early_init_f (void)
-{
-       volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
-
-       setbits_be32(&gur->pmuxcr,
-                       (MPC85xx_PMUXCR_SDHC_CD |
-                        MPC85xx_PMUXCR_SDHC_WP));
-       return 0;
-}
-#endif
-
-int checkboard (void)
-{
-       u32 val_gpdat, board_rev_gpio;
-       volatile ccsr_gpio_t *pgpio = (void *)(CONFIG_SYS_MPC85xx_GPIO_ADDR);
-       char board_rev = 0;
-       struct cpu_type *cpu;
-
-       val_gpdat = in_be32(&pgpio->gpdat);
-       board_rev_gpio = val_gpdat & BOARDREV_MASK;
-       if (board_rev_gpio == BOARDREV_C)
-               board_rev = 'C';
-       else if (board_rev_gpio == BOARDREV_D)
-               board_rev = 'D';
-       else
-               panic ("Unexpected Board REV %x detected!!\n", board_rev_gpio);
-
-       cpu = gd->arch.cpu;
-       printf ("Board: %sRDB Rev%c\n", cpu->name, board_rev);
-
-       setbits_be32(&pgpio->gpdir, GPIO_DIR);
-
-/*
- * Bringing the following peripherals out of reset via GPIOs
- * 0 = reset and 1 = out of reset
- * GPIO12 - Reset to Ethernet Switch
- * GPIO13 - Reset to SLIC/SLAC devices
- * GPIO14 - Reset to SGMII_PHY_N
- * GPIO15 - Reset to PCIe slots
- * GPIO6  - Reset to RGMII PHY
- * GPIO5  - Reset to USB3300 devices 1 = reset and 0 = out of reset
- */
-       clrsetbits_be32(&pgpio->gpdat, USB_RST_CLR, BOARD_PERI_RST_SET);
-
-       return 0;
-}
-
-int misc_init_r(void)
-{
-#if defined(CONFIG_SDCARD) || defined(CONFIG_SPIFLASH)
-       ccsr_gur_t *gur = (void *)CONFIG_SYS_MPC85xx_GUTS_ADDR;
-       ccsr_gpio_t *gpio = (void *)CONFIG_SYS_MPC85xx_GPIO_ADDR;
-
-       setbits_be32(&gpio->gpdir, USB2_PORT_OUT_EN);
-       setbits_be32(&gpio->gpdat, USB2_PORT_OUT_EN);
-       setbits_be32(&gur->pmuxcr, MPC85xx_PMUXCR_ELBC_OFF_USB2_ON);
-#endif
-       return 0;
-}
-
-int board_early_init_r(void)
-{
-       const unsigned int flashbase = CONFIG_SYS_FLASH_BASE;
-       int flash_esel = find_tlb_idx((void *)flashbase, 1);
-       volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
-       unsigned int orig_bus = i2c_get_bus_num();
-       u8 i2c_data;
-
-       i2c_set_bus_num(1);
-       if (i2c_read(CONFIG_SYS_I2C_PCA9557_ADDR, 0,
-               1, &i2c_data, sizeof(i2c_data)) == 0) {
-               if (i2c_data & 0x2)
-                       puts("NOR Flash Bank : Secondary\n");
-               else
-                       puts("NOR Flash Bank : Primary\n");
-
-               if (i2c_data & 0x1) {
-                       setbits_be32(&gur->pmuxcr, MPC85xx_PMUXCR_SD_DATA);
-                       puts("SD/MMC : 8-bit Mode\n");
-                       puts("eSPI : Disabled\n");
-               } else {
-                       puts("SD/MMC : 4-bit Mode\n");
-                       puts("eSPI : Enabled\n");
-               }
-       } else {
-               puts("Failed reading I2C Chip 0x18 on bus 1\n");
-       }
-       i2c_set_bus_num(orig_bus);
-
-       /*
-        * Remap Boot flash region to caching-inhibited
-        * so that flash can be erased properly.
-        */
-
-       /* Flush d-cache and invalidate i-cache of any FLASH data */
-       flush_dcache();
-       invalidate_icache();
-
-       if (flash_esel == -1) {
-               /* very unlikely unless something is messed up */
-               puts("Error: Could not find TLB for FLASH BASE\n");
-               flash_esel = 2; /* give our best effort to continue */
-       } else {
-               /* invalidate existing TLB entry for flash */
-               disable_tlb(flash_esel);
-       }
-
-       set_tlb(1, flashbase, CONFIG_SYS_FLASH_BASE_PHYS,
-                       MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
-                       0, flash_esel, BOOKE_PAGESZ_16M, 1);
-       rtc_reset();
-       return 0;
-}
-
-
-#ifdef CONFIG_TSEC_ENET
-int board_eth_init(bd_t *bis)
-{
-       struct fsl_pq_mdio_info mdio_info;
-       struct tsec_info_struct tsec_info[4];
-       int num = 0;
-       char *tmp;
-       unsigned int vscfw_addr;
-
-#ifdef CONFIG_TSEC1
-       SET_STD_TSEC_INFO(tsec_info[num], 1);
-       num++;
-#endif
-#ifdef CONFIG_TSEC2
-       SET_STD_TSEC_INFO(tsec_info[num], 2);
-       num++;
-#endif
-#ifdef CONFIG_TSEC3
-       SET_STD_TSEC_INFO(tsec_info[num], 3);
-       if (is_serdes_configured(SGMII_TSEC3)) {
-               puts("eTSEC3 is in sgmii mode.\n");
-               tsec_info[num].flags |= TSEC_SGMII;
-       }
-       num++;
-#endif
-       if (!num) {
-               printf("No TSECs initialized\n");
-               return 0;
-       }
-#ifdef CONFIG_VSC7385_ENET
-/* If a VSC7385 microcode image is present, then upload it. */
-       if ((tmp = getenv ("vscfw_addr")) != NULL) {
-               vscfw_addr = simple_strtoul (tmp, NULL, 16);
-               printf("uploading VSC7385 microcode from %x\n", vscfw_addr);
-               if (vsc7385_upload_firmware((void *) vscfw_addr,
-                                       CONFIG_VSC7385_IMAGE_SIZE))
-                       puts("Failure uploading VSC7385 microcode.\n");
-       } else
-               puts("No address specified for VSC7385 microcode.\n");
-#endif
-
-       mdio_info.regs = (struct tsec_mii_mng *)CONFIG_SYS_MDIO_BASE_ADDR;
-       mdio_info.name = DEFAULT_MII_NAME;
-       fsl_pq_mdio_init(bis, &mdio_info);
-
-       tsec_eth_init(bis, tsec_info, num);
-
-       return pci_eth_init(bis);
-}
-#endif
-
-#if defined(CONFIG_OF_BOARD_SETUP)
-extern void ft_pci_board_setup(void *blob);
-
-int ft_board_setup(void *blob, bd_t *bd)
-{
-       const char *soc_usb_compat = "fsl-usb2-dr";
-       int err, usb1_off, usb2_off;
-       phys_addr_t base;
-       phys_size_t size;
-
-       ft_cpu_setup(blob, bd);
-
-       base = getenv_bootm_low();
-       size = getenv_bootm_size();
-
-#if defined(CONFIG_PCI)
-       ft_pci_board_setup(blob);
-#endif /* #if defined(CONFIG_PCI) */
-
-       fdt_fixup_memory(blob, (u64)base, (u64)size);
-
-#if defined(CONFIG_HAS_FSL_DR_USB)
-       fdt_fixup_dr_usb(blob, bd);
-#endif
-
-#if defined(CONFIG_SDCARD) || defined(CONFIG_SPIFLASH)
-       /* Delete eLBC node as it is muxed with USB2 controller */
-       if (hwconfig("usb2")) {
-               const char *soc_elbc_compat = "fsl,p1020-elbc";
-               int off = fdt_node_offset_by_compatible(blob, -1,
-                       soc_elbc_compat);
-               if (off < 0) {
-                       printf("WARNING: could not find compatible node %s\n",
-                              soc_elbc_compat);
-                       return off;
-               }
-               err = fdt_del_node(blob, off);
-               if (err < 0) {
-                       printf("WARNING: could not remove %s\n",
-                              soc_elbc_compat);
-                       return err;
-               }
-               return 0;
-       }
-#endif
-       /* Delete USB2 node as it is muxed with eLBC */
-       usb1_off = fdt_node_offset_by_compatible(blob, -1,
-               soc_usb_compat);
-       if (usb1_off < 0) {
-               printf("WARNING: could not find compatible node %s\n",
-                      soc_usb_compat);
-               return usb1_off;
-       }
-       usb2_off = fdt_node_offset_by_compatible(blob, usb1_off,
-                       soc_usb_compat);
-       if (usb2_off < 0) {
-               printf("WARNING: could not find compatible node %s\n",
-                      soc_usb_compat);
-               return usb2_off;
-       }
-       err = fdt_del_node(blob, usb2_off);
-       if (err < 0) {
-               printf("WARNING: could not remove %s\n", soc_usb_compat);
-               return err;
-       }
-
-       return 0;
-}
-
-#endif
diff --git a/board/freescale/p1_p2_rdb/pci.c b/board/freescale/p1_p2_rdb/pci.c
deleted file mode 100644 (file)
index 745ebb1..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright 2009-2010 Freescale Semiconductor, Inc.
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#include <common.h>
-#include <command.h>
-#include <pci.h>
-#include <asm/immap_85xx.h>
-#include <asm/fsl_serdes.h>
-#include <asm/io.h>
-#include <asm/fsl_pci.h>
-#include <libfdt.h>
-#include <fdt_support.h>
-
-DECLARE_GLOBAL_DATA_PTR;
-
-void pci_init_board(void)
-{
-       fsl_pcie_init_board(0);
-}
-
-void ft_pci_board_setup(void *blob)
-{
-       FT_FSL_PCI_SETUP;
-}
diff --git a/board/freescale/p1_p2_rdb/spl.c b/board/freescale/p1_p2_rdb/spl.c
deleted file mode 100644 (file)
index f30c5fe..0000000
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * Copyright 2013 Freescale Semiconductor, Inc.
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#include <common.h>
-#include <ns16550.h>
-#include <malloc.h>
-#include <mmc.h>
-#include <nand.h>
-#include <i2c.h>
-#include <fsl_esdhc.h>
-#include <spi_flash.h>
-
-DECLARE_GLOBAL_DATA_PTR;
-
-#define SYSCLK_MASK    0x00200000
-#define BOARDREV_MASK  0x10100000
-
-#define SYSCLK_66      66666666
-#define SYSCLK_100     100000000
-
-unsigned long get_board_sys_clk(ulong dummy)
-{
-       ccsr_gpio_t *pgpio = (void *)(CONFIG_SYS_MPC85xx_GPIO_ADDR);
-       u32 val_gpdat, sysclk_gpio;
-
-       val_gpdat = in_be32(&pgpio->gpdat);
-       sysclk_gpio = val_gpdat & SYSCLK_MASK;
-
-       if (sysclk_gpio == 0)
-               return SYSCLK_66;
-       else
-               return SYSCLK_100;
-
-       return 0;
-}
-
-phys_size_t get_effective_memsize(void)
-{
-       return CONFIG_SYS_L2_SIZE;
-}
-
-void board_init_f(ulong bootflag)
-{
-       u32 plat_ratio, bus_clk;
-       ccsr_gur_t *gur = (void *)CONFIG_SYS_MPC85xx_GUTS_ADDR;
-
-       console_init_f();
-
-       /* Set pmuxcr to allow both i2c1 and i2c2 */
-       setbits_be32(&gur->pmuxcr, in_be32(&gur->pmuxcr) | 0x1000);
-       setbits_be32(&gur->pmuxcr,
-                    in_be32(&gur->pmuxcr) | MPC85xx_PMUXCR_SD_DATA);
-
-       /* Read back the register to synchronize the write. */
-       in_be32(&gur->pmuxcr);
-
-#ifdef CONFIG_SPL_SPI_BOOT
-       clrbits_be32(&gur->pmuxcr, MPC85xx_PMUXCR_SD_DATA);
-#endif
-
-       /* initialize selected port with appropriate baud rate */
-       plat_ratio = in_be32(&gur->porpllsr) & MPC85xx_PORPLLSR_PLAT_RATIO;
-       plat_ratio >>= 1;
-       bus_clk = CONFIG_SYS_CLK_FREQ * plat_ratio;
-       gd->bus_clk = bus_clk;
-
-       NS16550_init((NS16550_t)CONFIG_SYS_NS16550_COM1,
-                    bus_clk / 16 / CONFIG_BAUDRATE);
-#ifdef CONFIG_SPL_MMC_BOOT
-       puts("\nSD boot...\n");
-#elif defined(CONFIG_SPL_SPI_BOOT)
-       puts("\nSPI Flash boot...\n");
-#endif
-
-       /* copy code to RAM and jump to it - this should not return */
-       /* NOTE - code has to be copied out of NAND buffer before
-        * other blocks can be read.
-        */
-       relocate_code(CONFIG_SPL_RELOC_STACK, 0, CONFIG_SPL_RELOC_TEXT_BASE);
-}
-
-void board_init_r(gd_t *gd, ulong dest_addr)
-{
-       /* Pointer is writable since we allocated a register for it */
-       gd = (gd_t *)CONFIG_SPL_GD_ADDR;
-       bd_t *bd;
-
-       memset(gd, 0, sizeof(gd_t));
-       bd = (bd_t *)(CONFIG_SPL_GD_ADDR + sizeof(gd_t));
-       memset(bd, 0, sizeof(bd_t));
-       gd->bd = bd;
-       bd->bi_memstart = CONFIG_SYS_INIT_L2_ADDR;
-       bd->bi_memsize = CONFIG_SYS_L2_SIZE;
-
-       probecpu();
-       get_clocks();
-       mem_malloc_init(CONFIG_SPL_RELOC_MALLOC_ADDR,
-                       CONFIG_SPL_RELOC_MALLOC_SIZE);
-
-#ifdef CONFIG_SPL_MMC_BOOT
-       mmc_initialize(bd);
-#endif
-       /* relocate environment function pointers etc. */
-#ifdef CONFIG_SPL_NAND_BOOT
-       nand_spl_load_image(CONFIG_ENV_OFFSET, CONFIG_ENV_SIZE,
-                           (uchar *)CONFIG_ENV_ADDR);
-#endif
-#ifdef CONFIG_SPL_NAND_BOOT
-       nand_spl_load_image(CONFIG_ENV_OFFSET, CONFIG_ENV_SIZE,
-                           (uchar *)CONFIG_ENV_ADDR);
-#endif
-#ifdef CONFIG_SPL_MMC_BOOT
-       mmc_spl_load_image(CONFIG_ENV_OFFSET, CONFIG_ENV_SIZE,
-                          (uchar *)CONFIG_ENV_ADDR);
-#endif
-#ifdef CONFIG_SPL_SPI_BOOT
-       spi_spl_load_image(CONFIG_ENV_OFFSET, CONFIG_ENV_SIZE,
-                          (uchar *)CONFIG_ENV_ADDR);
-#endif
-
-       gd->env_addr  = (ulong)(CONFIG_ENV_ADDR);
-       gd->env_valid = 1;
-
-       gd->ram_size = initdram(0);
-#ifdef CONFIG_SPL_NAND_BOOT
-       puts("Tertiary program loader running in sram...");
-#else
-       puts("Second program loader running in sram...\n");
-#endif
-
-#ifdef CONFIG_SPL_MMC_BOOT
-       mmc_boot();
-#elif defined(CONFIG_SPL_SPI_BOOT)
-       spi_boot();
-#elif defined(CONFIG_SPL_NAND_BOOT)
-       nand_boot();
-#endif
-}
diff --git a/board/freescale/p1_p2_rdb/spl_minimal.c b/board/freescale/p1_p2_rdb/spl_minimal.c
deleted file mode 100644 (file)
index 96a4d1c..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright 2011 Freescale Semiconductor, Inc.
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#include <common.h>
-#include <ns16550.h>
-#include <asm/io.h>
-#include <nand.h>
-#include <linux/compiler.h>
-#include <asm/fsl_law.h>
-#include <fsl_ddr_sdram.h>
-#include <asm/global_data.h>
-
-DECLARE_GLOBAL_DATA_PTR;
-#define SYSCLK_MASK    0x00200000
-#define BOARDREV_MASK  0x10100000
-
-#define SYSCLK_66      66666666
-#define SYSCLK_100     100000000
-
-unsigned long get_board_sys_clk(ulong dummy)
-{
-       ccsr_gpio_t *pgpio = (void *)(CONFIG_SYS_MPC85xx_GPIO_ADDR);
-       u32 val_gpdat, sysclk_gpio;
-
-       val_gpdat = in_be32(&pgpio->gpdat);
-       sysclk_gpio = val_gpdat & SYSCLK_MASK;
-
-       if (sysclk_gpio == 0)
-               return SYSCLK_66;
-       else
-               return SYSCLK_100;
-
-       return 0;
-}
-
-void board_init_f(ulong bootflag)
-{
-       u32 plat_ratio;
-       ccsr_gur_t *gur = (void *)CONFIG_SYS_MPC85xx_GUTS_ADDR;
-
-#if defined(CONFIG_SYS_NAND_BR_PRELIM) && defined(CONFIG_SYS_NAND_OR_PRELIM)
-       set_lbc_br(0, CONFIG_SYS_NAND_BR_PRELIM);
-       set_lbc_or(0, CONFIG_SYS_NAND_OR_PRELIM);
-#endif
-
-       /* initialize selected port with appropriate baud rate */
-       plat_ratio = in_be32(&gur->porpllsr) & MPC85xx_PORPLLSR_PLAT_RATIO;
-       plat_ratio >>= 1;
-       gd->bus_clk = CONFIG_SYS_CLK_FREQ * plat_ratio;
-
-       NS16550_init((NS16550_t)CONFIG_SYS_NS16550_COM1,
-                    gd->bus_clk / 16 / CONFIG_BAUDRATE);
-
-       puts("\nNAND boot... ");
-
-       /* copy code to RAM and jump to it - this should not return */
-       /* NOTE - code has to be copied out of NAND buffer before
-        * other blocks can be read.
-        */
-       relocate_code(CONFIG_SPL_RELOC_STACK, 0, CONFIG_SPL_RELOC_TEXT_BASE);
-}
-
-void board_init_r(gd_t *gd, ulong dest_addr)
-{
-       puts("\nSecond program loader running in sram...");
-       nand_boot();
-}
-
-void putc(char c)
-{
-       if (c == '\n')
-               NS16550_putc((NS16550_t)CONFIG_SYS_NS16550_COM1, '\r');
-
-       NS16550_putc((NS16550_t)CONFIG_SYS_NS16550_COM1, c);
-}
-
-void puts(const char *str)
-{
-       while (*str)
-               putc(*str++);
-}
diff --git a/board/freescale/p1_p2_rdb/tlb.c b/board/freescale/p1_p2_rdb/tlb.c
deleted file mode 100644 (file)
index 73f5729..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright 2011 Freescale Semiconductor, Inc.
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#include <common.h>
-#include <asm/mmu.h>
-
-struct fsl_e_tlb_entry tlb_table[] = {
-       /* TLB 0 - for temp stack in cache */
-       SET_TLB_ENTRY(0, CONFIG_SYS_INIT_RAM_ADDR,
-                       CONFIG_SYS_INIT_RAM_ADDR_PHYS,
-                       MAS3_SX|MAS3_SW|MAS3_SR, 0,
-                       0, 0, BOOKE_PAGESZ_4K, 0),
-       SET_TLB_ENTRY(0, CONFIG_SYS_INIT_RAM_ADDR + 4 * 1024 ,
-                       CONFIG_SYS_INIT_RAM_ADDR_PHYS + 4 * 1024,
-                       MAS3_SX|MAS3_SW|MAS3_SR, 0,
-                       0, 0, BOOKE_PAGESZ_4K, 0),
-       SET_TLB_ENTRY(0, CONFIG_SYS_INIT_RAM_ADDR + 8 * 1024 ,
-                       CONFIG_SYS_INIT_RAM_ADDR_PHYS + 8 * 1024,
-                       MAS3_SX|MAS3_SW|MAS3_SR, 0,
-                       0, 0, BOOKE_PAGESZ_4K, 0),
-       SET_TLB_ENTRY(0, CONFIG_SYS_INIT_RAM_ADDR + 12 * 1024 ,
-                       CONFIG_SYS_INIT_RAM_ADDR_PHYS + 12 * 1024,
-                       MAS3_SX|MAS3_SW|MAS3_SR, 0,
-                       0, 0, BOOKE_PAGESZ_4K, 0),
-
-       /* TLB 1 */
-       /* *I*** - Covers boot page */
-       SET_TLB_ENTRY(1, 0xfffff000, 0xfffff000,
-                       MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
-                       0, 0, BOOKE_PAGESZ_4K, 1),
-
-       /* *I*G* - CCSRBAR */
-       SET_TLB_ENTRY(1, CONFIG_SYS_CCSRBAR, CONFIG_SYS_CCSRBAR_PHYS,
-                       MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
-                       0, 1, BOOKE_PAGESZ_1M, 1),
-
-#ifndef CONFIG_SPL_BUILD
-       /* W**G* - Flash/promjet, localbus */
-       /* This will be changed to *I*G* after relocation to RAM. */
-       SET_TLB_ENTRY(1, CONFIG_SYS_FLASH_BASE, CONFIG_SYS_FLASH_BASE_PHYS,
-                       MAS3_SX|MAS3_SR, MAS2_W|MAS2_G,
-                       0, 2, BOOKE_PAGESZ_16M, 1),
-
-#if defined(CONFIG_PCI)
-       /* *I*G* - PCI */
-       SET_TLB_ENTRY(1, CONFIG_SYS_PCIE1_MEM_VIRT, CONFIG_SYS_PCIE1_MEM_PHYS,
-                       MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
-                       0, 3, BOOKE_PAGESZ_1G, 1),
-
-       /* *I*G* - PCI I/O */
-       SET_TLB_ENTRY(1, CONFIG_SYS_PCIE1_IO_VIRT, CONFIG_SYS_PCIE1_IO_PHYS,
-                       MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
-                       0, 4, BOOKE_PAGESZ_256K, 1),
-
-#endif /* #if defined(CONFIG_PCI) */
-#endif
-       /* *I*G - NAND */
-       SET_TLB_ENTRY(1, CONFIG_SYS_NAND_BASE, CONFIG_SYS_NAND_BASE_PHYS,
-                       MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
-                       0, 5, BOOKE_PAGESZ_1M, 1),
-
-       /* *I*G - VSC7385 Switch */
-       SET_TLB_ENTRY(1, CONFIG_SYS_VSC7385_BASE, CONFIG_SYS_VSC7385_BASE_PHYS,
-                       MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
-                       0, 6, BOOKE_PAGESZ_1M, 1),
-
-#ifdef CONFIG_SYS_INIT_L2_ADDR
-       /* *I*G - L2SRAM */
-       SET_TLB_ENTRY(1, CONFIG_SYS_INIT_L2_ADDR, CONFIG_SYS_INIT_L2_ADDR_PHYS,
-                     MAS3_SX|MAS3_SW|MAS3_SR, MAS2_G,
-                     0, 11, BOOKE_PAGESZ_256K, 1),
-#if CONFIG_SYS_L2_SIZE >= (256 << 10)
-       SET_TLB_ENTRY(1, CONFIG_SYS_INIT_L2_ADDR + 0x40000,
-                     CONFIG_SYS_INIT_L2_ADDR_PHYS + 0x40000,
-                     MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
-                     0, 12, BOOKE_PAGESZ_256K, 1),
-#endif
-#endif
-
-#if defined(CONFIG_SYS_RAMBOOT) || \
-       (defined(CONFIG_SPL) && !defined(CONFIG_SPL_COMMON_INIT_DDR))
-       SET_TLB_ENTRY(1, CONFIG_SYS_DDR_SDRAM_BASE, CONFIG_SYS_DDR_SDRAM_BASE,
-                       MAS3_SX|MAS3_SW|MAS3_SR, 0,
-                       0, 7, BOOKE_PAGESZ_1G, 1)
-#endif
-};
-
-int num_tlb_entries = ARRAY_SIZE(tlb_table);
diff --git a/board/freescale/p2020come/Kconfig b/board/freescale/p2020come/Kconfig
deleted file mode 100644 (file)
index 8ce5cf1..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-if TARGET_P2020COME
-
-config SYS_BOARD
-       default "p2020come"
-
-config SYS_VENDOR
-       default "freescale"
-
-config SYS_CONFIG_NAME
-       default "P2020COME"
-
-endif
diff --git a/board/freescale/p2020come/MAINTAINERS b/board/freescale/p2020come/MAINTAINERS
deleted file mode 100644 (file)
index ab3ef94..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-P2020COME BOARD
-M:     Ira W. Snyder <iws@ovro.caltech.edu>
-S:     Maintained
-F:     board/freescale/p2020come/
-F:     include/configs/P2020COME.h
-F:     configs/P2020COME_SDCARD_defconfig
-F:     configs/P2020COME_SPIFLASH_defconfig
diff --git a/board/freescale/p2020come/Makefile b/board/freescale/p2020come/Makefile
deleted file mode 100644 (file)
index 4857136..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-#
-# Copyright 2009 Freescale Semiconductor, Inc.
-#
-# SPDX-License-Identifier:     GPL-2.0+
-#
-
-obj-y                  += p2020come.o
-obj-y                  += ddr.o
-obj-y                  += law.o
-obj-y                  += tlb.o
diff --git a/board/freescale/p2020come/ddr.c b/board/freescale/p2020come/ddr.c
deleted file mode 100644 (file)
index b642e12..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright 2009, 2011 Freescale Semiconductor, Inc.
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-#include <common.h>
-
-#include <fsl_ddr_sdram.h>
-#include <fsl_ddr_dimm_params.h>
-
-void fsl_ddr_board_options(memctl_options_t *popts,
-                               dimm_params_t *pdimm,
-                               unsigned int ctrl_num)
-{
-       if (ctrl_num) {
-               printf("Wrong parameter for controller number %d", ctrl_num);
-               return;
-       }
-
-       if (!pdimm->n_ranks)
-               return;
-
-       /*
-        * Set DDR_SDRAM_CLK_CNTL = 0x02800000
-        *
-        * Clock is launched 5/8 applied cycle after address/command
-        */
-       popts->clk_adjust = 5;
-}
diff --git a/board/freescale/p2020come/law.c b/board/freescale/p2020come/law.c
deleted file mode 100644 (file)
index 7048a08..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright 2009 Freescale Semiconductor, Inc.
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#include <common.h>
-#include <asm/fsl_law.h>
-#include <asm/mmu.h>
-
-/*
- * Create a dummy LAW entry for the DDR SDRAM which will be replaced when
- * the DDR SPD setup code runs.
- *
- * This table would be empty, except that it is used before the BSS section is
- * initialized, and therefore must have at least one entry to push it into
- * the DATA section.
- */
-struct law_entry law_table[] = {
-       SET_LAW(CONFIG_SYS_SDRAM_BASE, LAW_SIZE_4K, LAW_TRGT_IF_DDR),
-};
-
-int num_law_entries = ARRAY_SIZE(law_table);
diff --git a/board/freescale/p2020come/p2020come.c b/board/freescale/p2020come/p2020come.c
deleted file mode 100644 (file)
index 1db37e3..0000000
+++ /dev/null
@@ -1,275 +0,0 @@
-/*
- * Copyright 2009,2012 Freescale Semiconductor, Inc.
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#include <common.h>
-#include <hwconfig.h>
-#include <command.h>
-#include <asm/processor.h>
-#include <asm/mmu.h>
-#include <asm/cache.h>
-#include <asm/immap_85xx.h>
-#include <asm/mpc85xx_gpio.h>
-#include <asm/fsl_serdes.h>
-#include <asm/io.h>
-#include <miiphy.h>
-#include <libfdt.h>
-#include <fdt_support.h>
-#include <fsl_mdio.h>
-#include <tsec.h>
-#include <vsc7385.h>
-#include <netdev.h>
-#include <mmc.h>
-#include <malloc.h>
-#include <i2c.h>
-
-#if defined(CONFIG_PCI)
-#include <asm/fsl_pci.h>
-#include <pci.h>
-#endif
-
-DECLARE_GLOBAL_DATA_PTR;
-
-#if defined(CONFIG_PCI)
-void pci_init_board(void)
-{
-       fsl_pcie_init_board(0);
-}
-
-void ft_pci_board_setup(void *blob)
-{
-       FT_FSL_PCI_SETUP;
-}
-#endif
-
-#define BOARD_PERI_RST_SET     (VSC7385_RST_SET | SLIC_RST_SET | \
-                                SGMII_PHY_RST_SET | PCIE_RST_SET | \
-                                RGMII_PHY_RST_SET)
-
-#define SYSCLK_MASK    0x00200000
-#define BOARDREV_MASK  0x10100000
-#define BOARDREV_B     0x10100000
-#define BOARDREV_C     0x00100000
-#define BOARDREV_D     0x00000000
-
-#define SYSCLK_66      66666666
-#define SYSCLK_50      50000000
-#define SYSCLK_100     100000000
-
-unsigned long get_board_sys_clk(ulong dummy)
-{
-       ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
-       u32 ddr_ratio = in_be32(&gur->porpllsr) & MPC85xx_PORPLLSR_DDR_RATIO;
-
-       ddr_ratio >>= MPC85xx_PORPLLSR_DDR_RATIO_SHIFT;
-       switch (ddr_ratio) {
-       case 0x0C:
-               return SYSCLK_66;
-       case 0x0A:
-       case 0x08:
-               return SYSCLK_100;
-       default:
-               puts("ERROR: unknown DDR ratio\n");
-               return SYSCLK_100;
-       }
-}
-
-unsigned long get_board_ddr_clk(ulong dummy)
-{
-       ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
-       u32 ddr_ratio = in_be32(&gur->porpllsr) & MPC85xx_PORPLLSR_DDR_RATIO;
-
-       ddr_ratio >>= MPC85xx_PORPLLSR_DDR_RATIO_SHIFT;
-       switch (ddr_ratio) {
-       case 0x0C:
-       case 0x0A:
-               return SYSCLK_66;
-       case 0x08:
-               return SYSCLK_100;
-       default:
-               puts("ERROR: unknown DDR ratio\n");
-               return SYSCLK_100;
-       }
-}
-
-#ifdef CONFIG_MMC
-int board_early_init_f(void)
-{
-       ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
-
-       setbits_be32(&gur->pmuxcr,
-                       (MPC85xx_PMUXCR_SDHC_CD |
-                        MPC85xx_PMUXCR_SDHC_WP));
-
-       /* All the device are enable except for SRIO12 */
-       setbits_be32(&gur->devdisr, MPC85xx_DEVDISR_SRIO);
-       return 0;
-}
-#endif
-
-#define GPIO_DIR               0x0f3a0000
-#define GPIO_ODR               0x00000000
-#define GPIO_DAT               0x001a0000
-
-int checkboard(void)
-{
-       ccsr_gpio_t *pgpio = (void *)(CONFIG_SYS_MPC85xx_GPIO_ADDR + 0xC00);
-
-       /*
-        * GPIO
-        * 0 - 3: CarryBoard Input;
-        * 4 - 7: CarryBoard Output;
-        * 8 : Mux as SDHC_CD (card detection)
-        * 9 : Mux as SDHC_WP
-        * 10 : Clear Watchdog timer
-        * 11 : LED Input
-        * 12 : Output to 1
-        * 13 : Open Drain
-        * 14 : LED Output
-        * 15 : Switch Input
-        *
-        * Set GPIOs 11, 12, 14 to 1.
-        */
-       out_be32(&pgpio->gpodr, GPIO_ODR);
-       mpc85xx_gpio_set(0xffffffff, GPIO_DIR, GPIO_DAT);
-
-       puts("Board: Freescale COM Express P2020\n");
-       return 0;
-}
-
-#define M41ST85W_I2C_BUS       1
-#define M41ST85W_I2C_ADDR      0x68
-#define M41ST85W_ERROR(fmt, args...) printf("ERROR: M41ST85W: " fmt, ##args)
-
-static void m41st85w_clear_bit(u8 reg, u8 mask, const char *name)
-{
-       u8 data;
-
-       if (i2c_read(M41ST85W_I2C_ADDR, reg, 1, &data, 1)) {
-               M41ST85W_ERROR("unable to read %s bit\n", name);
-               return;
-       }
-
-       if (data & mask) {
-               data &= ~mask;
-               if (i2c_write(M41ST85W_I2C_ADDR, reg, 1, &data, 1)) {
-                       M41ST85W_ERROR("unable to clear %s bit\n", name);
-                       return;
-               }
-       }
-}
-
-#define M41ST85W_REG_SEC2      0x01
-#define M41ST85W_REG_SEC2_ST   0x80
-
-#define M41ST85W_REG_ALHOUR    0x0c
-#define M41ST85W_REG_ALHOUR_HT 0x40
-
-/*
- * The P2020COME board has a STMicro M41ST85W RTC/watchdog
- * at i2c bus 1 address 0x68.
- */
-static void start_rtc(void)
-{
-       unsigned int bus = i2c_get_bus_num();
-
-       if (i2c_set_bus_num(M41ST85W_I2C_BUS)) {
-               M41ST85W_ERROR("unable to set i2c bus\n");
-               goto out;
-       }
-
-       /* ensure ST (stop) and HT (halt update) bits are cleared */
-       m41st85w_clear_bit(M41ST85W_REG_SEC2, M41ST85W_REG_SEC2_ST, "ST");
-       m41st85w_clear_bit(M41ST85W_REG_ALHOUR, M41ST85W_REG_ALHOUR_HT, "HT");
-
-out:
-       /* reset the i2c bus */
-       i2c_set_bus_num(bus);
-}
-
-int board_early_init_r(void)
-{
-       start_rtc();
-       return 0;
-}
-
-#define M41ST85W_REG_WATCHDOG          0x09
-#define M41ST85W_REG_WATCHDOG_WDS      0x80
-#define M41ST85W_REG_WATCHDOG_BMB0     0x04
-
-void board_reset(void)
-{
-       u8 data = M41ST85W_REG_WATCHDOG_WDS | M41ST85W_REG_WATCHDOG_BMB0;
-
-       /* set the hardware watchdog timeout to 1/16 second, then hang */
-       i2c_set_bus_num(M41ST85W_I2C_BUS);
-       i2c_write(M41ST85W_I2C_ADDR, M41ST85W_REG_WATCHDOG, 1, &data, 1);
-
-       while (1)
-               /* hang */;
-}
-
-#ifdef CONFIG_TSEC_ENET
-int board_eth_init(bd_t *bis)
-{
-       struct fsl_pq_mdio_info mdio_info;
-       struct tsec_info_struct tsec_info[4];
-       int num = 0;
-
-#ifdef CONFIG_TSEC1
-       SET_STD_TSEC_INFO(tsec_info[num], 1);
-       num++;
-#endif
-#ifdef CONFIG_TSEC2
-       SET_STD_TSEC_INFO(tsec_info[num], 2);
-       num++;
-#endif
-#ifdef CONFIG_TSEC3
-       SET_STD_TSEC_INFO(tsec_info[num], 3);
-       if (is_serdes_configured(SGMII_TSEC3)) {
-               puts("eTSEC3 is in sgmii mode.");
-               tsec_info[num].flags |= TSEC_SGMII;
-       }
-       num++;
-#endif
-       if (!num) {
-               printf("No TSECs initialized\n");
-               return 0;
-       }
-
-       mdio_info.regs = (struct tsec_mii_mng *)CONFIG_SYS_MDIO_BASE_ADDR;
-       mdio_info.name = DEFAULT_MII_NAME;
-       fsl_pq_mdio_init(bis, &mdio_info);
-
-       tsec_eth_init(bis, tsec_info, num);
-
-       return pci_eth_init(bis);
-}
-#endif
-
-#if defined(CONFIG_OF_BOARD_SETUP)
-int ft_board_setup(void *blob, bd_t *bd)
-{
-       phys_addr_t base;
-       phys_size_t size;
-
-       ft_cpu_setup(blob, bd);
-
-       base = getenv_bootm_low();
-       size = getenv_bootm_size();
-
-#if defined(CONFIG_PCI)
-       ft_pci_board_setup(blob);
-#endif
-
-       fdt_fixup_memory(blob, (u64)base, (u64)size);
-
-#ifdef CONFIG_HAS_FSL_DR_USB
-       fdt_fixup_dr_usb(blob, bd);
-#endif
-
-       return 0;
-}
-#endif
diff --git a/board/freescale/p2020come/tlb.c b/board/freescale/p2020come/tlb.c
deleted file mode 100644 (file)
index 08a1e34..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright 2011 Freescale Semiconductor, Inc.
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#include <common.h>
-#include <asm/mmu.h>
-
-struct fsl_e_tlb_entry tlb_table[] = {
-       /* TLB 0 - for temp stack in cache */
-       SET_TLB_ENTRY(0, CONFIG_SYS_INIT_RAM_ADDR,
-                       CONFIG_SYS_INIT_RAM_ADDR_PHYS,
-                       MAS3_SW|MAS3_SR, 0,
-                       0, 0, BOOKE_PAGESZ_4K, 0),
-       SET_TLB_ENTRY(0, CONFIG_SYS_INIT_RAM_ADDR + 4 * 1024 ,
-                       CONFIG_SYS_INIT_RAM_ADDR_PHYS + 4 * 1024,
-                       MAS3_SW|MAS3_SR, 0,
-                       0, 0, BOOKE_PAGESZ_4K, 0),
-       SET_TLB_ENTRY(0, CONFIG_SYS_INIT_RAM_ADDR + 8 * 1024 ,
-                       CONFIG_SYS_INIT_RAM_ADDR_PHYS + 8 * 1024,
-                       MAS3_SW|MAS3_SR, 0,
-                       0, 0, BOOKE_PAGESZ_4K, 0),
-       SET_TLB_ENTRY(0, CONFIG_SYS_INIT_RAM_ADDR + 12 * 1024 ,
-                       CONFIG_SYS_INIT_RAM_ADDR_PHYS + 12 * 1024,
-                       MAS3_SW|MAS3_SR, 0,
-                       0, 0, BOOKE_PAGESZ_4K, 0),
-
-       /* TLB 1 */
-       /* *I*** - Covers boot page */
-       SET_TLB_ENTRY(1, 0xfffff000, 0xfffff000,
-                       MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
-                       0, 0, BOOKE_PAGESZ_4K, 1),
-
-       /* *I*G* - CCSRBAR */
-       SET_TLB_ENTRY(1, CONFIG_SYS_CCSRBAR, CONFIG_SYS_CCSRBAR_PHYS,
-                       MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
-                       0, 1, BOOKE_PAGESZ_1M, 1),
-
-#if defined(CONFIG_PCI)
-       /* *I*G* - PCI3 - PCI2 0x8000,0000 - 0xbfff,ffff, size = 1G */
-       SET_TLB_ENTRY(1, CONFIG_SYS_PCIE3_MEM_VIRT, CONFIG_SYS_PCIE3_MEM_PHYS,
-                       MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
-                       0, 2, BOOKE_PAGESZ_1G, 1),
-
-       /* *I*G* - PCI1 0xC000,0000 - 0xcfff,ffff, size = 256M */
-       SET_TLB_ENTRY(1, CONFIG_SYS_PCIE1_MEM_VIRT, CONFIG_SYS_PCIE1_MEM_VIRT,
-                       MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
-                       0, 3, BOOKE_PAGESZ_256M, 1),
-
-       /* *I*G* - PCI1  0xD000,0000 - 0xDFFF,FFFF, size = 256M */
-       SET_TLB_ENTRY(1, CONFIG_SYS_PCIE1_MEM_VIRT + 0x10000000,
-                       CONFIG_SYS_PCIE1_MEM_PHYS + 0x10000000,
-                       MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
-                       0, 4, BOOKE_PAGESZ_256M, 1),
-
-       /*
-        * *I*G* - PCI I/O
-        *
-        * PCI3 => 0xFFC10000
-        * PCI2 => 0xFFC2,0000
-        * PCI1 => 0xFFC3,0000
-        */
-       SET_TLB_ENTRY(1, CONFIG_SYS_PCIE3_IO_VIRT, CONFIG_SYS_PCIE3_IO_PHYS,
-                       MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
-                       0, 5, BOOKE_PAGESZ_256K, 1),
-#endif /* #if defined(CONFIG_PCI) */
-
-#if defined(CONFIG_SYS_RAMBOOT) && defined(CONFIG_SYS_INIT_L2_ADDR)
-       /* *I*G - DDR3  2G     Part 1: 0 - 0x3fff,ffff , size = 1G */
-       SET_TLB_ENTRY(1, CONFIG_SYS_INIT_L2_ADDR, CONFIG_SYS_INIT_L2_ADDR_PHYS,
-                       MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
-                       0, 6, BOOKE_PAGESZ_256K, 1),
-
-       /*        DDR3  2G     Part 2: 0x4000,0000 - 0x7fff,ffff , size = 1G */
-       SET_TLB_ENTRY(1, CONFIG_SYS_INIT_L2_ADDR + 0x40000,
-                       CONFIG_SYS_INIT_L2_ADDR_PHYS + 0x40000,
-                       MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
-                       0, 7, BOOKE_PAGESZ_256K, 1),
-#endif
-};
-
-int num_tlb_entries = ARRAY_SIZE(tlb_table);
diff --git a/board/freescale/p2020ds/Kconfig b/board/freescale/p2020ds/Kconfig
deleted file mode 100644 (file)
index e527ec9..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-if TARGET_P2020DS
-
-config SYS_BOARD
-       default "p2020ds"
-
-config SYS_VENDOR
-       default "freescale"
-
-config SYS_CONFIG_NAME
-       default "P2020DS"
-
-endif
diff --git a/board/freescale/p2020ds/MAINTAINERS b/board/freescale/p2020ds/MAINTAINERS
deleted file mode 100644 (file)
index cb61fc5..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-P2020DS BOARD
-#M:    -
-S:     Maintained
-F:     board/freescale/p2020ds/
-F:     include/configs/P2020DS.h
-F:     configs/P2020DS_defconfig
-F:     configs/P2020DS_36BIT_defconfig
-F:     configs/P2020DS_DDR2_defconfig
-F:     configs/P2020DS_SDCARD_defconfig
-F:     configs/P2020DS_SPIFLASH_defconfig
diff --git a/board/freescale/p2020ds/Makefile b/board/freescale/p2020ds/Makefile
deleted file mode 100644 (file)
index ee00806..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-#
-# Copyright 2007-2009 Freescale Semiconductor, Inc.
-# (C) Copyright 2001-2006
-# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
-#
-# SPDX-License-Identifier:     GPL-2.0+
-#
-
-obj-y  += p2020ds.o
-obj-y  += ddr.o
-obj-y  += law.o
-obj-y  += tlb.o
diff --git a/board/freescale/p2020ds/ddr.c b/board/freescale/p2020ds/ddr.c
deleted file mode 100644 (file)
index debe70b..0000000
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * Copyright 2008-2009 Freescale Semiconductor, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * Version 2 as published by the Free Software Foundation.
- */
-
-#include <common.h>
-
-#include <fsl_ddr_sdram.h>
-#include <fsl_ddr_dimm_params.h>
-
-struct board_specific_parameters {
-       u32 n_ranks;
-       u32 datarate_mhz_high;
-       u32 clk_adjust;
-       u32 cpo;
-       u32 write_data_delay;
-       u32 force_2t;
-};
-
-
-/*
- * This table contains all valid speeds we want to override with board
- * specific parameters. datarate_mhz_high values need to be in ascending order
- * for each n_ranks group.
- *
- * ranges for parameters:
- *  wr_data_delay = 0-6
- *  clk adjust = 0-8
- *  cpo 2-0x1E (30)
- */
-static const struct board_specific_parameters dimm0[] = {
-       /*
-        * memory controller 0
-        *   num|  hi|  clk| cpo|wrdata|2T
-        * ranks| mhz|adjst|    | delay|
-        */
-#ifdef CONFIG_SYS_FSL_DDR2
-       {2,  549,    4,   0x1f,    2,  0},
-       {2,  680,    4,   0x1f,    3,  0},
-       {2,  850,    4,   0x1f,    4,  0},
-       {1,  549,    4,   0x1f,    2,  0},
-       {1,  680,    4,   0x1f,    3,  0},
-       {1,  850,    4,   0x1f,    4,  0},
-#else
-       {2,  850,    6,   0x1f,    4,  0},
-       {1,  850,    4,   0x1f,    4,  0},
-#endif
-       {}
-};
-
-void fsl_ddr_board_options(memctl_options_t *popts,
-                               dimm_params_t *pdimm,
-                               unsigned int ctrl_num)
-{
-       const struct board_specific_parameters *pbsp, *pbsp_highest = NULL;
-       ulong ddr_freq;
-       int i;
-
-       if (ctrl_num) {
-               printf("Wrong parameter for controller number %d", ctrl_num);
-               return;
-       }
-       if (!pdimm->n_ranks)
-               return;
-
-       /*
-        * set odt_rd_cfg and odt_wr_cfg. If the there is only one dimm in
-        * that controller, set odt_wr_cfg to 4 for CS0, and 0 to CS1. If
-        * there are two dimms in the controller, set odt_rd_cfg to 3 and
-        * odt_wr_cfg to 3 for the even CS, 0 for the odd CS.
-        */
-       for (i = 0; i < CONFIG_CHIP_SELECTS_PER_CTRL; i++) {
-               popts->cs_local_opts[i].odt_rd_cfg = 0;
-               popts->cs_local_opts[i].odt_wr_cfg = 1;
-       }
-
-       pbsp = dimm0;
-
-       /* Get clk_adjust, cpo, write_data_delay,2T, according to the board ddr
-        * freqency and n_banks specified in board_specific_parameters table.
-        */
-       ddr_freq = get_ddr_freq(0) / 1000000;
-       while (pbsp->datarate_mhz_high) {
-               if (pbsp->n_ranks == pdimm->n_ranks) {
-                       if (ddr_freq <= pbsp->datarate_mhz_high) {
-                               popts->clk_adjust = pbsp->clk_adjust;
-                               popts->cpo_override = pbsp->cpo;
-                               popts->write_data_delay =
-                                       pbsp->write_data_delay;
-                               popts->twot_en = pbsp->force_2t;
-                               goto found;
-                       }
-                       pbsp_highest = pbsp;
-               }
-               pbsp++;
-       }
-
-       if (pbsp_highest) {
-               printf("Error: board specific timing not found "
-                       "for data rate %lu MT/s!\n"
-                       "Trying to use the highest speed (%u) parameters\n",
-                       ddr_freq, pbsp_highest->datarate_mhz_high);
-               popts->clk_adjust = pbsp_highest->clk_adjust;
-               popts->cpo_override = pbsp_highest->cpo;
-               popts->write_data_delay = pbsp_highest->write_data_delay;
-               popts->twot_en = pbsp_highest->force_2t;
-       } else {
-               panic("DIMM is not supported by this board");
-       }
-
-found:
-       /*
-        * Factors to consider for half-strength driver enable:
-        *      - number of DIMMs installed
-        */
-       popts->half_strength_driver_enable = 0;
-       popts->wrlvl_en = 1;
-       /* Write leveling override */
-       popts->wrlvl_override = 1;
-       popts->wrlvl_sample = 0xa;
-       popts->wrlvl_start = 0x8;
-       /* Rtt and Rtt_WR override */
-       popts->rtt_override = 1;
-       popts->rtt_override_value = DDR3_RTT_120_OHM;
-       popts->rtt_wr_override_value = 0; /* Rtt_WR= dynamic ODT off */
-}
diff --git a/board/freescale/p2020ds/law.c b/board/freescale/p2020ds/law.c
deleted file mode 100644 (file)
index 9cd4da9..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2008-2010 Freescale Semiconductor, Inc.
- *
- * (C) Copyright 2000
- * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#include <common.h>
-#include <asm/fsl_law.h>
-#include <asm/mmu.h>
-
-struct law_entry law_table[] = {
-       SET_LAW(CONFIG_SYS_FLASH_BASE_PHYS, LAW_SIZE_256M, LAW_TRGT_IF_LBC),
-       SET_LAW(PIXIS_BASE_PHYS, LAW_SIZE_4K, LAW_TRGT_IF_LBC),
-       SET_LAW(CONFIG_SYS_NAND_BASE_PHYS, LAW_SIZE_1M, LAW_TRGT_IF_LBC),
-};
-
-int num_law_entries = ARRAY_SIZE(law_table);
diff --git a/board/freescale/p2020ds/p2020ds.c b/board/freescale/p2020ds/p2020ds.c
deleted file mode 100644 (file)
index 5d18e8d..0000000
+++ /dev/null
@@ -1,263 +0,0 @@
-/*
- * Copyright 2007-2012 Freescale Semiconductor, Inc.
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#include <common.h>
-#include <command.h>
-#include <pci.h>
-#include <asm/processor.h>
-#include <asm/mmu.h>
-#include <asm/cache.h>
-#include <asm/immap_85xx.h>
-#include <asm/fsl_pci.h>
-#include <fsl_ddr_sdram.h>
-#include <asm/io.h>
-#include <asm/fsl_serdes.h>
-#include <miiphy.h>
-#include <libfdt.h>
-#include <fdt_support.h>
-#include <fsl_mdio.h>
-#include <tsec.h>
-#include <asm/fsl_law.h>
-#include <netdev.h>
-
-#include "../common/ngpixis.h"
-#include "../common/sgmii_riser.h"
-
-DECLARE_GLOBAL_DATA_PTR;
-
-int board_early_init_f(void)
-{
-#ifdef CONFIG_MMC
-       ccsr_gur_t *gur = (ccsr_gur_t *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
-
-       setbits_be32(&gur->pmuxcr,
-                        (MPC85xx_PMUXCR_SDHC_CD |
-                        MPC85xx_PMUXCR_SDHC_WP));
-#endif
-
-       return 0;
-}
-
-int checkboard(void)
-{
-       u8 sw;
-
-       printf("Board: P2020DS Sys ID: 0x%02x, "
-              "Sys Ver: 0x%02x, FPGA Ver: 0x%02x, ",
-               in_8(&pixis->id), in_8(&pixis->arch), in_8(&pixis->scver));
-
-       sw = in_8(&PIXIS_SW(PIXIS_LBMAP_SWITCH));
-       sw = (sw & PIXIS_LBMAP_MASK) >> PIXIS_LBMAP_SHIFT;
-
-       if (sw < 0x8)
-               /* The lower two bits are the actual vbank number */
-               printf("vBank: %d\n", sw & 3);
-       else
-               puts("Promjet\n");
-
-       return 0;
-}
-
-#if !defined(CONFIG_DDR_SPD)
-/*
- * Fixed sdram init -- doesn't use serial presence detect.
- */
-
-phys_size_t fixed_sdram(void)
-{
-       struct ccsr_ddr __iomem *ddr =
-               (struct ccsr_ddr __iomem *)CONFIG_SYS_FSL_DDR_ADDR;
-       uint d_init;
-
-       ddr->cs0_config = CONFIG_SYS_DDR_CS0_CONFIG;
-       ddr->timing_cfg_3 = CONFIG_SYS_DDR_TIMING_3;
-       ddr->timing_cfg_0 = CONFIG_SYS_DDR_TIMING_0;
-       ddr->sdram_mode = CONFIG_SYS_DDR_MODE_1;
-       ddr->sdram_mode_2 = CONFIG_SYS_DDR_MODE_2;
-       ddr->sdram_md_cntl = CONFIG_SYS_DDR_MODE_CTRL;
-       ddr->sdram_interval = CONFIG_SYS_DDR_INTERVAL;
-       ddr->sdram_data_init = CONFIG_SYS_DDR_DATA_INIT;
-       ddr->sdram_clk_cntl = CONFIG_SYS_DDR_CLK_CTRL;
-       ddr->sdram_cfg_2 = CONFIG_SYS_DDR_CONTROL2;
-       ddr->ddr_zq_cntl = CONFIG_SYS_DDR_ZQ_CNTL;
-       ddr->ddr_wrlvl_cntl = CONFIG_SYS_DDR_WRLVL_CNTL;
-       ddr->ddr_cdr1 = CONFIG_SYS_DDR_CDR1;
-       ddr->timing_cfg_4 = CONFIG_SYS_DDR_TIMING_4;
-       ddr->timing_cfg_5 = CONFIG_SYS_DDR_TIMING_5;
-
-       if (!strcmp("performance", getenv("perf_mode"))) {
-               /* Performance Mode Values */
-
-               ddr->cs1_config = CONFIG_SYS_DDR_CS1_CONFIG_PERF;
-               ddr->cs0_bnds = CONFIG_SYS_DDR_CS0_BNDS_PERF;
-               ddr->cs1_bnds = CONFIG_SYS_DDR_CS1_BNDS_PERF;
-               ddr->timing_cfg_1 = CONFIG_SYS_DDR_TIMING_1_PERF;
-               ddr->timing_cfg_2 = CONFIG_SYS_DDR_TIMING_2_PERF;
-
-               asm("sync;isync");
-
-               udelay(500);
-
-               ddr->sdram_cfg = CONFIG_SYS_DDR_CONTROL_PERF;
-       } else {
-               /* Stable Mode Values */
-
-               ddr->cs1_config = CONFIG_SYS_DDR_CS1_CONFIG;
-               ddr->cs0_bnds = CONFIG_SYS_DDR_CS0_BNDS;
-               ddr->cs1_bnds = CONFIG_SYS_DDR_CS1_BNDS;
-               ddr->timing_cfg_1 = CONFIG_SYS_DDR_TIMING_1;
-               ddr->timing_cfg_2 = CONFIG_SYS_DDR_TIMING_2;
-
-               /* ECC will be assumed in stable mode */
-               ddr->err_int_en = CONFIG_SYS_DDR_ERR_INT_EN;
-               ddr->err_disable = CONFIG_SYS_DDR_ERR_DIS;
-               ddr->err_sbe = CONFIG_SYS_DDR_SBE;
-
-               asm("sync;isync");
-
-               udelay(500);
-
-               ddr->sdram_cfg = CONFIG_SYS_DDR_CONTROL;
-       }
-
-#if defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER)
-       d_init = 1;
-       debug("DDR - 1st controller: memory initializing\n");
-       /*
-        * Poll until memory is initialized.
-        * 512 Meg at 400 might hit this 200 times or so.
-        */
-       while ((ddr->sdram_cfg_2 & (d_init << 4)) != 0)
-               udelay(1000);
-       debug("DDR: memory initialized\n\n");
-       asm("sync; isync");
-       udelay(500);
-#endif
-
-       if (set_ddr_laws(CONFIG_SYS_DDR_SDRAM_BASE,
-                        CONFIG_SYS_SDRAM_SIZE * 1024 * 1024,
-                        LAW_TRGT_IF_DDR) < 0) {
-               printf("ERROR setting Local Access Windows for DDR\n");
-               return 0;
-       };
-
-       return CONFIG_SYS_SDRAM_SIZE * 1024 * 1024;
-}
-
-#endif
-
-#ifdef CONFIG_PCI
-void pci_init_board(void)
-{
-       fsl_pcie_init_board(0);
-}
-#endif
-
-int board_early_init_r(void)
-{
-       const unsigned int flashbase = CONFIG_SYS_FLASH_BASE;
-       int flash_esel = find_tlb_idx((void *)flashbase, 1);
-
-       /*
-        * Remap Boot flash + PROMJET region to caching-inhibited
-        * so that flash can be erased properly.
-        */
-
-       /* Flush d-cache and invalidate i-cache of any FLASH data */
-       flush_dcache();
-       invalidate_icache();
-
-       if (flash_esel == -1) {
-               /* very unlikely unless something is messed up */
-               puts("Error: Could not find TLB for FLASH BASE\n");
-               flash_esel = 2; /* give our best effort to continue */
-       } else {
-               /* invalidate existing TLB entry for flash + promjet */
-               disable_tlb(flash_esel);
-       }
-
-       set_tlb(1, flashbase, CONFIG_SYS_FLASH_BASE_PHYS,
-                       MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
-                       0, flash_esel, BOOKE_PAGESZ_256M, 1);
-
-       return 0;
-}
-
-#ifdef CONFIG_TSEC_ENET
-int board_eth_init(bd_t *bis)
-{
-       struct fsl_pq_mdio_info mdio_info;
-       struct tsec_info_struct tsec_info[4];
-       int num = 0;
-
-#ifdef CONFIG_TSEC1
-       SET_STD_TSEC_INFO(tsec_info[num], 1);
-       num++;
-#endif
-#ifdef CONFIG_TSEC2
-       SET_STD_TSEC_INFO(tsec_info[num], 2);
-       if (is_serdes_configured(SGMII_TSEC2)) {
-               puts("eTSEC2 is in sgmii mode.\n");
-               tsec_info[num].flags |= TSEC_SGMII;
-       }
-       num++;
-#endif
-#ifdef CONFIG_TSEC3
-       SET_STD_TSEC_INFO(tsec_info[num], 3);
-       if (is_serdes_configured(SGMII_TSEC3)) {
-               puts("eTSEC3 is in sgmii mode.\n");
-               tsec_info[num].flags |= TSEC_SGMII;
-}
-       num++;
-#endif
-
-       if (!num) {
-               printf("No TSECs initialized\n");
-
-               return 0;
-       }
-
-#ifdef CONFIG_FSL_SGMII_RISER
-       fsl_sgmii_riser_init(tsec_info, num);
-#endif
-
-       mdio_info.regs = (struct tsec_mii_mng *)CONFIG_SYS_MDIO_BASE_ADDR;
-       mdio_info.name = DEFAULT_MII_NAME;
-
-       fsl_pq_mdio_init(bis, &mdio_info);
-
-       tsec_eth_init(bis, tsec_info, num);
-
-       return pci_eth_init(bis);
-}
-#endif
-
-#if defined(CONFIG_OF_BOARD_SETUP)
-int ft_board_setup(void *blob, bd_t *bd)
-{
-       phys_addr_t base;
-       phys_size_t size;
-
-       ft_cpu_setup(blob, bd);
-
-       base = getenv_bootm_low();
-       size = getenv_bootm_size();
-
-       fdt_fixup_memory(blob, (u64)base, (u64)size);
-
-#ifdef CONFIG_HAS_FSL_DR_USB
-       fdt_fixup_dr_usb(blob, bd);
-#endif
-
-       FT_FSL_PCI_SETUP;
-
-#ifdef CONFIG_FSL_SGMII_RISER
-       fsl_sgmii_riser_fdt_fixup(blob);
-#endif
-
-       return 0;
-}
-#endif
diff --git a/board/freescale/p2020ds/tlb.c b/board/freescale/p2020ds/tlb.c
deleted file mode 100644 (file)
index 02da6e8..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright 2008-2011 Freescale Semiconductor, Inc.
- *
- * (C) Copyright 2000
- * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#include <common.h>
-#include <asm/mmu.h>
-
-struct fsl_e_tlb_entry tlb_table[] = {
-       /* TLB 0 - for temp stack in cache */
-       SET_TLB_ENTRY(0, CONFIG_SYS_INIT_RAM_ADDR, CONFIG_SYS_INIT_RAM_ADDR_PHYS,
-                     MAS3_SX|MAS3_SW|MAS3_SR, 0,
-                     0, 0, BOOKE_PAGESZ_4K, 0),
-       SET_TLB_ENTRY(0, CONFIG_SYS_INIT_RAM_ADDR + 4 * 1024,
-                     CONFIG_SYS_INIT_RAM_ADDR_PHYS + 4 * 1024,
-                     MAS3_SX|MAS3_SW|MAS3_SR, 0,
-                     0, 0, BOOKE_PAGESZ_4K, 0),
-       SET_TLB_ENTRY(0, CONFIG_SYS_INIT_RAM_ADDR + 8 * 1024,
-                     CONFIG_SYS_INIT_RAM_ADDR_PHYS + 8 * 1024,
-                     MAS3_SX|MAS3_SW|MAS3_SR, 0,
-                     0, 0, BOOKE_PAGESZ_4K, 0),
-       SET_TLB_ENTRY(0, CONFIG_SYS_INIT_RAM_ADDR + 12 * 1024,
-                     CONFIG_SYS_INIT_RAM_ADDR_PHYS + 12 * 1024,
-                     MAS3_SX|MAS3_SW|MAS3_SR, 0,
-                     0, 0, BOOKE_PAGESZ_4K, 0),
-
-       /* TLB 1 */
-       /* *I*** - Covers boot page */
-       SET_TLB_ENTRY(1, 0xfffff000, 0xfffff000,
-                     MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
-                     0, 0, BOOKE_PAGESZ_4K, 1),
-
-       /* *I*G* - CCSRBAR */
-       SET_TLB_ENTRY(1, CONFIG_SYS_CCSRBAR, CONFIG_SYS_CCSRBAR_PHYS,
-                     MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
-                     0, 1, BOOKE_PAGESZ_1M, 1),
-
-       /* W**G* - Flash/promjet, localbus */
-       /* This will be changed to *I*G* after relocation to RAM. */
-       SET_TLB_ENTRY(1, CONFIG_SYS_FLASH_BASE, CONFIG_SYS_FLASH_BASE_PHYS,
-                     MAS3_SX|MAS3_SR, MAS2_W|MAS2_G,
-                     0, 2, BOOKE_PAGESZ_256M, 1),
-
-       /* *I*G* - PCI */
-       SET_TLB_ENTRY(1, CONFIG_SYS_PCIE3_MEM_VIRT, CONFIG_SYS_PCIE3_MEM_PHYS,
-                     MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
-                     0, 3, BOOKE_PAGESZ_1G, 1),
-
-       /* *I*G* - PCI */
-       SET_TLB_ENTRY(1, CONFIG_SYS_PCIE3_MEM_VIRT + 0x40000000,
-                     CONFIG_SYS_PCIE3_MEM_PHYS + 0x40000000,
-                     MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
-                     0, 4, BOOKE_PAGESZ_256M, 1),
-
-       SET_TLB_ENTRY(1, CONFIG_SYS_PCIE3_MEM_VIRT + 0x50000000,
-                     CONFIG_SYS_PCIE3_MEM_PHYS + 0x50000000,
-                     MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
-                     0, 5, BOOKE_PAGESZ_256M, 1),
-
-       /* *I*G* - PCI I/O */
-       SET_TLB_ENTRY(1, CONFIG_SYS_PCIE3_IO_VIRT, CONFIG_SYS_PCIE3_IO_PHYS,
-                     MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
-                     0, 6, BOOKE_PAGESZ_256K, 1),
-
-       /* *I*G - NAND */
-       SET_TLB_ENTRY(1, CONFIG_SYS_NAND_BASE, CONFIG_SYS_NAND_BASE_PHYS,
-                     MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
-                     0, 7, BOOKE_PAGESZ_1M, 1),
-
-       SET_TLB_ENTRY(1, PIXIS_BASE, PIXIS_BASE_PHYS,
-                     MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
-                     0, 8, BOOKE_PAGESZ_4K, 1),
-
-#if defined(CONFIG_SYS_RAMBOOT) && defined(CONFIG_SYS_INIT_L2_ADDR)
-       /* *I*G - L2SRAM */
-       SET_TLB_ENTRY(1, CONFIG_SYS_INIT_L2_ADDR, CONFIG_SYS_INIT_L2_ADDR_PHYS,
-                     MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
-                     0, 9, BOOKE_PAGESZ_256K, 1),
-       SET_TLB_ENTRY(1, CONFIG_SYS_INIT_L2_ADDR + 0x40000,
-                     CONFIG_SYS_INIT_L2_ADDR_PHYS + 0x40000,
-                     MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
-                     0, 10, BOOKE_PAGESZ_256K, 1),
-#endif
-};
-
-int num_tlb_entries = ARRAY_SIZE(tlb_table);
index 46fc64e5280343e36a09c07d4f13fd98ee987d35..2d4d10f351a1082a8eabc47ce19fc132e6314829 100644 (file)
@@ -11,6 +11,7 @@
 #include <fsl_ddr_sdram.h>
 #include <fsl_ddr_dimm_params.h>
 #include <asm/fsl_law.h>
+#include <asm/mpc85xx_gpio.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -152,6 +153,19 @@ found:
 #endif
 }
 
+#if defined(CONFIG_DEEP_SLEEP)
+void board_mem_sleep_setup(void)
+{
+       void __iomem *qixis_base = (void *)QIXIS_BASE;
+
+       /* does not provide HW signals for power management */
+       clrbits_8(qixis_base + 0x21, 0x2);
+       /* Disable MCKE isolation */
+       gpio_set_value(2, 0);
+       udelay(1);
+}
+#endif
+
 phys_size_t initdram(int board_type)
 {
        phys_size_t dram_size;
@@ -166,5 +180,10 @@ phys_size_t initdram(int board_type)
        /* DDR has been initialised by first stage boot loader */
        dram_size =  fsl_ddr_sdram_size();
 #endif
+
+#if defined(CONFIG_DEEP_SLEEP) && !defined(CONFIG_SPL_BUILD)
+       fsl_dp_resume();
+#endif
+
        return dram_size;
 }
index f3141b58e8d05f9a7726c317236dfbcdc9345709..708afcaebfacb4cb22ae214027e264fcb4b4c15d 100644 (file)
 #include <asm/fsl_liodn.h>
 #include <fm_eth.h>
 #include <hwconfig.h>
-#include <asm/mpc85xx_gpio.h>
 #include "../common/qixis.h"
 #include "t102xqds.h"
 #include "t102xqds_qixis.h"
+#include "../common/sleep.h"
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -242,6 +242,16 @@ void board_retimer_ds125df111_init(void)
        i2c_write(I2C_RETIMER_ADDR, 0x64, 1, &reg, 1);
 }
 
+int board_early_init_f(void)
+{
+#if defined(CONFIG_DEEP_SLEEP)
+       if (is_warm_boot())
+               fsl_dp_disable_console();
+#endif
+
+       return 0;
+}
+
 int board_early_init_r(void)
 {
 #ifdef CONFIG_SYS_FLASH_BASE
@@ -395,14 +405,3 @@ void qixis_dump_switch(void)
                printf("SW%d = (0x%02x)\n", i, QIXIS_READ(cms[1]));
        }
 }
-
-#ifdef CONFIG_DEEP_SLEEP
-void board_mem_sleep_setup(void)
-{
-       /* does not provide HW signals for power management */
-       QIXIS_WRITE(pwr_ctl[1], (QIXIS_READ(pwr_ctl[1]) & ~0x2));
-       /* Disable MCKE isolation */
-       gpio_set_value(2, 0);
-       udelay(1);
-}
-#endif
index 5a3100f6070e29babc627cafe332861b4763f68c..db50f818fbb6606aebfd2f5e692906b448195ca7 100644 (file)
@@ -43,3 +43,7 @@ void cpld_write(unsigned int reg, u8 value);
 #define CPLD_LBMAP_RESET       0xFF
 #define CPLD_LBMAP_SHIFT       0x03
 #define CPLD_BOOT_SEL     0x80
+
+#define CPLD_PCIE_SGMII_MUX    0x80
+#define CPLD_OVERRIDE_BOOT_EN  0x01
+#define CPLD_OVERRIDE_MUX_EN   0x02 /* PCIE/2.5G-SGMII mux override enable */
index a20330b1d013c21a9dca54f3f9987c59b9c41372..a2a8f4ccf0417f9932ebdbe38ea87e160e2dfe5b 100644 (file)
@@ -11,6 +11,7 @@
 #include <fsl_ddr_sdram.h>
 #include <fsl_ddr_dimm_params.h>
 #include <asm/fsl_law.h>
+#include <asm/mpc85xx_gpio.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -136,6 +137,19 @@ found:
 #endif
 }
 
+#if defined(CONFIG_DEEP_SLEEP)
+void board_mem_sleep_setup(void)
+{
+       void __iomem *cpld_base = (void *)CONFIG_SYS_CPLD_BASE;
+
+       /* does not provide HW signals for power management */
+       clrbits_8(cpld_base + 0x17, 0x40);
+       /* Disable MCKE isolation */
+       gpio_set_value(2, 0);
+       udelay(1);
+}
+#endif
+
 phys_size_t initdram(int board_type)
 {
        phys_size_t dram_size;
@@ -150,5 +164,10 @@ phys_size_t initdram(int board_type)
        /* DDR has been initialised by first stage boot loader */
        dram_size =  fsl_ddr_sdram_size();
 #endif
+
+#if defined(CONFIG_DEEP_SLEEP) && !defined(CONFIG_SPL_BUILD)
+       fsl_dp_resume();
+#endif
+
        return dram_size;
 }
index 2e400c4ebf1e12f3dfc04a6c33e942f7d5d34c3a..f611ff07e98cb8858995f5d67c10257ea6b44c2b 100644 (file)
@@ -21,6 +21,7 @@
 #include <phy.h>
 #include <asm/fsl_dtsec.h>
 #include <asm/fsl_serdes.h>
+#include "../common/fman.h"
 
 int board_eth_init(bd_t *bis)
 {
@@ -51,15 +52,22 @@ int board_eth_init(bd_t *bis)
        /* Register the 10G MDIO bus */
        fm_memac_mdio_init(bis, &tgec_mdio_info);
 
-       /* Set the two on-board RGMII PHY address */
-       fm_info_set_phy_address(FM1_DTSEC3, RGMII_PHY2_ADDR);
+       /* Set the on-board RGMII PHY address */
        fm_info_set_phy_address(FM1_DTSEC4, RGMII_PHY1_ADDR);
 
        switch (srds_s1) {
        case 0x95:
-               /* 10G XFI with Aquantia PHY */
+               /* set the on-board RGMII2  PHY */
+               fm_info_set_phy_address(FM1_DTSEC3, RGMII_PHY2_ADDR);
+
+               /* set 10G XFI with Aquantia AQR105 PHY */
                fm_info_set_phy_address(FM1_10GEC1, FM1_10GEC1_PHY_ADDR);
                break;
+       case 0x77:
+       case 0x135:
+               /* set the on-board 2.5G SGMII AQR105 PHY */
+               fm_info_set_phy_address(FM1_DTSEC3, SGMII_PHY1_ADDR);
+               break;
        default:
                printf("SerDes protocol 0x%x is not supported on T102xRDB\n",
                       srds_s1);
@@ -73,6 +81,10 @@ int board_eth_init(bd_t *bis)
                        dev = miiphy_get_dev_by_name(DEFAULT_FM_MDIO_NAME);
                        fm_info_set_mdio(i, dev);
                        break;
+               case PHY_INTERFACE_MODE_SGMII_2500:
+                       dev = miiphy_get_dev_by_name(DEFAULT_FM_TGEC_MDIO_NAME);
+                       fm_info_set_mdio(i, dev);
+                       break;
                default:
                        break;
                }
@@ -95,6 +107,18 @@ int board_eth_init(bd_t *bis)
        return pci_eth_init(bis);
 }
 
+void board_ft_fman_fixup_port(void *fdt, char *compat, phys_addr_t addr,
+                             enum fm_port port, int offset)
+{
+       if ((fm_info_get_enet_if(port) == PHY_INTERFACE_MODE_SGMII_2500) &&
+           (port == FM1_DTSEC3)) {
+               fdt_set_phy_handle(fdt, compat, addr, "sg_2500_aqr105_phy4");
+               fdt_setprop(fdt, offset, "phy-connection-type",
+                           "sgmii-2500", 10);
+               fdt_status_disabled_by_alias(fdt, "xg_aqr105_phy3");
+       }
+}
+
 void fdt_fixup_board_enet(void *fdt)
 {
 }
index dd2dec4412101948b00cad99ea9efbea0b6fc829..1a3a996439646ef53e932b3139fe532abea9c0fc 100644 (file)
@@ -11,6 +11,7 @@
 #include <mmc.h>
 #include <fsl_esdhc.h>
 #include <spi_flash.h>
+#include "../common/sleep.h"
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -42,6 +43,12 @@ void board_init_f(ulong bootflag)
 
        console_init_f();
 
+#ifdef CONFIG_DEEP_SLEEP
+       /* disable the console if boot from deep sleep */
+       if (is_warm_boot())
+               fsl_dp_disable_console();
+#endif
+
        /* initialize selected port with appropriate baud rate */
        sys_clk = get_board_sys_clk();
        plat_ratio = (in_be32(&gur->rcwsr[0]) >> 25) & 0x1f;
index f5c438ded3b0aafb5171e257121d3eb204c7a7c9..e196f12ac7a16844a3633a9691b40b24dc79eb0a 100644 (file)
 #include <asm/fsl_serdes.h>
 #include <asm/fsl_portals.h>
 #include <asm/fsl_liodn.h>
-#include <asm/mpc85xx_gpio.h>
 #include <fm_eth.h>
 #include "t102xrdb.h"
 #include "cpld.h"
+#include "../common/sleep.h"
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -27,6 +27,11 @@ int checkboard(void)
 {
        struct cpu_type *cpu = gd->arch.cpu;
        static const char *freq[3] = {"100.00MHZ", "125.00MHz", "156.25MHZ"};
+       ccsr_gur_t __iomem *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
+       u32 srds_s1;
+
+       srds_s1 = in_be32(&gur->rcwsr[4]) & FSL_CORENET2_RCWSR4_SRDS1_PRTCL;
+       srds_s1 >>= FSL_CORENET2_RCWSR4_SRDS1_PRTCL_SHIFT;
 
        printf("Board: %sRDB, ", cpu->name);
        printf("Board rev: 0x%02x CPLD ver: 0x%02x, boot from ",
@@ -50,7 +55,40 @@ int checkboard(void)
 #endif
 
        puts("SERDES Reference Clocks:\n");
-       printf("SD1_CLK1=%s, SD1_CLK2=%s\n", freq[2], freq[0]);
+       if (srds_s1 == 0x95)
+               printf("SD1_CLK1=%s, SD1_CLK2=%s\n", freq[2], freq[0]);
+       else
+               printf("SD1_CLK1=%s, SD1_CLK2=%s\n", freq[0], freq[0]);
+
+       return 0;
+}
+
+static void board_mux_lane(void)
+{
+       ccsr_gur_t __iomem *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
+       u32 srds_prtcl_s1;
+       u8 reg = CPLD_READ(misc_ctl_status);
+
+       srds_prtcl_s1 = in_be32(&gur->rcwsr[4]) &
+                               FSL_CORENET2_RCWSR4_SRDS1_PRTCL;
+       srds_prtcl_s1 >>= FSL_CORENET2_RCWSR4_SRDS1_PRTCL_SHIFT;
+
+       if (srds_prtcl_s1 == 0x95) {
+               /* Route Lane B to PCIE */
+               CPLD_WRITE(misc_ctl_status, reg & ~CPLD_PCIE_SGMII_MUX);
+       } else {
+               /* Route Lane B to SGMII */
+               CPLD_WRITE(misc_ctl_status, reg | CPLD_PCIE_SGMII_MUX);
+       }
+       CPLD_WRITE(boot_override, CPLD_OVERRIDE_MUX_EN);
+}
+
+int board_early_init_f(void)
+{
+#if defined(CONFIG_DEEP_SLEEP)
+       if (is_warm_boot())
+               fsl_dp_disable_console();
+#endif
 
        return 0;
 }
@@ -86,6 +124,7 @@ int board_early_init_r(void)
 #ifdef CONFIG_SYS_DPAA_QBMAN
        setup_portals();
 #endif
+       board_mux_lane();
 
        return 0;
 }
@@ -131,14 +170,3 @@ int ft_board_setup(void *blob, bd_t *bd)
 
        return 0;
 }
-
-#ifdef CONFIG_DEEP_SLEEP
-void board_mem_sleep_setup(void)
-{
-       /* does not provide HW signals for power management */
-       CPLD_WRITE(misc_ctl_status, (CPLD_READ(misc_ctl_status) & ~0x40));
-       /* Disable MCKE isolation */
-       gpio_set_value(2, 0);
-       udelay(1);
-}
-#endif
index 43f952f9c03b4e8fc21d5854adf5e48a510993a7..82402408a74b7090326854bd7872704f2cb7b8db 100644 (file)
@@ -11,6 +11,7 @@
 #include <fsl_ddr_sdram.h>
 #include <fsl_ddr_dimm_params.h>
 #include <asm/fsl_law.h>
+#include <asm/mpc85xx_gpio.h>
 #include "ddr.h"
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -100,6 +101,19 @@ found:
 #endif
 }
 
+#if defined(CONFIG_DEEP_SLEEP)
+void board_mem_sleep_setup(void)
+{
+       void __iomem *qixis_base = (void *)QIXIS_BASE;
+
+       /* does not provide HW signals for power management */
+       clrbits_8(qixis_base + 0x21, 0x2);
+       /* Disable MCKE isolation */
+       gpio_set_value(2, 0);
+       udelay(1);
+}
+#endif
+
 phys_size_t initdram(int board_type)
 {
        phys_size_t dram_size;
@@ -112,5 +126,10 @@ phys_size_t initdram(int board_type)
        dram_size *= 0x100000;
 
        puts("    DDR: ");
+
+#if defined(CONFIG_DEEP_SLEEP) && !defined(CONFIG_SPL_BUILD)
+       fsl_dp_resume();
+#endif
+
        return dram_size;
 }
index 06d908658dad62098a8e39602d3d2d6cffbd6fe0..8c8293426bb622428bca78ffbd2e7c885f1afc2e 100644 (file)
@@ -18,6 +18,7 @@
 #include <fsl_mdio.h>
 #include <malloc.h>
 #include <asm/fsl_dtsec.h>
+#include <vsc9953.h>
 
 #include "../common/fman.h"
 #include "../common/qixis.h"
@@ -216,6 +217,7 @@ static void initialize_lane_to_slot(void)
                lane_to_slot[1] = 7;
                lane_to_slot[2] = 7;
                lane_to_slot[3] = 7;
+               lane_to_slot[6] = 7;
                lane_to_slot[7] = 7;
                break;
        case 0x8d:
@@ -438,6 +440,12 @@ int board_eth_init(bd_t *bis)
 #ifdef CONFIG_FMAN_ENET
        struct memac_mdio_info memac_mdio_info;
        unsigned int i;
+#ifdef CONFIG_VSC9953
+       int lane;
+       int phy_addr;
+       phy_interface_t phy_int;
+       struct mii_dev *bus;
+#endif
 
        printf("Initializing Fman\n");
        set_brdcfg9_for_gtx_clk();
@@ -477,6 +485,7 @@ int board_eth_init(bd_t *bis)
        for (i = FM1_DTSEC1; i < FM1_DTSEC1 + CONFIG_SYS_NUM_FM1_DTSEC; i++) {
                switch (fm_info_get_enet_if(i)) {
                case PHY_INTERFACE_MODE_QSGMII:
+                       fm_info_set_mdio(i, NULL);
                        break;
                case PHY_INTERFACE_MODE_SGMII:
                        t1040_handle_phy_interface_sgmii(i);
@@ -491,6 +500,90 @@ int board_eth_init(bd_t *bis)
                }
        }
 
+#ifdef CONFIG_VSC9953
+       for (i = 0; i < VSC9953_MAX_PORTS; i++) {
+               lane = -1;
+               phy_addr = 0;
+               phy_int = PHY_INTERFACE_MODE_NONE;
+               switch (i) {
+               case 0:
+               case 1:
+               case 2:
+               case 3:
+                       lane = serdes_get_first_lane(FSL_SRDS_1, QSGMII_SW1_A);
+                       /* PHYs connected over QSGMII */
+                       if (lane >= 0) {
+                               phy_addr = CONFIG_SYS_FM1_QSGMII21_PHY_ADDR +
+                                               i;
+                               phy_int = PHY_INTERFACE_MODE_QSGMII;
+                               break;
+                       }
+                       lane = serdes_get_first_lane(FSL_SRDS_1,
+                                       SGMII_SW1_MAC1 + i);
+
+                       if (lane < 0)
+                               break;
+
+                       /* PHYs connected over QSGMII */
+                       if (i != 3 || lane_to_slot[lane] == 7)
+                               phy_addr = CONFIG_SYS_FM1_DTSEC1_RISER_PHY_ADDR
+                                       + i;
+                       else
+                               phy_addr = CONFIG_SYS_FM1_DTSEC1_RISER_PHY_ADDR;
+                       phy_int = PHY_INTERFACE_MODE_SGMII;
+                       break;
+               case 4:
+               case 5:
+               case 6:
+               case 7:
+                       lane = serdes_get_first_lane(FSL_SRDS_1, QSGMII_SW1_B);
+                       /* PHYs connected over QSGMII */
+                       if (lane >= 0) {
+                               phy_addr = CONFIG_SYS_FM1_QSGMII11_PHY_ADDR +
+                                               i - 4;
+                               phy_int = PHY_INTERFACE_MODE_QSGMII;
+                               break;
+                       }
+                       lane = serdes_get_first_lane(FSL_SRDS_1,
+                                       SGMII_SW1_MAC1 + i);
+                       /* PHYs connected over SGMII */
+                       if (lane >= 0) {
+                               phy_addr = CONFIG_SYS_FM1_DTSEC1_RISER_PHY_ADDR
+                                               + i - 3;
+                               phy_int = PHY_INTERFACE_MODE_SGMII;
+                       }
+                       break;
+               case 8:
+                       if (serdes_get_first_lane(FSL_SRDS_1,
+                                                 SGMII_FM1_DTSEC1) < 0)
+                               /* FM1@DTSEC1 is connected to SW1@PORT8 */
+                               vsc9953_port_enable(i);
+                       break;
+               case 9:
+                       if (serdes_get_first_lane(FSL_SRDS_1,
+                                                 SGMII_FM1_DTSEC2) < 0) {
+                               /* Enable L2 On MAC2 using SCFG */
+                               struct ccsr_scfg *scfg = (struct ccsr_scfg *)
+                                               CONFIG_SYS_MPC85xx_SCFG;
+
+                               out_be32(&scfg->esgmiiselcr,
+                                        in_be32(&scfg->esgmiiselcr) |
+                                        (0x80000000));
+                               vsc9953_port_enable(i);
+                       }
+                       break;
+               }
+
+               if (lane >= 0) {
+                       bus = mii_dev_for_muxval(lane_to_slot[lane]);
+                       vsc9953_port_info_set_mdio(i, bus);
+                       vsc9953_port_enable(i);
+               }
+               vsc9953_port_info_set_phy_address(i, phy_addr);
+               vsc9953_port_info_set_phy_int(i, phy_int);
+       }
+
+#endif
        cpu_eth_init(bis);
 #endif
 
index 13285be42cf394a3b711e24a79cf8df969319286..eaca57fc5dfe05efd65b49de70d6e51edf0cfff6 100644 (file)
@@ -19,8 +19,8 @@
 #include <asm/fsl_liodn.h>
 #include <fm_eth.h>
 #include <hwconfig.h>
-#include <asm/mpc85xx_gpio.h>
 
+#include "../common/sleep.h"
 #include "../common/qixis.h"
 #include "t1040qds.h"
 #include "t1040qds_qixis.h"
@@ -115,6 +115,16 @@ static void qe_board_setup(void)
        }
 }
 
+int board_early_init_f(void)
+{
+#if defined(CONFIG_DEEP_SLEEP)
+       if (is_warm_boot())
+               fsl_dp_disable_console();
+#endif
+
+       return 0;
+}
+
 int board_early_init_r(void)
 {
 #ifdef CONFIG_SYS_FLASH_BASE
@@ -281,14 +291,3 @@ int board_need_mem_reset(void)
 {
        return 1;
 }
-
-#ifdef CONFIG_DEEP_SLEEP
-void board_mem_sleep_setup(void)
-{
-       /* does not provide HW signals for power management */
-       QIXIS_WRITE(pwr_ctl[1], (QIXIS_READ(pwr_ctl[1]) & ~0x2));
-       /* Disable MCKE isolation */
-       gpio_set_value(2, 0);
-       udelay(1);
-}
-#endif
index b61e1c025404d673f9c6e0056055868225b66635..13d9be9da8f808096cc76db409c856360e1d752c 100644 (file)
@@ -21,3 +21,4 @@ T1040RDB_SECURE_BOOT BOARD
 M:     Aneesh Bansal  <aneesh.bansal@freescale.com>
 S:     Maintained
 F:     configs/T1040RDB_SECURE_BOOT_defconfig
+F:     configs/T1042RDB_SECURE_BOOT_defconfig
index c8b6c672a683a2e5b19213e792a575e621003457..7581a4cdd44b95a685720a3c052064116742ba7b 100644 (file)
@@ -6,11 +6,13 @@
 
 #include <common.h>
 #include <netdev.h>
+#include <asm/fsl_serdes.h>
 #include <asm/immap_85xx.h>
 #include <fm_eth.h>
 #include <fsl_mdio.h>
 #include <malloc.h>
 #include <asm/fsl_dtsec.h>
+#include <vsc9953.h>
 
 #include "../common/fman.h"
 
@@ -20,6 +22,11 @@ int board_eth_init(bd_t *bis)
        struct memac_mdio_info memac_mdio_info;
        unsigned int i;
        int phy_addr = 0;
+#ifdef CONFIG_VSC9953
+       phy_interface_t phy_int;
+       struct mii_dev *bus;
+#endif
+
        printf("Initializing Fman\n");
 
        memac_mdio_info.regs =
@@ -72,10 +79,58 @@ int board_eth_init(bd_t *bis)
                        fm_info_set_phy_address(i, 0);
                        break;
                }
-               fm_info_set_mdio(i,
-                                miiphy_get_dev_by_name(DEFAULT_FM_MDIO_NAME));
+               if (fm_info_get_enet_if(i) == PHY_INTERFACE_MODE_QSGMII ||
+                   fm_info_get_enet_if(i) == PHY_INTERFACE_MODE_NONE)
+                       fm_info_set_mdio(i, NULL);
+               else
+                       fm_info_set_mdio(i,
+                                        miiphy_get_dev_by_name(
+                                                       DEFAULT_FM_MDIO_NAME));
+       }
+
+#ifdef CONFIG_VSC9953
+       /* SerDes configured for QSGMII */
+       if (serdes_get_first_lane(FSL_SRDS_1, QSGMII_SW1_A) >= 0) {
+               for (i = 0; i < 4; i++) {
+                       bus = miiphy_get_dev_by_name(DEFAULT_FM_MDIO_NAME);
+                       phy_addr = CONFIG_SYS_FM1_QSGMII11_PHY_ADDR + i;
+                       phy_int = PHY_INTERFACE_MODE_QSGMII;
+
+                       vsc9953_port_info_set_mdio(i, bus);
+                       vsc9953_port_info_set_phy_address(i, phy_addr);
+                       vsc9953_port_info_set_phy_int(i, phy_int);
+                       vsc9953_port_enable(i);
+               }
+       }
+       if (serdes_get_first_lane(FSL_SRDS_1, QSGMII_SW1_B) >= 0) {
+               for (i = 4; i < 8; i++) {
+                       bus = miiphy_get_dev_by_name(DEFAULT_FM_MDIO_NAME);
+                       phy_addr = CONFIG_SYS_FM1_QSGMII21_PHY_ADDR + i - 4;
+                       phy_int = PHY_INTERFACE_MODE_QSGMII;
+
+                       vsc9953_port_info_set_mdio(i, bus);
+                       vsc9953_port_info_set_phy_address(i, phy_addr);
+                       vsc9953_port_info_set_phy_int(i, phy_int);
+                       vsc9953_port_enable(i);
+               }
        }
 
+       /* Connect DTSEC1 to L2 switch if it doesn't have a PHY */
+       if (serdes_get_first_lane(FSL_SRDS_1, SGMII_FM1_DTSEC1) < 0)
+               vsc9953_port_enable(8);
+
+       /* Connect DTSEC2 to L2 switch if it doesn't have a PHY */
+       if (serdes_get_first_lane(FSL_SRDS_1, SGMII_FM1_DTSEC2) < 0) {
+               /* Enable L2 On MAC2 using SCFG */
+               struct ccsr_scfg *scfg = (struct ccsr_scfg *)
+                               CONFIG_SYS_MPC85xx_SCFG;
+
+               out_be32(&scfg->esgmiiselcr, in_be32(&scfg->esgmiiselcr) |
+                        (0x80000000));
+               vsc9953_port_enable(9);
+       }
+#endif
+
        cpu_eth_init(bis);
 #endif
 
index 142c6a877bb641545fe2e8cfff81d425c4285101..879bd1a347b55697f34919d379bd446b6b79d77f 100644 (file)
@@ -101,7 +101,7 @@ int board_eth_init(bd_t *bis)
        }
 
 #if (CONFIG_SYS_NUM_FMAN == 2)
-       if (srds_prtcl_s2 == 56) {
+       if ((srds_prtcl_s2 == 56) || (srds_prtcl_s2 == 55)) {
                /* SGMII && XFI */
                fm_info_set_phy_address(FM2_DTSEC1, SGMII_PHY_ADDR5);
                fm_info_set_phy_address(FM2_DTSEC2, SGMII_PHY_ADDR6);
index fdbbe5ef6593b25b43b068bedf7f2b01d3a662bf..e46c7b25a55c0098530410ba649c43aabd957c62 100644 (file)
@@ -1,7 +1,7 @@
 #PBL preamble and RCW header
 aa55aa55 010e0100
-#serdes protocol  27_56_1_9
+#serdes protocol  27_55_1_9
 16070019 18101916 00000000 00000000
-6c700848 00448c00 6c020000 f5000000
+6c6e0848 00448c00 6c020000 f5000000
 00000000 ee0000ee 00000000 000287fc
 00000000 50000000 00000000 00000028
diff --git a/board/icecube/Kconfig b/board/icecube/Kconfig
deleted file mode 100644 (file)
index e5b2153..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-if TARGET_ICECUBE
-
-config SYS_BOARD
-       default "icecube"
-
-config SYS_CONFIG_NAME
-       default "IceCube"
-
-endif
diff --git a/board/icecube/MAINTAINERS b/board/icecube/MAINTAINERS
deleted file mode 100644 (file)
index 8a24eb4..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-ICECUBE BOARD
-M:     Wolfgang Denk <wd@denx.de>
-S:     Maintained
-F:     board/icecube/
-F:     include/configs/IceCube.h
-F:     configs/icecube_5200_defconfig
-
-ICECUBE_5200_DDR BOARD
-#M:    -
-S:     Maintained
-F:     configs/icecube_5200_DDR_defconfig
-F:     configs/icecube_5200_DDR_LOWBOOT_defconfig
-F:     configs/icecube_5200_DDR_LOWBOOT08_defconfig
-F:     configs/icecube_5200_LOWBOOT_defconfig
-F:     configs/icecube_5200_LOWBOOT08_defconfig
-F:     configs/Lite5200_defconfig
-F:     configs/Lite5200_LOWBOOT_defconfig
-F:     configs/Lite5200_LOWBOOT08_defconfig
-F:     configs/lite5200b_defconfig
-F:     configs/lite5200b_LOWBOOT_defconfig
-F:     configs/lite5200b_PM_defconfig
diff --git a/board/icecube/Makefile b/board/icecube/Makefile
deleted file mode 100644 (file)
index c3c2cd1..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-#
-# (C) Copyright 2003-2006
-# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
-#
-# SPDX-License-Identifier:     GPL-2.0+
-#
-
-obj-y  := icecube.o flash.o
diff --git a/board/icecube/README b/board/icecube/README
deleted file mode 100644 (file)
index 5252bc9..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
----------------------------------------------------------------------------
-Build target                Flash address | BDI "go" command | Reset Vector
----------------------------------------------------------------------------
-Lite5200                     0xFFF00000   |    0xFFF00100    |   0xFFF00100
-Lite5200_LOWBOOT             0xFF000000   |    0xFF000100    |   0x00000100
-Lite5200_LOWBOOT08           0xFF800000   |    0xFF800100    |   0x00000100
-icecube_5200                 0xFFF00000   |    0xFFF00100    |   0xFFF00100
-icecube_5200_LOWBOOT         0xFF000000   |    0xFF000100    |   0x00000100
-icecube_5200_LOWBOOT08       0xFF800000   |    0xFF800100    |   0x00000100
-icecube_5200_DDR             0xFFF00000   |    0xFFF00100    |   0xFFF00100
-icecube_5200_DDR_LOWBOOT     0xFF800000   |    0xFF800100    |   0x00000100
-icecube_5200_DDR_LOWBOOT08   0xFF800000   |    0xFF800100    |   0x00000100
----------------------------------------------------------------------------
diff --git a/board/icecube/README.Lite5200B_low_power b/board/icecube/README.Lite5200B_low_power
deleted file mode 100644 (file)
index 5b04fbb..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-Lite5200B wakeup from low-power mode (CONFIG_LITE5200B_PM)
-----------------------------------------------------------
-
-Low-power mode as described in Lite5200B User's Manual, means that
-with support of MC68HLC908QT1 microcontroller (refered to as QT),
-everything but the SDRAM can be powered down. This brings
-maximum power saving, while one can still restore previous state
-quickly.
-
-Quick overview where U-Boot comes into the picture:
-- OS saves device states
-- OS saves wakeup handler address to physical 0x0, puts SDRAM into
-  self-refresh and signals to QT, it should power down the board
-- / board is sleeping here /
-- someone presses SW4 (connected to QT)
-- U-Boot checks PSC2_4 pin, if QT drives it down, then we woke up,
-  so get SDRAM out of self-refresh and transfer control to OS
-  wakeup handler
-- OS restores device states
-
-This was tested on Linux with USB and Ethernet in use. Adding
-support for other devices is an OS issue.
diff --git a/board/icecube/flash.c b/board/icecube/flash.c
deleted file mode 100644 (file)
index a044e8f..0000000
+++ /dev/null
@@ -1,477 +0,0 @@
-/*
- * (C) Copyright 2003
- * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#include <common.h>
-
-#ifndef CONFIG_FLASH_CFI_DRIVER
-flash_info_t   flash_info[CONFIG_SYS_MAX_FLASH_BANKS]; /* info for FLASH chips */
-
-/* NOTE - CONFIG_FLASH_16BIT means the CPU interface is 16-bit, it
- *        has nothing to do with the flash chip being 8-bit or 16-bit.
- */
-#ifdef CONFIG_FLASH_16BIT
-typedef unsigned short FLASH_PORT_WIDTH;
-typedef volatile unsigned short FLASH_PORT_WIDTHV;
-#define        FLASH_ID_MASK   0xFFFF
-#else
-typedef unsigned char FLASH_PORT_WIDTH;
-typedef volatile unsigned char FLASH_PORT_WIDTHV;
-#define        FLASH_ID_MASK   0xFF
-#endif
-
-#define FPW    FLASH_PORT_WIDTH
-#define FPWV   FLASH_PORT_WIDTHV
-
-#define ORMASK(size) ((-size) & OR_AM_MSK)
-
-#define FLASH_CYCLE1   0x0555
-#define FLASH_CYCLE2   0x02aa
-
-/*-----------------------------------------------------------------------
- * Functions
- */
-static ulong flash_get_size(FPWV *addr, flash_info_t *info);
-static void flash_reset(flash_info_t *info);
-static int write_word_amd(flash_info_t *info, FPWV *dest, FPW data);
-static flash_info_t *flash_get_info(ulong base);
-
-/*-----------------------------------------------------------------------
- * flash_init()
- *
- * sets up flash_info and returns size of FLASH (bytes)
- */
-unsigned long flash_init (void)
-{
-       unsigned long size = 0;
-       int i;
-       extern void flash_preinit(void);
-       extern void flash_afterinit(ulong);
-       ulong flashbase = CONFIG_SYS_FLASH_BASE;
-
-       flash_preinit();
-
-       /* Init: no FLASHes known */
-       for (i=0; i < CONFIG_SYS_MAX_FLASH_BANKS; ++i) {
-               memset(&flash_info[i], 0, sizeof(flash_info_t));
-
-               flash_info[i].size =
-                       flash_get_size((FPW *)flashbase, &flash_info[i]);
-
-               size += flash_info[i].size;
-               flashbase += 0x800000;
-       }
-#if CONFIG_SYS_MONITOR_BASE >= CONFIG_SYS_FLASH_BASE
-       /* monitor protection ON by default */
-       flash_protect(FLAG_PROTECT_SET,
-                     CONFIG_SYS_MONITOR_BASE,
-                     CONFIG_SYS_MONITOR_BASE+monitor_flash_len-1,
-                     flash_get_info(CONFIG_SYS_MONITOR_BASE));
-#endif
-
-#ifdef CONFIG_ENV_IS_IN_FLASH
-       /* ENV protection ON by default */
-       flash_protect(FLAG_PROTECT_SET,
-                     CONFIG_ENV_ADDR,
-                     CONFIG_ENV_ADDR+CONFIG_ENV_SIZE-1,
-                     flash_get_info(CONFIG_ENV_ADDR));
-#endif
-
-
-       flash_afterinit(size);
-       return size ? size : 1;
-}
-
-/*-----------------------------------------------------------------------
- */
-static void flash_reset(flash_info_t *info)
-{
-       FPWV *base = (FPWV *)(info->start[0]);
-
-       /* Put FLASH back in read mode */
-       if ((info->flash_id & FLASH_VENDMASK) == FLASH_MAN_INTEL)
-               *base = (FPW)0x00FF00FF;        /* Intel Read Mode */
-       else if ((info->flash_id & FLASH_VENDMASK) == FLASH_MAN_AMD)
-               *base = (FPW)0x00F000F0;        /* AMD Read Mode */
-}
-
-/*-----------------------------------------------------------------------
- */
-
-static flash_info_t *flash_get_info(ulong base)
-{
-       int i;
-       flash_info_t * info;
-
-       for (i = 0; i < CONFIG_SYS_MAX_FLASH_BANKS; i ++) {
-               info = & flash_info[i];
-               if (info->size &&
-                       info->start[0] <= base && base <= info->start[0] + info->size - 1)
-                       break;
-       }
-
-       return i == CONFIG_SYS_MAX_FLASH_BANKS ? 0 : info;
-}
-
-/*-----------------------------------------------------------------------
- */
-
-void flash_print_info (flash_info_t *info)
-{
-       int i;
-       uchar *boottype;
-       uchar *bootletter;
-       char *fmt;
-       uchar botbootletter[] = "B";
-       uchar topbootletter[] = "T";
-       uchar botboottype[] = "bottom boot sector";
-       uchar topboottype[] = "top boot sector";
-
-       if (info->flash_id == FLASH_UNKNOWN) {
-               printf ("missing or unknown FLASH type\n");
-               return;
-       }
-
-       switch (info->flash_id & FLASH_VENDMASK) {
-       case FLASH_MAN_AMD:     printf ("AMD ");                break;
-       case FLASH_MAN_BM:      printf ("BRIGHT MICRO ");       break;
-       case FLASH_MAN_FUJ:     printf ("FUJITSU ");            break;
-       case FLASH_MAN_SST:     printf ("SST ");                break;
-       case FLASH_MAN_STM:     printf ("STM ");                break;
-       case FLASH_MAN_INTEL:   printf ("INTEL ");              break;
-       default:                printf ("Unknown Vendor ");     break;
-       }
-
-       /* check for top or bottom boot, if it applies */
-       if (info->flash_id & FLASH_BTYPE) {
-               boottype = botboottype;
-               bootletter = botbootletter;
-       }
-       else {
-               boottype = topboottype;
-               bootletter = topbootletter;
-       }
-
-       switch (info->flash_id & FLASH_TYPEMASK) {
-       case FLASH_AMDLV065D:
-               fmt = "29LV065 (64 Mbit, uniform sectors)\n";
-               break;
-       default:
-               fmt = "Unknown Chip Type\n";
-               break;
-       }
-
-       printf (fmt, bootletter, boottype);
-
-       printf ("  Size: %ld MB in %d Sectors\n",
-               info->size >> 20,
-               info->sector_count);
-
-       printf ("  Sector Start Addresses:");
-
-       for (i=0; i<info->sector_count; ++i) {
-               if ((i % 5) == 0) {
-                       printf ("\n   ");
-               }
-
-               printf (" %08lX%s", info->start[i],
-                       info->protect[i] ? " (RO)" : "     ");
-       }
-
-       printf ("\n");
-}
-
-/*-----------------------------------------------------------------------
- */
-
-/*
- * The following code cannot be run from FLASH!
- */
-
-ulong flash_get_size (FPWV *addr, flash_info_t *info)
-{
-       int i;
-       FPWV* addr2;
-
-       /* Write auto select command: read Manufacturer ID */
-       /* Write auto select command sequence and test FLASH answer */
-       addr[FLASH_CYCLE1] = (FPW)0x00AA00AA;   /* for AMD, Intel ignores this */
-       addr[FLASH_CYCLE2] = (FPW)0x00550055;   /* for AMD, Intel ignores this */
-       addr[FLASH_CYCLE1] = (FPW)0x00900090;   /* selects Intel or AMD */
-
-       /* The manufacturer codes are only 1 byte, so just use 1 byte.
-        * This works for any bus width and any FLASH device width.
-        */
-       udelay(100);
-       switch (addr[0] & 0xff) {
-
-       case (uchar)AMD_MANUFACT:
-               info->flash_id = FLASH_MAN_AMD;
-               break;
-
-       case (uchar)INTEL_MANUFACT:
-               info->flash_id = FLASH_MAN_INTEL;
-               break;
-
-       default:
-               info->flash_id = FLASH_UNKNOWN;
-               info->sector_count = 0;
-               info->size = 0;
-               break;
-       }
-
-       /* Check 16 bits or 32 bits of ID so work on 32 or 16 bit bus. */
-       if (info->flash_id != FLASH_UNKNOWN) switch ((FPW)addr[1]) {
-
-       case (FPW)AMD_ID_LV065D:
-               info->flash_id += FLASH_AMDLV065D;
-               info->sector_count = 128;
-               info->size = 0x00800000;
-               for( i = 0; i < info->sector_count; i++ )
-                       info->start[i] = (ulong)addr + (i * 0x10000);
-               break;                          /* => 8 or 16 MB        */
-
-       default:
-               info->flash_id = FLASH_UNKNOWN;
-               info->sector_count = 0;
-               info->size = 0;
-               return (0);                     /* => no or unknown flash */
-       }
-
-       /* test for real flash at bank 1 */
-       addr2 = (FPW *)((ulong)addr | 0x800000);
-       if (addr2 != addr &&
-               ((addr2[0] & 0xff) == (addr[0] & 0xff)) && ((FPW)addr2[1] == (FPW)addr[1])) {
-               /* Seems 2 banks are the same space (8Mb chip is installed,
-                * J24 in default position (CS0)). Disable this (first) bank.
-                */
-               info->flash_id = FLASH_UNKNOWN;
-               info->sector_count = 0;
-               info->size = 0;
-       }
-       /* Put FLASH back in read mode */
-       flash_reset(info);
-
-       return (info->size);
-}
-
-/*-----------------------------------------------------------------------
- */
-
-int    flash_erase (flash_info_t *info, int s_first, int s_last)
-{
-       FPWV *addr;
-       int flag, prot, sect;
-       int intel = (info->flash_id & FLASH_VENDMASK) == FLASH_MAN_INTEL;
-       ulong start, now, last;
-       int rcode = 0;
-
-       if ((s_first < 0) || (s_first > s_last)) {
-               if (info->flash_id == FLASH_UNKNOWN) {
-                       printf ("- missing\n");
-               } else {
-                       printf ("- no sectors to erase\n");
-               }
-               return 1;
-       }
-
-       switch (info->flash_id & FLASH_TYPEMASK) {
-       case FLASH_AMDLV065D:
-               break;
-       case FLASH_UNKNOWN:
-       default:
-               printf ("Can't erase unknown flash type %08lx - aborted\n",
-                       info->flash_id);
-               return 1;
-       }
-
-       prot = 0;
-       for (sect=s_first; sect<=s_last; ++sect) {
-               if (info->protect[sect]) {
-                       prot++;
-               }
-       }
-
-       if (prot) {
-               printf ("- Warning: %d protected sectors will not be erased!\n",
-                       prot);
-       } else {
-               printf ("\n");
-       }
-
-       last  = get_timer(0);
-
-       /* Start erase on unprotected sectors */
-       for (sect = s_first; sect<=s_last && rcode == 0; sect++) {
-
-               if (info->protect[sect] != 0)   /* protected, skip it */
-                       continue;
-
-               /* Disable interrupts which might cause a timeout here */
-               flag = disable_interrupts();
-
-               addr = (FPWV *)(info->start[sect]);
-               if (intel) {
-                       *addr = (FPW)0x00500050; /* clear status register */
-                       *addr = (FPW)0x00200020; /* erase setup */
-                       *addr = (FPW)0x00D000D0; /* erase confirm */
-               }
-               else {
-                       /* must be AMD style if not Intel */
-                       FPWV *base;             /* first address in bank */
-
-                       base = (FPWV *)(info->start[0]);
-                       base[FLASH_CYCLE1] = (FPW)0x00AA00AA;   /* unlock */
-                       base[FLASH_CYCLE2] = (FPW)0x00550055;   /* unlock */
-                       base[FLASH_CYCLE1] = (FPW)0x00800080;   /* erase mode */
-                       base[FLASH_CYCLE1] = (FPW)0x00AA00AA;   /* unlock */
-                       base[FLASH_CYCLE2] = (FPW)0x00550055;   /* unlock */
-                       *addr = (FPW)0x00300030;        /* erase sector */
-               }
-
-               /* re-enable interrupts if necessary */
-               if (flag)
-                       enable_interrupts();
-
-               start = get_timer(0);
-
-               /* wait at least 50us for AMD, 80us for Intel.
-                * Let's wait 1 ms.
-                */
-               udelay (1000);
-
-               while ((*addr & (FPW)0x00800080) != (FPW)0x00800080) {
-                       if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) {
-                               printf ("Timeout\n");
-
-                               if (intel) {
-                                       /* suspend erase        */
-                                       *addr = (FPW)0x00B000B0;
-                               }
-
-                               flash_reset(info);      /* reset to read mode */
-                               rcode = 1;              /* failed */
-                               break;
-                       }
-
-                       /* show that we're waiting */
-                       if ((get_timer(last)) > CONFIG_SYS_HZ) {/* every second */
-                               putc ('.');
-                               last = get_timer(0);
-                       }
-               }
-
-               /* show that we're waiting */
-               if ((get_timer(last)) > CONFIG_SYS_HZ) {        /* every second */
-                       putc ('.');
-                       last = get_timer(0);
-               }
-
-               flash_reset(info);      /* reset to read mode   */
-       }
-
-       printf (" done\n");
-       return rcode;
-}
-
-/*-----------------------------------------------------------------------
- * Copy memory to flash, returns:
- * 0 - OK
- * 1 - write timeout
- * 2 - Flash not erased
- */
-int write_buff (flash_info_t *info, uchar *src, ulong addr, ulong cnt)
-{
-       FPW data = 0; /* 16 or 32 bit word, matches flash bus width on MPC8XX */
-       int bytes;        /* number of bytes to program in current word         */
-       int left;         /* number of bytes left to program                    */
-       int i, res;
-
-       for (left = cnt, res = 0;
-                left > 0 && res == 0;
-                addr += sizeof(data), left -= sizeof(data) - bytes) {
-
-               bytes = addr & (sizeof(data) - 1);
-               addr &= ~(sizeof(data) - 1);
-
-               /* combine source and destination data so can program
-                * an entire word of 16 or 32 bits
-                */
-               for (i = 0; i < sizeof(data); i++) {
-                       data <<= 8;
-                       if (i < bytes || i - bytes >= left )
-                               data += *((uchar *)addr + i);
-                       else
-                               data += *src++;
-               }
-
-               /* write one word to the flash */
-               switch (info->flash_id & FLASH_VENDMASK) {
-               case FLASH_MAN_AMD:
-                       res = write_word_amd(info, (FPWV *)addr, data);
-                       break;
-               default:
-                       /* unknown flash type, error! */
-                       printf ("missing or unknown FLASH type\n");
-                       res = 1;        /* not really a timeout, but gives error */
-                       break;
-               }
-       }
-
-       return (res);
-}
-
-/*-----------------------------------------------------------------------
- * Write a word to Flash for AMD FLASH
- * A word is 16 or 32 bits, whichever the bus width of the flash bank
- * (not an individual chip) is.
- *
- * returns:
- * 0 - OK
- * 1 - write timeout
- * 2 - Flash not erased
- */
-static int write_word_amd (flash_info_t *info, FPWV *dest, FPW data)
-{
-       ulong start;
-       int flag;
-       int res = 0;    /* result, assume success       */
-       FPWV *base;             /* first address in flash bank  */
-
-       /* Check if Flash is (sufficiently) erased */
-       if ((*dest & data) != data) {
-               return (2);
-       }
-
-
-       base = (FPWV *)(info->start[0]);
-
-       /* Disable interrupts which might cause a timeout here */
-       flag = disable_interrupts();
-
-       base[FLASH_CYCLE1] = (FPW)0x00AA00AA;   /* unlock */
-       base[FLASH_CYCLE2] = (FPW)0x00550055;   /* unlock */
-       base[FLASH_CYCLE1] = (FPW)0x00A000A0;   /* selects program mode */
-
-       *dest = data;           /* start programming the data   */
-
-       /* re-enable interrupts if necessary */
-       if (flag)
-               enable_interrupts();
-
-       start = get_timer (0);
-
-       /* data polling for D7 */
-       while (res == 0 && (*dest & (FPW)0x00800080) != (data & (FPW)0x00800080)) {
-               if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) {
-                       *dest = (FPW)0x00F000F0;        /* reset bank */
-                       res = 1;
-               }
-       }
-
-       return (res);
-}
-#endif /*CONFIG_FLASH_CFI_DRIVER*/
diff --git a/board/icecube/icecube.c b/board/icecube/icecube.c
deleted file mode 100644 (file)
index f0af24a..0000000
+++ /dev/null
@@ -1,326 +0,0 @@
-/*
- * (C) Copyright 2003
- * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
- *
- * (C) Copyright 2004
- * Mark Jonas, Freescale Semiconductor, mark.jonas@motorola.com.
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#include <common.h>
-#include <mpc5xxx.h>
-#include <pci.h>
-#include <asm/processor.h>
-#include <libfdt.h>
-#include <netdev.h>
-
-#if defined(CONFIG_LITE5200B)
-#include "mt46v32m16.h"
-#else
-# if defined(CONFIG_MPC5200_DDR)
-#  include "mt46v16m16-75.h"
-# else
-#include "mt48lc16m16a2-75.h"
-# endif
-#endif
-
-#ifdef CONFIG_LITE5200B_PM
-/* u-boot part of low-power mode implementation */
-#define SAVED_ADDR (*(void **)0x00000000)
-#define PSC2_4 0x02
-
-void lite5200b_wakeup(void)
-{
-       unsigned char wakeup_pin;
-       void (*linux_wakeup)(void);
-
-       /* check PSC2_4, if it's down "QT" is signaling we have a wakeup
-        * from low power mode */
-       *(vu_char *)MPC5XXX_WU_GPIO_ENABLE = PSC2_4;
-       __asm__ volatile ("sync");
-
-       wakeup_pin = *(vu_char *)MPC5XXX_WU_GPIO_DATA_I;
-       if (wakeup_pin & PSC2_4)
-               return;
-
-       /* acknowledge to "QT"
-        * by holding pin at 1 for 10 uS */
-       *(vu_char *)MPC5XXX_WU_GPIO_DIR = PSC2_4;
-       __asm__ volatile ("sync");
-       *(vu_char *)MPC5XXX_WU_GPIO_DATA_O = PSC2_4;
-       __asm__ volatile ("sync");
-       udelay(10);
-
-       /* put ram out of self-refresh */
-       *(vu_long *)MPC5XXX_SDRAM_CTRL |= 0x80000000;   /* mode_en */
-       __asm__ volatile ("sync");
-       *(vu_long *)MPC5XXX_SDRAM_CTRL |= 0x50000000;   /* cke ref_en */
-       __asm__ volatile ("sync");
-       *(vu_long *)MPC5XXX_SDRAM_CTRL &= ~0x80000000;  /* !mode_en */
-       __asm__ volatile ("sync");
-       udelay(10); /* wait a bit */
-
-       /* jump back to linux kernel code */
-       linux_wakeup = SAVED_ADDR;
-       printf("\n\nLooks like we just woke, transferring control to 0x%08lx\n",
-                       (unsigned long)linux_wakeup);
-       linux_wakeup();
-}
-#else
-#define lite5200b_wakeup()
-#endif
-
-#ifndef CONFIG_SYS_RAMBOOT
-static void sdram_start (int hi_addr)
-{
-       long hi_addr_bit = hi_addr ? 0x01000000 : 0;
-
-       /* unlock mode register */
-       *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000000 | hi_addr_bit;
-       __asm__ volatile ("sync");
-
-       /* precharge all banks */
-       *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000002 | hi_addr_bit;
-       __asm__ volatile ("sync");
-
-#if SDRAM_DDR
-       /* set mode register: extended mode */
-       *(vu_long *)MPC5XXX_SDRAM_MODE = SDRAM_EMODE;
-       __asm__ volatile ("sync");
-
-       /* set mode register: reset DLL */
-       *(vu_long *)MPC5XXX_SDRAM_MODE = SDRAM_MODE | 0x04000000;
-       __asm__ volatile ("sync");
-#endif
-
-       /* precharge all banks */
-       *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000002 | hi_addr_bit;
-       __asm__ volatile ("sync");
-
-       /* auto refresh */
-       *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000004 | hi_addr_bit;
-       __asm__ volatile ("sync");
-
-       /* set mode register */
-       *(vu_long *)MPC5XXX_SDRAM_MODE = SDRAM_MODE;
-       __asm__ volatile ("sync");
-
-       /* normal operation */
-       *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | hi_addr_bit;
-       __asm__ volatile ("sync");
-}
-#endif
-
-/*
- * ATTENTION: Although partially referenced initdram does NOT make real use
- *            use of CONFIG_SYS_SDRAM_BASE. The code does not work if CONFIG_SYS_SDRAM_BASE
- *            is something else than 0x00000000.
- */
-
-phys_size_t initdram (int board_type)
-{
-       ulong dramsize = 0;
-       ulong dramsize2 = 0;
-       uint svr, pvr;
-
-#ifndef CONFIG_SYS_RAMBOOT
-       ulong test1, test2;
-
-       /* setup SDRAM chip selects */
-       *(vu_long *)MPC5XXX_SDRAM_CS0CFG = 0x0000001e;/* 2G at 0x0 */
-       *(vu_long *)MPC5XXX_SDRAM_CS1CFG = 0x80000000;/* disabled */
-       __asm__ volatile ("sync");
-
-       /* setup config registers */
-       *(vu_long *)MPC5XXX_SDRAM_CONFIG1 = SDRAM_CONFIG1;
-       *(vu_long *)MPC5XXX_SDRAM_CONFIG2 = SDRAM_CONFIG2;
-       __asm__ volatile ("sync");
-
-#if SDRAM_DDR
-       /* set tap delay */
-       *(vu_long *)MPC5XXX_CDM_PORCFG = SDRAM_TAPDELAY;
-       __asm__ volatile ("sync");
-#endif
-
-       /* find RAM size using SDRAM CS0 only */
-       sdram_start(0);
-       test1 = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
-       sdram_start(1);
-       test2 = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
-       if (test1 > test2) {
-               sdram_start(0);
-               dramsize = test1;
-       } else {
-               dramsize = test2;
-       }
-
-       /* memory smaller than 1MB is impossible */
-       if (dramsize < (1 << 20)) {
-               dramsize = 0;
-       }
-
-       /* set SDRAM CS0 size according to the amount of RAM found */
-       if (dramsize > 0) {
-               *(vu_long *)MPC5XXX_SDRAM_CS0CFG = 0x13 + __builtin_ffs(dramsize >> 20) - 1;
-       } else {
-               *(vu_long *)MPC5XXX_SDRAM_CS0CFG = 0; /* disabled */
-       }
-
-       /* let SDRAM CS1 start right after CS0 */
-       *(vu_long *)MPC5XXX_SDRAM_CS1CFG = dramsize + 0x0000001e;/* 2G */
-
-       /* find RAM size using SDRAM CS1 only */
-       if (!dramsize)
-               sdram_start(0);
-       test2 = test1 = get_ram_size((long *)(CONFIG_SYS_SDRAM_BASE + dramsize), 0x80000000);
-       if (!dramsize) {
-               sdram_start(1);
-               test2 = get_ram_size((long *)(CONFIG_SYS_SDRAM_BASE + dramsize), 0x80000000);
-       }
-       if (test1 > test2) {
-               sdram_start(0);
-               dramsize2 = test1;
-       } else {
-               dramsize2 = test2;
-       }
-
-       /* memory smaller than 1MB is impossible */
-       if (dramsize2 < (1 << 20)) {
-               dramsize2 = 0;
-       }
-
-       /* set SDRAM CS1 size according to the amount of RAM found */
-       if (dramsize2 > 0) {
-               *(vu_long *)MPC5XXX_SDRAM_CS1CFG = dramsize
-                       | (0x13 + __builtin_ffs(dramsize2 >> 20) - 1);
-       } else {
-               *(vu_long *)MPC5XXX_SDRAM_CS1CFG = dramsize; /* disabled */
-       }
-
-#else /* CONFIG_SYS_RAMBOOT */
-
-       /* retrieve size of memory connected to SDRAM CS0 */
-       dramsize = *(vu_long *)MPC5XXX_SDRAM_CS0CFG & 0xFF;
-       if (dramsize >= 0x13) {
-               dramsize = (1 << (dramsize - 0x13)) << 20;
-       } else {
-               dramsize = 0;
-       }
-
-       /* retrieve size of memory connected to SDRAM CS1 */
-       dramsize2 = *(vu_long *)MPC5XXX_SDRAM_CS1CFG & 0xFF;
-       if (dramsize2 >= 0x13) {
-               dramsize2 = (1 << (dramsize2 - 0x13)) << 20;
-       } else {
-               dramsize2 = 0;
-       }
-
-#endif /* CONFIG_SYS_RAMBOOT */
-
-       /*
-        * On MPC5200B we need to set the special configuration delay in the
-        * DDR controller. Please refer to Freescale's AN3221 "MPC5200B SDRAM
-        * Initialization and Configuration", 3.3.1 SDelay--MBAR + 0x0190:
-        *
-        * "The SDelay should be written to a value of 0x00000004. It is
-        * required to account for changes caused by normal wafer processing
-        * parameters."
-        */
-       svr = get_svr();
-       pvr = get_pvr();
-       if ((SVR_MJREV(svr) >= 2) &&
-           (PVR_MAJ(pvr) == 1) && (PVR_MIN(pvr) == 4)) {
-
-               *(vu_long *)MPC5XXX_SDRAM_SDELAY = 0x04;
-               __asm__ volatile ("sync");
-       }
-
-       lite5200b_wakeup();
-
-       return dramsize + dramsize2;
-}
-
-int checkboard (void)
-{
-#if defined (CONFIG_LITE5200B)
-       puts ("Board: Freescale Lite5200B\n");
-#else
-       puts ("Board: Motorola MPC5200 (IceCube)\n");
-#endif
-       return 0;
-}
-
-void flash_preinit(void)
-{
-       /*
-        * Now, when we are in RAM, enable flash write
-        * access for detection process.
-        * Note that CS_BOOT cannot be cleared when
-        * executing in flash.
-        */
-       *(vu_long *)MPC5XXX_BOOTCS_CFG &= ~0x1; /* clear RO */
-}
-
-void flash_afterinit(ulong size)
-{
-       if (size == 0x800000) { /* adjust mapping */
-               *(vu_long *)MPC5XXX_BOOTCS_START = *(vu_long *)MPC5XXX_CS0_START =
-                       START_REG(CONFIG_SYS_BOOTCS_START | size);
-               *(vu_long *)MPC5XXX_BOOTCS_STOP = *(vu_long *)MPC5XXX_CS0_STOP =
-                       STOP_REG(CONFIG_SYS_BOOTCS_START | size, size);
-       }
-}
-
-#ifdef CONFIG_PCI
-static struct pci_controller hose;
-
-extern void pci_mpc5xxx_init(struct pci_controller *);
-
-void pci_init_board(void)
-{
-       pci_mpc5xxx_init(&hose);
-}
-#endif
-
-#if defined(CONFIG_CMD_IDE) && defined(CONFIG_IDE_RESET)
-
-void init_ide_reset (void)
-{
-       debug ("init_ide_reset\n");
-
-       /* Configure PSC1_4 as GPIO output for ATA reset */
-       *(vu_long *) MPC5XXX_WU_GPIO_ENABLE |= GPIO_PSC1_4;
-       *(vu_long *) MPC5XXX_WU_GPIO_DIR    |= GPIO_PSC1_4;
-       /* Deassert reset */
-       *(vu_long *) MPC5XXX_WU_GPIO_DATA_O   |= GPIO_PSC1_4;
-}
-
-void ide_set_reset (int idereset)
-{
-       debug ("ide_reset(%d)\n", idereset);
-
-       if (idereset) {
-               *(vu_long *) MPC5XXX_WU_GPIO_DATA_O &= ~GPIO_PSC1_4;
-               /* Make a delay. MPC5200 spec says 25 usec min */
-               udelay(500000);
-       } else {
-               *(vu_long *) MPC5XXX_WU_GPIO_DATA_O |=  GPIO_PSC1_4;
-       }
-}
-#endif
-
-#if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
-int ft_board_setup(void *blob, bd_t *bd)
-{
-       ft_cpu_setup(blob, bd);
-
-       return 0;
-}
-#endif
-
-int board_eth_init(bd_t *bis)
-{
-       cpu_eth_init(bis); /* Built in FEC comes first */
-       return pci_eth_init(bis);
-}
diff --git a/board/icecube/mt46v16m16-75.h b/board/icecube/mt46v16m16-75.h
deleted file mode 100644 (file)
index 919876f..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * (C) Copyright 2004
- * Mark Jonas, Freescale Semiconductor, mark.jonas@motorola.com.
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#define SDRAM_DDR      1               /* is DDR */
-
-/* Settings for XLB = 132 MHz */
-#define SDRAM_MODE     0x018D0000
-#define SDRAM_EMODE    0x40090000
-#define SDRAM_CONTROL  0x705f0f00
-#define SDRAM_CONFIG1  0x73722930
-#define SDRAM_CONFIG2  0x47770000
-#define SDRAM_TAPDELAY 0x10000000
diff --git a/board/icecube/mt46v32m16.h b/board/icecube/mt46v32m16.h
deleted file mode 100644 (file)
index a200bc7..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * (C) Copyright 2004
- * Mark Jonas, Freescale Semiconductor, mark.jonas@motorola.com.
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#define SDRAM_DDR      1               /* is DDR */
-
-/* Settings for XLB = 132 MHz */
-#define SDRAM_MODE     0x018D0000
-#define SDRAM_EMODE    0x40090000
-#define SDRAM_CONTROL  0x704f0f00
-#define SDRAM_CONFIG1  0x73722930
-#define SDRAM_CONFIG2  0x47770000
-#define SDRAM_TAPDELAY 0x10000000
diff --git a/board/icecube/mt48lc16m16a2-75.h b/board/icecube/mt48lc16m16a2-75.h
deleted file mode 100644 (file)
index 0133eaa..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-/*
- * (C) Copyright 2004
- * Mark Jonas, Freescale Semiconductor, mark.jonas@motorola.com.
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#define SDRAM_DDR      0               /* is SDR */
-
-/* Settings for XLB = 132 MHz */
-#define SDRAM_MODE     0x00CD0000
-#define SDRAM_CONTROL  0x504F0000
-#define SDRAM_CONFIG1  0xD2322800
-#define SDRAM_CONFIG2  0x8AD70000
index 78c4bd4efe7114767e9c52ef07a42c6fe8c1460c..79562f79a80c6f93acb134e3a9d342957a3807c8 100644 (file)
@@ -6,6 +6,7 @@
  */
 
 #include <common.h>
+#include <ide.h>
 #include <netdev.h>
 #include <pci.h>
 #include <pci_gt64120.h>
@@ -123,6 +124,7 @@ void _machine_restart(void)
 
        reset_base = (void __iomem *)CKSEG1ADDR(MALTA_RESET_BASE);
        __raw_writel(GORESET, reset_base);
+       mdelay(1000);
 }
 
 int board_early_init_f(void)
@@ -217,4 +219,22 @@ void pci_init_board(void)
        pci_read_config_byte(bdf, PCI_CFG_PIIX4_SERIRQC, &val8);
        val8 |= PCI_CFG_PIIX4_SERIRQC_EN | PCI_CFG_PIIX4_SERIRQC_CONT;
        pci_write_config_byte(bdf, PCI_CFG_PIIX4_SERIRQC, val8);
+
+       bdf = pci_find_device(PCI_VENDOR_ID_INTEL,
+                             PCI_DEVICE_ID_INTEL_82371AB, 0);
+       if (bdf == -1)
+               panic("Failed to find PIIX4 IDE controller\n");
+
+       /* enable bus master & IO access */
+       val32 |= PCI_COMMAND_MASTER | PCI_COMMAND_IO;
+       pci_write_config_dword(bdf, PCI_COMMAND, val32);
+
+       /* set latency */
+       pci_write_config_byte(bdf, PCI_LATENCY_TIMER, 0x40);
+
+       /* enable IDE/ATA */
+       pci_write_config_dword(bdf, PCI_CFG_PIIX4_IDETIM_PRI,
+                              PCI_CFG_PIIX4_IDETIM_IDE);
+       pci_write_config_dword(bdf, PCI_CFG_PIIX4_IDETIM_SEC,
+                              PCI_CFG_PIIX4_IDETIM_IDE);
 }
index 3c63a03d3f4659327ff72ac22ea283e23c234102..f4260fa5043c3bd96bfde2b81ca8ad17dd512644 100644 (file)
@@ -20,7 +20,7 @@ NAND_PAGE_SIZE        0x0800
 # Configure RGMII-0 interface pad voltage to 1.8V
 DATA 0xffd100e0 0x1b1b1b9b
 
-#Dram initalization for SINGLE x16 CL=5 @ 400MHz
+# Dram initalization for SINGLE x16 CL=5 @ 400MHz
 DATA 0xffd01400 0x43000c30     # DDR Configuration register
 # bit13-0:  0xc30, (3120 DDR2 clks refresh rate)
 # bit23-14: 0x0,
@@ -87,7 +87,7 @@ DATA 0xffd0141c 0x00000c52    # DDR Mode
 # bit6-4:   0x4, CL=5
 # bit7:     0x0, TestMode=0 normal
 # bit8:     0x0, DLL reset=0 normal
-# bit11-9:  0x6, auto-precharge write recovery ????????????
+# bit11-9:  0x6, auto-precharge write recovery
 # bit12:    0x0, PD must be zero
 # bit31-13: 0x0, required
 
index 47522f8013e219f66b0d5e2021b24cd6cf656d43..693fce741a0791b3329794b17dbe8da4839c47f1 100644 (file)
@@ -5,6 +5,7 @@
  * SPDX-License-Identifier:    GPL-2.0+
  */
 #include <common.h>
+#include <status_led.h>
 #include <dm.h>
 #include <ns16550.h>
 #include <twl4030.h>
@@ -53,21 +54,12 @@ int board_init(void)
        /* boot param addr */
        gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
 
-       return 0;
-}
-
-#if defined(CONFIG_SHOW_BOOT_PROGRESS) && !defined(CONFIG_SPL_BUILD)
-void show_boot_progress(int val)
-{
-       if (val < 0) {
-               /* something went wrong */
-               return;
-       }
+#if defined(CONFIG_STATUS_LED) && defined(STATUS_LED_BOOT)
+       status_led_set(STATUS_LED_BOOT, STATUS_LED_ON);
+#endif
 
-       if (!gpio_request(IGEP00X0_GPIO_LED, ""))
-               gpio_direction_output(IGEP00X0_GPIO_LED, 1);
+       return 0;
 }
-#endif
 
 #ifdef CONFIG_SPL_BUILD
 /*
index 181f81f2a1c2a88059a59d6f20de093a26934b45..3c7ff9b1488a25ed2bec2fea417a1fdf57e45687 100644 (file)
@@ -7,14 +7,6 @@
 #ifndef _IGEP00X0_H_
 #define _IGEP00X0_H_
 
-#if (CONFIG_MACH_TYPE == MACH_TYPE_IGEP0020)
-#define IGEP00X0_GPIO_LED 27
-#endif
-
-#if (CONFIG_MACH_TYPE == MACH_TYPE_IGEP0030)
-#define IGEP00X0_GPIO_LED 16
-#endif
-
 const omap3_sysinfo sysinfo = {
        DDR_STACKED,
 #if (CONFIG_MACH_TYPE == MACH_TYPE_IGEP0020)
diff --git a/board/maxbcm/binary.0 b/board/maxbcm/binary.0
deleted file mode 100644 (file)
index 17bfad9..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
---------
-WARNING:
---------
-This file should contain the bin_hdr generated by the original Marvell
-U-Boot implementation. As this is currently not included in this
-U-Boot version, we have added this placeholder, so that the U-Boot
-image can be generated without errors.
-
-If you have a known to be working bin_hdr for your board, then you
-just need to replace this text file here with the binary header
-and recompile U-Boot.
-
-In a few weeks, mainline U-Boot will get support to generate the
-bin_hdr with the DDR training code itself. By implementing this code
-as SPL U-Boot. Then this file will not be needed any more and will
-get removed.
-
index 5a3bc67c1c8fae78a063cda5dba3786434063fb2..cc057925566c584d66b0dc73207f5a62523ad2f6 100644 (file)
@@ -9,4 +9,4 @@ VERSION         1
 BOOT_FROM      spi
 
 # Binary Header (bin_hdr) with DDR3 training code
-BINARY board/maxbcm/binary.0 0000005b 00000068
+BINARY spl/u-boot-spl.bin 0000005b 00000068
index 7fc83ee8205d2a5a00ed86aaf8d02b9032365fd2..46b16ac29ccc843aaeeb85c42818d1638aaff9df 100644 (file)
@@ -11,6 +11,9 @@
 #include <asm/arch/soc.h>
 #include <linux/mbus.h>
 
+#include "../drivers/ddr/mvebu/ddr3_hw_training.h"
+#include "../arch/arm/mvebu-common/serdes/high_speed_env_spec.h"
+
 DECLARE_GLOBAL_DATA_PTR;
 
 /* Base addresses for the external device chip selects */
@@ -19,8 +22,84 @@ DECLARE_GLOBAL_DATA_PTR;
 #define DEV_CS2_BASE           0xe2000000
 #define DEV_CS3_BASE           0xe3000000
 
-/* Needed for dynamic (board-specific) mbus configuration */
-extern struct mvebu_mbus_state mbus_state;
+/* DDR3 static configuration */
+MV_DRAM_MC_INIT ddr3_b0_maxbcm[MV_MAX_DDR3_STATIC_SIZE] = {
+       {0x00001400, 0x7301CC30},       /* DDR SDRAM Configuration Register */
+       {0x00001404, 0x30000820},       /* Dunit Control Low Register */
+       {0x00001408, 0x5515BAAB},       /* DDR SDRAM Timing (Low) Register */
+       {0x0000140C, 0x38DA3F97},       /* DDR SDRAM Timing (High) Register */
+       {0x00001410, 0x20100005},       /* DDR SDRAM Address Control Register */
+       {0x00001414, 0x0000F3FF},       /* DDR SDRAM Open Pages Control Reg */
+       {0x00001418, 0x00000e00},       /* DDR SDRAM Operation Register */
+       {0x0000141C, 0x00000672},       /* DDR SDRAM Mode Register */
+       {0x00001420, 0x00000004},       /* DDR SDRAM Extended Mode Register */
+       {0x00001424, 0x0000F3FF},       /* Dunit Control High Register */
+       {0x00001428, 0x0011A940},       /* Dunit Control High Register */
+       {0x0000142C, 0x014C5134},       /* Dunit Control High Register */
+       {0x0000147C, 0x0000D771},
+
+       {0x00001494, 0x00010000},       /* DDR SDRAM ODT Control (Low) Reg */
+       {0x0000149C, 0x00000001},       /* DDR Dunit ODT Control Register */
+       {0x000014A0, 0x00000001},
+       {0x000014A8, 0x00000101},
+
+       /* Recommended Settings from Marvell for 4 x 16 bit devices: */
+       {0x000014C0, 0x192424C9},       /* DRAM addr and Ctrl Driving Strenght*/
+       {0x000014C4, 0xAAA24C9},        /* DRAM Data and DQS Driving Strenght */
+
+       /*
+        * DO NOT Modify - Open Mbus Window - 2G - Mbus is required for the
+        * training sequence
+        */
+       {0x000200e8, 0x3FFF0E01},
+       {0x00020184, 0x3FFFFFE0},       /* Close fast path Window to - 2G */
+
+       {0x0001504, 0x3FFFFFE1},        /* CS0 Size */
+       {0x000150C, 0x00000000},        /* CS1 Size */
+       {0x0001514, 0x00000000},        /* CS2 Size */
+       {0x000151C, 0x00000000},        /* CS3 Size */
+
+       {0x0020220, 0x00000007},        /* Reserved */
+
+       {0x00001538, 0x0000000B},       /* Read Data Sample Delays Register */
+       {0x0000153C, 0x0000000B},       /* Read Data Ready Delay Register */
+
+       {0x000015D0, 0x00000670},       /* MR0 */
+       {0x000015D4, 0x00000044},       /* MR1 */
+       {0x000015D8, 0x00000018},       /* MR2 */
+       {0x000015DC, 0x00000000},       /* MR3 */
+       {0x000015E0, 0x00000001},
+       {0x000015E4, 0x00203c18},       /* ZQDS Configuration Register */
+       {0x000015EC, 0xF800A225},       /* DDR PHY */
+
+       {0x0, 0x0}
+};
+
+MV_DRAM_MODES maxbcm_ddr_modes[MV_DDR3_MODES_NUMBER] = {
+       {"maxbcm_1600-800", 0xB, 0x5, 0x0, A0, ddr3_b0_maxbcm,  NULL},
+};
+
+extern MV_SERDES_CHANGE_M_PHY serdes_change_m_phy[];
+
+/* MAXBCM: SERDES 0-4 PCIE, Serdes 7 = SGMII 0, all others =  unconnected */
+MV_BIN_SERDES_CFG maxbcm_serdes_cfg[] = {
+       { MV_PEX_ROOT_COMPLEX, 0x20011111, 0x00000000,
+         { PEX_BUS_MODE_X1, PEX_BUS_MODE_X1, PEX_BUS_DISABLED,
+           PEX_BUS_DISABLED },
+         0x1f, serdes_change_m_phy
+       }
+};
+
+MV_DRAM_MODES *ddr3_get_static_ddr_mode(void)
+{
+       /* Only one mode supported for this board */
+       return &maxbcm_ddr_modes[0];
+}
+
+MV_BIN_SERDES_CFG *board_serdes_cfg_get(u8 pex_mode)
+{
+       return &maxbcm_serdes_cfg[0];
+}
 
 int board_early_init_f(void)
 {
@@ -63,9 +142,7 @@ int checkboard(void)
 /* Configure and enable MV88E6185 switch */
 void reset_phy(void)
 {
-       u16 devadr = CONFIG_PHY_BASE_ADDR;
        char *name = "neta0";
-       u16 reg;
 
        if (miiphy_set_current_dev(name))
                return;
index 95c4ff25092b7272860d1770c25d239ab27b50b0..1540526a61348eb1959a6f6864b135c648adcbd6 100644 (file)
@@ -46,7 +46,7 @@ void board_sdmmc_voltage_init(void)
        int ret;
        int i;
 
-       ret = i2c_get_chip_for_busnum(0, PMU_I2C_ADDRESS, &dev);
+       ret = i2c_get_chip_for_busnum(0, PMU_I2C_ADDRESS, 1, &dev);
        if (ret) {
                debug("%s: Cannot find PMIC I2C chip\n", __func__);
                return;
@@ -57,7 +57,7 @@ void board_sdmmc_voltage_init(void)
        reg = 0x32;
 
        for (i = 0; i < MAX_I2C_RETRY; ++i) {
-               if (i2c_write(dev, reg, data_buffer, 1))
+               if (dm_i2c_write(dev, reg, data_buffer, 1))
                        udelay(100);
        }
 
@@ -66,7 +66,7 @@ void board_sdmmc_voltage_init(void)
        reg = 0x67;
 
        for (i = 0; i < MAX_I2C_RETRY; ++i) {
-               if (i2c_write(dev, reg, data_buffer, 1))
+               if (dm_i2c_write(dev, reg, data_buffer, 1))
                        udelay(100);
        }
 }
@@ -94,7 +94,7 @@ int tegra_pcie_board_init(void)
        u8 addr, data[1];
        int err;
 
-       err = i2c_get_chip_for_busnum(0, PMU_I2C_ADDRESS, &dev);
+       err = i2c_get_chip_for_busnum(0, PMU_I2C_ADDRESS, 1, &dev);
        if (err) {
                debug("failed to find PMU bus\n");
                return err;
@@ -104,7 +104,7 @@ int tegra_pcie_board_init(void)
        data[0] = 0x15;
        addr = 0x30;
 
-       err = i2c_write(dev, addr, data, 1);
+       err = dm_i2c_write(dev, addr, data, 1);
        if (err) {
                debug("failed to set VDD supply\n");
                return err;
@@ -121,7 +121,7 @@ int tegra_pcie_board_init(void)
        data[0] = 0x15;
        addr = 0x31;
 
-       err = i2c_write(dev, addr, data, 1);
+       err = dm_i2c_write(dev, addr, data, 1);
        if (err) {
                debug("failed to set AVDD supply\n");
                return err;
index 2a737468ddc4fce7411f2f9d183596c9edadf6c6..d7c1a695ff804562459791b2dd28d67d64609300 100644 (file)
@@ -55,7 +55,7 @@ void board_sdmmc_voltage_init(void)
        uchar reg, data_buffer[1];
        int ret;
 
-       ret = i2c_get_chip_for_busnum(0, PMU_I2C_ADDRESS, &dev);
+       ret = i2c_get_chip_for_busnum(0, PMU_I2C_ADDRESS, 1, &dev);
        if (ret) {
                debug("%s: Cannot find PMIC I2C chip\n", __func__);
                return;
@@ -65,7 +65,7 @@ void board_sdmmc_voltage_init(void)
        data_buffer[0] = 0x31;
        reg = 0x61;
 
-       ret = i2c_write(dev, reg, data_buffer, 1);
+       ret = dm_i2c_write(dev, reg, data_buffer, 1);
        if (ret)
                printf("%s: PMU i2c_write %02X<-%02X returned %d\n",
                        __func__, reg, data_buffer[0], ret);
@@ -74,7 +74,7 @@ void board_sdmmc_voltage_init(void)
        data_buffer[0] = 0x01;
        reg = 0x60;
 
-       ret = i2c_write(dev, reg, data_buffer, 1);
+       ret = dm_i2c_write(dev, reg, data_buffer, 1);
        if (ret)
                printf("%s: PMU i2c_write %02X<-%02X returned %d\n",
                        __func__, reg, data_buffer[0], ret);
@@ -83,12 +83,12 @@ void board_sdmmc_voltage_init(void)
        data_buffer[0] = 0x03;
        reg = 0x14;
 
-       ret = i2c_get_chip_for_busnum(0, BAT_I2C_ADDRESS, &dev);
+       ret = i2c_get_chip_for_busnum(0, BAT_I2C_ADDRESS, 1, &dev);
        if (ret) {
                debug("%s: Cannot find charger I2C chip\n", __func__);
                return;
        }
-       ret = i2c_write(dev, reg, data_buffer, 1);
+       ret = dm_i2c_write(dev, reg, data_buffer, 1);
        if (ret)
                printf("%s: BAT i2c_write %02X<-%02X returned %d\n",
                        __func__, reg, data_buffer[0], ret);
index 3114b20be0245602db4c6e7a46d55107b1a0258a..3476f1159feadc70ca214bb72af914143ef15153 100644 (file)
@@ -27,21 +27,21 @@ void pin_mux_mmc(void)
        int ret;
 
        /* Turn on MAX8907B LDO12 to 2.8V for J40 power */
-       ret = i2c_get_chip_for_busnum(0, 0x3c, &dev);
+       ret = i2c_get_chip_for_busnum(0, 0x3c, 1, &dev);
        if (ret) {
                printf("%s: Cannot find MAX8907B I2C chip\n", __func__);
                return;
        }
        val = 0x29;
-       ret = i2c_write(dev, 0x46, &val, 1);
+       ret = dm_i2c_write(dev, 0x46, &val, 1);
        if (ret)
                printf("i2c_write 0 0x3c 0x46 failed: %d\n", ret);
        val = 0x00;
-       ret = i2c_write(dev, 0x45, &val, 1);
+       ret = dm_i2c_write(dev, 0x45, &val, 1);
        if (ret)
                printf("i2c_write 0 0x3c 0x45 failed: %d\n", ret);
        val = 0x1f;
-       ret = i2c_write(dev, 0x44, &val, 1);
+       ret = dm_i2c_write(dev, 0x44, &val, 1);
        if (ret)
                printf("i2c_write 0 0x3c 0x44 failed: %d\n", ret);
 
@@ -64,17 +64,17 @@ void pin_mux_usb(void)
         */
 
        /* Turn on TAC6416's GPIO 0+1 for USB1/3's VBUS */
-       ret = i2c_get_chip_for_busnum(0, 0x20, &dev);
+       ret = i2c_get_chip_for_busnum(0, 0x20, 1, &dev);
        if (ret) {
                printf("%s: Cannot find TAC6416 I2C chip\n", __func__);
                return;
        }
        val = 0x03;
-       ret = i2c_write(dev, 2, &val, 1);
+       ret = dm_i2c_write(dev, 2, &val, 1);
        if (ret)
                printf("i2c_write 0 0x20 2 failed: %d\n", ret);
        val = 0xfc;
-       ret = i2c_write(dev, 6, &val, 1);
+       ret = dm_i2c_write(dev, 6, &val, 1);
        if (ret)
                printf("i2c_write 0 0x20 6 failed: %d\n", ret);
 }
diff --git a/board/pm520/Kconfig b/board/pm520/Kconfig
deleted file mode 100644 (file)
index 3f0a258..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-if TARGET_PM520
-
-config SYS_BOARD
-       default "pm520"
-
-config SYS_CONFIG_NAME
-       default "PM520"
-
-endif
diff --git a/board/pm520/MAINTAINERS b/board/pm520/MAINTAINERS
deleted file mode 100644 (file)
index 7b255bc..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-PM520 BOARD
-M:     Josef Wagner <Wagner@Microsys.de>
-S:     Maintained
-F:     board/pm520/
-F:     include/configs/PM520.h
-F:     configs/PM520_defconfig
-F:     configs/PM520_DDR_defconfig
-F:     configs/PM520_ROMBOOT_defconfig
-F:     configs/PM520_ROMBOOT_DDR_defconfig
diff --git a/board/pm520/Makefile b/board/pm520/Makefile
deleted file mode 100644 (file)
index 8b5a7eb..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-#
-# (C) Copyright 2003-2006
-# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
-#
-# SPDX-License-Identifier:     GPL-2.0+
-#
-
-obj-y  := pm520.o flash.o
diff --git a/board/pm520/flash.c b/board/pm520/flash.c
deleted file mode 100644 (file)
index 89c9f02..0000000
+++ /dev/null
@@ -1,659 +0,0 @@
-/*
- * (C) Copyright 2001
- * Kyle Harris, Nexus Technologies, Inc. kharris@nexus-tech.net
- *
- * (C) Copyright 2001-2004
- * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#include <common.h>
-#include <linux/byteorder/swab.h>
-
-
-flash_info_t flash_info[CONFIG_SYS_MAX_FLASH_BANKS];   /* info for FLASH chips    */
-
-/* Board support for 1 or 2 flash devices */
-#define FLASH_PORT_WIDTH32
-#undef FLASH_PORT_WIDTH16
-
-#ifdef FLASH_PORT_WIDTH16
-#define FLASH_PORT_WIDTH       ushort
-#define FLASH_PORT_WIDTHV      vu_short
-#define SWAP(x)                        (x)
-#else
-#define FLASH_PORT_WIDTH       ulong
-#define FLASH_PORT_WIDTHV      vu_long
-#define SWAP(x)                        (x)
-#endif
-
-/* Intel-compatible flash ID */
-#define INTEL_COMPAT           0x00890089
-#define INTEL_ALT              0x00B000B0
-
-/* Intel-compatible flash commands */
-#define INTEL_PROGRAM          0x00100010
-#define INTEL_ERASE            0x00200020
-#define INTEL_CLEAR            0x00500050
-#define INTEL_LOCKBIT          0x00600060
-#define INTEL_PROTECT          0x00010001
-#define INTEL_STATUS           0x00700070
-#define INTEL_READID           0x00900090
-#define INTEL_CONFIRM          0x00D000D0
-#define INTEL_RESET            0xFFFFFFFF
-
-/* Intel-compatible flash status bits */
-#define INTEL_FINISHED         0x00800080
-#define INTEL_OK               0x00800080
-
-#define FPW    FLASH_PORT_WIDTH
-#define FPWV   FLASH_PORT_WIDTHV
-
-#define mb() __asm__ __volatile__ ("" : : : "memory")
-
-/*-----------------------------------------------------------------------
- * Functions
- */
-static ulong flash_get_size (FPW *addr, flash_info_t *info);
-static int write_data (flash_info_t *info, ulong dest, FPW data);
-static void flash_get_offsets (ulong base, flash_info_t *info);
-void inline spin_wheel (void);
-static void flash_sync_real_protect (flash_info_t * info);
-static unsigned char intel_sector_protected (flash_info_t *info, ushort sector);
-
-/*-----------------------------------------------------------------------
- */
-
-unsigned long flash_init (void)
-{
-       int i;
-       ulong size = 0;
-       extern void flash_preinit(void);
-       extern void flash_afterinit(ulong, ulong);
-       ulong flashbase = CONFIG_SYS_FLASH_BASE;
-
-       flash_preinit();
-
-       for (i = 0; i < CONFIG_SYS_MAX_FLASH_BANKS; i++) {
-               switch (i) {
-               case 0:
-                       memset(&flash_info[i], 0, sizeof(flash_info_t));
-                       flash_get_size ((FPW *) flashbase, &flash_info[i]);
-                       flash_get_offsets (flash_info[i].start[0], &flash_info[i]);
-                       break;
-               default:
-                       panic ("configured to many flash banks!\n");
-                       break;
-               }
-               size += flash_info[i].size;
-
-               /* get the h/w and s/w protection status in sync */
-               flash_sync_real_protect(&flash_info[i]);
-       }
-
-       /* Protect monitor and environment sectors
-        */
-#if CONFIG_SYS_MONITOR_BASE >= CONFIG_SYS_FLASH_BASE
-#ifndef CONFIG_BOOT_ROM
-       flash_protect ( FLAG_PROTECT_SET,
-                       CONFIG_SYS_MONITOR_BASE,
-                       CONFIG_SYS_MONITOR_BASE + monitor_flash_len - 1,
-                       &flash_info[0] );
-#endif
-#endif
-
-#ifdef CONFIG_ENV_IS_IN_FLASH
-       flash_protect ( FLAG_PROTECT_SET,
-                       CONFIG_ENV_ADDR,
-                       CONFIG_ENV_ADDR + CONFIG_ENV_SIZE - 1, &flash_info[0] );
-#endif
-
-       flash_afterinit(flash_info[0].start[0], flash_info[0].size);
-
-       return size;
-}
-
-/*-----------------------------------------------------------------------
- */
-static void flash_get_offsets (ulong base, flash_info_t *info)
-{
-       int i;
-
-       if (info->flash_id == FLASH_UNKNOWN) {
-               return;
-       }
-
-       if ((info->flash_id & FLASH_VENDMASK) == FLASH_MAN_INTEL) {
-               for (i = 0; i < info->sector_count; i++) {
-                       info->start[i] = base + (i * PHYS_FLASH_SECT_SIZE);
-               }
-       }
-}
-
-/*-----------------------------------------------------------------------
- */
-void flash_print_info (flash_info_t *info)
-{
-       int i;
-
-       if (info->flash_id == FLASH_UNKNOWN) {
-               printf ("missing or unknown FLASH type\n");
-               return;
-       }
-
-       switch (info->flash_id & FLASH_VENDMASK) {
-       case FLASH_MAN_INTEL:
-               printf ("INTEL ");
-               break;
-       default:
-               printf ("Unknown Vendor ");
-               break;
-       }
-
-       switch (info->flash_id & FLASH_TYPEMASK) {
-       case FLASH_28F256J3A:
-               printf ("28F256J3A\n");
-               break;
-
-       case FLASH_28F128J3A:
-               printf ("28F128J3A\n");
-               break;
-
-       case FLASH_28F640J3A:
-               printf ("28F640J3A\n");
-               break;
-
-       case FLASH_28F320J3A:
-               printf ("28F320J3A\n");
-               break;
-
-       default:
-               printf ("Unknown Chip Type\n");
-               break;
-       }
-
-       printf ("  Size: %ld MB in %d Sectors\n",
-                       info->size >> 20, info->sector_count);
-
-       printf ("  Sector Start Addresses:");
-       for (i = 0; i < info->sector_count; ++i) {
-               if ((i % 5) == 0)
-                       printf ("\n   ");
-               printf (" %08lX%s",
-                       info->start[i],
-                       info->protect[i] ? " (RO)" : "     ");
-       }
-       printf ("\n");
-       return;
-}
-
-/*
- * The following code cannot be run from FLASH!
- */
-static ulong flash_get_size (FPW *addr, flash_info_t *info)
-{
-       volatile FPW value;
-
-       /* Write auto select command: read Manufacturer ID */
-       addr[0x5555] = (FPW) 0x00AA00AA;
-       addr[0x2AAA] = (FPW) 0x00550055;
-       addr[0x5555] = (FPW) 0x00900090;
-
-       mb ();
-       udelay(100);
-
-       value = addr[0];
-
-       switch (value) {
-
-       case (FPW) INTEL_MANUFACT:
-               info->flash_id = FLASH_MAN_INTEL;
-               break;
-
-       default:
-               info->flash_id = FLASH_UNKNOWN;
-               info->sector_count = 0;
-               info->size = 0;
-               addr[0] = (FPW) 0x00FF00FF;     /* restore read mode */
-               return (0);                     /* no or unknown flash  */
-       }
-
-       mb ();
-       value = addr[1];                        /* device ID        */
-
-       switch (value) {
-
-       case (FPW) INTEL_ID_28F256J3A:
-               info->flash_id += FLASH_28F256J3A;
-               /* In U-Boot we support only 32 MB (no bank-switching) */
-               info->sector_count = 256 / 2;
-               info->size =  0x04000000 / 2;
-               info->start[0] = CONFIG_SYS_FLASH_BASE + 0x02000000;
-               break;                          /* => 32 MB     */
-
-       case (FPW) INTEL_ID_28F128J3A:
-               info->flash_id += FLASH_28F128J3A;
-               info->sector_count = 128;
-               info->size = 0x02000000;
-               info->start[0] = CONFIG_SYS_FLASH_BASE + 0x02000000;
-               break;                          /* => 32 MB     */
-
-       case (FPW) INTEL_ID_28F640J3A:
-               info->flash_id += FLASH_28F640J3A;
-               info->sector_count = 64;
-               info->size = 0x01000000;
-               info->start[0] = CONFIG_SYS_FLASH_BASE + 0x03000000;
-               break;                          /* => 16 MB     */
-
-       case (FPW) INTEL_ID_28F320J3A:
-               info->flash_id += FLASH_28F320J3A;
-               info->sector_count = 32;
-               info->size = 0x800000;
-               info->start[0] = CONFIG_SYS_FLASH_BASE + 0x03800000;
-               break;                          /* => 8 MB     */
-
-       default:
-               info->flash_id = FLASH_UNKNOWN;
-               break;
-       }
-
-       if (info->sector_count > CONFIG_SYS_MAX_FLASH_SECT) {
-               printf ("** ERROR: sector count %d > max (%d) **\n",
-                       info->sector_count, CONFIG_SYS_MAX_FLASH_SECT);
-               info->sector_count = CONFIG_SYS_MAX_FLASH_SECT;
-       }
-
-       addr[0] = (FPW) 0x00FF00FF;             /* restore read mode */
-
-       return (info->size);
-}
-
-
-/*
- * This function gets the u-boot flash sector protection status
- * (flash_info_t.protect[]) in sync with the sector protection
- * status stored in hardware.
- */
-static void flash_sync_real_protect (flash_info_t * info)
-{
-       int i;
-
-       switch (info->flash_id & FLASH_TYPEMASK) {
-
-       case FLASH_28F256J3A:
-       case FLASH_28F128J3A:
-       case FLASH_28F640J3A:
-       case FLASH_28F320J3A:
-               for (i = 0; i < info->sector_count; ++i) {
-                       info->protect[i] = intel_sector_protected(info, i);
-               }
-               break;
-       default:
-               /* no h/w protect support */
-               break;
-       }
-}
-
-
-/*
- * checks if "sector" in bank "info" is protected. Should work on intel
- * strata flash chips 28FxxxJ3x in 8-bit mode.
- * Returns 1 if sector is protected (or timed-out while trying to read
- * protection status), 0 if it is not.
- */
-static unsigned char intel_sector_protected (flash_info_t *info, ushort sector)
-{
-       FPWV *addr;
-       FPWV *lock_conf_addr;
-       ulong start;
-       unsigned char ret;
-
-       /*
-        * first, wait for the WSM to be finished. The rationale for
-        * waiting for the WSM to become idle for at most
-        * CONFIG_SYS_FLASH_ERASE_TOUT is as follows. The WSM can be busy
-        * because of: (1) erase, (2) program or (3) lock bit
-        * configuration. So we just wait for the longest timeout of
-        * the (1)-(3), i.e. the erase timeout.
-        */
-
-       /* wait at least 35ns (W12) before issuing Read Status Register */
-       udelay(1);
-       addr = (FPWV *) info->start[sector];
-       *addr = (FPW) INTEL_STATUS;
-
-       start = get_timer (0);
-       while ((*addr & (FPW) INTEL_FINISHED) != (FPW) INTEL_FINISHED) {
-               if (get_timer (start) > CONFIG_SYS_FLASH_ERASE_TOUT) {
-                       *addr = (FPW) INTEL_RESET; /* restore read mode */
-                       printf("WSM busy too long, can't get prot status\n");
-                       return 1;
-               }
-       }
-
-       /* issue the Read Identifier Codes command */
-       *addr = (FPW) INTEL_READID;
-
-       /* wait at least 35ns (W12) before reading */
-       udelay(1);
-
-       /* Intel example code uses offset of 2 for 16 bit flash */
-       lock_conf_addr = (FPWV *) info->start[sector] + 2;
-       ret = (*lock_conf_addr & (FPW) INTEL_PROTECT) ? 1 : 0;
-
-       /* put flash back in read mode */
-       *addr = (FPW) INTEL_RESET;
-
-       return ret;
-}
-
-/*-----------------------------------------------------------------------
- */
-
-int flash_erase (flash_info_t *info, int s_first, int s_last)
-{
-       int flag, prot, sect;
-       ulong type, start;
-       int rcode = 0;
-
-       if ((s_first < 0) || (s_first > s_last)) {
-               if (info->flash_id == FLASH_UNKNOWN) {
-                       printf ("- missing\n");
-               } else {
-                       printf ("- no sectors to erase\n");
-               }
-               return 1;
-       }
-
-       type = (info->flash_id & FLASH_VENDMASK);
-       if ((type != FLASH_MAN_INTEL)) {
-               printf ("Can't erase unknown flash type %08lx - aborted\n",
-                       info->flash_id);
-               return 1;
-       }
-
-       prot = 0;
-       for (sect = s_first; sect <= s_last; ++sect) {
-               if (info->protect[sect]) {
-                       prot++;
-               }
-       }
-
-       if (prot) {
-               printf ("- Warning: %d protected sectors will not be erased!\n",
-                       prot);
-       } else {
-               printf ("\n");
-       }
-
-       start = get_timer (0);
-
-       /* Disable interrupts which might cause a timeout here */
-       flag = disable_interrupts ();
-
-       /* Start erase on unprotected sectors */
-       for (sect = s_first; sect <= s_last; sect++) {
-               if (info->protect[sect] == 0) { /* not protected */
-                       FPWV *addr = (FPWV *) (info->start[sect]);
-                       FPW status;
-
-                       printf ("Erasing sector %2d ... ", sect);
-
-                       /* arm simple, non interrupt dependent timer */
-                       start = get_timer(0);
-
-                       *addr = (FPW) 0x00500050;       /* clear status register */
-                       *addr = (FPW) 0x00200020;       /* erase setup */
-                       *addr = (FPW) 0x00D000D0;       /* erase confirm */
-
-                       while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) {
-                               if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) {
-                                       printf ("Timeout\n");
-                                       *addr = (FPW) 0x00B000B0;       /* suspend erase     */
-                                       *addr = (FPW) 0x00FF00FF;       /* reset to read mode */
-                                       rcode = 1;
-                                       break;
-                               }
-                       }
-
-                       *addr = 0x00500050;     /* clear status register cmd.   */
-                       *addr = 0x00FF00FF;     /* resest to read mode          */
-
-                       printf (" done\n");
-               }
-       }
-
-       if (flag)
-               enable_interrupts();
-
-       return rcode;
-}
-
-/*-----------------------------------------------------------------------
- * Copy memory to flash, returns:
- * 0 - OK
- * 1 - write timeout
- * 2 - Flash not erased
- * 4 - Flash not identified
- */
-
-int write_buff (flash_info_t *info, uchar *src, ulong addr, ulong cnt)
-{
-       ulong cp, wp;
-       FPW data;
-       int count, i, l, rc, port_width;
-
-       if (info->flash_id == FLASH_UNKNOWN) {
-               return 4;
-       }
-/* get lower word aligned address */
-#ifdef FLASH_PORT_WIDTH16
-       wp = (addr & ~1);
-       port_width = 2;
-#else
-       wp = (addr & ~3);
-       port_width = 4;
-#endif
-
-       /*
-        * handle unaligned start bytes
-        */
-       if ((l = addr - wp) != 0) {
-               data = 0;
-               for (i = 0, cp = wp; i < l; ++i, ++cp) {
-                       data = (data << 8) | (*(uchar *) cp);
-               }
-               for (; i < port_width && cnt > 0; ++i) {
-                       data = (data << 8) | *src++;
-                       --cnt;
-                       ++cp;
-               }
-               for (; cnt == 0 && i < port_width; ++i, ++cp) {
-                       data = (data << 8) | (*(uchar *) cp);
-               }
-
-               if ((rc = write_data (info, wp, SWAP (data))) != 0) {
-                       return (rc);
-               }
-               wp += port_width;
-       }
-
-       /*
-        * handle word aligned part
-        */
-       count = 0;
-       while (cnt >= port_width) {
-               data = 0;
-               for (i = 0; i < port_width; ++i) {
-                       data = (data << 8) | *src++;
-               }
-               if ((rc = write_data (info, wp, SWAP (data))) != 0) {
-                       return (rc);
-               }
-               wp += port_width;
-               cnt -= port_width;
-               if (count++ > 0x800) {
-                       spin_wheel ();
-                       count = 0;
-               }
-       }
-
-       if (cnt == 0) {
-               return (0);
-       }
-
-       /*
-        * handle unaligned tail bytes
-        */
-       data = 0;
-       for (i = 0, cp = wp; i < port_width && cnt > 0; ++i, ++cp) {
-               data = (data << 8) | *src++;
-               --cnt;
-       }
-       for (; i < port_width; ++i, ++cp) {
-               data = (data << 8) | (*(uchar *) cp);
-       }
-
-       return (write_data (info, wp, SWAP (data)));
-}
-
-/*-----------------------------------------------------------------------
- * Write a word or halfword to Flash, returns:
- * 0 - OK
- * 1 - write timeout
- * 2 - Flash not erased
- */
-static int write_data (flash_info_t *info, ulong dest, FPW data)
-{
-       FPWV *addr = (FPWV *) dest;
-       ulong status;
-       ulong start;
-       int flag;
-       int rcode = 0;
-
-       /* Check if Flash is (sufficiently) erased */
-       if ((*addr & data) != data) {
-               printf ("not erased at %08lx (%lx)\n", (ulong) addr, *addr);
-               return (2);
-       }
-       /* Disable interrupts which might cause a timeout here */
-       flag = disable_interrupts ();
-
-       *addr = (FPW) 0x00400040;       /* write setup */
-       *addr = data;
-
-       /* arm simple, non interrupt dependent timer */
-       start = get_timer(0);
-
-       /* wait while polling the status register */
-       while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) {
-               if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) {
-                       rcode = 1;
-                       break;
-               }
-       }
-
-       *addr = (FPW) 0x00FF00FF;       /* restore read mode */
-
-       if (flag)
-               enable_interrupts();
-
-       return rcode;
-}
-
-void inline spin_wheel (void)
-{
-       static int p = 0;
-       static char w[] = "\\/-";
-
-       printf ("\010%c", w[p]);
-       (++p == 3) ? (p = 0) : 0;
-}
-
-/*-----------------------------------------------------------------------
- * Set/Clear sector's lock bit, returns:
- * 0 - OK
- * 1 - Error (timeout, voltage problems, etc.)
- */
-int flash_real_protect (flash_info_t *info, long sector, int prot)
-{
-       ulong start;
-       int i;
-       int rc = 0;
-       vu_long *addr = (vu_long *)(info->start[sector]);
-       int flag = disable_interrupts();
-
-       *addr = INTEL_CLEAR;    /* Clear status register */
-       if (prot) {                     /* Set sector lock bit */
-               *addr = INTEL_LOCKBIT;  /* Sector lock bit */
-               *addr = INTEL_PROTECT;  /* set */
-       }
-       else {                          /* Clear sector lock bit */
-               *addr = INTEL_LOCKBIT;  /* All sectors lock bits */
-               *addr = INTEL_CONFIRM;  /* clear */
-       }
-
-       start = get_timer(0);
-
-       while ((*addr & INTEL_FINISHED) != INTEL_FINISHED) {
-               if (get_timer(start) > CONFIG_SYS_FLASH_UNLOCK_TOUT) {
-                       printf("Flash lock bit operation timed out\n");
-                       rc = 1;
-                       break;
-               }
-       }
-
-       if (*addr != INTEL_OK) {
-               printf("Flash lock bit operation failed at %08X, CSR=%08X\n",
-                      (uint)addr, (uint)*addr);
-               rc = 1;
-       }
-
-       if (!rc)
-               info->protect[sector] = prot;
-
-       /*
-        * Clear lock bit command clears all sectors lock bits, so
-        * we have to restore lock bits of protected sectors.
-        * WARNING: code below re-locks sectors only for one bank (info).
-        * This causes problems on boards where several banks share
-        * the same chip, as sectors in othere banks will be unlocked
-        * but not re-locked. It works fine on pm520 though, as there
-        * is only one chip and one bank.
-        */
-       if (!prot)
-       {
-               for (i = 0; i < info->sector_count; i++)
-               {
-                       if (info->protect[i])
-                       {
-                               start = get_timer(0);
-                               addr = (vu_long *)(info->start[i]);
-                               *addr = INTEL_LOCKBIT;  /* Sector lock bit */
-                               *addr = INTEL_PROTECT;  /* set */
-                               while ((*addr & INTEL_FINISHED) != INTEL_FINISHED)
-                               {
-                                       if (get_timer(start) > CONFIG_SYS_FLASH_UNLOCK_TOUT)
-                                       {
-                                               printf("Flash lock bit operation timed out\n");
-                                               rc = 1;
-                                               break;
-                                       }
-                               }
-                       }
-               }
-               /*
-                * get the s/w sector protection status in sync with the h/w,
-                * in case something went wrong during the re-locking.
-                */
-               flash_sync_real_protect(info); /* resets flash to read  mode */
-       }
-
-       if (flag)
-               enable_interrupts();
-
-       *addr = INTEL_RESET;            /* Reset to read array mode */
-
-       return rc;
-}
diff --git a/board/pm520/mt46v16m16-75.h b/board/pm520/mt46v16m16-75.h
deleted file mode 100644 (file)
index 9068fbf..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * (C) Copyright 2004
- * Mark Jonas, Freescale Semiconductor, mark.jonas@motorola.com.
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#define SDRAM_DDR      1               /* is DDR */
-
-/* Settings for XLB = 132 MHz */
-#define SDRAM_MODE     0x018D0000
-#define SDRAM_EMODE    0x40090000
-#define SDRAM_CONTROL  0x714f0f00
-#define SDRAM_CONFIG1  0x73722930
-#define SDRAM_CONFIG2  0x47770000
-#define SDRAM_TAPDELAY 0x10000000
diff --git a/board/pm520/mt48lc16m16a2-75.h b/board/pm520/mt48lc16m16a2-75.h
deleted file mode 100644 (file)
index 0133eaa..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-/*
- * (C) Copyright 2004
- * Mark Jonas, Freescale Semiconductor, mark.jonas@motorola.com.
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#define SDRAM_DDR      0               /* is SDR */
-
-/* Settings for XLB = 132 MHz */
-#define SDRAM_MODE     0x00CD0000
-#define SDRAM_CONTROL  0x504F0000
-#define SDRAM_CONFIG1  0xD2322800
-#define SDRAM_CONFIG2  0x8AD70000
diff --git a/board/pm520/pm520.c b/board/pm520/pm520.c
deleted file mode 100644 (file)
index 4ec4505..0000000
+++ /dev/null
@@ -1,253 +0,0 @@
-/*
- * (C) Copyright 2003-2004
- * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
- *
- * (C) Copyright 2004
- * Mark Jonas, Freescale Semiconductor, mark.jonas@motorola.com.
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#include <common.h>
-#include <mpc5xxx.h>
-#include <pci.h>
-#include <netdev.h>
-
-#if defined(CONFIG_MPC5200_DDR)
-#include "mt46v16m16-75.h"
-#else
-#include "mt48lc16m16a2-75.h"
-#endif
-
-DECLARE_GLOBAL_DATA_PTR;
-
-#ifndef CONFIG_SYS_RAMBOOT
-static void sdram_start (int hi_addr)
-{
-       long hi_addr_bit = hi_addr ? 0x01000000 : 0;
-
-       /* unlock mode register */
-       *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000000 | hi_addr_bit;
-       __asm__ volatile ("sync");
-
-       /* precharge all banks */
-       *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000002 | hi_addr_bit;
-       __asm__ volatile ("sync");
-
-#if SDRAM_DDR
-       /* set mode register: extended mode */
-       *(vu_long *)MPC5XXX_SDRAM_MODE = SDRAM_EMODE;
-       __asm__ volatile ("sync");
-
-       /* set mode register: reset DLL */
-       *(vu_long *)MPC5XXX_SDRAM_MODE = SDRAM_MODE | 0x04000000;
-       __asm__ volatile ("sync");
-#endif
-
-       /* precharge all banks */
-       *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000002 | hi_addr_bit;
-       __asm__ volatile ("sync");
-
-       /* auto refresh */
-       *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000004 | hi_addr_bit;
-       __asm__ volatile ("sync");
-
-       /* set mode register */
-       *(vu_long *)MPC5XXX_SDRAM_MODE = SDRAM_MODE;
-       __asm__ volatile ("sync");
-
-       /* normal operation */
-       *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | hi_addr_bit;
-       __asm__ volatile ("sync");
-}
-#endif
-
-/*
- * ATTENTION: Although partially referenced initdram does NOT make real use
- *            use of CONFIG_SYS_SDRAM_BASE. The code does not work if CONFIG_SYS_SDRAM_BASE
- *            is something else than 0x00000000.
- */
-
-phys_size_t initdram (int board_type)
-{
-       ulong dramsize = 0;
-       ulong dramsize2 = 0;
-#ifndef CONFIG_SYS_RAMBOOT
-       ulong test1, test2;
-
-       /* setup SDRAM chip selects */
-       *(vu_long *)MPC5XXX_SDRAM_CS0CFG = 0x0000001e;/* 2G at 0x0 */
-       *(vu_long *)MPC5XXX_SDRAM_CS1CFG = 0x80000000;/* disabled */
-       __asm__ volatile ("sync");
-
-       /* setup config registers */
-       *(vu_long *)MPC5XXX_SDRAM_CONFIG1 = SDRAM_CONFIG1;
-       *(vu_long *)MPC5XXX_SDRAM_CONFIG2 = SDRAM_CONFIG2;
-       __asm__ volatile ("sync");
-
-#if SDRAM_DDR
-       /* set tap delay */
-       *(vu_long *)MPC5XXX_CDM_PORCFG = SDRAM_TAPDELAY;
-       __asm__ volatile ("sync");
-#endif
-
-       /* find RAM size using SDRAM CS0 only */
-       sdram_start(0);
-       test1 = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
-       sdram_start(1);
-       test2 = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
-       if (test1 > test2) {
-               sdram_start(0);
-               dramsize = test1;
-       } else {
-               dramsize = test2;
-       }
-
-       /* memory smaller than 1MB is impossible */
-       if (dramsize < (1 << 20)) {
-               dramsize = 0;
-       }
-
-       /* set SDRAM CS0 size according to the amount of RAM found */
-       if (dramsize > 0) {
-               *(vu_long *)MPC5XXX_SDRAM_CS0CFG = 0x13 + __builtin_ffs(dramsize >> 20) - 1;
-       } else {
-               *(vu_long *)MPC5XXX_SDRAM_CS0CFG = 0; /* disabled */
-       }
-
-       /* let SDRAM CS1 start right after CS0 */
-       *(vu_long *)MPC5XXX_SDRAM_CS1CFG = dramsize + 0x0000001e;/* 2G */
-
-       /* find RAM size using SDRAM CS1 only */
-       if (!dramsize)
-               sdram_start(0);
-       test2 = test1 = get_ram_size((long *)(CONFIG_SYS_SDRAM_BASE + dramsize), 0x80000000);
-       if (!dramsize) {
-               sdram_start(1);
-               test2 = get_ram_size((long *)(CONFIG_SYS_SDRAM_BASE + dramsize), 0x80000000);
-       }
-       if (test1 > test2) {
-               sdram_start(0);
-               dramsize2 = test1;
-       } else {
-               dramsize2 = test2;
-       }
-
-       /* memory smaller than 1MB is impossible */
-       if (dramsize2 < (1 << 20)) {
-               dramsize2 = 0;
-       }
-
-       /* set SDRAM CS1 size according to the amount of RAM found */
-       if (dramsize2 > 0) {
-               *(vu_long *)MPC5XXX_SDRAM_CS1CFG = dramsize
-                       | (0x13 + __builtin_ffs(dramsize2 >> 20) - 1);
-       } else {
-               *(vu_long *)MPC5XXX_SDRAM_CS1CFG = dramsize; /* disabled */
-       }
-
-#else /* CONFIG_SYS_RAMBOOT */
-
-       /* retrieve size of memory connected to SDRAM CS0 */
-       dramsize = *(vu_long *)MPC5XXX_SDRAM_CS0CFG & 0xFF;
-       if (dramsize >= 0x13) {
-               dramsize = (1 << (dramsize - 0x13)) << 20;
-       } else {
-               dramsize = 0;
-       }
-
-       /* retrieve size of memory connected to SDRAM CS1 */
-       dramsize2 = *(vu_long *)MPC5XXX_SDRAM_CS1CFG & 0xFF;
-       if (dramsize2 >= 0x13) {
-               dramsize2 = (1 << (dramsize2 - 0x13)) << 20;
-       } else {
-               dramsize2 = 0;
-       }
-
-#endif /* CONFIG_SYS_RAMBOOT */
-
-       return dramsize + dramsize2;
-}
-
-int checkboard (void)
-{
-       puts ("Board: MicroSys PM520 \n");
-       return 0;
-}
-
-void flash_preinit(void)
-{
-       /*
-        * Now, when we are in RAM, enable flash write
-        * access for detection process.
-        * Note that CS_BOOT cannot be cleared when
-        * executing in flash.
-        */
-       *(vu_long *)MPC5XXX_BOOTCS_CFG &= ~0x1; /* clear RO */
-}
-
-void flash_afterinit(ulong start, ulong size)
-{
-#if defined(CONFIG_BOOT_ROM)
-       /* adjust mapping */
-       *(vu_long *)MPC5XXX_CS1_START =
-                       START_REG(start);
-       *(vu_long *)MPC5XXX_CS1_STOP =
-                       STOP_REG(start, size);
-#else
-       /* adjust mapping */
-       *(vu_long *)MPC5XXX_BOOTCS_START = *(vu_long *)MPC5XXX_CS0_START =
-                       START_REG(start);
-       *(vu_long *)MPC5XXX_BOOTCS_STOP = *(vu_long *)MPC5XXX_CS0_STOP =
-                       STOP_REG(start, size);
-#endif
-}
-
-
-extern flash_info_t flash_info[];      /* info for FLASH chips */
-
-int misc_init_r (void)
-{
-       /* adjust flash start */
-       gd->bd->bi_flashstart = flash_info[0].start[0];
-       return (0);
-}
-
-#ifdef CONFIG_PCI
-static struct pci_controller hose;
-
-extern void pci_mpc5xxx_init(struct pci_controller *);
-
-void pci_init_board(void)
-{
-       pci_mpc5xxx_init(&hose);
-}
-#endif
-
-#if defined(CONFIG_CMD_IDE) && defined(CONFIG_IDE_RESET)
-
-void init_ide_reset (void)
-{
-       debug ("init_ide_reset\n");
-
-}
-
-void ide_set_reset (int idereset)
-{
-       debug ("ide_reset(%d)\n", idereset);
-
-}
-#endif
-
-#if defined(CONFIG_CMD_DOC)
-void doc_init (void)
-{
-       doc_probe (CONFIG_SYS_DOC_BASE);
-}
-#endif
-
-int board_eth_init(bd_t *bis)
-{
-       cpu_eth_init(bis); /* Built in FEC comes first */
-       return pci_eth_init(bis);
-}
index 596071f9b358383d0df52e6742e26be627240027..ec00c15af3d6e62bc84bcd44a2861b48063f2ee8 100644 (file)
@@ -11,7 +11,7 @@
 #
 
 # Boot Media configurations
-BOOT_FROM      nand    # change from nand to uart if building UART image
+BOOT_FROM      nand
 NAND_ECC_MODE  default
 NAND_PAGE_SIZE 0x0800
 
@@ -21,12 +21,12 @@ NAND_PAGE_SIZE      0x0800
 # Configure RGMII-0 interface pad voltage to 1.8V
 DATA 0xffd100e0 0x1b1b1b9b
 
-#Dram initalization for SINGLE x16 CL=5 @ 400MHz
+# Dram initalization for SINGLE x16 CL=5 @ 400MHz
 DATA 0xffd01400 0x43000c30     # DDR Configuration register
 # bit13-0:  0xc30, (3120 DDR2 clks refresh rate)
 # bit23-14: 0x0,
-# bit24:    0x1,     enable exit self refresh mode on DDR access
-# bit25:    0x1,     required
+# bit24:    0x1,   enable exit self refresh mode on DDR access
+# bit25:    0x1,   required
 # bit29-26: 0x0,
 # bit31-30: 0x1,
 
@@ -64,10 +64,10 @@ DATA 0xffd01410 0x0000000c  # DDR Address Control
 # bit3-2:   11,  Cs0size (1Gb)
 # bit5-4:   00,  Cs1width (x8)
 # bit7-6:   11,  Cs1size (1Gb)
-# bit9-8:   00,  Cs2width (nonexistent
-# bit11-10: 00,  Cs2size  (nonexistent
-# bit13-12: 00,  Cs3width (nonexistent
-# bit15-14: 00,  Cs3size  (nonexistent
+# bit9-8:   00,  Cs2width (nonexistent)
+# bit11-10: 00,  Cs2size (nonexistent)
+# bit13-12: 00,  Cs3width (nonexistent)
+# bit15-14: 00,  Cs3size (nonexistent)
 # bit16:    0,   Cs0AddrSel
 # bit17:    0,   Cs1AddrSel
 # bit18:    0,   Cs2AddrSel
@@ -88,7 +88,7 @@ DATA 0xffd0141c 0x00000c52    # DDR Mode
 # bit6-4:   0x4, CL=5
 # bit7:     0x0, TestMode=0 normal
 # bit8:     0x0, DLL reset=0 normal
-# bit11-9:  0x6, auto-precharge write recovery ????????????
+# bit11-9:  0x6, auto-precharge write recovery
 # bit12:    0x0, PD must be zero
 # bit31-13: 0x0, required
 
@@ -148,8 +148,8 @@ DATA 0xffd0149c 0x0000e803  # CPU ODT Control
 DATA 0xffd01480 0x00000001     # DDR Initialization Control
 # bit0: 0x1, enable DDR init upon this register write
 
-DATA 0xFFD20134 0x66666666      # L2 RAM Timing 0 Register
-DATA 0xFFD20138 0x66666666      # L2 RAM Timing 1 Register
+DATA 0xffd20134 0x66666666     # L2 RAM Timing 0 Register
+DATA 0xffd20138 0x66666666     # L2 RAM Timing 1 Register
 
 # End of Header extension
 DATA 0x0 0x0
index b7d23817e143016688d332fbf1da1acd925fe6c2..e3517f2eb24101f8614b53c120d30f37ea5caa06 100644 (file)
@@ -415,15 +415,6 @@ static int pmic_init_max77686(void)
        return 0;
 }
 
-#ifdef CONFIG_SYS_I2C_INIT_BOARD
-static void board_init_i2c(void)
-{
-       /* I2C_0 */
-       if (exynos_pinmux_config(PERIPH_ID_I2C0, PINMUX_FLAG_NONE))
-               debug("I2C%d not configured\n", (I2C_0));
-}
-#endif
-
 int exynos_early_init_f(void)
 {
        board_clock_init();
@@ -444,10 +435,7 @@ int exynos_init(void)
 
 int exynos_power_init(void)
 {
-#ifdef CONFIG_SYS_I2C_INIT_BOARD
-       board_init_i2c();
-#endif
-       pmic_init(I2C_0);
+       pmic_init(0);
        pmic_init_max77686();
 
        return 0;
index 5f879f55065255d31ec152fde745190f60d4fe2f..3c0df1784553a85222660061c5b570c40823684a 100644 (file)
@@ -18,8 +18,8 @@ create unit tests which we can run to test this upper level code.
 
 CONFIG_SANDBOX is defined when building a native board.
 
-The chosen vendor and board names are also 'sandbox', so there is a single
-board in board/sandbox.
+The board name is 'sandbox' but the vendor name is unset, so there is a
+single board in board/sandbox.
 
 CONFIG_SANDBOX_BIG_ENDIAN should be defined when running on big-endian
 machines.
index 0a11540cca01d316db4b7eb6f71fd234a2cc9360..f3f6dae459af3ba6a74bfa49e544a73106db6b3f 100644 (file)
@@ -43,13 +43,13 @@ static void corvus_nand_hw_init(void)
        writel(csa, &matrix->ebicsa);
 
        /* Configure SMC CS3 for NAND/SmartMedia */
-       writel(AT91_SMC_SETUP_NWE(1) | AT91_SMC_SETUP_NCS_WR(0) |
-              AT91_SMC_SETUP_NRD(1) | AT91_SMC_SETUP_NCS_RD(0),
+       writel(AT91_SMC_SETUP_NWE(2) | AT91_SMC_SETUP_NCS_WR(0) |
+              AT91_SMC_SETUP_NRD(2) | AT91_SMC_SETUP_NCS_RD(0),
               &smc->cs[3].setup);
-       writel(AT91_SMC_PULSE_NWE(4) | AT91_SMC_PULSE_NCS_WR(3) |
-              AT91_SMC_PULSE_NRD(3) | AT91_SMC_PULSE_NCS_RD(2),
+       writel(AT91_SMC_PULSE_NWE(4) | AT91_SMC_PULSE_NCS_WR(4) |
+              AT91_SMC_PULSE_NRD(4) | AT91_SMC_PULSE_NCS_RD(4),
               &smc->cs[3].pulse);
-       writel(AT91_SMC_CYCLE_NWE(7) | AT91_SMC_CYCLE_NRD(4),
+       writel(AT91_SMC_CYCLE_NWE(7) | AT91_SMC_CYCLE_NRD(7),
               &smc->cs[3].cycle);
        writel(AT91_SMC_MODE_RM_NRD | AT91_SMC_MODE_WM_NWE |
               AT91_SMC_MODE_EXNW_DISABLE |
@@ -62,9 +62,11 @@ static void corvus_nand_hw_init(void)
               &smc->cs[3].mode);
 
        at91_periph_clk_enable(ATMEL_ID_PIOC);
+       at91_periph_clk_enable(ATMEL_ID_PIOA);
 
        /* Enable NandFlash */
        at91_set_gpio_output(CONFIG_SYS_NAND_ENABLE_PIN, 1);
+       at91_set_gpio_input(CONFIG_SYS_NAND_READY_PIN, 1);
 }
 
 #if defined(CONFIG_SPL_BUILD)
index b8ff478110287c89bbd3fa274ff4e3eae28e5298..013dac2e2fb131baa83ae883c1eb514c26f55ef1 100644 (file)
@@ -68,6 +68,7 @@ static void taurus_nand_hw_init(void)
 #if defined(CONFIG_SPL_BUILD)
 #include <spl.h>
 #include <nand.h>
+#include <spi_flash.h>
 
 void matrix_init(void)
 {
@@ -81,23 +82,28 @@ void matrix_init(void)
 void at91_spl_board_init(void)
 {
        taurus_nand_hw_init();
+       at91_spi0_hw_init(TAURUS_SPI_MASK);
 
        /* Configure recovery button PINs */
        at91_set_gpio_input(AT91_PIN_PA31, 1);
 
        /* check if button is pressed */
        if (at91_get_gpio_value(AT91_PIN_PA31) == 0) {
-               u32 boot_device;
+               struct spi_flash *flash;
 
                debug("Recovery button pressed\n");
-               boot_device = spl_boot_device();
-               switch (boot_device) {
-#ifdef CONFIG_SPL_NAND_SUPPORT
-               case BOOT_DEVICE_NAND:
-                       nand_init();
-                       spl_nand_erase_one(0, 0);
-                       break;
-#endif
+               nand_init();
+               spl_nand_erase_one(0, 0);
+               flash = spi_flash_probe(CONFIG_SF_DEFAULT_BUS,
+                                       0,
+                                       CONFIG_SF_DEFAULT_SPEED,
+                                       SPI_MODE_3);
+               if (!flash) {
+                       puts("no flash\n");
+               } else {
+                       puts("erase spi flash sector 0\n");
+                       spi_flash_erase(flash, 0,
+                                       CONFIG_SYS_NAND_U_BOOT_SIZE);
                }
        }
 }
index 6a4d764b7c9a94eaa4efe0d49f79d2bcbaf23a07..4a2158988fc9bce0d1991d51e72586e7c2af5615 100644 (file)
@@ -33,21 +33,103 @@ config MACH_SUN8I
 
 endchoice
 
-if MACH_SUN6I || MACH_SUN8I
-
 config DRAM_CLK
-       int "sun6i dram clock speed"
-       default 312
+       int "sunxi dram clock speed"
+       default 312 if MACH_SUN6I || MACH_SUN8I
+       default 360 if MACH_SUN4I || MACH_SUN5I || MACH_SUN7I
        ---help---
        Set the dram clock speed, valid range 240 - 480, must be a multiple
        of 24.
 
+if MACH_SUN5I || MACH_SUN7I
+config DRAM_MBUS_CLK
+       int "sunxi mbus clock speed"
+       default 300
+       ---help---
+       Set the mbus clock speed. The maximum on sun5i hardware is 300MHz.
+
+endif
+
 config DRAM_ZQ
-       int "sun6i dram zq value"
-       default 123
+       int "sunxi dram zq value"
+       default 123 if MACH_SUN4I || MACH_SUN5I || MACH_SUN6I || MACH_SUN8I
+       default 127 if MACH_SUN7I
        ---help---
        Set the dram zq value.
 
+if MACH_SUN4I || MACH_SUN5I || MACH_SUN7I
+config DRAM_EMR1
+       int "sunxi dram emr1 value"
+       default 0 if MACH_SUN4I
+       default 4 if MACH_SUN5I || MACH_SUN7I
+       ---help---
+       Set the dram controller emr1 value.
+
+config DRAM_ODT_EN
+       int "sunxi dram odt_en value"
+       default 0
+       ---help---
+       Set the dram controller odt_en parameter. This can be used to
+       enable/disable the ODT feature.
+
+config DRAM_TPR3
+       hex "sunxi dram tpr3 value"
+       default 0
+       ---help---
+       Set the dram controller tpr3 parameter. This parameter configures
+       the delay on the command lane and also phase shifts, which are
+       applied for sampling incoming read data. The default value 0
+       means that no phase/delay adjustments are necessary. Properly
+       configuring this parameter increases reliability at high DRAM
+       clock speeds.
+
+config DRAM_DQS_GATING_DELAY
+       hex "sunxi dram dqs_gating_delay value"
+       default 0
+       ---help---
+       Set the dram controller dqs_gating_delay parmeter. Each byte
+       encodes the DQS gating delay for each byte lane. The delay
+       granularity is 1/4 cycle. For example, the value 0x05060606
+       means that the delay is 5 quarter-cycles for one lane (1.25
+       cycles) and 6 quarter-cycles (1.5 cycles) for 3 other lanes.
+       The default value 0 means autodetection. The results of hardware
+       autodetection are not very reliable and depend on the chip
+       temperature (sometimes producing different results on cold start
+       and warm reboot). But the accuracy of hardware autodetection
+       is usually good enough, unless running at really high DRAM
+       clocks speeds (up to 600MHz). If unsure, keep as 0.
+
+choice
+       prompt "sunxi dram timings"
+       default DRAM_TIMINGS_VENDOR_MAGIC
+       ---help---
+       Select the timings of the DDR3 chips.
+
+config DRAM_TIMINGS_VENDOR_MAGIC
+       bool "Magic vendor timings from Android"
+       ---help---
+       The same DRAM timings as in the Allwinner boot0 bootloader.
+
+config DRAM_TIMINGS_DDR3_1066F_1333H
+       bool "JEDEC DDR3-1333H with down binning to DDR3-1066F"
+       ---help---
+       Use the timings of the standard JEDEC DDR3-1066F speed bin for
+       DRAM_CLK <= 533MHz and the timings of the DDR3-1333H speed bin
+       for DRAM_CLK > 533MHz. This covers the majority of DDR3 chips
+       used in Allwinner A10/A13/A20 devices. In the case of DDR3-1333
+       or DDR3-1600 chips, be sure to check the DRAM datasheet to confirm
+       that down binning to DDR3-1066F is supported (because DDR3-1066F
+       uses a bit faster timings than DDR3-1333H).
+
+config DRAM_TIMINGS_DDR3_800E_1066G_1333J
+       bool "JEDEC DDR3-800E / DDR3-1066G / DDR3-1333J"
+       ---help---
+       Use the timings of the slowest possible JEDEC speed bin for the
+       selected DRAM_CLK. Depending on the DRAM_CLK value, it may be
+       DDR3-800E, DDR3-1066G or DDR3-1333J.
+
+endchoice
+
 endif
 
 config SYS_CONFIG_NAME
@@ -57,149 +139,6 @@ config SYS_CONFIG_NAME
        default "sun7i" if MACH_SUN7I
        default "sun8i" if MACH_SUN8I
 
-choice
-       prompt "Board"
-
-config TARGET_A10_OLINUXINO_L
-       bool "A10_OLINUXINO_L"
-       depends on MACH_SUN4I
-
-config TARGET_A10S_OLINUXINO_M
-       bool "A10S_OLINUXINO_M"
-       depends on MACH_SUN5I
-
-config TARGET_A13_OLINUXINOM
-       bool "A13_OLINUXINOM"
-       depends on MACH_SUN5I
-
-config TARGET_A13_OLINUXINO
-       bool "A13_OLINUXINO"
-       depends on MACH_SUN5I
-
-config TARGET_A20_OLINUXINO_L2
-       bool "A20_OLINUXINO_L2"
-       depends on MACH_SUN7I
-
-config TARGET_A20_OLINUXINO_L
-       bool "A20_OLINUXINO_L"
-       depends on MACH_SUN7I
-
-config TARGET_A20_OLINUXINO_M
-       bool "A20_OLINUXINO_M"
-       depends on MACH_SUN7I
-
-config TARGET_AUXTEK_T004
-       bool "AUXTEK_T004"
-       depends on MACH_SUN5I
-
-config TARGET_BANANAPI
-       bool "BANANAPI"
-       depends on MACH_SUN7I
-
-config TARGET_BANANAPRO
-       bool "BANANAPRO"
-       depends on MACH_SUN7I
-
-config TARGET_COLOMBUS
-       bool "COLOMBUS"
-       depends on MACH_SUN6I
-
-config TARGET_CUBIEBOARD2
-       bool "CUBIEBOARD2"
-       depends on MACH_SUN7I
-
-config TARGET_CUBIEBOARD
-       bool "CUBIEBOARD"
-       depends on MACH_SUN4I
-
-config TARGET_CUBIETRUCK
-       bool "CUBIETRUCK"
-       depends on MACH_SUN7I
-
-config TARGET_HUMMINGBIRD_A31
-       bool "HUMMINGBIRD_A31"
-       depends on MACH_SUN6I
-
-config TARGET_IPPO_Q8H_V5
-       bool "IPPO_Q8H_V5"
-       depends on MACH_SUN8I
-
-config TARGET_PCDUINO
-       bool "PCDUINO"
-       depends on MACH_SUN4I
-
-config TARGET_PCDUINO3
-       bool "PCDUINO3"
-       depends on MACH_SUN7I
-
-config TARGET_MELE_A1000G
-       bool "MELE_A1000G"
-       depends on MACH_SUN4I
-
-config TARGET_MELE_A1000
-       bool "MELE_A1000"
-       depends on MACH_SUN4I
-
-config TARGET_MELE_M3
-       bool "MELE_M3"
-       depends on MACH_SUN7I
-
-config TARGET_MELE_M9
-       bool "MELE_M9"
-       depends on MACH_SUN6I
-
-config TARGET_MINI_X_1GB
-       bool "MINI_X_1GB"
-       depends on MACH_SUN4I
-
-config TARGET_MINI_X
-       bool "MINI_X"
-       depends on MACH_SUN4I
-
-config TARGET_MSI_PRIMO73
-       bool "MSI Primo73 (7\" tablet)"
-       depends on MACH_SUN7I
-       ---help---
-       The MSI Primo73 is an A20 based tablet, with 1G RAM, 16G NAND,
-       1024x600 TN LCD display, mono speaker, 0.3 MP front camera, 2.0 MP
-       rear camera, 3000 mAh battery, gt911 touchscreen, mma8452 accelerometer
-       and rtl8188etv usb wifi. Has "power", "volume+" and "volume-" buttons
-       (both volume buttons are also connected to the UBOOT_SEL pin). The
-       external connectors are represented by MicroSD slot, MiniHDMI, MicroUSB
-       OTG and 3.5mm headphone jack. More details are available at
-           http://linux-sunxi.org/MSI_Primo73
-
-config TARGET_MSI_PRIMO81
-       bool "MSI Primo81 (7.85\" tablet)"
-       depends on MACH_SUN6I
-       ---help---
-       The MSI Primo81 is an A31s based tablet, with 1G RAM, 16G NAND,
-       1024x768 IPS LCD display, mono speaker, 0.3 MP front camera, 2.0 MP
-       rear camera, 3500 mAh battery, gt911 touchscreen, mma8452 accelerometer
-       and rtl8188etv usb wifi. Has "power", "volume+" and "volume-" buttons
-       (both volume buttons are also connected to the UBOOT_SEL pin). The
-       external connectors are represented by MicroSD slot, MiniHDMI, MicroUSB
-       OTG and 3.5mm headphone jack. More details are available at
-           http://linux-sunxi.org/MSI_Primo81
-
-config TARGET_BA10_TV_BOX
-       bool "BA10_TV_BOX"
-       depends on MACH_SUN4I
-
-config TARGET_I12_TVBOX
-       bool "I12_TVBOX"
-       depends on MACH_SUN7I
-
-config TARGET_QT840A
-       bool "QT840A"
-       depends on MACH_SUN7I
-
-config TARGET_R7DONGLE
-       bool "R7DONGLE"
-       depends on MACH_SUN5I
-
-endchoice
-
 config SYS_BOARD
        default "sunxi"
 
@@ -321,6 +260,16 @@ config VIDEO_VGA_VIA_LCD
        LCD interface driving a VGA connector, such as found on the
        Olimex A13 boards.
 
+config VIDEO_VGA_VIA_LCD_FORCE_SYNC_ACTIVE_HIGH
+       boolean "Force sync active high for VGA via LCD controller support"
+       depends on VIDEO_VGA_VIA_LCD
+       default n
+       ---help---
+       Say Y here if you've a board which uses opendrain drivers for the vga
+       hsync and vsync signals. Opendrain drivers cannot generate steep enough
+       positive edges for a stable video output, so on boards with opendrain
+       drivers the sync signals must always be active high.
+
 config VIDEO_VGA_EXTERNAL_DAC_EN
        string "LCD panel power enable pin"
        depends on VIDEO_VGA_VIA_LCD
@@ -338,6 +287,13 @@ config VIDEO_LCD_MODE
        This is in drivers/video/videomodes.c: video_get_params() format, e.g.
        x:800,y:480,depth:18,pclk_khz:33000,le:16,ri:209,up:22,lo:22,hs:30,vs:1,sync:0,vmode:0
 
+config VIDEO_LCD_DCLK_PHASE
+       int "LCD panel display clock phase"
+       depends on VIDEO
+       default 1
+       ---help---
+       Select LCD panel display clock phase shift, range 0-3.
+
 config VIDEO_LCD_POWER
        string "LCD panel power enable pin"
        depends on VIDEO
@@ -363,6 +319,13 @@ config VIDEO_LCD_BL_PWM
        Set the backlight pwm pin for the LCD panel. This takes a string in the
        format understood by sunxi_name_to_gpio, e.g. PH1 for pin 1 of port H.
 
+config VIDEO_LCD_BL_PWM_ACTIVE_LOW
+       bool "LCD panel backlight pwm is inverted"
+       depends on VIDEO
+       default y
+       ---help---
+       Set this if the backlight pwm output is active low.
+
 
 # Note only one of these may be selected at a time! But hidden choices are
 # not supported by Kconfig
@@ -387,9 +350,32 @@ config VIDEO_LCD_PANEL_LVDS
        bool "Generic lvds interface LCD panel"
        select VIDEO_LCD_IF_LVDS
 
+config VIDEO_LCD_PANEL_MIPI_4_LANE_513_MBPS_VIA_SSD2828
+       bool "MIPI 4-lane, 513Mbps LCD panel via SSD2828 bridge chip"
+       select VIDEO_LCD_SSD2828
+       select VIDEO_LCD_IF_PARALLEL
+       ---help---
+        7.85" 768x1024 LCD panels, such as LG LP079X01 or AUO B079XAN01.0
+
+config VIDEO_LCD_PANEL_HITACHI_TX18D42VM
+       bool "Hitachi tx18d42vm LCD panel"
+       select VIDEO_LCD_HITACHI_TX18D42VM
+       select VIDEO_LCD_IF_LVDS
+       ---help---
+       7.85" 1024x768 Hitachi tx18d42vm LCD panel support
+
 endchoice
 
 
+config USB_MUSB_SUNXI
+       bool "Enable sunxi OTG / DRC USB controller in host mode"
+       default n
+       ---help---
+       Say y here to enable support for the sunxi OTG / DRC USB controller
+       used on almost all sunxi boards. Note currently u-boot can only have
+       one usb host controller enabled at a time, so enabling this on boards
+       which also use the ehci host controller will result in build errors.
+
 config USB_KEYBOARD
        boolean "Enable USB keyboard support"
        default y
@@ -397,4 +383,10 @@ config USB_KEYBOARD
        Say Y here to add support for using a USB keyboard (typically used
        in combination with a graphical console).
 
+config GMAC_TX_DELAY
+       int "GMAC Transmit Clock Delay Chain"
+       default 0
+       ---help---
+       Set the GMAC Transmit Clock Delay Chain value.
+
 endif
index 3a09be92de553482adc9b44c86b7a600e3911995..faa413cb0660678d50162e97f60a1ac36be789de 100644 (file)
@@ -5,17 +5,20 @@ F:    board/sunxi/
 F:     include/configs/sun4i.h
 F:     configs/A10-OLinuXino-Lime_defconfig
 F:     configs/ba10_tv_box_defconfig
+F:     configs/Chuwi_V7_CW0825_defconfig
 F:     configs/Cubieboard_defconfig
+F:     configs/Hyundai_A7HD_defconfig
 F:     configs/Mele_A1000_defconfig
-F:     configs/Mele_A1000G_defconfig
 F:     configs/Mele_M3_defconfig
 F:     configs/Mini-X_defconfig
-F:     configs/Mini-X-1Gb_defconfig
+F:     configs/mk802_defconfig
+F:     configs/mk802ii_defconfig
 F:     include/configs/sun5i.h
 F:     configs/A10s-OLinuXino-M_defconfig
 F:     configs/A13-OLinuXino_defconfig
 F:     configs/A13-OLinuXinoM_defconfig
 F:     configs/Auxtek-T004_defconfig
+F:     configs/mk802_a10s_defconfig
 F:     configs/r7-tv-dongle_defconfig
 F:     include/configs/sun6i.h
 F:     configs/CSQ_CS908_defconfig
@@ -31,16 +34,6 @@ F:   configs/qt840a_defconfig
 F:     include/configs/sun8i.h
 F:     configs/Ippo_q8h_v1_2_defconfig
 
-CUBIEBOARD2 BOARD
-M:     Ian Campbell <ijc@hellion.org.uk>
-M:     Hans de Goede <hdegoede@redhat.com>
-S:     Maintained
-F:     include/configs/sun7i.h
-F:     configs/Cubieboard2_defconfig
-F:     configs/Cubieboard2_FEL_defconfig
-F:     configs/Cubietruck_defconfig
-F:     configs/Cubietruck_FEL_defconfig
-
 A20-OLINUXINO-LIME BOARD
 M:     FUKAUMI Naoki <naobsd@gmail.com>
 S:     Maintained
@@ -58,16 +51,57 @@ M:  Maxime Ripard <maxime.ripard@free-electrons.com>
 S:     Maintained
 F:     configs/Colombus_defconfig
 
-HUMMINIGBIRD-A31 BOARD
+CUBIEBOARD2 BOARD
+M:     Ian Campbell <ijc@hellion.org.uk>
+M:     Hans de Goede <hdegoede@redhat.com>
+S:     Maintained
+F:     include/configs/sun7i.h
+F:     configs/Cubieboard2_defconfig
+F:     configs/Cubieboard2_FEL_defconfig
+F:     configs/Cubietruck_defconfig
+F:     configs/Cubietruck_FEL_defconfig
+
+GEMEI-G9 TABLET
+M:     Priit Laes <plaes@plaes.org>
+S:     Maintained
+F:     configs/sunxi_Gemei_G9_defconfig
+
+HUMMINGBIRD-A31 BOARD
 M:     Chen-Yu Tsai <wens@csie.org>
 S:     Maintained
 F:     configs/Hummingbird_A31_defconfig
 
+INET-86VS BOARD
+M:     Michal Suchanek <hramrach@gmail.com>
+S:     Maintained
+F:     board/sunxi/dram_inet_86vs.c
+F:     configs/Inet_86VS_defconfig
+
 IPPO-Q8H-V5 BOARD
 M:     Chen-Yu Tsai <wens@csie.org>
 S:     Maintained
 F:     configs/Ippo_q8h_v5_defconfig
 
+LINKSPRITE-PCDUINO BOARD
+M:     Zoltan Herpai <wigyori@uid0.hu>
+S:     Maintained
+F:     configs/Linksprite_pcDuino_defconfig
+
+LINKSPRITE-PCDUINO3-NANO BOARD
+M:     Adam Sampson <ats@offog.org>
+S:     Maintained
+F:     configs/Linksprite_pcDuino3_Nano_defconfig
+
+MARSBOARD-A10 BOARD
+M:     Aleksei Mamlin <mamlinav@gmail.com>
+S:     Maintained
+F:     configs/Marsboard_A10_defconfig
+
+MELE M5 BOARD
+M:     Ian Campbell <ijc@hellion.org.uk>
+S:     Maintained
+F:     configs/Mele_M5_defconfig
+
 MSI-PRIMO73 BOARD
 M:     Siarhei Siamashka <siarhei.siamashka@gmail.com>
 S:     Maintained
@@ -78,7 +112,7 @@ M:   Siarhei Siamashka <siarhei.siamashka@gmail.com>
 S:     Maintained
 F:     configs/MSI_Primo81_defconfig
 
-LINKSPRITE-PCDUINO BOARD
-M:     Zoltan Herpai <wigyori@uid0.hu>
+TZX-Q8-713B7 BOARD
+M:     Paul Kocialkowski <contact@paulk.fr>
 S:     Maintained
-F:     configs/Linksprite_pcDuino_defconfig
+F:     configs/TZX-Q8-713B7_defconfig
index fab0877a54df5aa0a73aa578205874e08eb0e464..43766e0ef482b54c1fc42fb17fa9c1bf2033f7f1 100644 (file)
 obj-y  += board.o
 obj-$(CONFIG_SUNXI_GMAC)       += gmac.o
 obj-$(CONFIG_SUNXI_AHCI)       += ahci.o
-obj-$(CONFIG_TARGET_A10_OLINUXINO_L)   += dram_a10_olinuxino_l.o
-obj-$(CONFIG_TARGET_A10S_OLINUXINO_M)  += dram_a10s_olinuxino_m.o
-obj-$(CONFIG_TARGET_A13_OLINUXINO)     += dram_a13_olinuxino.o
-obj-$(CONFIG_TARGET_A13_OLINUXINOM)    += dram_a13_oli_micro.o
-obj-$(CONFIG_TARGET_A20_OLINUXINO_L)   += dram_a20_olinuxino_l.o
-obj-$(CONFIG_TARGET_A20_OLINUXINO_L2)  += dram_a20_olinuxino_l2.o
-obj-$(CONFIG_TARGET_A20_OLINUXINO_M)   += dram_sun7i_384_1024_iow16.o
-# This is not a typo, uses the same mem settings as the a10s-olinuxino-m
-obj-$(CONFIG_TARGET_AUXTEK_T004)       += dram_a10s_olinuxino_m.o
-obj-$(CONFIG_TARGET_BA10_TV_BOX)       += dram_sun4i_384_1024_iow8.o
-obj-$(CONFIG_TARGET_BANANAPI)          += dram_bananapi.o
-obj-$(CONFIG_TARGET_BANANAPRO)         += dram_bananapi.o
-obj-$(CONFIG_TARGET_CUBIEBOARD)                += dram_cubieboard.o
-obj-$(CONFIG_TARGET_CUBIEBOARD2)       += dram_cubieboard2.o
-obj-$(CONFIG_TARGET_CUBIETRUCK)                += dram_cubietruck.o
-obj-$(CONFIG_TARGET_I12_TVBOX)         += dram_sun7i_384_1024_iow16.o
-obj-$(CONFIG_TARGET_MELE_A1000)                += dram_sun4i_360_512.o
-obj-$(CONFIG_TARGET_MELE_A1000G)       += dram_sun4i_360_1024_iow8.o
-obj-$(CONFIG_TARGET_MELE_M3)           += dram_sun7i_384_1024_iow16.o
-obj-$(CONFIG_TARGET_MINI_X)            += dram_sun4i_360_512.o
-obj-$(CONFIG_TARGET_MINI_X_1GB)                += dram_sun4i_360_1024_iow16.o
-obj-$(CONFIG_TARGET_MSI_PRIMO73)       += dram_sun7i_384_1024_iow16.o
-obj-$(CONFIG_TARGET_PCDUINO)           += dram_sun4i_408_1024_iow8.o
-obj-$(CONFIG_TARGET_PCDUINO3)          += dram_linksprite_pcduino3.o
-obj-$(CONFIG_TARGET_QT840A)            += dram_sun7i_384_512_busw16_iow16.o
-obj-$(CONFIG_TARGET_R7DONGLE)          += dram_r7dongle.o
+obj-$(CONFIG_MACH_SUN4I)       += dram_sun4i_auto.o
+obj-$(CONFIG_MACH_SUN5I)       += dram_sun5i_auto.o
+obj-$(CONFIG_MACH_SUN7I)       += dram_sun5i_auto.o
index 7d6d075f145ee93d4e3463544b7ccd3694ec9771..b70e00ce6bced72c405554e4951a076a48338069 100644 (file)
@@ -28,7 +28,9 @@
 #include <asm/arch/dram.h>
 #include <asm/arch/gpio.h>
 #include <asm/arch/mmc.h>
+#include <asm/arch/usbc.h>
 #include <asm/io.h>
+#include <linux/usb/musb.h>
 #include <net.h>
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -189,6 +191,7 @@ void sunxi_board_init(void)
        power_failed |= axp221_set_aldo1(CONFIG_AXP221_ALDO1_VOLT);
        power_failed |= axp221_set_aldo2(CONFIG_AXP221_ALDO2_VOLT);
        power_failed |= axp221_set_aldo3(CONFIG_AXP221_ALDO3_VOLT);
+       power_failed |= axp221_set_eldo(3, CONFIG_AXP221_ELDO3_VOLT);
 #endif
 
        printf("DRAM:");
@@ -208,6 +211,26 @@ void sunxi_board_init(void)
 }
 #endif
 
+#if defined(CONFIG_MUSB_HOST) || defined(CONFIG_MUSB_GADGET)
+static struct musb_hdrc_config musb_config = {
+       .multipoint     = 1,
+       .dyn_fifo       = 1,
+       .num_eps        = 6,
+       .ram_bits       = 11,
+};
+
+static struct musb_hdrc_platform_data musb_plat = {
+#if defined(CONFIG_MUSB_HOST)
+       .mode           = MUSB_HOST,
+#else
+       .mode           = MUSB_PERIPHERAL,
+#endif
+       .config         = &musb_config,
+       .power          = 250,
+       .platform_ops   = &sunxi_musb_ops,
+};
+#endif
+
 #ifdef CONFIG_MISC_INIT_R
 int misc_init_r(void)
 {
@@ -227,6 +250,9 @@ int misc_init_r(void)
                eth_setenv_enetaddr("ethaddr", mac_addr);
        }
 
+#if defined(CONFIG_MUSB_HOST) || defined(CONFIG_MUSB_GADGET)
+       musb_register(&musb_plat, NULL, (void *)SUNXI_USB0_BASE);
+#endif
        return 0;
 }
 #endif
diff --git a/board/sunxi/dram_a10_olinuxino_l.c b/board/sunxi/dram_a10_olinuxino_l.c
deleted file mode 100644 (file)
index 24a1bd9..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/* this file is generated, don't edit it yourself */
-
-#include <common.h>
-#include <asm/arch/dram.h>
-
-static struct dram_para dram_para = {
-       .clock = 480,
-       .type = 3,
-       .rank_num = 1,
-       .density = 4096,
-       .io_width = 16,
-       .bus_width = 16,
-       .cas = 6,
-       .zq = 123,
-       .odt_en = 0,
-       .size = 512,
-       .tpr0 = 0x30926692,
-       .tpr1 = 0x1090,
-       .tpr2 = 0x1a0c8,
-       .tpr3 = 0,
-       .tpr4 = 0,
-       .tpr5 = 0,
-       .emr1 = 0x4,
-       .emr2 = 0,
-       .emr3 = 0,
-};
-
-unsigned long sunxi_dram_init(void)
-{
-       return dramc_init(&dram_para);
-}
diff --git a/board/sunxi/dram_a10s_olinuxino_m.c b/board/sunxi/dram_a10s_olinuxino_m.c
deleted file mode 100644 (file)
index 8900539..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/* this file is generated, don't edit it yourself */
-
-#include <common.h>
-#include <asm/arch/dram.h>
-
-static struct dram_para dram_para = {
-       .clock = 432,
-       .type = 3,
-       .rank_num = 1,
-       .density = 4096,
-       .io_width = 16,
-       .bus_width = 16,
-       .cas = 9,
-       .zq = 123,
-       .odt_en = 0,
-       .size = 512,
-       .tpr0 = 0x42d899b7,
-       .tpr1 = 0xa090,
-       .tpr2 = 0x22a00,
-       .tpr3 = 0,
-       .tpr4 = 0,
-       .tpr5 = 0,
-       .emr1 = 0x4,
-       .emr2 = 0x10,
-       .emr3 = 0,
-};
-
-unsigned long sunxi_dram_init(void)
-{
-       return dramc_init(&dram_para);
-}
diff --git a/board/sunxi/dram_a13_oli_micro.c b/board/sunxi/dram_a13_oli_micro.c
deleted file mode 100644 (file)
index 8154ea2..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/* this file is generated, don't edit it yourself */
-
-#include <common.h>
-#include <asm/arch/dram.h>
-
-static struct dram_para dram_para = {
-       .clock = 408,
-       .type = 3,
-       .rank_num = 1,
-       .density = 2048,
-       .io_width = 16,
-       .bus_width = 16,
-       .cas = 9,
-       .zq = 123,
-       .odt_en = 0,
-       .size = 256,
-       .tpr0 = 0x42d899b7,
-       .tpr1 = 0xa090,
-       .tpr2 = 0x22a00,
-       .tpr3 = 0,
-       .tpr4 = 0,
-       .tpr5 = 0,
-       .emr1 = 0,
-       .emr2 = 0x10,
-       .emr3 = 0,
-
-};
-
-unsigned long sunxi_dram_init(void)
-{
-       return dramc_init(&dram_para);
-}
diff --git a/board/sunxi/dram_a13_olinuxino.c b/board/sunxi/dram_a13_olinuxino.c
deleted file mode 100644 (file)
index ca96260..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/* this file is generated, don't edit it yourself */
-
-#include <common.h>
-#include <asm/arch/dram.h>
-
-static struct dram_para dram_para = {
-       .clock = 408,
-       .type = 3,
-       .rank_num = 1,
-       .density = 2048,
-       .io_width = 8,
-       .bus_width = 16,
-       .cas = 9,
-       .zq = 123,
-       .odt_en = 0,
-       .size = 512,
-       .tpr0 = 0x42d899b7,
-       .tpr1 = 0xa090,
-       .tpr2 = 0x22a00,
-       .tpr3 = 0,
-       .tpr4 = 0,
-       .tpr5 = 0,
-       .emr1 = 0,
-       .emr2 = 0x10,
-       .emr3 = 0,
-};
-
-unsigned long sunxi_dram_init(void)
-{
-       return dramc_init(&dram_para);
-}
diff --git a/board/sunxi/dram_a20_olinuxino_l.c b/board/sunxi/dram_a20_olinuxino_l.c
deleted file mode 100644 (file)
index 2c74999..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/* this file is generated, don't edit it yourself */
-
-#include "common.h"
-#include <asm/arch/dram.h>
-
-static struct dram_para dram_para = {
-       .clock = 480,
-       .type = 3,
-       .rank_num = 1,
-       .density = 4096,
-       .io_width = 16,
-       .bus_width = 16,
-       .cas = 9,
-       .zq = 0x7f,
-       .odt_en = 0,
-       .size = 512,
-       .tpr0 = 0x42d899b7,
-       .tpr1 = 0xa090,
-       .tpr2 = 0x22a00,
-       .tpr3 = 0,
-       .tpr4 = 0,
-       .tpr5 = 0,
-       .emr1 = 0x4,
-       .emr2 = 0x10,
-       .emr3 = 0,
-};
-
-unsigned long sunxi_dram_init(void)
-{
-       return dramc_init(&dram_para);
-}
diff --git a/board/sunxi/dram_a20_olinuxino_l2.c b/board/sunxi/dram_a20_olinuxino_l2.c
deleted file mode 100644 (file)
index 2115d37..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/* this file is generated, don't edit it yourself */
-
-#include <common.h>
-#include <asm/arch/dram.h>
-
-static struct dram_para dram_para = {
-       .clock = 480,
-       .type = 3,
-       .rank_num = 1,
-       .density = 4096,
-       .io_width = 16,
-       .bus_width = 32,
-       .cas = 9,
-       .zq = 0x7f,
-       .odt_en = 0,
-       .size = 1024,
-       .tpr0 = 0x42d899b7,
-       .tpr1 = 0xa090,
-       .tpr2 = 0x22a00,
-       .tpr3 = 0,
-       .tpr4 = 0,
-       .tpr5 = 0,
-       .emr1 = 0x4,
-       .emr2 = 0x10,
-       .emr3 = 0,
-};
-
-unsigned long sunxi_dram_init(void)
-{
-       return dramc_init(&dram_para);
-}
diff --git a/board/sunxi/dram_bananapi.c b/board/sunxi/dram_bananapi.c
deleted file mode 100644 (file)
index 0ed7943..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/* this file is generated, don't edit it yourself */
-
-#include <common.h>
-#include <asm/arch/dram.h>
-
-static struct dram_para dram_para = {
-       .clock = 432,
-       .type = 3,
-       .rank_num = 1,
-       .density = 4096,
-       .io_width = 16,
-       .bus_width = 32,
-       .cas = 9,
-       .zq = 0x7f,
-       .odt_en = 0,
-       .size = 1024,
-       .tpr0 = 0x42d899b7,
-       .tpr1 = 0xa090,
-       .tpr2 = 0x22a00,
-       .tpr3 = 0x0,
-       .tpr4 = 0x1,
-       .tpr5 = 0x0,
-       .emr1 = 0x4,
-       .emr2 = 0x10,
-       .emr3 = 0x0,
-};
-
-unsigned long sunxi_dram_init(void)
-{
-       return dramc_init(&dram_para);
-}
diff --git a/board/sunxi/dram_cubieboard.c b/board/sunxi/dram_cubieboard.c
deleted file mode 100644 (file)
index 399028c..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/* this file is generated, don't edit it yourself */
-
-#include <common.h>
-#include <asm/arch/dram.h>
-
-static struct dram_para dram_para = {
-       .clock = 480,
-       .type = 3,
-       .rank_num = 1,
-       .density = 4096,
-       .io_width = 16,
-       .bus_width = 32,
-       .cas = 6,
-       .zq = 123,
-       .odt_en = 0,
-       .size = 1024,
-       .tpr0 = 0x30926692,
-       .tpr1 = 0x1090,
-       .tpr2 = 0x1a0c8,
-       .tpr3 = 0,
-       .tpr4 = 0,
-       .tpr5 = 0,
-       .emr1 = 0,
-       .emr2 = 0,
-       .emr3 = 0,
-};
-
-unsigned long sunxi_dram_init(void)
-{
-       return dramc_init(&dram_para);
-}
diff --git a/board/sunxi/dram_cubieboard2.c b/board/sunxi/dram_cubieboard2.c
deleted file mode 100644 (file)
index 9e75367..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/* this file is generated, don't edit it yourself */
-
-#include <common.h>
-#include <asm/arch/dram.h>
-
-static struct dram_para dram_para = {
-       .clock = 480,
-       .type = 3,
-       .rank_num = 1,
-       .density = 4096,
-       .io_width = 16,
-       .bus_width = 32,
-       .cas = 9,
-       .zq = 0x7f,
-       .odt_en = 0,
-       .size = 1024,
-       .tpr0 = 0x42d899b7,
-       .tpr1 = 0xa090,
-       .tpr2 = 0x22a00,
-       .tpr3 = 0x0,
-       .tpr4 = 0x1,
-       .tpr5 = 0x0,
-       .emr1 = 0x4,
-       .emr2 = 0x10,
-       .emr3 = 0x0,
-};
-
-unsigned long sunxi_dram_init(void)
-{
-       return dramc_init(&dram_para);
-}
diff --git a/board/sunxi/dram_cubietruck.c b/board/sunxi/dram_cubietruck.c
deleted file mode 100644 (file)
index fbcd687..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/* this file is generated, don't edit it yourself */
-
-#include <common.h>
-#include <asm/arch/dram.h>
-
-static struct dram_para dram_para = {
-       .clock = 432,
-       .type = 3,
-       .rank_num = 1,
-       .density = 4096,
-       .io_width = 8,
-       .bus_width = 32,
-       .cas = 9,
-       .zq = 0x7f,
-       .odt_en = 0,
-       .size = 2048,
-       .tpr0 = 0x42d899b7,
-       .tpr1 = 0xa090,
-       .tpr2 = 0x22a00,
-       .tpr3 = 0x0,
-       .tpr4 = 0x1,
-       .tpr5 = 0x0,
-       .emr1 = 0x4,
-       .emr2 = 0x10,
-       .emr3 = 0x0,
-};
-
-unsigned long sunxi_dram_init(void)
-{
-       return dramc_init(&dram_para);
-}
diff --git a/board/sunxi/dram_linksprite_pcduino3.c b/board/sunxi/dram_linksprite_pcduino3.c
deleted file mode 100644 (file)
index 9cc6e19..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/* this file is generated, don't edit it yourself */
-
-#include <common.h>
-#include <asm/arch/dram.h>
-
-static struct dram_para dram_para = {
-       .clock = 480,
-       .type = 3,
-       .rank_num = 1,
-       .density = 4096,
-       .io_width = 16,
-       .bus_width = 32,
-       .cas = 9,
-       .zq = 0x7a,
-       .odt_en = 0,
-       .size = 1024,
-       .tpr0 = 0x42d899b7,
-       .tpr1 = 0xa090,
-       .tpr2 = 0x22a00,
-       .tpr3 = 0,
-       .tpr4 = 0,
-       .tpr5 = 0,
-       .emr1 = 0x4,
-       .emr2 = 0x10,
-       .emr3 = 0x0,
-};
-
-unsigned long sunxi_dram_init(void)
-{
-       return dramc_init(&dram_para);
-}
diff --git a/board/sunxi/dram_r7dongle.c b/board/sunxi/dram_r7dongle.c
deleted file mode 100644 (file)
index 59343cb..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/* this file is generated, don't edit it yourself */
-
-#include <common.h>
-#include <asm/arch/dram.h>
-
-static struct dram_para dram_para = {
-       .clock = 384,
-       .type = 3,
-       .rank_num = 1,
-       .density = 2048,
-       .io_width = 8,
-       .bus_width = 32,
-       .cas = 9,
-       .zq = 123,
-       .odt_en = 0,
-       .size = 1024,
-       .tpr0 = 0x42d899b7,
-       .tpr1 = 0xa090,
-       .tpr2 = 0x22a00,
-       .tpr3 = 0,
-       .tpr4 = 0,
-       .tpr5 = 0,
-       .emr1 = 0x04,
-       .emr2 = 0x10,
-       .emr3 = 0,
-};
-
-unsigned long sunxi_dram_init(void)
-{
-       return dramc_init(&dram_para);
-}
diff --git a/board/sunxi/dram_sun4i_360_1024_iow16.c b/board/sunxi/dram_sun4i_360_1024_iow16.c
deleted file mode 100644 (file)
index 3763713..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/* this file is generated, don't edit it yourself */
-
-#include <common.h>
-#include <asm/arch/dram.h>
-
-static struct dram_para dram_para = {
-       .clock = 360,
-       .type = 3,
-       .rank_num = 1,
-       .density = 4096,
-       .io_width = 16,
-       .bus_width = 32,
-       .cas = 6,
-       .zq = 123,
-       .odt_en = 0,
-       .size = 1024,
-       .tpr0 = 0x30926692,
-       .tpr1 = 0x1090,
-       .tpr2 = 0x1a0c8,
-       .tpr3 = 0,
-       .tpr4 = 0,
-       .tpr5 = 0,
-       .emr1 = 0,
-       .emr2 = 0,
-       .emr3 = 0,
-};
-
-unsigned long sunxi_dram_init(void)
-{
-       return dramc_init(&dram_para);
-}
diff --git a/board/sunxi/dram_sun4i_360_1024_iow8.c b/board/sunxi/dram_sun4i_360_1024_iow8.c
deleted file mode 100644 (file)
index 2a5c9ed..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/* this file is generated, don't edit it yourself */
-
-#include <common.h>
-#include <asm/arch/dram.h>
-
-static struct dram_para dram_para = {
-       .clock = 360,
-       .type = 3,
-       .rank_num = 1,
-       .density = 2048,
-       .io_width = 8,
-       .bus_width = 32,
-       .cas = 6,
-       .zq = 123,
-       .odt_en = 0,
-       .size = 1024,
-       .tpr0 = 0x30926692,
-       .tpr1 = 0x1090,
-       .tpr2 = 0x1a0c8,
-       .tpr3 = 0,
-       .tpr4 = 0,
-       .tpr5 = 0,
-       .emr1 = 0,
-       .emr2 = 0,
-       .emr3 = 0,
-};
-
-unsigned long sunxi_dram_init(void)
-{
-       return dramc_init(&dram_para);
-}
diff --git a/board/sunxi/dram_sun4i_360_512.c b/board/sunxi/dram_sun4i_360_512.c
deleted file mode 100644 (file)
index 48aa6e2..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/* this file is generated, don't edit it yourself */
-
-#include <common.h>
-#include <asm/arch/dram.h>
-
-static struct dram_para dram_para = {
-       .clock = 360,
-       .type = 3,
-       .rank_num = 1,
-       .density = 2048,
-       .io_width = 16,
-       .bus_width = 32,
-       .cas = 6,
-       .zq = 123,
-       .odt_en = 0,
-       .size = 512,
-       .tpr0 = 0x30926692,
-       .tpr1 = 0x1090,
-       .tpr2 = 0x1a0c8,
-       .tpr3 = 0,
-       .tpr4 = 0,
-       .tpr5 = 0,
-       .emr1 = 0,
-       .emr2 = 0,
-       .emr3 = 0,
-};
-
-unsigned long sunxi_dram_init(void)
-{
-       return dramc_init(&dram_para);
-}
diff --git a/board/sunxi/dram_sun4i_384_1024_iow8.c b/board/sunxi/dram_sun4i_384_1024_iow8.c
deleted file mode 100644 (file)
index b0fcc55..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/* this file is generated, don't edit it yourself */
-
-#include <common.h>
-#include <asm/arch/dram.h>
-
-static struct dram_para dram_para = {
-       .clock = 384,
-       .type = 3,
-       .rank_num = 1,
-       .density = 2048,
-       .io_width = 8,
-       .bus_width = 32,
-       .cas = 6,
-       .zq = 123,
-       .odt_en = 0,
-       .size = 1024,
-       .tpr0 = 0x30926692,
-       .tpr1 = 0x1090,
-       .tpr2 = 0x1a0c8,
-       .tpr3 = 0,
-       .tpr4 = 0,
-       .tpr5 = 0,
-       .emr1 = 0x4,
-       .emr2 = 0,
-       .emr3 = 0,
-};
-
-unsigned long sunxi_dram_init(void)
-{
-       return dramc_init(&dram_para);
-}
diff --git a/board/sunxi/dram_sun4i_408_1024_iow8.c b/board/sunxi/dram_sun4i_408_1024_iow8.c
deleted file mode 100644 (file)
index c6d87d2..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/* this file is generated, don't edit it yourself */
-
-#include <common.h>
-#include <asm/arch/dram.h>
-
-static struct dram_para dram_para = {
-       .clock = 408,
-       .type = 3,
-       .rank_num = 1,
-       .density = 2048,
-       .io_width = 8,
-       .bus_width = 32,
-       .cas = 6,
-       .zq = 123,
-       .odt_en = 0,
-       .size = 1024,
-       .tpr0 = 0x30926692,
-       .tpr1 = 0x1090,
-       .tpr2 = 0x1a0c8,
-       .tpr3 = 0,
-       .tpr4 = 0,
-       .tpr5 = 0,
-       .emr1 = 0,
-       .emr2 = 0,
-       .emr3 = 0,
-};
-
-unsigned long sunxi_dram_init(void)
-{
-       return dramc_init(&dram_para);
-}
diff --git a/board/sunxi/dram_sun4i_auto.c b/board/sunxi/dram_sun4i_auto.c
new file mode 100644 (file)
index 0000000..09e0c9a
--- /dev/null
@@ -0,0 +1,35 @@
+#include <common.h>
+#include <asm/arch/dram.h>
+
+static struct dram_para dram_para = {
+       .clock = CONFIG_DRAM_CLK,
+       .type = 3,
+       .rank_num = 1,
+       .density = 0,
+       .io_width = 0,
+       .bus_width = 0,
+       .zq = CONFIG_DRAM_ZQ,
+       .odt_en = CONFIG_DRAM_ODT_EN,
+       .size = 0,
+#ifdef CONFIG_DRAM_TIMINGS_VENDOR_MAGIC
+       .cas = 6,
+       .tpr0 = 0x30926692,
+       .tpr1 = 0x1090,
+       .tpr2 = 0x1a0c8,
+       .emr2 = 0,
+#else
+#      include "dram_timings_sun4i.h"
+       .active_windowing = 1,
+#endif
+       .tpr3 = CONFIG_DRAM_TPR3,
+       .tpr4 = 0,
+       .tpr5 = 0,
+       .emr1 = CONFIG_DRAM_EMR1,
+       .emr3 = 0,
+       .dqs_gating_delay = CONFIG_DRAM_DQS_GATING_DELAY,
+};
+
+unsigned long sunxi_dram_init(void)
+{
+       return dramc_init(&dram_para);
+}
diff --git a/board/sunxi/dram_sun5i_auto.c b/board/sunxi/dram_sun5i_auto.c
new file mode 100644 (file)
index 0000000..e52d54c
--- /dev/null
@@ -0,0 +1,38 @@
+/* DRAM parameters for auto dram configuration on sun5i and sun7i */
+
+#include <common.h>
+#include <asm/arch/dram.h>
+
+static struct dram_para dram_para = {
+       .clock = CONFIG_DRAM_CLK,
+       .mbus_clock = CONFIG_DRAM_MBUS_CLK,
+       .type = 3,
+       .rank_num = 1,
+       .density = 0,
+       .io_width = 0,
+       .bus_width = 0,
+       .zq = CONFIG_DRAM_ZQ,
+       .odt_en = CONFIG_DRAM_ODT_EN,
+       .size = 0,
+#ifdef CONFIG_DRAM_TIMINGS_VENDOR_MAGIC
+       .cas = 9,
+       .tpr0 = 0x42d899b7,
+       .tpr1 = 0xa090,
+       .tpr2 = 0x22a00,
+       .emr2 = 0x10,
+#else
+#      include "dram_timings_sun4i.h"
+       .active_windowing = 1,
+#endif
+       .tpr3 = 0,
+       .tpr4 = 0,
+       .tpr5 = 0,
+       .emr1 = CONFIG_DRAM_EMR1,
+       .emr3 = 0,
+       .dqs_gating_delay = CONFIG_DRAM_DQS_GATING_DELAY,
+};
+
+unsigned long sunxi_dram_init(void)
+{
+       return dramc_init(&dram_para);
+}
diff --git a/board/sunxi/dram_sun7i_384_1024_iow16.c b/board/sunxi/dram_sun7i_384_1024_iow16.c
deleted file mode 100644 (file)
index 04e4b1e..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/* this file is generated, don't edit it yourself */
-
-#include "common.h"
-#include <asm/arch/dram.h>
-
-static struct dram_para dram_para = {
-       .clock = 384,
-       .type = 3,
-       .rank_num = 1,
-       .density = 4096,
-       .io_width = 16,
-       .bus_width = 32,
-       .cas = 9,
-       .zq = 0x7f,
-       .odt_en = 0,
-       .size = 1024,
-       .tpr0 = 0x42d899b7,
-       .tpr1 = 0xa090,
-       .tpr2 = 0x22a00,
-       .tpr3 = 0,
-       .tpr4 = 0,
-       .tpr5 = 0,
-       .emr1 = 0x4,
-       .emr2 = 0x10,
-       .emr3 = 0,
-};
-
-unsigned long sunxi_dram_init(void)
-{
-       return dramc_init(&dram_para);
-}
diff --git a/board/sunxi/dram_sun7i_384_512_busw16_iow16.c b/board/sunxi/dram_sun7i_384_512_busw16_iow16.c
deleted file mode 100644 (file)
index 2e36011..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/* this file is generated, don't edit it yourself */
-
-#include "common.h"
-#include <asm/arch/dram.h>
-
-static struct dram_para dram_para = {
-       .clock = 384,
-       .type = 3,
-       .rank_num = 1,
-       .density = 4096,
-       .io_width = 16,
-       .bus_width = 16,
-       .cas = 9,
-       .zq = 0x7f,
-       .odt_en = 0,
-       .size = 512,
-       .tpr0 = 0x42d899b7,
-       .tpr1 = 0xa090,
-       .tpr2 = 0x22a00,
-       .tpr3 = 0,
-       .tpr4 = 0,
-       .tpr5 = 0,
-       .emr1 = 0x4,
-       .emr2 = 0x10,
-       .emr3 = 0,
-};
-
-unsigned long sunxi_dram_init(void)
-{
-       return dramc_init(&dram_para);
-}
diff --git a/board/sunxi/dram_timings_sun4i.h b/board/sunxi/dram_timings_sun4i.h
new file mode 100644 (file)
index 0000000..29b934d
--- /dev/null
@@ -0,0 +1,205 @@
+/* This file is automatically generated, do not edit */
+
+#if defined(CONFIG_DRAM_TIMINGS_DDR3_1066F_1333H)
+# if CONFIG_DRAM_CLK <= 360 /* DDR3-1066F @360MHz, timings: 6-5-5-14 */
+       .cas  = 6,
+       .tpr0 = 0x268e5590,
+       .tpr1 = 0xa090,
+       .tpr2 = 0x22a00,
+       .emr2 = 0x0,
+# elif CONFIG_DRAM_CLK <= 384 /* DDR3-1066F @384MHz, timings: 6-6-6-15 */
+       .cas  = 6,
+       .tpr0 = 0x288f6690,
+       .tpr1 = 0xa0a0,
+       .tpr2 = 0x22a00,
+       .emr2 = 0x0,
+# elif CONFIG_DRAM_CLK <= 396 /* DDR3-1066F @396MHz, timings: 6-6-6-15 */
+       .cas  = 6,
+       .tpr0 = 0x2a8f6690,
+       .tpr1 = 0xa0a0,
+       .tpr2 = 0x22a00,
+       .emr2 = 0x0,
+# elif CONFIG_DRAM_CLK <= 408 /* DDR3-1066F @408MHz, timings: 7-6-6-16 */
+       .cas  = 7,
+       .tpr0 = 0x2ab06690,
+       .tpr1 = 0xa0a8,
+       .tpr2 = 0x22a00,
+       .emr2 = 0x8,
+# elif CONFIG_DRAM_CLK <= 432 /* DDR3-1066F @432MHz, timings: 7-6-6-17 */
+       .cas  = 7,
+       .tpr0 = 0x2cb16690,
+       .tpr1 = 0xa0b0,
+       .tpr2 = 0x22e00,
+       .emr2 = 0x8,
+# elif CONFIG_DRAM_CLK <= 456 /* DDR3-1066F @456MHz, timings: 7-6-6-18 */
+       .cas  = 7,
+       .tpr0 = 0x30b26690,
+       .tpr1 = 0xa0b8,
+       .tpr2 = 0x22e00,
+       .emr2 = 0x8,
+# elif CONFIG_DRAM_CLK <= 468 /* DDR3-1066F @468MHz, timings: 7-7-7-18 */
+       .cas  = 7,
+       .tpr0 = 0x30b27790,
+       .tpr1 = 0xa0c0,
+       .tpr2 = 0x23200,
+       .emr2 = 0x8,
+# elif CONFIG_DRAM_CLK <= 480 /* DDR3-1066F @480MHz, timings: 7-7-7-18 */
+       .cas  = 7,
+       .tpr0 = 0x32b27790,
+       .tpr1 = 0xa0c0,
+       .tpr2 = 0x23200,
+       .emr2 = 0x8,
+# elif CONFIG_DRAM_CLK <= 504 /* DDR3-1066F @504MHz, timings: 7-7-7-19 */
+       .cas  = 7,
+       .tpr0 = 0x34d37790,
+       .tpr1 = 0xa0d0,
+       .tpr2 = 0x23600,
+       .emr2 = 0x8,
+# elif CONFIG_DRAM_CLK <= 528 /* DDR3-1066F @528MHz, timings: 7-7-7-20 */
+       .cas  = 7,
+       .tpr0 = 0x36d47790,
+       .tpr1 = 0xa0d8,
+       .tpr2 = 0x23600,
+       .emr2 = 0x8,
+# elif CONFIG_DRAM_CLK <= 540 /* DDR3-1333H @540MHz, timings: 9-8-8-20 */
+       .cas  = 9,
+       .tpr0 = 0x36b488b4,
+       .tpr1 = 0xa0c8,
+       .tpr2 = 0x2b600,
+       .emr2 = 0x10,
+# elif CONFIG_DRAM_CLK <= 552 /* DDR3-1333H @552MHz, timings: 9-8-8-20 */
+       .cas  = 9,
+       .tpr0 = 0x38b488b4,
+       .tpr1 = 0xa0c8,
+       .tpr2 = 0x2ba00,
+       .emr2 = 0x10,
+# elif CONFIG_DRAM_CLK <= 576 /* DDR3-1333H @576MHz, timings: 9-8-8-21 */
+       .cas  = 9,
+       .tpr0 = 0x3ab588b4,
+       .tpr1 = 0xa0d0,
+       .tpr2 = 0x2ba00,
+       .emr2 = 0x10,
+# elif CONFIG_DRAM_CLK <= 600 /* DDR3-1333H @600MHz, timings: 9-9-9-22 */
+       .cas  = 9,
+       .tpr0 = 0x3cb699b4,
+       .tpr1 = 0xa0d8,
+       .tpr2 = 0x2be00,
+       .emr2 = 0x10,
+# elif CONFIG_DRAM_CLK <= 624 /* DDR3-1333H @624MHz, timings: 9-9-9-23 */
+       .cas  = 9,
+       .tpr0 = 0x3eb799b4,
+       .tpr1 = 0xa0e8,
+       .tpr2 = 0x2be00,
+       .emr2 = 0x10,
+# elif CONFIG_DRAM_CLK <= 648 /* DDR3-1333H @648MHz, timings: 9-9-9-24 */
+       .cas  = 9,
+       .tpr0 = 0x42b899b4,
+       .tpr1 = 0xa0f0,
+       .tpr2 = 0x2c200,
+       .emr2 = 0x10,
+# else
+#   error CONFIG_DRAM_CLK is set too high
+# endif
+#elif defined(CONFIG_DRAM_TIMINGS_DDR3_800E_1066G_1333J)
+# if CONFIG_DRAM_CLK <= 360 /* DDR3-800E @360MHz, timings: 6-6-6-14 */
+       .cas  = 6,
+       .tpr0 = 0x268e6690,
+       .tpr1 = 0xa090,
+       .tpr2 = 0x22a00,
+       .emr2 = 0x0,
+# elif CONFIG_DRAM_CLK <= 384 /* DDR3-800E @384MHz, timings: 6-6-6-15 */
+       .cas  = 6,
+       .tpr0 = 0x2a8f6690,
+       .tpr1 = 0xa0a0,
+       .tpr2 = 0x22a00,
+       .emr2 = 0x0,
+# elif CONFIG_DRAM_CLK <= 396 /* DDR3-800E @396MHz, timings: 6-6-6-15 */
+       .cas  = 6,
+       .tpr0 = 0x2a8f6690,
+       .tpr1 = 0xa0a0,
+       .tpr2 = 0x22a00,
+       .emr2 = 0x0,
+# elif CONFIG_DRAM_CLK <= 408 /* DDR3-1066G @408MHz, timings: 8-7-7-16 */
+       .cas  = 8,
+       .tpr0 = 0x2cb07790,
+       .tpr1 = 0xa0a8,
+       .tpr2 = 0x22a00,
+       .emr2 = 0x8,
+# elif CONFIG_DRAM_CLK <= 432 /* DDR3-1066G @432MHz, timings: 8-7-7-17 */
+       .cas  = 8,
+       .tpr0 = 0x2eb17790,
+       .tpr1 = 0xa0b0,
+       .tpr2 = 0x22e00,
+       .emr2 = 0x8,
+# elif CONFIG_DRAM_CLK <= 456 /* DDR3-1066G @456MHz, timings: 8-7-7-18 */
+       .cas  = 8,
+       .tpr0 = 0x30b27790,
+       .tpr1 = 0xa0b8,
+       .tpr2 = 0x22e00,
+       .emr2 = 0x8,
+# elif CONFIG_DRAM_CLK <= 468 /* DDR3-1066G @468MHz, timings: 8-8-8-18 */
+       .cas  = 8,
+       .tpr0 = 0x32b28890,
+       .tpr1 = 0xa0c0,
+       .tpr2 = 0x23200,
+       .emr2 = 0x8,
+# elif CONFIG_DRAM_CLK <= 480 /* DDR3-1066G @480MHz, timings: 8-8-8-18 */
+       .cas  = 8,
+       .tpr0 = 0x34b28890,
+       .tpr1 = 0xa0c0,
+       .tpr2 = 0x23200,
+       .emr2 = 0x8,
+# elif CONFIG_DRAM_CLK <= 504 /* DDR3-1066G @504MHz, timings: 8-8-8-19 */
+       .cas  = 8,
+       .tpr0 = 0x36d38890,
+       .tpr1 = 0xa0d0,
+       .tpr2 = 0x23600,
+       .emr2 = 0x8,
+# elif CONFIG_DRAM_CLK <= 528 /* DDR3-1066G @528MHz, timings: 8-8-8-20 */
+       .cas  = 8,
+       .tpr0 = 0x38d48890,
+       .tpr1 = 0xa0d8,
+       .tpr2 = 0x23600,
+       .emr2 = 0x8,
+# elif CONFIG_DRAM_CLK <= 540 /* DDR3-1333J @540MHz, timings: 10-9-9-20 */
+       .cas  = 10,
+       .tpr0 = 0x38b499b4,
+       .tpr1 = 0xa0c8,
+       .tpr2 = 0x2b600,
+       .emr2 = 0x10,
+# elif CONFIG_DRAM_CLK <= 552 /* DDR3-1333J @552MHz, timings: 10-9-9-20 */
+       .cas  = 10,
+       .tpr0 = 0x3ab499b4,
+       .tpr1 = 0xa0c8,
+       .tpr2 = 0x2ba00,
+       .emr2 = 0x10,
+# elif CONFIG_DRAM_CLK <= 576 /* DDR3-1333J @576MHz, timings: 10-9-9-21 */
+       .cas  = 10,
+       .tpr0 = 0x3cb599b4,
+       .tpr1 = 0xa0d0,
+       .tpr2 = 0x2ba00,
+       .emr2 = 0x10,
+# elif CONFIG_DRAM_CLK <= 600 /* DDR3-1333J @600MHz, timings: 10-9-9-22 */
+       .cas  = 10,
+       .tpr0 = 0x3eb699b4,
+       .tpr1 = 0xa0d8,
+       .tpr2 = 0x2be00,
+       .emr2 = 0x10,
+# elif CONFIG_DRAM_CLK <= 624 /* DDR3-1333J @624MHz, timings: 10-10-10-23 */
+       .cas  = 10,
+       .tpr0 = 0x40b7aab4,
+       .tpr1 = 0xa0e8,
+       .tpr2 = 0x2be00,
+       .emr2 = 0x10,
+# elif CONFIG_DRAM_CLK <= 648 /* DDR3-1333J @648MHz, timings: 10-10-10-24 */
+       .cas  = 10,
+       .tpr0 = 0x44b8aab4,
+       .tpr1 = 0xa0f0,
+       .tpr2 = 0x2c200,
+       .emr2 = 0x10,
+# else
+#   error CONFIG_DRAM_CLK is set too high
+# endif
+#else
+# error CONFIG_DRAM_TIMINGS_* is not defined
+#endif
index 4e4615e12f654fed06c8200ce5061e1ba76e2493..884913262792900bb58fd258050e496921f93804 100644 (file)
@@ -24,20 +24,13 @@ int sunxi_gmac_initialize(bd_t *bis)
 #ifdef CONFIG_RGMII
        setbits_le32(&ccm->gmac_clk_cfg, CCM_GMAC_CTRL_TX_CLK_SRC_INT_RGMII |
                CCM_GMAC_CTRL_GPIT_RGMII);
+       setbits_le32(&ccm->gmac_clk_cfg,
+                    CCM_GMAC_CTRL_TX_CLK_DELAY(CONFIG_GMAC_TX_DELAY));
 #else
        setbits_le32(&ccm->gmac_clk_cfg, CCM_GMAC_CTRL_TX_CLK_SRC_MII |
                CCM_GMAC_CTRL_GPIT_MII);
 #endif
 
-       /*
-        * In order for the gmac nic to work reliable on the Bananapi, we
-        * need to set bits 10-12 GTXDC "GMAC Transmit Clock Delay Chain"
-        * of the GMAC clk register to 3.
-        */
-#if defined CONFIG_TARGET_BANANAPI || defined CONFIG_TARGET_BANANAPRO
-       setbits_le32(&ccm->gmac_clk_cfg, 0x3 << 10);
-#endif
-
 #ifndef CONFIG_MACH_SUN6I
        /* Configure pin mux settings for GMAC */
        for (pin = SUNXI_GPA(0); pin <= SUNXI_GPA(16); pin++) {
index a54d3dfde367cdb154a8d04ec9fb6f770287a833..8ab48cd91c44aae6cc5fad3ab0a0308a0344814e 100644 (file)
@@ -1,8 +1,5 @@
 if TARGET_ARCANGEL4
 
-config SYS_CPU
-       default "arc700"
-
 config SYS_VENDOR
        default "synopsys"
 
@@ -10,16 +7,3 @@ config SYS_CONFIG_NAME
        default "arcangel4"
 
 endif
-
-if TARGET_ARCANGEL4_BE
-
-config SYS_CPU
-       default "arc700"
-
-config SYS_VENDOR
-       default "synopsys"
-
-config SYS_CONFIG_NAME
-       default "arcangel4-be"
-
-endif
index 720edd8893f14417b35696e0126ac44ee0bcc29e..43114cea5ecf5dc180dc218dd0d54a785d7ca80b 100644 (file)
@@ -3,5 +3,4 @@ M:      Alexey Brodkin <abrodkin@synopsys.com>
 S:     Maintained
 F:     include/configs/arcangel4.h
 F:     configs/arcangel4_defconfig
-F:     include/configs/arcangel4-be.h
 F:     configs/arcangel4-be_defconfig
index 8448265888076bc9cb9b521a1dc5f0e8e6b44ca4..79e5400ea86b14f3d6af0c598be8b7c54f07ef58 100644 (file)
@@ -1,8 +1,5 @@
 if TARGET_AXS101
 
-config SYS_CPU
-       default "arc700"
-
 config SYS_BOARD
        default "axs101"
 
index 5d2c024e890b9ffab6401517ce75bd33a759b70a..624421496a408fe72128bdf31083ab249559da8f 100644 (file)
@@ -42,7 +42,7 @@ int tegra_pcie_board_init(void)
        u8 addr, data[1];
        int err;
 
-       err = i2c_get_chip_for_busnum(0, PMU_I2C_ADDRESS, &dev);
+       err = i2c_get_chip_for_busnum(0, PMU_I2C_ADDRESS, 1, &dev);
        if (err) {
                debug("%s: Cannot find PMIC I2C chip\n", __func__);
                return err;
@@ -51,7 +51,7 @@ int tegra_pcie_board_init(void)
        data[0] = 0x27;
        addr = 0x25;
 
-       err = i2c_write(dev, addr, data, 1);
+       err = dm_i2c_write(dev, addr, data, 1);
        if (err) {
                debug("failed to set VDD supply\n");
                return err;
@@ -61,7 +61,7 @@ int tegra_pcie_board_init(void)
        data[0] = 0x0D;
        addr = 0x24;
 
-       err = i2c_write(dev, addr, data, 1);
+       err = dm_i2c_write(dev, addr, data, 1);
        if (err) {
                debug("failed to enable VDD supply\n");
                return err;
@@ -71,7 +71,7 @@ int tegra_pcie_board_init(void)
        data[0] = 0x0D;
        addr = 0x35;
 
-       err = i2c_write(dev, addr, data, 1);
+       err = dm_i2c_write(dev, addr, data, 1);
        if (err) {
                debug("failed to set AVDD supply\n");
                return err;
diff --git a/board/total5200/Kconfig b/board/total5200/Kconfig
deleted file mode 100644 (file)
index ffa9516..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-if TARGET_TOTAL5200
-
-config SYS_BOARD
-       default "total5200"
-
-config SYS_CONFIG_NAME
-       default "Total5200"
-
-endif
diff --git a/board/total5200/MAINTAINERS b/board/total5200/MAINTAINERS
deleted file mode 100644 (file)
index afb0058..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-TOTAL5200 BOARD
-#M:    -
-S:     Maintained
-F:     board/total5200/
-F:     include/configs/Total5200.h
-F:     configs/Total5200_defconfig
-F:     configs/Total5200_lowboot_defconfig
-F:     configs/Total5200_Rev2_defconfig
-F:     configs/Total5200_Rev2_lowboot_defconfig
diff --git a/board/total5200/Makefile b/board/total5200/Makefile
deleted file mode 100644 (file)
index 527557c..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-#
-# (C) Copyright 2003-2006
-# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
-#
-# SPDX-License-Identifier:     GPL-2.0+
-#
-
-obj-y  := total5200.o sdram.o
diff --git a/board/total5200/mt48lc16m16a2-75.h b/board/total5200/mt48lc16m16a2-75.h
deleted file mode 100644 (file)
index 068a9a6..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-/*
- * (C) Copyright 2004
- * Mark Jonas, Freescale Semiconductor, mark.jonas@freescale.com.
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#define SDRAM_DDR      0               /* is SDR */
-
-/* Settings for XLB = 132 MHz */
-#define SDRAM_MODE     0x00CD0000
-#define SDRAM_CONTROL  0x504F0000
-#define SDRAM_CONFIG1  0xD2322800
-#define SDRAM_CONFIG2  0x8AD70000
diff --git a/board/total5200/mt48lc32m16a2-75.h b/board/total5200/mt48lc32m16a2-75.h
deleted file mode 100644 (file)
index 0377417..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * (C) Copyright 2004
- * Mark Jonas, Freescale Semiconductor, mark.jonas@freescale.com.
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-/*
- * Micron MT48LC32M16A2-75 is compatible to:
- *  - Infineon HYB39S512160AT-75
- */
-
-#define SDRAM_DDR      0               /* is SDR */
-
-/* Settings for XLB = 132 MHz */
-#define SDRAM_MODE     0x00CD0000
-#define SDRAM_CONTROL  0x514F0000
-#define SDRAM_CONFIG1  0xD2322800
-#define SDRAM_CONFIG2  0x8AD70000
diff --git a/board/total5200/sdram.c b/board/total5200/sdram.c
deleted file mode 100644 (file)
index dbe3587..0000000
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * (C) Copyright 2003-2004
- * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
- *
- * (C) Copyright 2004
- * Mark Jonas, Freescale Semiconductor, mark.jonas@freescale.com.
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#include <common.h>
-#include <mpc5xxx.h>
-
-#include "sdram.h"
-
-#ifndef CONFIG_SYS_RAMBOOT
-static void mpc5xxx_sdram_start (sdram_conf_t *sdram_conf, int hi_addr)
-{
-       long hi_addr_bit = hi_addr ? 0x01000000 : 0;
-
-       /* unlock mode register */
-       *(vu_long *)MPC5XXX_SDRAM_CTRL = sdram_conf->control | 0x80000000 | hi_addr_bit;
-       __asm__ volatile ("sync");
-
-       /* precharge all banks */
-       *(vu_long *)MPC5XXX_SDRAM_CTRL = sdram_conf->control | 0x80000002 | hi_addr_bit;
-       __asm__ volatile ("sync");
-
-       if (sdram_conf->ddr) {
-               /* set mode register: extended mode */
-               *(vu_long *)MPC5XXX_SDRAM_MODE = sdram_conf->emode;
-               __asm__ volatile ("sync");
-
-               /* set mode register: reset DLL */
-               *(vu_long *)MPC5XXX_SDRAM_MODE = sdram_conf->mode | 0x04000000;
-               __asm__ volatile ("sync");
-       }
-
-       /* precharge all banks */
-       *(vu_long *)MPC5XXX_SDRAM_CTRL = sdram_conf->control | 0x80000002 | hi_addr_bit;
-       __asm__ volatile ("sync");
-
-       /* auto refresh */
-       *(vu_long *)MPC5XXX_SDRAM_CTRL = sdram_conf->control | 0x80000004 | hi_addr_bit;
-       __asm__ volatile ("sync");
-
-       /* set mode register */
-       *(vu_long *)MPC5XXX_SDRAM_MODE = sdram_conf->mode;
-       __asm__ volatile ("sync");
-
-       /* normal operation */
-       *(vu_long *)MPC5XXX_SDRAM_CTRL = sdram_conf->control | hi_addr_bit;
-       __asm__ volatile ("sync");
-}
-#endif
-
-/*
- * ATTENTION: Although partially referenced initdram does NOT make real use
- *            use of CONFIG_SYS_SDRAM_BASE. The code does not work if CONFIG_SYS_SDRAM_BASE
- *            is something else than 0x00000000.
- */
-
-long int mpc5xxx_sdram_init (sdram_conf_t *sdram_conf)
-{
-       ulong dramsize = 0;
-       ulong dramsize2 = 0;
-#ifndef CONFIG_SYS_RAMBOOT
-       ulong test1, test2;
-
-       /* setup SDRAM chip selects */
-       *(vu_long *)MPC5XXX_SDRAM_CS0CFG = 0x0000001e;/* 2G at 0x0 */
-       *(vu_long *)MPC5XXX_SDRAM_CS1CFG = 0x80000000;/* disabled */
-       __asm__ volatile ("sync");
-
-       /* setup config registers */
-       *(vu_long *)MPC5XXX_SDRAM_CONFIG1 = sdram_conf->config1;
-       *(vu_long *)MPC5XXX_SDRAM_CONFIG2 = sdram_conf->config2;
-       __asm__ volatile ("sync");
-
-       if (sdram_conf->ddr) {
-               /* set tap delay */
-               *(vu_long *)MPC5XXX_CDM_PORCFG = sdram_conf->tapdelay;
-               __asm__ volatile ("sync");
-       }
-
-       /* find RAM size using SDRAM CS0 only */
-       mpc5xxx_sdram_start(sdram_conf, 0);
-       test1 = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
-       mpc5xxx_sdram_start(sdram_conf, 1);
-       test2 = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
-       if (test1 > test2) {
-               mpc5xxx_sdram_start(sdram_conf, 0);
-               dramsize = test1;
-       } else {
-               dramsize = test2;
-       }
-
-       /* memory smaller than 1MB is impossible */
-       if (dramsize < (1 << 20)) {
-               dramsize = 0;
-       }
-
-       /* set SDRAM CS0 size according to the amount of RAM found */
-       if (dramsize > 0) {
-               *(vu_long *)MPC5XXX_SDRAM_CS0CFG = 0x13 + __builtin_ffs(dramsize >> 20) - 1;
-       } else {
-               *(vu_long *)MPC5XXX_SDRAM_CS0CFG = 0; /* disabled */
-       }
-
-       /* let SDRAM CS1 start right after CS0 */
-       *(vu_long *)MPC5XXX_SDRAM_CS1CFG = dramsize + 0x0000001e;/* 2G */
-
-       /* find RAM size using SDRAM CS1 only */
-       mpc5xxx_sdram_start(sdram_conf, 0);
-       test1 = get_ram_size((long *)(CONFIG_SYS_SDRAM_BASE + dramsize), 0x80000000);
-       mpc5xxx_sdram_start(sdram_conf, 1);
-       test2 = get_ram_size((long *)(CONFIG_SYS_SDRAM_BASE + dramsize), 0x80000000);
-       if (test1 > test2) {
-               mpc5xxx_sdram_start(sdram_conf, 0);
-               dramsize2 = test1;
-       } else {
-               dramsize2 = test2;
-       }
-
-       /* memory smaller than 1MB is impossible */
-       if (dramsize2 < (1 << 20)) {
-               dramsize2 = 0;
-       }
-
-       /* set SDRAM CS1 size according to the amount of RAM found */
-       if (dramsize2 > 0) {
-               *(vu_long *)MPC5XXX_SDRAM_CS1CFG = dramsize
-                       | (0x13 + __builtin_ffs(dramsize2 >> 20) - 1);
-       } else {
-               *(vu_long *)MPC5XXX_SDRAM_CS1CFG = dramsize; /* disabled */
-       }
-
-#else /* CONFIG_SYS_RAMBOOT */
-
-       /* retrieve size of memory connected to SDRAM CS0 */
-       dramsize = *(vu_long *)MPC5XXX_SDRAM_CS0CFG & 0xFF;
-       if (dramsize >= 0x13) {
-               dramsize = (1 << (dramsize - 0x13)) << 20;
-       } else {
-               dramsize = 0;
-       }
-
-       /* retrieve size of memory connected to SDRAM CS1 */
-       dramsize2 = *(vu_long *)MPC5XXX_SDRAM_CS1CFG & 0xFF;
-       if (dramsize2 >= 0x13) {
-               dramsize2 = (1 << (dramsize2 - 0x13)) << 20;
-       } else {
-               dramsize2 = 0;
-       }
-
-#endif /* CONFIG_SYS_RAMBOOT */
-
-       return dramsize + dramsize2;
-}
diff --git a/board/total5200/sdram.h b/board/total5200/sdram.h
deleted file mode 100644 (file)
index 3758f5c..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * (C) Copyright 2004
- * Mark Jonas, Freescale Semiconductor, mark.jonas@freescale.com.
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-typedef struct {
-       ulong ddr;
-       ulong mode;
-       ulong emode;
-       ulong control;
-       ulong config1;
-       ulong config2;
-       ulong tapdelay;
-} sdram_conf_t;
-
-long int mpc5xxx_sdram_init (sdram_conf_t *sdram_conf);
diff --git a/board/total5200/total5200.c b/board/total5200/total5200.c
deleted file mode 100644 (file)
index 345a186..0000000
+++ /dev/null
@@ -1,276 +0,0 @@
-/*
- * (C) Copyright 2003-2004
- * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
- *
- * (C) Copyright 2004
- * Mark Jonas, Freescale Semiconductor, mark.jonas@freescale.com.
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#include <common.h>
-#include <mpc5xxx.h>
-#include <pci.h>
-#include <netdev.h>
-
-#include "sdram.h"
-
-#if CONFIG_TOTAL5200_REV==2
-#include "mt48lc32m16a2-75.h"
-#else
-#include "mt48lc16m16a2-75.h"
-#endif
-
-phys_size_t initdram (int board_type)
-{
-       sdram_conf_t sdram_conf;
-
-       sdram_conf.ddr = SDRAM_DDR;
-       sdram_conf.mode = SDRAM_MODE;
-       sdram_conf.emode = 0;
-       sdram_conf.control = SDRAM_CONTROL;
-       sdram_conf.config1 = SDRAM_CONFIG1;
-       sdram_conf.config2 = SDRAM_CONFIG2;
-       sdram_conf.tapdelay = 0;
-       return mpc5xxx_sdram_init (&sdram_conf);
-}
-
-int checkboard (void)
-{
-#if CONFIG_TOTAL5200_REV==2
-       puts ("Board: Total5200 Rev.2 ");
-#else
-       puts ("Board: Total5200 ");
-#endif
-
-       /*
-        * Retrieve FPGA Revision.
-        */
-       printf ("(FPGA %08lX)\n", *(vu_long *) (CONFIG_SYS_FPGA_BASE + 0x400));
-
-       /*
-        * Take all peripherals in power-up mode.
-        */
-#if CONFIG_TOTAL5200_REV==2
-       *(vu_char *) (CONFIG_SYS_CPLD_BASE + 0x46) = 0x70;
-#else
-       *(vu_long *) (CONFIG_SYS_CPLD_BASE + 0x400) = 0x70;
-#endif
-
-       return 0;
-}
-
-#ifdef CONFIG_PCI
-static struct pci_controller hose;
-
-extern void pci_mpc5xxx_init(struct pci_controller *);
-
-void pci_init_board(void)
-{
-       pci_mpc5xxx_init(&hose);
-}
-#endif
-
-#if defined(CONFIG_CMD_IDE) && defined(CONFIG_IDE_RESET)
-
-/* IRDA_1 aka PSC6_3 (pin C13) */
-#define GPIO_IRDA_1    0x20000000UL
-
-void init_ide_reset (void)
-{
-       debug ("init_ide_reset\n");
-
-       /* Configure IRDA_1 (PSC6_3) as GPIO output for ATA reset */
-       *(vu_long *) MPC5XXX_GPIO_ENABLE |= GPIO_IRDA_1;
-       *(vu_long *) MPC5XXX_GPIO_DIR    |= GPIO_IRDA_1;
-}
-
-void ide_set_reset (int idereset)
-{
-       debug ("ide_reset(%d)\n", idereset);
-
-       if (idereset) {
-               *(vu_long *) MPC5XXX_GPIO_DATA_O &= ~GPIO_IRDA_1;
-       } else {
-               *(vu_long *) MPC5XXX_GPIO_DATA_O |=  GPIO_IRDA_1;
-       }
-}
-#endif
-
-#ifdef CONFIG_VIDEO_SED13806
-#include <sed13806.h>
-
-#define DISPLAY_WIDTH   640
-#define DISPLAY_HEIGHT  480
-
-#ifdef CONFIG_VIDEO_SED13806_8BPP
-#error CONFIG_VIDEO_SED13806_8BPP not supported.
-#endif /* CONFIG_VIDEO_SED13806_8BPP */
-
-#ifdef CONFIG_VIDEO_SED13806_16BPP
-static const S1D_REGS init_regs [] =
-{
-    {0x0001,0x00},   /* Miscellaneous Register */
-    {0x01FC,0x00},   /* Display Mode Register */
-    {0x0004,0x00},   /* General IO Pins Configuration Register 0 */
-    {0x0005,0x00},   /* General IO Pins Configuration Register 1 */
-    {0x0008,0x00},   /* General IO Pins Control Register 0 */
-    {0x0009,0x00},   /* General IO Pins Control Register 1 */
-    {0x0010,0x02},   /* Memory Clock Configuration Register */
-    {0x0014,0x02},   /* LCD Pixel Clock Configuration Register */
-    {0x0018,0x02},   /* CRT/TV Pixel Clock Configuration Register */
-    {0x001C,0x02},   /* MediaPlug Clock Configuration Register */
-    {0x001E,0x01},   /* CPU To Memory Wait State Select Register */
-    {0x0021,0x03},   /* DRAM Refresh Rate Register */
-    {0x002A,0x00},   /* DRAM Timings Control Register 0 */
-    {0x002B,0x01},   /* DRAM Timings Control Register 1 */
-    {0x0020,0x80},   /* Memory Configuration Register */
-    {0x0030,0x25},   /* Panel Type Register */
-    {0x0031,0x00},   /* MOD Rate Register */
-    {0x0032,0x4F},   /* LCD Horizontal Display Width Register */
-    {0x0034,0x13},   /* LCD Horizontal Non-Display Period Register */
-    {0x0035,0x01},   /* TFT FPLINE Start Position Register */
-    {0x0036,0x0B},   /* TFT FPLINE Pulse Width Register */
-    {0x0038,0xDF},   /* LCD Vertical Display Height Register 0 */
-    {0x0039,0x01},   /* LCD Vertical Display Height Register 1 */
-    {0x003A,0x2C},   /* LCD Vertical Non-Display Period Register */
-    {0x003B,0x0A},   /* TFT FPFRAME Start Position Register */
-    {0x003C,0x01},   /* TFT FPFRAME Pulse Width Register */
-    {0x0040,0x05},   /* LCD Display Mode Register */
-    {0x0041,0x00},   /* LCD Miscellaneous Register */
-    {0x0042,0x00},   /* LCD Display Start Address Register 0 */
-    {0x0043,0x00},   /* LCD Display Start Address Register 1 */
-    {0x0044,0x00},   /* LCD Display Start Address Register 2 */
-    {0x0046,0x80},   /* LCD Memory Address Offset Register 0 */
-    {0x0047,0x02},   /* LCD Memory Address Offset Register 1 */
-    {0x0048,0x00},   /* LCD Pixel Panning Register */
-    {0x004A,0x00},   /* LCD Display FIFO High Threshold Control Register */
-    {0x004B,0x00},   /* LCD Display FIFO Low Threshold Control Register */
-    {0x0050,0x4F},   /* CRT/TV Horizontal Display Width Register */
-    {0x0052,0x13},   /* CRT/TV Horizontal Non-Display Period Register */
-    {0x0053,0x01},   /* CRT/TV HRTC Start Position Register */
-    {0x0054,0x0B},   /* CRT/TV HRTC Pulse Width Register */
-    {0x0056,0xDF},   /* CRT/TV Vertical Display Height Register 0 */
-    {0x0057,0x01},   /* CRT/TV Vertical Display Height Register 1 */
-    {0x0058,0x2B},   /* CRT/TV Vertical Non-Display Period Register */
-    {0x0059,0x09},   /* CRT/TV VRTC Start Position Register */
-    {0x005A,0x01},   /* CRT/TV VRTC Pulse Width Register */
-    {0x005B,0x10},   /* TV Output Control Register */
-    {0x0060,0x05},   /* CRT/TV Display Mode Register */
-    {0x0062,0x00},   /* CRT/TV Display Start Address Register 0 */
-    {0x0063,0x00},   /* CRT/TV Display Start Address Register 1 */
-    {0x0064,0x00},   /* CRT/TV Display Start Address Register 2 */
-    {0x0066,0x80},   /* CRT/TV Memory Address Offset Register 0 */
-    {0x0067,0x02},   /* CRT/TV Memory Address Offset Register 1 */
-    {0x0068,0x00},   /* CRT/TV Pixel Panning Register */
-    {0x006A,0x00},   /* CRT/TV Display FIFO High Threshold Control Register */
-    {0x006B,0x00},   /* CRT/TV Display FIFO Low Threshold Control Register */
-    {0x0070,0x00},   /* LCD Ink/Cursor Control Register */
-    {0x0071,0x01},   /* LCD Ink/Cursor Start Address Register */
-    {0x0072,0x00},   /* LCD Cursor X Position Register 0 */
-    {0x0073,0x00},   /* LCD Cursor X Position Register 1 */
-    {0x0074,0x00},   /* LCD Cursor Y Position Register 0 */
-    {0x0075,0x00},   /* LCD Cursor Y Position Register 1 */
-    {0x0076,0x00},   /* LCD Ink/Cursor Blue Color 0 Register */
-    {0x0077,0x00},   /* LCD Ink/Cursor Green Color 0 Register */
-    {0x0078,0x00},   /* LCD Ink/Cursor Red Color 0 Register */
-    {0x007A,0x1F},   /* LCD Ink/Cursor Blue Color 1 Register */
-    {0x007B,0x3F},   /* LCD Ink/Cursor Green Color 1 Register */
-    {0x007C,0x1F},   /* LCD Ink/Cursor Red Color 1 Register */
-    {0x007E,0x00},   /* LCD Ink/Cursor FIFO Threshold Register */
-    {0x0080,0x00},   /* CRT/TV Ink/Cursor Control Register */
-    {0x0081,0x01},   /* CRT/TV Ink/Cursor Start Address Register */
-    {0x0082,0x00},   /* CRT/TV Cursor X Position Register 0 */
-    {0x0083,0x00},   /* CRT/TV Cursor X Position Register 1 */
-    {0x0084,0x00},   /* CRT/TV Cursor Y Position Register 0 */
-    {0x0085,0x00},   /* CRT/TV Cursor Y Position Register 1 */
-    {0x0086,0x00},   /* CRT/TV Ink/Cursor Blue Color 0 Register */
-    {0x0087,0x00},   /* CRT/TV Ink/Cursor Green Color 0 Register */
-    {0x0088,0x00},   /* CRT/TV Ink/Cursor Red Color 0 Register */
-    {0x008A,0x1F},   /* CRT/TV Ink/Cursor Blue Color 1 Register */
-    {0x008B,0x3F},   /* CRT/TV Ink/Cursor Green Color 1 Register */
-    {0x008C,0x1F},   /* CRT/TV Ink/Cursor Red Color 1 Register */
-    {0x008E,0x00},   /* CRT/TV Ink/Cursor FIFO Threshold Register */
-    {0x0100,0x00},   /* BitBlt Control Register 0 */
-    {0x0101,0x00},   /* BitBlt Control Register 1 */
-    {0x0102,0x00},   /* BitBlt ROP Code/Color Expansion Register */
-    {0x0103,0x00},   /* BitBlt Operation Register */
-    {0x0104,0x00},   /* BitBlt Source Start Address Register 0 */
-    {0x0105,0x00},   /* BitBlt Source Start Address Register 1 */
-    {0x0106,0x00},   /* BitBlt Source Start Address Register 2 */
-    {0x0108,0x00},   /* BitBlt Destination Start Address Register 0 */
-    {0x0109,0x00},   /* BitBlt Destination Start Address Register 1 */
-    {0x010A,0x00},   /* BitBlt Destination Start Address Register 2 */
-    {0x010C,0x00},   /* BitBlt Memory Address Offset Register 0 */
-    {0x010D,0x00},   /* BitBlt Memory Address Offset Register 1 */
-    {0x0110,0x00},   /* BitBlt Width Register 0 */
-    {0x0111,0x00},   /* BitBlt Width Register 1 */
-    {0x0112,0x00},   /* BitBlt Height Register 0 */
-    {0x0113,0x00},   /* BitBlt Height Register 1 */
-    {0x0114,0x00},   /* BitBlt Background Color Register 0 */
-    {0x0115,0x00},   /* BitBlt Background Color Register 1 */
-    {0x0118,0x00},   /* BitBlt Foreground Color Register 0 */
-    {0x0119,0x00},   /* BitBlt Foreground Color Register 1 */
-    {0x01E0,0x00},   /* Look-Up Table Mode Register */
-    {0x01E2,0x00},   /* Look-Up Table Address Register */
-    {0x01E4,0x00},   /* Look-Up Table Data Register */
-    {0x01F0,0x00},   /* Power Save Configuration Register */
-    {0x01F1,0x00},   /* Power Save Status Register */
-    {0x01F4,0x00},   /* CPU-to-Memory Access Watchdog Timer Register */
-    {0x01FC,0x01},   /* Display Mode Register */
-    {0, 0}
-};
-#endif /* CONFIG_VIDEO_SED13806_16BPP */
-
-#ifdef CONFIG_CONSOLE_EXTRA_INFO
-/* Return text to be printed besides the logo. */
-void video_get_info_str (int line_number, char *info)
-{
-       if (line_number == 1) {
-#if CONFIG_TOTAL5200_REV==1
-               strcpy (info, " Total5200");
-#elif CONFIG_TOTAL5200_REV==2
-               strcpy (info, " Total5200 Rev.2");
-#else
-#error CONFIG_TOTAL5200_REV must be 1 or 2.
-#endif
-       } else {
-               info [0] = '\0';
-       }
-}
-#endif
-
-/* Returns  SED13806 base address. First thing called in the driver. */
-unsigned int board_video_init (void)
-{
-       return CONFIG_SYS_LCD_BASE;
-}
-
-/* Called after initializing the SED13806 and before clearing the screen. */
-void board_validate_screen (unsigned int base)
-{
-}
-
-/* Return a pointer to the initialization sequence. */
-const S1D_REGS *board_get_regs (void)
-{
-       return init_regs;
-}
-
-int board_get_width (void)
-{
-       return DISPLAY_WIDTH;
-}
-
-int board_get_height (void)
-{
-       return DISPLAY_HEIGHT;
-}
-
-#endif /* CONFIG_VIDEO_SED13806 */
-
-int board_eth_init(bd_t *bis)
-{
-       cpu_eth_init(bis); /* Built in FEC comes first */
-       return pci_eth_init(bis);
-}
index 2744514435fccba72fc204d300db8276211abaff..3da61a4c3d333b4b750effdd9fe63e584cc35937 100644 (file)
@@ -137,9 +137,6 @@ void board_init_f(ulong dummy)
        /* Clear the BSS. */
        memset(__bss_start, 0, __bss_end - __bss_start);
 
-       /* Set global data pointer. */
-       gd = &gdata;
-
        preloader_console_init();
        timer_init();
 
index 42a8d0c400e5917262f709fffe128095568e50a7..3110405a1b615ad938b85df61ff88000feca21d1 100644 (file)
 
 #include <common.h>
 #include <config.h>
+#include <fdtdec.h>
 #include <netdev.h>
 #include <asm/processor.h>
 #include <asm/microblaze_intc.h>
 #include <asm/asm.h>
 #include <asm/gpio.h>
 
+DECLARE_GLOBAL_DATA_PTR;
+
 #ifdef CONFIG_XILINX_GPIO
 static int reset_pin = -1;
 #endif
 
+#ifdef CONFIG_OF_CONTROL
+ulong ram_base;
+
+void dram_init_banksize(void)
+{
+       gd->bd->bi_dram[0].start = ram_base;
+       gd->bd->bi_dram[0].size = get_effective_memsize();
+}
+
+int dram_init(void)
+{
+       int node;
+       fdt_addr_t addr;
+       fdt_size_t size;
+       const void *blob = gd->fdt_blob;
+
+       node = fdt_node_offset_by_prop_value(blob, -1, "device_type",
+                                            "memory", 7);
+       if (node == -FDT_ERR_NOTFOUND) {
+               debug("DRAM: Can't get memory node\n");
+               return 1;
+       }
+       addr = fdtdec_get_addr_size(blob, node, "reg", &size);
+       if (addr == FDT_ADDR_T_NONE || size == 0) {
+               debug("DRAM: Can't get base address or size\n");
+               return 1;
+       }
+       ram_base = addr;
+
+       gd->ram_top = addr; /* In setup_dest_addr() is done +ram_size */
+       gd->ram_size = size;
+
+       return 0;
+};
+#else
+int dram_init(void)
+{
+       gd->ram_size = CONFIG_SYS_SDRAM_SIZE;
+
+       return 0;
+}
+#endif
+
 int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 #ifdef CONFIG_XILINX_GPIO
index 258632e52b0b602cad9c7368f66e01d87aa04ccb..738c31c6ee1f568cc95a6dd47ce34579f2853b64 100644 (file)
@@ -24,6 +24,7 @@ static xilinx_desc fpga010 = XILINX_XC7Z010_DESC(0x10);
 static xilinx_desc fpga015 = XILINX_XC7Z015_DESC(0x15);
 static xilinx_desc fpga020 = XILINX_XC7Z020_DESC(0x20);
 static xilinx_desc fpga030 = XILINX_XC7Z030_DESC(0x30);
+static xilinx_desc fpga035 = XILINX_XC7Z035_DESC(0x35);
 static xilinx_desc fpga045 = XILINX_XC7Z045_DESC(0x45);
 static xilinx_desc fpga100 = XILINX_XC7Z100_DESC(0x100);
 #endif
@@ -49,6 +50,9 @@ int board_init(void)
        case XILINX_ZYNQ_7030:
                fpga = fpga030;
                break;
+       case XILINX_ZYNQ_7035:
+               fpga = fpga035;
+               break;
        case XILINX_ZYNQ_7045:
                fpga = fpga045;
                break;
@@ -87,6 +91,14 @@ int board_late_init(void)
        return 0;
 }
 
+#ifdef CONFIG_DISPLAY_BOARDINFO
+int checkboard(void)
+{
+       puts("Board:\tXilinx Zynq\n");
+       return 0;
+}
+#endif
+
 int board_eth_init(bd_t *bis)
 {
        u32 ret = 0;
@@ -111,11 +123,13 @@ int board_eth_init(bd_t *bis)
 #if defined(CONFIG_ZYNQ_GEM)
 # if defined(CONFIG_ZYNQ_GEM0)
        ret |= zynq_gem_initialize(bis, ZYNQ_GEM_BASEADDR0,
-                                               CONFIG_ZYNQ_GEM_PHY_ADDR0, 0);
+                                  CONFIG_ZYNQ_GEM_PHY_ADDR0,
+                                  CONFIG_ZYNQ_GEM_EMIO0);
 # endif
 # if defined(CONFIG_ZYNQ_GEM1)
        ret |= zynq_gem_initialize(bis, ZYNQ_GEM_BASEADDR1,
-                                               CONFIG_ZYNQ_GEM_PHY_ADDR1, 0);
+                                  CONFIG_ZYNQ_GEM_PHY_ADDR1,
+                                  CONFIG_ZYNQ_GEM_EMIO1);
 # endif
 #endif
        return ret;
index 0f1416d1e8a3d01cdf9632d9bdb4b8b0f5e724e2..b97bb95e6dec710dfc659cab5c5d44baaacbca98 100644 (file)
@@ -27,6 +27,8 @@ endif
 # boards
 obj-$(CONFIG_SYS_GENERIC_BOARD) += board_f.o
 obj-$(CONFIG_SYS_GENERIC_BOARD) += board_r.o
+obj-$(CONFIG_DISPLAY_BOARDINFO) += board_info.o
+obj-$(CONFIG_DISPLAY_BOARDINFO_LATE) += board_info.o
 
 # core command
 obj-y += cmd_boot.o
index 3a4b32c29dc1dbccb6f181297ce0686b4dcf990b..d25329a0aa87238eb3a40b185679eedefe121d49 100644 (file)
@@ -262,7 +262,7 @@ static int zero_global_data(void)
 
 static int setup_mon_len(void)
 {
-#ifdef __ARM__
+#if defined(__ARM__) || defined(__MICROBLAZE__)
        gd->mon_len = (ulong)&__bss_end - (ulong)_start;
 #elif defined(CONFIG_SANDBOX)
        gd->mon_len = (ulong)&_end - (ulong)_init;
@@ -807,6 +807,12 @@ static int initf_dm(void)
        return 0;
 }
 
+/* Architecture-specific memory reservation */
+__weak int reserve_arch(void)
+{
+       return 0;
+}
+
 static init_fnc_t init_sequence_f[] = {
 #ifdef CONFIG_SANDBOX
        setup_ram_buf,
@@ -888,7 +894,7 @@ static init_fnc_t init_sequence_f[] = {
        prt_mpc5xxx_clks,
 #endif /* CONFIG_MPC5xxx */
 #if defined(CONFIG_DISPLAY_BOARDINFO)
-       checkboard,             /* display board info */
+       show_board_info,
 #endif
        INIT_FUNC_WATCHDOG_INIT
 #if defined(CONFIG_MISC_INIT_F)
@@ -903,7 +909,7 @@ static init_fnc_t init_sequence_f[] = {
 #endif
        announce_dram_init,
        /* TODO: unify all these dram functions? */
-#if defined(CONFIG_ARM) || defined(CONFIG_X86)
+#if defined(CONFIG_ARM) || defined(CONFIG_X86) || defined(CONFIG_MICROBLAZE)
        dram_init,              /* configure available RAM banks */
 #endif
 #if defined(CONFIG_MIPS) || defined(CONFIG_PPC)
@@ -970,6 +976,7 @@ static init_fnc_t init_sequence_f[] = {
        setup_machine,
        reserve_global_data,
        reserve_fdt,
+       reserve_arch,
        reserve_stacks,
        setup_dram_config,
        show_dram_config,
diff --git a/common/board_info.c b/common/board_info.c
new file mode 100644 (file)
index 0000000..42d0641
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <common.h>
+#include <libfdt.h>
+#include <linux/compiler.h>
+
+int __weak checkboard(void)
+{
+       printf("Board: Unknown\n");
+       return 0;
+}
+
+/*
+ * If the root node of the DTB has a "model" property, show it.
+ * If CONFIG_OF_CONTROL is disabled or the "model" property is missing,
+ * fall back to checkboard().
+ */
+int show_board_info(void)
+{
+#ifdef CONFIG_OF_CONTROL
+       DECLARE_GLOBAL_DATA_PTR;
+       const char *model;
+
+       model = fdt_getprop(gd->fdt_blob, 0, "model", NULL);
+
+       if (model) {
+               printf("Model: %s\n", model);
+               return 0;
+       }
+#endif
+
+       return checkboard();
+}
index a301cc226f1e69fb4f6229382391c80218f12460..907b33cca7624124cd251b656db219a1e5052449 100644 (file)
@@ -294,6 +294,15 @@ static int initr_announce(void)
        return 0;
 }
 
+#ifdef CONFIG_NEEDS_MANUAL_RELOC
+static int initr_manual_reloc_cmdtable(void)
+{
+       fixup_cmdtable(ll_entry_start(cmd_tbl_t, cmd),
+                      ll_entry_count(cmd_tbl_t, cmd));
+       return 0;
+}
+#endif
+
 #if !defined(CONFIG_SYS_NO_FLASH)
 static int initr_flash(void)
 {
@@ -476,22 +485,6 @@ static int initr_api(void)
 }
 #endif
 
-#ifdef CONFIG_DISPLAY_BOARDINFO_LATE
-static int show_model_r(void)
-{
-       /* Put this here so it appears on the LCD, now it is ready */
-# ifdef CONFIG_OF_CONTROL
-       const char *model;
-
-       model = (char *)fdt_getprop(gd->fdt_blob, 0, "model", NULL);
-       printf("Model: %s\n", model ? model : "<unknown>");
-# else
-       checkboard();
-# endif
-       return 0;
-}
-#endif
-
 /* enable exceptions */
 #ifdef CONFIG_ARM
 static int initr_enable_interrupts(void)
@@ -718,6 +711,9 @@ init_fnc_t init_sequence_r[] = {
        initr_serial,
        initr_announce,
        INIT_FUNC_WATCHDOG_RESET
+#ifdef CONFIG_NEEDS_MANUAL_RELOC
+       initr_manual_reloc_cmdtable,
+#endif
 #ifdef CONFIG_PPC
        initr_trap,
 #endif
@@ -801,7 +797,7 @@ init_fnc_t init_sequence_r[] = {
 #endif
        console_init_r,         /* fully init console as a device */
 #ifdef CONFIG_DISPLAY_BOARDINFO_LATE
-       show_model_r,
+       show_board_info,
 #endif
 #ifdef CONFIG_ARCH_MISC_INIT
        arch_misc_init,         /* miscellaneous arch-dependent init */
@@ -817,7 +813,7 @@ init_fnc_t init_sequence_r[] = {
 #if defined(CONFIG_ARM)
        initr_enable_interrupts,
 #endif
-#ifdef CONFIG_X86
+#if defined(CONFIG_X86) || defined(CONFIG_MICROBLAZE)
        timer_init,             /* initialize timer */
 #endif
 #if defined(CONFIG_STATUS_LED) && defined(STATUS_LED_BOOT)
index e6d8a7ae2c50715daa03af64934f21d23d4635a7..e9eab232f961bb873a019fde8580a06fe4236b80 100644 (file)
@@ -183,8 +183,14 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
        bd_t *bd = gd->bd;
-       print_num("mem start      ",    (ulong)bd->bi_memstart);
-       print_lnum("mem size       ",   (u64)bd->bi_memsize);
+       int i;
+
+       for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) {
+               print_num("DRAM bank",  i);
+               print_num("-> start",   bd->bi_dram[i].start);
+               print_num("-> size",    bd->bi_dram[i].size);
+       }
+
        print_num("flash start    ",    (ulong)bd->bi_flashstart);
        print_num("flash size     ",    (ulong)bd->bi_flashsize);
        print_num("flash offset   ",    (ulong)bd->bi_flashoffset);
@@ -196,6 +202,12 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
        print_eths();
 #endif
        printf("baudrate    = %u bps\n", gd->baudrate);
+       print_num("relocaddr", gd->relocaddr);
+       print_num("reloc off", gd->reloc_off);
+       print_num("fdt_blob", (ulong)gd->fdt_blob);
+       print_num("new_fdt", (ulong)gd->new_fdt);
+       print_num("fdt_size", (ulong)gd->fdt_size);
+
        return 0;
 }
 
index 67233600b157244409c2710afa606337d2ebaf80..48199bfff3ed75a232ba3905cb4fe8662b09e321 100644 (file)
@@ -185,6 +185,9 @@ static char bootm_help_text[] =
        "\tcmdline - OS specific command line processing/setup\n"
        "\tbdt     - OS specific bd_t processing\n"
        "\tprep    - OS specific prep before relocation or go\n"
+#if defined(CONFIG_TRACE)
+       "\tfake    - OS specific fake start without go\n"
+#endif
        "\tgo      - start OS";
 #endif
 
index 652c61c70779bdab10116e80bca99e554f20a786..bcb34d904569d98612317dcc4e0712db6edd6410 100644 (file)
@@ -39,6 +39,26 @@ static int do_demo_status(cmd_tbl_t *cmdtp, int flag, int argc,
        return 0;
 }
 
+static int do_demo_light(cmd_tbl_t *cmdtp, int flag, int argc,
+                        char * const argv[])
+{
+       int light;
+       int ret;
+
+       if (argc) {
+               light = simple_strtoul(argv[0], NULL, 16);
+               ret = demo_set_light(demo_dev, light);
+       } else {
+               ret = demo_get_light(demo_dev);
+               if (ret >= 0) {
+                       printf("Light: %x\n", ret);
+                       ret = 0;
+               }
+       }
+
+       return ret;
+}
+
 int do_demo_list(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
        struct udevice *dev;
@@ -61,6 +81,7 @@ int do_demo_list(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 static cmd_tbl_t demo_commands[] = {
        U_BOOT_CMD_MKENT(list, 0, 1, do_demo_list, "", ""),
        U_BOOT_CMD_MKENT(hello, 2, 1, do_demo_hello, "", ""),
+       U_BOOT_CMD_MKENT(light, 2, 1, do_demo_light, "", ""),
        U_BOOT_CMD_MKENT(status, 1, 1, do_demo_status, "", ""),
 };
 
@@ -86,6 +107,10 @@ static int do_demo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
                        return cmd_process_error(cmdtp, ret);
                argc--;
                argv++;
+       } else {
+               demo_dev = NULL;
+               if (demo_cmd->cmd != do_demo_list)
+                       return CMD_RET_USAGE;
        }
 
        ret = demo_cmd->cmd(demo_cmd, flag, argc, argv);
@@ -98,5 +123,7 @@ U_BOOT_CMD(
        "Driver model (dm) demo operations",
        "list                     List available demo devices\n"
        "demo hello <num> [<char>]     Say hello\n"
-       "demo status <num>             Get demo device status"
+       "demo light [<num>]            Set or get the lights\n"
+       "demo status <num>             Get demo device status\n"
+       "demo list                     List available demo devices"
 );
index 8c5bf440fbb0903e9798242dcc131e630ba51e7f..7f99aabf8a5c69454a19fced5a71c596b043dddc 100644 (file)
@@ -211,6 +211,7 @@ int do_fpga(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
 
                                comp = image_get_comp(hdr);
                                if (comp == IH_COMP_GZIP) {
+#if defined(CONFIG_GZIP)
                                        ulong image_buf = image_get_data(hdr);
                                        data = image_get_load(hdr);
                                        ulong image_size = ~0UL;
@@ -222,6 +223,10 @@ int do_fpga(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
                                                return 1;
                                        }
                                        data_size = image_size;
+#else
+                                       puts("Gunzip image is not supported\n");
+                                       return 1;
+#endif
                                } else {
                                        data = (ulong)image_get_data(hdr);
                                        data_size = image_get_data_size(hdr);
@@ -341,7 +346,7 @@ U_BOOT_CMD(fpga, 6, 1, do_fpga,
           "loadable FPGA image support",
           "[operation type] [device number] [image address] [image size]\n"
           "fpga operations:\n"
-          "  dump\t[dev]\t\t\tLoad device to memory buffer\n"
+          "  dump\t[dev] [address] [size]\tLoad device to memory buffer\n"
           "  info\t[dev]\t\t\tlist known device information\n"
           "  load\t[dev] [address] [size]\tLoad device from memory buffer\n"
 #if defined(CONFIG_CMD_FPGA_LOADP)
index 0d9da113bf0c1305bc64e7e67368d6eba800b5e0..e146254f6d68367d8dc2650c409f24a1676362dd 100644 (file)
@@ -81,3 +81,18 @@ U_BOOT_CMD(
        "    - List files in directory 'directory' of partition 'part' on\n"
        "      device type 'interface' instance 'dev'."
 )
+
+static int do_fstype_wrapper(cmd_tbl_t *cmdtp, int flag, int argc,
+                               char * const argv[])
+{
+       return do_fs_type(cmdtp, flag, argc, argv);
+}
+
+U_BOOT_CMD(
+       fstype, 4, 1, do_fstype_wrapper,
+       "Look up a filesystem type",
+       "<interface> <dev>:<part>\n"
+       "- print filesystem type\n"
+       "fstype <interface> <dev>:<part> <varname>\n"
+       "- set environment variable to filesystem type\n"
+);
index 320ff709fafba3a6abe2f5f1cb6b12a152788df1..c48baad9a106ab9ec0cdfc1e1544cbd437231ff8 100644 (file)
@@ -35,6 +35,6 @@ static int do_gettime(cmd_tbl_t *cmdtp, int flag, int argc,
 
 U_BOOT_CMD(
        gettime,        1,      1,      do_gettime,
-       "get timer val elapsed,\n",
-       "get time elapsed from uboot start\n"
+       "get timer val elapsed",
+       "get time elapsed from uboot start"
 );
index 22db1bb47c137fd4fe08fc20e3e2f75fba72f16f..7c3ad00fdf03f30ee358cf4501717d6e657e5d18 100644 (file)
@@ -83,12 +83,12 @@ DECLARE_GLOBAL_DATA_PTR;
 /* Display values from last command.
  * Memory modify remembered values are different from display memory.
  */
-static uchar   i2c_dp_last_chip;
+static uint    i2c_dp_last_chip;
 static uint    i2c_dp_last_addr;
 static uint    i2c_dp_last_alen;
 static uint    i2c_dp_last_length = 0x10;
 
-static uchar   i2c_mm_last_chip;
+static uint    i2c_mm_last_chip;
 static uint    i2c_mm_last_addr;
 static uint    i2c_mm_last_alen;
 
@@ -133,7 +133,7 @@ static uchar i2c_no_probes[] = CONFIG_SYS_I2C_NOPROBES;
 #ifdef CONFIG_DM_I2C
 static struct udevice *i2c_cur_bus;
 
-static int i2c_set_bus_num(unsigned int busnum)
+static int cmd_i2c_set_bus_num(unsigned int busnum)
 {
        struct udevice *bus;
        int ret;
@@ -168,7 +168,7 @@ static int i2c_get_cur_bus_chip(uint chip_addr, struct udevice **devp)
        if (ret)
                return ret;
 
-       return i2c_get_chip(bus, chip_addr, devp);
+       return i2c_get_chip(bus, chip_addr, 1, devp);
 }
 
 #endif
@@ -282,7 +282,7 @@ static int i2c_report_err(int ret, enum i2c_err_op op)
  */
 static int do_i2c_read ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
-       u_char  chip;
+       uint    chip;
        uint    devaddr, length;
        int alen;
        u_char  *memaddr;
@@ -323,7 +323,7 @@ static int do_i2c_read ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv
        if (!ret && alen != -1)
                ret = i2c_set_chip_offset_len(dev, alen);
        if (!ret)
-               ret = i2c_read(dev, devaddr, memaddr, length);
+               ret = dm_i2c_read(dev, devaddr, memaddr, length);
 #else
        ret = i2c_read(chip, devaddr, alen, memaddr, length);
 #endif
@@ -335,7 +335,7 @@ static int do_i2c_read ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv
 
 static int do_i2c_write(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
-       u_char  chip;
+       uint    chip;
        uint    devaddr, length;
        int alen;
        u_char  *memaddr;
@@ -381,7 +381,7 @@ static int do_i2c_write(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[
 
        while (length-- > 0) {
 #ifdef CONFIG_DM_I2C
-               ret = i2c_write(dev, devaddr++, memaddr++, 1);
+               ret = dm_i2c_write(dev, devaddr++, memaddr++, 1);
 #else
                ret = i2c_write(chip, devaddr++, alen, memaddr++, 1);
 #endif
@@ -444,7 +444,7 @@ static int do_i2c_flags(cmd_tbl_t *cmdtp, int flag, int argc,
  */
 static int do_i2c_md ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
-       u_char  chip;
+       uint    chip;
        uint    addr, length;
        int alen;
        int     j, nbytes, linebytes;
@@ -513,7 +513,7 @@ static int do_i2c_md ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]
                linebytes = (nbytes > DISP_LINE_LEN) ? DISP_LINE_LEN : nbytes;
 
 #ifdef CONFIG_DM_I2C
-               ret = i2c_read(dev, addr, linebuf, linebytes);
+               ret = dm_i2c_read(dev, addr, linebuf, linebytes);
 #else
                ret = i2c_read(chip, addr, alen, linebuf, linebytes);
 #endif
@@ -563,7 +563,7 @@ static int do_i2c_md ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]
  */
 static int do_i2c_mw ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
-       uchar   chip;
+       uint    chip;
        ulong   addr;
        int     alen;
        uchar   byte;
@@ -611,7 +611,7 @@ static int do_i2c_mw ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]
 
        while (count-- > 0) {
 #ifdef CONFIG_DM_I2C
-               ret = i2c_write(dev, addr++, &byte, 1);
+               ret = dm_i2c_write(dev, addr++, &byte, 1);
 #else
                ret = i2c_write(chip, addr++, alen, &byte, 1);
 #endif
@@ -649,7 +649,7 @@ static int do_i2c_mw ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]
  */
 static int do_i2c_crc (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
-       uchar   chip;
+       uint    chip;
        ulong   addr;
        int     alen;
        int     count;
@@ -698,7 +698,7 @@ static int do_i2c_crc (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]
        err = 0;
        while (count-- > 0) {
 #ifdef CONFIG_DM_I2C
-               ret = i2c_read(dev, addr, &byte, 1);
+               ret = dm_i2c_read(dev, addr, &byte, 1);
 #else
                ret = i2c_read(chip, addr, alen, &byte, 1);
 #endif
@@ -734,7 +734,7 @@ static int do_i2c_crc (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]
 static int
 mod_i2c_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char * const argv[])
 {
-       uchar   chip;
+       uint    chip;
        ulong   addr;
        int     alen;
        ulong   data;
@@ -793,7 +793,7 @@ mod_i2c_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char * const arg
        do {
                printf("%08lx:", addr);
 #ifdef CONFIG_DM_I2C
-               ret = i2c_read(dev, addr, (uchar *)&data, size);
+               ret = dm_i2c_read(dev, addr, (uchar *)&data, size);
 #else
                ret = i2c_read(chip, addr, alen, (uchar *)&data, size);
 #endif
@@ -841,8 +841,8 @@ mod_i2c_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char * const arg
                                 */
                                bootretry_reset_cmd_timeout();
 #ifdef CONFIG_DM_I2C
-                               ret = i2c_write(dev, addr, (uchar *)&data,
-                                               size);
+                               ret = dm_i2c_write(dev, addr, (uchar *)&data,
+                                                  size);
 #else
                                ret = i2c_write(chip, addr, alen,
                                                (uchar *)&data, size);
@@ -917,7 +917,7 @@ static int do_i2c_probe (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv
                        continue;
 #endif
 #ifdef CONFIG_DM_I2C
-               ret = i2c_probe(bus, j, 0, &dev);
+               ret = dm_i2c_probe(bus, j, 0, &dev);
 #else
                ret = i2c_probe(j);
 #endif
@@ -957,7 +957,7 @@ static int do_i2c_probe (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv
  */
 static int do_i2c_loop(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
-       u_char  chip;
+       uint    chip;
        int alen;
        uint    addr;
        uint    length;
@@ -1010,7 +1010,7 @@ static int do_i2c_loop(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]
         */
        while (1) {
 #ifdef CONFIG_DM_I2C
-               ret = i2c_read(dev, addr, bytes, length);
+               ret = dm_i2c_read(dev, addr, bytes, length);
 #else
                ret = i2c_read(chip, addr, alen, bytes, length);
 #endif
@@ -1085,7 +1085,7 @@ static int do_sdram (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
 {
        enum { unknown, EDO, SDRAM, DDR2 } type;
 
-       u_char  chip;
+       uint    chip;
        u_char  data[128];
        u_char  cksum;
        int     j;
@@ -1563,7 +1563,7 @@ static int do_sdram (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
 #if defined(CONFIG_I2C_EDID)
 int do_edid(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
 {
-       u_char chip;
+       uint chip;
        struct edid1_info edid;
        int ret;
 #ifdef CONFIG_DM_I2C
@@ -1579,7 +1579,7 @@ int do_edid(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
 #ifdef CONFIG_DM_I2C
        ret = i2c_get_cur_bus_chip(chip, &dev);
        if (!ret)
-               ret = i2c_read(dev, 0, (uchar *)&edid, sizeof(edid));
+               ret = dm_i2c_read(dev, 0, (uchar *)&edid, sizeof(edid));
 #else
        ret = i2c_read(chip, 0, 1, (uchar *)&edid, sizeof(edid));
 #endif
@@ -1696,7 +1696,11 @@ static int do_i2c_bus_num(cmd_tbl_t *cmdtp, int flag, int argc,
                }
 #endif
                printf("Setting bus to %d\n", bus_no);
+#ifdef CONFIG_DM_I2C
+               ret = cmd_i2c_set_bus_num(bus_no);
+#else
                ret = i2c_set_bus_num(bus_no);
+#endif
                if (ret)
                        printf("Failure changing bus number (%d)\n", ret);
        }
index f6e522cbb3482bf48eeae51cfe0d2e1467404de3..d043e6d7bcf2d6368ead958a89574720ce6c37d4 100644 (file)
@@ -222,7 +222,7 @@ static int read_record(char *buf, ulong len)
                }
 
            /* Check for the console hangup (if any different from serial) */
-           if (gd->jt[XF_getc] != getc) {
+           if (gd->jt->getc != getc) {
                if (ctrlc()) {
                    return (-1);
                }
index 96478e45c14039cd88a1a59427d0ec7f1a44d07e..4e28c9d7a4d6541f0c1633ee494b77e476b5e776 100644 (file)
@@ -73,6 +73,8 @@ U_BOOT_CMD(
 
 static void print_mmcinfo(struct mmc *mmc)
 {
+       int i;
+
        printf("Device: %s\n", mmc->cfg->name);
        printf("Manufacturer ID: %x\n", mmc->cid[0] >> 24);
        printf("OEM: %x\n", (mmc->cid[0] >> 8) & 0xffff);
@@ -92,6 +94,48 @@ static void print_mmcinfo(struct mmc *mmc)
 
        printf("Bus Width: %d-bit%s\n", mmc->bus_width,
                        mmc->ddr_mode ? " DDR" : "");
+
+       puts("Erase Group Size: ");
+       print_size(((u64)mmc->erase_grp_size) << 9, "\n");
+
+       if (!IS_SD(mmc) && mmc->version >= MMC_VERSION_4_41) {
+               bool has_enh = (mmc->part_support & ENHNCD_SUPPORT) != 0;
+               bool usr_enh = has_enh && (mmc->part_attr & EXT_CSD_ENH_USR);
+
+               puts("HC WP Group Size: ");
+               print_size(((u64)mmc->hc_wp_grp_size) << 9, "\n");
+
+               puts("User Capacity: ");
+               print_size(mmc->capacity_user, usr_enh ? " ENH" : "");
+               if (mmc->wr_rel_set & EXT_CSD_WR_DATA_REL_USR)
+                       puts(" WRREL\n");
+               else
+                       putc('\n');
+               if (usr_enh) {
+                       puts("User Enhanced Start: ");
+                       print_size(mmc->enh_user_start, "\n");
+                       puts("User Enhanced Size: ");
+                       print_size(mmc->enh_user_size, "\n");
+               }
+               puts("Boot Capacity: ");
+               print_size(mmc->capacity_boot, has_enh ? " ENH\n" : "\n");
+               puts("RPMB Capacity: ");
+               print_size(mmc->capacity_rpmb, has_enh ? " ENH\n" : "\n");
+
+               for (i = 0; i < ARRAY_SIZE(mmc->capacity_gp); i++) {
+                       bool is_enh = has_enh &&
+                               (mmc->part_attr & EXT_CSD_ENH_GP(i));
+                       if (mmc->capacity_gp[i]) {
+                               printf("GP%i Capacity: ", i+1);
+                               print_size(mmc->capacity_gp[i],
+                                          is_enh ? " ENH" : "");
+                               if (mmc->wr_rel_set & EXT_CSD_WR_DATA_REL_GP(i))
+                                       puts(" WRREL\n");
+                               else
+                                       putc('\n');
+                       }
+               }
+       }
 }
 static struct mmc *init_mmc_device(int dev, bool force_init)
 {
@@ -444,6 +488,157 @@ static int do_mmc_list(cmd_tbl_t *cmdtp, int flag,
        print_mmc_devices('\n');
        return CMD_RET_SUCCESS;
 }
+
+static int parse_hwpart_user(struct mmc_hwpart_conf *pconf,
+                            int argc, char * const argv[])
+{
+       int i = 0;
+
+       memset(&pconf->user, 0, sizeof(pconf->user));
+
+       while (i < argc) {
+               if (!strcmp(argv[i], "enh")) {
+                       if (i + 2 >= argc)
+                               return -1;
+                       pconf->user.enh_start =
+                               simple_strtoul(argv[i+1], NULL, 10);
+                       pconf->user.enh_size =
+                               simple_strtoul(argv[i+2], NULL, 10);
+                       i += 3;
+               } else if (!strcmp(argv[i], "wrrel")) {
+                       if (i + 1 >= argc)
+                               return -1;
+                       pconf->user.wr_rel_change = 1;
+                       if (!strcmp(argv[i+1], "on"))
+                               pconf->user.wr_rel_set = 1;
+                       else if (!strcmp(argv[i+1], "off"))
+                               pconf->user.wr_rel_set = 0;
+                       else
+                               return -1;
+                       i += 2;
+               } else {
+                       break;
+               }
+       }
+       return i;
+}
+
+static int parse_hwpart_gp(struct mmc_hwpart_conf *pconf, int pidx,
+                          int argc, char * const argv[])
+{
+       int i;
+
+       memset(&pconf->gp_part[pidx], 0, sizeof(pconf->gp_part[pidx]));
+
+       if (1 >= argc)
+               return -1;
+       pconf->gp_part[pidx].size = simple_strtoul(argv[0], NULL, 10);
+
+       i = 1;
+       while (i < argc) {
+               if (!strcmp(argv[i], "enh")) {
+                       pconf->gp_part[pidx].enhanced = 1;
+                       i += 1;
+               } else if (!strcmp(argv[i], "wrrel")) {
+                       if (i + 1 >= argc)
+                               return -1;
+                       pconf->gp_part[pidx].wr_rel_change = 1;
+                       if (!strcmp(argv[i+1], "on"))
+                               pconf->gp_part[pidx].wr_rel_set = 1;
+                       else if (!strcmp(argv[i+1], "off"))
+                               pconf->gp_part[pidx].wr_rel_set = 0;
+                       else
+                               return -1;
+                       i += 2;
+               } else {
+                       break;
+               }
+       }
+       return i;
+}
+
+static int do_mmc_hwpartition(cmd_tbl_t *cmdtp, int flag,
+                             int argc, char * const argv[])
+{
+       struct mmc *mmc;
+       struct mmc_hwpart_conf pconf = { };
+       enum mmc_hwpart_conf_mode mode = MMC_HWPART_CONF_CHECK;
+       int i, r, pidx;
+
+       mmc = init_mmc_device(curr_device, false);
+       if (!mmc)
+               return CMD_RET_FAILURE;
+
+       if (argc < 1)
+               return CMD_RET_USAGE;
+       i = 1;
+       while (i < argc) {
+               if (!strcmp(argv[i], "user")) {
+                       i++;
+                       r = parse_hwpart_user(&pconf, argc-i, &argv[i]);
+                       if (r < 0)
+                               return CMD_RET_USAGE;
+                       i += r;
+               } else if (!strncmp(argv[i], "gp", 2) &&
+                          strlen(argv[i]) == 3 &&
+                          argv[i][2] >= '1' && argv[i][2] <= '4') {
+                       pidx = argv[i][2] - '1';
+                       i++;
+                       r = parse_hwpart_gp(&pconf, pidx, argc-i, &argv[i]);
+                       if (r < 0)
+                               return CMD_RET_USAGE;
+                       i += r;
+               } else if (!strcmp(argv[i], "check")) {
+                       mode = MMC_HWPART_CONF_CHECK;
+                       i++;
+               } else if (!strcmp(argv[i], "set")) {
+                       mode = MMC_HWPART_CONF_SET;
+                       i++;
+               } else if (!strcmp(argv[i], "complete")) {
+                       mode = MMC_HWPART_CONF_COMPLETE;
+                       i++;
+               } else {
+                       return CMD_RET_USAGE;
+               }
+       }
+
+       puts("Partition configuration:\n");
+       if (pconf.user.enh_size) {
+               puts("\tUser Enhanced Start: ");
+               print_size(((u64)pconf.user.enh_start) << 9, "\n");
+               puts("\tUser Enhanced Size: ");
+               print_size(((u64)pconf.user.enh_size) << 9, "\n");
+       } else {
+               puts("\tNo enhanced user data area\n");
+       }
+       if (pconf.user.wr_rel_change)
+               printf("\tUser partition write reliability: %s\n",
+                      pconf.user.wr_rel_set ? "on" : "off");
+       for (pidx = 0; pidx < 4; pidx++) {
+               if (pconf.gp_part[pidx].size) {
+                       printf("\tGP%i Capacity: ", pidx+1);
+                       print_size(((u64)pconf.gp_part[pidx].size) << 9,
+                                  pconf.gp_part[pidx].enhanced ?
+                                  " ENH\n" : "\n");
+               } else {
+                       printf("\tNo GP%i partition\n", pidx+1);
+               }
+               if (pconf.gp_part[pidx].wr_rel_change)
+                       printf("\tGP%i write reliability: %s\n", pidx+1,
+                              pconf.gp_part[pidx].wr_rel_set ? "on" : "off");
+       }
+
+       if (!mmc_hwpart_config(mmc, &pconf, mode)) {
+               if (mode == MMC_HWPART_CONF_COMPLETE)
+                       puts("Partitioning successful, "
+                            "power-cycle to make effective\n");
+               return CMD_RET_SUCCESS;
+       } else {
+               puts("Failed!\n");
+               return CMD_RET_FAILURE;
+       }
+}
+
 #ifdef CONFIG_SUPPORT_EMMC_BOOT
 static int do_mmc_bootbus(cmd_tbl_t *cmdtp, int flag,
                          int argc, char * const argv[])
@@ -601,6 +796,7 @@ static cmd_tbl_t cmd_mmc[] = {
        U_BOOT_CMD_MKENT(part, 1, 1, do_mmc_part, "", ""),
        U_BOOT_CMD_MKENT(dev, 3, 0, do_mmc_dev, "", ""),
        U_BOOT_CMD_MKENT(list, 1, 1, do_mmc_list, "", ""),
+       U_BOOT_CMD_MKENT(hwpartition, 28, 0, do_mmc_hwpartition, "", ""),
 #ifdef CONFIG_SUPPORT_EMMC_BOOT
        U_BOOT_CMD_MKENT(bootbus, 5, 0, do_mmc_bootbus, "", ""),
        U_BOOT_CMD_MKENT(bootpart-resize, 4, 0, do_mmc_boot_resize, "", ""),
@@ -640,7 +836,7 @@ static int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 }
 
 U_BOOT_CMD(
-       mmc, 7, 1, do_mmcops,
+       mmc, 29, 1, do_mmcops,
        "MMC sub system",
        "info - display info of the current MMC device\n"
        "mmc read addr blk# cnt\n"
@@ -650,6 +846,13 @@ U_BOOT_CMD(
        "mmc part - lists available partition on current mmc device\n"
        "mmc dev [dev] [part] - show or set current mmc device [partition]\n"
        "mmc list - lists available devices\n"
+       "mmc hwpartition [args...] - does hardware partitioning\n"
+       "  arguments (sizes in 512-byte blocks):\n"
+       "    [user [enh start cnt] [wrrel {on|off}]] - sets user data area attributes\n"
+       "    [gp1|gp2|gp3|gp4 cnt [enh] [wrrel {on|off}]] - general purpose partition\n"
+       "    [check|set|complete] - mode, complete set partitioning completed\n"
+       "  WARNING: Partitioning is a write-once setting once it is set to complete.\n"
+       "  Power cycling is required to initialize partitions after set to complete.\n"
 #ifdef CONFIG_SUPPORT_EMMC_BOOT
        "mmc bootbus dev boot_bus_width reset_boot_bus_width boot_mode\n"
        " - Set the BOOT_BUS_WIDTH field of the specified device\n"
index 39e8666b774a4b0d45c2a0f9b06295ac975a20b5..c99f52735f057c92b556bf49a7c0559f1ef66575 100644 (file)
@@ -54,13 +54,31 @@ static int do_part_list(int argc, char * const argv[])
        int ret;
        block_dev_desc_t *desc;
 
-       if (argc != 2)
+       if (argc < 2 || argc > 3)
                return CMD_RET_USAGE;
 
        ret = get_device(argv[0], argv[1], &desc);
        if (ret < 0)
                return 1;
 
+       if (argc == 3) {
+               int p;
+               char str[512] = { 0, };
+         disk_partition_t info;
+
+               for (p = 1; p < 128; p++) {
+                       int r = get_partition_info(desc, p, &info);
+
+                       if (r == 0) {
+                               char t[5];
+                               sprintf(t, "%s%d", str[0] ? " " : "", p);
+                               strcat(str, t);
+                       }
+               }
+               setenv(argv[2], str);
+               return 0;
+       }
+
        print_part(desc);
 
        return 0;
@@ -87,5 +105,7 @@ U_BOOT_CMD(
        "part uuid <interface> <dev>:<part> <varname>\n"
        "    - set environment variable to partition UUID\n"
        "part list <interface> <dev>\n"
-       "    - print a device's partition table"
+       "    - print a device's partition table\n"
+       "part list <interface> <dev> <varname>\n"
+       "    - set environment variable to the list of partitions"
 );
index c192498257fe8f60fed0f41e4c4f97b8fcd0d986..27813f0d7af680fffa67b0dba509da1ba020e43a 100644 (file)
@@ -441,6 +441,26 @@ static int do_usb_stop_keyboard(int force)
        return 0;
 }
 
+static void do_usb_start(void)
+{
+       bootstage_mark_name(BOOTSTAGE_ID_USB_START, "usb_start");
+
+       if (usb_init() < 0)
+               return;
+
+#ifdef CONFIG_USB_STORAGE
+       /* try to recognize storage devices immediately */
+       usb_stor_curr_dev = usb_stor_scan(1);
+#endif
+#ifdef CONFIG_USB_HOST_ETHER
+       /* try to recognize ethernet devices immediately */
+       usb_ether_curr_dev = usb_host_eth_scan(1);
+#endif
+#ifdef CONFIG_USB_KEYBOARD
+       drv_usb_kbd_init();
+#endif
+}
+
 /******************************************************************************
  * usb command intepreter
  */
@@ -457,26 +477,20 @@ static int do_usb(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
        if (argc < 2)
                return CMD_RET_USAGE;
 
-       if ((strncmp(argv[1], "reset", 5) == 0) ||
-                (strncmp(argv[1], "start", 5) == 0)) {
-               bootstage_mark_name(BOOTSTAGE_ID_USB_START, "usb_start");
+       if (strncmp(argv[1], "start", 5) == 0) {
+               if (usb_started)
+                       return 0; /* Already started */
+               printf("starting USB...\n");
+               do_usb_start();
+               return 0;
+       }
+
+       if (strncmp(argv[1], "reset", 5) == 0) {
+               printf("resetting USB...\n");
                if (do_usb_stop_keyboard(1) != 0)
                        return 1;
                usb_stop();
-               printf("(Re)start USB...\n");
-               if (usb_init() >= 0) {
-#ifdef CONFIG_USB_STORAGE
-                       /* try to recognize storage devices immediately */
-                       usb_stor_curr_dev = usb_stor_scan(1);
-#endif
-#ifdef CONFIG_USB_HOST_ETHER
-                       /* try to recognize ethernet devices immediately */
-                       usb_ether_curr_dev = usb_host_eth_scan(1);
-#endif
-#ifdef CONFIG_USB_KEYBOARD
-                       drv_usb_kbd_init();
-#endif
-               }
+               do_usb_start();
                return 0;
        }
        if (strncmp(argv[1], "stop", 4) == 0) {
index ae2714d3728021bdc0d262f2bbe3b4cb54fcfe52..64b9186d738920dabf3e8573dcebaecdbb3ee562 100644 (file)
@@ -247,6 +247,8 @@ do_imgextract(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
                puts("OK\n");
        }
 
+       flush_cache(dest, len);
+
        setenv_hex("fileaddr", data);
        setenv_hex("filesize", len);
 
index fc1963b2a978a1be548f07e98108e1b817432e0c..3f25e76fe79ea3c94a85d0306d668233320e2d47 100644 (file)
@@ -125,13 +125,13 @@ static int console_setfile(int file, struct stdio_dev * dev)
                 */
                switch (file) {
                case stdin:
-                       gd->jt[XF_getc] = getc;
-                       gd->jt[XF_tstc] = tstc;
+                       gd->jt->getc = getc;
+                       gd->jt->tstc = tstc;
                        break;
                case stdout:
-                       gd->jt[XF_putc] = putc;
-                       gd->jt[XF_puts] = puts;
-                       gd->jt[XF_printf] = printf;
+                       gd->jt->putc  = putc;
+                       gd->jt->puts  = puts;
+                       gd->jt->printf = printf;
                        break;
                }
                break;
@@ -758,11 +758,11 @@ int console_init_r(void)
 #endif
 
        /* set default handlers at first */
-       gd->jt[XF_getc] = serial_getc;
-       gd->jt[XF_tstc] = serial_tstc;
-       gd->jt[XF_putc] = serial_putc;
-       gd->jt[XF_puts] = serial_puts;
-       gd->jt[XF_printf] = serial_printf;
+       gd->jt->getc  = serial_getc;
+       gd->jt->tstc  = serial_tstc;
+       gd->jt->putc  = serial_putc;
+       gd->jt->puts  = serial_puts;
+       gd->jt->printf = serial_printf;
 
        /* stdin stdout and stderr are in environment */
        /* scan for it */
index 88fcfc8cb6fc652e8fb5242869ebdb4c0813f5dd..333107c74c3c68f9244eea3cdbd44a6f0c1c2802 100644 (file)
@@ -1,6 +1,7 @@
 #include <common.h>
 #include <exports.h>
 #include <spi.h>
+#include <i2c.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -13,33 +14,10 @@ unsigned long get_version(void)
        return XF_VERSION;
 }
 
-/* Reuse _exports.h with a little trickery to avoid bitrot */
-#define EXPORT_FUNC(sym) gd->jt[XF_##sym] = (void *)sym;
-
-#if !defined(CONFIG_X86) && !defined(CONFIG_PPC)
-# define install_hdlr      dummy
-# define free_hdlr         dummy
-#else /* kludge for non-standard function naming */
-# define install_hdlr      irq_install_handler
-# define free_hdlr         irq_free_handler
-#endif
-#ifndef CONFIG_CMD_I2C
-# define i2c_write         dummy
-# define i2c_read          dummy
-#endif
-#if !defined(CONFIG_CMD_SPI) || defined(CONFIG_DM_SPI)
-# define spi_init          dummy
-# define spi_setup_slave   dummy
-# define spi_free_slave    dummy
-#endif
-#ifndef CONFIG_CMD_SPI
-# define spi_claim_bus     dummy
-# define spi_release_bus   dummy
-# define spi_xfer          dummy
-#endif
+#define EXPORT_FUNC(f, a, x, ...)  gd->jt->x = f;
 
 void jumptable_init(void)
 {
-       gd->jt = malloc(XF_MAX * sizeof(void *));
+       gd->jt = malloc(sizeof(struct jt_funcs));
 #include <_exports.h>
 }
index aceabc5caddb12d1c52d9b4c4028981ff01670b0..d154d029e9c32466979bdc93116b70778402bb78 100644 (file)
  * SPDX-License-Identifier:    GPL-2.0+
  */
 
+#ifndef USE_HOSTCC
 #include <common.h>
 #include <command.h>
 #include <malloc.h>
 #include <hw_sha.h>
+#include <asm/io.h>
+#include <asm/errno.h>
+#else
+#include "mkimage.h"
+#include <time.h>
+#include <image.h>
+#endif /* !USE_HOSTCC*/
+
 #include <hash.h>
+#include <u-boot/crc.h>
 #include <u-boot/sha1.h>
 #include <u-boot/sha256.h>
-#include <asm/io.h>
-#include <asm/errno.h>
+#include <u-boot/md5.h>
 
-#ifdef CONFIG_CMD_SHA1SUM
+#ifdef CONFIG_SHA1
 static int hash_init_sha1(struct hash_algo *algo, void **ctxp)
 {
        sha1_context *ctx = malloc(sizeof(sha1_context));
@@ -125,12 +134,7 @@ static struct hash_algo hash_algo[] = {
                CHUNKSZ_SHA256,
        },
 #endif
-       /*
-        * This is CONFIG_CMD_SHA1SUM instead of CONFIG_SHA1 since otherwise
-        * it bloats the code for boards which use SHA1 but not the 'hash'
-        * or 'sha1sum' commands.
-        */
-#ifdef CONFIG_CMD_SHA1SUM
+#ifdef CONFIG_SHA1
        {
                "sha1",
                SHA1_SUM_LEN,
@@ -140,7 +144,6 @@ static struct hash_algo hash_algo[] = {
                hash_update_sha1,
                hash_finish_sha1,
        },
-#define MULTI_HASH
 #endif
 #ifdef CONFIG_SHA256
        {
@@ -152,7 +155,6 @@ static struct hash_algo hash_algo[] = {
                hash_update_sha256,
                hash_finish_sha256,
        },
-#define MULTI_HASH
 #endif
        {
                "crc32",
@@ -165,6 +167,10 @@ static struct hash_algo hash_algo[] = {
        },
 };
 
+#if defined(CONFIG_SHA256) || defined(CONFIG_CMD_SHA1SUM)
+#define MULTI_HASH
+#endif
+
 #if defined(CONFIG_HASH_VERIFY) || defined(CONFIG_CMD_HASH)
 #define MULTI_HASH
 #endif
@@ -176,6 +182,40 @@ static struct hash_algo hash_algo[] = {
 #define multi_hash()   0
 #endif
 
+int hash_lookup_algo(const char *algo_name, struct hash_algo **algop)
+{
+       int i;
+
+       for (i = 0; i < ARRAY_SIZE(hash_algo); i++) {
+               if (!strcmp(algo_name, hash_algo[i].name)) {
+                       *algop = &hash_algo[i];
+                       return 0;
+               }
+       }
+
+       debug("Unknown hash algorithm '%s'\n", algo_name);
+       return -EPROTONOSUPPORT;
+}
+
+int hash_progressive_lookup_algo(const char *algo_name,
+                                struct hash_algo **algop)
+{
+       int i;
+
+       for (i = 0; i < ARRAY_SIZE(hash_algo); i++) {
+               if (!strcmp(algo_name, hash_algo[i].name)) {
+                       if (hash_algo[i].hash_init) {
+                               *algop = &hash_algo[i];
+                               return 0;
+                       }
+               }
+       }
+
+       debug("Unknown hash algorithm '%s'\n", algo_name);
+       return -EPROTONOSUPPORT;
+}
+
+#ifndef USE_HOSTCC
 /**
  * store_result: Store the resulting sum to an address or variable
  *
@@ -296,21 +336,6 @@ static int parse_verify_sum(struct hash_algo *algo, char *verify_str,
        return 0;
 }
 
-int hash_lookup_algo(const char *algo_name, struct hash_algo **algop)
-{
-       int i;
-
-       for (i = 0; i < ARRAY_SIZE(hash_algo); i++) {
-               if (!strcmp(algo_name, hash_algo[i].name)) {
-                       *algop = &hash_algo[i];
-                       return 0;
-               }
-       }
-
-       debug("Unknown hash algorithm '%s'\n", algo_name);
-       return -EPROTONOSUPPORT;
-}
-
 void hash_show(struct hash_algo *algo, ulong addr, ulong len, uint8_t *output)
 {
        int i;
@@ -424,3 +449,4 @@ int hash_command(const char *algo_name, int flags, cmd_tbl_t *cmdtp, int flag,
 
        return 0;
 }
+#endif
index 1589ee3e4fb811ccb9bc8f31fbc094533abcd093..b47d11024f2beb007d049bc0cb54a43268d8bde1 100644 (file)
@@ -112,6 +112,33 @@ static void fit_get_debug(const void *fit, int noffset,
              fdt_strerror(err));
 }
 
+/**
+ * fit_get_subimage_count - get component (sub-image) count
+ * @fit: pointer to the FIT format image header
+ * @images_noffset: offset of images node
+ *
+ * returns:
+ *     number of image components
+ */
+int fit_get_subimage_count(const void *fit, int images_noffset)
+{
+       int noffset;
+       int ndepth;
+       int count = 0;
+
+       /* Process its subnodes, print out component images details */
+       for (ndepth = 0, count = 0,
+               noffset = fdt_next_node(fit, images_noffset, &ndepth);
+            (noffset >= 0) && (ndepth > 0);
+            noffset = fdt_next_node(fit, noffset, &ndepth)) {
+               if (ndepth == 1) {
+                       count++;
+               }
+       }
+
+       return count;
+}
+
 #if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_FIT_SPL_PRINT)
 /**
  * fit_print_contents - prints out the contents of the FIT format image
@@ -423,7 +450,8 @@ void fit_image_print(const void *fit, int image_noffset, const char *p)
                }
        }
 }
-#endif
+
+#endif /* !defined(CONFIG_SPL_BUILD) || defined(CONFIG_FIT_SPL_PRINT) */
 
 /**
  * fit_get_desc - get node description property
index 8601edaca35f41d0c996e15fb7f447179a8255b3..2c9f0cdf7ae3996b5c57bbe74b9ff7ee5cea58d7 100644 (file)
@@ -38,7 +38,7 @@ struct checksum_algo checksum_algos[] = {
 #if IMAGE_ENABLE_SIGN
                EVP_sha1,
 #endif
-               sha1_calculate,
+               hash_calculate,
                padding_sha1_rsa2048,
        },
        {
@@ -48,7 +48,7 @@ struct checksum_algo checksum_algos[] = {
 #if IMAGE_ENABLE_SIGN
                EVP_sha256,
 #endif
-               sha256_calculate,
+               hash_calculate,
                padding_sha256_rsa2048,
        },
        {
@@ -58,7 +58,7 @@ struct checksum_algo checksum_algos[] = {
 #if IMAGE_ENABLE_SIGN
                EVP_sha256,
 #endif
-               sha256_calculate,
+               hash_calculate,
                padding_sha256_rsa4096,
        }
 
index ad7a46d08d827fb18f7005132342d19c7d97cf5d..a911aa9b4d128227520fba77555c4879e5e93ff3 100644 (file)
@@ -756,7 +756,7 @@ int genimg_get_format(const void *img_addr)
  * genimg_get_image - get image from special storage (if necessary)
  * @img_addr: image start address
  *
- * genimg_get_image() checks if provided image start adddress is located
+ * genimg_get_image() checks if provided image start address is located
  * in a dataflash storage. If so, image is moved to a system RAM memory.
  *
  * returns:
index cc34b8aee4c484c123d6770d778331b9c8b6e880..1195a54efcc742837f3cb703b4c8ad6f5d356569 100644 (file)
@@ -268,6 +268,7 @@ void lcd_clear(void)
        console_rows = panel_info.vl_row / VIDEO_FONT_HEIGHT;
 #endif
        console_cols = panel_info.vl_col / VIDEO_FONT_WIDTH;
+       lcd_init_console(lcd_base, console_rows, console_cols);
        lcd_init_console(lcd_logo(), console_rows, console_cols);
        lcd_sync();
 }
index 1826c47a99c464bd0023f3c173cab788de49acb0..daaeb507c467b14cf0f80ecaab46e48064e58672 100644 (file)
@@ -231,7 +231,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
 #endif
        default:
 #if defined(CONFIG_SPL_SERIAL_SUPPORT) && defined(CONFIG_SPL_LIBCOMMON_SUPPORT)
-               printf("SPL: Unsupported Boot Device %d\n", boot_device);
+               puts("SPL: Unsupported Boot Device!\n");
 #endif
                hang();
        }
index 736cd9f00950929c3a269987d8c9c2e32cc80f7e..32e15cd8ddb93320c5758635268daac68e7196f7 100644 (file)
@@ -59,6 +59,7 @@ int usb_init(void)
        void *ctrl;
        struct usb_device *dev;
        int i, start_index = 0;
+       int controllers_initialized = 0;
        int ret;
 
        dev_index = 0;
@@ -78,6 +79,7 @@ int usb_init(void)
                ret = usb_lowlevel_init(i, USB_INIT_HOST, &ctrl);
                if (ret == -ENODEV) {   /* No such device. */
                        puts("Port not available.\n");
+                       controllers_initialized++;
                        continue;
                }
 
@@ -89,6 +91,7 @@ int usb_init(void)
                 * lowlevel init is OK, now scan the bus for devices
                 * i.e. search HUBs and configure them
                 */
+               controllers_initialized++;
                start_index = dev_index;
                printf("scanning bus %d for devices... ", i);
                dev = usb_alloc_new_device(ctrl);
@@ -110,12 +113,10 @@ int usb_init(void)
 
        debug("scan end\n");
        /* if we were not able to find at least one working bus, bail out */
-       if (!usb_started) {
+       if (controllers_initialized == 0)
                puts("USB error: all controllers failed lowlevel init\n");
-               return -1;
-       }
 
-       return 0;
+       return usb_started ? 0 : -1;
 }
 
 /******************************************************************************
@@ -969,6 +970,8 @@ int usb_new_device(struct usb_device *dev)
                        printf("\n     Couldn't reset port %i\n", dev->portnr);
                        return 1;
                }
+       } else {
+               usb_reset_root_port();
        }
 #endif
 
index bc7145ea79d38b87ce173b2b14dc9bf444f40826..ecc3085cc0811b5471cab07415904221153abf33 100644 (file)
@@ -332,7 +332,8 @@ static inline void usb_kbd_poll_for_event(struct usb_device *dev)
                /* We've consumed all queued int packets, create new */
                destroy_int_queue(dev, data->intq);
                data->intq = create_int_queue(dev, data->intpipe, 1,
-                                     USB_KBD_BOOT_REPORT_SIZE, data->new);
+                                     USB_KBD_BOOT_REPORT_SIZE, data->new,
+                                     data->intinterval);
        }
 #endif
 }
@@ -453,7 +454,8 @@ static int usb_kbd_probe(struct usb_device *dev, unsigned int ifnum)
        debug("USB KBD: enable interrupt pipe...\n");
 #ifdef CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE
        data->intq = create_int_queue(dev, data->intpipe, 1,
-                                     USB_KBD_BOOT_REPORT_SIZE, data->new);
+                                     USB_KBD_BOOT_REPORT_SIZE, data->new,
+                                     data->intinterval);
        if (!data->intq) {
 #else
        if (usb_submit_int_msg(dev, data->intpipe, data->new, data->intpktsize,
@@ -542,6 +544,10 @@ int usb_kbd_deregister(int force)
                data = usb_kbd_dev->privptr;
                if (stdio_deregister_dev(dev, force) != 0)
                        return 1;
+#ifdef CONFIG_CONSOLE_MUX
+               if (iomux_doenv(stdin, getenv("stdin")) != 0)
+                       return 1;
+#endif
 #ifdef CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE
                destroy_int_queue(usb_kbd_dev, data->intq);
 #endif
index f0cbf21025afefaecc05eb2af5527dfae1b0e61d..8fa1a330cd34e1a8202892595c549971b3275169 100644 (file)
@@ -4,4 +4,6 @@ CONFIG_FDTFILE="sun4i-a10-olinuxino-lime.dtb"
 +S:CONFIG_ARM=y
 +S:CONFIG_ARCH_SUNXI=y
 +S:CONFIG_MACH_SUN4I=y
-+S:CONFIG_TARGET_A10_OLINUXINO_L=y
++S:CONFIG_DRAM_CLK=480
++S:CONFIG_DRAM_ZQ=123
++S:CONFIG_DRAM_EMR1=4
index 94fafa6b97c2edfdab573279fcf877f7df385648..b5f0a0f782e1166e42680ec61326635be9edc3d7 100644 (file)
@@ -8,4 +8,6 @@ CONFIG_USB1_VBUS_PIN="PB10"
 +S:CONFIG_ARM=y
 +S:CONFIG_ARCH_SUNXI=y
 +S:CONFIG_MACH_SUN5I=y
-+S:CONFIG_TARGET_A10S_OLINUXINO_M=y
++S:CONFIG_DRAM_CLK=432
++S:CONFIG_DRAM_ZQ=123
++S:CONFIG_DRAM_EMR1=4
index 1a994180b5427b6ed099de520962d5a985d1b20d..a04f2b3362d2e695e98e1520303c0ae96a39095f 100644 (file)
@@ -4,6 +4,7 @@ CONFIG_FDTFILE="sun5i-a13-olinuxino-micro.dtb"
 CONFIG_USB1_VBUS_PIN="PG11"
 CONFIG_VIDEO_HDMI=n
 CONFIG_VIDEO_VGA_VIA_LCD=y
+CONFIG_VIDEO_VGA_VIA_LCD_FORCE_SYNC_ACTIVE_HIGH=y
 # For use with the Olimex 7" LCD module, adjust timings for other displays
 # Set video-mode=sunxi:800x600-24@60,monitor=lcd in the env. to enable
 CONFIG_VIDEO_LCD_MODE="x:800,y:480,depth:18,pclk_khz:33000,le:16,ri:209,up:22,lo:22,hs:30,vs:1,sync:3,vmode:0"
@@ -12,4 +13,6 @@ CONFIG_VIDEO_LCD_BL_PWM="PB2"
 +S:CONFIG_ARM=y
 +S:CONFIG_ARCH_SUNXI=y
 +S:CONFIG_MACH_SUN5I=y
-+S:CONFIG_TARGET_A13_OLINUXINOM=y
++S:CONFIG_DRAM_CLK=408
++S:CONFIG_DRAM_ZQ=123
++S:CONFIG_DRAM_EMR1=0
index 7df69517f6b26cc7191845004cfe13ff82fca4ca..806d5b7bd5346f93518494393324581c2809e0cc 100644 (file)
@@ -4,6 +4,7 @@ CONFIG_FDTFILE="sun5i-a13-olinuxino.dtb"
 CONFIG_USB1_VBUS_PIN="PG11"
 CONFIG_VIDEO_HDMI=n
 CONFIG_VIDEO_VGA_VIA_LCD=y
+CONFIG_VIDEO_VGA_VIA_LCD_FORCE_SYNC_ACTIVE_HIGH=y
 # For use with the Olimex 7" LCD module, adjust timings for other displays
 # Set video-mode=sunxi:800x600-24@60,monitor=lcd in the env. to enable
 CONFIG_VIDEO_LCD_MODE="x:800,y:480,depth:18,pclk_khz:33000,le:16,ri:209,up:22,lo:22,hs:30,vs:1,sync:3,vmode:0"
@@ -12,4 +13,6 @@ CONFIG_VIDEO_LCD_BL_PWM="PB2"
 +S:CONFIG_ARM=y
 +S:CONFIG_ARCH_SUNXI=y
 +S:CONFIG_MACH_SUN5I=y
-+S:CONFIG_TARGET_A13_OLINUXINO=y
++S:CONFIG_DRAM_CLK=408
++S:CONFIG_DRAM_ZQ=123
++S:CONFIG_DRAM_EMR1=0
index f80b98ae90a2d37df500d941fc402b4e5f01ca83..ff94e77200a39d77ea008098d65cfbcaebd7d385 100644 (file)
@@ -4,4 +4,6 @@ CONFIG_FDTFILE="sun7i-a20-olinuxino-lime2.dtb"
 +S:CONFIG_ARM=y
 +S:CONFIG_ARCH_SUNXI=y
 +S:CONFIG_MACH_SUN7I=y
-+S:CONFIG_TARGET_A20_OLINUXINO_L2=y
++S:CONFIG_DRAM_CLK=480
++S:CONFIG_DRAM_ZQ=127
++S:CONFIG_DRAM_EMR1=4
index d9e66b715514830da86073f7316f2c846482810f..5442f645f87165c34bbed8ba3e6cde3d8a8b87e8 100644 (file)
@@ -4,4 +4,6 @@ CONFIG_FDTFILE="sun7i-a20-olinuxino-lime.dtb"
 +S:CONFIG_ARM=y
 +S:CONFIG_ARCH_SUNXI=y
 +S:CONFIG_MACH_SUN7I=y
-+S:CONFIG_TARGET_A20_OLINUXINO_L=y
++S:CONFIG_DRAM_CLK=480
++S:CONFIG_DRAM_ZQ=127
++S:CONFIG_DRAM_EMR1=4
index 1c5a6f7a9faf1703a8d9d04dce5201647d2dc0db..97a21ee534702eaf133b450a331a9a6ee13f2d06 100644 (file)
@@ -8,4 +8,6 @@ CONFIG_VIDEO_VGA=y
 +S:CONFIG_ARM=y
 +S:CONFIG_ARCH_SUNXI=y
 +S:CONFIG_MACH_SUN7I=y
-+S:CONFIG_TARGET_A20_OLINUXINO_M=y
++S:CONFIG_DRAM_CLK=384
++S:CONFIG_DRAM_ZQ=127
++S:CONFIG_DRAM_EMR1=4
index 7fe9059179eb88116caa659e9033a221316a1029..03ec3dbdc410d633ae2eb503938a0218fca4c50f 100644 (file)
@@ -5,4 +5,6 @@ CONFIG_USB1_VBUS_PIN="PG13"
 +S:CONFIG_ARM=y
 +S:CONFIG_ARCH_SUNXI=y
 +S:CONFIG_MACH_SUN5I=y
-+S:CONFIG_TARGET_AUXTEK_T004=y
++S:CONFIG_DRAM_CLK=432
++S:CONFIG_DRAM_ZQ=123
++S:CONFIG_DRAM_EMR1=4
index 196f6824cb422c6f43c137fb10baf0fd83fec61a..5aba9382769411f5cf89a26db0a54937a74e29c6 100644 (file)
@@ -1,7 +1,10 @@
 CONFIG_SPL=y
 CONFIG_SYS_EXTRA_OPTIONS="AXP209_POWER,SUNXI_GMAC,RGMII,MACPWR=SUNXI_GPH(23),AHCI,USB_EHCI"
 CONFIG_FDTFILE="sun7i-a20-bananapi.dtb"
+CONFIG_GMAC_TX_DELAY=3
 +S:CONFIG_ARM=y
 +S:CONFIG_ARCH_SUNXI=y
 +S:CONFIG_MACH_SUN7I=y
-+S:CONFIG_TARGET_BANANAPI=y
++S:CONFIG_DRAM_CLK=432
++S:CONFIG_DRAM_ZQ=127
++S:CONFIG_DRAM_EMR1=4
index 7f9ce13e20e586f7836556af73734f5cd68d766f..e501b5c95c5fca8e9cb9886679e09b5ab7b78e3b 100644 (file)
@@ -3,7 +3,10 @@ CONFIG_SYS_EXTRA_OPTIONS="AXP209_POWER,SUNXI_GMAC,RGMII,MACPWR=SUNXI_GPH(23),AHC
 CONFIG_FDTFILE="sun7i-a20-bananapro.dtb"
 CONFIG_USB1_VBUS_PIN="PH0"
 CONFIG_USB2_VBUS_PIN="PH1"
+CONFIG_GMAC_TX_DELAY=3
 +S:CONFIG_ARM=y
 +S:CONFIG_ARCH_SUNXI=y
 +S:CONFIG_MACH_SUN7I=y
-+S:CONFIG_TARGET_BANANAPRO=y
++S:CONFIG_DRAM_CLK=432
++S:CONFIG_DRAM_ZQ=127
++S:CONFIG_DRAM_EMR1=4
diff --git a/configs/C29XPCIE_NOR_SECBOOT_defconfig b/configs/C29XPCIE_NOR_SECBOOT_defconfig
new file mode 100644 (file)
index 0000000..86751cf
--- /dev/null
@@ -0,0 +1,4 @@
+CONFIG_SYS_EXTRA_OPTIONS="C29XPCIE,36BIT,SECURE_BOOT"
+CONFIG_PPC=y
+CONFIG_MPC85xx=y
+CONFIG_TARGET_C29XPCIE=y
diff --git a/configs/C29XPCIE_SPIFLASH_SECBOOT_defconfig b/configs/C29XPCIE_SPIFLASH_SECBOOT_defconfig
new file mode 100644 (file)
index 0000000..d1a42b2
--- /dev/null
@@ -0,0 +1,4 @@
+CONFIG_SYS_EXTRA_OPTIONS="C29XPCIE,36BIT,SPIFLASH,SECURE_BOOT"
+CONFIG_PPC=y
+CONFIG_MPC85xx=y
+CONFIG_TARGET_C29XPCIE=y
diff --git a/configs/CATcenter_25_defconfig b/configs/CATcenter_25_defconfig
deleted file mode 100644 (file)
index 1a8903c..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-CONFIG_SYS_EXTRA_OPTIONS="PPCHAMELEON_MODULE_MODEL=1,PPCHAMELEON_CLK_25"
-CONFIG_PPC=y
-CONFIG_4xx=y
-CONFIG_TARGET_CATCENTER=y
diff --git a/configs/CATcenter_33_defconfig b/configs/CATcenter_33_defconfig
deleted file mode 100644 (file)
index 4b0eb8d..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-CONFIG_SYS_EXTRA_OPTIONS="PPCHAMELEON_MODULE_MODEL=1,PPCHAMELEON_CLK_33"
-CONFIG_PPC=y
-CONFIG_4xx=y
-CONFIG_TARGET_CATCENTER=y
diff --git a/configs/CATcenter_defconfig b/configs/CATcenter_defconfig
deleted file mode 100644 (file)
index 53e00ad..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-CONFIG_SYS_EXTRA_OPTIONS="PPCHAMELEON_MODULE_MODEL=1"
-CONFIG_PPC=y
-CONFIG_4xx=y
-CONFIG_TARGET_CATCENTER=y
index 1b6cdbf811b3bfdb4f9fece099b69d5174b4275f..4040beea69e4dfb7ccf89c29f3d1346ccd4d74d4 100644 (file)
@@ -4,7 +4,6 @@ CONFIG_FDTFILE="sun6i-a31s-cs908.dtb"
 +S:CONFIG_ARM=y
 +S:CONFIG_ARCH_SUNXI=y
 +S:CONFIG_MACH_SUN6I=y
-+S:CONFIG_TARGET_CSQ_CS908=y
 +S:CONFIG_DRAM_CLK=432
 +S:CONFIG_DRAM_ZQ=123
 # Ethernet phy power
diff --git a/configs/Chuwi_V7_CW0825_defconfig b/configs/Chuwi_V7_CW0825_defconfig
new file mode 100644 (file)
index 0000000..680b631
--- /dev/null
@@ -0,0 +1,19 @@
+CONFIG_SPL=y
+CONFIG_SYS_EXTRA_OPTIONS="AXP209_POWER"
+CONFIG_FDTFILE="sun4i-a10-chuwi-v7-cw0825.dtb"
+CONFIG_USB_MUSB_SUNXI=y
+CONFIG_USB0_VBUS_PIN="PB9"
+CONFIG_VIDEO_LCD_MODE="x:1024,y:768,depth:24,pclk_khz:51000,le:19,ri:300,up:6,lo:31,hs:1,vs:1,sync:3,vmode:0"
+CONFIG_VIDEO_LCD_POWER="PH8"
+CONFIG_VIDEO_LCD_BL_EN="PH7"
+CONFIG_VIDEO_LCD_BL_PWM="PB2"
+CONFIG_VIDEO_LCD_SPI_CS="PA0"
+CONFIG_VIDEO_LCD_SPI_SCLK="PA1"
+CONFIG_VIDEO_LCD_SPI_MOSI="PA2"
+CONFIG_VIDEO_LCD_PANEL_HITACHI_TX18D42VM=y
++S:CONFIG_ARM=y
++S:CONFIG_ARCH_SUNXI=y
++S:CONFIG_MACH_SUN4I=y
++S:CONFIG_DRAM_CLK=408
++S:CONFIG_DRAM_ZQ=123
++S:CONFIG_DRAM_EMR1=4
index f42ae5222e17022a6ccddd604c4915a0fe25df37..33edcc4205d66b332cd26d1ca89bd396fced28db 100644 (file)
@@ -4,7 +4,6 @@ CONFIG_FDTFILE="sun6i-a31-colombus.dtb"
 +S:CONFIG_ARM=y
 +S:CONFIG_ARCH_SUNXI=y
 +S:CONFIG_MACH_SUN6I=y
-+S:CONFIG_TARGET_COLOMBUS=y
 +S:CONFIG_DRAM_CLK=240
 +S:CONFIG_DRAM_ZQ=251
 # Wifi power
index 7e7a1ca3981cd4edeca132a71a9c1716fc011149..7704a0ef8108f86a97d8b60b018137ec12090d30 100644 (file)
@@ -4,4 +4,6 @@ CONFIG_FDTFILE="sun7i-a20-cubieboard2.dtb"
 +S:CONFIG_ARM=y
 +S:CONFIG_ARCH_SUNXI=y
 +S:CONFIG_MACH_SUN7I=y
-+S:CONFIG_TARGET_CUBIEBOARD2=y
++S:CONFIG_DRAM_CLK=480
++S:CONFIG_DRAM_ZQ=127
++S:CONFIG_DRAM_EMR1=4
index 0bc45fd2cb28af8c559d68371e1e3b82b821be9d..4efc6e147e88c0b4f8d263f531db5f1c49ee22c9 100644 (file)
@@ -4,4 +4,6 @@ CONFIG_FDTFILE="sun4i-a10-cubieboard.dtb"
 +S:CONFIG_ARM=y
 +S:CONFIG_ARCH_SUNXI=y
 +S:CONFIG_MACH_SUN4I=y
-+S:CONFIG_TARGET_CUBIEBOARD=y
++S:CONFIG_DRAM_CLK=480
++S:CONFIG_DRAM_ZQ=123
++S:CONFIG_DRAM_EMR1=0
index bc4441082b379669cb5edbd8a5b972de8ac92f19..b64f84f2b8d2d48bed3130aecd31d220013061f0 100644 (file)
@@ -5,4 +5,6 @@ CONFIG_VIDEO_VGA=y
 +S:CONFIG_ARM=y
 +S:CONFIG_ARCH_SUNXI=y
 +S:CONFIG_MACH_SUN7I=y
-+S:CONFIG_TARGET_CUBIETRUCK=y
++S:CONFIG_DRAM_CLK=432
++S:CONFIG_DRAM_ZQ=127
++S:CONFIG_DRAM_EMR1=4
index 8896999e1e38a37086a29f5c0f3e1baf2b0bc740..027546391f16638184dede90512798c0b8b89f43 100644 (file)
@@ -6,7 +6,6 @@ CONFIG_VIDEO_VGA_EXTERNAL_DAC_EN="PH25"
 +S:CONFIG_ARM=y
 +S:CONFIG_ARCH_SUNXI=y
 +S:CONFIG_MACH_SUN6I=y
-+S:CONFIG_TARGET_HUMMINGBIRD_A31=y
 +S:CONFIG_DRAM_CLK=312
 +S:CONFIG_DRAM_ZQ=251
 # Wifi power
diff --git a/configs/Hyundai_A7HD_defconfig b/configs/Hyundai_A7HD_defconfig
new file mode 100644 (file)
index 0000000..204640e
--- /dev/null
@@ -0,0 +1,23 @@
+# The Hyundai A7HD is a 7" 16:9 A10 powered tablet featuring 1G RAM, 8G
+# nand, 1024x600 IPS screen, a mini hdmi port, mini usb receptacle and a
+# headphones port for details see: http://linux-sunxi.org/Hyundai_A7HD
+CONFIG_SPL=y
+CONFIG_SYS_EXTRA_OPTIONS="AXP209_POWER"
+CONFIG_FDTFILE="sun4i-a10-hyundai-a7hd.dtb"
+CONFIG_USB_MUSB_SUNXI=y
+CONFIG_USB0_VBUS_PIN="PB09"
+CONFIG_USB1_VBUS_PIN=""
+CONFIG_USB2_VBUS_PIN="PH6"
+CONFIG_VIDEO_LCD_MODE="x:1024,y:600,depth:18,pclk_khz:51000,le:45,ri:274,up:22,lo:12,hs:1,vs:1,sync:3,vmode:0"
+CONFIG_VIDEO_LCD_DCLK_PHASE=1
+CONFIG_VIDEO_LCD_POWER="PH2"
+CONFIG_VIDEO_LCD_BL_EN="PH9"
+CONFIG_VIDEO_LCD_BL_PWM="PB2"
+CONFIG_VIDEO_LCD_BL_PWM_ACTIVE_LOW=n
+CONFIG_VIDEO_LCD_PANEL_LVDS=y
++S:CONFIG_ARM=y
++S:CONFIG_ARCH_SUNXI=y
++S:CONFIG_MACH_SUN4I=y
++S:CONFIG_DRAM_CLK=360
++S:CONFIG_DRAM_ZQ=123
++S:CONFIG_DRAM_EMR1=4
diff --git a/configs/Inet_86VS_defconfig b/configs/Inet_86VS_defconfig
new file mode 100644 (file)
index 0000000..ce9985a
--- /dev/null
@@ -0,0 +1,15 @@
+CONFIG_SPL=y
+CONFIG_SYS_EXTRA_OPTIONS="AXP209_POWER"
+CONFIG_FDTFILE="sun5i-a13-inet-86vs.dtb"
+CONFIG_USB_MUSB_SUNXI=y
+CONFIG_USB0_VBUS_PIN="PG12"
+CONFIG_VIDEO_LCD_MODE="x:800,y:480,depth:18,pclk_khz:33000,le:45,ri:209,up:22,lo:22,hs:1,vs:1,sync:3,vmode:0"
+CONFIG_VIDEO_LCD_POWER="AXP0-0"
+CONFIG_VIDEO_LCD_BL_EN="AXP0-1"
+CONFIG_VIDEO_LCD_BL_PWM="PB2"
++S:CONFIG_ARM=y
++S:CONFIG_ARCH_SUNXI=y
++S:CONFIG_MACH_SUN5I=y
++S:CONFIG_DRAM_CLK=408
++S:CONFIG_DRAM_ZQ=123
++S:CONFIG_DRAM_EMR1=4
index 0447b06c2b178bf546917bf72b1eb39d4a94b80f..192a461f55f6462c3519a9d5aade9b1be0020b15 100644 (file)
@@ -1,11 +1,13 @@
 CONFIG_SPL=y
 CONFIG_SYS_EXTRA_OPTIONS="CONS_INDEX=5"
 CONFIG_FDTFILE="sun8i-a23-ippo-q8h-v1.2.dtb"
+CONFIG_USB_MUSB_SUNXI=y
+CONFIG_USB0_VBUS_PIN="axp_drivebus"
 CONFIG_VIDEO_LCD_MODE="x:800,y:480,depth:18,pclk_khz:33000,le:87,ri:167,up:31,lo:13,hs:1,vs:1,sync:3,vmode:0"
+CONFIG_VIDEO_LCD_DCLK_PHASE=0
 CONFIG_VIDEO_LCD_POWER="PH7"
 CONFIG_VIDEO_LCD_BL_EN="PH6"
 CONFIG_VIDEO_LCD_BL_PWM="PH0"
-CONFIG_USB_KEYBOARD=n
 +S:CONFIG_ARM=y
 +S:CONFIG_ARCH_SUNXI=y
 +S:CONFIG_MACH_SUN8I=y
index 4e82bf93653e371b85d7c8421b150b43b20ee82a..4786202e16710c5d6511c46b8ba97b5ad4411fc6 100644 (file)
@@ -1,15 +1,16 @@
 CONFIG_SPL=y
 CONFIG_SYS_EXTRA_OPTIONS="CONS_INDEX=5"
 CONFIG_FDTFILE="sun8i-a23-ippo-q8h-v5.dtb"
+CONFIG_USB_MUSB_SUNXI=y
+CONFIG_USB0_VBUS_PIN="axp_drivebus"
 CONFIG_VIDEO_LCD_MODE="x:800,y:480,depth:18,pclk_khz:33000,le:87,ri:168,up:31,lo:13,hs:1,vs:1,sync:3,vmode:0"
+CONFIG_VIDEO_LCD_DCLK_PHASE=0
 CONFIG_VIDEO_LCD_POWER="PH7"
 CONFIG_VIDEO_LCD_BL_EN="PH6"
 CONFIG_VIDEO_LCD_BL_PWM="PH0"
-CONFIG_USB_KEYBOARD=n
 +S:CONFIG_ARM=y
 +S:CONFIG_ARCH_SUNXI=y
 +S:CONFIG_MACH_SUN8I=y
-+S:CONFIG_TARGET_IPPO_Q8H_V5=y
 +S:CONFIG_DRAM_CLK=480
 # zq = 0xf777
 +S:CONFIG_DRAM_ZQ=63351
diff --git a/configs/Linksprite_pcDuino3_Nano_defconfig b/configs/Linksprite_pcDuino3_Nano_defconfig
new file mode 100644 (file)
index 0000000..4baba14
--- /dev/null
@@ -0,0 +1,11 @@
+CONFIG_SPL=y
+CONFIG_SYS_EXTRA_OPTIONS="AXP209_POWER,SUNXI_GMAC,RGMII,AHCI,SATAPWR=SUNXI_GPH(2),USB_EHCI"
+CONFIG_FDTFILE="sun7i-a20-pcduino3-nano.dtb"
+CONFIG_GMAC_TX_DELAY=3
+CONFIG_USB1_VBUS_PIN="PH11"
++S:CONFIG_ARM=y
++S:CONFIG_ARCH_SUNXI=y
++S:CONFIG_MACH_SUN7I=y
++S:CONFIG_DRAM_CLK=408
++S:CONFIG_DRAM_ZQ=122
++S:CONFIG_DRAM_EMR1=4
index a26ff0a70f40efcb2fc9cdac035d49465c0f90c9..45d88f301576106940b020a4d9c32ddd595adf2a 100644 (file)
@@ -4,4 +4,6 @@ CONFIG_FDTFILE="sun7i-a20-pcduino3.dtb"
 +S:CONFIG_ARM=y
 +S:CONFIG_ARCH_SUNXI=y
 +S:CONFIG_MACH_SUN7I=y
-+S:CONFIG_TARGET_PCDUINO3=y
++S:CONFIG_DRAM_CLK=480
++S:CONFIG_DRAM_ZQ=122
++S:CONFIG_DRAM_EMR1=4
index a33f3a7981faa8723989d4b88ee0eda21bf84265..3b6dfa6fa691e9ac717609a268115e40e9772aac 100644 (file)
@@ -8,4 +8,6 @@ CONFIG_OF_SEPARATE=y
 +S:CONFIG_ARM=y
 +S:CONFIG_ARCH_SUNXI=y
 +S:CONFIG_MACH_SUN7I=y
-+S:CONFIG_TARGET_PCDUINO3=y
++S:CONFIG_DRAM_CLK=480
++S:CONFIG_DRAM_ZQ=122
++S:CONFIG_DRAM_EMR1=4
index f5b0ca9877f6277ad241631fb62cb85e3324517c..1ba37bb3fbdd1d9a00c74053143512ffec648a9d 100644 (file)
@@ -4,4 +4,6 @@ CONFIG_FDTFILE="sun4i-a10-pcduino.dtb"
 +S:CONFIG_ARM=y
 +S:CONFIG_ARCH_SUNXI=y
 +S:CONFIG_MACH_SUN4I=y
-+S:CONFIG_TARGET_PCDUINO=y
++S:CONFIG_DRAM_CLK=408
++S:CONFIG_DRAM_ZQ=123
++S:CONFIG_DRAM_EMR1=0
diff --git a/configs/Lite5200_LOWBOOT08_defconfig b/configs/Lite5200_LOWBOOT08_defconfig
deleted file mode 100644 (file)
index 9f0cbd8..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-CONFIG_SYS_EXTRA_OPTIONS="SYS_TEXT_BASE=0xFF800000"
-CONFIG_PPC=y
-CONFIG_MPC5xxx=y
-CONFIG_TARGET_ICECUBE=y
diff --git a/configs/Lite5200_LOWBOOT_defconfig b/configs/Lite5200_LOWBOOT_defconfig
deleted file mode 100644 (file)
index ff1552f..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-CONFIG_SYS_EXTRA_OPTIONS="SYS_TEXT_BASE=0xFF000000"
-CONFIG_PPC=y
-CONFIG_MPC5xxx=y
-CONFIG_TARGET_ICECUBE=y
diff --git a/configs/Lite5200_defconfig b/configs/Lite5200_defconfig
deleted file mode 100644 (file)
index 49fdb3b..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-CONFIG_PPC=y
-CONFIG_MPC5xxx=y
-CONFIG_TARGET_ICECUBE=y
diff --git a/configs/MPC8360EMDS_33_ATM_defconfig b/configs/MPC8360EMDS_33_ATM_defconfig
deleted file mode 100644 (file)
index dc325b1..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-CONFIG_SYS_EXTRA_OPTIONS="CLKIN_33MHZ,PQ_MDS_PIB=1,PQ_MDS_PIB_ATM=1"
-CONFIG_PPC=y
-CONFIG_MPC83xx=y
-CONFIG_TARGET_MPC8360EMDS=y
diff --git a/configs/MPC8360EMDS_33_HOST_33_defconfig b/configs/MPC8360EMDS_33_HOST_33_defconfig
deleted file mode 100644 (file)
index fba273d..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-CONFIG_SYS_EXTRA_OPTIONS="CLKIN_33MHZ,PCI,PCI_33M,PQ_MDS_PIB=1"
-CONFIG_PPC=y
-CONFIG_MPC83xx=y
-CONFIG_TARGET_MPC8360EMDS=y
diff --git a/configs/MPC8360EMDS_33_HOST_66_defconfig b/configs/MPC8360EMDS_33_HOST_66_defconfig
deleted file mode 100644 (file)
index e0cf6da..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-CONFIG_SYS_EXTRA_OPTIONS="CLKIN_33MHZ,PCI,PCI_66M,PQ_MDS_PIB=1"
-CONFIG_PPC=y
-CONFIG_MPC83xx=y
-CONFIG_TARGET_MPC8360EMDS=y
diff --git a/configs/MPC8360EMDS_33_SLAVE_defconfig b/configs/MPC8360EMDS_33_SLAVE_defconfig
deleted file mode 100644 (file)
index c3f74fc..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-CONFIG_SYS_EXTRA_OPTIONS="CLKIN_33MHZ,PCI,PCISLAVE"
-CONFIG_PPC=y
-CONFIG_MPC83xx=y
-CONFIG_TARGET_MPC8360EMDS=y
diff --git a/configs/MPC8360EMDS_33_defconfig b/configs/MPC8360EMDS_33_defconfig
deleted file mode 100644 (file)
index 60c6ddb..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-CONFIG_SYS_EXTRA_OPTIONS="CLKIN_33MHZ"
-CONFIG_PPC=y
-CONFIG_MPC83xx=y
-CONFIG_TARGET_MPC8360EMDS=y
diff --git a/configs/MPC8360EMDS_66_ATM_defconfig b/configs/MPC8360EMDS_66_ATM_defconfig
deleted file mode 100644 (file)
index 16f12fb..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-CONFIG_SYS_EXTRA_OPTIONS="CLKIN_66MHZ,PQ_MDS_PIB=1,PQ_MDS_PIB_ATM=1"
-CONFIG_PPC=y
-CONFIG_MPC83xx=y
-CONFIG_TARGET_MPC8360EMDS=y
diff --git a/configs/MPC8360EMDS_66_HOST_33_defconfig b/configs/MPC8360EMDS_66_HOST_33_defconfig
deleted file mode 100644 (file)
index 797a584..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-CONFIG_SYS_EXTRA_OPTIONS="CLKIN_66MHZ,PCI,PCI_33M,PQ_MDS_PIB=1"
-CONFIG_PPC=y
-CONFIG_MPC83xx=y
-CONFIG_TARGET_MPC8360EMDS=y
diff --git a/configs/MPC8360EMDS_66_HOST_66_defconfig b/configs/MPC8360EMDS_66_HOST_66_defconfig
deleted file mode 100644 (file)
index a887c29..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-CONFIG_SYS_EXTRA_OPTIONS="CLKIN_66MHZ,PCI,PCI_66M,PQ_MDS_PIB=1"
-CONFIG_PPC=y
-CONFIG_MPC83xx=y
-CONFIG_TARGET_MPC8360EMDS=y
diff --git a/configs/MPC8360EMDS_66_SLAVE_defconfig b/configs/MPC8360EMDS_66_SLAVE_defconfig
deleted file mode 100644 (file)
index 4442c61..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-CONFIG_SYS_EXTRA_OPTIONS="CLKIN_66MHZ,PCI,PCISLAVE"
-CONFIG_PPC=y
-CONFIG_MPC83xx=y
-CONFIG_TARGET_MPC8360EMDS=y
diff --git a/configs/MPC8360EMDS_66_defconfig b/configs/MPC8360EMDS_66_defconfig
deleted file mode 100644 (file)
index fce95dd..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-CONFIG_SYS_EXTRA_OPTIONS="CLKIN_66MHZ"
-CONFIG_PPC=y
-CONFIG_MPC83xx=y
-CONFIG_TARGET_MPC8360EMDS=y
diff --git a/configs/MPC8360ERDK_33_defconfig b/configs/MPC8360ERDK_33_defconfig
deleted file mode 100644 (file)
index 91c47b7..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-CONFIG_SYS_EXTRA_OPTIONS="CLKIN_33MHZ"
-CONFIG_PPC=y
-CONFIG_MPC83xx=y
-CONFIG_TARGET_MPC8360ERDK=y
diff --git a/configs/MPC8360ERDK_defconfig b/configs/MPC8360ERDK_defconfig
deleted file mode 100644 (file)
index 7e9fa59..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-CONFIG_PPC=y
-CONFIG_MPC83xx=y
-CONFIG_TARGET_MPC8360ERDK=y
index ef1adc5623136c5d0cf3bc654f1d309df6174fc3..c6fb7e65d0f94f1e0de6e4a0558bf83326714a0d 100644 (file)
@@ -1,7 +1,16 @@
+# The MSI Primo73 is an A20 based tablet, with 1G RAM, 16G NAND,
+# 1024x600 TN LCD display, mono speaker, 0.3 MP front camera, 2.0 MP
+# rear camera, 3000 mAh battery, gt911 touchscreen, mma8452 accelerometer
+# and rtl8188etv usb wifi. Has "power", "volume+" and "volume-" buttons
+# (both volume buttons are also connected to the UBOOT_SEL pin). The
+# external connectors are represented by MicroSD slot, MiniHDMI, MicroUSB
+# OTG and 3.5mm headphone jack. More details are available at
+#    http://linux-sunxi.org/MSI_Primo73
 CONFIG_SPL=y
 CONFIG_SYS_EXTRA_OPTIONS="AXP209_POWER"
 CONFIG_FDTFILE="sun7i-a20-primo73.dtb"
 CONFIG_VIDEO_LCD_MODE="x:1024,y:600,depth:18,pclk_khz:60000,le:60,ri:160,up:13,lo:12,hs:100,vs:10,sync:3,vmode:0"
+CONFIG_VIDEO_LCD_DCLK_PHASE=0
 CONFIG_VIDEO_LCD_POWER="PH8"
 CONFIG_VIDEO_LCD_BL_EN="PH7"
 CONFIG_VIDEO_LCD_BL_PWM="PB2"
@@ -9,4 +18,6 @@ CONFIG_USB_KEYBOARD=n
 +S:CONFIG_ARM=y
 +S:CONFIG_ARCH_SUNXI=y
 +S:CONFIG_MACH_SUN7I=y
-+S:CONFIG_TARGET_MSI_PRIMO73=y
++S:CONFIG_DRAM_CLK=384
++S:CONFIG_DRAM_ZQ=127
++S:CONFIG_DRAM_EMR1=4
index b4b0f6d0e2362de0fa4720fa168fe748d4ee6b74..6657ad66c9727ac4ceb2bb5bad3a6f16d09f1b2f 100644 (file)
@@ -1,11 +1,29 @@
+# The MSI Primo81 is an A31s based tablet, with 1G RAM, 16G NAND,
+# 1024x768 IPS LCD display, mono speaker, 0.3 MP front camera, 2.0 MP
+# rear camera, 3500 mAh battery, gt911 touchscreen, mma8452 accelerometer
+# and rtl8188etv usb wifi. Has "power", "volume+" and "volume-" buttons
+# (both volume buttons are also connected to the UBOOT_SEL pin). The
+# external connectors are represented by MicroSD slot, MiniHDMI, MicroUSB
+# OTG and 3.5mm headphone jack. More details are available at
+#     http://linux-sunxi.org/MSI_Primo81
+
 CONFIG_SPL=y
 CONFIG_SYS_EXTRA_OPTIONS=""
 CONFIG_FDTFILE="sun6i-a31s-primo81.dtb"
+CONFIG_VIDEO_LCD_MODE="x:768,y:1024,depth:18,pclk_khz:66000,le:56,ri:60,up:30,lo:36,hs:64,vs:50,sync:3,vmode:0"
+CONFIG_VIDEO_LCD_PANEL_MIPI_4_LANE_513_MBPS_VIA_SSD2828=y
+CONFIG_VIDEO_LCD_SSD2828_TX_CLK=27
+CONFIG_VIDEO_LCD_SSD2828_RESET="PA26"
+CONFIG_VIDEO_LCD_SPI_CS="PH9"
+CONFIG_VIDEO_LCD_SPI_SCLK="PH10"
+CONFIG_VIDEO_LCD_SPI_MOSI="PH11"
+CONFIG_VIDEO_LCD_SPI_MISO="PH12"
+CONFIG_VIDEO_LCD_BL_EN="PA25"
+CONFIG_VIDEO_LCD_BL_PWM="PH13"
 CONFIG_USB_KEYBOARD=n
 +S:CONFIG_ARM=y
 +S:CONFIG_ARCH_SUNXI=y
 +S:CONFIG_MACH_SUN6I=y
-+S:CONFIG_TARGET_MSI_PRIMO81=y
 +S:CONFIG_DRAM_CLK=360
 +S:CONFIG_DRAM_ZQ=122
 # Wifi power
diff --git a/configs/Marsboard_A10_defconfig b/configs/Marsboard_A10_defconfig
new file mode 100644 (file)
index 0000000..653cb01
--- /dev/null
@@ -0,0 +1,9 @@
+CONFIG_SPL=y
+CONFIG_SYS_EXTRA_OPTIONS="SUNXI_EMAC,AHCI,USB_EHCI"
+CONFIG_FDTFILE="sun4i-a10-marsboard.dtb"
++S:CONFIG_ARM=y
++S:CONFIG_ARCH_SUNXI=y
++S:CONFIG_MACH_SUN4I=y
++S:CONFIG_DRAM_CLK=360
++S:CONFIG_DRAM_ZQ=123
++S:CONFIG_DRAM_EMR1=0
diff --git a/configs/Mele_A1000G_defconfig b/configs/Mele_A1000G_defconfig
deleted file mode 100644 (file)
index 9cb3285..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-CONFIG_SPL=y
-CONFIG_SYS_EXTRA_OPTIONS="AXP209_POWER,SUNXI_EMAC,MACPWR=SUNXI_GPH(15),AHCI,USB_EHCI"
-CONFIG_FDTFILE="sun4i-a10-a1000.dtb"
-CONFIG_VIDEO_VGA=y
-+S:CONFIG_ARM=y
-+S:CONFIG_ARCH_SUNXI=y
-+S:CONFIG_MACH_SUN4I=y
-+S:CONFIG_TARGET_MELE_A1000G=y
index 97d94542d348efa2138116e309e0339909cf326b..1a0a025bd9eaa3b67ea6f3fb6c626b0af6f71076 100644 (file)
@@ -5,4 +5,6 @@ CONFIG_VIDEO_VGA=y
 +S:CONFIG_ARM=y
 +S:CONFIG_ARCH_SUNXI=y
 +S:CONFIG_MACH_SUN4I=y
-+S:CONFIG_TARGET_MELE_A1000=y
++S:CONFIG_DRAM_CLK=360
++S:CONFIG_DRAM_ZQ=123
++S:CONFIG_DRAM_EMR1=0
index 141d565cf8cfa6e1aa25224f562431fb2669c024..723a72a2efb1d68f49e8cdd78ca2eb07eb331ac4 100644 (file)
@@ -7,4 +7,6 @@ CONFIG_VIDEO_VGA=y
 +S:CONFIG_ARM=y
 +S:CONFIG_ARCH_SUNXI=y
 +S:CONFIG_MACH_SUN7I=y
-+S:CONFIG_TARGET_MELE_M3=y
++S:CONFIG_DRAM_CLK=384
++S:CONFIG_DRAM_ZQ=127
++S:CONFIG_DRAM_EMR1=4
diff --git a/configs/Mele_M5_defconfig b/configs/Mele_M5_defconfig
new file mode 100644 (file)
index 0000000..2e1f80d
--- /dev/null
@@ -0,0 +1,13 @@
+CONFIG_SPL=y
+CONFIG_SYS_EXTRA_OPTIONS="SUNXI_GMAC,AHCI,USB_EHCI,STATUSLED=234"
+CONFIG_FDTFILE="sun7i-a20-m5.dtb"
+CONFIG_VIDEO_HDMI=y
++S:CONFIG_MMC0_CD_PIN="PH1"
++S:CONFIG_USB1_VBUS_PIN="PH6"
++S:CONFIG_USB2_VBUS_PIN="PH3"
++S:CONFIG_ARM=y
++S:CONFIG_ARCH_SUNXI=y
++S:CONFIG_MACH_SUN7I=y
++S:CONFIG_DRAM_CLK=432
++S:CONFIG_DRAM_ZQ=122
++S:CONFIG_DRAM_EMR1=4
index e5ab0ec3029c62b478f06c76556feb969988c674..eaf9a7e349b3c765228398ccbbe4f3f34aff807a 100644 (file)
@@ -4,7 +4,6 @@ CONFIG_FDTFILE="sun6i-a31-m9.dtb"
 +S:CONFIG_ARM=y
 +S:CONFIG_ARCH_SUNXI=y
 +S:CONFIG_MACH_SUN6I=y
-+S:CONFIG_TARGET_MELE_M9=y
 +S:CONFIG_DRAM_CLK=312
 +S:CONFIG_DRAM_ZQ=120
 # The Mele M9 uses 3.3V for general IO
diff --git a/configs/Mini-X-1Gb_defconfig b/configs/Mini-X-1Gb_defconfig
deleted file mode 100644 (file)
index b8fea01..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-CONFIG_SPL=y
-CONFIG_SYS_EXTRA_OPTIONS="AXP209_POWER,USB_EHCI"
-CONFIG_FDTFILE="sun4i-a10-mini-xplus.dtb"
-+S:CONFIG_ARM=y
-+S:CONFIG_ARCH_SUNXI=y
-+S:CONFIG_MACH_SUN4I=y
-+S:CONFIG_TARGET_MINI_X_1GB=y
index 0f6bbe06b2c5d09585a334403b3dd97e91594dd3..6aea77716d35e62f608e67dc8fd20fb40e99e665 100644 (file)
@@ -4,4 +4,6 @@ CONFIG_FDTFILE="sun4i-a10-mini-xplus.dtb"
 +S:CONFIG_ARM=y
 +S:CONFIG_ARCH_SUNXI=y
 +S:CONFIG_MACH_SUN4I=y
-+S:CONFIG_TARGET_MINI_X=y
++S:CONFIG_DRAM_CLK=360
++S:CONFIG_DRAM_ZQ=123
++S:CONFIG_DRAM_EMR1=0
diff --git a/configs/P1011RDB_36BIT_SDCARD_defconfig b/configs/P1011RDB_36BIT_SDCARD_defconfig
deleted file mode 100644 (file)
index 7205bef..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-CONFIG_SPL=y
-CONFIG_SYS_EXTRA_OPTIONS="P1011RDB,36BIT,SDCARD"
-+S:CONFIG_PPC=y
-+S:CONFIG_MPC85xx=y
-+S:CONFIG_TARGET_P1_P2_RDB=y
diff --git a/configs/P1011RDB_36BIT_SPIFLASH_defconfig b/configs/P1011RDB_36BIT_SPIFLASH_defconfig
deleted file mode 100644 (file)
index 8b3806e..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-CONFIG_SPL=y
-CONFIG_SYS_EXTRA_OPTIONS="P1011RDB,36BIT,SPIFLASH"
-+S:CONFIG_PPC=y
-+S:CONFIG_MPC85xx=y
-+S:CONFIG_TARGET_P1_P2_RDB=y
diff --git a/configs/P1011RDB_36BIT_defconfig b/configs/P1011RDB_36BIT_defconfig
deleted file mode 100644 (file)
index c47f2e2..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-CONFIG_SYS_EXTRA_OPTIONS="P1011RDB,36BIT"
-CONFIG_PPC=y
-CONFIG_MPC85xx=y
-CONFIG_TARGET_P1_P2_RDB=y
diff --git a/configs/P1011RDB_NAND_defconfig b/configs/P1011RDB_NAND_defconfig
deleted file mode 100644 (file)
index aac0190..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-CONFIG_SPL=y
-CONFIG_TPL=y
-CONFIG_SYS_EXTRA_OPTIONS="P1011RDB,NAND"
-+ST:CONFIG_PPC=y
-+ST:CONFIG_MPC85xx=y
-+ST:CONFIG_TARGET_P1_P2_RDB=y
diff --git a/configs/P1011RDB_SDCARD_defconfig b/configs/P1011RDB_SDCARD_defconfig
deleted file mode 100644 (file)
index 16e872f..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-CONFIG_SPL=y
-CONFIG_SYS_EXTRA_OPTIONS="P1011RDB,SDCARD"
-+S:CONFIG_PPC=y
-+S:CONFIG_MPC85xx=y
-+S:CONFIG_TARGET_P1_P2_RDB=y
diff --git a/configs/P1011RDB_SPIFLASH_defconfig b/configs/P1011RDB_SPIFLASH_defconfig
deleted file mode 100644 (file)
index d14820f..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-CONFIG_SPL=y
-CONFIG_SYS_EXTRA_OPTIONS="P1011RDB,SPIFLASH"
-+S:CONFIG_PPC=y
-+S:CONFIG_MPC85xx=y
-+S:CONFIG_TARGET_P1_P2_RDB=y
diff --git a/configs/P1011RDB_defconfig b/configs/P1011RDB_defconfig
deleted file mode 100644 (file)
index d14868a..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-CONFIG_SYS_EXTRA_OPTIONS="P1011RDB"
-CONFIG_PPC=y
-CONFIG_MPC85xx=y
-CONFIG_TARGET_P1_P2_RDB=y
diff --git a/configs/P1020RDB_36BIT_SDCARD_defconfig b/configs/P1020RDB_36BIT_SDCARD_defconfig
deleted file mode 100644 (file)
index a18563e..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-CONFIG_SPL=y
-CONFIG_SYS_EXTRA_OPTIONS="P1020RDB,36BIT,SDCARD"
-+S:CONFIG_PPC=y
-+S:CONFIG_MPC85xx=y
-+S:CONFIG_TARGET_P1_P2_RDB=y
diff --git a/configs/P1020RDB_36BIT_SPIFLASH_defconfig b/configs/P1020RDB_36BIT_SPIFLASH_defconfig
deleted file mode 100644 (file)
index aa145fc..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-CONFIG_SPL=y
-CONFIG_SYS_EXTRA_OPTIONS="P1020RDB,36BIT,SPIFLASH"
-+S:CONFIG_PPC=y
-+S:CONFIG_MPC85xx=y
-+S:CONFIG_TARGET_P1_P2_RDB=y
diff --git a/configs/P1020RDB_36BIT_defconfig b/configs/P1020RDB_36BIT_defconfig
deleted file mode 100644 (file)
index 844651f..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-CONFIG_SYS_EXTRA_OPTIONS="P1020RDB,36BIT"
-CONFIG_PPC=y
-CONFIG_MPC85xx=y
-CONFIG_TARGET_P1_P2_RDB=y
diff --git a/configs/P1020RDB_NAND_defconfig b/configs/P1020RDB_NAND_defconfig
deleted file mode 100644 (file)
index 441241b..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-CONFIG_SPL=y
-CONFIG_TPL=y
-CONFIG_SYS_EXTRA_OPTIONS="P1020RDB,NAND"
-+ST:CONFIG_PPC=y
-+ST:CONFIG_MPC85xx=y
-+ST:CONFIG_TARGET_P1_P2_RDB=y
diff --git a/configs/P1020RDB_SDCARD_defconfig b/configs/P1020RDB_SDCARD_defconfig
deleted file mode 100644 (file)
index 1349bea..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-CONFIG_SPL=y
-CONFIG_SYS_EXTRA_OPTIONS="P1020RDB,SDCARD"
-+S:CONFIG_PPC=y
-+S:CONFIG_MPC85xx=y
-+S:CONFIG_TARGET_P1_P2_RDB=y
diff --git a/configs/P1020RDB_SPIFLASH_defconfig b/configs/P1020RDB_SPIFLASH_defconfig
deleted file mode 100644 (file)
index 7eb8696..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-CONFIG_SPL=y
-CONFIG_SYS_EXTRA_OPTIONS="P1020RDB,SPIFLASH"
-+S:CONFIG_PPC=y
-+S:CONFIG_MPC85xx=y
-+S:CONFIG_TARGET_P1_P2_RDB=y
diff --git a/configs/P1020RDB_defconfig b/configs/P1020RDB_defconfig
deleted file mode 100644 (file)
index fc58ac9..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-CONFIG_SYS_EXTRA_OPTIONS="P1020RDB"
-CONFIG_PPC=y
-CONFIG_MPC85xx=y
-CONFIG_TARGET_P1_P2_RDB=y
diff --git a/configs/P2010RDB_36BIT_SDCARD_defconfig b/configs/P2010RDB_36BIT_SDCARD_defconfig
deleted file mode 100644 (file)
index 1381e8e..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-CONFIG_SPL=y
-CONFIG_SYS_EXTRA_OPTIONS="P2010RDB,36BIT,SDCARD"
-+S:CONFIG_PPC=y
-+S:CONFIG_MPC85xx=y
-+S:CONFIG_TARGET_P1_P2_RDB=y
diff --git a/configs/P2010RDB_36BIT_SPIFLASH_defconfig b/configs/P2010RDB_36BIT_SPIFLASH_defconfig
deleted file mode 100644 (file)
index 53ebca1..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-CONFIG_SPL=y
-CONFIG_SYS_EXTRA_OPTIONS="P2010RDB,36BIT,SPIFLASH"
-+S:CONFIG_PPC=y
-+S:CONFIG_MPC85xx=y
-+S:CONFIG_TARGET_P1_P2_RDB=y
diff --git a/configs/P2010RDB_36BIT_defconfig b/configs/P2010RDB_36BIT_defconfig
deleted file mode 100644 (file)
index de29dcb..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-CONFIG_SYS_EXTRA_OPTIONS="P2010RDB,36BIT"
-CONFIG_PPC=y
-CONFIG_MPC85xx=y
-CONFIG_TARGET_P1_P2_RDB=y
diff --git a/configs/P2010RDB_NAND_defconfig b/configs/P2010RDB_NAND_defconfig
deleted file mode 100644 (file)
index bc91a67..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-CONFIG_SPL=y
-CONFIG_TPL=y
-CONFIG_SYS_EXTRA_OPTIONS="P2010RDB,NAND"
-+ST:CONFIG_PPC=y
-+ST:CONFIG_MPC85xx=y
-+ST:CONFIG_TARGET_P1_P2_RDB=y
diff --git a/configs/P2010RDB_SDCARD_defconfig b/configs/P2010RDB_SDCARD_defconfig
deleted file mode 100644 (file)
index fd4ade7..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-CONFIG_SPL=y
-CONFIG_SYS_EXTRA_OPTIONS="P2010RDB,SDCARD"
-+S:CONFIG_PPC=y
-+S:CONFIG_MPC85xx=y
-+S:CONFIG_TARGET_P1_P2_RDB=y
diff --git a/configs/P2010RDB_SPIFLASH_defconfig b/configs/P2010RDB_SPIFLASH_defconfig
deleted file mode 100644 (file)
index 9631864..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-CONFIG_SPL=y
-CONFIG_SYS_EXTRA_OPTIONS="P2010RDB,SPIFLASH"
-+S:CONFIG_PPC=y
-+S:CONFIG_MPC85xx=y
-+S:CONFIG_TARGET_P1_P2_RDB=y
diff --git a/configs/P2010RDB_defconfig b/configs/P2010RDB_defconfig
deleted file mode 100644 (file)
index 3b3352a..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-CONFIG_SYS_EXTRA_OPTIONS="P2010RDB"
-CONFIG_PPC=y
-CONFIG_MPC85xx=y
-CONFIG_TARGET_P1_P2_RDB=y
diff --git a/configs/P2020COME_SDCARD_defconfig b/configs/P2020COME_SDCARD_defconfig
deleted file mode 100644 (file)
index c186fcb..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-CONFIG_SYS_EXTRA_OPTIONS="SDCARD"
-CONFIG_PPC=y
-CONFIG_MPC85xx=y
-CONFIG_TARGET_P2020COME=y
diff --git a/configs/P2020COME_SPIFLASH_defconfig b/configs/P2020COME_SPIFLASH_defconfig
deleted file mode 100644 (file)
index 17ce136..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-CONFIG_SYS_EXTRA_OPTIONS="SPIFLASH"
-CONFIG_PPC=y
-CONFIG_MPC85xx=y
-CONFIG_TARGET_P2020COME=y
diff --git a/configs/P2020DS_36BIT_defconfig b/configs/P2020DS_36BIT_defconfig
deleted file mode 100644 (file)
index 359c446..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-CONFIG_SYS_EXTRA_OPTIONS="36BIT"
-CONFIG_PPC=y
-CONFIG_MPC85xx=y
-CONFIG_TARGET_P2020DS=y
diff --git a/configs/P2020DS_DDR2_defconfig b/configs/P2020DS_DDR2_defconfig
deleted file mode 100644 (file)
index 00b6731..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-CONFIG_SYS_EXTRA_OPTIONS="DDR2"
-CONFIG_PPC=y
-CONFIG_MPC85xx=y
-CONFIG_TARGET_P2020DS=y
diff --git a/configs/P2020DS_SDCARD_defconfig b/configs/P2020DS_SDCARD_defconfig
deleted file mode 100644 (file)
index 89aef3a..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-CONFIG_SYS_EXTRA_OPTIONS="SDCARD"
-CONFIG_PPC=y
-CONFIG_MPC85xx=y
-CONFIG_TARGET_P2020DS=y
diff --git a/configs/P2020DS_SPIFLASH_defconfig b/configs/P2020DS_SPIFLASH_defconfig
deleted file mode 100644 (file)
index 503328c..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-CONFIG_SYS_EXTRA_OPTIONS="SPIFLASH"
-CONFIG_PPC=y
-CONFIG_MPC85xx=y
-CONFIG_TARGET_P2020DS=y
diff --git a/configs/P2020DS_defconfig b/configs/P2020DS_defconfig
deleted file mode 100644 (file)
index f2ac6d9..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-CONFIG_PPC=y
-CONFIG_MPC85xx=y
-CONFIG_TARGET_P2020DS=y
diff --git a/configs/P2020RDB_36BIT_SDCARD_defconfig b/configs/P2020RDB_36BIT_SDCARD_defconfig
deleted file mode 100644 (file)
index 43cc2e3..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-CONFIG_SPL=y
-CONFIG_SYS_EXTRA_OPTIONS="P2020RDB,36BIT,SDCARD"
-+S:CONFIG_PPC=y
-+S:CONFIG_MPC85xx=y
-+S:CONFIG_TARGET_P1_P2_RDB=y
diff --git a/configs/P2020RDB_36BIT_SPIFLASH_defconfig b/configs/P2020RDB_36BIT_SPIFLASH_defconfig
deleted file mode 100644 (file)
index f1199b6..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-CONFIG_SPL=y
-CONFIG_SYS_EXTRA_OPTIONS="P2020RDB,36BIT,SPIFLASH"
-+S:CONFIG_PPC=y
-+S:CONFIG_MPC85xx=y
-+S:CONFIG_TARGET_P1_P2_RDB=y
diff --git a/configs/P2020RDB_36BIT_defconfig b/configs/P2020RDB_36BIT_defconfig
deleted file mode 100644 (file)
index 87490fd..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-CONFIG_SYS_EXTRA_OPTIONS="P2020RDB,36BIT"
-CONFIG_PPC=y
-CONFIG_MPC85xx=y
-CONFIG_TARGET_P1_P2_RDB=y
diff --git a/configs/P2020RDB_NAND_defconfig b/configs/P2020RDB_NAND_defconfig
deleted file mode 100644 (file)
index 70ee084..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-CONFIG_SPL=y
-CONFIG_TPL=y
-CONFIG_SYS_EXTRA_OPTIONS="P2020RDB,NAND"
-+ST:CONFIG_PPC=y
-+ST:CONFIG_MPC85xx=y
-+ST:CONFIG_TARGET_P1_P2_RDB=y
diff --git a/configs/P2020RDB_SDCARD_defconfig b/configs/P2020RDB_SDCARD_defconfig
deleted file mode 100644 (file)
index 2bf5773..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-CONFIG_SPL=y
-CONFIG_SYS_EXTRA_OPTIONS="P2020RDB,SDCARD"
-+S:CONFIG_PPC=y
-+S:CONFIG_MPC85xx=y
-+S:CONFIG_TARGET_P1_P2_RDB=y
diff --git a/configs/P2020RDB_SPIFLASH_defconfig b/configs/P2020RDB_SPIFLASH_defconfig
deleted file mode 100644 (file)
index 290ebd2..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-CONFIG_SPL=y
-CONFIG_SYS_EXTRA_OPTIONS="P2020RDB,SPIFLASH"
-+S:CONFIG_PPC=y
-+S:CONFIG_MPC85xx=y
-+S:CONFIG_TARGET_P1_P2_RDB=y
diff --git a/configs/P2020RDB_defconfig b/configs/P2020RDB_defconfig
deleted file mode 100644 (file)
index cc39735..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-CONFIG_SYS_EXTRA_OPTIONS="P2020RDB"
-CONFIG_PPC=y
-CONFIG_MPC85xx=y
-CONFIG_TARGET_P1_P2_RDB=y
diff --git a/configs/P5040DS_SECURE_BOOT_defconfig b/configs/P5040DS_SECURE_BOOT_defconfig
new file mode 100644 (file)
index 0000000..8e21ca5
--- /dev/null
@@ -0,0 +1,4 @@
+CONFIG_SYS_EXTRA_OPTIONS="SECURE_BOOT"
+CONFIG_PPC=y
+CONFIG_MPC85xx=y
+CONFIG_TARGET_P5040DS=y
diff --git a/configs/PM520_DDR_defconfig b/configs/PM520_DDR_defconfig
deleted file mode 100644 (file)
index 6d6a59d..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-CONFIG_SYS_EXTRA_OPTIONS="MPC5200_DDR"
-CONFIG_PPC=y
-CONFIG_MPC5xxx=y
-CONFIG_TARGET_PM520=y
diff --git a/configs/PM520_ROMBOOT_DDR_defconfig b/configs/PM520_ROMBOOT_DDR_defconfig
deleted file mode 100644 (file)
index f5a40d9..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-CONFIG_SYS_EXTRA_OPTIONS="MPC5200_DDR,BOOT_ROM"
-CONFIG_PPC=y
-CONFIG_MPC5xxx=y
-CONFIG_TARGET_PM520=y
diff --git a/configs/PM520_ROMBOOT_defconfig b/configs/PM520_ROMBOOT_defconfig
deleted file mode 100644 (file)
index d9f9ea0..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-CONFIG_SYS_EXTRA_OPTIONS="BOOT_ROM"
-CONFIG_PPC=y
-CONFIG_MPC5xxx=y
-CONFIG_TARGET_PM520=y
diff --git a/configs/PM520_defconfig b/configs/PM520_defconfig
deleted file mode 100644 (file)
index 2737a8c..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-CONFIG_PPC=y
-CONFIG_MPC5xxx=y
-CONFIG_TARGET_PM520=y
diff --git a/configs/PPChameleonEVB_BA_25_defconfig b/configs/PPChameleonEVB_BA_25_defconfig
deleted file mode 100644 (file)
index e367299..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-CONFIG_SYS_EXTRA_OPTIONS="PPCHAMELEON_MODULE_MODEL=0,PPCHAMELEON_CLK_25"
-CONFIG_PPC=y
-CONFIG_4xx=y
-CONFIG_TARGET_PPCHAMELEONEVB=y
diff --git a/configs/PPChameleonEVB_BA_33_defconfig b/configs/PPChameleonEVB_BA_33_defconfig
deleted file mode 100644 (file)
index f4041c9..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-CONFIG_SYS_EXTRA_OPTIONS="PPCHAMELEON_MODULE_MODEL=0,PPCHAMELEON_CLK_33"
-CONFIG_PPC=y
-CONFIG_4xx=y
-CONFIG_TARGET_PPCHAMELEONEVB=y
diff --git a/configs/PPChameleonEVB_HI_25_defconfig b/configs/PPChameleonEVB_HI_25_defconfig
deleted file mode 100644 (file)
index a9de221..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-CONFIG_SYS_EXTRA_OPTIONS="PPCHAMELEON_MODULE_MODEL=2,PPCHAMELEON_CLK_25"
-CONFIG_PPC=y
-CONFIG_4xx=y
-CONFIG_TARGET_PPCHAMELEONEVB=y
diff --git a/configs/PPChameleonEVB_HI_33_defconfig b/configs/PPChameleonEVB_HI_33_defconfig
deleted file mode 100644 (file)
index 882262b..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-CONFIG_SYS_EXTRA_OPTIONS="PPCHAMELEON_MODULE_MODEL=2,PPCHAMELEON_CLK_33"
-CONFIG_PPC=y
-CONFIG_4xx=y
-CONFIG_TARGET_PPCHAMELEONEVB=y
diff --git a/configs/PPChameleonEVB_ME_25_defconfig b/configs/PPChameleonEVB_ME_25_defconfig
deleted file mode 100644 (file)
index f9a0440..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-CONFIG_SYS_EXTRA_OPTIONS="PPCHAMELEON_MODULE_MODEL=1,PPCHAMELEON_CLK_25"
-CONFIG_PPC=y
-CONFIG_4xx=y
-CONFIG_TARGET_PPCHAMELEONEVB=y
diff --git a/configs/PPChameleonEVB_ME_33_defconfig b/configs/PPChameleonEVB_ME_33_defconfig
deleted file mode 100644 (file)
index 8ee09b8..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-CONFIG_SYS_EXTRA_OPTIONS="PPCHAMELEON_MODULE_MODEL=1,PPCHAMELEON_CLK_33"
-CONFIG_PPC=y
-CONFIG_4xx=y
-CONFIG_TARGET_PPCHAMELEONEVB=y
diff --git a/configs/PPChameleonEVB_defconfig b/configs/PPChameleonEVB_defconfig
deleted file mode 100644 (file)
index 2d83330..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-CONFIG_PPC=y
-CONFIG_4xx=y
-CONFIG_TARGET_PPCHAMELEONEVB=y
diff --git a/configs/T1024QDS_defconfig b/configs/T1024QDS_defconfig
new file mode 100644 (file)
index 0000000..94a76ba
--- /dev/null
@@ -0,0 +1,4 @@
+CONFIG_SYS_EXTRA_OPTIONS="PPC_T1024"
+CONFIG_PPC=y
+CONFIG_MPC85xx=y
+CONFIG_TARGET_T102XQDS=y
diff --git a/configs/T1042RDB_SECURE_BOOT_defconfig b/configs/T1042RDB_SECURE_BOOT_defconfig
new file mode 100644 (file)
index 0000000..c8dd5c2
--- /dev/null
@@ -0,0 +1,4 @@
+CONFIG_SYS_EXTRA_OPTIONS="PPC_T1042,SECURE_BOOT,T1042RDB"
+CONFIG_PPC=y
+CONFIG_MPC85xx=y
+CONFIG_TARGET_T104XRDB=y
diff --git a/configs/TZX-Q8-713B7_defconfig b/configs/TZX-Q8-713B7_defconfig
new file mode 100644 (file)
index 0000000..7b7b9dd
--- /dev/null
@@ -0,0 +1,15 @@
+CONFIG_SPL=y
+CONFIG_SYS_EXTRA_OPTIONS="CONS_INDEX=2,AXP209_POWER"
+CONFIG_FDTFILE="sun5i-a13-tzx-q8-713b7.dtb"
+CONFIG_USB_MUSB_SUNXI=y
+CONFIG_USB0_VBUS_PIN="PG12"
+CONFIG_VIDEO_LCD_MODE="x:800,y:480,depth:18,pclk_khz:33000,le:87,ri:40,up:31,lo:13,hs:1,vs:1,sync:3,vmode:0"
+CONFIG_VIDEO_LCD_POWER="AXP0-0"
+CONFIG_VIDEO_LCD_BL_EN="AXP0-1"
+CONFIG_VIDEO_LCD_BL_PWM="PB2"
++S:CONFIG_ARM=y
++S:CONFIG_ARCH_SUNXI=y
++S:CONFIG_MACH_SUN5I=y
++S:CONFIG_DRAM_CLK=408
++S:CONFIG_DRAM_ZQ=123
++S:CONFIG_DRAM_EMR1=4
diff --git a/configs/Total5200_Rev2_defconfig b/configs/Total5200_Rev2_defconfig
deleted file mode 100644 (file)
index 9f27734..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-CONFIG_SYS_EXTRA_OPTIONS="TOTAL5200_REV=2"
-CONFIG_PPC=y
-CONFIG_MPC5xxx=y
-CONFIG_TARGET_TOTAL5200=y
diff --git a/configs/Total5200_Rev2_lowboot_defconfig b/configs/Total5200_Rev2_lowboot_defconfig
deleted file mode 100644 (file)
index 15b27b3..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-CONFIG_SYS_EXTRA_OPTIONS="TOTAL5200_REV=2,SYS_TEXT_BASE=0xFE000000"
-CONFIG_PPC=y
-CONFIG_MPC5xxx=y
-CONFIG_TARGET_TOTAL5200=y
diff --git a/configs/Total5200_defconfig b/configs/Total5200_defconfig
deleted file mode 100644 (file)
index 5aaae49..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-CONFIG_SYS_EXTRA_OPTIONS="TOTAL5200_REV=1"
-CONFIG_PPC=y
-CONFIG_MPC5xxx=y
-CONFIG_TARGET_TOTAL5200=y
diff --git a/configs/Total5200_lowboot_defconfig b/configs/Total5200_lowboot_defconfig
deleted file mode 100644 (file)
index 4c9195e..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-CONFIG_SYS_EXTRA_OPTIONS="TOTAL5200_REV=1,SYS_TEXT_BASE=0xFE000000"
-CONFIG_PPC=y
-CONFIG_MPC5xxx=y
-CONFIG_TARGET_TOTAL5200=y
index 5837a0a4da75bfb9750fcf416194a58977a5ee90..51bf370364a3e10981c7a874ba89417daca604d2 100644 (file)
@@ -4,3 +4,7 @@ CONFIG_SYS_EXTRA_OPTIONS="EMMC_BOOT,ENABLE_VBOOT"
 +S:CONFIG_TARGET_AM335X_EVM=y
 CONFIG_OF_CONTROL=y
 CONFIG_DEFAULT_DEVICE_TREE="am335x-boneblack"
+CONFIG_FIT=y
+CONFIG_FIT_VERBOSE=y
+CONFIG_FIT_SIGNATURE=y
+CONFIG_DM=y
index 0c3ab4e4fc74cff8025be89bd8c23179d7e1487d..979f26e6dccece5024974614451e477603dbcea7 100644 (file)
@@ -1,3 +1,5 @@
 CONFIG_ARC=y
-CONFIG_TARGET_ARCANGEL4_BE=y
+CONFIG_TARGET_ARCANGEL4=y
 CONFIG_SYS_CLK_FREQ=70000000
+CONFIG_CPU_BIG_ENDIAN=y
+CONFIG_SYS_TEXT_BASE=0x81000000
index a63ef21de80ce9cbb26940ee8931db5f69e12ee3..797595f2c30ebc6c270b41a8d360684044dbe696 100644 (file)
@@ -1,3 +1,4 @@
 CONFIG_ARC=y
 CONFIG_TARGET_ARCANGEL4=y
 CONFIG_SYS_CLK_FREQ=70000000
+CONFIG_SYS_TEXT_BASE=0x81000000
index c0e8da2c12ace80ce671431e4adb23980332c3ad..076ad0fe8d9c99e592373953931b951aeef7428d 100644 (file)
@@ -1,3 +1,4 @@
+CONFIG_SPL=y
 CONFIG_SYS_EXTRA_OPTIONS="AT91SAM9G20,MACH_TYPE=2068,BOARD_AXM"
-CONFIG_ARM=y
-CONFIG_TARGET_TAURUS=y
++S:CONFIG_ARM=y
++S:CONFIG_TARGET_TAURUS=y
index 5c0ca11fa55419314c40a5e749021c829938746c..34ed9633a1362f02e1adcfe7cba6e25b03c92a84 100644 (file)
@@ -1,3 +1,6 @@
 CONFIG_ARC=y
 CONFIG_TARGET_AXS101=y
-CONFIG_SYS_CLK_FREQ=750000000
\ No newline at end of file
+CONFIG_SYS_CLK_FREQ=750000000
+CONFIG_ARC_CACHE_LINE_SHIFT=5
+CONFIG_SYS_DCACHE_OFF=y
+CONFIG_SYS_TEXT_BASE=0x81000000
\ No newline at end of file
index 6ca7c57186af556755b8293dbab6640ce3a30933..400906d3779408f423517985b06ac7b950999328 100644 (file)
@@ -1,8 +1,10 @@
 CONFIG_SPL=y
 CONFIG_SYS_EXTRA_OPTIONS="AXP209_POWER,SUNXI_EMAC,USB_EHCI"
 CONFIG_FDTFILE="sun4i-a10-ba10-tvbox.dtb"
-CONFIG_USB1_VBUS_PIN="PH12"
+CONFIG_USB2_VBUS_PIN="PH12"
 +S:CONFIG_ARM=y
 +S:CONFIG_ARCH_SUNXI=y
 +S:CONFIG_MACH_SUN4I=y
-+S:CONFIG_TARGET_BA10_TV_BOX=y
++S:CONFIG_DRAM_CLK=384
++S:CONFIG_DRAM_ZQ=123
++S:CONFIG_DRAM_EMR1=4
index e956835dc6d7ef39848388d3cbbc0c08ab60b22c..2f0c714e59f779e0c5743d2ffacd4d1060591cbb 100644 (file)
@@ -6,6 +6,6 @@ CONFIG_OF_SEPARATE=y
 CONFIG_DEFAULT_DEVICE_TREE="chromebook_link"
 CONFIG_HAVE_MRC=y
 CONFIG_SMM_TSEG_SIZE=0x800000
-CONFIG_VIDEO_X86=y
+CONFIG_VIDEO_VESA=y
 CONFIG_FRAMEBUFFER_SET_VESA_MODE=y
 CONFIG_FRAMEBUFFER_VESA_MODE_11A=y
diff --git a/configs/cpci5200_defconfig b/configs/cpci5200_defconfig
deleted file mode 100644 (file)
index bdbf4fc..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-CONFIG_PPC=y
-CONFIG_MPC5xxx=y
-CONFIG_TARGET_CPCI5200=y
index 7aa216c47d49186fa67d360e4a33db1c5b01b4fc..a7f13e2132be1751eeaad5366d891ea023f72b8b 100644 (file)
@@ -1,2 +1,3 @@
-CONFIG_ARM=y
-CONFIG_TARGET_DB_MV784MP_GP=y
+CONFIG_SPL=y
++S:CONFIG_ARM=y
++S:CONFIG_TARGET_DB_MV784MP_GP=y
index 5f5037e6982e8a095e2fe1b8e4702ed10ff7a0bb..41192fc73fee3bfa345930fa5b8dfe5fbfde489e 100644 (file)
@@ -4,4 +4,6 @@ CONFIG_FDTFILE="sun7i-a20-i12-tvbox.dtb"
 +S:CONFIG_ARM=y
 +S:CONFIG_ARCH_SUNXI=y
 +S:CONFIG_MACH_SUN7I=y
-+S:CONFIG_TARGET_I12_TVBOX=y
++S:CONFIG_DRAM_CLK=384
++S:CONFIG_DRAM_ZQ=127
++S:CONFIG_DRAM_EMR1=4
diff --git a/configs/icecube_5200_DDR_LOWBOOT08_defconfig b/configs/icecube_5200_DDR_LOWBOOT08_defconfig
deleted file mode 100644 (file)
index 79f8598..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-CONFIG_SYS_EXTRA_OPTIONS="SYS_TEXT_BASE=0xFF800000,MPC5200_DDR"
-CONFIG_PPC=y
-CONFIG_MPC5xxx=y
-CONFIG_TARGET_ICECUBE=y
diff --git a/configs/icecube_5200_DDR_LOWBOOT_defconfig b/configs/icecube_5200_DDR_LOWBOOT_defconfig
deleted file mode 100644 (file)
index 79f8598..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-CONFIG_SYS_EXTRA_OPTIONS="SYS_TEXT_BASE=0xFF800000,MPC5200_DDR"
-CONFIG_PPC=y
-CONFIG_MPC5xxx=y
-CONFIG_TARGET_ICECUBE=y
diff --git a/configs/icecube_5200_DDR_defconfig b/configs/icecube_5200_DDR_defconfig
deleted file mode 100644 (file)
index 19d9637..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-CONFIG_SYS_EXTRA_OPTIONS="MPC5200_DDR"
-CONFIG_PPC=y
-CONFIG_MPC5xxx=y
-CONFIG_TARGET_ICECUBE=y
diff --git a/configs/icecube_5200_LOWBOOT08_defconfig b/configs/icecube_5200_LOWBOOT08_defconfig
deleted file mode 100644 (file)
index 9f0cbd8..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-CONFIG_SYS_EXTRA_OPTIONS="SYS_TEXT_BASE=0xFF800000"
-CONFIG_PPC=y
-CONFIG_MPC5xxx=y
-CONFIG_TARGET_ICECUBE=y
diff --git a/configs/icecube_5200_LOWBOOT_defconfig b/configs/icecube_5200_LOWBOOT_defconfig
deleted file mode 100644 (file)
index ff1552f..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-CONFIG_SYS_EXTRA_OPTIONS="SYS_TEXT_BASE=0xFF000000"
-CONFIG_PPC=y
-CONFIG_MPC5xxx=y
-CONFIG_TARGET_ICECUBE=y
diff --git a/configs/icecube_5200_defconfig b/configs/icecube_5200_defconfig
deleted file mode 100644 (file)
index 49fdb3b..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-CONFIG_PPC=y
-CONFIG_MPC5xxx=y
-CONFIG_TARGET_ICECUBE=y
index 1c665aab943bda9ee911b40127dc85a561f2847e..0950ec8b77847b72ebfec4119da1be41a3d0b51e 100644 (file)
@@ -1,4 +1,7 @@
 CONFIG_SYS_EXTRA_OPTIONS="SYS_TEXT_BASE=0xFFF00000"
 CONFIG_PPC=y
 CONFIG_MPC83xx=y
+CONFIG_FIT=y
+CONFIG_FIT_SIGNATURE=y
 CONFIG_TARGET_IDS8313=y
+CONFIG_DM=y
diff --git a/configs/lite5200b_LOWBOOT_defconfig b/configs/lite5200b_LOWBOOT_defconfig
deleted file mode 100644 (file)
index 9ceb834..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-CONFIG_SYS_EXTRA_OPTIONS="MPC5200_DDR,LITE5200B,SYS_TEXT_BASE=0xFF000000"
-CONFIG_PPC=y
-CONFIG_MPC5xxx=y
-CONFIG_TARGET_ICECUBE=y
diff --git a/configs/lite5200b_PM_defconfig b/configs/lite5200b_PM_defconfig
deleted file mode 100644 (file)
index 35b2aa3..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-CONFIG_SYS_EXTRA_OPTIONS="MPC5200_DDR,LITE5200B,LITE5200B_PM"
-CONFIG_PPC=y
-CONFIG_MPC5xxx=y
-CONFIG_TARGET_ICECUBE=y
diff --git a/configs/lite5200b_defconfig b/configs/lite5200b_defconfig
deleted file mode 100644 (file)
index c7d4030..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-CONFIG_SYS_EXTRA_OPTIONS="MPC5200_DDR,LITE5200B"
-CONFIG_PPC=y
-CONFIG_MPC5xxx=y
-CONFIG_TARGET_ICECUBE=y
diff --git a/configs/ls1021aqds_nor_lpuart_defconfig b/configs/ls1021aqds_nor_lpuart_defconfig
new file mode 100644 (file)
index 0000000..29335ee
--- /dev/null
@@ -0,0 +1,3 @@
+CONFIG_SYS_EXTRA_OPTIONS="LPUART"
++S:CONFIG_ARM=y
++S:CONFIG_TARGET_LS1021AQDS=y
diff --git a/configs/ls1021atwr_nor_lpuart_defconfig b/configs/ls1021atwr_nor_lpuart_defconfig
new file mode 100644 (file)
index 0000000..bdab6d9
--- /dev/null
@@ -0,0 +1,3 @@
+CONFIG_SYS_EXTRA_OPTIONS="LPUART"
++S:CONFIG_ARM=y
++S:CONFIG_TARGET_LS1021ATWR=y
index 4bcffd8c2da773d50249b4974565379e421be2e9..219586a27da76614676163e96613a093e98f745c 100644 (file)
@@ -1,2 +1,3 @@
-CONFIG_ARM=y
-CONFIG_TARGET_MAXBCM=y
+CONFIG_SPL=y
++S:CONFIG_ARM=y
++S:CONFIG_TARGET_MAXBCM=y
diff --git a/configs/mecp5200_defconfig b/configs/mecp5200_defconfig
deleted file mode 100644 (file)
index a30e224..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-CONFIG_PPC=y
-CONFIG_MPC5xxx=y
-CONFIG_TARGET_MECP5200=y
diff --git a/configs/mk802_a10s_defconfig b/configs/mk802_a10s_defconfig
new file mode 100644 (file)
index 0000000..cafcbaa
--- /dev/null
@@ -0,0 +1,10 @@
+CONFIG_SPL=y
+CONFIG_SYS_EXTRA_OPTIONS="AXP152_POWER,USB_EHCI"
+CONFIG_FDTFILE="sun5i-a10s-mk802.dtb"
+CONFIG_USB1_VBUS_PIN="PB10"
++S:CONFIG_ARM=y
++S:CONFIG_ARCH_SUNXI=y
++S:CONFIG_MACH_SUN5I=y
++S:CONFIG_DRAM_CLK=432
++S:CONFIG_DRAM_ZQ=123
++S:CONFIG_DRAM_EMR1=0
diff --git a/configs/mk802_defconfig b/configs/mk802_defconfig
new file mode 100644 (file)
index 0000000..d6b51a5
--- /dev/null
@@ -0,0 +1,10 @@
+CONFIG_SPL=y
+CONFIG_SYS_EXTRA_OPTIONS="USB_EHCI"
+CONFIG_FDTFILE="sun4i-a10-mk802.dtb"
+CONFIG_USB2_VBUS_PIN="PH12"
++S:CONFIG_ARM=y
++S:CONFIG_ARCH_SUNXI=y
++S:CONFIG_MACH_SUN4I=y
++S:CONFIG_DRAM_CLK=360
++S:CONFIG_DRAM_ZQ=123
++S:CONFIG_DRAM_EMR1=0
diff --git a/configs/mk802ii_defconfig b/configs/mk802ii_defconfig
new file mode 100644 (file)
index 0000000..500f4df
--- /dev/null
@@ -0,0 +1,9 @@
+CONFIG_SPL=y
+CONFIG_SYS_EXTRA_OPTIONS="AXP209_POWER,USB_EHCI"
+CONFIG_FDTFILE="sun4i-a10-mk802ii.dtb"
++S:CONFIG_ARM=y
++S:CONFIG_ARCH_SUNXI=y
++S:CONFIG_MACH_SUN4I=y
++S:CONFIG_DRAM_CLK=360
++S:CONFIG_DRAM_ZQ=123
++S:CONFIG_DRAM_EMR1=0
diff --git a/configs/pf5200_defconfig b/configs/pf5200_defconfig
deleted file mode 100644 (file)
index fe926a0..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-CONFIG_PPC=y
-CONFIG_MPC5xxx=y
-CONFIG_TARGET_PF5200=y
index 2e9dd00c1d8baef2c5dc0e9fcc94f11130b8211f..86b4b15724b1da02bd7019ac360f4ec2b01a0f79 100644 (file)
@@ -18,6 +18,7 @@ CONFIG_CMD_LOADB=y
 CONFIG_CMD_LOADS=y
 CONFIG_CMD_FLASH=y
 CONFIG_CMD_NAND=y
+CONFIG_CMD_I2C=y
 CONFIG_CMD_USB=y
 CONFIG_CMD_ECHO=y
 CONFIG_CMD_ITEST=y
@@ -34,6 +35,7 @@ CONFIG_SYS_NAND_DENALI_64BIT=y
 CONFIG_NAND_DENALI_SPARE_AREA_SKIP_BYTES=8
 CONFIG_DM_SERIAL=y
 CONFIG_UNIPHIER_SERIAL=y
+CONFIG_DM_I2C=y
 CONFIG_USB=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_STORAGE=y
index 5dca64bf88ea42472d07cd352b02a05ee2acb31c..242bcf926359cd0f962aea04f0061fb84f1ad50e 100644 (file)
@@ -18,6 +18,7 @@ CONFIG_CMD_LOADB=y
 CONFIG_CMD_LOADS=y
 CONFIG_CMD_FLASH=y
 CONFIG_CMD_NAND=y
+CONFIG_CMD_I2C=y
 CONFIG_CMD_USB=y
 CONFIG_CMD_ECHO=y
 CONFIG_CMD_ITEST=y
@@ -34,6 +35,7 @@ CONFIG_SYS_NAND_DENALI_64BIT=y
 CONFIG_NAND_DENALI_SPARE_AREA_SKIP_BYTES=8
 CONFIG_DM_SERIAL=y
 CONFIG_UNIPHIER_SERIAL=y
+CONFIG_DM_I2C=y
 CONFIG_USB=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_STORAGE=y
index 2a6e334506a6e84722e7fac1cab8cb424b7b0248..8e95f17e6d101a200776f35adc3400ff7506e9d9 100644 (file)
@@ -18,6 +18,7 @@ CONFIG_CMD_LOADB=y
 CONFIG_CMD_LOADS=y
 CONFIG_CMD_FLASH=y
 CONFIG_CMD_NAND=y
+CONFIG_CMD_I2C=y
 CONFIG_CMD_USB=y
 CONFIG_CMD_ECHO=y
 CONFIG_CMD_ITEST=y
@@ -34,6 +35,7 @@ CONFIG_SYS_NAND_DENALI_64BIT=y
 CONFIG_NAND_DENALI_SPARE_AREA_SKIP_BYTES=8
 CONFIG_DM_SERIAL=y
 CONFIG_UNIPHIER_SERIAL=y
+CONFIG_DM_I2C=y
 CONFIG_USB=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_STORAGE=y
diff --git a/configs/qt840a_defconfig b/configs/qt840a_defconfig
deleted file mode 100644 (file)
index 70f8159..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-CONFIG_SPL=y
-CONFIG_SYS_EXTRA_OPTIONS="AXP209_POWER,SUNXI_GMAC,MACPWR=SUNXI_GPH(21),USB_EHCI"
-CONFIG_FDTFILE="sun7i-a20-i12-tvbox.dtb"
-+S:CONFIG_ARM=y
-+S:CONFIG_ARCH_SUNXI=y
-+S:CONFIG_MACH_SUN7I=y
-+S:CONFIG_TARGET_QT840A=y
index b9fd59c16a70aafcebbe64e44218c83e65758356..e99e57d505a5fa642fabfd58b0a8baa11e5c5b2e 100644 (file)
@@ -5,4 +5,6 @@ CONFIG_USB1_VBUS_PIN="PG13"
 +S:CONFIG_ARM=y
 +S:CONFIG_ARCH_SUNXI=y
 +S:CONFIG_MACH_SUN5I=y
-+S:CONFIG_TARGET_R7DONGLE=y
++S:CONFIG_DRAM_CLK=384
++S:CONFIG_DRAM_ZQ=123
++S:CONFIG_DRAM_EMR1=4
index 47d8400acece08586f535fad3b51e3872b3ed161..660063ebf333ae666ff7f1898a67d036c20909ad 100644 (file)
@@ -1,3 +1,7 @@
 CONFIG_OF_CONTROL=y
 CONFIG_OF_HOSTFILE=y
+CONFIG_FIT=y
+CONFIG_FIT_VERBOSE=y
+CONFIG_FIT_SIGNATURE=y
+CONFIG_DM=y
 CONFIG_DEFAULT_DEVICE_TREE="sandbox"
diff --git a/configs/sunxi_Gemei_G9_defconfig b/configs/sunxi_Gemei_G9_defconfig
new file mode 100644 (file)
index 0000000..a85db2a
--- /dev/null
@@ -0,0 +1,20 @@
+# Gemei G9 is an A10 based tablet, with 1G RAM, 16G NAND,
+# 1024x768 IPS LCD display, stereo speakers, 1.3MP front camera and 5 MP
+# rear camera, 8000mAh battery, GT901 2+1 touchscreen, Bosch BMA250
+# accelerometer and RTL8188CUS USB wifi. It also has MicroSD slot, MiniHDMI,
+# 1 x MicroUSB OTG port and 1 x MicroUSB host port and 3.5mm headphone jack.
+# More details are available at: http://linux-sunxi.org/Gemei_G9
+CONFIG_SPL=y
+CONFIG_SYS_EXTRA_OPTIONS="AXP209_POWER,USB_EHCI"
+CONFIG_FDTFILE="sun4i-gemei-g9.dtb"
+CONFIG_VIDEO_LCD_MODE="x:1024,y:768,depth:18,pclk_khz:100000,le:799,ri:260,up:15,lo:16,hs:1,vs:1,sync:3,vmode:0"
+CONFIG_VIDEO_LCD_PANEL_LVDS=y
+CONFIG_VIDEO_LCD_POWER="PH8"
+CONFIG_VIDEO_LCD_BL_EN="PH7"
+CONFIG_VIDEO_LCD_BL_PWM="PB2"
++S:CONFIG_ARM=y
++S:CONFIG_ARCH_SUNXI=y
++S:CONFIG_MACH_SUN4I=y
++S:CONFIG_DRAM_CLK=432
++S:CONFIG_DRAM_ZQ=123
++S:CONFIG_DRAM_EMR1=4
index d2de03b649b9925e31700aba878d2a4e3ab31bbd..b0e8c9f602d9f1e4435b2b29a8738b3b3230fa0f 100644 (file)
@@ -1,3 +1,5 @@
 CONFIG_ARC=y
 CONFIG_TARGET_TB100=y
-CONFIG_SYS_CLK_FREQ=500000000
\ No newline at end of file
+CONFIG_SYS_CLK_FREQ=500000000
+CONFIG_ARC_CACHE_LINE_SHIFT=5
+CONFIG_SYS_TEXT_BASE=0x84000000
index b463a333bc6bb10cd84c040fad6ae38c98732a0f..9f4b876556137aefa8270fc0da776378b045f2a1 100644 (file)
@@ -1,3 +1,3 @@
 CONFIG_ARM=y
-CONFIG_TARGET_VEXPRESS_AEMV8A=y
+CONFIG_TARGET_VEXPRESS64_AEMV8A=y
 CONFIG_DEFAULT_DEVICE_TREE="vexpress64"
diff --git a/configs/vexpress_aemv8a_juno_defconfig b/configs/vexpress_aemv8a_juno_defconfig
new file mode 100644 (file)
index 0000000..d28a428
--- /dev/null
@@ -0,0 +1,5 @@
+# ARM Ltd. Juno Board Reference Design
+CONFIG_ARM=y
+CONFIG_TARGET_VEXPRESS64_JUNO=y
+CONFIG_DEFAULT_DEVICE_TREE="vexpress64"
+CONFIG_SHOW_BOOT_PROGRESS=y
index 0035ccdaecd4596e557c1d38b9deaf254053577f..26cf7db47f845ab9dff99bdb30c6cb3ce568dcb9 100644 (file)
@@ -1,4 +1,4 @@
-CONFIG_SYS_EXTRA_OPTIONS="SEMIHOSTING,BASE_FVP"
+# Semihosted FVP fast model
 CONFIG_ARM=y
-CONFIG_TARGET_VEXPRESS_AEMV8A=y
+CONFIG_TARGET_VEXPRESS64_BASE_FVP=y
 CONFIG_DEFAULT_DEVICE_TREE="vexpress64"
index 9588849bb5c0f7c78694fc90a52fb46daed1286f..8b985fe5a4294b0867f5a4ef95efe3ae40d2d177 100644 (file)
@@ -3,4 +3,8 @@ CONFIG_SPL=y
 +S:CONFIG_ZYNQ=y
 +S:CONFIG_TARGET_ZYNQ_MICROZED=y
 CONFIG_OF_CONTROL=y
+CONFIG_FIT=y
+CONFIG_FIT_VERBOSE=y
+CONFIG_FIT_SIGNATURE=y
+CONFIG_DM=y
 CONFIG_DEFAULT_DEVICE_TREE="zynq-microzed"
index cf507308e95d209540ad5442df87abdb01632549..cceb32199da1b6291a65cc62fb155c17ee0bcb9e 100644 (file)
@@ -4,3 +4,7 @@ CONFIG_SPL=y
 +S:CONFIG_TARGET_ZYNQ_ZC70X=y
 CONFIG_OF_CONTROL=y
 CONFIG_DEFAULT_DEVICE_TREE="zynq-zc702"
+CONFIG_FIT=y
+CONFIG_FIT_VERBOSE=y
+CONFIG_FIT_SIGNATURE=y
+CONFIG_DM=y
index 8bb405d1808907756610f7ebd8ade97227615ec9..2935c0dff783fac32b6c0dda91917878e94b7c96 100644 (file)
@@ -5,3 +5,7 @@ CONFIG_SYS_EXTRA_OPTIONS="ZC770_XM010"
 +S:CONFIG_TARGET_ZYNQ_ZC770=y
 CONFIG_OF_CONTROL=y
 CONFIG_DEFAULT_DEVICE_TREE="zynq-zc770-xm010"
+CONFIG_FIT=y
+CONFIG_FIT_VERBOSE=y
+CONFIG_FIT_SIGNATURE=y
+CONFIG_DM=y
index 0ba5da589e95db553b682393db5348fdcdf00ceb..0401739652fc361d75b073faa1825223a375f780 100644 (file)
@@ -5,3 +5,7 @@ CONFIG_SYS_EXTRA_OPTIONS="ZC770_XM012"
 +S:CONFIG_TARGET_ZYNQ_ZC770=y
 CONFIG_OF_CONTROL=y
 CONFIG_DEFAULT_DEVICE_TREE="zynq-zc770-xm012"
+CONFIG_FIT=y
+CONFIG_FIT_VERBOSE=y
+CONFIG_FIT_SIGNATURE=y
+CONFIG_DM=y
index 13f8112a1b627139c8fc980370759c8cd0d0f36a..a95970a917cece43f64ceca2c95f719049558ee9 100644 (file)
@@ -5,3 +5,7 @@ CONFIG_SYS_EXTRA_OPTIONS="ZC770_XM013"
 +S:CONFIG_TARGET_ZYNQ_ZC770=y
 CONFIG_OF_CONTROL=y
 CONFIG_DEFAULT_DEVICE_TREE="zynq-zc770-xm013"
+CONFIG_FIT=y
+CONFIG_FIT_VERBOSE=y
+CONFIG_FIT_SIGNATURE=y
+CONFIG_DM=y
index eb057fae35c738332163e8693997c8667376124a..0fbc41ab8a8faca00138233a2be3db17eb9eb45a 100644 (file)
@@ -4,3 +4,7 @@ CONFIG_SPL=y
 +S:CONFIG_TARGET_ZYNQ_ZED=y
 CONFIG_OF_CONTROL=y
 CONFIG_DEFAULT_DEVICE_TREE="zynq-zed"
+CONFIG_FIT=y
+CONFIG_FIT_VERBOSE=y
+CONFIG_FIT_SIGNATURE=y
+CONFIG_DM=y
index 12311cd83b5011f35ff2b69737ad24c7b1fb9f9f..4e66760750c53bb6df093674aa6c60c8c79b3dde 100644 (file)
@@ -4,3 +4,7 @@ CONFIG_SPL=y
 +S:CONFIG_TARGET_ZYNQ_ZYBO=y
 CONFIG_OF_CONTROL=y
 CONFIG_DEFAULT_DEVICE_TREE="zynq-zybo"
+CONFIG_FIT=y
+CONFIG_FIT_VERBOSE=y
+CONFIG_FIT_SIGNATURE=y
+CONFIG_DM=y
diff --git a/doc/README.distro b/doc/README.distro
new file mode 100644 (file)
index 0000000..dd0f1c7
--- /dev/null
@@ -0,0 +1,341 @@
+/*
+ * (C) Copyright 2014 Red Hat Inc.
+ * Copyright (c) 2014-2015, NVIDIA CORPORATION.  All rights reserved.
+ *
+ * SPDX-License-Identifier:     GPL-2.0+
+ */
+
+Generic Distro Configuration Concept
+====================================
+
+Linux distributions are faced with supporting a variety of boot mechanisms,
+environments or bootloaders (PC BIOS, EFI, U-Boot, Barebox, ...). This makes
+life complicated. Worse, bootloaders such as U-Boot have a configurable set
+of features, and each board chooses to enable a different set of features.
+Hence, distros typically need to have board-specific knowledge in order to
+set up a bootable system.
+
+This document defines a common set of U-Boot features that are required for
+a distro to support the board in a generic fashion. Any board wishing to
+allow distros to install and boot in an out-of-the-box fashion should enable
+all these features. Linux distros can then create a single set of boot
+support/install logic that targets these features. This will allow distros
+to install on many boards without the need for board-specific logic.
+
+In fact, some of these features can be implemented by any bootloader, thus
+decoupling distro install/boot logic from any knowledge of the bootloader.
+
+This model assumes that boards will load boot configuration files from a
+regular storage mechanism (eMMC, SD card, USB Disk, SATA disk, etc.) with
+a standard partitioning scheme (MBR, GPT). Boards that cannnot support this
+storage model are outside the scope of this document, and may still need
+board-specific installer/boot-configuration support in a distro.
+
+To some extent, this model assumes that a board has a separate boot flash
+that contains U-Boot, and that the user has somehow installed U-Boot to this
+flash before running the distro installer. Even on boards that do not conform
+to this aspect of the model, the extent of the board-specific support in the
+distro installer logic would be to install a board-specific U-Boot package to
+the boot partition partition during installation. This distro-supplied U-Boot
+can still implement the same features as on any other board, and hence the
+distro's boot configuration file generation logic can still be board-agnostic.
+
+Locating Bootable Disks
+-----------------------
+
+Typical desktop/server PCs search all (or a user-defined subset of) attached
+storage devices for a bootable partition, then load the bootloader or boot
+configuration files from there. A U-Boot board port that enables the features
+mentioned in this document will search for boot configuration files in the
+same way.
+
+Thus, distros do not need to manipulate any kind of bootloader-specific
+configuration data to indicate which storage device the system should boot
+from.
+
+Distros simply need to install the boot configuration files (see next
+section) in an ext2/3/4 or FAT partition, mark the partition bootable (via
+the MBR bootable flag, or GPT legacy_bios_bootable attribute), and U-Boot (or
+any other bootloader) will find those boot files and execute them. This is
+conceptually identical to creating a grub2 configuration file on a desktop
+PC.
+
+Note that in the absense of any partition that is explicitly marked bootable,
+U-Boot falls back to searching the first valid partition of a disk for boot
+configuration files. Other bootloaders are recommended to do the same, since
+I believe that partition table bootable flags aren't so commonly used outside
+the realm of x86 PCs.
+
+U-Boot can also search for boot configuration files from a TFTP server.
+
+Boot Configuration Files
+------------------------
+
+The standard format for boot configuration files is that of extlinux.conf, as
+handled by U-Boot's "syslinux" (disk) or "pxe boot" (network). This is roughly
+as specified at:
+
+http://www.freedesktop.org/wiki/Specifications/BootLoaderSpec/
+
+... with the exceptions that the BootLoaderSpec document:
+
+* Prescribes a separate configuration per boot menu option, whereas U-Boot
+  lumps all options into a single extlinux.conf file. Hence, U-Boot searches
+  for /extlinux/extlinux.conf then /boot/extlinux/extlinux.conf on disk, or
+  pxelinux.cfg/default over the network.
+
+* Does not document the fdtdir option, which automatically selects the DTB to
+  pass to the kernel.
+
+One example extlinux.conf generated by the Fedora installer is:
+
+------------------------------------------------------------
+# extlinux.conf generated by anaconda
+
+ui menu.c32
+
+menu autoboot Welcome to Fedora. Automatic boot in # second{,s}. Press a key for options.
+menu title Fedora Boot Options.
+menu hidden
+
+timeout 50
+#totaltimeout 9000
+
+default Fedora (3.17.0-0.rc4.git2.1.fc22.armv7hl+lpae) 22 (Rawhide)
+
+label Fedora (3.17.0-0.rc4.git2.1.fc22.armv7hl) 22 (Rawhide)
+       kernel /boot/vmlinuz-3.17.0-0.rc4.git2.1.fc22.armv7hl
+       append ro root=UUID=8eac677f-8ea8-4270-8479-d5ddbb797450 console=ttyS0,115200n8 LANG=en_US.UTF-8 drm.debug=0xf
+       fdtdir /boot/dtb-3.17.0-0.rc4.git2.1.fc22.armv7hl
+       initrd /boot/initramfs-3.17.0-0.rc4.git2.1.fc22.armv7hl.img
+
+label Fedora (3.17.0-0.rc4.git2.1.fc22.armv7hl+lpae) 22 (Rawhide)
+       kernel /boot/vmlinuz-3.17.0-0.rc4.git2.1.fc22.armv7hl+lpae
+       append ro root=UUID=8eac677f-8ea8-4270-8479-d5ddbb797450 console=ttyS0,115200n8 LANG=en_US.UTF-8 drm.debug=0xf
+       fdtdir /boot/dtb-3.17.0-0.rc4.git2.1.fc22.armv7hl+lpae
+       initrd /boot/initramfs-3.17.0-0.rc4.git2.1.fc22.armv7hl+lpae.img
+
+label Fedora-0-rescue-8f6ba7b039524e0eb957d2c9203f04bc (0-rescue-8f6ba7b039524e0eb957d2c9203f04bc)
+       kernel /boot/vmlinuz-0-rescue-8f6ba7b039524e0eb957d2c9203f04bc
+       initrd /boot/initramfs-0-rescue-8f6ba7b039524e0eb957d2c9203f04bc.img
+       append ro root=UUID=8eac677f-8ea8-4270-8479-d5ddbb797450 console=ttyS0,115200n8
+       fdtdir /boot/dtb-3.16.0-0.rc6.git1.1.fc22.armv7hl+lpae
+------------------------------------------------------------
+
+Another hand-crafted network boot configuration file is:
+
+------------------------------------------------------------
+TIMEOUT 100
+
+MENU TITLE TFTP boot options
+
+LABEL jetson-tk1-emmc
+        MENU LABEL ../zImage root on Jetson TK1 eMMC
+        LINUX ../zImage
+        FDTDIR ../
+        APPEND console=ttyS0,115200n8 console=tty1 loglevel=8 rootwait rw earlyprintk root=PARTUUID=80a5a8e9-c744-491a-93c1-4f4194fd690b
+
+LABEL venice2-emmc
+        MENU LABEL ../zImage root on Venice2 eMMC
+        LINUX ../zImage
+        FDTDIR ../
+        APPEND console=ttyS0,115200n8 console=tty1 loglevel=8 rootwait rw earlyprintk root=PARTUUID=5f71e06f-be08-48ed-b1ef-ee4800cc860f
+
+LABEL sdcard
+        MENU LABEL ../zImage, root on 2GB sdcard
+        LINUX ../zImage
+        FDTDIR ../
+        APPEND console=ttyS0,115200n8 console=tty1 loglevel=8 rootwait rw earlyprintk root=PARTUUID=b2f82cda-2535-4779-b467-094a210fbae7
+
+LABEL fedora-installer-fk
+        MENU LABEL Fedora installer w/ Fedora kernel
+        LINUX fedora-installer/vmlinuz
+        INITRD fedora-installer/initrd.img.orig
+        FDTDIR fedora-installer/dtb
+        APPEND loglevel=8 ip=dhcp inst.repo=http://10.0.0.2/mirrors/fedora/linux/development/rawhide/armhfp/os/ rd.shell cma=64M
+------------------------------------------------------------
+
+U-Boot Implementation
+=====================
+
+Enabling the distro options
+---------------------------
+
+In your board configuration file, include the following:
+
+------------------------------------------------------------
+#ifndef CONFIG_SPL_BUILD
+#include <config_distro_defaults.h>
+#include <config_distro_bootcmd.h>
+#endif
+------------------------------------------------------------
+
+The first of those headers primarily enables a core set of U-Boot features,
+such as support for MBR and GPT partitions, ext* and FAT filesystems, booting
+raw zImage and initrd (rather than FIT- or uImage-wrapped files), etc. Network
+boot support is also enabled here, which is useful in order to boot distro
+installers given that distros do not commonly distribute bootable install
+media for non-PC targets at present.
+
+Finally, a few options that are mostly relevant only when using U-Boot-
+specific boot.scr scripts are enabled. This enables distros to generate a
+U-Boot-specific boot.scr script rather than extlinux.conf as the boot
+configuration file. While doing so is fully supported, and
+<config_distro_defaults.h> exposes enough parameterization to boot.scr to
+allow for board-agnostic boot.scr content, this document recommends that
+distros generate extlinux.conf rather than boot.scr. extlinux.conf is intended
+to work across multiple bootloaders, whereas boot.scr will only work with
+U-Boot. TODO: document the contract between U-Boot and boot.scr re: which
+environment variables a generic boot.scr may rely upon.
+
+The second of those headers sets up the default environment so that $bootcmd
+is defined in a way that searches attached disks for boot configuration files,
+and executes them if found.
+
+Required Environment Variables
+------------------------------
+
+The U-Boot "syslinux" and "pxe boot" commands require a number of environment
+variables be set. Default values for these variables are often hard-coded into
+CONFIG_EXTRA_ENV_SETTINGS in the board's U-Boot configuration file, so that
+the user doesn't have to configure them.
+
+fdt_addr:
+
+  Mandatory for any system that provides the DTB in HW (e.g. ROM) and wishes
+  to pass that DTB to Linux, rather than loading a DTB from the boot
+  filesystem. Prohibited for any other system.
+
+  If specified a DTB to boot the system must be available at the given
+  address.
+
+fdt_addr_r:
+
+  Mandatory. The location in RAM where the DTB will be loaded or copied to when
+  processing the fdtdir/devicetreedir or fdt/devicetree options in
+  extlinux.conf.
+
+  This is mandatory even when fdt_addr is provided, since extlinux.conf must
+  always be able to provide a DTB which overrides any copy provided by the HW.
+
+  A size of 1MB for the FDT/DTB seems reasonable.
+
+ramdisk_addr_r:
+
+  Mandatory. The location in RAM where the initial ramdisk will be loaded to
+  when processing the initrd option in extlinux.conf.
+
+  It is recommended that this location be highest in RAM out of fdt_addr_,
+  kernel_addr_r, and ramdisk_addr_r, so that the RAM disk can vary in size
+  and use any available RAM.
+
+kernel_addr_r:
+
+  Mandatory. The location in RAM where the kernel will be loaded to when
+  processing the kernel option in the extlinux.conf.
+
+  The kernel should be located within the first 128M of RAM in order for the
+  kernel CONFIG_AUTO_ZRELADDR option to work, which is likely enabled on any
+  distro kernel. Since the kernel will decompress itself to 0x8000 after the
+  start of RAM, kernel_addr_rshould not overlap that area, or the kernel will
+  have to copy itself somewhere else first before decompression.
+
+  A size of 16MB for the kernel is likely adequate.
+
+pxe_addr_r:
+
+  Mandatory. The location in RAM where extlinux.conf will be loaded to prior
+  to processing.
+
+  A size of 1MB for extlinux.conf is more than adequate.
+
+scriptaddr:
+
+  Mandatory, if the boot script is boot.scr rather than extlinux.conf. The
+  location in RAM where boot.scr will be loaded to prior to execution.
+
+  A size of 1MB for extlinux.conf is more than adequate.
+
+For suggestions on memory locations for ARM systems, you must follow the
+guidelines specified in Documentation/arm/Booting in the Linux kernel tree.
+
+For a commented example of setting these values, please see the definition of
+MEM_LAYOUT_ENV_SETTINGS in include/configs/tegra124-common.h.
+
+Boot Target Configuration
+-------------------------
+
+<config_distro_bootcmd.h> defines $bootcmd and many helper command variables
+that automatically search attached disks for boot configuration files and
+execute them. Boards must provide configure <config_distro_bootcmd.h> so that
+it supports the correct set of possible boot device types. To provide this
+configuration, simply define macro BOOT_TARGET_DEVICES prior to including
+<config_distro_bootcmd.h>. For example:
+
+------------------------------------------------------------
+#ifndef CONFIG_SPL_BUILD
+#define BOOT_TARGET_DEVICES(func) \
+        func(MMC, mmc, 1) \
+        func(MMC, mmc, 0) \
+        func(USB, usb, 0) \
+        func(PXE, pxe, na) \
+        func(DHCP, dhcp, na)
+#include <config_distro_bootcmd.h>
+#endif
+------------------------------------------------------------
+
+Each entry in the macro defines a single boot device (e.g. a specific eMMC
+device or SD card) or type of boot device (e.g. USB disk). The parameters to
+the func macro (passed in by the internal implementation of the header) are:
+
+- Upper-case disk type (MMC, SATA, SCSI, IDE, USB, DHCP, PXE).
+- Lower-case disk type (same options as above).
+- ID of the specific disk (MMC only) or ignored for other types.
+
+User Configuration
+==================
+
+Once the user has installed U-Boot, it is expected that the environment will
+be reset to the default values in order to enable $bootcmd and friends, as set
+up by <config_distro_bootcmd.h>. After this, various environment variables may
+be altered to influence the boot process:
+
+boot_targets:
+
+  The list of boot locations searched.
+
+  Example: mmc0, mmc1, usb, pxe
+
+  Entries may be removed or re-ordered in this list to affect the boot order.
+
+boot_prefixes:
+
+  For disk-based booting, the list of directories within a partition that are
+  searched for boot configuration files (extlinux.conf, boot.scr).
+
+  Example: / /boot/
+
+  Entries may be removed or re-ordered in this list to affect the set of
+  directories which are searched.
+
+boot_scripts:
+
+  The name of U-Boot style boot.scr files that $bootcmd searches for.
+
+  Example: boot.scr.uimg boot.scr
+
+  (Typically we expect extlinux.conf to be used, but execution of boot.scr is
+  maintained for backwards-compatibility.)
+
+  Entries may be removed or re-ordered in this list to affect the set of
+  filenames which are supported.
+
+scan_dev_for_extlinux:
+
+  If you want to disable extlinux.conf on all disks, set the value to something
+  innocuous, e.g. setenv scan_dev_for_extlinux true.
+
+scan_dev_for_scripts:
+
+  If you want to disable boot.scr on all disks, set the value to something
+  innocuous, e.g. setenv scan_dev_for_scripts true.
index b79c5a432bf6eb6e6cffab4ec00bf86daeb26f83..952ab871c298f8484fddfa63039128dc1335a938 100644 (file)
@@ -12,11 +12,28 @@ The list should be sorted in reverse chronological order.
 
 Board            Arch        CPU            Commit      Removed     Last known maintainer/contact
 =================================================================================================
-P3G4             powerpc     74xx_7xx       -           -           Wolfgang Denk <wd@denx.de>
-ZUMA             powerpc     74xx_7xx       -           -           Nye Liu <nyet@zumanetworks.com>
-ppmc7xx          powerpc     74xx_7xx       -           -
-ELPPC            powerpc     74xx_7xx       -           -
-mpc7448hpc2      powerpc     74xx_7xx       -           -           Roy Zang <tie-fei.zang@freescale.com>
+icecube_5200     powerpc     mpc5xxx        -           -           Wolfgang Denk <wd@denx.de>
+Lite5200         powerpc     mpc5xxx        -           -
+cpci5200         powerpc     mpc5xxx        -           -           Reinhard Arlt <reinhard.arlt@esd-electronics.com>
+mecp5200         powerpc     mpc5xxx        -           -           Reinhard Arlt <reinhard.arlt@esd-electronics.com>
+pf5200           powerpc     mpc5xxx        -           -           Reinhard Arlt <reinhard.arlt@esd-electronics.com>
+PM520            powerpc     mpc5xxx        -           -           Josef Wagner <Wagner@Microsys.de>
+Total5200        powerpc     mpc5xxx        -           -
+CATcenter        powerpc     ppc4xx         -           -
+PPChameleonEVB   powerpc     ppc4xx         -           -           Andrea "llandre" Marson <andrea.marson@dave-tech.it>
+P2020DS          powerpc     mpc85xx        -           -
+P2020COME        powerpc     mpc85xx        -           -           Ira W. Snyder <iws@ovro.caltech.edu>
+P2020RDB         powerpc     mpc85xx        -           -           Poonam Aggrwal <poonam.aggrwal@freescale.com>
+P2010RDB         powerpc     mpc85xx        -           -
+P1020RDB         powerpc     mpc85xx        -           -
+P1011RDB         powerpc     mpc85xx        -           -
+MPC8360EMDS      powerpc     mpc83xx        -           -           Dave Liu <daveliu@freescale.com>
+MPC8360ERDK      powerpc     mpc83xx        -           -           Anton Vorontsov <avorontsov@ru.mvista.com>
+P3G4             powerpc     74xx_7xx       d928664f    2015-01-16  Wolfgang Denk <wd@denx.de>
+ZUMA             powerpc     74xx_7xx       d928664f    2015-01-16  Nye Liu <nyet@zumanetworks.com>
+ppmc7xx          powerpc     74xx_7xx       d928664f    2015-01-16
+ELPPC            powerpc     74xx_7xx       d928664f    2015-01-16
+mpc7448hpc2      powerpc     74xx_7xx       d928664f    2015-01-16  Roy Zang <tie-fei.zang@freescale.com>
 CPCI405          ppc4xx      405gp          5f1459dc    2015-01-13  Matthias Fuchs <matthias.fuchs@esd.eu>
 CPCI405DT        ppc4xx      405gpr         5f1459dc    2015-01-13  Matthias Fuchs <matthias.fuchs@esd.eu>
 CPCI405AB        ppc4xx      405gpr         5f1459dc    2015-01-13  Matthias Fuchs <matthias.fuchs@esd.eu>
index e3000efcc62177962809e7972ecba8fece4aefe2..659a12f6cb70b05cccf1110bddd365cdf31363e8 100644 (file)
@@ -5,18 +5,18 @@ Design Notes on Exporting U-Boot Functions to Standalone Applications:
    table is allocated and initialized in the jumptable_init() routine
    (common/exports.c). Other routines may also modify the jump table,
    however. The jump table can be accessed as the 'jt' field of the
-   'global_data' structure. The slot numbers for the jump table are
+   'global_data' structure. The struct members for the jump table are
    defined in the <include/exports.h> header. E.g., to substitute the
    malloc() and free() functions that will be available to standalone
    applications, one should do the following:
 
        DECLARE_GLOBAL_DATA_PTR;
 
-       gd->jt[XF_malloc]       = my_malloc;
-       gd->jt[XF_free]         = my_free;
+       gd->jt->malloc  = my_malloc;
+       gd->jt->free = my_free;
 
-   Note that the pointers to the functions all have 'void *' type and
-   thus the compiler cannot perform type checks on these assignments.
+   Note that the pointers to the functions are real function pointers
+   so the compiler can perform type checks on these assignments.
 
 2. The pointer to the jump table is passed to the application in a
    machine-dependent way. PowerPC, ARM, MIPS, Blackfin and Nios II
@@ -65,27 +65,46 @@ Design Notes on Exporting U-Boot Functions to Standalone Applications:
    => tftp 0x40000 hello_world.bin
    => go 0x40004
 
-5. To export some additional function foobar(), the following steps
+5. To export some additional function long foobar(int i,char c), the following steps
    should be undertaken:
 
    - Append the following line at the end of the include/_exports.h
      file:
 
-       EXPORT_FUNC(foobar)
+       EXPORT_FUNC(foobar, long, foobar, int, char)
+
+       Parameters to EXPORT_FUNC:
+        - the first parameter is the function that is exported (default implementation)
+        - the second parameter is the return value type
+        - the third  parameter is the name of the member in struct jt_funcs
+          this is also the name that the standalone application will used.
+          the rest of the parameters are the function arguments
 
    - Add the prototype for this function to the include/exports.h
      file:
 
-       void foobar(void);
+       long foobar(int i, char c);
+
+       Initialization with the default implementation is done in jumptable_init()
+
+       You can override the default implementation using:
 
-   - Add the initialization of the jump table slot wherever
-     appropriate (most likely, to the jumptable_init() function):
+       gd->jt->foobar = another_foobar;
 
-       gd->jt[XF_foobar] = foobar;
+       The signature of another_foobar must then match the declaration of foobar.
 
    - Increase the XF_VERSION value by one in the include/exports.h
      file
 
+   - If you want to export a function which depends on a CONFIG_XXX
+       use 2 lines like this:
+       #ifdef CONFIG_FOOBAR
+               EXPORT_FUNC(foobar, long, foobar, int, char)
+       #else
+               EXPORT_FUNC(dummy, void, foobar, void)
+       #endif
+
+
 6. The code for exporting the U-Boot functions to applications is
    mostly machine-independent. The only places written in assembly
    language are stub functions that perform the jump through the jump
diff --git a/doc/README.t1040-l2switch b/doc/README.t1040-l2switch
new file mode 100644 (file)
index 0000000..14dbf31
--- /dev/null
@@ -0,0 +1,48 @@
+This file contains information for VSC9953, a Vitesse L2 Switch IP
+which is integrated in the T1040/T1020 Freescale SoCs.
+
+About Device:
+=============
+VSC9953 is an 8-port Gigabit Ethernet switch supports the following features:
+       -       8192 MAC addresses
+       -       Static Address provisioning
+       -       Dynamic learning of MAC addresses and aging
+       -       4096 VLANs
+       -       Independent and shared VLAN learning (IVL, SVL)
+       -       Policing with storm control and MC/BC protection
+       -       IPv4 and IPv6 multicast
+       -       Jumbo frames (9.6 KB)
+       -       Access Control List
+       -       VLAN editing, translation and remarking
+       -       RMON counters per port
+
+Switch interfaces:
+       -       8 Gigabit switch ports (ports 0 to 7) are external and are connected to external PHYs
+       -       2 switch ports (ports 8 and 9) of 2.5 G are connected (fixed links)
+               to FMan ports (FM1@DTSEC1 and FM1@DTSEC2)
+
+Commands Overview:
+=============
+Commands supported
+       - enable/disable a port
+       - check a port's link speed, duplexity and status.
+
+Commands syntax
+       ethsw port <port_nr> enable|disable             - enable/disable an l2 switch port
+       ethsw port <port_nr> show                       - show an l2 switch port's configuration
+
+       port_nr=0..9; use "all" for all ports
+
+=> ethsw port all show
+    Port   Status     Link    Speed   Duplex
+       0  enabled     down       10     half
+       1  enabled     down       10     half
+       2  enabled     down       10     half
+       3  enabled       up     1000     full
+       4 disabled     down        -     half
+       5 disabled     down        -     half
+       6 disabled     down        -     half
+       7 disabled     down        -     half
+       8  enabled       up     2500     full
+       9  enabled       up     2500     full
+=>
diff --git a/doc/README.uniphier b/doc/README.uniphier
new file mode 100644 (file)
index 0000000..aaeb50c
--- /dev/null
@@ -0,0 +1,85 @@
+U-Boot for UniPhier SoC family
+==============================
+
+
+Tested toolchains
+-----------------
+
+ (a) Ubuntu packages  (CROSS_COMPILE=arm-linux-gnueabi-)
+
+  If you are building U-Boot on Ubuntu, its standard package is recommended.
+  You can install it as follows:
+
+    $ sudo apt-get install gcc-arm-linux-gnueabi-
+
+ (b) Linaro compilers  (CROSS_COMPILE=arm-linux-gnueabihf-)
+
+  You can download pre-built toolchains from:
+
+    http://www.linaro.org/downloads/
+
+ (c) kernel.org compilers  (CROSS_COMPILE=arm-unknown-linux-gnueabi-)
+
+  You can download pre-built toolchains from:
+
+    ftp://www.kernel.org/pub/tools/crosstool/files/bin/
+
+
+Compile the source
+------------------
+
+PH1-Pro4:
+    $ make ph1_pro4_defconfig
+    $ make CROSS_COMPILE=arm-linux-gnueabi-
+
+PH1-LD4:
+    $ make ph1_ld4_defconfig
+    $ make CROSS_COMPILE=arm-linux-gnueabi-
+
+PH1-sLD8:
+    $ make ph1_sld8_defconfig
+    $ make CROSS_COMPILE=arm-linux-gnueabi-
+
+You may wish to change the "CROSS_COMPILE=arm-linux-gnueabi-"
+to use your favorite compiler.
+
+
+Burn U-Boot images to NAND
+--------------------------
+
+Write two files to the NAND device as follows:
+ - spl/u-boot-spl.bin at the offset address 0x00000000
+ - u-boot-dtb.img     at the offset address 0x00010000
+
+If a TFTP server is available, the images can be easily updated.
+Just copy the u-boot-spl.bin and u-boot-dtb.img to the TFTP public directory,
+and then run the following command at the U-Boot command line:
+
+  => run nandupdate
+
+
+UniPhier specific commands
+--------------------------
+
+ - pinmon (enabled by CONFIG_CMD_PINMON)
+     shows the boot mode pins that has been latched at the power-on reset
+
+ - ddrphy (enabled by CONFIG_CMD_DDRPHY_DUMP)
+     shows the DDR PHY parameters set by the PHY training
+
+
+Supported devices
+-----------------
+
+ - UART (on-chip)
+ - NAND
+ - USB (2.0)
+ - LAN (on-board SMSC9118)
+ - I2C
+ - EEPROM (connected to the on-board I2C bus)
+ - Support card (SRAM, NOR flash, some peripherals)
+
+
+--
+Masahiro Yamada <yamada.m@jp.panasonic.com>
+Feb. 2015
diff --git a/doc/device-tree-bindings/gpio/gpio-samsung.txt b/doc/device-tree-bindings/gpio/gpio-samsung.txt
new file mode 100644 (file)
index 0000000..5375625
--- /dev/null
@@ -0,0 +1,41 @@
+Samsung Exynos4 GPIO Controller
+
+Required properties:
+- compatible: Compatible property value should be "samsung,exynos4-gpio>".
+
+- reg: Physical base address of the controller and length of memory mapped
+  region.
+
+- #gpio-cells: Should be 4. The syntax of the gpio specifier used by client nodes
+  should be the following with values derived from the SoC user manual.
+     <[phandle of the gpio controller node]
+      [pin number within the gpio controller]
+      [mux function]
+      [flags and pull up/down]
+      [drive strength]>
+
+  Values for gpio specifier:
+  - Pin number: is a value between 0 to 7.
+  - Flags and Pull Up/Down: 0 - Pull Up/Down Disabled.
+                            1 - Pull Down Enabled.
+                            3 - Pull Up Enabled.
+          Bit 16 (0x00010000) - Input is active low.
+  - Drive Strength: 0 - 1x,
+                    1 - 3x,
+                    2 - 2x,
+                    3 - 4x
+
+- gpio-controller: Specifies that the node is a gpio controller.
+- #address-cells: should be 1.
+- #size-cells: should be 1.
+
+Example:
+
+       gpa0: gpio-controller@11400000 {
+               #address-cells = <1>;
+               #size-cells = <1>;
+               compatible = "samsung,exynos4-gpio";
+               reg = <0x11400000 0x20>;
+               #gpio-cells = <4>;
+               gpio-controller;
+       };
diff --git a/doc/device-tree-bindings/gpio/gpio.txt b/doc/device-tree-bindings/gpio/gpio.txt
new file mode 100644 (file)
index 0000000..b9bd1d6
--- /dev/null
@@ -0,0 +1,211 @@
+Specifying GPIO information for devices
+============================================
+
+1) gpios property
+-----------------
+
+Nodes that makes use of GPIOs should specify them using one or more
+properties, each containing a 'gpio-list':
+
+       gpio-list ::= <single-gpio> [gpio-list]
+       single-gpio ::= <gpio-phandle> <gpio-specifier>
+       gpio-phandle : phandle to gpio controller node
+       gpio-specifier : Array of #gpio-cells specifying specific gpio
+                        (controller specific)
+
+GPIO properties should be named "[<name>-]gpios", with <name> being the purpose
+of this GPIO for the device. While a non-existent <name> is considered valid
+for compatibility reasons (resolving to the "gpios" property), it is not allowed
+for new bindings.
+
+GPIO properties can contain one or more GPIO phandles, but only in exceptional
+cases should they contain more than one. If your device uses several GPIOs with
+distinct functions, reference each of them under its own property, giving it a
+meaningful name. The only case where an array of GPIOs is accepted is when
+several GPIOs serve the same function (e.g. a parallel data line).
+
+The exact purpose of each gpios property must be documented in the device tree
+binding of the device.
+
+The following example could be used to describe GPIO pins used as device enable
+and bit-banged data signals:
+
+       gpio1: gpio1 {
+               gpio-controller
+                #gpio-cells = <2>;
+       };
+       gpio2: gpio2 {
+               gpio-controller
+                #gpio-cells = <1>;
+       };
+       [...]
+
+       enable-gpios = <&gpio2 2>;
+       data-gpios = <&gpio1 12 0>,
+                    <&gpio1 13 0>,
+                    <&gpio1 14 0>,
+                    <&gpio1 15 0>;
+
+Note that gpio-specifier length is controller dependent.  In the
+above example, &gpio1 uses 2 cells to specify a gpio, while &gpio2
+only uses one.
+
+gpio-specifier may encode: bank, pin position inside the bank,
+whether pin is open-drain and whether pin is logically inverted.
+Exact meaning of each specifier cell is controller specific, and must
+be documented in the device tree binding for the device. Use the macros
+defined in include/dt-bindings/gpio/gpio.h whenever possible:
+
+Example of a node using GPIOs:
+
+       node {
+               enable-gpios = <&qe_pio_e 18 GPIO_ACTIVE_HIGH>;
+       };
+
+GPIO_ACTIVE_HIGH is 0, so in this example gpio-specifier is "18 0" and encodes
+GPIO pin number, and GPIO flags as accepted by the "qe_pio_e" gpio-controller.
+
+1.1) GPIO specifier best practices
+----------------------------------
+
+A gpio-specifier should contain a flag indicating the GPIO polarity; active-
+high or active-low. If it does, the follow best practices should be followed:
+
+The gpio-specifier's polarity flag should represent the physical level at the
+GPIO controller that achieves (or represents, for inputs) a logically asserted
+value at the device. The exact definition of logically asserted should be
+defined by the binding for the device. If the board inverts the signal between
+the GPIO controller and the device, then the gpio-specifier will represent the
+opposite physical level than the signal at the device's pin.
+
+When the device's signal polarity is configurable, the binding for the
+device must either:
+
+a) Define a single static polarity for the signal, with the expectation that
+any software using that binding would statically program the device to use
+that signal polarity.
+
+The static choice of polarity may be either:
+
+a1) (Preferred) Dictated by a binding-specific DT property.
+
+or:
+
+a2) Defined statically by the DT binding itself.
+
+In particular, the polarity cannot be derived from the gpio-specifier, since
+that would prevent the DT from separately representing the two orthogonal
+concepts of configurable signal polarity in the device, and possible board-
+level signal inversion.
+
+or:
+
+b) Pick a single option for device signal polarity, and document this choice
+in the binding. The gpio-specifier should represent the polarity of the signal
+(at the GPIO controller) assuming that the device is configured for this
+particular signal polarity choice. If software chooses to program the device
+to generate or receive a signal of the opposite polarity, software will be
+responsible for correctly interpreting (inverting) the GPIO signal at the GPIO
+controller.
+
+2) gpio-controller nodes
+------------------------
+
+Every GPIO controller node must contain both an empty "gpio-controller"
+property, and a #gpio-cells integer property, which indicates the number of
+cells in a gpio-specifier.
+
+Example of two SOC GPIO banks defined as gpio-controller nodes:
+
+       qe_pio_a: gpio-controller@1400 {
+               compatible = "fsl,qe-pario-bank-a", "fsl,qe-pario-bank";
+               reg = <0x1400 0x18>;
+               gpio-controller;
+               #gpio-cells = <2>;
+       };
+
+       qe_pio_e: gpio-controller@1460 {
+               compatible = "fsl,qe-pario-bank-e", "fsl,qe-pario-bank";
+               reg = <0x1460 0x18>;
+               gpio-controller;
+               #gpio-cells = <2>;
+       };
+
+2.1) gpio- and pin-controller interaction
+-----------------------------------------
+
+Some or all of the GPIOs provided by a GPIO controller may be routed to pins
+on the package via a pin controller. This allows muxing those pins between
+GPIO and other functions.
+
+It is useful to represent which GPIOs correspond to which pins on which pin
+controllers. The gpio-ranges property described below represents this, and
+contains information structures as follows:
+
+       gpio-range-list ::= <single-gpio-range> [gpio-range-list]
+       single-gpio-range ::= <numeric-gpio-range> | <named-gpio-range>
+       numeric-gpio-range ::=
+                       <pinctrl-phandle> <gpio-base> <pinctrl-base> <count>
+       named-gpio-range ::= <pinctrl-phandle> <gpio-base> '<0 0>'
+       gpio-phandle : phandle to pin controller node.
+       gpio-base : Base GPIO ID in the GPIO controller
+       pinctrl-base : Base pinctrl pin ID in the pin controller
+       count : The number of GPIOs/pins in this range
+
+The "pin controller node" mentioned above must conform to the bindings
+described in ../pinctrl/pinctrl-bindings.txt.
+
+In case named gpio ranges are used (ranges with both <pinctrl-base> and
+<count> set to 0), the property gpio-ranges-group-names contains one string
+for every single-gpio-range in gpio-ranges:
+       gpiorange-names-list ::= <gpiorange-name> [gpiorange-names-list]
+       gpiorange-name : Name of the pingroup associated to the GPIO range in
+                       the respective pin controller.
+
+Elements of gpiorange-names-list corresponding to numeric ranges contain
+the empty string. Elements of gpiorange-names-list corresponding to named
+ranges contain the name of a pin group defined in the respective pin
+controller. The number of pins/GPIOs in the range is the number of pins in
+that pin group.
+
+Previous versions of this binding required all pin controller nodes that
+were referenced by any gpio-ranges property to contain a property named
+#gpio-range-cells with value <3>. This requirement is now deprecated.
+However, that property may still exist in older device trees for
+compatibility reasons, and would still be required even in new device
+trees that need to be compatible with older software.
+
+Example 1:
+
+       qe_pio_e: gpio-controller@1460 {
+               #gpio-cells = <2>;
+               compatible = "fsl,qe-pario-bank-e", "fsl,qe-pario-bank";
+               reg = <0x1460 0x18>;
+               gpio-controller;
+               gpio-ranges = <&pinctrl1 0 20 10>, <&pinctrl2 10 50 20>;
+       };
+
+Here, a single GPIO controller has GPIOs 0..9 routed to pin controller
+pinctrl1's pins 20..29, and GPIOs 10..19 routed to pin controller pinctrl2's
+pins 50..59.
+
+Example 2:
+
+       gpio_pio_i: gpio-controller@14B0 {
+               #gpio-cells = <2>;
+               compatible = "fsl,qe-pario-bank-e", "fsl,qe-pario-bank";
+               reg = <0x1480 0x18>;
+               gpio-controller;
+               gpio-ranges =                   <&pinctrl1 0 20 10>,
+                                               <&pinctrl2 10 0 0>,
+                                               <&pinctrl1 15 0 10>,
+                                               <&pinctrl2 25 0 0>;
+               gpio-ranges-group-names =       "",
+                                               "foo",
+                                               "",
+                                               "bar";
+       };
+
+Here, three GPIO ranges are defined wrt. two pin controllers. pinctrl1 GPIO
+ranges are defined using pin numbers whereas the GPIO ranges wrt. pinctrl2
+are named "foo" and "bar".
diff --git a/doc/device-tree-bindings/gpio/nvidia,tegra20-gpio.txt b/doc/device-tree-bindings/gpio/nvidia,tegra20-gpio.txt
new file mode 100644 (file)
index 0000000..023c952
--- /dev/null
@@ -0,0 +1,40 @@
+NVIDIA Tegra GPIO controller
+
+Required properties:
+- compatible : "nvidia,tegra<chip>-gpio"
+- reg : Physical base address and length of the controller's registers.
+- interrupts : The interrupt outputs from the controller. For Tegra20,
+  there should be 7 interrupts specified, and for Tegra30, there should
+  be 8 interrupts specified.
+- #gpio-cells : Should be two. The first cell is the pin number and the
+  second cell is used to specify optional parameters:
+  - bit 0 specifies polarity (0 for normal, 1 for inverted)
+- gpio-controller : Marks the device node as a GPIO controller.
+- #interrupt-cells : Should be 2.
+  The first cell is the GPIO number.
+  The second cell is used to specify flags:
+    bits[3:0] trigger type and level flags:
+      1 = low-to-high edge triggered.
+      2 = high-to-low edge triggered.
+      4 = active high level-sensitive.
+      8 = active low level-sensitive.
+      Valid combinations are 1, 2, 3, 4, 8.
+- interrupt-controller : Marks the device node as an interrupt controller.
+
+Example:
+
+gpio: gpio@6000d000 {
+       compatible = "nvidia,tegra20-gpio";
+       reg = < 0x6000d000 0x1000 >;
+       interrupts = < 0 32 0x04
+                      0 33 0x04
+                      0 34 0x04
+                      0 35 0x04
+                      0 55 0x04
+                      0 87 0x04
+                      0 89 0x04 >;
+       #gpio-cells = <2>;
+       gpio-controller;
+       #interrupt-cells = <2>;
+       interrupt-controller;
+};
diff --git a/doc/device-tree-bindings/i2c/i2c.txt b/doc/device-tree-bindings/i2c/i2c.txt
new file mode 100644 (file)
index 0000000..ea918dd
--- /dev/null
@@ -0,0 +1,28 @@
+U-Boot I2C
+----------
+
+U-Boot's I2C model has the concept of an offset within a chip (I2C target
+device). The offset can be up to 4 bytes long, but is normally 1 byte,
+meaning that offsets from 0 to 255 are supported by the chip. This often
+corresponds to register numbers.
+
+Apart from the controller-specific I2C bindings, U-Boot supports a special
+property which allows the chip offset length to be selected.
+
+Optional properties:
+- u-boot,i2c-offset-len - length of chip offset in bytes. If omitted the
+    default value of 1 is used.
+
+
+Example
+-------
+
+i2c4: i2c@12ca0000 {
+       cros-ec@1e {
+               reg = <0x1e>;
+               compatible = "google,cros-ec";
+               i2c-max-frequency = <100000>;
+               u-boot,i2c-offset-len = <0>;
+               ec-interrupt = <&gpx1 6 GPIO_ACTIVE_LOW>;
+       };
+};
index eafa825ab44a00969f27dd805a4a504b59b74720..f83264d615da5390d34ed52b0a2394f6d2a6fcf6 100644 (file)
@@ -363,6 +363,10 @@ can leave out platdata_auto_alloc_size. In this case you can use malloc
 in your ofdata_to_platdata (or probe) method to allocate the required memory,
 and you should free it in the remove method.
 
+The driver model tree is intended to mirror that of the device tree. The
+root driver is at device tree offset 0 (the root node, '/'), and its
+children are the children of the root node.
+
 
 Declaring Uclasses
 ------------------
@@ -384,12 +388,12 @@ Device Sequence Numbers
 U-Boot numbers devices from 0 in many situations, such as in the command
 line for I2C and SPI buses, and the device names for serial ports (serial0,
 serial1, ...). Driver model supports this numbering and permits devices
-to be locating by their 'sequence'. This numbering unique identifies a
+to be locating by their 'sequence'. This numbering uniquely identifies a
 device in its uclass, so no two devices within a particular uclass can have
 the same sequence number.
 
 Sequence numbers start from 0 but gaps are permitted. For example, a board
-may have I2C buses 0, 1, 4, 5 but no 2 or 3. The choice of how devices are
+may have I2C buses 1, 4, 5 but no 0, 2 or 3. The choice of how devices are
 numbered is up to a particular board, and may be set by the SoC in some
 cases. While it might be tempting to automatically renumber the devices
 where there are gaps in the sequence, this can lead to confusion and is
@@ -399,7 +403,7 @@ Each device can request a sequence number. If none is required then the
 device will be automatically allocated the next available sequence number.
 
 To specify the sequence number in the device tree an alias is typically
-used.
+used. Make sure that the uclass has the DM_UC_FLAG_SEQ_ALIAS flag set.
 
 aliases {
        serial2 = "/serial@22230000";
@@ -409,43 +413,18 @@ This indicates that in the uclass called "serial", the named node
 ("/serial@22230000") will be given sequence number 2. Any command or driver
 which requests serial device 2 will obtain this device.
 
-Some devices represent buses where the devices on the bus are numbered or
-addressed. For example, SPI typically numbers its slaves from 0, and I2C
-uses a 7-bit address. In these cases the 'reg' property of the subnode is
-used, for example:
-
-{
-       aliases {
-               spi2 = "/spi@22300000";
-       };
-
-       spi@22300000 {
-               #address-cells = <1>;
-               #size-cells = <1>;
-               spi-flash@0 {
-                       reg = <0>;
-                       ...
-               }
-               eeprom@1 {
-                       reg = <1>;
-               };
-       };
-
-In this case we have a SPI bus with two slaves at 0 and 1. The SPI bus
-itself is numbered 2. So we might access the SPI flash with:
-
-       sf probe 2:0
+More commonly you can use node references, which expand to the full path:
 
-and the eeprom with
-
-       sspi 2:1 32 ef
-
-These commands simply need to look up the 2nd device in the SPI uclass to
-find the right SPI bus. Then, they look at the children of that bus for the
-right sequence number (0 or 1 in this case).
+aliases {
+       serial2 = &serial_2;
+};
+...
+serial_2: serial@22230000 {
+...
+};
 
-Typically the alias method is used for top-level nodes and the 'reg' method
-is used only for buses.
+The alias resolves to the same string in this case, but this version is
+easier to read.
 
 Device sequence numbers are resolved when a device is probed. Before then
 the sequence number is only a request which may or may not be honoured,
@@ -462,11 +441,18 @@ access to other devices. Example of buses include SPI and I2C. Typically
 the bus provides some sort of transport or translation that makes it
 possible to talk to the devices on the bus.
 
-Driver model provides a few useful features to help with implementing
-buses. Firstly, a bus can request that its children store some 'parent
-data' which can be used to keep track of child state. Secondly, the bus can
-define methods which are called when a child is probed or removed. This is
-similar to the methods the uclass driver provides.
+Driver model provides some useful features to help with implementing buses.
+Firstly, a bus can request that its children store some 'parent data' which
+can be used to keep track of child state. Secondly, the bus can define
+methods which are called when a child is probed or removed. This is similar
+to the methods the uclass driver provides. Thirdly, per-child platform data
+can be provided to specify things like the child's address on the bus. This
+persists across child probe()/remove() cycles.
+
+For consistency and ease of implementation, the bus uclass can specify the
+per-child platform data, so that it can be the same for all children of buses
+in that uclass. There are also uclass methods which can be called when
+children are bound and probed.
 
 Here an explanation of how a bus fits with a uclass may be useful. Consider
 a USB bus with several devices attached to it, each from a different (made
@@ -481,15 +467,23 @@ Each of the devices is connected to a different address on the USB bus.
 The bus device wants to store this address and some other information such
 as the bus speed for each device.
 
-To achieve this, the bus device can use dev->parent_priv in each of its
-three children. This can be auto-allocated if the bus driver has a non-zero
-value for per_child_auto_alloc_size. If not, then the bus device can
-allocate the space itself before the child device is probed.
+To achieve this, the bus device can use dev->parent_platdata in each of its
+three children. This can be auto-allocated if the bus driver (or bus uclass)
+has a non-zero value for per_child_platdata_auto_alloc_size. If not, then
+the bus device or uclass can allocate the space itself before the child
+device is probed.
 
 Also the bus driver can define the child_pre_probe() and child_post_remove()
 methods to allow it to do some processing before the child is activated or
 after it is deactivated.
 
+Similarly the bus uclass can define the child_post_bind() method to obtain
+the per-child platform data from the device tree and set it up for the child.
+The bus uclass can also provide a child_pre_probe() method. Very often it is
+the bus uclass that controls these features, since it avoids each driver
+having to do the same processing. Of course the driver can still tweak and
+override these activities.
+
 Note that the information that controls this behaviour is in the bus's
 driver, not the child's. In fact it is possible that child has no knowledge
 that it is connected to a bus. The same child device may even be used on two
@@ -516,7 +510,8 @@ bus device, regardless of its own views on the matter.
 The uclass for the device can also contain data private to that uclass.
 But note that each device on the bus may be a memeber of a different
 uclass, and this data has nothing to do with the child data for each child
-on the bus.
+on the bus. It is the bus' uclass that controls the child with respect to
+the bus.
 
 
 Driver Lifecycle
index 719dbd5cdd24e9156769d9be6c1adf747d623964..5bc29ad65ce145b7dbea4fb7fbd4928e8b7395e6 100644 (file)
@@ -3,7 +3,8 @@ How to port a SPI driver to driver model
 
 Here is a rough step-by-step guide. It is based around converting the
 exynos SPI driver to driver model (DM) and the example code is based
-around U-Boot v2014.10-rc2 (commit be9f643).
+around U-Boot v2014.10-rc2 (commit be9f643). This has been updated for
+v2015.04.
 
 It is quite long since it includes actual code examples.
 
@@ -262,8 +263,8 @@ U_BOOT_DEVICE(board_spi0) = {
        .platdata = &platdata_spi0,
 };
 
-You will unfortunately need to put the struct into a header file in this
-case so that your board file can use it.
+You will unfortunately need to put the struct definition into a header file
+in this case so that your board file can use it.
 
 
 9. Add the device private data
@@ -592,3 +593,36 @@ board.
 
 You can use 'tools/patman/patman' to prepare, check and send patches for
 your work. See the README for details.
+
+20. A little note about SPI uclass features:
+
+The SPI uclass keeps some information about each device 'dev' on the bus:
+
+   struct dm_spi_slave_platdata - this is device_get_parent_platdata(dev)
+               This is where the chip select number is stored, along with
+               the default bus speed and mode. It is automatically read
+               from the device tree in spi_child_post_bind(). It must not
+               be changed at run-time after being set up because platform
+               data is supposed to be immutable at run-time.
+   struct spi_slave - this is device_get_parentdata(dev)
+               Already mentioned above. It holds run-time information about
+               the device.
+
+There are also some SPI uclass methods that get called behind the scenes:
+
+   spi_post_bind() - called when a new bus is bound
+               This scans the device tree for devices on the bus, and binds
+               each one. This in turn causes spi_child_post_bind() to be
+               called for each, which reads the device tree information
+               into the parent (per-child) platform data.
+   spi_child_post_bind() - called when a new child is bound
+               As mentioned above this reads the device tree information
+               into the per-child platform data
+   spi_child_pre_probe() - called before a new child is probed
+               This sets up the mode and speed in struct spi_slave by
+               copying it from the parent's platform data for this child.
+               It also sets the 'dev' pointer, needed to permit passing
+               'struct spi_slave' around the place without needing a
+               separate 'struct udevice' pointer.
+
+The above housekeeping makes it easier to write your SPI driver.
index b47ce73b8323a4034bbd58c77ce50d49f5492b38..427ea498b498793f3af51bdad51dbf3ab351349c 100644 (file)
@@ -159,17 +159,17 @@ the '/images' node should have the following layout:
   - description : Textual description of the component sub-image
   - type : Name of component sub-image type, supported types are:
     "standalone", "kernel", "ramdisk", "firmware", "script", "filesystem",
-    "flat_dt" and others (see uimage_type in common/images.c).
+    "flat_dt" and others (see uimage_type in common/image.c).
   - data : Path to the external file which contains this node's binary data.
   - compression : Compression used by included data. Supported compressions
     are "gzip" and "bzip2". If no compression is used compression property
     should be set to "none".
 
   Conditionally mandatory property:
-  - os : OS name, mandatory for type="kernel", valid OS names are: "openbsd",
-    "netbsd", "freebsd", "4_4bsd", "linux", "svr4", "esix", "solaris", "irix",
-    "sco", "dell", "ncr", "lynxos", "vxworks", "psos", "qnx", "u_boot",
-    "rtems", "unity", "integrity".
+  - os : OS name, mandatory for types "kernel" and "ramdisk". Valid OS names
+    are: "openbsd", "netbsd", "freebsd", "4_4bsd", "linux", "svr4", "esix",
+    "solaris", "irix", "sco", "dell", "ncr", "lynxos", "vxworks", "psos", "qnx",
+    "u_boot", "rtems", "unity", "integrity".
   - arch : Architecture name, mandatory for types: "standalone", "kernel",
     "firmware", "ramdisk" and "fdt". Valid architecture names are: "alpha",
     "arm", "i386", "ia64", "mips", "mips64", "ppc", "s390", "sh", "sparc",
index 3c83fbc2c16744c2387e3c4271971b14489aa124..e639e7ae71a1e6bbe0f421630959369ec15fcf3a 100644 (file)
@@ -64,7 +64,7 @@ software from updatable memory.
 
 It is critical that the public key be secure and cannot be tampered with.
 It can be stored in read-only memory, or perhaps protected by other on-chip
-crypto provided by some modern SOCs. If the public key can ben changed, then
+crypto provided by some modern SOCs. If the public key can be changed, then
 the verification is worthless.
 
 
@@ -87,7 +87,7 @@ affect the whole change.
 
 Flattened Image Tree (FIT)
 --------------------------
-The FIT format is alreay widely used in U-Boot. It is a flattened device
+The FIT format is already widely used in U-Boot. It is a flattened device
 tree (FDT) in a particular format, with images contained within. FITs
 include hashes to verify images, so it is relatively straightforward to
 add signatures as well.
index 93b815ccb497d7c81eb0491a441fa082e3c703f6..7ea5fa622472ca38a8256e97cc82c6a2cf883d93 100644 (file)
@@ -62,40 +62,158 @@ static u32 saveBaseAddress14;
 static u32 saveBaseAddress18;
 static u32 saveBaseAddress20;
 
-static void atibios_set_vesa_mode(RMREGS *regs, int vesa_mode,
-                                 struct vbe_mode_info *mode_info)
+/* Addres im memory of VBE region */
+const int vbe_offset = 0x2000;
+
+static const void *bios_ptr(const void *buf, BE_VGAInfo *vga_info,
+                           u32 x86_dword_ptr)
+{
+       u32 seg_ofs, flat;
+
+       seg_ofs = le32_to_cpu(x86_dword_ptr);
+       flat = ((seg_ofs & 0xffff0000) >> 12) | (seg_ofs & 0xffff);
+       if (flat >= 0xc0000)
+               return vga_info->BIOSImage + flat - 0xc0000;
+       else
+               return buf + (flat - vbe_offset);
+}
+
+static int atibios_debug_mode(BE_VGAInfo *vga_info, RMREGS *regs,
+                             int vesa_mode, struct vbe_mode_info *mode_info)
+{
+       void *buffer = (void *)(M.mem_base + vbe_offset);
+       u16 buffer_seg = (((unsigned long)vbe_offset) >> 4) & 0xff00;
+       u16 buffer_adr = ((unsigned long)vbe_offset) & 0xffff;
+       struct vesa_mode_info *vm;
+       struct vbe_info *info;
+       const u16 *modes_bios, *ptr;
+       u16 *modes;
+       int size;
+
+       debug("VBE: Getting information\n");
+       regs->e.eax = VESA_GET_INFO;
+       regs->e.esi = buffer_seg;
+       regs->e.edi = buffer_adr;
+       info = buffer;
+       memset(info, '\0', sizeof(*info));
+       strcpy(info->signature, "VBE2");
+       BE_int86(0x10, regs, regs);
+       if (regs->e.eax != 0x4f) {
+               debug("VESA_GET_INFO: error %x\n", regs->e.eax);
+               return -ENOSYS;
+       }
+       debug("version %x\n", le16_to_cpu(info->version));
+       debug("oem '%s'\n", (char *)bios_ptr(buffer, vga_info,
+                                            info->oem_string_ptr));
+       debug("vendor '%s'\n", (char *)bios_ptr(buffer, vga_info,
+                                               info->vendor_name_ptr));
+       debug("product '%s'\n", (char *)bios_ptr(buffer, vga_info,
+                                                info->product_name_ptr));
+       debug("rev '%s'\n", (char *)bios_ptr(buffer, vga_info,
+                                            info->product_rev_ptr));
+       modes_bios = bios_ptr(buffer, vga_info, info->modes_ptr);
+       debug("Modes: ");
+       for (ptr = modes_bios; *ptr != 0xffff; ptr++)
+               debug("%x ", le16_to_cpu(*ptr));
+       debug("\nmemory %dMB\n", le16_to_cpu(info->total_memory) >> 4);
+       size = (ptr - modes_bios) * sizeof(u16) + 2;
+       modes = malloc(size);
+       if (!modes)
+               return -ENOMEM;
+       memcpy(modes, modes_bios, size);
+
+       regs->e.eax = VESA_GET_CUR_MODE;
+       BE_int86(0x10, regs, regs);
+       if (regs->e.eax != 0x4f) {
+               debug("VESA_GET_CUR_MODE: error %x\n", regs->e.eax);
+               return -ENOSYS;
+       }
+       debug("Current mode %x\n", regs->e.ebx);
+
+       for (ptr = modes; *ptr != 0xffff; ptr++) {
+               int mode = le16_to_cpu(*ptr);
+               bool linear_ok;
+               int attr;
+
+               break;
+               debug("Mode %x: ", mode);
+               memset(buffer, '\0', sizeof(struct vbe_mode_info));
+               regs->e.eax = VESA_GET_MODE_INFO;
+               regs->e.ebx = 0;
+               regs->e.ecx = mode;
+               regs->e.edx = 0;
+               regs->e.esi = buffer_seg;
+               regs->e.edi = buffer_adr;
+               BE_int86(0x10, regs, regs);
+               if (regs->e.eax != 0x4f) {
+                       debug("VESA_GET_MODE_INFO: error %x\n", regs->e.eax);
+                       continue;
+               }
+               memcpy(mode_info->mode_info_block, buffer,
+                      sizeof(struct vesa_mode_info));
+               mode_info->valid = true;
+               vm = &mode_info->vesa;
+               attr = le16_to_cpu(vm->mode_attributes);
+               linear_ok = attr & 0x80;
+               debug("res %d x %d, %d bpp, mm %d, (Linear %s, attr %02x)\n",
+                     le16_to_cpu(vm->x_resolution),
+                     le16_to_cpu(vm->y_resolution),
+                     vm->bits_per_pixel, vm->memory_model,
+                     linear_ok ? "OK" : "not available",
+                     attr);
+               debug("\tRGB pos=%d,%d,%d, size=%d,%d,%d\n",
+                     vm->red_mask_pos, vm->green_mask_pos, vm->blue_mask_pos,
+                     vm->red_mask_size, vm->green_mask_size,
+                     vm->blue_mask_size);
+       }
+
+       return 0;
+}
+
+static int atibios_set_vesa_mode(RMREGS *regs, int vesa_mode,
+                                struct vbe_mode_info *mode_info)
 {
+       void *buffer = (void *)(M.mem_base + vbe_offset);
+       u16 buffer_seg = (((unsigned long)vbe_offset) >> 4) & 0xff00;
+       u16 buffer_adr = ((unsigned long)vbe_offset) & 0xffff;
+       struct vesa_mode_info *vm;
+
        debug("VBE: Setting VESA mode %#04x\n", vesa_mode);
-       /* request linear framebuffer mode */
-       vesa_mode |= (1 << 14);
-       /* request clearing of framebuffer */
-       vesa_mode &= ~(1 << 15);
        regs->e.eax = VESA_SET_MODE;
        regs->e.ebx = vesa_mode;
+       /* request linear framebuffer mode and don't clear display */
+       regs->e.ebx |= (1 << 14) | (1 << 15);
        BE_int86(0x10, regs, regs);
+       if (regs->e.eax != 0x4f) {
+               debug("VESA_SET_MODE: error %x\n", regs->e.eax);
+               return -ENOSYS;
+       }
 
-       int offset = 0x2000;
-       void *buffer = (void *)(M.mem_base + offset);
-
-       u16 buffer_seg = (((unsigned long)offset) >> 4) & 0xff00;
-       u16 buffer_adr = ((unsigned long)offset) & 0xffff;
+       memset(buffer, '\0', sizeof(struct vbe_mode_info));
+       debug("VBE: Geting info for VESA mode %#04x\n", vesa_mode);
        regs->e.eax = VESA_GET_MODE_INFO;
-       regs->e.ebx = 0;
        regs->e.ecx = vesa_mode;
-       regs->e.edx = 0;
        regs->e.esi = buffer_seg;
        regs->e.edi = buffer_adr;
        BE_int86(0x10, regs, regs);
+       if (regs->e.eax != 0x4f) {
+               debug("VESA_GET_MODE_INFO: error %x\n", regs->e.eax);
+               return -ENOSYS;
+       }
+
        memcpy(mode_info->mode_info_block, buffer,
-              sizeof(struct vbe_mode_info));
+               sizeof(struct vesa_mode_info));
        mode_info->valid = true;
+       mode_info->video_mode = vesa_mode;
+       vm = &mode_info->vesa;
+       vm->x_resolution = le16_to_cpu(vm->x_resolution);
+       vm->y_resolution = le16_to_cpu(vm->y_resolution);
+       vm->bytes_per_scanline = le16_to_cpu(vm->bytes_per_scanline);
+       vm->phys_base_ptr = le32_to_cpu(vm->phys_base_ptr);
+       vm->mode_attributes = le16_to_cpu(vm->mode_attributes);
+       debug("VBE: Init complete\n");
 
-       vesa_mode |= (1 << 14);
-       /* request clearing of framebuffer */
-       vesa_mode &= ~(1 << 15);
-       regs->e.eax = VESA_SET_MODE;
-       regs->e.ebx = vesa_mode;
-       BE_int86(0x10, regs, regs);
+       return 0;
 }
 
 /****************************************************************************
@@ -132,6 +250,9 @@ static void PCI_doBIOSPOST(pci_dev_t pcidev, BE_VGAInfo *vga_info,
        /*Cleanup and exit*/
        BE_getVGA(vga_info);
 
+       /* Useful for debugging */
+       if (0)
+               atibios_debug_mode(vga_info, &regs, vesa_mode, mode_info);
        if (vesa_mode != -1)
                atibios_set_vesa_mode(&regs, vesa_mode, mode_info);
 }
index 304b2bf007095aa8a926965c73d1e4dabcfd86d3..4962a2acaf1ca8f4394a4f538c7d5d012e78c101 100644 (file)
 # define ERR_PRINTF(x)         printf(x)
 # define ERR_PRINTF2(x, y)     printf(x, y)
 
-#ifdef CONFIG_X86EMU_DEBUG103
+#ifdef CONFIG_X86EMU_DEBUG
 
 
 # define DECODE_PRINTF(x)      if (DEBUG_DECODE()) \
index 2bb5e2d9d508112124275397cd48d41e3fc845fc..5752fee1cdac80369090fe0cc1cf8d58234a7866 100644 (file)
@@ -179,7 +179,7 @@ void x86emuOp_illegal_op(
 {
     START_OF_INSTR();
     if (M.x86.R_SP != 0) {
-       ERR_PRINTF("ILLEGAL X86 OPCODE\n");
+       DB(printf("ILLEGAL X86 OPCODE\n"));
        TRACE_REGS();
        DB( printk("%04x:%04x: %02X ILLEGAL X86 OPCODE!\n",
            M.x86.R_CS, M.x86.R_IP-1,op1));
index 37d2d2a28eef53bbd2477b7bb06b37f415e68735..c908fab4506e5c6400dc91150cbc23234c0ed9e3 100644 (file)
@@ -513,6 +513,20 @@ static void ahci_set_feature(u8 port)
 }
 #endif
 
+static int wait_spinup(volatile u8 *port_mmio)
+{
+       ulong start;
+       u32 tf_data;
+
+       start = get_timer(0);
+       do {
+               tf_data = readl(port_mmio + PORT_TFDATA);
+               if (!(tf_data & ATA_BUSY))
+                       return 0;
+       } while (get_timer(start) < WAIT_MS_SPINUP);
+
+       return -ETIMEDOUT;
+}
 
 static int ahci_port_start(u8 port)
 {
@@ -579,7 +593,11 @@ static int ahci_port_start(u8 port)
 
        debug("Exit start port %d\n", port);
 
-       return 0;
+       /*
+        * Make sure interface is not busy based on error and status
+        * information from task file data register before proceeding
+        */
+       return wait_spinup(port_mmio);
 }
 
 
index 8fc6b7108427add4a2f8f3a1047eee7e5e440073..3a5f48df7a27511a5bf9231e547360f11facdd7b 100644 (file)
@@ -88,6 +88,14 @@ int device_unbind(struct udevice *dev)
        if (ret)
                return ret;
 
+       if (dev->flags & DM_FLAG_ALLOC_PDATA) {
+               free(dev->platdata);
+               dev->platdata = NULL;
+       }
+       if (dev->flags & DM_FLAG_ALLOC_PARENT_PDATA) {
+               free(dev->parent_platdata);
+               dev->parent_platdata = NULL;
+       }
        ret = uclass_unbind_device(dev);
        if (ret)
                return ret;
@@ -111,10 +119,6 @@ void device_free(struct udevice *dev)
                free(dev->priv);
                dev->priv = NULL;
        }
-       if (dev->flags & DM_FLAG_ALLOC_PDATA) {
-               free(dev->platdata);
-               dev->platdata = NULL;
-       }
        size = dev->uclass->uc_drv->per_device_auto_alloc_size;
        if (size) {
                free(dev->uclass_priv);
@@ -122,6 +126,10 @@ void device_free(struct udevice *dev)
        }
        if (dev->parent) {
                size = dev->parent->driver->per_child_auto_alloc_size;
+               if (!size) {
+                       size = dev->parent->uclass->uc_drv->
+                                       per_child_auto_alloc_size;
+               }
                if (size) {
                        free(dev->parent_priv);
                        dev->parent_priv = NULL;
index 963b16f26f0dc015a7f676891e0d845b42ec6594..b73d3b8961de337c1ec871d3d4ed2c1b24285e59 100644 (file)
@@ -53,27 +53,47 @@ int device_bind(struct udevice *parent, struct driver *drv, const char *name,
        dev->driver = drv;
        dev->uclass = uc;
 
-       /*
-        * For some devices, such as a SPI or I2C bus, the 'reg' property
-        * is a reasonable indicator of the sequence number. But if there is
-        * an alias, we use that in preference. In any case, this is just
-        * a 'requested' sequence, and will be resolved (and ->seq updated)
-        * when the device is probed.
-        */
        dev->seq = -1;
+       dev->req_seq = -1;
 #ifdef CONFIG_OF_CONTROL
-       dev->req_seq = fdtdec_get_int(gd->fdt_blob, of_offset, "reg", -1);
-       if (!IS_ERR_VALUE(dev->req_seq))
-               dev->req_seq &= INT_MAX;
-       if (uc->uc_drv->name && of_offset != -1) {
-               fdtdec_get_alias_seq(gd->fdt_blob, uc->uc_drv->name, of_offset,
-                                    &dev->req_seq);
+       /*
+        * Some devices, such as a SPI bus, I2C bus and serial ports are
+        * numbered using aliases.
+        *
+        * This is just a 'requested' sequence, and will be
+        * resolved (and ->seq updated) when the device is probed.
+        */
+       if (uc->uc_drv->flags & DM_UC_FLAG_SEQ_ALIAS) {
+               if (uc->uc_drv->name && of_offset != -1) {
+                       fdtdec_get_alias_seq(gd->fdt_blob, uc->uc_drv->name,
+                                            of_offset, &dev->req_seq);
+               }
        }
-#else
-       dev->req_seq = -1;
 #endif
-       if (!dev->platdata && drv->platdata_auto_alloc_size)
+       if (!dev->platdata && drv->platdata_auto_alloc_size) {
                dev->flags |= DM_FLAG_ALLOC_PDATA;
+               dev->platdata = calloc(1, drv->platdata_auto_alloc_size);
+               if (!dev->platdata) {
+                       ret = -ENOMEM;
+                       goto fail_alloc1;
+               }
+       }
+       if (parent) {
+               int size = parent->driver->per_child_platdata_auto_alloc_size;
+
+               if (!size) {
+                       size = parent->uclass->uc_drv->
+                                       per_child_platdata_auto_alloc_size;
+               }
+               if (size) {
+                       dev->flags |= DM_FLAG_ALLOC_PARENT_PDATA;
+                       dev->parent_platdata = calloc(1, size);
+                       if (!dev->parent_platdata) {
+                               ret = -ENOMEM;
+                               goto fail_alloc2;
+                       }
+               }
+       }
 
        /* put dev into parent's successor list */
        if (parent)
@@ -81,28 +101,51 @@ int device_bind(struct udevice *parent, struct driver *drv, const char *name,
 
        ret = uclass_bind_device(dev);
        if (ret)
-               goto fail_bind;
+               goto fail_uclass_bind;
 
        /* if we fail to bind we remove device from successors and free it */
        if (drv->bind) {
                ret = drv->bind(dev);
-               if (ret) {
-                       if (uclass_unbind_device(dev)) {
-                               dm_warn("Failed to unbind dev '%s' on error path\n",
-                                       dev->name);
-                       }
+               if (ret)
                        goto fail_bind;
-               }
        }
+       if (parent && parent->driver->child_post_bind) {
+               ret = parent->driver->child_post_bind(dev);
+               if (ret)
+                       goto fail_child_post_bind;
+       }
+
        if (parent)
                dm_dbg("Bound device %s to %s\n", dev->name, parent->name);
        *devp = dev;
 
        return 0;
 
+fail_child_post_bind:
+       if (drv->unbind && drv->unbind(dev)) {
+               dm_warn("unbind() method failed on dev '%s' on error path\n",
+                       dev->name);
+       }
+
 fail_bind:
+       if (uclass_unbind_device(dev)) {
+               dm_warn("Failed to unbind dev '%s' on error path\n",
+                       dev->name);
+       }
+fail_uclass_bind:
        list_del(&dev->sibling_node);
+       if (dev->flags & DM_FLAG_ALLOC_PARENT_PDATA) {
+               free(dev->parent_platdata);
+               dev->parent_platdata = NULL;
+       }
+fail_alloc2:
+       if (dev->flags & DM_FLAG_ALLOC_PDATA) {
+               free(dev->platdata);
+               dev->platdata = NULL;
+       }
+fail_alloc1:
        free(dev);
+
        return ret;
 }
 
@@ -137,7 +180,7 @@ int device_probe_child(struct udevice *dev, void *parent_priv)
        drv = dev->driver;
        assert(drv);
 
-       /* Allocate private data and platdata if requested */
+       /* Allocate private data if requested */
        if (drv->priv_auto_alloc_size) {
                dev->priv = calloc(1, drv->priv_auto_alloc_size);
                if (!dev->priv) {
@@ -146,13 +189,6 @@ int device_probe_child(struct udevice *dev, void *parent_priv)
                }
        }
        /* Allocate private data if requested */
-       if (dev->flags & DM_FLAG_ALLOC_PDATA) {
-               dev->platdata = calloc(1, drv->platdata_auto_alloc_size);
-               if (!dev->platdata) {
-                       ret = -ENOMEM;
-                       goto fail;
-               }
-       }
        size = dev->uclass->uc_drv->per_device_auto_alloc_size;
        if (size) {
                dev->uclass_priv = calloc(1, size);
@@ -165,6 +201,10 @@ int device_probe_child(struct udevice *dev, void *parent_priv)
        /* Ensure all parents are probed */
        if (dev->parent) {
                size = dev->parent->driver->per_child_auto_alloc_size;
+               if (!size) {
+                       size = dev->parent->uclass->uc_drv->
+                                       per_child_auto_alloc_size;
+               }
                if (size) {
                        dev->parent_priv = calloc(1, size);
                        if (!dev->parent_priv) {
@@ -187,6 +227,10 @@ int device_probe_child(struct udevice *dev, void *parent_priv)
        }
        dev->seq = seq;
 
+       ret = uclass_pre_probe_child(dev);
+       if (ret)
+               goto fail;
+
        if (dev->parent && dev->parent->driver->child_pre_probe) {
                ret = dev->parent->driver->child_pre_probe(dev);
                if (ret)
@@ -241,6 +285,16 @@ void *dev_get_platdata(struct udevice *dev)
        return dev->platdata;
 }
 
+void *dev_get_parent_platdata(struct udevice *dev)
+{
+       if (!dev) {
+               dm_warn("%s: null device", __func__);
+               return NULL;
+       }
+
+       return dev->parent_platdata;
+}
+
 void *dev_get_priv(struct udevice *dev)
 {
        if (!dev) {
@@ -390,3 +444,8 @@ ulong dev_get_of_data(struct udevice *dev)
 {
        return dev->of_id->data;
 }
+
+enum uclass_id device_get_uclass_id(struct udevice *dev)
+{
+       return dev->uclass->uc_drv->id;
+}
index 47b3acfbe981da9fcfe5ca6d7c20e60dd63b0285..73e3c7228e300e67da317098160d9c9c988446b3 100644 (file)
@@ -9,6 +9,7 @@
 
 #include <common.h>
 #include <errno.h>
+#include <fdtdec.h>
 #include <malloc.h>
 #include <libfdt.h>
 #include <dm/device.h>
@@ -49,6 +50,9 @@ int dm_init(void)
        ret = device_bind_by_name(NULL, false, &root_info, &DM_ROOT_NON_CONST);
        if (ret)
                return ret;
+#ifdef CONFIG_OF_CONTROL
+       DM_ROOT_NON_CONST->of_offset = 0;
+#endif
        ret = device_probe(DM_ROOT_NON_CONST);
        if (ret)
                return ret;
@@ -89,6 +93,10 @@ int dm_scan_fdt_node(struct udevice *parent, const void *blob, int offset,
                if (pre_reloc_only &&
                    !fdt_getprop(blob, offset, "u-boot,dm-pre-reloc", NULL))
                        continue;
+               if (!fdtdec_get_is_enabled(blob, offset)) {
+                       dm_dbg("   - ignoring disabled device\n");
+                       continue;
+               }
                err = lists_bind_fdt(parent, blob, offset, NULL);
                if (err && !ret)
                        ret = err;
index 901b06ed2baaf5f4b0cbdb71d3ca40170de33991..289a5d2d53dfc7af75c19cc1dcc21aa88e8cd0cf 100644 (file)
@@ -319,18 +319,29 @@ int uclass_bind_device(struct udevice *dev)
        int ret;
 
        uc = dev->uclass;
-
        list_add_tail(&dev->uclass_node, &uc->dev_head);
 
+       if (dev->parent) {
+               struct uclass_driver *uc_drv = dev->parent->uclass->uc_drv;
+
+               if (uc_drv->child_post_bind) {
+                       ret = uc_drv->child_post_bind(dev);
+                       if (ret)
+                               goto err;
+               }
+       }
        if (uc->uc_drv->post_bind) {
                ret = uc->uc_drv->post_bind(dev);
-               if (ret) {
-                       list_del(&dev->uclass_node);
-                       return ret;
-               }
+               if (ret)
+                       goto err;
        }
 
        return 0;
+err:
+       /* There is no need to undo the parent's post_bind call */
+       list_del(&dev->uclass_node);
+
+       return ret;
 }
 
 int uclass_unbind_device(struct udevice *dev)
@@ -380,6 +391,19 @@ int uclass_resolve_seq(struct udevice *dev)
        return seq;
 }
 
+int uclass_pre_probe_child(struct udevice *dev)
+{
+       struct uclass_driver *uc_drv;
+
+       if (!dev->parent)
+               return 0;
+       uc_drv = dev->parent->uclass->uc_drv;
+       if (uc_drv->child_pre_probe)
+               return uc_drv->child_pre_probe(dev);
+
+       return 0;
+}
+
 int uclass_post_probe_device(struct udevice *dev)
 {
        struct uclass_driver *uc_drv = dev->uclass->uc_drv;
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..bd26a2bcfa286d9fd6b80b60cbd7ee9cc4c63ac8 100644 (file)
@@ -0,0 +1 @@
+source drivers/crypto/fsl/Kconfig
index 7b792371811eb37e7dadcf39310e65f955237678..fb8c10b38c2fd4537a1fa94dfc75faf737b5cfef 100644 (file)
@@ -6,4 +6,5 @@
 #
 
 obj-$(CONFIG_EXYNOS_ACE_SHA)   += ace_sha.o
+obj-y += rsa_mod_exp/
 obj-y += fsl/
diff --git a/drivers/crypto/fsl/Kconfig b/drivers/crypto/fsl/Kconfig
new file mode 100644 (file)
index 0000000..86b2f2f
--- /dev/null
@@ -0,0 +1,6 @@
+config FSL_CAAM
+       bool "Freescale Crypto Driver Support"
+       help
+         Enables the Freescale's Cryptographic Accelerator and Assurance
+         Module (CAAM), also known as the SEC version 4 (SEC4). The driver uses
+         Job Ring as interface to communicate with CAAM.
index cb13d2e0ae65c6c80009730890448a12681e14eb..c0cf64229ebe513688c6a85e61dac16689cdcb83 100644 (file)
@@ -6,5 +6,7 @@
 # Version 2 as published by the Free Software Foundation.
 #
 
+obj-y += sec.o
 obj-$(CONFIG_FSL_CAAM) += jr.o fsl_hash.o jobdesc.o error.o
 obj-$(CONFIG_CMD_BLOB) += fsl_blob.o
+obj-$(CONFIG_RSA_FREESCALE_EXP) += fsl_rsa.o
diff --git a/drivers/crypto/fsl/fsl_rsa.c b/drivers/crypto/fsl/fsl_rsa.c
new file mode 100644 (file)
index 0000000..cf1c4c1
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * (C) Copyright 2014 Freescale Semiconductor, Inc.
+ * Author: Ruchika Gupta <ruchika.gupta@freescale.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <config.h>
+#include <common.h>
+#include <dm.h>
+#include <asm/types.h>
+#include <malloc.h>
+#include "jobdesc.h"
+#include "desc.h"
+#include "jr.h"
+#include "rsa_caam.h"
+#include <u-boot/rsa-mod-exp.h>
+
+int fsl_mod_exp(struct udevice *dev, const uint8_t *sig, uint32_t sig_len,
+               struct key_prop *prop, uint8_t *out)
+{
+       uint32_t keylen;
+       struct pk_in_params pkin;
+       uint32_t desc[MAX_CAAM_DESCSIZE];
+       int ret;
+
+       /* Length in bytes */
+       keylen = prop->num_bits / 8;
+
+       pkin.a = sig;
+       pkin.a_siz = sig_len;
+       pkin.n = prop->modulus;
+       pkin.n_siz = keylen;
+       pkin.e = prop->public_exponent;
+       pkin.e_siz = prop->exp_len;
+
+       inline_cnstr_jobdesc_pkha_rsaexp(desc, &pkin, out, sig_len);
+
+       ret = run_descriptor_jr(desc);
+       if (ret) {
+               debug("%s: RSA failed to verify: %d\n", __func__, ret);
+               return -EFAULT;
+       }
+
+       return 0;
+}
+
+static const struct mod_exp_ops fsl_mod_exp_ops = {
+       .mod_exp        = fsl_mod_exp,
+};
+
+U_BOOT_DRIVER(fsl_rsa_mod_exp) = {
+       .name   = "fsl_rsa_mod_exp",
+       .id     = UCLASS_MOD_EXP,
+       .ops    = &fsl_mod_exp_ops,
+};
+
+U_BOOT_DEVICE(fsl_rsa) = {
+       .name = "fsl_rsa_mod_exp",
+};
index 1386baec0fda45a54e7d9664a92cef90d3c6e150..cc0dcede7b787ed19cd815a2b73a18a5334f75cb 100644 (file)
@@ -11,6 +11,7 @@
 #include <common.h>
 #include "desc_constr.h"
 #include "jobdesc.h"
+#include "rsa_caam.h"
 
 #define KEY_BLOB_SIZE                  32
 #define MAC_SIZE                       16
@@ -123,3 +124,30 @@ void inline_cnstr_jobdesc_rng_instantiation(uint32_t *desc)
        append_operation(desc, OP_TYPE_CLASS1_ALG | OP_ALG_ALGSEL_RNG |
                         OP_ALG_RNG4_SK);
 }
+
+/* Change key size to bytes form bits in calling function*/
+void inline_cnstr_jobdesc_pkha_rsaexp(uint32_t *desc,
+                                     struct pk_in_params *pkin, uint8_t *out,
+                                     uint32_t out_siz)
+{
+       dma_addr_t dma_addr_e, dma_addr_a, dma_addr_n, dma_addr_out;
+
+       dma_addr_e = virt_to_phys((void *)pkin->e);
+       dma_addr_a = virt_to_phys((void *)pkin->a);
+       dma_addr_n = virt_to_phys((void *)pkin->n);
+       dma_addr_out = virt_to_phys((void *)out);
+
+       init_job_desc(desc, 0);
+       append_key(desc, dma_addr_e, pkin->e_siz, KEY_DEST_PKHA_E | CLASS_1);
+
+       append_fifo_load(desc, dma_addr_a,
+                        pkin->a_siz, LDST_CLASS_1_CCB | FIFOLD_TYPE_PK_A);
+
+       append_fifo_load(desc, dma_addr_n,
+                        pkin->n_siz, LDST_CLASS_1_CCB | FIFOLD_TYPE_PK_N);
+
+       append_operation(desc, OP_TYPE_PK | OP_ALG_PK | OP_ALG_PKMODE_MOD_EXPO);
+
+       append_fifo_store(desc, dma_addr_out, out_siz,
+                         LDST_CLASS_1_CCB | FIFOST_TYPE_PKHA_B);
+}
index 3cf7226de23b7d47ebfa8d7f4aad2a4af9eb40e5..84b3edd6e2f9ab5ad4b49e1da105143fc654400e 100644 (file)
@@ -10,6 +10,7 @@
 
 #include <common.h>
 #include <asm/io.h>
+#include "rsa_caam.h"
 
 #define KEY_IDNFR_SZ_BYTES             16
 
@@ -26,4 +27,8 @@ void inline_cnstr_jobdesc_blob_decap(uint32_t *desc, uint8_t *key_idnfr,
                                     uint32_t out_sz);
 
 void inline_cnstr_jobdesc_rng_instantiation(uint32_t *desc);
+
+void inline_cnstr_jobdesc_pkha_rsaexp(uint32_t *desc,
+                                     struct pk_in_params *pkin, uint8_t *out,
+                                     uint32_t out_siz);
 #endif
diff --git a/drivers/crypto/fsl/rsa_caam.h b/drivers/crypto/fsl/rsa_caam.h
new file mode 100644 (file)
index 0000000..4ff87ef
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2014 Freescale Semiconductor, Inc.
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#ifndef __RSA_CAAM_H
+#define __RSA_CAAM_H
+
+#include <common.h>
+
+/**
+ * struct pk_in_params - holder for input to PKHA block in CAAM
+ * These parameters are required to perform Modular Exponentiation
+ * using PKHA Block in CAAM
+ */
+struct pk_in_params {
+       const uint8_t *e;       /* public exponent as byte array */
+       uint32_t e_siz;         /* size of e[] in number of bytes */
+       const uint8_t *n;       /* modulus as byte array */
+       uint32_t n_siz;         /* size of n[] in number of bytes */
+       const uint8_t *a;               /* Signature as byte array */
+       uint32_t a_siz;         /* size of a[] in number of bytes */
+       uint8_t *b;             /* Result exp. modulus in number of bytes */
+       uint32_t b_siz;         /* size of b[] in number of bytes */
+};
+
+#endif
diff --git a/drivers/crypto/fsl/sec.c b/drivers/crypto/fsl/sec.c
new file mode 100644 (file)
index 0000000..443ee96
--- /dev/null
@@ -0,0 +1,184 @@
+/*
+ * Copyright 2014 Freescale Semiconductor, Inc.
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <common.h>
+#include <libfdt.h>
+#include <fdt_support.h>
+#if CONFIG_SYS_FSL_SEC_COMPAT == 2 || CONFIG_SYS_FSL_SEC_COMPAT >= 4
+#include <fsl_sec.h>
+#endif
+
+/*
+ * update crypto node properties to a specified revision of the SEC
+ * called with sec_rev == 0 if not on an E processor
+ */
+#if CONFIG_SYS_FSL_SEC_COMPAT == 2 /* SEC 2.x/3.x */
+void fdt_fixup_crypto_node(void *blob, int sec_rev)
+{
+       static const struct sec_rev_prop {
+               u32 sec_rev;
+               u32 num_channels;
+               u32 channel_fifo_len;
+               u32 exec_units_mask;
+               u32 descriptor_types_mask;
+       } sec_rev_prop_list[] = {
+               { 0x0200, 4, 24, 0x07e, 0x01010ebf }, /* SEC 2.0 */
+               { 0x0201, 4, 24, 0x0fe, 0x012b0ebf }, /* SEC 2.1 */
+               { 0x0202, 1, 24, 0x04c, 0x0122003f }, /* SEC 2.2 */
+               { 0x0204, 4, 24, 0x07e, 0x012b0ebf }, /* SEC 2.4 */
+               { 0x0300, 4, 24, 0x9fe, 0x03ab0ebf }, /* SEC 3.0 */
+               { 0x0301, 4, 24, 0xbfe, 0x03ab0ebf }, /* SEC 3.1 */
+               { 0x0303, 4, 24, 0x97c, 0x03a30abf }, /* SEC 3.3 */
+       };
+       static char compat_strlist[ARRAY_SIZE(sec_rev_prop_list) *
+                                  sizeof("fsl,secX.Y")];
+       int crypto_node, sec_idx, err;
+       char *p;
+       u32 val;
+
+       /* locate crypto node based on lowest common compatible */
+       crypto_node = fdt_node_offset_by_compatible(blob, -1, "fsl,sec2.0");
+       if (crypto_node == -FDT_ERR_NOTFOUND)
+               return;
+
+       /* delete it if not on an E-processor */
+       if (crypto_node > 0 && !sec_rev) {
+               fdt_del_node(blob, crypto_node);
+               return;
+       }
+
+       /* else we got called for possible uprev */
+       for (sec_idx = 0; sec_idx < ARRAY_SIZE(sec_rev_prop_list); sec_idx++)
+               if (sec_rev_prop_list[sec_idx].sec_rev == sec_rev)
+                       break;
+
+       if (sec_idx == ARRAY_SIZE(sec_rev_prop_list)) {
+               puts("warning: unknown SEC revision number\n");
+               return;
+       }
+
+       val = cpu_to_fdt32(sec_rev_prop_list[sec_idx].num_channels);
+       err = fdt_setprop(blob, crypto_node, "fsl,num-channels", &val, 4);
+       if (err < 0)
+               printf("WARNING: could not set crypto property: %s\n",
+                      fdt_strerror(err));
+
+       val = cpu_to_fdt32(sec_rev_prop_list[sec_idx].descriptor_types_mask);
+       err = fdt_setprop(blob, crypto_node, "fsl,descriptor-types-mask",
+                         &val, 4);
+       if (err < 0)
+               printf("WARNING: could not set crypto property: %s\n",
+                      fdt_strerror(err));
+
+       val = cpu_to_fdt32(sec_rev_prop_list[sec_idx].exec_units_mask);
+       err = fdt_setprop(blob, crypto_node, "fsl,exec-units-mask", &val, 4);
+       if (err < 0)
+               printf("WARNING: could not set crypto property: %s\n",
+                      fdt_strerror(err));
+
+       val = cpu_to_fdt32(sec_rev_prop_list[sec_idx].channel_fifo_len);
+       err = fdt_setprop(blob, crypto_node, "fsl,channel-fifo-len", &val, 4);
+       if (err < 0)
+               printf("WARNING: could not set crypto property: %s\n",
+                      fdt_strerror(err));
+
+       val = 0;
+       while (sec_idx >= 0) {
+               p = compat_strlist + val;
+               val += sprintf(p, "fsl,sec%d.%d",
+                       (sec_rev_prop_list[sec_idx].sec_rev & 0xff00) >> 8,
+                       sec_rev_prop_list[sec_idx].sec_rev & 0x00ff) + 1;
+               sec_idx--;
+       }
+       err = fdt_setprop(blob, crypto_node, "compatible", &compat_strlist,
+                         val);
+       if (err < 0)
+               printf("WARNING: could not set crypto property: %s\n",
+                      fdt_strerror(err));
+}
+#elif CONFIG_SYS_FSL_SEC_COMPAT >= 4  /* SEC4 */
+static u8 caam_get_era(void)
+{
+       static const struct {
+               u16 ip_id;
+               u8 maj_rev;
+               u8 era;
+       } caam_eras[] = {
+               {0x0A10, 1, 1},
+               {0x0A10, 2, 2},
+               {0x0A12, 1, 3},
+               {0x0A14, 1, 3},
+               {0x0A14, 2, 4},
+               {0x0A16, 1, 4},
+               {0x0A10, 3, 4},
+               {0x0A11, 1, 4},
+               {0x0A18, 1, 4},
+               {0x0A11, 2, 5},
+               {0x0A12, 2, 5},
+               {0x0A13, 1, 5},
+               {0x0A1C, 1, 5}
+       };
+
+       ccsr_sec_t __iomem *sec = (void __iomem *)CONFIG_SYS_FSL_SEC_ADDR;
+       u32 secvid_ms = sec_in32(&sec->secvid_ms);
+       u32 ccbvid = sec_in32(&sec->ccbvid);
+       u16 ip_id = (secvid_ms & SEC_SECVID_MS_IPID_MASK) >>
+                               SEC_SECVID_MS_IPID_SHIFT;
+       u8 maj_rev = (secvid_ms & SEC_SECVID_MS_MAJ_REV_MASK) >>
+                               SEC_SECVID_MS_MAJ_REV_SHIFT;
+       u8 era = (ccbvid & SEC_CCBVID_ERA_MASK) >> SEC_CCBVID_ERA_SHIFT;
+
+       int i;
+
+       if (era)        /* This is '0' prior to CAAM ERA-6 */
+               return era;
+
+       for (i = 0; i < ARRAY_SIZE(caam_eras); i++)
+               if (caam_eras[i].ip_id == ip_id &&
+                   caam_eras[i].maj_rev == maj_rev)
+                       return caam_eras[i].era;
+
+       return 0;
+}
+
+static void fdt_fixup_crypto_era(void *blob, u32 era)
+{
+       int err;
+       int crypto_node;
+
+       crypto_node = fdt_path_offset(blob, "crypto");
+       if (crypto_node < 0) {
+               printf("WARNING: Missing crypto node\n");
+               return;
+       }
+
+       err = fdt_setprop(blob, crypto_node, "fsl,sec-era", &era,
+                         sizeof(era));
+       if (err < 0) {
+               printf("ERROR: could not set fsl,sec-era property: %s\n",
+                      fdt_strerror(err));
+       }
+}
+
+void fdt_fixup_crypto_node(void *blob, int sec_rev)
+{
+       u8 era;
+
+       if (!sec_rev) {
+               fdt_del_node_and_alias(blob, "crypto");
+               return;
+       }
+
+       /* Add SEC ERA information in compatible */
+       era = caam_get_era();
+       if (era) {
+               fdt_fixup_crypto_era(blob, era);
+       } else {
+               printf("WARNING: Unable to get ERA for CAAM rev: %d\n",
+                      sec_rev);
+       }
+}
+#endif
diff --git a/drivers/crypto/rsa_mod_exp/Kconfig b/drivers/crypto/rsa_mod_exp/Kconfig
new file mode 100644 (file)
index 0000000..6dcb39a
--- /dev/null
@@ -0,0 +1,5 @@
+config DM_MOD_EXP
+       bool "Enable Driver Model for RSA Modular Exponentiation"
+       depends on DM
+       help
+         If you want to use driver model for RSA Modular Exponentiation, say Y.
diff --git a/drivers/crypto/rsa_mod_exp/Makefile b/drivers/crypto/rsa_mod_exp/Makefile
new file mode 100644 (file)
index 0000000..915b751
--- /dev/null
@@ -0,0 +1,7 @@
+#
+# (C) Copyright 2014 Freescale Semiconductor, Inc.
+#
+# SPDX-License-Identifier:     GPL-2.0+
+#
+
+obj-$(CONFIG_RSA) += mod_exp_uclass.o mod_exp_sw.o
diff --git a/drivers/crypto/rsa_mod_exp/mod_exp_sw.c b/drivers/crypto/rsa_mod_exp/mod_exp_sw.c
new file mode 100644 (file)
index 0000000..dc6c064
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * (C) Copyright 2014 Freescale Semiconductor, Inc.
+ * Author: Ruchika Gupta <ruchika.gupta@freescale.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <config.h>
+#include <common.h>
+#include <dm.h>
+#include <u-boot/rsa-mod-exp.h>
+
+int mod_exp_sw(struct udevice *dev, const uint8_t *sig, uint32_t sig_len,
+               struct key_prop *prop, uint8_t *out)
+{
+       int ret = 0;
+
+       ret = rsa_mod_exp_sw(sig, sig_len, prop, out);
+       if (ret) {
+               debug("%s: RSA failed to verify: %d\n", __func__, ret);
+               return ret;
+       }
+
+       return 0;
+}
+
+static const struct mod_exp_ops mod_exp_ops_sw = {
+       .mod_exp        = mod_exp_sw,
+};
+
+U_BOOT_DRIVER(mod_exp_sw) = {
+       .name   = "mod_exp_sw",
+       .id     = UCLASS_MOD_EXP,
+       .ops    = &mod_exp_ops_sw,
+};
+
+U_BOOT_DEVICE(mod_exp_sw) = {
+       .name = "mod_exp_sw",
+};
diff --git a/drivers/crypto/rsa_mod_exp/mod_exp_uclass.c b/drivers/crypto/rsa_mod_exp/mod_exp_uclass.c
new file mode 100644 (file)
index 0000000..266f094
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * (C) Copyright 2014 Freescale Semiconductor, Inc
+ * Author: Ruchika Gupta <ruchika.gupta@freescale.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <u-boot/rsa-mod-exp.h>
+#include <errno.h>
+#include <fdtdec.h>
+#include <malloc.h>
+#include <asm/io.h>
+#include <linux/list.h>
+
+int rsa_mod_exp(struct udevice *dev, const uint8_t *sig, uint32_t sig_len,
+               struct key_prop *node, uint8_t *out)
+{
+       const struct mod_exp_ops *ops = device_get_ops(dev);
+
+       if (!ops->mod_exp)
+               return -ENOSYS;
+
+       return ops->mod_exp(dev, sig, sig_len, node, out);
+}
+
+UCLASS_DRIVER(mod_exp) = {
+       .id             = UCLASS_MOD_EXP,
+       .name           = "rsa_mod_exp",
+};
index a3c01e7f1e2ffa5e977a9d8c3b77c6d033467b44..4eef0473439a98028395d7403fa8980eb21e8ed0 100644 (file)
@@ -171,6 +171,14 @@ void fsl_ddr_set_memctl_regs(const fsl_ddr_cfg_regs_t *regs,
                        ddr_out32(&ddr->debug[i], regs->debug[i]);
                }
        }
+#ifdef CONFIG_SYS_FSL_ERRATUM_A008378
+       /* Erratum applies when accumulated ECC is used, or DBI is enabled */
+#define IS_ACC_ECC_EN(v) ((v) & 0x4)
+#define IS_DBI(v) ((((v) >> 12) & 0x3) == 0x2)
+       if (IS_ACC_ECC_EN(regs->ddr_sdram_cfg) ||
+           IS_DBI(regs->ddr_sdram_cfg_3))
+               ddr_setbits32(ddr->debug[28], 0x9 << 20);
+#endif
 
        /*
         * For RDIMMs, JEDEC spec requires clocks to be stable before reset is
diff --git a/drivers/ddr/mvebu/Makefile b/drivers/ddr/mvebu/Makefile
new file mode 100644 (file)
index 0000000..50a69ea
--- /dev/null
@@ -0,0 +1,14 @@
+#
+# SPDX-License-Identifier:     GPL-2.0+
+#
+
+obj-$(CONFIG_SPL_BUILD) += ddr3_dfs.o
+obj-$(CONFIG_SPL_BUILD) += ddr3_dqs.o
+obj-$(CONFIG_SPL_BUILD) += ddr3_hw_training.o
+obj-$(CONFIG_SPL_BUILD) += ddr3_init.o
+obj-$(CONFIG_SPL_BUILD) += ddr3_pbs.o
+obj-$(CONFIG_SPL_BUILD) += ddr3_read_leveling.o
+obj-$(CONFIG_SPL_BUILD) += ddr3_sdram.o
+obj-$(CONFIG_SPL_BUILD) += ddr3_spd.o
+obj-$(CONFIG_SPL_BUILD) += ddr3_write_leveling.o
+obj-$(CONFIG_SPL_BUILD) += xor.o
diff --git a/drivers/ddr/mvebu/ddr3_axp.h b/drivers/ddr/mvebu/ddr3_axp.h
new file mode 100644 (file)
index 0000000..bf65f6b
--- /dev/null
@@ -0,0 +1,510 @@
+/*
+ * Copyright (C) Marvell International Ltd. and its affiliates
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#ifndef __DDR3_AXP_H
+#define __DDR3_AXP_H
+
+#define MV_78XX0_Z1_REV                        0x0
+#define MV_78XX0_A0_REV                        0x1
+#define MV_78XX0_B0_REV                        0x2
+
+#define SAR_DDR3_FREQ_MASK             0xFE00000
+#define SAR_CPU_FAB_GET(cpu, fab)      (((cpu & 0x7) << 21) | ((fab & 0xF) << 24))
+
+#define MAX_CS                         4
+
+#define MIN_DIMM_ADDR                  0x50
+#define FAR_END_DIMM_ADDR              0x50
+#define MAX_DIMM_ADDR                  0x60
+
+#ifndef CONFIG_DDR_FIXED_SIZE
+#define SDRAM_CS_SIZE                  0xFFFFFFF
+#else
+#define SDRAM_CS_SIZE                  (CONFIG_DDR_FIXED_SIZE - 1)
+#endif
+#define SDRAM_CS_BASE                  0x0
+#define SDRAM_DIMM_SIZE                        0x80000000
+
+#define CPU_CONFIGURATION_REG(id)      (0x21800 + (id * 0x100))
+#define CPU_MRVL_ID_OFFSET             0x10
+#define SAR1_CPU_CORE_MASK             0x00000018
+#define SAR1_CPU_CORE_OFFSET           3
+
+#define ECC_SUPPORT
+#define NEW_FABRIC_TWSI_ADDR           0x4E
+#ifdef DB_784MP_GP
+#define BUS_WIDTH_ECC_TWSI_ADDR                0x4E
+#else
+#define BUS_WIDTH_ECC_TWSI_ADDR                0x4F
+#endif
+#define MV_MAX_DDR3_STATIC_SIZE                50
+#define MV_DDR3_MODES_NUMBER           30
+
+#define RESUME_RL_PATTERNS_ADDR                (0xFE0000)
+#define RESUME_RL_PATTERNS_SIZE                (0x100)
+#define RESUME_TRAINING_VALUES_ADDR    (RESUME_RL_PATTERNS_ADDR + RESUME_RL_PATTERNS_SIZE)
+#define RESUME_TRAINING_VALUES_MAX     (0xCD0)
+#define BOOT_INFO_ADDR                 (RESUME_RL_PATTERNS_ADDR + 0x1000)
+#define CHECKSUM_RESULT_ADDR           (BOOT_INFO_ADDR + 0x1000)
+#define NUM_OF_REGISTER_ADDR           (CHECKSUM_RESULT_ADDR + 4)
+#define SUSPEND_MAGIC_WORD             (0xDEADB002)
+#define REGISTER_LIST_END              (0xFFFFFFFF)
+
+/*
+ * Registers offset
+ */
+
+#define REG_SAMPLE_RESET_LOW_ADDR              0x18230
+#define REG_SAMPLE_RESET_HIGH_ADDR             0x18234
+#define        REG_SAMPLE_RESET_CPU_FREQ_OFFS          21
+#define        REG_SAMPLE_RESET_CPU_FREQ_MASK          0x00E00000
+#define        REG_SAMPLE_RESET_FAB_OFFS               24
+#define        REG_SAMPLE_RESET_FAB_MASK               0xF000000
+#define        REG_SAMPLE_RESET_TCLK_OFFS              28
+#define        REG_SAMPLE_RESET_CPU_ARCH_OFFS          31
+#define        REG_SAMPLE_RESET_HIGH_CPU_FREQ_OFFS     20
+
+/* MISC */
+/*
+ * In mainline U-Boot we're re-configuring the mvebu base address
+ * register to 0xf1000000. So need to use this value for the DDR
+ * training code as well.
+ */
+#define INTER_REGS_BASE                                SOC_REGS_PHY_BASE
+
+/* DDR */
+#define REG_SDRAM_CONFIG_ADDR                  0x1400
+#define REG_SDRAM_CONFIG_MASK                  0x9FFFFFFF
+#define REG_SDRAM_CONFIG_RFRS_MASK             0x3FFF
+#define REG_SDRAM_CONFIG_WIDTH_OFFS            15
+#define REG_SDRAM_CONFIG_REGDIMM_OFFS          17
+#define REG_SDRAM_CONFIG_ECC_OFFS              18
+#define REG_SDRAM_CONFIG_IERR_OFFS             19
+#define REG_SDRAM_CONFIG_PUPRSTDIV_OFFS                28
+#define REG_SDRAM_CONFIG_RSTRD_OFFS            30
+
+#define REG_DUNIT_CTRL_LOW_ADDR                        0x1404
+#define REG_DUNIT_CTRL_LOW_2T_OFFS             3
+#define REG_DUNIT_CTRL_LOW_2T_MASK             0x3
+#define REG_DUNIT_CTRL_LOW_DPDE_OFFS           14
+
+#define REG_SDRAM_TIMING_LOW_ADDR              0x1408
+
+#define REG_SDRAM_TIMING_HIGH_ADDR             0x140C
+#define REG_SDRAM_TIMING_H_R2R_OFFS            7
+#define REG_SDRAM_TIMING_H_R2R_MASK            0x3
+#define REG_SDRAM_TIMING_H_R2W_W2R_OFFS                9
+#define REG_SDRAM_TIMING_H_R2W_W2R_MASK                0x3
+#define REG_SDRAM_TIMING_H_W2W_OFFS            11
+#define REG_SDRAM_TIMING_H_W2W_MASK            0x1F
+#define REG_SDRAM_TIMING_H_R2R_H_OFFS          19
+#define REG_SDRAM_TIMING_H_R2R_H_MASK          0x7
+#define REG_SDRAM_TIMING_H_R2W_W2R_H_OFFS      22
+#define REG_SDRAM_TIMING_H_R2W_W2R_H_MASK      0x7
+
+#define REG_SDRAM_ADDRESS_CTRL_ADDR            0x1410
+#define REG_SDRAM_ADDRESS_SIZE_OFFS            2
+#define REG_SDRAM_ADDRESS_SIZE_HIGH_OFFS       18
+#define REG_SDRAM_ADDRESS_CTRL_STRUCT_OFFS     4
+
+#define REG_SDRAM_OPEN_PAGES_ADDR              0x1414
+#define REG_SDRAM_OPERATION_CS_OFFS            8
+
+#define REG_SDRAM_OPERATION_ADDR               0x1418
+#define REG_SDRAM_OPERATION_CWA_DELAY_SEL_OFFS 24
+#define REG_SDRAM_OPERATION_CWA_DATA_OFFS      20
+#define REG_SDRAM_OPERATION_CWA_DATA_MASK      0xF
+#define REG_SDRAM_OPERATION_CWA_RC_OFFS                16
+#define REG_SDRAM_OPERATION_CWA_RC_MASK                0xF
+#define REG_SDRAM_OPERATION_CMD_MR0            0xF03
+#define REG_SDRAM_OPERATION_CMD_MR1            0xF04
+#define REG_SDRAM_OPERATION_CMD_MR2            0xF08
+#define REG_SDRAM_OPERATION_CMD_MR3            0xF09
+#define REG_SDRAM_OPERATION_CMD_RFRS           0xF02
+#define REG_SDRAM_OPERATION_CMD_CWA            0xF0E
+#define REG_SDRAM_OPERATION_CMD_RFRS_DONE      0xF
+#define REG_SDRAM_OPERATION_CMD_MASK           0xF
+#define REG_SDRAM_OPERATION_CS_OFFS            8
+
+#define REG_OUDDR3_TIMING_ADDR                 0x142C
+
+#define REG_SDRAM_MODE_ADDR                    0x141C
+
+#define REG_SDRAM_EXT_MODE_ADDR                        0x1420
+
+#define REG_DDR_CONT_HIGH_ADDR                 0x1424
+
+#define REG_ODT_TIME_LOW_ADDR                  0x1428
+#define REG_ODT_ON_CTL_RD_OFFS                  12
+#define REG_ODT_OFF_CTL_RD_OFFS                 16
+#define REG_SDRAM_ERROR_ADDR                   0x1454
+#define REG_SDRAM_AUTO_PWR_SAVE_ADDR           0x1474
+#define REG_ODT_TIME_HIGH_ADDR                 0x147C
+
+#define REG_SDRAM_INIT_CTRL_ADDR               0x1480
+#define REG_SDRAM_INIT_CTRL_OFFS               0
+#define REG_SDRAM_INIT_CKE_ASSERT_OFFS         2
+#define REG_SDRAM_INIT_RESET_DEASSERT_OFFS     3
+
+#define REG_SDRAM_ODT_CTRL_LOW_ADDR            0x1494
+
+#define REG_SDRAM_ODT_CTRL_HIGH_ADDR           0x1498
+/*#define REG_SDRAM_ODT_CTRL_HIGH_OVRD_MASK    0xFFFFFF55 */
+#define REG_SDRAM_ODT_CTRL_HIGH_OVRD_MASK      0x0
+#define REG_SDRAM_ODT_CTRL_HIGH_OVRD_ENA       0x3
+
+#define REG_DUNIT_ODT_CTRL_ADDR                        0x149C
+#define REG_DUNIT_ODT_CTRL_OVRD_OFFS            8
+#define REG_DUNIT_ODT_CTRL_OVRD_VAL_OFFS        9
+
+#define REG_DRAM_FIFO_CTRL_ADDR                        0x14A0
+
+#define REG_DRAM_AXI_CTRL_ADDR                 0x14A8
+#define REG_DRAM_AXI_CTRL_AXIDATABUSWIDTH_OFFS 0
+
+#define REG_METAL_MASK_ADDR                    0x14B0
+#define REG_METAL_MASK_MASK                    0xDFFFFFFF
+#define REG_METAL_MASK_RETRY_OFFS              0
+
+#define REG_DRAM_ADDR_CTRL_DRIVE_STRENGTH_ADDR 0x14C0
+
+#define REG_DRAM_DATA_DQS_DRIVE_STRENGTH_ADDR  0x14C4
+#define REG_DRAM_VER_CAL_MACHINE_CTRL_ADDR     0x14c8
+#define REG_DRAM_MAIN_PADS_CAL_ADDR            0x14CC
+
+#define REG_DRAM_HOR_CAL_MACHINE_CTRL_ADDR     0x17c8
+
+#define REG_CS_SIZE_SCRATCH_ADDR               0x1504
+#define REG_DYNAMIC_POWER_SAVE_ADDR            0x1520
+#define REG_DDR_IO_ADDR                                0x1524
+#define REG_DDR_IO_CLK_RATIO_OFFS              15
+
+#define REG_DFS_ADDR                           0x1528
+#define REG_DFS_DLLNEXTSTATE_OFFS              0
+#define REG_DFS_BLOCK_OFFS                     1
+#define REG_DFS_SR_OFFS                                2
+#define REG_DFS_ATSR_OFFS                      3
+#define REG_DFS_RECONF_OFFS                    4
+#define REG_DFS_CL_NEXT_STATE_OFFS             8
+#define REG_DFS_CL_NEXT_STATE_MASK             0xF
+#define REG_DFS_CWL_NEXT_STATE_OFFS            12
+#define REG_DFS_CWL_NEXT_STATE_MASK            0x7
+
+#define REG_READ_DATA_SAMPLE_DELAYS_ADDR       0x1538
+#define REG_READ_DATA_SAMPLE_DELAYS_MASK       0x1F
+#define REG_READ_DATA_SAMPLE_DELAYS_OFFS       8
+
+#define REG_READ_DATA_READY_DELAYS_ADDR                0x153C
+#define REG_READ_DATA_READY_DELAYS_MASK                0x1F
+#define REG_READ_DATA_READY_DELAYS_OFFS                8
+
+#define START_BURST_IN_ADDR                    1
+
+#define REG_DRAM_TRAINING_SHADOW_ADDR          0x18488
+#define REG_DRAM_TRAINING_ADDR                 0x15B0
+#define REG_DRAM_TRAINING_LOW_FREQ_OFFS                0
+#define REG_DRAM_TRAINING_PATTERNS_OFFS                4
+#define REG_DRAM_TRAINING_MED_FREQ_OFFS                2
+#define REG_DRAM_TRAINING_WL_OFFS              3
+#define REG_DRAM_TRAINING_RL_OFFS              6
+#define REG_DRAM_TRAINING_DQS_RX_OFFS          15
+#define REG_DRAM_TRAINING_DQS_TX_OFFS          16
+#define REG_DRAM_TRAINING_CS_OFFS              20
+#define REG_DRAM_TRAINING_RETEST_OFFS          24
+#define REG_DRAM_TRAINING_DFS_FREQ_OFFS                27
+#define REG_DRAM_TRAINING_DFS_REQ_OFFS         29
+#define REG_DRAM_TRAINING_ERROR_OFFS           30
+#define REG_DRAM_TRAINING_AUTO_OFFS            31
+#define REG_DRAM_TRAINING_RETEST_PAR           0x3
+#define REG_DRAM_TRAINING_RETEST_MASK          0xF8FFFFFF
+#define REG_DRAM_TRAINING_CS_MASK              0xFF0FFFFF
+#define REG_DRAM_TRAINING_PATTERNS_MASK                0xFF0F0000
+
+#define REG_DRAM_TRAINING_1_ADDR               0x15B4
+#define REG_DRAM_TRAINING_1_TRNBPOINT_OFFS     16
+
+#define REG_DRAM_TRAINING_2_ADDR               0x15B8
+#define REG_DRAM_TRAINING_2_OVERRUN_OFFS       17
+#define REG_DRAM_TRAINING_2_FIFO_RST_OFFS      4
+#define REG_DRAM_TRAINING_2_RL_MODE_OFFS       3
+#define REG_DRAM_TRAINING_2_WL_MODE_OFFS       2
+#define REG_DRAM_TRAINING_2_ECC_MUX_OFFS       1
+#define REG_DRAM_TRAINING_2_SW_OVRD_OFFS       0
+
+#define REG_DRAM_TRAINING_PATTERN_BASE_ADDR    0x15BC
+#define REG_DRAM_TRAINING_PATTERN_BASE_OFFS    3
+
+#define REG_TRAINING_DEBUG_2_ADDR              0x15C4
+#define REG_TRAINING_DEBUG_2_OFFS              16
+#define REG_TRAINING_DEBUG_2_MASK              0x3
+
+#define REG_TRAINING_DEBUG_3_ADDR              0x15C8
+#define REG_TRAINING_DEBUG_3_OFFS              3
+#define REG_TRAINING_DEBUG_3_MASK              0x7
+
+#define        MR_CS_ADDR_OFFS                         4
+
+#define        REG_DDR3_MR0_ADDR                       0x15D0
+#define        REG_DDR3_MR0_CS_ADDR                    0x1870
+#define REG_DDR3_MR0_CL_MASK                   0x74
+#define        REG_DDR3_MR0_CL_OFFS                    2
+#define        REG_DDR3_MR0_CL_HIGH_OFFS               3
+#define        CL_MASK                                 0xF
+
+#define        REG_DDR3_MR1_ADDR                       0x15D4
+#define        REG_DDR3_MR1_CS_ADDR                    0x1874
+#define REG_DDR3_MR1_RTT_MASK                  0xFFFFFDBB
+#define REG_DDR3_MR1_DLL_ENA_OFFS              0
+#define REG_DDR3_MR1_RTT_DISABLED              0x0
+#define REG_DDR3_MR1_RTT_RZQ2                  0x40
+#define REG_DDR3_MR1_RTT_RZQ4                  0x2
+#define REG_DDR3_MR1_RTT_RZQ6                  0x42
+#define REG_DDR3_MR1_RTT_RZQ8                  0x202
+#define REG_DDR3_MR1_RTT_RZQ12                 0x4
+#define REG_DDR3_MR1_OUTBUF_WL_MASK            0xFFFFEF7F      /* WL-disabled,OB-enabled */
+#define REG_DDR3_MR1_OUTBUF_DIS_OFFS           12      /* Output Buffer Disabled */
+#define REG_DDR3_MR1_WL_ENA_OFFS               7
+#define REG_DDR3_MR1_WL_ENA                    0x80    /* WL Enabled */
+#define REG_DDR3_MR1_ODT_MASK                  0xFFFFFDBB
+
+#define        REG_DDR3_MR2_ADDR                       0x15D8
+#define        REG_DDR3_MR2_CS_ADDR                    0x1878
+#define        REG_DDR3_MR2_CWL_OFFS                   3
+#define        REG_DDR3_MR2_CWL_MASK                   0x7
+#define REG_DDR3_MR2_ODT_MASK                  0xFFFFF9FF
+#define        REG_DDR3_MR3_ADDR                       0x15DC
+#define        REG_DDR3_MR3_CS_ADDR                    0x187C
+
+#define REG_DDR3_RANK_CTRL_ADDR                        0x15E0
+#define REG_DDR3_RANK_CTRL_CS_ENA_MASK         0xF
+#define REG_DDR3_RANK_CTRL_MIRROR_OFFS         4
+
+#define REG_ZQC_CONF_ADDR                      0x15E4
+
+#define REG_DRAM_PHY_CONFIG_ADDR               0x15EC
+#define REG_DRAM_PHY_CONFIG_MASK               0x3FFFFFFF
+
+#define REG_ODPG_CNTRL_ADDR                    0x1600
+#define REG_ODPG_CNTRL_OFFS                    21
+
+#define REG_PHY_LOCK_MASK_ADDR                 0x1670
+#define REG_PHY_LOCK_MASK_MASK                 0xFFFFF000
+
+#define REG_PHY_LOCK_STATUS_ADDR               0x1674
+#define REG_PHY_LOCK_STATUS_LOCK_OFFS          9
+#define REG_PHY_LOCK_STATUS_LOCK_MASK          0xFFF
+#define REG_PHY_LOCK_APLL_ADLL_STATUS_MASK     0x7FF
+
+#define REG_PHY_REGISTRY_FILE_ACCESS_ADDR      0x16A0
+#define REG_PHY_REGISTRY_FILE_ACCESS_OP_WR     0xC0000000
+#define REG_PHY_REGISTRY_FILE_ACCESS_OP_RD     0x80000000
+#define REG_PHY_REGISTRY_FILE_ACCESS_OP_DONE   0x80000000
+#define REG_PHY_BC_OFFS                                27
+#define REG_PHY_CNTRL_OFFS                     26
+#define REG_PHY_CS_OFFS                                16
+#define REG_PHY_DQS_REF_DLY_OFFS               10
+#define REG_PHY_PHASE_OFFS                     8
+#define REG_PHY_PUP_OFFS                       22
+
+#define REG_TRAINING_WL_ADDR                   0x16AC
+#define REG_TRAINING_WL_CS_MASK                        0xFFFFFFFC
+#define REG_TRAINING_WL_UPD_OFFS               2
+#define REG_TRAINING_WL_CS_DONE_OFFS           3
+#define REG_TRAINING_WL_RATIO_MASK             0xFFFFFF0F
+#define REG_TRAINING_WL_1TO1                   0x50
+#define REG_TRAINING_WL_2TO1                   0x10
+#define REG_TRAINING_WL_DELAYEXP_MASK          0x20000000
+#define REG_TRAINING_WL_RESULTS_MASK           0x000001FF
+#define REG_TRAINING_WL_RESULTS_OFFS           20
+
+#define REG_REGISTERED_DRAM_CTRL_ADDR          0x16D0
+#define REG_REGISTERED_DRAM_CTRL_SR_FLOAT_OFFS 15
+#define REG_REGISTERED_DRAM_CTRL_PARITY_MASK   0x3F
+/* DLB*/
+#define REG_STATIC_DRAM_DLB_CONTROL            0x1700
+#define DLB_BUS_OPTIMIZATION_WEIGHTS_REG       0x1704
+#define DLB_AGING_REGISTER                     0x1708
+#define DLB_EVICTION_CONTROL_REG               0x170c
+#define DLB_EVICTION_TIMERS_REGISTER_REG       0x1710
+
+#define DLB_ENABLE                             0x1
+#define DLB_WRITE_COALESING                    (0x1 << 2)
+#define DLB_AXI_PREFETCH_EN                    (0x1 << 3)
+#define DLB_MBUS_PREFETCH_EN                   (0x1 << 4)
+#define PREFETCH_NLNSZTR                       (0x1 << 6)
+
+/* CPU    */
+#define REG_BOOTROM_ROUTINE_ADDR               0x182D0
+#define REG_BOOTROM_ROUTINE_DRAM_INIT_OFFS     12
+
+#define REG_DRAM_INIT_CTRL_STATUS_ADDR         0x18488
+#define REG_DRAM_INIT_CTRL_TRN_CLK_OFFS                16
+#define REG_CPU_DIV_CLK_CTRL_0_NEW_RATIO       0x000200FF
+#define REG_DRAM_INIT_CTRL_STATUS_2_ADDR       0x1488
+
+#define REG_CPU_DIV_CLK_CTRL_0_ADDR            0x18700
+
+#define REG_CPU_DIV_CLK_CTRL_1_ADDR            0x18704
+#define REG_CPU_DIV_CLK_CTRL_2_ADDR            0x18708
+
+#define REG_CPU_DIV_CLK_CTRL_3_ADDR            0x1870C
+#define REG_CPU_DIV_CLK_CTRL_3_FREQ_MASK       0xFFFFC0FF
+#define REG_CPU_DIV_CLK_CTRL_3_FREQ_OFFS       8
+
+#define REG_CPU_DIV_CLK_CTRL_4_ADDR            0x18710
+
+#define REG_CPU_DIV_CLK_STATUS_0_ADDR          0x18718
+#define REG_CPU_DIV_CLK_ALL_STABLE_OFFS                8
+
+#define REG_CPU_PLL_CTRL_0_ADDR                        0x1871C
+#define REG_CPU_PLL_STATUS_0_ADDR              0x18724
+#define REG_CORE_DIV_CLK_CTRL_ADDR             0x18740
+#define REG_CORE_DIV_CLK_STATUS_ADDR           0x18744
+#define REG_DDRPHY_APLL_CTRL_ADDR              0x18780
+
+#define REG_DDRPHY_APLL_CTRL_2_ADDR            0x18784
+
+#define REG_SFABRIC_CLK_CTRL_ADDR              0x20858
+#define REG_SFABRIC_CLK_CTRL_SMPL_OFFS         8
+
+/* DRAM Windows */
+#define REG_XBAR_WIN_19_CTRL_ADDR              0x200e8
+#define REG_XBAR_WIN_4_CTRL_ADDR               0x20040
+#define REG_XBAR_WIN_4_BASE_ADDR               0x20044
+#define REG_XBAR_WIN_4_REMAP_ADDR              0x20048
+#define REG_FASTPATH_WIN_0_CTRL_ADDR           0x20184
+#define REG_XBAR_WIN_7_REMAP_ADDR              0x20078
+
+/* SRAM */
+#define REG_CDI_CONFIG_ADDR                    0x20220
+#define REG_SRAM_WINDOW_0_ADDR                 0x20240
+#define REG_SRAM_WINDOW_0_ENA_OFFS             0
+#define REG_SRAM_WINDOW_1_ADDR                 0x20244
+#define REG_SRAM_L2_ENA_ADDR                   0x8500
+#define REG_SRAM_CLEAN_BY_WAY_ADDR             0x87BC
+
+/* PMU */
+#define REG_PMU_I_F_CTRL_ADDR                  0x1C090
+#define REG_PMU_DUNIT_BLK_OFFS                 16
+#define REG_PMU_DUNIT_RFRS_OFFS                        20
+#define REG_PMU_DUNIT_ACK_OFFS                 24
+
+/* MBUS*/
+#define MBUS_UNITS_PRIORITY_CONTROL_REG                (MV_MBUS_REGS_OFFSET + 0x420)
+#define FABRIC_UNITS_PRIORITY_CONTROL_REG      (MV_MBUS_REGS_OFFSET + 0x424)
+#define MBUS_UNITS_PREFETCH_CONTROL_REG                (MV_MBUS_REGS_OFFSET + 0x428)
+#define FABRIC_UNITS_PREFETCH_CONTROL_REG      (MV_MBUS_REGS_OFFSET + 0x42c)
+
+#define REG_PM_STAT_MASK_ADDR                  0x2210C
+#define REG_PM_STAT_MASK_CPU0_IDLE_MASK_OFFS   16
+
+#define REG_PM_EVENT_STAT_MASK_ADDR            0x22120
+#define REG_PM_EVENT_STAT_MASK_DFS_DONE_OFFS   17
+
+#define REG_PM_CTRL_CONFIG_ADDR                        0x22104
+#define REG_PM_CTRL_CONFIG_DFS_REQ_OFFS                18
+
+#define REG_FABRIC_LOCAL_IRQ_MASK_ADDR         0x218C4
+#define REG_FABRIC_LOCAL_IRQ_PMU_MASK_OFFS     18
+
+/* Controller revision info */
+#define PCI_CLASS_CODE_AND_REVISION_ID         0x008
+#define PCCRIR_REVID_OFFS                      0       /* Revision ID */
+#define PCCRIR_REVID_MASK                      (0xff << PCCRIR_REVID_OFFS)
+
+/*  Power Management Clock Gating Control Register     */
+#define MV_PEX_IF_REGS_OFFSET(if) \
+       (if < 8 ? (0x40000 + ((if) / 4) * 0x40000 + ((if) % 4) * 0x4000) \
+        : (0x42000 + ((if) % 8) * 0x40000))
+#define MV_PEX_IF_REGS_BASE(unit)              (MV_PEX_IF_REGS_OFFSET(unit))
+#define POWER_MNG_CTRL_REG                     0x18220
+#define PEX_DEVICE_AND_VENDOR_ID               0x000
+#define PEX_CFG_DIRECT_ACCESS(if, reg)         (MV_PEX_IF_REGS_BASE(if) + (reg))
+#define PMC_PEXSTOPCLOCK_OFFS(port)            ((port) < 8 ? (5 + (port)) : (18 + (port)))
+#define PMC_PEXSTOPCLOCK_MASK(port)            (1 << PMC_PEXSTOPCLOCK_OFFS(port))
+#define PMC_PEXSTOPCLOCK_EN(port)              (1 << PMC_PEXSTOPCLOCK_OFFS(port))
+#define PMC_PEXSTOPCLOCK_STOP(port)            (0 << PMC_PEXSTOPCLOCK_OFFS(port))
+
+/* TWSI */
+#define TWSI_DATA_ADDR_MASK                    0x7
+#define TWSI_DATA_ADDR_OFFS                    1
+
+/* General */
+#define MAX_CS                                 4
+
+/* Frequencies */
+#define FAB_OPT                                        21
+#define CLK_CPU                                        12
+#define CLK_VCO                                        (2 * CLK_CPU)
+#define CLK_DDR                                        12
+
+/* Cpu Frequencies: */
+#define CLK_CPU_1000                           0
+#define CLK_CPU_1066                           1
+#define CLK_CPU_1200                           2
+#define CLK_CPU_1333                           3
+#define CLK_CPU_1500                           4
+#define CLK_CPU_1666                           5
+#define CLK_CPU_1800                           6
+#define CLK_CPU_2000                           7
+#define CLK_CPU_600                            8
+#define CLK_CPU_667                            9
+#define CLK_CPU_800                            0xa
+
+/* Extra Cpu Frequencies: */
+#define CLK_CPU_1600                           11
+#define CLK_CPU_2133                           12
+#define CLK_CPU_2200                           13
+#define CLK_CPU_2400                           14
+
+/* DDR3 Frequencies: */
+#define DDR_100                                        0
+#define DDR_300                                        1
+#define DDR_333                                        1
+#define DDR_360                                        2
+#define DDR_400                                        3
+#define DDR_444                                        4
+#define DDR_500                                        5
+#define DDR_533                                        6
+#define DDR_600                                        7
+#define DDR_640                                        8
+#define DDR_666                                        8
+#define DDR_720                                        9
+#define DDR_750                                        9
+#define DDR_800                                        10
+#define DDR_833                                        11
+#define DDR_HCLK                               20
+#define DDR_S                                  12
+#define DDR_S_1TO1                             13
+#define MARGIN_FREQ                            DDR_400
+#define DFS_MARGIN                             DDR_100
+
+#define ODT_OPT                                        16
+#define ODT20                                  0x200
+#define ODT30                                  0x204
+#define ODT40                                  0x44
+#define ODT120                                 0x40
+#define ODT120D                                        0x400
+
+#define MRS_DELAY                              100
+
+#define SDRAM_WL_SW_OFFS                       0x100
+#define SDRAM_RL_OFFS                          0x0
+#define SDRAM_PBS_I_OFFS                       0x140
+#define SDRAM_PBS_II_OFFS                      0x180
+#define SDRAM_PBS_NEXT_OFFS                    (SDRAM_PBS_II_OFFS - SDRAM_PBS_I_OFFS)
+#define SDRAM_PBS_TX_OFFS                      0x180
+#define SDRAM_PBS_TX_DM_OFFS                   576
+#define SDRAM_DQS_RX_OFFS                      1024
+#define SDRAM_DQS_TX_OFFS                      2048
+#define SDRAM_DQS_RX_SPECIAL_OFFS              5120
+
+#define LEN_STD_PATTERN                                16
+#define LEN_KILLER_PATTERN                     128
+#define LEN_SPECIAL_PATTERN                    128
+#define LEN_PBS_PATTERN                                16
+
+#endif /* __DDR3_AXP_H */
diff --git a/drivers/ddr/mvebu/ddr3_axp_config.h b/drivers/ddr/mvebu/ddr3_axp_config.h
new file mode 100644 (file)
index 0000000..800d2d1
--- /dev/null
@@ -0,0 +1,146 @@
+/*
+ * Copyright (C) Marvell International Ltd. and its affiliates
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#ifndef __DDR3_AXP_CONFIG_H
+#define __DDR3_AXP_CONFIG_H
+
+/*
+ * DDR3_LOG_LEVEL Information
+ *
+ * Level 0: Provides an error code in a case of failure, RL, WL errors
+ *          and other algorithm failure
+ * Level 1: Provides the D-Unit setup (SPD/Static configuration)
+ * Level 2: Provides the windows margin as a results of DQS centeralization
+ * Level 3: Provides the windows margin of each DQ as a results of DQS
+ *          centeralization
+ */
+#ifdef CONFIG_DDR_LOG_LEVEL
+#define        DDR3_LOG_LEVEL  CONFIG_DDR_LOG_LEVEL
+#else
+#define        DDR3_LOG_LEVEL  0
+#endif
+
+#define DDR3_PBS        1
+
+/* This flag allows the execution of SW WL/RL upon HW failure */
+#define DDR3_RUN_SW_WHEN_HW_FAIL    1
+
+/*
+ * General Configurations
+ *
+ * The following parameters are required for proper setup:
+ *
+ * DDR_TARGET_FABRIC   - Set desired fabric configuration
+ *                       (for sample@Reset fabfreq parameter)
+ * DRAM_ECC            - Set ECC support 1/0
+ * BUS_WIDTH           - 64/32 bit
+ * CONFIG_SPD_EEPROM   - Enables auto detection of DIMMs and their timing values
+ * DQS_CLK_ALIGNED     - Set this if CLK and DQS signals are aligned on board
+ * MIXED_DIMM_STATIC   - Mixed DIMM + On board devices support (ODT registers
+ *                       values are taken statically)
+ * DDR3_TRAINING_DEBUG - Debug prints of internal code
+ */
+#define DDR_TARGET_FABRIC                      5
+#define DRAM_ECC                               0
+
+#ifdef MV_DDR_32BIT
+#define BUS_WIDTH                               32
+#else
+#define BUS_WIDTH                              64
+#endif
+
+#undef DQS_CLK_ALIGNED
+#undef MIXED_DIMM_STATIC
+#define DDR3_TRAINING_DEBUG                    0
+#define REG_DIMM_SKIP_WL                       0
+
+/* Marvell boards specific configurations */
+#if defined(DB_78X60_PCAC)
+#undef CONFIG_SPD_EEPROM
+#define STATIC_TRAINING
+#endif
+
+#if defined(DB_78X60_AMC)
+#undef CONFIG_SPD_EEPROM
+#undef  DRAM_ECC
+#define DRAM_ECC                               1
+#endif
+
+#ifdef CONFIG_SPD_EEPROM
+/*
+ * DIMM support parameters:
+ * DRAM_2T - Set Desired 2T Mode - 0 - 1T, 0x1 - 2T, 0x2 - 3T
+ * DIMM_CS_BITMAP - bitmap representing the optional CS in DIMMs
+ * (0xF=CS0+CS1+CS2+CS3, 0xC=CS2+CS3...)
+ */
+#define DRAM_2T                                        0x0
+#define DIMM_CS_BITMAP                         0xF
+#define DUNIT_SPD
+#endif
+
+#ifdef DRAM_ECC
+/*
+ * ECC support parameters:
+ *
+ * U_BOOT_START_ADDR, U_BOOT_SCRUB_SIZE - relevant when using ECC and need
+ * to configure the scrubbing area
+ */
+#define TRAINING_SIZE                          0x20000
+#define U_BOOT_START_ADDR                      0
+#define U_BOOT_SCRUB_SIZE                      0x1000000 /* TRAINING_SIZE */
+#endif
+
+/*
+ * Registered DIMM Support - In case registered DIMM is attached,
+ * please supply the following values:
+ * (see JEDEC - JESD82-29A "Definition of the SSTE32882 Registering Clock
+ * Driver with Parity and Quad Chip
+ * Selects for DDR3/DDR3L/DDR3U RDIMM 1.5 V/1.35 V/1.25 V Applications")
+ * RC0: Global Features Control Word
+ * RC1: Clock Driver Enable Control Word
+ * RC2: Timing Control Word
+ * RC3-RC5 - taken from SPD
+ * RC8: Additional IBT Setting Control Word
+ * RC9: Power Saving Settings Control Word
+ * RC10: Encoding for RDIMM Operating Speed
+ * RC11: Operating Voltage VDD and VREFCA Control Word
+ */
+#define RDIMM_RC0                              0
+#define RDIMM_RC1                              0
+#define RDIMM_RC2                              0
+#define RDIMM_RC8                              0
+#define RDIMM_RC9                              0
+#define RDIMM_RC10                             0x2
+#define RDIMM_RC11                             0x0
+
+#if defined(MIXED_DIMM_STATIC) || !defined(CONFIG_SPD_EEPROM)
+#define DUNIT_STATIC
+#endif
+
+#if defined(MIXED_DIMM_STATIC) || defined(CONFIG_SPD_EEPROM)
+/*
+ * This flag allows the user to change the dram refresh cycle in ps,
+ * only in case of SPD or MIX DIMM topology
+ */
+#define TREFI_USER_EN
+
+#ifdef TREFI_USER_EN
+#define TREFI_USER                             3900000
+#endif
+#endif
+
+#ifdef CONFIG_SPD_EEPROM
+/*
+ * AUTO_DETECTION_SUPPORT - relevant ONLY for Marvell DB boards.
+ * Enables I2C auto detection different options
+ */
+#if defined(CONFIG_DB_88F78X60) || defined(CONFIG_DB_88F78X60_REV2) || \
+    defined(CONFIG_DB_784MP_GP)
+#define AUTO_DETECTION_SUPPORT
+#endif
+#endif
+
+#endif /* __DDR3_AXP_CONFIG_H */
diff --git a/drivers/ddr/mvebu/ddr3_axp_mc_static.h b/drivers/ddr/mvebu/ddr3_axp_mc_static.h
new file mode 100644 (file)
index 0000000..2c0e907
--- /dev/null
@@ -0,0 +1,284 @@
+/*
+ * Copyright (C) Marvell International Ltd. and its affiliates
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#ifndef __AXP_MC_STATIC_H
+#define __AXP_MC_STATIC_H
+
+MV_DRAM_MC_INIT ddr3_A0_db_667[MV_MAX_DDR3_STATIC_SIZE] = {
+#ifdef MV_DDR_32BIT
+       {0x00001400, 0x7301c924},       /*DDR SDRAM Configuration Register */
+#else /*MV_DDR_64BIT */
+       {0x00001400, 0x7301CA28},       /*DDR SDRAM Configuration Register */
+#endif
+       {0x00001404, 0x3630b800},       /*Dunit Control Low Register */
+       {0x00001408, 0x43149775},       /*DDR SDRAM Timing (Low) Register */
+       /* {0x0000140C, 0x38000C6A}, *//*DDR SDRAM Timing (High) Register */
+       {0x0000140C, 0x38d83fe0},       /*DDR SDRAM Timing (High) Register */
+
+#ifdef DB_78X60_PCAC
+       {0x00001410, 0x040F0001},       /*DDR SDRAM Address Control Register */
+#else
+       {0x00001410, 0x040F0000},       /*DDR SDRAM Open Pages Control Register */
+#endif
+
+       {0x00001414, 0x00000000},       /*DDR SDRAM Open Pages Control Register */
+       {0x00001418, 0x00000e00},       /*DDR SDRAM Operation Register */
+       {0x00001420, 0x00000004},       /*DDR SDRAM Extended Mode Register */
+       {0x00001424, 0x0000D3FF},       /*Dunit Control High Register */
+       {0x00001428, 0x000F8830},       /*Dunit Control High Register */
+       {0x0000142C, 0x214C2F38},       /*Dunit Control High Register */
+       {0x0000147C, 0x0000c671},
+
+       {0x000014a0, 0x000002A9},
+       {0x000014a8, 0x00000101},       /*2:1 */
+       {0x00020220, 0x00000007},
+
+       {0x00001494, 0x00010000},       /*DDR SDRAM ODT Control (Low) Register */
+       {0x00001498, 0x00000000},       /*DDR SDRAM ODT Control (High) Register */
+       {0x0000149C, 0x00000301},       /*DDR Dunit ODT Control Register */
+
+       {0x000014C0, 0x192434e9},       /* DRAM address and Control Driving Strenght  */
+       {0x000014C4, 0x092434e9},       /* DRAM Data and DQS Driving Strenght  */
+
+       {0x000200e8, 0x3FFF0E01},       /* DO NOT Modify - Open Mbus Window - 2G - Mbus is required for the training sequence */
+       {0x00020184, 0x3FFFFFE0},       /* DO NOT Modify - Close fast path Window to - 2G */
+
+       {0x0001504, 0x7FFFFFF1},        /* CS0 Size */
+       {0x000150C, 0x00000000},        /* CS1 Size */
+       {0x0001514, 0x00000000},        /* CS2 Size */
+       {0x000151C, 0x00000000},        /* CS3 Size */
+
+       /*     {0x00001524, 0x0000C800},  */
+       {0x00001538, 0x0000000b},       /*Read Data Sample Delays Register */
+       {0x0000153C, 0x0000000d},       /*Read Data Ready Delay Register */
+
+       {0x000015D0, 0x00000640},       /*MR0 */
+       {0x000015D4, 0x00000046},       /*MR1 */
+       {0x000015D8, 0x00000010},       /*MR2 */
+       {0x000015DC, 0x00000000},       /*MR3 */
+
+       {0x000015E4, 0x00203c18},       /*ZQC Configuration Register */
+       {0x000015EC, 0xd800aa25},       /*DDR PHY */
+       {0x0, 0x0}
+};
+
+MV_DRAM_MC_INIT ddr3_A0_AMC_667[MV_MAX_DDR3_STATIC_SIZE] = {
+#ifdef MV_DDR_32BIT
+       {0x00001400, 0x7301c924},       /*DDR SDRAM Configuration Register */
+#else /*MV_DDR_64BIT */
+       {0x00001400, 0x7301CA28},       /*DDR SDRAM Configuration Register */
+#endif
+       {0x00001404, 0x3630b800},       /*Dunit Control Low Register */
+       {0x00001408, 0x43149775},       /*DDR SDRAM Timing (Low) Register */
+       /* {0x0000140C, 0x38000C6A}, *//*DDR SDRAM Timing (High) Register */
+       {0x0000140C, 0x38d83fe0},       /*DDR SDRAM Timing (High) Register */
+
+#ifdef DB_78X60_PCAC
+       {0x00001410, 0x040F0001},       /*DDR SDRAM Address Control Register */
+#else
+       {0x00001410, 0x040F000C},       /*DDR SDRAM Open Pages Control Register */
+#endif
+
+       {0x00001414, 0x00000000},       /*DDR SDRAM Open Pages Control Register */
+       {0x00001418, 0x00000e00},       /*DDR SDRAM Operation Register */
+       {0x00001420, 0x00000004},       /*DDR SDRAM Extended Mode Register */
+       {0x00001424, 0x0000D3FF},       /*Dunit Control High Register */
+       {0x00001428, 0x000F8830},       /*Dunit Control High Register */
+       {0x0000142C, 0x214C2F38},       /*Dunit Control High Register */
+       {0x0000147C, 0x0000c671},
+
+       {0x000014a0, 0x000002A9},
+       {0x000014a8, 0x00000101},       /*2:1 */
+       {0x00020220, 0x00000007},
+
+       {0x00001494, 0x00010000},       /*DDR SDRAM ODT Control (Low) Register */
+       {0x00001498, 0x00000000},       /*DDR SDRAM ODT Control (High) Register */
+       {0x0000149C, 0x00000301},       /*DDR Dunit ODT Control Register */
+
+       {0x000014C0, 0x192434e9},       /* DRAM address and Control Driving Strenght  */
+       {0x000014C4, 0x092434e9},       /* DRAM Data and DQS Driving Strenght  */
+
+       {0x000200e8, 0x3FFF0E01},       /* DO NOT Modify - Open Mbus Window - 2G - Mbus is required for the training sequence */
+       {0x00020184, 0x3FFFFFE0},       /* DO NOT Modify - Close fast path Window to - 2G */
+
+       {0x0001504, 0x3FFFFFF1},        /* CS0 Size */
+       {0x000150C, 0x00000000},        /* CS1 Size */
+       {0x0001514, 0x00000000},        /* CS2 Size */
+       {0x000151C, 0x00000000},        /* CS3 Size */
+
+       /*     {0x00001524, 0x0000C800},  */
+       {0x00001538, 0x0000000b},       /*Read Data Sample Delays Register */
+       {0x0000153C, 0x0000000d},       /*Read Data Ready Delay Register */
+
+       {0x000015D0, 0x00000640},       /*MR0 */
+       {0x000015D4, 0x00000046},       /*MR1 */
+       {0x000015D8, 0x00000010},       /*MR2 */
+       {0x000015DC, 0x00000000},       /*MR3 */
+
+       {0x000015E4, 0x00203c18},       /*ZQC Configuration Register */
+       {0x000015EC, 0xd800aa25},       /*DDR PHY */
+       {0x0, 0x0}
+};
+
+MV_DRAM_MC_INIT ddr3_A0_db_400[MV_MAX_DDR3_STATIC_SIZE] = {
+#ifdef MV_DDR_32BIT
+       {0x00001400, 0x73004C30},       /*DDR SDRAM Configuration Register */
+#else /* MV_DDR_64BIT */
+       {0x00001400, 0x7300CC30},       /*DDR SDRAM Configuration Register */
+#endif
+       {0x00001404, 0x3630B840},       /*Dunit Control Low Register */
+       {0x00001408, 0x33137663},       /*DDR SDRAM Timing (Low) Register */
+       {0x0000140C, 0x38000C55},       /*DDR SDRAM Timing (High) Register */
+       {0x00001410, 0x040F0000},       /*DDR SDRAM Address Control Register */
+       {0x00001414, 0x00000000},       /*DDR SDRAM Open Pages Control Register */
+       {0x00001418, 0x00000e00},       /*DDR SDRAM Operation Register */
+       {0x0000141C, 0x00000672},       /*DDR SDRAM Mode Register */
+       {0x00001420, 0x00000004},       /*DDR SDRAM Extended Mode Register */
+       {0x00001424, 0x0100D3FF},       /*Dunit Control High Register */
+       {0x00001428, 0x000D6720},       /*Dunit Control High Register */
+       {0x0000142C, 0x014C2F38},       /*Dunit Control High Register */
+       {0x0000147C, 0x00006571},
+
+       {0x00001494, 0x00010000},       /*DDR SDRAM ODT Control (Low) Register */
+       {0x00001498, 0x00000000},       /*DDR SDRAM ODT Control (High) Register */
+       {0x0000149C, 0x00000301},       /*DDR Dunit ODT Control Register */
+
+       {0x000014a0, 0x000002A9},
+       {0x000014a8, 0x00000101},       /*2:1 */
+       {0x00020220, 0x00000007},
+
+       {0x000014C0, 0x192424C8},       /* DRAM address and Control Driving Strenght  */
+       {0x000014C4, 0xEFB24C8},        /* DRAM Data and DQS Driving Strenght  */
+
+       {0x000200e8, 0x3FFF0E01},       /* DO NOT Modify - Open Mbus Window - 2G - Mbus is required for the training sequence */
+       {0x00020184, 0x3FFFFFE0},       /* DO NOT Modify - Close fast path Window to - 2G */
+
+       {0x0001504, 0x7FFFFFF1},        /* CS0 Size */
+       {0x000150C, 0x00000000},        /* CS1 Size */
+       {0x0001514, 0x00000000},        /* CS2 Size */
+       {0x000151C, 0x00000000},        /* CS3 Size */
+
+       {0x00001538, 0x00000008},       /*Read Data Sample Delays Register */
+       {0x0000153C, 0x0000000A},       /*Read Data Ready Delay Register */
+
+       {0x000015D0, 0x00000630},       /*MR0 */
+       {0x000015D4, 0x00000046},       /*MR1 */
+       {0x000015D8, 0x00000008},       /*MR2 */
+       {0x000015DC, 0x00000000},       /*MR3 */
+
+       {0x000015E4, 0x00203c18},       /*ZQDS Configuration Register */
+       /* {0x000015EC, 0xDE000025}, *//*DDR PHY */
+       {0x000015EC, 0xF800AA25},       /*DDR PHY */
+       {0x0, 0x0}
+};
+
+MV_DRAM_MC_INIT ddr3_Z1_db_600[MV_MAX_DDR3_STATIC_SIZE] = {
+#ifdef MV_DDR_32BIT
+       {0x00001400, 0x73014A28},       /*DDR SDRAM Configuration Register */
+#else /*MV_DDR_64BIT */
+       {0x00001400, 0x7301CA28},       /*DDR SDRAM Configuration Register */
+#endif
+       {0x00001404, 0x3630B040},       /*Dunit Control Low Register */
+       {0x00001408, 0x44149887},       /*DDR SDRAM Timing (Low) Register */
+       /* {0x0000140C, 0x38000C6A}, *//*DDR SDRAM Timing (High) Register */
+       {0x0000140C, 0x38D83FE0},       /*DDR SDRAM Timing (High) Register */
+
+#ifdef DB_78X60_PCAC
+       {0x00001410, 0x040F0001},       /*DDR SDRAM Address Control Register */
+#else
+       {0x00001410, 0x040F0000},       /*DDR SDRAM Open Pages Control Register */
+#endif
+
+       {0x00001414, 0x00000000},       /*DDR SDRAM Open Pages Control Register */
+       {0x00001418, 0x00000e00},       /*DDR SDRAM Operation Register */
+       {0x00001420, 0x00000004},       /*DDR SDRAM Extended Mode Register */
+       {0x00001424, 0x0100D1FF},       /*Dunit Control High Register */
+       {0x00001428, 0x000F8830},       /*Dunit Control High Register */
+       {0x0000142C, 0x214C2F38},       /*Dunit Control High Register */
+       {0x0000147C, 0x0000c671},
+
+       {0x000014a8, 0x00000101},       /*2:1 */
+       {0x00020220, 0x00000007},
+
+       {0x00001494, 0x00010000},       /*DDR SDRAM ODT Control (Low) Register */
+       {0x00001498, 0x00000000},       /*DDR SDRAM ODT Control (High) Register */
+       {0x0000149C, 0x00000301},       /*DDR Dunit ODT Control Register */
+
+       {0x000014C0, 0x192424C8},       /* DRAM address and Control Driving Strenght  */
+       {0x000014C4, 0xEFB24C8},        /* DRAM Data and DQS Driving Strenght  */
+
+       {0x000200e8, 0x3FFF0E01},       /* DO NOT Modify - Open Mbus Window - 2G - Mbus is required for the training sequence */
+       {0x00020184, 0x3FFFFFE0},       /* DO NOT Modify - Close fast path Window to - 2G */
+
+       {0x0001504, 0x7FFFFFF1},        /* CS0 Size */
+       {0x000150C, 0x00000000},        /* CS1 Size */
+       {0x0001514, 0x00000000},        /* CS2 Size */
+       {0x000151C, 0x00000000},        /* CS3 Size */
+
+       /*     {0x00001524, 0x0000C800},  */
+       {0x00001538, 0x0000000b},       /*Read Data Sample Delays Register */
+       {0x0000153C, 0x0000000d},       /*Read Data Ready Delay Register */
+
+       {0x000015D0, 0x00000650},       /*MR0 */
+       {0x000015D4, 0x00000046},       /*MR1 */
+       {0x000015D8, 0x00000010},       /*MR2 */
+       {0x000015DC, 0x00000000},       /*MR3 */
+
+       {0x000015E4, 0x00203c18},       /*ZQC Configuration Register */
+       {0x000015EC, 0xDE000025},       /*DDR PHY */
+       {0x0, 0x0}
+};
+
+MV_DRAM_MC_INIT ddr3_Z1_db_300[MV_MAX_DDR3_STATIC_SIZE] = {
+#ifdef MV_DDR_32BIT
+       {0x00001400, 0x73004C30},       /*DDR SDRAM Configuration Register */
+#else /*MV_DDR_64BIT */
+       {0x00001400, 0x7300CC30},       /*DDR SDRAM Configuration Register */
+       /*{0x00001400, 0x7304CC30},  *//*DDR SDRAM Configuration Register */
+#endif
+       {0x00001404, 0x3630B840},       /*Dunit Control Low Register */
+       {0x00001408, 0x33137663},       /*DDR SDRAM Timing (Low) Register */
+       {0x0000140C, 0x38000C55},       /*DDR SDRAM Timing (High) Register */
+       {0x00001410, 0x040F0000},       /*DDR SDRAM Address Control Register */
+       {0x00001414, 0x00000000},       /*DDR SDRAM Open Pages Control Register */
+       {0x00001418, 0x00000e00},       /*DDR SDRAM Operation Register */
+       {0x0000141C, 0x00000672},       /*DDR SDRAM Mode Register */
+       {0x00001420, 0x00000004},       /*DDR SDRAM Extended Mode Register */
+       {0x00001424, 0x0100F1FF},       /*Dunit Control High Register */
+       {0x00001428, 0x000D6720},       /*Dunit Control High Register */
+       {0x0000142C, 0x014C2F38},       /*Dunit Control High Register */
+       {0x0000147C, 0x00006571},
+
+       {0x00001494, 0x00010000},       /*DDR SDRAM ODT Control (Low) Register */
+       {0x00001498, 0x00000000},       /*DDR SDRAM ODT Control (High) Register */
+       {0x0000149C, 0x00000301},       /*DDR Dunit ODT Control Register */
+
+       {0x000014C0, 0x192424C8},       /* DRAM address and Control Driving Strenght  */
+       {0x000014C4, 0xEFB24C8},        /* DRAM Data and DQS Driving Strenght  */
+
+       {0x000200e8, 0x3FFF0E01},       /* DO NOT Modify - Open Mbus Window - 2G - Mbus is required for the training sequence */
+       {0x00020184, 0x3FFFFFE0},       /* DO NOT Modify - Close fast path Window to - 2G */
+
+       {0x0001504, 0x7FFFFFF1},        /* CS0 Size */
+       {0x000150C, 0x00000000},        /* CS1 Size */
+       {0x0001514, 0x00000000},        /* CS2 Size */
+       {0x000151C, 0x00000000},        /* CS3 Size */
+
+       {0x00001538, 0x00000008},       /*Read Data Sample Delays Register */
+       {0x0000153C, 0x0000000A},       /*Read Data Ready Delay Register */
+
+       {0x000015D0, 0x00000630},       /*MR0 */
+       {0x000015D4, 0x00000046},       /*MR1 */
+       {0x000015D8, 0x00000008},       /*MR2 */
+       {0x000015DC, 0x00000000},       /*MR3 */
+
+       {0x000015E4, 0x00203c18},       /*ZQDS Configuration Register */
+       {0x000015EC, 0xDE000025},       /*DDR PHY */
+
+       {0x0, 0x0}
+};
+
+#endif /* __AXP_MC_STATIC_H */
diff --git a/drivers/ddr/mvebu/ddr3_axp_training_static.h b/drivers/ddr/mvebu/ddr3_axp_training_static.h
new file mode 100644 (file)
index 0000000..4e61547
--- /dev/null
@@ -0,0 +1,770 @@
+/*
+ * Copyright (C) Marvell International Ltd. and its affiliates
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#ifndef __AXP_TRAINING_STATIC_H
+#define __AXP_TRAINING_STATIC_H
+
+/*
+ * STATIC_TRAINING - Set only if static parameters for training are set and
+ * required
+ */
+
+MV_DRAM_TRAINING_INIT ddr3_db_rev2_667[MV_MAX_DDR3_STATIC_SIZE] = {
+       /* Read Leveling */
+       /*PUP   RdSampleDly (+CL)       Phase   RL ADLL value */
+       /*0     */
+       {0x000016A0, 0xC002011A},
+       /*1 */
+       {0x000016A0, 0xC0420100},
+       /*2 */
+       {0x000016A0, 0xC082020A},
+       /*3 */
+       {0x000016A0, 0xC0C20017},
+       /*4 */
+       {0x000016A0, 0xC1020113},
+       /*5 */
+       {0x000016A0, 0xC1420107},
+       /*6 */
+       {0x000016A0, 0xC182011F},
+       /*7 */
+       {0x000016A0, 0xC1C2001C},
+       /*8 */
+       {0x000016A0, 0xC202010D},
+
+       /* Write Leveling */
+       /*0 */
+       {0x000016A0, 0xC0004A06},
+       /*1 */
+       {0x000016A0, 0xC040690D},
+       /*2 */
+       {0x000016A0, 0xC0806A0D},
+       /*3 */
+       {0x000016A0, 0xC0C0A01B},
+       /*4 */
+       {0x000016A0, 0xC1003A01},
+       /*5 */
+       {0x000016A0, 0xC1408113},
+       /*6 */
+       {0x000016A0, 0xC1805609},
+       /*7 */
+       {0x000016A0, 0xC1C04504},
+       /*8 */
+       {0x000016A0, 0xC2009518},
+
+       /*center DQS on read cycle */
+       {0x000016A0, 0xC803000F},
+
+       {0x00001538, 0x0000000B},       /*Read Data Sample Delays Register */
+       {0x0000153C, 0x0000000F},       /*Read Data Ready Delay Register */
+
+       /*init DRAM */
+       {0x00001480, 0x00000001},
+       {0x0, 0x0}
+};
+
+MV_DRAM_TRAINING_INIT ddr3_db_rev2_800[MV_MAX_DDR3_STATIC_SIZE] = {
+       /* Read Leveling */
+       /*PUP   RdSampleDly (+CL)       Phase   RL ADLL value */
+       /*0     */
+       {0x000016A0, 0xC0020301},
+       /*1 */
+       {0x000016A0, 0xC0420202},
+       /*2 */
+       {0x000016A0, 0xC0820314},
+       /*3 */
+       {0x000016A0, 0xC0C20117},
+       /*4 */
+       {0x000016A0, 0xC1020219},
+       /*5 */
+       {0x000016A0, 0xC142020B},
+       /*6 */
+       {0x000016A0, 0xC182030A},
+       /*7 */
+       {0x000016A0, 0xC1C2011D},
+       /*8 */
+       {0x000016A0, 0xC2020212},
+
+       /* Write Leveling */
+       /*0 */
+       {0x000016A0, 0xC0007A12},
+       /*1 */
+       {0x000016A0, 0xC0408D16},
+       /*2 */
+       {0x000016A0, 0xC0809E1B},
+       /*3 */
+       {0x000016A0, 0xC0C0AC1F},
+       /*4 */
+       {0x000016A0, 0xC1005E0A},
+       /*5 */
+       {0x000016A0, 0xC140A91D},
+       /*6 */
+       {0x000016A0, 0xC1808E17},
+       /*7 */
+       {0x000016A0, 0xC1C05509},
+       /*8 */
+       {0x000016A0, 0xC2003A01},
+
+       /* PBS Leveling */
+       /*0 */
+       {0x000016A0, 0xC0007A12},
+       /*1 */
+       {0x000016A0, 0xC0408D16},
+       /*2 */
+       {0x000016A0, 0xC0809E1B},
+       /*3 */
+       {0x000016A0, 0xC0C0AC1F},
+       /*4 */
+       {0x000016A0, 0xC1005E0A},
+       /*5 */
+       {0x000016A0, 0xC140A91D},
+       /*6 */
+       {0x000016A0, 0xC1808E17},
+       /*7 */
+       {0x000016A0, 0xC1C05509},
+       /*8 */
+       {0x000016A0, 0xC2003A01},
+
+       /*center DQS on read cycle */
+       {0x000016A0, 0xC803000B},
+
+       {0x00001538, 0x0000000D},       /*Read Data Sample Delays Register */
+       {0x0000153C, 0x00000011},       /*Read Data Ready Delay Register */
+
+       /*init DRAM */
+       {0x00001480, 0x00000001},
+       {0x0, 0x0}
+};
+
+MV_DRAM_TRAINING_INIT ddr3_db_400[MV_MAX_DDR3_STATIC_SIZE] = {
+       /* Read Leveling */
+       /*PUP   RdSampleDly (+CL)       Phase   RL ADLL value */
+       /*0             2               4               15 */
+       {0x000016A0, 0xC002010C},
+       /*1             2               4               2 */
+       {0x000016A0, 0xC042001C},
+       /*2             2               4               27 */
+       {0x000016A0, 0xC0820115},
+       /*3             2               4               0 */
+       {0x000016A0, 0xC0C20019},
+       /*4             2               4               13 */
+       {0x000016A0, 0xC1020108},
+       /*5             2               4               5 */
+       {0x000016A0, 0xC1420100},
+       /*6             2               4               19 */
+       {0x000016A0, 0xC1820111},
+       /*7             2               4               0 */
+       {0x000016A0, 0xC1C2001B},
+       /*8             2               4               10 */
+       /*{0x000016A0, 0xC2020117}, */
+       {0x000016A0, 0xC202010C},
+
+       /* Write Leveling */
+       /*0 */
+       {0x000016A0, 0xC0005508},
+       /*1 */
+       {0x000016A0, 0xC0409819},
+       /*2 */
+       {0x000016A0, 0xC080650C},
+       /*3 */
+       {0x000016A0, 0xC0C0700F},
+       /*4 */
+       {0x000016A0, 0xC1004103},
+       /*5 */
+       {0x000016A0, 0xC140A81D},
+       /*6 */
+       {0x000016A0, 0xC180650C},
+       /*7 */
+       {0x000016A0, 0xC1C08013},
+       /*8 */
+       {0x000016A0, 0xC2005508},
+
+       /*center DQS on read cycle */
+       {0x000016A0, 0xC803000F},
+
+       {0x00001538, 0x00000008},       /*Read Data Sample Delays Register */
+       {0x0000153C, 0x0000000A},       /*Read Data Ready Delay Register */
+
+       /*init DRAM */
+       {0x00001480, 0x00000001},
+       {0x0, 0x0}
+};
+
+MV_DRAM_TRAINING_INIT ddr3_db_533[MV_MAX_DDR3_STATIC_SIZE] = {
+       /* Read Leveling */
+       /*PUP   RdSampleDly (+CL)       Phase   RL ADLL value */
+       /*0             2               4               15 */
+       {0x000016A0, 0xC002040C},
+       /*1             2               4               2 */
+       {0x000016A0, 0xC0420117},
+       /*2             2               4               27 */
+       {0x000016A0, 0xC082041B},
+       /*3             2               4               0 */
+       {0x000016A0, 0xC0C20117},
+       /*4             2               4               13 */
+       {0x000016A0, 0xC102040A},
+       /*5             2               4               5 */
+       {0x000016A0, 0xC1420117},
+       /*6             2               4               19 */
+       {0x000016A0, 0xC1820419},
+       /*7             2               4               0 */
+       {0x000016A0, 0xC1C20117},
+       /*8             2               4               10 */
+       {0x000016A0, 0xC2020117},
+
+       /* Write Leveling */
+       /*0 */
+       {0x000016A0, 0xC0008113},
+       /*1 */
+       {0x000016A0, 0xC0404504},
+       /*2 */
+       {0x000016A0, 0xC0808514},
+       /*3 */
+       {0x000016A0, 0xC0C09418},
+       /*4 */
+       {0x000016A0, 0xC1006D0E},
+       /*5 */
+       {0x000016A0, 0xC1405508},
+       /*6 */
+       {0x000016A0, 0xC1807D12},
+       /*7 */
+       {0x000016A0, 0xC1C0b01F},
+       /*8 */
+       {0x000016A0, 0xC2005D0A},
+
+       /*center DQS on read cycle */
+       {0x000016A0, 0xC803000F},
+
+       {0x00001538, 0x00000008},       /*Read Data Sample Delays Register */
+       {0x0000153C, 0x0000000A},       /*Read Data Ready Delay Register */
+
+       /*init DRAM */
+       {0x00001480, 0x00000001},
+       {0x0, 0x0}
+};
+
+MV_DRAM_TRAINING_INIT ddr3_db_600[MV_MAX_DDR3_STATIC_SIZE] = {
+       /* Read Leveling */
+       /*PUP   RdSampleDly (+CL)       Phase   RL ADLL value */
+       /*0             2               3               1 */
+       {0x000016A0, 0xC0020104},
+       /*1             2               2               6 */
+       {0x000016A0, 0xC0420010},
+       /*2             2               3               16 */
+       {0x000016A0, 0xC0820112},
+       /*3             2               1               26 */
+       {0x000016A0, 0xC0C20009},
+       /*4             2               2               29 */
+       {0x000016A0, 0xC102001F},
+       /*5             2               2               13 */
+       {0x000016A0, 0xC1420014},
+       /*6             2               3               6 */
+       {0x000016A0, 0xC1820109},
+       /*7             2               1               31 */
+       {0x000016A0, 0xC1C2000C},
+       /*8             2               2               22 */
+       {0x000016A0, 0xC2020112},
+
+       /* Write Leveling */
+       /*0 */
+       {0x000016A0, 0xC0009919},
+       /*1 */
+       {0x000016A0, 0xC0405508},
+       /*2 */
+       {0x000016A0, 0xC0809919},
+       /*3 */
+       {0x000016A0, 0xC0C09C1A},
+       /*4 */
+       {0x000016A0, 0xC1008113},
+       /*5 */
+       {0x000016A0, 0xC140650C},
+       /*6 */
+       {0x000016A0, 0xC1809518},
+       /*7 */
+       {0x000016A0, 0xC1C04103},
+       /*8 */
+       {0x000016A0, 0xC2006D0E},
+
+       /*center DQS on read cycle */
+       {0x000016A0, 0xC803000F},
+
+       {0x00001538, 0x0000000B},       /*Read Data Sample Delays Register */
+       {0x0000153C, 0x0000000F},       /*Read Data Ready Delay Register */
+       /*init DRAM */
+       {0x00001480, 0x00000001},
+       {0x0, 0x0}
+};
+
+MV_DRAM_TRAINING_INIT ddr3_db_667[MV_MAX_DDR3_STATIC_SIZE] = {
+
+       /* Read Leveling */
+       /*PUP   RdSampleDly (+CL)       Phase   RL ADLL value */
+       /*0             2               3               1 */
+       {0x000016A0, 0xC0020103},
+       /*1            2               2               6 */
+       {0x000016A0, 0xC0420012},
+       /*2            2               3               16 */
+       {0x000016A0, 0xC0820113},
+       /*3            2               1               26 */
+       {0x000016A0, 0xC0C20012},
+       /*4            2               2               29 */
+       {0x000016A0, 0xC1020100},
+       /*5            2               2               13 */
+       {0x000016A0, 0xC1420016},
+       /*6            2               3               6 */
+       {0x000016A0, 0xC1820109},
+       /*7            2               1               31 */
+       {0x000016A0, 0xC1C20010},
+       /*8            2               2               22 */
+       {0x000016A0, 0xC2020112},
+
+       /* Write Leveling */
+       /*0 */
+       {0x000016A0, 0xC000b11F},
+       /*1 */
+       {0x000016A0, 0xC040690D},
+       /*2 */
+       {0x000016A0, 0xC0803600},
+       /*3 */
+       {0x000016A0, 0xC0C0a81D},
+       /*4 */
+       {0x000016A0, 0xC1009919},
+       /*5 */
+       {0x000016A0, 0xC1407911},
+       /*6 */
+       {0x000016A0, 0xC180ad1e},
+       /*7 */
+       {0x000016A0, 0xC1C04d06},
+       /*8 */
+       {0x000016A0, 0xC2008514},
+
+       /*center DQS on read cycle */
+       {0x000016A0, 0xC803000F},
+
+       {0x00001538, 0x0000000B},       /*Read Data Sample Delays Register */
+       {0x0000153C, 0x0000000F},       /*Read Data Ready Delay Register */
+
+       /*init DRAM */
+       {0x00001480, 0x00000001},
+       {0x0, 0x0}
+};
+
+MV_DRAM_TRAINING_INIT ddr3_db_800[MV_MAX_DDR3_STATIC_SIZE] = {
+
+       /* Read Leveling */
+       /*PUP   RdSampleDly (+CL)       Phase   RL ADLL value */
+       /*0             2               3               1 */
+       {0x000016A0, 0xC0020213},
+       /*1            2               2               6 */
+       {0x000016A0, 0xC0420108},
+       /*2            2               3               16 */
+       {0x000016A0, 0xC0820210},
+       /*3            2               1               26 */
+       {0x000016A0, 0xC0C20108},
+       /*4            2               2               29 */
+       {0x000016A0, 0xC102011A},
+       /*5            2               2               13 */
+       {0x000016A0, 0xC1420300},
+       /*6            2               3               6 */
+       {0x000016A0, 0xC1820204},
+       /*7            2               1               31 */
+       {0x000016A0, 0xC1C20106},
+       /*8            2               2               22 */
+       {0x000016A0, 0xC2020112},
+
+       /* Write Leveling */
+       /*0 */
+       {0x000016A0, 0xC000620B},
+       /*1 */
+       {0x000016A0, 0xC0408D16},
+       /*2 */
+       {0x000016A0, 0xC0806A0D},
+       /*3 */
+       {0x000016A0, 0xC0C03D02},
+       /*4 */
+       {0x000016A0, 0xC1004a05},
+       /*5 */
+       {0x000016A0, 0xC140A11B},
+       /*6 */
+       {0x000016A0, 0xC1805E0A},
+       /*7 */
+       {0x000016A0, 0xC1C06D0E},
+       /*8 */
+       {0x000016A0, 0xC200AD1E},
+
+       /*center DQS on read cycle */
+       {0x000016A0, 0xC803000F},
+
+       {0x00001538, 0x0000000C},       /*Read Data Sample Delays Register */
+       {0x0000153C, 0x0000000E},       /*Read Data Ready Delay Register */
+
+       /*init DRAM */
+       {0x00001480, 0x00000001},
+       {0x0, 0x0}
+};
+
+MV_DRAM_TRAINING_INIT ddr3_rd_667_0[MV_MAX_DDR3_STATIC_SIZE] = {
+       /* Read Leveling */
+       /*PUP   RdSampleDly (+CL)       Phase   RL ADLL value */
+       /*0 */
+       {0x000016A0, 0xC002010E},
+       /*1 */
+       {0x000016A0, 0xC042001E},
+       /*2 */
+       {0x000016A0, 0xC0820118},
+       /*3 */
+       {0x000016A0, 0xC0C2001E},
+       /*4 */
+       {0x000016A0, 0xC102010C},
+       /*5 */
+       {0x000016A0, 0xC1420102},
+       /*6 */
+       {0x000016A0, 0xC1820111},
+       /*7 */
+       {0x000016A0, 0xC1C2001C},
+       /*8 */
+       {0x000016A0, 0xC2020109},
+
+       /* Write Leveling */
+       /*0 */
+       {0x000016A0, 0xC0003600},
+       /*1 */
+       {0x000016A0, 0xC040690D},
+       /*2 */
+       {0x000016A0, 0xC0805207},
+       /*3 */
+       {0x000016A0, 0xC0C0A81D},
+       /*4 */
+       {0x000016A0, 0xC1009919},
+       /*5 */
+       {0x000016A0, 0xC1407911},
+       /*6 */
+       {0x000016A0, 0xC1803E02},
+       /*7 */
+       {0x000016A0, 0xC1C05107},
+       /*8 */
+       {0x000016A0, 0xC2008113},
+
+       /*center DQS on read cycle */
+       {0x000016A0, 0xC803000F},
+
+       {0x00001538, 0x0000000B},       /*Read Data Sample Delays Register */
+       {0x0000153C, 0x0000000F},       /*Read Data Ready Delay Register */
+
+       /*init DRAM */
+       {0x00001480, 0x00000001},
+       {0x0, 0x0}
+};
+
+MV_DRAM_TRAINING_INIT ddr3_rd_667_1[MV_MAX_DDR3_STATIC_SIZE] = {
+       /* Read Leveling */
+       /*PUP   RdSampleDly (+CL)       Phase   RL ADLL value */
+       /*0 */
+       {0x000016A0, 0xC0020106},
+       /*1 */
+       {0x000016A0, 0xC0420016},
+       /*2 */
+       {0x000016A0, 0xC0820117},
+       /*3 */
+       {0x000016A0, 0xC0C2000F},
+       /*4 */
+       {0x000016A0, 0xC1020105},
+       /*5 */
+       {0x000016A0, 0xC142001B},
+       /*6 */
+       {0x000016A0, 0xC182010C},
+       /*7 */
+       {0x000016A0, 0xC1C20011},
+       /*8 */
+       {0x000016A0, 0xC2020101},
+
+       /* Write Leveling */
+       /*0 */
+       {0x000016A0, 0xC0003600},
+       /*1 */
+       {0x000016A0, 0xC0406D0E},
+       /*2 */
+       {0x000016A0, 0xC0803600},
+       /*3 */
+       {0x000016A0, 0xC0C04504},
+       /*4 */
+       {0x000016A0, 0xC1009919},
+       /*5 */
+       {0x000016A0, 0xC1407911},
+       /*6 */
+       {0x000016A0, 0xC1803600},
+       /*7 */
+       {0x000016A0, 0xC1C0610B},
+       /*8 */
+       {0x000016A0, 0xC2008113},
+
+       /*center DQS on read cycle */
+       {0x000016A0, 0xC803000F},
+
+       {0x00001538, 0x0000000B},       /*Read Data Sample Delays Register */
+       {0x0000153C, 0x0000000F},       /*Read Data Ready Delay Register */
+
+       /*init DRAM */
+       {0x00001480, 0x00000001},
+       {0x0, 0x0}
+};
+
+MV_DRAM_TRAINING_INIT ddr3_rd_667_2[MV_MAX_DDR3_STATIC_SIZE] = {
+       /* Read Leveling */
+       /*PUP   RdSampleDly (+CL)       Phase   RL ADLL value */
+       /*0 */
+       {0x000016A0, 0xC002010C},
+       /*1 */
+       {0x000016A0, 0xC042001B},
+       /*2 */
+       {0x000016A0, 0xC082011D},
+       /*3 */
+       {0x000016A0, 0xC0C20015},
+       /*4 */
+       {0x000016A0, 0xC102010B},
+       /*5 */
+       {0x000016A0, 0xC1420101},
+       /*6 */
+       {0x000016A0, 0xC1820113},
+       /*7 */
+       {0x000016A0, 0xC1C20017},
+       /*8 */
+       {0x000016A0, 0xC2020107},
+
+       /* Write Leveling */
+       /*0 */
+       {0x000016A0, 0xC0003600},
+       /*1 */
+       {0x000016A0, 0xC0406D0E},
+       /*2 */
+       {0x000016A0, 0xC0803600},
+       /*3 */
+       {0x000016A0, 0xC0C04504},
+       /*4 */
+       {0x000016A0, 0xC1009919},
+       /*5 */
+       {0x000016A0, 0xC1407911},
+       /*6 */
+       {0x000016A0, 0xC180B11F},
+       /*7 */
+       {0x000016A0, 0xC1C0610B},
+       /*8 */
+       {0x000016A0, 0xC2008113},
+
+       /*center DQS on read cycle */
+       {0x000016A0, 0xC803000F},
+
+       {0x00001538, 0x0000000B},       /*Read Data Sample Delays Register */
+       {0x0000153C, 0x0000000F},       /*Read Data Ready Delay Register */
+
+       /*init DRAM */
+       {0x00001480, 0x00000001},
+       {0x0, 0x0}
+};
+
+MV_DRAM_TRAINING_INIT ddr3_db_667_M[MV_MAX_DDR3_STATIC_SIZE] = {
+       /* Read Leveling */
+       /*PUP   RdSampleDly (+CL)       Phase   RL ADLL value */
+       /* CS 0 */
+       /*0             2               3               1 */
+       {0x000016A0, 0xC0020103},
+       /*1            2               2               6 */
+       {0x000016A0, 0xC0420012},
+       /*2            2               3               16 */
+       {0x000016A0, 0xC0820113},
+       /*3            2               1               26 */
+       {0x000016A0, 0xC0C20012},
+       /*4            2               2               29 */
+       {0x000016A0, 0xC1020100},
+       /*5            2               2               13 */
+       {0x000016A0, 0xC1420016},
+       /*6            2               3               6 */
+       {0x000016A0, 0xC1820109},
+       /*7            2               1               31 */
+       {0x000016A0, 0xC1C20010},
+       /*8            2               2               22 */
+       {0x000016A0, 0xC2020112},
+
+       /* Write Leveling */
+       /*0 */
+       {0x000016A0, 0xC000b11F},
+       /*1 */
+       {0x000016A0, 0xC040690D},
+       /*2 */
+       {0x000016A0, 0xC0803600},
+       /*3 */
+       {0x000016A0, 0xC0C0a81D},
+       /*4 */
+       {0x000016A0, 0xC1009919},
+       /*5 */
+       {0x000016A0, 0xC1407911},
+       /*6 */
+       {0x000016A0, 0xC180ad1e},
+       /*7 */
+       {0x000016A0, 0xC1C04d06},
+       /*8 */
+       {0x000016A0, 0xC2008514},
+
+       /*center DQS on read cycle */
+       {0x000016A0, 0xC803000F},
+
+       /* CS 1 */
+
+       {0x000016A0, 0xC0060103},
+       /*1            2               2               6 */
+       {0x000016A0, 0xC0460012},
+       /*2            2               3               16 */
+       {0x000016A0, 0xC0860113},
+       /*3            2               1               26 */
+       {0x000016A0, 0xC0C60012},
+       /*4            2               2               29 */
+       {0x000016A0, 0xC1060100},
+       /*5            2               2               13 */
+       {0x000016A0, 0xC1460016},
+       /*6            2               3               6 */
+       {0x000016A0, 0xC1860109},
+       /*7            2               1               31 */
+       {0x000016A0, 0xC1C60010},
+       /*8            2               2               22 */
+       {0x000016A0, 0xC2060112},
+
+       /* Write Leveling */
+       /*0 */
+       {0x000016A0, 0xC004b11F},
+       /*1 */
+       {0x000016A0, 0xC044690D},
+       /*2 */
+       {0x000016A0, 0xC0843600},
+       /*3 */
+       {0x000016A0, 0xC0C4a81D},
+       /*4 */
+       {0x000016A0, 0xC1049919},
+       /*5 */
+       {0x000016A0, 0xC1447911},
+       /*6 */
+       {0x000016A0, 0xC184ad1e},
+       /*7 */
+       {0x000016A0, 0xC1C44d06},
+       /*8 */
+       {0x000016A0, 0xC2048514},
+
+       /*center DQS on read cycle */
+       {0x000016A0, 0xC807000F},
+
+       /* Both CS */
+
+       {0x00001538, 0x00000B0B},       /*Read Data Sample Delays Register */
+       {0x0000153C, 0x00000F0F},       /*Read Data Ready Delay Register */
+
+       /*init DRAM */
+       {0x00001480, 0x00000001},
+       {0x0, 0x0}
+};
+
+MV_DRAM_TRAINING_INIT ddr3_rd_667_3[MV_MAX_DDR3_STATIC_SIZE] = {
+       /* Read Leveling */
+       /*PUP   RdSampleDly (+CL)       Phase   RL ADLL value */
+       /*0 */
+       {0x000016A0, 0xC0020118},
+       /*1 */
+       {0x000016A0, 0xC0420108},
+       /*2 */
+       {0x000016A0, 0xC0820202},
+       /*3 */
+       {0x000016A0, 0xC0C20108},
+       /*4 */
+       {0x000016A0, 0xC1020117},
+       /*5 */
+       {0x000016A0, 0xC142010C},
+       /*6 */
+       {0x000016A0, 0xC182011B},
+       /*7 */
+       {0x000016A0, 0xC1C20107},
+       /*8 */
+       {0x000016A0, 0xC2020113},
+
+       /* Write Leveling */
+       /*0 */
+       {0x000016A0, 0xC0003600},
+       /*1 */
+       {0x000016A0, 0xC0406D0E},
+       /*2 */
+       {0x000016A0, 0xC0805207},
+       /*3 */
+       {0x000016A0, 0xC0C0A81D},
+       /*4 */
+       {0x000016A0, 0xC1009919},
+       /*5 */
+       {0x000016A0, 0xC1407911},
+       /*6 */
+       {0x000016A0, 0xC1803E02},
+       /*7 */
+       {0x000016A0, 0xC1C04D06},
+       /*8 */
+       {0x000016A0, 0xC2008113},
+
+       /*center DQS on read cycle */
+       {0x000016A0, 0xC803000F},
+
+       {0x00001538, 0x0000000B},       /*Read Data Sample Delays Register */
+       {0x0000153C, 0x0000000F},       /*Read Data Ready Delay Register */
+
+       /*init DRAM */
+       {0x00001480, 0x00000001},
+       {0x0, 0x0}
+};
+
+MV_DRAM_TRAINING_INIT ddr3_pcac_600[MV_MAX_DDR3_STATIC_SIZE] = {
+       /* Read Leveling */
+       /*PUP   RdSampleDly (+CL)       Phase   RL ADLL value */
+       /*0 */
+       {0x000016A0, 0xC0020404},
+       /* 1           2               2               6 */
+       {0x000016A0, 0xC042031E},
+       /* 2           2               3               16 */
+       {0x000016A0, 0xC0820411},
+       /* 3           2               1               26 */
+       {0x000016A0, 0xC0C20400},
+       /* 4           2               2               29 */
+       {0x000016A0, 0xC1020404},
+       /* 5           2               2               13 */
+       {0x000016A0, 0xC142031D},
+       /* 6           2               3               6 */
+       {0x000016A0, 0xC182040C},
+       /* 7           2               1               31 */
+       {0x000016A0, 0xC1C2031B},
+       /* 8           2               2               22 */
+       {0x000016A0, 0xC2020112},
+
+       /*  Write Leveling */
+       /* 0 */
+       {0x000016A0, 0xC0004905},
+       /* 1 */
+       {0x000016A0, 0xC040A81D},
+       /* 2 */
+       {0x000016A0, 0xC0804504},
+       /* 3 */
+       {0x000016A0, 0xC0C08013},
+       /* 4 */
+       {0x000016A0, 0xC1004504},
+       /* 5 */
+       {0x000016A0, 0xC140A81D},
+       /* 6 */
+       {0x000016A0, 0xC1805909},
+       /* 7 */
+       {0x000016A0, 0xC1C09418},
+       /* 8 */
+       {0x000016A0, 0xC2006D0E},
+
+       /*center DQS on read cycle */
+       {0x000016A0, 0xC803000F},
+       {0x00001538, 0x00000009},       /*Read Data Sample Delays Register */
+       {0x0000153C, 0x0000000D},       /*Read Data Ready Delay Register */
+       /* init DRAM */
+       {0x00001480, 0x00000001},
+       {0x0, 0x0}
+};
+
+#endif /* __AXP_TRAINING_STATIC_H */
diff --git a/drivers/ddr/mvebu/ddr3_axp_vars.h b/drivers/ddr/mvebu/ddr3_axp_vars.h
new file mode 100644 (file)
index 0000000..1b0ab56
--- /dev/null
@@ -0,0 +1,226 @@
+/*
+ * Copyright (C) Marvell International Ltd. and its affiliates
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#ifndef __AXP_VARS_H
+#define __AXP_VARS_H
+
+#include "ddr3_axp_config.h"
+#include "ddr3_axp_mc_static.h"
+#include "ddr3_axp_training_static.h"
+
+MV_DRAM_MODES ddr_modes[MV_DDR3_MODES_NUMBER] = {
+       /*      Conf name               CPUFreq         FabFreq         Chip ID Chip/Board      MC regs                 Training Values */
+       /* db board values: */
+       {"db_800-400", 0xA, 0x5, 0x0, A0, ddr3_A0_db_400, NULL},
+       {"db_1200-300", 0x2, 0xC, 0x0, A0, ddr3_A0_db_400, NULL},
+       {"db_1200-600", 0x2, 0x5, 0x0, A0, NULL, NULL},
+       {"db_1333-667", 0x3, 0x5, 0x0, A0, ddr3_A0_db_667, ddr3_db_rev2_667},
+       {"db_1600-800", 0xB, 0x5, 0x0, A0, ddr3_A0_db_667, ddr3_db_rev2_800},
+       {"amc_1333-667", 0x3, 0x5, 0x0, A0_AMC, ddr3_A0_AMC_667, NULL},
+       {"db_667-667", 0x9, 0x13, 0x0, Z1, ddr3_Z1_db_600, ddr3_db_667},
+       {"db_800-400", 0xA, 0x1, 0x0, Z1, ddr3_Z1_db_300, ddr3_db_400},
+       {"db_1066-533", 0x1, 0x1, 0x0, Z1, ddr3_Z1_db_300, ddr3_db_533},
+       {"db_1200-300", 0x2, 0xC, 0x0, Z1, ddr3_Z1_db_300, ddr3_db_667},
+       {"db_1200-600", 0x2, 0x5, 0x0, Z1, ddr3_Z1_db_600, NULL},
+       {"db_1333-333", 0x3, 0xC, 0x0, Z1, ddr3_Z1_db_300, ddr3_db_400},
+       {"db_1333-667", 0x3, 0x5, 0x0, Z1, ddr3_Z1_db_600, ddr3_db_667},
+       /* pcac board values (Z1 device): */
+       {"pcac_1200-600", 0x2, 0x5, 0x0, Z1_PCAC, ddr3_Z1_db_600,
+        ddr3_pcac_600},
+       /* rd board values (Z1 device): */
+       {"rd_667_0", 0x3, 0x5, 0x0, Z1_RD_SLED, ddr3_Z1_db_600, ddr3_rd_667_0},
+       {"rd_667_1", 0x3, 0x5, 0x1, Z1_RD_SLED, ddr3_Z1_db_600, ddr3_rd_667_1},
+       {"rd_667_2", 0x3, 0x5, 0x2, Z1_RD_SLED, ddr3_Z1_db_600, ddr3_rd_667_2},
+       {"rd_667_3", 0x3, 0x5, 0x3, Z1_RD_SLED, ddr3_Z1_db_600, ddr3_rd_667_3}
+};
+
+/* ODT settings - if needed update the following tables: (ODT_OPT - represents the CS configuration bitmap) */
+
+u16 odt_static[ODT_OPT][MAX_CS] = {    /*        NearEnd/FarEnd */
+       {0, 0, 0, 0},           /* 0000         0/0 - Not supported */
+       {ODT40, 0, 0, 0},       /* 0001         0/1 */
+       {0, 0, 0, 0},           /* 0010         0/0 - Not supported */
+       {ODT40, ODT40, 0, 0},   /* 0011         0/2 */
+       {0, 0, ODT40, 0},       /* 0100         1/0 */
+       {ODT30, 0, ODT30, 0},   /* 0101         1/1 */
+       {0, 0, 0, 0},           /* 0110         0/0 - Not supported */
+       {ODT120, ODT20, ODT20, 0},      /* 0111         1/2 */
+       {0, 0, 0, 0},           /* 1000         0/0 - Not supported */
+       {0, 0, 0, 0},           /* 1001         0/0 - Not supported */
+       {0, 0, 0, 0},           /* 1010         0/0 - Not supported */
+       {0, 0, 0, 0},           /* 1011         0/0 - Not supported */
+       {0, 0, ODT40, 0},       /* 1100         2/0 */
+       {ODT20, 0, ODT120, ODT20},      /* 1101         2/1 */
+       {0, 0, 0, 0},           /* 1110         0/0 - Not supported */
+       {ODT120, ODT30, ODT120, ODT30}  /* 1111         2/2 */
+};
+
+u16 odt_dynamic[ODT_OPT][MAX_CS] = {   /*        NearEnd/FarEnd */
+       {0, 0, 0, 0},           /* 0000         0/0 */
+       {0, 0, 0, 0},           /* 0001         0/1 */
+       {0, 0, 0, 0},           /* 0010         0/0 - Not supported */
+       {0, 0, 0, 0},           /* 0011         0/2 */
+       {0, 0, 0, 0},           /* 0100         1/0 */
+       {ODT120D, 0, ODT120D, 0},       /* 0101         1/1 */
+       {0, 0, 0, 0},           /* 0110         0/0 - Not supported */
+       {0, 0, ODT120D, 0},     /* 0111         1/2 */
+       {0, 0, 0, 0},           /* 1000         0/0 - Not supported */
+       {0, 0, 0, 0},           /* 1001         0/0 - Not supported */
+       {0, 0, 0, 0},           /* 1010         0/0 - Not supported */
+       {0, 0, 0, 0},           /* 1011         0/0 - Not supported */
+       {0, 0, 0, 0},           /* 1100         2/0 */
+       {ODT120D, 0, 0, 0},     /* 1101         2/1 */
+       {0, 0, 0, 0},           /* 1110         0/0 - Not supported */
+       {0, 0, 0, 0}            /* 1111         2/2 */
+};
+
+u32 odt_config[ODT_OPT] = {
+       0, 0x00010000, 0, 0x00030000, 0x04000000, 0x05050104, 0, 0x07430340, 0,
+           0, 0, 0,
+       0x30000, 0x1C0D100C, 0, 0x3CC330C0
+};
+
+/*
+ * User can manually set SPD values (in case SPD is not available on
+ * DIMM/System).
+ * SPD Values can simplify calculating the DUNIT registers values
+ */
+u8 spd_data[SPD_SIZE] = {
+       /* AXP DB Board DIMM SPD Values - manually set */
+       0x92, 0x10, 0x0B, 0x2, 0x3, 0x19, 0x0, 0x9, 0x09, 0x52, 0x1, 0x8, 0x0C,
+       0x0, 0x7E, 0x0, 0x69, 0x78,
+       0x69, 0x30, 0x69, 0x11, 0x20, 0x89, 0x0, 0x5, 0x3C, 0x3C, 0x0, 0xF0,
+       0x82, 0x5, 0x80, 0x0, 0x0, 0x0,
+       0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
+       0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
+       0x0, 0x0, 0x0, 0x0, 0x0F, 0x1, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
+       0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
+       0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
+       0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
+       0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
+       0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
+       0x0, 0x80, 0x2C, 0x1, 0x10, 0x23, 0x35, 0x28, 0xEB, 0xCA, 0x19, 0x8F
+};
+
+/*
+ * Controller Specific configurations Starts Here - DO NOT MODIFY
+ */
+
+/* Frequency - values are 1/HCLK in ps */
+u32 cpu_fab_clk_to_hclk[FAB_OPT][CLK_CPU] =
+/* CPU Frequency:
+       1000    1066    1200    1333    1500    1666    1800    2000    600             667             800             1600    Fabric */
+{
+       {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+       {0, 0, 0, 0, 0, 0, 0, 0, 0, 3000, 2500, 0},
+       {0, 0, 0, 0, 0, 0, 0, 0, 0, 4500, 3750, 0},
+       {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+       {0, 0, 2500, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+       {4000, 3750, 3333, 3000, 2666, 2400, 0, 0, 0, 0, 5000, 2500},
+       {0, 0, 0, 0, 0, 0, 0, 0, 0, 3000, 0, 0},
+       {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+       {2500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+       {0, 0, 5000, 0, 4000, 0, 0, 0, 0, 0, 0, 3750},
+       {5000, 0, 0, 3750, 3333, 0, 0, 0, 0, 0, 0, 3125},
+       {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+       {0, 0, 3330, 3000, 0, 0, 0, 0, 0, 0, 0, 2500},
+       {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3750},
+       {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+       {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+       {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+       {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+       {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+       {0, 0, 0, 0, 0, 0, 0, 0, 0, 3000, 2500, 0},
+       {3000, 0, 2500, 0, 0, 0, 0, 0, 0, 0, 3750, 0}
+};
+
+u32 cpu_ddr_ratios[FAB_OPT][CLK_CPU] =
+/* CPU Frequency:
+       1000    1066    1200    1333    1500    1666    1800    2000    600             667             800             1600    Fabric */
+{
+       {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+       {0, 0, 0, 0, 0, 0, 0, 0, 0, DDR_333, DDR_400, 0},
+       {0, 0, 0, 0, 0, 0, 0, 0, 0, DDR_444, DDR_533, 0},
+       {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+       {0, 0, DDR_400, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+       {DDR_500, DDR_533, DDR_600, DDR_666, DDR_750, DDR_833, 0, 0, 0, 0,
+        DDR_400, DDR_800},
+       {0, 0, 0, 0, 0, 0, 0, 0, 0, DDR_333, 0, 0},
+       {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+       {DDR_400, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+       {0, 0, DDR_400, 0, DDR_500, 0, 0, 0, 0, 0, 0, DDR_533},
+       {DDR_400, 0, 0, DDR_533, DDR_600, 0, 0, 0, 0, 0, 0, DDR_640},
+       {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+       {0, 0, DDR_300, DDR_333, 0, 0, 0, 0, 0, 0, 0, DDR_400},
+       {0, 0, 0, 0, 0, 0, DDR_600, DDR_666, 0, 0, 0, DDR_533},
+       {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+       {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+       {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+       {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+       {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+       {0, 0, 0, 0, 0, 0, 0, 0, 0, DDR_666, DDR_800, 0},
+       {DDR_666, 0, DDR_800, 0, 0, 0, 0, 0, 0, 0, DDR_533, 0}
+};
+
+u8 div_ratio1to1[CLK_VCO][CLK_DDR] =
+/* DDR Frequency:
+       100             300     360     400     444     500     533     600     666     750     800     833  */
+{ {0xA, 3, 0, 3, 0, 2, 0, 0, 0, 0, 0, 0},      /*  1:1     CLK_CPU_1000  */
+{0xB, 3, 0, 3, 0, 0, 2, 0, 0, 0, 0, 0},        /*  1:1     CLK_CPU_1066  */
+{0xC, 4, 0, 3, 0, 0, 0, 2, 0, 0, 0, 0},        /*  1:1     CLK_CPU_1200  */
+{0xD, 4, 0, 4, 0, 0, 0, 0, 2, 0, 0, 0},        /*      1:1     CLK_CPU_1333  */
+{0xF, 5, 0, 4, 0, 3, 0, 0, 0, 0, 0, 0},        /*      1:1     CLK_CPU_1500  */
+{0x11, 5, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0},       /*      1:1     CLK_CPU_1666  */
+{0x12, 6, 5, 4, 0, 0, 0, 3, 0, 0, 0, 0},       /*      1:1     CLK_CPU_1800  */
+{0x14, 7, 0, 5, 0, 4, 0, 0, 3, 0, 0, 0},       /*      1:1     CLK_CPU_2000  */
+{0x6, 2, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0},        /*      1:1 CLK_CPU_600   */
+{0x6, 2, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0},        /*      1:1     CLK_CPU_667   */
+{0x8, 2, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0},        /*      1:1 CLK_CPU_800   */
+{0x10, 5, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0},       /*      1:1 CLK_CPU_1600   */
+{0x14, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0},       /*  1:1     CLK_CPU_1000 VCO_2000 */
+{0x15, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0},       /*  1:1     CLK_CPU_1066 VCO_2133 */
+{0x18, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0},       /*  1:1     CLK_CPU_1200 VCO_2400 */
+{0x1A, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0},       /*      1:1     CLK_CPU_1333 VCO_2666 */
+{0x1E, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0},       /*      1:1     CLK_CPU_1500 VCO_3000 */
+{0x21, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0},       /*      1:1     CLK_CPU_1666 VCO_3333 */
+{0x24, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0},       /*      1:1     CLK_CPU_1800 VCO_3600 */
+{0x28, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0},      /*      1:1     CLK_CPU_2000 VCO_4000 */
+{0xC, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0},        /*      1:1 CLK_CPU_600 VCO_1200 */
+{0xD, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0},        /*      1:1     CLK_CPU_667 VCO_1333 */
+{0x10, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0},       /*  1:1 CLK_CPU_800 VCO_1600 */
+{0x20, 10, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0}       /*      1:1 CLK_CPU_1600 VCO_3200 */
+};
+
+u8 div_ratio2to1[CLK_VCO][CLK_DDR] =
+/* DDR Frequency:
+               100     300     360     400     444     500     533     600     666     750     800     833  */
+{ {0, 0, 0, 0, 0, 2, 0, 0, 3, 0, 0, 0},        /*      2:1     CLK_CPU_1000  */
+{0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0},  /*      2:1     CLK_CPU_1066  */
+{0, 0, 0, 3, 5, 0, 0, 2, 0, 0, 3, 3},  /*      2:1     CLK_CPU_1200  */
+{0, 0, 0, 0, 0, 0, 5, 0, 2, 0, 3, 0},  /*      2:1     CLK_CPU_1333  */
+{0, 0, 0, 0, 0, 3, 0, 5, 0, 2, 0, 0},  /*      2:1     CLK_CPU_1500  */
+{0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 2},  /*      2:1     CLK_CPU_1666  */
+{0, 0, 0, 0, 0, 0, 0, 3, 0, 5, 0, 0},  /*      2:1     CLK_CPU_1800  */
+{0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 5},  /*      2:1     CLK_CPU_2000  */
+{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},  /*      2:1     CLK_CPU_600   */
+{0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0},  /*  2:1 CLK_CPU_667   */
+{0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 1, 0},  /*      2:1 CLK_CPU_800   */
+{0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 2, 0},  /*      2:1 CLK_CPU_1600   */
+{0, 0, 0, 5, 0, 0, 0, 0, 3, 0, 0, 0},  /*      2:1     CLK_CPU_1000 VCO_2000 */
+{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},  /*      2:1     CLK_CPU_1066 VCO_2133 */
+{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0},  /*      2:1     CLK_CPU_1200 VCO_2400 */
+{0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0},  /*      2:1     CLK_CPU_1333 VCO_2666 */
+{0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0},  /*      2:1     CLK_CPU_1500 VCO_3000 */
+{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},  /*      2:1     CLK_CPU_1666 VCO_3333 */
+{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},  /*      2:1     CLK_CPU_1800 VCO_3600 */
+{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},  /*      2:1     CLK_CPU_2000 VCO_4000 */
+{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},  /*      2:1     CLK_CPU_600 VCO_1200 */
+{0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0},  /*  2:1 CLK_CPU_667 VCO_1333 */
+{0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0},  /*      2:1 CLK_CPU_800 VCO_1600 */
+{0, 0, 0, 0, 0, 0, 0, 5, 5, 0, 0, 0}   /*      2:1 CLK_CPU_1600 VCO_3200 */
+};
+
+#endif /* __AXP_VARS_H */
diff --git a/drivers/ddr/mvebu/ddr3_dfs.c b/drivers/ddr/mvebu/ddr3_dfs.c
new file mode 100644 (file)
index 0000000..9347773
--- /dev/null
@@ -0,0 +1,1552 @@
+/*
+ * Copyright (C) Marvell International Ltd. and its affiliates
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#include <common.h>
+#include <i2c.h>
+#include <spl.h>
+#include <asm/io.h>
+#include <asm/arch/cpu.h>
+#include <asm/arch/soc.h>
+
+#include "ddr3_hw_training.h"
+
+/*
+ * Debug
+ */
+#define DEBUG_DFS_C(s, d, l) \
+       DEBUG_DFS_S(s); DEBUG_DFS_D(d, l); DEBUG_DFS_S("\n")
+#define DEBUG_DFS_FULL_C(s, d, l) \
+       DEBUG_DFS_FULL_S(s); DEBUG_DFS_FULL_D(d, l); DEBUG_DFS_FULL_S("\n")
+
+#ifdef MV_DEBUG_DFS
+#define DEBUG_DFS_S(s)                 puts(s)
+#define DEBUG_DFS_D(d, l)              printf("%x", d)
+#else
+#define DEBUG_DFS_S(s)
+#define DEBUG_DFS_D(d, l)
+#endif
+
+#ifdef MV_DEBUG_DFS_FULL
+#define DEBUG_DFS_FULL_S(s)            puts(s)
+#define DEBUG_DFS_FULL_D(d, l)         printf("%x", d)
+#else
+#define DEBUG_DFS_FULL_S(s)
+#define DEBUG_DFS_FULL_D(d, l)
+#endif
+
+#if defined(MV88F672X)
+extern u8 div_ratio[CLK_VCO][CLK_DDR];
+extern void get_target_freq(u32 freq_mode, u32 *ddr_freq, u32 *hclk_ps);
+#else
+extern u16 odt_dynamic[ODT_OPT][MAX_CS];
+extern u8 div_ratio1to1[CLK_CPU][CLK_DDR];
+extern u8 div_ratio2to1[CLK_CPU][CLK_DDR];
+#endif
+extern u16 odt_static[ODT_OPT][MAX_CS];
+
+extern u32 cpu_fab_clk_to_hclk[FAB_OPT][CLK_CPU];
+
+extern u32 ddr3_get_vco_freq(void);
+
+u32 ddr3_get_freq_parameter(u32 target_freq, int ratio_2to1);
+
+#ifdef MV_DEBUG_DFS
+static inline void dfs_reg_write(u32 addr, u32 val)
+{
+       printf("\n write reg 0x%08x = 0x%08x", addr, val);
+       writel(val, INTER_REGS_BASE + addr);
+}
+#else
+static inline void dfs_reg_write(u32 addr, u32 val)
+{
+       writel(val, INTER_REGS_BASE + addr);
+}
+#endif
+
+static void wait_refresh_op_complete(void)
+{
+       u32 reg;
+
+       /* Poll - Wait for Refresh operation completion */
+       do {
+               reg = reg_read(REG_SDRAM_OPERATION_ADDR) &
+                       REG_SDRAM_OPERATION_CMD_RFRS_DONE;
+       } while (reg);          /* Wait for '0' */
+}
+
+/*
+ * Name:     ddr3_get_freq_parameter
+ * Desc:     Finds CPU/DDR frequency ratio according to Sample@reset and table.
+ * Args:     target_freq - target frequency
+ * Notes:
+ * Returns:  freq_par - the ratio parameter
+ */
+u32 ddr3_get_freq_parameter(u32 target_freq, int ratio_2to1)
+{
+       u32 ui_vco_freq, freq_par;
+
+       ui_vco_freq = ddr3_get_vco_freq();
+
+#if defined(MV88F672X)
+       freq_par = div_ratio[ui_vco_freq][target_freq];
+#else
+       /* Find the ratio between PLL frequency and ddr-clk */
+       if (ratio_2to1)
+               freq_par = div_ratio2to1[ui_vco_freq][target_freq];
+       else
+               freq_par = div_ratio1to1[ui_vco_freq][target_freq];
+#endif
+
+       return freq_par;
+}
+
+/*
+ * Name:     ddr3_dfs_high_2_low
+ * Desc:
+ * Args:     freq - target frequency
+ * Notes:
+ * Returns:  MV_OK - success, MV_FAIL - fail
+ */
+int ddr3_dfs_high_2_low(u32 freq, MV_DRAM_INFO *dram_info)
+{
+#if defined(MV88F78X60) || defined(MV88F672X)
+       /* This Flow is relevant for ArmadaXP A0 */
+       u32 reg, freq_par, tmp;
+       u32 cs = 0;
+
+       DEBUG_DFS_C("DDR3 - DFS - High To Low - Starting DFS procedure to Frequency - ",
+                   freq, 1);
+
+       /* target frequency - 100MHz */
+       freq_par = ddr3_get_freq_parameter(freq, 0);
+
+#if defined(MV88F672X)
+       u32 hclk;
+       u32 cpu_freq = ddr3_get_cpu_freq();
+       get_target_freq(cpu_freq, &tmp, &hclk);
+#endif
+
+       /* Configure - DRAM DLL final state after DFS is complete - Enable */
+       reg = reg_read(REG_DFS_ADDR);
+       /* [0] - DfsDllNextState - Disable */
+       reg |= (1 << REG_DFS_DLLNEXTSTATE_OFFS);
+       dfs_reg_write(REG_DFS_ADDR, reg);       /* 0x1528 - DFS register */
+
+       /*
+        * Configure - XBAR Retry response during Block to enable internal
+        * access - Disable
+        */
+       reg = reg_read(REG_METAL_MASK_ADDR);
+       /* [0] - RetryMask - Disable */
+       reg &= ~(1 << REG_METAL_MASK_RETRY_OFFS);
+       /* 0x14B0 - Dunit MMask Register */
+       dfs_reg_write(REG_METAL_MASK_ADDR, reg);
+
+       /* Configure - Block new external transactions - Enable */
+       reg = reg_read(REG_DFS_ADDR);
+       reg |= (1 << REG_DFS_BLOCK_OFFS);       /* [1] - DfsBlock - Enable  */
+       dfs_reg_write(REG_DFS_ADDR, reg);       /* 0x1528 - DFS register */
+
+       /* Registered DIMM support */
+       if (dram_info->reg_dimm) {
+               /*
+                * Configure - Disable Register DIMM CKE Power
+                * Down mode - CWA_RC
+                */
+               reg = (0x9 & REG_SDRAM_OPERATION_CWA_RC_MASK) <<
+                       REG_SDRAM_OPERATION_CWA_RC_OFFS;
+               /*
+                * Configure - Disable Register DIMM CKE Power
+                * Down mode - CWA_DATA
+                */
+               reg |= ((0 & REG_SDRAM_OPERATION_CWA_DATA_MASK) <<
+                       REG_SDRAM_OPERATION_CWA_DATA_OFFS);
+
+               /*
+                * Configure - Disable Register DIMM CKE Power
+                * Down mode - Set Delay - tMRD
+                */
+               reg |= (0 << REG_SDRAM_OPERATION_CWA_DELAY_SEL_OFFS);
+
+               /* Configure - Issue CWA command with the above parameters */
+               reg |= (REG_SDRAM_OPERATION_CMD_CWA &
+                       ~(0xF << REG_SDRAM_OPERATION_CS_OFFS));
+
+               /* 0x1418 - SDRAM Operation Register */
+               dfs_reg_write(REG_SDRAM_OPERATION_ADDR, reg);
+
+               /* Poll - Wait for CWA operation completion */
+               do {
+                       reg = reg_read(REG_SDRAM_OPERATION_ADDR) &
+                              (REG_SDRAM_OPERATION_CMD_MASK);
+               } while (reg);
+
+               /* Configure - Disable outputs floating during Self Refresh */
+               reg = reg_read(REG_REGISTERED_DRAM_CTRL_ADDR);
+               /* [15] - SRFloatEn - Disable */
+               reg &= ~(1 << REG_REGISTERED_DRAM_CTRL_SR_FLOAT_OFFS);
+               /* 0x16D0 - DDR3 Registered DRAM Control */
+               dfs_reg_write(REG_REGISTERED_DRAM_CTRL_ADDR, reg);
+       }
+
+       /* Optional - Configure - DDR3_Rtt_nom_CS# */
+       for (cs = 0; cs < MAX_CS; cs++) {
+               if (dram_info->cs_ena & (1 << cs)) {
+                       reg = reg_read(REG_DDR3_MR1_CS_ADDR +
+                                      (cs << MR_CS_ADDR_OFFS));
+                       reg &= REG_DDR3_MR1_RTT_MASK;
+                       dfs_reg_write(REG_DDR3_MR1_CS_ADDR +
+                                     (cs << MR_CS_ADDR_OFFS), reg);
+               }
+       }
+
+       /* Configure - Move DRAM into Self Refresh */
+       reg = reg_read(REG_DFS_ADDR);
+       reg |= (1 << REG_DFS_SR_OFFS);  /* [2] - DfsSR - Enable */
+       dfs_reg_write(REG_DFS_ADDR, reg);       /* 0x1528 - DFS register */
+
+       /* Poll - Wait for Self Refresh indication */
+       do {
+               reg = ((reg_read(REG_DFS_ADDR)) & (1 << REG_DFS_ATSR_OFFS));
+       } while (reg == 0x0);   /* 0x1528 [3] - DfsAtSR - Wait for '1' */
+
+       /* Start of clock change procedure (PLL) */
+#if defined(MV88F672X)
+       /* avantaLP */
+       /* Configure    cpupll_clkdiv_reset_mask */
+       reg = reg_read(CPU_PLL_CLOCK_DIVIDER_CNTRL0);
+       reg &= CPU_PLL_CLOCK_DIVIDER_CNTRL0_MASK;
+       /* 0xE8264[7:0]   0xff CPU Clock Dividers Reset mask */
+       dfs_reg_write(CPU_PLL_CLOCK_DIVIDER_CNTRL0, (reg + 0xFF));
+
+       /* Configure    cpu_clkdiv_reload_smooth    */
+       reg = reg_read(CPU_PLL_CNTRL0);
+       reg &= CPU_PLL_CNTRL0_RELOAD_SMOOTH_MASK;
+       /* 0xE8260   [15:8]  0x2 CPU Clock Dividers Reload Smooth enable */
+       dfs_reg_write(CPU_PLL_CNTRL0,
+                     (reg + (2 << CPU_PLL_CNTRL0_RELOAD_SMOOTH_OFFS)));
+
+       /* Configure    cpupll_clkdiv_relax_en */
+       reg = reg_read(CPU_PLL_CNTRL0);
+       reg &= CPU_PLL_CNTRL0_RELAX_EN_MASK;
+       /* 0xE8260 [31:24] 0x2 Relax Enable */
+       dfs_reg_write(CPU_PLL_CNTRL0,
+                     (reg + (2 << CPU_PLL_CNTRL0_RELAX_EN_OFFS)));
+
+       /* Configure    cpupll_clkdiv_ddr_clk_ratio */
+       reg = reg_read(CPU_PLL_CLOCK_DIVIDER_CNTRL1);
+       /*
+        * 0xE8268  [13:8]  N   Set Training clock:
+        * APLL Out Clock (VCO freq) / N = 100 MHz
+        */
+       reg &= CPU_PLL_CLOCK_DIVIDER_CNTRL1_MASK;
+       reg |= (freq_par << 8); /* full Integer ratio from PLL-out to ddr-clk */
+       dfs_reg_write(CPU_PLL_CLOCK_DIVIDER_CNTRL1, reg);
+
+       /* Configure    cpupll_clkdiv_reload_ratio  */
+       reg = reg_read(CPU_PLL_CLOCK_DIVIDER_CNTRL0);
+       reg &= CPU_PLL_CLOCK_RELOAD_RATIO_MASK;
+       /* 0xE8264 [8]=0x1 CPU Clock Dividers Reload Ratio trigger set */
+       dfs_reg_write(CPU_PLL_CLOCK_DIVIDER_CNTRL0,
+                     (reg + (1 << CPU_PLL_CLOCK_RELOAD_RATIO_OFFS)));
+
+       udelay(1);
+
+       /* Configure    cpupll_clkdiv_reload_ratio  */
+       reg = reg_read(CPU_PLL_CLOCK_DIVIDER_CNTRL0);
+       reg &= CPU_PLL_CLOCK_RELOAD_RATIO_MASK;
+       /* 0xE8264 [8]=0x0 CPU Clock Dividers Reload Ratio trigger clear */
+       dfs_reg_write(CPU_PLL_CLOCK_DIVIDER_CNTRL0, reg);
+
+       udelay(5);
+
+#else
+       /*
+        * Initial Setup - assure that the "load new ratio" is clear (bit 24)
+        * and in the same chance, block reassertions of reset [15:8] and
+        * force reserved bits[7:0].
+        */
+       reg = 0x0000FDFF;
+       /* 0x18700 - CPU Div CLK control 0 */
+       dfs_reg_write(REG_CPU_DIV_CLK_CTRL_0_ADDR, reg);
+
+       /*
+        * RelaX whenever reset is asserted to that channel
+        * (good for any case)
+        */
+       reg = 0x0000FF00;
+       /* 0x18704 - CPU Div CLK control 0 */
+       dfs_reg_write(REG_CPU_DIV_CLK_CTRL_1_ADDR, reg);
+
+       reg = reg_read(REG_CPU_DIV_CLK_CTRL_2_ADDR) &
+               REG_CPU_DIV_CLK_CTRL_3_FREQ_MASK;
+
+       /* full Integer ratio from PLL-out to ddr-clk */
+       reg |= (freq_par << REG_CPU_DIV_CLK_CTRL_3_FREQ_OFFS);
+       /* 0x1870C - CPU Div CLK control 3 register */
+       dfs_reg_write(REG_CPU_DIV_CLK_CTRL_2_ADDR, reg);
+
+       /*
+        * Shut off clock enable to the DDRPHY clock channel (this is the "D").
+        * All the rest are kept as is (forced, but could be read-modify-write).
+        * This is done now by RMW above.
+        */
+
+       /* Clock is not shut off gracefully - keep it running */
+       reg = 0x000FFF02;
+       dfs_reg_write(REG_CPU_DIV_CLK_CTRL_4_ADDR, reg);
+
+       /* Wait before replacing the clock on the DDR Phy Channel. */
+       udelay(1);
+
+       /*
+        * This for triggering the frequency update. Bit[24] is the
+        * central control
+        * bits [23:16] == which channels to change ==2 ==>
+        *                 only DDR Phy (smooth transition)
+        * bits [15:8] == mask reset reassertion due to clock modification
+        *                to these channels.
+        * bits [7:0] == not in use
+        */
+       reg = 0x0102FDFF;
+       /* 0x18700 - CPU Div CLK control 0 register */
+       dfs_reg_write(REG_CPU_DIV_CLK_CTRL_0_ADDR, reg);
+
+       udelay(1);              /* Wait 1usec */
+
+       /*
+        * Poll Div CLK status 0 register - indication that the clocks
+        * are active - 0x18718 [8]
+        */
+       do {
+               reg = (reg_read(REG_CPU_DIV_CLK_STATUS_0_ADDR)) &
+                       (1 << REG_CPU_DIV_CLK_ALL_STABLE_OFFS);
+       } while (reg == 0);
+
+       /*
+        * Clean the CTRL0, to be ready for next resets and next requests
+        * of ratio modifications.
+        */
+       reg = 0x000000FF;
+       /* 0x18700 - CPU Div CLK control 0 register */
+       dfs_reg_write(REG_CPU_DIV_CLK_CTRL_0_ADDR, reg);
+
+       udelay(5);
+#endif
+       /* End of clock change procedure (PLL) */
+
+       /* Configure - Select normal clock for the DDR PHY - Enable */
+       reg = reg_read(REG_DRAM_INIT_CTRL_STATUS_ADDR);
+       /* [16] - ddr_phy_trn_clk_sel - Enable  */
+       reg |= (1 << REG_DRAM_INIT_CTRL_TRN_CLK_OFFS);
+       /* 0x18488 - DRAM Init control status register */
+       dfs_reg_write(REG_DRAM_INIT_CTRL_STATUS_ADDR, reg);
+
+       /* Configure - Set Correct Ratio - 1:1 */
+       /* [15] - Phy2UnitClkRatio = 0 - Set 1:1 Ratio between Dunit and Phy */
+
+       reg = reg_read(REG_DDR_IO_ADDR) & ~(1 << REG_DDR_IO_CLK_RATIO_OFFS);
+       dfs_reg_write(REG_DDR_IO_ADDR, reg);    /* 0x1524 - DDR IO Register */
+
+       /* Configure - 2T Mode - Restore original configuration */
+       reg = reg_read(REG_DUNIT_CTRL_LOW_ADDR);
+       /* [3:4] 2T - 1T Mode - low freq */
+       reg &= ~(REG_DUNIT_CTRL_LOW_2T_MASK << REG_DUNIT_CTRL_LOW_2T_OFFS);
+       /* 0x1404 - DDR Controller Control Low Register */
+       dfs_reg_write(REG_DUNIT_CTRL_LOW_ADDR, reg);
+
+       /* Configure - Restore CL and CWL - MRS Commands */
+       reg = reg_read(REG_DFS_ADDR);
+       reg &= ~(REG_DFS_CL_NEXT_STATE_MASK << REG_DFS_CL_NEXT_STATE_OFFS);
+       reg &= ~(REG_DFS_CWL_NEXT_STATE_MASK << REG_DFS_CWL_NEXT_STATE_OFFS);
+       /* [8] - DfsCLNextState - MRS CL=6 after DFS (due to DLL-off mode) */
+       reg |= (0x4 << REG_DFS_CL_NEXT_STATE_OFFS);
+       /* [12] - DfsCWLNextState - MRS CWL=6 after DFS (due to DLL-off mode) */
+       reg |= (0x1 << REG_DFS_CWL_NEXT_STATE_OFFS);
+       dfs_reg_write(REG_DFS_ADDR, reg);       /* 0x1528 - DFS register */
+
+       /* Poll - Wait for APLL + ADLLs lock on new frequency */
+       do {
+               reg = (reg_read(REG_PHY_LOCK_STATUS_ADDR)) &
+                       REG_PHY_LOCK_APLL_ADLL_STATUS_MASK;
+               /* 0x1674 [10:0] - Phy lock status Register */
+       } while (reg != REG_PHY_LOCK_APLL_ADLL_STATUS_MASK);
+
+       /* Configure - Reset the PHY Read FIFO and Write channels - Set Reset */
+       reg = (reg_read(REG_SDRAM_CONFIG_ADDR) & REG_SDRAM_CONFIG_MASK);
+       /* [30:29] = 0 - Data Pup R/W path reset */
+       /* 0x1400 - SDRAM Configuration register */
+       dfs_reg_write(REG_SDRAM_CONFIG_ADDR, reg);
+
+       /*
+        * Configure - DRAM Data PHY Read [30], Write [29] path
+        * reset - Release Reset
+        */
+       reg = (reg_read(REG_SDRAM_CONFIG_ADDR) | ~REG_SDRAM_CONFIG_MASK);
+       /* [30:29] = '11' - Data Pup R/W path reset */
+       /* 0x1400 - SDRAM Configuration register */
+       dfs_reg_write(REG_SDRAM_CONFIG_ADDR, reg);
+
+       /* Registered DIMM support */
+       if (dram_info->reg_dimm) {
+               /*
+                * Configure - Change register DRAM operating speed
+                * (below 400MHz) - CWA_RC
+                */
+               reg = (0xA & REG_SDRAM_OPERATION_CWA_RC_MASK) <<
+                       REG_SDRAM_OPERATION_CWA_RC_OFFS;
+
+               /*
+                * Configure - Change register DRAM operating speed
+                * (below 400MHz) - CWA_DATA
+                */
+               reg |= ((0x0 & REG_SDRAM_OPERATION_CWA_DATA_MASK) <<
+                       REG_SDRAM_OPERATION_CWA_DATA_OFFS);
+
+               /* Configure - Set Delay - tSTAB */
+               reg |= (0x1 << REG_SDRAM_OPERATION_CWA_DELAY_SEL_OFFS);
+
+               /* Configure - Issue CWA command with the above parameters */
+               reg |= (REG_SDRAM_OPERATION_CMD_CWA &
+                       ~(0xF << REG_SDRAM_OPERATION_CS_OFFS));
+
+               /* 0x1418 - SDRAM Operation Register */
+               dfs_reg_write(REG_SDRAM_OPERATION_ADDR, reg);
+
+               /* Poll - Wait for CWA operation completion */
+               do {
+                       reg = reg_read(REG_SDRAM_OPERATION_ADDR) &
+                               (REG_SDRAM_OPERATION_CMD_MASK);
+               } while (reg);
+       }
+
+       /* Configure - Exit Self Refresh */
+       /* [2] - DfsSR  */
+       reg = (reg_read(REG_DFS_ADDR) & ~(1 << REG_DFS_SR_OFFS));
+       dfs_reg_write(REG_DFS_ADDR, reg);       /* 0x1528 - DFS register */
+
+       /*
+        * Poll - DFS Register - 0x1528 [3] - DfsAtSR - All DRAM devices
+        * on all ranks are NOT in self refresh mode
+        */
+       do {
+               reg = ((reg_read(REG_DFS_ADDR)) & (1 << REG_DFS_ATSR_OFFS));
+       } while (reg);          /* Wait for '0' */
+
+       /* Configure - Issue Refresh command */
+       /* [3-0] = 0x2 - Refresh Command, [11-8] - enabled Cs */
+       reg = REG_SDRAM_OPERATION_CMD_RFRS;
+       for (cs = 0; cs < MAX_CS; cs++) {
+               if (dram_info->cs_ena & (1 << cs))
+                       reg &= ~(1 << (REG_SDRAM_OPERATION_CS_OFFS + cs));
+       }
+
+       /* 0x1418 - SDRAM Operation Register */
+       dfs_reg_write(REG_SDRAM_OPERATION_ADDR, reg);
+
+       /* Poll - Wait for Refresh operation completion */
+       wait_refresh_op_complete();
+
+       /* Configure - Block new external transactions - Disable */
+       reg = reg_read(REG_DFS_ADDR);
+       reg &= ~(1 << REG_DFS_BLOCK_OFFS);      /* [1] - DfsBlock - Disable  */
+       dfs_reg_write(REG_DFS_ADDR, reg);       /* 0x1528 - DFS register */
+
+       /*
+        * Configure -  XBAR Retry response during Block to enable
+        * internal access - Disable
+        */
+       reg = reg_read(REG_METAL_MASK_ADDR);
+       /* [0] - RetryMask - Enable */
+       reg |= (1 << REG_METAL_MASK_RETRY_OFFS);
+       /* 0x14B0 - Dunit MMask Register */
+       dfs_reg_write(REG_METAL_MASK_ADDR, reg);
+
+       for (cs = 0; cs < MAX_CS; cs++) {
+               if (dram_info->cs_ena & (1 << cs)) {
+                       /* Configure - Set CL */
+                       reg = reg_read(REG_DDR3_MR0_CS_ADDR +
+                                      (cs << MR_CS_ADDR_OFFS)) &
+                               ~REG_DDR3_MR0_CL_MASK;
+                       tmp = 0x4;      /* CL=6 - 0x4 */
+                       reg |= ((tmp & 0x1) << REG_DDR3_MR0_CL_OFFS);
+                       reg |= ((tmp & 0xE) << REG_DDR3_MR0_CL_HIGH_OFFS);
+                       dfs_reg_write(REG_DDR3_MR0_CS_ADDR +
+                                     (cs << MR_CS_ADDR_OFFS), reg);
+
+                       /* Configure - Set CWL */
+                       reg = reg_read(REG_DDR3_MR2_CS_ADDR +
+                                      (cs << MR_CS_ADDR_OFFS))
+                               & ~(REG_DDR3_MR2_CWL_MASK << REG_DDR3_MR2_CWL_OFFS);
+                       /* CWL=6 - 0x1 */
+                       reg |= ((0x1) << REG_DDR3_MR2_CWL_OFFS);
+                       dfs_reg_write(REG_DDR3_MR2_CS_ADDR +
+                                     (cs << MR_CS_ADDR_OFFS), reg);
+               }
+       }
+
+       DEBUG_DFS_C("DDR3 - DFS - High To Low - Ended successfuly - new Frequency - ",
+                   freq, 1);
+
+       return MV_OK;
+#else
+       /* This Flow is relevant for Armada370 A0 and ArmadaXP Z1 */
+
+       u32 reg, freq_par;
+       u32 cs = 0;
+
+       DEBUG_DFS_C("DDR3 - DFS - High To Low - Starting DFS procedure to Frequency - ",
+                   freq, 1);
+
+       /* target frequency - 100MHz */
+       freq_par = ddr3_get_freq_parameter(freq, 0);
+
+       reg = 0x0000FF00;
+       /* 0x18700 - CPU Div CLK control 0 */
+       dfs_reg_write(REG_CPU_DIV_CLK_CTRL_1_ADDR, reg);
+
+       /* 0x1600 - ODPG_CNTRL_Control */
+       reg = reg_read(REG_ODPG_CNTRL_ADDR);
+       /* [21] = 1 - auto refresh disable */
+       reg |= (1 << REG_ODPG_CNTRL_OFFS);
+       dfs_reg_write(REG_ODPG_CNTRL_ADDR, reg);
+
+       /* 0x1670 - PHY lock mask register */
+       reg = reg_read(REG_PHY_LOCK_MASK_ADDR);
+       reg &= REG_PHY_LOCK_MASK_MASK;  /* [11:0] = 0 */
+       dfs_reg_write(REG_PHY_LOCK_MASK_ADDR, reg);
+
+       reg = reg_read(REG_DFS_ADDR);   /* 0x1528 - DFS register */
+
+       /* Disable reconfig */
+       reg &= ~0x10;   /* [4] - Enable reconfig MR registers after DFS_ERG */
+       reg |= 0x1;     /* [0] - DRAM DLL disabled after DFS */
+
+       dfs_reg_write(REG_DFS_ADDR, reg);       /* 0x1528 - DFS register */
+
+       reg = reg_read(REG_METAL_MASK_ADDR) & ~(1 << 0); /* [0] - disable */
+       /* 0x14B0 - Dunit MMask Register */
+       dfs_reg_write(REG_METAL_MASK_ADDR, reg);
+
+       /* [1] - DFS Block enable  */
+       reg = reg_read(REG_DFS_ADDR) | (1 << REG_DFS_BLOCK_OFFS);
+       dfs_reg_write(REG_DFS_ADDR, reg);       /* 0x1528 - DFS register */
+
+       /* [2] - DFS Self refresh enable  */
+       reg = reg_read(REG_DFS_ADDR) | (1 << REG_DFS_SR_OFFS);
+       dfs_reg_write(REG_DFS_ADDR, reg);       /* 0x1528 - DFS register */
+
+       /*
+        * Poll DFS Register - 0x1528 [3] - DfsAtSR -
+        * All DRAM devices on all ranks are in self refresh mode -
+        * DFS can be executed afterwards
+        */
+       do {
+               reg = reg_read(REG_DFS_ADDR) & (1 << REG_DFS_ATSR_OFFS);
+       } while (reg == 0x0);   /* Wait for '1' */
+
+       /* Disable ODT on DLL-off mode */
+       dfs_reg_write(REG_SDRAM_ODT_CTRL_HIGH_ADDR,
+                     REG_SDRAM_ODT_CTRL_HIGH_OVRD_MASK);
+
+       /* [11:0] = 0 */
+       reg = (reg_read(REG_PHY_LOCK_MASK_ADDR) & REG_PHY_LOCK_MASK_MASK);
+       /* 0x1670 - PHY lock mask register */
+       dfs_reg_write(REG_PHY_LOCK_MASK_ADDR, reg);
+
+       /* Add delay between entering SR and start ratio modification */
+       udelay(1);
+
+       /*
+        * Initial Setup - assure that the "load new ratio" is clear (bit 24)
+        * and in the same chance, block reassertions of reset [15:8] and
+        * force reserved bits[7:0].
+        */
+       reg = 0x0000FDFF;
+       /* 0x18700 - CPU Div CLK control 0 */
+       dfs_reg_write(REG_CPU_DIV_CLK_CTRL_0_ADDR, reg);
+
+       /*
+        * RelaX whenever reset is asserted to that channel (good for any case)
+        */
+       reg = 0x0000FF00;
+       /* 0x18700 - CPU Div CLK control 0 */
+       dfs_reg_write(REG_CPU_DIV_CLK_CTRL_1_ADDR, reg);
+
+       reg = reg_read(REG_CPU_DIV_CLK_CTRL_3_ADDR) &
+               REG_CPU_DIV_CLK_CTRL_3_FREQ_MASK;
+       /* Full Integer ratio from PLL-out to ddr-clk */
+       reg |= (freq_par << REG_CPU_DIV_CLK_CTRL_3_FREQ_OFFS);
+       /* 0x1870C - CPU Div CLK control 3 register */
+       dfs_reg_write(REG_CPU_DIV_CLK_CTRL_3_ADDR, reg);
+
+       /*
+        * Shut off clock enable to the DDRPHY clock channel (this is the "D").
+        * All the rest are kept as is (forced, but could be read-modify-write).
+        * This is done now by RMW above.
+        */
+
+       /* Clock is not shut off gracefully - keep it running */
+       reg = 0x000FFF02;
+       dfs_reg_write(REG_CPU_DIV_CLK_CTRL_4_ADDR, reg);
+
+       /* Wait before replacing the clock on the DDR Phy Channel. */
+       udelay(1);
+
+       /*
+        * This for triggering the frequency update. Bit[24] is the
+        * central control
+        * bits [23:16] == which channels to change ==2 ==> only DDR Phy
+        *                 (smooth transition)
+        * bits [15:8] == mask reset reassertion due to clock modification
+        *                to these channels.
+        * bits [7:0] == not in use
+        */
+       reg = 0x0102FDFF;
+       /* 0x18700 - CPU Div CLK control 0 register */
+       dfs_reg_write(REG_CPU_DIV_CLK_CTRL_0_ADDR, reg);
+
+       udelay(1);              /* Wait 1usec */
+
+       /*
+        * Poll Div CLK status 0 register - indication that the clocks
+        * are active - 0x18718 [8]
+        */
+       do {
+               reg = (reg_read(REG_CPU_DIV_CLK_STATUS_0_ADDR)) &
+                       (1 << REG_CPU_DIV_CLK_ALL_STABLE_OFFS);
+       } while (reg == 0);
+
+       /*
+        * Clean the CTRL0, to be ready for next resets and next requests of
+        * ratio modifications.
+        */
+       reg = 0x000000FF;
+       /* 0x18700 - CPU Div CLK control 0 register */
+       dfs_reg_write(REG_CPU_DIV_CLK_CTRL_0_ADDR, reg);
+
+       udelay(5);
+
+       /* Switch HCLK Mux to training clk (100Mhz), keep DFS request bit */
+       reg = 0x20050000;
+       /* 0x18488 - DRAM Init control status register */
+       dfs_reg_write(REG_DRAM_INIT_CTRL_STATUS_ADDR, reg);
+
+       reg = reg_read(REG_DDR_IO_ADDR) & ~(1 << REG_DDR_IO_CLK_RATIO_OFFS);
+       /* [15] = 0 - Set 1:1 Ratio between Dunit and Phy */
+       dfs_reg_write(REG_DDR_IO_ADDR, reg);    /* 0x1524 - DDR IO Regist */
+
+       reg = reg_read(REG_DRAM_PHY_CONFIG_ADDR) & REG_DRAM_PHY_CONFIG_MASK;
+       /* [31:30]] - reset pup data ctrl ADLL */
+       /* 0x15EC - DRAM PHY Config register */
+       dfs_reg_write(REG_DRAM_PHY_CONFIG_ADDR, reg);
+
+       reg = (reg_read(REG_DRAM_PHY_CONFIG_ADDR) | ~REG_DRAM_PHY_CONFIG_MASK);
+       /* [31:30] - normal pup data ctrl ADLL */
+       /* 0x15EC - DRAM PHY Config register */
+       dfs_reg_write(REG_DRAM_PHY_CONFIG_ADDR, reg);
+
+       udelay(1);              /* Wait 1usec */
+
+       /* 0x1404 */
+       reg = (reg_read(REG_DUNIT_CTRL_LOW_ADDR) & 0xFFFFFFE7);
+       dfs_reg_write(REG_DUNIT_CTRL_LOW_ADDR, reg);
+
+       /* Poll Phy lock status register - APLL lock indication - 0x1674 */
+       do {
+               reg = (reg_read(REG_PHY_LOCK_STATUS_ADDR)) &
+                       REG_PHY_LOCK_STATUS_LOCK_MASK;
+       } while (reg != REG_PHY_LOCK_STATUS_LOCK_MASK); /* Wait for '0xFFF' */
+
+       reg = (reg_read(REG_SDRAM_CONFIG_ADDR) & REG_SDRAM_CONFIG_MASK);
+       /* [30:29] = 0 - Data Pup R/W path reset */
+       /* 0x1400 - SDRAM Configuration register */
+       dfs_reg_write(REG_SDRAM_CONFIG_ADDR, reg);
+
+       reg = reg_read(REG_SDRAM_CONFIG_ADDR) | ~REG_SDRAM_CONFIG_MASK;
+       /* [30:29] = '11' - Data Pup R/W path reset */
+       /* 0x1400 - SDRAM Configuration register */
+       dfs_reg_write(REG_SDRAM_CONFIG_ADDR, reg);
+
+       udelay(1000);           /* Wait 1msec */
+
+       for (cs = 0; cs < MAX_CS; cs++) {
+               if (dram_info->cs_ena & (1 << cs)) {
+                       /* Poll - Wait for Refresh operation completion */
+                       wait_refresh_op_complete();
+
+                       /* Config CL and CWL with MR0 and MR2 registers */
+                       reg = reg_read(REG_DDR3_MR0_ADDR);
+                       reg &= ~0x74;   /* CL [3:0]; [6:4],[2] */
+                       reg |= (1 << 5);        /* CL = 4, CAS is 6 */
+                       dfs_reg_write(REG_DDR3_MR0_ADDR, reg);
+                       reg = REG_SDRAM_OPERATION_CMD_MR0 &
+                               ~(1 << (REG_SDRAM_OPERATION_CS_OFFS + cs));
+                       /* 0x1418 - SDRAM Operation Register */
+                       dfs_reg_write(REG_SDRAM_OPERATION_ADDR, reg);
+
+                       /* Poll - Wait for Refresh operation completion */
+                       wait_refresh_op_complete();
+
+                       reg = reg_read(REG_DDR3_MR2_ADDR);
+                       reg &= ~0x38;   /* CWL [5:3] */
+                       reg |= (1 << 3);        /* CWL = 1, CWL is 6 */
+                       dfs_reg_write(REG_DDR3_MR2_ADDR, reg);
+
+                       reg = REG_SDRAM_OPERATION_CMD_MR2 &
+                               ~(1 << (REG_SDRAM_OPERATION_CS_OFFS + cs));
+                       /* 0x1418 - SDRAM Operation Register */
+                       dfs_reg_write(REG_SDRAM_OPERATION_ADDR, reg);
+
+                       /* Poll - Wait for Refresh operation completion */
+                       wait_refresh_op_complete();
+
+                       /* Set current rd_sample_delay  */
+                       reg = reg_read(REG_READ_DATA_SAMPLE_DELAYS_ADDR);
+                       reg &= ~(REG_READ_DATA_SAMPLE_DELAYS_MASK <<
+                                (REG_READ_DATA_SAMPLE_DELAYS_OFFS * cs));
+                       reg |= (5 << (REG_READ_DATA_SAMPLE_DELAYS_OFFS * cs));
+                       dfs_reg_write(REG_READ_DATA_SAMPLE_DELAYS_ADDR, reg);
+
+                       /* Set current rd_ready_delay  */
+                       reg = reg_read(REG_READ_DATA_READY_DELAYS_ADDR);
+                       reg &= ~(REG_READ_DATA_READY_DELAYS_MASK <<
+                                (REG_READ_DATA_READY_DELAYS_OFFS * cs));
+                       reg |= ((6) << (REG_READ_DATA_READY_DELAYS_OFFS * cs));
+                       dfs_reg_write(REG_READ_DATA_READY_DELAYS_ADDR, reg);
+               }
+       }
+
+       /* [2] - DFS Self refresh disable  */
+       reg = reg_read(REG_DFS_ADDR) & ~(1 << REG_DFS_SR_OFFS);
+       dfs_reg_write(REG_DFS_ADDR, reg);       /* 0x1528 - DFS register */
+
+       /* [1] - DFS Block enable  */
+       reg = reg_read(REG_DFS_ADDR) & ~(1 << REG_DFS_BLOCK_OFFS);
+       dfs_reg_write(REG_DFS_ADDR, reg);       /* 0x1528 - DFS register */
+
+       /*
+        * Poll DFS Register - 0x1528 [3] - DfsAtSR -
+        * All DRAM devices on all ranks are in self refresh mode - DFS can
+        * be executed afterwards
+        */
+       do {
+               reg = reg_read(REG_DFS_ADDR) & (1 << REG_DFS_ATSR_OFFS);
+       } while (reg);          /* Wait for '1' */
+
+       reg = (reg_read(REG_METAL_MASK_ADDR) | (1 << 0));
+       /* [0] - Enable Dunit to crossbar retry */
+       /* 0x14B0 - Dunit MMask Register */
+       dfs_reg_write(REG_METAL_MASK_ADDR, reg);
+
+       /* 0x1600 - PHY lock mask register */
+       reg = reg_read(REG_ODPG_CNTRL_ADDR);
+       reg &= ~(1 << REG_ODPG_CNTRL_OFFS);     /* [21] = 0 */
+       dfs_reg_write(REG_ODPG_CNTRL_ADDR, reg);
+
+       /* 0x1670 - PHY lock mask register */
+       reg = reg_read(REG_PHY_LOCK_MASK_ADDR);
+       reg |= ~REG_PHY_LOCK_MASK_MASK; /* [11:0] = FFF */
+       dfs_reg_write(REG_PHY_LOCK_MASK_ADDR, reg);
+
+       DEBUG_DFS_C("DDR3 - DFS - High To Low - Ended successfuly - new Frequency - ",
+                   freq, 1);
+
+       return MV_OK;
+#endif
+}
+
+/*
+ * Name:     ddr3_dfs_low_2_high
+ * Desc:
+ * Args:     freq - target frequency
+ * Notes:
+ * Returns:  MV_OK - success, MV_FAIL - fail
+ */
+int ddr3_dfs_low_2_high(u32 freq, int ratio_2to1, MV_DRAM_INFO *dram_info)
+{
+#if defined(MV88F78X60) || defined(MV88F672X)
+       /* This Flow is relevant for ArmadaXP A0 */
+       u32 reg, freq_par, tmp;
+       u32 cs = 0;
+
+       DEBUG_DFS_C("DDR3 - DFS - Low To High - Starting DFS procedure to Frequency - ",
+                   freq, 1);
+
+       /* target frequency - freq */
+       freq_par = ddr3_get_freq_parameter(freq, ratio_2to1);
+
+#if defined(MV88F672X)
+       u32 hclk;
+       u32 cpu_freq = ddr3_get_cpu_freq();
+       get_target_freq(cpu_freq, &tmp, &hclk);
+#endif
+
+       /* Configure - DRAM DLL final state after DFS is complete - Enable */
+       reg = reg_read(REG_DFS_ADDR);
+       /* [0] - DfsDllNextState - Enable */
+       reg &= ~(1 << REG_DFS_DLLNEXTSTATE_OFFS);
+       dfs_reg_write(REG_DFS_ADDR, reg);       /* 0x1528 - DFS register */
+
+       /*
+        * Configure -  XBAR Retry response during Block to enable
+        * internal access - Disable
+        */
+       reg = reg_read(REG_METAL_MASK_ADDR);
+       /* [0] - RetryMask - Disable */
+       reg &= ~(1 << REG_METAL_MASK_RETRY_OFFS);
+       /* 0x14B0 - Dunit MMask Register */
+       dfs_reg_write(REG_METAL_MASK_ADDR, reg);
+
+       /* Configure - Block new external transactions - Enable */
+       reg = reg_read(REG_DFS_ADDR);
+       reg |= (1 << REG_DFS_BLOCK_OFFS);       /* [1] - DfsBlock - Enable  */
+       dfs_reg_write(REG_DFS_ADDR, reg);       /* 0x1528 - DFS register */
+
+       /* Configure - Move DRAM into Self Refresh */
+       reg = reg_read(REG_DFS_ADDR);
+       reg |= (1 << REG_DFS_SR_OFFS);  /* [2] - DfsSR - Enable */
+       dfs_reg_write(REG_DFS_ADDR, reg);       /* 0x1528 - DFS register */
+
+       /* Poll - Wait for Self Refresh indication */
+       do {
+               reg = ((reg_read(REG_DFS_ADDR)) & (1 << REG_DFS_ATSR_OFFS));
+       } while (reg == 0x0);   /* 0x1528 [3] - DfsAtSR - Wait for '1' */
+
+       /* Start of clock change procedure (PLL) */
+#if defined(MV88F672X)
+       /* avantaLP */
+       /* Configure    cpupll_clkdiv_reset_mask */
+       reg = reg_read(CPU_PLL_CLOCK_DIVIDER_CNTRL0);
+       reg &= CPU_PLL_CLOCK_DIVIDER_CNTRL0_MASK;
+       /* 0xE8264[7:0]   0xff CPU Clock Dividers Reset mask */
+       dfs_reg_write(CPU_PLL_CLOCK_DIVIDER_CNTRL0, (reg + 0xFF));
+
+       /* Configure    cpu_clkdiv_reload_smooth    */
+       reg = reg_read(CPU_PLL_CNTRL0);
+       reg &= CPU_PLL_CNTRL0_RELOAD_SMOOTH_MASK;
+       /* 0xE8260   [15:8]  0x2 CPU Clock Dividers Reload Smooth enable */
+       dfs_reg_write(CPU_PLL_CNTRL0,
+                     reg + (2 << CPU_PLL_CNTRL0_RELOAD_SMOOTH_OFFS));
+
+       /* Configure    cpupll_clkdiv_relax_en */
+       reg = reg_read(CPU_PLL_CNTRL0);
+       reg &= CPU_PLL_CNTRL0_RELAX_EN_MASK;
+       /* 0xE8260 [31:24] 0x2 Relax Enable */
+       dfs_reg_write(CPU_PLL_CNTRL0,
+                     reg + (2 << CPU_PLL_CNTRL0_RELAX_EN_OFFS));
+
+       /* Configure    cpupll_clkdiv_ddr_clk_ratio */
+       reg = reg_read(CPU_PLL_CLOCK_DIVIDER_CNTRL1);
+       /*
+        * 0xE8268  [13:8]  N   Set Training clock:
+        * APLL Out Clock (VCO freq) / N = 100 MHz
+        */
+       reg &= CPU_PLL_CLOCK_DIVIDER_CNTRL1_MASK;
+       reg |= (freq_par << 8); /* full Integer ratio from PLL-out to ddr-clk */
+       dfs_reg_write(CPU_PLL_CLOCK_DIVIDER_CNTRL1, reg);
+       /* Configure    cpupll_clkdiv_reload_ratio  */
+       reg = reg_read(CPU_PLL_CLOCK_DIVIDER_CNTRL0);
+       reg &= CPU_PLL_CLOCK_RELOAD_RATIO_MASK;
+       /* 0xE8264 [8]=0x1 CPU Clock Dividers Reload Ratio trigger set */
+       dfs_reg_write(CPU_PLL_CLOCK_DIVIDER_CNTRL0,
+                     reg + (1 << CPU_PLL_CLOCK_RELOAD_RATIO_OFFS));
+
+       udelay(1);
+
+       /* Configure    cpupll_clkdiv_reload_ratio  */
+       reg = reg_read(CPU_PLL_CLOCK_DIVIDER_CNTRL0);
+       reg &= CPU_PLL_CLOCK_RELOAD_RATIO_MASK;
+       /* 0xE8264 [8]=0x0 CPU Clock Dividers Reload Ratio trigger clear */
+       dfs_reg_write(CPU_PLL_CLOCK_DIVIDER_CNTRL0, reg);
+
+       udelay(5);
+
+#else
+       /*
+        * Initial Setup - assure that the "load new ratio" is clear (bit 24)
+        * and in the same chance, block reassertions of reset [15:8]
+        * and force reserved bits[7:0].
+        */
+       reg = 0x0000FFFF;
+
+       /* 0x18700 - CPU Div CLK control 0 */
+       dfs_reg_write(REG_CPU_DIV_CLK_CTRL_0_ADDR, reg);
+
+       /*
+        * RelaX whenever reset is asserted to that channel (good for any case)
+        */
+       reg = 0x0000FF00;
+       /* 0x18704 - CPU Div CLK control 0 */
+       dfs_reg_write(REG_CPU_DIV_CLK_CTRL_1_ADDR, reg);
+
+       reg = reg_read(REG_CPU_DIV_CLK_CTRL_2_ADDR) &
+               REG_CPU_DIV_CLK_CTRL_3_FREQ_MASK;
+       reg |= (freq_par << REG_CPU_DIV_CLK_CTRL_3_FREQ_OFFS);
+       /* full Integer ratio from PLL-out to ddr-clk */
+       /* 0x1870C - CPU Div CLK control 3 register */
+       dfs_reg_write(REG_CPU_DIV_CLK_CTRL_2_ADDR, reg);
+
+       /*
+        * Shut off clock enable to the DDRPHY clock channel (this is the "D").
+        * All the rest are kept as is (forced, but could be read-modify-write).
+        * This is done now by RMW above.
+        */
+       reg = 0x000FFF02;
+       dfs_reg_write(REG_CPU_DIV_CLK_CTRL_4_ADDR, reg);
+
+       /* Wait before replacing the clock on the DDR Phy Channel. */
+       udelay(1);
+
+       reg = 0x0102FDFF;
+       /*
+        * This for triggering the frequency update. Bit[24] is the
+        * central control
+        * bits [23:16] == which channels to change ==2 ==> only DDR Phy
+        *                 (smooth transition)
+        * bits [15:8] == mask reset reassertion due to clock modification
+        *                to these channels.
+        * bits [7:0] == not in use
+        */
+       /* 0x18700 - CPU Div CLK control 0 register */
+       dfs_reg_write(REG_CPU_DIV_CLK_CTRL_0_ADDR, reg);
+
+       udelay(1);
+
+       /*
+        * Poll Div CLK status 0 register - indication that the clocks
+        * are active - 0x18718 [8]
+        */
+       do {
+               reg = reg_read(REG_CPU_DIV_CLK_STATUS_0_ADDR) &
+                       (1 << REG_CPU_DIV_CLK_ALL_STABLE_OFFS);
+       } while (reg == 0);
+
+       reg = 0x000000FF;
+       /*
+        * Clean the CTRL0, to be ready for next resets and next requests
+        * of ratio modifications.
+        */
+       /* 0x18700 - CPU Div CLK control 0 register */
+       dfs_reg_write(REG_CPU_DIV_CLK_CTRL_0_ADDR, reg);
+#endif
+       /* End of clock change procedure (PLL) */
+
+       if (ratio_2to1) {
+               /* Configure - Select normal clock for the DDR PHY - Disable */
+               reg = reg_read(REG_DRAM_INIT_CTRL_STATUS_ADDR);
+               /* [16] - ddr_phy_trn_clk_sel - Disable  */
+               reg &= ~(1 << REG_DRAM_INIT_CTRL_TRN_CLK_OFFS);
+               /* 0x18488 - DRAM Init control status register */
+               dfs_reg_write(REG_DRAM_INIT_CTRL_STATUS_ADDR, reg);
+       }
+
+       /*
+        * Configure - Set Correct Ratio - according to target ratio
+        * parameter - 2:1/1:1
+        */
+       if (ratio_2to1) {
+               /*
+                * [15] - Phy2UnitClkRatio = 1 - Set 2:1 Ratio between
+                * Dunit and Phy
+                */
+               reg = reg_read(REG_DDR_IO_ADDR) |
+                       (1 << REG_DDR_IO_CLK_RATIO_OFFS);
+       } else {
+               /*
+                * [15] - Phy2UnitClkRatio = 0 - Set 1:1 Ratio between
+                * Dunit and Phy
+                */
+               reg = reg_read(REG_DDR_IO_ADDR) &
+                       ~(1 << REG_DDR_IO_CLK_RATIO_OFFS);
+       }
+       dfs_reg_write(REG_DDR_IO_ADDR, reg);    /* 0x1524 - DDR IO Register */
+
+       /* Configure - 2T Mode - Restore original configuration */
+       reg = reg_read(REG_DUNIT_CTRL_LOW_ADDR);
+       /* [3:4] 2T - Restore value */
+       reg &= ~(REG_DUNIT_CTRL_LOW_2T_MASK << REG_DUNIT_CTRL_LOW_2T_OFFS);
+       reg |= ((dram_info->mode_2t & REG_DUNIT_CTRL_LOW_2T_MASK) <<
+               REG_DUNIT_CTRL_LOW_2T_OFFS);
+       /* 0x1404 - DDR Controller Control Low Register */
+       dfs_reg_write(REG_DUNIT_CTRL_LOW_ADDR, reg);
+
+       /* Configure - Restore CL and CWL - MRS Commands */
+       reg = reg_read(REG_DFS_ADDR);
+       reg &= ~(REG_DFS_CL_NEXT_STATE_MASK << REG_DFS_CL_NEXT_STATE_OFFS);
+       reg &= ~(REG_DFS_CWL_NEXT_STATE_MASK << REG_DFS_CWL_NEXT_STATE_OFFS);
+
+       if (freq == DDR_400) {
+               if (dram_info->target_frequency == 0x8)
+                       tmp = ddr3_cl_to_valid_cl(5);
+               else
+                       tmp = ddr3_cl_to_valid_cl(6);
+       } else {
+               tmp = ddr3_cl_to_valid_cl(dram_info->cl);
+       }
+
+       /* [8] - DfsCLNextState */
+       reg |= ((tmp & REG_DFS_CL_NEXT_STATE_MASK) << REG_DFS_CL_NEXT_STATE_OFFS);
+       if (freq == DDR_400) {
+               /* [12] - DfsCWLNextState */
+               reg |= (((0) & REG_DFS_CWL_NEXT_STATE_MASK) <<
+                       REG_DFS_CWL_NEXT_STATE_OFFS);
+       } else {
+               /* [12] - DfsCWLNextState */
+               reg |= (((dram_info->cwl) & REG_DFS_CWL_NEXT_STATE_MASK) <<
+                       REG_DFS_CWL_NEXT_STATE_OFFS);
+       }
+       dfs_reg_write(REG_DFS_ADDR, reg);       /* 0x1528 - DFS register */
+
+       /* Optional - Configure - DDR3_Rtt_nom_CS# */
+       for (cs = 0; cs < MAX_CS; cs++) {
+               if (dram_info->cs_ena & (1 << cs)) {
+                       reg = reg_read(REG_DDR3_MR1_CS_ADDR +
+                                      (cs << MR_CS_ADDR_OFFS));
+                       reg &= REG_DDR3_MR1_RTT_MASK;
+                       reg |= odt_static[dram_info->cs_ena][cs];
+                       dfs_reg_write(REG_DDR3_MR1_CS_ADDR +
+                                     (cs << MR_CS_ADDR_OFFS), reg);
+               }
+       }
+
+       /* Configure - Reset ADLLs - Set Reset */
+       reg = reg_read(REG_DRAM_PHY_CONFIG_ADDR) & REG_DRAM_PHY_CONFIG_MASK;
+       /* [31:30]] - reset pup data ctrl ADLL */
+       /* 0x15EC - DRAM PHY Config Register */
+       dfs_reg_write(REG_DRAM_PHY_CONFIG_ADDR, reg);
+
+       /* Configure - Reset ADLLs - Release Reset */
+       reg = reg_read(REG_DRAM_PHY_CONFIG_ADDR) | ~REG_DRAM_PHY_CONFIG_MASK;
+       /* [31:30] - normal pup data ctrl ADLL */
+       /* 0x15EC - DRAM PHY Config register */
+       dfs_reg_write(REG_DRAM_PHY_CONFIG_ADDR, reg);
+
+       /* Poll - Wait for APLL + ADLLs lock on new frequency */
+       do {
+               reg = reg_read(REG_PHY_LOCK_STATUS_ADDR) &
+                       REG_PHY_LOCK_APLL_ADLL_STATUS_MASK;
+               /* 0x1674 [10:0] - Phy lock status Register */
+       } while (reg != REG_PHY_LOCK_APLL_ADLL_STATUS_MASK);
+
+       /* Configure - Reset the PHY SDR clock divider */
+       if (ratio_2to1) {
+               /* Pup Reset Divider B - Set Reset */
+               /* [28] - DataPupRdRST = 0 */
+               reg = reg_read(REG_SDRAM_CONFIG_ADDR) &
+                       ~(1 << REG_SDRAM_CONFIG_PUPRSTDIV_OFFS);
+               /* [28] - DataPupRdRST = 1 */
+               tmp = reg_read(REG_SDRAM_CONFIG_ADDR) |
+                       (1 << REG_SDRAM_CONFIG_PUPRSTDIV_OFFS);
+               /* 0x1400 - SDRAM Configuration register */
+               dfs_reg_write(REG_SDRAM_CONFIG_ADDR, reg);
+
+               /* Pup Reset Divider B - Release Reset */
+               /* 0x1400 - SDRAM Configuration register */
+               dfs_reg_write(REG_SDRAM_CONFIG_ADDR, tmp);
+       }
+
+       /* Configure - Reset the PHY Read FIFO and Write channels - Set Reset */
+       reg = reg_read(REG_SDRAM_CONFIG_ADDR) & REG_SDRAM_CONFIG_MASK;
+       /* [30:29] = 0 - Data Pup R/W path reset */
+       /* 0x1400 - SDRAM Configuration register */
+       dfs_reg_write(REG_SDRAM_CONFIG_ADDR, reg);
+
+       /*
+        * Configure - DRAM Data PHY Read [30], Write [29] path reset -
+        * Release Reset
+        */
+       reg = reg_read(REG_SDRAM_CONFIG_ADDR) | ~REG_SDRAM_CONFIG_MASK;
+       /* [30:29] = '11' - Data Pup R/W path reset */
+       /* 0x1400 - SDRAM Configuration register */
+       dfs_reg_write(REG_SDRAM_CONFIG_ADDR, reg);
+
+       /* Registered DIMM support */
+       if (dram_info->reg_dimm) {
+               /*
+                * Configure - Change register DRAM operating speed
+                * (DDR3-1333 / DDR3-1600) - CWA_RC
+                */
+               reg = (0xA & REG_SDRAM_OPERATION_CWA_RC_MASK) <<
+                       REG_SDRAM_OPERATION_CWA_RC_OFFS;
+               if (freq <= DDR_400) {
+                       /*
+                        * Configure - Change register DRAM operating speed
+                        * (DDR3-800) - CWA_DATA
+                        */
+                       reg |= ((0x0 & REG_SDRAM_OPERATION_CWA_DATA_MASK) <<
+                               REG_SDRAM_OPERATION_CWA_DATA_OFFS);
+               } else if ((freq > DDR_400) && (freq <= DDR_533)) {
+                       /*
+                        * Configure - Change register DRAM operating speed
+                        * (DDR3-1066) - CWA_DATA
+                        */
+                       reg |= ((0x1 & REG_SDRAM_OPERATION_CWA_DATA_MASK) <<
+                               REG_SDRAM_OPERATION_CWA_DATA_OFFS);
+               } else if ((freq > DDR_533) && (freq <= DDR_666)) {
+                       /*
+                        * Configure - Change register DRAM operating speed
+                        * (DDR3-1333) - CWA_DATA
+                        */
+                       reg |= ((0x2 & REG_SDRAM_OPERATION_CWA_DATA_MASK) <<
+                               REG_SDRAM_OPERATION_CWA_DATA_OFFS);
+               } else {
+                       /*
+                        * Configure - Change register DRAM operating speed
+                        * (DDR3-1600) - CWA_DATA
+                        */
+                       reg |= ((0x3 & REG_SDRAM_OPERATION_CWA_DATA_MASK) <<
+                               REG_SDRAM_OPERATION_CWA_DATA_OFFS);
+               }
+
+               /* Configure - Set Delay - tSTAB */
+               reg |= (0x1 << REG_SDRAM_OPERATION_CWA_DELAY_SEL_OFFS);
+               /* Configure - Issue CWA command with the above parameters */
+               reg |= (REG_SDRAM_OPERATION_CMD_CWA &
+                       ~(0xF << REG_SDRAM_OPERATION_CS_OFFS));
+
+               /* 0x1418 - SDRAM Operation Register */
+               dfs_reg_write(REG_SDRAM_OPERATION_ADDR, reg);
+
+               /* Poll - Wait for CWA operation completion */
+               do {
+                       reg = reg_read(REG_SDRAM_OPERATION_ADDR) &
+                               REG_SDRAM_OPERATION_CMD_MASK;
+               } while (reg);
+       }
+
+       /* Configure - Exit Self Refresh */
+       /* [2] - DfsSR  */
+       reg = reg_read(REG_DFS_ADDR) & ~(1 << REG_DFS_SR_OFFS);
+       dfs_reg_write(REG_DFS_ADDR, reg);       /* 0x1528 - DFS register */
+
+       /*
+        * Poll - DFS Register - 0x1528 [3] - DfsAtSR - All DRAM
+        * devices on all ranks are NOT in self refresh mode
+        */
+       do {
+               reg = reg_read(REG_DFS_ADDR) & (1 << REG_DFS_ATSR_OFFS);
+       } while (reg);          /* Wait for '0' */
+
+       /* Configure - Issue Refresh command */
+       /* [3-0] = 0x2 - Refresh Command, [11-8] - enabled Cs */
+       reg = REG_SDRAM_OPERATION_CMD_RFRS;
+       for (cs = 0; cs < MAX_CS; cs++) {
+               if (dram_info->cs_ena & (1 << cs))
+                       reg &= ~(1 << (REG_SDRAM_OPERATION_CS_OFFS + cs));
+       }
+
+       /* 0x1418 - SDRAM Operation Register */
+       dfs_reg_write(REG_SDRAM_OPERATION_ADDR, reg);
+
+       /* Poll - Wait for Refresh operation completion */
+       wait_refresh_op_complete();
+
+       /* Configure - Block new external transactions - Disable */
+       reg = reg_read(REG_DFS_ADDR);
+       reg &= ~(1 << REG_DFS_BLOCK_OFFS);      /* [1] - DfsBlock - Disable  */
+       dfs_reg_write(REG_DFS_ADDR, reg);       /* 0x1528 - DFS register */
+
+       /*
+        * Configure -  XBAR Retry response during Block to enable
+        * internal access - Disable
+        */
+       reg = reg_read(REG_METAL_MASK_ADDR);
+       /* [0] - RetryMask - Enable */
+       reg |= (1 << REG_METAL_MASK_RETRY_OFFS);
+       /* 0x14B0 - Dunit MMask Register */
+       dfs_reg_write(REG_METAL_MASK_ADDR, reg);
+
+       for (cs = 0; cs < MAX_CS; cs++) {
+               if (dram_info->cs_ena & (1 << cs)) {
+                       /* Configure - Set CL */
+                       reg = reg_read(REG_DDR3_MR0_CS_ADDR +
+                                      (cs << MR_CS_ADDR_OFFS)) &
+                               ~REG_DDR3_MR0_CL_MASK;
+                       if (freq == DDR_400)
+                               tmp = ddr3_cl_to_valid_cl(6);
+                       else
+                               tmp = ddr3_cl_to_valid_cl(dram_info->cl);
+                       reg |= ((tmp & 0x1) << REG_DDR3_MR0_CL_OFFS);
+                       reg |= ((tmp & 0xE) << REG_DDR3_MR0_CL_HIGH_OFFS);
+                       dfs_reg_write(REG_DDR3_MR0_CS_ADDR +
+                                     (cs << MR_CS_ADDR_OFFS), reg);
+
+                       /* Configure - Set CWL */
+                       reg = reg_read(REG_DDR3_MR2_CS_ADDR +
+                                      (cs << MR_CS_ADDR_OFFS)) &
+                               ~(REG_DDR3_MR2_CWL_MASK << REG_DDR3_MR2_CWL_OFFS);
+                       if (freq == DDR_400)
+                               reg |= ((0) << REG_DDR3_MR2_CWL_OFFS);
+                       else
+                               reg |= ((dram_info->cwl) << REG_DDR3_MR2_CWL_OFFS);
+                       dfs_reg_write(REG_DDR3_MR2_CS_ADDR +
+                                     (cs << MR_CS_ADDR_OFFS), reg);
+               }
+       }
+
+       DEBUG_DFS_C("DDR3 - DFS - Low To High - Ended successfuly - new Frequency - ",
+                   freq, 1);
+
+       return MV_OK;
+
+#else
+
+       /* This Flow is relevant for Armada370 A0 and ArmadaXP Z1 */
+
+       u32 reg, freq_par, tmp;
+       u32 cs = 0;
+
+       DEBUG_DFS_C("DDR3 - DFS - Low To High - Starting DFS procedure to Frequency - ",
+                   freq, 1);
+
+       /* target frequency - freq */
+       freq_par = ddr3_get_freq_parameter(freq, ratio_2to1);
+
+       reg = 0x0000FF00;
+       dfs_reg_write(REG_CPU_DIV_CLK_CTRL_1_ADDR, reg);
+
+       /* 0x1600 - PHY lock mask register */
+       reg = reg_read(REG_ODPG_CNTRL_ADDR);
+       reg |= (1 << REG_ODPG_CNTRL_OFFS);      /* [21] = 1 */
+       dfs_reg_write(REG_ODPG_CNTRL_ADDR, reg);
+
+       /* 0x1670 - PHY lock mask register */
+       reg = reg_read(REG_PHY_LOCK_MASK_ADDR);
+       reg &= REG_PHY_LOCK_MASK_MASK;  /* [11:0] = 0 */
+       dfs_reg_write(REG_PHY_LOCK_MASK_ADDR, reg);
+
+       /* Enable reconfig MR Registers after DFS */
+       reg = reg_read(REG_DFS_ADDR);   /* 0x1528 - DFS register */
+       /* [4] - Disable - reconfig MR registers after DFS_ERG */
+       reg &= ~0x11;
+       /* [0] - Enable - DRAM DLL after DFS */
+       dfs_reg_write(REG_DFS_ADDR, reg);       /* 0x1528 - DFS register */
+
+       /* Disable DRAM Controller to crossbar retry */
+       /* [0] - disable */
+       reg = reg_read(REG_METAL_MASK_ADDR) & ~(1 << 0);
+       /* 0x14B0 - Dunit MMask Register */
+       dfs_reg_write(REG_METAL_MASK_ADDR, reg);
+
+       /* Enable DRAM Blocking */
+       /* [1] - DFS Block enable  */
+       reg = reg_read(REG_DFS_ADDR) | (1 << REG_DFS_BLOCK_OFFS);
+       dfs_reg_write(REG_DFS_ADDR, reg);       /* 0x1528 - DFS register */
+
+       /* Enable Self refresh */
+       /* [2] - DFS Self refresh enable  */
+       reg = reg_read(REG_DFS_ADDR) | (1 << REG_DFS_SR_OFFS);
+       dfs_reg_write(REG_DFS_ADDR, reg);       /* 0x1528 - DFS register */
+
+       /*
+        * Poll DFS Register - All DRAM devices on all ranks are in
+        * self refresh mode - DFS can be executed afterwards
+        */
+       /* 0x1528 [3] - DfsAtSR  */
+       do {
+               reg = reg_read(REG_DFS_ADDR) & (1 << REG_DFS_ATSR_OFFS);
+       } while (reg == 0x0);   /* Wait for '1' */
+
+       /*
+        * Set Correct Ratio - if freq>MARGIN_FREQ use 2:1 ratio
+        * else use 1:1 ratio
+        */
+       if (ratio_2to1) {
+               /* [15] = 1 - Set 2:1 Ratio between Dunit and Phy */
+               reg = reg_read(REG_DDR_IO_ADDR) |
+                       (1 << REG_DDR_IO_CLK_RATIO_OFFS);
+       } else {
+               /* [15] = 0 - Set 1:1 Ratio between Dunit and Phy */
+               reg = reg_read(REG_DDR_IO_ADDR) &
+                       ~(1 << REG_DDR_IO_CLK_RATIO_OFFS);
+       }
+       dfs_reg_write(REG_DDR_IO_ADDR, reg);    /* 0x1524 - DDR IO Register */
+
+       /* Switch HCLK Mux from (100Mhz) [16]=0, keep DFS request bit */
+       reg = 0x20040000;
+       /*
+        * [29] - training logic request DFS, [28:27] -
+        * preload patterns frequency [18]
+        */
+
+       /* 0x18488 - DRAM Init control status register */
+       dfs_reg_write(REG_DRAM_INIT_CTRL_STATUS_ADDR, reg);
+
+       /* Add delay between entering SR and start ratio modification */
+       udelay(1);
+
+       /*
+        * Initial Setup - assure that the "load new ratio" is clear (bit 24)
+        * and in the same chance, block reassertions of reset [15:8] and
+        * force reserved bits[7:0].
+        */
+       reg = 0x0000FFFF;
+       /* 0x18700 - CPU Div CLK control 0 */
+       dfs_reg_write(REG_CPU_DIV_CLK_CTRL_0_ADDR, reg);
+
+       /*
+        * RelaX whenever reset is asserted to that channel (good for any case)
+        */
+       reg = 0x0000FF00;
+       /* 0x18704 - CPU Div CLK control 0 */
+       dfs_reg_write(REG_CPU_DIV_CLK_CTRL_1_ADDR, reg);
+
+       reg = reg_read(REG_CPU_DIV_CLK_CTRL_3_ADDR) &
+               REG_CPU_DIV_CLK_CTRL_3_FREQ_MASK;
+       reg |= (freq_par << REG_CPU_DIV_CLK_CTRL_3_FREQ_OFFS);
+       /* Full Integer ratio from PLL-out to ddr-clk */
+       /* 0x1870C - CPU Div CLK control 3 register */
+       dfs_reg_write(REG_CPU_DIV_CLK_CTRL_3_ADDR, reg);
+
+       /*
+        * Shut off clock enable to the DDRPHY clock channel (this is the "D").
+        * All the rest are kept as is (forced, but could be read-modify-write).
+        * This is done now by RMW above.
+        */
+
+       reg = 0x000FFF02;
+
+       dfs_reg_write(REG_CPU_DIV_CLK_CTRL_4_ADDR, reg);
+
+       /* Wait before replacing the clock on the DDR Phy Channel. */
+       udelay(1);
+
+       reg = 0x0102FDFF;
+       /*
+        * This for triggering the frequency update. Bit[24] is the
+        * central control
+        * bits [23:16] == which channels to change ==2 ==> only DDR Phy
+        *                 (smooth transition)
+        * bits [15:8] == mask reset reassertion due to clock modification
+        *                to these channels.
+        * bits [7:0] == not in use
+        */
+       /* 0x18700 - CPU Div CLK control 0 register */
+       dfs_reg_write(REG_CPU_DIV_CLK_CTRL_0_ADDR, reg);
+
+       udelay(1);
+
+       /*
+        * Poll Div CLK status 0 register - indication that the clocks are
+        * active - 0x18718 [8]
+        */
+       do {
+               reg = reg_read(REG_CPU_DIV_CLK_STATUS_0_ADDR) &
+                       (1 << REG_CPU_DIV_CLK_ALL_STABLE_OFFS);
+       } while (reg == 0);
+
+       reg = 0x000000FF;
+       /*
+        * Clean the CTRL0, to be ready for next resets and next requests of
+        * ratio modifications.
+        */
+       /* 0x18700 - CPU Div CLK control 0 register */
+       dfs_reg_write(REG_CPU_DIV_CLK_CTRL_0_ADDR, reg);
+
+       udelay(5);
+
+       if (ratio_2to1) {
+               /* Pup Reset Divider B - Set Reset */
+               /* [28] = 0 - Pup Reset Divider B */
+               reg = reg_read(REG_SDRAM_CONFIG_ADDR) & ~(1 << 28);
+               /* [28] = 1 - Pup Reset Divider B */
+               tmp = reg_read(REG_SDRAM_CONFIG_ADDR) | (1 << 28);
+               /* 0x1400 - SDRAM Configuration register */
+               dfs_reg_write(REG_SDRAM_CONFIG_ADDR, reg);
+
+               /* Pup Reset Divider B - Release Reset */
+               /* 0x1400 - SDRAM Configuration register */
+               dfs_reg_write(REG_SDRAM_CONFIG_ADDR, tmp);
+       }
+
+       /* DRAM Data PHYs ADLL Reset - Set Reset */
+       reg = (reg_read(REG_DRAM_PHY_CONFIG_ADDR) & REG_DRAM_PHY_CONFIG_MASK);
+       /* [31:30]] - reset pup data ctrl ADLL */
+       /* 0x15EC - DRAM PHY Config Register */
+       dfs_reg_write(REG_DRAM_PHY_CONFIG_ADDR, reg);
+
+       udelay(25);
+
+       /* APLL lock indication - Poll Phy lock status Register - 0x1674 [9] */
+       do {
+               reg = reg_read(REG_PHY_LOCK_STATUS_ADDR) &
+                       (1 << REG_PHY_LOCK_STATUS_LOCK_OFFS);
+       } while (reg == 0);
+
+       /* DRAM Data PHYs ADLL Reset - Release Reset */
+       reg = reg_read(REG_DRAM_PHY_CONFIG_ADDR) | ~REG_DRAM_PHY_CONFIG_MASK;
+       /* [31:30] - normal pup data ctrl ADLL */
+       /* 0x15EC - DRAM PHY Config register */
+       dfs_reg_write(REG_DRAM_PHY_CONFIG_ADDR, reg);
+
+       udelay(10000);          /* Wait 10msec */
+
+       /*
+        * APLL lock indication - Poll Phy lock status Register - 0x1674 [11:0]
+        */
+       do {
+               reg = reg_read(REG_PHY_LOCK_STATUS_ADDR) &
+                       REG_PHY_LOCK_STATUS_LOCK_MASK;
+       } while (reg != REG_PHY_LOCK_STATUS_LOCK_MASK);
+
+       /* DRAM Data PHY Read [30], Write [29] path reset - Set Reset */
+       reg = reg_read(REG_SDRAM_CONFIG_ADDR) & REG_SDRAM_CONFIG_MASK;
+       /* [30:29] = 0 - Data Pup R/W path reset */
+       /* 0x1400 - SDRAM Configuration register */
+       dfs_reg_write(REG_SDRAM_CONFIG_ADDR, reg);
+
+       /* DRAM Data PHY Read [30], Write [29] path reset - Release Reset */
+       reg = reg_read(REG_SDRAM_CONFIG_ADDR) | ~REG_SDRAM_CONFIG_MASK;
+       /* [30:29] = '11' - Data Pup R/W path reset */
+       /* 0x1400 - SDRAM Configuration register */
+       dfs_reg_write(REG_SDRAM_CONFIG_ADDR, reg);
+
+       /* Disable DFS Reconfig */
+       reg = reg_read(REG_DFS_ADDR) & ~(1 << 4);
+       dfs_reg_write(REG_DFS_ADDR, reg);       /* 0x1528 - DFS register */
+
+       /* [2] - DFS Self refresh disable  */
+       reg = reg_read(REG_DFS_ADDR) & ~(1 << REG_DFS_SR_OFFS);
+       dfs_reg_write(REG_DFS_ADDR, reg);       /* 0x1528 - DFS register */
+
+       /*
+        * Poll DFS Register - 0x1528 [3] - DfsAtSR - All DRAM devices on
+        * all ranks are NOT in self refresh mode
+        */
+       do {
+               reg = reg_read(REG_DFS_ADDR) & (1 << REG_DFS_ATSR_OFFS);
+       } while (reg);          /* Wait for '0' */
+
+       /* 0x1404 */
+       reg = (reg_read(REG_DUNIT_CTRL_LOW_ADDR) & 0xFFFFFFE7) | 0x2;
+
+       /* Configure - 2T Mode - Restore original configuration */
+       /* [3:4] 2T - Restore value */
+       reg &= ~(REG_DUNIT_CTRL_LOW_2T_MASK << REG_DUNIT_CTRL_LOW_2T_OFFS);
+       reg |= ((dram_info->mode_2t & REG_DUNIT_CTRL_LOW_2T_MASK) <<
+               REG_DUNIT_CTRL_LOW_2T_OFFS);
+       dfs_reg_write(REG_DUNIT_CTRL_LOW_ADDR, reg);
+
+       udelay(1);              /* Wait 1us */
+
+       for (cs = 0; cs < MAX_CS; cs++) {
+               if (dram_info->cs_ena & (1 << cs)) {
+                       reg = (reg_read(REG_DDR3_MR1_ADDR));
+                       /* DLL Enable */
+                       reg &= ~(1 << REG_DDR3_MR1_DLL_ENA_OFFS);
+                       dfs_reg_write(REG_DDR3_MR1_ADDR, reg);
+
+                       /* Issue MRS Command to current cs */
+                       reg = REG_SDRAM_OPERATION_CMD_MR1 &
+                               ~(1 << (REG_SDRAM_OPERATION_CS_OFFS + cs));
+                       /*
+                        * [3-0] = 0x4 - MR1 Command, [11-8] -
+                        * enable current cs
+                        */
+                       /* 0x1418 - SDRAM Operation Register */
+                       dfs_reg_write(REG_SDRAM_OPERATION_ADDR, reg);
+
+                       /* Poll - Wait for Refresh operation completion */
+                       wait_refresh_op_complete();
+
+                       /* DLL Reset - MR0 */
+                       reg = reg_read(REG_DDR3_MR0_ADDR);
+                       dfs_reg_write(REG_DDR3_MR0_ADDR, reg);
+
+                       /* Issue MRS Command to current cs */
+                       reg = REG_SDRAM_OPERATION_CMD_MR0 &
+                               ~(1 << (REG_SDRAM_OPERATION_CS_OFFS + cs));
+                       /*
+                        * [3-0] = 0x4 - MR1 Command, [11-8] -
+                        * enable current cs
+                        */
+                       /* 0x1418 - SDRAM Operation Register */
+                       dfs_reg_write(REG_SDRAM_OPERATION_ADDR, reg);
+
+                       /* Poll - Wait for Refresh operation completion */
+                       wait_refresh_op_complete();
+
+                       reg = reg_read(REG_DDR3_MR0_ADDR);
+                       reg &= ~0x74;   /* CL [3:0]; [6:4],[2] */
+
+                       if (freq == DDR_400)
+                               tmp = ddr3_cl_to_valid_cl(6) & 0xF;
+                       else
+                               tmp = ddr3_cl_to_valid_cl(dram_info->cl) & 0xF;
+
+                       reg |= ((tmp & 0x1) << 2);
+                       reg |= ((tmp >> 1) << 4);       /* to bit 4 */
+                       dfs_reg_write(REG_DDR3_MR0_ADDR, reg);
+
+                       reg = REG_SDRAM_OPERATION_CMD_MR0 &
+                               ~(1 << (REG_SDRAM_OPERATION_CS_OFFS + cs));
+                       /* 0x1418 - SDRAM Operation Register */
+                       dfs_reg_write(REG_SDRAM_OPERATION_ADDR, reg);
+
+                       /* Poll - Wait for Refresh operation completion */
+                       wait_refresh_op_complete();
+
+                       reg = reg_read(REG_DDR3_MR2_ADDR);
+                       reg &= ~0x38;   /* CWL [5:3] */
+                       /* CWL = 0 ,for 400 MHg is 5 */
+                       if (freq != DDR_400)
+                               reg |= dram_info->cwl << REG_DDR3_MR2_CWL_OFFS;
+                       dfs_reg_write(REG_DDR3_MR2_ADDR, reg);
+                       reg = REG_SDRAM_OPERATION_CMD_MR2 &
+                               ~(1 << (REG_SDRAM_OPERATION_CS_OFFS + cs));
+                       /* 0x1418 - SDRAM Operation Register */
+                       dfs_reg_write(REG_SDRAM_OPERATION_ADDR, reg);
+
+                       /* Poll - Wait for Refresh operation completion */
+                       wait_refresh_op_complete();
+
+                       /* Set current rd_sample_delay  */
+                       reg = reg_read(REG_READ_DATA_SAMPLE_DELAYS_ADDR);
+                       reg &= ~(REG_READ_DATA_SAMPLE_DELAYS_MASK <<
+                                (REG_READ_DATA_SAMPLE_DELAYS_OFFS * cs));
+                       reg |= (dram_info->cl <<
+                               (REG_READ_DATA_SAMPLE_DELAYS_OFFS * cs));
+                       dfs_reg_write(REG_READ_DATA_SAMPLE_DELAYS_ADDR, reg);
+
+                       /* Set current rd_ready_delay  */
+                       reg = reg_read(REG_READ_DATA_READY_DELAYS_ADDR);
+                       reg &= ~(REG_READ_DATA_READY_DELAYS_MASK <<
+                                (REG_READ_DATA_READY_DELAYS_OFFS * cs));
+                       reg |= ((dram_info->cl + 1) <<
+                               (REG_READ_DATA_SAMPLE_DELAYS_OFFS * cs));
+                       dfs_reg_write(REG_READ_DATA_READY_DELAYS_ADDR, reg);
+               }
+       }
+
+       /* Enable ODT on DLL-on mode */
+       dfs_reg_write(REG_SDRAM_ODT_CTRL_HIGH_ADDR, 0);
+
+       /* [1] - DFS Block disable  */
+       reg = reg_read(REG_DFS_ADDR) & ~(1 << REG_DFS_BLOCK_OFFS);
+       dfs_reg_write(REG_DFS_ADDR, reg);       /* 0x1528 - DFS register */
+
+       /* Change DDR frequency to 100MHz procedure: */
+       /* 0x1600 - PHY lock mask register */
+       reg = reg_read(REG_ODPG_CNTRL_ADDR);
+       reg &= ~(1 << REG_ODPG_CNTRL_OFFS);     /* [21] = 0 */
+       dfs_reg_write(REG_ODPG_CNTRL_ADDR, reg);
+
+       /* Change DDR frequency to 100MHz procedure: */
+       /* 0x1670 - PHY lock mask register */
+       reg = reg_read(REG_PHY_LOCK_MASK_ADDR);
+       reg |= ~REG_PHY_LOCK_MASK_MASK; /* [11:0] = FFF */
+       dfs_reg_write(REG_PHY_LOCK_MASK_ADDR, reg);
+
+       reg = reg_read(REG_METAL_MASK_ADDR) | (1 << 0); /* [0] - disable */
+       /* 0x14B0 - Dunit MMask Register */
+       dfs_reg_write(REG_METAL_MASK_ADDR, reg);
+
+       DEBUG_DFS_C("DDR3 - DFS - Low To High - Ended successfuly - new Frequency - ",
+                   freq, 1);
+       return MV_OK;
+#endif
+}
diff --git a/drivers/ddr/mvebu/ddr3_dqs.c b/drivers/ddr/mvebu/ddr3_dqs.c
new file mode 100644 (file)
index 0000000..71a986d
--- /dev/null
@@ -0,0 +1,1374 @@
+/*
+ * Copyright (C) Marvell International Ltd. and its affiliates
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#include <common.h>
+#include <i2c.h>
+#include <spl.h>
+#include <asm/io.h>
+#include <asm/arch/cpu.h>
+#include <asm/arch/soc.h>
+
+#include "ddr3_hw_training.h"
+
+/*
+ * Debug
+ */
+#define DEBUG_DQS_C(s, d, l) \
+       DEBUG_DQS_S(s); DEBUG_DQS_D(d, l); DEBUG_DQS_S("\n")
+#define DEBUG_DQS_FULL_C(s, d, l) \
+       DEBUG_DQS_FULL_S(s); DEBUG_DQS_FULL_D(d, l); DEBUG_DQS_FULL_S("\n")
+#define DEBUG_DQS_RESULTS_C(s, d, l) \
+       DEBUG_DQS_RESULTS_S(s); DEBUG_DQS_RESULTS_D(d, l); DEBUG_DQS_RESULTS_S("\n")
+#define DEBUG_PER_DQ_C(s, d, l) \
+       puts(s); printf("%x", d); puts("\n")
+
+#define DEBUG_DQS_RESULTS_S(s) \
+       debug_cond(ddr3_get_log_level() >= MV_LOG_LEVEL_2, "%s", s)
+#define DEBUG_DQS_RESULTS_D(d, l) \
+       debug_cond(ddr3_get_log_level() >= MV_LOG_LEVEL_2, "%x", d)
+
+#define DEBUG_PER_DQ_S(s) \
+       debug_cond(ddr3_get_log_level() >= MV_LOG_LEVEL_3, "%s", s)
+#define DEBUG_PER_DQ_D(d, l) \
+       debug_cond(ddr3_get_log_level() >= MV_LOG_LEVEL_3, "%x", d)
+#define DEBUG_PER_DQ_DD(d, l) \
+       debug_cond(ddr3_get_log_level() >= MV_LOG_LEVEL_3, "%d", d)
+
+#ifdef MV_DEBUG_DQS
+#define DEBUG_DQS_S(s)                 puts(s)
+#define DEBUG_DQS_D(d, l)              printf("%x", d)
+#else
+#define DEBUG_DQS_S(s)
+#define DEBUG_DQS_D(d, l)
+#endif
+
+#ifdef MV_DEBUG_DQS_FULL
+#define DEBUG_DQS_FULL_S(s)            puts(s)
+#define DEBUG_DQS_FULL_D(d, l)         printf("%x", d)
+#else
+#define DEBUG_DQS_FULL_S(s)
+#define DEBUG_DQS_FULL_D(d, l)
+#endif
+
+/* State machine for centralization - find low & high limit */
+enum {
+       PUP_ADLL_LIMITS_STATE_FAIL,
+       PUP_ADLL_LIMITS_STATE_PASS,
+       PUP_ADLL_LIMITS_STATE_FAIL_AFTER_PASS,
+};
+
+/* Hold centralization low results */
+static int centralization_low_limit[MAX_PUP_NUM] = { 0 };
+/* Hold centralization high results */
+static int centralization_high_limit[MAX_PUP_NUM] = { 0 };
+
+int ddr3_find_adll_limits(MV_DRAM_INFO *dram_info, u32 cs, u32 ecc, int is_tx);
+int ddr3_check_window_limits(u32 pup, int high_limit, int low_limit, int is_tx,
+                         int *size_valid);
+static int ddr3_center_calc(MV_DRAM_INFO *dram_info, u32 cs, u32 ecc,
+                           int is_tx);
+int ddr3_special_pattern_i_search(MV_DRAM_INFO *dram_info, u32 cs, u32 ecc,
+                             int is_tx, u32 special_pattern_pup);
+int ddr3_special_pattern_ii_search(MV_DRAM_INFO *dram_info, u32 cs, u32 ecc,
+                                  int is_tx, u32 special_pattern_pup);
+int ddr3_set_dqs_centralization_results(MV_DRAM_INFO *dram_info, u32 cs, u32 ecc,
+                                   int is_tx);
+
+#ifdef MV88F78X60
+extern u32 killer_pattern_32b[DQ_NUM][LEN_SPECIAL_PATTERN];
+extern u32 killer_pattern_64b[DQ_NUM][LEN_SPECIAL_PATTERN];
+extern int per_bit_data[MAX_PUP_NUM][DQ_NUM];
+#else
+extern u32 killer_pattern[DQ_NUM][LEN_16BIT_KILLER_PATTERN];
+extern u32 killer_pattern_32b[DQ_NUM][LEN_SPECIAL_PATTERN];
+#if defined(MV88F672X)
+extern int per_bit_data[MAX_PUP_NUM][DQ_NUM];
+#endif
+#endif
+extern u32 special_pattern[DQ_NUM][LEN_SPECIAL_PATTERN];
+
+static u32 *ddr3_dqs_choose_pattern(MV_DRAM_INFO *dram_info, u32 victim_dq)
+{
+       u32 *pattern_ptr;
+
+       /* Choose pattern */
+       switch (dram_info->ddr_width) {
+#if defined(MV88F672X)
+       case 16:
+               pattern_ptr = (u32 *)&killer_pattern[victim_dq];
+               break;
+#endif
+       case 32:
+               pattern_ptr = (u32 *)&killer_pattern_32b[victim_dq];
+               break;
+#if defined(MV88F78X60)
+       case 64:
+               pattern_ptr = (u32 *)&killer_pattern_64b[victim_dq];
+               break;
+#endif
+       default:
+#if defined(MV88F78X60)
+               pattern_ptr = (u32 *)&killer_pattern_32b[victim_dq];
+#else
+               pattern_ptr = (u32 *)&killer_pattern[victim_dq];
+#endif
+               break;
+       }
+
+       return pattern_ptr;
+}
+
+/*
+ * Name:     ddr3_dqs_centralization_rx
+ * Desc:     Execute the DQS centralization RX phase.
+ * Args:     dram_info
+ * Notes:
+ * Returns:  MV_OK if success, other error code if fail.
+ */
+int ddr3_dqs_centralization_rx(MV_DRAM_INFO *dram_info)
+{
+       u32 cs, ecc, reg;
+       int status;
+
+       DEBUG_DQS_S("DDR3 - DQS Centralization RX - Starting procedure\n");
+
+       /* Enable SW override */
+       reg = reg_read(REG_DRAM_TRAINING_2_ADDR) |
+               (1 << REG_DRAM_TRAINING_2_SW_OVRD_OFFS);
+
+       /* [0] = 1 - Enable SW override  */
+       /* 0x15B8 - Training SW 2 Register */
+       reg_write(REG_DRAM_TRAINING_2_ADDR, reg);
+       DEBUG_DQS_S("DDR3 - DQS Centralization RX - SW Override Enabled\n");
+
+       reg = (1 << REG_DRAM_TRAINING_AUTO_OFFS);
+       reg_write(REG_DRAM_TRAINING_ADDR, reg); /* 0x15B0 - Training Register */
+
+       /* Loop for each CS */
+       for (cs = 0; cs < MAX_CS; cs++) {
+               if (dram_info->cs_ena & (1 << cs)) {
+                       DEBUG_DQS_FULL_C("DDR3 - DQS Centralization RX - CS - ",
+                                        (u32) cs, 1);
+
+                       for (ecc = 0; ecc < (dram_info->ecc_ena + 1); ecc++) {
+
+                               /* ECC Support - Switch ECC Mux on ecc=1 */
+                               reg = reg_read(REG_DRAM_TRAINING_2_ADDR) &
+                                       ~(1 << REG_DRAM_TRAINING_2_ECC_MUX_OFFS);
+                               reg |= (dram_info->ecc_ena *
+                                       ecc << REG_DRAM_TRAINING_2_ECC_MUX_OFFS);
+                               reg_write(REG_DRAM_TRAINING_2_ADDR, reg);
+
+                               if (ecc)
+                                       DEBUG_DQS_FULL_S("DDR3 - DQS Centralization RX - ECC Mux Enabled\n");
+                               else
+                                       DEBUG_DQS_FULL_S("DDR3 - DQS Centralization RX - ECC Mux Disabled\n");
+
+                               DEBUG_DQS_FULL_S("DDR3 - DQS Centralization RX - Find all limits\n");
+
+                               status = ddr3_find_adll_limits(dram_info, cs,
+                                                              ecc, 0);
+                               if (MV_OK != status)
+                                       return status;
+
+                               DEBUG_DQS_FULL_S("DDR3 - DQS Centralization RX - Start calculating center\n");
+
+                               status = ddr3_center_calc(dram_info, cs, ecc,
+                                                         0);
+                               if (MV_OK != status)
+                                       return status;
+                       }
+               }
+       }
+
+       /* ECC Support - Disable ECC MUX */
+       reg = reg_read(REG_DRAM_TRAINING_2_ADDR) &
+               ~(1 << REG_DRAM_TRAINING_2_ECC_MUX_OFFS);
+       reg_write(REG_DRAM_TRAINING_2_ADDR, reg);
+
+       /* Disable SW override - Must be in a different stage */
+       /* [0]=0 - Enable SW override  */
+       reg = reg_read(REG_DRAM_TRAINING_2_ADDR);
+       reg &= ~(1 << REG_DRAM_TRAINING_2_SW_OVRD_OFFS);
+       /* 0x15B8 - Training SW 2 Register */
+       reg_write(REG_DRAM_TRAINING_2_ADDR, reg);
+
+       reg = reg_read(REG_DRAM_TRAINING_1_ADDR) |
+               (1 << REG_DRAM_TRAINING_1_TRNBPOINT_OFFS);
+       reg_write(REG_DRAM_TRAINING_1_ADDR, reg);
+
+       return MV_OK;
+}
+
+/*
+ * Name:     ddr3_dqs_centralization_tx
+ * Desc:     Execute the DQS centralization TX phase.
+ * Args:     dram_info
+ * Notes:
+ * Returns:  MV_OK if success, other error code if fail.
+ */
+int ddr3_dqs_centralization_tx(MV_DRAM_INFO *dram_info)
+{
+       u32 cs, ecc, reg;
+       int status;
+
+       DEBUG_DQS_S("DDR3 - DQS Centralization TX - Starting procedure\n");
+
+       /* Enable SW override */
+       reg = reg_read(REG_DRAM_TRAINING_2_ADDR) |
+               (1 << REG_DRAM_TRAINING_2_SW_OVRD_OFFS);
+
+       /* [0] = 1 - Enable SW override  */
+       /* 0x15B8 - Training SW 2 Register */
+       reg_write(REG_DRAM_TRAINING_2_ADDR, reg);
+       DEBUG_DQS_S("DDR3 - DQS Centralization TX - SW Override Enabled\n");
+
+       reg = (1 << REG_DRAM_TRAINING_AUTO_OFFS);
+       reg_write(REG_DRAM_TRAINING_ADDR, reg); /* 0x15B0 - Training Register */
+
+       /* Loop for each CS */
+       for (cs = 0; cs < MAX_CS; cs++) {
+               if (dram_info->cs_ena & (1 << cs)) {
+                       DEBUG_DQS_FULL_C("DDR3 - DQS Centralization TX - CS - ",
+                                        (u32) cs, 1);
+                       for (ecc = 0; ecc < (dram_info->ecc_ena + 1); ecc++) {
+                               /* ECC Support - Switch ECC Mux on ecc=1 */
+                               reg = reg_read(REG_DRAM_TRAINING_2_ADDR) &
+                                       ~(1 << REG_DRAM_TRAINING_2_ECC_MUX_OFFS);
+                               reg |= (dram_info->ecc_ena *
+                                       ecc << REG_DRAM_TRAINING_2_ECC_MUX_OFFS);
+                               reg_write(REG_DRAM_TRAINING_2_ADDR, reg);
+
+                               if (ecc)
+                                       DEBUG_DQS_FULL_S("DDR3 - DQS Centralization TX - ECC Mux Enabled\n");
+                               else
+                                       DEBUG_DQS_FULL_S("DDR3 - DQS Centralization TX - ECC Mux Disabled\n");
+
+                               DEBUG_DQS_FULL_S("DDR3 - DQS Centralization TX - Find all limits\n");
+
+                               status = ddr3_find_adll_limits(dram_info, cs,
+                                                              ecc, 1);
+                               if (MV_OK != status)
+                                       return status;
+
+                               DEBUG_DQS_FULL_S("DDR3 - DQS Centralization TX - Start calculating center\n");
+
+                               status = ddr3_center_calc(dram_info, cs, ecc,
+                                                         1);
+                               if (MV_OK != status)
+                                       return status;
+                       }
+               }
+       }
+
+       /* ECC Support - Disable ECC MUX */
+       reg = reg_read(REG_DRAM_TRAINING_2_ADDR) &
+               ~(1 << REG_DRAM_TRAINING_2_ECC_MUX_OFFS);
+       reg_write(REG_DRAM_TRAINING_2_ADDR, reg);
+
+       /* Disable SW override - Must be in a different stage */
+       /* [0]=0 - Enable SW override  */
+       reg = reg_read(REG_DRAM_TRAINING_2_ADDR);
+       reg &= ~(1 << REG_DRAM_TRAINING_2_SW_OVRD_OFFS);
+       /* 0x15B8 - Training SW 2 Register */
+       reg_write(REG_DRAM_TRAINING_2_ADDR, reg);
+
+       reg = reg_read(REG_DRAM_TRAINING_1_ADDR) |
+               (1 << REG_DRAM_TRAINING_1_TRNBPOINT_OFFS);
+       reg_write(REG_DRAM_TRAINING_1_ADDR, reg);
+
+       return MV_OK;
+}
+
+/*
+ * Name:     ddr3_find_adll_limits
+ * Desc:     Execute the Find ADLL limits phase.
+ * Args:     dram_info
+ *           cs
+ *           ecc_ena
+ *           is_tx             Indicate whether Rx or Tx
+ * Notes:
+ * Returns:  MV_OK if success, other error code if fail.
+ */
+int ddr3_find_adll_limits(MV_DRAM_INFO *dram_info, u32 cs, u32 ecc, int is_tx)
+{
+       u32 victim_dq, pup, tmp;
+       u32 adll_addr;
+       u32 max_pup;            /* maximal pup index */
+       u32 pup_mask = 0;
+       u32 unlock_pup;         /* bit array of un locked pups */
+       u32 new_unlock_pup;     /* bit array of compare failed pups */
+       u32 curr_adll;
+       u32 adll_start_val;     /* adll start loop value - for rx or tx limit */
+       u32 high_limit; /* holds found High Limit */
+       u32 low_limit;          /* holds found Low Limit */
+       int win_valid;
+       int update_win;
+       u32 sdram_offset;
+       u32 uj, cs_count, cs_tmp, ii;
+       u32 *pattern_ptr;
+       u32 dq;
+       u32 adll_end_val;       /* adll end of loop val - for rx or tx limit */
+       u8 analog_pbs[DQ_NUM][MAX_PUP_NUM][DQ_NUM][2];
+       u8 analog_pbs_sum[MAX_PUP_NUM][DQ_NUM][2];
+       int pup_adll_limit_state[MAX_PUP_NUM];  /* hold state of each pup */
+
+       adll_addr = ((is_tx == 1) ? PUP_DQS_WR : PUP_DQS_RD);
+       adll_end_val = ((is_tx == 1) ? ADLL_MIN : ADLL_MAX);
+       adll_start_val = ((is_tx == 1) ? ADLL_MAX : ADLL_MIN);
+       max_pup = (ecc + (1 - ecc) * dram_info->num_of_std_pups);
+
+       DEBUG_DQS_FULL_S("DDR3 - DQS Find Limits - Starting Find ADLL Limits\n");
+
+       /* init the array */
+       for (pup = 0; pup < max_pup; pup++) {
+               centralization_low_limit[pup] = ADLL_MIN;
+               centralization_high_limit[pup] = ADLL_MAX;
+       }
+
+       /* Killer Pattern */
+       cs_count = 0;
+       for (cs_tmp = 0; cs_tmp < cs; cs_tmp++) {
+               if (dram_info->cs_ena & (1 << cs_tmp))
+                       cs_count++;
+       }
+       sdram_offset = cs_count * (SDRAM_CS_SIZE + 1);
+       sdram_offset += ((is_tx == 1) ?
+                        SDRAM_DQS_TX_OFFS : SDRAM_DQS_RX_OFFS);
+
+       /* Prepare pup masks */
+       for (pup = 0; pup < max_pup; pup++)
+               pup_mask |= (1 << pup);
+
+       for (pup = 0; pup < max_pup; pup++) {
+               for (dq = 0; dq < DQ_NUM; dq++) {
+                       analog_pbs_sum[pup][dq][0] = adll_start_val;
+                       analog_pbs_sum[pup][dq][1] = adll_end_val;
+               }
+       }
+
+       /* Loop - use different pattern for each victim_dq */
+       for (victim_dq = 0; victim_dq < DQ_NUM; victim_dq++) {
+               DEBUG_DQS_FULL_C("DDR3 - DQS Find Limits - Victim DQ - ",
+                                (u32)victim_dq, 1);
+               /*
+                * The pups 3 bit arrays represent state machine. with
+                * 3 stages for each pup.
+                * 1. fail and didn't get pass in earlier compares.
+                * 2. pass compare
+                * 3. fail after pass - end state.
+                * The window limits are the adll values where the adll
+                * was in the pass stage.
+                */
+
+               /* Set all states to Fail (1st state) */
+               for (pup = 0; pup < max_pup; pup++)
+                       pup_adll_limit_state[pup] = PUP_ADLL_LIMITS_STATE_FAIL;
+
+               /* Set current valid pups */
+               unlock_pup = pup_mask;
+
+               /* Set ADLL to start value */
+               curr_adll = adll_start_val;
+
+#if defined(MV88F78X60)
+               for (pup = 0; pup < max_pup; pup++) {
+                       for (dq = 0; dq < DQ_NUM; dq++) {
+                               analog_pbs[victim_dq][pup][dq][0] =
+                                       adll_start_val;
+                               analog_pbs[victim_dq][pup][dq][1] =
+                                       adll_end_val;
+                               per_bit_data[pup][dq] = 0;
+                       }
+               }
+#endif
+
+               for (uj = 0; uj < ADLL_MAX; uj++) {
+                       DEBUG_DQS_FULL_C("DDR3 - DQS Find Limits - Setting ADLL to ",
+                                        curr_adll, 2);
+                       for (pup = 0; pup < max_pup; pup++) {
+                               if (IS_PUP_ACTIVE(unlock_pup, pup) == 1) {
+                                       tmp = ((is_tx == 1) ? curr_adll +
+                                              dram_info->wl_val[cs]
+                                              [pup * (1 - ecc) + ecc * ECC_PUP]
+                                              [D] : curr_adll);
+                                       ddr3_write_pup_reg(adll_addr, cs, pup +
+                                               (ecc * ECC_PUP), 0, tmp);
+                               }
+                       }
+
+                       /* Choose pattern */
+                       pattern_ptr = ddr3_dqs_choose_pattern(dram_info,
+                                                             victim_dq);
+
+                       /* '1' - means pup failed, '0' - means pup pass */
+                       new_unlock_pup = 0;
+
+                       /* Read and compare results for Victim_DQ# */
+                       for (ii = 0; ii < 3; ii++) {
+                               u32 tmp = 0;
+                               if (MV_OK != ddr3_sdram_dqs_compare(dram_info,
+                                                          unlock_pup, &tmp,
+                                                          pattern_ptr,
+                                                          LEN_KILLER_PATTERN,
+                                                          sdram_offset +
+                                                          LEN_KILLER_PATTERN *
+                                                          4 * victim_dq,
+                                                          is_tx, 0, NULL,
+                                                          0))
+                                       return MV_DDR3_TRAINING_ERR_DRAM_COMPARE;
+
+                               new_unlock_pup |= tmp;
+                       }
+
+                       pup = 0;
+                       DEBUG_DQS_FULL_C("DDR3 - DQS Find Limits - UnlockPup: ",
+                                        unlock_pup, 2);
+                       DEBUG_DQS_FULL_C("DDR3 - DQS Find Limits - NewUnlockPup: ",
+                                        new_unlock_pup, 2);
+
+                       /* Update pup state */
+                       for (pup = 0; pup < max_pup; pup++) {
+                               if (IS_PUP_ACTIVE(unlock_pup, pup) == 0) {
+                                       DEBUG_DQS_FULL_C("DDR3 - DQS Find Limits - Skipping pup ",
+                                                        pup, 1);
+                                       continue;
+                               }
+
+                               /*
+                                * Still didn't find the window limit of the pup
+                                */
+                               if (IS_PUP_ACTIVE(new_unlock_pup, pup) == 1) {
+                                       /* Current compare result == fail */
+                                       if (pup_adll_limit_state[pup] ==
+                                           PUP_ADLL_LIMITS_STATE_PASS) {
+                                               /*
+                                                * If now it failed but passed
+                                                * earlier
+                                                */
+                                               DEBUG_DQS_S("DDR3 - DQS Find Limits - PASS to FAIL: CS - ");
+                                               DEBUG_DQS_D(cs, 1);
+                                               DEBUG_DQS_S(", DQ - ");
+                                               DEBUG_DQS_D(victim_dq, 1);
+                                               DEBUG_DQS_S(", Pup - ");
+                                               DEBUG_DQS_D(pup, 1);
+                                               DEBUG_DQS_S(", ADLL - ");
+                                               DEBUG_DQS_D(curr_adll, 2);
+                                               DEBUG_DQS_S("\n");
+
+#if defined(MV88F78X60)
+                                               for (dq = 0; dq < DQ_NUM; dq++) {
+                                                       if ((analog_pbs[victim_dq][pup][dq][0] != adll_start_val)
+                                                           && (analog_pbs[victim_dq][pup]
+                                                               [dq][1] == adll_end_val))
+                                                               analog_pbs
+                                                                       [victim_dq]
+                                                                       [pup][dq]
+                                                                       [1] =
+                                                                       curr_adll;
+                                               }
+#endif
+                                               win_valid = 1;
+                                               update_win = 0;
+
+                                               /* Keep min / max limit value */
+                                               if (is_tx == 0) {
+                                                       /* RX - found upper limit */
+                                                       if (centralization_high_limit[pup] >
+                                                           (curr_adll - 1)) {
+                                                               high_limit =
+                                                                       curr_adll - 1;
+                                                               low_limit =
+                                                                       centralization_low_limit[pup];
+                                                               update_win = 1;
+                                                       }
+                                               } else {
+                                                       /* TX - found lower limit */
+                                                       if (centralization_low_limit[pup] < (curr_adll + 1)) {
+                                                               high_limit =
+                                                                       centralization_high_limit
+                                                                       [pup];
+                                                               low_limit =
+                                                                       curr_adll + 1;
+                                                               update_win =
+                                                                       1;
+                                                       }
+                                               }
+
+                                               if (update_win == 1) {
+                                                       /*
+                                                        * Before updating
+                                                        * window limits we need
+                                                        * to check that the
+                                                        * limits are valid
+                                                        */
+                                                       if (MV_OK !=
+                                                           ddr3_check_window_limits
+                                                           (pup, high_limit,
+                                                            low_limit, is_tx,
+                                                            &win_valid))
+                                                               return MV_DDR3_TRAINING_ERR_WIN_LIMITS;
+
+                                                       if (win_valid == 1) {
+                                                               /*
+                                                                * Window limits
+                                                                * should be
+                                                                * updated
+                                                                */
+                                                               centralization_low_limit
+                                                                       [pup] =
+                                                                       low_limit;
+                                                               centralization_high_limit
+                                                                       [pup] =
+                                                                       high_limit;
+                                                       }
+                                               }
+
+                                               if (win_valid == 1) {
+                                                       /* Found end of window - lock the pup */
+                                                       pup_adll_limit_state[pup] =
+                                                               PUP_ADLL_LIMITS_STATE_FAIL_AFTER_PASS;
+                                                       unlock_pup &= ~(1 << pup);
+                                               } else {
+                                                       /* Probably false pass - reset status */
+                                                       pup_adll_limit_state[pup] =
+                                                               PUP_ADLL_LIMITS_STATE_FAIL;
+
+#if defined(MV88F78X60)
+                                                       /* Clear logging array of win size (per Dq) */
+                                                       for (dq = 0;
+                                                            dq < DQ_NUM;
+                                                            dq++) {
+                                                               analog_pbs
+                                                                       [victim_dq]
+                                                                       [pup][dq]
+                                                                       [0] =
+                                                                       adll_start_val;
+                                                               analog_pbs
+                                                                       [victim_dq]
+                                                                       [pup][dq]
+                                                                       [1] =
+                                                                       adll_end_val;
+                                                               per_bit_data
+                                                                       [pup][dq]
+                                                                       = 0;
+                                                       }
+#endif
+                                               }
+                                       }
+                               } else {
+                                       /* Current compare result == pass */
+                                       if (pup_adll_limit_state[pup] ==
+                                           PUP_ADLL_LIMITS_STATE_FAIL) {
+                                               /* If now it passed but failed earlier */
+                                               DEBUG_DQS_S("DDR3 - DQS Find Limits - FAIL to PASS: CS - ");
+                                               DEBUG_DQS_D(cs, 1);
+                                               DEBUG_DQS_S(", DQ - ");
+                                               DEBUG_DQS_D(victim_dq, 1);
+                                               DEBUG_DQS_S(", Pup - ");
+                                               DEBUG_DQS_D(pup, 1);
+                                               DEBUG_DQS_S(", ADLL - ");
+                                               DEBUG_DQS_D(curr_adll, 2);
+                                               DEBUG_DQS_S("\n");
+
+#if defined(MV88F78X60)
+                                               for (dq = 0; dq < DQ_NUM;
+                                                    dq++) {
+                                                       if (analog_pbs[victim_dq][pup][dq][0] == adll_start_val)
+                                                               analog_pbs
+                                                                   [victim_dq]
+                                                                   [pup][dq]
+                                                                   [0] =
+                                                                   curr_adll;
+                                               }
+#endif
+                                               /* Found start of window */
+                                               pup_adll_limit_state[pup] =
+                                                   PUP_ADLL_LIMITS_STATE_PASS;
+
+                                               /* Keep min / max limit value */
+                                               if (is_tx == 0) {
+                                                       /* RX - found low limit */
+                                                       if (centralization_low_limit[pup] <= curr_adll)
+                                                               centralization_low_limit
+                                                                   [pup] =
+                                                                   curr_adll;
+                                               } else {
+                                                       /* TX - found high limit */
+                                                       if (centralization_high_limit[pup] >= curr_adll)
+                                                               centralization_high_limit
+                                                                   [pup] =
+                                                                   curr_adll;
+                                               }
+                                       }
+                               }
+                       }
+
+                       if (unlock_pup == 0) {
+                               /* Found limit to all pups */
+                               DEBUG_DQS_FULL_S("DDR3 - DQS Find Limits - found PUP limit\n");
+                               break;
+                       }
+
+                       /*
+                        * Increment / decrement (Move to right / left
+                        * one phase - ADLL) dqs RX / TX delay (for all un
+                        * lock pups
+                        */
+                       if (is_tx == 0)
+                               curr_adll++;
+                       else
+                               curr_adll--;
+               }
+
+               if (unlock_pup != 0) {
+                       /*
+                        * Found pups that didn't reach to the end of the
+                        * state machine
+                        */
+                       DEBUG_DQS_C("DDR3 - DQS Find Limits - Pups that didn't reached end of the state machine: ",
+                                   unlock_pup, 1);
+
+                       for (pup = 0; pup < max_pup; pup++) {
+                               if (IS_PUP_ACTIVE(unlock_pup, pup) == 1) {
+                                       if (pup_adll_limit_state[pup] ==
+                                           PUP_ADLL_LIMITS_STATE_FAIL) {
+                                               /* ERROR - found fail for all window size */
+                                               DEBUG_DQS_S("DDR3 - DQS Find Limits - Got FAIL for the complete range on pup - ");
+                                               DEBUG_DQS_D(pup, 1);
+                                               DEBUG_DQS_C(" victim DQ ",
+                                                           victim_dq, 1);
+
+                                               /* For debug - set min limit to illegal limit */
+                                               centralization_low_limit[pup]
+                                                       = ADLL_ERROR;
+                                               /*
+                                                * In case the pup is in mode
+                                                * PASS - the limit is the min
+                                                * / max adll, no need to
+                                                * update because of the results
+                                                * array default value
+                                                */
+                                               return MV_DDR3_TRAINING_ERR_PUP_RANGE;
+                                       }
+                               }
+                       }
+               }
+       }
+
+       DEBUG_DQS_S("DDR3 - DQS Find Limits - DQ values per victim results:\n");
+       for (victim_dq = 0; victim_dq < DQ_NUM; victim_dq++) {
+               for (pup = 0; pup < max_pup; pup++) {
+                       DEBUG_DQS_S("Victim DQ-");
+                       DEBUG_DQS_D(victim_dq, 1);
+                       DEBUG_DQS_S(", PUP-");
+                       DEBUG_DQS_D(pup, 1);
+                       for (dq = 0; dq < DQ_NUM; dq++) {
+                               DEBUG_DQS_S(", DQ-");
+                               DEBUG_DQS_D(dq, 1);
+                               DEBUG_DQS_S(",S-");
+                               DEBUG_DQS_D(analog_pbs[victim_dq][pup][dq]
+                                           [0], 2);
+                               DEBUG_DQS_S(",E-");
+                               DEBUG_DQS_D(analog_pbs[victim_dq][pup][dq]
+                                           [1], 2);
+
+                               if (is_tx == 0) {
+                                       if (analog_pbs[victim_dq][pup][dq][0]
+                                           > analog_pbs_sum[pup][dq][0])
+                                               analog_pbs_sum[pup][dq][0] =
+                                                   analog_pbs[victim_dq][pup]
+                                                   [dq][0];
+                                       if (analog_pbs[victim_dq][pup][dq][1]
+                                           < analog_pbs_sum[pup][dq][1])
+                                               analog_pbs_sum[pup][dq][1] =
+                                                   analog_pbs[victim_dq][pup]
+                                                   [dq][1];
+                               } else {
+                                       if (analog_pbs[victim_dq][pup][dq][0]
+                                           < analog_pbs_sum[pup][dq][0])
+                                               analog_pbs_sum[pup][dq][0] =
+                                                   analog_pbs[victim_dq][pup]
+                                                   [dq][0];
+                                       if (analog_pbs[victim_dq][pup][dq][1]
+                                           > analog_pbs_sum[pup][dq][1])
+                                               analog_pbs_sum[pup][dq][1] =
+                                                   analog_pbs[victim_dq][pup]
+                                                   [dq][1];
+                               }
+                       }
+                       DEBUG_DQS_S("\n");
+               }
+       }
+
+       if (ddr3_get_log_level() >= MV_LOG_LEVEL_3) {
+               u32 dq;
+
+               DEBUG_PER_DQ_S("\n########## LOG LEVEL 3(Windows margins per-DQ) ##########\n");
+               if (is_tx) {
+                       DEBUG_PER_DQ_C("DDR3 - TX  CS: ", cs, 1);
+               } else {
+                       DEBUG_PER_DQ_C("DDR3 - RX  CS: ", cs, 1);
+               }
+
+               if (ecc == 0) {
+                       DEBUG_PER_DQ_S("\n DATA RESULTS:\n");
+               } else {
+                       DEBUG_PER_DQ_S("\n ECC RESULTS:\n");
+               }
+
+               /* Since all dq has the same value we take 0 as representive */
+               dq = 0;
+               for (pup = 0; pup < max_pup; pup++) {
+                       if (ecc == 0) {
+                               DEBUG_PER_DQ_S("\nBYTE:");
+                               DEBUG_PER_DQ_D(pup, 1);
+                               DEBUG_PER_DQ_S("\n");
+                       } else {
+                               DEBUG_PER_DQ_S("\nECC BYTE:\n");
+                       }
+                       DEBUG_PER_DQ_S("  DQ's        LOW       HIGH       WIN-SIZE\n");
+                       DEBUG_PER_DQ_S("============================================\n");
+                       for (victim_dq = 0; victim_dq < DQ_NUM; victim_dq++) {
+                               if (ecc == 0) {
+                                       DEBUG_PER_DQ_S("DQ[");
+                                       DEBUG_PER_DQ_DD((victim_dq +
+                                                        DQ_NUM * pup), 2);
+                                       DEBUG_PER_DQ_S("]");
+                               } else {
+                                       DEBUG_PER_DQ_S("CB[");
+                                       DEBUG_PER_DQ_DD(victim_dq, 2);
+                                       DEBUG_PER_DQ_S("]");
+                               }
+                               if (is_tx) {
+                                       DEBUG_PER_DQ_S("      0x");
+                                       DEBUG_PER_DQ_D(analog_pbs[victim_dq][pup][dq][1], 2);   /* low value */
+                                       DEBUG_PER_DQ_S("        0x");
+                                       DEBUG_PER_DQ_D(analog_pbs[victim_dq][pup][dq][0], 2);   /* high value */
+                                       DEBUG_PER_DQ_S("        0x");
+                                       DEBUG_PER_DQ_D(analog_pbs[victim_dq][pup][dq][0] - analog_pbs[victim_dq][pup][dq][1], 2);       /* win-size */
+                               } else {
+                                       DEBUG_PER_DQ_S("     0x");
+                                       DEBUG_PER_DQ_D(analog_pbs[victim_dq][pup][dq][0], 2);   /* low value */
+                                       DEBUG_PER_DQ_S("       0x");
+                                       DEBUG_PER_DQ_D((analog_pbs[victim_dq][pup][dq][1] - 1), 2);     /* high value */
+                                       DEBUG_PER_DQ_S("       0x");
+                                       DEBUG_PER_DQ_D(analog_pbs[victim_dq][pup][dq][1] - analog_pbs[victim_dq][pup][dq][0], 2);       /* win-size */
+                               }
+                               DEBUG_PER_DQ_S("\n");
+                       }
+               }
+               DEBUG_PER_DQ_S("\n");
+       }
+
+       if (is_tx) {
+               DEBUG_DQS_S("DDR3 - DQS TX - Find Limits - DQ values Summary:\n");
+       } else {
+               DEBUG_DQS_S("DDR3 - DQS RX - Find Limits - DQ values Summary:\n");
+       }
+
+       for (pup = 0; pup < max_pup; pup++) {
+               DEBUG_DQS_S("PUP-");
+               DEBUG_DQS_D(pup, 1);
+               for (dq = 0; dq < DQ_NUM; dq++) {
+                       DEBUG_DQS_S(", DQ-");
+                       DEBUG_DQS_D(dq, 1);
+                       DEBUG_DQS_S(",S-");
+                       DEBUG_DQS_D(analog_pbs_sum[pup][dq][0], 2);
+                       DEBUG_DQS_S(",E-");
+                       DEBUG_DQS_D(analog_pbs_sum[pup][dq][1], 2);
+               }
+               DEBUG_DQS_S("\n");
+       }
+
+       if (is_tx) {
+               DEBUG_DQS_S("DDR3 - DQS TX - Find Limits - DQ values Summary:\n");
+       } else {
+               DEBUG_DQS_S("DDR3 - DQS RX - Find Limits - DQ values Summary:\n");
+       }
+
+       for (pup = 0; pup < max_pup; pup++) {
+               if (max_pup == 1) {
+                       /* For ECC PUP */
+                       DEBUG_DQS_S("DDR3 - DQS8");
+               } else {
+                       DEBUG_DQS_S("DDR3 - DQS");
+                       DEBUG_DQS_D(pup, 1);
+               }
+
+               for (dq = 0; dq < DQ_NUM; dq++) {
+                       DEBUG_DQS_S(", DQ-");
+                       DEBUG_DQS_D(dq, 1);
+                       DEBUG_DQS_S("::S-");
+                       DEBUG_DQS_D(analog_pbs_sum[pup][dq][0], 2);
+                       DEBUG_DQS_S(",E-");
+                       DEBUG_DQS_D(analog_pbs_sum[pup][dq][1], 2);
+               }
+               DEBUG_DQS_S("\n");
+       }
+
+       DEBUG_DQS_S("DDR3 - DQS Find Limits - Ended\n");
+
+       return MV_OK;
+}
+
+/*
+ * Name:     ddr3_check_window_limits
+ * Desc:     Check window High & Low limits.
+ * Args:     pup                pup index
+ *           high_limit           window high limit
+ *           low_limit            window low limit
+ *           is_tx                Indicate whether Rx or Tx
+ *           size_valid          Indicate whether window size is valid
+ * Notes:
+ * Returns:  MV_OK if success, other error code if fail.
+ */
+int ddr3_check_window_limits(u32 pup, int high_limit, int low_limit, int is_tx,
+                            int *size_valid)
+{
+       DEBUG_DQS_FULL_S("DDR3 - DQS Check Win Limits - Starting\n");
+
+       if (low_limit > high_limit) {
+               DEBUG_DQS_S("DDR3 - DQS Check Win Limits - Pup ");
+               DEBUG_DQS_D(pup, 1);
+               DEBUG_DQS_S(" Low Limit grater than High Limit\n");
+               *size_valid = 0;
+               return MV_OK;
+       }
+
+       /*
+        * Check that window size is valid, if not it was probably false pass
+        * before
+        */
+       if ((high_limit - low_limit) < MIN_WIN_SIZE) {
+               /*
+                * Since window size is too small probably there was false
+                * pass
+                */
+               *size_valid = 0;
+
+               DEBUG_DQS_S("DDR3 - DQS Check Win Limits - Pup ");
+               DEBUG_DQS_D(pup, 1);
+               DEBUG_DQS_S(" Window size is smaller than MIN_WIN_SIZE\n");
+
+       } else if ((high_limit - low_limit) > ADLL_MAX) {
+               *size_valid = 0;
+
+               DEBUG_DQS_S("DDR3 - DQS Check Win Limits - Pup ");
+               DEBUG_DQS_D(pup, 1);
+               DEBUG_DQS_S
+                   (" Window size is bigger than max ADLL taps (31)  Exiting.\n");
+
+               return MV_FAIL;
+
+       } else {
+               *size_valid = 1;
+
+               DEBUG_DQS_FULL_S("DDR3 - DQS Check Win Limits - Pup ");
+               DEBUG_DQS_FULL_D(pup, 1);
+               DEBUG_DQS_FULL_C(" window size is ", (high_limit - low_limit),
+                                2);
+       }
+
+       return MV_OK;
+}
+
+/*
+ * Name:     ddr3_center_calc
+ * Desc:     Execute the calculate the center of windows phase.
+ * Args:     pDram Info
+ *           is_tx             Indicate whether Rx or Tx
+ * Notes:
+ * Returns:  MV_OK if success, other error code if fail.
+ */
+static int ddr3_center_calc(MV_DRAM_INFO *dram_info, u32 cs, u32 ecc,
+                           int is_tx)
+{
+       /* bit array of pups that need specail search */
+       u32 special_pattern_i_pup = 0;
+       u32 special_pattern_ii_pup = 0;
+       u32 pup;
+       u32 max_pup;
+
+       max_pup = (ecc + (1 - ecc) * dram_info->num_of_std_pups);
+
+       for (pup = 0; pup < max_pup; pup++) {
+               if (is_tx == 0) {
+                       /* Check special pattern I */
+                       /*
+                        * Special pattern Low limit search - relevant only
+                        * for Rx, win size < threshold and low limit = 0
+                        */
+                       if (((centralization_high_limit[pup] -
+                             centralization_low_limit[pup]) < VALID_WIN_THRS)
+                           && (centralization_low_limit[pup] == MIN_DELAY))
+                               special_pattern_i_pup |= (1 << pup);
+
+                       /* Check special pattern II */
+                       /*
+                        * Special pattern High limit search - relevant only
+                        * for Rx, win size < threshold and high limit = 31
+                        */
+                       if (((centralization_high_limit[pup] -
+                             centralization_low_limit[pup]) < VALID_WIN_THRS)
+                           && (centralization_high_limit[pup] == MAX_DELAY))
+                               special_pattern_ii_pup |= (1 << pup);
+               }
+       }
+
+       /* Run special pattern Low limit search - for relevant pup */
+       if (special_pattern_i_pup != 0) {
+               DEBUG_DQS_S("DDR3 - DQS Center Calc - Entering special pattern I for Low limit search\n");
+               if (MV_OK !=
+                   ddr3_special_pattern_i_search(dram_info, cs, ecc, is_tx,
+                                             special_pattern_i_pup))
+                       return MV_DDR3_TRAINING_ERR_DQS_LOW_LIMIT_SEARCH;
+       }
+
+       /* Run special pattern High limit search - for relevant pup */
+       if (special_pattern_ii_pup != 0) {
+               DEBUG_DQS_S("DDR3 - DQS Center Calc - Entering special pattern II for High limit search\n");
+               if (MV_OK !=
+                   ddr3_special_pattern_ii_search(dram_info, cs, ecc, is_tx,
+                                                  special_pattern_ii_pup))
+                       return MV_DDR3_TRAINING_ERR_DQS_HIGH_LIMIT_SEARCH;
+       }
+
+       /* Set adll to center = (General_High_limit + General_Low_limit)/2 */
+       return ddr3_set_dqs_centralization_results(dram_info, cs, ecc, is_tx);
+}
+
+/*
+ * Name:     ddr3_special_pattern_i_search
+ * Desc:     Execute special pattern low limit search.
+ * Args:
+ *           special_pattern_pup  The pups that need the special search
+ * Notes:
+ * Returns:  MV_OK if success, other error code if fail.
+ */
+int ddr3_special_pattern_i_search(MV_DRAM_INFO *dram_info, u32 cs, u32 ecc,
+                                 int is_tx, u32 special_pattern_pup)
+{
+       u32 victim_dq;          /* loop index - victim DQ */
+       u32 adll_idx;
+       u32 pup;
+       u32 unlock_pup;         /* bit array of the unlock pups  */
+       u32 first_fail; /* bit array - of pups that  get first fail */
+       u32 new_lockup_pup;     /* bit array of compare failed pups */
+       u32 pass_pup;           /* bit array of compare pass pup */
+       u32 sdram_offset;
+       u32 max_pup;
+       u32 comp_val;
+       u32 special_res[MAX_PUP_NUM];   /* hold tmp results */
+
+       DEBUG_DQS_S("DDR3 - DQS - Special Pattern I Search - Starting\n");
+
+       max_pup = ecc + (1 - ecc) * dram_info->num_of_std_pups;
+
+       /* Init the temporary results to max ADLL value */
+       for (pup = 0; pup < max_pup; pup++)
+               special_res[pup] = ADLL_MAX;
+
+       /* Run special pattern for all DQ - use the same pattern */
+       for (victim_dq = 0; victim_dq < DQ_NUM; victim_dq++) {
+               unlock_pup = special_pattern_pup;
+               first_fail = 0;
+
+               sdram_offset = cs * SDRAM_CS_SIZE + SDRAM_DQS_RX_OFFS +
+                       LEN_KILLER_PATTERN * 4 * victim_dq;
+
+               for (pup = 0; pup < max_pup; pup++) {
+                       /* Set adll value per PUP. adll = high limit per pup */
+                       if (IS_PUP_ACTIVE(unlock_pup, pup)) {
+                               /* only for pups that need special search */
+                               ddr3_write_pup_reg(PUP_DQS_RD, cs,
+                                                  pup + (ecc * ECC_PUP), 0,
+                                                  centralization_high_limit
+                                                  [pup]);
+                       }
+               }
+
+               adll_idx = 0;
+               do {
+                       /*
+                        * Perform read and compare simultaneously for all
+                        * un-locked MC use the special pattern mask
+                        */
+                       new_lockup_pup = 0;
+
+                       if (MV_OK !=
+                           ddr3_sdram_dqs_compare(dram_info, unlock_pup,
+                                                  &new_lockup_pup,
+                                                  special_pattern
+                                                  [victim_dq],
+                                                  LEN_SPECIAL_PATTERN,
+                                                  sdram_offset, 0,
+                                                  0, NULL, 1))
+                               return MV_FAIL;
+
+                       DEBUG_DQS_S("DDR3 - DQS - Special I - ADLL value is: ");
+                       DEBUG_DQS_D(adll_idx, 2);
+                       DEBUG_DQS_S(", UnlockPup: ");
+                       DEBUG_DQS_D(unlock_pup, 2);
+                       DEBUG_DQS_S(", NewLockPup: ");
+                       DEBUG_DQS_D(new_lockup_pup, 2);
+                       DEBUG_DQS_S("\n");
+
+                       if (unlock_pup != new_lockup_pup)
+                               DEBUG_DQS_S("DDR3 - DQS - Special I - Some Pup passed!\n");
+
+                       /* Search for pups with passed compare & already fail */
+                       pass_pup = first_fail & ~new_lockup_pup & unlock_pup;
+                       first_fail |= new_lockup_pup;
+                       unlock_pup &= ~pass_pup;
+
+                       /* Get pass pups */
+                       if (pass_pup != 0) {
+                               for (pup = 0; pup < max_pup; pup++) {
+                                       if (IS_PUP_ACTIVE(pass_pup, pup) ==
+                                           1) {
+                                               /* If pup passed and has first fail = 1 */
+                                               /* keep min value of ADLL max value - current adll */
+                                               /* (centralization_high_limit[pup] + adll_idx) = current adll !!! */
+                                               comp_val =
+                                                   (ADLL_MAX -
+                                                    (centralization_high_limit
+                                                     [pup] + adll_idx));
+
+                                               DEBUG_DQS_C
+                                                   ("DDR3 - DQS - Special I - Pup - ",
+                                                    pup, 1);
+                                               DEBUG_DQS_C
+                                                   (" comp_val = ",
+                                                    comp_val, 2);
+
+                                               if (comp_val <
+                                                   special_res[pup]) {
+                                                       special_res[pup] =
+                                                           comp_val;
+                                                       centralization_low_limit
+                                                           [pup] =
+                                                           (-1) *
+                                                           comp_val;
+
+                                                       DEBUG_DQS_C
+                                                           ("DDR3 - DQS - Special I - Pup - ",
+                                                            pup, 1);
+                                                       DEBUG_DQS_C
+                                                           (" Changed Low limit to ",
+                                                            centralization_low_limit
+                                                            [pup], 2);
+                                               }
+                                       }
+                               }
+                       }
+
+                       /*
+                        * Did all PUP found missing window?
+                        * Check for each pup if adll (different for each pup)
+                        * reach maximum if reach max value - lock the pup
+                        * if not - increment (Move to right one phase - ADLL)
+                        * dqs RX delay
+                        */
+                       adll_idx++;
+                       for (pup = 0; pup < max_pup; pup++) {
+                               if (IS_PUP_ACTIVE(unlock_pup, pup) == 1) {
+                                       /* Check only unlocked pups */
+                                       if ((centralization_high_limit[pup] +
+                                            adll_idx) >= ADLL_MAX) {
+                                               /* reach maximum - lock the pup */
+                                               DEBUG_DQS_C("DDR3 - DQS - Special I - reach maximum - lock pup ",
+                                                           pup, 1);
+                                               unlock_pup &= ~(1 << pup);
+                                       } else {
+                                               /* Didn't reach maximum - increment ADLL */
+                                               ddr3_write_pup_reg(PUP_DQS_RD,
+                                                                  cs,
+                                                                  pup +
+                                                                  (ecc *
+                                                                   ECC_PUP), 0,
+                                                                  (centralization_high_limit
+                                                                   [pup] +
+                                                                   adll_idx));
+                                       }
+                               }
+                       }
+               } while (unlock_pup != 0);
+       }
+
+       return MV_OK;
+}
+
+/*
+ * Name:     ddr3_special_pattern_ii_search
+ * Desc:     Execute special pattern high limit search.
+ * Args:
+ *           special_pattern_pup  The pups that need the special search
+ * Notes:
+ * Returns:  MV_OK if success, other error code if fail.
+ */
+int ddr3_special_pattern_ii_search(MV_DRAM_INFO *dram_info, u32 cs, u32 ecc,
+                                  int is_tx, u32 special_pattern_pup)
+{
+       u32 victim_dq;          /* loop index - victim DQ */
+       u32 adll_idx;
+       u32 pup;
+       u32 unlock_pup;         /* bit array of the unlock pups  */
+       u32 first_fail; /* bit array - of pups that  get first fail */
+       u32 new_lockup_pup;     /* bit array of compare failed pups */
+       u32 pass_pup;           /* bit array of compare pass pup */
+       u32 sdram_offset;
+       u32 max_pup;
+       u32 comp_val;
+       u32 special_res[MAX_PUP_NUM];   /* hold tmp results */
+
+       DEBUG_DQS_S("DDR3 - DQS - Special Pattern II Search - Starting\n");
+
+       max_pup = (ecc + (1 - ecc) * dram_info->num_of_std_pups);
+
+       /* init the tmporary results to max ADLL value */
+       for (pup = 0; pup < max_pup; pup++)
+               special_res[pup] = ADLL_MAX;
+
+       sdram_offset = cs * SDRAM_CS_SIZE + SDRAM_DQS_RX_OFFS;
+
+       /* run special pattern for all DQ - use the same pattern */
+       for (victim_dq = 0; victim_dq < DQ_NUM; victim_dq++) {
+               unlock_pup = special_pattern_pup;
+               first_fail = 0;
+
+               for (pup = 0; pup < max_pup; pup++) {
+                       /* Set adll value per PUP. adll = 0 */
+                       if (IS_PUP_ACTIVE(unlock_pup, pup)) {
+                               /* Only for pups that need special search */
+                               ddr3_write_pup_reg(PUP_DQS_RD, cs,
+                                                  pup + (ecc * ECC_PUP), 0,
+                                                  ADLL_MIN);
+                       }
+               }
+
+               adll_idx = 0;
+               do {
+                       /*
+                        * Perform read and compare simultaneously for all
+                        * un-locked MC use the special pattern mask
+                        */
+                       new_lockup_pup = 0;
+
+                       if (MV_OK != ddr3_sdram_dqs_compare(
+                                   dram_info, unlock_pup, &new_lockup_pup,
+                                   special_pattern[victim_dq],
+                                   LEN_SPECIAL_PATTERN,
+                                   sdram_offset, 0, 0, NULL, 0))
+                               return MV_FAIL;
+
+                       DEBUG_DQS_S("DDR3 - DQS - Special II - ADLL value is ");
+                       DEBUG_DQS_D(adll_idx, 2);
+                       DEBUG_DQS_S("unlock_pup ");
+                       DEBUG_DQS_D(unlock_pup, 1);
+                       DEBUG_DQS_S("new_lockup_pup ");
+                       DEBUG_DQS_D(new_lockup_pup, 1);
+                       DEBUG_DQS_S("\n");
+
+                       if (unlock_pup != new_lockup_pup) {
+                               DEBUG_DQS_S("DDR3 - DQS - Special II - Some Pup passed!\n");
+                       }
+
+                       /* Search for pups with passed compare & already fail */
+                       pass_pup = first_fail & ~new_lockup_pup & unlock_pup;
+                       first_fail |= new_lockup_pup;
+                       unlock_pup &= ~pass_pup;
+
+                       /* Get pass pups */
+                       if (pass_pup != 0) {
+                               for (pup = 0; pup < max_pup; pup++) {
+                                       if (IS_PUP_ACTIVE(pass_pup, pup) ==
+                                           1) {
+                                               /* If pup passed and has first fail = 1 */
+                                               /* keep min value of ADLL max value - current adll */
+                                               /* (adll_idx) = current adll !!! */
+                                               comp_val = adll_idx;
+
+                                               DEBUG_DQS_C("DDR3 - DQS - Special II - Pup - ",
+                                                           pup, 1);
+                                               DEBUG_DQS_C(" comp_val = ",
+                                                           comp_val, 1);
+
+                                               if (comp_val <
+                                                   special_res[pup]) {
+                                                       special_res[pup] =
+                                                           comp_val;
+                                                       centralization_high_limit
+                                                           [pup] =
+                                                           ADLL_MAX +
+                                                           comp_val;
+
+                                                       DEBUG_DQS_C
+                                                           ("DDR3 - DQS - Special II - Pup - ",
+                                                            pup, 1);
+                                                       DEBUG_DQS_C
+                                                           (" Changed High limit to ",
+                                                            centralization_high_limit
+                                                            [pup], 2);
+                                               }
+                                       }
+                               }
+                       }
+
+                       /*
+                        * Did all PUP found missing window?
+                        * Check for each pup if adll (different for each pup)
+                        * reach maximum if reach max value - lock the pup
+                        * if not - increment (Move to right one phase - ADLL)
+                        * dqs RX delay
+                        */
+                       adll_idx++;
+                       for (pup = 0; pup < max_pup; pup++) {
+                               if (IS_PUP_ACTIVE(unlock_pup, pup) == 1) {
+                                       /* Check only unlocked pups */
+                                       if ((adll_idx) >= ADLL_MAX) {
+                                               /* Reach maximum - lock the pup */
+                                               DEBUG_DQS_C("DDR3 - DQS - Special II - reach maximum - lock pup ",
+                                                           pup, 1);
+                                               unlock_pup &= ~(1 << pup);
+                                       } else {
+                                               /* Didn't reach maximum - increment ADLL */
+                                               ddr3_write_pup_reg(PUP_DQS_RD,
+                                                                  cs,
+                                                                  pup +
+                                                                  (ecc *
+                                                                   ECC_PUP), 0,
+                                                                  (adll_idx));
+                                       }
+                               }
+                       }
+               } while (unlock_pup != 0);
+       }
+
+       return MV_OK;
+}
+
+/*
+ * Name:     ddr3_set_dqs_centralization_results
+ * Desc:     Set to HW the DQS centralization phase results.
+ * Args:
+ *           is_tx             Indicates whether to set Tx or RX results
+ * Notes:
+ * Returns:  MV_OK if success, other error code if fail.
+ */
+int ddr3_set_dqs_centralization_results(MV_DRAM_INFO *dram_info, u32 cs,
+                                       u32 ecc, int is_tx)
+{
+       u32 pup, pup_num;
+       int addl_val;
+       u32 max_pup;
+
+       max_pup = (ecc + (1 - ecc) * dram_info->num_of_std_pups);
+
+       DEBUG_DQS_RESULTS_S("\n############ LOG LEVEL 2(Windows margins) ############\n");;
+
+       if (is_tx) {
+               DEBUG_DQS_RESULTS_C("DDR3 - DQS TX - Set Dqs Centralization Results - CS: ",
+                                   cs, 1);
+       } else {
+               DEBUG_DQS_RESULTS_C("DDR3 - DQS RX - Set Dqs Centralization Results - CS: ",
+                                   cs, 1);
+       }
+
+       /* Set adll to center = (General_High_limit + General_Low_limit)/2 */
+       DEBUG_DQS_RESULTS_S("\nDQS    LOW     HIGH     WIN-SIZE      Set\n");
+       DEBUG_DQS_RESULTS_S("==============================================\n");
+       for (pup = 0; pup < max_pup; pup++) {
+               addl_val = (centralization_high_limit[pup] +
+                           centralization_low_limit[pup]) / 2;
+
+               pup_num = pup * (1 - ecc) + ecc * ECC_PUP;
+
+               DEBUG_DQS_RESULTS_D(pup_num, 1);
+               DEBUG_DQS_RESULTS_S("     0x");
+               DEBUG_DQS_RESULTS_D(centralization_low_limit[pup], 2);
+               DEBUG_DQS_RESULTS_S("      0x");
+               DEBUG_DQS_RESULTS_D(centralization_high_limit[pup], 2);
+               DEBUG_DQS_RESULTS_S("      0x");
+               DEBUG_DQS_RESULTS_D(centralization_high_limit[pup] -
+                                   centralization_low_limit[pup], 2);
+               DEBUG_DQS_RESULTS_S("       0x");
+               DEBUG_DQS_RESULTS_D(addl_val, 2);
+               DEBUG_DQS_RESULTS_S("\n");
+
+               if (addl_val < ADLL_MIN) {
+                       addl_val = ADLL_MIN;
+                       DEBUG_DQS_RESULTS_S("DDR3 - DQS - Setting ADLL value for Pup to MIN (since it was lower than 0)\n");
+               }
+
+               if (addl_val > ADLL_MAX) {
+                       addl_val = ADLL_MAX;
+                       DEBUG_DQS_RESULTS_S("DDR3 - DQS - Setting ADLL value for Pup to MAX (since it was higher than 31)\n");
+               }
+
+               if (is_tx) {
+                       ddr3_write_pup_reg(PUP_DQS_WR, cs, pup_num, 0,
+                                          addl_val +
+                                          dram_info->wl_val[cs][pup_num][D]);
+               } else {
+                       ddr3_write_pup_reg(PUP_DQS_RD, cs, pup_num, 0,
+                                          addl_val);
+               }
+       }
+
+       return MV_OK;
+}
+
+/*
+ * Set training patterns
+ */
+int ddr3_load_dqs_patterns(MV_DRAM_INFO *dram_info)
+{
+       u32 cs, cs_count, cs_tmp, victim_dq;
+       u32 sdram_addr;
+       u32 *pattern_ptr;
+
+       /* Loop for each CS */
+       for (cs = 0; cs < MAX_CS; cs++) {
+               if (dram_info->cs_ena & (1 << cs)) {
+                       cs_count = 0;
+                       for (cs_tmp = 0; cs_tmp < cs; cs_tmp++) {
+                               if (dram_info->cs_ena & (1 << cs_tmp))
+                                       cs_count++;
+                       }
+
+                       /* Init killer pattern */
+                       sdram_addr = (cs_count * (SDRAM_CS_SIZE + 1) +
+                                     SDRAM_DQS_RX_OFFS);
+                       for (victim_dq = 0; victim_dq < DQ_NUM; victim_dq++) {
+                               pattern_ptr = ddr3_dqs_choose_pattern(dram_info,
+                                                                     victim_dq);
+                               if (MV_OK != ddr3_sdram_dqs_compare(
+                                           dram_info, (u32)NULL, NULL,
+                                           pattern_ptr, LEN_KILLER_PATTERN,
+                                           sdram_addr + LEN_KILLER_PATTERN *
+                                           4 * victim_dq, 1, 0, NULL,
+                                           0))
+                                       return MV_DDR3_TRAINING_ERR_DQS_PATTERN;
+                       }
+
+                       /* Init special-killer pattern */
+                       sdram_addr = (cs_count * (SDRAM_CS_SIZE + 1) +
+                                     SDRAM_DQS_RX_SPECIAL_OFFS);
+                       for (victim_dq = 0; victim_dq < DQ_NUM; victim_dq++) {
+                               if (MV_OK != ddr3_sdram_dqs_compare(
+                                           dram_info, (u32)NULL, NULL,
+                                           special_pattern[victim_dq],
+                                           LEN_KILLER_PATTERN, sdram_addr +
+                                           LEN_KILLER_PATTERN * 4 * victim_dq,
+                                           1, 0, NULL, 0))
+                                       return MV_DDR3_TRAINING_ERR_DQS_PATTERN;
+                       }
+               }
+       }
+
+       return MV_OK;
+}
diff --git a/drivers/ddr/mvebu/ddr3_hw_training.c b/drivers/ddr/mvebu/ddr3_hw_training.c
new file mode 100644 (file)
index 0000000..a8c5e6a
--- /dev/null
@@ -0,0 +1,1115 @@
+/*
+ * Copyright (C) Marvell International Ltd. and its affiliates
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#include <common.h>
+#include <i2c.h>
+#include <spl.h>
+#include <asm/io.h>
+#include <asm/arch/cpu.h>
+#include <asm/arch/soc.h>
+
+#include "ddr3_init.h"
+#include "ddr3_hw_training.h"
+#include "xor.h"
+
+#ifdef MV88F78X60
+#include "ddr3_patterns_64bit.h"
+#else
+#include "ddr3_patterns_16bit.h"
+#if defined(MV88F672X)
+#include "ddr3_patterns_16bit.h"
+#endif
+#endif
+
+/*
+ * Debug
+ */
+
+#define DEBUG_MAIN_C(s, d, l) \
+       DEBUG_MAIN_S(s); DEBUG_MAIN_D(d, l); DEBUG_MAIN_S("\n")
+#define DEBUG_MAIN_FULL_C(s, d, l) \
+       DEBUG_MAIN_FULL_S(s); DEBUG_MAIN_FULL_D(d, l); DEBUG_MAIN_FULL_S("\n")
+
+#ifdef MV_DEBUG_MAIN
+#define DEBUG_MAIN_S(s)                        puts(s)
+#define DEBUG_MAIN_D(d, l)             printf("%x", d)
+#else
+#define DEBUG_MAIN_S(s)
+#define DEBUG_MAIN_D(d, l)
+#endif
+
+#ifdef MV_DEBUG_MAIN_FULL
+#define DEBUG_MAIN_FULL_S(s)           puts(s)
+#define DEBUG_MAIN_FULL_D(d, l)                printf("%x", d)
+#else
+#define DEBUG_MAIN_FULL_S(s)
+#define DEBUG_MAIN_FULL_D(d, l)
+#endif
+
+#ifdef MV_DEBUG_SUSPEND_RESUME
+#define DEBUG_SUSPEND_RESUME_S(s)      puts(s)
+#define DEBUG_SUSPEND_RESUME_D(d, l)   printf("%x", d)
+#else
+#define DEBUG_SUSPEND_RESUME_S(s)
+#define DEBUG_SUSPEND_RESUME_D(d, l)
+#endif
+
+static u32 ddr3_sw_wl_rl_debug;
+static u32 ddr3_run_pbs = 1;
+
+void ddr3_print_version(void)
+{
+       puts("DDR3 Training Sequence - Ver 5.7.");
+}
+
+void ddr3_set_sw_wl_rl_debug(u32 val)
+{
+       ddr3_sw_wl_rl_debug = val;
+}
+
+void ddr3_set_pbs(u32 val)
+{
+       ddr3_run_pbs = val;
+}
+
+int ddr3_hw_training(u32 target_freq, u32 ddr_width, int xor_bypass,
+                    u32 scrub_offs, u32 scrub_size, int dqs_clk_aligned,
+                    int debug_mode, int reg_dimm_skip_wl)
+{
+       /* A370 has no PBS mechanism */
+       __maybe_unused u32 first_loop_flag = 0;
+       u32 freq, reg;
+       MV_DRAM_INFO dram_info;
+       int ratio_2to1 = 0;
+       int tmp_ratio = 1;
+       int status;
+
+       if (debug_mode)
+               DEBUG_MAIN_S("DDR3 Training Sequence - DEBUG - 1\n");
+
+       memset(&dram_info, 0, sizeof(dram_info));
+       dram_info.num_cs = ddr3_get_cs_num_from_reg();
+       dram_info.cs_ena = ddr3_get_cs_ena_from_reg();
+       dram_info.target_frequency = target_freq;
+       dram_info.ddr_width = ddr_width;
+       dram_info.num_of_std_pups = ddr_width / PUP_SIZE;
+       dram_info.rl400_bug = 0;
+       dram_info.multi_cs_mr_support = 0;
+#ifdef MV88F67XX
+       dram_info.rl400_bug = 1;
+#endif
+
+       /* Ignore ECC errors - if ECC is enabled */
+       reg = reg_read(REG_SDRAM_CONFIG_ADDR);
+       if (reg & (1 << REG_SDRAM_CONFIG_ECC_OFFS)) {
+               dram_info.ecc_ena = 1;
+               reg |= (1 << REG_SDRAM_CONFIG_IERR_OFFS);
+               reg_write(REG_SDRAM_CONFIG_ADDR, reg);
+       } else {
+               dram_info.ecc_ena = 0;
+       }
+
+       reg = reg_read(REG_SDRAM_CONFIG_ADDR);
+       if (reg & (1 << REG_SDRAM_CONFIG_REGDIMM_OFFS))
+               dram_info.reg_dimm = 1;
+       else
+               dram_info.reg_dimm = 0;
+
+       dram_info.num_of_total_pups = ddr_width / PUP_SIZE + dram_info.ecc_ena;
+
+       /* Get target 2T value */
+       reg = reg_read(REG_DUNIT_CTRL_LOW_ADDR);
+       dram_info.mode_2t = (reg >> REG_DUNIT_CTRL_LOW_2T_OFFS) &
+               REG_DUNIT_CTRL_LOW_2T_MASK;
+
+       /* Get target CL value */
+#ifdef MV88F67XX
+       reg = reg_read(REG_DDR3_MR0_ADDR) >> 2;
+#else
+       reg = reg_read(REG_DDR3_MR0_CS_ADDR) >> 2;
+#endif
+
+       reg = (((reg >> 1) & 0xE) | (reg & 0x1)) & 0xF;
+       dram_info.cl = ddr3_valid_cl_to_cl(reg);
+
+       /* Get target CWL value */
+#ifdef MV88F67XX
+       reg = reg_read(REG_DDR3_MR2_ADDR) >> REG_DDR3_MR2_CWL_OFFS;
+#else
+       reg = reg_read(REG_DDR3_MR2_CS_ADDR) >> REG_DDR3_MR2_CWL_OFFS;
+#endif
+
+       reg &= REG_DDR3_MR2_CWL_MASK;
+       dram_info.cwl = reg;
+#if !defined(MV88F67XX)
+       /* A370 has no PBS mechanism */
+#if defined(MV88F78X60)
+       if ((dram_info.target_frequency > DDR_400) && (ddr3_run_pbs))
+               first_loop_flag = 1;
+#else
+       /* first_loop_flag = 1; skip mid freq at ALP/A375 */
+       if ((dram_info.target_frequency > DDR_400) && (ddr3_run_pbs) &&
+           (mv_ctrl_revision_get() >= UMC_A0))
+               first_loop_flag = 1;
+       else
+               first_loop_flag = 0;
+#endif
+#endif
+
+       freq = dram_info.target_frequency;
+
+       /* Set ODT to always on */
+       ddr3_odt_activate(1);
+
+       /* Init XOR */
+       mv_sys_xor_init(&dram_info);
+
+       /* Get DRAM/HCLK ratio */
+       if (reg_read(REG_DDR_IO_ADDR) & (1 << REG_DDR_IO_CLK_RATIO_OFFS))
+               ratio_2to1 = 1;
+
+       /*
+        * Xor Bypass - ECC support in AXP is currently available for 1:1
+        * modes frequency modes.
+        * Not all frequency modes support the ddr3 training sequence
+        * (Only 1200/300).
+        * Xor Bypass allows using the Xor initializations and scrubbing
+        * inside the ddr3 training sequence without running the training
+        * itself.
+        */
+       if (xor_bypass == 0) {
+               if (ddr3_run_pbs) {
+                       DEBUG_MAIN_S("DDR3 Training Sequence - Run with PBS.\n");
+               } else {
+                       DEBUG_MAIN_S("DDR3 Training Sequence - Run without PBS.\n");
+               }
+
+               if (dram_info.target_frequency > DFS_MARGIN) {
+                       tmp_ratio = 0;
+                       freq = DDR_100;
+
+                       if (dram_info.reg_dimm == 1)
+                               freq = DDR_300;
+
+                       if (MV_OK != ddr3_dfs_high_2_low(freq, &dram_info)) {
+                               /* Set low - 100Mhz DDR Frequency by HW */
+                               DEBUG_MAIN_S("DDR3 Training Sequence - FAILED (Dfs High2Low)\n");
+                               return MV_DDR3_TRAINING_ERR_DFS_H2L;
+                       }
+
+                       if ((dram_info.reg_dimm == 1) &&
+                           (reg_dimm_skip_wl == 0)) {
+                               if (MV_OK !=
+                                   ddr3_write_leveling_hw_reg_dimm(freq,
+                                                                   &dram_info))
+                                       DEBUG_MAIN_S("DDR3 Training Sequence - Registered DIMM Low WL - SKIP\n");
+                       }
+
+                       if (ddr3_get_log_level() >= MV_LOG_LEVEL_1)
+                               ddr3_print_freq(freq);
+
+                       if (debug_mode)
+                               DEBUG_MAIN_S("DDR3 Training Sequence - DEBUG - 2\n");
+               } else {
+                       if (!dqs_clk_aligned) {
+#ifdef MV88F67XX
+                               /*
+                                * If running training sequence without DFS,
+                                * we must run Write leveling before writing
+                                * the patterns
+                                */
+
+                               /*
+                                * ODT - Multi CS system use SW WL,
+                                * Single CS System use HW WL
+                                */
+                               if (dram_info.cs_ena > 1) {
+                                       if (MV_OK !=
+                                           ddr3_write_leveling_sw(
+                                                   freq, tmp_ratio,
+                                                   &dram_info)) {
+                                               DEBUG_MAIN_S("DDR3 Training Sequence - FAILED (Write Leveling Sw)\n");
+                                               return MV_DDR3_TRAINING_ERR_WR_LVL_SW;
+                                       }
+                               } else {
+                                       if (MV_OK !=
+                                           ddr3_write_leveling_hw(freq,
+                                                                  &dram_info)) {
+                                               DEBUG_MAIN_S("DDR3 Training Sequence - FAILED (Write Leveling Hw)\n");
+                                               return MV_DDR3_TRAINING_ERR_WR_LVL_HW;
+                                       }
+                               }
+#else
+                               if (MV_OK != ddr3_write_leveling_hw(
+                                           freq, &dram_info)) {
+                                       DEBUG_MAIN_S("DDR3 Training Sequence - FAILED (Write Leveling Hw)\n");
+                                       if (ddr3_sw_wl_rl_debug) {
+                                               if (MV_OK !=
+                                                   ddr3_write_leveling_sw(
+                                                           freq, tmp_ratio,
+                                                           &dram_info)) {
+                                                       DEBUG_MAIN_S("DDR3 Training Sequence - FAILED (Write Leveling Sw)\n");
+                                                       return MV_DDR3_TRAINING_ERR_WR_LVL_SW;
+                                               }
+                                       } else {
+                                               return MV_DDR3_TRAINING_ERR_WR_LVL_HW;
+                                       }
+                               }
+#endif
+                       }
+
+                       if (debug_mode)
+                               DEBUG_MAIN_S("DDR3 Training Sequence - DEBUG - 3\n");
+               }
+
+               if (MV_OK != ddr3_load_patterns(&dram_info, 0)) {
+                       DEBUG_MAIN_S("DDR3 Training Sequence - FAILED (Loading Patterns)\n");
+                       return MV_DDR3_TRAINING_ERR_LOAD_PATTERNS;
+               }
+
+               /*
+                * TODO:
+                * The mainline U-Boot port of the bin_hdr DDR training code
+                * needs a delay of minimum 20ms here (10ms is a bit too short
+                * and the CPU hangs). The bin_hdr code doesn't have this delay.
+                * To be save here, lets add a delay of 50ms here.
+                *
+                * Tested on the Marvell DB-MV784MP-GP board
+                */
+               mdelay(50);
+
+               do {
+                       freq = dram_info.target_frequency;
+                       tmp_ratio = ratio_2to1;
+                       DEBUG_MAIN_FULL_S("DDR3 Training Sequence - DEBUG - 4\n");
+
+#if defined(MV88F78X60)
+                       /*
+                        * There is a difference on the DFS frequency at the
+                        * first iteration of this loop
+                        */
+                       if (first_loop_flag) {
+                               freq = DDR_400;
+                               tmp_ratio = 0;
+                       }
+#endif
+
+                       if (MV_OK != ddr3_dfs_low_2_high(freq, tmp_ratio,
+                                                        &dram_info)) {
+                               DEBUG_MAIN_S("DDR3 Training Sequence - FAILED (Dfs Low2High)\n");
+                               return MV_DDR3_TRAINING_ERR_DFS_H2L;
+                       }
+
+                       if (ddr3_get_log_level() >= MV_LOG_LEVEL_1) {
+                               ddr3_print_freq(freq);
+                       }
+
+                       if (debug_mode)
+                               DEBUG_MAIN_S("DDR3 Training Sequence - DEBUG - 5\n");
+
+                       /* Write leveling */
+                       if (!dqs_clk_aligned) {
+#ifdef MV88F67XX
+                               /*
+                                * ODT - Multi CS system that not support Multi
+                                * CS MRS commands must use SW WL
+                                */
+                               if (dram_info.cs_ena > 1) {
+                                       if (MV_OK != ddr3_write_leveling_sw(
+                                                   freq, tmp_ratio, &dram_info)) {
+                                               DEBUG_MAIN_S("DDR3 Training Sequence - FAILED (Write Leveling Sw)\n");
+                                               return MV_DDR3_TRAINING_ERR_WR_LVL_SW;
+                                       }
+                               } else {
+                                       if (MV_OK != ddr3_write_leveling_hw(
+                                                   freq, &dram_info)) {
+                                               DEBUG_MAIN_S("DDR3 Training Sequence - FAILED (Write Leveling Hw)\n");
+                                               return MV_DDR3_TRAINING_ERR_WR_LVL_HW;
+                                       }
+                               }
+#else
+                               if ((dram_info.reg_dimm == 1) &&
+                                   (freq == DDR_400)) {
+                                       if (reg_dimm_skip_wl == 0) {
+                                               if (MV_OK != ddr3_write_leveling_hw_reg_dimm(
+                                                           freq, &dram_info))
+                                                       DEBUG_MAIN_S("DDR3 Training Sequence - Registered DIMM WL - SKIP\n");
+                                       }
+                               } else {
+                                       if (MV_OK != ddr3_write_leveling_hw(
+                                                   freq, &dram_info)) {
+                                               DEBUG_MAIN_S("DDR3 Training Sequence - FAILED (Write Leveling Hw)\n");
+                                               if (ddr3_sw_wl_rl_debug) {
+                                                       if (MV_OK != ddr3_write_leveling_sw(
+                                                                   freq, tmp_ratio, &dram_info)) {
+                                                               DEBUG_MAIN_S("DDR3 Training Sequence - FAILED (Write Leveling Sw)\n");
+                                                               return MV_DDR3_TRAINING_ERR_WR_LVL_SW;
+                                                       }
+                                               } else {
+                                                       return MV_DDR3_TRAINING_ERR_WR_LVL_HW;
+                                               }
+                                       }
+                               }
+#endif
+                               if (debug_mode)
+                                       DEBUG_MAIN_S
+                                           ("DDR3 Training Sequence - DEBUG - 6\n");
+                       }
+
+                       /* Read Leveling */
+                       /*
+                        * Armada 370 - Support for HCLK @ 400MHZ - must use
+                        * SW read leveling
+                        */
+                       if (freq == DDR_400 && dram_info.rl400_bug) {
+                               status = ddr3_read_leveling_sw(freq, tmp_ratio,
+                                                      &dram_info);
+                               if (MV_OK != status) {
+                                       DEBUG_MAIN_S
+                                           ("DDR3 Training Sequence - FAILED (Read Leveling Sw)\n");
+                                       return status;
+                               }
+                       } else {
+                               if (MV_OK != ddr3_read_leveling_hw(
+                                           freq, &dram_info)) {
+                                       DEBUG_MAIN_S("DDR3 Training Sequence - FAILED (Read Leveling Hw)\n");
+                                       if (ddr3_sw_wl_rl_debug) {
+                                               if (MV_OK != ddr3_read_leveling_sw(
+                                                           freq, tmp_ratio,
+                                                           &dram_info)) {
+                                                       DEBUG_MAIN_S("DDR3 Training Sequence - FAILED (Read Leveling Sw)\n");
+                                                       return MV_DDR3_TRAINING_ERR_WR_LVL_SW;
+                                               }
+                                       } else {
+                                               return MV_DDR3_TRAINING_ERR_WR_LVL_HW;
+                                       }
+                               }
+                       }
+
+                       if (debug_mode)
+                               DEBUG_MAIN_S("DDR3 Training Sequence - DEBUG - 7\n");
+
+                       if (MV_OK != ddr3_wl_supplement(&dram_info)) {
+                               DEBUG_MAIN_S("DDR3 Training Sequence - FAILED (Write Leveling Hi-Freq Sup)\n");
+                               return MV_DDR3_TRAINING_ERR_WR_LVL_HI_FREQ;
+                       }
+
+                       if (debug_mode)
+                               DEBUG_MAIN_S("DDR3 Training Sequence - DEBUG - 8\n");
+#if !defined(MV88F67XX)
+                       /* A370 has no PBS mechanism */
+#if defined(MV88F78X60) || defined(MV88F672X)
+                       if (first_loop_flag == 1) {
+                               first_loop_flag = 0;
+
+                               status = MV_OK;
+                               status = ddr3_pbs_rx(&dram_info);
+                               if (MV_OK != status) {
+                                       DEBUG_MAIN_S("DDR3 Training Sequence - FAILED (PBS RX)\n");
+                                       return status;
+                               }
+
+                               if (debug_mode)
+                                       DEBUG_MAIN_S("DDR3 Training Sequence - DEBUG - 9\n");
+
+                               status = ddr3_pbs_tx(&dram_info);
+                               if (MV_OK != status) {
+                                       DEBUG_MAIN_S("DDR3 Training Sequence - FAILED (PBS TX)\n");
+                                       return status;
+                               }
+
+                               if (debug_mode)
+                                       DEBUG_MAIN_S("DDR3 Training Sequence - DEBUG - 10\n");
+                       }
+#endif
+#endif
+               } while (freq != dram_info.target_frequency);
+
+               status = ddr3_dqs_centralization_rx(&dram_info);
+               if (MV_OK != status) {
+                       DEBUG_MAIN_S("DDR3 Training Sequence - FAILED (DQS Centralization RX)\n");
+                       return status;
+               }
+
+               if (debug_mode)
+                       DEBUG_MAIN_S("DDR3 Training Sequence - DEBUG - 11\n");
+
+               status = ddr3_dqs_centralization_tx(&dram_info);
+               if (MV_OK != status) {
+                       DEBUG_MAIN_S("DDR3 Training Sequence - FAILED (DQS Centralization TX)\n");
+                       return status;
+               }
+
+               if (debug_mode)
+                       DEBUG_MAIN_S("DDR3 Training Sequence - DEBUG - 12\n");
+       }
+
+       ddr3_set_performance_params(&dram_info);
+
+       if (dram_info.ecc_ena) {
+               /* Need to SCRUB the DRAM memory area to load U-boot */
+               mv_sys_xor_finish();
+               dram_info.num_cs = 1;
+               dram_info.cs_ena = 1;
+               mv_sys_xor_init(&dram_info);
+               mv_xor_mem_init(0, scrub_offs, scrub_size, 0xdeadbeef,
+                               0xdeadbeef);
+
+               /* Wait for previous transfer completion */
+               while (mv_xor_state_get(0) != MV_IDLE)
+                       ;
+
+               if (debug_mode)
+                       DEBUG_MAIN_S("DDR3 Training Sequence - DEBUG - 13\n");
+       }
+
+       /* Return XOR State */
+       mv_sys_xor_finish();
+
+#if defined(MV88F78X60)
+       /* Save training results in memeory for resume state */
+       ddr3_save_training(&dram_info);
+#endif
+       /* Clear ODT always on */
+       ddr3_odt_activate(0);
+
+       /* Configure Dynamic read ODT */
+       ddr3_odt_read_dynamic_config(&dram_info);
+
+       return MV_OK;
+}
+
+void ddr3_set_performance_params(MV_DRAM_INFO *dram_info)
+{
+       u32 twr2wr, trd2rd, trd2wr_wr2rd;
+       u32 tmp1, tmp2, reg;
+
+       DEBUG_MAIN_FULL_C("Max WL Phase: ", dram_info->wl_max_phase, 2);
+       DEBUG_MAIN_FULL_C("Min WL Phase: ", dram_info->wl_min_phase, 2);
+       DEBUG_MAIN_FULL_C("Max RL Phase: ", dram_info->rl_max_phase, 2);
+       DEBUG_MAIN_FULL_C("Min RL Phase: ", dram_info->rl_min_phase, 2);
+
+       if (dram_info->wl_max_phase < 2)
+               twr2wr = 0x2;
+       else
+               twr2wr = 0x3;
+
+       trd2rd = 0x1 + (dram_info->rl_max_phase + 1) / 2 +
+               (dram_info->rl_max_phase + 1) % 2;
+
+       tmp1 = (dram_info->rl_max_phase - dram_info->wl_min_phase) / 2 +
+               (((dram_info->rl_max_phase - dram_info->wl_min_phase) % 2) >
+                0 ? 1 : 0);
+       tmp2 = (dram_info->wl_max_phase - dram_info->rl_min_phase) / 2 +
+               ((dram_info->wl_max_phase - dram_info->rl_min_phase) % 2 >
+                0 ? 1 : 0);
+       trd2wr_wr2rd = (tmp1 >= tmp2) ? tmp1 : tmp2;
+
+       trd2wr_wr2rd += 2;
+       trd2rd += 2;
+       twr2wr += 2;
+
+       DEBUG_MAIN_FULL_C("WR 2 WR: ", twr2wr, 2);
+       DEBUG_MAIN_FULL_C("RD 2 RD: ", trd2rd, 2);
+       DEBUG_MAIN_FULL_C("RD 2 WR / WR 2 RD: ", trd2wr_wr2rd, 2);
+
+       reg = reg_read(REG_SDRAM_TIMING_HIGH_ADDR);
+
+       reg &= ~(REG_SDRAM_TIMING_H_W2W_MASK << REG_SDRAM_TIMING_H_W2W_OFFS);
+       reg |= ((twr2wr & REG_SDRAM_TIMING_H_W2W_MASK) <<
+               REG_SDRAM_TIMING_H_W2W_OFFS);
+
+       reg &= ~(REG_SDRAM_TIMING_H_R2R_MASK << REG_SDRAM_TIMING_H_R2R_OFFS);
+       reg &= ~(REG_SDRAM_TIMING_H_R2R_H_MASK <<
+                REG_SDRAM_TIMING_H_R2R_H_OFFS);
+       reg |= ((trd2rd & REG_SDRAM_TIMING_H_R2R_MASK) <<
+               REG_SDRAM_TIMING_H_R2R_OFFS);
+       reg |= (((trd2rd >> 2) & REG_SDRAM_TIMING_H_R2R_H_MASK) <<
+               REG_SDRAM_TIMING_H_R2R_H_OFFS);
+
+       reg &= ~(REG_SDRAM_TIMING_H_R2W_W2R_MASK <<
+                REG_SDRAM_TIMING_H_R2W_W2R_OFFS);
+       reg &= ~(REG_SDRAM_TIMING_H_R2W_W2R_H_MASK <<
+                REG_SDRAM_TIMING_H_R2W_W2R_H_OFFS);
+       reg |= ((trd2wr_wr2rd & REG_SDRAM_TIMING_H_R2W_W2R_MASK) <<
+               REG_SDRAM_TIMING_H_R2W_W2R_OFFS);
+       reg |= (((trd2wr_wr2rd >> 2) & REG_SDRAM_TIMING_H_R2W_W2R_H_MASK) <<
+               REG_SDRAM_TIMING_H_R2W_W2R_H_OFFS);
+
+       reg_write(REG_SDRAM_TIMING_HIGH_ADDR, reg);
+}
+
+/*
+ * Perform DDR3 PUP Indirect Write
+ */
+void ddr3_write_pup_reg(u32 mode, u32 cs, u32 pup, u32 phase, u32 delay)
+{
+       u32 reg = 0;
+
+       if (pup == PUP_BC)
+               reg |= (1 << REG_PHY_BC_OFFS);
+       else
+               reg |= (pup << REG_PHY_PUP_OFFS);
+
+       reg |= ((0x4 * cs + mode) << REG_PHY_CS_OFFS);
+       reg |= (phase << REG_PHY_PHASE_OFFS) | delay;
+
+       if (mode == PUP_WL_MODE)
+               reg |= ((INIT_WL_DELAY + delay) << REG_PHY_DQS_REF_DLY_OFFS);
+
+       reg_write(REG_PHY_REGISTRY_FILE_ACCESS_ADDR, reg);      /* 0x16A0 */
+       reg |= REG_PHY_REGISTRY_FILE_ACCESS_OP_WR;
+       reg_write(REG_PHY_REGISTRY_FILE_ACCESS_ADDR, reg);      /* 0x16A0 */
+
+       do {
+               reg = reg_read(REG_PHY_REGISTRY_FILE_ACCESS_ADDR) &
+                       REG_PHY_REGISTRY_FILE_ACCESS_OP_DONE;
+       } while (reg);  /* Wait for '0' to mark the end of the transaction */
+
+       /* If read Leveling mode - need to write to register 3 separetly */
+       if (mode == PUP_RL_MODE) {
+               reg = 0;
+
+               if (pup == PUP_BC)
+                       reg |= (1 << REG_PHY_BC_OFFS);
+               else
+                       reg |= (pup << REG_PHY_PUP_OFFS);
+
+               reg |= ((0x4 * cs + mode + 1) << REG_PHY_CS_OFFS);
+               reg |= (INIT_RL_DELAY);
+
+               reg_write(REG_PHY_REGISTRY_FILE_ACCESS_ADDR, reg); /* 0x16A0 */
+               reg |= REG_PHY_REGISTRY_FILE_ACCESS_OP_WR;
+               reg_write(REG_PHY_REGISTRY_FILE_ACCESS_ADDR, reg); /* 0x16A0 */
+
+               do {
+                       reg = reg_read(REG_PHY_REGISTRY_FILE_ACCESS_ADDR) &
+                               REG_PHY_REGISTRY_FILE_ACCESS_OP_DONE;
+               } while (reg);
+       }
+}
+
+/*
+ * Perform DDR3 PUP Indirect Read
+ */
+u32 ddr3_read_pup_reg(u32 mode, u32 cs, u32 pup)
+{
+       u32 reg;
+
+       reg = (pup << REG_PHY_PUP_OFFS) |
+               ((0x4 * cs + mode) << REG_PHY_CS_OFFS);
+       reg_write(REG_PHY_REGISTRY_FILE_ACCESS_ADDR, reg);      /* 0x16A0 */
+
+       reg |= REG_PHY_REGISTRY_FILE_ACCESS_OP_RD;
+       reg_write(REG_PHY_REGISTRY_FILE_ACCESS_ADDR, reg);      /* 0x16A0 */
+
+       do {
+               reg = reg_read(REG_PHY_REGISTRY_FILE_ACCESS_ADDR) &
+                       REG_PHY_REGISTRY_FILE_ACCESS_OP_DONE;
+       } while (reg);  /* Wait for '0' to mark the end of the transaction */
+
+       return reg_read(REG_PHY_REGISTRY_FILE_ACCESS_ADDR);     /* 0x16A0 */
+}
+
+/*
+ * Set training patterns
+ */
+int ddr3_load_patterns(MV_DRAM_INFO *dram_info, int resume)
+{
+       u32 reg;
+
+       /* Enable SW override - Required for the ECC Pup */
+       reg = reg_read(REG_DRAM_TRAINING_2_ADDR) |
+               (1 << REG_DRAM_TRAINING_2_SW_OVRD_OFFS);
+
+       /* [0] = 1 - Enable SW override  */
+       /* 0x15B8 - Training SW 2 Register */
+       reg_write(REG_DRAM_TRAINING_2_ADDR, reg);
+
+       reg = (1 << REG_DRAM_TRAINING_AUTO_OFFS);
+       reg_write(REG_DRAM_TRAINING_ADDR, reg); /* 0x15B0 - Training Register */
+
+       if (resume == 0) {
+#if defined(MV88F78X60) || defined(MV88F672X)
+               ddr3_load_pbs_patterns(dram_info);
+#endif
+               ddr3_load_dqs_patterns(dram_info);
+       }
+
+       /* Disable SW override - Must be in a different stage */
+       /* [0]=0 - Enable SW override  */
+       reg = reg_read(REG_DRAM_TRAINING_2_ADDR);
+       reg &= ~(1 << REG_DRAM_TRAINING_2_SW_OVRD_OFFS);
+       /* 0x15B8 - Training SW 2 Register */
+       reg_write(REG_DRAM_TRAINING_2_ADDR, reg);
+
+       reg = reg_read(REG_DRAM_TRAINING_1_ADDR) |
+               (1 << REG_DRAM_TRAINING_1_TRNBPOINT_OFFS);
+       reg_write(REG_DRAM_TRAINING_1_ADDR, reg);
+
+       /* Set Base Addr */
+#if defined(MV88F67XX)
+       reg_write(REG_DRAM_TRAINING_PATTERN_BASE_ADDR, 0);
+#else
+       if (resume == 0)
+               reg_write(REG_DRAM_TRAINING_PATTERN_BASE_ADDR, 0);
+       else
+               reg_write(REG_DRAM_TRAINING_PATTERN_BASE_ADDR,
+                         RESUME_RL_PATTERNS_ADDR);
+#endif
+
+       /* Set Patterns */
+       if (resume == 0) {
+               reg = (dram_info->cs_ena << REG_DRAM_TRAINING_CS_OFFS) |
+                       (1 << REG_DRAM_TRAINING_PATTERNS_OFFS);
+       } else {
+               reg = (0x1 << REG_DRAM_TRAINING_CS_OFFS) |
+                       (1 << REG_DRAM_TRAINING_PATTERNS_OFFS);
+       }
+
+       reg |= (1 << REG_DRAM_TRAINING_AUTO_OFFS);
+
+       reg_write(REG_DRAM_TRAINING_ADDR, reg);
+
+       udelay(100);
+
+       /* Check if Successful */
+       if (reg_read(REG_DRAM_TRAINING_ADDR) &
+           (1 << REG_DRAM_TRAINING_ERROR_OFFS))
+               return MV_OK;
+       else
+               return MV_FAIL;
+}
+
+#if !defined(MV88F67XX)
+/*
+ * Name:     ddr3_save_training(MV_DRAM_INFO *dram_info)
+ * Desc:     saves the training results to memeory (RL,WL,PBS,Rx/Tx
+ *           Centeralization)
+ * Args:     MV_DRAM_INFO *dram_info
+ * Notes:
+ * Returns:  None.
+ */
+void ddr3_save_training(MV_DRAM_INFO *dram_info)
+{
+       u32 val, pup, tmp_cs, cs, i, dq;
+       u32 crc = 0;
+       u32 regs = 0;
+       u32 *sdram_offset = (u32 *)RESUME_TRAINING_VALUES_ADDR;
+       u32 mode_config[MAX_TRAINING_MODE];
+
+       mode_config[DQS_WR_MODE] = PUP_DQS_WR;
+       mode_config[WL_MODE_] = PUP_WL_MODE;
+       mode_config[RL_MODE_] = PUP_RL_MODE;
+       mode_config[DQS_RD_MODE] = PUP_DQS_RD;
+       mode_config[PBS_TX_DM_MODE] = PUP_PBS_TX_DM;
+       mode_config[PBS_TX_MODE] = PUP_PBS_TX;
+       mode_config[PBS_RX_MODE] = PUP_PBS_RX;
+
+       /* num of training modes */
+       for (i = 0; i < MAX_TRAINING_MODE; i++) {
+               tmp_cs = dram_info->cs_ena;
+               /* num of CS */
+               for (cs = 0; cs < MAX_CS; cs++) {
+                       if (tmp_cs & (1 << cs)) {
+                               /* num of PUPs */
+                               for (pup = 0; pup < dram_info->num_of_total_pups;
+                                    pup++) {
+                                       if (pup == dram_info->num_of_std_pups &&
+                                           dram_info->ecc_ena)
+                                               pup = ECC_PUP;
+                                       if (i == PBS_TX_DM_MODE) {
+                                               /*
+                                                * Change CS bitmask because
+                                                * PBS works only with CS0
+                                                */
+                                               tmp_cs = 0x1;
+                                               val = ddr3_read_pup_reg(
+                                                       mode_config[i], CS0, pup);
+                                       } else if (i == PBS_TX_MODE ||
+                                                  i == PBS_RX_MODE) {
+                                               /*
+                                                * Change CS bitmask because
+                                                * PBS works only with CS0
+                                                */
+                                               tmp_cs = 0x1;
+                                               for (dq = 0; dq <= DQ_NUM;
+                                                    dq++) {
+                                                       val = ddr3_read_pup_reg(
+                                                               mode_config[i] + dq,
+                                                               CS0,
+                                                               pup);
+                                                       (*sdram_offset) = val;
+                                                       crc += *sdram_offset;
+                                                       sdram_offset++;
+                                                       regs++;
+                                               }
+                                               continue;
+                                       } else {
+                                               val = ddr3_read_pup_reg(
+                                                       mode_config[i], cs, pup);
+                                       }
+
+                                       *sdram_offset = val;
+                                       crc += *sdram_offset;
+                                       sdram_offset++;
+                                       regs++;
+                               }
+                       }
+               }
+       }
+
+       *sdram_offset = reg_read(REG_READ_DATA_SAMPLE_DELAYS_ADDR);
+       crc += *sdram_offset;
+       sdram_offset++;
+       regs++;
+       *sdram_offset = reg_read(REG_READ_DATA_READY_DELAYS_ADDR);
+       crc += *sdram_offset;
+       sdram_offset++;
+       regs++;
+       sdram_offset = (u32 *)NUM_OF_REGISTER_ADDR;
+       *sdram_offset = regs;
+       DEBUG_SUSPEND_RESUME_S("Training Results CheckSum write= ");
+       DEBUG_SUSPEND_RESUME_D(crc, 8);
+       DEBUG_SUSPEND_RESUME_S("\n");
+       sdram_offset = (u32 *)CHECKSUM_RESULT_ADDR;
+       *sdram_offset = crc;
+}
+
+/*
+ * Name:     ddr3_read_training_results()
+ * Desc:     Reads the training results from memeory (RL,WL,PBS,Rx/Tx
+ *           Centeralization)
+ *           and writes them to the relevant registers
+ * Args:     MV_DRAM_INFO *dram_info
+ * Notes:
+ * Returns:  None.
+ */
+int ddr3_read_training_results(void)
+{
+       u32 val, reg, idx, dqs_wr_idx = 0, crc = 0;
+       u32 *sdram_offset = (u32 *)RESUME_TRAINING_VALUES_ADDR;
+       u32 training_val[RESUME_TRAINING_VALUES_MAX] = { 0 };
+       u32 regs = *((u32 *)NUM_OF_REGISTER_ADDR);
+
+       /*
+        * Read Training results & Dunit registers from memory and write
+        * it to an array
+        */
+       for (idx = 0; idx < regs; idx++) {
+               training_val[idx] = *sdram_offset;
+               crc += *sdram_offset;
+               sdram_offset++;
+       }
+
+       sdram_offset = (u32 *)CHECKSUM_RESULT_ADDR;
+
+       if ((*sdram_offset) == crc) {
+               DEBUG_SUSPEND_RESUME_S("Training Results CheckSum read PASS= ");
+               DEBUG_SUSPEND_RESUME_D(crc, 8);
+               DEBUG_SUSPEND_RESUME_S("\n");
+       } else {
+               DEBUG_MAIN_S("Wrong Training Results CheckSum\n");
+               return MV_FAIL;
+       }
+
+       /*
+        * We iterate through all the registers except for the last 2 since
+        * they are Dunit registers (and not PHY registers)
+        */
+       for (idx = 0; idx < (regs - 2); idx++) {
+               val = training_val[idx];
+               reg = (val >> REG_PHY_CS_OFFS) & 0x3F; /*read the phy address */
+
+               /* Check if the values belongs to the DQS WR */
+               if (reg == PUP_WL_MODE) {
+                       /* bit[5:0] in DQS_WR are delay */
+                       val = (training_val[dqs_wr_idx++] & 0x3F);
+                       /*
+                        * bit[15:10] are DQS_WR delay & bit[9:0] are
+                        * WL phase & delay
+                        */
+                       val = (val << REG_PHY_DQS_REF_DLY_OFFS) |
+                               (training_val[idx] & 0x3C003FF);
+                       /* Add Request pending and write operation bits */
+                       val |= REG_PHY_REGISTRY_FILE_ACCESS_OP_WR;
+               } else if (reg == PUP_DQS_WR) {
+                       /*
+                        * Do nothing since DQS_WR will be done in PUP_WL_MODE
+                        */
+                       continue;
+               }
+
+               val |= REG_PHY_REGISTRY_FILE_ACCESS_OP_WR;
+               reg_write(REG_PHY_REGISTRY_FILE_ACCESS_ADDR, val);
+               do {
+                       val = (reg_read(REG_PHY_REGISTRY_FILE_ACCESS_ADDR)) &
+                               REG_PHY_REGISTRY_FILE_ACCESS_OP_DONE;
+               } while (val);  /* Wait for '0' to mark the end of the transaction */
+       }
+
+       /* write last 2 Dunit configurations */
+       val = training_val[idx];
+       reg_write(REG_READ_DATA_SAMPLE_DELAYS_ADDR, val);       /* reg 0x1538 */
+       val = training_val[idx + 1];
+       reg_write(REG_READ_DATA_READY_DELAYS_ADDR, val);        /* reg 0x153c */
+
+       return MV_OK;
+}
+
+/*
+ * Name:     ddr3_check_if_resume_mode()
+ * Desc:     Reads the address (0x3000) of the Resume Magic word (0xDEADB002)
+ * Args:     MV_DRAM_INFO *dram_info
+ * Notes:
+ * Returns:  return (magic_word == SUSPEND_MAGIC_WORD)
+ */
+int ddr3_check_if_resume_mode(MV_DRAM_INFO *dram_info, u32 freq)
+{
+       u32 magic_word;
+       u32 *sdram_offset = (u32 *)BOOT_INFO_ADDR;
+
+       if (dram_info->reg_dimm != 1) {
+               /*
+                * Perform write levleling in order initiate the phy with
+                * low frequency
+                */
+               if (MV_OK != ddr3_write_leveling_hw(freq, dram_info)) {
+                       DEBUG_MAIN_S("DDR3 Training Sequence - FAILED (Write Leveling Hw)\n");
+                       return MV_DDR3_TRAINING_ERR_WR_LVL_HW;
+               }
+       }
+
+       if (MV_OK != ddr3_load_patterns(dram_info, 1)) {
+               DEBUG_MAIN_S("DDR3 Training Sequence - FAILED (Loading Patterns)\n");
+               return MV_DDR3_TRAINING_ERR_LOAD_PATTERNS;
+       }
+
+       /* Enable CS0 only for RL */
+       dram_info->cs_ena = 0x1;
+
+       /* Perform Read levleling in order to get stable memory */
+       if (MV_OK != ddr3_read_leveling_hw(freq, dram_info)) {
+               DEBUG_MAIN_S("DDR3 Training Sequence - FAILED (Read Leveling Hw)\n");
+               return MV_DDR3_TRAINING_ERR_WR_LVL_HW;
+       }
+
+       /* Back to relevant CS */
+       dram_info->cs_ena = ddr3_get_cs_ena_from_reg();
+
+       magic_word = *sdram_offset;
+       return magic_word == SUSPEND_MAGIC_WORD;
+}
+
+/*
+ * Name:     ddr3_training_suspend_resume()
+ * Desc:     Execute the Resume state
+ * Args:     MV_DRAM_INFO *dram_info
+ * Notes:
+ * Returns:  return (magic_word == SUSPEND_MAGIC_WORD)
+ */
+int ddr3_training_suspend_resume(MV_DRAM_INFO *dram_info)
+{
+       u32 freq, reg;
+       int tmp_ratio;
+
+       /* Configure DDR */
+       if (MV_OK != ddr3_read_training_results())
+               return MV_FAIL;
+
+       /* Reset read FIFO */
+       reg = reg_read(REG_DRAM_TRAINING_ADDR);
+
+       /* Start Auto Read Leveling procedure */
+       reg |= (1 << REG_DRAM_TRAINING_RL_OFFS);
+       reg_write(REG_DRAM_TRAINING_ADDR, reg); /* 0x15B0 - Training Register */
+
+       reg = reg_read(REG_DRAM_TRAINING_2_ADDR);
+       reg |= ((1 << REG_DRAM_TRAINING_2_FIFO_RST_OFFS) +
+               (1 << REG_DRAM_TRAINING_2_SW_OVRD_OFFS));
+
+       /* [0] = 1 - Enable SW override, [4] = 1 - FIFO reset  */
+       /* 0x15B8 - Training SW 2 Register */
+       reg_write(REG_DRAM_TRAINING_2_ADDR, reg);
+
+       udelay(2);
+
+       reg = reg_read(REG_DRAM_TRAINING_ADDR);
+       /* Clear Auto Read Leveling procedure */
+       reg &= ~(1 << REG_DRAM_TRAINING_RL_OFFS);
+       reg_write(REG_DRAM_TRAINING_ADDR, reg); /* 0x15B0 - Training Register */
+
+       /* Return to target frequency */
+       freq = dram_info->target_frequency;
+       tmp_ratio = 1;
+       if (MV_OK != ddr3_dfs_low_2_high(freq, tmp_ratio, dram_info)) {
+               DEBUG_MAIN_S("DDR3 Training Sequence - FAILED (Dfs Low2High)\n");
+               return MV_DDR3_TRAINING_ERR_DFS_H2L;
+       }
+
+       if (dram_info->ecc_ena) {
+               /* Scabbling the RL area pattern and the training area */
+               mv_sys_xor_finish();
+               dram_info->num_cs = 1;
+               dram_info->cs_ena = 1;
+               mv_sys_xor_init(dram_info);
+               mv_xor_mem_init(0, RESUME_RL_PATTERNS_ADDR,
+                               RESUME_RL_PATTERNS_SIZE, 0xFFFFFFFF, 0xFFFFFFFF);
+
+               /* Wait for previous transfer completion */
+
+               while (mv_xor_state_get(0) != MV_IDLE)
+                       ;
+
+               /* Return XOR State */
+               mv_sys_xor_finish();
+       }
+
+       return MV_OK;
+}
+#endif
+
+void ddr3_print_freq(u32 freq)
+{
+       u32 tmp_freq;
+
+       switch (freq) {
+       case 0:
+               tmp_freq = 100;
+               break;
+       case 1:
+               tmp_freq = 300;
+               break;
+       case 2:
+               tmp_freq = 360;
+               break;
+       case 3:
+               tmp_freq = 400;
+               break;
+       case 4:
+               tmp_freq = 444;
+               break;
+       case 5:
+               tmp_freq = 500;
+               break;
+       case 6:
+               tmp_freq = 533;
+               break;
+       case 7:
+               tmp_freq = 600;
+               break;
+       case 8:
+               tmp_freq = 666;
+               break;
+       case 9:
+               tmp_freq = 720;
+               break;
+       case 10:
+               tmp_freq = 800;
+               break;
+       default:
+               tmp_freq = 100;
+       }
+
+       printf("Current frequency is: %dMHz\n", tmp_freq);
+}
+
+int ddr3_get_min_max_read_sample_delay(u32 cs_enable, u32 reg, u32 *min,
+                                      u32 *max, u32 *cs_max)
+{
+       u32 cs, delay;
+
+       *min = 0xFFFFFFFF;
+       *max = 0x0;
+
+       for (cs = 0; cs < MAX_CS; cs++) {
+               if ((cs_enable & (1 << cs)) == 0)
+                       continue;
+
+               delay = ((reg >> (cs * 8)) & 0x1F);
+
+               if (delay < *min)
+                       *min = delay;
+
+               if (delay > *max) {
+                       *max = delay;
+                       *cs_max = cs;
+               }
+       }
+
+       return MV_OK;
+}
+
+int ddr3_get_min_max_rl_phase(MV_DRAM_INFO *dram_info, u32 *min, u32 *max,
+                             u32 cs)
+{
+       u32 pup, reg, phase;
+
+       *min = 0xFFFFFFFF;
+       *max = 0x0;
+
+       for (pup = 0; pup < dram_info->num_of_total_pups; pup++) {
+               reg = ddr3_read_pup_reg(PUP_RL_MODE, cs, pup);
+               phase = ((reg >> 8) & 0x7);
+
+               if (phase < *min)
+                       *min = phase;
+
+               if (phase > *max)
+                       *max = phase;
+       }
+
+       return MV_OK;
+}
+
+int ddr3_odt_activate(int activate)
+{
+       u32 reg, mask;
+
+       mask = (1 << REG_DUNIT_ODT_CTRL_OVRD_OFFS) |
+               (1 << REG_DUNIT_ODT_CTRL_OVRD_VAL_OFFS);
+       /* {0x0000149C}  -   DDR Dunit ODT Control Register */
+       reg = reg_read(REG_DUNIT_ODT_CTRL_ADDR);
+       if (activate)
+               reg |= mask;
+       else
+               reg &= ~mask;
+
+       reg_write(REG_DUNIT_ODT_CTRL_ADDR, reg);
+
+       return MV_OK;
+}
+
+int ddr3_odt_read_dynamic_config(MV_DRAM_INFO *dram_info)
+{
+       u32 min_read_sample_delay, max_read_sample_delay, max_rl_phase;
+       u32 min, max, cs_max;
+       u32 cs_ena, reg;
+
+       reg = reg_read(REG_READ_DATA_SAMPLE_DELAYS_ADDR);
+       cs_ena = ddr3_get_cs_ena_from_reg();
+
+       /* Get minimum and maximum of read sample delay of all CS */
+       ddr3_get_min_max_read_sample_delay(cs_ena, reg, &min_read_sample_delay,
+                                          &max_read_sample_delay, &cs_max);
+
+       /*
+        * Get minimum and maximum read leveling phase which belongs to the
+        * maximal read sample delay
+        */
+       ddr3_get_min_max_rl_phase(dram_info, &min, &max, cs_max);
+       max_rl_phase = max;
+
+       /* DDR ODT Timing (Low) Register calculation */
+       reg = reg_read(REG_ODT_TIME_LOW_ADDR);
+       reg &= ~(0x1FF << REG_ODT_ON_CTL_RD_OFFS);
+       reg |= (((min_read_sample_delay - 1) & 0xF) << REG_ODT_ON_CTL_RD_OFFS);
+       reg |= (((max_read_sample_delay + 4 + (((max_rl_phase + 1) / 2) + 1)) &
+                0x1F) << REG_ODT_OFF_CTL_RD_OFFS);
+       reg_write(REG_ODT_TIME_LOW_ADDR, reg);
+
+       return MV_OK;
+}
diff --git a/drivers/ddr/mvebu/ddr3_hw_training.h b/drivers/ddr/mvebu/ddr3_hw_training.h
new file mode 100644 (file)
index 0000000..cffa7c4
--- /dev/null
@@ -0,0 +1,392 @@
+/*
+ * Copyright (C) Marvell International Ltd. and its affiliates
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#ifndef __DDR3_TRAINING_H
+#define __DDR3_TRAINING_H
+
+#include "ddr3_init.h"
+
+#ifdef MV88F78X60
+#include "ddr3_axp.h"
+#elif defined(MV88F67XX)
+#include "ddr3_a370.h"
+#elif defined(MV88F672X)
+#include "ddr3_a375.h"
+#endif
+
+/* The following is a list of Marvell status    */
+#define MV_ERROR       (-1)
+#define MV_OK          (0x00)  /* Operation succeeded                   */
+#define MV_FAIL                (0x01)  /* Operation failed                      */
+#define MV_BAD_VALUE   (0x02)  /* Illegal value (general)               */
+#define MV_OUT_OF_RANGE        (0x03)  /* The value is out of range             */
+#define MV_BAD_PARAM   (0x04)  /* Illegal parameter in function called  */
+#define MV_BAD_PTR     (0x05)  /* Illegal pointer value                 */
+#define MV_BAD_SIZE    (0x06)  /* Illegal size                          */
+#define MV_BAD_STATE   (0x07)  /* Illegal state of state machine        */
+#define MV_SET_ERROR   (0x08)  /* Set operation failed                  */
+#define MV_GET_ERROR   (0x09)  /* Get operation failed                  */
+#define MV_CREATE_ERROR        (0x0A)  /* Fail while creating an item           */
+#define MV_NOT_FOUND   (0x0B)  /* Item not found                        */
+#define MV_NO_MORE     (0x0C)  /* No more items found                   */
+#define MV_NO_SUCH     (0x0D)  /* No such item                          */
+#define MV_TIMEOUT     (0x0E)  /* Time Out                              */
+#define MV_NO_CHANGE   (0x0F)  /* Parameter(s) is already in this value */
+#define MV_NOT_SUPPORTED (0x10)        /* This request is not support           */
+#define MV_NOT_IMPLEMENTED (0x11) /* Request supported but not implemented*/
+#define MV_NOT_INITIALIZED (0x12) /* The item is not initialized          */
+#define MV_NO_RESOURCE (0x13)  /* Resource not available (memory ...)   */
+#define MV_FULL                (0x14)  /* Item is full (Queue or table etc...)  */
+#define MV_EMPTY       (0x15)  /* Item is empty (Queue or table etc...) */
+#define MV_INIT_ERROR  (0x16)  /* Error occured while INIT process      */
+#define MV_HW_ERROR    (0x17)  /* Hardware error                        */
+#define MV_TX_ERROR    (0x18)  /* Transmit operation not succeeded      */
+#define MV_RX_ERROR    (0x19)  /* Recieve operation not succeeded       */
+#define MV_NOT_READY   (0x1A)  /* The other side is not ready yet       */
+#define MV_ALREADY_EXIST (0x1B)        /* Tried to create existing item         */
+#define MV_OUT_OF_CPU_MEM   (0x1C) /* Cpu memory allocation failed.      */
+#define MV_NOT_STARTED (0x1D)  /* Not started yet                       */
+#define MV_BUSY                (0x1E)  /* Item is busy.                         */
+#define MV_TERMINATE   (0x1F)  /* Item terminates it's work.            */
+#define MV_NOT_ALIGNED (0x20)  /* Wrong alignment                       */
+#define MV_NOT_ALLOWED (0x21)  /* Operation NOT allowed                 */
+#define MV_WRITE_PROTECT (0x22)        /* Write protected                       */
+
+#define MV_INVALID     (int)(-1)
+
+/*
+ * Debug (Enable/Disable modules) and Error report
+ */
+
+#ifdef BASIC_DEBUG
+#define MV_DEBUG_WL
+#define MV_DEBUG_RL
+#define MV_DEBUG_DQS_RESULTS
+#endif
+
+#ifdef FULL_DEBUG
+#define MV_DEBUG_WL
+#define MV_DEBUG_RL
+#define MV_DEBUG_DQS
+
+#define MV_DEBUG_PBS
+#define MV_DEBUG_DFS
+#define MV_DEBUG_MAIN_FULL
+#define MV_DEBUG_DFS_FULL
+#define MV_DEBUG_DQS_FULL
+#define MV_DEBUG_RL_FULL
+#define MV_DEBUG_WL_FULL
+#endif
+
+/*
+ * General Consts
+ */
+
+#define SDRAM_READ_WRITE_LEN_IN_WORDS           16
+#define SDRAM_READ_WRITE_LEN_IN_DOUBLE_WORDS    8
+#define CACHE_LINE_SIZE                         0x20
+
+#define SDRAM_CS_BASE                           0x0
+
+#define SRAM_BASE                               0x40000000
+#define SRAM_SIZE                               0xFFF
+
+#define LEN_64BIT_STD_PATTERN                   16
+#define LEN_64BIT_KILLER_PATTERN                128
+#define LEN_64BIT_SPECIAL_PATTERN               128
+#define LEN_64BIT_PBS_PATTERN                   16
+#define LEN_WL_SUP_PATTERN                             32
+
+#define LEN_16BIT_STD_PATTERN                   4
+#define LEN_16BIT_KILLER_PATTERN                128
+#define LEN_16BIT_SPECIAL_PATTERN               128
+#define LEN_16BIT_PBS_PATTERN                   4
+
+#define CMP_BYTE_SHIFT                          8
+#define CMP_BYTE_MASK                           0xFF
+#define PUP_SIZE                                8
+
+#define S 0
+#define C 1
+#define P 2
+#define D 3
+#define DQS 6
+#define PS 2
+#define DS 3
+#define PE 4
+#define DE 5
+
+#define CS0                                     0
+#define MAX_DIMM_NUM                            2
+#define MAX_DELAY                               0x1F
+
+/*
+ * Invertion limit and phase1 limit are WA for the RL @ 1:1 design bug -
+ * Armada 370 & AXP Z1
+ */
+#define MAX_DELAY_INV_LIMIT                     0x5
+#define MIN_DELAY_PHASE_1_LIMIT                 0x10
+
+#define MAX_DELAY_INV                           (0x3F - MAX_DELAY_INV_LIMIT)
+#define MIN_DELAY                               0
+#define MAX_PUP_NUM                             9
+#define ECC_PUP                                 8
+#define DQ_NUM                                  8
+#define DQS_DQ_NUM                              8
+#define INIT_WL_DELAY                           13
+#define INIT_RL_DELAY                           15
+#define TWLMRD_DELAY                            20
+#define TCLK_3_DELAY                            3
+#define ECC_BIT                                 8
+#define DMA_SIZE                                64
+#define MV_DMA_0                                0
+#define MAX_TRAINING_RETRY                      10
+
+#define PUP_RL_MODE                             0x2
+#define PUP_WL_MODE                             0
+#define PUP_PBS_TX                              0x10
+#define PUP_PBS_TX_DM                           0x1A
+#define PUP_PBS_RX                              0x30
+#define PUP_DQS_WR                              0x1
+#define PUP_DQS_RD                              0x3
+#define PUP_BC                                  10
+#define PUP_DELAY_MASK                          0x1F
+#define PUP_PHASE_MASK                          0x7
+#define PUP_NUM_64BIT                           8
+#define PUP_NUM_32BIT                           4
+#define PUP_NUM_16BIT                           2
+
+/* control PHY registers */
+#define CNTRL_PUP_DESKEW                        0x10
+
+/* WL */
+#define COUNT_WL_HI_FREQ                        2
+#define COUNT_WL                                2
+#define COUNT_WL_RFRS                           9
+#define WL_HI_FREQ_SHIFT                        2
+#define WL_HI_FREQ_STATE                        1
+#define COUNT_HW_WL                             2
+
+/* RL */
+/*
+ * RL_MODE - this define uses the RL mode SW RL instead of the functional
+ * window SW RL
+ */
+#define RL_MODE
+#define RL_WINDOW_WA
+#define MAX_PHASE_1TO1                          2
+#define MAX_PHASE_2TO1                          4
+
+#define MAX_PHASE_RL_UL_1TO1                    0
+#define MAX_PHASE_RL_L_1TO1                     4
+#define MAX_PHASE_RL_UL_2TO1                    3
+#define MAX_PHASE_RL_L_2TO1                     7
+
+#define RL_UNLOCK_STATE                         0
+#define RL_WINDOW_STATE                         1
+#define RL_FINAL_STATE                          2
+#define RL_RETRY_COUNT                          2
+#define COUNT_HW_RL                             2
+
+/* PBS */
+#define MAX_PBS                                 31
+#define MIN_PBS                                 0
+#define COUNT_PBS_PATTERN                       2
+#define COUNT_PBS_STARTOVER                     2
+#define COUNT_PBS_REPEAT                        3
+#define COUNT_PBS_COMP_RETRY_NUM                2
+#define PBS_DIFF_LIMIT                          31
+#define PATTERN_PBS_TX_A                        0x55555555
+#define PATTERN_PBS_TX_B                        0xAAAAAAAA
+
+/* DQS */
+#define ADLL_ERROR                              0x55
+#define ADLL_MAX                                31
+#define ADLL_MIN                                0
+#define MIN_WIN_SIZE                            4
+#define VALID_WIN_THRS                          MIN_WIN_SIZE
+
+#define MODE_2TO1                               1
+#define MODE_1TO1                               0
+
+/*
+ * Macros
+ */
+#define IS_PUP_ACTIVE(_data_, _pup_)        (((_data_) >> (_pup_)) & 0x1)
+
+/*
+ * Internal ERROR codes
+ */
+#define MV_DDR3_TRAINING_ERR_WR_LVL_HW              0xDD302001
+#define MV_DDR3_TRAINING_ERR_LOAD_PATTERNS          0xDD302002
+#define MV_DDR3_TRAINING_ERR_WR_LVL_HI_FREQ         0xDD302003
+#define MV_DDR3_TRAINING_ERR_DFS_H2L                0xDD302004
+#define MV_DDR3_TRAINING_ERR_DRAM_COMPARE           0xDD302005
+#define MV_DDR3_TRAINING_ERR_WIN_LIMITS             0xDD302006
+#define MV_DDR3_TRAINING_ERR_PUP_RANGE              0xDD302025
+#define MV_DDR3_TRAINING_ERR_DQS_LOW_LIMIT_SEARCH   0xDD302007
+#define MV_DDR3_TRAINING_ERR_DQS_HIGH_LIMIT_SEARCH  0xDD302008
+#define MV_DDR3_TRAINING_ERR_DQS_PATTERN            0xDD302009
+#define MV_DDR3_TRAINING_ERR_PBS_ADLL_SHR_1PHASE    0xDD302010
+#define MV_DDR3_TRAINING_ERR_PBS_TX_MAX_VAL         0xDD302011
+#define MV_DDR3_TRAINING_ERR_PBS_RX_PER_BIT         0xDD302012
+#define MV_DDR3_TRAINING_ERR_PBS_TX_PER_BIT         0xDD302013
+#define MV_DDR3_TRAINING_ERR_PBS_RX_MAX_VAL         0xDD302014
+#define MV_DDR3_TRAINING_ERR_PBS_SHIFT_QDS_SRAM_CMP 0xDD302015
+#define MV_DDR3_TRAINING_ERR_PBS_SHIFT_QDS_MAX_VAL  0xDD302016
+#define MV_DDR3_TRAINING_ERR_RD_LVL_RL_PATTERN      0xDD302017
+#define MV_DDR3_TRAINING_ERR_RD_LVL_RL_PUP_UNLOCK   0xDD302018
+#define MV_DDR3_TRAINING_ERR_RD_LVL_PUP_UNLOCK      0xDD302019
+#define MV_DDR3_TRAINING_ERR_WR_LVL_SW              0xDD302020
+#define MV_DDR3_TRAINING_ERR_PRBS_RX                0xDD302021
+#define MV_DDR3_TRAINING_ERR_DQS_RX                 0xDD302022
+#define MV_DDR3_TRAINING_ERR_PRBS_TX                0xDD302023
+#define MV_DDR3_TRAINING_ERR_DQS_TX                 0xDD302024
+
+/*
+ * DRAM information structure
+ */
+typedef struct dram_info {
+       u32 num_cs;
+       u32 cs_ena;
+       u32 num_of_std_pups;    /* Q value = ddrWidth/8 - Without ECC!! */
+       u32 num_of_total_pups;  /* numOfStdPups + eccEna */
+       u32 target_frequency;   /* DDR Frequency */
+       u32 ddr_width;          /* 32/64 Bit or 16/32 Bit */
+       u32 ecc_ena;            /* 0/1 */
+       u32 wl_val[MAX_CS][MAX_PUP_NUM][7];
+       u32 rl_val[MAX_CS][MAX_PUP_NUM][7];
+       u32 rl_max_phase;
+       u32 rl_min_phase;
+       u32 wl_max_phase;
+       u32 wl_min_phase;
+       u32 rd_smpl_dly;
+       u32 rd_rdy_dly;
+       u32 cl;
+       u32 cwl;
+       u32 mode_2t;
+       int rl400_bug;
+       int multi_cs_mr_support;
+       int reg_dimm;
+} MV_DRAM_INFO;
+
+enum training_modes  {
+       DQS_WR_MODE,
+       WL_MODE_,
+       RL_MODE_,
+       DQS_RD_MODE,
+       PBS_TX_DM_MODE,
+       PBS_TX_MODE,
+       PBS_RX_MODE,
+       MAX_TRAINING_MODE,
+};
+
+typedef struct dram_training_init {
+       u32 reg_addr;
+       u32 reg_value;
+} MV_DRAM_TRAINING_INIT;
+
+typedef struct dram_mv_init {
+       u32 reg_addr;
+       u32 reg_value;
+} MV_DRAM_MC_INIT;
+
+/* Board/Soc revisions define */
+enum board_rev {
+       Z1,
+       Z1_PCAC,
+       Z1_RD_SLED,
+       A0,
+       A0_AMC
+};
+
+typedef struct dram_modes {
+       char *mode_name;
+       u8 cpu_freq;
+       u8 fab_freq;
+       u8 chip_id;
+       int chip_board_rev;
+       MV_DRAM_MC_INIT *regs;
+       MV_DRAM_TRAINING_INIT *vals;
+} MV_DRAM_MODES;
+
+/*
+ * Function Declarations
+ */
+
+u32 cache_inv(u32 addr);
+void flush_l1_v7(u32 line);
+void flush_l1_v6(u32 line);
+
+u32 ddr3_cl_to_valid_cl(u32 cl);
+u32 ddr3_valid_cl_to_cl(u32 ui_valid_cl);
+
+void ddr3_write_pup_reg(u32 mode, u32 cs, u32 pup, u32 phase, u32 delay);
+u32 ddr3_read_pup_reg(u32 mode, u32 cs, u32 pup);
+
+int ddr3_sdram_pbs_compare(MV_DRAM_INFO *dram_info, u32 pup_locked, int is_tx,
+                          u32 pbs_pattern_idx, u32 pbs_curr_val,
+                          u32 pbs_lock_val, u32 *skew_array,
+                          u8 *unlock_pup_dq_array, u32 ecc);
+
+int ddr3_sdram_dqs_compare(MV_DRAM_INFO *dram_info, u32 unlock_pup,
+                          u32 *new_locked_pup, u32 *pattern,
+                          u32 pattern_len, u32 sdram_offset, int write,
+                          int mask, u32 *mask_pattern, int b_special_compare);
+
+int ddr3_sdram_compare(MV_DRAM_INFO *dram_info, u32 unlock_pup,
+                      u32 *new_locked_pup, u32 *pattern, u32 pattern_len,
+                      u32 sdram_offset, int write, int mask,
+                      u32 *mask_pattern, int b_special_compare);
+
+int ddr3_sdram_direct_compare(MV_DRAM_INFO *dram_info, u32 unlock_pup,
+                             u32 *new_locked_pup, u32 *pattern,
+                             u32 pattern_len, u32 sdram_offset, int write,
+                             int mask, u32 *mask_pattern);
+
+int ddr3_sdram_dm_compare(MV_DRAM_INFO *dram_info, u32 unlock_pup,
+                         u32 *new_locked_pup, u32 *pattern,
+                         u32 sdram_offset);
+int ddr3_dram_sram_read(u32 src, u32 dst, u32 len);
+int ddr3_load_patterns(MV_DRAM_INFO *dram_info, int resume);
+
+int ddr3_read_leveling_hw(u32 freq, MV_DRAM_INFO *dram_info);
+int ddr3_read_leveling_sw(u32 freq, int ratio_2to1, MV_DRAM_INFO *dram_info);
+
+int ddr3_write_leveling_hw(u32 freq, MV_DRAM_INFO *dram_info);
+int ddr3_write_leveling_sw(u32 freq, int ratio_2to1, MV_DRAM_INFO *dram_info);
+int ddr3_write_leveling_hw_reg_dimm(u32 freq, MV_DRAM_INFO *dram_info);
+int ddr3_wl_supplement(MV_DRAM_INFO *dram_info);
+
+int ddr3_dfs_high_2_low(u32 freq, MV_DRAM_INFO *dram_info);
+int ddr3_dfs_low_2_high(u32 freq, int ratio_2to1, MV_DRAM_INFO *dram_info);
+
+int ddr3_pbs_tx(MV_DRAM_INFO *dram_info);
+int ddr3_pbs_rx(MV_DRAM_INFO *dram_info);
+int ddr3_load_pbs_patterns(MV_DRAM_INFO *dram_info);
+
+int ddr3_dqs_centralization_rx(MV_DRAM_INFO *dram_info);
+int ddr3_dqs_centralization_tx(MV_DRAM_INFO *dram_info);
+int ddr3_load_dqs_patterns(MV_DRAM_INFO *dram_info);
+
+void ddr3_static_training_init(void);
+
+u8 ddr3_get_eprom_fabric(void);
+void ddr3_set_performance_params(MV_DRAM_INFO *dram_info);
+int ddr3_dram_sram_burst(u32 src, u32 dst, u32 len);
+void ddr3_save_training(MV_DRAM_INFO *dram_info);
+int ddr3_read_training_results(void);
+int ddr3_training_suspend_resume(MV_DRAM_INFO *dram_info);
+int ddr3_get_min_max_read_sample_delay(u32 cs_enable, u32 reg, u32 *min,
+                                      u32 *max, u32 *cs_max);
+int ddr3_get_min_max_rl_phase(MV_DRAM_INFO *dram_info, u32 *min, u32 *max,
+                             u32 cs);
+int ddr3_odt_activate(int activate);
+int ddr3_odt_read_dynamic_config(MV_DRAM_INFO *dram_info);
+void ddr3_print_freq(u32 freq);
+void ddr3_reset_phy_read_fifo(void);
+
+#endif /* __DDR3_TRAINING_H */
diff --git a/drivers/ddr/mvebu/ddr3_init.c b/drivers/ddr/mvebu/ddr3_init.c
new file mode 100644 (file)
index 0000000..11b8591
--- /dev/null
@@ -0,0 +1,1219 @@
+/*
+ * Copyright (C) Marvell International Ltd. and its affiliates
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#include <common.h>
+#include <i2c.h>
+#include <spl.h>
+#include <asm/io.h>
+#include <asm/arch/cpu.h>
+#include <asm/arch/soc.h>
+
+#include "ddr3_init.h"
+
+#if defined(MV88F78X60)
+#include "ddr3_axp_vars.h"
+#elif defined(MV88F67XX)
+#include "ddr3_a370_vars.h"
+#elif defined(MV88F672X)
+#include "ddr3_a375_vars.h"
+#endif
+
+#ifdef STATIC_TRAINING
+static void ddr3_static_training_init(void);
+#endif
+#ifdef DUNIT_STATIC
+static void ddr3_static_mc_init(void);
+#endif
+#if defined(DUNIT_STATIC) || defined(STATIC_TRAINING)
+MV_DRAM_MODES *ddr3_get_static_ddr_mode(void);
+#endif
+#if defined(MV88F672X)
+void get_target_freq(u32 freq_mode, u32 *ddr_freq, u32 *hclk_ps);
+#endif
+u32 mv_board_id_get(void);
+extern void ddr3_set_sw_wl_rl_debug(u32);
+extern void ddr3_set_pbs(u32);
+extern void ddr3_set_log_level(u32 val);
+
+static u32 log_level = DDR3_LOG_LEVEL;
+
+static u32 ddr3_init_main(void);
+
+/*
+ * Name:     ddr3_set_log_level
+ * Desc:     This routine initialize the log_level acording to nLogLevel
+ *           which getting from user
+ * Args:     nLogLevel
+ * Notes:
+ * Returns:  None.
+ */
+void ddr3_set_log_level(u32 val)
+{
+       log_level = val;
+}
+
+/*
+ * Name:     ddr3_get_log_level
+ * Desc:     This routine returns the log level
+ * Args:     none
+ * Notes:
+ * Returns:  log level.
+ */
+u32 ddr3_get_log_level(void)
+{
+       return log_level;
+}
+
+static void debug_print_reg(u32 reg)
+{
+       printf("0x%08x = 0x%08x\n", reg, reg_read(reg));
+}
+
+static void print_dunit_setup(void)
+{
+       puts("\n########### LOG LEVEL 1 (D-UNIT SETUP)###########\n");
+
+#ifdef DUNIT_STATIC
+       puts("\nStatic D-UNIT Setup:\n");
+#endif
+#ifdef DUNIT_SPD
+       puts("\nDynamic(using SPD) D-UNIT Setup:\n");
+#endif
+       debug_print_reg(REG_SDRAM_CONFIG_ADDR);
+       debug_print_reg(REG_DUNIT_CTRL_LOW_ADDR);
+       debug_print_reg(REG_SDRAM_TIMING_LOW_ADDR);
+       debug_print_reg(REG_SDRAM_TIMING_HIGH_ADDR);
+       debug_print_reg(REG_SDRAM_ADDRESS_CTRL_ADDR);
+       debug_print_reg(REG_SDRAM_OPEN_PAGES_ADDR);
+       debug_print_reg(REG_SDRAM_OPERATION_ADDR);
+       debug_print_reg(REG_SDRAM_MODE_ADDR);
+       debug_print_reg(REG_SDRAM_EXT_MODE_ADDR);
+       debug_print_reg(REG_DDR_CONT_HIGH_ADDR);
+       debug_print_reg(REG_ODT_TIME_LOW_ADDR);
+       debug_print_reg(REG_SDRAM_ERROR_ADDR);
+       debug_print_reg(REG_SDRAM_AUTO_PWR_SAVE_ADDR);
+       debug_print_reg(REG_OUDDR3_TIMING_ADDR);
+       debug_print_reg(REG_ODT_TIME_HIGH_ADDR);
+       debug_print_reg(REG_SDRAM_ODT_CTRL_LOW_ADDR);
+       debug_print_reg(REG_SDRAM_ODT_CTRL_HIGH_ADDR);
+       debug_print_reg(REG_DUNIT_ODT_CTRL_ADDR);
+#ifndef MV88F67XX
+       debug_print_reg(REG_DRAM_FIFO_CTRL_ADDR);
+       debug_print_reg(REG_DRAM_AXI_CTRL_ADDR);
+       debug_print_reg(REG_DRAM_ADDR_CTRL_DRIVE_STRENGTH_ADDR);
+       debug_print_reg(REG_DRAM_DATA_DQS_DRIVE_STRENGTH_ADDR);
+       debug_print_reg(REG_DRAM_VER_CAL_MACHINE_CTRL_ADDR);
+       debug_print_reg(REG_DRAM_MAIN_PADS_CAL_ADDR);
+       debug_print_reg(REG_DRAM_HOR_CAL_MACHINE_CTRL_ADDR);
+       debug_print_reg(REG_CS_SIZE_SCRATCH_ADDR);
+       debug_print_reg(REG_DYNAMIC_POWER_SAVE_ADDR);
+       debug_print_reg(REG_READ_DATA_SAMPLE_DELAYS_ADDR);
+       debug_print_reg(REG_READ_DATA_READY_DELAYS_ADDR);
+       debug_print_reg(REG_DDR3_MR0_ADDR);
+       debug_print_reg(REG_DDR3_MR1_ADDR);
+       debug_print_reg(REG_DDR3_MR2_ADDR);
+       debug_print_reg(REG_DDR3_MR3_ADDR);
+       debug_print_reg(REG_DDR3_RANK_CTRL_ADDR);
+       debug_print_reg(REG_DRAM_PHY_CONFIG_ADDR);
+       debug_print_reg(REG_STATIC_DRAM_DLB_CONTROL);
+       debug_print_reg(DLB_BUS_OPTIMIZATION_WEIGHTS_REG);
+       debug_print_reg(DLB_AGING_REGISTER);
+       debug_print_reg(DLB_EVICTION_CONTROL_REG);
+       debug_print_reg(DLB_EVICTION_TIMERS_REGISTER_REG);
+#if defined(MV88F672X)
+       debug_print_reg(REG_FASTPATH_WIN_CTRL_ADDR(0));
+       debug_print_reg(REG_FASTPATH_WIN_BASE_ADDR(0));
+       debug_print_reg(REG_FASTPATH_WIN_CTRL_ADDR(1));
+       debug_print_reg(REG_FASTPATH_WIN_BASE_ADDR(1));
+#else
+       debug_print_reg(REG_FASTPATH_WIN_0_CTRL_ADDR);
+#endif
+       debug_print_reg(REG_CDI_CONFIG_ADDR);
+#endif
+}
+
+#if !defined(STATIC_TRAINING)
+static void ddr3_restore_and_set_final_windows(u32 *win_backup)
+{
+       u32 ui, reg, cs;
+       u32 win_ctrl_reg, num_of_win_regs;
+       u32 cs_ena = ddr3_get_cs_ena_from_reg();
+
+#if defined(MV88F672X)
+       if (DDR3_FAST_PATH_EN == 0)
+               return;
+#endif
+
+#if defined(MV88F672X)
+       win_ctrl_reg = REG_XBAR_WIN_16_CTRL_ADDR;
+       num_of_win_regs = 8;
+#else
+       win_ctrl_reg = REG_XBAR_WIN_4_CTRL_ADDR;
+       num_of_win_regs = 16;
+#endif
+
+       /* Return XBAR windows 4-7 or 16-19 init configuration */
+       for (ui = 0; ui < num_of_win_regs; ui++)
+               reg_write((win_ctrl_reg + 0x4 * ui), win_backup[ui]);
+
+       DEBUG_INIT_FULL_S("DDR3 Training Sequence - Switching XBAR Window to FastPath Window\n");
+
+#if defined(MV88F672X)
+       /* Set L2 filtering to 1G */
+       reg_write(0x8c04, 0x40000000);
+
+       /* Open fast path windows */
+       for (cs = 0; cs < MAX_CS; cs++) {
+               if (cs_ena & (1 << cs)) {
+                       /* set fast path window control for the cs */
+                       reg = 0x1FFFFFE1;
+                       reg |= (cs << 2);
+                       reg |= (SDRAM_CS_SIZE & 0xFFFF0000);
+                       /* Open fast path Window */
+                       reg_write(REG_FASTPATH_WIN_CTRL_ADDR(cs), reg);
+                       /* set fast path window base address for the cs */
+                       reg = (((SDRAM_CS_SIZE + 1) * cs) & 0xFFFF0000);
+                       /* Set base address */
+                       reg_write(REG_FASTPATH_WIN_BASE_ADDR(cs), reg);
+               }
+       }
+#else
+       reg = 0x1FFFFFE1;
+       for (cs = 0; cs < MAX_CS; cs++) {
+               if (cs_ena & (1 << cs)) {
+                       reg |= (cs << 2);
+                       break;
+               }
+       }
+
+       /* Open fast path Window to - 0.5G */
+       reg_write(REG_FASTPATH_WIN_0_CTRL_ADDR, reg);
+#endif
+}
+
+static void ddr3_save_and_set_training_windows(u32 *win_backup)
+{
+       u32 cs_ena = ddr3_get_cs_ena_from_reg();
+       u32 reg, tmp_count, cs, ui;
+       u32 win_ctrl_reg, win_base_reg, win_remap_reg;
+       u32 num_of_win_regs, win_jump_index;
+
+#if defined(MV88F672X)
+       /* Disable L2 filtering */
+       reg_write(0x8c04, 0);
+
+       win_ctrl_reg = REG_XBAR_WIN_16_CTRL_ADDR;
+       win_base_reg = REG_XBAR_WIN_16_BASE_ADDR;
+       win_remap_reg = REG_XBAR_WIN_16_REMAP_ADDR;
+       win_jump_index = 0x8;
+       num_of_win_regs = 8;
+#else
+       win_ctrl_reg = REG_XBAR_WIN_4_CTRL_ADDR;
+       win_base_reg = REG_XBAR_WIN_4_BASE_ADDR;
+       win_remap_reg = REG_XBAR_WIN_4_REMAP_ADDR;
+       win_jump_index = 0x10;
+       num_of_win_regs = 16;
+#endif
+
+       /* Close XBAR Window 19 - Not needed */
+       /* {0x000200e8}  -   Open Mbus Window - 2G */
+       reg_write(REG_XBAR_WIN_19_CTRL_ADDR, 0);
+
+       /* Save XBAR Windows 4-19 init configurations */
+       for (ui = 0; ui < num_of_win_regs; ui++)
+               win_backup[ui] = reg_read(win_ctrl_reg + 0x4 * ui);
+
+       /* Open XBAR Windows 4-7 or 16-19 for other CS */
+       reg = 0;
+       tmp_count = 0;
+       for (cs = 0; cs < MAX_CS; cs++) {
+               if (cs_ena & (1 << cs)) {
+                       switch (cs) {
+                       case 0:
+                               reg = 0x0E00;
+                               break;
+                       case 1:
+                               reg = 0x0D00;
+                               break;
+                       case 2:
+                               reg = 0x0B00;
+                               break;
+                       case 3:
+                               reg = 0x0700;
+                               break;
+                       }
+                       reg |= (1 << 0);
+                       reg |= (SDRAM_CS_SIZE & 0xFFFF0000);
+
+                       reg_write(win_ctrl_reg + win_jump_index * tmp_count,
+                                 reg);
+                       reg = ((SDRAM_CS_SIZE + 1) * (tmp_count)) & 0xFFFF0000;
+                       reg_write(win_base_reg + win_jump_index * tmp_count,
+                                 reg);
+
+                       if (win_remap_reg <= REG_XBAR_WIN_7_REMAP_ADDR) {
+                               reg_write(win_remap_reg +
+                                         win_jump_index * tmp_count, 0);
+                       }
+
+                       tmp_count++;
+               }
+       }
+}
+#endif /*  !defined(STATIC_TRAINING) */
+
+/*
+ * Name:     ddr3_init - Main DDR3 Init function
+ * Desc:     This routine initialize the DDR3 MC and runs HW training.
+ * Args:     None.
+ * Notes:
+ * Returns:  None.
+ */
+int ddr3_init(void)
+{
+       unsigned int status;
+
+       ddr3_set_pbs(DDR3_PBS);
+       ddr3_set_sw_wl_rl_debug(DDR3_RUN_SW_WHEN_HW_FAIL);
+
+       status = ddr3_init_main();
+       if (status == MV_DDR3_TRAINING_ERR_BAD_SAR)
+               DEBUG_INIT_S("DDR3 Training Error: Bad sample at reset");
+       if (status == MV_DDR3_TRAINING_ERR_BAD_DIMM_SETUP)
+               DEBUG_INIT_S("DDR3 Training Error: Bad DIMM setup");
+       if (status == MV_DDR3_TRAINING_ERR_MAX_CS_LIMIT)
+               DEBUG_INIT_S("DDR3 Training Error: Max CS limit");
+       if (status == MV_DDR3_TRAINING_ERR_MAX_ENA_CS_LIMIT)
+               DEBUG_INIT_S("DDR3 Training Error: Max enable CS limit");
+       if (status == MV_DDR3_TRAINING_ERR_BAD_R_DIMM_SETUP)
+               DEBUG_INIT_S("DDR3 Training Error: Bad R-DIMM setup");
+       if (status == MV_DDR3_TRAINING_ERR_TWSI_FAIL)
+               DEBUG_INIT_S("DDR3 Training Error: TWSI failure");
+       if (status == MV_DDR3_TRAINING_ERR_DIMM_TYPE_NO_MATCH)
+               DEBUG_INIT_S("DDR3 Training Error: DIMM type no match");
+       if (status == MV_DDR3_TRAINING_ERR_TWSI_BAD_TYPE)
+               DEBUG_INIT_S("DDR3 Training Error: TWSI bad type");
+       if (status == MV_DDR3_TRAINING_ERR_BUS_WIDTH_NOT_MATCH)
+               DEBUG_INIT_S("DDR3 Training Error: bus width no match");
+       if (status > MV_DDR3_TRAINING_ERR_HW_FAIL_BASE)
+               DEBUG_INIT_C("DDR3 Training Error: HW Failure 0x", status, 8);
+
+       return status;
+}
+
+static void print_ddr_target_freq(u32 cpu_freq, u32 fab_opt)
+{
+       puts("\nDDR3 Training Sequence - Run DDR3 at ");
+
+       switch (cpu_freq) {
+#if defined(MV88F672X)
+       case 21:
+               puts("533 Mhz\n");
+               break;
+#else
+       case 1:
+               puts("533 Mhz\n");
+               break;
+       case 2:
+               if (fab_opt == 5)
+                       puts("600 Mhz\n");
+               if (fab_opt == 9)
+                       puts("400 Mhz\n");
+               break;
+       case 3:
+               puts("667 Mhz\n");
+               break;
+       case 4:
+               if (fab_opt == 5)
+                       puts("750 Mhz\n");
+               if (fab_opt == 9)
+                       puts("500 Mhz\n");
+               break;
+       case 0xa:
+               puts("400 Mhz\n");
+               break;
+       case 0xb:
+               if (fab_opt == 5)
+                       puts("800 Mhz\n");
+               if (fab_opt == 9)
+                       puts("553 Mhz\n");
+               if (fab_opt == 0xA)
+                       puts("640 Mhz\n");
+               break;
+#endif
+       default:
+               puts("NOT DEFINED FREQ\n");
+       }
+}
+
+static u32 ddr3_init_main(void)
+{
+       u32 target_freq;
+       u32 reg = 0;
+       u32 cpu_freq, fab_opt, hclk_time_ps, soc_num;
+       __maybe_unused u32 ecc = DRAM_ECC;
+       __maybe_unused int dqs_clk_aligned = 0;
+       __maybe_unused u32 scrub_offs, scrub_size;
+       __maybe_unused u32 ddr_width = BUS_WIDTH;
+       __maybe_unused int status;
+       __maybe_unused u32 win_backup[16];
+
+       /* SoC/Board special Initializtions */
+       fab_opt = ddr3_get_fab_opt();
+
+#ifdef CONFIG_SPD_EEPROM
+       i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
+#endif
+
+       ddr3_print_version();
+       DEBUG_INIT_S("4\n");
+       /* Lib version 5.5.4 */
+
+       fab_opt = ddr3_get_fab_opt();
+
+       /* Switching CPU to MRVL ID */
+       soc_num = (reg_read(REG_SAMPLE_RESET_HIGH_ADDR) & SAR1_CPU_CORE_MASK) >>
+               SAR1_CPU_CORE_OFFSET;
+       switch (soc_num) {
+       case 0x3:
+               reg_bit_set(CPU_CONFIGURATION_REG(3), CPU_MRVL_ID_OFFSET);
+               reg_bit_set(CPU_CONFIGURATION_REG(2), CPU_MRVL_ID_OFFSET);
+       case 0x1:
+               reg_bit_set(CPU_CONFIGURATION_REG(1), CPU_MRVL_ID_OFFSET);
+       case 0x0:
+               reg_bit_set(CPU_CONFIGURATION_REG(0), CPU_MRVL_ID_OFFSET);
+       default:
+               break;
+       }
+
+       /* Power down deskew PLL */
+#if !defined(MV88F672X)
+       /* 0x18780 [25] */
+       reg = (reg_read(REG_DDRPHY_APLL_CTRL_ADDR) & ~(1 << 25));
+       reg_write(REG_DDRPHY_APLL_CTRL_ADDR, reg);
+#endif
+
+       /*
+        * Stage 0 - Set board configuration
+        */
+       cpu_freq = ddr3_get_cpu_freq();
+       if (fab_opt > FAB_OPT)
+               fab_opt = FAB_OPT - 1;
+
+       if (ddr3_get_log_level() > 0)
+               print_ddr_target_freq(cpu_freq, fab_opt);
+
+#if defined(MV88F672X)
+       get_target_freq(cpu_freq, &target_freq, &hclk_time_ps);
+#else
+       target_freq = cpu_ddr_ratios[fab_opt][cpu_freq];
+       hclk_time_ps = cpu_fab_clk_to_hclk[fab_opt][cpu_freq];
+#endif
+       if ((target_freq == 0) || (hclk_time_ps == 0)) {
+               DEBUG_INIT_S("DDR3 Training Sequence - FAILED - Wrong Sample at Reset Configurations\n");
+               if (target_freq == 0) {
+                       DEBUG_INIT_C("target_freq", target_freq, 2);
+                       DEBUG_INIT_C("fab_opt", fab_opt, 2);
+                       DEBUG_INIT_C("cpu_freq", cpu_freq, 2);
+               } else if (hclk_time_ps == 0) {
+                       DEBUG_INIT_C("hclk_time_ps", hclk_time_ps, 2);
+                       DEBUG_INIT_C("fab_opt", fab_opt, 2);
+                       DEBUG_INIT_C("cpu_freq", cpu_freq, 2);
+               }
+
+               return MV_DDR3_TRAINING_ERR_BAD_SAR;
+       }
+
+#if defined(ECC_SUPPORT)
+       scrub_offs = U_BOOT_START_ADDR;
+       scrub_size = U_BOOT_SCRUB_SIZE;
+#else
+       scrub_offs = 0;
+       scrub_size = 0;
+#endif
+
+#if defined(ECC_SUPPORT) && defined(AUTO_DETECTION_SUPPORT)
+       ecc = DRAM_ECC;
+#endif
+
+#if defined(ECC_SUPPORT) && defined(AUTO_DETECTION_SUPPORT)
+       ecc = 0;
+       if (ddr3_check_config(BUS_WIDTH_ECC_TWSI_ADDR, CONFIG_ECC))
+               ecc = 1;
+#endif
+
+#ifdef DQS_CLK_ALIGNED
+       dqs_clk_aligned = 1;
+#endif
+
+       /* Check if DRAM is already initialized  */
+       if (reg_read(REG_BOOTROM_ROUTINE_ADDR) &
+           (1 << REG_BOOTROM_ROUTINE_DRAM_INIT_OFFS)) {
+               DEBUG_INIT_S("DDR3 Training Sequence - 2nd boot - Skip\n");
+               return MV_OK;
+       }
+
+       /*
+        * Stage 1 - Dunit Setup
+        */
+
+#ifdef DUNIT_STATIC
+       /*
+        * For Static D-Unit Setup use must set the correct static values
+        * at the ddr3_*soc*_vars.h file
+        */
+       DEBUG_INIT_FULL_S("DDR3 Training Sequence - Static MC Init\n");
+       ddr3_static_mc_init();
+
+#ifdef ECC_SUPPORT
+       ecc = DRAM_ECC;
+       if (ecc) {
+               reg = reg_read(REG_SDRAM_CONFIG_ADDR);
+               reg |= (1 << REG_SDRAM_CONFIG_ECC_OFFS);
+               reg_write(REG_SDRAM_CONFIG_ADDR, reg);
+       }
+#endif
+#endif
+
+#if defined(MV88F78X60) || defined(MV88F672X)
+#if defined(AUTO_DETECTION_SUPPORT)
+       /*
+        * Configurations for both static and dynamic MC setups
+        *
+        * Dynamically Set 32Bit and ECC for AXP (Relevant only for
+        * Marvell DB boards)
+        */
+       if (ddr3_check_config(BUS_WIDTH_ECC_TWSI_ADDR, CONFIG_BUS_WIDTH)) {
+               ddr_width = 32;
+               DEBUG_INIT_S("DDR3 Training Sequence - DRAM bus width 32Bit\n");
+       }
+#endif
+
+#if defined(MV88F672X)
+       reg = reg_read(REG_SDRAM_CONFIG_ADDR);
+       if ((reg >> 15) & 1)
+               ddr_width = 32;
+       else
+               ddr_width = 16;
+#endif
+#endif
+
+#ifdef DUNIT_SPD
+       status = ddr3_dunit_setup(ecc, hclk_time_ps, &ddr_width);
+       if (MV_OK != status) {
+               DEBUG_INIT_S("DDR3 Training Sequence - FAILED (ddr3 Dunit Setup)\n");
+               return status;
+       }
+#endif
+
+       /* Fix read ready phases for all SOC in reg 0x15C8 */
+       reg = reg_read(REG_TRAINING_DEBUG_3_ADDR);
+       reg &= ~(REG_TRAINING_DEBUG_3_MASK);
+       reg |= 0x4;             /* Phase 0 */
+       reg &= ~(REG_TRAINING_DEBUG_3_MASK << REG_TRAINING_DEBUG_3_OFFS);
+       reg |= (0x4 << (1 * REG_TRAINING_DEBUG_3_OFFS));        /* Phase 1 */
+       reg &= ~(REG_TRAINING_DEBUG_3_MASK << (3 * REG_TRAINING_DEBUG_3_OFFS));
+       reg |= (0x6 << (3 * REG_TRAINING_DEBUG_3_OFFS));        /* Phase 3 */
+       reg &= ~(REG_TRAINING_DEBUG_3_MASK << (4 * REG_TRAINING_DEBUG_3_OFFS));
+       reg |= (0x6 << (4 * REG_TRAINING_DEBUG_3_OFFS));
+       reg &= ~(REG_TRAINING_DEBUG_3_MASK << (5 * REG_TRAINING_DEBUG_3_OFFS));
+       reg |= (0x6 << (5 * REG_TRAINING_DEBUG_3_OFFS));
+       reg_write(REG_TRAINING_DEBUG_3_ADDR, reg);
+
+#if defined(MV88F672X)
+       /*
+        * AxiBrespMode[8] = Compliant,
+        * AxiAddrDecodeCntrl[11] = Internal,
+        * AxiDataBusWidth[0] = 128bit
+        */
+       /* 0x14A8 - AXI Control Register */
+       reg_write(REG_DRAM_AXI_CTRL_ADDR, 0);
+#else
+       /* 0x14A8 - AXI Control Register */
+       reg_write(REG_DRAM_AXI_CTRL_ADDR, 0x00000100);
+       reg_write(REG_CDI_CONFIG_ADDR, 0x00000006);
+
+       if ((ddr_width == 64) && (reg_read(REG_DDR_IO_ADDR) &
+                                 (1 << REG_DDR_IO_CLK_RATIO_OFFS))) {
+               /* 0x14A8 - AXI Control Register */
+               reg_write(REG_DRAM_AXI_CTRL_ADDR, 0x00000101);
+               reg_write(REG_CDI_CONFIG_ADDR, 0x00000007);
+       }
+#endif
+
+#if !defined(MV88F67XX)
+       /*
+        * ARMADA-370 activate DLB later at the u-boot,
+        * Armada38x - No DLB activation at this time
+        */
+       reg_write(DLB_BUS_OPTIMIZATION_WEIGHTS_REG, 0x18C01E);
+
+#if defined(MV88F78X60)
+       /* WA according to eratta GL-8672902*/
+       if (mv_ctrl_rev_get() == MV_78XX0_B0_REV)
+               reg_write(DLB_BUS_OPTIMIZATION_WEIGHTS_REG, 0xc19e);
+#endif
+
+       reg_write(DLB_AGING_REGISTER, 0x0f7f007f);
+       reg_write(DLB_EVICTION_CONTROL_REG, 0x0);
+       reg_write(DLB_EVICTION_TIMERS_REGISTER_REG, 0x00FF3C1F);
+
+       reg_write(MBUS_UNITS_PRIORITY_CONTROL_REG, 0x55555555);
+       reg_write(FABRIC_UNITS_PRIORITY_CONTROL_REG, 0xAA);
+       reg_write(MBUS_UNITS_PREFETCH_CONTROL_REG, 0xffff);
+       reg_write(FABRIC_UNITS_PREFETCH_CONTROL_REG, 0xf0f);
+
+#if defined(MV88F78X60)
+       /* WA according to eratta GL-8672902 */
+       if (mv_ctrl_rev_get() == MV_78XX0_B0_REV) {
+               reg = reg_read(REG_STATIC_DRAM_DLB_CONTROL);
+               reg |= DLB_ENABLE;
+               reg_write(REG_STATIC_DRAM_DLB_CONTROL, reg);
+       }
+#endif /* end defined(MV88F78X60) */
+#endif /* end !defined(MV88F67XX) */
+
+       if (ddr3_get_log_level() >= MV_LOG_LEVEL_1)
+               print_dunit_setup();
+
+       /*
+        * Stage 2 - Training Values Setup
+        */
+#ifdef STATIC_TRAINING
+       /*
+        * DRAM Init - After all the D-unit values are set, its time to init
+        * the D-unit
+        */
+       /* Wait for '0' */
+       reg_write(REG_SDRAM_INIT_CTRL_ADDR, 0x1);
+       do {
+               reg = (reg_read(REG_SDRAM_INIT_CTRL_ADDR)) &
+                       (1 << REG_SDRAM_INIT_CTRL_OFFS);
+       } while (reg);
+
+       /* ddr3 init using static parameters - HW training is disabled */
+       DEBUG_INIT_FULL_S("DDR3 Training Sequence - Static Training Parameters\n");
+       ddr3_static_training_init();
+
+#if defined(MV88F78X60)
+       /*
+        * If ECC is enabled, need to scrub the U-Boot area memory region -
+        * Run training function with Xor bypass just to scrub the memory
+        */
+       status = ddr3_hw_training(target_freq, ddr_width,
+                                 1, scrub_offs, scrub_size,
+                                 dqs_clk_aligned, DDR3_TRAINING_DEBUG,
+                                 REG_DIMM_SKIP_WL);
+       if (MV_OK != status) {
+               DEBUG_INIT_FULL_S("DDR3 Training Sequence - FAILED\n");
+               return status;
+       }
+#endif
+#else
+       /* Set X-BAR windows for the training sequence */
+       ddr3_save_and_set_training_windows(win_backup);
+
+       /* Run DDR3 Training Sequence */
+       /* DRAM Init */
+       reg_write(REG_SDRAM_INIT_CTRL_ADDR, 0x1);
+       do {
+               reg = (reg_read(REG_SDRAM_INIT_CTRL_ADDR)) &
+                       (1 << REG_SDRAM_INIT_CTRL_OFFS);
+       } while (reg);          /* Wait for '0' */
+
+       /* ddr3 init using DDR3 HW training procedure */
+       DEBUG_INIT_FULL_S("DDR3 Training Sequence - HW Training Procedure\n");
+       status = ddr3_hw_training(target_freq, ddr_width,
+                                 0, scrub_offs, scrub_size,
+                                 dqs_clk_aligned, DDR3_TRAINING_DEBUG,
+                                 REG_DIMM_SKIP_WL);
+       if (MV_OK != status) {
+               DEBUG_INIT_FULL_S("DDR3 Training Sequence - FAILED\n");
+               return status;
+       }
+#endif
+
+       /*
+        * Stage 3 - Finish
+        */
+#if defined(MV88F78X60) || defined(MV88F672X)
+       /* Disable ECC Ignore bit */
+       reg = reg_read(REG_SDRAM_CONFIG_ADDR) &
+               ~(1 << REG_SDRAM_CONFIG_IERR_OFFS);
+       reg_write(REG_SDRAM_CONFIG_ADDR, reg);
+#endif
+
+#if !defined(STATIC_TRAINING)
+       /* Restore and set windows */
+       ddr3_restore_and_set_final_windows(win_backup);
+#endif
+
+       /* Update DRAM init indication in bootROM register */
+       reg = reg_read(REG_BOOTROM_ROUTINE_ADDR);
+       reg_write(REG_BOOTROM_ROUTINE_ADDR,
+                 reg | (1 << REG_BOOTROM_ROUTINE_DRAM_INIT_OFFS));
+
+#if !defined(MV88F67XX)
+#if defined(MV88F78X60)
+       if (mv_ctrl_rev_get() == MV_78XX0_B0_REV) {
+               reg = reg_read(REG_SDRAM_CONFIG_ADDR);
+               if (ecc == 0)
+                       reg_write(REG_SDRAM_CONFIG_ADDR, reg | (1 << 19));
+       }
+#endif /* end defined(MV88F78X60) */
+
+       reg_write(DLB_EVICTION_CONTROL_REG, 0x9);
+
+       reg = reg_read(REG_STATIC_DRAM_DLB_CONTROL);
+       reg |= (DLB_ENABLE | DLB_WRITE_COALESING | DLB_AXI_PREFETCH_EN |
+               DLB_MBUS_PREFETCH_EN | PREFETCH_NLNSZTR);
+       reg_write(REG_STATIC_DRAM_DLB_CONTROL, reg);
+#endif /* end !defined(MV88F67XX) */
+
+#ifdef STATIC_TRAINING
+       DEBUG_INIT_S("DDR3 Training Sequence - Ended Successfully (S)\n");
+#else
+       DEBUG_INIT_S("DDR3 Training Sequence - Ended Successfully\n");
+#endif
+
+       return MV_OK;
+}
+
+/*
+ * Name:     ddr3_get_cpu_freq
+ * Desc:     read S@R and return CPU frequency
+ * Args:
+ * Notes:
+ * Returns:  required value
+ */
+
+u32 ddr3_get_cpu_freq(void)
+{
+       u32 reg, cpu_freq;
+
+#if defined(MV88F672X)
+       /* Read sample at reset setting */
+       reg = reg_read(REG_SAMPLE_RESET_HIGH_ADDR);     /* 0xE8200 */
+       cpu_freq = (reg & REG_SAMPLE_RESET_CPU_FREQ_MASK) >>
+               REG_SAMPLE_RESET_CPU_FREQ_OFFS;
+#else
+       /* Read sample at reset setting */
+       reg = reg_read(REG_SAMPLE_RESET_LOW_ADDR);      /* 0x18230 [23:21] */
+#if defined(MV88F78X60)
+       cpu_freq = (reg & REG_SAMPLE_RESET_CPU_FREQ_MASK) >>
+               REG_SAMPLE_RESET_CPU_FREQ_OFFS;
+       reg = reg_read(REG_SAMPLE_RESET_HIGH_ADDR);     /* 0x18234 [20] */
+       cpu_freq |= (((reg >> REG_SAMPLE_RESET_HIGH_CPU_FREQ_OFFS) & 0x1) << 3);
+#elif defined(MV88F67XX)
+       cpu_freq = (reg & REG_SAMPLE_RESET_CPU_FREQ_MASK) >>
+               REG_SAMPLE_RESET_CPU_FREQ_OFFS;
+#endif
+#endif
+
+       return cpu_freq;
+}
+
+/*
+ * Name:     ddr3_get_fab_opt
+ * Desc:     read S@R and return CPU frequency
+ * Args:
+ * Notes:
+ * Returns:  required value
+ */
+u32 ddr3_get_fab_opt(void)
+{
+       __maybe_unused u32 reg, fab_opt;
+
+#if defined(MV88F672X)
+       return 0;               /* No fabric */
+#else
+       /* Read sample at reset setting */
+       reg = reg_read(REG_SAMPLE_RESET_LOW_ADDR);
+       fab_opt = (reg & REG_SAMPLE_RESET_FAB_MASK) >>
+               REG_SAMPLE_RESET_FAB_OFFS;
+
+#if defined(MV88F78X60)
+       reg = reg_read(REG_SAMPLE_RESET_HIGH_ADDR);
+       fab_opt |= (((reg >> 19) & 0x1) << 4);
+#endif
+
+       return fab_opt;
+#endif
+}
+
+/*
+ * Name:     ddr3_get_vco_freq
+ * Desc:     read S@R and return VCO frequency
+ * Args:
+ * Notes:
+ * Returns:  required value
+ */
+u32 ddr3_get_vco_freq(void)
+{
+       u32 fab, cpu_freq, ui_vco_freq;
+
+       fab = ddr3_get_fab_opt();
+       cpu_freq = ddr3_get_cpu_freq();
+
+       if (fab == 2 || fab == 3 || fab == 7 || fab == 8 || fab == 10 ||
+           fab == 15 || fab == 17 || fab == 20)
+               ui_vco_freq = cpu_freq + CLK_CPU;
+       else
+               ui_vco_freq = cpu_freq;
+
+       return ui_vco_freq;
+}
+
+#ifdef STATIC_TRAINING
+/*
+ * Name:     ddr3_static_training_init - Init DDR3 Training with
+ *           static parameters
+ * Desc:     Use this routine to init the controller without the HW training
+ *           procedure
+ *           User must provide compatible header file with registers data.
+ * Args:     None.
+ * Notes:
+ * Returns:  None.
+ */
+void ddr3_static_training_init(void)
+{
+       MV_DRAM_MODES *ddr_mode;
+       u32 reg;
+       int j;
+
+       ddr_mode = ddr3_get_static_ddr_mode();
+
+       j = 0;
+       while (ddr_mode->vals[j].reg_addr != 0) {
+               udelay(10);     /* haim want to delay each write */
+               reg_write(ddr_mode->vals[j].reg_addr,
+                         ddr_mode->vals[j].reg_value);
+
+               if (ddr_mode->vals[j].reg_addr ==
+                   REG_PHY_REGISTRY_FILE_ACCESS_ADDR)
+                       do {
+                               reg = reg_read(REG_PHY_REGISTRY_FILE_ACCESS_ADDR) &
+                                       REG_PHY_REGISTRY_FILE_ACCESS_OP_DONE;
+                       } while (reg);
+               j++;
+       }
+}
+#endif
+
+/*
+ * Name:     ddr3_get_static_mc_value - Init Memory controller with static
+ *           parameters
+ * Desc:     Use this routine to init the controller without the HW training
+ *           procedure
+ *           User must provide compatible header file with registers data.
+ * Args:     None.
+ * Notes:
+ * Returns:  None.
+ */
+u32 ddr3_get_static_mc_value(u32 reg_addr, u32 offset1, u32 mask1, u32 offset2,
+                            u32 mask2)
+{
+       u32 reg, tmp;
+
+       reg = reg_read(reg_addr);
+
+       tmp = (reg >> offset1) & mask1;
+       if (mask2)
+               tmp |= (reg >> offset2) & mask2;
+
+       return tmp;
+}
+
+/*
+ * Name:     ddr3_get_static_ddr_mode - Init Memory controller with static
+ *           parameters
+ * Desc:     Use this routine to init the controller without the HW training
+ *           procedure
+ *           User must provide compatible header file with registers data.
+ * Args:     None.
+ * Notes:
+ * Returns:  None.
+ */
+__weak MV_DRAM_MODES *ddr3_get_static_ddr_mode(void)
+{
+       u32 chip_board_rev, i;
+       u32 size;
+
+       /* Do not modify this code. relevant only for marvell Boards */
+#if defined(DB_78X60_PCAC)
+       chip_board_rev = Z1_PCAC;
+#elif defined(DB_78X60_AMC)
+       chip_board_rev = A0_AMC;
+#elif defined(DB_88F6710_PCAC)
+       chip_board_rev = A0_PCAC;
+#elif defined(RD_88F6710)
+       chip_board_rev = A0_RD;
+#elif defined(MV88F672X)
+       chip_board_rev = mv_board_id_get();
+#else
+       chip_board_rev = A0;
+#endif
+
+       size = sizeof(ddr_modes) / sizeof(MV_DRAM_MODES);
+       for (i = 0; i < size; i++) {
+               if ((ddr3_get_cpu_freq() == ddr_modes[i].cpu_freq) &&
+                   (ddr3_get_fab_opt() == ddr_modes[i].fab_freq) &&
+                   (chip_board_rev == ddr_modes[i].chip_board_rev))
+                       return &ddr_modes[i];
+       }
+
+       return &ddr_modes[0];
+}
+
+#ifdef DUNIT_STATIC
+/*
+ * Name:     ddr3_static_mc_init - Init Memory controller with static parameters
+ * Desc:     Use this routine to init the controller without the HW training
+ *           procedure
+ *           User must provide compatible header file with registers data.
+ * Args:     None.
+ * Notes:
+ * Returns:  None.
+ */
+void ddr3_static_mc_init(void)
+{
+       MV_DRAM_MODES *ddr_mode;
+       u32 reg;
+       int j;
+
+       ddr_mode = ddr3_get_static_ddr_mode();
+       j = 0;
+       while (ddr_mode->regs[j].reg_addr != 0) {
+               reg_write(ddr_mode->regs[j].reg_addr,
+                         ddr_mode->regs[j].reg_value);
+               if (ddr_mode->regs[j].reg_addr ==
+                   REG_PHY_REGISTRY_FILE_ACCESS_ADDR)
+                       do {
+                               reg = reg_read(REG_PHY_REGISTRY_FILE_ACCESS_ADDR) &
+                                       REG_PHY_REGISTRY_FILE_ACCESS_OP_DONE;
+                       } while (reg);
+               j++;
+       }
+}
+#endif
+
+/*
+ * Name:     ddr3_check_config - Check user configurations: ECC/MultiCS
+ * Desc:
+ * Args:     twsi Address
+ * Notes:    Only Available for ArmadaXP/Armada 370 DB boards
+ * Returns:  None.
+ */
+int ddr3_check_config(u32 twsi_addr, MV_CONFIG_TYPE config_type)
+{
+#ifdef AUTO_DETECTION_SUPPORT
+       u8 data = 0;
+       int ret;
+       int offset;
+
+       if ((config_type == CONFIG_ECC) || (config_type == CONFIG_BUS_WIDTH))
+               offset = 1;
+       else
+               offset = 0;
+
+       ret = i2c_read(twsi_addr, offset, 1, (u8 *)&data, 1);
+       if (!ret) {
+               switch (config_type) {
+               case CONFIG_ECC:
+                       if (data & 0x2)
+                               return 1;
+                       break;
+               case CONFIG_BUS_WIDTH:
+                       if (data & 0x1)
+                               return 1;
+                       break;
+#ifdef DB_88F6710
+               case CONFIG_MULTI_CS:
+                       if (CFG_MULTI_CS_MODE(data))
+                               return 1;
+                       break;
+#else
+               case CONFIG_MULTI_CS:
+                       break;
+#endif
+               }
+       }
+#endif
+
+       return 0;
+}
+
+#if defined(DB_88F78X60_REV2)
+/*
+ * Name:     ddr3_get_eprom_fabric - Get Fabric configuration from EPROM
+ * Desc:
+ * Args:     twsi Address
+ * Notes:    Only Available for ArmadaXP DB Rev2 boards
+ * Returns:  None.
+ */
+u8 ddr3_get_eprom_fabric(void)
+{
+#ifdef AUTO_DETECTION_SUPPORT
+       u8 data = 0;
+       int ret;
+
+       ret = i2c_read(NEW_FABRIC_TWSI_ADDR, 1, 1, (u8 *)&data, 1);
+       if (!ret)
+               return data & 0x1F;
+#endif
+
+       return 0;
+}
+
+#endif
+
+/*
+ * Name:     ddr3_cl_to_valid_cl - this return register matching CL value
+ * Desc:
+ * Args:     clValue - the value
+
+ * Notes:
+ * Returns:  required CL value
+ */
+u32 ddr3_cl_to_valid_cl(u32 cl)
+{
+       switch (cl) {
+       case 5:
+               return 2;
+               break;
+       case 6:
+               return 4;
+               break;
+       case 7:
+               return 6;
+               break;
+       case 8:
+               return 8;
+               break;
+       case 9:
+               return 10;
+               break;
+       case 10:
+               return 12;
+               break;
+       case 11:
+               return 14;
+               break;
+       case 12:
+               return 1;
+               break;
+       case 13:
+               return 3;
+               break;
+       case 14:
+               return 5;
+               break;
+       default:
+               return 2;
+       }
+}
+
+/*
+ * Name:     ddr3_cl_to_valid_cl - this return register matching CL value
+ * Desc:
+ * Args:     clValue - the value
+ * Notes:
+ * Returns:  required CL value
+ */
+u32 ddr3_valid_cl_to_cl(u32 ui_valid_cl)
+{
+       switch (ui_valid_cl) {
+       case 1:
+               return 12;
+               break;
+       case 2:
+               return 5;
+               break;
+       case 3:
+               return 13;
+               break;
+       case 4:
+               return 6;
+               break;
+       case 5:
+               return 14;
+               break;
+       case 6:
+               return 7;
+               break;
+       case 8:
+               return 8;
+               break;
+       case 10:
+               return 9;
+               break;
+       case 12:
+               return 10;
+               break;
+       case 14:
+               return 11;
+               break;
+       default:
+               return 0;
+       }
+}
+
+/*
+ * Name:     ddr3_get_cs_num_from_reg
+ * Desc:
+ * Args:
+ * Notes:
+ * Returns:
+ */
+u32 ddr3_get_cs_num_from_reg(void)
+{
+       u32 cs_ena = ddr3_get_cs_ena_from_reg();
+       u32 cs_count = 0;
+       u32 cs;
+
+       for (cs = 0; cs < MAX_CS; cs++) {
+               if (cs_ena & (1 << cs))
+                       cs_count++;
+       }
+
+       return cs_count;
+}
+
+/*
+ * Name:     ddr3_get_cs_ena_from_reg
+ * Desc:
+ * Args:
+ * Notes:
+ * Returns:
+ */
+u32 ddr3_get_cs_ena_from_reg(void)
+{
+       return reg_read(REG_DDR3_RANK_CTRL_ADDR) &
+               REG_DDR3_RANK_CTRL_CS_ENA_MASK;
+}
+
+/*
+ * mv_ctrl_rev_get - Get Marvell controller device revision number
+ *
+ * DESCRIPTION:
+ *       This function returns 8bit describing the device revision as defined
+ *       in PCI Express Class Code and Revision ID Register.
+ *
+ * INPUT:
+ *       None.
+ *
+ * OUTPUT:
+ *       None.
+ *
+ * RETURN:
+ *       8bit desscribing Marvell controller revision number
+ *
+ */
+#if !defined(MV88F672X)
+u8 mv_ctrl_rev_get(void)
+{
+       u8 rev_num;
+
+#if defined(MV_INCLUDE_CLK_PWR_CNTRL)
+       /* Check pex power state */
+       u32 pex_power;
+       pex_power = mv_ctrl_pwr_clck_get(PEX_UNIT_ID, 0);
+       if (pex_power == 0)
+               mv_ctrl_pwr_clck_set(PEX_UNIT_ID, 0, 1);
+#endif
+       rev_num = (u8)reg_read(PEX_CFG_DIRECT_ACCESS(0,
+                       PCI_CLASS_CODE_AND_REVISION_ID));
+
+#if defined(MV_INCLUDE_CLK_PWR_CNTRL)
+       /* Return to power off state */
+       if (pex_power == 0)
+               mv_ctrl_pwr_clck_set(PEX_UNIT_ID, 0, 0);
+#endif
+
+       return (rev_num & PCCRIR_REVID_MASK) >> PCCRIR_REVID_OFFS;
+}
+
+#endif
+
+#if defined(MV88F672X)
+void get_target_freq(u32 freq_mode, u32 *ddr_freq, u32 *hclk_ps)
+{
+       u32 tmp, hclk;
+
+       switch (freq_mode) {
+       case CPU_333MHz_DDR_167MHz_L2_167MHz:
+               hclk = 84;
+               tmp = DDR_100;
+               break;
+       case CPU_266MHz_DDR_266MHz_L2_133MHz:
+       case CPU_333MHz_DDR_222MHz_L2_167MHz:
+       case CPU_400MHz_DDR_200MHz_L2_200MHz:
+       case CPU_400MHz_DDR_267MHz_L2_200MHz:
+       case CPU_533MHz_DDR_267MHz_L2_267MHz:
+       case CPU_500MHz_DDR_250MHz_L2_250MHz:
+       case CPU_600MHz_DDR_300MHz_L2_300MHz:
+       case CPU_800MHz_DDR_267MHz_L2_400MHz:
+       case CPU_900MHz_DDR_300MHz_L2_450MHz:
+               tmp = DDR_300;
+               hclk = 150;
+               break;
+       case CPU_333MHz_DDR_333MHz_L2_167MHz:
+       case CPU_500MHz_DDR_334MHz_L2_250MHz:
+       case CPU_666MHz_DDR_333MHz_L2_333MHz:
+               tmp = DDR_333;
+               hclk = 165;
+               break;
+       case CPU_533MHz_DDR_356MHz_L2_267MHz:
+               tmp = DDR_360;
+               hclk = 180;
+               break;
+       case CPU_400MHz_DDR_400MHz_L2_200MHz:
+       case CPU_600MHz_DDR_400MHz_L2_300MHz:
+       case CPU_800MHz_DDR_400MHz_L2_400MHz:
+       case CPU_400MHz_DDR_400MHz_L2_400MHz:
+               tmp = DDR_400;
+               hclk = 200;
+               break;
+       case CPU_666MHz_DDR_444MHz_L2_333MHz:
+       case CPU_900MHz_DDR_450MHz_L2_450MHz:
+               tmp = DDR_444;
+               hclk = 222;
+               break;
+       case CPU_500MHz_DDR_500MHz_L2_250MHz:
+       case CPU_1000MHz_DDR_500MHz_L2_500MHz:
+       case CPU_1000MHz_DDR_500MHz_L2_333MHz:
+               tmp = DDR_500;
+               hclk = 250;
+               break;
+       case CPU_533MHz_DDR_533MHz_L2_267MHz:
+       case CPU_800MHz_DDR_534MHz_L2_400MHz:
+       case CPU_1100MHz_DDR_550MHz_L2_550MHz:
+               tmp = DDR_533;
+               hclk = 267;
+               break;
+       case CPU_600MHz_DDR_600MHz_L2_300MHz:
+       case CPU_900MHz_DDR_600MHz_L2_450MHz:
+       case CPU_1200MHz_DDR_600MHz_L2_600MHz:
+               tmp = DDR_600;
+               hclk = 300;
+               break;
+       case CPU_666MHz_DDR_666MHz_L2_333MHz:
+       case CPU_1000MHz_DDR_667MHz_L2_500MHz:
+               tmp = DDR_666;
+               hclk = 333;
+               break;
+       default:
+               *ddr_freq = 0;
+               *hclk_ps = 0;
+               break;
+       }
+
+       *ddr_freq = tmp;                /* DDR freq define */
+       *hclk_ps = 1000000 / hclk;      /* values are 1/HCLK in ps */
+
+       return;
+}
+#endif
diff --git a/drivers/ddr/mvebu/ddr3_init.h b/drivers/ddr/mvebu/ddr3_init.h
new file mode 100644 (file)
index 0000000..b259e09
--- /dev/null
@@ -0,0 +1,143 @@
+/*
+ * Copyright (C) Marvell International Ltd. and its affiliates
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#ifndef __DDR3_INIT_H
+#define __DDR3_INIT_H
+
+/*
+ * Debug
+ */
+
+/*
+ * MV_DEBUG_INIT need to be defines, otherwise the output of the
+ * DDR2 training code is not complete and misleading
+ */
+#define MV_DEBUG_INIT
+
+#ifdef MV_DEBUG_INIT
+#define DEBUG_INIT_S(s)                        puts(s)
+#define DEBUG_INIT_D(d, l)             printf("%x", d)
+#define DEBUG_INIT_D_10(d, l)          printf("%d", d)
+#else
+#define DEBUG_INIT_S(s)
+#define DEBUG_INIT_D(d, l)
+#define DEBUG_INIT_D_10(d, l)
+#endif
+
+#ifdef MV_DEBUG_INIT_FULL
+#define DEBUG_INIT_FULL_S(s)           puts(s)
+#define DEBUG_INIT_FULL_D(d, l)                printf("%x", d)
+#define DEBUG_INIT_FULL_D_10(d, l)     printf("%d", d)
+#define DEBUG_WR_REG(reg, val) \
+       { DEBUG_INIT_S("Write Reg: 0x"); DEBUG_INIT_D((reg), 8); \
+         DEBUG_INIT_S("= "); DEBUG_INIT_D((val), 8); DEBUG_INIT_S("\n"); }
+#define DEBUG_RD_REG(reg, val) \
+       { DEBUG_INIT_S("Read  Reg: 0x"); DEBUG_INIT_D((reg), 8); \
+         DEBUG_INIT_S("= "); DEBUG_INIT_D((val), 8); DEBUG_INIT_S("\n"); }
+#else
+#define DEBUG_INIT_FULL_S(s)
+#define DEBUG_INIT_FULL_D(d, l)
+#define DEBUG_INIT_FULL_D_10(d, l)
+#define DEBUG_WR_REG(reg, val)
+#define DEBUG_RD_REG(reg, val)
+#endif
+
+#define DEBUG_INIT_FULL_C(s, d, l) \
+       { DEBUG_INIT_FULL_S(s); DEBUG_INIT_FULL_D(d, l); DEBUG_INIT_FULL_S("\n"); }
+#define DEBUG_INIT_C(s, d, l) \
+       { DEBUG_INIT_S(s); DEBUG_INIT_D(d, l); DEBUG_INIT_S("\n"); }
+
+#define MV_MBUS_REGS_OFFSET                 (0x20000)
+
+#include "ddr3_hw_training.h"
+
+#define MAX_DIMM_NUM                   2
+#define SPD_SIZE                       128
+
+#ifdef MV88F78X60
+#include "ddr3_axp.h"
+#elif defined(MV88F67XX)
+#include "ddr3_a370.h"
+#elif defined(MV88F672X)
+#include "ddr3_a375.h"
+#endif
+
+/* DRR training Error codes */
+/* Stage 0 errors */
+#define MV_DDR3_TRAINING_ERR_BAD_SAR                   0xDD300001
+/* Stage 1 errors */
+#define MV_DDR3_TRAINING_ERR_TWSI_FAIL                 0xDD301001
+#define MV_DDR3_TRAINING_ERR_DIMM_TYPE_NO_MATCH                0xDD301001
+#define MV_DDR3_TRAINING_ERR_TWSI_BAD_TYPE             0xDD301003
+#define MV_DDR3_TRAINING_ERR_BUS_WIDTH_NOT_MATCH       0xDD301004
+#define MV_DDR3_TRAINING_ERR_BAD_DIMM_SETUP            0xDD301005
+#define MV_DDR3_TRAINING_ERR_MAX_CS_LIMIT              0xDD301006
+#define MV_DDR3_TRAINING_ERR_MAX_ENA_CS_LIMIT          0xDD301007
+#define MV_DDR3_TRAINING_ERR_BAD_R_DIMM_SETUP          0xDD301008
+/* Stage 2 errors */
+#define MV_DDR3_TRAINING_ERR_HW_FAIL_BASE              0xDD302000
+
+typedef enum config_type {
+       CONFIG_ECC,
+       CONFIG_MULTI_CS,
+       CONFIG_BUS_WIDTH
+} MV_CONFIG_TYPE;
+
+enum log_level  {
+       MV_LOG_LEVEL_0,
+       MV_LOG_LEVEL_1,
+       MV_LOG_LEVEL_2,
+       MV_LOG_LEVEL_3
+};
+
+int ddr3_hw_training(u32 target_freq, u32 ddr_width,
+                    int xor_bypass, u32 scrub_offs, u32 scrub_size,
+                    int dqs_clk_aligned, int debug_mode, int reg_dimm_skip_wl);
+
+void ddr3_print_version(void);
+void fix_pll_val(u8 target_fab);
+u8 ddr3_get_eprom_fabric(void);
+u32 ddr3_get_fab_opt(void);
+u32 ddr3_get_cpu_freq(void);
+u32 ddr3_get_vco_freq(void);
+int ddr3_check_config(u32 addr, MV_CONFIG_TYPE config_type);
+u32 ddr3_get_static_mc_value(u32 reg_addr, u32 offset1, u32 mask1, u32 offset2,
+                            u32 mask2);
+u32 ddr3_cl_to_valid_cl(u32 cl);
+u32 ddr3_valid_cl_to_cl(u32 ui_valid_cl);
+u32 ddr3_get_cs_num_from_reg(void);
+u32 ddr3_get_cs_ena_from_reg(void);
+u8 mv_ctrl_rev_get(void);
+
+u32 ddr3_get_log_level(void);
+
+/* SPD */
+int ddr3_dunit_setup(u32 ecc_ena, u32 hclk_time, u32 *ddr_width);
+
+/*
+ * Accessor functions for the registers
+ */
+static inline void reg_write(u32 addr, u32 val)
+{
+       writel(val, INTER_REGS_BASE + addr);
+}
+
+static inline u32 reg_read(u32 addr)
+{
+       return readl(INTER_REGS_BASE + addr);
+}
+
+static inline void reg_bit_set(u32 addr, u32 mask)
+{
+       setbits_le32(INTER_REGS_BASE + addr, mask);
+}
+
+static inline void reg_bit_clr(u32 addr, u32 mask)
+{
+       clrbits_le32(INTER_REGS_BASE + addr, mask);
+}
+
+#endif /* __DDR3_INIT_H */
diff --git a/drivers/ddr/mvebu/ddr3_patterns_64bit.h b/drivers/ddr/mvebu/ddr3_patterns_64bit.h
new file mode 100644 (file)
index 0000000..1b57328
--- /dev/null
@@ -0,0 +1,924 @@
+/*
+ * Copyright (C) Marvell International Ltd. and its affiliates
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#ifndef __DDR3_PATTERNS_64_H
+#define __DDR3_PATTERNS_64_H
+
+/*
+ * Patterns Declerations
+ */
+
+u32 wl_sup_pattern[LEN_WL_SUP_PATTERN] __aligned(32) = {
+       0x04030201, 0x08070605, 0x0c0b0a09, 0x100f0e0d,
+       0x14131211, 0x18171615, 0x1c1b1a19, 0x201f1e1d,
+       0x24232221, 0x28272625, 0x2c2b2a29, 0x302f2e2d,
+       0x34333231, 0x38373635, 0x3c3b3a39, 0x403f3e3d,
+       0x44434241, 0x48474645, 0x4c4b4a49, 0x504f4e4d,
+       0x54535251, 0x58575655, 0x5c5b5a59, 0x605f5e5d,
+       0x64636261, 0x68676665, 0x6c6b6a69, 0x706f6e6d,
+       0x74737271, 0x78777675, 0x7c7b7a79, 0x807f7e7d
+};
+
+u32 pbs_pattern_32b[2][LEN_PBS_PATTERN] __aligned(32) = {
+       {
+               0xAAAAAAAA, 0x55555555, 0xAAAAAAAA, 0x55555555,
+               0xAAAAAAAA, 0x55555555, 0xAAAAAAAA, 0x55555555,
+               0xAAAAAAAA, 0x55555555, 0xAAAAAAAA, 0x55555555,
+               0xAAAAAAAA, 0x55555555, 0xAAAAAAAA, 0x55555555
+       },
+       {
+               0x55555555, 0xAAAAAAAA, 0x55555555, 0xAAAAAAAA,
+               0x55555555, 0xAAAAAAAA, 0x55555555, 0xAAAAAAAA,
+               0x55555555, 0xAAAAAAAA, 0x55555555, 0xAAAAAAAA,
+               0x55555555, 0xAAAAAAAA, 0x55555555, 0xAAAAAAAA
+       }
+};
+
+u32 pbs_pattern_64b[2][LEN_PBS_PATTERN] __aligned(32) = {
+       {
+               0xAAAAAAAA, 0xAAAAAAAA, 0x55555555, 0x55555555,
+               0xAAAAAAAA, 0xAAAAAAAA, 0x55555555, 0x55555555,
+               0xAAAAAAAA, 0xAAAAAAAA, 0x55555555, 0x55555555,
+               0xAAAAAAAA, 0xAAAAAAAA, 0x55555555, 0x55555555
+       },
+       {
+               0x55555555, 0x55555555, 0xAAAAAAAA, 0xAAAAAAAA,
+               0x55555555, 0x55555555, 0xAAAAAAAA, 0xAAAAAAAA,
+               0x55555555, 0x55555555, 0xAAAAAAAA, 0xAAAAAAAA,
+               0x55555555, 0x55555555, 0xAAAAAAAA, 0xAAAAAAAA
+       }
+};
+
+u32 rl_pattern[LEN_STD_PATTERN] __aligned(32) = {
+       0x00000000, 0x00000000, 0x00000000, 0x00000000,
+       0x00000000, 0x00000000, 0x00000000, 0x00000000,
+       0x00000000, 0x00000000, 0x00000000, 0x00000000,
+       0x01010101, 0x01010101, 0x01010101, 0x01010101
+};
+
+u32 killer_pattern_32b[DQ_NUM][LEN_KILLER_PATTERN] __aligned(32) = {
+       {
+               0x01010101, 0x00000000, 0x01010101, 0xFFFFFFFF,
+               0x01010101, 0x00000000, 0x01010101, 0xFFFFFFFF,
+               0xFEFEFEFE, 0xFEFEFEFE, 0x01010101, 0xFEFEFEFE,
+               0xFEFEFEFE, 0xFEFEFEFE, 0x01010101, 0xFEFEFEFE,
+               0x01010101, 0xFEFEFEFE, 0x01010101, 0x01010101,
+               0x01010101, 0xFEFEFEFE, 0x01010101, 0x01010101,
+               0xFEFEFEFE, 0x01010101, 0xFEFEFEFE, 0x00000000,
+               0xFEFEFEFE, 0x01010101, 0xFEFEFEFE, 0x00000000,
+               0xFFFFFFFF, 0x00000000, 0xFFFFFFFF, 0x00000000,
+               0xFFFFFFFF, 0x00000000, 0xFFFFFFFF, 0x00000000,
+               0xFFFFFFFF, 0x00000000, 0xFFFFFFFF, 0x01010101,
+               0xFFFFFFFF, 0x00000000, 0xFFFFFFFF, 0x01010101,
+               0x00000000, 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF,
+               0x00000000, 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0x00000000, 0xFEFEFEFE,
+               0x00000000, 0x00000000, 0x00000000, 0xFEFEFEFE,
+               0xFEFEFEFE, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0xFEFEFEFE, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF,
+               0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000,
+               0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000,
+               0x00000000, 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF,
+               0x00000000, 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF,
+               0xFEFEFEFE, 0x00000000, 0xFEFEFEFE, 0x00000000,
+               0xFEFEFEFE, 0x00000000, 0xFEFEFEFE, 0x00000000,
+               0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0x01010101,
+               0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0x01010101,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x01010101, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x01010101, 0x00000000,
+               0x01010101, 0xFFFFFFFF, 0xFEFEFEFE, 0xFEFEFEFE,
+               0x01010101, 0xFFFFFFFF, 0xFEFEFEFE, 0xFEFEFEFE
+       },
+       {
+               0x02020202, 0x00000000, 0x02020202, 0xFFFFFFFF,
+               0x02020202, 0x00000000, 0x02020202, 0xFFFFFFFF,
+               0xFDFDFDFD, 0xFDFDFDFD, 0x02020202, 0xFDFDFDFD,
+               0xFDFDFDFD, 0xFDFDFDFD, 0x02020202, 0xFDFDFDFD,
+               0x02020202, 0xFDFDFDFD, 0x02020202, 0x02020202,
+               0x02020202, 0xFDFDFDFD, 0x02020202, 0x02020202,
+               0xFDFDFDFD, 0x02020202, 0xFDFDFDFD, 0x00000000,
+               0xFDFDFDFD, 0x02020202, 0xFDFDFDFD, 0x00000000,
+               0xFFFFFFFF, 0x00000000, 0xFFFFFFFF, 0x00000000,
+               0xFFFFFFFF, 0x00000000, 0xFFFFFFFF, 0x00000000,
+               0xFFFFFFFF, 0x00000000, 0xFFFFFFFF, 0x02020202,
+               0xFFFFFFFF, 0x00000000, 0xFFFFFFFF, 0x02020202,
+               0x00000000, 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF,
+               0x00000000, 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0x00000000, 0xFDFDFDFD,
+               0x00000000, 0x00000000, 0x00000000, 0xFDFDFDFD,
+               0xFDFDFDFD, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0xFDFDFDFD, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF,
+               0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000,
+               0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000,
+               0x00000000, 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF,
+               0x00000000, 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF,
+               0xFDFDFDFD, 0x00000000, 0xFDFDFDFD, 0x00000000,
+               0xFDFDFDFD, 0x00000000, 0xFDFDFDFD, 0x00000000,
+               0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0x02020202,
+               0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0x02020202,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x02020202, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x02020202, 0x00000000,
+               0x02020202, 0xFFFFFFFF, 0xFDFDFDFD, 0xFDFDFDFD,
+               0x02020202, 0xFFFFFFFF, 0xFDFDFDFD, 0xFDFDFDFD
+       },
+       {
+               0x04040404, 0x00000000, 0x04040404, 0xFFFFFFFF,
+               0x04040404, 0x00000000, 0x04040404, 0xFFFFFFFF,
+               0xFBFBFBFB, 0xFBFBFBFB, 0x04040404, 0xFBFBFBFB,
+               0xFBFBFBFB, 0xFBFBFBFB, 0x04040404, 0xFBFBFBFB,
+               0x04040404, 0xFBFBFBFB, 0x04040404, 0x04040404,
+               0x04040404, 0xFBFBFBFB, 0x04040404, 0x04040404,
+               0xFBFBFBFB, 0x04040404, 0xFBFBFBFB, 0x00000000,
+               0xFBFBFBFB, 0x04040404, 0xFBFBFBFB, 0x00000000,
+               0xFFFFFFFF, 0x00000000, 0xFFFFFFFF, 0x00000000,
+               0xFFFFFFFF, 0x00000000, 0xFFFFFFFF, 0x00000000,
+               0xFFFFFFFF, 0x00000000, 0xFFFFFFFF, 0x04040404,
+               0xFFFFFFFF, 0x00000000, 0xFFFFFFFF, 0x04040404,
+               0x00000000, 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF,
+               0x00000000, 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0x00000000, 0xFBFBFBFB,
+               0x00000000, 0x00000000, 0x00000000, 0xFBFBFBFB,
+               0xFBFBFBFB, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0xFBFBFBFB, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF,
+               0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000,
+               0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000,
+               0x00000000, 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF,
+               0x00000000, 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF,
+               0xFBFBFBFB, 0x00000000, 0xFBFBFBFB, 0x00000000,
+               0xFBFBFBFB, 0x00000000, 0xFBFBFBFB, 0x00000000,
+               0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0x04040404,
+               0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0x04040404,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x04040404, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x04040404, 0x00000000,
+               0x04040404, 0xFFFFFFFF, 0xFBFBFBFB, 0xFBFBFBFB,
+               0x04040404, 0xFFFFFFFF, 0xFBFBFBFB, 0xFBFBFBFB
+       },
+       {
+               0x08080808, 0x00000000, 0x08080808, 0xFFFFFFFF,
+               0x08080808, 0x00000000, 0x08080808, 0xFFFFFFFF,
+               0xF7F7F7F7, 0xF7F7F7F7, 0x08080808, 0xF7F7F7F7,
+               0xF7F7F7F7, 0xF7F7F7F7, 0x08080808, 0xF7F7F7F7,
+               0x08080808, 0xF7F7F7F7, 0x08080808, 0x08080808,
+               0x08080808, 0xF7F7F7F7, 0x08080808, 0x08080808,
+               0xF7F7F7F7, 0x08080808, 0xF7F7F7F7, 0x00000000,
+               0xF7F7F7F7, 0x08080808, 0xF7F7F7F7, 0x00000000,
+               0xFFFFFFFF, 0x00000000, 0xFFFFFFFF, 0x00000000,
+               0xFFFFFFFF, 0x00000000, 0xFFFFFFFF, 0x00000000,
+               0xFFFFFFFF, 0x00000000, 0xFFFFFFFF, 0x08080808,
+               0xFFFFFFFF, 0x00000000, 0xFFFFFFFF, 0x08080808,
+               0x00000000, 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF,
+               0x00000000, 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0x00000000, 0xF7F7F7F7,
+               0x00000000, 0x00000000, 0x00000000, 0xF7F7F7F7,
+               0xF7F7F7F7, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0xF7F7F7F7, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF,
+               0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000,
+               0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000,
+               0x00000000, 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF,
+               0x00000000, 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF,
+               0xF7F7F7F7, 0x00000000, 0xF7F7F7F7, 0x00000000,
+               0xF7F7F7F7, 0x00000000, 0xF7F7F7F7, 0x00000000,
+               0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0x08080808,
+               0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0x08080808,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x08080808, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x08080808, 0x00000000,
+               0x08080808, 0xFFFFFFFF, 0xF7F7F7F7, 0xF7F7F7F7,
+               0x08080808, 0xFFFFFFFF, 0xF7F7F7F7, 0xF7F7F7F7
+       },
+       {
+               0x10101010, 0x00000000, 0x10101010, 0xFFFFFFFF,
+               0x10101010, 0x00000000, 0x10101010, 0xFFFFFFFF,
+               0xEFEFEFEF, 0xEFEFEFEF, 0x10101010, 0xEFEFEFEF,
+               0xEFEFEFEF, 0xEFEFEFEF, 0x10101010, 0xEFEFEFEF,
+               0x10101010, 0xEFEFEFEF, 0x10101010, 0x10101010,
+               0x10101010, 0xEFEFEFEF, 0x10101010, 0x10101010,
+               0xEFEFEFEF, 0x10101010, 0xEFEFEFEF, 0x00000000,
+               0xEFEFEFEF, 0x10101010, 0xEFEFEFEF, 0x00000000,
+               0xFFFFFFFF, 0x00000000, 0xFFFFFFFF, 0x00000000,
+               0xFFFFFFFF, 0x00000000, 0xFFFFFFFF, 0x00000000,
+               0xFFFFFFFF, 0x00000000, 0xFFFFFFFF, 0x10101010,
+               0xFFFFFFFF, 0x00000000, 0xFFFFFFFF, 0x10101010,
+               0x00000000, 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF,
+               0x00000000, 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0x00000000, 0xEFEFEFEF,
+               0x00000000, 0x00000000, 0x00000000, 0xEFEFEFEF,
+               0xEFEFEFEF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0xEFEFEFEF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF,
+               0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000,
+               0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000,
+               0x00000000, 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF,
+               0x00000000, 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF,
+               0xEFEFEFEF, 0x00000000, 0xEFEFEFEF, 0x00000000,
+               0xEFEFEFEF, 0x00000000, 0xEFEFEFEF, 0x00000000,
+               0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0x10101010,
+               0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0x10101010,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x10101010, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x10101010, 0x00000000,
+               0x10101010, 0xFFFFFFFF, 0xEFEFEFEF, 0xEFEFEFEF,
+               0x10101010, 0xFFFFFFFF, 0xEFEFEFEF, 0xEFEFEFEF
+       },
+       {
+               0x20202020, 0x00000000, 0x20202020, 0xFFFFFFFF,
+               0x20202020, 0x00000000, 0x20202020, 0xFFFFFFFF,
+               0xDFDFDFDF, 0xDFDFDFDF, 0x20202020, 0xDFDFDFDF,
+               0xDFDFDFDF, 0xDFDFDFDF, 0x20202020, 0xDFDFDFDF,
+               0x20202020, 0xDFDFDFDF, 0x20202020, 0x20202020,
+               0x20202020, 0xDFDFDFDF, 0x20202020, 0x20202020,
+               0xDFDFDFDF, 0x20202020, 0xDFDFDFDF, 0x00000000,
+               0xDFDFDFDF, 0x20202020, 0xDFDFDFDF, 0x00000000,
+               0xFFFFFFFF, 0x00000000, 0xFFFFFFFF, 0x00000000,
+               0xFFFFFFFF, 0x00000000, 0xFFFFFFFF, 0x00000000,
+               0xFFFFFFFF, 0x00000000, 0xFFFFFFFF, 0x20202020,
+               0xFFFFFFFF, 0x00000000, 0xFFFFFFFF, 0x20202020,
+               0x00000000, 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF,
+               0x00000000, 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0x00000000, 0xDFDFDFDF,
+               0x00000000, 0x00000000, 0x00000000, 0xDFDFDFDF,
+               0xDFDFDFDF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0xDFDFDFDF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF,
+               0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000,
+               0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000,
+               0x00000000, 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF,
+               0x00000000, 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF,
+               0xDFDFDFDF, 0x00000000, 0xDFDFDFDF, 0x00000000,
+               0xDFDFDFDF, 0x00000000, 0xDFDFDFDF, 0x00000000,
+               0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0x20202020,
+               0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0x20202020,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x20202020, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x20202020, 0x00000000,
+               0x20202020, 0xFFFFFFFF, 0xDFDFDFDF, 0xDFDFDFDF,
+               0x20202020, 0xFFFFFFFF, 0xDFDFDFDF, 0xDFDFDFDF
+       },
+       {
+               0x40404040, 0x00000000, 0x40404040, 0xFFFFFFFF,
+               0x40404040, 0x00000000, 0x40404040, 0xFFFFFFFF,
+               0xBFBFBFBF, 0xBFBFBFBF, 0x40404040, 0xBFBFBFBF,
+               0xBFBFBFBF, 0xBFBFBFBF, 0x40404040, 0xBFBFBFBF,
+               0x40404040, 0xBFBFBFBF, 0x40404040, 0x40404040,
+               0x40404040, 0xBFBFBFBF, 0x40404040, 0x40404040,
+               0xBFBFBFBF, 0x40404040, 0xBFBFBFBF, 0x00000000,
+               0xBFBFBFBF, 0x40404040, 0xBFBFBFBF, 0x00000000,
+               0xFFFFFFFF, 0x00000000, 0xFFFFFFFF, 0x00000000,
+               0xFFFFFFFF, 0x00000000, 0xFFFFFFFF, 0x00000000,
+               0xFFFFFFFF, 0x00000000, 0xFFFFFFFF, 0x40404040,
+               0xFFFFFFFF, 0x00000000, 0xFFFFFFFF, 0x40404040,
+               0x00000000, 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF,
+               0x00000000, 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0x00000000, 0xBFBFBFBF,
+               0x00000000, 0x00000000, 0x00000000, 0xBFBFBFBF,
+               0xBFBFBFBF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0xBFBFBFBF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF,
+               0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000,
+               0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000,
+               0x00000000, 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF,
+               0x00000000, 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF,
+               0xBFBFBFBF, 0x00000000, 0xBFBFBFBF, 0x00000000,
+               0xBFBFBFBF, 0x00000000, 0xBFBFBFBF, 0x00000000,
+               0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0x40404040,
+               0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0x40404040,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x40404040, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x40404040, 0x00000000,
+               0x40404040, 0xFFFFFFFF, 0xBFBFBFBF, 0xBFBFBFBF,
+               0x40404040, 0xFFFFFFFF, 0xBFBFBFBF, 0xBFBFBFBF
+       },
+       {
+               0x80808080, 0x00000000, 0x80808080, 0xFFFFFFFF,
+               0x80808080, 0x00000000, 0x80808080, 0xFFFFFFFF,
+               0x7F7F7F7F, 0x7F7F7F7F, 0x80808080, 0x7F7F7F7F,
+               0x7F7F7F7F, 0x7F7F7F7F, 0x80808080, 0x7F7F7F7F,
+               0x80808080, 0x7F7F7F7F, 0x80808080, 0x80808080,
+               0x80808080, 0x7F7F7F7F, 0x80808080, 0x80808080,
+               0x7F7F7F7F, 0x80808080, 0x7F7F7F7F, 0x00000000,
+               0x7F7F7F7F, 0x80808080, 0x7F7F7F7F, 0x00000000,
+               0xFFFFFFFF, 0x00000000, 0xFFFFFFFF, 0x00000000,
+               0xFFFFFFFF, 0x00000000, 0xFFFFFFFF, 0x00000000,
+               0xFFFFFFFF, 0x00000000, 0xFFFFFFFF, 0x80808080,
+               0xFFFFFFFF, 0x00000000, 0xFFFFFFFF, 0x80808080,
+               0x00000000, 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF,
+               0x00000000, 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0x00000000, 0x7F7F7F7F,
+               0x00000000, 0x00000000, 0x00000000, 0x7F7F7F7F,
+               0x7F7F7F7F, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0x7F7F7F7F, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF,
+               0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000,
+               0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000,
+               0x00000000, 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF,
+               0x00000000, 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF,
+               0x7F7F7F7F, 0x00000000, 0x7F7F7F7F, 0x00000000,
+               0x7F7F7F7F, 0x00000000, 0x7F7F7F7F, 0x00000000,
+               0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0x80808080,
+               0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0x80808080,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x80808080, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x80808080, 0x00000000,
+               0x80808080, 0xFFFFFFFF, 0x7F7F7F7F, 0x7F7F7F7F,
+               0x80808080, 0xFFFFFFFF, 0x7F7F7F7F, 0x7F7F7F7F
+       }
+};
+
+u32 killer_pattern_64b[DQ_NUM][LEN_KILLER_PATTERN] __aligned(32) = {
+       {
+               0x01010101, 0x01010101, 0x00000000, 0x00000000,
+               0x01010101, 0x01010101, 0xFFFFFFFF, 0xFFFFFFFF,
+               0xFEFEFEFE, 0xFEFEFEFE, 0xFEFEFEFE, 0xFEFEFEFE,
+               0x01010101, 0x01010101, 0xFEFEFEFE, 0xFEFEFEFE,
+               0x01010101, 0x01010101, 0xFEFEFEFE, 0xFEFEFEFE,
+               0x01010101, 0x01010101, 0x01010101, 0x01010101,
+               0xFEFEFEFE, 0xFEFEFEFE, 0x01010101, 0x01010101,
+               0xFEFEFEFE, 0xFEFEFEFE, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x01010101, 0x01010101,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0x00000000, 0x00000000,
+               0x00000000, 0x00000000, 0xFEFEFEFE, 0xFEFEFEFE,
+               0xFEFEFEFE, 0xFEFEFEFE, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0xFEFEFEFE, 0xFEFEFEFE, 0x00000000, 0x00000000,
+               0xFEFEFEFE, 0xFEFEFEFE, 0x00000000, 0x00000000,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x01010101, 0x01010101,
+               0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x01010101, 0x01010101, 0x00000000, 0x00000000,
+               0x01010101, 0x01010101, 0xFFFFFFFF, 0xFFFFFFFF,
+               0xFEFEFEFE, 0xFEFEFEFE, 0xFEFEFEFE, 0xFEFEFEFE
+       },
+       {
+               0x02020202, 0x02020202, 0x00000000, 0x00000000,
+               0x02020202, 0x02020202, 0xFFFFFFFF, 0xFFFFFFFF,
+               0xFDFDFDFD, 0xFDFDFDFD, 0xFDFDFDFD, 0xFDFDFDFD,
+               0x02020202, 0x02020202, 0xFDFDFDFD, 0xFDFDFDFD,
+               0x02020202, 0x02020202, 0xFDFDFDFD, 0xFDFDFDFD,
+               0x02020202, 0x02020202, 0x02020202, 0x02020202,
+               0xFDFDFDFD, 0xFDFDFDFD, 0x02020202, 0x02020202,
+               0xFDFDFDFD, 0xFDFDFDFD, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x02020202, 0x02020202,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0x00000000, 0x00000000,
+               0x00000000, 0x00000000, 0xFDFDFDFD, 0xFDFDFDFD,
+               0xFDFDFDFD, 0xFDFDFDFD, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0xFDFDFDFD, 0xFDFDFDFD, 0x00000000, 0x00000000,
+               0xFDFDFDFD, 0xFDFDFDFD, 0x00000000, 0x00000000,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x02020202, 0x02020202,
+               0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x02020202, 0x02020202, 0x00000000, 0x00000000,
+               0x02020202, 0x02020202, 0xFFFFFFFF, 0xFFFFFFFF,
+               0xFDFDFDFD, 0xFDFDFDFD, 0xFDFDFDFD, 0xFDFDFDFD
+       },
+       {
+               0x04040404, 0x04040404, 0x00000000, 0x00000000,
+               0x04040404, 0x04040404, 0xFFFFFFFF, 0xFFFFFFFF,
+               0xFBFBFBFB, 0xFBFBFBFB, 0xFBFBFBFB, 0xFBFBFBFB,
+               0x04040404, 0x04040404, 0xFBFBFBFB, 0xFBFBFBFB,
+               0x04040404, 0x04040404, 0xFBFBFBFB, 0xFBFBFBFB,
+               0x04040404, 0x04040404, 0x04040404, 0x04040404,
+               0xFBFBFBFB, 0xFBFBFBFB, 0x04040404, 0x04040404,
+               0xFBFBFBFB, 0xFBFBFBFB, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x04040404, 0x04040404,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0x00000000, 0x00000000,
+               0x00000000, 0x00000000, 0xFBFBFBFB, 0xFBFBFBFB,
+               0xFBFBFBFB, 0xFBFBFBFB, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0xFBFBFBFB, 0xFBFBFBFB, 0x00000000, 0x00000000,
+               0xFBFBFBFB, 0xFBFBFBFB, 0x00000000, 0x00000000,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x04040404, 0x04040404,
+               0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x04040404, 0x04040404, 0x00000000, 0x00000000,
+               0x04040404, 0x04040404, 0xFFFFFFFF, 0xFFFFFFFF,
+               0xFBFBFBFB, 0xFBFBFBFB, 0xFBFBFBFB, 0xFBFBFBFB
+       },
+       {
+               0x08080808, 0x08080808, 0x00000000, 0x00000000,
+               0x08080808, 0x08080808, 0xFFFFFFFF, 0xFFFFFFFF,
+               0xF7F7F7F7, 0xF7F7F7F7, 0xF7F7F7F7, 0xF7F7F7F7,
+               0x08080808, 0x08080808, 0xF7F7F7F7, 0xF7F7F7F7,
+               0x08080808, 0x08080808, 0xF7F7F7F7, 0xF7F7F7F7,
+               0x08080808, 0x08080808, 0x08080808, 0x08080808,
+               0xF7F7F7F7, 0xF7F7F7F7, 0x08080808, 0x08080808,
+               0xF7F7F7F7, 0xF7F7F7F7, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x08080808, 0x08080808,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0x00000000, 0x00000000,
+               0x00000000, 0x00000000, 0xF7F7F7F7, 0xF7F7F7F7,
+               0xF7F7F7F7, 0xF7F7F7F7, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0xF7F7F7F7, 0xF7F7F7F7, 0x00000000, 0x00000000,
+               0xF7F7F7F7, 0xF7F7F7F7, 0x00000000, 0x00000000,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x08080808, 0x08080808,
+               0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x08080808, 0x08080808, 0x00000000, 0x00000000,
+               0x08080808, 0x08080808, 0xFFFFFFFF, 0xFFFFFFFF,
+               0xF7F7F7F7, 0xF7F7F7F7, 0xF7F7F7F7, 0xF7F7F7F7
+       },
+       {
+               0x10101010, 0x10101010, 0x00000000, 0x00000000,
+               0x10101010, 0x10101010, 0xFFFFFFFF, 0xFFFFFFFF,
+               0xEFEFEFEF, 0xEFEFEFEF, 0xEFEFEFEF, 0xEFEFEFEF,
+               0x10101010, 0x10101010, 0xEFEFEFEF, 0xEFEFEFEF,
+               0x10101010, 0x10101010, 0xEFEFEFEF, 0xEFEFEFEF,
+               0x10101010, 0x10101010, 0x10101010, 0x10101010,
+               0xEFEFEFEF, 0xEFEFEFEF, 0x10101010, 0x10101010,
+               0xEFEFEFEF, 0xEFEFEFEF, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x10101010, 0x10101010,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0x00000000, 0x00000000,
+               0x00000000, 0x00000000, 0xEFEFEFEF, 0xEFEFEFEF,
+               0xEFEFEFEF, 0xEFEFEFEF, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0xEFEFEFEF, 0xEFEFEFEF, 0x00000000, 0x00000000,
+               0xEFEFEFEF, 0xEFEFEFEF, 0x00000000, 0x00000000,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x10101010, 0x10101010,
+               0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x10101010, 0x10101010, 0x00000000, 0x00000000,
+               0x10101010, 0x10101010, 0xFFFFFFFF, 0xFFFFFFFF,
+               0xEFEFEFEF, 0xEFEFEFEF, 0xEFEFEFEF, 0xEFEFEFEF
+       },
+       {
+               0x20202020, 0x20202020, 0x00000000, 0x00000000,
+               0x20202020, 0x20202020, 0xFFFFFFFF, 0xFFFFFFFF,
+               0xDFDFDFDF, 0xDFDFDFDF, 0xDFDFDFDF, 0xDFDFDFDF,
+               0x20202020, 0x20202020, 0xDFDFDFDF, 0xDFDFDFDF,
+               0x20202020, 0x20202020, 0xDFDFDFDF, 0xDFDFDFDF,
+               0x20202020, 0x20202020, 0x20202020, 0x20202020,
+               0xDFDFDFDF, 0xDFDFDFDF, 0x20202020, 0x20202020,
+               0xDFDFDFDF, 0xDFDFDFDF, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x20202020, 0x20202020,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0x00000000, 0x00000000,
+               0x00000000, 0x00000000, 0xDFDFDFDF, 0xDFDFDFDF,
+               0xDFDFDFDF, 0xDFDFDFDF, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0xDFDFDFDF, 0xDFDFDFDF, 0x00000000, 0x00000000,
+               0xDFDFDFDF, 0xDFDFDFDF, 0x00000000, 0x00000000,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x20202020, 0x20202020,
+               0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x20202020, 0x20202020, 0x00000000, 0x00000000,
+               0x20202020, 0x20202020, 0xFFFFFFFF, 0xFFFFFFFF,
+               0xDFDFDFDF, 0xDFDFDFDF, 0xDFDFDFDF, 0xDFDFDFDF
+       },
+       {
+               0x40404040, 0x40404040, 0x00000000, 0x00000000,
+               0x40404040, 0x40404040, 0xFFFFFFFF, 0xFFFFFFFF,
+               0xBFBFBFBF, 0xBFBFBFBF, 0xBFBFBFBF, 0xBFBFBFBF,
+               0x40404040, 0x40404040, 0xBFBFBFBF, 0xBFBFBFBF,
+               0x40404040, 0x40404040, 0xBFBFBFBF, 0xBFBFBFBF,
+               0x40404040, 0x40404040, 0x40404040, 0x40404040,
+               0xBFBFBFBF, 0xBFBFBFBF, 0x40404040, 0x40404040,
+               0xBFBFBFBF, 0xBFBFBFBF, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x40404040, 0x40404040,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0x00000000, 0x00000000,
+               0x00000000, 0x00000000, 0xBFBFBFBF, 0xBFBFBFBF,
+               0xBFBFBFBF, 0xBFBFBFBF, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0xBFBFBFBF, 0xBFBFBFBF, 0x00000000, 0x00000000,
+               0xBFBFBFBF, 0xBFBFBFBF, 0x00000000, 0x00000000,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x40404040, 0x40404040,
+               0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x40404040, 0x40404040, 0x00000000, 0x00000000,
+               0x40404040, 0x40404040, 0xFFFFFFFF, 0xFFFFFFFF,
+               0xBFBFBFBF, 0xBFBFBFBF, 0xBFBFBFBF, 0xBFBFBFBF
+       },
+       {
+               0x80808080, 0x80808080, 0x00000000, 0x00000000,
+               0x80808080, 0x80808080, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x7F7F7F7F, 0x7F7F7F7F, 0x7F7F7F7F, 0x7F7F7F7F,
+               0x80808080, 0x80808080, 0x7F7F7F7F, 0x7F7F7F7F,
+               0x80808080, 0x80808080, 0x7F7F7F7F, 0x7F7F7F7F,
+               0x80808080, 0x80808080, 0x80808080, 0x80808080,
+               0x7F7F7F7F, 0x7F7F7F7F, 0x80808080, 0x80808080,
+               0x7F7F7F7F, 0x7F7F7F7F, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x80808080, 0x80808080,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0x00000000, 0x00000000,
+               0x00000000, 0x00000000, 0x7F7F7F7F, 0x7F7F7F7F,
+               0x7F7F7F7F, 0x7F7F7F7F, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x7F7F7F7F, 0x7F7F7F7F, 0x00000000, 0x00000000,
+               0x7F7F7F7F, 0x7F7F7F7F, 0x00000000, 0x00000000,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x80808080, 0x80808080,
+               0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x80808080, 0x80808080, 0x00000000, 0x00000000,
+               0x80808080, 0x80808080, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x7F7F7F7F, 0x7F7F7F7F, 0x7F7F7F7F, 0x7F7F7F7F
+       }
+};
+
+u32 special_pattern[DQ_NUM][LEN_SPECIAL_PATTERN] __aligned(32) = {
+       {
+               0x00000000, 0x00000000, 0x01010101, 0x01010101,
+               0xFFFFFFFF, 0xFFFFFFFF, 0xFEFEFEFE, 0xFEFEFEFE,
+               0xFEFEFEFE, 0xFEFEFEFE, 0x01010101, 0x01010101,
+               0xFEFEFEFE, 0xFEFEFEFE, 0x01010101, 0x01010101,
+               0xFEFEFEFE, 0xFEFEFEFE, 0x01010101, 0x01010101,
+               0x01010101, 0x01010101, 0xFEFEFEFE, 0xFEFEFEFE,
+               0x01010101, 0x01010101, 0xFEFEFEFE, 0xFEFEFEFE,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x01010101, 0x01010101, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0x00000000, 0x00000000, 0x00000000, 0x00000000,
+               0xFEFEFEFE, 0xFEFEFEFE, 0xFEFEFEFE, 0xFEFEFEFE,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0xFEFEFEFE, 0xFEFEFEFE,
+               0x00000000, 0x00000000, 0xFEFEFEFE, 0xFEFEFEFE,
+               0x00000000, 0x00000000, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x01010101, 0x01010101, 0xFFFFFFFF, 0xFFFFFFFF,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x01010101, 0x01010101,
+               0x00000000, 0x00000000, 0x01010101, 0x01010101,
+               0xFFFFFFFF, 0xFFFFFFFF, 0xFEFEFEFE, 0xFEFEFEFE,
+               0xFEFEFEFE, 0xFEFEFEFE, 0x00000000, 0x00000000
+       },
+       {
+               0x00000000, 0x00000000, 0x02020202, 0x02020202,
+               0xFFFFFFFF, 0xFFFFFFFF, 0xFDFDFDFD, 0xFDFDFDFD,
+               0xFDFDFDFD, 0xFDFDFDFD, 0x02020202, 0x02020202,
+               0xFDFDFDFD, 0xFDFDFDFD, 0x02020202, 0x02020202,
+               0xFDFDFDFD, 0xFDFDFDFD, 0x02020202, 0x02020202,
+               0x02020202, 0x02020202, 0xFDFDFDFD, 0xFDFDFDFD,
+               0x02020202, 0x02020202, 0xFDFDFDFD, 0xFDFDFDFD,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x02020202, 0x02020202, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0x00000000, 0x00000000, 0x00000000, 0x00000000,
+               0xFDFDFDFD, 0xFDFDFDFD, 0xFDFDFDFD, 0xFDFDFDFD,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0xFDFDFDFD, 0xFDFDFDFD,
+               0x00000000, 0x00000000, 0xFDFDFDFD, 0xFDFDFDFD,
+               0x00000000, 0x00000000, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x02020202, 0x02020202, 0xFFFFFFFF, 0xFFFFFFFF,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x02020202, 0x02020202,
+               0x00000000, 0x00000000, 0x02020202, 0x02020202,
+               0xFFFFFFFF, 0xFFFFFFFF, 0xFDFDFDFD, 0xFDFDFDFD,
+               0xFDFDFDFD, 0xFDFDFDFD, 0x00000000, 0x00000000
+       },
+       {
+               0x00000000, 0x00000000, 0x04040404, 0x04040404,
+               0xFFFFFFFF, 0xFFFFFFFF, 0xFBFBFBFB, 0xFBFBFBFB,
+               0xFBFBFBFB, 0xFBFBFBFB, 0x04040404, 0x04040404,
+               0xFBFBFBFB, 0xFBFBFBFB, 0x04040404, 0x04040404,
+               0xFBFBFBFB, 0xFBFBFBFB, 0x04040404, 0x04040404,
+               0x04040404, 0x04040404, 0xFBFBFBFB, 0xFBFBFBFB,
+               0x04040404, 0x04040404, 0xFBFBFBFB, 0xFBFBFBFB,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x04040404, 0x04040404, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0x00000000, 0x00000000, 0x00000000, 0x00000000,
+               0xFBFBFBFB, 0xFBFBFBFB, 0xFBFBFBFB, 0xFBFBFBFB,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0xFBFBFBFB, 0xFBFBFBFB,
+               0x00000000, 0x00000000, 0xFBFBFBFB, 0xFBFBFBFB,
+               0x00000000, 0x00000000, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x04040404, 0x04040404, 0xFFFFFFFF, 0xFFFFFFFF,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x04040404, 0x04040404,
+               0x00000000, 0x00000000, 0x04040404, 0x04040404,
+               0xFFFFFFFF, 0xFFFFFFFF, 0xFBFBFBFB, 0xFBFBFBFB,
+               0xFBFBFBFB, 0xFBFBFBFB, 0x00000000, 0x00000000
+       },
+       {
+               0x00000000, 0x00000000, 0x08080808, 0x08080808,
+               0xFFFFFFFF, 0xFFFFFFFF, 0xF7F7F7F7, 0xF7F7F7F7,
+               0xF7F7F7F7, 0xF7F7F7F7, 0x08080808, 0x08080808,
+               0xF7F7F7F7, 0xF7F7F7F7, 0x08080808, 0x08080808,
+               0xF7F7F7F7, 0xF7F7F7F7, 0x08080808, 0x08080808,
+               0x08080808, 0x08080808, 0xF7F7F7F7, 0xF7F7F7F7,
+               0x08080808, 0x08080808, 0xF7F7F7F7, 0xF7F7F7F7,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x08080808, 0x08080808, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0x00000000, 0x00000000, 0x00000000, 0x00000000,
+               0xF7F7F7F7, 0xF7F7F7F7, 0xF7F7F7F7, 0xF7F7F7F7,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0xF7F7F7F7, 0xF7F7F7F7,
+               0x00000000, 0x00000000, 0xF7F7F7F7, 0xF7F7F7F7,
+               0x00000000, 0x00000000, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x08080808, 0x08080808, 0xFFFFFFFF, 0xFFFFFFFF,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x08080808, 0x08080808,
+               0x00000000, 0x00000000, 0x08080808, 0x08080808,
+               0xFFFFFFFF, 0xFFFFFFFF, 0xF7F7F7F7, 0xF7F7F7F7,
+               0xF7F7F7F7, 0xF7F7F7F7, 0x00000000, 0x00000000
+       },
+       {
+               0x00000000, 0x00000000, 0x10101010, 0x10101010,
+               0xFFFFFFFF, 0xFFFFFFFF, 0xEFEFEFEF, 0xEFEFEFEF,
+               0xEFEFEFEF, 0xEFEFEFEF, 0x10101010, 0x10101010,
+               0xEFEFEFEF, 0xEFEFEFEF, 0x10101010, 0x10101010,
+               0xEFEFEFEF, 0xEFEFEFEF, 0x10101010, 0x10101010,
+               0x10101010, 0x10101010, 0xEFEFEFEF, 0xEFEFEFEF,
+               0x10101010, 0x10101010, 0xEFEFEFEF, 0xEFEFEFEF,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x10101010, 0x10101010, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0x00000000, 0x00000000, 0x00000000, 0x00000000,
+               0xEFEFEFEF, 0xEFEFEFEF, 0xEFEFEFEF, 0xEFEFEFEF,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0xEFEFEFEF, 0xEFEFEFEF,
+               0x00000000, 0x00000000, 0xEFEFEFEF, 0xEFEFEFEF,
+               0x00000000, 0x00000000, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x10101010, 0x10101010, 0xFFFFFFFF, 0xFFFFFFFF,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x10101010, 0x10101010,
+               0x00000000, 0x00000000, 0x10101010, 0x10101010,
+               0xFFFFFFFF, 0xFFFFFFFF, 0xEFEFEFEF, 0xEFEFEFEF,
+               0xEFEFEFEF, 0xEFEFEFEF, 0x00000000, 0x00000000
+       },
+       {
+               0x00000000, 0x00000000, 0x20202020, 0x20202020,
+               0xFFFFFFFF, 0xFFFFFFFF, 0xDFDFDFDF, 0xDFDFDFDF,
+               0xDFDFDFDF, 0xDFDFDFDF, 0x20202020, 0x20202020,
+               0xDFDFDFDF, 0xDFDFDFDF, 0x20202020, 0x20202020,
+               0xDFDFDFDF, 0xDFDFDFDF, 0x20202020, 0x20202020,
+               0x20202020, 0x20202020, 0xDFDFDFDF, 0xDFDFDFDF,
+               0x20202020, 0x20202020, 0xDFDFDFDF, 0xDFDFDFDF,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x20202020, 0x20202020, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0x00000000, 0x00000000, 0x00000000, 0x00000000,
+               0xDFDFDFDF, 0xDFDFDFDF, 0xDFDFDFDF, 0xDFDFDFDF,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0xDFDFDFDF, 0xDFDFDFDF,
+               0x00000000, 0x00000000, 0xDFDFDFDF, 0xDFDFDFDF,
+               0x00000000, 0x00000000, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x20202020, 0x20202020, 0xFFFFFFFF, 0xFFFFFFFF,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x20202020, 0x20202020,
+               0x00000000, 0x00000000, 0x20202020, 0x20202020,
+               0xFFFFFFFF, 0xFFFFFFFF, 0xDFDFDFDF, 0xDFDFDFDF,
+               0xDFDFDFDF, 0xDFDFDFDF, 0x00000000, 0x00000000
+       },
+       {
+               0x00000000, 0x00000000, 0x40404040, 0x40404040,
+               0xFFFFFFFF, 0xFFFFFFFF, 0xBFBFBFBF, 0xBFBFBFBF,
+               0xBFBFBFBF, 0xBFBFBFBF, 0x40404040, 0x40404040,
+               0xBFBFBFBF, 0xBFBFBFBF, 0x40404040, 0x40404040,
+               0xBFBFBFBF, 0xBFBFBFBF, 0x40404040, 0x40404040,
+               0x40404040, 0x40404040, 0xBFBFBFBF, 0xBFBFBFBF,
+               0x40404040, 0x40404040, 0xBFBFBFBF, 0xBFBFBFBF,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x40404040, 0x40404040, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0x00000000, 0x00000000, 0x00000000, 0x00000000,
+               0xBFBFBFBF, 0xBFBFBFBF, 0xBFBFBFBF, 0xBFBFBFBF,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0xBFBFBFBF, 0xBFBFBFBF,
+               0x00000000, 0x00000000, 0xBFBFBFBF, 0xBFBFBFBF,
+               0x00000000, 0x00000000, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x40404040, 0x40404040, 0xFFFFFFFF, 0xFFFFFFFF,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x40404040, 0x40404040,
+               0x00000000, 0x00000000, 0x40404040, 0x40404040,
+               0xFFFFFFFF, 0xFFFFFFFF, 0xBFBFBFBF, 0xBFBFBFBF,
+               0xBFBFBFBF, 0xBFBFBFBF, 0x00000000, 0x00000000
+       },
+       {
+               0x00000000, 0x00000000, 0x80808080, 0x80808080,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x7F7F7F7F, 0x7F7F7F7F,
+               0x7F7F7F7F, 0x7F7F7F7F, 0x80808080, 0x80808080,
+               0x7F7F7F7F, 0x7F7F7F7F, 0x80808080, 0x80808080,
+               0x7F7F7F7F, 0x7F7F7F7F, 0x80808080, 0x80808080,
+               0x80808080, 0x80808080, 0x7F7F7F7F, 0x7F7F7F7F,
+               0x80808080, 0x80808080, 0x7F7F7F7F, 0x7F7F7F7F,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x80808080, 0x80808080, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0x00000000, 0x00000000, 0x00000000, 0x00000000,
+               0x7F7F7F7F, 0x7F7F7F7F, 0x7F7F7F7F, 0x7F7F7F7F,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x00000000, 0x00000000, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x7F7F7F7F, 0x7F7F7F7F,
+               0x00000000, 0x00000000, 0x7F7F7F7F, 0x7F7F7F7F,
+               0x00000000, 0x00000000, 0x00000000, 0x00000000,
+               0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
+               0x80808080, 0x80808080, 0xFFFFFFFF, 0xFFFFFFFF,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x80808080, 0x80808080,
+               0x00000000, 0x00000000, 0x80808080, 0x80808080,
+               0xFFFFFFFF, 0xFFFFFFFF, 0x7F7F7F7F, 0x7F7F7F7F,
+               0x7F7F7F7F, 0x7F7F7F7F, 0x00000000, 0x00000000
+       }
+};
+
+/* Fabric ratios table */
+u32 fabric_ratio[FAB_OPT] = {
+       0x04010204,
+       0x04020202,
+       0x08020306,
+       0x08020303,
+       0x04020303,
+       0x04020204,
+       0x04010202,
+       0x08030606,
+       0x08030505,
+       0x04020306,
+       0x0804050A,
+       0x04030606,
+       0x04020404,
+       0x04030306,
+       0x04020505,
+       0x08020505,
+       0x04010303,
+       0x08050A0A,
+       0x04030408,
+       0x04010102,
+       0x08030306
+};
+
+u32 pbs_dq_mapping[PUP_NUM_64BIT + 1][DQ_NUM] = {
+       {3, 2, 5, 7, 1, 0, 6, 4},
+       {2, 3, 6, 7, 1, 0, 4, 5},
+       {1, 3, 5, 6, 0, 2, 4, 7},
+       {0, 2, 4, 7, 1, 3, 5, 6},
+       {3, 0, 4, 6, 1, 2, 5, 7},
+       {0, 3, 5, 7, 1, 2, 4, 6},
+       {2, 3, 5, 7, 1, 0, 4, 6},
+       {0, 2, 5, 4, 1, 3, 6, 7},
+       {2, 3, 4, 7, 0, 1, 5, 6}
+};
+
+#endif /* __DDR3_PATTERNS_64_H */
diff --git a/drivers/ddr/mvebu/ddr3_pbs.c b/drivers/ddr/mvebu/ddr3_pbs.c
new file mode 100644 (file)
index 0000000..00ea3fd
--- /dev/null
@@ -0,0 +1,1592 @@
+/*
+ * Copyright (C) Marvell International Ltd. and its affiliates
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#include <common.h>
+#include <i2c.h>
+#include <spl.h>
+#include <asm/io.h>
+#include <asm/arch/cpu.h>
+#include <asm/arch/soc.h>
+
+#include "ddr3_hw_training.h"
+
+/*
+ * Debug
+ */
+#define DEBUG_PBS_FULL_C(s, d, l) \
+       DEBUG_PBS_FULL_S(s); DEBUG_PBS_FULL_D(d, l); DEBUG_PBS_FULL_S("\n")
+#define DEBUG_PBS_C(s, d, l) \
+       DEBUG_PBS_S(s); DEBUG_PBS_D(d, l); DEBUG_PBS_S("\n")
+
+#ifdef MV_DEBUG_PBS
+#define DEBUG_PBS_S(s)                 puts(s)
+#define DEBUG_PBS_D(d, l)              printf("%x", d)
+#else
+#define DEBUG_PBS_S(s)
+#define DEBUG_PBS_D(d, l)
+#endif
+
+#ifdef MV_DEBUG_FULL_PBS
+#define DEBUG_PBS_FULL_S(s)            puts(s)
+#define DEBUG_PBS_FULL_D(d, l)         printf("%x", d)
+#else
+#define DEBUG_PBS_FULL_S(s)
+#define DEBUG_PBS_FULL_D(d, l)
+#endif
+
+#if defined(MV88F78X60) || defined(MV88F672X)
+
+/* Temp array for skew data storage */
+static u32 skew_array[(MAX_PUP_NUM) * DQ_NUM] = { 0 };
+
+/* PBS locked dq (per pup) */
+extern u32 pbs_locked_dq[MAX_PUP_NUM][DQ_NUM];
+extern u32 pbs_locked_dm[MAX_PUP_NUM];
+extern u32 pbs_locked_value[MAX_PUP_NUM][DQ_NUM];
+
+#if defined(MV88F672X)
+extern u32 pbs_pattern[2][LEN_16BIT_PBS_PATTERN];
+extern u32 pbs_pattern_32b[2][LEN_PBS_PATTERN];
+#else
+extern u32 pbs_pattern_32b[2][LEN_PBS_PATTERN];
+extern u32 pbs_pattern_64b[2][LEN_PBS_PATTERN];
+#endif
+
+extern u32 pbs_dq_mapping[PUP_NUM_64BIT + 1][DQ_NUM];
+
+static int ddr3_tx_shift_dqs_adll_step_before_fail(MV_DRAM_INFO *dram_info,
+               u32 cur_pup, u32 pbs_pattern_idx, u32 ecc);
+static int ddr3_rx_shift_dqs_to_first_fail(MV_DRAM_INFO *dram_info, u32 cur_pup,
+               u32 pbs_pattern_idx, u32 ecc);
+static int ddr3_pbs_per_bit(MV_DRAM_INFO *dram_info, int *start_over, int is_tx,
+               u32 *pcur_pup, u32 pbs_pattern_idx, u32 ecc);
+static int ddr3_set_pbs_results(MV_DRAM_INFO *dram_info, int is_tx);
+static void ddr3_pbs_write_pup_dqs_reg(u32 cs, u32 pup, u32 dqs_delay);
+
+/*
+ * Name:     ddr3_pbs_tx
+ * Desc:     Execute the PBS TX phase.
+ * Args:     dram_info   ddr3 training information struct
+ * Notes:
+ * Returns:  MV_OK if success, other error code if fail.
+ */
+int ddr3_pbs_tx(MV_DRAM_INFO *dram_info)
+{
+       /* Array of Deskew results */
+
+       /*
+        * Array to hold the total sum of skew from all iterations
+        * (for average purpose)
+        */
+       u32 skew_sum_array[MAX_PUP_NUM][DQ_NUM] = { {0} };
+
+       /*
+        * Array to hold the total average skew from both patterns
+        * (for average purpose)
+        */
+       u32 pattern_skew_array[MAX_PUP_NUM][DQ_NUM] = { {0} };
+
+       u32 pbs_rep_time = 0;   /* counts number of loop in case of fail */
+       /* bit array for unlock pups - used to repeat on the RX operation */
+       u32 cur_pup;
+       u32 max_pup;
+       u32 pbs_retry;
+       u32 pup, dq, pups, cur_max_pup, valid_pup, reg;
+       u32 pattern_idx;
+       u32 ecc;
+       /* indicates whether we need to start the loop again */
+       int start_over;
+
+       DEBUG_PBS_S("DDR3 - PBS TX - Starting PBS TX procedure\n");
+
+       pups = dram_info->num_of_total_pups;
+       max_pup = dram_info->num_of_total_pups;
+
+       /* Enable SW override */
+       reg = reg_read(REG_DRAM_TRAINING_2_ADDR) |
+               (1 << REG_DRAM_TRAINING_2_SW_OVRD_OFFS);
+       /* [0] = 1 - Enable SW override  */
+       /* 0x15B8 - Training SW 2 Register */
+       reg_write(REG_DRAM_TRAINING_2_ADDR, reg);
+       DEBUG_PBS_S("DDR3 - PBS RX - SW Override Enabled\n");
+
+       reg = 1 << REG_DRAM_TRAINING_AUTO_OFFS;
+       reg_write(REG_DRAM_TRAINING_ADDR, reg); /* 0x15B0 - Training Register */
+
+       /* Running twice for 2 different patterns. each patterns - 3 times */
+       for (pattern_idx = 0; pattern_idx < COUNT_PBS_PATTERN; pattern_idx++) {
+               DEBUG_PBS_C("DDR3 - PBS TX - Working with pattern - ",
+                           pattern_idx, 1);
+
+               /* Reset sum array */
+               for (pup = 0; pup < pups; pup++) {
+                       for (dq = 0; dq < DQ_NUM; dq++)
+                               skew_sum_array[pup][dq] = 0;
+               }
+
+               /*
+                * Perform PBS several of times (3 for each pattern).
+                * At the end, we'll use the average
+                */
+               /* If there is ECC, do each PBS again with mux change */
+               for (pbs_retry = 0; pbs_retry < COUNT_PBS_REPEAT; pbs_retry++) {
+                       for (ecc = 0; ecc < (dram_info->ecc_ena + 1); ecc++) {
+
+                               /*
+                                * This parameter stores the current PUP
+                                * num - ecc mode dependent - 4-8 / 1 pups
+                                */
+                               cur_max_pup = (1 - ecc) *
+                                       dram_info->num_of_std_pups + ecc;
+
+                               if (ecc) {
+                                       /* Only 1 pup in this case */
+                                       valid_pup = 0x1;
+                               } else if (cur_max_pup > 4) {
+                                       /* 64 bit - 8 pups */
+                                       valid_pup = 0xFF;
+                               } else if (cur_max_pup == 4) {
+                                       /* 32 bit - 4 pups */
+                                       valid_pup = 0xF;
+                               } else {
+                                       /* 16 bit - 2 pups */
+                                       valid_pup = 0x3;
+                               }
+
+                               /* ECC Support - Switch ECC Mux on ecc=1 */
+                               reg = reg_read(REG_DRAM_TRAINING_2_ADDR) &
+                                       ~(1 << REG_DRAM_TRAINING_2_ECC_MUX_OFFS);
+                               reg |= (dram_info->ecc_ena * ecc <<
+                                       REG_DRAM_TRAINING_2_ECC_MUX_OFFS);
+                               reg_write(REG_DRAM_TRAINING_2_ADDR, reg);
+
+                               if (ecc)
+                                       DEBUG_PBS_S("DDR3 - PBS Tx - ECC Mux Enabled\n");
+                               else
+                                       DEBUG_PBS_S("DDR3 - PBS Tx - ECC Mux Disabled\n");
+
+                               /* Init iteration values */
+                               /* Clear the locked DQs */
+                               for (pup = 0; pup < cur_max_pup; pup++) {
+                                       for (dq = 0; dq < DQ_NUM; dq++) {
+                                               pbs_locked_dq[
+                                                       pup + ecc *
+                                                       (max_pup - 1)][dq] =
+                                                       0;
+                                       }
+                               }
+
+                               pbs_rep_time = 0;
+                               cur_pup = valid_pup;
+                               start_over = 0;
+
+                               /*
+                                * Run loop On current Pattern and current
+                                * pattern iteration (just to cover the false
+                                * fail problem)
+                                */
+                               do {
+                                       DEBUG_PBS_S("DDR3 - PBS Tx - Pbs Rep Loop is ");
+                                       DEBUG_PBS_D(pbs_rep_time, 1);
+                                       DEBUG_PBS_S(", for Retry No.");
+                                       DEBUG_PBS_D(pbs_retry, 1);
+                                       DEBUG_PBS_S("\n");
+
+                                       /* Set all PBS values to MIN (0) */
+                                       DEBUG_PBS_S("DDR3 - PBS Tx - Set all PBS values to MIN\n");
+
+                                       for (dq = 0; dq < DQ_NUM; dq++) {
+                                               ddr3_write_pup_reg(
+                                                       PUP_PBS_TX +
+                                                       pbs_dq_mapping[pup *
+                                                               (1 - ecc) +
+                                                               ecc * ECC_PUP]
+                                                       [dq], CS0, (1 - ecc) *
+                                                       PUP_BC + ecc * ECC_PUP, 0,
+                                                       0);
+                                       }
+
+                                       /*
+                                        * Shift DQ ADLL right, One step before
+                                        * fail
+                                        */
+                                       DEBUG_PBS_S("DDR3 - PBS Tx - ADLL shift right one phase before fail\n");
+
+                                       if (MV_OK != ddr3_tx_shift_dqs_adll_step_before_fail
+                                           (dram_info, cur_pup, pattern_idx,
+                                            ecc))
+                                               return MV_DDR3_TRAINING_ERR_PBS_ADLL_SHR_1PHASE;
+
+                                       /* PBS For each bit */
+                                       DEBUG_PBS_S("DDR3 - PBS Tx - perform PBS for each bit\n");
+
+                                       /*
+                                        * In this stage - start_over = 0
+                                        */
+                                       if (MV_OK != ddr3_pbs_per_bit(
+                                                   dram_info, &start_over, 1,
+                                                   &cur_pup, pattern_idx, ecc))
+                                               return MV_DDR3_TRAINING_ERR_PBS_TX_PER_BIT;
+
+                               } while ((start_over == 1) &&
+                                        (++pbs_rep_time < COUNT_PBS_STARTOVER));
+
+                               if (pbs_rep_time == COUNT_PBS_STARTOVER &&
+                                   start_over == 1) {
+                                       DEBUG_PBS_S("DDR3 - PBS Tx - FAIL - Adll reach max value\n");
+                                       return MV_DDR3_TRAINING_ERR_PBS_TX_MAX_VAL;
+                               }
+
+                               DEBUG_PBS_FULL_C("DDR3 - PBS TX - values for iteration - ",
+                                                pbs_retry, 1);
+                               for (pup = 0; pup < cur_max_pup; pup++) {
+                                       /*
+                                        * To minimize delay elements, inc
+                                        * from pbs value the min pbs val
+                                        */
+                                       DEBUG_PBS_S("DDR3 - PBS - PUP");
+                                       DEBUG_PBS_D((pup + (ecc * ECC_PUP)), 1);
+                                       DEBUG_PBS_S(": ");
+
+                                       for (dq = 0; dq < DQ_NUM; dq++) {
+                                               /* Set skew value for all dq */
+                                               /*
+                                                * Bit# Deskew <- Bit# Deskew -
+                                                * last / first  failing bit
+                                                * Deskew For all bits (per PUP)
+                                                * (minimize delay elements)
+                                                */
+                                               DEBUG_PBS_S("DQ");
+                                               DEBUG_PBS_D(dq, 1);
+                                               DEBUG_PBS_S("-");
+                                               DEBUG_PBS_D(skew_array
+                                                           [((pup) * DQ_NUM) +
+                                                            dq], 2);
+                                               DEBUG_PBS_S(", ");
+                                       }
+                                       DEBUG_PBS_S("\n");
+                               }
+
+                               /*
+                                * Collect the results we got on this trial
+                                * of PBS
+                                */
+                               for (pup = 0; pup < cur_max_pup; pup++) {
+                                       for (dq = 0; dq < DQ_NUM; dq++) {
+                                               skew_sum_array[pup + (ecc * (max_pup - 1))]
+                                                       [dq] += skew_array
+                                                       [((pup) * DQ_NUM) + dq];
+                                       }
+                               }
+
+                               /* ECC Support - Disable ECC MUX */
+                               reg = reg_read(REG_DRAM_TRAINING_2_ADDR) &
+                                       ~(1 << REG_DRAM_TRAINING_2_ECC_MUX_OFFS);
+                               reg_write(REG_DRAM_TRAINING_2_ADDR, reg);
+                       }
+               }
+
+               DEBUG_PBS_C("DDR3 - PBS TX - values for current pattern - ",
+                           pattern_idx, 1);
+               for (pup = 0; pup < max_pup; pup++) {
+                       /*
+                        * To minimize delay elements, inc from pbs value the
+                        * min pbs val
+                        */
+                       DEBUG_PBS_S("DDR3 - PBS - PUP");
+                       DEBUG_PBS_D(pup, 1);
+                       DEBUG_PBS_S(": ");
+
+                       for (dq = 0; dq < DQ_NUM; dq++) {
+                               /* set skew value for all dq */
+                               /* Bit# Deskew <- Bit# Deskew - last / first  failing bit Deskew For all bits (per PUP) (minimize delay elements) */
+                               DEBUG_PBS_S("DQ");
+                               DEBUG_PBS_D(dq, 1);
+                               DEBUG_PBS_S("-");
+                               DEBUG_PBS_D(skew_sum_array[pup][dq] /
+                                           COUNT_PBS_REPEAT, 2);
+                               DEBUG_PBS_S(", ");
+                       }
+                       DEBUG_PBS_S("\n");
+               }
+
+               /*
+                * Calculate the average skew for current pattern for each
+                * pup and each bit
+                */
+               DEBUG_PBS_C("DDR3 - PBS TX - Average for pattern - ",
+                           pattern_idx, 1);
+
+               for (pup = 0; pup < max_pup; pup++) {
+                       /*
+                        * FOR ECC only :: found min and max value for current
+                        * pattern skew array
+                        */
+                       /* Loop for all dqs */
+                       for (dq = 0; dq < DQ_NUM; dq++) {
+                               pattern_skew_array[pup][dq] +=
+                                       (skew_sum_array[pup][dq] /
+                                        COUNT_PBS_REPEAT);
+                       }
+               }
+       }
+
+       /* Calculate the average skew */
+       for (pup = 0; pup < max_pup; pup++) {
+               for (dq = 0; dq < DQ_NUM; dq++)
+                       skew_array[((pup) * DQ_NUM) + dq] =
+                               pattern_skew_array[pup][dq] / COUNT_PBS_PATTERN;
+       }
+
+       DEBUG_PBS_S("DDR3 - PBS TX - Average for all patterns:\n");
+       for (pup = 0; pup < max_pup; pup++) {
+               /*
+                * To minimize delay elements, inc from pbs value the min
+                * pbs val
+                */
+               DEBUG_PBS_S("DDR3 - PBS - PUP");
+               DEBUG_PBS_D(pup, 1);
+               DEBUG_PBS_S(": ");
+
+               for (dq = 0; dq < DQ_NUM; dq++) {
+                       /* Set skew value for all dq */
+                       /*
+                        * Bit# Deskew <- Bit# Deskew - last / first
+                        * failing bit Deskew For all bits (per PUP)
+                        * (minimize delay elements)
+                        */
+                       DEBUG_PBS_S("DQ");
+                       DEBUG_PBS_D(dq, 1);
+                       DEBUG_PBS_S("-");
+                       DEBUG_PBS_D(skew_array[(pup * DQ_NUM) + dq], 2);
+                       DEBUG_PBS_S(", ");
+               }
+               DEBUG_PBS_S("\n");
+       }
+
+       /* Return ADLL to default value */
+       for (pup = 0; pup < max_pup; pup++) {
+               if (pup == (max_pup - 1) && dram_info->ecc_ena)
+                       pup = ECC_PUP;
+               ddr3_pbs_write_pup_dqs_reg(CS0, pup, INIT_WL_DELAY);
+       }
+
+       /* Set averaged PBS results */
+       ddr3_set_pbs_results(dram_info, 1);
+
+       /* Disable SW override - Must be in a different stage */
+       /* [0]=0 - Enable SW override  */
+       reg = reg_read(REG_DRAM_TRAINING_2_ADDR);
+       reg &= ~(1 << REG_DRAM_TRAINING_2_SW_OVRD_OFFS);
+       /* 0x15B8 - Training SW 2 Register */
+       reg_write(REG_DRAM_TRAINING_2_ADDR, reg);
+
+       reg = reg_read(REG_DRAM_TRAINING_1_ADDR) |
+               (1 << REG_DRAM_TRAINING_1_TRNBPOINT_OFFS);
+       reg_write(REG_DRAM_TRAINING_1_ADDR, reg);
+
+       DEBUG_PBS_S("DDR3 - PBS Tx - PBS TX ended successfuly\n");
+
+       return MV_OK;
+}
+
+/*
+ * Name:     ddr3_tx_shift_dqs_adll_step_before_fail
+ * Desc:     Execute the Tx shift DQ phase.
+ * Args:     dram_info            ddr3 training information struct
+ *           cur_pup              bit array of the function active pups.
+ *           pbs_pattern_idx      Index of PBS pattern
+ * Notes:
+ * Returns:  MV_OK if success, other error code if fail.
+ */
+static int ddr3_tx_shift_dqs_adll_step_before_fail(MV_DRAM_INFO *dram_info,
+                                                  u32 cur_pup,
+                                                  u32 pbs_pattern_idx, u32 ecc)
+{
+       u32 unlock_pup;         /* bit array of unlock pups  */
+       u32 new_lockup_pup;     /* bit array of compare failed pups */
+       u32 adll_val = 4;       /* INIT_WL_DELAY */
+       u32 cur_max_pup, pup;
+       u32 dqs_dly_set[MAX_PUP_NUM] = { 0 };
+       u32 *pattern_ptr;
+
+       /* Choose pattern */
+       switch (dram_info->ddr_width) {
+#if defined(MV88F672X)
+       case 16:
+               pattern_ptr = (u32 *)&pbs_pattern[pbs_pattern_idx];
+               break;
+#endif
+       case 32:
+               pattern_ptr = (u32 *)&pbs_pattern_32b[pbs_pattern_idx];
+               break;
+#if defined(MV88F78X60)
+       case 64:
+               pattern_ptr = (u32 *)&pbs_pattern_64b[pbs_pattern_idx];
+               break;
+#endif
+       default:
+               return MV_FAIL;
+       }
+
+       /* Set current pup number */
+       if (cur_pup == 0x1)     /* Ecc mode */
+               cur_max_pup = 1;
+       else
+               cur_max_pup = dram_info->num_of_std_pups;
+
+       unlock_pup = cur_pup;   /* '1' for each unlocked pup */
+
+       /* Loop on all ADLL Vaules */
+       do {
+               /* Loop until found first fail */
+               adll_val++;
+
+               /*
+                * Increment (Move to right - ADLL) DQ TX delay
+                * (broadcast to all Data PUPs)
+                */
+               for (pup = 0; pup < cur_max_pup; pup++)
+                       ddr3_pbs_write_pup_dqs_reg(CS0,
+                                                  pup * (1 - ecc) +
+                                                  ECC_PUP * ecc, adll_val);
+
+               /*
+                * Write and Read, compare results (read was already verified)
+                */
+               /* 0 - all locked */
+               new_lockup_pup = 0;
+
+               if (MV_OK != ddr3_sdram_compare(dram_info, unlock_pup,
+                                               &new_lockup_pup,
+                                               pattern_ptr, LEN_PBS_PATTERN,
+                                               SDRAM_PBS_TX_OFFS, 1, 0,
+                                               NULL,
+                                               0))
+                       return MV_FAIL;
+
+               unlock_pup &= ~new_lockup_pup;
+
+               DEBUG_PBS_FULL_S("Shift DQS by 2 steps for PUPs: ");
+               DEBUG_PBS_FULL_D(unlock_pup, 2);
+               DEBUG_PBS_FULL_C(", Set ADLL value = ", adll_val, 2);
+
+               /* If any PUP failed there is '1' to mark the PUP */
+               if (new_lockup_pup != 0) {
+                       /*
+                        * Decrement (Move Back to Left two steps - ADLL)
+                        * DQ TX delay for current failed pups and save
+                        */
+                       for (pup = 0; pup < cur_max_pup; pup++) {
+                               if (((new_lockup_pup >> pup) & 0x1) &&
+                                   dqs_dly_set[pup] == 0)
+                                       dqs_dly_set[pup] = adll_val - 1;
+                       }
+               }
+       } while ((unlock_pup != 0) && (adll_val != ADLL_MAX));
+
+       if (unlock_pup != 0) {
+               DEBUG_PBS_FULL_S("DDR3 - PBS Tx - Shift DQ - Adll value reached maximum\n");
+
+               for (pup = 0; pup < cur_max_pup; pup++) {
+                       if (((unlock_pup >> pup) & 0x1) &&
+                           dqs_dly_set[pup] == 0)
+                               dqs_dly_set[pup] = adll_val - 1;
+               }
+       }
+
+       DEBUG_PBS_FULL_C("PBS TX one step before fail last pups locked Adll ",
+                        adll_val - 2, 2);
+
+       /* Set the PUP DQS DLY Values */
+       for (pup = 0; pup < cur_max_pup; pup++)
+               ddr3_pbs_write_pup_dqs_reg(CS0, pup * (1 - ecc) + ECC_PUP * ecc,
+                                          dqs_dly_set[pup]);
+
+       /* Found one phase before fail */
+       return MV_OK;
+}
+
+/*
+ * Name:     ddr3_pbs_rx
+ * Desc:     Execute the PBS RX phase.
+ * Args:     dram_info   ddr3 training information struct
+ * Notes:
+ * Returns:  MV_OK if success, other error code if fail.
+ */
+int ddr3_pbs_rx(MV_DRAM_INFO *dram_info)
+{
+       /*
+        * Array to hold the total sum of skew from all iterations
+        * (for average purpose)
+        */
+       u32 skew_sum_array[MAX_PUP_NUM][DQ_NUM] = { {0} };
+
+       /*
+        * Array to hold the total average skew from both patterns
+        * (for average purpose)
+        */
+       u32 pattern_skew_array[MAX_PUP_NUM][DQ_NUM] = { {0} };
+
+       u32 pbs_rep_time = 0;   /* counts number of loop in case of fail */
+       /* bit array for unlock pups - used to repeat on the RX operation */
+       u32 cur_pup;
+       u32 max_pup;
+       u32 pbs_retry;
+       u32 pup, dq, pups, cur_max_pup, valid_pup, reg;
+       u32 pattern_idx;
+       u32 ecc;
+       /* indicates whether we need to start the loop again */
+       int start_over;
+       int status;
+
+       DEBUG_PBS_S("DDR3 - PBS RX - Starting PBS RX procedure\n");
+
+       pups = dram_info->num_of_total_pups;
+       max_pup = dram_info->num_of_total_pups;
+
+       /* Enable SW override */
+       reg = reg_read(REG_DRAM_TRAINING_2_ADDR) |
+               (1 << REG_DRAM_TRAINING_2_SW_OVRD_OFFS);
+       /* [0] = 1 - Enable SW override  */
+       /* 0x15B8 - Training SW 2 Register */
+       reg_write(REG_DRAM_TRAINING_2_ADDR, reg);
+       DEBUG_PBS_FULL_S("DDR3 - PBS RX - SW Override Enabled\n");
+
+       reg = 1 << REG_DRAM_TRAINING_AUTO_OFFS;
+       reg_write(REG_DRAM_TRAINING_ADDR, reg); /* 0x15B0 - Training Register */
+
+       /* Running twice for 2 different patterns. each patterns - 3 times */
+       for (pattern_idx = 0; pattern_idx < COUNT_PBS_PATTERN; pattern_idx++) {
+               DEBUG_PBS_FULL_C("DDR3 - PBS RX - Working with pattern - ",
+                                pattern_idx, 1);
+
+               /* Reset sum array */
+               for (pup = 0; pup < pups; pup++) {
+                       for (dq = 0; dq < DQ_NUM; dq++)
+                               skew_sum_array[pup][dq] = 0;
+               }
+
+               /*
+                * Perform PBS several of times (3 for each pattern).
+                * At the end, we'll use the average
+                */
+               /* If there is ECC, do each PBS again with mux change */
+               for (pbs_retry = 0; pbs_retry < COUNT_PBS_REPEAT; pbs_retry++) {
+                       for (ecc = 0; ecc < (dram_info->ecc_ena + 1); ecc++) {
+                               /*
+                                * This parameter stores the current PUP
+                                * num - ecc mode dependent - 4-8 / 1 pups
+                                */
+                               cur_max_pup = (1 - ecc) *
+                                       dram_info->num_of_std_pups + ecc;
+
+                               if (ecc) {
+                                       /* Only 1 pup in this case */
+                                       valid_pup = 0x1;
+                               } else if (cur_max_pup > 4) {
+                                       /* 64 bit - 8 pups */
+                                       valid_pup = 0xFF;
+                               } else if (cur_max_pup == 4) {
+                                       /* 32 bit - 4 pups */
+                                       valid_pup = 0xF;
+                               } else {
+                                       /* 16 bit - 2 pups */
+                                       valid_pup = 0x3;
+                               }
+
+                               /* ECC Support - Switch ECC Mux on ecc=1 */
+                               reg = reg_read(REG_DRAM_TRAINING_2_ADDR) &
+                                       ~(1 << REG_DRAM_TRAINING_2_ECC_MUX_OFFS);
+                               reg |= (dram_info->ecc_ena * ecc <<
+                                       REG_DRAM_TRAINING_2_ECC_MUX_OFFS);
+                               reg_write(REG_DRAM_TRAINING_2_ADDR, reg);
+
+                               if (ecc)
+                                       DEBUG_PBS_FULL_S("DDR3 - PBS Rx - ECC Mux Enabled\n");
+                               else
+                                       DEBUG_PBS_FULL_S("DDR3 - PBS Rx - ECC Mux Disabled\n");
+
+                               /* Init iteration values */
+                               /* Clear the locked DQs */
+                               for (pup = 0; pup < cur_max_pup; pup++) {
+                                       for (dq = 0; dq < DQ_NUM; dq++) {
+                                               pbs_locked_dq[
+                                                       pup + ecc * (max_pup - 1)][dq] =
+                                                       0;
+                                       }
+                               }
+
+                               pbs_rep_time = 0;
+                               cur_pup = valid_pup;
+                               start_over = 0;
+
+                               /*
+                                * Run loop On current Pattern and current
+                                * pattern iteration (just to cover the false
+                                * fail problem
+                                */
+                               do {
+                                       DEBUG_PBS_FULL_S("DDR3 - PBS Rx - Pbs Rep Loop is ");
+                                       DEBUG_PBS_FULL_D(pbs_rep_time, 1);
+                                       DEBUG_PBS_FULL_S(", for Retry No.");
+                                       DEBUG_PBS_FULL_D(pbs_retry, 1);
+                                       DEBUG_PBS_FULL_S("\n");
+
+                                       /* Set all PBS values to MAX (31) */
+                                       for (pup = 0; pup < cur_max_pup; pup++) {
+                                               for (dq = 0; dq < DQ_NUM; dq++)
+                                                       ddr3_write_pup_reg(
+                                                               PUP_PBS_RX +
+                                                               pbs_dq_mapping[
+                                                               pup * (1 - ecc)
+                                                               + ecc * ECC_PUP]
+                                                               [dq], CS0,
+                                                               pup + ecc * ECC_PUP,
+                                                               0, MAX_PBS);
+                                       }
+
+                                       /* Set all DQS PBS values to MIN (0) */
+                                       for (pup = 0; pup < cur_max_pup; pup++) {
+                                               ddr3_write_pup_reg(PUP_PBS_RX +
+                                                                  DQ_NUM, CS0,
+                                                                  pup +
+                                                                  ecc *
+                                                                  ECC_PUP, 0,
+                                                                  0);
+                                       }
+
+                                       /* Shift DQS, To first Fail */
+                                       DEBUG_PBS_FULL_S("DDR3 - PBS Rx - Shift RX DQS to first fail\n");
+
+                                       status = ddr3_rx_shift_dqs_to_first_fail
+                                               (dram_info, cur_pup,
+                                                pattern_idx, ecc);
+                                       if (MV_OK != status) {
+                                               DEBUG_PBS_S("DDR3 - PBS Rx - ddr3_rx_shift_dqs_to_first_fail failed.\n");
+                                               DEBUG_PBS_D(status, 8);
+                                               DEBUG_PBS_S("\nDDR3 - PBS Rx - SKIP.\n");
+
+                                               /* Reset read FIFO */
+                                               reg = reg_read(REG_DRAM_TRAINING_ADDR);
+                                               /* Start Auto Read Leveling procedure */
+                                               reg |= (1 << REG_DRAM_TRAINING_RL_OFFS);
+                                               /* 0x15B0 - Training Register */
+                                               reg_write(REG_DRAM_TRAINING_ADDR, reg);
+
+                                               reg = reg_read(REG_DRAM_TRAINING_2_ADDR);
+                                               reg |= ((1 << REG_DRAM_TRAINING_2_FIFO_RST_OFFS)
+                                                       + (1 << REG_DRAM_TRAINING_2_SW_OVRD_OFFS));
+                                               /* [0] = 1 - Enable SW override, [4] = 1 - FIFO reset  */
+                                               /* 0x15B8 - Training SW 2 Register */
+                                               reg_write(REG_DRAM_TRAINING_2_ADDR, reg);
+
+                                               do {
+                                                       reg = (reg_read(REG_DRAM_TRAINING_2_ADDR))
+                                                               & (1 << REG_DRAM_TRAINING_2_FIFO_RST_OFFS);
+                                               } while (reg);  /* Wait for '0' */
+
+                                               reg = reg_read(REG_DRAM_TRAINING_ADDR);
+                                               /* Clear Auto Read Leveling procedure */
+                                               reg &= ~(1 << REG_DRAM_TRAINING_RL_OFFS);
+                                               /* 0x15B0 - Training Register */
+                                               reg_write(REG_DRAM_TRAINING_ADDR, reg);
+
+                                               /* Set ADLL to 15 */
+                                               for (pup = 0; pup < max_pup;
+                                                    pup++) {
+                                                       ddr3_write_pup_reg
+                                                           (PUP_DQS_RD, CS0,
+                                                            pup +
+                                                            (ecc * ECC_PUP), 0,
+                                                            15);
+                                               }
+
+                                               /* Set all PBS values to MIN (0) */
+                                               for (pup = 0; pup < cur_max_pup;
+                                                    pup++) {
+                                                       for (dq = 0;
+                                                            dq < DQ_NUM; dq++)
+                                                               ddr3_write_pup_reg
+                                                                   (PUP_PBS_RX +
+                                                                    pbs_dq_mapping
+                                                                    [pup * (1 - ecc) +
+                                                                     ecc * ECC_PUP]
+                                                                    [dq], CS0,
+                                                                    pup + ecc * ECC_PUP,
+                                                                    0, MIN_PBS);
+                                               }
+
+                                               return MV_OK;
+                                       }
+
+                                       /* PBS For each bit */
+                                       DEBUG_PBS_FULL_S("DDR3 - PBS Rx - perform PBS for each bit\n");
+                                       /* in this stage - start_over = 0; */
+                                       if (MV_OK != ddr3_pbs_per_bit(
+                                                   dram_info, &start_over,
+                                                   0, &cur_pup,
+                                                   pattern_idx, ecc)) {
+                                               DEBUG_PBS_S("DDR3 - PBS Rx - ddr3_pbs_per_bit failed.");
+                                               return MV_DDR3_TRAINING_ERR_PBS_RX_PER_BIT;
+                                       }
+
+                               } while ((start_over == 1) &&
+                                        (++pbs_rep_time < COUNT_PBS_STARTOVER));
+
+                               if (pbs_rep_time == COUNT_PBS_STARTOVER &&
+                                   start_over == 1) {
+                                       DEBUG_PBS_FULL_S("DDR3 - PBS Rx - FAIL - Algorithm failed doing RX PBS\n");
+                                       return MV_DDR3_TRAINING_ERR_PBS_RX_MAX_VAL;
+                               }
+
+                               /* Return DQS ADLL to default value - 15 */
+                               /* Set all DQS PBS values to MIN (0) */
+                               for (pup = 0; pup < cur_max_pup; pup++)
+                                       ddr3_write_pup_reg(PUP_DQS_RD, CS0,
+                                                          pup + ecc * ECC_PUP,
+                                                          0, INIT_RL_DELAY);
+
+                               DEBUG_PBS_FULL_C("DDR3 - PBS RX - values for iteration - ",
+                                                pbs_retry, 1);
+                               for (pup = 0; pup < cur_max_pup; pup++) {
+                                       /*
+                                        * To minimize delay elements, inc from
+                                        * pbs value the min pbs val
+                                        */
+                                       DEBUG_PBS_FULL_S("DDR3 - PBS - PUP");
+                                       DEBUG_PBS_FULL_D((pup +
+                                                         (ecc * ECC_PUP)), 1);
+                                       DEBUG_PBS_FULL_S(": ");
+
+                                       for (dq = 0; dq < DQ_NUM; dq++) {
+                                               /* Set skew value for all dq */
+                                               /*
+                                                * Bit# Deskew <- Bit# Deskew -
+                                                * last / first  failing bit
+                                                * Deskew For all bits (per PUP)
+                                                * (minimize delay elements)
+                                                */
+                                               DEBUG_PBS_FULL_S("DQ");
+                                               DEBUG_PBS_FULL_D(dq, 1);
+                                               DEBUG_PBS_FULL_S("-");
+                                               DEBUG_PBS_FULL_D(skew_array
+                                                                [((pup) *
+                                                                  DQ_NUM) +
+                                                                 dq], 2);
+                                               DEBUG_PBS_FULL_S(", ");
+                                       }
+                                       DEBUG_PBS_FULL_S("\n");
+                               }
+
+                               /*
+                                * Collect the results we got on this trial
+                                * of PBS
+                                */
+                               for (pup = 0; pup < cur_max_pup; pup++) {
+                                       for (dq = 0; dq < DQ_NUM; dq++) {
+                                               skew_sum_array
+                                                       [pup + (ecc * (max_pup - 1))]
+                                                       [dq] +=
+                                                       skew_array[((pup) * DQ_NUM) + dq];
+                                       }
+                               }
+
+                               /* ECC Support - Disable ECC MUX */
+                               reg = reg_read(REG_DRAM_TRAINING_2_ADDR) &
+                                       ~(1 << REG_DRAM_TRAINING_2_ECC_MUX_OFFS);
+                               reg_write(REG_DRAM_TRAINING_2_ADDR, reg);
+                       }
+               }
+
+               /*
+                * Calculate the average skew for current pattern for each
+                * pup and each bit
+                */
+               DEBUG_PBS_FULL_C("DDR3 - PBS RX - Average for pattern - ",
+                                pattern_idx, 1);
+               for (pup = 0; pup < max_pup; pup++) {
+                       /*
+                        * FOR ECC only :: found min and max value for
+                        * current pattern skew array
+                        */
+                       /* Loop for all dqs */
+                       for (dq = 0; dq < DQ_NUM; dq++) {
+                               pattern_skew_array[pup][dq] +=
+                                       (skew_sum_array[pup][dq] /
+                                        COUNT_PBS_REPEAT);
+                       }
+               }
+
+               DEBUG_PBS_C("DDR3 - PBS RX - values for current pattern - ",
+                           pattern_idx, 1);
+               for (pup = 0; pup < max_pup; pup++) {
+                       /*
+                        * To minimize delay elements, inc from pbs value the
+                        * min pbs val
+                        */
+                       DEBUG_PBS_S("DDR3 - PBS RX - PUP");
+                       DEBUG_PBS_D(pup, 1);
+                       DEBUG_PBS_S(": ");
+
+                       for (dq = 0; dq < DQ_NUM; dq++) {
+                               /* Set skew value for all dq */
+                               /*
+                                * Bit# Deskew <- Bit# Deskew - last / first
+                                * failing bit Deskew For all bits (per PUP)
+                                * (minimize delay elements)
+                                */
+                               DEBUG_PBS_S("DQ");
+                               DEBUG_PBS_D(dq, 1);
+                               DEBUG_PBS_S("-");
+                               DEBUG_PBS_D(skew_sum_array[pup][dq] /
+                                           COUNT_PBS_REPEAT, 2);
+                               DEBUG_PBS_S(", ");
+                       }
+                       DEBUG_PBS_S("\n");
+               }
+       }
+
+       /* Calculate the average skew */
+       for (pup = 0; pup < max_pup; pup++) {
+               for (dq = 0; dq < DQ_NUM; dq++)
+                       skew_array[((pup) * DQ_NUM) + dq] =
+                               pattern_skew_array[pup][dq] / COUNT_PBS_PATTERN;
+       }
+
+       DEBUG_PBS_S("DDR3 - PBS RX - Average for all patterns:\n");
+       for (pup = 0; pup < max_pup; pup++) {
+               /*
+                * To minimize delay elements, inc from pbs value the
+                * min pbs val
+                */
+               DEBUG_PBS_S("DDR3 - PBS - PUP");
+               DEBUG_PBS_D(pup, 1);
+               DEBUG_PBS_S(": ");
+
+               for (dq = 0; dq < DQ_NUM; dq++) {
+                       /* Set skew value for all dq */
+                       /*
+                        * Bit# Deskew <- Bit# Deskew - last / first
+                        * failing bit Deskew For all bits (per PUP)
+                        * (minimize delay elements)
+                        */
+                       DEBUG_PBS_S("DQ");
+                       DEBUG_PBS_D(dq, 1);
+                       DEBUG_PBS_S("-");
+                       DEBUG_PBS_D(skew_array[(pup * DQ_NUM) + dq], 2);
+                       DEBUG_PBS_S(", ");
+               }
+               DEBUG_PBS_S("\n");
+       }
+
+       /* Return ADLL to default value */
+       ddr3_write_pup_reg(PUP_DQS_RD, CS0, PUP_BC, 0, INIT_RL_DELAY);
+
+       /* Set averaged PBS results */
+       ddr3_set_pbs_results(dram_info, 0);
+
+       /* Disable SW override - Must be in a different stage */
+       /* [0]=0 - Enable SW override  */
+       reg = reg_read(REG_DRAM_TRAINING_2_ADDR);
+       reg &= ~(1 << REG_DRAM_TRAINING_2_SW_OVRD_OFFS);
+       /* 0x15B8 - Training SW 2 Register */
+       reg_write(REG_DRAM_TRAINING_2_ADDR, reg);
+
+       reg = reg_read(REG_DRAM_TRAINING_1_ADDR) |
+               (1 << REG_DRAM_TRAINING_1_TRNBPOINT_OFFS);
+       reg_write(REG_DRAM_TRAINING_1_ADDR, reg);
+
+       DEBUG_PBS_FULL_S("DDR3 - PBS RX - ended successfuly\n");
+
+       return MV_OK;
+}
+
+/*
+ * Name:     ddr3_rx_shift_dqs_to_first_fail
+ * Desc:     Execute the Rx shift DQ phase.
+ * Args:     dram_info           ddr3 training information struct
+ *           cur_pup             bit array of the function active pups.
+ *           pbs_pattern_idx     Index of PBS pattern
+ * Notes:
+ * Returns:  MV_OK if success, other error code if fail.
+ */
+static int ddr3_rx_shift_dqs_to_first_fail(MV_DRAM_INFO *dram_info, u32 cur_pup,
+                                          u32 pbs_pattern_idx, u32 ecc)
+{
+       u32 unlock_pup;         /* bit array of unlock pups  */
+       u32 new_lockup_pup;     /* bit array of compare failed pups */
+       u32 adll_val = MAX_DELAY;
+       u32 dqs_deskew_val = 0; /* current value of DQS PBS deskew */
+       u32 cur_max_pup, pup, pass_pup;
+       u32 *pattern_ptr;
+
+       /* Choose pattern */
+       switch (dram_info->ddr_width) {
+#if defined(MV88F672X)
+       case 16:
+               pattern_ptr = (u32 *)&pbs_pattern[pbs_pattern_idx];
+               break;
+#endif
+       case 32:
+               pattern_ptr = (u32 *)&pbs_pattern_32b[pbs_pattern_idx];
+               break;
+#if defined(MV88F78X60)
+       case 64:
+               pattern_ptr = (u32 *)&pbs_pattern_64b[pbs_pattern_idx];
+               break;
+#endif
+       default:
+               return MV_FAIL;
+       }
+
+       /* Set current pup number */
+       if (cur_pup == 0x1)     /* Ecc mode */
+               cur_max_pup = 1;
+       else
+               cur_max_pup = dram_info->num_of_std_pups;
+
+       unlock_pup = cur_pup;   /* '1' for each unlocked pup */
+
+       DEBUG_PBS_FULL_S("DDR3 - PBS RX - Shift DQS - Starting...\n");
+
+       /* Set DQS ADLL to MAX */
+       DEBUG_PBS_FULL_S("DDR3 - PBS RX - Shift DQS - Set DQS ADLL to Max for all PUPs\n");
+       for (pup = 0; pup < cur_max_pup; pup++)
+               ddr3_write_pup_reg(PUP_DQS_RD, CS0, pup + ecc * ECC_PUP, 0,
+                                  MAX_DELAY);
+
+       /* Loop on all ADLL Vaules */
+       do {
+               /* Loop until found fail for all pups */
+               new_lockup_pup = 0;
+               if (MV_OK != ddr3_sdram_compare(dram_info, unlock_pup,
+                                               &new_lockup_pup,
+                                               pattern_ptr, LEN_PBS_PATTERN,
+                                               SDRAM_PBS_I_OFFS +
+                                               pbs_pattern_idx * SDRAM_PBS_NEXT_OFFS,
+                                               0, 0, NULL, 0)) {
+                       DEBUG_PBS_S("DDR3 - PBS Rx - Shift DQS - MV_DDR3_TRAINING_ERR_PBS_SHIFT_QDS_SRAM_CMP(ddr3_sdram_compare)\n");
+                       return MV_DDR3_TRAINING_ERR_PBS_SHIFT_QDS_SRAM_CMP;
+               }
+
+               if ((new_lockup_pup != 0) && (dqs_deskew_val <= 1)) {
+                       /* Fail on start with first deskew value */
+                       /* Decrement DQS ADLL */
+                       --adll_val;
+                       if (adll_val == ADLL_MIN) {
+                               DEBUG_PBS_S("DDR3 - PBS Rx - Shift DQS - fail on start with first deskew value\n");
+                               return MV_DDR3_TRAINING_ERR_PBS_SHIFT_QDS_SRAM_CMP;
+                       }
+                       ddr3_write_pup_reg(PUP_DQS_RD, CS0, pup + ecc * ECC_PUP,
+                                          0, adll_val);
+                       continue;
+               }
+
+               /* Update all new locked pups */
+               unlock_pup &= ~new_lockup_pup;
+
+               if ((unlock_pup == 0) || (dqs_deskew_val == MAX_PBS)) {
+                       if (dqs_deskew_val == MAX_PBS) {
+                               /*
+                                * Reach max value of dqs deskew or get fail
+                                * for all pups
+                                */
+                               DEBUG_PBS_FULL_S("DDR3 - PBS RX - Shift DQS - DQS deskew reached maximum value\n");
+                       }
+                       break;
+               }
+
+               DEBUG_PBS_FULL_S("DDR3 - PBS RX - Shift DQS - Inc DQS deskew for PUPs: ");
+               DEBUG_PBS_FULL_D(unlock_pup, 2);
+               DEBUG_PBS_FULL_C(", deskew = ", dqs_deskew_val, 2);
+
+               /* Increment DQS deskew elements - Only for unlocked pups */
+               dqs_deskew_val++;
+               for (pup = 0; pup < cur_max_pup; pup++) {
+                       if (IS_PUP_ACTIVE(unlock_pup, pup) == 1) {
+                               ddr3_write_pup_reg(PUP_PBS_RX + DQS_DQ_NUM, CS0,
+                                                  pup + ecc * ECC_PUP, 0,
+                                                  dqs_deskew_val);
+                       }
+               }
+       } while (1);
+
+       DEBUG_PBS_FULL_S("DDR3 - PBS RX - Shift DQS - ADLL shift one step before fail\n");
+       /* Continue to ADLL shift one step before fail */
+       unlock_pup = cur_pup;
+       do {
+               /* Loop until pass compare for all pups */
+               new_lockup_pup = 0;
+               /* Read and compare results  */
+               if (MV_OK != ddr3_sdram_compare(dram_info, unlock_pup, &new_lockup_pup,
+                                               pattern_ptr, LEN_PBS_PATTERN,
+                                               SDRAM_PBS_I_OFFS +
+                                               pbs_pattern_idx * SDRAM_PBS_NEXT_OFFS,
+                                               1, 0, NULL, 0)) {
+                       DEBUG_PBS_S("DDR3 - PBS Rx - Shift DQS - MV_DDR3_TRAINING_ERR_PBS_SHIFT_QDS_SRAM_CMP(ddr3_sdram_compare)\n");
+                       return MV_DDR3_TRAINING_ERR_PBS_SHIFT_QDS_SRAM_CMP;
+               }
+
+               /*
+                * Get mask for pup which passed so their adll will be
+                * changed to 2 steps before fails
+                */
+               pass_pup = unlock_pup & ~new_lockup_pup;
+
+               DEBUG_PBS_FULL_S("Shift DQS by 2 steps for PUPs: ");
+               DEBUG_PBS_FULL_D(pass_pup, 2);
+               DEBUG_PBS_FULL_C(", Set ADLL value = ", (adll_val - 2), 2);
+
+               /* Only for pass pups   */
+               for (pup = 0; pup < cur_max_pup; pup++) {
+                       if (IS_PUP_ACTIVE(pass_pup, pup) == 1) {
+                               ddr3_write_pup_reg(PUP_DQS_RD, CS0,
+                                                  pup + ecc * ECC_PUP, 0,
+                                                  (adll_val - 2));
+                       }
+               }
+
+               /* Locked pups that compare success  */
+               unlock_pup &= new_lockup_pup;
+
+               if (unlock_pup == 0) {
+                       /* All pups locked */
+                       break;
+               }
+
+               /* Found error */
+               if (adll_val == 0) {
+                       DEBUG_PBS_FULL_S("DDR3 - PBS Rx - Shift DQS - Adll reach min value\n");
+                       return MV_DDR3_TRAINING_ERR_PBS_SHIFT_QDS_MAX_VAL;
+               }
+
+               /*
+                * Decrement (Move Back to Left one phase - ADLL) dqs RX delay
+                */
+               adll_val--;
+               for (pup = 0; pup < cur_max_pup; pup++) {
+                       if (IS_PUP_ACTIVE(unlock_pup, pup) == 1) {
+                               ddr3_write_pup_reg(PUP_DQS_RD, CS0,
+                                                  pup + ecc * ECC_PUP, 0,
+                                                  adll_val);
+                       }
+               }
+       } while (1);
+
+       return MV_OK;
+}
+
+/*
+ * lock_pups() extracted from ddr3_pbs_per_bit(). This just got too
+ * much indented making it hard to read / edit.
+ */
+static void lock_pups(u32 pup, u32 *pup_locked, u8 *unlock_pup_dq_array,
+                     u32 pbs_curr_val, u32 start_pbs, u32 ecc, int is_tx)
+{
+       u32 dq;
+       int idx;
+
+       /* Lock PBS value for all remaining PUPs bits */
+       DEBUG_PBS_FULL_S("DDR3 - PBS Per bit - Lock PBS value for all remaining PUPs bits, pup ");
+       DEBUG_PBS_FULL_D(pup, 1);
+       DEBUG_PBS_FULL_C(" pbs value ", pbs_curr_val, 2);
+
+       idx = pup * (1 - ecc) + ecc * ECC_PUP;
+       *pup_locked &= ~(1 << pup);
+
+       for (dq = 0; dq < DQ_NUM; dq++) {
+               if (IS_PUP_ACTIVE(unlock_pup_dq_array[dq], pup) == 1) {
+                       int offs;
+
+                       /* Lock current dq */
+                       unlock_pup_dq_array[dq] &= ~(1 << pup);
+                       skew_array[(pup * DQ_NUM) + dq] = pbs_curr_val;
+
+                       if (is_tx == 1)
+                               offs = PUP_PBS_TX;
+                       else
+                               offs = PUP_PBS_RX;
+
+                       ddr3_write_pup_reg(offs +
+                                          pbs_dq_mapping[idx][dq], CS0,
+                                          idx, 0, start_pbs);
+               }
+       }
+}
+
+/*
+ * Name:     ddr3_pbs_per_bit
+ * Desc:     Execute the Per Bit Skew phase.
+ * Args:     start_over      Return whether need to start over the algorithm
+ *           is_tx           Indicate whether Rx or Tx
+ *           pcur_pup        bit array of the function active pups. return the
+ *                           pups that need to repeat on the PBS
+ *           pbs_pattern_idx Index of PBS pattern
+ *
+ * Notes:    Current implementation supports double activation of this function.
+ *           i.e. in order to activate this function (using start_over) more than
+ *           twice, the implementation should change.
+ *           imlementation limitation are marked using
+ *           ' CHIP-ONLY! - Implementation Limitation '
+ * Returns:  MV_OK if success, other error code if fail.
+ */
+static int ddr3_pbs_per_bit(MV_DRAM_INFO *dram_info, int *start_over, int is_tx,
+                           u32 *pcur_pup, u32 pbs_pattern_idx, u32 ecc)
+{
+       /*
+        * Bit array to indicate if we already get fail on bit per pup & dq bit
+        */
+       u8 unlock_pup_dq_array[DQ_NUM] = {
+               *pcur_pup, *pcur_pup, *pcur_pup, *pcur_pup, *pcur_pup,
+               *pcur_pup, *pcur_pup, *pcur_pup
+       };
+
+       u8 cmp_unlock_pup_dq_array[COUNT_PBS_COMP_RETRY_NUM][DQ_NUM];
+       u32 pup, dq;
+       /* value of pbs is according to RX or TX */
+       u32 start_pbs, last_pbs;
+       u32 pbs_curr_val;
+       /* bit array that indicates all dq of the pup locked */
+       u32 pup_locked;
+       u32 first_fail[MAX_PUP_NUM] = { 0 };    /* count first fail per pup */
+       /* indicates whether we get first fail per pup */
+       int first_failed[MAX_PUP_NUM] = { 0 };
+       /* bit array that indicates pup already get fail */
+       u32 sum_pup_fail;
+       /* use to calculate diff between curr pbs to first fail pbs */
+       u32 calc_pbs_diff;
+       u32 pbs_cmp_retry;
+       u32 max_pup;
+
+       /* Set init values for retry array - 8 retry */
+       for (pbs_cmp_retry = 0; pbs_cmp_retry < COUNT_PBS_COMP_RETRY_NUM;
+            pbs_cmp_retry++) {
+               for (dq = 0; dq < DQ_NUM; dq++)
+                       cmp_unlock_pup_dq_array[pbs_cmp_retry][dq] = *pcur_pup;
+       }
+
+       memset(&skew_array, 0, MAX_PUP_NUM * DQ_NUM * sizeof(u32));
+
+       DEBUG_PBS_FULL_S("DDR3 - PBS Per bit - Started\n");
+
+       /* The pbs value depends if rx or tx */
+       if (is_tx == 1) {
+               start_pbs = MIN_PBS;
+               last_pbs = MAX_PBS;
+       } else {
+               start_pbs = MAX_PBS;
+               last_pbs = MIN_PBS;
+       }
+
+       pbs_curr_val = start_pbs;
+       pup_locked = *pcur_pup;
+
+       /* Set current pup number */
+       if (pup_locked == 0x1)  /* Ecc mode */
+               max_pup = 1;
+       else
+               max_pup = dram_info->num_of_std_pups;
+
+       do {
+               /* Increment/ decrement PBS for un-lock bits only */
+               if (is_tx == 1)
+                       pbs_curr_val++;
+               else
+                       pbs_curr_val--;
+
+               /* Set Current PBS delay  */
+               for (dq = 0; dq < DQ_NUM; dq++) {
+                       /* Check DQ bits to see if locked in all pups */
+                       if (unlock_pup_dq_array[dq] == 0) {
+                               DEBUG_PBS_FULL_S("DDR3 - PBS Per bit - All pups are locked for DQ ");
+                               DEBUG_PBS_FULL_D(dq, 1);
+                               DEBUG_PBS_FULL_S("\n");
+                               continue;
+                       }
+
+                       for (pup = 0; pup < max_pup; pup++) {
+                               int idx;
+
+                               idx = pup * (1 - ecc) + ecc * ECC_PUP;
+
+                               if (IS_PUP_ACTIVE(unlock_pup_dq_array[dq], pup)
+                                   == 0)
+                                       continue;
+
+                               if (is_tx == 1)
+                                       ddr3_write_pup_reg(
+                                               PUP_PBS_TX + pbs_dq_mapping[idx][dq],
+                                               CS0, idx, 0, pbs_curr_val);
+                               else
+                                       ddr3_write_pup_reg(
+                                               PUP_PBS_RX + pbs_dq_mapping[idx][dq],
+                                               CS0, idx, 0, pbs_curr_val);
+                       }
+               }
+
+               /*
+                * Write Read and compare results - run the test
+                * DDR_PBS_COMP_RETRY_NUM times
+                */
+               /* Run number of read and write to verify */
+               for (pbs_cmp_retry = 0;
+                    pbs_cmp_retry < COUNT_PBS_COMP_RETRY_NUM;
+                    pbs_cmp_retry++) {
+
+                       if (MV_OK !=
+                           ddr3_sdram_pbs_compare(dram_info, pup_locked, is_tx,
+                                                  pbs_pattern_idx,
+                                                  pbs_curr_val, start_pbs,
+                                                  skew_array,
+                                                  cmp_unlock_pup_dq_array
+                                                  [pbs_cmp_retry], ecc))
+                               return MV_FAIL;
+
+                       for (pup = 0; pup < max_pup; pup++) {
+                               for (dq = 0; dq < DQ_NUM; dq++) {
+                                       if ((IS_PUP_ACTIVE(unlock_pup_dq_array[dq],
+                                                          pup) == 1)
+                                           && (IS_PUP_ACTIVE(cmp_unlock_pup_dq_array
+                                             [pbs_cmp_retry][dq],
+                                             pup) == 0)) {
+                                               DEBUG_PBS_FULL_S("DDR3 - PBS Per bit - PbsCurrVal: ");
+                                               DEBUG_PBS_FULL_D(pbs_curr_val, 2);
+                                               DEBUG_PBS_FULL_S(" PUP: ");
+                                               DEBUG_PBS_FULL_D(pup, 1);
+                                               DEBUG_PBS_FULL_S(" DQ: ");
+                                               DEBUG_PBS_FULL_D(dq, 1);
+                                               DEBUG_PBS_FULL_S(" - failed\n");
+                                       }
+                               }
+                       }
+
+                       for (dq = 0; dq < DQ_NUM; dq++) {
+                               unlock_pup_dq_array[dq] &=
+                                   cmp_unlock_pup_dq_array[pbs_cmp_retry][dq];
+                       }
+               }
+
+               pup_locked = 0;
+               sum_pup_fail = *pcur_pup;
+
+               /* Check which DQ is failed */
+               for (dq = 0; dq < DQ_NUM; dq++) {
+                       /* Summarize the locked pup */
+                       pup_locked |= unlock_pup_dq_array[dq];
+
+                       /* Check if get fail */
+                       sum_pup_fail &= unlock_pup_dq_array[dq];
+               }
+
+               /* If all PUPS are locked in all DQ - Break */
+               if (pup_locked == 0) {
+                       /* All pups are locked */
+                       *start_over = 0;
+                       DEBUG_PBS_FULL_S("DDR3 - PBS Per bit -  All bit in all pups are successfully locked\n");
+                       break;
+               }
+
+               /* PBS deskew elements reach max ? */
+               if (pbs_curr_val == last_pbs) {
+                       DEBUG_PBS_FULL_S("DDR3 - PBS Per bit - PBS deskew elements reach max\n");
+                       /* CHIP-ONLY! - Implementation Limitation */
+                       *start_over = (sum_pup_fail != 0) && (!(*start_over));
+                       *pcur_pup = pup_locked;
+
+                       DEBUG_PBS_FULL_S("DDR3 - PBS Per bit - StartOver: ");
+                       DEBUG_PBS_FULL_D(*start_over, 1);
+                       DEBUG_PBS_FULL_S("  pup_locked: ");
+                       DEBUG_PBS_FULL_D(pup_locked, 2);
+                       DEBUG_PBS_FULL_S("  sum_pup_fail: ");
+                       DEBUG_PBS_FULL_D(sum_pup_fail, 2);
+                       DEBUG_PBS_FULL_S("\n");
+
+                       /* Lock PBS value for all remaining  bits */
+                       for (pup = 0; pup < max_pup; pup++) {
+                               /* Check if current pup already received error */
+                               if (IS_PUP_ACTIVE(pup_locked, pup) == 1) {
+                                       /* Valid pup for current function */
+                                       if (IS_PUP_ACTIVE(sum_pup_fail, pup) ==
+                                           1 && (*start_over == 1)) {
+                                               DEBUG_PBS_FULL_C("DDR3 - PBS Per bit - skipping lock of pup (first loop of pbs)",
+                                                                pup, 1);
+                                               continue;
+                                       } else
+                                           if (IS_PUP_ACTIVE(sum_pup_fail, pup)
+                                               == 1) {
+                                               DEBUG_PBS_FULL_C("DDR3 - PBS Per bit - Locking pup %d (even though it wasn't supposed to be locked)",
+                                                                pup, 1);
+                                       }
+
+                                       /* Already got fail on the PUP */
+                                       /* Lock PBS value for all remaining bits */
+                                       DEBUG_PBS_FULL_S("DDR3 - PBS Per bit - Locking remaning DQs for pup - ");
+                                       DEBUG_PBS_FULL_D(pup, 1);
+                                       DEBUG_PBS_FULL_S(": ");
+
+                                       for (dq = 0; dq < DQ_NUM; dq++) {
+                                               if (IS_PUP_ACTIVE
+                                                   (unlock_pup_dq_array[dq],
+                                                    pup) == 1) {
+                                                       DEBUG_PBS_FULL_D(dq, 1);
+                                                       DEBUG_PBS_FULL_S(",");
+                                                       /* set current PBS */
+                                                       skew_array[((pup) *
+                                                                   DQ_NUM) +
+                                                                  dq] =
+                                                           pbs_curr_val;
+                                               }
+                                       }
+
+                                       if (*start_over == 1) {
+                                               /*
+                                                * Reset this pup bit - when
+                                                * restart the PBS, ignore this
+                                                * pup
+                                                */
+                                               *pcur_pup &= ~(1 << pup);
+                                       }
+                                       DEBUG_PBS_FULL_S("\n");
+                               } else {
+                                       DEBUG_PBS_FULL_S("DDR3 - PBS Per bit - Pup ");
+                                       DEBUG_PBS_FULL_D(pup, 1);
+                                       DEBUG_PBS_FULL_C(" is not set in puplocked - ",
+                                                        pup_locked, 1);
+                               }
+                       }
+
+                       /* Need to start the PBS again */
+                       if (*start_over == 1) {
+                               DEBUG_PBS_FULL_S("DDR3 - PBS Per bit - false fail - returning to start\n");
+                               return MV_OK;
+                       }
+                       break;
+               }
+
+               /* Diff Check */
+               for (pup = 0; pup < max_pup; pup++) {
+                       if (IS_PUP_ACTIVE(pup_locked, pup) == 1) {
+                               /* pup is not locked */
+                               if (first_failed[pup] == 0) {
+                                       /* No first fail until now */
+                                       if (IS_PUP_ACTIVE(sum_pup_fail, pup) ==
+                                           0) {
+                                               /* Get first fail */
+                                               DEBUG_PBS_FULL_C("DDR3 - PBS Per bit - First fail in pup ",
+                                                                pup, 1);
+                                               first_failed[pup] = 1;
+                                               first_fail[pup] = pbs_curr_val;
+                                       }
+                               } else {
+                                       /* Already got first fail */
+                                       if (is_tx == 1) {
+                                               /* TX - inc pbs */
+                                               calc_pbs_diff = pbs_curr_val -
+                                                       first_fail[pup];
+                                       } else {
+                                               /* RX - dec pbs */
+                                               calc_pbs_diff = first_fail[pup] -
+                                                       pbs_curr_val;
+                                       }
+
+                                       if (calc_pbs_diff >= PBS_DIFF_LIMIT) {
+                                               lock_pups(pup, &pup_locked,
+                                                         unlock_pup_dq_array,
+                                                         pbs_curr_val,
+                                                         start_pbs, ecc, is_tx);
+                                       }
+                               }
+                       }
+               }
+       } while (1);
+
+       return MV_OK;
+}
+
+/*
+ * Name:         ddr3_set_pbs_results
+ * Desc:         Set to HW the PBS phase results.
+ * Args:         is_tx       Indicates whether to set Tx or RX results
+ * Notes:
+ * Returns:      MV_OK if success, other error code if fail.
+ */
+static int ddr3_set_pbs_results(MV_DRAM_INFO *dram_info, int is_tx)
+{
+       u32 pup, phys_pup, dq;
+       u32 max_pup;            /* number of valid pups */
+       u32 pbs_min;            /* minimal pbs val per pup */
+       u32 pbs_max;            /* maximum pbs val per pup */
+       u32 val[9];
+
+       max_pup = dram_info->num_of_total_pups;
+       DEBUG_PBS_FULL_S("DDR3 - PBS - ddr3_set_pbs_results:\n");
+
+       /* Loop for all dqs & pups */
+       for (pup = 0; pup < max_pup; pup++) {
+               if (pup == (max_pup - 1) && dram_info->ecc_ena)
+                       phys_pup = ECC_PUP;
+               else
+                       phys_pup = pup;
+
+               /*
+                * To minimize delay elements, inc from pbs value the min
+                * pbs val
+                */
+               pbs_min = MAX_PBS;
+               pbs_max = 0;
+               for (dq = 0; dq < DQ_NUM; dq++) {
+                       if (pbs_min > skew_array[(pup * DQ_NUM) + dq])
+                               pbs_min = skew_array[(pup * DQ_NUM) + dq];
+
+                       if (pbs_max < skew_array[(pup * DQ_NUM) + dq])
+                               pbs_max = skew_array[(pup * DQ_NUM) + dq];
+               }
+
+               pbs_max -= pbs_min;
+
+               DEBUG_PBS_FULL_S("DDR3 - PBS - PUP");
+               DEBUG_PBS_FULL_D(phys_pup, 1);
+               DEBUG_PBS_FULL_S(": Min Val = ");
+               DEBUG_PBS_FULL_D(pbs_min, 2);
+               DEBUG_PBS_FULL_C(", Max Val = ", pbs_max, 2);
+
+               val[pup] = 0;
+
+               for (dq = 0; dq < DQ_NUM; dq++) {
+                       int idx;
+                       int offs;
+
+                       /* Set skew value for all dq */
+                       /*
+                        * Bit# Deskew <- Bit# Deskew - last / first
+                        * failing bit Deskew For all bits (per PUP)
+                        * (minimize delay elements)
+                        */
+
+                       DEBUG_PBS_FULL_S("DQ");
+                       DEBUG_PBS_FULL_D(dq, 1);
+                       DEBUG_PBS_FULL_S("-");
+                       DEBUG_PBS_FULL_D((skew_array[(pup * DQ_NUM) + dq] -
+                                         pbs_min), 2);
+                       DEBUG_PBS_FULL_S(", ");
+
+                       idx = (pup * DQ_NUM) + dq;
+
+                       if (is_tx == 1)
+                               offs = PUP_PBS_TX;
+                       else
+                               offs = PUP_PBS_RX;
+
+                       ddr3_write_pup_reg(offs + pbs_dq_mapping[phys_pup][dq],
+                                          CS0, phys_pup, 0,
+                                          skew_array[idx] - pbs_min);
+
+                       if (is_tx == 1)
+                               val[pup] += skew_array[idx] - pbs_min;
+               }
+
+               DEBUG_PBS_FULL_S("\n");
+
+               /* Set the DQS the half of the Max PBS of the DQs  */
+               if (is_tx == 1) {
+                       ddr3_write_pup_reg(PUP_PBS_TX + 8, CS0, phys_pup, 0,
+                                          pbs_max / 2);
+                       ddr3_write_pup_reg(PUP_PBS_TX + 0xa, CS0, phys_pup, 0,
+                                          val[pup] / 8);
+               } else
+                       ddr3_write_pup_reg(PUP_PBS_RX + 8, CS0, phys_pup, 0,
+                                          pbs_max / 2);
+       }
+
+       return MV_OK;
+}
+
+static void ddr3_pbs_write_pup_dqs_reg(u32 cs, u32 pup, u32 dqs_delay)
+{
+       u32 reg, delay;
+
+       reg = (ddr3_read_pup_reg(PUP_WL_MODE, cs, pup) & 0x3FF);
+       delay = reg & PUP_DELAY_MASK;
+       reg |= ((dqs_delay + delay) << REG_PHY_DQS_REF_DLY_OFFS);
+       reg |= REG_PHY_REGISTRY_FILE_ACCESS_OP_WR;
+       reg |= (pup << REG_PHY_PUP_OFFS);
+       reg |= ((0x4 * cs + PUP_WL_MODE) << REG_PHY_CS_OFFS);
+
+       reg_write(REG_PHY_REGISTRY_FILE_ACCESS_ADDR, reg);      /* 0x16A0 */
+       do {
+               reg = reg_read(REG_PHY_REGISTRY_FILE_ACCESS_ADDR) &
+                       REG_PHY_REGISTRY_FILE_ACCESS_OP_DONE;
+       } while (reg);  /* Wait for '0' to mark the end of the transaction */
+
+       udelay(10);
+}
+
+/*
+ * Set training patterns
+ */
+int ddr3_load_pbs_patterns(MV_DRAM_INFO *dram_info)
+{
+       u32 cs, cs_count, cs_tmp;
+       u32 sdram_addr;
+       u32 *pattern_ptr0, *pattern_ptr1;
+
+       /* Choose pattern */
+       switch (dram_info->ddr_width) {
+#if defined(MV88F672X)
+       case 16:
+               pattern_ptr0 = (u32 *)&pbs_pattern[0];
+               pattern_ptr1 = (u32 *)&pbs_pattern[1];
+               break;
+#endif
+       case 32:
+               pattern_ptr0 = (u32 *)&pbs_pattern_32b[0];
+               pattern_ptr1 = (u32 *)&pbs_pattern_32b[1];
+               break;
+#if defined(MV88F78X60)
+       case 64:
+               pattern_ptr0 = (u32 *)&pbs_pattern_64b[0];
+               pattern_ptr1 = (u32 *)&pbs_pattern_64b[1];
+               break;
+#endif
+       default:
+               return MV_FAIL;
+       }
+
+       /* Loop for each CS */
+       for (cs = 0; cs < MAX_CS; cs++) {
+               if (dram_info->cs_ena & (1 << cs)) {
+                       cs_count = 0;
+                       for (cs_tmp = 0; cs_tmp < cs; cs_tmp++) {
+                               if (dram_info->cs_ena & (1 << cs_tmp))
+                                       cs_count++;
+                       }
+
+                       /* Init PBS I pattern */
+                       sdram_addr = (cs_count * (SDRAM_CS_SIZE + 1) +
+                                     SDRAM_PBS_I_OFFS);
+                       if (MV_OK !=
+                           ddr3_sdram_compare(dram_info, (u32) NULL, NULL,
+                                              pattern_ptr0, LEN_STD_PATTERN,
+                                              sdram_addr, 1, 0, NULL,
+                                              0))
+                               return MV_FAIL;
+
+                       /* Init PBS II pattern */
+                       sdram_addr = (cs_count * (SDRAM_CS_SIZE + 1) +
+                                     SDRAM_PBS_II_OFFS);
+                       if (MV_OK !=
+                           ddr3_sdram_compare(dram_info, (u32) NULL, NULL,
+                                              pattern_ptr1, LEN_STD_PATTERN,
+                                              sdram_addr, 1, 0, NULL,
+                                              0))
+                               return MV_FAIL;
+               }
+       }
+
+       return MV_OK;
+}
+#endif
diff --git a/drivers/ddr/mvebu/ddr3_read_leveling.c b/drivers/ddr/mvebu/ddr3_read_leveling.c
new file mode 100644 (file)
index 0000000..4662bde
--- /dev/null
@@ -0,0 +1,1214 @@
+/*
+ * Copyright (C) Marvell International Ltd. and its affiliates
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#include <common.h>
+#include <i2c.h>
+#include <spl.h>
+#include <asm/io.h>
+#include <asm/arch/cpu.h>
+#include <asm/arch/soc.h>
+
+#include "ddr3_hw_training.h"
+
+/*
+ * Debug
+ */
+#define DEBUG_RL_C(s, d, l) \
+       DEBUG_RL_S(s); DEBUG_RL_D(d, l); DEBUG_RL_S("\n")
+#define DEBUG_RL_FULL_C(s, d, l) \
+       DEBUG_RL_FULL_S(s); DEBUG_RL_FULL_D(d, l); DEBUG_RL_FULL_S("\n")
+
+#ifdef MV_DEBUG_RL
+#define DEBUG_RL_S(s) \
+       debug_cond(ddr3_get_log_level() >= MV_LOG_LEVEL_2, "%s", s)
+#define DEBUG_RL_D(d, l) \
+       debug_cond(ddr3_get_log_level() >= MV_LOG_LEVEL_2, "%x", d)
+#else
+#define DEBUG_RL_S(s)
+#define DEBUG_RL_D(d, l)
+#endif
+
+#ifdef MV_DEBUG_RL_FULL
+#define DEBUG_RL_FULL_S(s)             puts(s)
+#define DEBUG_RL_FULL_D(d, l)          printf("%x", d)
+#else
+#define DEBUG_RL_FULL_S(s)
+#define DEBUG_RL_FULL_D(d, l)
+#endif
+
+extern u32 rl_pattern[LEN_STD_PATTERN];
+
+#ifdef RL_MODE
+static int ddr3_read_leveling_single_cs_rl_mode(u32 cs, u32 freq,
+                                               int ratio_2to1, u32 ecc,
+                                               MV_DRAM_INFO *dram_info);
+#else
+static int ddr3_read_leveling_single_cs_window_mode(u32 cs, u32 freq,
+                                                   int ratio_2to1, u32 ecc,
+                                                   MV_DRAM_INFO *dram_info);
+#endif
+
+/*
+ * Name:     ddr3_read_leveling_hw
+ * Desc:     Execute the Read leveling phase by HW
+ * Args:     dram_info - main struct
+ *           freq      - current sequence frequency
+ * Notes:
+ * Returns:  MV_OK if success, MV_FAIL if fail.
+ */
+int ddr3_read_leveling_hw(u32 freq, MV_DRAM_INFO *dram_info)
+{
+       u32 reg;
+
+       /* Debug message - Start Read leveling procedure */
+       DEBUG_RL_S("DDR3 - Read Leveling - Starting HW RL procedure\n");
+
+       /* Start Auto Read Leveling procedure */
+       reg = 1 << REG_DRAM_TRAINING_RL_OFFS;
+       /* Config the retest number */
+       reg |= (COUNT_HW_RL << REG_DRAM_TRAINING_RETEST_OFFS);
+
+       /* Enable CS in the automatic process */
+       reg |= (dram_info->cs_ena << REG_DRAM_TRAINING_CS_OFFS);
+
+       reg_write(REG_DRAM_TRAINING_ADDR, reg); /* 0x15B0 - Training Register */
+
+       reg = reg_read(REG_DRAM_TRAINING_SHADOW_ADDR) |
+               (1 << REG_DRAM_TRAINING_AUTO_OFFS);
+       reg_write(REG_DRAM_TRAINING_SHADOW_ADDR, reg);
+
+       /* Wait */
+       do {
+               reg = reg_read(REG_DRAM_TRAINING_SHADOW_ADDR) &
+                       (1 << REG_DRAM_TRAINING_AUTO_OFFS);
+       } while (reg);          /* Wait for '0' */
+
+       /* Check if Successful */
+       if (reg_read(REG_DRAM_TRAINING_SHADOW_ADDR) &
+           (1 << REG_DRAM_TRAINING_ERROR_OFFS)) {
+               u32 delay, phase, pup, cs;
+
+               dram_info->rl_max_phase = 0;
+               dram_info->rl_min_phase = 10;
+
+               /* Read results to arrays */
+               for (cs = 0; cs < MAX_CS; cs++) {
+                       if (dram_info->cs_ena & (1 << cs)) {
+                               for (pup = 0;
+                                    pup < dram_info->num_of_total_pups;
+                                    pup++) {
+                                       if (pup == dram_info->num_of_std_pups
+                                           && dram_info->ecc_ena)
+                                               pup = ECC_PUP;
+                                       reg =
+                                           ddr3_read_pup_reg(PUP_RL_MODE, cs,
+                                                             pup);
+                                       phase = (reg >> REG_PHY_PHASE_OFFS) &
+                                               PUP_PHASE_MASK;
+                                       delay = reg & PUP_DELAY_MASK;
+                                       dram_info->rl_val[cs][pup][P] = phase;
+                                       if (phase > dram_info->rl_max_phase)
+                                               dram_info->rl_max_phase = phase;
+                                       if (phase < dram_info->rl_min_phase)
+                                               dram_info->rl_min_phase = phase;
+                                       dram_info->rl_val[cs][pup][D] = delay;
+                                       dram_info->rl_val[cs][pup][S] =
+                                           RL_FINAL_STATE;
+                                       reg =
+                                           ddr3_read_pup_reg(PUP_RL_MODE + 0x1,
+                                                             cs, pup);
+                                       dram_info->rl_val[cs][pup][DQS] =
+                                           (reg & 0x3F);
+                               }
+#ifdef MV_DEBUG_RL
+                               /* Print results */
+                               DEBUG_RL_C("DDR3 - Read Leveling - Results for CS - ",
+                                          (u32) cs, 1);
+
+                               for (pup = 0;
+                                    pup < (dram_info->num_of_total_pups);
+                                    pup++) {
+                                       if (pup == dram_info->num_of_std_pups
+                                           && dram_info->ecc_ena)
+                                               pup = ECC_PUP;
+                                       DEBUG_RL_S("DDR3 - Read Leveling - PUP: ");
+                                       DEBUG_RL_D((u32) pup, 1);
+                                       DEBUG_RL_S(", Phase: ");
+                                       DEBUG_RL_D((u32) dram_info->
+                                                  rl_val[cs][pup][P], 1);
+                                       DEBUG_RL_S(", Delay: ");
+                                       DEBUG_RL_D((u32) dram_info->
+                                                  rl_val[cs][pup][D], 2);
+                                       DEBUG_RL_S("\n");
+                               }
+#endif
+                       }
+               }
+
+               dram_info->rd_rdy_dly =
+                       reg_read(REG_READ_DATA_READY_DELAYS_ADDR) &
+                       REG_READ_DATA_SAMPLE_DELAYS_MASK;
+               dram_info->rd_smpl_dly =
+                       reg_read(REG_READ_DATA_SAMPLE_DELAYS_ADDR) &
+                       REG_READ_DATA_READY_DELAYS_MASK;
+#ifdef MV_DEBUG_RL
+               DEBUG_RL_C("DDR3 - Read Leveling - Read Sample Delay: ",
+                          dram_info->rd_smpl_dly, 2);
+               DEBUG_RL_C("DDR3 - Read Leveling - Read Ready Delay: ",
+                          dram_info->rd_rdy_dly, 2);
+               DEBUG_RL_S("DDR3 - Read Leveling - HW RL Ended Successfully\n");
+#endif
+               return MV_OK;
+
+       } else {
+               DEBUG_RL_S("DDR3 - Read Leveling - HW RL Error\n");
+               return MV_FAIL;
+       }
+}
+
+/*
+ * Name:     ddr3_read_leveling_sw
+ * Desc:     Execute the Read leveling phase by SW
+ * Args:     dram_info - main struct
+ *           freq      - current sequence frequency
+ * Notes:
+ * Returns:  MV_OK if success, MV_FAIL if fail.
+ */
+int ddr3_read_leveling_sw(u32 freq, int ratio_2to1, MV_DRAM_INFO *dram_info)
+{
+       u32 reg, cs, ecc, pup_num, phase, delay, pup;
+       int status;
+
+       /* Debug message - Start Read leveling procedure */
+       DEBUG_RL_S("DDR3 - Read Leveling - Starting SW RL procedure\n");
+
+       /* Enable SW Read Leveling */
+       reg = reg_read(REG_DRAM_TRAINING_2_ADDR) |
+               (1 << REG_DRAM_TRAINING_2_SW_OVRD_OFFS);
+       reg &= ~(1 << REG_DRAM_TRAINING_2_RL_MODE_OFFS);
+       /* [0]=1 - Enable SW override  */
+       /* 0x15B8 - Training SW 2 Register */
+       reg_write(REG_DRAM_TRAINING_2_ADDR, reg);
+
+#ifdef RL_MODE
+       reg = (dram_info->cs_ena << REG_DRAM_TRAINING_CS_OFFS) |
+               (1 << REG_DRAM_TRAINING_AUTO_OFFS);
+       reg_write(REG_DRAM_TRAINING_ADDR, reg); /* 0x15B0 - Training Register */
+#endif
+
+       /* Loop for each CS */
+       for (cs = 0; cs < dram_info->num_cs; cs++) {
+               DEBUG_RL_C("DDR3 - Read Leveling - CS - ", (u32) cs, 1);
+
+               for (ecc = 0; ecc <= (dram_info->ecc_ena); ecc++) {
+                       /* ECC Support - Switch ECC Mux on ecc=1 */
+                       reg = reg_read(REG_DRAM_TRAINING_2_ADDR) &
+                               ~(1 << REG_DRAM_TRAINING_2_ECC_MUX_OFFS);
+                       reg |= (dram_info->ecc_ena *
+                               ecc << REG_DRAM_TRAINING_2_ECC_MUX_OFFS);
+                       reg_write(REG_DRAM_TRAINING_2_ADDR, reg);
+
+                       if (ecc)
+                               DEBUG_RL_S("DDR3 - Read Leveling - ECC Mux Enabled\n");
+                       else
+                               DEBUG_RL_S("DDR3 - Read Leveling - ECC Mux Disabled\n");
+
+                       /* Set current sample delays */
+                       reg = reg_read(REG_READ_DATA_SAMPLE_DELAYS_ADDR);
+                       reg &= ~(REG_READ_DATA_SAMPLE_DELAYS_MASK <<
+                                (REG_READ_DATA_SAMPLE_DELAYS_OFFS * cs));
+                       reg |= (dram_info->cl <<
+                               (REG_READ_DATA_SAMPLE_DELAYS_OFFS * cs));
+                       reg_write(REG_READ_DATA_SAMPLE_DELAYS_ADDR, reg);
+
+                       /* Set current Ready delay */
+                       reg = reg_read(REG_READ_DATA_READY_DELAYS_ADDR);
+                       reg &= ~(REG_READ_DATA_READY_DELAYS_MASK <<
+                                (REG_READ_DATA_READY_DELAYS_OFFS * cs));
+                       if (!ratio_2to1) {
+                               /* 1:1 mode */
+                               reg |= ((dram_info->cl + 1) <<
+                                       (REG_READ_DATA_READY_DELAYS_OFFS * cs));
+                       } else {
+                               /* 2:1 mode */
+                               reg |= ((dram_info->cl + 2) <<
+                                       (REG_READ_DATA_READY_DELAYS_OFFS * cs));
+                       }
+                       reg_write(REG_READ_DATA_READY_DELAYS_ADDR, reg);
+
+                       /* Read leveling Single CS[cs] */
+#ifdef RL_MODE
+                       status =
+                           ddr3_read_leveling_single_cs_rl_mode(cs, freq,
+                                                                ratio_2to1,
+                                                                ecc,
+                                                                dram_info);
+                       if (MV_OK != status)
+                               return status;
+#else
+                       status =
+                           ddr3_read_leveling_single_cs_window_mode(cs, freq,
+                                                                    ratio_2to1,
+                                                                    ecc,
+                                                                    dram_info)
+                           if (MV_OK != status)
+                               return status;
+#endif
+               }
+
+               /* Print results */
+               DEBUG_RL_C("DDR3 - Read Leveling - Results for CS - ", (u32) cs,
+                          1);
+
+               for (pup = 0;
+                    pup < (dram_info->num_of_std_pups + dram_info->ecc_ena);
+                    pup++) {
+                       DEBUG_RL_S("DDR3 - Read Leveling - PUP: ");
+                       DEBUG_RL_D((u32) pup, 1);
+                       DEBUG_RL_S(", Phase: ");
+                       DEBUG_RL_D((u32) dram_info->rl_val[cs][pup][P], 1);
+                       DEBUG_RL_S(", Delay: ");
+                       DEBUG_RL_D((u32) dram_info->rl_val[cs][pup][D], 2);
+                       DEBUG_RL_S("\n");
+               }
+
+               DEBUG_RL_C("DDR3 - Read Leveling - Read Sample Delay: ",
+                          dram_info->rd_smpl_dly, 2);
+               DEBUG_RL_C("DDR3 - Read Leveling - Read Ready Delay: ",
+                          dram_info->rd_rdy_dly, 2);
+
+               /* Configure PHY with average of 3 locked leveling settings */
+               for (pup = 0;
+                    pup < (dram_info->num_of_std_pups + dram_info->ecc_ena);
+                    pup++) {
+                       /* ECC support - bit 8 */
+                       pup_num = (pup == dram_info->num_of_std_pups) ? ECC_BIT : pup;
+
+                       /* For now, set last cnt result */
+                       phase = dram_info->rl_val[cs][pup][P];
+                       delay = dram_info->rl_val[cs][pup][D];
+                       ddr3_write_pup_reg(PUP_RL_MODE, cs, pup_num, phase,
+                                          delay);
+               }
+       }
+
+       /* Reset PHY read FIFO */
+       reg = reg_read(REG_DRAM_TRAINING_2_ADDR) |
+               (1 << REG_DRAM_TRAINING_2_FIFO_RST_OFFS);
+       /* 0x15B8 - Training SW 2 Register */
+       reg_write(REG_DRAM_TRAINING_2_ADDR, reg);
+
+       do {
+               reg = (reg_read(REG_DRAM_TRAINING_2_ADDR)) &
+                       (1 << REG_DRAM_TRAINING_2_FIFO_RST_OFFS);
+       } while (reg);          /* Wait for '0' */
+
+       /* ECC Support - Switch ECC Mux off ecc=0 */
+       reg = reg_read(REG_DRAM_TRAINING_2_ADDR) &
+               ~(1 << REG_DRAM_TRAINING_2_ECC_MUX_OFFS);
+       reg_write(REG_DRAM_TRAINING_2_ADDR, reg);
+
+#ifdef RL_MODE
+       reg_write(REG_DRAM_TRAINING_ADDR, 0);   /* 0x15B0 - Training Register */
+#endif
+
+       /* Disable SW Read Leveling */
+       reg = reg_read(REG_DRAM_TRAINING_2_ADDR) &
+               ~(1 << REG_DRAM_TRAINING_2_SW_OVRD_OFFS);
+       /* [0] = 0 - Disable SW override  */
+       reg = (reg | (0x1 << REG_DRAM_TRAINING_2_RL_MODE_OFFS));
+       /* [3] = 1 - Disable RL MODE */
+       /* 0x15B8 - Training SW 2 Register */
+       reg_write(REG_DRAM_TRAINING_2_ADDR, reg);
+
+       DEBUG_RL_S("DDR3 - Read Leveling - Finished RL procedure for all CS\n");
+       return MV_OK;
+}
+
+#ifdef RL_MODE
+/*
+ * overrun() extracted from ddr3_read_leveling_single_cs_rl_mode().
+ * This just got too much indented making it hard to read / edit.
+ */
+static void overrun(u32 cs, MV_DRAM_INFO *info, u32 pup, u32 locked_pups,
+                   u32 *locked_sum, u32 ecc, int *first_octet_locked,
+                   int *counter_in_progress, int final_delay, u32 delay,
+                   u32 phase)
+{
+       /* If no OverRun */
+       if (((~locked_pups >> pup) & 0x1) && (final_delay == 0)) {
+               int idx;
+
+               idx = pup + ecc * ECC_BIT;
+
+               /* PUP passed, start examining */
+               if (info->rl_val[cs][idx][S] == RL_UNLOCK_STATE) {
+                       /* Must be RL_UNLOCK_STATE */
+                       /* Match expected value ? - Update State Machine */
+                       if (info->rl_val[cs][idx][C] < RL_RETRY_COUNT) {
+                               DEBUG_RL_FULL_C("DDR3 - Read Leveling - We have no overrun and a match on pup: ",
+                                               (u32)pup, 1);
+                               info->rl_val[cs][idx][C]++;
+
+                               /* If pup got to last state - lock the delays */
+                               if (info->rl_val[cs][idx][C] == RL_RETRY_COUNT) {
+                                       info->rl_val[cs][idx][C] = 0;
+                                       info->rl_val[cs][idx][DS] = delay;
+                                       info->rl_val[cs][idx][PS] = phase;
+
+                                       /* Go to Final State */
+                                       info->rl_val[cs][idx][S] = RL_FINAL_STATE;
+                                       *locked_sum = *locked_sum + 1;
+                                       DEBUG_RL_FULL_C("DDR3 - Read Leveling - We have locked pup: ",
+                                                       (u32)pup, 1);
+
+                                       /*
+                                        * If first lock - need to lock delays
+                                        */
+                                       if (*first_octet_locked == 0) {
+                                               DEBUG_RL_FULL_C("DDR3 - Read Leveling - We got first lock on pup: ",
+                                                               (u32)pup, 1);
+                                               *first_octet_locked = 1;
+                                       }
+
+                                       /*
+                                        * If pup is in not in final state but
+                                        * there was match - dont increment
+                                        * counter
+                                        */
+                               } else {
+                                       *counter_in_progress = 1;
+                               }
+                       }
+               }
+       }
+}
+
+/*
+ * Name:     ddr3_read_leveling_single_cs_rl_mode
+ * Desc:     Execute Read leveling for single Chip select
+ * Args:     cs        - current chip select
+ *           freq      - current sequence frequency
+ *           ecc       - ecc iteration indication
+ *           dram_info - main struct
+ * Notes:
+ * Returns:  MV_OK if success, MV_FAIL if fail.
+ */
+static int ddr3_read_leveling_single_cs_rl_mode(u32 cs, u32 freq,
+                                               int ratio_2to1, u32 ecc,
+                                               MV_DRAM_INFO *dram_info)
+{
+       u32 reg, delay, phase, pup, rd_sample_delay, add, locked_pups,
+               repeat_max_cnt, sdram_offset, locked_sum;
+       u32 phase_min, ui_max_delay;
+       int all_locked, first_octet_locked, counter_in_progress;
+       int final_delay = 0;
+
+       DEBUG_RL_FULL_C("DDR3 - Read Leveling - Single CS - ", (u32) cs, 1);
+
+       /* Init values */
+       phase = 0;
+       delay = 0;
+       rd_sample_delay = dram_info->cl;
+       all_locked = 0;
+       first_octet_locked = 0;
+       repeat_max_cnt = 0;
+       locked_sum = 0;
+
+       for (pup = 0; pup < (dram_info->num_of_std_pups * (1 - ecc) + ecc);
+            pup++)
+               dram_info->rl_val[cs][pup + ecc * ECC_BIT][S] = 0;
+
+       /* Main loop */
+       while (!all_locked) {
+               counter_in_progress = 0;
+
+               DEBUG_RL_FULL_S("DDR3 - Read Leveling - RdSmplDly = ");
+               DEBUG_RL_FULL_D(rd_sample_delay, 2);
+               DEBUG_RL_FULL_S(", RdRdyDly = ");
+               DEBUG_RL_FULL_D(dram_info->rd_rdy_dly, 2);
+               DEBUG_RL_FULL_S(", Phase = ");
+               DEBUG_RL_FULL_D(phase, 1);
+               DEBUG_RL_FULL_S(", Delay = ");
+               DEBUG_RL_FULL_D(delay, 2);
+               DEBUG_RL_FULL_S("\n");
+
+               /*
+                * Broadcast to all PUPs current RL delays: DQS phase,
+                * leveling delay
+                */
+               ddr3_write_pup_reg(PUP_RL_MODE, cs, PUP_BC, phase, delay);
+
+               /* Reset PHY read FIFO */
+               reg = reg_read(REG_DRAM_TRAINING_2_ADDR) |
+                       (1 << REG_DRAM_TRAINING_2_FIFO_RST_OFFS);
+               /* 0x15B8 - Training SW 2 Register */
+               reg_write(REG_DRAM_TRAINING_2_ADDR, reg);
+
+               do {
+                       reg = (reg_read(REG_DRAM_TRAINING_2_ADDR)) &
+                               (1 << REG_DRAM_TRAINING_2_FIFO_RST_OFFS);
+               } while (reg);  /* Wait for '0' */
+
+               /* Read pattern from SDRAM */
+               sdram_offset = cs * (SDRAM_CS_SIZE + 1) + SDRAM_RL_OFFS;
+               locked_pups = 0;
+               if (MV_OK !=
+                   ddr3_sdram_compare(dram_info, 0xFF, &locked_pups,
+                                      rl_pattern, LEN_STD_PATTERN,
+                                      sdram_offset, 0, 0, NULL, 0))
+                       return MV_DDR3_TRAINING_ERR_RD_LVL_RL_PATTERN;
+
+               /* Octet evaluation */
+               /* pup_num = Q or 1 for ECC */
+               for (pup = 0; pup < (dram_info->num_of_std_pups * (1 - ecc) + ecc); pup++) {
+                       /* Check Overrun */
+                       if (!((reg_read(REG_DRAM_TRAINING_2_ADDR) >>
+                              (REG_DRAM_TRAINING_2_OVERRUN_OFFS + pup)) & 0x1)) {
+                               overrun(cs, dram_info, pup, locked_pups,
+                                       &locked_sum, ecc, &first_octet_locked,
+                                       &counter_in_progress, final_delay,
+                                       delay, phase);
+                       } else {
+                               DEBUG_RL_FULL_C("DDR3 - Read Leveling - We got overrun on pup: ",
+                                               (u32)pup, 1);
+                       }
+               }
+
+               if (locked_sum == (dram_info->num_of_std_pups *
+                                  (1 - ecc) + ecc)) {
+                       all_locked = 1;
+                       DEBUG_RL_FULL_S("DDR3 - Read Leveling - Single Cs - All pups locked\n");
+               }
+
+               /*
+                * This is a fix for unstable condition where pups are
+                * toggling between match and no match
+                */
+               /*
+                * If some of the pups is >1 <3, check if we did it too
+                * many times
+                */
+               if (counter_in_progress == 1) {
+                       /* Notify at least one Counter is >=1 and < 3 */
+                       if (repeat_max_cnt < RL_RETRY_COUNT) {
+                               repeat_max_cnt++;
+                               counter_in_progress = 1;
+                               DEBUG_RL_FULL_S("DDR3 - Read Leveling - Counter is >=1 and <3\n");
+                               DEBUG_RL_FULL_S("DDR3 - Read Leveling - So we will not increment the delay to see if locked again\n");
+                       } else {
+                               DEBUG_RL_FULL_S("DDR3 - Read Leveling - repeat_max_cnt reached max so now we will increment the delay\n");
+                               counter_in_progress = 0;
+                       }
+               }
+
+               /*
+                * Check some of the pups are in the middle of state machine
+                * and don't increment the delays
+                */
+               if (!counter_in_progress && !all_locked) {
+                       int idx;
+
+                       idx = pup + ecc * ECC_BIT;
+
+                       repeat_max_cnt = 0;
+                       /* if 1:1 mode */
+                       if ((!ratio_2to1) && ((phase == 0) || (phase == 4)))
+                               ui_max_delay = MAX_DELAY_INV;
+                       else
+                               ui_max_delay = MAX_DELAY;
+
+                       /* Increment Delay */
+                       if (delay < ui_max_delay) {
+                               delay++;
+                               /*
+                                * Mark the last delay/pahse place for
+                                * window final place
+                                */
+                               if (delay == ui_max_delay) {
+                                       if ((!ratio_2to1 && phase ==
+                                            MAX_PHASE_RL_L_1TO1)
+                                           || (ratio_2to1 && phase ==
+                                               MAX_PHASE_RL_L_2TO1))
+                                               final_delay = 1;
+                               }
+                       } else {
+                               /* Phase+CL Incrementation */
+                               delay = 0;
+
+                               if (!ratio_2to1) {
+                                       /* 1:1 mode */
+                                       if (first_octet_locked) {
+                                               /* some Pup was Locked */
+                                               if (phase < MAX_PHASE_RL_L_1TO1) {
+                                                       if (phase == 1) {
+                                                               phase = 4;
+                                                       } else {
+                                                               phase++;
+                                                               delay = MIN_DELAY_PHASE_1_LIMIT;
+                                                       }
+                                               } else {
+                                                       DEBUG_RL_FULL_S("DDR3 - Read Leveling - ERROR - NOT all PUPs Locked\n");
+                                                       DEBUG_RL_S("1)DDR3 - Read Leveling - ERROR - NOT all PUPs Locked n");
+                                                       return MV_DDR3_TRAINING_ERR_RD_LVL_RL_PUP_UNLOCK;
+                                               }
+                                       } else {
+                                               /* NO Pup was Locked */
+                                               if (phase < MAX_PHASE_RL_UL_1TO1) {
+                                                       phase++;
+                                                       delay =
+                                                           MIN_DELAY_PHASE_1_LIMIT;
+                                               } else {
+                                                       phase = 0;
+                                               }
+                                       }
+                               } else {
+                                       /* 2:1 mode */
+                                       if (first_octet_locked) {
+                                               /* some Pup was Locked */
+                                               if (phase < MAX_PHASE_RL_L_2TO1) {
+                                                       phase++;
+                                               } else {
+                                                       DEBUG_RL_FULL_S("DDR3 - Read Leveling - ERROR - NOT all PUPs Locked\n");
+                                                       DEBUG_RL_S("2)DDR3 - Read Leveling - ERROR - NOT all PUPs Locked\n");
+                                                       for (pup = 0; pup < (dram_info->num_of_std_pups * (1 - ecc) + ecc); pup++) {
+                                                               /* pup_num = Q or 1 for ECC */
+                                                               if (dram_info->rl_val[cs][idx][S]
+                                                                   == 0) {
+                                                                       DEBUG_RL_C("Failed byte is = ",
+                                                                                  pup, 1);
+                                                               }
+                                                       }
+                                                       return MV_DDR3_TRAINING_ERR_RD_LVL_RL_PUP_UNLOCK;
+                                               }
+                                       } else {
+                                               /* No Pup was Locked */
+                                               if (phase < MAX_PHASE_RL_UL_2TO1)
+                                                       phase++;
+                                               else
+                                                       phase = 0;
+                                       }
+                               }
+
+                               /*
+                                * If we finished a full Phases cycle (so now
+                                * phase = 0, need to increment rd_sample_dly
+                                */
+                               if (phase == 0 && first_octet_locked == 0) {
+                                       rd_sample_delay++;
+                                       if (rd_sample_delay == 0x10) {
+                                               DEBUG_RL_FULL_S("DDR3 - Read Leveling - ERROR - NOT all PUPs Locked\n");
+                                               DEBUG_RL_S("3)DDR3 - Read Leveling - ERROR - NOT all PUPs Locked\n");
+                                               for (pup = 0; pup < (dram_info->num_of_std_pups * (1 - ecc) + ecc); pup++) {
+                                                       /* pup_num = Q or 1 for ECC */
+                                                       if (dram_info->
+                                                           rl_val[cs][idx][S] == 0) {
+                                                               DEBUG_RL_C("Failed byte is = ",
+                                                                          pup, 1);
+                                                       }
+                                               }
+                                               return MV_DDR3_TRAINING_ERR_RD_LVL_PUP_UNLOCK;
+                                       }
+
+                                       /* Set current rd_sample_delay  */
+                                       reg = reg_read(REG_READ_DATA_SAMPLE_DELAYS_ADDR);
+                                       reg &= ~(REG_READ_DATA_SAMPLE_DELAYS_MASK
+                                             << (REG_READ_DATA_SAMPLE_DELAYS_OFFS
+                                                 * cs));
+                                       reg |= (rd_sample_delay <<
+                                               (REG_READ_DATA_SAMPLE_DELAYS_OFFS *
+                                                cs));
+                                       reg_write(REG_READ_DATA_SAMPLE_DELAYS_ADDR,
+                                                 reg);
+                               }
+
+                               /*
+                                * Set current rdReadyDelay according to the
+                                * hash table (Need to do this in every phase
+                                * change)
+                                */
+                               if (!ratio_2to1) {
+                                       /* 1:1 mode */
+                                       add = reg_read(REG_TRAINING_DEBUG_2_ADDR);
+                                       switch (phase) {
+                                       case 0:
+                                               add = (add >>
+                                                      REG_TRAINING_DEBUG_2_OFFS);
+                                               break;
+                                       case 1:
+                                               add = (add >>
+                                                      (REG_TRAINING_DEBUG_2_OFFS
+                                                       + 3));
+                                               break;
+                                       case 4:
+                                               add = (add >>
+                                                      (REG_TRAINING_DEBUG_2_OFFS
+                                                       + 6));
+                                               break;
+                                       case 5:
+                                               add = (add >>
+                                                      (REG_TRAINING_DEBUG_2_OFFS
+                                                       + 9));
+                                               break;
+                                       }
+                                       add &= REG_TRAINING_DEBUG_2_MASK;
+                               } else {
+                                       /* 2:1 mode */
+                                       add = reg_read(REG_TRAINING_DEBUG_3_ADDR);
+                                       add = (add >>
+                                              (phase *
+                                               REG_TRAINING_DEBUG_3_OFFS));
+                                       add &= REG_TRAINING_DEBUG_3_MASK;
+                               }
+
+                               reg = reg_read(REG_READ_DATA_READY_DELAYS_ADDR);
+                               reg &= ~(REG_READ_DATA_READY_DELAYS_MASK <<
+                                        (REG_READ_DATA_READY_DELAYS_OFFS * cs));
+                               reg |= ((rd_sample_delay + add) <<
+                                       (REG_READ_DATA_READY_DELAYS_OFFS * cs));
+                               reg_write(REG_READ_DATA_READY_DELAYS_ADDR, reg);
+                               dram_info->rd_smpl_dly = rd_sample_delay;
+                               dram_info->rd_rdy_dly = rd_sample_delay + add;
+                       }
+
+                       /* Reset counters for pups with states<RD_STATE_COUNT */
+                       for (pup = 0; pup <
+                                    (dram_info->num_of_std_pups * (1 - ecc) + ecc);
+                            pup++) {
+                               if (dram_info->rl_val[cs][idx][C] < RL_RETRY_COUNT)
+                                       dram_info->rl_val[cs][idx][C] = 0;
+                       }
+               }
+       }
+
+       phase_min = 10;
+
+       for (pup = 0; pup < (dram_info->num_of_std_pups); pup++) {
+               if (dram_info->rl_val[cs][pup][PS] < phase_min)
+                       phase_min = dram_info->rl_val[cs][pup][PS];
+       }
+
+       /*
+        * Set current rdReadyDelay according to the hash table (Need to
+        * do this in every phase change)
+        */
+       if (!ratio_2to1) {
+               /* 1:1 mode */
+               add = reg_read(REG_TRAINING_DEBUG_2_ADDR);
+               switch (phase_min) {
+               case 0:
+                       add = (add >> REG_TRAINING_DEBUG_2_OFFS);
+                       break;
+               case 1:
+                       add = (add >> (REG_TRAINING_DEBUG_2_OFFS + 3));
+                       break;
+               case 4:
+                       add = (add >> (REG_TRAINING_DEBUG_2_OFFS + 6));
+                       break;
+               case 5:
+                       add = (add >> (REG_TRAINING_DEBUG_2_OFFS + 9));
+                       break;
+               }
+               add &= REG_TRAINING_DEBUG_2_MASK;
+       } else {
+               /* 2:1 mode */
+               add = reg_read(REG_TRAINING_DEBUG_3_ADDR);
+               add = (add >> (phase_min * REG_TRAINING_DEBUG_3_OFFS));
+               add &= REG_TRAINING_DEBUG_3_MASK;
+       }
+
+       reg = reg_read(REG_READ_DATA_READY_DELAYS_ADDR);
+       reg &= ~(REG_READ_DATA_READY_DELAYS_MASK <<
+                (REG_READ_DATA_READY_DELAYS_OFFS * cs));
+       reg |= ((rd_sample_delay + add) << (REG_READ_DATA_READY_DELAYS_OFFS * cs));
+       reg_write(REG_READ_DATA_READY_DELAYS_ADDR, reg);
+       dram_info->rd_rdy_dly = rd_sample_delay + add;
+
+       for (cs = 0; cs < dram_info->num_cs; cs++) {
+               for (pup = 0; pup < dram_info->num_of_total_pups; pup++) {
+                       reg = ddr3_read_pup_reg(PUP_RL_MODE + 0x1, cs, pup);
+                       dram_info->rl_val[cs][pup][DQS] = (reg & 0x3F);
+               }
+       }
+
+       return MV_OK;
+}
+
+#else
+
+/*
+ * Name:     ddr3_read_leveling_single_cs_window_mode
+ * Desc:     Execute Read leveling for single Chip select
+ * Args:     cs        - current chip select
+ *           freq      - current sequence frequency
+ *           ecc       - ecc iteration indication
+ *           dram_info - main struct
+ * Notes:
+ * Returns:  MV_OK if success, MV_FAIL if fail.
+ */
+static int ddr3_read_leveling_single_cs_window_mode(u32 cs, u32 freq,
+                                                   int ratio_2to1, u32 ecc,
+                                                   MV_DRAM_INFO *dram_info)
+{
+       u32 reg, delay, phase, sum, pup, rd_sample_delay, add, locked_pups,
+           repeat_max_cnt, sdram_offset, final_sum, locked_sum;
+       u32 delay_s, delay_e, tmp, phase_min, ui_max_delay;
+       int all_locked, first_octet_locked, counter_in_progress;
+       int final_delay = 0;
+
+       DEBUG_RL_FULL_C("DDR3 - Read Leveling - Single CS - ", (u32) cs, 1);
+
+       /* Init values */
+       phase = 0;
+       delay = 0;
+       rd_sample_delay = dram_info->cl;
+       all_locked = 0;
+       first_octet_locked = 0;
+       repeat_max_cnt = 0;
+       sum = 0;
+       final_sum = 0;
+       locked_sum = 0;
+
+       for (pup = 0; pup < (dram_info->num_of_std_pups * (1 - ecc) + ecc);
+            pup++)
+               dram_info->rl_val[cs][pup + ecc * ECC_BIT][S] = 0;
+
+       /* Main loop */
+       while (!all_locked) {
+               counter_in_progress = 0;
+
+               DEBUG_RL_FULL_S("DDR3 - Read Leveling - RdSmplDly = ");
+               DEBUG_RL_FULL_D(rd_sample_delay, 2);
+               DEBUG_RL_FULL_S(", RdRdyDly = ");
+               DEBUG_RL_FULL_D(dram_info->rd_rdy_dly, 2);
+               DEBUG_RL_FULL_S(", Phase = ");
+               DEBUG_RL_FULL_D(phase, 1);
+               DEBUG_RL_FULL_S(", Delay = ");
+               DEBUG_RL_FULL_D(delay, 2);
+               DEBUG_RL_FULL_S("\n");
+
+               /*
+                * Broadcast to all PUPs current RL delays: DQS phase,leveling
+                * delay
+                */
+               ddr3_write_pup_reg(PUP_RL_MODE, cs, PUP_BC, phase, delay);
+
+               /* Reset PHY read FIFO */
+               reg = reg_read(REG_DRAM_TRAINING_2_ADDR) |
+                       (1 << REG_DRAM_TRAINING_2_FIFO_RST_OFFS);
+               /* 0x15B8 - Training SW 2 Register */
+               reg_write(REG_DRAM_TRAINING_2_ADDR, reg);
+
+               do {
+                       reg = (reg_read(REG_DRAM_TRAINING_2_ADDR)) &
+                               (1 << REG_DRAM_TRAINING_2_FIFO_RST_OFFS);
+               } while (reg);  /* Wait for '0' */
+
+               /* Read pattern from SDRAM */
+               sdram_offset = cs * (SDRAM_CS_SIZE + 1) + SDRAM_RL_OFFS;
+               locked_pups = 0;
+               if (MV_OK !=
+                   ddr3_sdram_compare(dram_info, 0xFF, &locked_pups,
+                                      rl_pattern, LEN_STD_PATTERN,
+                                      sdram_offset, 0, 0, NULL, 0))
+                       return MV_DDR3_TRAINING_ERR_RD_LVL_WIN_PATTERN;
+
+               /* Octet evaluation */
+               for (pup = 0; pup < (dram_info->num_of_std_pups *
+                                    (1 - ecc) + ecc); pup++) {
+                       /* pup_num = Q or 1 for ECC */
+                       int idx;
+
+                       idx = pup + ecc * ECC_BIT;
+
+                       /* Check Overrun */
+                       if (!((reg_read(REG_DRAM_TRAINING_2_ADDR) >>
+                             (REG_DRAM_TRAINING_2_OVERRUN_OFFS +
+                              pup)) & 0x1)) {
+                               /* If no OverRun */
+
+                               /* Inside the window */
+                               if (dram_info->rl_val[cs][idx][S] == RL_WINDOW_STATE) {
+                                       /*
+                                        * Match expected value ? - Update
+                                        * State Machine
+                                        */
+                                       if (((~locked_pups >> pup) & 0x1)
+                                           && (final_delay == 0)) {
+                                               /* Match - Still inside the Window */
+                                               DEBUG_RL_FULL_C("DDR3 - Read Leveling - We got another match inside the window  for pup: ",
+                                                               (u32)pup, 1);
+
+                                       } else {
+                                               /* We got fail -> this is the end of the window */
+                                               dram_info->rl_val[cs][idx][DE] = delay;
+                                               dram_info->rl_val[cs][idx][PE] = phase;
+                                               /* Go to Final State */
+                                               dram_info->rl_val[cs][idx][S]++;
+                                               final_sum++;
+                                               DEBUG_RL_FULL_C("DDR3 - Read Leveling - We finished the window for pup: ",
+                                                               (u32)pup, 1);
+                                       }
+
+                                       /* Before the start of the window */
+                               } else if (dram_info->rl_val[cs][idx][S] ==
+                                          RL_UNLOCK_STATE) {
+                                       /* Must be RL_UNLOCK_STATE */
+                                       /*
+                                        * Match expected value ? - Update
+                                        * State Machine
+                                        */
+                                       if (dram_info->rl_val[cs][idx][C] <
+                                           RL_RETRY_COUNT) {
+                                               if (((~locked_pups >> pup) & 0x1)) {
+                                                       /* Match */
+                                                       DEBUG_RL_FULL_C("DDR3 - Read Leveling - We have no overrun and a match on pup: ",
+                                                                       (u32)pup, 1);
+                                                       dram_info->rl_val[cs][idx][C]++;
+
+                                                       /* If pup got to last state - lock the delays */
+                                                       if (dram_info->rl_val[cs][idx][C] ==
+                                                           RL_RETRY_COUNT) {
+                                                               dram_info->rl_val[cs][idx][C] = 0;
+                                                               dram_info->rl_val[cs][idx][DS] =
+                                                                       delay;
+                                                               dram_info->rl_val[cs][idx][PS] =
+                                                                       phase;
+                                                               dram_info->rl_val[cs][idx][S]++;        /* Go to Window State */
+                                                               locked_sum++;
+                                                               /* Will count the pups that got locked */
+
+                                                               /* IF First lock - need to lock delays */
+                                                               if (first_octet_locked == 0) {
+                                                                       DEBUG_RL_FULL_C("DDR3 - Read Leveling - We got first lock on pup: ",
+                                                                                       (u32)pup, 1);
+                                                                       first_octet_locked
+                                                                           =
+                                                                           1;
+                                                               }
+                                                       }
+
+                                                       /* if pup is in not in final state but there was match - dont increment counter */
+                                                       else {
+                                                               counter_in_progress
+                                                                   = 1;
+                                                       }
+                                               }
+                                       }
+                               }
+                       } else {
+                               DEBUG_RL_FULL_C("DDR3 - Read Leveling - We got overrun on pup: ",
+                                               (u32)pup, 1);
+                               counter_in_progress = 1;
+                       }
+               }
+
+               if (final_sum == (dram_info->num_of_std_pups * (1 - ecc) + ecc)) {
+                       all_locked = 1;
+                       DEBUG_RL_FULL_S("DDR3 - Read Leveling - Single Cs - All pups locked\n");
+               }
+
+               /*
+                * This is a fix for unstable condition where pups are
+                * toggling between match and no match
+                */
+               /*
+                * If some of the pups is >1 <3, check if we did it too many
+                * times
+                */
+               if (counter_in_progress == 1) {
+                       if (repeat_max_cnt < RL_RETRY_COUNT) {
+                               /* Notify at least one Counter is >=1 and < 3 */
+                               repeat_max_cnt++;
+                               counter_in_progress = 1;
+                               DEBUG_RL_FULL_S("DDR3 - Read Leveling - Counter is >=1 and <3\n");
+                               DEBUG_RL_FULL_S("DDR3 - Read Leveling - So we will not increment the delay to see if locked again\n");
+                       } else {
+                               DEBUG_RL_FULL_S("DDR3 - Read Leveling - repeat_max_cnt reached max so now we will increment the delay\n");
+                               counter_in_progress = 0;
+                       }
+               }
+
+               /*
+                * Check some of the pups are in the middle of state machine
+                * and don't increment the delays
+                */
+               if (!counter_in_progress && !all_locked) {
+                       repeat_max_cnt = 0;
+                       if (!ratio_2to1)
+                               ui_max_delay = MAX_DELAY_INV;
+                       else
+                               ui_max_delay = MAX_DELAY;
+
+                       /* Increment Delay */
+                       if (delay < ui_max_delay) {
+                               /* Delay Incrementation */
+                               delay++;
+                               if (delay == ui_max_delay) {
+                                       /*
+                                        * Mark the last delay/pahse place
+                                        * for window final place
+                                        */
+                                       if ((!ratio_2to1
+                                            && phase == MAX_PHASE_RL_L_1TO1)
+                                           || (ratio_2to1
+                                               && phase ==
+                                               MAX_PHASE_RL_L_2TO1))
+                                               final_delay = 1;
+                               }
+                       } else {
+                               /* Phase+CL Incrementation */
+                               delay = 0;
+                               if (!ratio_2to1) {
+                                       /* 1:1 mode */
+                                       if (first_octet_locked) {
+                                               /* some pupet was Locked */
+                                               if (phase < MAX_PHASE_RL_L_1TO1) {
+#ifdef RL_WINDOW_WA
+                                                       if (phase == 0)
+#else
+                                                       if (phase == 1)
+#endif
+                                                               phase = 4;
+                                                       else
+                                                               phase++;
+                                               } else {
+                                                       DEBUG_RL_FULL_S("DDR3 - Read Leveling - ERROR - NOT all PUPs Locked\n");
+                                                       return MV_DDR3_TRAINING_ERR_RD_LVL_WIN_PUP_UNLOCK;
+                                               }
+                                       } else {
+                                               /* No Pup was Locked */
+                                               if (phase < MAX_PHASE_RL_UL_1TO1) {
+#ifdef RL_WINDOW_WA
+                                                       if (phase == 0)
+                                                               phase = 4;
+#else
+                                                       phase++;
+#endif
+                                               } else
+                                                       phase = 0;
+                                       }
+                               } else {
+                                       /* 2:1 mode */
+                                       if (first_octet_locked) {
+                                               /* Some Pup was Locked */
+                                               if (phase < MAX_PHASE_RL_L_2TO1) {
+                                                       phase++;
+                                               } else {
+                                                       DEBUG_RL_FULL_S("DDR3 - Read Leveling - ERROR - NOT all PUPs Locked\n");
+                                                       return MV_DDR3_TRAINING_ERR_RD_LVL_WIN_PUP_UNLOCK;
+                                               }
+                                       } else {
+                                               /* No Pup was Locked */
+                                               if (phase < MAX_PHASE_RL_UL_2TO1)
+                                                       phase++;
+                                               else
+                                                       phase = 0;
+                                       }
+                               }
+
+                               /*
+                                * If we finished a full Phases cycle (so
+                                * now phase = 0, need to increment
+                                * rd_sample_dly
+                                */
+                               if (phase == 0 && first_octet_locked == 0) {
+                                       rd_sample_delay++;
+
+                                       /* Set current rd_sample_delay  */
+                                       reg = reg_read(REG_READ_DATA_SAMPLE_DELAYS_ADDR);
+                                       reg &= ~(REG_READ_DATA_SAMPLE_DELAYS_MASK <<
+                                                (REG_READ_DATA_SAMPLE_DELAYS_OFFS
+                                                 * cs));
+                                       reg |= (rd_sample_delay <<
+                                               (REG_READ_DATA_SAMPLE_DELAYS_OFFS *
+                                                cs));
+                                       reg_write(REG_READ_DATA_SAMPLE_DELAYS_ADDR,
+                                                 reg);
+                               }
+
+                               /*
+                                * Set current rdReadyDelay according to the
+                                * hash table (Need to do this in every phase
+                                * change)
+                                */
+                               if (!ratio_2to1) {
+                                       /* 1:1 mode */
+                                       add = reg_read(REG_TRAINING_DEBUG_2_ADDR);
+                                       switch (phase) {
+                                       case 0:
+                                               add = add >>
+                                                       REG_TRAINING_DEBUG_2_OFFS;
+                                               break;
+                                       case 1:
+                                               add = add >>
+                                                       (REG_TRAINING_DEBUG_2_OFFS
+                                                        + 3);
+                                               break;
+                                       case 4:
+                                               add = add >>
+                                                       (REG_TRAINING_DEBUG_2_OFFS
+                                                        + 6);
+                                               break;
+                                       case 5:
+                                               add = add >>
+                                                       (REG_TRAINING_DEBUG_2_OFFS
+                                                        + 9);
+                                               break;
+                                       }
+                               } else {
+                                       /* 2:1 mode */
+                                       add = reg_read(REG_TRAINING_DEBUG_3_ADDR);
+                                       add = (add >> phase *
+                                              REG_TRAINING_DEBUG_3_OFFS);
+                               }
+                               add &= REG_TRAINING_DEBUG_2_MASK;
+                               reg = reg_read(REG_READ_DATA_READY_DELAYS_ADDR);
+                               reg &= ~(REG_READ_DATA_READY_DELAYS_MASK <<
+                                        (REG_READ_DATA_READY_DELAYS_OFFS * cs));
+                               reg |= ((rd_sample_delay + add) <<
+                                       (REG_READ_DATA_READY_DELAYS_OFFS * cs));
+                               reg_write(REG_READ_DATA_READY_DELAYS_ADDR, reg);
+                               dram_info->rd_smpl_dly = rd_sample_delay;
+                               dram_info->rd_rdy_dly = rd_sample_delay + add;
+                       }
+
+                       /* Reset counters for pups with states<RD_STATE_COUNT */
+                       for (pup = 0;
+                            pup <
+                            (dram_info->num_of_std_pups * (1 - ecc) + ecc);
+                            pup++) {
+                               if (dram_info->rl_val[cs][idx][C] < RL_RETRY_COUNT)
+                                       dram_info->rl_val[cs][idx][C] = 0;
+                       }
+               }
+       }
+
+       phase_min = 10;
+
+       for (pup = 0; pup < (dram_info->num_of_std_pups); pup++) {
+               DEBUG_RL_S("DDR3 - Read Leveling - Window info - PUP: ");
+               DEBUG_RL_D((u32) pup, 1);
+               DEBUG_RL_S(", PS: ");
+               DEBUG_RL_D((u32) dram_info->rl_val[cs][pup][PS], 1);
+               DEBUG_RL_S(", DS: ");
+               DEBUG_RL_D((u32) dram_info->rl_val[cs][pup][DS], 2);
+               DEBUG_RL_S(", PE: ");
+               DEBUG_RL_D((u32) dram_info->rl_val[cs][pup][PE], 1);
+               DEBUG_RL_S(", DE: ");
+               DEBUG_RL_D((u32) dram_info->rl_val[cs][pup][DE], 2);
+               DEBUG_RL_S("\n");
+       }
+
+       /* Find center of the window procedure */
+       for (pup = 0; pup < (dram_info->num_of_std_pups * (1 - ecc) + ecc);
+            pup++) {
+#ifdef RL_WINDOW_WA
+               if (!ratio_2to1) {      /* 1:1 mode */
+                       if (dram_info->rl_val[cs][idx][PS] == 4)
+                               dram_info->rl_val[cs][idx][PS] = 1;
+                       if (dram_info->rl_val[cs][idx][PE] == 4)
+                               dram_info->rl_val[cs][idx][PE] = 1;
+
+                       delay_s = dram_info->rl_val[cs][idx][PS] *
+                               MAX_DELAY_INV + dram_info->rl_val[cs][idx][DS];
+                       delay_e = dram_info->rl_val[cs][idx][PE] *
+                               MAX_DELAY_INV + dram_info->rl_val[cs][idx][DE];
+
+                       tmp = (delay_e - delay_s) / 2 + delay_s;
+                       phase = tmp / MAX_DELAY_INV;
+                       if (phase == 1) /* 1:1 mode */
+                               phase = 4;
+
+                       if (phase < phase_min)  /* for the read ready delay */
+                               phase_min = phase;
+
+                       dram_info->rl_val[cs][idx][P] = phase;
+                       dram_info->rl_val[cs][idx][D] = tmp % MAX_DELAY_INV;
+
+               } else {
+                       delay_s = dram_info->rl_val[cs][idx][PS] *
+                               MAX_DELAY + dram_info->rl_val[cs][idx][DS];
+                       delay_e = dram_info->rl_val[cs][idx][PE] *
+                               MAX_DELAY + dram_info->rl_val[cs][idx][DE];
+
+                       tmp = (delay_e - delay_s) / 2 + delay_s;
+                       phase = tmp / MAX_DELAY;
+
+                       if (phase < phase_min)  /* for the read ready delay */
+                               phase_min = phase;
+
+                       dram_info->rl_val[cs][idx][P] = phase;
+                       dram_info->rl_val[cs][idx][D] = tmp % MAX_DELAY;
+               }
+#else
+               if (!ratio_2to1) {      /* 1:1 mode */
+                       if (dram_info->rl_val[cs][idx][PS] > 1)
+                               dram_info->rl_val[cs][idx][PS] -= 2;
+                       if (dram_info->rl_val[cs][idx][PE] > 1)
+                               dram_info->rl_val[cs][idx][PE] -= 2;
+               }
+
+               delay_s = dram_info->rl_val[cs][idx][PS] * MAX_DELAY +
+                       dram_info->rl_val[cs][idx][DS];
+               delay_e = dram_info->rl_val[cs][idx][PE] * MAX_DELAY +
+                       dram_info->rl_val[cs][idx][DE];
+
+               tmp = (delay_e - delay_s) / 2 + delay_s;
+               phase = tmp / MAX_DELAY;
+               if (!ratio_2to1 && phase > 1)   /* 1:1 mode */
+                       phase += 2;
+
+               if (phase < phase_min)  /* for the read ready delay */
+                       phase_min = phase;
+
+               dram_info->rl_val[cs][idx][P] = phase;
+               dram_info->rl_val[cs][idx][D] = tmp % MAX_DELAY;
+#endif
+       }
+
+       /* Set current rdReadyDelay according to the hash table (Need to do this in every phase change) */
+       if (!ratio_2to1) {      /* 1:1 mode */
+               add = reg_read(REG_TRAINING_DEBUG_2_ADDR);
+               switch (phase_min) {
+               case 0:
+                       add = (add >> REG_TRAINING_DEBUG_2_OFFS);
+                       break;
+               case 1:
+                       add = (add >> (REG_TRAINING_DEBUG_2_OFFS + 3));
+                       break;
+               case 4:
+                       add = (add >> (REG_TRAINING_DEBUG_2_OFFS + 6));
+                       break;
+               case 5:
+                       add = (add >> (REG_TRAINING_DEBUG_2_OFFS + 9));
+                       break;
+               }
+       } else {                /* 2:1 mode */
+               add = reg_read(REG_TRAINING_DEBUG_3_ADDR);
+               add = (add >> phase_min * REG_TRAINING_DEBUG_3_OFFS);
+       }
+
+       add &= REG_TRAINING_DEBUG_2_MASK;
+       reg = reg_read(REG_READ_DATA_READY_DELAYS_ADDR);
+       reg &=
+           ~(REG_READ_DATA_READY_DELAYS_MASK <<
+             (REG_READ_DATA_READY_DELAYS_OFFS * cs));
+       reg |=
+           ((rd_sample_delay + add) << (REG_READ_DATA_READY_DELAYS_OFFS * cs));
+       reg_write(REG_READ_DATA_READY_DELAYS_ADDR, reg);
+       dram_info->rd_rdy_dly = rd_sample_delay + add;
+
+       for (cs = 0; cs < dram_info->num_cs; cs++) {
+               for (pup = 0; pup < dram_info->num_of_total_pups; pup++) {
+                       reg = ddr3_read_pup_reg(PUP_RL_MODE + 0x1, cs, pup);
+                       dram_info->rl_val[cs][pup][DQS] = (reg & 0x3F);
+               }
+       }
+
+       return MV_OK;
+}
+#endif
diff --git a/drivers/ddr/mvebu/ddr3_sdram.c b/drivers/ddr/mvebu/ddr3_sdram.c
new file mode 100644 (file)
index 0000000..50c1bf8
--- /dev/null
@@ -0,0 +1,669 @@
+/*
+ * Copyright (C) Marvell International Ltd. and its affiliates
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#include <common.h>
+#include <i2c.h>
+#include <spl.h>
+#include <asm/io.h>
+#include <asm/arch/cpu.h>
+#include <asm/arch/soc.h>
+
+#include "ddr3_hw_training.h"
+#include "xor.h"
+#include "xor_regs.h"
+
+static void ddr3_flush_l1_line(u32 line);
+
+extern u32 pbs_pattern[2][LEN_16BIT_PBS_PATTERN];
+extern u32 pbs_pattern_32b[2][LEN_PBS_PATTERN];
+#if defined(MV88F78X60)
+extern u32 pbs_pattern_64b[2][LEN_PBS_PATTERN];
+#endif
+extern u32 pbs_dq_mapping[PUP_NUM_64BIT][DQ_NUM];
+
+#if defined(MV88F78X60) || defined(MV88F672X)
+/* PBS locked dq (per pup) */
+u32 pbs_locked_dq[MAX_PUP_NUM][DQ_NUM] = { { 0 } };
+u32 pbs_locked_dm[MAX_PUP_NUM] = { 0 };
+u32 pbs_locked_value[MAX_PUP_NUM][DQ_NUM] = { { 0 } };
+
+int per_bit_data[MAX_PUP_NUM][DQ_NUM];
+#endif
+
+static u32 sdram_data[LEN_KILLER_PATTERN] __aligned(32) = { 0 };
+
+static struct crc_dma_desc dma_desc __aligned(32) = { 0 };
+
+#define XOR_TIMEOUT 0x8000000
+
+struct xor_channel_t {
+       struct crc_dma_desc *desc;
+       unsigned long desc_phys_addr;
+};
+
+#define XOR_CAUSE_DONE_MASK(chan)      ((0x1 | 0x2) << (chan * 16))
+
+void xor_waiton_eng(int chan)
+{
+       int timeout;
+
+       timeout = 0;
+       while (!(reg_read(XOR_CAUSE_REG(XOR_UNIT(chan))) &
+                XOR_CAUSE_DONE_MASK(XOR_CHAN(chan)))) {
+               if (timeout > XOR_TIMEOUT)
+                       goto timeout;
+
+               timeout++;
+       }
+
+       timeout = 0;
+       while (mv_xor_state_get(chan) != MV_IDLE) {
+               if (timeout > XOR_TIMEOUT)
+                       goto timeout;
+
+               timeout++;
+       }
+
+       /* Clear int */
+       reg_write(XOR_CAUSE_REG(XOR_UNIT(chan)),
+                 ~(XOR_CAUSE_DONE_MASK(XOR_CHAN(chan))));
+
+timeout:
+       return;
+}
+
+static int special_compare_pattern(u32 uj)
+{
+       if ((uj == 30) || (uj == 31) || (uj == 61) || (uj == 62) ||
+           (uj == 93) || (uj == 94) || (uj == 126) || (uj == 127))
+               return 1;
+
+       return 0;
+}
+
+/*
+ * Compare code extracted as its used by multiple functions. This
+ * reduces code-size and makes it easier to maintain it. Additionally
+ * the code is not indented that much and therefore easier to read.
+ */
+static void compare_pattern_v1(u32 uj, u32 *pup, u32 *pattern,
+                              u32 pup_groups, int debug_dqs)
+{
+       u32 val;
+       u32 uk;
+       u32 var1;
+       u32 var2;
+       __maybe_unused u32 dq;
+
+       if (((sdram_data[uj]) != (pattern[uj])) && (*pup != 0xFF)) {
+               for (uk = 0; uk < PUP_NUM_32BIT; uk++) {
+                       val = CMP_BYTE_SHIFT * uk;
+                       var1 = ((sdram_data[uj] >> val) & CMP_BYTE_MASK);
+                       var2 = ((pattern[uj] >> val) & CMP_BYTE_MASK);
+
+                       if (var1 != var2) {
+                               *pup |= (1 << (uk + (PUP_NUM_32BIT *
+                                                    (uj % pup_groups))));
+
+#ifdef MV_DEBUG_DQS
+                               if (!debug_dqs)
+                                       continue;
+
+                               for (dq = 0; dq < DQ_NUM; dq++) {
+                                       val = uk + (PUP_NUM_32BIT *
+                                                   (uj % pup_groups));
+                                       if (((var1 >> dq) & 0x1) !=
+                                           ((var2 >> dq) & 0x1))
+                                               per_bit_data[val][dq] = 1;
+                                       else
+                                               per_bit_data[val][dq] = 0;
+                               }
+#endif
+                       }
+               }
+       }
+}
+
+static void compare_pattern_v2(u32 uj, u32 *pup, u32 *pattern)
+{
+       u32 val;
+       u32 uk;
+       u32 var1;
+       u32 var2;
+
+       if (((sdram_data[uj]) != (pattern[uj])) && (*pup != 0x3)) {
+               /* Found error */
+               for (uk = 0; uk < PUP_NUM_32BIT; uk++) {
+                       val = CMP_BYTE_SHIFT * uk;
+                       var1 = (sdram_data[uj] >> val) & CMP_BYTE_MASK;
+                       var2 = (pattern[uj] >> val) & CMP_BYTE_MASK;
+                       if (var1 != var2)
+                               *pup |= (1 << (uk % PUP_NUM_16BIT));
+               }
+       }
+}
+
+/*
+ * Name:     ddr3_sdram_compare
+ * Desc:     Execute compare per PUP
+ * Args:     unlock_pup      Bit array of the unlock pups
+ *           new_locked_pup  Output  bit array of the pups with failed compare
+ *           pattern         Pattern to compare
+ *           pattern_len     Length of pattern (in bytes)
+ *           sdram_offset    offset address to the SDRAM
+ *           write           write to the SDRAM before read
+ *           mask            compare pattern with mask;
+ *           mask_pattern    Mask to compare pattern
+ *
+ * Notes:
+ * Returns:  MV_OK if success, other error code if fail.
+ */
+int ddr3_sdram_compare(MV_DRAM_INFO *dram_info, u32 unlock_pup,
+                      u32 *new_locked_pup, u32 *pattern,
+                      u32 pattern_len, u32 sdram_offset, int write,
+                      int mask, u32 *mask_pattern,
+                      int special_compare)
+{
+       u32 uj;
+       __maybe_unused u32 pup_groups;
+       __maybe_unused u32 dq;
+
+#if !defined(MV88F67XX)
+       if (dram_info->num_of_std_pups == PUP_NUM_64BIT)
+               pup_groups = 2;
+       else
+               pup_groups = 1;
+#endif
+
+       ddr3_reset_phy_read_fifo();
+
+       /* Check if need to write to sdram before read */
+       if (write == 1)
+               ddr3_dram_sram_burst((u32)pattern, sdram_offset, pattern_len);
+
+       ddr3_dram_sram_burst(sdram_offset, (u32)sdram_data, pattern_len);
+
+       /* Compare read result to write */
+       for (uj = 0; uj < pattern_len; uj++) {
+               if (special_compare && special_compare_pattern(uj))
+                       continue;
+
+#if defined(MV88F78X60) || defined(MV88F672X)
+               compare_pattern_v1(uj, new_locked_pup, pattern, pup_groups, 1);
+#elif defined(MV88F67XX)
+               compare_pattern_v2(uj, new_locked_pup, pattern);
+#endif
+       }
+
+       return MV_OK;
+}
+
+#if defined(MV88F78X60) || defined(MV88F672X)
+/*
+ * Name:     ddr3_sdram_dm_compare
+ * Desc:     Execute compare per PUP
+ * Args:     unlock_pup      Bit array of the unlock pups
+ *           new_locked_pup  Output  bit array of the pups with failed compare
+ *           pattern         Pattern to compare
+ *           pattern_len     Length of pattern (in bytes)
+ *           sdram_offset    offset address to the SDRAM
+ *           write           write to the SDRAM before read
+ *           mask            compare pattern with mask;
+ *           mask_pattern    Mask to compare pattern
+ *
+ * Notes:
+ * Returns:  MV_OK if success, other error code if fail.
+ */
+int ddr3_sdram_dm_compare(MV_DRAM_INFO *dram_info, u32 unlock_pup,
+                         u32 *new_locked_pup, u32 *pattern,
+                         u32 sdram_offset)
+{
+       u32 uj, uk, var1, var2, pup_groups;
+       u32 val;
+       u32 pup = 0;
+
+       if (dram_info->num_of_std_pups == PUP_NUM_64BIT)
+               pup_groups = 2;
+       else
+               pup_groups = 1;
+
+       ddr3_dram_sram_burst((u32)pattern, SDRAM_PBS_TX_OFFS,
+                            LEN_PBS_PATTERN);
+       ddr3_dram_sram_burst(SDRAM_PBS_TX_OFFS, (u32)sdram_data,
+                            LEN_PBS_PATTERN);
+
+       /* Validate the correctness of the results */
+       for (uj = 0; uj < LEN_PBS_PATTERN; uj++)
+               compare_pattern_v1(uj, &pup, pattern, pup_groups, 0);
+
+       /* Test the DM Signals */
+       *(u32 *)(SDRAM_PBS_TX_OFFS + 0x10) = 0x12345678;
+       *(u32 *)(SDRAM_PBS_TX_OFFS + 0x14) = 0x12345678;
+
+       sdram_data[0] = *(u32 *)(SDRAM_PBS_TX_OFFS + 0x10);
+       sdram_data[1] = *(u32 *)(SDRAM_PBS_TX_OFFS + 0x14);
+
+       for (uj = 0; uj < 2; uj++) {
+               if (((sdram_data[uj]) != (pattern[uj])) &&
+                   (*new_locked_pup != 0xFF)) {
+                       for (uk = 0; uk < PUP_NUM_32BIT; uk++) {
+                               val = CMP_BYTE_SHIFT * uk;
+                               var1 = ((sdram_data[uj] >> val) & CMP_BYTE_MASK);
+                               var2 = ((pattern[uj] >> val) & CMP_BYTE_MASK);
+                               if (var1 != var2) {
+                                       *new_locked_pup |= (1 << (uk +
+                                               (PUP_NUM_32BIT * (uj % pup_groups))));
+                                       *new_locked_pup |= pup;
+                               }
+                       }
+               }
+       }
+
+       return MV_OK;
+}
+
+/*
+ * Name:     ddr3_sdram_pbs_compare
+ * Desc:     Execute SRAM compare per PUP and DQ.
+ * Args:     pup_locked             bit array of locked pups
+ *           is_tx                  Indicate whether Rx or Tx
+ *           pbs_pattern_idx        Index of PBS pattern
+ *           pbs_curr_val           The PBS value
+ *           pbs_lock_val           The value to set to locked PBS
+ *           skew_array             Global array to update with the compare results
+ *           ai_unlock_pup_dq_array bit array of the locked / unlocked pups per dq.
+ * Notes:
+ * Returns:  MV_OK if success, other error code if fail.
+ */
+int ddr3_sdram_pbs_compare(MV_DRAM_INFO *dram_info, u32 pup_locked,
+                          int is_tx, u32 pbs_pattern_idx,
+                          u32 pbs_curr_val, u32 pbs_lock_val,
+                          u32 *skew_array, u8 *unlock_pup_dq_array,
+                          u32 ecc)
+{
+       /* bit array failed dq per pup for current compare */
+       u32 pbs_write_pup[DQ_NUM] = { 0 };
+       u32 update_pup; /* pup as HW convention */
+       u32 max_pup;    /* maximal pup index */
+       u32 pup_addr;
+       u32 ui, dq, pup;
+       int var1, var2;
+       u32 sdram_offset, pup_groups, tmp_pup;
+       u32 *pattern_ptr;
+       u32 val;
+
+       /* Choose pattern */
+       switch (dram_info->ddr_width) {
+#if defined(MV88F672X)
+       case 16:
+               pattern_ptr = (u32 *)&pbs_pattern[pbs_pattern_idx];
+               break;
+#endif
+       case 32:
+               pattern_ptr = (u32 *)&pbs_pattern_32b[pbs_pattern_idx];
+               break;
+#if defined(MV88F78X60)
+       case 64:
+               pattern_ptr = (u32 *)&pbs_pattern_64b[pbs_pattern_idx];
+               break;
+#endif
+       default:
+               return MV_FAIL;
+       }
+
+       max_pup = dram_info->num_of_std_pups;
+
+       sdram_offset = SDRAM_PBS_I_OFFS + pbs_pattern_idx * SDRAM_PBS_NEXT_OFFS;
+
+       if (dram_info->num_of_std_pups == PUP_NUM_64BIT)
+               pup_groups = 2;
+       else
+               pup_groups = 1;
+
+       ddr3_reset_phy_read_fifo();
+
+       /* Check if need to write to sdram before read */
+       if (is_tx == 1) {
+               ddr3_dram_sram_burst((u32)pattern_ptr, sdram_offset,
+                                    LEN_PBS_PATTERN);
+       }
+
+       ddr3_dram_sram_read(sdram_offset, (u32)sdram_data, LEN_PBS_PATTERN);
+
+       /* Compare read result to write */
+       for (ui = 0; ui < LEN_PBS_PATTERN; ui++) {
+               if ((sdram_data[ui]) != (pattern_ptr[ui])) {
+                       /* found error */
+                       /* error in low pup group */
+                       for (pup = 0; pup < PUP_NUM_32BIT; pup++) {
+                               val = CMP_BYTE_SHIFT * pup;
+                               var1 = ((sdram_data[ui] >> val) &
+                                       CMP_BYTE_MASK);
+                               var2 = ((pattern_ptr[ui] >> val) &
+                                       CMP_BYTE_MASK);
+
+                               if (var1 != var2) {
+                                       if (dram_info->ddr_width > 16) {
+                                               tmp_pup = (pup + PUP_NUM_32BIT *
+                                                          (ui % pup_groups));
+                                       } else {
+                                               tmp_pup = (pup % PUP_NUM_16BIT);
+                                       }
+
+                                       update_pup = (1 << tmp_pup);
+                                       if (ecc && (update_pup != 0x1))
+                                               continue;
+
+                                       /*
+                                        * Pup is failed - Go over all DQs and
+                                        * look for failures
+                                        */
+                                       for (dq = 0; dq < DQ_NUM; dq++) {
+                                               val = tmp_pup * (1 - ecc) +
+                                                       ecc * ECC_PUP;
+                                               if (((var1 >> dq) & 0x1) !=
+                                                   ((var2 >> dq) & 0x1)) {
+                                                       if (pbs_locked_dq[val][dq] == 1 &&
+                                                           pbs_locked_value[val][dq] != pbs_curr_val)
+                                                               continue;
+
+                                                       /*
+                                                        * Activate write to
+                                                        * update PBS to
+                                                        * pbs_lock_val
+                                                        */
+                                                       pbs_write_pup[dq] |=
+                                                               update_pup;
+
+                                                       /*
+                                                        * Update the
+                                                        * unlock_pup_dq_array
+                                                        */
+                                                       unlock_pup_dq_array[dq] &=
+                                                               ~update_pup;
+
+                                                       /*
+                                                        * Lock PBS value for
+                                                        * failed bits in
+                                                        * compare operation
+                                                        */
+                                                       skew_array[tmp_pup * DQ_NUM + dq] =
+                                                               pbs_curr_val;
+                                               }
+                                       }
+                               }
+                       }
+               }
+       }
+
+       pup_addr = (is_tx == 1) ? PUP_PBS_TX : PUP_PBS_RX;
+
+       /* Set last failed bits PBS to min / max pbs value */
+       for (dq = 0; dq < DQ_NUM; dq++) {
+               for (pup = 0; pup < max_pup; pup++) {
+                       if (pbs_write_pup[dq] & (1 << pup)) {
+                               val = pup * (1 - ecc) + ecc * ECC_PUP;
+                               if (pbs_locked_dq[val][dq] == 1 &&
+                                   pbs_locked_value[val][dq] != pbs_curr_val)
+                                       continue;
+
+                               /* Mark the dq as locked */
+                               pbs_locked_dq[val][dq] = 1;
+                               pbs_locked_value[val][dq] = pbs_curr_val;
+                               ddr3_write_pup_reg(pup_addr +
+                                                  pbs_dq_mapping[val][dq],
+                                                  CS0, val, 0, pbs_lock_val);
+                       }
+               }
+       }
+
+       return MV_OK;
+}
+#endif
+
+/*
+ * Name:     ddr3_sdram_direct_compare
+ * Desc:     Execute compare  per PUP without DMA (no burst mode)
+ * Args:     unlock_pup       Bit array of the unlock pups
+ *           new_locked_pup   Output  bit array of the pups with failed compare
+ *           pattern          Pattern to compare
+ *           pattern_len      Length of pattern (in bytes)
+ *           sdram_offset     offset address to the SDRAM
+ *           write            write to the SDRAM before read
+ *           mask             compare pattern with mask;
+ *           auiMaskPatter    Mask to compare pattern
+ *
+ * Notes:
+ * Returns:  MV_OK if success, other error code if fail.
+ */
+int ddr3_sdram_direct_compare(MV_DRAM_INFO *dram_info, u32 unlock_pup,
+                             u32 *new_locked_pup, u32 *pattern,
+                             u32 pattern_len, u32 sdram_offset,
+                             int write, int mask, u32 *mask_pattern)
+{
+       u32 uj, uk, pup_groups;
+       u32 *sdram_addr;        /* used to read from SDRAM */
+
+       sdram_addr = (u32 *)sdram_offset;
+
+       if (dram_info->num_of_std_pups == PUP_NUM_64BIT)
+               pup_groups = 2;
+       else
+               pup_groups = 1;
+
+       /* Check if need to write before read */
+       if (write == 1) {
+               for (uk = 0; uk < pattern_len; uk++) {
+                       *sdram_addr = pattern[uk];
+                       sdram_addr++;
+               }
+       }
+
+       sdram_addr = (u32 *)sdram_offset;
+
+       for (uk = 0; uk < pattern_len; uk++) {
+               sdram_data[uk] = *sdram_addr;
+               sdram_addr++;
+       }
+
+       /* Compare read result to write */
+       for (uj = 0; uj < pattern_len; uj++) {
+               if (dram_info->ddr_width > 16) {
+                       compare_pattern_v1(uj, new_locked_pup, pattern,
+                                          pup_groups, 0);
+               } else {
+                       compare_pattern_v2(uj, new_locked_pup, pattern);
+               }
+       }
+
+       return MV_OK;
+}
+
+/*
+ * Name:     ddr3_dram_sram_burst
+ * Desc:     Read from the SDRAM in burst of 64 bytes
+ * Args:     src
+ *           dst
+ * Notes:    Using the XOR mechanism
+ * Returns:  MV_OK if success, other error code if fail.
+ */
+int ddr3_dram_sram_burst(u32 src, u32 dst, u32 len)
+{
+       u32 chan, byte_count, cs_num, byte;
+       struct xor_channel_t channel;
+
+       chan = 0;
+       byte_count = len * 4;
+
+       /* Wait for previous transfer completion */
+       while (mv_xor_state_get(chan) != MV_IDLE)
+               ;
+
+       /* Build the channel descriptor */
+       channel.desc = &dma_desc;
+
+       /* Enable Address Override and set correct src and dst */
+       if (src < SRAM_BASE) {
+               /* src is DRAM CS, dst is SRAM */
+               cs_num = (src / (1 + SDRAM_CS_SIZE));
+               reg_write(XOR_ADDR_OVRD_REG(0, 0),
+                         ((cs_num << 1) | (1 << 0)));
+               channel.desc->src_addr0 = (src % (1 + SDRAM_CS_SIZE));
+               channel.desc->dst_addr = dst;
+       } else {
+               /* src is SRAM, dst is DRAM CS */
+               cs_num = (dst / (1 + SDRAM_CS_SIZE));
+               reg_write(XOR_ADDR_OVRD_REG(0, 0),
+                         ((cs_num << 25) | (1 << 24)));
+               channel.desc->src_addr0 = (src);
+               channel.desc->dst_addr = (dst % (1 + SDRAM_CS_SIZE));
+               channel.desc->src_addr0 = src;
+               channel.desc->dst_addr = (dst % (1 + SDRAM_CS_SIZE));
+       }
+
+       channel.desc->src_addr1 = 0;
+       channel.desc->byte_cnt = byte_count;
+       channel.desc->next_desc_ptr = 0;
+       channel.desc->status = 1 << 31;
+       channel.desc->desc_cmd = 0x0;
+       channel.desc_phys_addr = (unsigned long)&dma_desc;
+
+       ddr3_flush_l1_line((u32)&dma_desc);
+
+       /* Issue the transfer */
+       if (mv_xor_transfer(chan, MV_DMA, channel.desc_phys_addr) != MV_OK)
+               return MV_FAIL;
+
+       /* Wait for completion */
+       xor_waiton_eng(chan);
+
+       if (dst > SRAM_BASE) {
+               for (byte = 0; byte < byte_count; byte += 0x20)
+                       cache_inv(dst + byte);
+       }
+
+       return MV_OK;
+}
+
+/*
+ * Name:     ddr3_flush_l1_line
+ * Desc:
+ * Args:
+ * Notes:
+ * Returns:  MV_OK if success, other error code if fail.
+ */
+static void ddr3_flush_l1_line(u32 line)
+{
+       u32 reg;
+
+#if defined(MV88F672X)
+       reg = 1;
+#else
+       reg = reg_read(REG_SAMPLE_RESET_LOW_ADDR) &
+               (1 << REG_SAMPLE_RESET_CPU_ARCH_OFFS);
+#ifdef MV88F67XX
+       reg = ~reg & (1 << REG_SAMPLE_RESET_CPU_ARCH_OFFS);
+#endif
+#endif
+
+       if (reg) {
+               /* V7 Arch mode */
+               flush_l1_v7(line);
+               flush_l1_v7(line + CACHE_LINE_SIZE);
+       } else {
+               /* V6 Arch mode */
+               flush_l1_v6(line);
+               flush_l1_v6(line + CACHE_LINE_SIZE);
+       }
+}
+
+int ddr3_dram_sram_read(u32 src, u32 dst, u32 len)
+{
+       u32 ui;
+       u32 *dst_ptr, *src_ptr;
+
+       dst_ptr = (u32 *)dst;
+       src_ptr = (u32 *)src;
+
+       for (ui = 0; ui < len; ui++) {
+               *dst_ptr = *src_ptr;
+               dst_ptr++;
+               src_ptr++;
+       }
+
+       return MV_OK;
+}
+
+int ddr3_sdram_dqs_compare(MV_DRAM_INFO *dram_info, u32 unlock_pup,
+                          u32 *new_locked_pup, u32 *pattern,
+                          u32 pattern_len, u32 sdram_offset, int write,
+                          int mask, u32 *mask_pattern,
+                          int special_compare)
+{
+       u32 uj, pup_groups;
+
+       if (dram_info->num_of_std_pups == PUP_NUM_64BIT)
+               pup_groups = 2;
+       else
+               pup_groups = 1;
+
+       ddr3_reset_phy_read_fifo();
+
+       /* Check if need to write to sdram before read */
+       if (write == 1)
+               ddr3_dram_sram_burst((u32)pattern, sdram_offset, pattern_len);
+
+       ddr3_dram_sram_burst(sdram_offset, (u32)sdram_data, pattern_len);
+
+       /* Compare read result to write */
+       for (uj = 0; uj < pattern_len; uj++) {
+               if (special_compare && special_compare_pattern(uj))
+                       continue;
+
+               if (dram_info->ddr_width > 16) {
+                       compare_pattern_v1(uj, new_locked_pup, pattern,
+                                          pup_groups, 1);
+               } else {
+                       compare_pattern_v2(uj, new_locked_pup, pattern);
+               }
+       }
+
+       return MV_OK;
+}
+
+void ddr3_reset_phy_read_fifo(void)
+{
+       u32 reg;
+
+       /* reset read FIFO */
+       reg = reg_read(REG_DRAM_TRAINING_ADDR);
+       /* Start Auto Read Leveling procedure */
+       reg |= (1 << REG_DRAM_TRAINING_RL_OFFS);
+
+       /* 0x15B0 - Training Register */
+       reg_write(REG_DRAM_TRAINING_ADDR, reg);
+
+       reg = reg_read(REG_DRAM_TRAINING_2_ADDR);
+       reg |= ((1 << REG_DRAM_TRAINING_2_FIFO_RST_OFFS) +
+               (1 << REG_DRAM_TRAINING_2_SW_OVRD_OFFS));
+
+       /* [0] = 1 - Enable SW override, [4] = 1 - FIFO reset  */
+       /* 0x15B8 - Training SW 2 Register */
+       reg_write(REG_DRAM_TRAINING_2_ADDR, reg);
+
+       do {
+               reg = reg_read(REG_DRAM_TRAINING_2_ADDR) &
+                       (1 << REG_DRAM_TRAINING_2_FIFO_RST_OFFS);
+       } while (reg);  /* Wait for '0' */
+
+       reg = reg_read(REG_DRAM_TRAINING_ADDR);
+
+       /* Clear Auto Read Leveling procedure */
+       reg &= ~(1 << REG_DRAM_TRAINING_RL_OFFS);
+
+       /* 0x15B0 - Training Register */
+       reg_write(REG_DRAM_TRAINING_ADDR, reg);
+}
diff --git a/drivers/ddr/mvebu/ddr3_spd.c b/drivers/ddr/mvebu/ddr3_spd.c
new file mode 100644 (file)
index 0000000..f4f94c5
--- /dev/null
@@ -0,0 +1,1300 @@
+/*
+ * Copyright (C) Marvell International Ltd. and its affiliates
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#include <common.h>
+#include <i2c.h>
+#include <spl.h>
+#include <asm/io.h>
+#include <asm/arch/cpu.h>
+#include <asm/arch/soc.h>
+
+#include "ddr3_init.h"
+
+#if defined(MV88F78X60)
+#include "ddr3_axp_config.h"
+#elif defined(MV88F67XX)
+#include "ddr3_a370_config.h"
+#endif
+
+#if defined(MV88F672X)
+#include "ddr3_a375_config.h"
+#endif
+
+#ifdef DUNIT_SPD
+
+/* DIMM SPD offsets */
+#define SPD_DEV_TYPE_BYTE              2
+
+#define SPD_MODULE_TYPE_BYTE           3
+#define SPD_MODULE_MASK                        0xf
+#define SPD_MODULE_TYPE_RDIMM          1
+#define SPD_MODULE_TYPE_UDIMM          2
+
+#define SPD_DEV_DENSITY_BYTE           4
+#define SPD_DEV_DENSITY_MASK           0xf
+
+#define SPD_ROW_NUM_BYTE               5
+#define SPD_ROW_NUM_MIN                        12
+#define SPD_ROW_NUM_OFF                        3
+#define SPD_ROW_NUM_MASK               (7 << SPD_ROW_NUM_OFF)
+
+#define SPD_COL_NUM_BYTE               5
+#define SPD_COL_NUM_MIN                        9
+#define SPD_COL_NUM_OFF                        0
+#define SPD_COL_NUM_MASK               (7 << SPD_COL_NUM_OFF)
+
+#define SPD_MODULE_ORG_BYTE            7
+#define SPD_MODULE_SDRAM_DEV_WIDTH_OFF         0
+#define SPD_MODULE_SDRAM_DEV_WIDTH_MASK        (7 << SPD_MODULE_SDRAM_DEV_WIDTH_OFF)
+#define SPD_MODULE_BANK_NUM_MIN                1
+#define SPD_MODULE_BANK_NUM_OFF                3
+#define SPD_MODULE_BANK_NUM_MASK       (7 << SPD_MODULE_BANK_NUM_OFF)
+
+#define SPD_BUS_WIDTH_BYTE             8
+#define SPD_BUS_WIDTH_OFF              0
+#define SPD_BUS_WIDTH_MASK             (7 << SPD_BUS_WIDTH_OFF)
+#define SPD_BUS_ECC_OFF                        3
+#define SPD_BUS_ECC_MASK               (3 << SPD_BUS_ECC_OFF)
+
+#define SPD_MTB_DIVIDEND_BYTE          10
+#define SPD_MTB_DIVISOR_BYTE           11
+#define SPD_TCK_BYTE                   12
+#define SPD_SUP_CAS_LAT_LSB_BYTE       14
+#define SPD_SUP_CAS_LAT_MSB_BYTE       15
+#define SPD_TAA_BYTE                   16
+#define SPD_TWR_BYTE                   17
+#define SPD_TRCD_BYTE                  18
+#define SPD_TRRD_BYTE                  19
+#define SPD_TRP_BYTE                   20
+
+#define SPD_TRAS_MSB_BYTE              21
+#define SPD_TRAS_MSB_MASK              0xf
+
+#define SPD_TRC_MSB_BYTE               21
+#define SPD_TRC_MSB_MASK               0xf0
+
+#define SPD_TRAS_LSB_BYTE              22
+#define SPD_TRC_LSB_BYTE               23
+#define SPD_TRFC_LSB_BYTE              24
+#define SPD_TRFC_MSB_BYTE              25
+#define SPD_TWTR_BYTE                  26
+#define SPD_TRTP_BYTE                  27
+
+#define SPD_TFAW_MSB_BYTE              28
+#define SPD_TFAW_MSB_MASK              0xf
+
+#define SPD_TFAW_LSB_BYTE              29
+#define SPD_OPT_FEATURES_BYTE          30
+#define SPD_THERMAL_REFRESH_OPT_BYTE   31
+
+#define SPD_ADDR_MAP_BYTE              63
+#define SPD_ADDR_MAP_MIRROR_OFFS       0
+
+#define SPD_RDIMM_RC_BYTE              69
+#define SPD_RDIMM_RC_NIBBLE_MASK       0xF
+#define SPD_RDIMM_RC_NUM               16
+
+/* Dimm Memory Type values */
+#define SPD_MEM_TYPE_SDRAM             0x4
+#define SPD_MEM_TYPE_DDR1              0x7
+#define SPD_MEM_TYPE_DDR2              0x8
+#define SPD_MEM_TYPE_DDR3              0xB
+
+#define DIMM_MODULE_MANU_OFFS          64
+#define DIMM_MODULE_MANU_SIZE          8
+#define DIMM_MODULE_VEN_OFFS           73
+#define DIMM_MODULE_VEN_SIZE           25
+#define DIMM_MODULE_ID_OFFS            99
+#define DIMM_MODULE_ID_SIZE            18
+
+/* enumeration for voltage levels. */
+enum dimm_volt_if {
+       TTL_5V_TOLERANT,
+       LVTTL,
+       HSTL_1_5V,
+       SSTL_3_3V,
+       SSTL_2_5V,
+       VOLTAGE_UNKNOWN,
+};
+
+/* enumaration for SDRAM CAS Latencies. */
+enum dimm_sdram_cas {
+       SD_CL_1 = 1,
+       SD_CL_2,
+       SD_CL_3,
+       SD_CL_4,
+       SD_CL_5,
+       SD_CL_6,
+       SD_CL_7,
+       SD_FAULT
+};
+
+/* enumeration for memory types */
+enum memory_type {
+       MEM_TYPE_SDRAM,
+       MEM_TYPE_DDR1,
+       MEM_TYPE_DDR2,
+       MEM_TYPE_DDR3
+};
+
+/* DIMM information structure */
+typedef struct dimm_info {
+       /* DIMM dimensions */
+       u32 num_of_module_ranks;
+       u32 data_width;
+       u32 rank_capacity;
+       u32 num_of_devices;
+
+       u32 sdram_width;
+       u32 num_of_banks_on_each_device;
+       u32 sdram_capacity;
+
+       u32 num_of_row_addr;
+       u32 num_of_col_addr;
+
+       u32 addr_mirroring;
+
+       u32 err_check_type;                     /* ECC , PARITY.. */
+       u32 type_info;                          /* DDR2 only */
+
+       /* DIMM timing parameters */
+       u32 supported_cas_latencies;
+       u32 refresh_interval;
+       u32 min_cycle_time;
+       u32 min_row_precharge_time;
+       u32 min_row_active_to_row_active;
+       u32 min_ras_to_cas_delay;
+       u32 min_write_recovery_time;            /* DDR3/2 only */
+       u32 min_write_to_read_cmd_delay;        /* DDR3/2 only */
+       u32 min_read_to_prech_cmd_delay;        /* DDR3/2 only */
+       u32 min_active_to_precharge;
+       u32 min_refresh_recovery;               /* DDR3/2 only */
+       u32 min_cas_lat_time;
+       u32 min_four_active_win_delay;
+       u8 dimm_rc[SPD_RDIMM_RC_NUM];
+
+       /* DIMM vendor ID */
+       u32 vendor;
+} MV_DIMM_INFO;
+
+static int ddr3_spd_sum_init(MV_DIMM_INFO *info, MV_DIMM_INFO *sum_info,
+                            u32 dimm);
+static u32 ddr3_get_max_val(u32 spd_val, u32 dimm_num, u32 static_val);
+static u32 ddr3_get_min_val(u32 spd_val, u32 dimm_num, u32 static_val);
+static int ddr3_spd_init(MV_DIMM_INFO *info, u32 dimm_addr, u32 dimm_width);
+static u32 ddr3_div(u32 val, u32 divider, u32 sub);
+
+extern u8 spd_data[SPD_SIZE];
+extern u32 odt_config[ODT_OPT];
+extern u16 odt_static[ODT_OPT][MAX_CS];
+extern u16 odt_dynamic[ODT_OPT][MAX_CS];
+
+#if !(defined(DB_88F6710) || defined(DB_88F6710_PCAC) || defined(RD_88F6710))
+/*
+ * Name:     ddr3_get_dimm_num - Find number of dimms and their addresses
+ * Desc:
+ * Args:     dimm_addr - array of dimm addresses
+ * Notes:
+ * Returns:  None.
+ */
+static u32 ddr3_get_dimm_num(u32 *dimm_addr)
+{
+       u32 dimm_cur_addr;
+       u8 data[3];
+       u32 dimm_num = 0;
+       int ret;
+
+       /* Read the dimm eeprom */
+       for (dimm_cur_addr = MAX_DIMM_ADDR; dimm_cur_addr > MIN_DIMM_ADDR;
+            dimm_cur_addr--) {
+               data[SPD_DEV_TYPE_BYTE] = 0;
+
+               /* Far-End DIMM must be connected */
+               if ((dimm_num == 0) && (dimm_cur_addr < FAR_END_DIMM_ADDR))
+                       return 0;
+
+               ret = i2c_read(dimm_cur_addr, 0, 1, (uchar *)data, 3);
+               if (!ret) {
+                       if (data[SPD_DEV_TYPE_BYTE] == SPD_MEM_TYPE_DDR3) {
+                               dimm_addr[dimm_num] = dimm_cur_addr;
+                               dimm_num++;
+                       }
+               }
+       }
+
+       return dimm_num;
+}
+#endif
+
+/*
+ * Name:     dimmSpdInit - Get the SPD parameters.
+ * Desc:     Read the DIMM SPD parameters into given struct parameter.
+ * Args:     dimmNum - DIMM number. See MV_BOARD_DIMM_NUM enumerator.
+ *           info - DIMM information structure.
+ * Notes:
+ * Returns:  MV_OK if function could read DIMM parameters, 0 otherwise.
+ */
+int ddr3_spd_init(MV_DIMM_INFO *info, u32 dimm_addr, u32 dimm_width)
+{
+       u32 tmp;
+       u32 time_base;
+       int ret;
+       __maybe_unused u32 rc;
+       __maybe_unused u8 vendor_high, vendor_low;
+
+       if (dimm_addr != 0) {
+               memset(spd_data, 0, SPD_SIZE * sizeof(u8));
+
+               ret = i2c_read(dimm_addr, 0, 1, (uchar *)spd_data, SPD_SIZE);
+               if (ret)
+                       return MV_DDR3_TRAINING_ERR_TWSI_FAIL;
+       }
+
+       /* Check if DDR3 */
+       if (spd_data[SPD_DEV_TYPE_BYTE] != SPD_MEM_TYPE_DDR3)
+               return MV_DDR3_TRAINING_ERR_TWSI_BAD_TYPE;
+
+       /* Error Check Type */
+       /* No byte for error check in DDR3 SPD, use DDR2 convention */
+       info->err_check_type = 0;
+
+       /* Check if ECC */
+       if ((spd_data[SPD_BUS_WIDTH_BYTE] & 0x18) >> 3)
+               info->err_check_type = 1;
+
+       DEBUG_INIT_FULL_C("DRAM err_check_type ", info->err_check_type, 1);
+       switch (spd_data[SPD_MODULE_TYPE_BYTE]) {
+       case 1:
+               /* support RDIMM */
+               info->type_info = SPD_MODULE_TYPE_RDIMM;
+               break;
+       case 2:
+               /* support UDIMM */
+               info->type_info = SPD_MODULE_TYPE_UDIMM;
+               break;
+       case 11:                /* LRDIMM current not supported */
+       default:
+               info->type_info = (spd_data[SPD_MODULE_TYPE_BYTE]);
+               break;
+       }
+
+       /* Size Calculations: */
+
+       /* Number Of Row Addresses - 12/13/14/15/16 */
+       info->num_of_row_addr =
+               (spd_data[SPD_ROW_NUM_BYTE] & SPD_ROW_NUM_MASK) >>
+               SPD_ROW_NUM_OFF;
+       info->num_of_row_addr += SPD_ROW_NUM_MIN;
+       DEBUG_INIT_FULL_C("DRAM num_of_row_addr ", info->num_of_row_addr, 2);
+
+       /* Number Of Column Addresses - 9/10/11/12 */
+       info->num_of_col_addr =
+               (spd_data[SPD_COL_NUM_BYTE] & SPD_COL_NUM_MASK) >>
+               SPD_COL_NUM_OFF;
+       info->num_of_col_addr += SPD_COL_NUM_MIN;
+       DEBUG_INIT_FULL_C("DRAM num_of_col_addr ", info->num_of_col_addr, 1);
+
+       /* Number Of Ranks = number of CS on Dimm - 1/2/3/4 Ranks */
+       info->num_of_module_ranks =
+               (spd_data[SPD_MODULE_ORG_BYTE] & SPD_MODULE_BANK_NUM_MASK) >>
+               SPD_MODULE_BANK_NUM_OFF;
+       info->num_of_module_ranks += SPD_MODULE_BANK_NUM_MIN;
+       DEBUG_INIT_FULL_C("DRAM numOfModuleBanks ", info->num_of_module_ranks,
+                         1);
+
+       /* Data Width - 8/16/32/64 bits */
+       info->data_width =
+               1 << (3 + (spd_data[SPD_BUS_WIDTH_BYTE] & SPD_BUS_WIDTH_MASK));
+       DEBUG_INIT_FULL_C("DRAM data_width ", info->data_width, 1);
+
+       /* Number Of Banks On Each Device - 8/16/32/64 banks */
+       info->num_of_banks_on_each_device =
+               1 << (3 + ((spd_data[SPD_DEV_DENSITY_BYTE] >> 4) & 0x7));
+       DEBUG_INIT_FULL_C("DRAM num_of_banks_on_each_device ",
+                         info->num_of_banks_on_each_device, 1);
+
+       /* Total SDRAM capacity - 256Mb/512Mb/1Gb/2Gb/4Gb/8Gb/16Gb - MegaBits */
+       info->sdram_capacity =
+               spd_data[SPD_DEV_DENSITY_BYTE] & SPD_DEV_DENSITY_MASK;
+
+       /* Sdram Width - 4/8/16/32 bits */
+       info->sdram_width = 1 << (2 + (spd_data[SPD_MODULE_ORG_BYTE] &
+                                      SPD_MODULE_SDRAM_DEV_WIDTH_MASK));
+       DEBUG_INIT_FULL_C("DRAM sdram_width ", info->sdram_width, 1);
+
+       /* CS (Rank) Capacity - MB */
+       /*
+        * DDR3 device uiDensity val are: (device capacity/8) *
+        * (Module_width/Device_width)
+        */
+       /* Jedec SPD DDR3 - page 7, Save spd_data in Mb  - 2048=2GB */
+       if (dimm_width == 32) {
+               info->rank_capacity =
+                       ((1 << info->sdram_capacity) * 256 *
+                        (info->data_width / info->sdram_width)) << 16;
+               /* CS size = CS size / 2  */
+       } else {
+               info->rank_capacity =
+                       ((1 << info->sdram_capacity) * 256 *
+                        (info->data_width / info->sdram_width) * 0x2) << 16;
+               /* 0x2 =>  0x100000-1Mbit / 8-bit->byte / 0x10000  */
+       }
+       DEBUG_INIT_FULL_C("DRAM rank_capacity[31] ", info->rank_capacity, 1);
+
+       /* Number of devices includeing Error correction */
+       info->num_of_devices =
+               ((info->data_width / info->sdram_width) *
+                info->num_of_module_ranks) + info->err_check_type;
+       DEBUG_INIT_FULL_C("DRAM num_of_devices  ", info->num_of_devices, 1);
+
+       /* Address Mapping from Edge connector to DRAM - mirroring option */
+       info->addr_mirroring =
+               spd_data[SPD_ADDR_MAP_BYTE] & (1 << SPD_ADDR_MAP_MIRROR_OFFS);
+
+       /* Timings - All in ps */
+
+       time_base = (1000 * spd_data[SPD_MTB_DIVIDEND_BYTE]) /
+               spd_data[SPD_MTB_DIVISOR_BYTE];
+
+       /* Minimum Cycle Time At Max CasLatancy */
+       info->min_cycle_time = spd_data[SPD_TCK_BYTE] * time_base;
+       DEBUG_INIT_FULL_C("DRAM tCKmin ", info->min_cycle_time, 1);
+
+       /* Refresh Interval */
+       /* No byte for refresh interval in DDR3 SPD, use DDR2 convention */
+       /*
+        * JEDEC param are 0 <= Tcase <= 85: 7.8uSec, 85 <= Tcase
+        * <= 95: 3.9uSec
+        */
+       info->refresh_interval = 7800000;       /* Set to 7.8uSec */
+       DEBUG_INIT_FULL_C("DRAM refresh_interval ", info->refresh_interval, 1);
+
+       /* Suported Cas Latencies -  DDR 3: */
+
+       /*
+        *         bit7 | bit6 | bit5 | bit4 | bit3 | bit2 | bit1 | bit0 *
+        *******-******-******-******-******-******-******-*******-*******
+        CAS =      11  |  10  |  9   |  8   |  7   |  6   |  5   |  4   *
+        *********************************************************-*******
+        *******-******-******-******-******-******-******-*******-*******
+        *        bit15 |bit14 |bit13 |bit12 |bit11 |bit10 | bit9 | bit8 *
+        *******-******-******-******-******-******-******-*******-*******
+        CAS =     TBD  |  18  |  17  |  16  |  15  |  14  |  13  |  12  *
+       */
+
+       /* DDR3 include 2 byte of CAS support */
+       info->supported_cas_latencies =
+               (spd_data[SPD_SUP_CAS_LAT_MSB_BYTE] << 8) |
+               spd_data[SPD_SUP_CAS_LAT_LSB_BYTE];
+       DEBUG_INIT_FULL_C("DRAM supported_cas_latencies ",
+                         info->supported_cas_latencies, 1);
+
+       /* Minimum Cycle Time At Max CasLatancy */
+       info->min_cas_lat_time = (spd_data[SPD_TAA_BYTE] * time_base);
+       /*
+        * This field divided by the cycleTime will give us the CAS latency
+        * to config
+        */
+
+       /*
+        * For DDR3 and DDR2 includes Write Recovery Time field.
+        * Other SDRAM ignore
+        */
+       info->min_write_recovery_time = spd_data[SPD_TWR_BYTE] * time_base;
+       DEBUG_INIT_FULL_C("DRAM min_write_recovery_time ",
+                         info->min_write_recovery_time, 1);
+
+       /* Mininmum Ras to Cas Delay */
+       info->min_ras_to_cas_delay = spd_data[SPD_TRCD_BYTE] * time_base;
+       DEBUG_INIT_FULL_C("DRAM min_ras_to_cas_delay ",
+                         info->min_ras_to_cas_delay, 1);
+
+       /* Minimum Row Active to Row Active Time */
+       info->min_row_active_to_row_active =
+           spd_data[SPD_TRRD_BYTE] * time_base;
+       DEBUG_INIT_FULL_C("DRAM min_row_active_to_row_active ",
+                         info->min_row_active_to_row_active, 1);
+
+       /* Minimum Row Precharge Delay Time */
+       info->min_row_precharge_time = spd_data[SPD_TRP_BYTE] * time_base;
+       DEBUG_INIT_FULL_C("DRAM min_row_precharge_time ",
+                         info->min_row_precharge_time, 1);
+
+       /* Minimum Active to Precharge Delay Time - tRAS   ps */
+       info->min_active_to_precharge =
+               (spd_data[SPD_TRAS_MSB_BYTE] & SPD_TRAS_MSB_MASK) << 8;
+       info->min_active_to_precharge |= spd_data[SPD_TRAS_LSB_BYTE];
+       info->min_active_to_precharge *= time_base;
+       DEBUG_INIT_FULL_C("DRAM min_active_to_precharge ",
+                         info->min_active_to_precharge, 1);
+
+       /* Minimum Refresh Recovery Delay Time - tRFC  ps */
+       info->min_refresh_recovery = spd_data[SPD_TRFC_MSB_BYTE] << 8;
+       info->min_refresh_recovery |= spd_data[SPD_TRFC_LSB_BYTE];
+       info->min_refresh_recovery *= time_base;
+       DEBUG_INIT_FULL_C("DRAM min_refresh_recovery ",
+                         info->min_refresh_recovery, 1);
+
+       /*
+        * For DDR3 and DDR2 includes Internal Write To Read Command Delay
+        * field.
+        */
+       info->min_write_to_read_cmd_delay = spd_data[SPD_TWTR_BYTE] * time_base;
+       DEBUG_INIT_FULL_C("DRAM min_write_to_read_cmd_delay ",
+                         info->min_write_to_read_cmd_delay, 1);
+
+       /*
+        * For DDR3 and DDR2 includes Internal Read To Precharge Command Delay
+        * field.
+        */
+       info->min_read_to_prech_cmd_delay = spd_data[SPD_TRTP_BYTE] * time_base;
+       DEBUG_INIT_FULL_C("DRAM min_read_to_prech_cmd_delay ",
+                         info->min_read_to_prech_cmd_delay, 1);
+
+       /*
+        * For DDR3 includes Minimum Activate to Activate/Refresh Command
+        * field
+        */
+       tmp = ((spd_data[SPD_TFAW_MSB_BYTE] & SPD_TFAW_MSB_MASK) << 8) |
+               spd_data[SPD_TFAW_LSB_BYTE];
+       info->min_four_active_win_delay = tmp * time_base;
+       DEBUG_INIT_FULL_C("DRAM min_four_active_win_delay ",
+                         info->min_four_active_win_delay, 1);
+
+#if defined(MV88F78X60) || defined(MV88F672X)
+       /* Registered DIMM support */
+       if (info->type_info == SPD_MODULE_TYPE_RDIMM) {
+               for (rc = 2; rc < 6; rc += 2) {
+                       tmp = spd_data[SPD_RDIMM_RC_BYTE + rc / 2];
+                       info->dimm_rc[rc] =
+                               spd_data[SPD_RDIMM_RC_BYTE + rc / 2] &
+                               SPD_RDIMM_RC_NIBBLE_MASK;
+                       info->dimm_rc[rc + 1] =
+                               (spd_data[SPD_RDIMM_RC_BYTE + rc / 2] >> 4) &
+                               SPD_RDIMM_RC_NIBBLE_MASK;
+               }
+
+               vendor_low = spd_data[66];
+               vendor_high = spd_data[65];
+               info->vendor = (vendor_high << 8) + vendor_low;
+               DEBUG_INIT_C("DDR3 Training Sequence - Registered DIMM vendor ID 0x",
+                            info->vendor, 4);
+
+               info->dimm_rc[0] = RDIMM_RC0;
+               info->dimm_rc[1] = RDIMM_RC1;
+               info->dimm_rc[2] = RDIMM_RC2;
+               info->dimm_rc[8] = RDIMM_RC8;
+               info->dimm_rc[9] = RDIMM_RC9;
+               info->dimm_rc[10] = RDIMM_RC10;
+               info->dimm_rc[11] = RDIMM_RC11;
+       }
+#endif
+
+       return MV_OK;
+}
+
+/*
+ * Name:     ddr3_spd_sum_init - Get the SPD parameters.
+ * Desc:     Read the DIMM SPD parameters into given struct parameter.
+ * Args:     dimmNum - DIMM number. See MV_BOARD_DIMM_NUM enumerator.
+ *           info - DIMM information structure.
+ * Notes:
+ * Returns:  MV_OK if function could read DIMM parameters, 0 otherwise.
+ */
+int ddr3_spd_sum_init(MV_DIMM_INFO *info, MV_DIMM_INFO *sum_info, u32 dimm)
+{
+       if (dimm == 0) {
+               memcpy(sum_info, info, sizeof(MV_DIMM_INFO));
+               return MV_OK;
+       }
+       if (sum_info->type_info != info->type_info) {
+               DEBUG_INIT_S("DDR3 Dimm Compare - DIMM type does not match - FAIL\n");
+               return MV_DDR3_TRAINING_ERR_DIMM_TYPE_NO_MATCH;
+       }
+       if (sum_info->err_check_type > info->err_check_type) {
+               sum_info->err_check_type = info->err_check_type;
+               DEBUG_INIT_S("DDR3 Dimm Compare - ECC does not match. ECC is disabled\n");
+       }
+       if (sum_info->data_width != info->data_width) {
+               DEBUG_INIT_S("DDR3 Dimm Compare - DRAM bus width does not match - FAIL\n");
+               return MV_DDR3_TRAINING_ERR_BUS_WIDTH_NOT_MATCH;
+       }
+       if (sum_info->min_cycle_time < info->min_cycle_time)
+               sum_info->min_cycle_time = info->min_cycle_time;
+       if (sum_info->refresh_interval < info->refresh_interval)
+               sum_info->refresh_interval = info->refresh_interval;
+       sum_info->supported_cas_latencies &= info->supported_cas_latencies;
+       if (sum_info->min_cas_lat_time < info->min_cas_lat_time)
+               sum_info->min_cas_lat_time = info->min_cas_lat_time;
+       if (sum_info->min_write_recovery_time < info->min_write_recovery_time)
+               sum_info->min_write_recovery_time =
+                   info->min_write_recovery_time;
+       if (sum_info->min_ras_to_cas_delay < info->min_ras_to_cas_delay)
+               sum_info->min_ras_to_cas_delay = info->min_ras_to_cas_delay;
+       if (sum_info->min_row_active_to_row_active <
+           info->min_row_active_to_row_active)
+               sum_info->min_row_active_to_row_active =
+                   info->min_row_active_to_row_active;
+       if (sum_info->min_row_precharge_time < info->min_row_precharge_time)
+               sum_info->min_row_precharge_time = info->min_row_precharge_time;
+       if (sum_info->min_active_to_precharge < info->min_active_to_precharge)
+               sum_info->min_active_to_precharge =
+                   info->min_active_to_precharge;
+       if (sum_info->min_refresh_recovery < info->min_refresh_recovery)
+               sum_info->min_refresh_recovery = info->min_refresh_recovery;
+       if (sum_info->min_write_to_read_cmd_delay <
+           info->min_write_to_read_cmd_delay)
+               sum_info->min_write_to_read_cmd_delay =
+                   info->min_write_to_read_cmd_delay;
+       if (sum_info->min_read_to_prech_cmd_delay <
+           info->min_read_to_prech_cmd_delay)
+               sum_info->min_read_to_prech_cmd_delay =
+                   info->min_read_to_prech_cmd_delay;
+       if (sum_info->min_four_active_win_delay <
+           info->min_four_active_win_delay)
+               sum_info->min_four_active_win_delay =
+                   info->min_four_active_win_delay;
+       if (sum_info->min_write_to_read_cmd_delay <
+           info->min_write_to_read_cmd_delay)
+               sum_info->min_write_to_read_cmd_delay =
+                       info->min_write_to_read_cmd_delay;
+
+       return MV_OK;
+}
+
+/*
+ * Name:     ddr3_dunit_setup
+ * Desc:     Set the controller with the timing values.
+ * Args:     ecc_ena - User ECC setup
+ * Notes:
+ * Returns:
+ */
+int ddr3_dunit_setup(u32 ecc_ena, u32 hclk_time, u32 *ddr_width)
+{
+       u32 reg, tmp, cwl;
+       u32 ddr_clk_time;
+       MV_DIMM_INFO dimm_info[2];
+       MV_DIMM_INFO sum_info;
+       u32 stat_val, spd_val;
+       u32 cs, cl, cs_num, cs_ena;
+       u32 dimm_num = 0;
+       int status;
+       u32 rc;
+       __maybe_unused u32 dimm_cnt, cs_count, dimm;
+       __maybe_unused u32 dimm_addr[2] = { 0, 0 };
+
+#if defined(DB_88F6710) || defined(DB_88F6710_PCAC) || defined(RD_88F6710)
+       /* Armada 370 - SPD is not available on DIMM */
+       /*
+        * Set MC registers according to Static SPD values Values -
+        * must be set manually
+        */
+       /*
+        * We only have one optional DIMM for the DB and we already got the
+        * SPD matching values
+        */
+       status = ddr3_spd_init(&dimm_info[0], 0, *ddr_width);
+       if (MV_OK != status)
+               return status;
+
+       dimm_num = 1;
+       /* Use JP8 to enable multiCS support for Armada 370 DB */
+       if (!ddr3_check_config(EEPROM_MODULE_ADDR, CONFIG_MULTI_CS))
+               dimm_info[0].num_of_module_ranks = 1;
+       status = ddr3_spd_sum_init(&dimm_info[0], &sum_info, 0);
+       if (MV_OK != status)
+               return status;
+#else
+       /* Dynamic D-Unit Setup - Read SPD values */
+#ifdef DUNIT_SPD
+       dimm_num = ddr3_get_dimm_num(dimm_addr);
+       if (dimm_num == 0) {
+#ifdef MIXED_DIMM_STATIC
+               DEBUG_INIT_S("DDR3 Training Sequence - No DIMMs detected\n");
+#else
+               DEBUG_INIT_S("DDR3 Training Sequence - FAILED (Wrong DIMMs Setup)\n");
+               return MV_DDR3_TRAINING_ERR_BAD_DIMM_SETUP;
+#endif
+       } else {
+               DEBUG_INIT_C("DDR3 Training Sequence - Number of DIMMs detected: ",
+                            dimm_num, 1);
+       }
+
+       for (dimm = 0; dimm < dimm_num; dimm++) {
+               status = ddr3_spd_init(&dimm_info[dimm], dimm_addr[dimm],
+                                      *ddr_width);
+               if (MV_OK != status)
+                       return status;
+               status = ddr3_spd_sum_init(&dimm_info[dimm], &sum_info, dimm);
+               if (MV_OK != status)
+                       return status;
+       }
+#endif
+#endif
+
+       /* Set number of enabled CS */
+       cs_num = 0;
+#ifdef DUNIT_STATIC
+       cs_num = ddr3_get_cs_num_from_reg();
+#endif
+#ifdef DUNIT_SPD
+       for (dimm = 0; dimm < dimm_num; dimm++)
+               cs_num += dimm_info[dimm].num_of_module_ranks;
+#endif
+       if (cs_num > MAX_CS) {
+               DEBUG_INIT_C("DDR3 Training Sequence - Number of CS exceed limit -  ",
+                            MAX_CS, 1);
+               return MV_DDR3_TRAINING_ERR_MAX_CS_LIMIT;
+       }
+
+       /* Set bitmap of enabled CS */
+       cs_ena = 0;
+#ifdef DUNIT_STATIC
+       cs_ena = ddr3_get_cs_ena_from_reg();
+#endif
+#ifdef DUNIT_SPD
+       dimm = 0;
+
+       if (dimm_num) {
+               for (cs = 0; cs < MAX_CS; cs += 2) {
+                       if (((1 << cs) & DIMM_CS_BITMAP) &&
+                           !(cs_ena & (1 << cs))) {
+                               if (dimm_info[dimm].num_of_module_ranks == 1)
+                                       cs_ena |= (0x1 << cs);
+                               else if (dimm_info[dimm].num_of_module_ranks == 2)
+                                       cs_ena |= (0x3 << cs);
+                               else if (dimm_info[dimm].num_of_module_ranks == 3)
+                                       cs_ena |= (0x7 << cs);
+                               else if (dimm_info[dimm].num_of_module_ranks == 4)
+                                       cs_ena |= (0xF << cs);
+
+                               dimm++;
+                               if (dimm == dimm_num)
+                                       break;
+                       }
+               }
+       }
+#endif
+
+       if (cs_ena > 0xF) {
+               DEBUG_INIT_C("DDR3 Training Sequence - Number of enabled CS exceed limit -  ",
+                            MAX_CS, 1);
+               return MV_DDR3_TRAINING_ERR_MAX_ENA_CS_LIMIT;
+       }
+
+       DEBUG_INIT_FULL_C("DDR3 - DUNIT-SET - Number of CS = ", cs_num, 1);
+
+       /* Check Ratio - '1' - 2:1, '0' - 1:1 */
+       if (reg_read(REG_DDR_IO_ADDR) & (1 << REG_DDR_IO_CLK_RATIO_OFFS))
+               ddr_clk_time = hclk_time / 2;
+       else
+               ddr_clk_time = hclk_time;
+
+#ifdef DUNIT_STATIC
+       /* Get target CL value from set register */
+       reg = (reg_read(REG_DDR3_MR0_ADDR) >> 2);
+       reg = ((((reg >> 1) & 0xE)) | (reg & 0x1)) & 0xF;
+
+       cl = ddr3_get_max_val(ddr3_div(sum_info.min_cas_lat_time,
+                                      ddr_clk_time, 0),
+                             dimm_num, ddr3_valid_cl_to_cl(reg));
+#else
+       cl = ddr3_div(sum_info.min_cas_lat_time, ddr_clk_time, 0);
+#endif
+       if (cl < 5)
+               cl = 5;
+
+       DEBUG_INIT_FULL_C("DDR3 - DUNIT-SET - Cas Latency = ", cl, 1);
+
+       /* {0x00001400} -   DDR SDRAM Configuration Register */
+       reg = 0x73004000;
+       stat_val = ddr3_get_static_mc_value(
+               REG_SDRAM_CONFIG_ADDR, REG_SDRAM_CONFIG_ECC_OFFS, 0x1, 0, 0);
+       if (ecc_ena && ddr3_get_min_val(sum_info.err_check_type, dimm_num,
+                                       stat_val)) {
+               reg |= (1 << REG_SDRAM_CONFIG_ECC_OFFS);
+               reg |= (1 << REG_SDRAM_CONFIG_IERR_OFFS);
+               DEBUG_INIT_FULL_S("DDR3 - DUNIT-SET - ECC Enabled\n");
+       } else {
+               DEBUG_INIT_FULL_S("DDR3 - DUNIT-SET - ECC Disabled\n");
+       }
+
+       if (sum_info.type_info == SPD_MODULE_TYPE_RDIMM) {
+#ifdef DUNIT_STATIC
+               DEBUG_INIT_S("DDR3 Training Sequence - FAIL - Illegal R-DIMM setup\n");
+               return MV_DDR3_TRAINING_ERR_BAD_R_DIMM_SETUP;
+#endif
+               reg |= (1 << REG_SDRAM_CONFIG_REGDIMM_OFFS);
+               DEBUG_INIT_FULL_S("DDR3 - DUNIT-SET - R-DIMM\n");
+       } else {
+               DEBUG_INIT_FULL_S("DDR3 - DUNIT-SET - U-DIMM\n");
+       }
+
+#ifndef MV88F67XX
+#ifdef DUNIT_STATIC
+       if (ddr3_get_min_val(sum_info.data_width, dimm_num, BUS_WIDTH) == 64) {
+#else
+       if (*ddr_width == 64) {
+#endif
+               reg |= (1 << REG_SDRAM_CONFIG_WIDTH_OFFS);
+               DEBUG_INIT_FULL_S("DDR3 - DUNIT-SET - Datawidth - 64Bits\n");
+       } else {
+               DEBUG_INIT_FULL_S("DDR3 - DUNIT-SET - Datawidth - 32Bits\n");
+       }
+#else
+       DEBUG_INIT_FULL_S("DDR3 - DUNIT-SET - Datawidth - 16Bits\n");
+#endif
+
+#if defined(MV88F672X)
+       if (*ddr_width == 32) {
+               reg |= (1 << REG_SDRAM_CONFIG_WIDTH_OFFS);
+               DEBUG_INIT_FULL_S("DDR3 - DUNIT-SET - Datawidth - 32Bits\n");
+       } else {
+               DEBUG_INIT_FULL_S("DDR3 - DUNIT-SET - Datawidth - 16Bits\n");
+       }
+#endif
+       stat_val = ddr3_get_static_mc_value(REG_SDRAM_CONFIG_ADDR, 0,
+                                              REG_SDRAM_CONFIG_RFRS_MASK, 0, 0);
+       tmp = ddr3_get_min_val(sum_info.refresh_interval / hclk_time,
+                              dimm_num, stat_val);
+
+#ifdef TREFI_USER_EN
+       tmp = min(TREFI_USER / hclk_time, tmp);
+#endif
+
+       DEBUG_INIT_FULL_C("DDR3 - DUNIT-SET - RefreshInterval/Hclk = ", tmp, 4);
+       reg |= tmp;
+
+       if (cl != 3)
+               reg |= (1 << 16);       /*  If 2:1 need to set P2DWr */
+
+#if defined(MV88F672X)
+       reg |= (1 << 27);       /* PhyRfRST = Disable */
+#endif
+       reg_write(REG_SDRAM_CONFIG_ADDR, reg);
+
+       /*{0x00001404}  -   DDR SDRAM Configuration Register */
+       reg = 0x3630B800;
+#ifdef DUNIT_SPD
+       reg |= (DRAM_2T << REG_DUNIT_CTRL_LOW_2T_OFFS);
+#endif
+       reg_write(REG_DUNIT_CTRL_LOW_ADDR, reg);
+
+       /* {0x00001408}  -   DDR SDRAM Timing (Low) Register */
+       reg = 0x0;
+
+       /* tRAS - (0:3,20) */
+       spd_val = ddr3_div(sum_info.min_active_to_precharge,
+                           ddr_clk_time, 1);
+       stat_val = ddr3_get_static_mc_value(REG_SDRAM_TIMING_LOW_ADDR,
+                                           0, 0xF, 16, 0x10);
+       tmp = ddr3_get_max_val(spd_val, dimm_num, stat_val);
+       DEBUG_INIT_FULL_C("DDR3 - DUNIT-SET - tRAS-1 = ", tmp, 1);
+       reg |= (tmp & 0xF);
+       reg |= ((tmp & 0x10) << 16);    /* to bit 20 */
+
+       /* tRCD - (4:7) */
+       spd_val = ddr3_div(sum_info.min_ras_to_cas_delay, ddr_clk_time, 1);
+       stat_val = ddr3_get_static_mc_value(REG_SDRAM_TIMING_LOW_ADDR,
+                                           4, 0xF, 0, 0);
+       tmp = ddr3_get_max_val(spd_val, dimm_num, stat_val);
+       DEBUG_INIT_FULL_C("DDR3 - DUNIT-SET - tRCD-1 = ", tmp, 1);
+       reg |= ((tmp & 0xF) << 4);
+
+       /* tRP - (8:11) */
+       spd_val = ddr3_div(sum_info.min_row_precharge_time, ddr_clk_time, 1);
+       stat_val = ddr3_get_static_mc_value(REG_SDRAM_TIMING_LOW_ADDR,
+                                           8, 0xF, 0, 0);
+       tmp = ddr3_get_max_val(spd_val, dimm_num, stat_val);
+       DEBUG_INIT_FULL_C("DDR3 - DUNIT-SET - tRP-1 = ", tmp, 1);
+       reg |= ((tmp & 0xF) << 8);
+
+       /* tWR - (12:15) */
+       spd_val = ddr3_div(sum_info.min_write_recovery_time, ddr_clk_time, 1);
+       stat_val = ddr3_get_static_mc_value(REG_SDRAM_TIMING_LOW_ADDR,
+                                           12, 0xF, 0, 0);
+       tmp = ddr3_get_max_val(spd_val, dimm_num, stat_val);
+       DEBUG_INIT_FULL_C("DDR3 - DUNIT-SET - tWR-1 = ", tmp, 1);
+       reg |= ((tmp & 0xF) << 12);
+
+       /* tWTR - (16:19) */
+       spd_val = ddr3_div(sum_info.min_write_to_read_cmd_delay, ddr_clk_time, 1);
+       stat_val = ddr3_get_static_mc_value(REG_SDRAM_TIMING_LOW_ADDR,
+                                           16, 0xF, 0, 0);
+       tmp = ddr3_get_max_val(spd_val, dimm_num, stat_val);
+       DEBUG_INIT_FULL_C("DDR3 - DUNIT-SET - tWTR-1 = ", tmp, 1);
+       reg |= ((tmp & 0xF) << 16);
+
+       /* tRRD - (24:27) */
+       spd_val = ddr3_div(sum_info.min_row_active_to_row_active, ddr_clk_time, 1);
+       stat_val = ddr3_get_static_mc_value(REG_SDRAM_TIMING_LOW_ADDR,
+                                           24, 0xF, 0, 0);
+       tmp = ddr3_get_max_val(spd_val, dimm_num, stat_val);
+       DEBUG_INIT_FULL_C("DDR3 - DUNIT-SET - tRRD-1 = ", tmp, 1);
+       reg |= ((tmp & 0xF) << 24);
+
+       /* tRTP - (28:31) */
+       spd_val = ddr3_div(sum_info.min_read_to_prech_cmd_delay, ddr_clk_time, 1);
+       stat_val = ddr3_get_static_mc_value(REG_SDRAM_TIMING_LOW_ADDR,
+                                           28, 0xF, 0, 0);
+       tmp = ddr3_get_max_val(spd_val, dimm_num, stat_val);
+       DEBUG_INIT_FULL_C("DDR3 - DUNIT-SET - tRTP-1 = ", tmp, 1);
+       reg |= ((tmp & 0xF) << 28);
+
+       if (cl < 7)
+               reg = 0x33137663;
+
+       reg_write(REG_SDRAM_TIMING_LOW_ADDR, reg);
+
+       /*{0x0000140C}  -   DDR SDRAM Timing (High) Register */
+       /* Add cycles to R2R W2W */
+       reg = 0x39F8FF80;
+
+       /* tRFC - (0:6,16:18) */
+       spd_val = ddr3_div(sum_info.min_refresh_recovery, ddr_clk_time, 1);
+       stat_val = ddr3_get_static_mc_value(REG_SDRAM_TIMING_HIGH_ADDR,
+                                           0, 0x7F, 9, 0x380);
+       tmp = ddr3_get_max_val(spd_val, dimm_num, stat_val);
+       DEBUG_INIT_FULL_C("DDR3 - DUNIT-SET - tRFC-1 = ", tmp, 1);
+       reg |= (tmp & 0x7F);
+       reg |= ((tmp & 0x380) << 9);    /* to bit 16 */
+       reg_write(REG_SDRAM_TIMING_HIGH_ADDR, reg);
+
+       /*{0x00001410}  -   DDR SDRAM Address Control Register */
+       reg = 0x000F0000;
+
+       /* tFAW - (24:28)  */
+#if (defined(MV88F78X60) || defined(MV88F672X))
+       tmp = sum_info.min_four_active_win_delay;
+       spd_val = ddr3_div(tmp, ddr_clk_time, 0);
+       stat_val = ddr3_get_static_mc_value(REG_SDRAM_ADDRESS_CTRL_ADDR,
+                                           24, 0x3F, 0, 0);
+       tmp = ddr3_get_max_val(spd_val, dimm_num, stat_val);
+       DEBUG_INIT_FULL_C("DDR3 - DUNIT-SET - tFAW = ", tmp, 1);
+       reg |= ((tmp & 0x3F) << 24);
+#else
+       tmp = sum_info.min_four_active_win_delay -
+               4 * (sum_info.min_row_active_to_row_active);
+       spd_val = ddr3_div(tmp, ddr_clk_time, 0);
+       stat_val = ddr3_get_static_mc_value(REG_SDRAM_ADDRESS_CTRL_ADDR,
+                                           24, 0x1F, 0, 0);
+       tmp = ddr3_get_max_val(spd_val, dimm_num, stat_val);
+       DEBUG_INIT_FULL_C("DDR3 - DUNIT-SET - tFAW-4*tRRD = ", tmp, 1);
+       reg |= ((tmp & 0x1F) << 24);
+#endif
+
+       /* SDRAM device capacity */
+#ifdef DUNIT_STATIC
+       reg |= (reg_read(REG_SDRAM_ADDRESS_CTRL_ADDR) & 0xF0FFFF);
+#endif
+
+#ifdef DUNIT_SPD
+       cs_count = 0;
+       dimm_cnt = 0;
+       for (cs = 0; cs < MAX_CS; cs++) {
+               if (cs_ena & (1 << cs) & DIMM_CS_BITMAP) {
+                       if (dimm_info[dimm_cnt].num_of_module_ranks == cs_count) {
+                               dimm_cnt++;
+                               cs_count = 0;
+                       }
+                       cs_count++;
+                       if (dimm_info[dimm_cnt].sdram_capacity < 0x3) {
+                               reg |= ((dimm_info[dimm_cnt].sdram_capacity + 1) <<
+                                       (REG_SDRAM_ADDRESS_SIZE_OFFS +
+                                        (REG_SDRAM_ADDRESS_CTRL_STRUCT_OFFS * cs)));
+                       } else if (dimm_info[dimm_cnt].sdram_capacity > 0x3) {
+                               reg |= ((dimm_info[dimm_cnt].sdram_capacity & 0x3) <<
+                                       (REG_SDRAM_ADDRESS_SIZE_OFFS +
+                                        (REG_SDRAM_ADDRESS_CTRL_STRUCT_OFFS * cs)));
+                               reg |= ((dimm_info[dimm_cnt].sdram_capacity & 0x4) <<
+                                       (REG_SDRAM_ADDRESS_SIZE_HIGH_OFFS + cs));
+                       }
+               }
+       }
+
+       /* SDRAM device structure */
+       cs_count = 0;
+       dimm_cnt = 0;
+       for (cs = 0; cs < MAX_CS; cs++) {
+               if (cs_ena & (1 << cs) & DIMM_CS_BITMAP) {
+                       if (dimm_info[dimm_cnt].num_of_module_ranks == cs_count) {
+                               dimm_cnt++;
+                               cs_count = 0;
+                       }
+                       cs_count++;
+                       if (dimm_info[dimm_cnt].sdram_width == 16)
+                               reg |= (1 << (REG_SDRAM_ADDRESS_CTRL_STRUCT_OFFS * cs));
+               }
+       }
+#endif
+       reg_write(REG_SDRAM_ADDRESS_CTRL_ADDR, reg);
+
+       /*{0x00001418}  -   DDR SDRAM Operation Register */
+       reg = 0xF00;
+       for (cs = 0; cs < MAX_CS; cs++) {
+               if (cs_ena & (1 << cs))
+                       reg &= ~(1 << (cs + REG_SDRAM_OPERATION_CS_OFFS));
+       }
+       reg_write(REG_SDRAM_OPERATION_ADDR, reg);
+
+       /*{0x00001420}  -   DDR SDRAM Extended Mode Register */
+       reg = 0x00000004;
+       reg_write(REG_SDRAM_EXT_MODE_ADDR, reg);
+
+       /*{0x00001424}  -   DDR Controller Control (High) Register */
+#if (defined(MV88F78X60) || defined(MV88F672X))
+       reg = 0x0000D3FF;
+#else
+       reg = 0x0100D1FF;
+#endif
+       reg_write(REG_DDR_CONT_HIGH_ADDR, reg);
+
+       /*{0x0000142C}  -   DDR3 Timing Register */
+       reg = 0x014C2F38;
+#if defined(MV88F78X60) || defined(MV88F672X)
+       reg = 0x1FEC2F38;
+#endif
+       reg_write(0x142C, reg);
+
+       /*{0x00001484}  - MBus CPU Block Register */
+#ifdef MV88F67XX
+       if (reg_read(REG_DDR_IO_ADDR) & (1 << REG_DDR_IO_CLK_RATIO_OFFS))
+               reg_write(REG_MBUS_CPU_BLOCK_ADDR, 0x0000E907);
+#endif
+
+       /*
+        * In case of mixed dimm and on-board devices setup paramters will
+        * be taken statically
+        */
+       /*{0x00001494}  -   DDR SDRAM ODT Control (Low) Register */
+       reg = odt_config[cs_ena];
+       reg_write(REG_SDRAM_ODT_CTRL_LOW_ADDR, reg);
+
+       /*{0x00001498}  -   DDR SDRAM ODT Control (High) Register */
+       reg = 0x00000000;
+       reg_write(REG_SDRAM_ODT_CTRL_HIGH_ADDR, reg);
+
+       /*{0x0000149C}  -   DDR Dunit ODT Control Register */
+       reg = cs_ena;
+       reg_write(REG_DUNIT_ODT_CTRL_ADDR, reg);
+
+       /*{0x000014A0}  -   DDR Dunit ODT Control Register */
+#if defined(MV88F672X)
+       reg = 0x000006A9;
+       reg_write(REG_DRAM_FIFO_CTRL_ADDR, reg);
+#endif
+
+       /*{0x000014C0}  -   DRAM address and Control Driving Strenght */
+       reg_write(REG_DRAM_ADDR_CTRL_DRIVE_STRENGTH_ADDR, 0x192435e9);
+
+       /*{0x000014C4}  -   DRAM Data and DQS Driving Strenght */
+       reg_write(REG_DRAM_DATA_DQS_DRIVE_STRENGTH_ADDR, 0xB2C35E9);
+
+#if (defined(MV88F78X60) || defined(MV88F672X))
+       /*{0x000014CC}  -   DRAM Main Pads Calibration Machine Control Register */
+       reg = reg_read(REG_DRAM_MAIN_PADS_CAL_ADDR);
+       reg_write(REG_DRAM_MAIN_PADS_CAL_ADDR, reg | (1 << 0));
+#endif
+
+#if defined(MV88F672X)
+       /* DRAM Main Pads Calibration Machine Control Register */
+       /* 0x14CC[4:3] - CalUpdateControl = IntOnly */
+       reg = reg_read(REG_DRAM_MAIN_PADS_CAL_ADDR);
+       reg &= 0xFFFFFFE7;
+       reg |= (1 << 3);
+       reg_write(REG_DRAM_MAIN_PADS_CAL_ADDR, reg);
+#endif
+
+#ifdef DUNIT_SPD
+       cs_count = 0;
+       dimm_cnt = 0;
+       for (cs = 0; cs < MAX_CS; cs++) {
+               if ((1 << cs) & DIMM_CS_BITMAP) {
+                       if ((1 << cs) & cs_ena) {
+                               if (dimm_info[dimm_cnt].num_of_module_ranks ==
+                                   cs_count) {
+                                       dimm_cnt++;
+                                       cs_count = 0;
+                               }
+                               cs_count++;
+                               reg_write(REG_CS_SIZE_SCRATCH_ADDR + (cs * 0x8),
+                                         dimm_info[dimm_cnt].rank_capacity - 1);
+                       } else {
+                               reg_write(REG_CS_SIZE_SCRATCH_ADDR + (cs * 0x8), 0);
+                       }
+               }
+       }
+#endif
+
+       /*{0x00020184}  -   Close FastPath - 2G */
+       reg_write(REG_FASTPATH_WIN_0_CTRL_ADDR, 0);
+
+       /*{0x00001538}  -    Read Data Sample Delays Register */
+       reg = 0;
+       for (cs = 0; cs < MAX_CS; cs++) {
+               if (cs_ena & (1 << cs))
+                       reg |= (cl << (REG_READ_DATA_SAMPLE_DELAYS_OFFS * cs));
+       }
+
+       reg_write(REG_READ_DATA_SAMPLE_DELAYS_ADDR, reg);
+       DEBUG_INIT_FULL_C("DDR3 - SPD-SET - Read Data Sample Delays = ", reg,
+                         1);
+
+       /*{0x0000153C}  -   Read Data Ready Delay Register */
+       reg = 0;
+       for (cs = 0; cs < MAX_CS; cs++) {
+               if (cs_ena & (1 << cs)) {
+                       reg |= ((cl + 2) <<
+                               (REG_READ_DATA_READY_DELAYS_OFFS * cs));
+               }
+       }
+       reg_write(REG_READ_DATA_READY_DELAYS_ADDR, reg);
+       DEBUG_INIT_FULL_C("DDR3 - SPD-SET - Read Data Ready Delays = ", reg, 1);
+
+       /* Set MR registers */
+       /* MR0 */
+       reg = 0x00000600;
+       tmp = ddr3_cl_to_valid_cl(cl);
+       reg |= ((tmp & 0x1) << 2);
+       reg |= ((tmp & 0xE) << 3);      /* to bit 4 */
+       for (cs = 0; cs < MAX_CS; cs++) {
+               if (cs_ena & (1 << cs)) {
+                       reg_write(REG_DDR3_MR0_CS_ADDR +
+                                 (cs << MR_CS_ADDR_OFFS), reg);
+               }
+       }
+
+       /* MR1 */
+       reg = 0x00000044 & REG_DDR3_MR1_ODT_MASK;
+       if (cs_num > 1)
+               reg = 0x00000046 & REG_DDR3_MR1_ODT_MASK;
+
+       for (cs = 0; cs < MAX_CS; cs++) {
+               if (cs_ena & (1 << cs)) {
+                       reg |= odt_static[cs_ena][cs];
+                       reg_write(REG_DDR3_MR1_CS_ADDR +
+                                 (cs << MR_CS_ADDR_OFFS), reg);
+               }
+       }
+
+       /* MR2 */
+       if (reg_read(REG_DDR_IO_ADDR) & (1 << REG_DDR_IO_CLK_RATIO_OFFS))
+               tmp = hclk_time / 2;
+       else
+               tmp = hclk_time;
+
+       if (tmp >= 2500)
+               cwl = 5;        /* CWL = 5 */
+       else if (tmp >= 1875 && tmp < 2500)
+               cwl = 6;        /* CWL = 6 */
+       else if (tmp >= 1500 && tmp < 1875)
+               cwl = 7;        /* CWL = 7 */
+       else if (tmp >= 1250 && tmp < 1500)
+               cwl = 8;        /* CWL = 8 */
+       else if (tmp >= 1070 && tmp < 1250)
+               cwl = 9;        /* CWL = 9 */
+       else if (tmp >= 935 && tmp < 1070)
+               cwl = 10;       /* CWL = 10 */
+       else if (tmp >= 833 && tmp < 935)
+               cwl = 11;       /* CWL = 11 */
+       else if (tmp >= 750 && tmp < 833)
+               cwl = 12;       /* CWL = 12 */
+       else {
+               cwl = 12;       /* CWL = 12 */
+               printf("Unsupported hclk %d MHz\n", tmp);
+       }
+
+       reg = ((cwl - 5) << REG_DDR3_MR2_CWL_OFFS);
+
+       for (cs = 0; cs < MAX_CS; cs++) {
+               if (cs_ena & (1 << cs)) {
+                       reg &= REG_DDR3_MR2_ODT_MASK;
+                       reg |= odt_dynamic[cs_ena][cs];
+                       reg_write(REG_DDR3_MR2_CS_ADDR +
+                                 (cs << MR_CS_ADDR_OFFS), reg);
+               }
+       }
+
+       /* MR3 */
+       reg = 0x00000000;
+       for (cs = 0; cs < MAX_CS; cs++) {
+               if (cs_ena & (1 << cs)) {
+                       reg_write(REG_DDR3_MR3_CS_ADDR +
+                                 (cs << MR_CS_ADDR_OFFS), reg);
+               }
+       }
+
+       /* {0x00001428}  -   DDR ODT Timing (Low) Register */
+       reg = 0;
+       reg |= (((cl - cwl + 1) & 0xF) << 4);
+       reg |= (((cl - cwl + 6) & 0xF) << 8);
+       reg |= ((((cl - cwl + 6) >> 4) & 0x1) << 21);
+       reg |= (((cl - 1) & 0xF) << 12);
+       reg |= (((cl + 6) & 0x1F) << 16);
+       reg_write(REG_ODT_TIME_LOW_ADDR, reg);
+
+       /* {0x0000147C}  -   DDR ODT Timing (High) Register */
+       reg = 0x00000071;
+       reg |= ((cwl - 1) << 8);
+       reg |= ((cwl + 5) << 12);
+       reg_write(REG_ODT_TIME_HIGH_ADDR, reg);
+
+#ifdef DUNIT_SPD
+       /*{0x000015E0} - DDR3 Rank Control Register */
+       reg = cs_ena;
+       cs_count = 0;
+       dimm_cnt = 0;
+       for (cs = 0; cs < MAX_CS; cs++) {
+               if (cs_ena & (1 << cs) & DIMM_CS_BITMAP) {
+                       if (dimm_info[dimm_cnt].num_of_module_ranks == cs_count) {
+                               dimm_cnt++;
+                               cs_count = 0;
+                       }
+                       cs_count++;
+
+                       if (dimm_info[dimm_cnt].addr_mirroring &&
+                           (cs == 1 || cs == 3) &&
+                           (sum_info.type_info != SPD_MODULE_TYPE_RDIMM)) {
+                               reg |= (1 << (REG_DDR3_RANK_CTRL_MIRROR_OFFS + cs));
+                               DEBUG_INIT_FULL_C("DDR3 - SPD-SET - Setting Address Mirroring for CS = ",
+                                                 cs, 1);
+                       }
+               }
+       }
+       reg_write(REG_DDR3_RANK_CTRL_ADDR, reg);
+#endif
+
+       /*{0xD00015E4}  -   ZQDS Configuration Register */
+       reg = 0x00203c18;
+       reg_write(REG_ZQC_CONF_ADDR, reg);
+
+       /* {0x00015EC}  -   DDR PHY */
+#if defined(MV88F78X60)
+       reg = 0xF800AAA5;
+       if (mv_ctrl_rev_get() == MV_78XX0_B0_REV)
+               reg = 0xF800A225;
+#else
+       reg = 0xDE000025;
+#if defined(MV88F672X)
+       reg = 0xF800A225;
+#endif
+#endif
+       reg_write(REG_DRAM_PHY_CONFIG_ADDR, reg);
+
+#if (defined(MV88F78X60) || defined(MV88F672X))
+       /* Registered DIMM support - supported only in AXP A0 devices */
+       /* Currently supported for SPD detection only */
+       /*
+        * Flow is according to the Registered DIMM chapter in the
+        * Functional Spec
+        */
+       if (sum_info.type_info == SPD_MODULE_TYPE_RDIMM) {
+               DEBUG_INIT_S("DDR3 Training Sequence - Registered DIMM detected\n");
+
+               /* Set commands parity completion */
+               reg = reg_read(REG_REGISTERED_DRAM_CTRL_ADDR);
+               reg &= ~REG_REGISTERED_DRAM_CTRL_PARITY_MASK;
+               reg |= 0x8;
+               reg_write(REG_REGISTERED_DRAM_CTRL_ADDR, reg);
+
+               /* De-assert M_RESETn and assert M_CKE */
+               reg_write(REG_SDRAM_INIT_CTRL_ADDR,
+                         1 << REG_SDRAM_INIT_CKE_ASSERT_OFFS);
+               do {
+                       reg = (reg_read(REG_SDRAM_INIT_CTRL_ADDR)) &
+                               (1 << REG_SDRAM_INIT_CKE_ASSERT_OFFS);
+               } while (reg);
+
+               for (rc = 0; rc < SPD_RDIMM_RC_NUM; rc++) {
+                       if (rc != 6 && rc != 7) {
+                               /* Set CWA Command */
+                               reg = (REG_SDRAM_OPERATION_CMD_CWA &
+                                      ~(0xF << REG_SDRAM_OPERATION_CS_OFFS));
+                               reg |= ((dimm_info[0].dimm_rc[rc] &
+                                        REG_SDRAM_OPERATION_CWA_DATA_MASK) <<
+                                       REG_SDRAM_OPERATION_CWA_DATA_OFFS);
+                               reg |= rc << REG_SDRAM_OPERATION_CWA_RC_OFFS;
+                               /* Configure - Set Delay - tSTAB/tMRD */
+                               if (rc == 2 || rc == 10)
+                                       reg |= (0x1 << REG_SDRAM_OPERATION_CWA_DELAY_SEL_OFFS);
+                               /* 0x1418 - SDRAM Operation Register */
+                               reg_write(REG_SDRAM_OPERATION_ADDR, reg);
+
+                               /*
+                                * Poll the "cmd" field in the SDRAM OP
+                                * register for 0x0
+                                */
+                               do {
+                                       reg = reg_read(REG_SDRAM_OPERATION_ADDR) &
+                                               (REG_SDRAM_OPERATION_CMD_MASK);
+                               } while (reg);
+                       }
+               }
+       }
+#endif
+
+       return MV_OK;
+}
+
+/*
+ * Name:     ddr3_div - this function divides integers
+ * Desc:
+ * Args:     val - the value
+ *           divider - the divider
+ *           sub - substruction value
+ * Notes:
+ * Returns:  required value
+ */
+u32 ddr3_div(u32 val, u32 divider, u32 sub)
+{
+       return val / divider + (val % divider > 0 ? 1 : 0) - sub;
+}
+
+/*
+ * Name:     ddr3_get_max_val
+ * Desc:
+ * Args:
+ * Notes:
+ * Returns:
+ */
+u32 ddr3_get_max_val(u32 spd_val, u32 dimm_num, u32 static_val)
+{
+#ifdef DUNIT_STATIC
+       if (dimm_num > 0) {
+               if (spd_val >= static_val)
+                       return spd_val;
+               else
+                       return static_val;
+       } else {
+               return static_val;
+       }
+#else
+       return spd_val;
+#endif
+}
+
+/*
+ * Name:     ddr3_get_min_val
+ * Desc:
+ * Args:
+ * Notes:
+ * Returns:
+ */
+u32 ddr3_get_min_val(u32 spd_val, u32 dimm_num, u32 static_val)
+{
+#ifdef DUNIT_STATIC
+       if (dimm_num > 0) {
+               if (spd_val <= static_val)
+                       return spd_val;
+               else
+                       return static_val;
+       } else
+               return static_val;
+#else
+       return spd_val;
+#endif
+}
+#endif
diff --git a/drivers/ddr/mvebu/ddr3_write_leveling.c b/drivers/ddr/mvebu/ddr3_write_leveling.c
new file mode 100644 (file)
index 0000000..df3a3df
--- /dev/null
@@ -0,0 +1,1366 @@
+/*
+ * Copyright (C) Marvell International Ltd. and its affiliates
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#include <common.h>
+#include <i2c.h>
+#include <spl.h>
+#include <asm/io.h>
+#include <asm/arch/cpu.h>
+#include <asm/arch/soc.h>
+
+#include "ddr3_hw_training.h"
+
+/*
+ * Debug
+ */
+#define DEBUG_WL_C(s, d, l) \
+       DEBUG_WL_S(s); DEBUG_WL_D(d, l); DEBUG_WL_S("\n")
+#define DEBUG_WL_FULL_C(s, d, l) \
+       DEBUG_WL_FULL_S(s); DEBUG_WL_FULL_D(d, l); DEBUG_WL_FULL_S("\n")
+
+#ifdef MV_DEBUG_WL
+#define DEBUG_RL_S(s) \
+       debug_cond(ddr3_get_log_level() >= MV_LOG_LEVEL_2, "%s", s)
+#define DEBUG_RL_D(d, l) \
+       debug_cond(ddr3_get_log_level() >= MV_LOG_LEVEL_2, "%x", d)
+#else
+#define DEBUG_WL_S(s)
+#define DEBUG_WL_D(d, l)
+#endif
+
+#ifdef MV_DEBUG_WL_FULL
+#define DEBUG_WL_FULL_S(s)             puts(s)
+#define DEBUG_WL_FULL_D(d, l)          printf("%x", d)
+#else
+#define DEBUG_WL_FULL_S(s)
+#define DEBUG_WL_FULL_D(d, l)
+#endif
+
+#define WL_SUP_EXPECTED_DATA           0x21
+#define WL_SUP_READ_DRAM_ENTRY         0x8
+
+static int ddr3_write_leveling_single_cs(u32 cs, u32 freq, int ratio_2to1,
+                                        u32 *result,
+                                        MV_DRAM_INFO *dram_info);
+static void ddr3_write_ctrl_pup_reg(int bc_acc, u32 pup, u32 reg_addr,
+                                   u32 data);
+
+extern u16 odt_static[ODT_OPT][MAX_CS];
+extern u16 odt_dynamic[ODT_OPT][MAX_CS];
+extern u32 wl_sup_pattern[LEN_WL_SUP_PATTERN];
+
+/*
+ * Name:     ddr3_write_leveling_hw
+ * Desc:     Execute Write leveling phase by HW
+ * Args:     freq      - current sequence frequency
+ *           dram_info   - main struct
+ * Notes:
+ * Returns:  MV_OK if success, MV_FAIL if fail.
+ */
+int ddr3_write_leveling_hw(u32 freq, MV_DRAM_INFO *dram_info)
+{
+       u32 reg, phase, delay, cs, pup;
+#ifdef MV88F67XX
+       int dpde_flag = 0;
+#endif
+       /* Debug message - Start Read leveling procedure */
+       DEBUG_WL_S("DDR3 - Write Leveling - Starting HW WL procedure\n");
+
+#ifdef MV88F67XX
+       /* Dynamic pad issue (BTS669) during WL */
+       reg = reg_read(REG_DUNIT_CTRL_LOW_ADDR);
+       if (reg & (1 << REG_DUNIT_CTRL_LOW_DPDE_OFFS)) {
+               dpde_flag = 1;
+               reg_write(REG_DUNIT_CTRL_LOW_ADDR,
+                         reg & ~(1 << REG_DUNIT_CTRL_LOW_DPDE_OFFS));
+       }
+#endif
+
+       reg = 1 << REG_DRAM_TRAINING_WL_OFFS;
+       /* Config the retest number */
+       reg |= (COUNT_HW_WL << REG_DRAM_TRAINING_RETEST_OFFS);
+       reg |= (dram_info->cs_ena << (REG_DRAM_TRAINING_CS_OFFS));
+       reg_write(REG_DRAM_TRAINING_ADDR, reg); /* 0x15B0 - Training Register */
+
+       reg =  reg_read(REG_DRAM_TRAINING_SHADOW_ADDR) |
+               (1 << REG_DRAM_TRAINING_AUTO_OFFS);
+       reg_write(REG_DRAM_TRAINING_SHADOW_ADDR, reg);
+
+       /* Wait */
+       do {
+               reg = reg_read(REG_DRAM_TRAINING_SHADOW_ADDR) &
+                       (1 << REG_DRAM_TRAINING_AUTO_OFFS);
+       } while (reg);          /* Wait for '0' */
+
+       reg = reg_read(REG_DRAM_TRAINING_ADDR);
+       /* Check if Successful */
+       if (reg & (1 << REG_DRAM_TRAINING_ERROR_OFFS)) {
+               /*
+                * Read results to arrays - Results are required for WL
+                * High freq Supplement and DQS Centralization
+                */
+               for (cs = 0; cs < MAX_CS; cs++) {
+                       if (dram_info->cs_ena & (1 << cs)) {
+                               for (pup = 0;
+                                    pup < dram_info->num_of_total_pups;
+                                    pup++) {
+                                       if (pup == dram_info->num_of_std_pups
+                                           && dram_info->ecc_ena)
+                                               pup = ECC_PUP;
+                                       reg =
+                                           ddr3_read_pup_reg(PUP_WL_MODE, cs,
+                                                             pup);
+                                       phase =
+                                           (reg >> REG_PHY_PHASE_OFFS) &
+                                           PUP_PHASE_MASK;
+                                       delay = reg & PUP_DELAY_MASK;
+                                       dram_info->wl_val[cs][pup][P] = phase;
+                                       dram_info->wl_val[cs][pup][D] = delay;
+                                       dram_info->wl_val[cs][pup][S] =
+                                           WL_HI_FREQ_STATE - 1;
+                                       reg =
+                                           ddr3_read_pup_reg(PUP_WL_MODE + 0x1,
+                                                             cs, pup);
+                                       dram_info->wl_val[cs][pup][DQS] =
+                                           (reg & 0x3F);
+                               }
+
+#ifdef MV_DEBUG_WL
+                               /* Debug message - Print res for cs[i]: cs,PUP,Phase,Delay */
+                               DEBUG_WL_S("DDR3 - Write Leveling - Write Leveling Cs - ");
+                               DEBUG_WL_D((u32) cs, 1);
+                               DEBUG_WL_S(" Results:\n");
+                               for (pup = 0;
+                                    pup < dram_info->num_of_total_pups;
+                                    pup++) {
+                                       if (pup == dram_info->num_of_std_pups
+                                           && dram_info->ecc_ena)
+                                               pup = ECC_PUP;
+                                       DEBUG_WL_S("DDR3 - Write Leveling - PUP: ");
+                                       DEBUG_WL_D((u32) pup, 1);
+                                       DEBUG_WL_S(", Phase: ");
+                                       DEBUG_WL_D((u32)
+                                                  dram_info->wl_val[cs][pup]
+                                                  [P], 1);
+                                       DEBUG_WL_S(", Delay: ");
+                                       DEBUG_WL_D((u32)
+                                                  dram_info->wl_val[cs][pup]
+                                                  [D], 2);
+                                       DEBUG_WL_S("\n");
+                               }
+#endif
+                       }
+               }
+
+               /* Dynamic pad issue (BTS669) during WL */
+#ifdef MV88F67XX
+               if (dpde_flag) {
+                       reg = reg_read(REG_DUNIT_CTRL_LOW_ADDR) |
+                               (1 << REG_DUNIT_CTRL_LOW_DPDE_OFFS);
+                       reg_write(REG_DUNIT_CTRL_LOW_ADDR, reg);
+               }
+#endif
+
+               DEBUG_WL_S("DDR3 - Write Leveling - HW WL Ended Successfully\n");
+
+               return MV_OK;
+       } else {
+               DEBUG_WL_S("DDR3 - Write Leveling - HW WL Error\n");
+               return MV_FAIL;
+       }
+}
+
+/*
+ * Name:     ddr3_wl_supplement
+ * Desc:     Write Leveling Supplement
+ * Args:     dram_info   - main struct
+ * Notes:
+ * Returns:  MV_OK if success, MV_FAIL if fail.
+ */
+int ddr3_wl_supplement(MV_DRAM_INFO *dram_info)
+{
+       u32 cs, cnt, pup_num, sum, phase, delay, max_pup_num, pup, sdram_offset;
+       u32 tmp_count, ecc, reg;
+       u32 ddr_width, tmp_pup, idx;
+       u32 sdram_pup_val, uj;
+       u32 one_clk_err = 0, align_err = 0, no_err = 0, err = 0, err_n = 0;
+       u32 sdram_data[LEN_WL_SUP_PATTERN] __aligned(32) = { 0 };
+
+       ddr_width = dram_info->ddr_width;
+       no_err = 0;
+
+       DEBUG_WL_S("DDR3 - Write Leveling Hi-Freq Supplement - Starting\n");
+
+       switch (ddr_width) {
+               /* Data error from pos-adge to pos-adge */
+       case 16:
+               one_clk_err = 4;
+               align_err = 4;
+               break;
+       case 32:
+               one_clk_err = 8;
+               align_err = 8;
+               break;
+       case 64:
+               one_clk_err = 0x10;
+               align_err = 0x10;
+               break;
+       default:
+               DEBUG_WL_S("Error - bus width!!!\n");
+               return MV_FAIL;
+       }
+
+       /* Enable SW override */
+       reg = reg_read(REG_DRAM_TRAINING_2_ADDR) |
+               (1 << REG_DRAM_TRAINING_2_SW_OVRD_OFFS);
+
+       /* [0] = 1 - Enable SW override  */
+       /* 0x15B8 - Training SW 2 Register */
+       reg_write(REG_DRAM_TRAINING_2_ADDR, reg);
+       DEBUG_WL_S("DDR3 - Write Leveling Hi-Freq Supplement - SW Override Enabled\n");
+       reg = (1 << REG_DRAM_TRAINING_AUTO_OFFS);
+       reg_write(REG_DRAM_TRAINING_ADDR, reg); /* 0x15B0 - Training Register */
+       tmp_count = 0;
+       for (cs = 0; cs < MAX_CS; cs++) {
+               if (dram_info->cs_ena & (1 << cs)) {
+                       sum = 0;
+                       /*
+                        * 2 iterations loop: 1)actual WL results 2) fix WL
+                        * if needed
+                        */
+                       for (cnt = 0; cnt < COUNT_WL_HI_FREQ; cnt++) {
+                               DEBUG_WL_C("COUNT = ", cnt, 1);
+                               for (ecc = 0; ecc < (dram_info->ecc_ena + 1);
+                                    ecc++) {
+                                       if (ecc) {
+                                               DEBUG_WL_S("ECC PUP:\n");
+                                       } else {
+                                               DEBUG_WL_S("DATA PUP:\n");
+                                       }
+
+                                       max_pup_num =
+                                           dram_info->num_of_std_pups * (1 -
+                                                                         ecc) +
+                                           ecc;
+                                       /* ECC Support - Switch ECC Mux on ecc=1 */
+                                       reg =
+                                           (reg_read(REG_DRAM_TRAINING_2_ADDR)
+                                            & ~(1 <<
+                                                REG_DRAM_TRAINING_2_ECC_MUX_OFFS));
+                                       reg |=
+                                           (dram_info->ecc_ena *
+                                            ecc <<
+                                            REG_DRAM_TRAINING_2_ECC_MUX_OFFS);
+                                       reg_write(REG_DRAM_TRAINING_2_ADDR,
+                                                 reg);
+                                       ddr3_reset_phy_read_fifo();
+
+                                       /* Write to memory */
+                                       sdram_offset =
+                                           tmp_count * (SDRAM_CS_SIZE + 1) +
+                                           0x200;
+                                       if (MV_OK != ddr3_dram_sram_burst((u32)
+                                                                         wl_sup_pattern,
+                                                                         sdram_offset,
+                                                                         LEN_WL_SUP_PATTERN))
+                                               return MV_FAIL;
+
+                                       /* Read from memory */
+                                       if (MV_OK !=
+                                           ddr3_dram_sram_burst(sdram_offset,
+                                                                (u32)
+                                                                sdram_data,
+                                                                LEN_WL_SUP_PATTERN))
+                                               return MV_FAIL;
+
+                                       /* Print the buffer */
+                                       for (uj = 0; uj < LEN_WL_SUP_PATTERN;
+                                            uj++) {
+                                               if ((uj % 4 == 0) && (uj != 0)) {
+                                                       DEBUG_WL_S("\n");
+                                               }
+                                               DEBUG_WL_D(sdram_data[uj],
+                                                          8);
+                                               DEBUG_WL_S(" ");
+                                       }
+
+                                       /* Check pup which DQS/DATA is error */
+                                       for (pup = 0; pup < max_pup_num; pup++) {
+                                               /* ECC support - bit 8 */
+                                               pup_num = (ecc) ? ECC_PUP : pup;
+                                               if (pup < 4) {  /* lower 32 bit */
+                                                       tmp_pup = pup;
+                                                       idx =
+                                                           WL_SUP_READ_DRAM_ENTRY;
+                                               } else {        /* higher 32 bit */
+                                                       tmp_pup = pup - 4;
+                                                       idx =
+                                                           WL_SUP_READ_DRAM_ENTRY
+                                                           + 1;
+                                               }
+                                               DEBUG_WL_S("\nCS: ");
+                                               DEBUG_WL_D((u32) cs, 1);
+                                               DEBUG_WL_S(" PUP: ");
+                                               DEBUG_WL_D((u32) pup_num, 1);
+                                               DEBUG_WL_S("\n");
+                                               sdram_pup_val =
+                                                   ((sdram_data[idx] >>
+                                                     ((tmp_pup) * 8)) & 0xFF);
+                                               DEBUG_WL_C("Actual Data = ",
+                                                          sdram_pup_val, 2);
+                                               DEBUG_WL_C("Expected Data = ",
+                                                          (WL_SUP_EXPECTED_DATA
+                                                           + pup), 2);
+                                               /*
+                                                * ALINGHMENT: calculate
+                                                * expected data vs actual data
+                                                */
+                                               err =
+                                                   (WL_SUP_EXPECTED_DATA +
+                                                    pup) - sdram_pup_val;
+                                               /*
+                                                * CLOCK LONG: calculate
+                                                * expected data vs actual data
+                                                */
+                                               err_n =
+                                                   sdram_pup_val -
+                                                   (WL_SUP_EXPECTED_DATA +
+                                                    pup);
+                                               DEBUG_WL_C("err = ", err, 2);
+                                               DEBUG_WL_C("err_n = ", err_n,
+                                                          2);
+                                               if (err == no_err) {
+                                                       /* PUP is correct - increment State */
+                                                       dram_info->wl_val[cs]
+                                                           [pup_num]
+                                                           [S] = 1;
+                                               } else if (err_n == one_clk_err) {
+                                                       /* clock is longer than DQS */
+                                                       phase =
+                                                           ((dram_info->wl_val
+                                                             [cs]
+                                                             [pup_num][P] +
+                                                             WL_HI_FREQ_SHIFT)
+                                                            % MAX_PHASE_2TO1);
+                                                       dram_info->wl_val[cs]
+                                                           [pup_num]
+                                                           [P] = phase;
+                                                       delay =
+                                                           dram_info->wl_val
+                                                           [cs][pup_num]
+                                                           [D];
+                                                       DEBUG_WL_S("#### Clock is longer than DQS more than one clk cycle ####\n");
+                                                       ddr3_write_pup_reg
+                                                           (PUP_WL_MODE, cs,
+                                                            pup * (1 - ecc) +
+                                                            ECC_PUP * ecc,
+                                                            phase, delay);
+                                               } else if (err == align_err) {
+                                                       /* clock is align to DQS */
+                                                       phase =
+                                                           dram_info->wl_val
+                                                           [cs][pup_num]
+                                                           [P];
+                                                       delay =
+                                                           dram_info->wl_val
+                                                           [cs][pup_num]
+                                                           [D];
+                                                       DEBUG_WL_S("#### Alignment PUPS problem ####\n");
+                                                       if ((phase == 0)
+                                                           || ((phase == 1)
+                                                               && (delay <=
+                                                                   0x10))) {
+                                                               DEBUG_WL_S("#### Warning - Possible Layout Violation (DQS is longer than CLK)####\n");
+                                                       }
+
+                                                       phase = 0x0;
+                                                       delay = 0x0;
+                                                       dram_info->wl_val[cs]
+                                                           [pup_num]
+                                                           [P] = phase;
+                                                       dram_info->wl_val[cs]
+                                                           [pup_num]
+                                                           [D] = delay;
+                                                       ddr3_write_pup_reg
+                                                           (PUP_WL_MODE, cs,
+                                                            pup * (1 - ecc) +
+                                                            ECC_PUP * ecc,
+                                                            phase, delay);
+                                               }
+                                               /* Stop condition for ECC phase */
+                                               pup = (ecc) ? max_pup_num : pup;
+                                       }
+
+                                       /* ECC Support - Disable ECC MUX */
+                                       reg =
+                                           (reg_read(REG_DRAM_TRAINING_2_ADDR)
+                                            & ~(1 <<
+                                                REG_DRAM_TRAINING_2_ECC_MUX_OFFS));
+                                       reg_write(REG_DRAM_TRAINING_2_ADDR,
+                                                 reg);
+                               }
+                       }
+
+                       for (pup = 0; pup < dram_info->num_of_std_pups; pup++)
+                               sum += dram_info->wl_val[cs][pup][S];
+
+                       if (dram_info->ecc_ena)
+                               sum += dram_info->wl_val[cs][ECC_PUP][S];
+
+                       /* Checks if any pup is not locked after the change */
+                       if (sum < (WL_HI_FREQ_STATE * (dram_info->num_of_total_pups))) {
+                               DEBUG_WL_C("DDR3 - Write Leveling Hi-Freq Supplement - didn't work for Cs - ",
+                                          (u32) cs, 1);
+                               return MV_FAIL;
+                       }
+                       tmp_count++;
+               }
+       }
+
+       dram_info->wl_max_phase = 0;
+       dram_info->wl_min_phase = 10;
+
+       /*
+        * Read results to arrays - Results are required for DQS Centralization
+        */
+       for (cs = 0; cs < MAX_CS; cs++) {
+               if (dram_info->cs_ena & (1 << cs)) {
+                       for (pup = 0; pup < dram_info->num_of_total_pups; pup++) {
+                               if (pup == dram_info->num_of_std_pups
+                                   && dram_info->ecc_ena)
+                                       pup = ECC_PUP;
+                               reg = ddr3_read_pup_reg(PUP_WL_MODE, cs, pup);
+                               phase =
+                                   (reg >> REG_PHY_PHASE_OFFS) &
+                                   PUP_PHASE_MASK;
+                               if (phase > dram_info->wl_max_phase)
+                                       dram_info->wl_max_phase = phase;
+                               if (phase < dram_info->wl_min_phase)
+                                       dram_info->wl_min_phase = phase;
+                       }
+               }
+       }
+
+       /* Disable SW override - Must be in a different stage */
+       /* [0]=0 - Enable SW override  */
+       reg = reg_read(REG_DRAM_TRAINING_2_ADDR);
+       reg &= ~(1 << REG_DRAM_TRAINING_2_SW_OVRD_OFFS);
+       /* 0x15B8 - Training SW 2 Register */
+       reg_write(REG_DRAM_TRAINING_2_ADDR, reg);
+
+       reg = reg_read(REG_DRAM_TRAINING_1_ADDR) |
+               (1 << REG_DRAM_TRAINING_1_TRNBPOINT_OFFS);
+       reg_write(REG_DRAM_TRAINING_1_ADDR, reg);
+
+       DEBUG_WL_S("DDR3 - Write Leveling Hi-Freq Supplement - Ended Successfully\n");
+
+       return MV_OK;
+}
+
+/*
+ * Name:     ddr3_write_leveling_hw_reg_dimm
+ * Desc:     Execute Write leveling phase by HW
+ * Args:     freq      - current sequence frequency
+ *           dram_info   - main struct
+ * Notes:
+ * Returns:  MV_OK if success, MV_FAIL if fail.
+ */
+int ddr3_write_leveling_hw_reg_dimm(u32 freq, MV_DRAM_INFO *dram_info)
+{
+       u32 reg, phase, delay, cs, pup, pup_num;
+       __maybe_unused int dpde_flag = 0;
+
+       /* Debug message - Start Read leveling procedure */
+       DEBUG_WL_S("DDR3 - Write Leveling - Starting HW WL procedure\n");
+
+       if (dram_info->num_cs > 2) {
+               DEBUG_WL_S("DDR3 - Write Leveling - HW WL Ended Successfully\n");
+               return MV_NO_CHANGE;
+       }
+
+       /* If target freq = 400 move clock start point */
+       /* Write to control PUP to Control Deskew Regs */
+       if (freq <= DDR_400) {
+               for (pup = 0; pup <= dram_info->num_of_total_pups; pup++) {
+                       /* PUP_DELAY_MASK 0x1F */
+                       /* reg = 0x0C10001F + (uj << 16); */
+                       ddr3_write_ctrl_pup_reg(1, pup, CNTRL_PUP_DESKEW + pup,
+                                               0x1F);
+               }
+       }
+
+#ifdef MV88F67XX
+       /* Dynamic pad issue (BTS669) during WL */
+       reg = reg_read(REG_DUNIT_CTRL_LOW_ADDR);
+       if (reg & (1 << REG_DUNIT_CTRL_LOW_DPDE_OFFS)) {
+               dpde_flag = 1;
+               reg_write(REG_DUNIT_CTRL_LOW_ADDR,
+                         reg & ~(1 << REG_DUNIT_CTRL_LOW_DPDE_OFFS));
+       }
+#endif
+
+       reg = (1 << REG_DRAM_TRAINING_WL_OFFS);
+       /* Config the retest number */
+       reg |= (COUNT_HW_WL << REG_DRAM_TRAINING_RETEST_OFFS);
+       reg |= (dram_info->cs_ena << (REG_DRAM_TRAINING_CS_OFFS));
+       reg_write(REG_DRAM_TRAINING_ADDR, reg); /* 0x15B0 - Training Register */
+
+       reg = reg_read(REG_DRAM_TRAINING_SHADOW_ADDR) |
+               (1 << REG_DRAM_TRAINING_AUTO_OFFS);
+       reg_write(REG_DRAM_TRAINING_SHADOW_ADDR, reg);
+
+       /* Wait */
+       do {
+               reg = reg_read(REG_DRAM_TRAINING_SHADOW_ADDR) &
+                       (1 << REG_DRAM_TRAINING_AUTO_OFFS);
+       } while (reg);          /* Wait for '0' */
+
+       reg = reg_read(REG_DRAM_TRAINING_ADDR);
+       /* Check if Successful */
+       if (reg & (1 << REG_DRAM_TRAINING_ERROR_OFFS)) {
+               /*
+                * Read results to arrays - Results are required for WL High
+                * freq Supplement and DQS Centralization
+                */
+               for (cs = 0; cs < MAX_CS; cs++) {
+                       if (dram_info->cs_ena & (1 << cs)) {
+                               for (pup = 0;
+                                    pup < dram_info->num_of_total_pups;
+                                    pup++) {
+                                       if (pup == dram_info->num_of_std_pups
+                                           && dram_info->ecc_ena)
+                                               pup = ECC_BIT;
+                                       reg =
+                                           ddr3_read_pup_reg(PUP_WL_MODE, cs,
+                                                             pup);
+                                       phase =
+                                           (reg >> REG_PHY_PHASE_OFFS) &
+                                           PUP_PHASE_MASK;
+                                       delay = reg & PUP_DELAY_MASK;
+                                       dram_info->wl_val[cs][pup][P] = phase;
+                                       dram_info->wl_val[cs][pup][D] = delay;
+                                       if ((phase == 1) && (delay >= 0x1D)) {
+                                               /*
+                                                * Need to do it here for
+                                                * uncorrect WL values
+                                                */
+                                               ddr3_write_pup_reg(PUP_WL_MODE,
+                                                                  cs, pup, 0,
+                                                                  0);
+                                               dram_info->wl_val[cs][pup][P] =
+                                                   0;
+                                               dram_info->wl_val[cs][pup][D] =
+                                                   0;
+                                       }
+                                       dram_info->wl_val[cs][pup][S] =
+                                           WL_HI_FREQ_STATE - 1;
+                                       reg =
+                                           ddr3_read_pup_reg(PUP_WL_MODE + 0x1,
+                                                             cs, pup);
+                                       dram_info->wl_val[cs][pup][DQS] =
+                                           (reg & 0x3F);
+                               }
+#ifdef MV_DEBUG_WL
+                               /*
+                                * Debug message - Print res for cs[i]:
+                                * cs,PUP,Phase,Delay
+                                */
+                               DEBUG_WL_S("DDR3 - Write Leveling - Write Leveling Cs - ");
+                               DEBUG_WL_D((u32) cs, 1);
+                               DEBUG_WL_S(" Results:\n");
+                               for (pup = 0;
+                                    pup < dram_info->num_of_total_pups;
+                                    pup++) {
+                                       DEBUG_WL_S
+                                           ("DDR3 - Write Leveling - PUP: ");
+                                       DEBUG_WL_D((u32) pup, 1);
+                                       DEBUG_WL_S(", Phase: ");
+                                       DEBUG_WL_D((u32)
+                                                  dram_info->wl_val[cs][pup]
+                                                  [P], 1);
+                                       DEBUG_WL_S(", Delay: ");
+                                       DEBUG_WL_D((u32)
+                                                  dram_info->wl_val[cs][pup]
+                                                  [D], 2);
+                                       DEBUG_WL_S("\n");
+                               }
+#endif
+                       }
+               }
+
+#ifdef MV88F67XX
+               /* Dynamic pad issue (BTS669) during WL */
+               if (dpde_flag) {
+                       reg = reg_read(REG_DUNIT_CTRL_LOW_ADDR) |
+                               (1 << REG_DUNIT_CTRL_LOW_DPDE_OFFS);
+                       reg_write(REG_DUNIT_CTRL_LOW_ADDR, reg);
+               }
+#endif
+               DEBUG_WL_S("DDR3 - Write Leveling - HW WL Ended Successfully\n");
+
+               /* If target freq = 400 move clock back */
+               /* Write to control PUP to Control Deskew Regs */
+               if (freq <= DDR_400) {
+                       for (pup = 0; pup <= dram_info->num_of_total_pups;
+                            pup++) {
+                               ddr3_write_ctrl_pup_reg(1, pup,
+                                                       CNTRL_PUP_DESKEW + pup, 0);
+                       }
+               }
+
+               return MV_OK;
+       } else {
+               /* Configure Each PUP with locked leveling settings */
+               for (cs = 0; cs < MAX_CS; cs++) {
+                       if (dram_info->cs_ena & (1 << cs)) {
+                               for (pup = 0;
+                                    pup < dram_info->num_of_total_pups;
+                                    pup++) {
+                                       /* ECC support - bit 8 */
+                                       pup_num = (pup == dram_info->num_of_std_pups) ?
+                                               ECC_BIT : pup;
+                                       ddr3_write_pup_reg(PUP_WL_MODE, cs,
+                                                          pup_num, 0, 0);
+                               }
+                       }
+               }
+
+               reg_write(REG_DRAM_TRAINING_ADDR, 0);
+
+               /* If target freq = 400 move clock back */
+               /* Write to control PUP to Control Deskew Regs */
+               if (freq <= DDR_400) {
+                       for (pup = 0; pup <= dram_info->num_of_total_pups;
+                            pup++) {
+                               ddr3_write_ctrl_pup_reg(1, pup,
+                                                       CNTRL_PUP_DESKEW + pup, 0);
+                       }
+               }
+
+               DEBUG_WL_S("DDR3 - Write Leveling - HW WL Ended Successfully\n");
+               return MV_NO_CHANGE;
+       }
+}
+
+/*
+ * Name:     ddr3_write_leveling_sw
+ * Desc:     Execute Write leveling phase by SW
+ * Args:     freq      - current sequence frequency
+ *           dram_info   - main struct
+ * Notes:
+ * Returns:  MV_OK if success, MV_FAIL if fail.
+ */
+int ddr3_write_leveling_sw(u32 freq, int ratio_2to1, MV_DRAM_INFO *dram_info)
+{
+       u32 reg, cs, cnt, pup, max_pup_num;
+       u32 res[MAX_CS];
+       max_pup_num = dram_info->num_of_total_pups;
+       __maybe_unused int dpde_flag = 0;
+
+       /* Debug message - Start Write leveling procedure */
+       DEBUG_WL_S("DDR3 - Write Leveling - Starting SW WL procedure\n");
+
+#ifdef MV88F67XX
+       /* Dynamic pad issue (BTS669) during WL */
+       reg = reg_read(REG_DUNIT_CTRL_LOW_ADDR);
+       if (reg & (1 << REG_DUNIT_CTRL_LOW_DPDE_OFFS)) {
+               dpde_flag = 1;
+               reg_write(REG_DUNIT_CTRL_LOW_ADDR,
+                         reg & ~(1 << REG_DUNIT_CTRL_LOW_DPDE_OFFS));
+       }
+#endif
+
+       /* Set Output buffer-off to all CS and correct ODT values */
+       for (cs = 0; cs < MAX_CS; cs++) {
+               if (dram_info->cs_ena & (1 << cs)) {
+                       reg = reg_read(REG_DDR3_MR1_ADDR) &
+                               REG_DDR3_MR1_ODT_MASK;
+                       reg |= odt_static[dram_info->cs_ena][cs];
+                       reg |= (1 << REG_DDR3_MR1_OUTBUF_DIS_OFFS);
+
+                       /* 0x15D0 - DDR3 MR0 Register */
+                       reg_write(REG_DDR3_MR1_ADDR, reg);
+                       /* Issue MRS Command to current cs */
+                       reg = REG_SDRAM_OPERATION_CMD_MR1 &
+                               ~(1 << (REG_SDRAM_OPERATION_CS_OFFS + cs));
+                       /*
+                        * [3-0] = 0x4 - MR1 Command, [11-8] -
+                        * enable current cs
+                        */
+                       /* 0x1418 - SDRAM Operation Register */
+                       reg_write(REG_SDRAM_OPERATION_ADDR, reg);
+
+                       udelay(MRS_DELAY);
+               }
+       }
+
+       DEBUG_WL_FULL_S("DDR3 - Write Leveling - Qoff and RTT Values are set for all Cs\n");
+
+       /* Enable SW override */
+       reg = reg_read(REG_DRAM_TRAINING_2_ADDR) |
+               (1 << REG_DRAM_TRAINING_2_SW_OVRD_OFFS);
+       /* [0] = 1 - Enable SW override  */
+       /* 0x15B8 - Training SW 2 Register */
+       reg_write(REG_DRAM_TRAINING_2_ADDR, reg);
+       DEBUG_WL_FULL_S("DDR3 - Write Leveling - SW Override Enabled\n");
+
+       /* Enable PHY write leveling mode */
+       reg = reg_read(REG_DRAM_TRAINING_2_ADDR) &
+               ~(1 << REG_DRAM_TRAINING_2_WL_MODE_OFFS);
+       /* [2] = 0 - TrnWLMode - Enable */
+       /* 0x15B8 - Training SW 2 Register */
+       reg_write(REG_DRAM_TRAINING_2_ADDR, reg);
+       /* Reset WL results arry */
+       memset(dram_info->wl_val, 0, sizeof(u32) * MAX_CS * MAX_PUP_NUM * 7);
+
+       /* Loop for each cs */
+       for (cs = 0; cs < MAX_CS; cs++) {
+               if (dram_info->cs_ena & (1 << cs)) {
+                       DEBUG_WL_FULL_C("DDR3 - Write Leveling - Starting working with Cs - ",
+                                       (u32) cs, 1);
+                       /* Refresh X9 current cs */
+                       DEBUG_WL_FULL_S("DDR3 - Write Leveling - Refresh X9\n");
+                       for (cnt = 0; cnt < COUNT_WL_RFRS; cnt++) {
+                               reg =
+                                   REG_SDRAM_OPERATION_CMD_RFRS & ~(1 <<
+                                                                    (REG_SDRAM_OPERATION_CS_OFFS
+                                                                     + cs));
+                               /* [3-0] = 0x2 - refresh, [11-8] - enable current cs */
+                               reg_write(REG_SDRAM_OPERATION_ADDR, reg);       /* 0x1418 - SDRAM Operation Register */
+
+                               do {
+                                       reg =
+                                           ((reg_read
+                                             (REG_SDRAM_OPERATION_ADDR)) &
+                                            REG_SDRAM_OPERATION_CMD_RFRS_DONE);
+                               } while (reg);  /* Wait for '0' */
+                       }
+
+                       /* Configure MR1 in Cs[CsNum] - write leveling on, output buffer on */
+                       DEBUG_WL_FULL_S("DDR3 - Write Leveling - Configure MR1 for current Cs: WL-on,OB-on\n");
+                       reg = reg_read(REG_DDR3_MR1_ADDR) &
+                               REG_DDR3_MR1_OUTBUF_WL_MASK;
+                       /* Set ODT Values */
+                       reg &= REG_DDR3_MR1_ODT_MASK;
+                       reg |= odt_static[dram_info->cs_ena][cs];
+                       /* Enable WL MODE */
+                       reg |= (1 << REG_DDR3_MR1_WL_ENA_OFFS);
+                       /* [7]=1, [12]=0 - Output Buffer and write leveling enabled */
+                       reg_write(REG_DDR3_MR1_ADDR, reg);      /* 0x15D4 - DDR3 MR1 Register */
+                       /* Issue MRS Command to current cs */
+                       reg = REG_SDRAM_OPERATION_CMD_MR1 &
+                               ~(1 << (REG_SDRAM_OPERATION_CS_OFFS + cs));
+                       /*
+                        * [3-0] = 0x4 - MR1 Command, [11-8] -
+                        * enable current cs
+                        */
+                       /* 0x1418 - SDRAM Operation Register */
+                       reg_write(REG_SDRAM_OPERATION_ADDR, reg);
+
+                       udelay(MRS_DELAY);
+
+                       /* Write leveling  cs[cs] */
+                       if (MV_OK !=
+                           ddr3_write_leveling_single_cs(cs, freq, ratio_2to1,
+                                                         (u32 *)(res + cs),
+                                                         dram_info)) {
+                               DEBUG_WL_FULL_C("DDR3 - Write Leveling single Cs - FAILED -  Cs - ",
+                                               (u32) cs, 1);
+                               for (pup = 0; pup < max_pup_num; pup++) {
+                                       if (((res[cs] >> pup) & 0x1) == 0) {
+                                               DEBUG_WL_C("Failed Byte : ",
+                                                          pup, 1);
+                                       }
+                               }
+                               return MV_FAIL;
+                       }
+
+                       /* Set TrnWLDeUpd - After each CS is done */
+                       reg = reg_read(REG_TRAINING_WL_ADDR) |
+                               (1 << REG_TRAINING_WL_CS_DONE_OFFS);
+                       /* 0x16AC - Training Write leveling register */
+                       reg_write(REG_TRAINING_WL_ADDR, reg);
+
+                       /*
+                        * Debug message - Finished Write leveling cs[cs] -
+                        * each PUP Fail/Success
+                        */
+                       DEBUG_WL_FULL_C("DDR3 - Write Leveling - Finished Cs - ", (u32) cs,
+                                       1);
+                       DEBUG_WL_FULL_C("DDR3 - Write Leveling - The Results: 1-PUP locked, 0-PUP failed -",
+                                       (u32) res[cs], 3);
+
+                       /*
+                        * Configure MR1 in cs[cs] - write leveling off (0),
+                        * output buffer off (1)
+                        */
+                       reg = reg_read(REG_DDR3_MR1_ADDR) &
+                               REG_DDR3_MR1_OUTBUF_WL_MASK;
+                       reg |= (1 << REG_DDR3_MR1_OUTBUF_DIS_OFFS);
+                       /* No need to sort ODT since it is same CS */
+                       /* 0x15D4 - DDR3 MR1 Register */
+                       reg_write(REG_DDR3_MR1_ADDR, reg);
+                       /* Issue MRS Command to current cs */
+                       reg = REG_SDRAM_OPERATION_CMD_MR1 &
+                               ~(1 << (REG_SDRAM_OPERATION_CS_OFFS + cs));
+                       /*
+                        * [3-0] = 0x4 - MR1 Command, [11-8] -
+                        * enable current cs
+                        */
+                       /* 0x1418 - SDRAM Operation Register */
+                       reg_write(REG_SDRAM_OPERATION_ADDR, reg);
+
+                       udelay(MRS_DELAY);
+               }
+       }
+
+       /* Disable WL Mode */
+       /* [2]=1 - TrnWLMode - Disable */
+       reg = reg_read(REG_DRAM_TRAINING_2_ADDR);
+       reg |= (1 << REG_DRAM_TRAINING_2_WL_MODE_OFFS);
+       /* 0x15B8 - Training SW 2 Register */
+       reg_write(REG_DRAM_TRAINING_2_ADDR, reg);
+
+       /* Disable SW override - Must be in a different stage */
+       /* [0]=0 - Enable SW override  */
+       reg = reg_read(REG_DRAM_TRAINING_2_ADDR);
+       reg &= ~(1 << REG_DRAM_TRAINING_2_SW_OVRD_OFFS);
+       /* 0x15B8 - Training SW 2 Register */
+       reg_write(REG_DRAM_TRAINING_2_ADDR, reg);
+
+       /* Set Output buffer-on to all CS and correct ODT values */
+       for (cs = 0; cs < MAX_CS; cs++) {
+               if (dram_info->cs_ena & (1 << cs)) {
+                       reg = reg_read(REG_DDR3_MR1_ADDR) &
+                               REG_DDR3_MR1_ODT_MASK;
+                       reg &= REG_DDR3_MR1_OUTBUF_WL_MASK;
+                       reg |= odt_static[dram_info->cs_ena][cs];
+
+                       /* 0x15D0 - DDR3 MR1 Register */
+                       reg_write(REG_DDR3_MR1_ADDR, reg);
+                       /* Issue MRS Command to current cs */
+                       reg = REG_SDRAM_OPERATION_CMD_MR1 &
+                               ~(1 << (REG_SDRAM_OPERATION_CS_OFFS + cs));
+                       /*
+                        * [3-0] = 0x4 - MR1 Command, [11-8] -
+                        * enable current cs
+                        */
+                       /* 0x1418 - SDRAM Operation Register */
+                       reg_write(REG_SDRAM_OPERATION_ADDR, reg);
+
+                       udelay(MRS_DELAY);
+               }
+       }
+
+#ifdef MV88F67XX
+       /* Dynamic pad issue (BTS669) during WL */
+       if (dpde_flag) {
+               reg = reg_read(REG_DUNIT_CTRL_LOW_ADDR) |
+                       (1 << REG_DUNIT_CTRL_LOW_DPDE_OFFS);
+               reg_write(REG_DUNIT_CTRL_LOW_ADDR, reg);
+       }
+#endif
+       DEBUG_WL_FULL_S("DDR3 - Write Leveling - Finished WL procedure for all Cs\n");
+
+       return MV_OK;
+}
+
+#if !defined(MV88F672X)
+/*
+ * Name:     ddr3_write_leveling_sw
+ * Desc:     Execute Write leveling phase by SW
+ * Args:     freq        - current sequence frequency
+ *           dram_info   - main struct
+ * Notes:
+ * Returns:  MV_OK if success, MV_FAIL if fail.
+ */
+int ddr3_write_leveling_sw_reg_dimm(u32 freq, int ratio_2to1,
+                                   MV_DRAM_INFO *dram_info)
+{
+       u32 reg, cs, cnt, pup;
+       u32 res[MAX_CS];
+       __maybe_unused int dpde_flag = 0;
+
+       /* Debug message - Start Write leveling procedure */
+       DEBUG_WL_S("DDR3 - Write Leveling - Starting SW WL procedure\n");
+
+#ifdef MV88F67XX
+       /* Dynamic pad issue (BTS669) during WL */
+       reg = reg_read(REG_DUNIT_CTRL_LOW_ADDR);
+       if (reg & (1 << REG_DUNIT_CTRL_LOW_DPDE_OFFS)) {
+               dpde_flag = 1;
+               reg_write(REG_DUNIT_CTRL_LOW_ADDR,
+                         reg & ~(1 << REG_DUNIT_CTRL_LOW_DPDE_OFFS));
+       }
+#endif
+
+       /* If target freq = 400 move clock start point */
+       /* Write to control PUP to Control Deskew Regs */
+       if (freq <= DDR_400) {
+               for (pup = 0; pup <= dram_info->num_of_total_pups; pup++) {
+                       /* PUP_DELAY_MASK 0x1F */
+                       /* reg = 0x0C10001F + (uj << 16); */
+                       ddr3_write_ctrl_pup_reg(1, pup, CNTRL_PUP_DESKEW + pup,
+                                               0x1F);
+               }
+       }
+
+       /* Set Output buffer-off to all CS and correct ODT values */
+       for (cs = 0; cs < MAX_CS; cs++) {
+               if (dram_info->cs_ena & (1 << cs)) {
+                       reg = reg_read(REG_DDR3_MR1_ADDR) &
+                               REG_DDR3_MR1_ODT_MASK;
+                       reg |= odt_static[dram_info->cs_ena][cs];
+                       reg |= (1 << REG_DDR3_MR1_OUTBUF_DIS_OFFS);
+
+                       /* 0x15D0 - DDR3 MR0 Register */
+                       reg_write(REG_DDR3_MR1_ADDR, reg);
+                       /* Issue MRS Command to current cs */
+                       reg = REG_SDRAM_OPERATION_CMD_MR1 &
+                               ~(1 << (REG_SDRAM_OPERATION_CS_OFFS + cs));
+                       /*
+                        * [3-0] = 0x4 - MR1 Command, [11-8] -
+                        * enable current cs
+                        */
+                       /* 0x1418 - SDRAM Operation Register */
+                       reg_write(REG_SDRAM_OPERATION_ADDR, reg);
+
+                       udelay(MRS_DELAY);
+               }
+       }
+
+       DEBUG_WL_FULL_S("DDR3 - Write Leveling - Qoff and RTT Values are set for all Cs\n");
+
+       /* Enable SW override */
+       reg = reg_read(REG_DRAM_TRAINING_2_ADDR) |
+               (1 << REG_DRAM_TRAINING_2_SW_OVRD_OFFS);
+       /* [0] = 1 - Enable SW override  */
+       /* 0x15B8 - Training SW 2 Register */
+       reg_write(REG_DRAM_TRAINING_2_ADDR, reg);
+       DEBUG_WL_FULL_S("DDR3 - Write Leveling - SW Override Enabled\n");
+
+       /* Enable PHY write leveling mode */
+       reg = reg_read(REG_DRAM_TRAINING_2_ADDR) &
+               ~(1 << REG_DRAM_TRAINING_2_WL_MODE_OFFS);
+       /* [2] = 0 - TrnWLMode - Enable */
+       /* 0x15B8 - Training SW 2 Register */
+       reg_write(REG_DRAM_TRAINING_2_ADDR, reg);
+
+       /* Loop for each cs */
+       for (cs = 0; cs < MAX_CS; cs++) {
+               if (dram_info->cs_ena & (1 << cs)) {
+                       DEBUG_WL_FULL_C("DDR3 - Write Leveling - Starting working with Cs - ",
+                                       (u32) cs, 1);
+
+                       /* Refresh X9 current cs */
+                       DEBUG_WL_FULL_S("DDR3 - Write Leveling - Refresh X9\n");
+                       for (cnt = 0; cnt < COUNT_WL_RFRS; cnt++) {
+                               reg =
+                                   REG_SDRAM_OPERATION_CMD_RFRS & ~(1 <<
+                                                                    (REG_SDRAM_OPERATION_CS_OFFS
+                                                                     + cs));
+                               /* [3-0] = 0x2 - refresh, [11-8] - enable current cs */
+                               reg_write(REG_SDRAM_OPERATION_ADDR, reg);       /* 0x1418 - SDRAM Operation Register */
+
+                               do {
+                                       reg =
+                                           ((reg_read
+                                             (REG_SDRAM_OPERATION_ADDR)) &
+                                            REG_SDRAM_OPERATION_CMD_RFRS_DONE);
+                               } while (reg);  /* Wait for '0' */
+                       }
+
+                       /*
+                        * Configure MR1 in Cs[CsNum] - write leveling on,
+                        * output buffer on
+                        */
+                       DEBUG_WL_FULL_S("DDR3 - Write Leveling - Configure MR1 for current Cs: WL-on,OB-on\n");
+                       reg = reg_read(REG_DDR3_MR1_ADDR) &
+                               REG_DDR3_MR1_OUTBUF_WL_MASK;
+                       /* Set ODT Values */
+                       reg &= REG_DDR3_MR1_ODT_MASK;
+                       reg |= odt_static[dram_info->cs_ena][cs];
+                       /* Enable WL MODE */
+                       reg |= (1 << REG_DDR3_MR1_WL_ENA_OFFS);
+                       /*
+                        * [7]=1, [12]=0 - Output Buffer and write leveling
+                        * enabled
+                        */
+                       /* 0x15D4 - DDR3 MR1 Register */
+                       reg_write(REG_DDR3_MR1_ADDR, reg);
+                       /* Issue MRS Command to current cs */
+                       reg = REG_SDRAM_OPERATION_CMD_MR1 &
+                               ~(1 << (REG_SDRAM_OPERATION_CS_OFFS + cs));
+                       /*
+                        * [3-0] = 0x4 - MR1 Command, [11-8] -
+                        * enable current cs
+                        */
+                       /* 0x1418 - SDRAM Operation Register */
+                       reg_write(REG_SDRAM_OPERATION_ADDR, reg);
+
+                       udelay(MRS_DELAY);
+
+                       /* Write leveling  cs[cs] */
+                       if (MV_OK !=
+                           ddr3_write_leveling_single_cs(cs, freq, ratio_2to1,
+                                                         (u32 *)(res + cs),
+                                                         dram_info)) {
+                               DEBUG_WL_FULL_C("DDR3 - Write Leveling single Cs - FAILED -  Cs - ",
+                                               (u32) cs, 1);
+                               return MV_FAIL;
+                       }
+
+                       /* Set TrnWLDeUpd - After each CS is done */
+                       reg = reg_read(REG_TRAINING_WL_ADDR) |
+                               (1 << REG_TRAINING_WL_CS_DONE_OFFS);
+                       /* 0x16AC - Training Write leveling register */
+                       reg_write(REG_TRAINING_WL_ADDR, reg);
+
+                       /*
+                        * Debug message - Finished Write leveling cs[cs] -
+                        * each PUP Fail/Success
+                        */
+                       DEBUG_WL_FULL_C("DDR3 - Write Leveling - Finished Cs - ", (u32) cs,
+                                       1);
+                       DEBUG_WL_FULL_C("DDR3 - Write Leveling - The Results: 1-PUP locked, 0-PUP failed -",
+                                       (u32) res[cs], 3);
+
+                       /* Configure MR1 in cs[cs] - write leveling off (0), output buffer off (1) */
+                       reg = reg_read(REG_DDR3_MR1_ADDR) &
+                               REG_DDR3_MR1_OUTBUF_WL_MASK;
+                       reg |= (1 << REG_DDR3_MR1_OUTBUF_DIS_OFFS);
+                       /* No need to sort ODT since it is same CS */
+                       /* 0x15D4 - DDR3 MR1 Register */
+                       reg_write(REG_DDR3_MR1_ADDR, reg);
+                       /* Issue MRS Command to current cs */
+                       reg = REG_SDRAM_OPERATION_CMD_MR1 &
+                               ~(1 << (REG_SDRAM_OPERATION_CS_OFFS + cs));
+                       /*
+                        * [3-0] = 0x4 - MR1 Command, [11-8] -
+                        * enable current cs
+                        */
+                       /* 0x1418 - SDRAM Operation Register */
+                       reg_write(REG_SDRAM_OPERATION_ADDR, reg);
+
+                       udelay(MRS_DELAY);
+               }
+       }
+
+       /* Disable WL Mode */
+       /* [2]=1 - TrnWLMode - Disable */
+       reg = reg_read(REG_DRAM_TRAINING_2_ADDR);
+       reg |= (1 << REG_DRAM_TRAINING_2_WL_MODE_OFFS);
+       /* 0x15B8 - Training SW 2 Register */
+       reg_write(REG_DRAM_TRAINING_2_ADDR, reg);
+
+       /* Disable SW override - Must be in a different stage */
+       /* [0]=0 - Enable SW override  */
+       reg = reg_read(REG_DRAM_TRAINING_2_ADDR);
+       reg &= ~(1 << REG_DRAM_TRAINING_2_SW_OVRD_OFFS);
+       /* 0x15B8 - Training SW 2 Register */
+       reg_write(REG_DRAM_TRAINING_2_ADDR, reg);
+
+       /* Set Output buffer-on to all CS and correct ODT values */
+       for (cs = 0; cs < MAX_CS; cs++) {
+               if (dram_info->cs_ena & (1 << cs)) {
+                       reg = reg_read(REG_DDR3_MR1_ADDR) &
+                               REG_DDR3_MR1_ODT_MASK;
+                       reg &= REG_DDR3_MR1_OUTBUF_WL_MASK;
+                       reg |= odt_static[dram_info->cs_ena][cs];
+
+                       /* 0x15D0 - DDR3 MR1 Register */
+                       reg_write(REG_DDR3_MR1_ADDR, reg);
+                       /* Issue MRS Command to current cs */
+                       reg = REG_SDRAM_OPERATION_CMD_MR1 &
+                               ~(1 << (REG_SDRAM_OPERATION_CS_OFFS + cs));
+                       /*
+                        * [3-0] = 0x4 - MR1 Command, [11-8] -
+                        * enable current cs
+                        */
+                       /* 0x1418 - SDRAM Operation Register */
+                       reg_write(REG_SDRAM_OPERATION_ADDR, reg);
+
+                       udelay(MRS_DELAY);
+               }
+       }
+
+#ifdef MV88F67XX
+       /* Dynamic pad issue (BTS669) during WL */
+       if (dpde_flag) {
+               reg = reg_read(REG_DUNIT_CTRL_LOW_ADDR) |
+                       (1 << REG_DUNIT_CTRL_LOW_DPDE_OFFS);
+               reg_write(REG_DUNIT_CTRL_LOW_ADDR, reg);
+       }
+#endif
+
+       /* If target freq = 400 move clock back */
+       /* Write to control PUP to Control Deskew Regs */
+       if (freq <= DDR_400) {
+               for (pup = 0; pup <= dram_info->num_of_total_pups; pup++) {
+                       ddr3_write_ctrl_pup_reg(1, pup, CNTRL_PUP_DESKEW + pup,
+                                               0);
+               }
+       }
+
+       DEBUG_WL_FULL_S("DDR3 - Write Leveling - Finished WL procedure for all Cs\n");
+       return MV_OK;
+}
+#endif
+
+/*
+ * Name:     ddr3_write_leveling_single_cs
+ * Desc:     Execute Write leveling for single Chip select
+ * Args:     cs          - current chip select
+ *           freq        - current sequence frequency
+ *           result      - res array
+ *           dram_info   - main struct
+ * Notes:
+ * Returns:  MV_OK if success, MV_FAIL if fail.
+ */
+static int ddr3_write_leveling_single_cs(u32 cs, u32 freq, int ratio_2to1,
+                                        u32 *result, MV_DRAM_INFO *dram_info)
+{
+       u32 reg, pup_num, delay, phase, phaseMax, max_pup_num, pup,
+               max_pup_mask;
+
+       max_pup_num = dram_info->num_of_total_pups;
+       *result = 0;
+       u32 flag[MAX_PUP_NUM] = { 0 };
+
+       DEBUG_WL_FULL_C("DDR3 - Write Leveling Single Cs - WL for Cs - ",
+                       (u32) cs, 1);
+
+       switch (max_pup_num) {
+       case 2:
+               max_pup_mask = 0x3;
+               break;
+       case 4:
+               max_pup_mask = 0xf;
+               DEBUG_WL_C("max_pup_mask =  ", max_pup_mask, 3);
+               break;
+       case 5:
+               max_pup_mask = 0x1f;
+               DEBUG_WL_C("max_pup_mask =  ", max_pup_mask, 3);
+               break;
+       case 8:
+               max_pup_mask = 0xff;
+               DEBUG_WL_C("max_pup_mask =  ", max_pup_mask, 3);
+               break;
+       case 9:
+               max_pup_mask = 0x1ff;
+               DEBUG_WL_C("max_pup_mask =  ", max_pup_mask, 3);
+               break;
+       default:
+               DEBUG_WL_C("ddr3_write_leveling_single_cs wrong max_pup_num =  ",
+                          max_pup_num, 3);
+               return MV_FAIL;
+       }
+
+       /* CS ODT Override */
+       reg = reg_read(REG_SDRAM_ODT_CTRL_HIGH_ADDR) &
+               REG_SDRAM_ODT_CTRL_HIGH_OVRD_MASK;
+       reg |= (REG_SDRAM_ODT_CTRL_HIGH_OVRD_ENA << (2 * cs));
+       /* Set 0x3 - Enable ODT on the curent cs and disable on other cs */
+       /* 0x1498 - SDRAM ODT Control high */
+       reg_write(REG_SDRAM_ODT_CTRL_HIGH_ADDR, reg);
+
+       DEBUG_WL_FULL_S("DDR3 - Write Leveling Single Cs - ODT Asserted for current Cs\n");
+
+       /* tWLMRD Delay */
+       /* Delay of minimum 40 Dram clock cycles - 20 Tclk cycles */
+       udelay(1);
+
+       /* [1:0] - current cs number */
+       reg = (reg_read(REG_TRAINING_WL_ADDR) & REG_TRAINING_WL_CS_MASK) | cs;
+       reg |= (1 << REG_TRAINING_WL_UPD_OFFS); /* [2] - trnWLCsUpd */
+       /* 0x16AC - Training Write leveling register */
+       reg_write(REG_TRAINING_WL_ADDR, reg);
+
+       /* Broadcast to all PUPs: Reset DQS phase, reset leveling delay */
+       ddr3_write_pup_reg(PUP_WL_MODE, cs, PUP_BC, 0, 0);
+
+       /* Seek Edge */
+       DEBUG_WL_FULL_S("DDR3 - Write Leveling Single Cs - Seek Edge - Current Cs\n");
+
+       /* Drive DQS high for one cycle - All data PUPs */
+       DEBUG_WL_FULL_S("DDR3 - Write Leveling Single Cs - Seek Edge - Driving DQS high for one cycle\n");
+       if (!ratio_2to1) {
+               reg = (reg_read(REG_TRAINING_WL_ADDR) &
+                      REG_TRAINING_WL_RATIO_MASK) | REG_TRAINING_WL_1TO1;
+       } else {
+               reg = (reg_read(REG_TRAINING_WL_ADDR) &
+                      REG_TRAINING_WL_RATIO_MASK) | REG_TRAINING_WL_2TO1;
+       }
+       /* 0x16AC - Training Write leveling register */
+       reg_write(REG_TRAINING_WL_ADDR, reg);
+
+       /* Wait tWLdelay */
+       do {
+               /* [29] - trnWLDelayExp */
+               reg = (reg_read(REG_TRAINING_WL_ADDR)) &
+                       REG_TRAINING_WL_DELAYEXP_MASK;
+       } while (reg == 0x0);   /* Wait for '1' */
+
+       /* Read WL res */
+       reg = (reg_read(REG_TRAINING_WL_ADDR) >> REG_TRAINING_WL_RESULTS_OFFS) &
+               REG_TRAINING_WL_RESULTS_MASK;
+       /* [28:20] - TrnWLResult */
+
+       if (!ratio_2to1) /* Different phase options for 2:1 or 1:1 modes */
+               phaseMax = MAX_PHASE_1TO1;
+       else
+               phaseMax = MAX_PHASE_2TO1;
+
+       DEBUG_WL_FULL_S("DDR3 - Write Leveling Single Cs - Seek Edge - Shift DQS + Octet Leveling\n");
+
+       /* Shift DQS + Octet leveling */
+       for (phase = 0; phase < phaseMax; phase++) {
+               for (delay = 0; delay < MAX_DELAY; delay++) {
+                       /*  Broadcast to all PUPs: DQS phase,leveling delay */
+                       ddr3_write_pup_reg(PUP_WL_MODE, cs, PUP_BC, phase,
+                                          delay);
+
+                       udelay(1);      /* Delay of  3 Tclk cycles */
+
+                       DEBUG_WL_FULL_S("DDR3 - Write Leveling Single Cs - Seek Edge: Phase = ");
+                       DEBUG_WL_FULL_D((u32) phase, 1);
+                       DEBUG_WL_FULL_S(", Delay = ");
+                       DEBUG_WL_FULL_D((u32) delay, 1);
+                       DEBUG_WL_FULL_S(", Counter = ");
+                       DEBUG_WL_FULL_D((u32) i, 1);
+                       DEBUG_WL_FULL_S("\n");
+
+                       /* Drive DQS high for one cycle - All data PUPs */
+                       if (!ratio_2to1) {
+                               reg = (reg_read(REG_TRAINING_WL_ADDR) &
+                                      REG_TRAINING_WL_RATIO_MASK) |
+                                       REG_TRAINING_WL_1TO1;
+                       } else {
+                               reg = (reg_read(REG_TRAINING_WL_ADDR) &
+                                      REG_TRAINING_WL_RATIO_MASK) |
+                                       REG_TRAINING_WL_2TO1;
+                       }
+                       reg_write(REG_TRAINING_WL_ADDR, reg);   /* 0x16AC  */
+
+                       /* Wait tWLdelay */
+                       do {
+                               reg = (reg_read(REG_TRAINING_WL_ADDR)) &
+                                       REG_TRAINING_WL_DELAYEXP_MASK;
+                       } while (reg == 0x0);   /* [29] Wait for '1' */
+
+                       /* Read WL res */
+                       reg = reg_read(REG_TRAINING_WL_ADDR);
+                       reg = (reg >> REG_TRAINING_WL_RESULTS_OFFS) &
+                               REG_TRAINING_WL_RESULTS_MASK;   /* [28:20] */
+
+                       DEBUG_WL_FULL_C("DDR3 - Write Leveling Single Cs - Seek Edge: Results =  ",
+                                       (u32) reg, 3);
+
+                       /* Update State machine */
+                       for (pup = 0; pup < (max_pup_num); pup++) {
+                               /* ECC support - bit 8 */
+                               pup_num = (pup == dram_info->num_of_std_pups) ?
+                                       ECC_BIT : pup;
+                               if (dram_info->wl_val[cs][pup][S] == 0) {
+                                       /* Update phase to PUP */
+                                       dram_info->wl_val[cs][pup][P] = phase;
+                                       /* Update delay to PUP */
+                                       dram_info->wl_val[cs][pup][D] = delay;
+                               }
+
+                               if (((reg >> pup_num) & 0x1) == 0)
+                                       flag[pup_num] = 1;
+
+                               if (((reg >> pup_num) & 0x1)
+                                   && (flag[pup_num] == 1)
+                                   && (dram_info->wl_val[cs][pup][S] == 0)) {
+                                       /*
+                                        * If the PUP is locked now and in last
+                                        * counter states
+                                        */
+                                       /* Go to next state */
+                                       dram_info->wl_val[cs][pup][S] = 1;
+                                       /* Set res */
+                                       *result = *result | (1 << pup_num);
+                               }
+                       }
+
+                       /* If all locked - Break the loops - Finished */
+                       if (*result == max_pup_mask) {
+                               phase = phaseMax;
+                               delay = MAX_DELAY;
+                               DEBUG_WL_S("DDR3 - Write Leveling Single Cs - Seek Edge: All Locked\n");
+                       }
+               }
+       }
+
+       /* Debug message - Print res for cs[i]: cs,PUP,Phase,Delay */
+       DEBUG_WL_C("DDR3 - Write Leveling - Results for CS - ", (u32) cs, 1);
+       for (pup = 0; pup < (max_pup_num); pup++) {
+               DEBUG_WL_S("DDR3 - Write Leveling - PUP: ");
+               DEBUG_WL_D((u32) pup, 1);
+               DEBUG_WL_S(", Phase: ");
+               DEBUG_WL_D((u32) dram_info->wl_val[cs][pup][P], 1);
+               DEBUG_WL_S(", Delay: ");
+               DEBUG_WL_D((u32) dram_info->wl_val[cs][pup][D], 2);
+               DEBUG_WL_S("\n");
+       }
+
+       /* Check if some not locked and return error */
+       if (*result != max_pup_mask) {
+               DEBUG_WL_S("DDR3 - Write Leveling - ERROR - not all PUPS were locked\n");
+               return MV_FAIL;
+       }
+
+       /* Configure Each PUP with locked leveling settings */
+       for (pup = 0; pup < (max_pup_num); pup++) {
+               /* ECC support - bit 8 */
+               pup_num = (pup == dram_info->num_of_std_pups) ? ECC_BIT : pup;
+               phase = dram_info->wl_val[cs][pup][P];
+               delay = dram_info->wl_val[cs][pup][D];
+               ddr3_write_pup_reg(PUP_WL_MODE, cs, pup_num, phase, delay);
+       }
+
+       /* CS ODT Override */
+       reg =  reg_read(REG_SDRAM_ODT_CTRL_HIGH_ADDR) &
+               REG_SDRAM_ODT_CTRL_HIGH_OVRD_MASK;
+       /* 0x1498 - SDRAM ODT Control high */
+       reg_write(REG_SDRAM_ODT_CTRL_HIGH_ADDR, reg);
+
+       return MV_OK;
+}
+
+/*
+ * Perform DDR3 Control PUP Indirect Write
+ */
+static void ddr3_write_ctrl_pup_reg(int bc_acc, u32 pup, u32 reg_addr, u32 data)
+{
+       u32 reg = 0;
+
+       /* Store value for write */
+       reg = (data & 0xFFFF);
+
+       /* Set bit 26 for control PHY access */
+       reg |= (1 << REG_PHY_CNTRL_OFFS);
+
+       /* Configure BC or UC access to PHYs */
+       if (bc_acc == 1)
+               reg |= (1 << REG_PHY_BC_OFFS);
+       else
+               reg |= (pup << REG_PHY_PUP_OFFS);
+
+       /* Set PHY register address to write to */
+       reg |= (reg_addr << REG_PHY_CS_OFFS);
+
+       reg_write(REG_PHY_REGISTRY_FILE_ACCESS_ADDR, reg);      /* 0x16A0 */
+       reg |= REG_PHY_REGISTRY_FILE_ACCESS_OP_WR;
+       reg_write(REG_PHY_REGISTRY_FILE_ACCESS_ADDR, reg);      /* 0x16A0 */
+
+       do {
+               reg = (reg_read(REG_PHY_REGISTRY_FILE_ACCESS_ADDR)) &
+                       REG_PHY_REGISTRY_FILE_ACCESS_OP_DONE;
+       } while (reg);          /* Wait for '0' to mark the end of the transaction */
+}
diff --git a/drivers/ddr/mvebu/xor.c b/drivers/ddr/mvebu/xor.c
new file mode 100644 (file)
index 0000000..66c96ae
--- /dev/null
@@ -0,0 +1,436 @@
+/*
+ * Copyright (C) Marvell International Ltd. and its affiliates
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#include <common.h>
+#include <i2c.h>
+#include <spl.h>
+#include <asm/io.h>
+#include <asm/arch/cpu.h>
+#include <asm/arch/soc.h>
+
+#include "xor.h"
+#include "xor_regs.h"
+
+static u32 xor_regs_ctrl_backup;
+static u32 xor_regs_base_backup[MAX_CS];
+static u32 xor_regs_mask_backup[MAX_CS];
+
+static void mv_xor_hal_init(u32 chan_num);
+static int mv_xor_cmd_set(u32 chan, int command);
+static int mv_xor_ctrl_set(u32 chan, u32 xor_ctrl);
+
+void mv_sys_xor_init(MV_DRAM_INFO *dram_info)
+{
+       u32 reg, ui, base, cs_count;
+
+       xor_regs_ctrl_backup = reg_read(XOR_WINDOW_CTRL_REG(0, 0));
+       for (ui = 0; ui < MAX_CS; ui++)
+               xor_regs_base_backup[ui] = reg_read(XOR_BASE_ADDR_REG(0, ui));
+       for (ui = 0; ui < MAX_CS; ui++)
+               xor_regs_mask_backup[ui] = reg_read(XOR_SIZE_MASK_REG(0, ui));
+
+       reg = 0;
+       for (ui = 0; ui < (dram_info->num_cs + 1); ui++) {
+               /* Enable Window x for each CS */
+               reg |= (0x1 << (ui));
+               /* Enable Window x for each CS */
+               reg |= (0x3 << ((ui * 2) + 16));
+       }
+
+       reg_write(XOR_WINDOW_CTRL_REG(0, 0), reg);
+
+       /* Last window - Base - 0x40000000, Attribute 0x1E - SRAM */
+       base = (SRAM_BASE & 0xFFFF0000) | 0x1E00;
+       reg_write(XOR_BASE_ADDR_REG(0, dram_info->num_cs), base);
+       /* Last window - Size - 64 MB */
+       reg_write(XOR_SIZE_MASK_REG(0, dram_info->num_cs), 0x03FF0000);
+
+       cs_count = 0;
+       for (ui = 0; ui < MAX_CS; ui++) {
+               if (dram_info->cs_ena & (1 << ui)) {
+                       /*
+                        * Window x - Base - 0x00000000, Attribute 0x0E - DRAM
+                        */
+                       base = 0;
+                       switch (ui) {
+                       case 0:
+                               base |= 0xE00;
+                               break;
+                       case 1:
+                               base |= 0xD00;
+                               break;
+                       case 2:
+                               base |= 0xB00;
+                               break;
+                       case 3:
+                               base |= 0x700;
+                               break;
+                       }
+
+                       reg_write(XOR_BASE_ADDR_REG(0, cs_count), base);
+
+                       /* Window x - Size - 256 MB */
+                       reg_write(XOR_SIZE_MASK_REG(0, cs_count), 0x0FFF0000);
+                       cs_count++;
+               }
+       }
+
+       mv_xor_hal_init(1);
+
+       return;
+}
+
+void mv_sys_xor_finish(void)
+{
+       u32 ui;
+
+       reg_write(XOR_WINDOW_CTRL_REG(0, 0), xor_regs_ctrl_backup);
+       for (ui = 0; ui < MAX_CS; ui++)
+               reg_write(XOR_BASE_ADDR_REG(0, ui), xor_regs_base_backup[ui]);
+       for (ui = 0; ui < MAX_CS; ui++)
+               reg_write(XOR_SIZE_MASK_REG(0, ui), xor_regs_mask_backup[ui]);
+
+       reg_write(XOR_ADDR_OVRD_REG(0, 0), 0);
+}
+
+/*
+ * mv_xor_hal_init - Initialize XOR engine
+ *
+ * DESCRIPTION:
+ *               This function initialize XOR unit.
+ * INPUT:
+ *       None.
+ *
+ * OUTPUT:
+ *       None.
+ *
+ * RETURN:
+ *       MV_BAD_PARAM if parameters to function invalid, MV_OK otherwise.
+ */
+static void mv_xor_hal_init(u32 chan_num)
+{
+       u32 i;
+
+       /* Abort any XOR activity & set default configuration */
+       for (i = 0; i < chan_num; i++) {
+               mv_xor_cmd_set(i, MV_STOP);
+               mv_xor_ctrl_set(i, (1 << XEXCR_REG_ACC_PROTECT_OFFS) |
+                               (4 << XEXCR_DST_BURST_LIMIT_OFFS) |
+                               (4 << XEXCR_SRC_BURST_LIMIT_OFFS));
+       }
+}
+
+/*
+ * mv_xor_ctrl_set - Set XOR channel control registers
+ *
+ * DESCRIPTION:
+ *
+ * INPUT:
+ *
+ * OUTPUT:
+ *       None.
+ *
+ * RETURN:
+ *       MV_BAD_PARAM if parameters to function invalid, MV_OK otherwise.
+ * NOTE:
+ *    This function does not modify the OperationMode field of control register.
+ *
+ */
+static int mv_xor_ctrl_set(u32 chan, u32 xor_ctrl)
+{
+       u32 val;
+
+       /* Update the XOR Engine [0..1] Configuration Registers (XExCR) */
+       val = reg_read(XOR_CONFIG_REG(XOR_UNIT(chan), XOR_CHAN(chan)))
+           & XEXCR_OPERATION_MODE_MASK;
+       xor_ctrl &= ~XEXCR_OPERATION_MODE_MASK;
+       xor_ctrl |= val;
+       reg_write(XOR_CONFIG_REG(XOR_UNIT(chan), XOR_CHAN(chan)), xor_ctrl);
+
+       return MV_OK;
+}
+
+int mv_xor_mem_init(u32 chan, u32 start_ptr, u32 block_size, u32 init_val_high,
+                   u32 init_val_low)
+{
+       u32 tmp;
+
+       /* Parameter checking */
+       if (chan >= MV_XOR_MAX_CHAN)
+               return MV_BAD_PARAM;
+
+       if (MV_ACTIVE == mv_xor_state_get(chan))
+               return MV_BUSY;
+
+       if ((block_size < XEXBSR_BLOCK_SIZE_MIN_VALUE) ||
+           (block_size > XEXBSR_BLOCK_SIZE_MAX_VALUE))
+               return MV_BAD_PARAM;
+
+       /* Set the operation mode to Memory Init */
+       tmp = reg_read(XOR_CONFIG_REG(XOR_UNIT(chan), XOR_CHAN(chan)));
+       tmp &= ~XEXCR_OPERATION_MODE_MASK;
+       tmp |= XEXCR_OPERATION_MODE_MEM_INIT;
+       reg_write(XOR_CONFIG_REG(XOR_UNIT(chan), XOR_CHAN(chan)), tmp);
+
+       /*
+        * Update the start_ptr field in XOR Engine [0..1] Destination Pointer
+        * Register (XExDPR0)
+        */
+       reg_write(XOR_DST_PTR_REG(XOR_UNIT(chan), XOR_CHAN(chan)), start_ptr);
+
+       /*
+        * Update the BlockSize field in the XOR Engine[0..1] Block Size
+        * Registers (XExBSR)
+        */
+       reg_write(XOR_BLOCK_SIZE_REG(XOR_UNIT(chan), XOR_CHAN(chan)),
+                 block_size);
+
+       /*
+        * Update the field InitValL in the XOR Engine Initial Value Register
+        * Low (XEIVRL)
+        */
+       reg_write(XOR_INIT_VAL_LOW_REG(XOR_UNIT(chan)), init_val_low);
+
+       /*
+        * Update the field InitValH in the XOR Engine Initial Value Register
+        * High (XEIVRH)
+        */
+       reg_write(XOR_INIT_VAL_HIGH_REG(XOR_UNIT(chan)), init_val_high);
+
+       /* Start transfer */
+       reg_bit_set(XOR_ACTIVATION_REG(XOR_UNIT(chan), XOR_CHAN(chan)),
+                   XEXACTR_XESTART_MASK);
+
+       return MV_OK;
+}
+
+/*
+ * mv_xor_transfer - Transfer data from source to destination on one of
+ *                 three modes (XOR,CRC32,DMA)
+ *
+ * DESCRIPTION:
+ *       This function initiates XOR channel, according to function parameters,
+ *       in order to perform XOR or CRC32 or DMA transaction.
+ *       To gain maximum performance the user is asked to keep the following
+ *       restrictions:
+ *       1) Selected engine is available (not busy).
+ *       1) This module does not take into consideration CPU MMU issues.
+ *          In order for the XOR engine to access the appropreate source
+ *          and destination, address parameters must be given in system
+ *          physical mode.
+ *       2) This API does not take care of cache coherency issues. The source,
+ *          destination and in case of chain the descriptor list are assumed
+ *          to be cache coherent.
+ *       4) Parameters validity. For example, does size parameter exceeds
+ *          maximum byte count of descriptor mode (16M or 64K).
+ *
+ * INPUT:
+ *       chan          - XOR channel number. See MV_XOR_CHANNEL enumerator.
+ *       xor_type      - One of three: XOR, CRC32 and DMA operations.
+ *       xor_chain_ptr - address of chain pointer
+ *
+ * OUTPUT:
+ *       None.
+ *
+ * RETURS:
+ *       MV_BAD_PARAM if parameters to function invalid, MV_OK otherwise.
+ *
+ */
+int mv_xor_transfer(u32 chan, int xor_type, u32 xor_chain_ptr)
+{
+       u32 tmp;
+
+       /* Parameter checking */
+       if (chan >= MV_XOR_MAX_CHAN) {
+               debug("%s: ERR. Invalid chan num %d\n", __func__, chan);
+               return MV_BAD_PARAM;
+       }
+
+       if (MV_ACTIVE == mv_xor_state_get(chan)) {
+               debug("%s: ERR. Channel is already active\n", __func__);
+               return MV_BUSY;
+       }
+
+       if (0x0 == xor_chain_ptr) {
+               debug("%s: ERR. xor_chain_ptr is NULL pointer\n", __func__);
+               return MV_BAD_PARAM;
+       }
+
+       /* Read configuration register and mask the operation mode field */
+       tmp = reg_read(XOR_CONFIG_REG(XOR_UNIT(chan), XOR_CHAN(chan)));
+       tmp &= ~XEXCR_OPERATION_MODE_MASK;
+
+       switch (xor_type) {
+       case MV_XOR:
+               if (0 != (xor_chain_ptr & XEXDPR_DST_PTR_XOR_MASK)) {
+                       debug("%s: ERR. Invalid chain pointer (bits [5:0] must be cleared)\n",
+                             __func__);
+                       return MV_BAD_PARAM;
+               }
+
+               /* Set the operation mode to XOR */
+               tmp |= XEXCR_OPERATION_MODE_XOR;
+               break;
+
+       case MV_DMA:
+               if (0 != (xor_chain_ptr & XEXDPR_DST_PTR_DMA_MASK)) {
+                       debug("%s: ERR. Invalid chain pointer (bits [4:0] must be cleared)\n",
+                             __func__);
+                       return MV_BAD_PARAM;
+               }
+
+               /* Set the operation mode to DMA */
+               tmp |= XEXCR_OPERATION_MODE_DMA;
+               break;
+
+       case MV_CRC32:
+               if (0 != (xor_chain_ptr & XEXDPR_DST_PTR_CRC_MASK)) {
+                       debug("%s: ERR. Invalid chain pointer (bits [4:0] must be cleared)\n",
+                             __func__);
+                       return MV_BAD_PARAM;
+               }
+
+               /* Set the operation mode to CRC32 */
+               tmp |= XEXCR_OPERATION_MODE_CRC;
+               break;
+
+       default:
+               return MV_BAD_PARAM;
+       }
+
+       /* Write the operation mode to the register */
+       reg_write(XOR_CONFIG_REG(XOR_UNIT(chan), XOR_CHAN(chan)), tmp);
+
+       /*
+        * Update the NextDescPtr field in the XOR Engine [0..1] Next Descriptor
+        * Pointer Register (XExNDPR)
+        */
+       reg_write(XOR_NEXT_DESC_PTR_REG(XOR_UNIT(chan), XOR_CHAN(chan)),
+                 xor_chain_ptr);
+
+       /* Start transfer */
+       reg_bit_set(XOR_ACTIVATION_REG(XOR_UNIT(chan), XOR_CHAN(chan)),
+                   XEXACTR_XESTART_MASK);
+
+       return MV_OK;
+}
+
+/*
+ * mv_xor_state_get - Get XOR channel state.
+ *
+ * DESCRIPTION:
+ *       XOR channel activity state can be active, idle, paused.
+ *       This function retrunes the channel activity state.
+ *
+ * INPUT:
+ *       chan     - the channel number
+ *
+ * OUTPUT:
+ *       None.
+ *
+ * RETURN:
+ *       XOR_CHANNEL_IDLE    - If the engine is idle.
+ *       XOR_CHANNEL_ACTIVE  - If the engine is busy.
+ *       XOR_CHANNEL_PAUSED  - If the engine is paused.
+ *       MV_UNDEFINED_STATE  - If the engine state is undefind or there is no
+ *                             such engine
+ *
+ */
+int mv_xor_state_get(u32 chan)
+{
+       u32 state;
+
+       /* Parameter checking */
+       if (chan >= MV_XOR_MAX_CHAN) {
+               debug("%s: ERR. Invalid chan num %d\n", __func__, chan);
+               return MV_UNDEFINED_STATE;
+       }
+
+       /* Read the current state */
+       state = reg_read(XOR_ACTIVATION_REG(XOR_UNIT(chan), XOR_CHAN(chan)));
+       state &= XEXACTR_XESTATUS_MASK;
+
+       /* Return the state */
+       switch (state) {
+       case XEXACTR_XESTATUS_IDLE:
+               return MV_IDLE;
+       case XEXACTR_XESTATUS_ACTIVE:
+               return MV_ACTIVE;
+       case XEXACTR_XESTATUS_PAUSED:
+               return MV_PAUSED;
+       }
+
+       return MV_UNDEFINED_STATE;
+}
+
+/*
+ * mv_xor_cmd_set - Set command of XOR channel
+ *
+ * DESCRIPTION:
+ *       XOR channel can be started, idle, paused and restarted.
+ *       Paused can be set only if channel is active.
+ *       Start can be set only if channel is idle or paused.
+ *       Restart can be set only if channel is paused.
+ *       Stop can be set only if channel is active.
+ *
+ * INPUT:
+ *       chan     - The channel number
+ *       command  - The command type (start, stop, restart, pause)
+ *
+ * OUTPUT:
+ *       None.
+ *
+ * RETURN:
+ *       MV_OK on success , MV_BAD_PARAM on erroneous parameter, MV_ERROR on
+ *       undefind XOR engine mode
+ *
+ */
+static int mv_xor_cmd_set(u32 chan, int command)
+{
+       int state;
+
+       /* Parameter checking */
+       if (chan >= MV_XOR_MAX_CHAN) {
+               debug("%s: ERR. Invalid chan num %d\n", __func__, chan);
+               return MV_BAD_PARAM;
+       }
+
+       /* Get the current state */
+       state = mv_xor_state_get(chan);
+
+       /* Command is start and current state is idle */
+       if ((command == MV_START) && (state == MV_IDLE)) {
+               reg_bit_set(XOR_ACTIVATION_REG(XOR_UNIT(chan), XOR_CHAN(chan)),
+                           XEXACTR_XESTART_MASK);
+               return MV_OK;
+       }
+       /* Command is stop and current state is active */
+       else if ((command == MV_STOP) && (state == MV_ACTIVE)) {
+               reg_bit_set(XOR_ACTIVATION_REG(XOR_UNIT(chan), XOR_CHAN(chan)),
+                           XEXACTR_XESTOP_MASK);
+               return MV_OK;
+       }
+       /* Command is paused and current state is active */
+       else if ((command == MV_PAUSED) && (state == MV_ACTIVE)) {
+               reg_bit_set(XOR_ACTIVATION_REG(XOR_UNIT(chan), XOR_CHAN(chan)),
+                           XEXACTR_XEPAUSE_MASK);
+               return MV_OK;
+       }
+       /* Command is restart and current state is paused */
+       else if ((command == MV_RESTART) && (state == MV_PAUSED)) {
+               reg_bit_set(XOR_ACTIVATION_REG(XOR_UNIT(chan), XOR_CHAN(chan)),
+                           XEXACTR_XERESTART_MASK);
+               return MV_OK;
+       }
+       /* Command is stop and current state is active */
+       else if ((command == MV_STOP) && (state == MV_IDLE))
+               return MV_OK;
+
+       /* Illegal command */
+       debug("%s: ERR. Illegal command\n", __func__);
+
+       return MV_BAD_PARAM;
+}
diff --git a/drivers/ddr/mvebu/xor.h b/drivers/ddr/mvebu/xor.h
new file mode 100644 (file)
index 0000000..3536487
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) Marvell International Ltd. and its affiliates
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#ifndef __XOR_H
+#define __XOR_H
+
+#include "ddr3_hw_training.h"
+
+#define MV_XOR_MAX_CHAN         4 /* total channels for all units together */
+
+/*
+ * This enumerator describes the type of functionality the XOR channel
+ * can have while using the same data structures.
+ */
+enum xor_type {
+       MV_XOR,         /* XOR channel functions as XOR accelerator     */
+       MV_DMA,         /* XOR channel functions as IDMA channel        */
+       MV_CRC32        /* XOR channel functions as CRC 32 calculator   */
+};
+
+/*
+ * This enumerator describes the set of commands that can be applied on
+ * an engine (e.g. IDMA, XOR). Appling a comman depends on the current
+ * status (see MV_STATE enumerator)
+ * Start can be applied only when status is IDLE
+ * Stop can be applied only when status is IDLE, ACTIVE or PAUSED
+ * Pause can be applied only when status is ACTIVE
+ * Restart can be applied only when status is PAUSED
+ */
+enum mv_command {
+       MV_START,               /* Start     */
+       MV_STOP,                /* Stop     */
+       MV_PAUSE,               /* Pause    */
+       MV_RESTART              /* Restart  */
+};
+
+/*
+ * This enumerator describes the set of state conditions.
+ * Moving from one state to other is stricted.
+ */
+enum mv_state {
+       MV_IDLE,
+       MV_ACTIVE,
+       MV_PAUSED,
+       MV_UNDEFINED_STATE
+};
+
+/* XOR descriptor structure for CRC and DMA descriptor */
+struct crc_dma_desc {
+       u32 status;             /* Successful descriptor execution indication */
+       u32 crc32_result;       /* Result of CRC-32 calculation */
+       u32 desc_cmd;           /* type of operation to be carried out on the data */
+       u32 next_desc_ptr;      /* Next descriptor address pointer */
+       u32 byte_cnt;           /* Size of source block part represented by the descriptor */
+       u32 dst_addr;           /* Destination Block address pointer (not used in CRC32 */
+       u32 src_addr0;          /* Mode: Source Block address pointer */
+       u32 src_addr1;          /* Mode: Source Block address pointer */
+} __packed;
+
+int mv_xor_state_get(u32 chan);
+void mv_sys_xor_init(MV_DRAM_INFO *dram_info);
+void mv_sys_xor_finish(void);
+int mv_xor_transfer(u32 chan, int xor_type, u32 xor_chain_ptr);
+int mv_xor_mem_init(u32 chan, u32 start_ptr, u32 block_size, u32 init_val_high,
+                   u32 init_val_low);
+
+#endif /* __XOR_H */
diff --git a/drivers/ddr/mvebu/xor_regs.h b/drivers/ddr/mvebu/xor_regs.h
new file mode 100644 (file)
index 0000000..884aa15
--- /dev/null
@@ -0,0 +1,103 @@
+/*
+ * Copyright (C) Marvell International Ltd. and its affiliates
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#ifndef __XOR_REGS_H
+#define __XOR_REGS_H
+
+/*
+ * For controllers that have two XOR units, then chans 2 & 3 will be mapped
+ * to channels 0 & 1 of unit 1
+ */
+#define XOR_UNIT(chan)                 ((chan) >> 1)
+#define XOR_CHAN(chan)                 ((chan) & 1)
+
+#define MV_XOR_REGS_OFFSET(unit)       (0x60900)
+#define MV_XOR_REGS_BASE(unit)         (MV_XOR_REGS_OFFSET(unit))
+
+/* XOR Engine Control Register Map */
+#define XOR_CHANNEL_ARBITER_REG(unit)  (MV_XOR_REGS_BASE(unit))
+#define XOR_CONFIG_REG(unit, chan)     (MV_XOR_REGS_BASE(unit) + (0x10 + ((chan) * 4)))
+#define XOR_ACTIVATION_REG(unit, chan) (MV_XOR_REGS_BASE(unit) + (0x20 + ((chan) * 4)))
+
+/* XOR Engine Interrupt Register Map */
+#define XOR_CAUSE_REG(unit)            (MV_XOR_REGS_BASE(unit) + 0x30)
+#define XOR_MASK_REG(unit)             (MV_XOR_REGS_BASE(unit) + 0x40)
+#define XOR_ERROR_CAUSE_REG(unit)      (MV_XOR_REGS_BASE(unit) + 0x50)
+#define XOR_ERROR_ADDR_REG(unit)       (MV_XOR_REGS_BASE(unit) + 0x60)
+
+/* XOR Engine Descriptor Register Map */
+#define XOR_NEXT_DESC_PTR_REG(unit, chan)      (MV_XOR_REGS_BASE(unit) + (0x200 + ((chan) * 4)))
+#define XOR_CURR_DESC_PTR_REG(unit, chan)      (MV_XOR_REGS_BASE(unit) + (0x210 + ((chan) * 4)))
+#define XOR_BYTE_COUNT_REG(unit, chan)         (MV_XOR_REGS_BASE(unit) + (0x220 + ((chan) * 4)))
+
+#define XOR_DST_PTR_REG(unit, chan)            (MV_XOR_REGS_BASE(unit) + (0x2B0 + ((chan) * 4)))
+#define XOR_BLOCK_SIZE_REG(unit, chan)         (MV_XOR_REGS_BASE(unit) + (0x2C0 + ((chan) * 4)))
+#define XOR_TIMER_MODE_CTRL_REG(unit)          (MV_XOR_REGS_BASE(unit) + 0x2D0)
+#define XOR_TIMER_MODE_INIT_VAL_REG(unit)      (MV_XOR_REGS_BASE(unit) + 0x2D4)
+#define XOR_TIMER_MODE_CURR_VAL_REG(unit)      (MV_XOR_REGS_BASE(unit) + 0x2D8)
+#define XOR_INIT_VAL_LOW_REG(unit)             (MV_XOR_REGS_BASE(unit) + 0x2E0)
+#define XOR_INIT_VAL_HIGH_REG(unit)            (MV_XOR_REGS_BASE(unit) + 0x2E4)
+
+/* XOR register fileds */
+
+/* XOR Engine [0..1] Configuration Registers (XExCR) */
+#define XEXCR_OPERATION_MODE_OFFS      (0)
+#define XEXCR_OPERATION_MODE_MASK      (7 << XEXCR_OPERATION_MODE_OFFS)
+#define XEXCR_OPERATION_MODE_XOR       (0 << XEXCR_OPERATION_MODE_OFFS)
+#define XEXCR_OPERATION_MODE_CRC       (1 << XEXCR_OPERATION_MODE_OFFS)
+#define XEXCR_OPERATION_MODE_DMA       (2 << XEXCR_OPERATION_MODE_OFFS)
+#define XEXCR_OPERATION_MODE_ECC       (3 << XEXCR_OPERATION_MODE_OFFS)
+#define XEXCR_OPERATION_MODE_MEM_INIT  (4 << XEXCR_OPERATION_MODE_OFFS)
+
+#define XEXCR_SRC_BURST_LIMIT_OFFS     (4)
+#define XEXCR_SRC_BURST_LIMIT_MASK     (7 << XEXCR_SRC_BURST_LIMIT_OFFS)
+#define XEXCR_DST_BURST_LIMIT_OFFS     (8)
+#define XEXCR_DST_BURST_LIMIT_MASK     (7 << XEXCR_DST_BURST_LIMIT_OFFS)
+#define XEXCR_DRD_RES_SWP_OFFS         (12)
+#define XEXCR_DRD_RES_SWP_MASK         (1 << XEXCR_DRD_RES_SWP_OFFS)
+#define XEXCR_DWR_REQ_SWP_OFFS         (13)
+#define XEXCR_DWR_REQ_SWP_MASK         (1 << XEXCR_DWR_REQ_SWP_OFFS)
+#define XEXCR_DES_SWP_OFFS             (14)
+#define XEXCR_DES_SWP_MASK             (1 << XEXCR_DES_SWP_OFFS)
+#define XEXCR_REG_ACC_PROTECT_OFFS     (15)
+#define XEXCR_REG_ACC_PROTECT_MASK     (1 << XEXCR_REG_ACC_PROTECT_OFFS)
+
+/* XOR Engine [0..1] Activation Registers (XExACTR) */
+#define XEXACTR_XESTART_OFFS           (0)
+#define XEXACTR_XESTART_MASK           (1 << XEXACTR_XESTART_OFFS)
+#define XEXACTR_XESTOP_OFFS            (1)
+#define XEXACTR_XESTOP_MASK            (1 << XEXACTR_XESTOP_OFFS)
+#define XEXACTR_XEPAUSE_OFFS           (2)
+#define XEXACTR_XEPAUSE_MASK           (1 << XEXACTR_XEPAUSE_OFFS)
+#define XEXACTR_XERESTART_OFFS         (3)
+#define XEXACTR_XERESTART_MASK         (1 << XEXACTR_XERESTART_OFFS)
+#define XEXACTR_XESTATUS_OFFS          (4)
+#define XEXACTR_XESTATUS_MASK          (3 << XEXACTR_XESTATUS_OFFS)
+#define XEXACTR_XESTATUS_IDLE          (0 << XEXACTR_XESTATUS_OFFS)
+#define XEXACTR_XESTATUS_ACTIVE                (1 << XEXACTR_XESTATUS_OFFS)
+#define XEXACTR_XESTATUS_PAUSED                (2 << XEXACTR_XESTATUS_OFFS)
+
+/* XOR Engine [0..1] Destination Pointer Register (XExDPR0) */
+#define XEXDPR_DST_PTR_OFFS            (0)
+#define XEXDPR_DST_PTR_MASK            (0xFFFFFFFF << XEXDPR_DST_PTR_OFFS)
+#define XEXDPR_DST_PTR_XOR_MASK                (0x3F)
+#define XEXDPR_DST_PTR_DMA_MASK                (0x1F)
+#define XEXDPR_DST_PTR_CRC_MASK                (0x1F)
+
+/* XOR Engine[0..1] Block Size Registers (XExBSR) */
+#define XEXBSR_BLOCK_SIZE_OFFS         (0)
+#define XEXBSR_BLOCK_SIZE_MASK         (0xFFFFFFFF << XEXBSR_BLOCK_SIZE_OFFS)
+#define XEXBSR_BLOCK_SIZE_MIN_VALUE    (128)
+#define XEXBSR_BLOCK_SIZE_MAX_VALUE    (0xFFFFFFFF)
+
+/* XOR Engine Address Decoding Register Map */
+#define XOR_WINDOW_CTRL_REG(unit, chan)        (MV_XOR_REGS_BASE(unit) + (0x240 + ((chan) * 4)))
+#define XOR_BASE_ADDR_REG(unit, win)   (MV_XOR_REGS_BASE(unit) + (0x250 + ((win) * 4)))
+#define XOR_SIZE_MASK_REG(unit, win)   (MV_XOR_REGS_BASE(unit) + (0x270 + ((win) * 4)))
+#define XOR_HIGH_ADDR_REMAP_REG(unit, win) (MV_XOR_REGS_BASE(unit) + (0x290 + ((win) * 4)))
+#define XOR_ADDR_OVRD_REG(unit, win)   (MV_XOR_REGS_BASE(unit) + (0x2A0 + ((win) * 4)))
+
+#endif /* __XOR_REGS_H */
index 3fa9c5994703d473494a4d2199ecae3e34a0c9c0..d908736cffe31e2acb1bfa787bc12b05265543b7 100644 (file)
@@ -11,6 +11,7 @@
 #include <malloc.h>
 #include <dm-demo.h>
 #include <asm/io.h>
+#include <asm/gpio.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -20,6 +21,8 @@ DECLARE_GLOBAL_DATA_PTR;
 
 struct shape_data {
        int num_chars;  /* Number of non-space characters output so far */
+       struct gpio_desc gpio_desc[8];
+       int gpio_count;
 };
 
 /* Crazy little function to draw shapes on the console */
@@ -89,9 +92,52 @@ static int shape_status(struct udevice *dev, int *status)
        return 0;
 }
 
+static int set_light(struct udevice *dev, int light)
+{
+       struct shape_data *priv = dev_get_priv(dev);
+       struct gpio_desc *desc;
+       int ret;
+       int i;
+
+       desc = priv->gpio_desc;
+       for (i = 0; i < priv->gpio_count; i++, desc++) {
+               uint mask = 1 << i;
+
+               ret = dm_gpio_set_value(desc, light & mask);
+               if (ret < 0)
+                       return ret;
+       }
+
+       return 0;
+}
+
+static int get_light(struct udevice *dev)
+{
+       struct shape_data *priv = dev_get_priv(dev);
+       struct gpio_desc *desc;
+       uint value = 0;
+       int ret;
+       int i;
+
+       desc = priv->gpio_desc;
+       for (i = 0; i < priv->gpio_count; i++, desc++) {
+               uint mask = 1 << i;
+
+               ret = dm_gpio_get_value(desc);
+               if (ret < 0)
+                       return ret;
+               if (ret)
+                       value |= mask;
+       }
+
+       return value;
+}
+
 static const struct demo_ops shape_ops = {
        .hello = shape_hello,
        .status = shape_status,
+       .get_light = get_light,
+       .set_light = set_light,
 };
 
 static int shape_ofdata_to_platdata(struct udevice *dev)
@@ -111,6 +157,29 @@ static int shape_ofdata_to_platdata(struct udevice *dev)
        return 0;
 }
 
+static int dm_shape_probe(struct udevice *dev)
+{
+       struct shape_data *priv = dev_get_priv(dev);
+       int ret;
+
+       ret = gpio_request_list_by_name(dev, "light-gpios", priv->gpio_desc,
+                                       ARRAY_SIZE(priv->gpio_desc),
+                                       GPIOD_IS_OUT | GPIOD_IS_OUT_ACTIVE);
+       if (ret < 0)
+               return ret;
+       priv->gpio_count = ret;
+       debug("%s: %d GPIOs\n", __func__, priv->gpio_count);
+
+       return 0;
+}
+
+static int dm_shape_remove(struct udevice *dev)
+{
+       struct shape_data *priv = dev_get_priv(dev);
+
+       return gpio_free_list(dev, priv->gpio_desc, priv->gpio_count);
+}
+
 static const struct udevice_id demo_shape_id[] = {
        { "demo-shape", 0 },
        { },
@@ -122,6 +191,8 @@ U_BOOT_DRIVER(demo_shape_drv) = {
        .id     = UCLASS_DEMO,
        .ofdata_to_platdata = shape_ofdata_to_platdata,
        .ops    = &shape_ops,
+       .probe = dm_shape_probe,
+       .remove = dm_shape_remove,
        .priv_auto_alloc_size = sizeof(struct shape_data),
        .platdata_auto_alloc_size = sizeof(struct dm_demo_pdata),
 };
index f6510d602c83472695065b66c0f01e55f75b881b..725f06898f33deb8d7e827f016d1a63da90b71aa 100644 (file)
@@ -43,6 +43,26 @@ int demo_status(struct udevice *dev, int *status)
        return ops->status(dev, status);
 }
 
+int demo_get_light(struct udevice *dev)
+{
+       const struct demo_ops *ops = device_get_ops(dev);
+
+       if (!ops->get_light)
+               return -ENOSYS;
+
+       return ops->get_light(dev);
+}
+
+int demo_set_light(struct udevice *dev, int light)
+{
+       const struct demo_ops *ops = device_get_ops(dev);
+
+       if (!ops->set_light)
+               return -ENOSYS;
+
+       return ops->set_light(dev, light);
+}
+
 int demo_parse_dt(struct udevice *dev)
 {
        struct dm_demo_pdata *pdata = dev_get_platdata(dev);
index 37946d5e183a73d07bff9da4f324c8357a72a89c..d94eb5cc25c4fce6c4df48bd22c39a659b709378 100644 (file)
@@ -38,7 +38,7 @@ static void fpga_no_sup(char *fn, char *msg)
 /* fpga_get_desc
  *     map a device number to a descriptor
  */
-static const fpga_desc *const fpga_get_desc(int devnum)
+const fpga_desc *const fpga_get_desc(int devnum)
 {
        fpga_desc *desc = (fpga_desc *)NULL;
 
index adb4b8cd25fdcce540f9d73c1aee49a920c09e7a..c765a74a25e0f17895b8010cfcbb646f735a5093 100644 (file)
@@ -139,6 +139,11 @@ int xilinx_load(xilinx_desc *desc, const void *buf, size_t bsize,
                return FPGA_FAIL;
        }
 
+       if (!desc->operations || !desc->operations->load) {
+               printf("%s: Missing load operation\n", __func__);
+               return FPGA_FAIL;
+       }
+
        return desc->operations->load(desc, buf, bsize, bstype);
 }
 
@@ -151,8 +156,10 @@ int xilinx_loadfs(xilinx_desc *desc, const void *buf, size_t bsize,
                return FPGA_FAIL;
        }
 
-       if (!desc->operations->loadfs)
+       if (!desc->operations || !desc->operations->loadfs) {
+               printf("%s: Missing loadfs operation\n", __func__);
                return FPGA_FAIL;
+       }
 
        return desc->operations->loadfs(desc, buf, bsize, fpga_fsinfo);
 }
@@ -165,6 +172,11 @@ int xilinx_dump(xilinx_desc *desc, const void *buf, size_t bsize)
                return FPGA_FAIL;
        }
 
+       if (!desc->operations || !desc->operations->dump) {
+               printf("%s: Missing dump operation\n", __func__);
+               return FPGA_FAIL;
+       }
+
        return desc->operations->dump(desc, buf, bsize);
 }
 
@@ -226,12 +238,14 @@ int xilinx_info(xilinx_desc *desc)
                if (desc->name)
                        printf("Device name:   \t%s\n", desc->name);
 
-               if (desc->iface_fns) {
+               if (desc->iface_fns)
                        printf ("Device Function Table @ 0x%p\n", desc->iface_fns);
-                       desc->operations->info(desc);
-               } else
+               else
                        printf ("No Device Function Table.\n");
 
+               if (desc->operations && desc->operations->info)
+                       desc->operations->info(desc);
+
                ret_val = FPGA_SUCCESS;
        } else {
                printf ("%s: Invalid device descriptor\n", __FUNCTION__);
index 255700ab18d2d93cf107fcbf3b5a10b2e66e855f..a69bbd2002e9f62c06f75cb1f1b4b755140eecc2 100644 (file)
@@ -7,20 +7,25 @@
 #include <common.h>
 #include <dm.h>
 #include <errno.h>
+#include <fdtdec.h>
 #include <malloc.h>
 #include <asm/gpio.h>
 #include <linux/ctype.h>
 
+DECLARE_GLOBAL_DATA_PTR;
+
 /**
  * gpio_to_device() - Convert global GPIO number to device, number
- * gpio:       The numeric representation of the GPIO
  *
  * Convert the GPIO number to an entry in the list of GPIOs
  * or GPIO blocks registered with the GPIO controller. Returns
  * entry on success, NULL on error.
+ *
+ * @gpio:      The numeric representation of the GPIO
+ * @desc:      Returns description (desc->flags will always be 0)
+ * @return 0 if found, -ENOENT if not found
  */
-static int gpio_to_device(unsigned int gpio, struct udevice **devp,
-                         unsigned int *offset)
+static int gpio_to_device(unsigned int gpio, struct gpio_desc *desc)
 {
        struct gpio_dev_priv *uc_priv;
        struct udevice *dev;
@@ -32,14 +37,15 @@ static int gpio_to_device(unsigned int gpio, struct udevice **devp,
                uc_priv = dev->uclass_priv;
                if (gpio >= uc_priv->gpio_base &&
                    gpio < uc_priv->gpio_base + uc_priv->gpio_count) {
-                       *devp = dev;
-                       *offset = gpio - uc_priv->gpio_base;
+                       desc->dev = dev;
+                       desc->offset = gpio - uc_priv->gpio_base;
+                       desc->flags = 0;
                        return 0;
                }
        }
 
        /* No such GPIO */
-       return ret ? ret : -EINVAL;
+       return ret ? ret : -ENOENT;
 }
 
 int gpio_lookup_name(const char *name, struct udevice **devp,
@@ -88,6 +94,57 @@ int gpio_lookup_name(const char *name, struct udevice **devp,
        return 0;
 }
 
+static int gpio_find_and_xlate(struct gpio_desc *desc,
+                              struct fdtdec_phandle_args *args)
+{
+       struct dm_gpio_ops *ops = gpio_get_ops(desc->dev);
+
+       /* Use the first argument as the offset by default */
+       if (args->args_count > 0)
+               desc->offset = args->args[0];
+       else
+               desc->offset = -1;
+       desc->flags = 0;
+
+       return ops->xlate ? ops->xlate(desc->dev, desc, args) : 0;
+}
+
+static int dm_gpio_request(struct gpio_desc *desc, const char *label)
+{
+       struct udevice *dev = desc->dev;
+       struct gpio_dev_priv *uc_priv;
+       char *str;
+       int ret;
+
+       uc_priv = dev->uclass_priv;
+       if (uc_priv->name[desc->offset])
+               return -EBUSY;
+       str = strdup(label);
+       if (!str)
+               return -ENOMEM;
+       if (gpio_get_ops(dev)->request) {
+               ret = gpio_get_ops(dev)->request(dev, desc->offset, label);
+               if (ret) {
+                       free(str);
+                       return ret;
+               }
+       }
+       uc_priv->name[desc->offset] = str;
+
+       return 0;
+}
+
+static int dm_gpio_requestf(struct gpio_desc *desc, const char *fmt, ...)
+{
+       va_list args;
+       char buf[40];
+
+       va_start(args, fmt);
+       vscnprintf(buf, sizeof(buf), fmt, args);
+       va_end(args);
+       return dm_gpio_request(desc, buf);
+}
+
 /**
  * gpio_request() - [COMPAT] Request GPIO
  * gpio:       GPIO number
@@ -102,32 +159,14 @@ int gpio_lookup_name(const char *name, struct udevice **devp,
  */
 int gpio_request(unsigned gpio, const char *label)
 {
-       struct gpio_dev_priv *uc_priv;
-       unsigned int offset;
-       struct udevice *dev;
-       char *str;
+       struct gpio_desc desc;
        int ret;
 
-       ret = gpio_to_device(gpio, &dev, &offset);
+       ret = gpio_to_device(gpio, &desc);
        if (ret)
                return ret;
 
-       uc_priv = dev->uclass_priv;
-       if (uc_priv->name[offset])
-               return -EBUSY;
-       str = strdup(label);
-       if (!str)
-               return -ENOMEM;
-       if (gpio_get_ops(dev)->request) {
-               ret = gpio_get_ops(dev)->request(dev, offset, label);
-               if (ret) {
-                       free(str);
-                       return ret;
-               }
-       }
-       uc_priv->name[offset] = str;
-
-       return 0;
+       return dm_gpio_request(&desc, label);
 }
 
 /**
@@ -151,25 +190,11 @@ int gpio_requestf(unsigned gpio, const char *fmt, ...)
        return gpio_request(gpio, buf);
 }
 
-/**
- * gpio_free() - [COMPAT] Relinquish GPIO
- * gpio:       GPIO number
- *
- * This function implements the API that's compatible with current
- * GPIO API used in U-Boot. The request is forwarded to particular
- * GPIO driver. Returns 0 on success, negative value on error.
- */
-int gpio_free(unsigned gpio)
+int _dm_gpio_free(struct udevice *dev, uint offset)
 {
        struct gpio_dev_priv *uc_priv;
-       unsigned int offset;
-       struct udevice *dev;
        int ret;
 
-       ret = gpio_to_device(gpio, &dev, &offset);
-       if (ret)
-               return ret;
-
        uc_priv = dev->uclass_priv;
        if (!uc_priv->name[offset])
                return -ENXIO;
@@ -185,15 +210,35 @@ int gpio_free(unsigned gpio)
        return 0;
 }
 
-static int check_reserved(struct udevice *dev, unsigned offset,
-                         const char *func)
+/**
+ * gpio_free() - [COMPAT] Relinquish GPIO
+ * gpio:       GPIO number
+ *
+ * This function implements the API that's compatible with current
+ * GPIO API used in U-Boot. The request is forwarded to particular
+ * GPIO driver. Returns 0 on success, negative value on error.
+ */
+int gpio_free(unsigned gpio)
 {
-       struct gpio_dev_priv *uc_priv = dev->uclass_priv;
+       struct gpio_desc desc;
+       int ret;
+
+       ret = gpio_to_device(gpio, &desc);
+       if (ret)
+               return ret;
+
+       return _dm_gpio_free(desc.dev, desc.offset);
+}
+
+static int check_reserved(struct gpio_desc *desc, const char *func)
+{
+       struct gpio_dev_priv *uc_priv = desc->dev->uclass_priv;
 
-       if (!uc_priv->name[offset]) {
+       if (!uc_priv->name[desc->offset]) {
                printf("%s: %s: error: gpio %s%d not reserved\n",
-                      dev->name, func,
-                      uc_priv->bank_name ? uc_priv->bank_name : "", offset);
+                      desc->dev->name, func,
+                      uc_priv->bank_name ? uc_priv->bank_name : "",
+                      desc->offset);
                return -EBUSY;
        }
 
@@ -210,16 +255,17 @@ static int check_reserved(struct udevice *dev, unsigned offset,
  */
 int gpio_direction_input(unsigned gpio)
 {
-       unsigned int offset;
-       struct udevice *dev;
+       struct gpio_desc desc;
        int ret;
 
-       ret = gpio_to_device(gpio, &dev, &offset);
+       ret = gpio_to_device(gpio, &desc);
+       if (ret)
+               return ret;
+       ret = check_reserved(&desc, "dir_input");
        if (ret)
                return ret;
-       ret = check_reserved(dev, offset, "dir_input");
 
-       return ret ? ret : gpio_get_ops(dev)->direction_input(dev, offset);
+       return gpio_get_ops(desc.dev)->direction_input(desc.dev, desc.offset);
 }
 
 /**
@@ -233,17 +279,81 @@ int gpio_direction_input(unsigned gpio)
  */
 int gpio_direction_output(unsigned gpio, int value)
 {
-       unsigned int offset;
-       struct udevice *dev;
+       struct gpio_desc desc;
+       int ret;
+
+       ret = gpio_to_device(gpio, &desc);
+       if (ret)
+               return ret;
+       ret = check_reserved(&desc, "dir_output");
+       if (ret)
+               return ret;
+
+       return gpio_get_ops(desc.dev)->direction_output(desc.dev,
+                                                       desc.offset, value);
+}
+
+int dm_gpio_get_value(struct gpio_desc *desc)
+{
+       int value;
+       int ret;
+
+       ret = check_reserved(desc, "get_value");
+       if (ret)
+               return ret;
+
+       value = gpio_get_ops(desc->dev)->get_value(desc->dev, desc->offset);
+
+       return desc->flags & GPIOD_ACTIVE_LOW ? !value : value;
+}
+
+int dm_gpio_set_value(struct gpio_desc *desc, int value)
+{
+       int ret;
+
+       ret = check_reserved(desc, "set_value");
+       if (ret)
+               return ret;
+
+       if (desc->flags & GPIOD_ACTIVE_LOW)
+               value = !value;
+       gpio_get_ops(desc->dev)->set_value(desc->dev, desc->offset, value);
+       return 0;
+}
+
+int dm_gpio_set_dir_flags(struct gpio_desc *desc, ulong flags)
+{
+       struct udevice *dev = desc->dev;
+       struct dm_gpio_ops *ops = gpio_get_ops(dev);
        int ret;
 
-       ret = gpio_to_device(gpio, &dev, &offset);
+       ret = check_reserved(desc, "set_dir");
+       if (ret)
+               return ret;
+
+       if (flags & GPIOD_IS_OUT) {
+               int value = flags & GPIOD_IS_OUT_ACTIVE ? 1 : 0;
+
+               if (flags & GPIOD_ACTIVE_LOW)
+                       value = !value;
+               ret = ops->direction_output(dev, desc->offset, value);
+       } else  if (flags & GPIOD_IS_IN) {
+               ret = ops->direction_input(dev, desc->offset);
+       }
        if (ret)
                return ret;
-       ret = check_reserved(dev, offset, "dir_output");
+       /*
+        * Update desc->flags here, so that GPIO_ACTIVE_LOW is honoured in
+        * futures
+        */
+       desc->flags = flags;
+
+       return 0;
+}
 
-       return ret ? ret :
-               gpio_get_ops(dev)->direction_output(dev, offset, value);
+int dm_gpio_set_dir(struct gpio_desc *desc)
+{
+       return dm_gpio_set_dir_flags(desc, desc->flags);
 }
 
 /**
@@ -257,16 +367,14 @@ int gpio_direction_output(unsigned gpio, int value)
  */
 int gpio_get_value(unsigned gpio)
 {
-       unsigned int offset;
-       struct udevice *dev;
        int ret;
 
-       ret = gpio_to_device(gpio, &dev, &offset);
+       struct gpio_desc desc;
+
+       ret = gpio_to_device(gpio, &desc);
        if (ret)
                return ret;
-       ret = check_reserved(dev, offset, "get_value");
-
-       return ret ? ret : gpio_get_ops(dev)->get_value(dev, offset);
+       return dm_gpio_get_value(&desc);
 }
 
 /**
@@ -280,16 +388,13 @@ int gpio_get_value(unsigned gpio)
  */
 int gpio_set_value(unsigned gpio, int value)
 {
-       unsigned int offset;
-       struct udevice *dev;
+       struct gpio_desc desc;
        int ret;
 
-       ret = gpio_to_device(gpio, &dev, &offset);
+       ret = gpio_to_device(gpio, &desc);
        if (ret)
                return ret;
-       ret = check_reserved(dev, offset, "set_value");
-
-       return ret ? ret : gpio_get_ops(dev)->set_value(dev, offset, value);
+       return dm_gpio_set_value(&desc, value);
 }
 
 const char *gpio_get_bank_info(struct udevice *dev, int *bit_count)
@@ -409,6 +514,155 @@ unsigned gpio_get_values_as_int(const int *gpio_num_array)
        return vector;
 }
 
+static int _gpio_request_by_name_nodev(const void *blob, int node,
+                                      const char *list_name, int index,
+                                      struct gpio_desc *desc, int flags,
+                                      bool add_index)
+{
+       struct fdtdec_phandle_args args;
+       int ret;
+
+       desc->dev = NULL;
+       desc->offset = 0;
+       ret = fdtdec_parse_phandle_with_args(blob, node, list_name,
+                                            "#gpio-cells", 0, index, &args);
+       if (ret) {
+               debug("%s: fdtdec_parse_phandle_with_args failed\n", __func__);
+               goto err;
+       }
+
+       ret = uclass_get_device_by_of_offset(UCLASS_GPIO, args.node,
+                                            &desc->dev);
+       if (ret) {
+               debug("%s: uclass_get_device_by_of_offset failed\n", __func__);
+               goto err;
+       }
+       ret = gpio_find_and_xlate(desc, &args);
+       if (ret) {
+               debug("%s: gpio_find_and_xlate failed\n", __func__);
+               goto err;
+       }
+       ret = dm_gpio_requestf(desc, add_index ? "%s.%s%d" : "%s.%s",
+                              fdt_get_name(blob, node, NULL),
+                              list_name, index);
+       if (ret) {
+               debug("%s: dm_gpio_requestf failed\n", __func__);
+               goto err;
+       }
+       ret = dm_gpio_set_dir_flags(desc, flags | desc->flags);
+       if (ret) {
+               debug("%s: dm_gpio_set_dir failed\n", __func__);
+               goto err;
+       }
+
+       return 0;
+err:
+       debug("%s: Node '%s', property '%s', failed to request GPIO index %d: %d\n",
+             __func__, fdt_get_name(blob, node, NULL), list_name, index, ret);
+       return ret;
+}
+
+int gpio_request_by_name_nodev(const void *blob, int node,
+                              const char *list_name, int index,
+                              struct gpio_desc *desc, int flags)
+{
+       return _gpio_request_by_name_nodev(blob, node, list_name, index, desc,
+                                          flags, index > 0);
+}
+
+int gpio_request_by_name(struct udevice *dev,  const char *list_name, int index,
+                        struct gpio_desc *desc, int flags)
+{
+       /*
+        * This isn't ideal since we don't use dev->name in the debug()
+        * calls in gpio_request_by_name(), but we can do this until
+        * gpio_request_by_name_nodev() can be dropped.
+        */
+       return gpio_request_by_name_nodev(gd->fdt_blob, dev->of_offset,
+                                         list_name, index, desc, flags);
+}
+
+int gpio_request_list_by_name_nodev(const void *blob, int node,
+                                   const char *list_name,
+                                   struct gpio_desc *desc, int max_count,
+                                   int flags)
+{
+       int count;
+       int ret;
+
+       for (count = 0; ; count++) {
+               if (count >= max_count) {
+                       ret = -ENOSPC;
+                       goto err;
+               }
+               ret = _gpio_request_by_name_nodev(blob, node, list_name, count,
+                                                 &desc[count], flags, true);
+               if (ret == -ENOENT)
+                       break;
+               else if (ret)
+                       goto err;
+       }
+
+       /* We ran out of GPIOs in the list */
+       return count;
+
+err:
+       gpio_free_list_nodev(desc, count - 1);
+
+       return ret;
+}
+
+int gpio_request_list_by_name(struct udevice *dev, const char *list_name,
+                             struct gpio_desc *desc, int max_count,
+                             int flags)
+{
+       /*
+        * This isn't ideal since we don't use dev->name in the debug()
+        * calls in gpio_request_by_name(), but we can do this until
+        * gpio_request_list_by_name_nodev() can be dropped.
+        */
+       return gpio_request_list_by_name_nodev(gd->fdt_blob, dev->of_offset,
+                                              list_name, desc, max_count,
+                                              flags);
+}
+
+int gpio_get_list_count(struct udevice *dev, const char *list_name)
+{
+       int ret;
+
+       ret = fdtdec_parse_phandle_with_args(gd->fdt_blob, dev->of_offset,
+                                            list_name, "#gpio-cells", 0, -1,
+                                            NULL);
+       if (ret) {
+               debug("%s: Node '%s', property '%s', GPIO count failed: %d\n",
+                     __func__, dev->name, list_name, ret);
+       }
+
+       return ret;
+}
+
+int dm_gpio_free(struct udevice *dev, struct gpio_desc *desc)
+{
+       /* For now, we don't do any checking of dev */
+       return _dm_gpio_free(desc->dev, desc->offset);
+}
+
+int gpio_free_list(struct udevice *dev, struct gpio_desc *desc, int count)
+{
+       int i;
+
+       /* For now, we don't do any checking of dev */
+       for (i = 0; i < count; i++)
+               dm_gpio_free(dev, &desc[i]);
+
+       return 0;
+}
+
+int gpio_free_list_nodev(struct gpio_desc *desc, int count)
+{
+       return gpio_free_list(NULL, desc, count);
+}
+
 /* We need to renumber the GPIOs when any driver is probed/removed */
 static int gpio_renumber(struct udevice *removed_dev)
 {
index 6c41a42c177351adcd0d6f96ff81ae2a0f1036ee..0a245ba18ad0eb42bdc6b67697dbdfa7fedd20a0 100644 (file)
@@ -13,6 +13,7 @@
 #include <asm/io.h>
 #include <asm/gpio.h>
 #include <dm/device-internal.h>
+#include <dt-bindings/gpio/gpio.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -275,12 +276,22 @@ static int exynos_gpio_get_function(struct udevice *dev, unsigned offset)
                return GPIOF_FUNC;
 }
 
+static int exynos_gpio_xlate(struct udevice *dev, struct gpio_desc *desc,
+                            struct fdtdec_phandle_args *args)
+{
+       desc->offset = args->args[0];
+       desc->flags = args->args[1] & GPIO_ACTIVE_LOW ? GPIOD_ACTIVE_LOW : 0;
+
+       return 0;
+}
+
 static const struct dm_gpio_ops gpio_exynos_ops = {
        .direction_input        = exynos_gpio_direction_input,
        .direction_output       = exynos_gpio_direction_output,
        .get_value              = exynos_gpio_get_value,
        .set_value              = exynos_gpio_set_value,
        .get_function           = exynos_gpio_get_function,
+       .xlate                  = exynos_gpio_xlate,
 };
 
 static int gpio_exynos_probe(struct udevice *dev)
@@ -342,7 +353,7 @@ static int gpio_exynos_bind(struct udevice *parent)
                                        plat->bank_name, plat, -1, &dev);
                if (ret)
                        return ret;
-               dev->of_offset = parent->of_offset;
+               dev->of_offset = node;
        }
 
        return 0;
index 53c80d5be65dd85c0dbe20d2e1823e0400a4937f..d564c252c7d7336d9f5bcc93d9ac306bd42eb539 100644 (file)
@@ -8,6 +8,7 @@
 #include <fdtdec.h>
 #include <malloc.h>
 #include <asm/gpio.h>
+#include <dt-bindings/gpio/gpio.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -130,12 +131,31 @@ static int sb_gpio_get_function(struct udevice *dev, unsigned offset)
        return GPIOF_INPUT;
 }
 
+static int sb_gpio_xlate(struct udevice *dev, struct gpio_desc *desc,
+                        struct fdtdec_phandle_args *args)
+{
+       desc->offset = args->args[0];
+       if (args->args_count < 2)
+               return 0;
+       if (args->args[1] & GPIO_ACTIVE_LOW)
+               desc->flags |= GPIOD_ACTIVE_LOW;
+       if (args->args[1] & 2)
+               desc->flags |= GPIOD_IS_IN;
+       if (args->args[1] & 4)
+               desc->flags |= GPIOD_IS_OUT;
+       if (args->args[1] & 8)
+               desc->flags |= GPIOD_IS_OUT_ACTIVE;
+
+       return 0;
+}
+
 static const struct dm_gpio_ops gpio_sandbox_ops = {
        .direction_input        = sb_gpio_direction_input,
        .direction_output       = sb_gpio_direction_output,
        .get_value              = sb_gpio_get_value,
        .set_value              = sb_gpio_set_value,
        .get_function           = sb_gpio_get_function,
+       .xlate                  = sb_gpio_xlate,
 };
 
 static int sandbox_gpio_ofdata_to_platdata(struct udevice *dev)
index 88f7ef5bf04d9abce9605cd7e8e161a11b135a8d..43928b8812c3aad0077b8beb4a837993c653ed59 100644 (file)
@@ -21,6 +21,7 @@
 #include <asm/arch/tegra.h>
 #include <asm/gpio.h>
 #include <dm/device-internal.h>
+#include <dt-bindings/gpio/gpio.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -251,6 +252,22 @@ static int tegra_gpio_get_function(struct udevice *dev, unsigned offset)
                return GPIOF_INPUT;
 }
 
+static int tegra_gpio_xlate(struct udevice *dev, struct gpio_desc *desc,
+                           struct fdtdec_phandle_args *args)
+{
+       int gpio, port, ret;
+
+       gpio = args->args[0];
+       port = gpio / TEGRA_GPIOS_PER_PORT;
+       ret = device_get_child(dev, port, &desc->dev);
+       if (ret)
+               return ret;
+       desc->offset = gpio % TEGRA_GPIOS_PER_PORT;
+       desc->flags = args->args[1] & GPIO_ACTIVE_LOW ? GPIOD_ACTIVE_LOW : 0;
+
+       return 0;
+}
+
 static const struct dm_gpio_ops gpio_tegra_ops = {
        .request                = tegra_gpio_request,
        .direction_input        = tegra_gpio_direction_input,
@@ -258,6 +275,7 @@ static const struct dm_gpio_ops gpio_tegra_ops = {
        .get_value              = tegra_gpio_get_value,
        .set_value              = tegra_gpio_set_value,
        .get_function           = tegra_gpio_get_function,
+       .xlate                  = tegra_gpio_xlate,
 };
 
 /**
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..202ea5d67940ece1c555568794a7cfd343f0fc30 100644 (file)
@@ -0,0 +1,22 @@
+config DM_I2C
+       bool "Enable Driver Model for I2C drivers"
+       depends on DM
+       help
+         If you want to use driver model for I2C drivers, say Y.
+         To use legacy I2C drivers, say N.
+
+config SYS_I2C_UNIPHIER
+       bool "UniPhier I2C driver"
+       depends on ARCH_UNIPHIER && DM_I2C
+       default y
+       help
+         Support for Panasonic UniPhier I2C controller driver.  This I2C
+         controller is used on PH1-LD4, PH1-sLD8 or older UniPhier SoCs.
+
+config SYS_I2C_UNIPHIER_F
+       bool "UniPhier FIFO-builtin I2C driver"
+       depends on ARCH_UNIPHIER && DM_I2C
+       default y
+       help
+         Support for Panasonic UniPhier FIFO-builtin I2C controller driver.
+         This I2C controller is used on PH1-Pro4 or newer UniPhier SoCs.
index 6f3c86c03859171f940305801f564ff0c2b9e1cd..774bc94a4a7a864acfbdb6a8a5214f34637f7fe7 100644 (file)
@@ -5,6 +5,7 @@
 # SPDX-License-Identifier:     GPL-2.0+
 #
 obj-$(CONFIG_DM_I2C) += i2c-uclass.o
+obj-$(CONFIG_DM_I2C_COMPAT) += i2c-uclass-compat.o
 
 obj-$(CONFIG_SYS_I2C_ADI) += adi_i2c.o
 obj-$(CONFIG_I2C_MV) += mv_i2c.o
@@ -31,4 +32,6 @@ obj-$(CONFIG_SYS_I2C_SANDBOX) += sandbox_i2c.o i2c-emul-uclass.o
 obj-$(CONFIG_SYS_I2C_SH) += sh_i2c.o
 obj-$(CONFIG_SYS_I2C_SOFT) += soft_i2c.o
 obj-$(CONFIG_SYS_I2C_TEGRA) += tegra_i2c.o
+obj-$(CONFIG_SYS_I2C_UNIPHIER) += i2c-uniphier.o
+obj-$(CONFIG_SYS_I2C_UNIPHIER_F) += i2c-uniphier-f.o
 obj-$(CONFIG_SYS_I2C_ZYNQ) += zynq_i2c.o
diff --git a/drivers/i2c/i2c-uclass-compat.c b/drivers/i2c/i2c-uclass-compat.c
new file mode 100644 (file)
index 0000000..223f238
--- /dev/null
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2014 Google, Inc
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <errno.h>
+#include <i2c.h>
+
+static int cur_busnum;
+
+static int i2c_compat_get_device(uint chip_addr, int alen,
+                                struct udevice **devp)
+{
+       struct dm_i2c_chip *chip;
+       int ret;
+
+       ret = i2c_get_chip_for_busnum(cur_busnum, chip_addr, alen, devp);
+       if (ret)
+               return ret;
+       chip = dev_get_parent_platdata(*devp);
+       if (chip->offset_len != alen) {
+               printf("I2C chip %x: requested alen %d does not match chip offset_len %d\n",
+                      chip_addr, alen, chip->offset_len);
+               return -EADDRNOTAVAIL;
+       }
+
+       return 0;
+}
+
+int i2c_probe(uint8_t chip_addr)
+{
+       struct udevice *bus, *dev;
+       int ret;
+
+       ret = uclass_get_device_by_seq(UCLASS_I2C, cur_busnum, &bus);
+       if (ret) {
+               debug("Cannot find I2C bus %d: err=%d\n", cur_busnum, ret);
+               return ret;
+       }
+
+       if (!bus)
+               return -ENOENT;
+
+       return dm_i2c_probe(bus, chip_addr, 0, &dev);
+}
+
+int i2c_read(uint8_t chip_addr, unsigned int addr, int alen, uint8_t *buffer,
+            int len)
+{
+       struct udevice *dev;
+       int ret;
+
+       ret = i2c_compat_get_device(chip_addr, alen, &dev);
+       if (ret)
+               return ret;
+
+       return dm_i2c_read(dev, addr, buffer, len);
+}
+
+int i2c_write(uint8_t chip_addr, unsigned int addr, int alen, uint8_t *buffer,
+             int len)
+{
+       struct udevice *dev;
+       int ret;
+
+       ret = i2c_compat_get_device(chip_addr, alen, &dev);
+       if (ret)
+               return ret;
+
+       return dm_i2c_write(dev, addr, buffer, len);
+}
+
+int i2c_get_bus_num_fdt(int node)
+{
+       struct udevice *bus;
+       int ret;
+
+       ret = uclass_get_device_by_of_offset(UCLASS_I2C, node, &bus);
+       if (ret)
+               return ret;
+
+       return bus->seq;
+}
+
+unsigned int i2c_get_bus_num(void)
+{
+       return cur_busnum;
+}
+
+int i2c_set_bus_num(unsigned int bus)
+{
+       cur_busnum = bus;
+
+       return 0;
+}
+
+void i2c_init(int speed, int slaveaddr)
+{
+       /* Nothing to do here - the init happens through driver model */
+}
+
+void board_i2c_init(const void *blob)
+{
+       /* Nothing to do here - the init happens through driver model */
+}
index 005bf8662f2b496c1691b36e2a6036219552e1bb..eafa457845df2371bff8a59ce8b20b7d2d32dd82 100644 (file)
@@ -50,7 +50,7 @@ static int i2c_setup_offset(struct dm_i2c_chip *chip, uint offset,
 static int i2c_read_bytewise(struct udevice *dev, uint offset,
                             uint8_t *buffer, int len)
 {
-       struct dm_i2c_chip *chip = dev_get_parentdata(dev);
+       struct dm_i2c_chip *chip = dev_get_parent_platdata(dev);
        struct udevice *bus = dev_get_parent(dev);
        struct dm_i2c_ops *ops = i2c_get_ops(bus);
        struct i2c_msg msg[2], *ptr;
@@ -79,7 +79,7 @@ static int i2c_read_bytewise(struct udevice *dev, uint offset,
 static int i2c_write_bytewise(struct udevice *dev, uint offset,
                             const uint8_t *buffer, int len)
 {
-       struct dm_i2c_chip *chip = dev_get_parentdata(dev);
+       struct dm_i2c_chip *chip = dev_get_parent_platdata(dev);
        struct udevice *bus = dev_get_parent(dev);
        struct dm_i2c_ops *ops = i2c_get_ops(bus);
        struct i2c_msg msg[1];
@@ -100,9 +100,9 @@ static int i2c_write_bytewise(struct udevice *dev, uint offset,
        return 0;
 }
 
-int i2c_read(struct udevice *dev, uint offset, uint8_t *buffer, int len)
+int dm_i2c_read(struct udevice *dev, uint offset, uint8_t *buffer, int len)
 {
-       struct dm_i2c_chip *chip = dev_get_parentdata(dev);
+       struct dm_i2c_chip *chip = dev_get_parent_platdata(dev);
        struct udevice *bus = dev_get_parent(dev);
        struct dm_i2c_ops *ops = i2c_get_ops(bus);
        struct i2c_msg msg[2], *ptr;
@@ -130,9 +130,10 @@ int i2c_read(struct udevice *dev, uint offset, uint8_t *buffer, int len)
        return ops->xfer(bus, msg, msg_count);
 }
 
-int i2c_write(struct udevice *dev, uint offset, const uint8_t *buffer, int len)
+int dm_i2c_write(struct udevice *dev, uint offset, const uint8_t *buffer,
+                int len)
 {
-       struct dm_i2c_chip *chip = dev_get_parentdata(dev);
+       struct dm_i2c_chip *chip = dev_get_parent_platdata(dev);
        struct udevice *bus = dev_get_parent(dev);
        struct dm_i2c_ops *ops = i2c_get_ops(bus);
        struct i2c_msg msg[1];
@@ -219,10 +220,10 @@ static int i2c_probe_chip(struct udevice *bus, uint chip_addr,
        return ops->xfer(bus, msg, 1);
 }
 
-static int i2c_bind_driver(struct udevice *bus, uint chip_addr,
+static int i2c_bind_driver(struct udevice *bus, uint chip_addr, uint offset_len,
                           struct udevice **devp)
 {
-       struct dm_i2c_chip chip;
+       struct dm_i2c_chip *chip;
        char name[30], *str;
        struct udevice *dev;
        int ret;
@@ -235,11 +236,11 @@ static int i2c_bind_driver(struct udevice *bus, uint chip_addr,
                goto err_bind;
 
        /* Tell the device what we know about it */
-       memset(&chip, '\0', sizeof(chip));
-       chip.chip_addr = chip_addr;
-       chip.offset_len = 1;    /* we assume */
-       ret = device_probe_child(dev, &chip);
-       debug("%s:  device_probe_child: ret=%d\n", __func__, ret);
+       chip = dev_get_parent_platdata(dev);
+       chip->chip_addr = chip_addr;
+       chip->offset_len = offset_len;
+       ret = device_probe(dev);
+       debug("%s:  device_probe: ret=%d\n", __func__, ret);
        if (ret)
                goto err_probe;
 
@@ -247,13 +248,18 @@ static int i2c_bind_driver(struct udevice *bus, uint chip_addr,
        return 0;
 
 err_probe:
+       /*
+        * If the device failed to probe, unbind it. There is nothing there
+        * on the bus so we don't want to leave it lying around
+        */
        device_unbind(dev);
 err_bind:
        free(str);
        return ret;
 }
 
-int i2c_get_chip(struct udevice *bus, uint chip_addr, struct udevice **devp)
+int i2c_get_chip(struct udevice *bus, uint chip_addr, uint offset_len,
+                struct udevice **devp)
 {
        struct udevice *dev;
 
@@ -261,15 +267,9 @@ int i2c_get_chip(struct udevice *bus, uint chip_addr, struct udevice **devp)
              bus->name, chip_addr);
        for (device_find_first_child(bus, &dev); dev;
                        device_find_next_child(&dev)) {
-               struct dm_i2c_chip store;
-               struct dm_i2c_chip *chip = dev_get_parentdata(dev);
+               struct dm_i2c_chip *chip = dev_get_parent_platdata(dev);
                int ret;
 
-               if (!chip) {
-                       chip = &store;
-                       i2c_chip_ofdata_to_platdata(gd->fdt_blob,
-                                                   dev->of_offset, chip);
-               }
                if (chip->chip_addr == chip_addr) {
                        ret = device_probe(dev);
                        debug("found, ret=%d\n", ret);
@@ -280,10 +280,11 @@ int i2c_get_chip(struct udevice *bus, uint chip_addr, struct udevice **devp)
                }
        }
        debug("not found\n");
-       return i2c_bind_driver(bus, chip_addr, devp);
+       return i2c_bind_driver(bus, chip_addr, offset_len, devp);
 }
 
-int i2c_get_chip_for_busnum(int busnum, int chip_addr, struct udevice **devp)
+int i2c_get_chip_for_busnum(int busnum, int chip_addr, uint offset_len,
+                           struct udevice **devp)
 {
        struct udevice *bus;
        int ret;
@@ -293,7 +294,7 @@ int i2c_get_chip_for_busnum(int busnum, int chip_addr, struct udevice **devp)
                debug("Cannot find I2C bus %d\n", busnum);
                return ret;
        }
-       ret = i2c_get_chip(bus, chip_addr, devp);
+       ret = i2c_get_chip(bus, chip_addr, offset_len, devp);
        if (ret) {
                debug("Cannot find I2C chip %02x on bus %d\n", chip_addr,
                      busnum);
@@ -303,8 +304,8 @@ int i2c_get_chip_for_busnum(int busnum, int chip_addr, struct udevice **devp)
        return 0;
 }
 
-int i2c_probe(struct udevice *bus, uint chip_addr, uint chip_flags,
-             struct udevice **devp)
+int dm_i2c_probe(struct udevice *bus, uint chip_addr, uint chip_flags,
+                struct udevice **devp)
 {
        int ret;
 
@@ -318,7 +319,7 @@ int i2c_probe(struct udevice *bus, uint chip_addr, uint chip_flags,
                return ret;
 
        /* The chip was found, see if we have a driver, and probe it */
-       ret = i2c_get_chip(bus, chip_addr, devp);
+       ret = i2c_get_chip(bus, chip_addr, 1, devp);
        debug("%s:  i2c_get_chip: ret=%d\n", __func__, ret);
 
        return ret;
@@ -364,7 +365,7 @@ int i2c_get_bus_speed(struct udevice *bus)
 int i2c_set_chip_flags(struct udevice *dev, uint flags)
 {
        struct udevice *bus = dev->parent;
-       struct dm_i2c_chip *chip = dev_get_parentdata(dev);
+       struct dm_i2c_chip *chip = dev_get_parent_platdata(dev);
        struct dm_i2c_ops *ops = i2c_get_ops(bus);
        int ret;
 
@@ -380,7 +381,7 @@ int i2c_set_chip_flags(struct udevice *dev, uint flags)
 
 int i2c_get_chip_flags(struct udevice *dev, uint *flagsp)
 {
-       struct dm_i2c_chip *chip = dev_get_parentdata(dev);
+       struct dm_i2c_chip *chip = dev_get_parent_platdata(dev);
 
        *flagsp = chip->flags;
 
@@ -389,7 +390,7 @@ int i2c_get_chip_flags(struct udevice *dev, uint *flagsp)
 
 int i2c_set_chip_offset_len(struct udevice *dev, uint offset_len)
 {
-       struct dm_i2c_chip *chip = dev_get_parentdata(dev);
+       struct dm_i2c_chip *chip = dev_get_parent_platdata(dev);
 
        if (offset_len > I2C_MAX_OFFSET_LEN)
                return -EINVAL;
@@ -419,7 +420,8 @@ int i2c_deblock(struct udevice *bus)
 int i2c_chip_ofdata_to_platdata(const void *blob, int node,
                                struct dm_i2c_chip *chip)
 {
-       chip->offset_len = 1;   /* default */
+       chip->offset_len = fdtdec_get_int(gd->fdt_blob, node,
+                                         "u-boot,i2c-offset-len", 1);
        chip->flags = 0;
        chip->chip_addr = fdtdec_get_int(gd->fdt_blob, node, "reg", -1);
        if (chip->chip_addr == -1) {
@@ -441,18 +443,31 @@ static int i2c_post_probe(struct udevice *dev)
        return i2c_set_bus_speed(dev, i2c->speed_hz);
 }
 
-int i2c_post_bind(struct udevice *dev)
+static int i2c_post_bind(struct udevice *dev)
 {
        /* Scan the bus for devices */
        return dm_scan_fdt_node(dev, gd->fdt_blob, dev->of_offset, false);
 }
 
+static int i2c_child_post_bind(struct udevice *dev)
+{
+       struct dm_i2c_chip *plat = dev_get_parent_platdata(dev);
+
+       if (dev->of_offset == -1)
+               return 0;
+
+       return i2c_chip_ofdata_to_platdata(gd->fdt_blob, dev->of_offset, plat);
+}
+
 UCLASS_DRIVER(i2c) = {
        .id             = UCLASS_I2C,
        .name           = "i2c",
-       .per_device_auto_alloc_size = sizeof(struct dm_i2c_bus),
+       .flags          = DM_UC_FLAG_SEQ_ALIAS,
        .post_bind      = i2c_post_bind,
        .post_probe     = i2c_post_probe,
+       .per_device_auto_alloc_size = sizeof(struct dm_i2c_bus),
+       .per_child_platdata_auto_alloc_size = sizeof(struct dm_i2c_chip),
+       .child_post_bind = i2c_child_post_bind,
 };
 
 UCLASS_DRIVER(i2c_generic) = {
diff --git a/drivers/i2c/i2c-uniphier-f.c b/drivers/i2c/i2c-uniphier-f.c
new file mode 100644 (file)
index 0000000..6707edd
--- /dev/null
@@ -0,0 +1,367 @@
+/*
+ * Copyright (C) 2014 Panasonic Corporation
+ *   Author: Masahiro Yamada <yamada.m@jp.panasonic.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <common.h>
+#include <linux/types.h>
+#include <asm/io.h>
+#include <asm/errno.h>
+#include <dm/device.h>
+#include <dm/root.h>
+#include <i2c.h>
+#include <fdtdec.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+struct uniphier_fi2c_regs {
+       u32 cr;                         /* control register */
+#define I2C_CR_MST     (1 << 3)        /* master mode */
+#define I2C_CR_STA     (1 << 2)        /* start condition */
+#define I2C_CR_STO     (1 << 1)        /* stop condition */
+#define I2C_CR_NACK    (1 << 0)        /* not ACK */
+       u32 dttx;                       /* send FIFO (write-only) */
+#define dtrx           dttx            /* receive FIFO (read-only) */
+#define I2C_DTTX_CMD   (1 << 8)        /* send command (slave addr) */
+#define I2C_DTTX_RD    (1 << 0)        /* read */
+       u32 __reserved;                 /* no register at offset 0x08 */
+       u32 slad;                       /* slave address */
+       u32 cyc;                        /* clock cycle control */
+       u32 lctl;                       /* clock low period control */
+       u32 ssut;                       /* restart/stop setup time control */
+       u32 dsut;                       /* data setup time control */
+       u32 intr;                       /* interrupt status */
+       u32 ie;                         /* interrupt enable */
+       u32 ic;                         /* interrupt clear */
+#define I2C_INT_TE     (1 << 9)        /* TX FIFO empty */
+#define I2C_INT_RB     (1 << 4)        /* received specified bytes */
+#define I2C_INT_NA     (1 << 2)        /* no answer */
+#define I2C_INT_AL     (1 << 1)        /* arbitration lost */
+       u32 sr;                         /* status register */
+#define I2C_SR_DB      (1 << 12)       /* device busy */
+#define I2C_SR_BB      (1 << 8)        /* bus busy */
+#define I2C_SR_RFF     (1 << 3)        /* Rx FIFO full */
+#define I2C_SR_RNE     (1 << 2)        /* Rx FIFO not empty */
+#define I2C_SR_TNF     (1 << 1)        /* Tx FIFO not full */
+#define I2C_SR_TFE     (1 << 0)        /* Tx FIFO empty */
+       u32 __reserved2;                /* no register at offset 0x30 */
+       u32 rst;                        /* reset control */
+#define I2C_RST_TBRST  (1 << 2)        /* clear Tx FIFO */
+#define I2C_RST_RBRST  (1 << 1)        /* clear Rx FIFO */
+#define I2C_RST_RST    (1 << 0)        /* forcible bus reset */
+       u32 bm;                         /* bus monitor */
+       u32 noise;                      /* noise filter control */
+       u32 tbc;                        /* Tx byte count setting */
+       u32 rbc;                        /* Rx byte count setting */
+       u32 tbcm;                       /* Tx byte count monitor */
+       u32 rbcm;                       /* Rx byte count monitor */
+       u32 brst;                       /* bus reset */
+#define I2C_BRST_FOEN  (1 << 1)        /* normal operation */
+#define I2C_BRST_RSCLO (1 << 0)        /* release SCL low fixing */
+};
+
+#define FIOCLK 50000000
+
+struct uniphier_fi2c_dev {
+       struct uniphier_fi2c_regs __iomem *regs;        /* register base */
+       unsigned long fioclk;                   /* internal operation clock */
+       unsigned long timeout;                  /* time out (us) */
+};
+
+static int poll_status(u32 __iomem *reg, u32 flag)
+{
+       int wait = 1000000; /* 1 sec is long enough */
+
+       while (readl(reg) & flag) {
+               if (wait-- < 0)
+                       return -EREMOTEIO;
+               udelay(1);
+       }
+
+       return 0;
+}
+
+static int reset_bus(struct uniphier_fi2c_regs __iomem *regs)
+{
+       int ret;
+
+       /* bus forcible reset */
+       writel(I2C_RST_RST, &regs->rst);
+       ret = poll_status(&regs->rst, I2C_RST_RST);
+       if (ret < 0)
+               debug("error: fail to reset I2C controller\n");
+
+       return ret;
+}
+
+static int check_device_busy(struct uniphier_fi2c_regs __iomem *regs)
+{
+       int ret;
+
+       ret = poll_status(&regs->sr, I2C_SR_DB);
+       if (ret < 0) {
+               debug("error: device busy too long. reset...\n");
+               ret = reset_bus(regs);
+       }
+
+       return ret;
+}
+
+static int uniphier_fi2c_probe(struct udevice *dev)
+{
+       fdt_addr_t addr;
+       fdt_size_t size;
+       struct uniphier_fi2c_dev *priv = dev_get_priv(dev);
+       int ret;
+
+       addr = fdtdec_get_addr_size(gd->fdt_blob, dev->of_offset, "reg",
+                                   &size);
+
+       priv->regs = map_sysmem(addr, size);
+
+       if (!priv->regs)
+               return -ENOMEM;
+
+       priv->fioclk = FIOCLK;
+
+       /* bus forcible reset */
+       ret = reset_bus(priv->regs);
+       if (ret < 0)
+               return ret;
+
+       writel(I2C_BRST_FOEN | I2C_BRST_RSCLO, &priv->regs->brst);
+
+       return 0;
+}
+
+static int uniphier_fi2c_remove(struct udevice *dev)
+{
+       struct uniphier_fi2c_dev *priv = dev_get_priv(dev);
+
+       unmap_sysmem(priv->regs);
+
+       return 0;
+}
+
+static int wait_for_irq(struct uniphier_fi2c_dev *dev, u32 flags,
+                       bool *stop)
+{
+       u32 irq;
+       unsigned long wait = dev->timeout;
+       int ret = -EREMOTEIO;
+
+       do {
+               udelay(1);
+               irq = readl(&dev->regs->intr);
+       } while (!(irq & flags) && wait--);
+
+       if (wait < 0) {
+               debug("error: time out\n");
+               return ret;
+       }
+
+       if (irq & I2C_INT_AL) {
+               debug("error: arbitration lost\n");
+               *stop = false;
+               return ret;
+       }
+
+       if (irq & I2C_INT_NA) {
+               debug("error: no answer\n");
+               return ret;
+       }
+
+       return 0;
+}
+
+static int issue_stop(struct uniphier_fi2c_dev *dev, int old_ret)
+{
+       int ret;
+
+       debug("stop condition\n");
+       writel(I2C_CR_MST | I2C_CR_STO, &dev->regs->cr);
+
+       ret = poll_status(&dev->regs->sr, I2C_SR_DB);
+       if (ret < 0)
+               debug("error: device busy after operation\n");
+
+       return old_ret ? old_ret : ret;
+}
+
+static int uniphier_fi2c_transmit(struct uniphier_fi2c_dev *dev, uint addr,
+                                 uint len, const u8 *buf, bool *stop)
+{
+       int ret;
+       const u32 irq_flags = I2C_INT_TE | I2C_INT_NA | I2C_INT_AL;
+       struct uniphier_fi2c_regs __iomem *regs = dev->regs;
+
+       debug("%s: addr = %x, len = %d\n", __func__, addr, len);
+
+       writel(I2C_DTTX_CMD | addr << 1, &regs->dttx);
+
+       writel(irq_flags, &regs->ie);
+       writel(irq_flags, &regs->ic);
+
+       debug("start condition\n");
+       writel(I2C_CR_MST | I2C_CR_STA, &regs->cr);
+
+       ret = wait_for_irq(dev, irq_flags, stop);
+       if (ret < 0)
+               goto error;
+
+       while (len--) {
+               debug("sending %x\n", *buf);
+               writel(*buf++, &regs->dttx);
+
+               writel(irq_flags, &regs->ic);
+
+               ret = wait_for_irq(dev, irq_flags, stop);
+               if (ret < 0)
+                       goto error;
+       }
+
+error:
+       writel(irq_flags, &regs->ic);
+
+       if (*stop)
+               ret = issue_stop(dev, ret);
+
+       return ret;
+}
+
+static int uniphier_fi2c_receive(struct uniphier_fi2c_dev *dev, uint addr,
+                                uint len, u8 *buf, bool *stop)
+{
+       int ret = 0;
+       const u32 irq_flags = I2C_INT_RB | I2C_INT_NA | I2C_INT_AL;
+       struct uniphier_fi2c_regs __iomem *regs = dev->regs;
+
+       debug("%s: addr = %x, len = %d\n", __func__, addr, len);
+
+       /*
+        * In case 'len == 0', only the slave address should be sent
+        * for probing, which is covered by the transmit function.
+        */
+       if (len == 0)
+               return uniphier_fi2c_transmit(dev, addr, len, buf, stop);
+
+       writel(I2C_DTTX_CMD | I2C_DTTX_RD | addr << 1, &regs->dttx);
+
+       writel(0, &regs->rbc);
+       writel(irq_flags, &regs->ie);
+       writel(irq_flags, &regs->ic);
+
+       debug("start condition\n");
+       writel(I2C_CR_MST | I2C_CR_STA | (len == 1 ? I2C_CR_NACK : 0),
+              &regs->cr);
+
+       while (len--) {
+               ret = wait_for_irq(dev, irq_flags, stop);
+               if (ret < 0)
+                       goto error;
+
+               *buf++ = readl(&regs->dtrx);
+               debug("received %x\n", *(buf - 1));
+
+               if (len == 1)
+                       writel(I2C_CR_MST | I2C_CR_NACK, &regs->cr);
+
+               writel(irq_flags, &regs->ic);
+       }
+
+error:
+       writel(irq_flags, &regs->ic);
+
+       if (*stop)
+               ret = issue_stop(dev, ret);
+
+       return ret;
+}
+
+static int uniphier_fi2c_xfer(struct udevice *bus, struct i2c_msg *msg,
+                            int nmsgs)
+{
+       int ret;
+       struct uniphier_fi2c_dev *dev = dev_get_priv(bus);
+       bool stop;
+
+       ret = check_device_busy(dev->regs);
+       if (ret < 0)
+               return ret;
+
+       for (; nmsgs > 0; nmsgs--, msg++) {
+               /* If next message is read, skip the stop condition */
+               stop = nmsgs > 1 && msg[1].flags & I2C_M_RD ? false : true;
+
+               if (msg->flags & I2C_M_RD)
+                       ret = uniphier_fi2c_receive(dev, msg->addr, msg->len,
+                                                   msg->buf, &stop);
+               else
+                       ret = uniphier_fi2c_transmit(dev, msg->addr, msg->len,
+                                                    msg->buf, &stop);
+
+               if (ret < 0)
+                       break;
+       }
+
+       return ret;
+}
+
+static int uniphier_fi2c_set_bus_speed(struct udevice *bus, unsigned int speed)
+{
+       int ret;
+       unsigned int clk_count;
+       struct uniphier_fi2c_dev *dev = dev_get_priv(bus);
+       struct uniphier_fi2c_regs __iomem *regs = dev->regs;
+
+       /* max supported frequency is 400 kHz */
+       if (speed > 400000)
+               return -EINVAL;
+
+       ret = check_device_busy(dev->regs);
+       if (ret < 0)
+               return ret;
+
+       /* make sure the bus is idle when changing the frequency */
+       writel(I2C_BRST_RSCLO, &regs->brst);
+
+       clk_count = dev->fioclk / speed;
+
+       writel(clk_count, &regs->cyc);
+       writel(clk_count / 2, &regs->lctl);
+       writel(clk_count / 2, &regs->ssut);
+       writel(clk_count / 16, &regs->dsut);
+
+       writel(I2C_BRST_FOEN | I2C_BRST_RSCLO, &regs->brst);
+
+       /*
+        * Theoretically, each byte can be transferred in
+        * 1000000 * 9 / speed usec.
+        * This time out value is long enough.
+        */
+       dev->timeout = 100000000L / speed;
+
+       return 0;
+}
+
+static const struct dm_i2c_ops uniphier_fi2c_ops = {
+       .xfer = uniphier_fi2c_xfer,
+       .set_bus_speed = uniphier_fi2c_set_bus_speed,
+};
+
+static const struct udevice_id uniphier_fi2c_of_match[] = {
+       { .compatible = "panasonic,uniphier-fi2c" },
+       {},
+};
+
+U_BOOT_DRIVER(uniphier_fi2c) = {
+       .name = "uniphier-fi2c",
+       .id = UCLASS_I2C,
+       .of_match = uniphier_fi2c_of_match,
+       .probe = uniphier_fi2c_probe,
+       .remove = uniphier_fi2c_remove,
+       .priv_auto_alloc_size = sizeof(struct uniphier_fi2c_dev),
+       .ops = &uniphier_fi2c_ops,
+};
diff --git a/drivers/i2c/i2c-uniphier.c b/drivers/i2c/i2c-uniphier.c
new file mode 100644 (file)
index 0000000..64a9ed8
--- /dev/null
@@ -0,0 +1,227 @@
+/*
+ * Copyright (C) 2014 Panasonic Corporation
+ *   Author: Masahiro Yamada <yamada.m@jp.panasonic.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <common.h>
+#include <linux/types.h>
+#include <asm/io.h>
+#include <asm/errno.h>
+#include <dm/device.h>
+#include <dm/root.h>
+#include <i2c.h>
+#include <fdtdec.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+struct uniphier_i2c_regs {
+       u32 dtrm;                       /* data transmission */
+#define I2C_DTRM_STA   (1 << 10)
+#define I2C_DTRM_STO   (1 << 9)
+#define I2C_DTRM_NACK  (1 << 8)
+#define I2C_DTRM_RD    (1 << 0)
+       u32 drec;                       /* data reception */
+#define I2C_DREC_STS   (1 << 12)
+#define I2C_DREC_LRB   (1 << 11)
+#define I2C_DREC_LAB   (1 << 9)
+       u32 myad;                       /* slave address */
+       u32 clk;                        /* clock frequency control */
+       u32 brst;                       /* bus reset */
+#define I2C_BRST_FOEN  (1 << 1)
+#define I2C_BRST_BRST  (1 << 0)
+       u32 hold;                       /* hold time control */
+       u32 bsts;                       /* bus status monitor */
+       u32 noise;                      /* noise filter control */
+       u32 setup;                      /* setup time control */
+};
+
+#define IOBUS_FREQ     100000000
+
+struct uniphier_i2c_dev {
+       struct uniphier_i2c_regs __iomem *regs; /* register base */
+       unsigned long input_clk;        /* master clock (Hz) */
+       unsigned long wait_us;          /* wait for every byte transfer (us) */
+};
+
+static int uniphier_i2c_probe(struct udevice *dev)
+{
+       fdt_addr_t addr;
+       fdt_size_t size;
+       struct uniphier_i2c_dev *priv = dev_get_priv(dev);
+
+       addr = fdtdec_get_addr_size(gd->fdt_blob, dev->of_offset, "reg", &size);
+
+       priv->regs = map_sysmem(addr, size);
+
+       if (!priv->regs)
+               return -ENOMEM;
+
+       priv->input_clk = IOBUS_FREQ;
+
+       /* deassert reset */
+       writel(0x3, &priv->regs->brst);
+
+       return 0;
+}
+
+static int uniphier_i2c_remove(struct udevice *dev)
+{
+       struct uniphier_i2c_dev *priv = dev_get_priv(dev);
+
+       unmap_sysmem(priv->regs);
+
+       return 0;
+}
+
+static int send_and_recv_byte(struct uniphier_i2c_dev *dev, u32 dtrm)
+{
+       writel(dtrm, &dev->regs->dtrm);
+
+       /*
+        * This controller only provides interruption to inform the completion
+        * of each byte transfer.  (No status register to poll it.)
+        * Unfortunately, U-Boot does not have a good support of interrupt.
+        * Wait for a while.
+        */
+       udelay(dev->wait_us);
+
+       return readl(&dev->regs->drec);
+}
+
+static int send_byte(struct uniphier_i2c_dev *dev, u32 dtrm, bool *stop)
+{
+       int ret = 0;
+       u32 drec;
+
+       drec = send_and_recv_byte(dev, dtrm);
+
+       if (drec & I2C_DREC_LAB) {
+               debug("uniphier_i2c: bus arbitration failed\n");
+               *stop = false;
+               ret = -EREMOTEIO;
+       }
+       if (drec & I2C_DREC_LRB) {
+               debug("uniphier_i2c: slave did not return ACK\n");
+               ret = -EREMOTEIO;
+       }
+       return ret;
+}
+
+static int uniphier_i2c_transmit(struct uniphier_i2c_dev *dev, uint addr,
+                                uint len, const u8 *buf, bool *stop)
+{
+       int ret;
+
+       debug("%s: addr = %x, len = %d\n", __func__, addr, len);
+
+       ret = send_byte(dev, I2C_DTRM_STA | I2C_DTRM_NACK | addr << 1, stop);
+       if (ret < 0)
+               goto fail;
+
+       while (len--) {
+               ret = send_byte(dev, I2C_DTRM_NACK | *buf++, stop);
+               if (ret < 0)
+                       goto fail;
+       }
+
+fail:
+       if (*stop)
+               writel(I2C_DTRM_STO | I2C_DTRM_NACK, &dev->regs->dtrm);
+
+       return ret;
+}
+
+static int uniphier_i2c_receive(struct uniphier_i2c_dev *dev, uint addr,
+                               uint len, u8 *buf, bool *stop)
+{
+       int ret;
+
+       debug("%s: addr = %x, len = %d\n", __func__, addr, len);
+
+       ret = send_byte(dev, I2C_DTRM_STA | I2C_DTRM_NACK |
+                       I2C_DTRM_RD | addr << 1, stop);
+       if (ret < 0)
+               goto fail;
+
+       while (len--)
+               *buf++ = send_and_recv_byte(dev, len ? 0 : I2C_DTRM_NACK);
+
+fail:
+       if (*stop)
+               writel(I2C_DTRM_STO | I2C_DTRM_NACK, &dev->regs->dtrm);
+
+       return ret;
+}
+
+static int uniphier_i2c_xfer(struct udevice *bus, struct i2c_msg *msg,
+                            int nmsgs)
+{
+       int ret = 0;
+       struct uniphier_i2c_dev *dev = dev_get_priv(bus);
+       bool stop;
+
+       for (; nmsgs > 0; nmsgs--, msg++) {
+               /* If next message is read, skip the stop condition */
+               stop = nmsgs > 1 && msg[1].flags & I2C_M_RD ? false : true;
+
+               if (msg->flags & I2C_M_RD)
+                       ret = uniphier_i2c_receive(dev, msg->addr, msg->len,
+                                                  msg->buf, &stop);
+               else
+                       ret = uniphier_i2c_transmit(dev, msg->addr, msg->len,
+                                                   msg->buf, &stop);
+
+               if (ret < 0)
+                       break;
+       }
+
+       return ret;
+}
+
+static int uniphier_i2c_set_bus_speed(struct udevice *bus, unsigned int speed)
+{
+       struct uniphier_i2c_dev *priv = dev_get_priv(bus);
+
+       /* max supported frequency is 400 kHz */
+       if (speed > 400000)
+               return -EINVAL;
+
+       /* bus reset: make sure the bus is idle when change the frequency */
+       writel(0x1, &priv->regs->brst);
+
+       writel((priv->input_clk / speed / 2 << 16) | (priv->input_clk / speed),
+              &priv->regs->clk);
+
+       writel(0x3, &priv->regs->brst);
+
+       /*
+        * Theoretically, each byte can be transferred in
+        * 1000000 * 9 / speed usec.  For safety, wait more than double.
+        */
+       priv->wait_us = 20000000 / speed;
+
+       return 0;
+}
+
+
+static const struct dm_i2c_ops uniphier_i2c_ops = {
+       .xfer = uniphier_i2c_xfer,
+       .set_bus_speed = uniphier_i2c_set_bus_speed,
+};
+
+static const struct udevice_id uniphier_i2c_of_match[] = {
+       { .compatible = "panasonic,uniphier-i2c" },
+       {},
+};
+
+U_BOOT_DRIVER(uniphier_i2c) = {
+       .name = "uniphier-i2c",
+       .id = UCLASS_I2C,
+       .of_match = uniphier_i2c_of_match,
+       .probe = uniphier_i2c_probe,
+       .remove = uniphier_i2c_remove,
+       .priv_auto_alloc_size = sizeof(struct uniphier_i2c_dev),
+       .ops = &uniphier_i2c_ops,
+};
index fd328f054940f3beb2214b76c4f103c9b06377a3..0dd1abcf80fcfe0e87fdb09323907244b3033e15 100644 (file)
@@ -9,8 +9,9 @@
  * as they seem to have the same I2C controller inside.
  * The different address mapping is handled by the s3c24xx.h files below.
  */
-
 #include <common.h>
+#include <errno.h>
+#include <dm.h>
 #include <fdtdec.h>
 #if (defined CONFIG_EXYNOS4 || defined CONFIG_EXYNOS5)
 #include <asm/arch/clk.h>
 #define CONFIG_MAX_I2C_NUM 1
 #endif
 
+DECLARE_GLOBAL_DATA_PTR;
+
 /*
  * For SPL boot some boards need i2c before SDRAM is initialised so force
  * variables to live in SRAM
  */
+#ifdef CONFIG_SYS_I2C
 static struct s3c24x0_i2c_bus i2c_bus[CONFIG_MAX_I2C_NUM]
                        __attribute__((section(".data")));
+#endif
+
+enum exynos_i2c_type {
+       EXYNOS_I2C_STD,
+       EXYNOS_I2C_HS,
+};
 
+#ifdef CONFIG_SYS_I2C
 /**
  * Get a pointer to the given bus index
  *
@@ -147,6 +158,7 @@ static struct s3c24x0_i2c_bus *get_bus(unsigned int bus_idx)
        debug("Undefined bus: %d\n", bus_idx);
        return NULL;
 }
+#endif
 
 #if !(defined CONFIG_EXYNOS4 || defined CONFIG_EXYNOS5)
 static int GetI2CSDA(void)
@@ -251,6 +263,7 @@ static void ReadWriteByte(struct s3c24x0_i2c *i2c)
        writel(readl(&i2c->iiccon) & ~I2CCON_IRPND, &i2c->iiccon);
 }
 
+#ifdef CONFIG_SYS_I2C
 static struct s3c24x0_i2c *get_base_i2c(int bus)
 {
 #ifdef CONFIG_EXYNOS4
@@ -267,6 +280,7 @@ static struct s3c24x0_i2c *get_base_i2c(int bus)
        return s3c24x0_get_base_i2c();
 #endif
 }
+#endif
 
 static void i2c_ch_init(struct s3c24x0_i2c *i2c, int speed, int slaveadd)
 {
@@ -326,7 +340,7 @@ static int hsi2c_get_clk_details(struct s3c24x0_i2c_bus *i2c_bus)
                        return 0;
                }
        }
-       return -1;
+       return -EINVAL;
 }
 
 static void hsi2c_ch_init(struct s3c24x0_i2c_bus *i2c_bus)
@@ -398,18 +412,20 @@ static void exynos5_i2c_reset(struct s3c24x0_i2c_bus *i2c_bus)
        hsi2c_ch_init(i2c_bus);
 }
 
+#ifdef CONFIG_SYS_I2C
 static void s3c24x0_i2c_init(struct i2c_adapter *adap, int speed, int slaveadd)
 {
        struct s3c24x0_i2c *i2c;
        struct s3c24x0_i2c_bus *bus;
-
 #if !(defined CONFIG_EXYNOS4 || defined CONFIG_EXYNOS5)
        struct s3c24x0_gpio *gpio = s3c24x0_get_base_gpio();
 #endif
        ulong start_time = get_timer(0);
 
-       /* By default i2c channel 0 is the current bus */
        i2c = get_base_i2c(adap->hwadapnr);
+       bus = &i2c_bus[adap->hwadapnr];
+       if (!bus)
+               return;
 
        /*
         * In case the previous transfer is still going, wait to give it a
@@ -470,12 +486,13 @@ static void s3c24x0_i2c_init(struct i2c_adapter *adap, int speed, int slaveadd)
 #endif
        }
 #endif /* #if !(defined CONFIG_EXYNOS4 || defined CONFIG_EXYNOS5) */
+
        i2c_ch_init(i2c, speed, slaveadd);
 
-       bus = &i2c_bus[adap->hwadapnr];
        bus->active = true;
        bus->regs = i2c;
 }
+#endif /* CONFIG_SYS_I2C */
 
 /*
  * Poll the appropriate bit of the fifo status register until the interface is
@@ -698,20 +715,27 @@ static int hsi2c_read(struct exynos5_hsi2c *i2c,
        return rv;
 }
 
+#ifdef CONFIG_SYS_I2C
 static unsigned int s3c24x0_i2c_set_bus_speed(struct i2c_adapter *adap,
-                                         unsigned int speed)
+                                             unsigned int speed)
+#else
+static int s3c24x0_i2c_set_bus_speed(struct udevice *dev, unsigned int speed)
+#endif
 {
        struct s3c24x0_i2c_bus *i2c_bus;
 
+#ifdef CONFIG_SYS_I2C
        i2c_bus = get_bus(adap->hwadapnr);
        if (!i2c_bus)
-               return -1;
-
+               return -EFAULT;
+#else
+       i2c_bus = dev_get_priv(dev);
+#endif
        i2c_bus->clock_frequency = speed;
 
        if (i2c_bus->is_highspeed) {
                if (hsi2c_get_clk_details(i2c_bus))
-                       return -1;
+                       return -EFAULT;
                hsi2c_ch_init(i2c_bus);
        } else {
                i2c_ch_init(i2c_bus->regs, i2c_bus->clock_frequency,
@@ -721,17 +745,6 @@ static unsigned int s3c24x0_i2c_set_bus_speed(struct i2c_adapter *adap,
        return 0;
 }
 
-#ifdef CONFIG_EXYNOS5
-static void exynos_i2c_init(struct i2c_adapter *adap, int speed, int slaveaddr)
-{
-       /* This will override the speed selected in the fdt for that port */
-       debug("i2c_init(speed=%u, slaveaddr=0x%x)\n", speed, slaveaddr);
-       if (i2c_set_bus_speed(speed))
-               printf("i2c_init: failed to init bus %d for speed = %d\n",
-                                               adap->hwadapnr, speed);
-}
-#endif
-
 /*
  * cmd_type is 0 for write, 1 for read.
  *
@@ -844,15 +857,23 @@ bailout:
        return result;
 }
 
+#ifdef CONFIG_SYS_I2C
 static int s3c24x0_i2c_probe(struct i2c_adapter *adap, uchar chip)
+#else
+static int s3c24x0_i2c_probe(struct udevice *dev, uint chip, uint chip_flags)
+#endif
 {
        struct s3c24x0_i2c_bus *i2c_bus;
        uchar buf[1];
        int ret;
 
+#ifdef CONFIG_SYS_I2C
        i2c_bus = get_bus(adap->hwadapnr);
        if (!i2c_bus)
-               return -1;
+               return -EFAULT;
+#else
+       i2c_bus = dev_get_priv(dev);
+#endif
        buf[0] = 0;
 
        /*
@@ -871,6 +892,7 @@ static int s3c24x0_i2c_probe(struct i2c_adapter *adap, uchar chip)
        return ret != I2C_OK;
 }
 
+#ifdef CONFIG_SYS_I2C
 static int s3c24x0_i2c_read(struct i2c_adapter *adap, uchar chip, uint addr,
                            int alen, uchar *buffer, int len)
 {
@@ -878,9 +900,13 @@ static int s3c24x0_i2c_read(struct i2c_adapter *adap, uchar chip, uint addr,
        uchar xaddr[4];
        int ret;
 
+       i2c_bus = get_bus(adap->hwadapnr);
+       if (!i2c_bus)
+               return -EFAULT;
+
        if (alen > 4) {
                debug("I2C read: addr len %d not supported\n", alen);
-               return 1;
+               return -EADDRNOTAVAIL;
        }
 
        if (alen > 0) {
@@ -906,10 +932,6 @@ static int s3c24x0_i2c_read(struct i2c_adapter *adap, uchar chip, uint addr,
                chip |= ((addr >> (alen * 8)) &
                         CONFIG_SYS_I2C_EEPROM_ADDR_OVERFLOW);
 #endif
-       i2c_bus = get_bus(adap->hwadapnr);
-       if (!i2c_bus)
-               return -1;
-
        if (i2c_bus->is_highspeed)
                ret = hsi2c_read(i2c_bus->hsregs, chip, &xaddr[4 - alen],
                                 alen, buffer, len);
@@ -921,7 +943,7 @@ static int s3c24x0_i2c_read(struct i2c_adapter *adap, uchar chip, uint addr,
                if (i2c_bus->is_highspeed)
                        exynos5_i2c_reset(i2c_bus);
                debug("I2c read failed %d\n", ret);
-               return 1;
+               return -EIO;
        }
        return 0;
 }
@@ -933,9 +955,13 @@ static int s3c24x0_i2c_write(struct i2c_adapter *adap, uchar chip, uint addr,
        uchar xaddr[4];
        int ret;
 
+       i2c_bus = get_bus(adap->hwadapnr);
+       if (!i2c_bus)
+               return -EFAULT;
+
        if (alen > 4) {
                debug("I2C write: addr len %d not supported\n", alen);
-               return 1;
+               return -EINVAL;
        }
 
        if (alen > 0) {
@@ -960,10 +986,6 @@ static int s3c24x0_i2c_write(struct i2c_adapter *adap, uchar chip, uint addr,
                chip |= ((addr >> (alen * 8)) &
                         CONFIG_SYS_I2C_EEPROM_ADDR_OVERFLOW);
 #endif
-       i2c_bus = get_bus(adap->hwadapnr);
-       if (!i2c_bus)
-               return -1;
-
        if (i2c_bus->is_highspeed)
                ret = hsi2c_write(i2c_bus->hsregs, chip, &xaddr[4 - alen],
                                  alen, buffer, len, true);
@@ -985,7 +1007,7 @@ static void process_nodes(const void *blob, int node_list[], int count,
                         int is_highspeed)
 {
        struct s3c24x0_i2c_bus *bus;
-       int i;
+       int i, flags;
 
        for (i = 0; i < count; i++) {
                int node = node_list[i];
@@ -997,12 +1019,15 @@ static void process_nodes(const void *blob, int node_list[], int count,
                bus->active = true;
                bus->is_highspeed = is_highspeed;
 
-               if (is_highspeed)
+               if (is_highspeed) {
+                       flags = PINMUX_FLAG_HS_MODE;
                        bus->hsregs = (struct exynos5_hsi2c *)
                                        fdtdec_get_addr(blob, node, "reg");
-               else
+               } else {
+                       flags = 0;
                        bus->regs = (struct s3c24x0_i2c *)
                                        fdtdec_get_addr(blob, node, "reg");
+               }
 
                bus->id = pinmux_decode_periph_id(blob, node);
                bus->clock_frequency = fdtdec_get_int(blob, node,
@@ -1010,7 +1035,7 @@ static void process_nodes(const void *blob, int node_list[], int count,
                                                CONFIG_SYS_I2C_S3C24X0_SPEED);
                bus->node = node;
                bus->bus_num = i;
-               exynos_pinmux_config(bus->id, 0);
+               exynos_pinmux_config(PERIPH_ID_I2C0 + bus->id, flags);
 
                /* Mark position as used */
                node_list[i] = -1;
@@ -1033,7 +1058,6 @@ void board_i2c_init(const void *blob)
                COMPAT_SAMSUNG_EXYNOS5_I2C, node_list,
                CONFIG_MAX_I2C_NUM);
        process_nodes(blob, node_list, count, 1);
-
 }
 
 int i2c_get_bus_num_fdt(int node)
@@ -1046,7 +1070,7 @@ int i2c_get_bus_num_fdt(int node)
        }
 
        debug("%s: Can't find any matched I2C bus\n", __func__);
-       return -1;
+       return -EINVAL;
 }
 
 int i2c_reset_port_fdt(const void *blob, int node)
@@ -1057,18 +1081,18 @@ int i2c_reset_port_fdt(const void *blob, int node)
        bus = i2c_get_bus_num_fdt(node);
        if (bus < 0) {
                debug("could not get bus for node %d\n", node);
-               return -1;
+               return bus;
        }
 
        i2c_bus = get_bus(bus);
        if (!i2c_bus) {
-               debug("get_bus() failed for node node %d\n", node);
-               return -1;
+               debug("get_bus() failed for node %d\n", node);
+               return -EFAULT;
        }
 
        if (i2c_bus->is_highspeed) {
                if (hsi2c_get_clk_details(i2c_bus))
-                       return -1;
+                       return -EINVAL;
                hsi2c_ch_init(i2c_bus);
        } else {
                i2c_ch_init(i2c_bus->regs, i2c_bus->clock_frequency,
@@ -1077,7 +1101,17 @@ int i2c_reset_port_fdt(const void *blob, int node)
 
        return 0;
 }
-#endif
+#endif /* CONFIG_OF_CONTROL */
+
+#ifdef CONFIG_EXYNOS5
+static void exynos_i2c_init(struct i2c_adapter *adap, int speed, int slaveaddr)
+{
+       /* This will override the speed selected in the fdt for that port */
+       debug("i2c_init(speed=%u, slaveaddr=0x%x)\n", speed, slaveaddr);
+       if (i2c_set_bus_speed(speed))
+               error("i2c_init: failed to init bus for speed = %d", speed);
+}
+#endif /* CONFIG_EXYNOS5 */
 
 /*
  * Register s3c24x0 i2c adapters
@@ -1247,3 +1281,120 @@ U_BOOT_I2C_ADAP_COMPLETE(s3c0, s3c24x0_i2c_init, s3c24x0_i2c_probe,
                        CONFIG_SYS_I2C_S3C24X0_SPEED,
                        CONFIG_SYS_I2C_S3C24X0_SLAVE, 0)
 #endif
+#endif /* CONFIG_SYS_I2C */
+
+#ifdef CONFIG_DM_I2C
+static int i2c_write_data(struct s3c24x0_i2c_bus *i2c_bus, uchar chip,
+                         uchar *buffer, int len, bool end_with_repeated_start)
+{
+       int ret;
+
+       if (i2c_bus->is_highspeed) {
+               ret = hsi2c_write(i2c_bus->hsregs, chip, 0, 0,
+                                 buffer, len, true);
+               if (ret)
+                       exynos5_i2c_reset(i2c_bus);
+       } else {
+               ret = i2c_transfer(i2c_bus->regs, I2C_WRITE,
+                                  chip << 1, 0, 0, buffer, len);
+       }
+
+       return ret != I2C_OK;
+}
+
+static int i2c_read_data(struct s3c24x0_i2c_bus  *i2c_bus, uchar chip,
+                        uchar *buffer, int len)
+{
+       int ret;
+
+       if (i2c_bus->is_highspeed) {
+               ret = hsi2c_read(i2c_bus->hsregs, chip, 0, 0, buffer, len);
+               if (ret)
+                       exynos5_i2c_reset(i2c_bus);
+       } else {
+               ret = i2c_transfer(i2c_bus->regs, I2C_READ,
+                                  chip << 1, 0, 0, buffer, len);
+       }
+
+       return ret != I2C_OK;
+}
+
+static int s3c24x0_i2c_xfer(struct udevice *dev, struct i2c_msg *msg,
+                           int nmsgs)
+{
+       struct s3c24x0_i2c_bus *i2c_bus = dev_get_priv(dev);
+       int ret;
+
+       for (; nmsgs > 0; nmsgs--, msg++) {
+               bool next_is_read = nmsgs > 1 && (msg[1].flags & I2C_M_RD);
+
+               if (msg->flags & I2C_M_RD) {
+                       ret = i2c_read_data(i2c_bus, msg->addr, msg->buf,
+                                           msg->len);
+               } else {
+                       ret = i2c_write_data(i2c_bus, msg->addr, msg->buf,
+                                            msg->len, next_is_read);
+               }
+               if (ret)
+                       return -EREMOTEIO;
+       }
+
+       return 0;
+}
+
+static int s3c_i2c_ofdata_to_platdata(struct udevice *dev)
+{
+       const void *blob = gd->fdt_blob;
+       struct s3c24x0_i2c_bus *i2c_bus = dev_get_priv(dev);
+       int node, flags;
+
+       i2c_bus->is_highspeed = dev->of_id->data;
+       node = dev->of_offset;
+
+       if (i2c_bus->is_highspeed) {
+               flags = PINMUX_FLAG_HS_MODE;
+               i2c_bus->hsregs = (struct exynos5_hsi2c *)
+                               fdtdec_get_addr(blob, node, "reg");
+       } else {
+               flags = 0;
+               i2c_bus->regs = (struct s3c24x0_i2c *)
+                               fdtdec_get_addr(blob, node, "reg");
+       }
+
+       i2c_bus->id = pinmux_decode_periph_id(blob, node);
+
+       i2c_bus->clock_frequency = fdtdec_get_int(blob, node,
+                                               "clock-frequency",
+                                               CONFIG_SYS_I2C_S3C24X0_SPEED);
+       i2c_bus->node = node;
+       i2c_bus->bus_num = dev->seq;
+
+       exynos_pinmux_config(i2c_bus->id, flags);
+
+       i2c_bus->active = true;
+
+       return 0;
+}
+
+static const struct dm_i2c_ops s3c_i2c_ops = {
+       .xfer           = s3c24x0_i2c_xfer,
+       .probe_chip     = s3c24x0_i2c_probe,
+       .set_bus_speed  = s3c24x0_i2c_set_bus_speed,
+};
+
+static const struct udevice_id s3c_i2c_ids[] = {
+       { .compatible = "samsung,s3c2440-i2c", .data = EXYNOS_I2C_STD },
+       { .compatible = "samsung,exynos5-hsi2c", .data = EXYNOS_I2C_HS },
+       { }
+};
+
+U_BOOT_DRIVER(i2c_s3c) = {
+       .name   = "i2c_s3c",
+       .id     = UCLASS_I2C,
+       .of_match = s3c_i2c_ids,
+       .ofdata_to_platdata = s3c_i2c_ofdata_to_platdata,
+       .per_child_auto_alloc_size = sizeof(struct dm_i2c_chip),
+       .priv_auto_alloc_size = sizeof(struct s3c24x0_i2c_bus),
+       .ops    = &s3c_i2c_ops,
+};
+#endif /* CONFIG_DM_I2C */
index f0e9f51a1f28fda9822e765a5821b095f6badfef..a943aa6382142b4ebf411bc7c11ad7a9dbd9d80a 100644 (file)
@@ -25,24 +25,24 @@ struct dm_sandbox_i2c_emul_priv {
 static int get_emul(struct udevice *dev, struct udevice **devp,
                    struct dm_i2c_ops **opsp)
 {
-       struct dm_i2c_chip *priv;
+       struct dm_i2c_chip *plat;
        int ret;
 
        *devp = NULL;
        *opsp = NULL;
-       priv = dev_get_parentdata(dev);
-       if (!priv->emul) {
+       plat = dev_get_parent_platdata(dev);
+       if (!plat->emul) {
                ret = dm_scan_fdt_node(dev, gd->fdt_blob, dev->of_offset,
                                       false);
                if (ret)
                        return ret;
 
-               ret = device_get_child(dev, 0, &priv->emul);
+               ret = device_get_child(dev, 0, &plat->emul);
                if (ret)
                        return ret;
        }
-       *devp = priv->emul;
-       *opsp = i2c_get_ops(priv->emul);
+       *devp = plat->emul;
+       *opsp = i2c_get_ops(plat->emul);
 
        return 0;
 }
@@ -60,7 +60,7 @@ static int sandbox_i2c_xfer(struct udevice *bus, struct i2c_msg *msg,
        if (msg->addr == SANDBOX_I2C_TEST_ADDR)
                return 0;
 
-       ret = i2c_get_chip(bus, msg->addr, &dev);
+       ret = i2c_get_chip(bus, msg->addr, 1, &dev);
        if (ret)
                return ret;
 
@@ -82,20 +82,6 @@ static const struct dm_i2c_ops sandbox_i2c_ops = {
        .xfer           = sandbox_i2c_xfer,
 };
 
-static int sandbox_i2c_child_pre_probe(struct udevice *dev)
-{
-       struct dm_i2c_chip *i2c_chip = dev_get_parentdata(dev);
-
-       /* Ignore our test address */
-       if (i2c_chip->chip_addr == SANDBOX_I2C_TEST_ADDR)
-               return 0;
-       if (dev->of_offset == -1)
-               return 0;
-
-       return i2c_chip_ofdata_to_platdata(gd->fdt_blob, dev->of_offset,
-                                          i2c_chip);
-}
-
 static const struct udevice_id sandbox_i2c_ids[] = {
        { .compatible = "sandbox,i2c" },
        { }
@@ -105,7 +91,5 @@ U_BOOT_DRIVER(i2c_sandbox) = {
        .name   = "i2c_sandbox",
        .id     = UCLASS_I2C,
        .of_match = sandbox_i2c_ids,
-       .per_child_auto_alloc_size = sizeof(struct dm_i2c_chip),
-       .child_pre_probe = sandbox_i2c_child_pre_probe,
        .ops    = &sandbox_i2c_ops,
 };
index 87290c3127612c3369f8e98c383118f0e3229563..f4142870b304037273cb405f36e9ad2a39819d4b 100644 (file)
@@ -484,21 +484,6 @@ static const struct dm_i2c_ops tegra_i2c_ops = {
        .set_bus_speed  = tegra_i2c_set_bus_speed,
 };
 
-static int tegra_i2c_child_pre_probe(struct udevice *dev)
-{
-       struct dm_i2c_chip *i2c_chip = dev_get_parentdata(dev);
-
-       if (dev->of_offset == -1)
-               return 0;
-       return i2c_chip_ofdata_to_platdata(gd->fdt_blob, dev->of_offset,
-                                          i2c_chip);
-}
-
-static int tegra_i2c_ofdata_to_platdata(struct udevice *dev)
-{
-       return 0;
-}
-
 static const struct udevice_id tegra_i2c_ids[] = {
        { .compatible = "nvidia,tegra114-i2c", .data = TYPE_114 },
        { .compatible = "nvidia,tegra20-i2c", .data = TYPE_STD },
@@ -510,10 +495,7 @@ U_BOOT_DRIVER(i2c_tegra) = {
        .name   = "i2c_tegra",
        .id     = UCLASS_I2C,
        .of_match = tegra_i2c_ids,
-       .ofdata_to_platdata = tegra_i2c_ofdata_to_platdata,
        .probe  = tegra_i2c_probe,
-       .per_child_auto_alloc_size = sizeof(struct dm_i2c_chip),
-       .child_pre_probe = tegra_i2c_child_pre_probe,
        .priv_auto_alloc_size = sizeof(struct i2c_bus),
        .ops    = &tegra_i2c_ops,
 };
index 9b4effb2fb56cda2fcba39d1a5ee80fe084384b8..5846e76c49525549f784ef6645834fa6b6611e5d 100644 (file)
@@ -154,7 +154,9 @@ static int prepare_proto3_response_buffer(struct cros_ec_dev *dev, int din_len)
  * @param dev          CROS-EC device
  * @param dinp          Returns pointer to response data
  * @param din_len       Maximum size of response in bytes
- * @return number of bytes of response data, or <0 if error
+ * @return number of bytes of response data, or <0 if error. Note that error
+ * codes can be from errno.h or -ve EC_RES_INVALID_CHECKSUM values (and they
+ * overlap!)
  */
 static int handle_proto3_response(struct cros_ec_dev *dev,
                                  uint8_t **dinp, int din_len)
@@ -228,7 +230,7 @@ static int send_command_proto3(struct cros_ec_dev *dev,
 
 #ifdef CONFIG_DM_CROS_EC
        ops = dm_cros_ec_get_ops(dev->dev);
-       rv = ops->packet(dev->dev, out_bytes, in_bytes);
+       rv = ops->packet ? ops->packet(dev->dev, out_bytes, in_bytes) : -ENOSYS;
 #else
        switch (dev->interface) {
 #ifdef CONFIG_CROS_EC_SPI
@@ -320,7 +322,7 @@ static int send_command(struct cros_ec_dev *dev, uint8_t cmd, int cmd_version,
  *                     If not NULL, it will be updated to point to the data
  *                     and will always be double word aligned (64-bits)
  * @param din_len       Maximum size of response in bytes
- * @return number of bytes in response, or -1 on error
+ * @return number of bytes in response, or -ve on error
  */
 static int ec_command_inptr(struct cros_ec_dev *dev, uint8_t cmd,
                int cmd_version, const void *dout, int dout_len, uint8_t **dinp,
@@ -387,7 +389,7 @@ static int ec_command_inptr(struct cros_ec_dev *dev, uint8_t cmd,
  *                     It not NULL, it is a place for ec_command() to copy the
  *      data to.
  * @param din_len       Maximum size of response in bytes
- * @return number of bytes in response, or -1 on error
+ * @return number of bytes in response, or -ve on error
  */
 static int ec_command(struct cros_ec_dev *dev, uint8_t cmd, int cmd_version,
                      const void *dout, int dout_len,
@@ -606,10 +608,10 @@ int cros_ec_reboot(struct cros_ec_dev *dev, enum ec_reboot_cmd cmd,
 int cros_ec_interrupt_pending(struct cros_ec_dev *dev)
 {
        /* no interrupt support : always poll */
-       if (!fdt_gpio_isvalid(&dev->ec_int))
+       if (!dm_gpio_is_valid(&dev->ec_int))
                return -ENOENT;
 
-       return !gpio_get_value(dev->ec_int.gpio);
+       return dm_gpio_get_value(&dev->ec_int);
 }
 
 int cros_ec_info(struct cros_ec_dev *dev, struct ec_response_mkbp_info *info)
@@ -1072,7 +1074,8 @@ static int cros_ec_decode_fdt(const void *blob, int node,
                return -1;
        }
 
-       fdtdec_decode_gpio(blob, node, "ec-interrupt", &dev->ec_int);
+       gpio_request_by_name_nodev(blob, node, "ec-interrupt", 0, &dev->ec_int,
+                                  GPIOD_IS_IN);
        dev->optimise_flash_write = fdtdec_get_bool(blob, node,
                                                    "optimise-flash-write");
        *devp = dev;
@@ -1090,17 +1093,11 @@ int cros_ec_register(struct udevice *dev)
        char id[MSG_BYTES];
 
        cdev->dev = dev;
-       fdtdec_decode_gpio(blob, node, "ec-interrupt", &cdev->ec_int);
+       gpio_request_by_name(dev, "ec-interrupt", 0, &cdev->ec_int,
+                            GPIOD_IS_IN);
        cdev->optimise_flash_write = fdtdec_get_bool(blob, node,
                                                     "optimise-flash-write");
 
-       /* we will poll the EC interrupt line */
-       fdtdec_setup_gpio(&cdev->ec_int);
-       if (fdt_gpio_isvalid(&cdev->ec_int)) {
-               gpio_request(cdev->ec_int.gpio, "cros-ec-irq");
-               gpio_direction_input(cdev->ec_int.gpio);
-       }
-
        if (cros_ec_check_version(cdev)) {
                debug("%s: Could not detect CROS-EC version\n", __func__);
                return -CROS_EC_ERR_CHECK_VERSION;
@@ -1184,13 +1181,6 @@ int cros_ec_init(const void *blob, struct cros_ec_dev **cros_ecp)
        }
 #endif
 
-       /* we will poll the EC interrupt line */
-       fdtdec_setup_gpio(&dev->ec_int);
-       if (fdt_gpio_isvalid(&dev->ec_int)) {
-               gpio_request(dev->ec_int.gpio, "cros-ec-irq");
-               gpio_direction_input(dev->ec_int.gpio);
-       }
-
        if (cros_ec_check_version(dev)) {
                debug("%s: Could not detect CROS-EC version\n", __func__);
                return -CROS_EC_ERR_CHECK_VERSION;
index 513cdb1cb09808be69ac6a44be2cb651ad9ac347..f9bc9750d4cb2e617eab6fb4f4dd126d64c9e2b5 100644 (file)
@@ -14,6 +14,7 @@
  */
 
 #include <common.h>
+#include <dm.h>
 #include <i2c.h>
 #include <cros_ec.h>
 
 #define debug_trace(fmt, b...)
 #endif
 
-int cros_ec_i2c_command(struct cros_ec_dev *dev, uint8_t cmd, int cmd_version,
-                    const uint8_t *dout, int dout_len,
-                    uint8_t **dinp, int din_len)
+static int cros_ec_i2c_command(struct udevice *udev, uint8_t cmd,
+                              int cmd_version, const uint8_t *dout,
+                              int dout_len, uint8_t **dinp, int din_len)
 {
-       int old_bus = 0;
+       struct cros_ec_dev *dev = udev->uclass_priv;
        /* version8, cmd8, arglen8, out8[dout_len], csum8 */
        int out_bytes = dout_len + 4;
        /* response8, arglen8, in8[din_len], checksum8 */
@@ -37,8 +38,6 @@ int cros_ec_i2c_command(struct cros_ec_dev *dev, uint8_t cmd, int cmd_version,
        uint8_t *in_ptr;
        int len, csum, ret;
 
-       old_bus = i2c_get_bus_num();
-
        /*
         * Sanity-check I/O sizes given transaction overhead in internal
         * buffers.
@@ -86,36 +85,24 @@ int cros_ec_i2c_command(struct cros_ec_dev *dev, uint8_t cmd, int cmd_version,
        *ptr++ = (uint8_t)
                cros_ec_calc_checksum(dev->dout, dout_len + 3);
 
-       /* Set to the proper i2c bus */
-       if (i2c_set_bus_num(dev->bus_num)) {
-               debug("%s: Cannot change to I2C bus %d\n", __func__,
-                       dev->bus_num);
-               return -1;
-       }
-
        /* Send output data */
        cros_ec_dump_data("out", -1, dev->dout, out_bytes);
-       ret = i2c_write(dev->addr, 0, 0, dev->dout, out_bytes);
+       ret = dm_i2c_write(udev, 0, dev->dout, out_bytes);
        if (ret) {
-               debug("%s: Cannot complete I2C write to 0x%x\n",
-                       __func__, dev->addr);
+               debug("%s: Cannot complete I2C write to %s\n", __func__,
+                     udev->name);
                ret = -1;
        }
 
        if (!ret) {
-               ret = i2c_read(dev->addr, 0, 0, in_ptr, in_bytes);
+               ret = dm_i2c_read(udev, 0, in_ptr, in_bytes);
                if (ret) {
-                       debug("%s: Cannot complete I2C read from 0x%x\n",
-                               __func__, dev->addr);
+                       debug("%s: Cannot complete I2C read from %s\n",
+                             __func__, udev->name);
                        ret = -1;
                }
        }
 
-       /* Return to original bus number */
-       i2c_set_bus_num(old_bus);
-       if (ret)
-               return ret;
-
        if (*in_ptr != EC_RES_SUCCESS) {
                debug("%s: Received bad result code %d\n", __func__, *in_ptr);
                return -(int)*in_ptr;
@@ -142,35 +129,24 @@ int cros_ec_i2c_command(struct cros_ec_dev *dev, uint8_t cmd, int cmd_version,
        return din_len;
 }
 
-int cros_ec_i2c_decode_fdt(struct cros_ec_dev *dev, const void *blob)
+static int cros_ec_probe(struct udevice *dev)
 {
-       /* Decode interface-specific FDT params */
-       dev->max_frequency = fdtdec_get_int(blob, dev->node,
-                                           "i2c-max-frequency", 100000);
-       dev->bus_num = i2c_get_bus_num_fdt(dev->parent_node);
-       if (dev->bus_num == -1) {
-               debug("%s: Failed to read bus number\n", __func__);
-               return -1;
-       }
-       dev->addr = fdtdec_get_int(blob, dev->node, "reg", -1);
-       if (dev->addr == -1) {
-               debug("%s: Failed to read device address\n", __func__);
-               return -1;
-       }
-
-       return 0;
+       return cros_ec_register(dev);
 }
 
-/**
- * Initialize I2C protocol.
- *
- * @param dev          CROS_EC device
- * @param blob         Device tree blob
- * @return 0 if ok, -1 on error
- */
-int cros_ec_i2c_init(struct cros_ec_dev *dev, const void *blob)
-{
-       i2c_init(dev->max_frequency, dev->addr);
-
-       return 0;
-}
+static struct dm_cros_ec_ops cros_ec_ops = {
+       .command = cros_ec_i2c_command,
+};
+
+static const struct udevice_id cros_ec_ids[] = {
+       { .compatible = "google,cros-ec" },
+       { }
+};
+
+U_BOOT_DRIVER(cros_ec_i2c) = {
+       .name           = "cros_ec",
+       .id             = UCLASS_CROS_EC,
+       .of_match       = cros_ec_ids,
+       .probe          = cros_ec_probe,
+       .ops            = &cros_ec_ops,
+};
index e6dba298b1e9f2a37b31b4511cf9c8902c9ff227..9359c56e876d03ed2f798e137df43975afcd2f5d 100644 (file)
 
 DECLARE_GLOBAL_DATA_PTR;
 
-#ifdef CONFIG_DM_CROS_EC
 int cros_ec_spi_packet(struct udevice *udev, int out_bytes, int in_bytes)
 {
        struct cros_ec_dev *dev = udev->uclass_priv;
-#else
-int cros_ec_spi_packet(struct cros_ec_dev *dev, int out_bytes, int in_bytes)
-{
-#endif
        struct spi_slave *slave = dev_get_parentdata(dev->dev);
        int rv;
 
@@ -67,18 +62,11 @@ int cros_ec_spi_packet(struct cros_ec_dev *dev, int out_bytes, int in_bytes)
  * @param din_len      Maximum size of response in bytes
  * @return number of bytes in response, or -1 on error
  */
-#ifdef CONFIG_DM_CROS_EC
 int cros_ec_spi_command(struct udevice *udev, uint8_t cmd, int cmd_version,
                     const uint8_t *dout, int dout_len,
                     uint8_t **dinp, int din_len)
 {
        struct cros_ec_dev *dev = udev->uclass_priv;
-#else
-int cros_ec_spi_command(struct cros_ec_dev *dev, uint8_t cmd, int cmd_version,
-                    const uint8_t *dout, int dout_len,
-                    uint8_t **dinp, int din_len)
-{
-#endif
        struct spi_slave *slave = dev_get_parentdata(dev->dev);
        int in_bytes = din_len + 4;     /* status, length, checksum, trailer */
        uint8_t *out;
@@ -166,65 +154,12 @@ int cros_ec_spi_command(struct cros_ec_dev *dev, uint8_t cmd, int cmd_version,
        return len;
 }
 
-#ifndef CONFIG_DM_CROS_EC
-int cros_ec_spi_decode_fdt(struct cros_ec_dev *dev, const void *blob)
+static int cros_ec_probe(struct udevice *dev)
 {
-       /* Decode interface-specific FDT params */
-       dev->max_frequency = fdtdec_get_int(blob, dev->node,
-                                           "spi-max-frequency", 500000);
-       dev->cs = fdtdec_get_int(blob, dev->node, "reg", 0);
-
-       return 0;
-}
-
-/**
- * Initialize SPI protocol.
- *
- * @param dev          CROS_EC device
- * @param blob         Device tree blob
- * @return 0 if ok, -1 on error
- */
-int cros_ec_spi_init(struct cros_ec_dev *dev, const void *blob)
-{
-       int ret;
-
-       ret = spi_setup_slave_fdt(blob, dev->node, dev->parent_node,
-                                 &slave);
-       if (ret) {
-               debug("%s: Could not setup SPI slave\n", __func__);
-               return ret;
-       }
-
-       return 0;
-}
-#endif
-
-#ifdef CONFIG_DM_CROS_EC
-int cros_ec_probe(struct udevice *dev)
-{
-       struct spi_slave *slave = dev_get_parentdata(dev);
-       int ret;
-
-       /*
-        * TODO(sjg@chromium.org)
-        *
-        * This is really horrible at present. It is an artifact of removing
-        * the child_pre_probe() method for SPI. Everything here could go in
-        * an automatic function, except that spi_get_bus_and_cs() wants to
-        * set it up manually and call device_probe_child().
-        *
-        * The solution may be to re-enable the child_pre_probe() method for
-        * SPI and have it do nothing if the child is already passed in via
-        * device_probe_child().
-        */
-       slave->dev = dev;
-       ret = spi_ofdata_to_platdata(gd->fdt_blob, dev->of_offset, slave);
-       if (ret)
-               return ret;
        return cros_ec_register(dev);
 }
 
-struct dm_cros_ec_ops cros_ec_ops = {
+static struct dm_cros_ec_ops cros_ec_ops = {
        .packet = cros_ec_spi_packet,
        .command = cros_ec_spi_command,
 };
@@ -241,4 +176,3 @@ U_BOOT_DRIVER(cros_ec_spi) = {
        .probe          = cros_ec_probe,
        .ops            = &cros_ec_ops,
 };
-#endif
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..7ba85a2b62c45b5f968dbddc1994d7f174163e9a 100644 (file)
@@ -0,0 +1,9 @@
+menu "MMC Host controller Support"
+
+config SH_SDHI
+       bool "SuperH/Renesas ARM SoCs on-chip SDHI host controller support"
+       depends on RMOBILE
+       help
+         Support for the on-chip SDHI host controller on SuperH/Renesas ARM SoCs platform
+
+endmenu
index 461d7d8ec1c1d626d977e18166a6fbd9cee663c6..4ba58789361f369d5b1c608d0a71d8543ff76f21 100644 (file)
@@ -30,6 +30,7 @@ obj-$(CONFIG_S3C_SDI) += s3c_sdi.o
 obj-$(CONFIG_S5P_SDHCI) += s5p_sdhci.o
 obj-$(CONFIG_SDHCI) += sdhci.o
 obj-$(CONFIG_SH_MMCIF) += sh_mmcif.o
+obj-$(CONFIG_SH_SDHI) += sh_sdhi.o
 obj-$(CONFIG_SOCFPGA_DWMMC) += socfpga_dw_mmc.o
 obj-$(CONFIG_SPEAR_SDHCI) += spear_sdhci.o
 obj-$(CONFIG_TEGRA_MMC) += tegra_mmc.o
index 1eb9c2733948bf954aa00414824aa491adc4a4e3..b8039cd092abd43a14022f0a1e7a646198c30aa6 100644 (file)
@@ -486,7 +486,7 @@ static int mmc_change_freq(struct mmc *mmc)
        char cardtype;
        int err;
 
-       mmc->card_caps = MMC_MODE_4BIT | MMC_MODE_8BIT;
+       mmc->card_caps = 0;
 
        if (mmc_host_is_spi(mmc))
                return 0;
@@ -495,6 +495,8 @@ static int mmc_change_freq(struct mmc *mmc)
        if (mmc->version < MMC_VERSION_4)
                return 0;
 
+       mmc->card_caps |= MMC_MODE_4BIT | MMC_MODE_8BIT;
+
        err = mmc_send_ext_csd(mmc, ext_csd);
 
        if (err)
@@ -605,6 +607,200 @@ int mmc_switch_part(int dev_num, unsigned int part_num)
        return ret;
 }
 
+int mmc_hwpart_config(struct mmc *mmc,
+                     const struct mmc_hwpart_conf *conf,
+                     enum mmc_hwpart_conf_mode mode)
+{
+       u8 part_attrs = 0;
+       u32 enh_size_mult;
+       u32 enh_start_addr;
+       u32 gp_size_mult[4];
+       u32 max_enh_size_mult;
+       u32 tot_enh_size_mult = 0;
+       u8 wr_rel_set;
+       int i, pidx, err;
+       ALLOC_CACHE_ALIGN_BUFFER(u8, ext_csd, MMC_MAX_BLOCK_LEN);
+
+       if (mode < MMC_HWPART_CONF_CHECK || mode > MMC_HWPART_CONF_COMPLETE)
+               return -EINVAL;
+
+       if (IS_SD(mmc) || (mmc->version < MMC_VERSION_4_41)) {
+               printf("eMMC >= 4.4 required for enhanced user data area\n");
+               return -EMEDIUMTYPE;
+       }
+
+       if (!(mmc->part_support & PART_SUPPORT)) {
+               printf("Card does not support partitioning\n");
+               return -EMEDIUMTYPE;
+       }
+
+       if (!mmc->hc_wp_grp_size) {
+               printf("Card does not define HC WP group size\n");
+               return -EMEDIUMTYPE;
+       }
+
+       /* check partition alignment and total enhanced size */
+       if (conf->user.enh_size) {
+               if (conf->user.enh_size % mmc->hc_wp_grp_size ||
+                   conf->user.enh_start % mmc->hc_wp_grp_size) {
+                       printf("User data enhanced area not HC WP group "
+                              "size aligned\n");
+                       return -EINVAL;
+               }
+               part_attrs |= EXT_CSD_ENH_USR;
+               enh_size_mult = conf->user.enh_size / mmc->hc_wp_grp_size;
+               if (mmc->high_capacity) {
+                       enh_start_addr = conf->user.enh_start;
+               } else {
+                       enh_start_addr = (conf->user.enh_start << 9);
+               }
+       } else {
+               enh_size_mult = 0;
+               enh_start_addr = 0;
+       }
+       tot_enh_size_mult += enh_size_mult;
+
+       for (pidx = 0; pidx < 4; pidx++) {
+               if (conf->gp_part[pidx].size % mmc->hc_wp_grp_size) {
+                       printf("GP%i partition not HC WP group size "
+                              "aligned\n", pidx+1);
+                       return -EINVAL;
+               }
+               gp_size_mult[pidx] = conf->gp_part[pidx].size / mmc->hc_wp_grp_size;
+               if (conf->gp_part[pidx].size && conf->gp_part[pidx].enhanced) {
+                       part_attrs |= EXT_CSD_ENH_GP(pidx);
+                       tot_enh_size_mult += gp_size_mult[pidx];
+               }
+       }
+
+       if (part_attrs && ! (mmc->part_support & ENHNCD_SUPPORT)) {
+               printf("Card does not support enhanced attribute\n");
+               return -EMEDIUMTYPE;
+       }
+
+       err = mmc_send_ext_csd(mmc, ext_csd);
+       if (err)
+               return err;
+
+       max_enh_size_mult =
+               (ext_csd[EXT_CSD_MAX_ENH_SIZE_MULT+2] << 16) +
+               (ext_csd[EXT_CSD_MAX_ENH_SIZE_MULT+1] << 8) +
+               ext_csd[EXT_CSD_MAX_ENH_SIZE_MULT];
+       if (tot_enh_size_mult > max_enh_size_mult) {
+               printf("Total enhanced size exceeds maximum (%u > %u)\n",
+                      tot_enh_size_mult, max_enh_size_mult);
+               return -EMEDIUMTYPE;
+       }
+
+       /* The default value of EXT_CSD_WR_REL_SET is device
+        * dependent, the values can only be changed if the
+        * EXT_CSD_HS_CTRL_REL bit is set. The values can be
+        * changed only once and before partitioning is completed. */
+       wr_rel_set = ext_csd[EXT_CSD_WR_REL_SET];
+       if (conf->user.wr_rel_change) {
+               if (conf->user.wr_rel_set)
+                       wr_rel_set |= EXT_CSD_WR_DATA_REL_USR;
+               else
+                       wr_rel_set &= ~EXT_CSD_WR_DATA_REL_USR;
+       }
+       for (pidx = 0; pidx < 4; pidx++) {
+               if (conf->gp_part[pidx].wr_rel_change) {
+                       if (conf->gp_part[pidx].wr_rel_set)
+                               wr_rel_set |= EXT_CSD_WR_DATA_REL_GP(pidx);
+                       else
+                               wr_rel_set &= ~EXT_CSD_WR_DATA_REL_GP(pidx);
+               }
+       }
+
+       if (wr_rel_set != ext_csd[EXT_CSD_WR_REL_SET] &&
+           !(ext_csd[EXT_CSD_WR_REL_PARAM] & EXT_CSD_HS_CTRL_REL)) {
+               puts("Card does not support host controlled partition write "
+                    "reliability settings\n");
+               return -EMEDIUMTYPE;
+       }
+
+       if (ext_csd[EXT_CSD_PARTITION_SETTING] &
+           EXT_CSD_PARTITION_SETTING_COMPLETED) {
+               printf("Card already partitioned\n");
+               return -EPERM;
+       }
+
+       if (mode == MMC_HWPART_CONF_CHECK)
+               return 0;
+
+       /* Partitioning requires high-capacity size definitions */
+       if (!(ext_csd[EXT_CSD_ERASE_GROUP_DEF] & 0x01)) {
+               err = mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL,
+                                EXT_CSD_ERASE_GROUP_DEF, 1);
+
+               if (err)
+                       return err;
+
+               ext_csd[EXT_CSD_ERASE_GROUP_DEF] = 1;
+
+               /* update erase group size to be high-capacity */
+               mmc->erase_grp_size =
+                       ext_csd[EXT_CSD_HC_ERASE_GRP_SIZE] * 1024;
+
+       }
+
+       /* all OK, write the configuration */
+       for (i = 0; i < 4; i++) {
+               err = mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL,
+                                EXT_CSD_ENH_START_ADDR+i,
+                                (enh_start_addr >> (i*8)) & 0xFF);
+               if (err)
+                       return err;
+       }
+       for (i = 0; i < 3; i++) {
+               err = mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL,
+                                EXT_CSD_ENH_SIZE_MULT+i,
+                                (enh_size_mult >> (i*8)) & 0xFF);
+               if (err)
+                       return err;
+       }
+       for (pidx = 0; pidx < 4; pidx++) {
+               for (i = 0; i < 3; i++) {
+                       err = mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL,
+                                        EXT_CSD_GP_SIZE_MULT+pidx*3+i,
+                                        (gp_size_mult[pidx] >> (i*8)) & 0xFF);
+                       if (err)
+                               return err;
+               }
+       }
+       err = mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL,
+                        EXT_CSD_PARTITIONS_ATTRIBUTE, part_attrs);
+       if (err)
+               return err;
+
+       if (mode == MMC_HWPART_CONF_SET)
+               return 0;
+
+       /* The WR_REL_SET is a write-once register but shall be
+        * written before setting PART_SETTING_COMPLETED. As it is
+        * write-once we can only write it when completing the
+        * partitioning. */
+       if (wr_rel_set != ext_csd[EXT_CSD_WR_REL_SET]) {
+               err = mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL,
+                                EXT_CSD_WR_REL_SET, wr_rel_set);
+               if (err)
+                       return err;
+       }
+
+       /* Setting PART_SETTING_COMPLETED confirms the partition
+        * configuration but it only becomes effective after power
+        * cycle, so we do not adjust the partition related settings
+        * in the mmc struct. */
+
+       err = mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL,
+                        EXT_CSD_PARTITION_SETTING,
+                        EXT_CSD_PARTITION_SETTING_COMPLETED);
+       if (err)
+               return err;
+
+       return 0;
+}
+
 int mmc_getcd(struct mmc *mmc)
 {
        int cd;
@@ -818,6 +1014,8 @@ static int mmc_startup(struct mmc *mmc)
        ALLOC_CACHE_ALIGN_BUFFER(u8, ext_csd, MMC_MAX_BLOCK_LEN);
        ALLOC_CACHE_ALIGN_BUFFER(u8, test_csd, MMC_MAX_BLOCK_LEN);
        int timeout = 1000;
+       bool has_parts = false;
+       bool part_completed;
 
 #ifdef CONFIG_MMC_SPI_CRC_ON
        if (mmc_host_is_spi(mmc)) { /* enable CRC check for spi */
@@ -970,7 +1168,9 @@ static int mmc_startup(struct mmc *mmc)
        if (!IS_SD(mmc) && (mmc->version >= MMC_VERSION_4)) {
                /* check  ext_csd version and capacity */
                err = mmc_send_ext_csd(mmc, ext_csd);
-               if (!err && (ext_csd[EXT_CSD_REV] >= 2)) {
+               if (err)
+                       return err;
+               if (ext_csd[EXT_CSD_REV] >= 2) {
                        /*
                         * According to the JEDEC Standard, the value of
                         * ext_csd's capacity is valid if the value is more
@@ -1006,13 +1206,70 @@ static int mmc_startup(struct mmc *mmc)
                        break;
                }
 
+               /* The partition data may be non-zero but it is only
+                * effective if PARTITION_SETTING_COMPLETED is set in
+                * EXT_CSD, so ignore any data if this bit is not set,
+                * except for enabling the high-capacity group size
+                * definition (see below). */
+               part_completed = !!(ext_csd[EXT_CSD_PARTITION_SETTING] &
+                                   EXT_CSD_PARTITION_SETTING_COMPLETED);
+
+               /* store the partition info of emmc */
+               mmc->part_support = ext_csd[EXT_CSD_PARTITIONING_SUPPORT];
+               if ((ext_csd[EXT_CSD_PARTITIONING_SUPPORT] & PART_SUPPORT) ||
+                   ext_csd[EXT_CSD_BOOT_MULT])
+                       mmc->part_config = ext_csd[EXT_CSD_PART_CONF];
+               if (part_completed &&
+                   (ext_csd[EXT_CSD_PARTITIONING_SUPPORT] & ENHNCD_SUPPORT))
+                       mmc->part_attr = ext_csd[EXT_CSD_PARTITIONS_ATTRIBUTE];
+
+               mmc->capacity_boot = ext_csd[EXT_CSD_BOOT_MULT] << 17;
+
+               mmc->capacity_rpmb = ext_csd[EXT_CSD_RPMB_MULT] << 17;
+
+               for (i = 0; i < 4; i++) {
+                       int idx = EXT_CSD_GP_SIZE_MULT + i * 3;
+                       uint mult = (ext_csd[idx + 2] << 16) +
+                               (ext_csd[idx + 1] << 8) + ext_csd[idx];
+                       if (mult)
+                               has_parts = true;
+                       if (!part_completed)
+                               continue;
+                       mmc->capacity_gp[i] = mult;
+                       mmc->capacity_gp[i] *=
+                               ext_csd[EXT_CSD_HC_ERASE_GRP_SIZE];
+                       mmc->capacity_gp[i] *= ext_csd[EXT_CSD_HC_WP_GRP_SIZE];
+                       mmc->capacity_gp[i] <<= 19;
+               }
+
+               if (part_completed) {
+                       mmc->enh_user_size =
+                               (ext_csd[EXT_CSD_ENH_SIZE_MULT+2] << 16) +
+                               (ext_csd[EXT_CSD_ENH_SIZE_MULT+1] << 8) +
+                               ext_csd[EXT_CSD_ENH_SIZE_MULT];
+                       mmc->enh_user_size *= ext_csd[EXT_CSD_HC_ERASE_GRP_SIZE];
+                       mmc->enh_user_size *= ext_csd[EXT_CSD_HC_WP_GRP_SIZE];
+                       mmc->enh_user_size <<= 19;
+                       mmc->enh_user_start =
+                               (ext_csd[EXT_CSD_ENH_START_ADDR+3] << 24) +
+                               (ext_csd[EXT_CSD_ENH_START_ADDR+2] << 16) +
+                               (ext_csd[EXT_CSD_ENH_START_ADDR+1] << 8) +
+                               ext_csd[EXT_CSD_ENH_START_ADDR];
+                       if (mmc->high_capacity)
+                               mmc->enh_user_start <<= 9;
+               }
+
                /*
                 * Host needs to enable ERASE_GRP_DEF bit if device is
                 * partitioned. This bit will be lost every time after a reset
                 * or power off. This will affect erase size.
                 */
+               if (part_completed)
+                       has_parts = true;
                if ((ext_csd[EXT_CSD_PARTITIONING_SUPPORT] & PART_SUPPORT) &&
-                   (ext_csd[EXT_CSD_PARTITIONS_ATTRIBUTE] & PART_ENH_ATTRIB)) {
+                   (ext_csd[EXT_CSD_PARTITIONS_ATTRIBUTE] & PART_ENH_ATTRIB))
+                       has_parts = true;
+               if (has_parts) {
                        err = mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL,
                                EXT_CSD_ERASE_GROUP_DEF, 1);
 
@@ -1020,19 +1277,18 @@ static int mmc_startup(struct mmc *mmc)
                                return err;
                        else
                                ext_csd[EXT_CSD_ERASE_GROUP_DEF] = 1;
+               }
 
+               if (ext_csd[EXT_CSD_ERASE_GROUP_DEF] & 0x01) {
                        /* Read out group size from ext_csd */
                        mmc->erase_grp_size =
-                               ext_csd[EXT_CSD_HC_ERASE_GRP_SIZE] *
-                                       MMC_MAX_BLOCK_LEN * 1024;
+                               ext_csd[EXT_CSD_HC_ERASE_GRP_SIZE] * 1024;
                        /*
                         * if high capacity and partition setting completed
                         * SEC_COUNT is valid even if it is smaller than 2 GiB
                         * JEDEC Standard JESD84-B45, 6.2.4
                         */
-                       if (mmc->high_capacity &&
-                           (ext_csd[EXT_CSD_PARTITION_SETTING] &
-                            EXT_CSD_PARTITION_SETTING_COMPLETED)) {
+                       if (mmc->high_capacity && part_completed) {
                                capacity = (ext_csd[EXT_CSD_SEC_CNT]) |
                                        (ext_csd[EXT_CSD_SEC_CNT + 1] << 8) |
                                        (ext_csd[EXT_CSD_SEC_CNT + 2] << 16) |
@@ -1049,23 +1305,11 @@ static int mmc_startup(struct mmc *mmc)
                                * (erase_gmul + 1);
                }
 
-               /* store the partition info of emmc */
-               if ((ext_csd[EXT_CSD_PARTITIONING_SUPPORT] & PART_SUPPORT) ||
-                   ext_csd[EXT_CSD_BOOT_MULT])
-                       mmc->part_config = ext_csd[EXT_CSD_PART_CONF];
-
-               mmc->capacity_boot = ext_csd[EXT_CSD_BOOT_MULT] << 17;
-
-               mmc->capacity_rpmb = ext_csd[EXT_CSD_RPMB_MULT] << 17;
+               mmc->hc_wp_grp_size = 1024
+                       * ext_csd[EXT_CSD_HC_ERASE_GRP_SIZE]
+                       * ext_csd[EXT_CSD_HC_WP_GRP_SIZE];
 
-               for (i = 0; i < 4; i++) {
-                       int idx = EXT_CSD_GP_SIZE_MULT + i * 3;
-                       mmc->capacity_gp[i] = (ext_csd[idx + 2] << 16) +
-                               (ext_csd[idx + 1] << 8) + ext_csd[idx];
-                       mmc->capacity_gp[i] *=
-                               ext_csd[EXT_CSD_HC_ERASE_GRP_SIZE];
-                       mmc->capacity_gp[i] *= ext_csd[EXT_CSD_HC_WP_GRP_SIZE];
-               }
+               mmc->wr_rel_set = ext_csd[EXT_CSD_WR_REL_SET];
        }
 
        err = mmc_set_capacity(mmc, mmc->part_num);
@@ -1107,7 +1351,8 @@ static int mmc_startup(struct mmc *mmc)
                        mmc->tran_speed = 50000000;
                else
                        mmc->tran_speed = 25000000;
-       } else {
+       } else if (mmc->version >= MMC_VERSION_4) {
+               /* Only version 4 of MMC supports wider bus widths */
                int idx;
 
                /* An array of possible bus widths in order of preference */
@@ -1138,6 +1383,18 @@ static int mmc_startup(struct mmc *mmc)
                        unsigned int extw = ext_csd_bits[idx];
                        unsigned int caps = ext_to_hostcaps[extw];
 
+                       /*
+                        * If the bus width is still not changed,
+                        * don't try to set the default again.
+                        * Otherwise, recover from switch attempts
+                        * by switching to 1-bit bus width.
+                        */
+                       if (extw == EXT_CSD_BUS_WIDTH_1 &&
+                                       mmc->bus_width == 1) {
+                               err = 0;
+                               break;
+                       }
+
                        /*
                         * Check to make sure the card and controller support
                         * these capabilities
index c880cedb0addce6761aa67797bf19ed785a93031..dc725cb5b0d83428a6d8e6b65b180aa413f08c95 100644 (file)
@@ -134,6 +134,10 @@ static unsigned char mmc_board_init(struct mmc *mmc)
 
        pbias_lite = readl(&t2_base->pbias_lite);
        pbias_lite &= ~(PBIASLITEPWRDNZ1 | PBIASLITEPWRDNZ0);
+#ifdef CONFIG_TARGET_OMAP3_CAIRO
+       /* for cairo board, we need to set up 1.8 Volt bias level on MMC1 */
+       pbias_lite &= ~PBIASLITEVMODE0;
+#endif
        writel(pbias_lite, &t2_base->pbias_lite);
 
        writel(pbias_lite | PBIASLITEPWRDNZ1 |
index a5d34876bbb6d7633f4a8f3dac3c9f21a6b82753..3899372e0e44a82ab9df970fb95e0292fbc19d29 100644 (file)
@@ -102,17 +102,14 @@ struct sdhci_host sdhci_host[SDHCI_MAX_HOSTS];
 
 static int do_sdhci_init(struct sdhci_host *host)
 {
-       char str[20];
        int dev_id, flag;
        int err = 0;
 
        flag = host->bus_width == 8 ? PINMUX_FLAG_8BIT_MODE : PINMUX_FLAG_NONE;
        dev_id = host->index + PERIPH_ID_SDMMC0;
 
-       if (fdt_gpio_isvalid(&host->pwr_gpio)) {
-               sprintf(str, "sdhci%d_power", host->index & 0xf);
-               gpio_request(host->pwr_gpio.gpio, str);
-               gpio_direction_output(host->pwr_gpio.gpio, 1);
+       if (dm_gpio_is_valid(&host->pwr_gpio)) {
+               dm_gpio_set_value(&host->pwr_gpio, 1);
                err = exynos_pinmux_config(dev_id, flag);
                if (err) {
                        debug("MMC not configured\n");
@@ -120,11 +117,8 @@ static int do_sdhci_init(struct sdhci_host *host)
                }
        }
 
-       if (fdt_gpio_isvalid(&host->cd_gpio)) {
-               sprintf(str, "sdhci%d_cd", host->index & 0xf);
-               gpio_request(host->cd_gpio.gpio, str);
-               gpio_direction_input(host->cd_gpio.gpio);
-               if (gpio_get_value(host->cd_gpio.gpio))
+       if (dm_gpio_is_valid(&host->cd_gpio)) {
+               if (dm_gpio_get_value(&host->cd_gpio))
                        return -ENODEV;
 
                err = exynos_pinmux_config(dev_id, flag);
@@ -166,8 +160,10 @@ static int sdhci_get_config(const void *blob, int node, struct sdhci_host *host)
        }
        host->ioaddr = (void *)base;
 
-       fdtdec_decode_gpio(blob, node, "pwr-gpios", &host->pwr_gpio);
-       fdtdec_decode_gpio(blob, node, "cd-gpios", &host->cd_gpio);
+       gpio_request_by_name_nodev(blob, node, "pwr-gpios", 0, &host->pwr_gpio,
+                                  GPIOD_IS_OUT);
+       gpio_request_by_name_nodev(blob, node, "cd-gpios", 0, &host->cd_gpio,
+                                  GPIOD_IS_IN);
 
        return 0;
 }
diff --git a/drivers/mmc/sh_sdhi.c b/drivers/mmc/sh_sdhi.c
new file mode 100644 (file)
index 0000000..cc62c89
--- /dev/null
@@ -0,0 +1,695 @@
+/*
+ * drivers/mmc/sh_sdhi.c
+ *
+ * SD/MMC driver for Renesas rmobile ARM SoCs.
+ *
+ * Copyright (C) 2011,2013-2014 Renesas Electronics Corporation
+ * Copyright (C) 2014 Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
+ * Copyright (C) 2008-2009 Renesas Solutions Corp.
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#include <common.h>
+#include <malloc.h>
+#include <mmc.h>
+#include <asm/errno.h>
+#include <asm/io.h>
+#include <asm/arch/rmobile.h>
+#include <asm/arch/sh_sdhi.h>
+
+#define DRIVER_NAME "sh-sdhi"
+
+struct sh_sdhi_host {
+       unsigned long addr;
+       int ch;
+       int bus_shift;
+       unsigned long quirks;
+       unsigned char wait_int;
+       unsigned char sd_error;
+       unsigned char detect_waiting;
+};
+static inline void sh_sdhi_writew(struct sh_sdhi_host *host, int reg, u16 val)
+{
+       writew(val, host->addr + (reg << host->bus_shift));
+}
+
+static inline u16 sh_sdhi_readw(struct sh_sdhi_host *host, int reg)
+{
+       return readw(host->addr + (reg << host->bus_shift));
+}
+
+static void *mmc_priv(struct mmc *mmc)
+{
+       return (void *)mmc->priv;
+}
+
+static void sh_sdhi_detect(struct sh_sdhi_host *host)
+{
+       sh_sdhi_writew(host, SDHI_OPTION,
+                      OPT_BUS_WIDTH_1 | sh_sdhi_readw(host, SDHI_OPTION));
+
+       host->detect_waiting = 0;
+}
+
+static int sh_sdhi_intr(void *dev_id)
+{
+       struct sh_sdhi_host *host = dev_id;
+       int state1 = 0, state2 = 0;
+
+       state1 = sh_sdhi_readw(host, SDHI_INFO1);
+       state2 = sh_sdhi_readw(host, SDHI_INFO2);
+
+       debug("%s: state1 = %x, state2 = %x\n", __func__, state1, state2);
+
+       /* CARD Insert */
+       if (state1 & INFO1_CARD_IN) {
+               sh_sdhi_writew(host, SDHI_INFO1, ~INFO1_CARD_IN);
+               if (!host->detect_waiting) {
+                       host->detect_waiting = 1;
+                       sh_sdhi_detect(host);
+               }
+               sh_sdhi_writew(host, SDHI_INFO1_MASK, INFO1M_RESP_END |
+                              INFO1M_ACCESS_END | INFO1M_CARD_IN |
+                              INFO1M_DATA3_CARD_RE | INFO1M_DATA3_CARD_IN);
+               return -EAGAIN;
+       }
+       /* CARD Removal */
+       if (state1 & INFO1_CARD_RE) {
+               sh_sdhi_writew(host, SDHI_INFO1, ~INFO1_CARD_RE);
+               if (!host->detect_waiting) {
+                       host->detect_waiting = 1;
+                       sh_sdhi_detect(host);
+               }
+               sh_sdhi_writew(host, SDHI_INFO1_MASK, INFO1M_RESP_END |
+                              INFO1M_ACCESS_END | INFO1M_CARD_RE |
+                              INFO1M_DATA3_CARD_RE | INFO1M_DATA3_CARD_IN);
+               sh_sdhi_writew(host, SDHI_SDIO_INFO1_MASK, SDIO_INFO1M_ON);
+               sh_sdhi_writew(host, SDHI_SDIO_MODE, SDIO_MODE_OFF);
+               return -EAGAIN;
+       }
+
+       if (state2 & INFO2_ALL_ERR) {
+               sh_sdhi_writew(host, SDHI_INFO2,
+                              (unsigned short)~(INFO2_ALL_ERR));
+               sh_sdhi_writew(host, SDHI_INFO2_MASK,
+                              INFO2M_ALL_ERR |
+                              sh_sdhi_readw(host, SDHI_INFO2_MASK));
+               host->sd_error = 1;
+               host->wait_int = 1;
+               return 0;
+       }
+       /* Respons End */
+       if (state1 & INFO1_RESP_END) {
+               sh_sdhi_writew(host, SDHI_INFO1, ~INFO1_RESP_END);
+               sh_sdhi_writew(host, SDHI_INFO1_MASK,
+                              INFO1M_RESP_END |
+                              sh_sdhi_readw(host, SDHI_INFO1_MASK));
+               host->wait_int = 1;
+               return 0;
+       }
+       /* SD_BUF Read Enable */
+       if (state2 & INFO2_BRE_ENABLE) {
+               sh_sdhi_writew(host, SDHI_INFO2, ~INFO2_BRE_ENABLE);
+               sh_sdhi_writew(host, SDHI_INFO2_MASK,
+                              INFO2M_BRE_ENABLE | INFO2M_BUF_ILL_READ |
+                              sh_sdhi_readw(host, SDHI_INFO2_MASK));
+               host->wait_int = 1;
+               return 0;
+       }
+       /* SD_BUF Write Enable */
+       if (state2 & INFO2_BWE_ENABLE) {
+               sh_sdhi_writew(host, SDHI_INFO2, ~INFO2_BWE_ENABLE);
+               sh_sdhi_writew(host, SDHI_INFO2_MASK,
+                              INFO2_BWE_ENABLE | INFO2M_BUF_ILL_WRITE |
+                              sh_sdhi_readw(host, SDHI_INFO2_MASK));
+               host->wait_int = 1;
+               return 0;
+       }
+       /* Access End */
+       if (state1 & INFO1_ACCESS_END) {
+               sh_sdhi_writew(host, SDHI_INFO1, ~INFO1_ACCESS_END);
+               sh_sdhi_writew(host, SDHI_INFO1_MASK,
+                              INFO1_ACCESS_END |
+                              sh_sdhi_readw(host, SDHI_INFO1_MASK));
+               host->wait_int = 1;
+               return 0;
+       }
+       return -EAGAIN;
+}
+
+static int sh_sdhi_wait_interrupt_flag(struct sh_sdhi_host *host)
+{
+       int timeout = 10000000;
+
+       while (1) {
+               timeout--;
+               if (timeout < 0) {
+                       debug(DRIVER_NAME": %s timeout\n", __func__);
+                       return 0;
+               }
+
+               if (!sh_sdhi_intr(host))
+                       break;
+
+               udelay(1);      /* 1 usec */
+       }
+
+       return 1; /* Return value: NOT 0 = complete waiting */
+}
+
+static int sh_sdhi_clock_control(struct sh_sdhi_host *host, unsigned long clk)
+{
+       u32 clkdiv, i, timeout;
+
+       if (sh_sdhi_readw(host, SDHI_INFO2) & (1 << 14)) {
+               printf(DRIVER_NAME": Busy state ! Cannot change the clock\n");
+               return -EBUSY;
+       }
+
+       sh_sdhi_writew(host, SDHI_CLK_CTRL,
+                      ~CLK_ENABLE & sh_sdhi_readw(host, SDHI_CLK_CTRL));
+
+       if (clk == 0)
+               return -EIO;
+
+       clkdiv = 0x80;
+       i = CONFIG_SH_SDHI_FREQ >> (0x8 + 1);
+       for (; clkdiv && clk >= (i << 1); (clkdiv >>= 1))
+               i <<= 1;
+
+       sh_sdhi_writew(host, SDHI_CLK_CTRL, clkdiv);
+
+       timeout = 100000;
+       /* Waiting for SD Bus busy to be cleared */
+       while (timeout--) {
+               if ((sh_sdhi_readw(host, SDHI_INFO2) & 0x2000))
+                       break;
+       }
+
+       if (timeout)
+               sh_sdhi_writew(host, SDHI_CLK_CTRL,
+                              CLK_ENABLE | sh_sdhi_readw(host, SDHI_CLK_CTRL));
+       else
+               return -EBUSY;
+
+       return 0;
+}
+
+static int sh_sdhi_sync_reset(struct sh_sdhi_host *host)
+{
+       u32 timeout;
+       sh_sdhi_writew(host, SDHI_SOFT_RST, SOFT_RST_ON);
+       sh_sdhi_writew(host, SDHI_SOFT_RST, SOFT_RST_OFF);
+       sh_sdhi_writew(host, SDHI_CLK_CTRL,
+                      CLK_ENABLE | sh_sdhi_readw(host, SDHI_CLK_CTRL));
+
+       timeout = 100000;
+       while (timeout--) {
+               if (!(sh_sdhi_readw(host, SDHI_INFO2) & INFO2_CBUSY))
+                       break;
+               udelay(100);
+       }
+
+       if (!timeout)
+               return -EBUSY;
+
+       if (host->quirks & SH_SDHI_QUIRK_16BIT_BUF)
+               sh_sdhi_writew(host, SDHI_HOST_MODE, 1);
+
+       return 0;
+}
+
+static int sh_sdhi_error_manage(struct sh_sdhi_host *host)
+{
+       unsigned short e_state1, e_state2;
+       int ret;
+
+       host->sd_error = 0;
+       host->wait_int = 0;
+
+       e_state1 = sh_sdhi_readw(host, SDHI_ERR_STS1);
+       e_state2 = sh_sdhi_readw(host, SDHI_ERR_STS2);
+       if (e_state2 & ERR_STS2_SYS_ERROR) {
+               if (e_state2 & ERR_STS2_RES_STOP_TIMEOUT)
+                       ret = TIMEOUT;
+               else
+                       ret = -EILSEQ;
+               debug("%s: ERR_STS2 = %04x\n",
+                     DRIVER_NAME, sh_sdhi_readw(host, SDHI_ERR_STS2));
+               sh_sdhi_sync_reset(host);
+
+               sh_sdhi_writew(host, SDHI_INFO1_MASK,
+                              INFO1M_DATA3_CARD_RE | INFO1M_DATA3_CARD_IN);
+               return ret;
+       }
+       if (e_state1 & ERR_STS1_CRC_ERROR || e_state1 & ERR_STS1_CMD_ERROR)
+               ret = -EILSEQ;
+       else
+               ret = TIMEOUT;
+
+       debug("%s: ERR_STS1 = %04x\n",
+             DRIVER_NAME, sh_sdhi_readw(host, SDHI_ERR_STS1));
+       sh_sdhi_sync_reset(host);
+       sh_sdhi_writew(host, SDHI_INFO1_MASK,
+                      INFO1M_DATA3_CARD_RE | INFO1M_DATA3_CARD_IN);
+       return ret;
+}
+
+static int sh_sdhi_single_read(struct sh_sdhi_host *host, struct mmc_data *data)
+{
+       long time;
+       unsigned short blocksize, i;
+       unsigned short *p = (unsigned short *)data->dest;
+
+       if ((unsigned long)p & 0x00000001) {
+               debug(DRIVER_NAME": %s: The data pointer is unaligned.",
+                     __func__);
+               return -EIO;
+       }
+
+       host->wait_int = 0;
+       sh_sdhi_writew(host, SDHI_INFO2_MASK,
+                      ~(INFO2M_BRE_ENABLE | INFO2M_BUF_ILL_READ) &
+                      sh_sdhi_readw(host, SDHI_INFO2_MASK));
+       sh_sdhi_writew(host, SDHI_INFO1_MASK,
+                      ~INFO1M_ACCESS_END &
+                      sh_sdhi_readw(host, SDHI_INFO1_MASK));
+       time = sh_sdhi_wait_interrupt_flag(host);
+       if (time == 0 || host->sd_error != 0)
+               return sh_sdhi_error_manage(host);
+
+       host->wait_int = 0;
+       blocksize = sh_sdhi_readw(host, SDHI_SIZE);
+       for (i = 0; i < blocksize / 2; i++)
+               *p++ = sh_sdhi_readw(host, SDHI_BUF0);
+
+       time = sh_sdhi_wait_interrupt_flag(host);
+       if (time == 0 || host->sd_error != 0)
+               return sh_sdhi_error_manage(host);
+
+       host->wait_int = 0;
+       return 0;
+}
+
+static int sh_sdhi_multi_read(struct sh_sdhi_host *host, struct mmc_data *data)
+{
+       long time;
+       unsigned short blocksize, i, sec;
+       unsigned short *p = (unsigned short *)data->dest;
+
+       if ((unsigned long)p & 0x00000001) {
+               debug(DRIVER_NAME": %s: The data pointer is unaligned.",
+                     __func__);
+               return -EIO;
+       }
+
+       debug("%s: blocks = %d, blocksize = %d\n",
+             __func__, data->blocks, data->blocksize);
+
+       host->wait_int = 0;
+       for (sec = 0; sec < data->blocks; sec++) {
+               sh_sdhi_writew(host, SDHI_INFO2_MASK,
+                              ~(INFO2M_BRE_ENABLE | INFO2M_BUF_ILL_READ) &
+                              sh_sdhi_readw(host, SDHI_INFO2_MASK));
+
+               time = sh_sdhi_wait_interrupt_flag(host);
+               if (time == 0 || host->sd_error != 0)
+                       return sh_sdhi_error_manage(host);
+
+               host->wait_int = 0;
+               blocksize = sh_sdhi_readw(host, SDHI_SIZE);
+               for (i = 0; i < blocksize / 2; i++)
+                       *p++ = sh_sdhi_readw(host, SDHI_BUF0);
+       }
+
+       return 0;
+}
+
+static int sh_sdhi_single_write(struct sh_sdhi_host *host,
+               struct mmc_data *data)
+{
+       long time;
+       unsigned short blocksize, i;
+       const unsigned short *p = (const unsigned short *)data->src;
+
+       if ((unsigned long)p & 0x00000001) {
+               debug(DRIVER_NAME": %s: The data pointer is unaligned.",
+                     __func__);
+               return -EIO;
+       }
+
+       debug("%s: blocks = %d, blocksize = %d\n",
+             __func__, data->blocks, data->blocksize);
+
+       host->wait_int = 0;
+       sh_sdhi_writew(host, SDHI_INFO2_MASK,
+                      ~(INFO2M_BWE_ENABLE | INFO2M_BUF_ILL_WRITE) &
+                      sh_sdhi_readw(host, SDHI_INFO2_MASK));
+       sh_sdhi_writew(host, SDHI_INFO1_MASK,
+                      ~INFO1M_ACCESS_END &
+                      sh_sdhi_readw(host, SDHI_INFO1_MASK));
+
+       time = sh_sdhi_wait_interrupt_flag(host);
+       if (time == 0 || host->sd_error != 0)
+               return sh_sdhi_error_manage(host);
+
+       host->wait_int = 0;
+       blocksize = sh_sdhi_readw(host, SDHI_SIZE);
+       for (i = 0; i < blocksize / 2; i++)
+               sh_sdhi_writew(host, SDHI_BUF0, *p++);
+
+       time = sh_sdhi_wait_interrupt_flag(host);
+       if (time == 0 || host->sd_error != 0)
+               return sh_sdhi_error_manage(host);
+
+       host->wait_int = 0;
+       return 0;
+}
+
+static int sh_sdhi_multi_write(struct sh_sdhi_host *host, struct mmc_data *data)
+{
+       long time;
+       unsigned short i, sec, blocksize;
+       const unsigned short *p = (const unsigned short *)data->src;
+
+       debug("%s: blocks = %d, blocksize = %d\n",
+             __func__, data->blocks, data->blocksize);
+
+       host->wait_int = 0;
+       for (sec = 0; sec < data->blocks; sec++) {
+               sh_sdhi_writew(host, SDHI_INFO2_MASK,
+                              ~(INFO2M_BWE_ENABLE | INFO2M_BUF_ILL_WRITE) &
+                              sh_sdhi_readw(host, SDHI_INFO2_MASK));
+
+               time = sh_sdhi_wait_interrupt_flag(host);
+               if (time == 0 || host->sd_error != 0)
+                       return sh_sdhi_error_manage(host);
+
+               host->wait_int = 0;
+               blocksize = sh_sdhi_readw(host, SDHI_SIZE);
+               for (i = 0; i < blocksize / 2; i++)
+                       sh_sdhi_writew(host, SDHI_BUF0, *p++);
+       }
+
+       return 0;
+}
+
+static void sh_sdhi_get_response(struct sh_sdhi_host *host, struct mmc_cmd *cmd)
+{
+       unsigned short i, j, cnt = 1;
+       unsigned short resp[8];
+       unsigned long *p1, *p2;
+
+       if (cmd->resp_type & MMC_RSP_136) {
+               cnt = 4;
+               resp[0] = sh_sdhi_readw(host, SDHI_RSP00);
+               resp[1] = sh_sdhi_readw(host, SDHI_RSP01);
+               resp[2] = sh_sdhi_readw(host, SDHI_RSP02);
+               resp[3] = sh_sdhi_readw(host, SDHI_RSP03);
+               resp[4] = sh_sdhi_readw(host, SDHI_RSP04);
+               resp[5] = sh_sdhi_readw(host, SDHI_RSP05);
+               resp[6] = sh_sdhi_readw(host, SDHI_RSP06);
+               resp[7] = sh_sdhi_readw(host, SDHI_RSP07);
+
+               /* SDHI REGISTER SPECIFICATION */
+               for (i = 7, j = 6; i > 0; i--) {
+                       resp[i] = (resp[i] << 8) & 0xff00;
+                       resp[i] |= (resp[j--] >> 8) & 0x00ff;
+               }
+               resp[0] = (resp[0] << 8) & 0xff00;
+
+               /* SDHI REGISTER SPECIFICATION */
+               p1 = ((unsigned long *)resp) + 3;
+
+       } else {
+               resp[0] = sh_sdhi_readw(host, SDHI_RSP00);
+               resp[1] = sh_sdhi_readw(host, SDHI_RSP01);
+
+               p1 = ((unsigned long *)resp);
+       }
+
+       p2 = (unsigned long *)cmd->response;
+#if defined(__BIG_ENDIAN_BITFIELD)
+       for (i = 0; i < cnt; i++) {
+               *p2++ = ((*p1 >> 16) & 0x0000ffff) |
+                               ((*p1 << 16) & 0xffff0000);
+               p1--;
+       }
+#else
+       for (i = 0; i < cnt; i++)
+               *p2++ = *p1--;
+#endif /* __BIG_ENDIAN_BITFIELD */
+}
+
+static unsigned short sh_sdhi_set_cmd(struct sh_sdhi_host *host,
+                       struct mmc_data *data, unsigned short opc)
+{
+       switch (opc) {
+       case SD_CMD_APP_SEND_OP_COND:
+       case SD_CMD_APP_SEND_SCR:
+               opc |= SDHI_APP;
+               break;
+       case SD_CMD_APP_SET_BUS_WIDTH:
+                /* SD_APP_SET_BUS_WIDTH*/
+               if (!data)
+                       opc |= SDHI_APP;
+               else /* SD_SWITCH */
+                       opc = SDHI_SD_SWITCH;
+               break;
+       default:
+               break;
+       }
+       return opc;
+}
+
+static unsigned short sh_sdhi_data_trans(struct sh_sdhi_host *host,
+                       struct mmc_data *data, unsigned short opc)
+{
+       unsigned short ret;
+
+       switch (opc) {
+       case MMC_CMD_READ_MULTIPLE_BLOCK:
+               ret = sh_sdhi_multi_read(host, data);
+               break;
+       case MMC_CMD_WRITE_MULTIPLE_BLOCK:
+               ret = sh_sdhi_multi_write(host, data);
+               break;
+       case MMC_CMD_WRITE_SINGLE_BLOCK:
+               ret = sh_sdhi_single_write(host, data);
+               break;
+       case MMC_CMD_READ_SINGLE_BLOCK:
+       case SDHI_SD_APP_SEND_SCR:
+       case SDHI_SD_SWITCH: /* SD_SWITCH */
+               ret = sh_sdhi_single_read(host, data);
+               break;
+       default:
+               printf(DRIVER_NAME": SD: NOT SUPPORT CMD = d'%04d\n", opc);
+               ret = -EINVAL;
+               break;
+       }
+       return ret;
+}
+
+static int sh_sdhi_start_cmd(struct sh_sdhi_host *host,
+                       struct mmc_data *data, struct mmc_cmd *cmd)
+{
+       long time;
+       unsigned short opc = cmd->cmdidx;
+       int ret = 0;
+       unsigned long timeout;
+
+       debug("opc = %d, arg = %x, resp_type = %x\n",
+             opc, cmd->cmdarg, cmd->resp_type);
+
+       if (opc == MMC_CMD_STOP_TRANSMISSION) {
+               /* SDHI sends the STOP command automatically by STOP reg */
+               sh_sdhi_writew(host, SDHI_INFO1_MASK, ~INFO1M_ACCESS_END &
+                              sh_sdhi_readw(host, SDHI_INFO1_MASK));
+
+               time = sh_sdhi_wait_interrupt_flag(host);
+               if (time == 0 || host->sd_error != 0)
+                       return sh_sdhi_error_manage(host);
+
+               sh_sdhi_get_response(host, cmd);
+               return 0;
+       }
+
+       if (data) {
+               if ((opc == MMC_CMD_READ_MULTIPLE_BLOCK) ||
+                   opc == MMC_CMD_WRITE_MULTIPLE_BLOCK) {
+                       sh_sdhi_writew(host, SDHI_STOP, STOP_SEC_ENABLE);
+                       sh_sdhi_writew(host, SDHI_SECCNT, data->blocks);
+               }
+               sh_sdhi_writew(host, SDHI_SIZE, data->blocksize);
+       }
+       opc = sh_sdhi_set_cmd(host, data, opc);
+
+       /*
+        *  U-boot cannot use interrupt.
+        *  So this flag may not be clear by timing
+        */
+       sh_sdhi_writew(host, SDHI_INFO1, ~INFO1_RESP_END);
+
+       sh_sdhi_writew(host, SDHI_INFO1_MASK,
+                      INFO1M_RESP_END | sh_sdhi_readw(host, SDHI_INFO1_MASK));
+       sh_sdhi_writew(host, SDHI_ARG0,
+                      (unsigned short)(cmd->cmdarg & ARG0_MASK));
+       sh_sdhi_writew(host, SDHI_ARG1,
+                      (unsigned short)((cmd->cmdarg >> 16) & ARG1_MASK));
+
+       timeout = 100000;
+       /* Waiting for SD Bus busy to be cleared */
+       while (timeout--) {
+               if ((sh_sdhi_readw(host, SDHI_INFO2) & 0x2000))
+                       break;
+       }
+
+       sh_sdhi_writew(host, SDHI_CMD, (unsigned short)(opc & CMD_MASK));
+
+       host->wait_int = 0;
+       sh_sdhi_writew(host, SDHI_INFO1_MASK,
+                      ~INFO1M_RESP_END & sh_sdhi_readw(host, SDHI_INFO1_MASK));
+       sh_sdhi_writew(host, SDHI_INFO2_MASK,
+                      ~(INFO2M_CMD_ERROR | INFO2M_CRC_ERROR |
+                      INFO2M_END_ERROR | INFO2M_TIMEOUT |
+                      INFO2M_RESP_TIMEOUT | INFO2M_ILA) &
+                      sh_sdhi_readw(host, SDHI_INFO2_MASK));
+
+       time = sh_sdhi_wait_interrupt_flag(host);
+       if (!time)
+               return sh_sdhi_error_manage(host);
+
+       if (host->sd_error) {
+               switch (cmd->cmdidx) {
+               case MMC_CMD_ALL_SEND_CID:
+               case MMC_CMD_SELECT_CARD:
+               case SD_CMD_SEND_IF_COND:
+               case MMC_CMD_APP_CMD:
+                       ret = TIMEOUT;
+                       break;
+               default:
+                       debug(DRIVER_NAME": Cmd(d'%d) err\n", opc);
+                       debug(DRIVER_NAME": cmdidx = %d\n", cmd->cmdidx);
+                       ret = sh_sdhi_error_manage(host);
+                       break;
+               }
+               host->sd_error = 0;
+               host->wait_int = 0;
+               return ret;
+       }
+       if (sh_sdhi_readw(host, SDHI_INFO1) & INFO1_RESP_END)
+               return -EINVAL;
+
+       if (host->wait_int) {
+               sh_sdhi_get_response(host, cmd);
+               host->wait_int = 0;
+       }
+       if (data)
+               ret = sh_sdhi_data_trans(host, data, opc);
+
+       debug("ret = %d, resp = %08x, %08x, %08x, %08x\n",
+             ret, cmd->response[0], cmd->response[1],
+             cmd->response[2], cmd->response[3]);
+       return ret;
+}
+
+static int sh_sdhi_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd,
+                       struct mmc_data *data)
+{
+       struct sh_sdhi_host *host = mmc_priv(mmc);
+       int ret;
+
+       host->sd_error = 0;
+
+       ret = sh_sdhi_start_cmd(host, data, cmd);
+
+       return ret;
+}
+
+static void sh_sdhi_set_ios(struct mmc *mmc)
+{
+       int ret;
+       struct sh_sdhi_host *host = mmc_priv(mmc);
+
+       ret = sh_sdhi_clock_control(host, mmc->clock);
+       if (ret)
+               return;
+
+       if (mmc->bus_width == 4)
+               sh_sdhi_writew(host, SDHI_OPTION, ~OPT_BUS_WIDTH_1 &
+                              sh_sdhi_readw(host, SDHI_OPTION));
+       else
+               sh_sdhi_writew(host, SDHI_OPTION, OPT_BUS_WIDTH_1 |
+                              sh_sdhi_readw(host, SDHI_OPTION));
+
+       debug("clock = %d, buswidth = %d\n", mmc->clock, mmc->bus_width);
+}
+
+static int sh_sdhi_initialize(struct mmc *mmc)
+{
+       struct sh_sdhi_host *host = mmc_priv(mmc);
+       int ret = sh_sdhi_sync_reset(host);
+
+       sh_sdhi_writew(host, SDHI_PORTSEL, USE_1PORT);
+
+#if defined(__BIG_ENDIAN_BITFIELD)
+       sh_sdhi_writew(host, SDHI_EXT_SWAP, SET_SWAP);
+#endif
+
+       sh_sdhi_writew(host, SDHI_INFO1_MASK, INFO1M_RESP_END |
+                      INFO1M_ACCESS_END | INFO1M_CARD_RE |
+                      INFO1M_DATA3_CARD_RE | INFO1M_DATA3_CARD_IN);
+
+       return ret;
+}
+
+static const struct mmc_ops sh_sdhi_ops = {
+       .send_cmd       = sh_sdhi_send_cmd,
+       .set_ios        = sh_sdhi_set_ios,
+       .init           = sh_sdhi_initialize,
+};
+
+static struct mmc_config sh_sdhi_cfg = {
+       .name           = DRIVER_NAME,
+       .ops            = &sh_sdhi_ops,
+       .f_min          = CLKDEV_INIT,
+       .f_max          = CLKDEV_HS_DATA,
+       .voltages       = MMC_VDD_32_33 | MMC_VDD_33_34,
+       .host_caps      = MMC_MODE_4BIT | MMC_MODE_HS,
+       .part_type      = PART_TYPE_DOS,
+       .b_max          = CONFIG_SYS_MMC_MAX_BLK_COUNT,
+};
+
+int sh_sdhi_init(unsigned long addr, int ch, unsigned long quirks)
+{
+       int ret = 0;
+       struct mmc *mmc;
+       struct sh_sdhi_host *host = NULL;
+
+       if (ch >= CONFIG_SYS_SH_SDHI_NR_CHANNEL)
+               return -ENODEV;
+
+       host = malloc(sizeof(struct sh_sdhi_host));
+       if (!host)
+               return -ENOMEM;
+
+       mmc = mmc_create(&sh_sdhi_cfg, host);
+       if (!mmc) {
+               ret = -1;
+               goto error;
+       }
+
+       host->ch = ch;
+       host->addr = addr;
+       host->quirks = quirks;
+
+       if (host->quirks & SH_SDHI_QUIRK_16BIT_BUF)
+               host->bus_shift = 1;
+
+       return ret;
+error:
+       if (host)
+               free(host);
+       return ret;
+}
index 623498187ef0255e6fd5a647819a7bdf4477f8e3..ebfec7cf079bb6f55c53c31bb8b7e2219403ebe4 100644 (file)
@@ -89,8 +89,13 @@ static int mmc_set_mod_clk(struct sunxi_mmc_host *mmchost, unsigned int hz)
                pll = CCM_MMC_CTRL_OSCM24;
                pll_hz = 24000000;
        } else {
+#ifdef CONFIG_MACH_SUN9I
+               pll = CCM_MMC_CTRL_PLL_PERIPH0;
+               pll_hz = clock_get_pll4_periph0();
+#else
                pll = CCM_MMC_CTRL_PLL6;
                pll_hz = clock_get_pll6();
+#endif
        }
 
        div = pll_hz / hz;
@@ -146,10 +151,16 @@ static int mmc_clk_io_on(int sdc_no)
        /* config ahb clock */
        setbits_le32(&ccm->ahb_gate0, 1 << AHB_GATE_OFFSET_MMC(sdc_no));
 
-#if defined(CONFIG_MACH_SUN6I) || defined(CONFIG_MACH_SUN8I)
+#if defined(CONFIG_MACH_SUN6I) || defined(CONFIG_MACH_SUN8I) || \
+    defined(CONFIG_MACH_SUN9I)
        /* unassert reset */
        setbits_le32(&ccm->ahb_reset0_cfg, 1 << AHB_RESET_OFFSET_MMC(sdc_no));
 #endif
+#if defined(CONFIG_MACH_SUN9I)
+       /* sun9i has a mmc-common module, also set the gate and reset there */
+       writel(SUNXI_MMC_COMMON_CLK_GATE | SUNXI_MMC_COMMON_RESET,
+              SUNXI_MMC_COMMON_BASE + 4 * sdc_no);
+#endif
 
        return mmc_set_mod_clk(mmchost, 24000000);
 }
@@ -204,7 +215,7 @@ static int mmc_config_clock(struct mmc *mmc)
        return 0;
 }
 
-static void mmc_set_ios(struct mmc *mmc)
+static void sunxi_mmc_set_ios(struct mmc *mmc)
 {
        struct sunxi_mmc_host *mmchost = mmc->priv;
 
@@ -226,7 +237,7 @@ static void mmc_set_ios(struct mmc *mmc)
                writel(0x0, &mmchost->reg->width);
 }
 
-static int mmc_core_init(struct mmc *mmc)
+static int sunxi_mmc_core_init(struct mmc *mmc)
 {
        struct sunxi_mmc_host *mmchost = mmc->priv;
 
@@ -287,8 +298,8 @@ static int mmc_rint_wait(struct mmc *mmc, unsigned int timeout_msecs,
        return 0;
 }
 
-static int mmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd,
-                       struct mmc_data *data)
+static int sunxi_mmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd,
+                             struct mmc_data *data)
 {
        struct sunxi_mmc_host *mmchost = mmc->priv;
        unsigned int cmdval = SUNXI_MMC_CMD_START;
@@ -355,7 +366,7 @@ static int mmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd,
                }
        }
 
-       error = mmc_rint_wait(mmc, 0xfffff, SUNXI_MMC_RINT_COMMAND_DONE, "cmd");
+       error = mmc_rint_wait(mmc, 1000, SUNXI_MMC_RINT_COMMAND_DONE, "cmd");
        if (error)
                goto out;
 
@@ -421,9 +432,9 @@ static int sunxi_mmc_getcd(struct mmc *mmc)
 }
 
 static const struct mmc_ops sunxi_mmc_ops = {
-       .send_cmd       = mmc_send_cmd,
-       .set_ios        = mmc_set_ios,
-       .init           = mmc_core_init,
+       .send_cmd       = sunxi_mmc_send_cmd,
+       .set_ios        = sunxi_mmc_set_ios,
+       .init           = sunxi_mmc_core_init,
        .getcd          = sunxi_mmc_getcd,
 };
 
@@ -439,7 +450,8 @@ struct mmc *sunxi_mmc_init(int sdc_no)
        cfg->voltages = MMC_VDD_32_33 | MMC_VDD_33_34;
        cfg->host_caps = MMC_MODE_4BIT;
        cfg->host_caps |= MMC_MODE_HS_52MHz | MMC_MODE_HS;
-#if defined(CONFIG_MACH_SUN6I) || defined(CONFIG_MACH_SUN7I) || defined(CONFIG_MACH_SUN8I)
+#if defined(CONFIG_MACH_SUN6I) || defined(CONFIG_MACH_SUN7I) || \
+    defined(CONFIG_MACH_SUN8I) || defined(CONFIG_MACH_SUN9I)
        cfg->host_caps |= MMC_MODE_HC;
 #endif
        cfg->b_max = CONFIG_SYS_MMC_MAX_BLK_COUNT;
index 2bd36b0ee704a86308bfa0d3c7faa68cc506249a..2cd8cf10aec557cc3a3579f3e292d9ee3f686e90 100644 (file)
@@ -515,8 +515,8 @@ static int tegra_mmc_getcd(struct mmc *mmc)
 
        debug("tegra_mmc_getcd called\n");
 
-       if (fdt_gpio_isvalid(&host->cd_gpio))
-               return fdtdec_get_gpio(&host->cd_gpio);
+       if (dm_gpio_is_valid(&host->cd_gpio))
+               return dm_gpio_get_value(&host->cd_gpio);
 
        return 1;
 }
@@ -531,7 +531,6 @@ static const struct mmc_ops tegra_mmc_ops = {
 static int do_mmc_init(int dev_index)
 {
        struct mmc_host *host;
-       char gpusage[12]; /* "SD/MMCn PWR" or "SD/MMCn CD" */
        struct mmc *mmc;
 
        /* DT should have been read & host config filled in */
@@ -539,27 +538,15 @@ static int do_mmc_init(int dev_index)
        if (!host->enabled)
                return -1;
 
-       debug(" do_mmc_init: index %d, bus width %d "
-               "pwr_gpio %d cd_gpio %d\n",
-               dev_index, host->width,
-               host->pwr_gpio.gpio, host->cd_gpio.gpio);
+       debug(" do_mmc_init: index %d, bus width %d pwr_gpio %d cd_gpio %d\n",
+             dev_index, host->width, gpio_get_number(&host->pwr_gpio),
+             gpio_get_number(&host->cd_gpio));
 
        host->clock = 0;
        clock_start_periph_pll(host->mmc_id, CLOCK_ID_PERIPH, 20000000);
 
-       if (fdt_gpio_isvalid(&host->pwr_gpio)) {
-               sprintf(gpusage, "SD/MMC%d PWR", dev_index);
-               gpio_request(host->pwr_gpio.gpio, gpusage);
-               gpio_direction_output(host->pwr_gpio.gpio, 1);
-               debug(" Power GPIO name = %s\n", host->pwr_gpio.name);
-       }
-
-       if (fdt_gpio_isvalid(&host->cd_gpio)) {
-               sprintf(gpusage, "SD/MMC%d CD", dev_index);
-               gpio_request(host->cd_gpio.gpio, gpusage);
-               gpio_direction_input(host->cd_gpio.gpio);
-               debug(" CD GPIO name = %s\n", host->cd_gpio.name);
-       }
+       if (dm_gpio_is_valid(&host->pwr_gpio))
+               dm_gpio_set_value(&host->pwr_gpio, 1);
 
        memset(&host->cfg, 0, sizeof(host->cfg));
 
@@ -626,9 +613,12 @@ static int mmc_get_config(const void *blob, int node, struct mmc_host *host)
                debug("%s: no sdmmc width found\n", __func__);
 
        /* These GPIOs are optional */
-       fdtdec_decode_gpio(blob, node, "cd-gpios", &host->cd_gpio);
-       fdtdec_decode_gpio(blob, node, "wp-gpios", &host->wp_gpio);
-       fdtdec_decode_gpio(blob, node, "power-gpios", &host->pwr_gpio);
+       gpio_request_by_name_nodev(blob, node, "cd-gpios", 0, &host->cd_gpio,
+                                  GPIOD_IS_IN);
+       gpio_request_by_name_nodev(blob, node, "wp-gpios", 0, &host->wp_gpio,
+                                  GPIOD_IS_IN);
+       gpio_request_by_name_nodev(blob, node, "power-gpios", 0,
+                                  &host->pwr_gpio, GPIOD_IS_OUT);
 
        debug("%s: found controller at %p, width = %d, periph_id = %d\n",
                __func__, host->reg, host->width, host->mmc_id);
index fdce2c2c10ec85c4a291532f927eae4a0b5627c9..7887f11c649b01ae7a4565c3297f68c5f068ab18 100644 (file)
@@ -13,7 +13,7 @@
 #include <sdhci.h>
 #include <asm/arch/sys_proto.h>
 
-int zynq_sdhci_init(u32 regbase)
+int zynq_sdhci_init(phys_addr_t regbase)
 {
        struct sdhci_host *host = NULL;
 
@@ -40,7 +40,7 @@ int zynq_sdhci_of_init(const void *blob)
 {
        int offset = 0;
        u32 ret = 0;
-       u32 reg;
+       phys_addr_t reg;
 
        debug("ZYNQ SDHCI: Initialization\n");
 
index 63bdf65f82c46949bce9fc975a469d3cda86311a..6db6566e733656d55a88c024bd1b07b5c6d58c3c 100644 (file)
@@ -1065,11 +1065,6 @@ static int nand_wait(struct mtd_info *mtd, struct nand_chip *chip)
                }
        }
 #endif
-#ifdef PPCHAMELON_NAND_TIMER_HACK
-       time_start = get_timer(0);
-       while (get_timer(time_start) < 10)
-               ;
-#endif /*  PPCHAMELON_NAND_TIMER_HACK */
        led_trigger_event(nand_led_trigger, LED_OFF);
 
        status = (int)chip->read_byte(mtd);
index 163cf29a3986058cfc3472241ac2865cd5f99516..b660f3b20662dfbb427dd2770765d2acd1f6a089 100644 (file)
@@ -79,7 +79,7 @@ enum {
 struct fdt_nand {
        struct nand_ctlr *reg;
        int enabled;            /* 1 to enable, 0 to disable */
-       struct fdt_gpio_state wp_gpio;  /* write-protect GPIO */
+       struct gpio_desc wp_gpio;       /* write-protect GPIO */
        s32 width;              /* bit width, normally 8 */
        u32 timing[FDT_NAND_TIMING_COUNT];
 };
@@ -945,8 +945,8 @@ static int fdt_decode_nand(const void *blob, int node, struct fdt_nand *config)
        config->reg = (struct nand_ctlr *)fdtdec_get_addr(blob, node, "reg");
        config->enabled = fdtdec_get_is_enabled(blob, node);
        config->width = fdtdec_get_int(blob, node, "nvidia,nand-width", 8);
-       err = fdtdec_decode_gpio(blob, node, "nvidia,wp-gpios",
-                                &config->wp_gpio);
+       err = gpio_request_by_name_nodev(blob, node, "nvidia,wp-gpios", 0,
+                                &config->wp_gpio, GPIOD_IS_OUT);
        if (err)
                return err;
        err = fdtdec_get_int_array(blob, node, "nvidia,timing",
@@ -1009,8 +1009,7 @@ int tegra_nand_init(struct nand_chip *nand, int devnum)
        /* Adjust timing for NAND device */
        setup_timing(config->timing, info->reg);
 
-       fdtdec_setup_gpio(&config->wp_gpio);
-       gpio_direction_output(config->wp_gpio.gpio, 1);
+       dm_gpio_set_value(&config->wp_gpio, 1);
 
        our_mtd = &nand_info[devnum];
        our_mtd->priv = nand;
index 3024b988fef904884f4d6e4920d98859714f115c..d576d31243a7a90a7213466d7b3ce600a2d1d84f 100644 (file)
@@ -141,8 +141,10 @@ static int sandbox_sf_probe(struct udevice *dev)
                assert(bus->seq != -1);
                if (bus->seq < CONFIG_SANDBOX_SPI_MAX_BUS)
                        spec = state->spi[bus->seq][cs].spec;
-               if (!spec)
-                       return -ENOENT;
+               if (!spec) {
+                       ret = -ENOENT;
+                       goto error;
+               }
 
                file = strchr(spec, ':');
                if (!file) {
@@ -196,6 +198,7 @@ static int sandbox_sf_probe(struct udevice *dev)
        return 0;
 
  error:
+       debug("%s: Got error %d\n", __func__, ret);
        return ret;
 }
 
@@ -587,6 +590,11 @@ int sandbox_sf_bind_emul(struct sandbox_state *state, int busnum, int cs,
 
 void sandbox_sf_unbind_emul(struct sandbox_state *state, int busnum, int cs)
 {
+       struct udevice *dev;
+
+       dev = state->spi[busnum][cs].emul;
+       device_remove(dev);
+       device_unbind(dev);
        state->spi[busnum][cs].emul = NULL;
 }
 
index ce9987fd1a8770aeb8d948030a792553b511ed80..41037238590b650cfe12cfe59c2edd960170db27 100644 (file)
@@ -481,11 +481,12 @@ int spi_flash_std_erase(struct udevice *dev, u32 offset, size_t len)
 int spi_flash_std_probe(struct udevice *dev)
 {
        struct spi_slave *slave = dev_get_parentdata(dev);
+       struct dm_spi_slave_platdata *plat = dev_get_parent_platdata(dev);
        struct spi_flash *flash;
 
        flash = dev->uclass_priv;
        flash->dev = dev;
-       debug("%s: slave=%p, cs=%d\n", __func__, slave, slave->cs);
+       debug("%s: slave=%p, cs=%d\n", __func__, slave, plat->cs);
        return spi_flash_probe_slave(slave, flash);
 }
 
index 584cf5f22b38f4830ced26e6e011df1bd3115ac5..290d524b1be2577d8a9da710a8c3518cc2d1d632 100644 (file)
@@ -1358,6 +1358,10 @@ out_version:
 out_class:
        class_destroy(ubi_class);
 out:
+#ifdef __UBOOT__
+       /* Reset any globals that the driver depends on being zeroed */
+       mtd_devs = 0;
+#endif
        ubi_err("cannot initialize UBI, error %d", err);
        return err;
 }
@@ -1384,6 +1388,10 @@ void ubi_exit(void)
        misc_deregister(&ubi_ctrl_cdev);
        class_remove_file(ubi_class, &ubi_version);
        class_destroy(ubi_class);
+#ifdef __UBOOT__
+       /* Reset any globals that the driver depends on being zeroed */
+       mtd_devs = 0;
+#endif
 }
 module_exit(ubi_exit);
 
index fb0cf8c1cf172dce03a8dcea02d7522de26793a9..46c4ac697d6a6f87ae36df5788a9b69b0011de1d 100644 (file)
@@ -66,3 +66,4 @@ obj-$(CONFIG_XILINX_LL_TEMAC) += xilinx_ll_temac.o xilinx_ll_temac_mdio.o \
                xilinx_ll_temac_fifo.o xilinx_ll_temac_sdma.o
 obj-$(CONFIG_ZYNQ_GEM) += zynq_gem.o
 obj-$(CONFIG_FSL_MC_ENET) += fsl_mc/
+obj-$(CONFIG_VSC9953) += vsc9953.o
index 9ded8950b83d22aa6021ed8e81ee4141e6d85a23..c03e935e2fb7df54771bf6222b7ce816c53209b3 100644 (file)
@@ -236,8 +236,10 @@ static int dw_eth_init(struct eth_device *dev, bd_t *bis)
 
        start = get_timer(0);
        while (readl(&dma_p->busmode) & DMAMAC_SRST) {
-               if (get_timer(start) >= CONFIG_MACRESET_TIMEOUT)
+               if (get_timer(start) >= CONFIG_MACRESET_TIMEOUT) {
+                       printf("DMA reset timeout\n");
                        return -1;
+               }
 
                mdelay(100);
        };
index 6531030463cd57c643f58be1520a8f77ef60018d..cd4422215fb0fbbd43c4aefb09e0f0652df01867 100644 (file)
@@ -4927,22 +4927,23 @@ void
 fill_rx(struct e1000_hw *hw)
 {
        struct e1000_rx_desc *rd;
-       uint32_t flush_start, flush_end;
+       unsigned long flush_start, flush_end;
 
        rx_last = rx_tail;
        rd = rx_base + rx_tail;
        rx_tail = (rx_tail + 1) % 8;
        memset(rd, 0, 16);
-       rd->buffer_addr = cpu_to_le64((u32)packet);
+       rd->buffer_addr = cpu_to_le64((unsigned long)packet);
 
        /*
         * Make sure there are no stale data in WB over this area, which
         * might get written into the memory while the e1000 also writes
         * into the same memory area.
         */
-       invalidate_dcache_range((u32)packet, (u32)packet + 4096);
+       invalidate_dcache_range((unsigned long)packet,
+                               (unsigned long)packet + 4096);
        /* Dump the DMA descriptor into RAM. */
-       flush_start = ((u32)rd) & ~(ARCH_DMA_MINALIGN - 1);
+       flush_start = ((unsigned long)rd) & ~(ARCH_DMA_MINALIGN - 1);
        flush_end = flush_start + roundup(sizeof(*rd), ARCH_DMA_MINALIGN);
        flush_dcache_range(flush_start, flush_end);
 
@@ -4963,7 +4964,7 @@ e1000_configure_tx(struct e1000_hw *hw)
        unsigned long tipg, tarc;
        uint32_t ipgr1, ipgr2;
 
-       E1000_WRITE_REG(hw, TDBAL, (u32) tx_base);
+       E1000_WRITE_REG(hw, TDBAL, (unsigned long)tx_base);
        E1000_WRITE_REG(hw, TDBAH, 0);
 
        E1000_WRITE_REG(hw, TDLEN, 128);
@@ -5107,7 +5108,7 @@ e1000_configure_rx(struct e1000_hw *hw)
                E1000_WRITE_FLUSH(hw);
        }
        /* Setup the Base and Length of the Rx Descriptor Ring */
-       E1000_WRITE_REG(hw, RDBAL, (u32) rx_base);
+       E1000_WRITE_REG(hw, RDBAL, (unsigned long)rx_base);
        E1000_WRITE_REG(hw, RDBAH, 0);
 
        E1000_WRITE_REG(hw, RDLEN, 128);
@@ -5138,14 +5139,14 @@ e1000_poll(struct eth_device *nic)
 {
        struct e1000_hw *hw = nic->priv;
        struct e1000_rx_desc *rd;
-       uint32_t inval_start, inval_end;
+       unsigned long inval_start, inval_end;
        uint32_t len;
 
        /* return true if there's an ethernet packet ready to read */
        rd = rx_base + rx_last;
 
        /* Re-load the descriptor from RAM. */
-       inval_start = ((u32)rd) & ~(ARCH_DMA_MINALIGN - 1);
+       inval_start = ((unsigned long)rd) & ~(ARCH_DMA_MINALIGN - 1);
        inval_end = inval_start + roundup(sizeof(*rd), ARCH_DMA_MINALIGN);
        invalidate_dcache_range(inval_start, inval_end);
 
@@ -5154,8 +5155,9 @@ e1000_poll(struct eth_device *nic)
        /*DEBUGOUT("recv: packet len=%d \n", rd->length); */
        /* Packet received, make sure the data are re-loaded from RAM. */
        len = le32_to_cpu(rd->length);
-       invalidate_dcache_range((u32)packet,
-                               (u32)packet + roundup(len, ARCH_DMA_MINALIGN));
+       invalidate_dcache_range((unsigned long)packet,
+                               (unsigned long)packet +
+                               roundup(len, ARCH_DMA_MINALIGN));
        NetReceive((uchar *)packet, len);
        fill_rx(hw);
        return 1;
@@ -5170,7 +5172,7 @@ static int e1000_transmit(struct eth_device *nic, void *txpacket, int length)
        struct e1000_hw *hw = nic->priv;
        struct e1000_tx_desc *txp;
        int i = 0;
-       uint32_t flush_start, flush_end;
+       unsigned long flush_start, flush_end;
 
        txp = tx_base + tx_tail;
        tx_tail = (tx_tail + 1) % 8;
@@ -5180,10 +5182,11 @@ static int e1000_transmit(struct eth_device *nic, void *txpacket, int length)
        txp->upper.data = 0;
 
        /* Dump the packet into RAM so e1000 can pick them. */
-       flush_dcache_range((u32)nv_packet,
-                          (u32)nv_packet + roundup(length, ARCH_DMA_MINALIGN));
+       flush_dcache_range((unsigned long)nv_packet,
+                          (unsigned long)nv_packet +
+                          roundup(length, ARCH_DMA_MINALIGN));
        /* Dump the descriptor into RAM as well. */
-       flush_start = ((u32)txp) & ~(ARCH_DMA_MINALIGN - 1);
+       flush_start = ((unsigned long)txp) & ~(ARCH_DMA_MINALIGN - 1);
        flush_end = flush_start + roundup(sizeof(*txp), ARCH_DMA_MINALIGN);
        flush_dcache_range(flush_start, flush_end);
 
index f1e39b982a2a01091715581ac7280370a8a41c03..1d1089d0173df0c25697044d159e5c5d23afac2b 100644 (file)
@@ -410,10 +410,15 @@ static int fm_eth_open(struct eth_device *dev, bd_t *bd)
        fmc_tx_port_graceful_stop_disable(fm_eth);
 
 #ifdef CONFIG_PHYLIB
-       ret = phy_startup(fm_eth->phydev);
-       if (ret) {
-               printf("%s: Could not initialize\n", fm_eth->phydev->dev->name);
-               return ret;
+       if (fm_eth->phydev) {
+               ret = phy_startup(fm_eth->phydev);
+               if (ret) {
+                       printf("%s: Could not initialize\n",
+                              fm_eth->phydev->dev->name);
+                       return ret;
+               }
+       } else {
+               return 0;
        }
 #else
        fm_eth->phydev->speed = SPEED_1000;
@@ -447,7 +452,8 @@ static void fm_eth_halt(struct eth_device *dev)
        /* disable bmi Rx port */
        bmi_rx_port_disable(fm_eth->rx_port);
 
-       phy_shutdown(fm_eth->phydev);
+       if (fm_eth->phydev)
+               phy_shutdown(fm_eth->phydev);
 }
 
 static int fm_eth_send(struct eth_device *dev, void *buf, int len)
@@ -625,11 +631,12 @@ static int init_phy(struct eth_device *dev)
        if (fm_eth->bus) {
                phydev = phy_connect(fm_eth->bus, fm_eth->phyaddr, dev,
                                        fm_eth->enet_if);
-       }
-
-       if (!phydev) {
-               printf("Failed to connect\n");
-               return -1;
+               if (!phydev) {
+                       printf("Failed to connect\n");
+                       return -1;
+               }
+       } else {
+               return 0;
        }
 
        if (fm_eth->type == FM_ETH_1G_E) {
@@ -711,8 +718,7 @@ int fm_eth_initialize(struct ccsr_fman *reg, struct fm_eth_info *info)
        if (!fm_eth_startup(fm_eth))
                return 0;
 
-       if (init_phy(dev))
-               return 0;
+       init_phy(dev);
 
        /* clear the ethernet address */
        for (i = 0; i < 6; i++)
index d2a097e0e55d0facd9ed1e1e290f27cc60a4cb09..04583661eceb496920999920e7d4de7ed30e40b4 100644 (file)
@@ -50,7 +50,8 @@ phy_interface_t fman_port_enet_if(enum fm_port port)
        switch (port) {
        case FM1_DTSEC1:
        case FM1_DTSEC2:
-               if (is_serdes_configured(QSGMII_SW1_A + port - FM1_DTSEC1))
+               if (is_serdes_configured(QSGMII_SW1_A + port - FM1_DTSEC1) ||
+                   is_serdes_configured(SGMII_SW1_MAC1  + port - FM1_DTSEC1))
                        return PHY_INTERFACE_MODE_QSGMII;
        case FM1_DTSEC3:
        case FM1_DTSEC4:
index d9d6f4f28b932ca0c8664867a3e7155c20d42af6..d2a8ae0868dfed69f30234824bffdfe3722eac4f 100644 (file)
@@ -407,13 +407,8 @@ static int mpc5xxx_fec_init_phy(struct eth_device *dev, bd_t * bis)
         */
        if (fec->xcv_type == SEVENWIRE) {
                /*  10MBit with 7-wire operation */
-#if defined(CONFIG_TOTAL5200)
-               /* 7-wire and USB2 on Ethernet */
-               *(vu_long *)MPC5XXX_GPS_PORT_CONFIG |= 0x00030000;
-#else  /* !CONFIG_TOTAL5200 */
                /* 7-wire only */
                *(vu_long *)MPC5XXX_GPS_PORT_CONFIG |= 0x00020000;
-#endif /* CONFIG_TOTAL5200 */
        } else {
                /* 100MBit with MD operation */
                *(vu_long *)MPC5XXX_GPS_PORT_CONFIG |= 0x00050000;
index 6ef6cacb6b87940421bae8d78085eb0ebb5a6e0d..6b31a82ec40204ba60791308878900a903b9179e 100644 (file)
 
 DECLARE_GLOBAL_DATA_PTR;
 
+#ifndef CONFIG_MVGBE_PORTS
+# define CONFIG_MVGBE_PORTS {0, 0}
+#endif
+
 #define MV_PHY_ADR_REQUEST 0xee
 #define MVGBE_SMI_REG (((struct mvgbe_registers *)MVGBE0_BASE)->smi)
 
index f46bf00abe459bc726eaca97b963c7dc84ec3107..d096db87a2766a6c02c2bbb984071f71533f17e3 100644 (file)
@@ -11,6 +11,7 @@ obj-$(CONFIG_MV88E6352_SWITCH) += mv88e6352.o
 
 obj-$(CONFIG_PHYLIB) += phy.o
 obj-$(CONFIG_PHYLIB_10G) += generic_10g.o
+obj-$(CONFIG_PHY_AQUANTIA) += aquantia.o
 obj-$(CONFIG_PHY_ATHEROS) += atheros.o
 obj-$(CONFIG_PHY_BROADCOM) += broadcom.o
 obj-$(CONFIG_PHY_CORTINA) += cortina.o
diff --git a/drivers/net/phy/aquantia.c b/drivers/net/phy/aquantia.c
new file mode 100644 (file)
index 0000000..ef4da4e
--- /dev/null
@@ -0,0 +1,156 @@
+/*
+ * Aquantia PHY drivers
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ *
+ * Copyright 2014 Freescale Semiconductor, Inc.
+ */
+#include <config.h>
+#include <common.h>
+#include <phy.h>
+
+#ifndef CONFIG_PHYLIB_10G
+#error The Aquantia PHY needs 10G support
+#endif
+
+#define AQUNTIA_10G_CTL                0x20
+#define AQUNTIA_VENDOR_P1      0xc400
+
+#define AQUNTIA_SPEED_LSB_MASK 0x2000
+#define AQUNTIA_SPEED_MSB_MASK 0x40
+
+int aquantia_config(struct phy_device *phydev)
+{
+       u32 val = phy_read(phydev, MDIO_MMD_PMAPMD, MII_BMCR);
+
+       if (phydev->interface == PHY_INTERFACE_MODE_SGMII) {
+               /* 1000BASE-T mode */
+               phydev->advertising = SUPPORTED_1000baseT_Full;
+               phydev->supported = phydev->advertising;
+
+               val = (val & ~AQUNTIA_SPEED_LSB_MASK) | AQUNTIA_SPEED_MSB_MASK;
+               phy_write(phydev, MDIO_MMD_PMAPMD, MII_BMCR, val);
+       } else if (phydev->interface == PHY_INTERFACE_MODE_XGMII) {
+               /* 10GBASE-T mode */
+               phydev->advertising = SUPPORTED_10000baseT_Full;
+               phydev->supported = phydev->advertising;
+
+               if (!(val & AQUNTIA_SPEED_LSB_MASK) ||
+                   !(val & AQUNTIA_SPEED_MSB_MASK))
+                       phy_write(phydev, MDIO_MMD_PMAPMD, MII_BMCR,
+                                 AQUNTIA_SPEED_LSB_MASK |
+                                 AQUNTIA_SPEED_MSB_MASK);
+       } else if (phydev->interface == PHY_INTERFACE_MODE_SGMII_2500) {
+               /* 2.5GBASE-T mode */
+               phydev->advertising = SUPPORTED_1000baseT_Full;
+               phydev->supported = phydev->advertising;
+
+               phy_write(phydev, MDIO_MMD_AN, AQUNTIA_10G_CTL, 1);
+               phy_write(phydev, MDIO_MMD_AN, AQUNTIA_VENDOR_P1, 0x9440);
+       } else if (phydev->interface == PHY_INTERFACE_MODE_MII) {
+               /* 100BASE-TX mode */
+               phydev->advertising = SUPPORTED_100baseT_Full;
+               phydev->supported = phydev->advertising;
+
+               val = (val & ~AQUNTIA_SPEED_MSB_MASK) | AQUNTIA_SPEED_LSB_MASK;
+               phy_write(phydev, MDIO_MMD_PMAPMD, MII_BMCR, val);
+       }
+       return 0;
+}
+
+int aquantia_startup(struct phy_device *phydev)
+{
+       u32 reg, speed;
+       int i = 0;
+
+       phydev->duplex = DUPLEX_FULL;
+
+       /* if the AN is still in progress, wait till timeout. */
+       phy_read(phydev, MDIO_MMD_AN, MDIO_STAT1);
+       reg = phy_read(phydev, MDIO_MMD_AN, MDIO_STAT1);
+       if (!(reg & MDIO_AN_STAT1_COMPLETE)) {
+               printf("%s Waiting for PHY auto negotiation to complete",
+                      phydev->dev->name);
+               do {
+                       udelay(1000);
+                       reg = phy_read(phydev, MDIO_MMD_AN, MDIO_STAT1);
+                       if ((i++ % 500) == 0)
+                               printf(".");
+               } while (!(reg & MDIO_AN_STAT1_COMPLETE) &&
+                        i < (4 * PHY_ANEG_TIMEOUT));
+
+               if (i > PHY_ANEG_TIMEOUT)
+                       printf(" TIMEOUT !\n");
+       }
+
+       /* Read twice because link state is latched and a
+        * read moves the current state into the register */
+       phy_read(phydev, MDIO_MMD_AN, MDIO_STAT1);
+       reg = phy_read(phydev, MDIO_MMD_AN, MDIO_STAT1);
+       if (reg < 0 || !(reg & MDIO_STAT1_LSTATUS))
+               phydev->link = 0;
+       else
+               phydev->link = 1;
+
+       speed = phy_read(phydev, MDIO_MMD_PMAPMD, MII_BMCR);
+       if (speed & AQUNTIA_SPEED_MSB_MASK) {
+               if (speed & AQUNTIA_SPEED_LSB_MASK)
+                       phydev->speed = SPEED_10000;
+               else
+                       phydev->speed = SPEED_1000;
+       } else {
+               if (speed & AQUNTIA_SPEED_LSB_MASK)
+                       phydev->speed = SPEED_100;
+               else
+                       phydev->speed = SPEED_10;
+       }
+
+       return 0;
+}
+
+struct phy_driver aq1202_driver = {
+       .name = "Aquantia AQ1202",
+       .uid = 0x3a1b445,
+       .mask = 0xfffffff0,
+       .features = PHY_10G_FEATURES,
+       .mmds = (MDIO_MMD_PMAPMD | MDIO_MMD_PCS|
+                       MDIO_MMD_PHYXS | MDIO_MMD_AN |
+                       MDIO_MMD_VEND1),
+       .config = &aquantia_config,
+       .startup = &aquantia_startup,
+       .shutdown = &gen10g_shutdown,
+};
+
+struct phy_driver aq2104_driver = {
+       .name = "Aquantia AQ2104",
+       .uid = 0x3a1b460,
+       .mask = 0xfffffff0,
+       .features = PHY_10G_FEATURES,
+       .mmds = (MDIO_MMD_PMAPMD | MDIO_MMD_PCS|
+                       MDIO_MMD_PHYXS | MDIO_MMD_AN |
+                       MDIO_MMD_VEND1),
+       .config = &aquantia_config,
+       .startup = &aquantia_startup,
+       .shutdown = &gen10g_shutdown,
+};
+
+struct phy_driver aqr105_driver = {
+       .name = "Aquantia AQR105",
+       .uid = 0x3a1b4a2,
+       .mask = 0xfffffff0,
+       .features = PHY_10G_FEATURES,
+       .mmds = (MDIO_MMD_PMAPMD | MDIO_MMD_PCS|
+                       MDIO_MMD_PHYXS | MDIO_MMD_AN |
+                       MDIO_MMD_VEND1),
+       .config = &aquantia_config,
+       .startup = &aquantia_startup,
+       .shutdown = &gen10g_shutdown,
+};
+int phy_aquantia_init(void)
+{
+       phy_register(&aq1202_driver);
+       phy_register(&aq2104_driver);
+       phy_register(&aqr105_driver);
+
+       return 0;
+}
index 507b9a368be72e6d24fea6da9f169cbc2c4cb579..1815b2900ddb2ad1ec80cb9d521bda1ddaa323de 100644 (file)
@@ -22,6 +22,63 @@ static struct phy_driver KSZ804_driver = {
        .shutdown = &genphy_shutdown,
 };
 
+/**
+ * KSZ8895
+ */
+
+static unsigned short smireg_to_phy(unsigned short reg)
+{
+       return ((reg & 0xc0) >> 3) + 0x06 + ((reg & 0x20) >> 5);
+}
+
+static unsigned short smireg_to_reg(unsigned short reg)
+{
+       return reg & 0x1F;
+}
+
+static void ksz8895_write_smireg(struct phy_device *phydev, int smireg, int val)
+{
+       phydev->bus->write(phydev->bus, smireg_to_phy(smireg), MDIO_DEVAD_NONE,
+                                               smireg_to_reg(smireg), val);
+}
+
+#if 0
+static int ksz8895_read_smireg(struct phy_device *phydev, int smireg)
+{
+       return phydev->bus->read(phydev->bus, smireg_to_phy(smireg),
+                                       MDIO_DEVAD_NONE, smireg_to_reg(smireg));
+}
+#endif
+
+int ksz8895_config(struct phy_device *phydev)
+{
+       /* we are connected directly to the switch without
+        * dedicated PHY. SCONF1 == 001 */
+       phydev->link = 1;
+       phydev->duplex = DUPLEX_FULL;
+       phydev->speed = SPEED_100;
+
+       /* Force the switch to start */
+       ksz8895_write_smireg(phydev, 1, 1);
+
+       return 0;
+}
+
+static int ksz8895_startup(struct phy_device *phydev)
+{
+       return 0;
+}
+
+static struct phy_driver ksz8895_driver = {
+       .name = "Micrel KSZ8895/KSZ8864",
+       .uid  = 0x221450,
+       .mask = 0xffffe1,
+       .features = PHY_BASIC_FEATURES,
+       .config   = &ksz8895_config,
+       .startup  = &ksz8895_startup,
+       .shutdown = &genphy_shutdown,
+};
+
 #ifndef CONFIG_PHY_MICREL_KSZ9021
 /*
  * I can't believe Micrel used the exact same part number
@@ -221,5 +278,6 @@ int phy_micrel_init(void)
        phy_register(&KS8721_driver);
 #endif
        phy_register(&ksz9031_driver);
+       phy_register(&ksz8895_driver);
        return 0;
 }
index 5b04c85939040c27b832194a32f171686d6b88f6..df7e9450c2614a4040ced79d12d0e21238e5f689 100644 (file)
@@ -442,6 +442,9 @@ static LIST_HEAD(phy_drivers);
 
 int phy_init(void)
 {
+#ifdef CONFIG_PHY_AQUANTIA
+       phy_aquantia_init();
+#endif
 #ifdef CONFIG_PHY_ATHEROS
        phy_atheros_init();
 #endif
index d9135cb57dfa5b6058a1cc03a8fdc16b81fba92f..e19c491cbce7c00d3f429f9b7d009172bd0b66b5 100644 (file)
@@ -236,7 +236,36 @@ struct smc91111_priv{
                                          *(__b2 + __i) = SMC_inb((a),(r));  \
                                        };  \
                                }while(0)
-
+#elif defined(CONFIG_MS7206SE)
+#define SWAB7206(x) ({ word __x = x; ((__x << 8)|(__x >> 8)); })
+#define SMC_inw(a, r) *((volatile word*)((a)->iobase + (r)))
+#define SMC_inb(a, r) (*((volatile byte*)((a)->iobase + ((r) ^ 0x01))))
+#define SMC_insw(a, r, b, l) \
+       do { \
+               int __i; \
+               word *__b2 = (word *)(b);                 \
+               for (__i = 0; __i < (l); __i++) { \
+                       *__b2++ = SWAB7206(SMC_inw(a, r));      \
+               } \
+       } while (0)
+#define        SMC_outw(a, d, r)       (*((volatile word *)((a)->iobase+(r))) = d)
+#define        SMC_outb(a, d, r)       ({      word __d = (byte)(d);  \
+                               word __w = SMC_inw((a), ((r)&(~1)));    \
+                               if (((r) & 1)) \
+                                       __w = (__w & 0x00ff) | (__d << 8); \
+                               else \
+                                       __w = (__w & 0xff00) | (__d); \
+                               SMC_outw((a), __w, ((r)&(~1)));       \
+                       })
+#define SMC_outsw(a, r, b, l) \
+       do { \
+               int __i; \
+               word *__b2 = (word *)(b);                 \
+               for (__i = 0; __i < (l); __i++) { \
+                       SMC_outw(a, SWAB7206(*__b2), r);          \
+                       __b2++; \
+               } \
+       } while (0)
 #else                  /* if not CONFIG_CPU_PXA25X and not CONFIG_LEON */
 
 #ifndef CONFIG_SMC_USE_IOFUNCS /* these macros don't work on some boards */
index 79d656133adb4d50a7a28dfb529f81121db708ac..dcdba4ea827190759ea9ab0de43239a02024a096 100644 (file)
@@ -597,6 +597,8 @@ static int init_phy(struct eth_device *dev)
                tsec_configure_serdes(priv);
 
        phydev = phy_connect(priv->bus, priv->phyaddr, dev, priv->interface);
+       if (!phydev)
+               return 0;
 
        phydev->supported &= supported;
        phydev->advertising = phydev->supported;
diff --git a/drivers/net/vsc9953.c b/drivers/net/vsc9953.c
new file mode 100644 (file)
index 0000000..9fc3c18
--- /dev/null
@@ -0,0 +1,497 @@
+/*
+ *  Copyright 2014 Freescale Semiconductor, Inc.
+ *
+ *  SPDX-License-Identifier:      GPL-2.0+
+ *
+ *  Driver for the Vitesse VSC9953 L2 Switch
+ */
+
+#include <asm/io.h>
+#include <asm/fsl_serdes.h>
+#include <fm_eth.h>
+#include <asm/fsl_memac.h>
+#include <vsc9953.h>
+
+static struct vsc9953_info vsc9953_l2sw = {
+               .port[0] = VSC9953_PORT_INFO_INITIALIZER(0),
+               .port[1] = VSC9953_PORT_INFO_INITIALIZER(1),
+               .port[2] = VSC9953_PORT_INFO_INITIALIZER(2),
+               .port[3] = VSC9953_PORT_INFO_INITIALIZER(3),
+               .port[4] = VSC9953_PORT_INFO_INITIALIZER(4),
+               .port[5] = VSC9953_PORT_INFO_INITIALIZER(5),
+               .port[6] = VSC9953_PORT_INFO_INITIALIZER(6),
+               .port[7] = VSC9953_PORT_INFO_INITIALIZER(7),
+               .port[8] = VSC9953_PORT_INFO_INITIALIZER(8),
+               .port[9] = VSC9953_PORT_INFO_INITIALIZER(9),
+};
+
+void vsc9953_port_info_set_mdio(int port, struct mii_dev *bus)
+{
+       if (!VSC9953_PORT_CHECK(port))
+               return;
+
+       vsc9953_l2sw.port[port].bus = bus;
+}
+
+void vsc9953_port_info_set_phy_address(int port, int address)
+{
+       if (!VSC9953_PORT_CHECK(port))
+               return;
+
+       vsc9953_l2sw.port[port].phyaddr = address;
+}
+
+void vsc9953_port_info_set_phy_int(int port, phy_interface_t phy_int)
+{
+       if (!VSC9953_PORT_CHECK(port))
+               return;
+
+       vsc9953_l2sw.port[port].enet_if = phy_int;
+}
+
+void vsc9953_port_enable(int port)
+{
+       if (!VSC9953_PORT_CHECK(port))
+               return;
+
+       vsc9953_l2sw.port[port].enabled = 1;
+}
+
+void vsc9953_port_disable(int port)
+{
+       if (!VSC9953_PORT_CHECK(port))
+               return;
+
+       vsc9953_l2sw.port[port].enabled = 0;
+}
+
+static void vsc9953_mdio_write(struct vsc9953_mii_mng *phyregs, int port_addr,
+               int regnum, int value)
+{
+       int                     timeout = 50000;
+
+       out_le32(&phyregs->miimcmd, (0x1 << 31) | ((port_addr & 0x1f) << 25) |
+                       ((regnum & 0x1f) << 20) | ((value & 0xffff) << 4) |
+                       (0x1 << 1));
+       asm("sync");
+
+       while ((in_le32(&phyregs->miimstatus) & 0x8) && --timeout)
+               udelay(1);
+
+       if (timeout == 0)
+               debug("Timeout waiting for MDIO write\n");
+}
+
+static int vsc9953_mdio_read(struct vsc9953_mii_mng *phyregs, int port_addr,
+               int regnum)
+{
+       int                     value = 0xFFFF;
+       int                     timeout = 50000;
+
+       while ((in_le32(&phyregs->miimstatus) & MIIMIND_OPR_PEND) && --timeout)
+               udelay(1);
+       if (timeout == 0) {
+               debug("Timeout waiting for MDIO operation to finish\n");
+               return value;
+       }
+
+       /* Put the address of the phy, and the register
+        * number into MIICMD
+        */
+       out_le32(&phyregs->miimcmd, (0x1 << 31) | ((port_addr & 0x1f) << 25) |
+                       ((regnum & 0x1f) << 20) | ((value & 0xffff) << 4) |
+                       (0x2 << 1));
+
+       timeout = 50000;
+       /* Wait for the the indication that the read is done */
+       while ((in_le32(&phyregs->miimstatus) & 0x8) && --timeout)
+               udelay(1);
+       if (timeout == 0)
+               debug("Timeout waiting for MDIO read\n");
+
+       /* Grab the value read from the PHY */
+       value = in_le32(&phyregs->miimdata);
+
+       if ((value & 0x00030000) == 0)
+               return value & 0x0000ffff;
+
+       return value;
+}
+
+static int init_phy(struct eth_device *dev)
+{
+       struct vsc9953_port_info        *l2sw_port = dev->priv;
+       struct phy_device               *phydev = NULL;
+
+#ifdef CONFIG_PHYLIB
+       if (!l2sw_port->bus)
+               return 0;
+       phydev = phy_connect(l2sw_port->bus, l2sw_port->phyaddr, dev,
+                       l2sw_port->enet_if);
+       if (!phydev) {
+               printf("Failed to connect\n");
+               return -1;
+       }
+
+       phydev->supported &= SUPPORTED_10baseT_Half |
+                       SUPPORTED_10baseT_Full |
+                       SUPPORTED_100baseT_Half |
+                       SUPPORTED_100baseT_Full |
+                       SUPPORTED_1000baseT_Full;
+       phydev->advertising = phydev->supported;
+
+       l2sw_port->phydev = phydev;
+
+       phy_config(phydev);
+#endif
+
+       return 0;
+}
+
+static int vsc9953_port_init(int port)
+{
+       struct eth_device               *dev;
+
+       /* Internal ports never have a PHY */
+       if (VSC9953_INTERNAL_PORT_CHECK(port))
+               return 0;
+
+       /* alloc eth device */
+       dev = (struct eth_device *)calloc(1, sizeof(struct eth_device));
+       if (!dev)
+               return 1;
+
+       sprintf(dev->name, "SW@PORT%d", port);
+       dev->priv = &vsc9953_l2sw.port[port];
+       dev->init = NULL;
+       dev->halt = NULL;
+       dev->send = NULL;
+       dev->recv = NULL;
+
+       if (init_phy(dev)) {
+               free(dev);
+               return 1;
+       }
+
+       return 0;
+}
+
+void vsc9953_init(bd_t *bis)
+{
+       u32                             i, hdx_cfg = 0, phy_addr = 0;
+       int                             timeout;
+       struct vsc9953_system_reg       *l2sys_reg;
+       struct vsc9953_qsys_reg         *l2qsys_reg;
+       struct vsc9953_dev_gmii         *l2dev_gmii_reg;
+       struct vsc9953_analyzer         *l2ana_reg;
+       struct vsc9953_devcpu_gcb       *l2dev_gcb;
+
+       l2dev_gmii_reg = (struct vsc9953_dev_gmii *)(VSC9953_OFFSET +
+                       VSC9953_DEV_GMII_OFFSET);
+
+       l2ana_reg = (struct vsc9953_analyzer *)(VSC9953_OFFSET +
+                       VSC9953_ANA_OFFSET);
+
+       l2sys_reg = (struct vsc9953_system_reg *)(VSC9953_OFFSET +
+                       VSC9953_SYS_OFFSET);
+
+       l2qsys_reg = (struct vsc9953_qsys_reg *)(VSC9953_OFFSET +
+                       VSC9953_QSYS_OFFSET);
+
+       l2dev_gcb = (struct vsc9953_devcpu_gcb *)(VSC9953_OFFSET +
+                       VSC9953_DEVCPU_GCB);
+
+       out_le32(&l2dev_gcb->chip_regs.soft_rst,
+                CONFIG_VSC9953_SOFT_SWC_RST_ENA);
+       timeout = 50000;
+       while ((in_le32(&l2dev_gcb->chip_regs.soft_rst) &
+                       CONFIG_VSC9953_SOFT_SWC_RST_ENA) && --timeout)
+               udelay(1); /* busy wait for vsc9953 soft reset */
+       if (timeout == 0)
+               debug("Timeout waiting for VSC9953 to reset\n");
+
+       out_le32(&l2sys_reg->sys.reset_cfg, CONFIG_VSC9953_MEM_ENABLE |
+                CONFIG_VSC9953_MEM_INIT);
+
+       timeout = 50000;
+       while ((in_le32(&l2sys_reg->sys.reset_cfg) &
+               CONFIG_VSC9953_MEM_INIT) && --timeout)
+               udelay(1); /* busy wait for vsc9953 memory init */
+       if (timeout == 0)
+               debug("Timeout waiting for VSC9953 memory to initialize\n");
+
+       out_le32(&l2sys_reg->sys.reset_cfg, (in_le32(&l2sys_reg->sys.reset_cfg)
+                       | CONFIG_VSC9953_CORE_ENABLE));
+
+       /* VSC9953 Setting to be done once only */
+       out_le32(&l2qsys_reg->sys.ext_cpu_cfg, 0x00000b00);
+
+       for (i = 0; i < VSC9953_MAX_PORTS; i++) {
+               if (vsc9953_port_init(i))
+                       printf("Failed to initialize l2switch port %d\n", i);
+
+               /* Enable VSC9953 GMII Ports Port ID 0 - 7 */
+               if (VSC9953_INTERNAL_PORT_CHECK(i)) {
+                       out_le32(&l2ana_reg->pfc[i].pfc_cfg,
+                                CONFIG_VSC9953_PFC_FC_QSGMII);
+                       out_le32(&l2sys_reg->pause_cfg.mac_fc_cfg[i],
+                                CONFIG_VSC9953_MAC_FC_CFG_QSGMII);
+               } else {
+                       out_le32(&l2ana_reg->pfc[i].pfc_cfg,
+                                CONFIG_VSC9953_PFC_FC);
+                       out_le32(&l2sys_reg->pause_cfg.mac_fc_cfg[i],
+                                CONFIG_VSC9953_MAC_FC_CFG);
+               }
+               out_le32(&l2dev_gmii_reg->port_mode.clock_cfg,
+                        CONFIG_VSC9953_CLOCK_CFG);
+               out_le32(&l2dev_gmii_reg->mac_cfg_status.mac_ena_cfg,
+                        CONFIG_VSC9953_MAC_ENA_CFG);
+               out_le32(&l2dev_gmii_reg->mac_cfg_status.mac_mode_cfg,
+                        CONFIG_VSC9953_MAC_MODE_CFG);
+               out_le32(&l2dev_gmii_reg->mac_cfg_status.mac_ifg_cfg,
+                        CONFIG_VSC9953_MAC_IFG_CFG);
+               /* mac_hdx_cfg varies with port id*/
+               hdx_cfg = (CONFIG_VSC9953_MAC_HDX_CFG | (i << 16));
+               out_le32(&l2dev_gmii_reg->mac_cfg_status.mac_hdx_cfg, hdx_cfg);
+               out_le32(&l2sys_reg->sys.front_port_mode[i],
+                        CONFIG_VSC9953_FRONT_PORT_MODE);
+               out_le32(&l2qsys_reg->sys.switch_port_mode[i],
+                        CONFIG_VSC9953_PORT_ENA);
+               out_le32(&l2dev_gmii_reg->mac_cfg_status.mac_maxlen_cfg,
+                        CONFIG_VSC9953_MAC_MAX_LEN);
+               out_le32(&l2sys_reg->pause_cfg.pause_cfg[i],
+                        CONFIG_VSC9953_PAUSE_CFG);
+               /* WAIT FOR 2 us*/
+               udelay(2);
+
+               l2dev_gmii_reg = (struct vsc9953_dev_gmii *)(
+                               (char *)l2dev_gmii_reg
+                               + T1040_SWITCH_GMII_DEV_OFFSET);
+
+               /* Initialize Lynx PHY Wrappers */
+               phy_addr = 0;
+               if (vsc9953_l2sw.port[i].enet_if ==
+                               PHY_INTERFACE_MODE_QSGMII)
+                       phy_addr = (i + 0x4) & 0x1F;
+               else if (vsc9953_l2sw.port[i].enet_if ==
+                               PHY_INTERFACE_MODE_SGMII)
+                       phy_addr = (i + 1) & 0x1F;
+
+               if (phy_addr) {
+                       /* SGMII IF mode + AN enable */
+                       vsc9953_mdio_write(&l2dev_gcb->mii_mng[0], phy_addr,
+                                          0x14, PHY_SGMII_IF_MODE_AN |
+                                          PHY_SGMII_IF_MODE_SGMII);
+                       /* Dev ability according to SGMII specification */
+                       vsc9953_mdio_write(&l2dev_gcb->mii_mng[0], phy_addr,
+                                          0x4, PHY_SGMII_DEV_ABILITY_SGMII);
+                       /* Adjust link timer for SGMII
+                        * 1.6 ms in units of 8 ns = 2 * 10^5 = 0x30d40
+                        */
+                       vsc9953_mdio_write(&l2dev_gcb->mii_mng[0], phy_addr,
+                                          0x13, 0x0003);
+                       vsc9953_mdio_write(&l2dev_gcb->mii_mng[0], phy_addr,
+                                          0x12, 0x0d40);
+                       /* Restart AN */
+                       vsc9953_mdio_write(&l2dev_gcb->mii_mng[0], phy_addr,
+                                          0x0, PHY_SGMII_CR_DEF_VAL |
+                                          PHY_SGMII_CR_RESET_AN);
+
+                       timeout = 50000;
+                       while ((vsc9953_mdio_read(&l2dev_gcb->mii_mng[0],
+                                       phy_addr, 0x01) & 0x0020) && --timeout)
+                               udelay(1); /* wait for AN to complete */
+                       if (timeout == 0)
+                               debug("Timeout waiting for AN to complete\n");
+               }
+       }
+
+       printf("VSC9953 L2 switch initialized\n");
+       return;
+}
+
+#ifdef CONFIG_VSC9953_CMD
+/* Enable/disable status of a VSC9953 port */
+static void vsc9953_port_status_set(int port_nr, u8 enabled)
+{
+       u32                     val;
+       struct vsc9953_qsys_reg *l2qsys_reg;
+
+       /* Administrative down */
+       if (vsc9953_l2sw.port[port_nr].enabled == 0)
+               return;
+
+       l2qsys_reg = (struct vsc9953_qsys_reg *)(VSC9953_OFFSET +
+                       VSC9953_QSYS_OFFSET);
+
+       val = in_le32(&l2qsys_reg->sys.switch_port_mode[port_nr]);
+       if (enabled == 1)
+               val |= (1 << 13);
+       else
+               val &= ~(1 << 13);
+
+       out_le32(&l2qsys_reg->sys.switch_port_mode[port_nr], val);
+}
+
+/* Set all VSC9953 ports' status */
+static void vsc9953_port_all_status_set(u8 enabled)
+{
+       int             i;
+
+       for (i = 0; i < VSC9953_MAX_PORTS; i++)
+               vsc9953_port_status_set(i, enabled);
+}
+
+/* Start autonegotiation for a VSC9953 PHY */
+static void vsc9953_phy_autoneg(int port_nr)
+{
+       if (!vsc9953_l2sw.port[port_nr].phydev)
+               return;
+
+       if (vsc9953_l2sw.port[port_nr].phydev->drv->startup(
+                       vsc9953_l2sw.port[port_nr].phydev))
+               printf("Failed to start PHY for port %d\n", port_nr);
+}
+
+/* Start autonegotiation for all VSC9953 PHYs */
+static void vsc9953_phy_all_autoneg(void)
+{
+       int             i;
+
+       for (i = 0; i < VSC9953_MAX_PORTS; i++)
+               vsc9953_phy_autoneg(i);
+}
+
+/* Print a VSC9953 port's configuration */
+static void vsc9953_port_config_show(int port)
+{
+       int                     speed;
+       int                     duplex;
+       int                     link;
+       u8                      enabled;
+       u32                     val;
+       struct vsc9953_qsys_reg *l2qsys_reg;
+
+       l2qsys_reg = (struct vsc9953_qsys_reg *)(VSC9953_OFFSET +
+                       VSC9953_QSYS_OFFSET);
+
+       val = in_le32(&l2qsys_reg->sys.switch_port_mode[port]);
+       enabled = vsc9953_l2sw.port[port].enabled &
+                       ((val & 0x00002000) >> 13);
+
+       /* internal ports (8 and 9) are fixed */
+       if (VSC9953_INTERNAL_PORT_CHECK(port)) {
+               link = 1;
+               speed = SPEED_2500;
+               duplex = DUPLEX_FULL;
+       } else {
+               if (vsc9953_l2sw.port[port].phydev) {
+                       link = vsc9953_l2sw.port[port].phydev->link;
+                       speed = vsc9953_l2sw.port[port].phydev->speed;
+                       duplex = vsc9953_l2sw.port[port].phydev->duplex;
+               } else {
+                       link = -1;
+                       speed = -1;
+                       duplex = -1;
+               }
+       }
+
+       printf("%8d ", port);
+       printf("%8s ", enabled == 1 ? "enabled" : "disabled");
+       printf("%8s ", link == 1 ? "up" : "down");
+
+       switch (speed) {
+       case SPEED_10:
+               printf("%8d ", 10);
+               break;
+       case SPEED_100:
+               printf("%8d ", 100);
+               break;
+       case SPEED_1000:
+               printf("%8d ", 1000);
+               break;
+       case SPEED_2500:
+               printf("%8d ", 2500);
+               break;
+       case SPEED_10000:
+               printf("%8d ", 10000);
+               break;
+       default:
+               printf("%8s ", "-");
+       }
+
+       printf("%8s\n", duplex == DUPLEX_FULL ? "full" : "half");
+}
+
+/* Print VSC9953 ports' configuration */
+static void vsc9953_port_all_config_show(void)
+{
+       int             i;
+
+       for (i = 0; i < VSC9953_MAX_PORTS; i++)
+               vsc9953_port_config_show(i);
+}
+
+/* function to interpret commands starting with "ethsw " */
+static int do_ethsw(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+       u8 enable;
+       u32 port;
+
+       if (argc < 4)
+               return -1;
+
+       if (strcmp(argv[1], "port"))
+               return -1;
+
+       if (!strcmp(argv[3], "show")) {
+               if (!strcmp(argv[2], "all")) {
+                       vsc9953_phy_all_autoneg();
+                       printf("%8s %8s %8s %8s %8s\n",
+                              "Port", "Status", "Link", "Speed",
+                              "Duplex");
+                       vsc9953_port_all_config_show();
+                       return 0;
+               } else {
+                       port = simple_strtoul(argv[2], NULL, 10);
+                       if (!VSC9953_PORT_CHECK(port))
+                               return -1;
+                       vsc9953_phy_autoneg(port);
+                       printf("%8s %8s %8s %8s %8s\n",
+                              "Port", "Status", "Link", "Speed",
+                              "Duplex");
+                       vsc9953_port_config_show(port);
+                       return 0;
+               }
+       } else if (!strcmp(argv[3], "enable")) {
+               enable = 1;
+       } else if (!strcmp(argv[3], "disable")) {
+               enable = 0;
+       } else {
+               return -1;
+       }
+
+       if (!strcmp(argv[2], "all")) {
+               vsc9953_port_all_status_set(enable);
+               return 0;
+       } else {
+               port = simple_strtoul(argv[2], NULL, 10);
+               if (!VSC9953_PORT_CHECK(port))
+                       return -1;
+               vsc9953_port_status_set(port, enable);
+               return 0;
+       }
+
+       return -1;
+}
+
+U_BOOT_CMD(ethsw, 5, 0, do_ethsw,
+          "vsc9953 l2 switch commands",
+          "port <port_nr> enable|disable\n"
+          "    - enable/disable an l2 switch port\n"
+          "      port_nr=0..9; use \"all\" for all ports\n"
+          "ethsw port <port_nr> show\n"
+          "    - show an l2 switch port's configuration\n"
+          "      port_nr=0..9; use \"all\" for all ports\n"
+);
+#endif /* CONFIG_VSC9953_CMD */
index dab78d073dab6185ec5445617185f794c437f5b9..7cc86571e4952e001f2d5da234795abd520d223a 100644 (file)
@@ -231,7 +231,7 @@ static int ll_temac_init(struct eth_device *dev, bd_t *bis)
        struct ll_temac *ll_temac = dev->priv;
        int ret;
 
-       printf("%s: Xilinx XPS LocalLink Tri-Mode Ether MAC #%d at 0x%08X.\n",
+       printf("%s: Xilinx XPS LocalLink Tri-Mode Ether MAC #%d at 0x%08lx.\n",
                dev->name, dev->index, dev->iobase);
 
        if (!ll_temac_setup_ctrl(dev))
index 3cadd23bb46aa77529b9a15909f20409588eb4e9..430e22821c7d5c21371b2e59a22c6a6d010ee10e 100644 (file)
@@ -489,7 +489,8 @@ static int zynq_gem_miiphy_write(const char *devname, uchar addr,
        return phywrite(dev, addr, reg, val);
 }
 
-int zynq_gem_initialize(bd_t *bis, int base_addr, int phy_addr, u32 emio)
+int zynq_gem_initialize(bd_t *bis, phys_addr_t base_addr,
+                       int phy_addr, u32 emio)
 {
        struct eth_device *dev;
        struct zynq_gem_priv *priv;
@@ -521,7 +522,7 @@ int zynq_gem_initialize(bd_t *bis, int base_addr, int phy_addr, u32 emio)
        priv->phyaddr = phy_addr;
        priv->emio = emio;
 
-       sprintf(dev->name, "Gem.%x", base_addr);
+       sprintf(dev->name, "Gem.%lx", base_addr);
 
        dev->iobase = base_addr;
 
index 44470fa812b0ed42ca475bb27262d1b7be0fb733..ed928574061600118a7ed8c0e83398c5c070291c 100644 (file)
@@ -11,7 +11,7 @@
  */
 
 #include <common.h>
-
+#include <errno.h>
 #include <pci.h>
 
 #undef DEBUG
@@ -191,6 +191,32 @@ void pciauto_setup_device(struct pci_controller *hose,
        pci_hose_write_config_byte(hose, dev, PCI_LATENCY_TIMER, 0x80);
 }
 
+int pciauto_setup_rom(struct pci_controller *hose, pci_dev_t dev)
+{
+       pci_addr_t bar_value;
+       pci_size_t bar_size;
+       u32 bar_response;
+       u16 cmdstat = 0;
+
+       pci_hose_write_config_dword(hose, dev, PCI_ROM_ADDRESS, 0xfffffffe);
+       pci_hose_read_config_dword(hose, dev, PCI_ROM_ADDRESS, &bar_response);
+       if (!bar_response)
+               return -ENOENT;
+
+       bar_size = -(bar_response & ~1);
+       DEBUGF("PCI Autoconfig: ROM, size=%#x, ", bar_size);
+       if (pciauto_region_allocate(hose->pci_mem, bar_size, &bar_value) == 0) {
+               pci_hose_write_config_dword(hose, dev, PCI_ROM_ADDRESS,
+                                           bar_value);
+       }
+       DEBUGF("\n");
+       pci_hose_read_config_word(hose, dev, PCI_COMMAND, &cmdstat);
+       cmdstat |= PCI_COMMAND_IO | PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER;
+       pci_hose_write_config_word(hose, dev, PCI_COMMAND, cmdstat);
+
+       return 0;
+}
+
 void pciauto_prescan_setup_bridge(struct pci_controller *hose,
                                         pci_dev_t dev, int sub_bus)
 {
index 7d25cc9f2f37d8b1a06b9cd67f2a320e013b958e..5729a152e5bb00ed759dfe90bd7750f10b7e20b7 100644 (file)
@@ -66,6 +66,7 @@ static int pci_rom_probe(pci_dev_t dev, uint class,
        struct pci_rom_header *rom_header;
        struct pci_rom_data *rom_data;
        u16 vendor, device;
+       u16 rom_vendor, rom_device;
        u32 vendev;
        u32 mapped_vendev;
        u32 rom_address;
@@ -80,7 +81,12 @@ static int pci_rom_probe(pci_dev_t dev, uint class,
 #ifdef CONFIG_X86_OPTION_ROM_ADDR
        rom_address = CONFIG_X86_OPTION_ROM_ADDR;
 #else
-       pci_write_config_dword(dev, PCI_ROM_ADDRESS, (u32)PCI_ROM_ADDRESS_MASK);
+
+       if (pciauto_setup_rom(pci_bus_to_hose(PCI_BUS(dev)), dev)) {
+               debug("Cannot find option ROM\n");
+               return -ENOENT;
+       }
+
        pci_read_config_dword(dev, PCI_ROM_ADDRESS, &rom_address);
        if (rom_address == 0x00000000 || rom_address == 0xffffffff) {
                debug("%s: rom_address=%x\n", __func__, rom_address);
@@ -92,29 +98,31 @@ static int pci_rom_probe(pci_dev_t dev, uint class,
                               rom_address | PCI_ROM_ADDRESS_ENABLE);
 #endif
        debug("Option ROM address %x\n", rom_address);
-       rom_header = (struct pci_rom_header *)rom_address;
+       rom_header = (struct pci_rom_header *)(unsigned long)rom_address;
 
        debug("PCI expansion ROM, signature %#04x, INIT size %#04x, data ptr %#04x\n",
-             le32_to_cpu(rom_header->signature),
-             rom_header->size * 512, le32_to_cpu(rom_header->data));
+             le16_to_cpu(rom_header->signature),
+             rom_header->size * 512, le16_to_cpu(rom_header->data));
 
-       if (le32_to_cpu(rom_header->signature) != PCI_ROM_HDR) {
+       if (le16_to_cpu(rom_header->signature) != PCI_ROM_HDR) {
                printf("Incorrect expansion ROM header signature %04x\n",
-                      le32_to_cpu(rom_header->signature));
+                      le16_to_cpu(rom_header->signature));
                return -EINVAL;
        }
 
-       rom_data = (((void *)rom_header) + le32_to_cpu(rom_header->data));
+       rom_data = (((void *)rom_header) + le16_to_cpu(rom_header->data));
+       rom_vendor = le16_to_cpu(rom_data->vendor);
+       rom_device = le16_to_cpu(rom_data->device);
 
        debug("PCI ROM image, vendor ID %04x, device ID %04x,\n",
-             rom_data->vendor, rom_data->device);
+             rom_vendor, rom_device);
 
        /* If the device id is mapped, a mismatch is expected */
-       if ((vendor != rom_data->vendor || device != rom_data->device) &&
+       if ((vendor != rom_vendor || device != rom_device) &&
            (vendev == mapped_vendev)) {
                printf("ID mismatch: vendor ID %04x, device ID %04x\n",
-                      rom_data->vendor, rom_data->device);
-               return -EPERM;
+                      rom_vendor, rom_device);
+               /* Continue anyway */
        }
 
        debug("PCI ROM image, Class Code %04x%02x, Code Type %02x\n",
@@ -144,17 +152,23 @@ int pci_rom_load(uint16_t class, struct pci_rom_header *rom_header,
                                                            image_size);
 
                rom_data = (struct pci_rom_data *)((void *)rom_header +
-                               le32_to_cpu(rom_header->data));
+                               le16_to_cpu(rom_header->data));
 
-               image_size = le32_to_cpu(rom_data->ilen) * 512;
-       } while ((rom_data->type != 0) && (rom_data->indicator != 0));
+               image_size = le16_to_cpu(rom_data->ilen) * 512;
+       } while ((rom_data->type != 0) && (rom_data->indicator == 0));
 
        if (rom_data->type != 0)
                return -EACCES;
 
        rom_size = rom_header->size * 512;
 
+#ifdef PCI_VGA_RAM_IMAGE_START
        target = (void *)PCI_VGA_RAM_IMAGE_START;
+#else
+       target = (void *)malloc(rom_size);
+       if (!target)
+               return -ENOMEM;
+#endif
        if (target != rom_header) {
                ulong start = get_timer(0);
 
index f9e05add19157ee885e4c97b7fe4effe052e5333..67b5fdf07c5ad833c03d00981392555a9adc9e71 100644 (file)
@@ -459,7 +459,6 @@ static int tegra_pcie_parse_port_info(const void *fdt, int node,
                                      unsigned int *lanes)
 {
        struct fdt_pci_addr addr;
-       pci_dev_t bdf;
        int err;
 
        err = fdtdec_get_int(fdt, node, "nvidia,num-lanes", 0);
@@ -470,13 +469,13 @@ static int tegra_pcie_parse_port_info(const void *fdt, int node,
 
        *lanes = err;
 
-       err = fdtdec_get_pci_bdf(fdt, node, &addr, &bdf);
+       err = fdtdec_get_pci_addr(fdt, node, 0, "reg", &addr);
        if (err < 0) {
                error("failed to parse \"reg\" property");
                return err;
        }
 
-       *index = PCI_DEV(bdf) - 1;
+       *index = PCI_DEV(addr.phys_hi) - 1;
 
        return 0;
 }
index e68e16b3211757271a27e99d0089fbf4b29fc83f..f8f0239484fd43811cbf9dc9fcff3bb6dec179ef 100644 (file)
@@ -63,3 +63,13 @@ config AXP221_ALDO3_VOLT
        Set the voltage (mV) to program the axp221 aldo3 at, set to 0 to
        disable aldo3. This is typically connected to VCC-PLL and AVCC and
        must be set to 3V.
+
+config AXP221_ELDO3_VOLT
+       int "axp221 eldo3 voltage"
+       depends on AXP221_POWER
+       default 0
+       ---help---
+       Set the voltage (mV) to program the axp221 eldo3 at, set to 0 to
+       disable eldo3. On some A31(s) tablets it might be used to supply
+       1.2V for the SSD2828 chip (converter of parallel LCD interface
+       into MIPI DSI).
index 4c6de79cd608cae49eae25bfbb4973654897ce9a..a60bb5f83fbc5cda5a5533b3893f85e47d450c0a 100644 (file)
@@ -31,7 +31,7 @@ static int as3722_read(struct udevice *pmic, u8 reg, u8 *value)
 {
        int err;
 
-       err = i2c_read(pmic, reg, value, 1);
+       err = dm_i2c_read(pmic, reg, value, 1);
        if (err < 0)
                return err;
 
@@ -42,7 +42,7 @@ static int as3722_write(struct udevice *pmic, u8 reg, u8 value)
 {
        int err;
 
-       err = i2c_write(pmic, reg, &value, 1);
+       err = dm_i2c_write(pmic, reg, &value, 1);
        if (err < 0)
                return err;
 
@@ -242,7 +242,7 @@ int as3722_init(struct udevice **devp)
        const unsigned int address = 0x40;
        int err;
 
-       err = i2c_get_chip_for_busnum(bus, address, &pmic);
+       err = i2c_get_chip_for_busnum(bus, address, 1, &pmic);
        if (err)
                return err;
        err = as3722_read_id(pmic, &id, &revision);
index 3b1a6a73aed8ecfd8f748c1ffc37db8fff747e2e..4565398b0bf37d70b55e7f403aef4c3e70877cc3 100644 (file)
@@ -16,6 +16,11 @@ enum axp209_reg {
        AXP209_DCDC3_VOLTAGE = 0x27,
        AXP209_LDO24_VOLTAGE = 0x28,
        AXP209_LDO3_VOLTAGE = 0x29,
+       AXP209_IRQ_ENABLE1 = 0x40,
+       AXP209_IRQ_ENABLE2 = 0x41,
+       AXP209_IRQ_ENABLE3 = 0x42,
+       AXP209_IRQ_ENABLE4 = 0x43,
+       AXP209_IRQ_ENABLE5 = 0x44,
        AXP209_IRQ_STATUS5 = 0x4c,
        AXP209_SHUTDOWN = 0x32,
        AXP209_GPIO0_CTRL = 0x90,
@@ -143,7 +148,7 @@ int axp209_set_ldo4(int mvolt)
 int axp209_init(void)
 {
        u8 ver;
-       int rc;
+       int i, rc;
 
        rc = axp209_read(AXP209_CHIP_VERSION, &ver);
        if (rc)
@@ -155,6 +160,13 @@ int axp209_init(void)
        if (ver != 0x1)
                return -1;
 
+       /* Mask all interrupts */
+       for (i = AXP209_IRQ_ENABLE1; i <= AXP209_IRQ_ENABLE5; i++) {
+               rc = axp209_write(i, 0);
+               if (rc)
+                       return rc;
+       }
+
        return 0;
 }
 
index 4c86f099a2df52bb8223ed17115cbbc3da3232bf..3e07f23c20c621ba9cbfc101d788462aed93026d 100644 (file)
@@ -29,9 +29,7 @@ static int pmic_bus_init(void)
 #else
        int ret;
 
-       rsb_init();
-
-       ret = rsb_set_device_mode(AXP223_DEVICE_MODE_DATA);
+       ret = rsb_init();
        if (ret)
                return ret;
 
@@ -302,6 +300,39 @@ int axp221_set_aldo3(unsigned int mvolt)
                              AXP221_OUTPUT_CTRL3_ALDO3_EN);
 }
 
+int axp221_set_eldo(int eldo_num, unsigned int mvolt)
+{
+       int ret;
+       u8 cfg = axp221_mvolt_to_cfg(mvolt, 700, 3300, 100);
+       u8 addr, bits;
+
+       switch (eldo_num) {
+       case 3:
+               addr = AXP221_ELDO3_CTRL;
+               bits = AXP221_OUTPUT_CTRL2_ELDO3_EN;
+               break;
+       case 2:
+               addr = AXP221_ELDO2_CTRL;
+               bits = AXP221_OUTPUT_CTRL2_ELDO2_EN;
+               break;
+       case 1:
+               addr = AXP221_ELDO1_CTRL;
+               bits = AXP221_OUTPUT_CTRL2_ELDO1_EN;
+               break;
+       default:
+               return -EINVAL;
+       }
+
+       if (mvolt == 0)
+               return axp221_clrbits(AXP221_OUTPUT_CTRL2, bits);
+
+       ret = pmic_bus_write(addr, cfg);
+       if (ret)
+               return ret;
+
+       return axp221_setbits(AXP221_OUTPUT_CTRL2, bits);
+}
+
 int axp221_init(void)
 {
        /* This cannot be 0 because it is used in SPL before BSS is ready */
index 29bab4cc00dc7683121fc3302d65c660b9190a3f..865098386d932ae22ce5f3d781e268bede874a95 100644 (file)
@@ -37,7 +37,7 @@ static int tps6586x_read(int reg)
        int     retval = -1;
 
        for (i = 0; i < MAX_I2C_RETRY; ++i) {
-               if (!i2c_read(tps6586x_dev, reg,  &data, 1)) {
+               if (!dm_i2c_read(tps6586x_dev, reg,  &data, 1)) {
                        retval = (int)data;
                        goto exit;
                }
@@ -60,7 +60,7 @@ static int tps6586x_write(int reg, uchar *data, uint len)
        int     retval = -1;
 
        for (i = 0; i < MAX_I2C_RETRY; ++i) {
-               if (!i2c_write(tps6586x_dev, reg, data, len)) {
+               if (!dm_i2c_write(tps6586x_dev, reg, data, len)) {
                        retval = 0;
                        goto exit;
                }
index 39e6041be365ccdb9089d21ee302c9de76d429cf..c9d318c0a7eb2d83e992ded95615bd550310d1e9 100644 (file)
@@ -27,9 +27,6 @@
 /* Set this to 1 to clear the CMOS RAM */
 #define CLEAR_CMOS 0
 
-static uchar rtc_read  (uchar reg);
-static void  rtc_write (uchar reg, uchar val);
-
 #define RTC_PORT_MC146818      CONFIG_SYS_ISA_IO_BASE_ADDRESS +  0x70
 #define RTC_SECONDS            0x00
 #define RTC_SECONDS_ALARM      0x01
@@ -60,24 +57,24 @@ int rtc_get (struct rtc_time *tmp)
 {
        uchar sec, min, hour, mday, wday, mon, year;
   /* here check if rtc can be accessed */
-       while((rtc_read(RTC_CONFIG_A)&0x80)==0x80);
-       sec     = rtc_read (RTC_SECONDS);
-       min     = rtc_read (RTC_MINUTES);
-       hour    = rtc_read (RTC_HOURS);
-       mday    = rtc_read (RTC_DATE_OF_MONTH);
-       wday    = rtc_read (RTC_DAY_OF_WEEK);
-       mon     = rtc_read (RTC_MONTH);
-       year    = rtc_read (RTC_YEAR);
+       while ((rtc_read8(RTC_CONFIG_A) & 0x80) == 0x80);
+       sec     = rtc_read8(RTC_SECONDS);
+       min     = rtc_read8(RTC_MINUTES);
+       hour    = rtc_read8(RTC_HOURS);
+       mday    = rtc_read8(RTC_DATE_OF_MONTH);
+       wday    = rtc_read8(RTC_DAY_OF_WEEK);
+       mon     = rtc_read8(RTC_MONTH);
+       year    = rtc_read8(RTC_YEAR);
 #ifdef RTC_DEBUG
        printf ( "Get RTC year: %02x mon/cent: %02x mday: %02x wday: %02x "
                "hr: %02x min: %02x sec: %02x\n",
                year, mon, mday, wday,
                hour, min, sec );
        printf ( "Alarms: month: %02x hour: %02x min: %02x sec: %02x\n",
-               rtc_read (RTC_CONFIG_D) & 0x3F,
-               rtc_read (RTC_HOURS_ALARM),
-               rtc_read (RTC_MINUTES_ALARM),
-               rtc_read (RTC_SECONDS_ALARM) );
+               rtc_read8(RTC_CONFIG_D) & 0x3F,
+               rtc_read8(RTC_HOURS_ALARM),
+               rtc_read8(RTC_MINUTES_ALARM),
+               rtc_read8(RTC_SECONDS_ALARM));
 #endif
        tmp->tm_sec  = bcd2bin (sec  & 0x7F);
        tmp->tm_min  = bcd2bin (min  & 0x7F);
@@ -108,80 +105,108 @@ int rtc_set (struct rtc_time *tmp)
                tmp->tm_year, tmp->tm_mon, tmp->tm_mday, tmp->tm_wday,
                tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
 #endif
-       rtc_write(RTC_CONFIG_B,0x82); /* disables the RTC to update the regs */
+       rtc_write8(RTC_CONFIG_B, 0x82); /* disable the RTC to update the regs */
 
-       rtc_write (RTC_YEAR, bin2bcd(tmp->tm_year % 100));
-       rtc_write (RTC_MONTH, bin2bcd(tmp->tm_mon));
-       rtc_write (RTC_DAY_OF_WEEK, bin2bcd(tmp->tm_wday));
-       rtc_write (RTC_DATE_OF_MONTH, bin2bcd(tmp->tm_mday));
-       rtc_write (RTC_HOURS, bin2bcd(tmp->tm_hour));
-       rtc_write (RTC_MINUTES, bin2bcd(tmp->tm_min ));
-       rtc_write (RTC_SECONDS, bin2bcd(tmp->tm_sec ));
-       rtc_write(RTC_CONFIG_B,0x02); /* enables the RTC to update the regs */
+       rtc_write8(RTC_YEAR, bin2bcd(tmp->tm_year % 100));
+       rtc_write8(RTC_MONTH, bin2bcd(tmp->tm_mon));
+       rtc_write8(RTC_DAY_OF_WEEK, bin2bcd(tmp->tm_wday));
+       rtc_write8(RTC_DATE_OF_MONTH, bin2bcd(tmp->tm_mday));
+       rtc_write8(RTC_HOURS, bin2bcd(tmp->tm_hour));
+       rtc_write8(RTC_MINUTES, bin2bcd(tmp->tm_min));
+       rtc_write8(RTC_SECONDS, bin2bcd(tmp->tm_sec));
+       rtc_write8(RTC_CONFIG_B, 0x02); /* enable the RTC to update the regs */
 
        return 0;
 }
 
 void rtc_reset (void)
 {
-       rtc_write(RTC_CONFIG_B,0x82); /* disables the RTC to update the regs */
-       rtc_write(RTC_CONFIG_A,0x20); /* Normal OP */
-       rtc_write(RTC_CONFIG_B,0x00);
-       rtc_write(RTC_CONFIG_B,0x00);
-       rtc_write(RTC_CONFIG_B,0x02); /* enables the RTC to update the regs */
+       rtc_write8(RTC_CONFIG_B, 0x82); /* disable the RTC to update the regs */
+       rtc_write8(RTC_CONFIG_A, 0x20); /* Normal OP */
+       rtc_write8(RTC_CONFIG_B, 0x00);
+       rtc_write8(RTC_CONFIG_B, 0x00);
+       rtc_write8(RTC_CONFIG_B, 0x02); /* enable the RTC to update the regs */
 }
 
 /* ------------------------------------------------------------------------- */
 
-#ifdef CONFIG_SYS_RTC_REG_BASE_ADDR
 /*
  * use direct memory access
  */
-static uchar rtc_read (uchar reg)
+int rtc_read8(int reg)
 {
+#ifdef CONFIG_SYS_RTC_REG_BASE_ADDR
        return in8(CONFIG_SYS_RTC_REG_BASE_ADDR + reg);
+#else
+       int ofs = 0;
+
+       if (reg >= 128) {
+               ofs = 2;
+               reg -= 128;
+       }
+       out8(RTC_PORT_MC146818 + ofs, reg);
+
+       return in8(RTC_PORT_MC146818 + ofs + 1);
+#endif
 }
 
-static void rtc_write (uchar reg, uchar val)
+void rtc_write8(int reg, uchar val)
 {
+#ifdef CONFIG_SYS_RTC_REG_BASE_ADDR
        out8(CONFIG_SYS_RTC_REG_BASE_ADDR + reg, val);
-}
 #else
-static uchar rtc_read (uchar reg)
+       int ofs = 0;
+
+       if (reg >= 128) {
+               ofs = 2;
+               reg -= 128;
+       }
+       out8(RTC_PORT_MC146818 + ofs, reg);
+       out8(RTC_PORT_MC146818 + ofs + 1, val);
+#endif
+}
+
+u32 rtc_read32(int reg)
 {
-       out8(RTC_PORT_MC146818,reg);
-       return in8(RTC_PORT_MC146818 + 1);
+       u32 value = 0;
+       int i;
+
+       for (i = 0; i < sizeof(value); i++)
+               value |= rtc_read8(reg + i) << (i << 3);
+
+       return value;
 }
 
-static void rtc_write (uchar reg, uchar val)
+void rtc_write32(int reg, u32 value)
 {
-       out8(RTC_PORT_MC146818,reg);
-       out8(RTC_PORT_MC146818+1, val);
+       int i;
+
+       for (i = 0; i < sizeof(value); i++)
+               rtc_write8(reg + i, (value >> (i << 3)) & 0xff);
 }
-#endif
 
 void rtc_init(void)
 {
 #if CLEAR_CMOS
        int i;
 
-       rtc_write(RTC_SECONDS_ALARM, 0);
-       rtc_write(RTC_MINUTES_ALARM, 0);
-       rtc_write(RTC_HOURS_ALARM, 0);
+       rtc_write8(RTC_SECONDS_ALARM, 0);
+       rtc_write8(RTC_MINUTES_ALARM, 0);
+       rtc_write8(RTC_HOURS_ALARM, 0);
        for (i = RTC_CONFIG_A; i < RTC_REG_SIZE; i++)
-               rtc_write(i, 0);
+               rtc_write8(i, 0);
        printf("RTC: zeroing CMOS RAM\n");
 #endif
 
        /* Setup the real time clock */
-       rtc_write(RTC_CONFIG_B, RTC_CONFIG_B_24H);
+       rtc_write8(RTC_CONFIG_B, RTC_CONFIG_B_24H);
        /* Setup the frequency it operates at */
-       rtc_write(RTC_CONFIG_A, RTC_CONFIG_A_REF_CLCK_32KHZ |
+       rtc_write8(RTC_CONFIG_A, RTC_CONFIG_A_REF_CLCK_32KHZ |
                  RTC_CONFIG_A_RATE_1024HZ);
        /* Ensure all reserved bits are 0 in register D */
-       rtc_write(RTC_CONFIG_D, RTC_CONFIG_D_VALID_RAM_AND_TIME);
+       rtc_write8(RTC_CONFIG_D, RTC_CONFIG_D_VALID_RAM_AND_TIME);
 
        /* Clear any pending interrupts */
-       rtc_read(RTC_CONFIG_C);
+       rtc_read8(RTC_CONFIG_C);
 }
 #endif
index d1b5777cecda13be6191404cefe6dcf82a92f564..9131a8f93d9a5adff359d2940ddfd6a6a05c445e 100644 (file)
@@ -297,6 +297,7 @@ static int serial_pre_remove(struct udevice *dev)
 UCLASS_DRIVER(serial) = {
        .id             = UCLASS_SERIAL,
        .name           = "serial",
+       .flags          = DM_UC_FLAG_SEQ_ALIAS,
        .post_probe     = serial_post_probe,
        .pre_remove     = serial_pre_remove,
        .per_device_auto_alloc_size = sizeof(struct serial_dev_priv),
index 1ff27d5f4889a5198ac14d761559360236436f87..3e2b8dc183e467c6562d3a868a6a8147bcf48179 100644 (file)
@@ -27,14 +27,14 @@ DECLARE_GLOBAL_DATA_PTR;
 #define ZYNQ_UART_MR_PARITY_NONE       0x00000020  /* No parity mode */
 
 struct uart_zynq {
-       u32 control; /* Control Register [8:0] */
-       u32 mode; /* Mode Register [10:0] */
+       u32 control; /* 0x0 - Control Register [8:0] */
+       u32 mode; /* 0x4 - Mode Register [10:0] */
        u32 reserved1[4];
-       u32 baud_rate_gen; /* Baud Rate Generator [15:0] */
+       u32 baud_rate_gen; /* 0x18 - Baud Rate Generator [15:0] */
        u32 reserved2[4];
-       u32 channel_sts; /* Channel Status [11:0] */
-       u32 tx_rx_fifo; /* FIFO [15:0] or [7:0] */
-       u32 baud_rate_divider; /* Baud Rate Divider [7:0] */
+       u32 channel_sts; /* 0x2c - Channel Status [11:0] */
+       u32 tx_rx_fifo; /* 0x30 - FIFO [15:0] or [7:0] */
+       u32 baud_rate_divider; /* 0x34 - Baud Rate Divider [7:0] */
 };
 
 static struct uart_zynq *uart_zynq_ports[2] = {
@@ -42,29 +42,13 @@ static struct uart_zynq *uart_zynq_ports[2] = {
        [1] = (struct uart_zynq *)ZYNQ_SERIAL_BASEADDR1,
 };
 
-#if !defined(CONFIG_ZYNQ_SERIAL_BAUDRATE0)
-# define CONFIG_ZYNQ_SERIAL_BAUDRATE0  CONFIG_BAUDRATE
-#endif
-#if !defined(CONFIG_ZYNQ_SERIAL_BAUDRATE1)
-# define CONFIG_ZYNQ_SERIAL_BAUDRATE1  CONFIG_BAUDRATE
-#endif
-
-struct uart_zynq_params {
-       u32 baudrate;
-};
-
-static struct uart_zynq_params uart_zynq_ports_param[2] = {
-       [0].baudrate = CONFIG_ZYNQ_SERIAL_BAUDRATE0,
-       [1].baudrate = CONFIG_ZYNQ_SERIAL_BAUDRATE1,
-};
-
 /* Set up the baud rate in gd struct */
 static void uart_zynq_serial_setbrg(const int port)
 {
        /* Calculation results. */
        unsigned int calc_bauderror, bdiv, bgen;
        unsigned long calc_baud = 0;
-       unsigned long baud = uart_zynq_ports_param[port].baudrate;
+       unsigned long baud = gd->baudrate;
        unsigned long clock = get_uart_clk(port);
        struct uart_zynq *regs = uart_zynq_ports[port];
 
index 98ae3b808fb0a970b9e467e94bef0e336458bd19..a75fc46e95dc5f060e0e8a6a3e89ef72e4dfb6ec 100644 (file)
@@ -340,6 +340,5 @@ U_BOOT_DRIVER(cadence_spi) = {
        .ofdata_to_platdata = cadence_spi_ofdata_to_platdata,
        .platdata_auto_alloc_size = sizeof(struct cadence_spi_platdata),
        .priv_auto_alloc_size = sizeof(struct cadence_spi_priv),
-       .per_child_auto_alloc_size = sizeof(struct spi_slave),
        .probe = cadence_spi_probe,
 };
index 700f616ad7630608dc50136f9abf4c148714a7a3..2624844d528566bb7ed786ae06537b4cbf69b777 100644 (file)
@@ -421,6 +421,5 @@ U_BOOT_DRIVER(dw_spi) = {
        .ofdata_to_platdata = dw_spi_ofdata_to_platdata,
        .platdata_auto_alloc_size = sizeof(struct dw_spi_platdata),
        .priv_auto_alloc_size = sizeof(struct dw_spi_priv),
-       .per_child_auto_alloc_size = sizeof(struct spi_slave),
        .probe = dw_spi_probe,
 };
index f078973531c1d960e5635a485e50c42170b45d80..a46d8c187668cff8560eea31c7189c7dfa3b4161 100644 (file)
@@ -425,6 +425,5 @@ U_BOOT_DRIVER(exynos_spi) = {
        .ofdata_to_platdata = exynos_spi_ofdata_to_platdata,
        .platdata_auto_alloc_size = sizeof(struct exynos_spi_platdata),
        .priv_auto_alloc_size = sizeof(struct exynos_spi_priv),
-       .per_child_auto_alloc_size      = sizeof(struct spi_slave),
        .probe  = exynos_spi_probe,
 };
index 0379444872e73ed413cc03ff029b08dad30d1f37..fdff158637da063a9be9967c4ae13df5b5018e21 100644 (file)
@@ -153,6 +153,13 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
        return &ich->slave;
 }
 
+struct spi_slave *spi_setup_slave_fdt(const void *blob, int slave_node,
+                                     int spi_node)
+{
+       /* We only support a single SPI at present */
+       return spi_setup_slave(0, 0, 20000000, 0);
+}
+
 void spi_free_slave(struct spi_slave *slave)
 {
        struct ich_spi_slave *ich = to_ich_spi(slave);
index e717424db83a9ff7dcc15bc57074c5722b66ff11..bad56603ba6809443ee020a4f3459057f166ebf3 100644 (file)
@@ -160,6 +160,5 @@ U_BOOT_DRIVER(spi_sandbox) = {
        .name   = "spi_sandbox",
        .id     = UCLASS_SPI,
        .of_match = sandbox_spi_ids,
-       .per_child_auto_alloc_size      = sizeof(struct spi_slave),
        .ops    = &sandbox_spi_ops,
 };
index 558803618a272cc6e0e8b880ddd89cc8950e6e68..6ae45f5377ab89ba647387029fdfa771dc1ee8ed 100644 (file)
 DECLARE_GLOBAL_DATA_PTR;
 
 struct soft_spi_platdata {
-       struct fdt_gpio_state cs;
-       struct fdt_gpio_state sclk;
-       struct fdt_gpio_state mosi;
-       struct fdt_gpio_state miso;
+       struct gpio_desc cs;
+       struct gpio_desc sclk;
+       struct gpio_desc mosi;
+       struct gpio_desc miso;
        int spi_delay_us;
 };
 
@@ -35,9 +35,8 @@ struct soft_spi_priv {
 static int soft_spi_scl(struct udevice *dev, int bit)
 {
        struct soft_spi_platdata *plat = dev->platdata;
-       struct soft_spi_priv *priv = dev_get_priv(dev);
 
-       gpio_set_value(plat->sclk.gpio, priv->mode & SPI_CPOL ? bit : !bit);
+       dm_gpio_set_value(&plat->sclk, bit);
 
        return 0;
 }
@@ -46,7 +45,7 @@ static int soft_spi_sda(struct udevice *dev, int bit)
 {
        struct soft_spi_platdata *plat = dev->platdata;
 
-       gpio_set_value(plat->mosi.gpio, bit);
+       dm_gpio_set_value(&plat->mosi, bit);
 
        return 0;
 }
@@ -54,11 +53,10 @@ static int soft_spi_sda(struct udevice *dev, int bit)
 static int soft_spi_cs_activate(struct udevice *dev)
 {
        struct soft_spi_platdata *plat = dev->platdata;
-       struct soft_spi_priv *priv = dev_get_priv(dev);
 
-       gpio_set_value(plat->cs.gpio, !(priv->mode & SPI_CS_HIGH));
-       gpio_set_value(plat->sclk.gpio, priv->mode & SPI_CPOL);
-       gpio_set_value(plat->cs.gpio, priv->mode & SPI_CS_HIGH);
+       dm_gpio_set_value(&plat->cs, 0);
+       dm_gpio_set_value(&plat->sclk, 0);
+       dm_gpio_set_value(&plat->cs, 1);
 
        return 0;
 }
@@ -66,9 +64,8 @@ static int soft_spi_cs_activate(struct udevice *dev)
 static int soft_spi_cs_deactivate(struct udevice *dev)
 {
        struct soft_spi_platdata *plat = dev->platdata;
-       struct soft_spi_priv *priv = dev_get_priv(dev);
 
-       gpio_set_value(plat->cs.gpio, !(priv->mode & SPI_CS_HIGH));
+       dm_gpio_set_value(&plat->cs, 0);
 
        return 0;
 }
@@ -109,7 +106,6 @@ static int soft_spi_xfer(struct udevice *dev, unsigned int bitlen,
        uchar           tmpdout = 0;
        const u8        *txd = dout;
        u8              *rxd = din;
-       int             cpol = priv->mode & SPI_CPOL;
        int             cpha = priv->mode & SPI_CPHA;
        unsigned int    j;
 
@@ -137,19 +133,19 @@ static int soft_spi_xfer(struct udevice *dev, unsigned int bitlen,
                }
 
                if (!cpha)
-                       soft_spi_scl(dev, !cpol);
+                       soft_spi_scl(dev, 0);
                soft_spi_sda(dev, tmpdout & 0x80);
                udelay(plat->spi_delay_us);
                if (cpha)
-                       soft_spi_scl(dev, !cpol);
+                       soft_spi_scl(dev, 0);
                else
-                       soft_spi_scl(dev, cpol);
+                       soft_spi_scl(dev, 1);
                tmpdin  <<= 1;
-               tmpdin  |= gpio_get_value(plat->miso.gpio);
+               tmpdin  |= dm_gpio_get_value(&plat->miso);
                tmpdout <<= 1;
                udelay(plat->spi_delay_us);
                if (cpha)
-                       soft_spi_scl(dev, cpol);
+                       soft_spi_scl(dev, 1);
        }
        /*
         * If the number of bits isn't a multiple of 8, shift the last
@@ -183,14 +179,6 @@ static int soft_spi_set_mode(struct udevice *dev, unsigned int mode)
        return 0;
 }
 
-static int soft_spi_child_pre_probe(struct udevice *dev)
-{
-       struct spi_slave *slave = dev_get_parentdata(dev);
-
-       slave->dev = dev;
-       return spi_ofdata_to_platdata(gd->fdt_blob, dev->of_offset, slave);
-}
-
 static const struct dm_spi_ops soft_spi_ops = {
        .claim_bus      = soft_spi_claim_bus,
        .release_bus    = soft_spi_release_bus,
@@ -205,11 +193,6 @@ static int soft_spi_ofdata_to_platdata(struct udevice *dev)
        const void *blob = gd->fdt_blob;
        int node = dev->of_offset;
 
-       if (fdtdec_decode_gpio(blob, node, "cs-gpio", &plat->cs) ||
-           fdtdec_decode_gpio(blob, node, "sclk-gpio", &plat->sclk) ||
-           fdtdec_decode_gpio(blob, node, "mosi-gpio", &plat->mosi) ||
-           fdtdec_decode_gpio(blob, node, "miso-gpio", &plat->miso))
-               return -EINVAL;
        plat->spi_delay_us = fdtdec_get_int(blob, node, "spi-delay-us", 0);
 
        return 0;
@@ -219,16 +202,19 @@ static int soft_spi_probe(struct udevice *dev)
 {
        struct spi_slave *slave = dev_get_parentdata(dev);
        struct soft_spi_platdata *plat = dev->platdata;
-
-       gpio_request(plat->cs.gpio, "soft_spi_cs");
-       gpio_request(plat->sclk.gpio, "soft_spi_sclk");
-       gpio_request(plat->mosi.gpio, "soft_spi_mosi");
-       gpio_request(plat->miso.gpio, "soft_spi_miso");
-
-       gpio_direction_output(plat->sclk.gpio, slave->mode & SPI_CPOL);
-       gpio_direction_output(plat->mosi.gpio, 1);
-       gpio_direction_input(plat->miso.gpio);
-       gpio_direction_output(plat->cs.gpio, !(slave->mode & SPI_CS_HIGH));
+       int cs_flags, clk_flags;
+
+       cs_flags = (slave->mode & SPI_CS_HIGH) ? 0 : GPIOD_ACTIVE_LOW;
+       clk_flags = (slave->mode & SPI_CPOL) ? GPIOD_ACTIVE_LOW : 0;
+       if (gpio_request_by_name(dev, "cs-gpio", 0, &plat->cs,
+                                GPIOD_IS_OUT | cs_flags) ||
+           gpio_request_by_name(dev, "sclk-gpio", 0, &plat->sclk,
+                                GPIOD_IS_OUT | clk_flags) ||
+           gpio_request_by_name(dev, "mosi-gpio", 0, &plat->mosi,
+                                GPIOD_IS_OUT | GPIOD_IS_OUT_ACTIVE) ||
+           gpio_request_by_name(dev, "miso-gpio", 0, &plat->miso,
+                                GPIOD_IS_IN))
+               return -EINVAL;
 
        return 0;
 }
@@ -246,7 +232,5 @@ U_BOOT_DRIVER(soft_spi) = {
        .ofdata_to_platdata = soft_spi_ofdata_to_platdata,
        .platdata_auto_alloc_size = sizeof(struct soft_spi_platdata),
        .priv_auto_alloc_size = sizeof(struct soft_spi_priv),
-       .per_child_auto_alloc_size      = sizeof(struct spi_slave),
        .probe  = soft_spi_probe,
-       .child_pre_probe        = soft_spi_child_pre_probe,
 };
index 7a57bceb260f1c3e79fc9ed4d735f1b27c45160b..63a6217cc62d0085b6c4ba259415fae514651ba9 100644 (file)
@@ -98,21 +98,51 @@ int spi_post_bind(struct udevice *dev)
        return dm_scan_fdt_node(dev, gd->fdt_blob, dev->of_offset, false);
 }
 
-int spi_post_probe(struct udevice *dev)
+int spi_child_post_bind(struct udevice *dev)
 {
-       struct dm_spi_bus *spi = dev->uclass_priv;
+       struct dm_spi_slave_platdata *plat = dev_get_parent_platdata(dev);
 
-       spi->max_hz = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+       if (dev->of_offset == -1)
+               return 0;
+
+       return spi_slave_ofdata_to_platdata(gd->fdt_blob, dev->of_offset, plat);
+}
+
+int spi_post_probe(struct udevice *bus)
+{
+       struct dm_spi_bus *spi = bus->uclass_priv;
+
+       spi->max_hz = fdtdec_get_int(gd->fdt_blob, bus->of_offset,
                                     "spi-max-frequency", 0);
 
        return 0;
 }
 
-int spi_chip_select(struct udevice *dev)
+int spi_child_pre_probe(struct udevice *dev)
 {
+       struct dm_spi_slave_platdata *plat = dev_get_parent_platdata(dev);
        struct spi_slave *slave = dev_get_parentdata(dev);
 
-       return slave ? slave->cs : -ENOENT;
+       /*
+        * This is needed because we pass struct spi_slave around the place
+        * instead slave->dev (a struct udevice). So we have to have some
+        * way to access the slave udevice given struct spi_slave. Once we
+        * change the SPI API to use udevice instead of spi_slave, we can
+        * drop this.
+        */
+       slave->dev = dev;
+
+       slave->max_hz = plat->max_hz;
+       slave->mode = plat->mode;
+
+       return 0;
+}
+
+int spi_chip_select(struct udevice *dev)
+{
+       struct dm_spi_slave_platdata *plat = dev_get_parent_platdata(dev);
+
+       return plat ? plat->cs : -ENOENT;
 }
 
 int spi_find_chip_select(struct udevice *bus, int cs, struct udevice **devp)
@@ -121,17 +151,11 @@ int spi_find_chip_select(struct udevice *bus, int cs, struct udevice **devp)
 
        for (device_find_first_child(bus, &dev); dev;
             device_find_next_child(&dev)) {
-               struct spi_slave store;
-               struct spi_slave *slave = dev_get_parentdata(dev);
+               struct dm_spi_slave_platdata *plat;
 
-               if (!slave)  {
-                       slave = &store;
-                       spi_ofdata_to_platdata(gd->fdt_blob, dev->of_offset,
-                                              slave);
-               }
-               debug("%s: slave=%p, cs=%d\n", __func__, slave,
-                     slave ? slave->cs : -1);
-               if (slave && slave->cs == cs) {
+               plat = dev_get_parent_platdata(dev);
+               debug("%s: plat=%p, cs=%d\n", __func__, plat, plat->cs);
+               if (plat->cs == cs) {
                        *devp = dev;
                        return 0;
                }
@@ -215,7 +239,6 @@ int spi_get_bus_and_cs(int busnum, int cs, int speed, int mode,
                       struct udevice **busp, struct spi_slave **devp)
 {
        struct udevice *bus, *dev;
-       struct spi_slave *slave;
        bool created = false;
        int ret;
 
@@ -232,11 +255,17 @@ int spi_get_bus_and_cs(int busnum, int cs, int speed, int mode,
         * SPI flash chip - we will bind to the correct driver.
         */
        if (ret == -ENODEV && drv_name) {
+               struct dm_spi_slave_platdata *plat;
+
                debug("%s: Binding new device '%s', busnum=%d, cs=%d, driver=%s\n",
                      __func__, dev_name, busnum, cs, drv_name);
                ret = device_bind_driver(bus, drv_name, dev_name, &dev);
                if (ret)
                        return ret;
+               plat = dev_get_parent_platdata(dev);
+               plat->cs = cs;
+               plat->max_hz = speed;
+               plat->mode = mode;
                created = true;
        } else if (ret) {
                printf("Invalid chip select %d:%d (err=%d)\n", busnum, cs,
@@ -245,23 +274,13 @@ int spi_get_bus_and_cs(int busnum, int cs, int speed, int mode,
        }
 
        if (!device_active(dev)) {
-               slave = (struct spi_slave *)calloc(1,
-                                                  sizeof(struct spi_slave));
-               if (!slave) {
-                       ret = -ENOMEM;
-                       goto err;
-               }
+               struct spi_slave *slave;
 
-               ret = spi_ofdata_to_platdata(gd->fdt_blob, dev->of_offset,
-                                            slave);
+               ret = device_probe(dev);
                if (ret)
                        goto err;
-               slave->cs = cs;
+               slave = dev_get_parentdata(dev);
                slave->dev = dev;
-               ret = device_probe_child(dev, slave);
-               free(slave);
-               if (ret)
-                       goto err;
        }
 
        ret = spi_set_speed_mode(bus, speed, mode);
@@ -275,6 +294,8 @@ int spi_get_bus_and_cs(int busnum, int cs, int speed, int mode,
        return 0;
 
 err:
+       debug("%s: Error path, credted=%d, device '%s'\n", __func__,
+             created, dev->name);
        if (created) {
                device_remove(dev);
                device_unbind(dev);
@@ -321,13 +342,13 @@ void spi_free_slave(struct spi_slave *slave)
        slave->dev = NULL;
 }
 
-int spi_ofdata_to_platdata(const void *blob, int node,
-                          struct spi_slave *spi)
+int spi_slave_ofdata_to_platdata(const void *blob, int node,
+                                struct dm_spi_slave_platdata *plat)
 {
        int mode = 0;
 
-       spi->cs = fdtdec_get_int(blob, node, "reg", -1);
-       spi->max_hz = fdtdec_get_int(blob, node, "spi-max-frequency", 0);
+       plat->cs = fdtdec_get_int(blob, node, "reg", -1);
+       plat->max_hz = fdtdec_get_int(blob, node, "spi-max-frequency", 0);
        if (fdtdec_get_bool(blob, node, "spi-cpol"))
                mode |= SPI_CPOL;
        if (fdtdec_get_bool(blob, node, "spi-cpha"))
@@ -336,7 +357,7 @@ int spi_ofdata_to_platdata(const void *blob, int node,
                mode |= SPI_CS_HIGH;
        if (fdtdec_get_bool(blob, node, "spi-half-duplex"))
                mode |= SPI_PREAMBLE;
-       spi->mode = mode;
+       plat->mode = mode;
 
        return 0;
 }
@@ -344,9 +365,15 @@ int spi_ofdata_to_platdata(const void *blob, int node,
 UCLASS_DRIVER(spi) = {
        .id             = UCLASS_SPI,
        .name           = "spi",
+       .flags          = DM_UC_FLAG_SEQ_ALIAS,
        .post_bind      = spi_post_bind,
        .post_probe     = spi_post_probe,
+       .child_pre_probe = spi_child_pre_probe,
        .per_device_auto_alloc_size = sizeof(struct dm_spi_bus),
+       .per_child_auto_alloc_size = sizeof(struct spi_slave),
+       .per_child_platdata_auto_alloc_size =
+                       sizeof(struct dm_spi_slave_platdata),
+       .child_post_bind = spi_child_post_bind,
 };
 
 UCLASS_DRIVER(spi_generic) = {
index 2d97625fba73b81dcb8a2ba2d55d5e1d5eef0bcb..53ff9ea22105353180159203def640905b5fecf8 100644 (file)
@@ -407,6 +407,5 @@ U_BOOT_DRIVER(tegra114_spi) = {
        .ofdata_to_platdata = tegra114_spi_ofdata_to_platdata,
        .platdata_auto_alloc_size = sizeof(struct tegra_spi_platdata),
        .priv_auto_alloc_size = sizeof(struct tegra114_spi_priv),
-       .per_child_auto_alloc_size      = sizeof(struct spi_slave),
        .probe  = tegra114_spi_probe,
 };
index 7d0d0f37fc70a7f5f5da821b2af8589bf59ac7a1..78c74cdf37fe095d8efa34c26ab5df0093e305bd 100644 (file)
@@ -348,6 +348,5 @@ U_BOOT_DRIVER(tegra20_sflash) = {
        .ofdata_to_platdata = tegra20_sflash_ofdata_to_platdata,
        .platdata_auto_alloc_size = sizeof(struct tegra_spi_platdata),
        .priv_auto_alloc_size = sizeof(struct tegra20_sflash_priv),
-       .per_child_auto_alloc_size      = sizeof(struct spi_slave),
        .probe  = tegra20_sflash_probe,
 };
index 213fa5f7939a848889e0168d1991040dd9830a61..597d6ad5ccecb8e36818bb6d2d555c2f3b14294f 100644 (file)
@@ -361,6 +361,5 @@ U_BOOT_DRIVER(tegra30_spi) = {
        .ofdata_to_platdata = tegra30_spi_ofdata_to_platdata,
        .platdata_auto_alloc_size = sizeof(struct tegra_spi_platdata),
        .priv_auto_alloc_size = sizeof(struct tegra30_spi_priv),
-       .per_child_auto_alloc_size      = sizeof(struct spi_slave),
        .probe  = tegra30_spi_probe,
 };
index b8ca720e25bf7ae342814b6015ba41ba789c0d22..0ef85db7b51d51e3db2ce300a158699b87e30744 100644 (file)
@@ -271,6 +271,19 @@ static int asix_read_mac(struct eth_device *eth)
        return 0;
 }
 
+static int asix_write_mac(struct eth_device *eth)
+{
+       struct ueth_data *dev = (struct ueth_data *)eth->priv;
+       int ret;
+
+       ret = asix_write_cmd(dev, AX_ACCESS_MAC, AX_NODE_ID, ETH_ALEN,
+                                ETH_ALEN, eth->enetaddr);
+       if (ret < 0)
+               debug("Failed to set MAC address: %02x\n", ret);
+
+       return ret;
+}
+
 static int asix_basic_reset(struct ueth_data *dev)
 {
        struct asix_private *dev_priv = (struct asix_private *)dev->dev_priv;
@@ -686,6 +699,7 @@ int ax88179_eth_get_info(struct usb_device *dev, struct ueth_data *ss,
        eth->send = asix_send;
        eth->recv = asix_recv;
        eth->halt = asix_halt;
+       eth->write_hwaddr = asix_write_mac;
        eth->priv = ss;
 
        if (asix_basic_reset(ss))
index a4c5606527a824bca5f53a5c7514d38e2d530f8b..98c2da6f14bbf3522125221cde25e8946ad18281 100644 (file)
@@ -761,6 +761,14 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
                        if (value >= 0)
                                value = min(w_length, (u16) value);
                        break;
+               case USB_DT_BOS:
+                       /*
+                        * The USB compliance test (USB 2.0 Command Verifier)
+                        * issues this request. We should not run into the
+                        * default path here. But return for now until
+                        * the superspeed support is added.
+                        */
+                       break;
                default:
                        goto unknown;
                }
index ead71eba6b136db95c9cd4b017ef2da6827872a4..77a1567a944c71b95fc5c11d077138e7cc6df563 100644 (file)
@@ -780,6 +780,13 @@ static int dfu_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
        return 0;
 }
 
+static int __dfu_get_alt(struct usb_function *f, unsigned intf)
+{
+       struct f_dfu *f_dfu = func_to_dfu(f);
+
+       return f_dfu->altsetting;
+}
+
 /* TODO: is this really what we need here? */
 static void dfu_disable(struct usb_function *f)
 {
@@ -806,6 +813,7 @@ static int dfu_bind_config(struct usb_configuration *c)
        f_dfu->usb_function.bind = dfu_bind;
        f_dfu->usb_function.unbind = dfu_unbind;
        f_dfu->usb_function.set_alt = dfu_set_alt;
+       f_dfu->usb_function.get_alt = __dfu_get_alt;
        f_dfu->usb_function.disable = dfu_disable;
        f_dfu->usb_function.strings = dfu_generic_strings;
        f_dfu->usb_function.setup = dfu_handle;
index 8945c5b665511b16dc44dd04c240dcbedc0af3b1..d4460b2dc715fe2ca197533aed285ee63fe35f0f 100644 (file)
@@ -1950,11 +1950,11 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
        dev->watchdog.period = 5000 * CONFIG_SYS_HZ / 1000000; /* 5 ms */
        dev->watchdog.function = udc_watchdog;
 
+       dev->mach = &mach_info;
+
        udc_disable(dev);
        udc_reinit(dev);
 
-       dev->mach = &mach_info;
-
        dev->gadget.name = "pxa2xx_udc";
        retval = driver->bind(&dev->gadget);
        if (retval) {
index 6fdbf5724f4a6527757d8cec692c9a59c7529b6a..f3c077d82e4d4c726ef99c32189f759571feb46e 100644 (file)
@@ -31,7 +31,7 @@ DECLARE_GLOBAL_DATA_PTR;
 struct exynos_ehci {
        struct exynos_usb_phy *usb;
        struct ehci_hccr *hcd;
-       struct fdt_gpio_state vbus_gpio;
+       struct gpio_desc vbus_gpio;
 };
 
 static struct exynos_ehci exynos;
@@ -61,7 +61,8 @@ static int exynos_usb_parse_dt(const void *blob, struct exynos_ehci *exynos)
        exynos->hcd = (struct ehci_hccr *)addr;
 
        /* Vbus gpio */
-       fdtdec_decode_gpio(blob, node, "samsung,vbus-gpio", &exynos->vbus_gpio);
+       gpio_request_by_name_nodev(blob, node, "samsung,vbus-gpio", 0,
+                                  &exynos->vbus_gpio, GPIOD_IS_OUT);
 
        depth = 0;
        node = fdtdec_next_compatible_subnode(blob, node,
@@ -236,9 +237,8 @@ int ehci_hcd_init(int index, enum usb_init_type init,
 
 #ifdef CONFIG_OF_CONTROL
        /* setup the Vbus gpio here */
-       if (fdt_gpio_isvalid(&ctx->vbus_gpio) &&
-           !fdtdec_setup_gpio(&ctx->vbus_gpio))
-               gpio_direction_output(ctx->vbus_gpio.gpio, 1);
+       if (dm_gpio_is_valid(&ctx->vbus_gpio))
+               dm_gpio_set_value(&ctx->vbus_gpio, 1);
 #endif
 
        setup_usb_phy(ctx->usb);
index bc7606646bbcf9ac76ab679a8f85405ceaa6d45a..f1fb19013281c6483c052ce77b64689faf09fe93 100644 (file)
@@ -1148,7 +1148,7 @@ disable_periodic(struct ehci_ctrl *ctrl)
 
 struct int_queue *
 create_int_queue(struct usb_device *dev, unsigned long pipe, int queuesize,
-                int elementsize, void *buffer)
+                int elementsize, void *buffer, int interval)
 {
        struct ehci_ctrl *ctrl = dev->controller;
        struct int_queue *result = NULL;
@@ -1398,7 +1398,7 @@ submit_int_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
        debug("dev=%p, pipe=%lu, buffer=%p, length=%d, interval=%d",
              dev, pipe, buffer, length, interval);
 
-       queue = create_int_queue(dev, pipe, 1, length, buffer);
+       queue = create_int_queue(dev, pipe, 1, length, buffer, interval);
        if (!queue)
                return -1;
 
index 5f0a98e8b80b59f79372e2185e31e16585c6dd7f..b5ad1e35e54c668fa0e5d3c9207d74d39904527a 100644 (file)
@@ -72,8 +72,8 @@ struct fdt_usb {
        enum usb_init_type init_type;
        enum dr_mode dr_mode;   /* dual role mode */
        enum periph_id periph_id;/* peripheral id */
-       struct fdt_gpio_state vbus_gpio;        /* GPIO for vbus enable */
-       struct fdt_gpio_state phy_reset_gpio; /* GPIO to reset ULPI phy */
+       struct gpio_desc vbus_gpio;     /* GPIO for vbus enable */
+       struct gpio_desc phy_reset_gpio; /* GPIO to reset ULPI phy */
 };
 
 static struct fdt_usb port[USB_PORTS_MAX];     /* List of valid USB ports */
@@ -252,17 +252,14 @@ static void set_up_vbus(struct fdt_usb *config, enum usb_init_type init)
                return;
        }
 
-       if (fdt_gpio_isvalid(&config->vbus_gpio)) {
+       if (dm_gpio_is_valid(&config->vbus_gpio)) {
                int vbus_value;
 
-               fdtdec_setup_gpio(&config->vbus_gpio);
+               vbus_value = (init == USB_INIT_HOST);
+               dm_gpio_set_value(&config->vbus_gpio, vbus_value);
 
-               vbus_value = (init == USB_INIT_HOST) ^
-                            !!(config->vbus_gpio.flags & FDT_GPIO_ACTIVE_LOW);
-               gpio_direction_output(config->vbus_gpio.gpio, vbus_value);
-
-               debug("set_up_vbus: GPIO %d %d\n", config->vbus_gpio.gpio,
-                     vbus_value);
+               debug("set_up_vbus: GPIO %d %d\n",
+                     gpio_get_number(&config->vbus_gpio), vbus_value);
        }
 }
 
@@ -360,7 +357,7 @@ static int init_utmi_usb_controller(struct fdt_usb *config,
         * mux must be switched to actually use a_sess_vld threshold.
         */
        if (config->dr_mode == DR_MODE_OTG &&
-           fdt_gpio_isvalid(&config->vbus_gpio))
+           dm_gpio_is_valid(&config->vbus_gpio))
                clrsetbits_le32(&usbctlr->usb1_legacy_ctrl,
                        VBUS_SENSE_CTL_MASK,
                        VBUS_SENSE_CTL_A_SESS_VLD << VBUS_SENSE_CTL_SHIFT);
@@ -569,11 +566,10 @@ static int init_ulpi_usb_controller(struct fdt_usb *config,
        clock_set_pllout(CLOCK_ID_PERIPH, PLL_OUT4, CONFIG_ULPI_REF_CLK);
 
        /* reset ULPI phy */
-       if (fdt_gpio_isvalid(&config->phy_reset_gpio)) {
-               fdtdec_setup_gpio(&config->phy_reset_gpio);
-               gpio_direction_output(config->phy_reset_gpio.gpio, 0);
+       if (dm_gpio_is_valid(&config->phy_reset_gpio)) {
+               dm_gpio_set_value(&config->phy_reset_gpio, 0);
                mdelay(5);
-               gpio_set_value(config->phy_reset_gpio.gpio, 1);
+               dm_gpio_set_value(&config->phy_reset_gpio, 1);
        }
 
        /* Reset the usb controller */
@@ -685,14 +681,16 @@ static int fdt_decode_usb(const void *blob, int node, struct fdt_usb *config)
                debug("%s: Missing/invalid peripheral ID\n", __func__);
                return -FDT_ERR_NOTFOUND;
        }
-       fdtdec_decode_gpio(blob, node, "nvidia,vbus-gpio", &config->vbus_gpio);
-       fdtdec_decode_gpio(blob, node, "nvidia,phy-reset-gpio",
-                       &config->phy_reset_gpio);
+       gpio_request_by_name_nodev(blob, node, "nvidia,vbus-gpio", 0,
+                                  &config->vbus_gpio, GPIOD_IS_OUT);
+       gpio_request_by_name_nodev(blob, node, "nvidia,phy-reset-gpio", 0,
+                                  &config->phy_reset_gpio, GPIOD_IS_OUT);
        debug("enabled=%d, legacy_mode=%d, utmi=%d, ulpi=%d, periph_id=%d, "
                "vbus=%d, phy_reset=%d, dr_mode=%d\n",
                config->enabled, config->has_legacy_mode, config->utmi,
-               config->ulpi, config->periph_id, config->vbus_gpio.gpio,
-               config->phy_reset_gpio.gpio, config->dr_mode);
+               config->ulpi, config->periph_id,
+               gpio_get_number(&config->vbus_gpio),
+               gpio_get_number(&config->phy_reset_gpio), config->dr_mode);
 
        return 0;
 }
index b4946a3f1cf5900614e7238f8033979876eac942..a77c8bc91930524e75de4749accb927ab9d2d586 100644 (file)
@@ -40,7 +40,7 @@ struct exynos_xhci {
        struct exynos_usb3_phy *usb3_phy;
        struct xhci_hccr *hcd;
        struct dwc3 *dwc3_reg;
-       struct fdt_gpio_state vbus_gpio;
+       struct gpio_desc vbus_gpio;
 };
 
 static struct exynos_xhci exynos;
@@ -69,7 +69,8 @@ static int exynos_usb3_parse_dt(const void *blob, struct exynos_xhci *exynos)
        exynos->hcd = (struct xhci_hccr *)addr;
 
        /* Vbus gpio */
-       fdtdec_decode_gpio(blob, node, "samsung,vbus-gpio", &exynos->vbus_gpio);
+       gpio_request_by_name_nodev(blob, node, "samsung,vbus-gpio", 0,
+                                  &exynos->vbus_gpio, GPIOD_IS_OUT);
 
        depth = 0;
        node = fdtdec_next_compatible_subnode(blob, node,
@@ -298,9 +299,8 @@ int xhci_hcd_init(int index, struct xhci_hccr **hccr, struct xhci_hcor **hcor)
 
 #ifdef CONFIG_OF_CONTROL
        /* setup the Vbus gpio here */
-       if (fdt_gpio_isvalid(&ctx->vbus_gpio) &&
-           !fdtdec_setup_gpio(&ctx->vbus_gpio))
-               gpio_direction_output(ctx->vbus_gpio.gpio, 1);
+       if (dm_gpio_is_valid(&ctx->vbus_gpio))
+               dm_gpio_set_value(&ctx->vbus_gpio, 1);
 #endif
 
        ret = exynos_xhci_core_init(ctx);
index 3facf0fc105dbf430d0eeb6b884fcb7e0ee9081e..9edeece381de106b1ae613085fbded6240bda0c5 100644 (file)
@@ -8,6 +8,7 @@ obj-$(CONFIG_MUSB_HOST) += musb_host.o musb_core.o musb_uboot.o
 obj-$(CONFIG_USB_MUSB_DSPS) += musb_dsps.o
 obj-$(CONFIG_USB_MUSB_AM35X) += am35x.o
 obj-$(CONFIG_USB_MUSB_OMAP2PLUS) += omap2430.o
+obj-$(CONFIG_USB_MUSB_SUNXI) += sunxi.o
 
 ccflags-y := $(call cc-option,-Wno-unused-variable) \
                $(call cc-option,-Wno-unused-but-set-variable) \
index bbcee88241ba33f05cafad51d3162bc63bc12021..437309ceb44a380bfed9b05d73d6f9828db08210 100644 (file)
@@ -2130,8 +2130,6 @@ done:
        return ret;
 }
 
-
-#ifndef __UBOOT__
 /*
  * abort a transfer that's at the head of a hardware queue.
  * called with controller locked, irqs blocked
@@ -2195,7 +2193,14 @@ static int musb_cleanup_urb(struct urb *urb, struct musb_qh *qh)
        return status;
 }
 
-static int musb_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
+#ifndef __UBOOT__
+static int musb_urb_dequeue(
+#else
+int musb_urb_dequeue(
+#endif
+       struct usb_hcd *hcd,
+       struct urb *urb,
+       int status)
 {
        struct musb             *musb = hcd_to_musb(hcd);
        struct musb_qh          *qh;
@@ -2253,6 +2258,7 @@ done:
        return ret;
 }
 
+#ifndef __UBOOT__
 /* disable an endpoint */
 static void
 musb_h_disable(struct usb_hcd *hcd, struct usb_host_endpoint *hep)
index ebebe0c02a57c61b6cd9cb881990714feb0d5c6b..546b4a2715f4549c96e0b426f2dad78e86a1772f 100644 (file)
@@ -110,5 +110,6 @@ static inline struct urb *next_urb(struct musb_qh *qh)
 
 #ifdef __UBOOT__
 int musb_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flags);
+int musb_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status);
 #endif
 #endif                         /* _MUSB_HOST_H */
index 03f2655af290758cb708a67f832abd6257df2894..27e4ed4ec6a3257b9e49f8b416fa90c758e32d74 100644 (file)
 
 #ifndef CONFIG_BLACKFIN
 
+/* SUNXI has different reg addresses, but identical r/w functions */
+#ifndef CONFIG_ARCH_SUNXI 
+
 /*
  * Common USB registers
  */
 #define MUSB_BUSCTL_OFFSET(_epnum, _offset) \
        (0x80 + (8*(_epnum)) + (_offset))
 
+#else /* CONFIG_ARCH_SUNXI */
+
+/*
+ * Common USB registers
+ */
+
+#define MUSB_FADDR             0x0098
+#define MUSB_POWER             0x0040
+
+#define MUSB_INTRTX            0x0044
+#define MUSB_INTRRX            0x0046
+#define MUSB_INTRTXE           0x0048
+#define MUSB_INTRRXE           0x004A
+#define MUSB_INTRUSB           0x004C
+#define MUSB_INTRUSBE          0x0050
+#define MUSB_FRAME             0x0054
+#define MUSB_INDEX             0x0042
+#define MUSB_TESTMODE          0x007C
+
+/* Get offset for a given FIFO from musb->mregs */
+#define MUSB_FIFO_OFFSET(epnum)        (0x00 + ((epnum) * 4))
+
+/*
+ * Additional Control Registers
+ */
+
+#define MUSB_DEVCTL            0x0041
+
+/* These are always controlled through the INDEX register */
+#define MUSB_TXFIFOSZ          0x0090
+#define MUSB_RXFIFOSZ          0x0094
+#define MUSB_TXFIFOADD         0x0092
+#define MUSB_RXFIFOADD         0x0096
+
+#define MUSB_EPINFO            0x0078
+#define MUSB_RAMINFO           0x0079
+#define MUSB_LINKINFO          0x007A
+#define MUSB_VPLEN             0x007B
+#define MUSB_HS_EOF1           0x007C
+#define MUSB_FS_EOF1           0x007D
+#define MUSB_LS_EOF1           0x007E
+
+/* Offsets to endpoint registers */
+#define MUSB_TXMAXP            0x0080
+#define MUSB_TXCSR             0x0082
+#define MUSB_CSR0              0x0082
+#define MUSB_RXMAXP            0x0084
+#define MUSB_RXCSR             0x0086
+#define MUSB_RXCOUNT           0x0088
+#define MUSB_COUNT0            0x0088
+#define MUSB_TXTYPE            0x008C
+#define MUSB_TYPE0             0x008C
+#define MUSB_TXINTERVAL                0x008D
+#define MUSB_NAKLIMIT0         0x008D
+#define MUSB_RXTYPE            0x008E
+#define MUSB_RXINTERVAL                0x008F
+
+#define MUSB_CONFIGDATA                0x00b0 /* musb_read_configdata adds 0x10 ! */
+#define MUSB_FIFOSIZE          0x0090
+
+/* Offsets to endpoint registers in indexed model (using INDEX register) */
+#define MUSB_INDEXED_OFFSET(_epnum, _offset) (_offset)
+
+#define MUSB_TXCSR_MODE                0x2000
+
+/* "bus control"/target registers, for host side multipoint (external hubs) */
+#define MUSB_TXFUNCADDR                0x0098
+#define MUSB_TXHUBADDR         0x009A
+#define MUSB_TXHUBPORT         0x009B
+
+#define MUSB_RXFUNCADDR                0x009C
+#define MUSB_RXHUBADDR         0x009E
+#define MUSB_RXHUBPORT         0x009F
+
+/* Endpoint is selected with MUSB_INDEX. */
+#define MUSB_BUSCTL_OFFSET(_epnum, _offset) (_offset)
+
+#endif /* CONFIG_ARCH_SUNXI */
+
 static inline void musb_write_txfifosz(void __iomem *mbase, u8 c_size)
 {
        musb_writeb(mbase, MUSB_TXFIFOSZ, c_size);
@@ -340,7 +422,9 @@ static inline void  musb_write_rxfifoadd(void __iomem *mbase, u16 c_off)
 
 static inline void musb_write_ulpi_buscontrol(void __iomem *mbase, u8 val)
 {
+#ifndef CONFIG_ARCH_SUNXI /* No ulpi on sunxi */
        musb_writeb(mbase, MUSB_ULPI_BUSCONTROL, val);
+#endif
 }
 
 static inline u8 musb_read_txfifosz(void __iomem *mbase)
@@ -365,7 +449,11 @@ static inline u16  musb_read_rxfifoadd(void __iomem *mbase)
 
 static inline u8 musb_read_ulpi_buscontrol(void __iomem *mbase)
 {
+#ifdef CONFIG_ARCH_SUNXI /* No ulpi on sunxi */
+       return 0;
+#else
        return musb_readb(mbase, MUSB_ULPI_BUSCONTROL);
+#endif
 }
 
 static inline u8 musb_read_configdata(void __iomem *mbase)
@@ -376,7 +464,11 @@ static inline u8 musb_read_configdata(void __iomem *mbase)
 
 static inline u16 musb_read_hwvers(void __iomem *mbase)
 {
+#ifdef CONFIG_ARCH_SUNXI
+       return 0; /* Unknown version */
+#else
        return musb_readw(mbase, MUSB_HWVERS);
+#endif
 }
 
 static inline void __iomem *musb_read_target_reg_base(u8 i, void __iomem *mbase)
index 2676f09c3844d159c5f15130ccdff6c287339aed..6e58ddf02cc34b67b4550b9f752d5a00c2d0615c 100644 (file)
 #include "musb_gadget.h"
 
 #ifdef CONFIG_MUSB_HOST
+struct int_queue {
+       struct usb_host_endpoint hep;
+       struct urb urb;
+};
+
 static struct musb *host;
 static struct usb_hcd hcd;
 static enum usb_device_speed host_speed;
@@ -25,45 +30,42 @@ static void musb_host_complete_urb(struct urb *urb)
 static struct usb_host_endpoint hep;
 static struct urb urb;
 
-static struct urb *construct_urb(struct usb_device *dev, int endpoint_type,
-                               unsigned long pipe, void *buffer, int len,
-                               struct devrequest *setup, int interval)
+static void construct_urb(struct urb *urb, struct usb_host_endpoint *hep,
+                         struct usb_device *dev, int endpoint_type,
+                         unsigned long pipe, void *buffer, int len,
+                         struct devrequest *setup, int interval)
 {
        int epnum = usb_pipeendpoint(pipe);
        int is_in = usb_pipein(pipe);
 
-       memset(&urb, 0, sizeof(struct urb));
-       memset(&hep, 0, sizeof(struct usb_host_endpoint));
-       INIT_LIST_HEAD(&hep.urb_list);
-       INIT_LIST_HEAD(&urb.urb_list);
-       urb.ep = &hep;
-       urb.complete = musb_host_complete_urb;
-       urb.status = -EINPROGRESS;
-       urb.dev = dev;
-       urb.pipe = pipe;
-       urb.transfer_buffer = buffer;
-       urb.transfer_dma = (unsigned long)buffer;
-       urb.transfer_buffer_length = len;
-       urb.setup_packet = (unsigned char *)setup;
-
-       urb.ep->desc.wMaxPacketSize =
+       memset(urb, 0, sizeof(struct urb));
+       memset(hep, 0, sizeof(struct usb_host_endpoint));
+       INIT_LIST_HEAD(&hep->urb_list);
+       INIT_LIST_HEAD(&urb->urb_list);
+       urb->ep = hep;
+       urb->complete = musb_host_complete_urb;
+       urb->status = -EINPROGRESS;
+       urb->dev = dev;
+       urb->pipe = pipe;
+       urb->transfer_buffer = buffer;
+       urb->transfer_dma = (unsigned long)buffer;
+       urb->transfer_buffer_length = len;
+       urb->setup_packet = (unsigned char *)setup;
+
+       urb->ep->desc.wMaxPacketSize =
                __cpu_to_le16(is_in ? dev->epmaxpacketin[epnum] :
                                dev->epmaxpacketout[epnum]);
-       urb.ep->desc.bmAttributes = endpoint_type;
-       urb.ep->desc.bEndpointAddress =
+       urb->ep->desc.bmAttributes = endpoint_type;
+       urb->ep->desc.bEndpointAddress =
                (is_in ? USB_DIR_IN : USB_DIR_OUT) | epnum;
-       urb.ep->desc.bInterval = interval;
-
-       return &urb;
+       urb->ep->desc.bInterval = interval;
 }
 
-#define MUSB_HOST_TIMEOUT      0x3ffffff
-
 static int submit_urb(struct usb_hcd *hcd, struct urb *urb)
 {
        struct musb *host = hcd->hcd_priv;
        int ret;
-       int timeout;
+       unsigned long timeout;
 
        ret = musb_urb_enqueue(hcd, urb, 0);
        if (ret < 0) {
@@ -71,12 +73,16 @@ static int submit_urb(struct usb_hcd *hcd, struct urb *urb)
                return ret;
        }
 
-       timeout = MUSB_HOST_TIMEOUT;
+       timeout = get_timer(0) + USB_TIMEOUT_MS(urb->pipe);
        do {
                if (ctrlc())
                        return -EIO;
                host->isr(0, host);
-       } while ((urb->dev->status & USB_ST_NOT_PROC) && --timeout);
+       } while (urb->status == -EINPROGRESS &&
+                get_timer(0) < timeout);
+
+       if (urb->status == -EINPROGRESS)
+               musb_urb_dequeue(hcd, urb, -ETIME);
 
        return urb->status;
 }
@@ -84,38 +90,117 @@ static int submit_urb(struct usb_hcd *hcd, struct urb *urb)
 int submit_control_msg(struct usb_device *dev, unsigned long pipe,
                        void *buffer, int len, struct devrequest *setup)
 {
-       struct urb *urb = construct_urb(dev, USB_ENDPOINT_XFER_CONTROL, pipe,
-                                       buffer, len, setup, 0);
+       construct_urb(&urb, &hep, dev, USB_ENDPOINT_XFER_CONTROL, pipe,
+                     buffer, len, setup, 0);
 
        /* Fix speed for non hub-attached devices */
        if (!dev->parent)
                dev->speed = host_speed;
 
-       return submit_urb(&hcd, urb);
+       return submit_urb(&hcd, &urb);
 }
 
 
 int submit_bulk_msg(struct usb_device *dev, unsigned long pipe,
                                        void *buffer, int len)
 {
-       struct urb *urb = construct_urb(dev, USB_ENDPOINT_XFER_BULK, pipe,
-                                       buffer, len, NULL, 0);
-       return submit_urb(&hcd, urb);
+       construct_urb(&urb, &hep, dev, USB_ENDPOINT_XFER_BULK, pipe,
+                     buffer, len, NULL, 0);
+       return submit_urb(&hcd, &urb);
 }
 
 int submit_int_msg(struct usb_device *dev, unsigned long pipe,
                                void *buffer, int len, int interval)
 {
-       struct urb *urb = construct_urb(dev, USB_ENDPOINT_XFER_INT, pipe,
-                                       buffer, len, NULL, interval);
-       return submit_urb(&hcd, urb);
+       construct_urb(&urb, &hep, dev, USB_ENDPOINT_XFER_INT, pipe,
+                     buffer, len, NULL, interval);
+       return submit_urb(&hcd, &urb);
 }
 
-int usb_lowlevel_init(int index, enum usb_init_type init, void **controller)
+struct int_queue *create_int_queue(struct usb_device *dev, unsigned long pipe,
+       int queuesize, int elementsize, void *buffer, int interval)
+{
+       struct int_queue *queue;
+       int ret, index = usb_pipein(pipe) * 16 + usb_pipeendpoint(pipe);
+
+       if (queuesize != 1) {
+               printf("ERROR musb int-queues only support queuesize 1\n");
+               return NULL;
+       }
+
+       if (dev->int_pending & (1 << index)) {
+               printf("ERROR int-urb is already pending on pipe %lx\n", pipe);
+               return NULL;
+       }
+
+       queue = malloc(sizeof(*queue));
+       if (!queue)
+               return NULL;
+
+       construct_urb(&queue->urb, &queue->hep, dev, USB_ENDPOINT_XFER_INT,
+                     pipe, buffer, elementsize, NULL, interval);
+
+       ret = musb_urb_enqueue(&hcd, &queue->urb, 0);
+       if (ret < 0) {
+               printf("Failed to enqueue URB to controller\n");
+               free(queue);
+               return NULL;
+       }
+
+       dev->int_pending |= 1 << index;
+       return queue;
+}
+
+int destroy_int_queue(struct usb_device *dev, struct int_queue *queue)
+{
+       int index = usb_pipein(queue->urb.pipe) * 16 + 
+                   usb_pipeendpoint(queue->urb.pipe);
+
+       if (queue->urb.status == -EINPROGRESS)
+               musb_urb_dequeue(&hcd, &queue->urb, -ETIME);
+
+       dev->int_pending &= ~(1 << index);
+       free(queue);
+       return 0;
+}
+
+void *poll_int_queue(struct usb_device *dev, struct int_queue *queue)
 {
+       if (queue->urb.status != -EINPROGRESS)
+               return NULL; /* URB has already completed in a prev. poll */
+
+       host->isr(0, host);
+
+       if (queue->urb.status != -EINPROGRESS)
+               return queue->urb.transfer_buffer; /* Done */
+
+       return NULL; /* URB still pending */
+}
+
+void usb_reset_root_port(void)
+{
+       void *mbase = host->mregs;
        u8 power;
+
+       power = musb_readb(mbase, MUSB_POWER);
+       power &= 0xf0;
+       musb_writeb(mbase, MUSB_POWER, MUSB_POWER_RESET | power);
+       mdelay(50);
+       power = musb_readb(mbase, MUSB_POWER);
+       musb_writeb(mbase, MUSB_POWER, ~MUSB_POWER_RESET & power);
+       host->isr(0, host);
+       host_speed = (musb_readb(mbase, MUSB_POWER) & MUSB_POWER_HSMODE) ?
+                       USB_SPEED_HIGH :
+                       (musb_readb(mbase, MUSB_DEVCTL) & MUSB_DEVCTL_FSDEV) ?
+                       USB_SPEED_FULL : USB_SPEED_LOW;
+       mdelay((host_speed == USB_SPEED_LOW) ? 200 : 50);
+}
+
+int usb_lowlevel_init(int index, enum usb_init_type init, void **controller)
+{
        void *mbase;
-       int timeout = MUSB_HOST_TIMEOUT;
+       /* USB spec says it may take up to 1 second for a device to connect */
+       unsigned long timeout = get_timer(0) + 1000;
 
        if (!host) {
                printf("MUSB host is not registered\n");
@@ -127,20 +212,11 @@ int usb_lowlevel_init(int index, enum usb_init_type init, void **controller)
        do {
                if (musb_readb(mbase, MUSB_DEVCTL) & MUSB_DEVCTL_HM)
                        break;
-       } while (--timeout);
-       if (!timeout)
+       } while (get_timer(0) < timeout);
+       if (get_timer(0) >= timeout)
                return -ENODEV;
 
-       power = musb_readb(mbase, MUSB_POWER);
-       musb_writeb(mbase, MUSB_POWER, MUSB_POWER_RESET | power);
-       udelay(30000);
-       power = musb_readb(mbase, MUSB_POWER);
-       musb_writeb(mbase, MUSB_POWER, ~MUSB_POWER_RESET & power);
-       host->isr(0, host);
-       host_speed = (musb_readb(mbase, MUSB_POWER) & MUSB_POWER_HSMODE) ?
-                       USB_SPEED_HIGH :
-                       (musb_readb(mbase, MUSB_DEVCTL) & MUSB_DEVCTL_FSDEV) ?
-                       USB_SPEED_FULL : USB_SPEED_LOW;
+       usb_reset_root_port();
        host->is_active = 1;
        hcd.hcd_priv = host;
 
diff --git a/drivers/usb/musb-new/sunxi.c b/drivers/usb/musb-new/sunxi.c
new file mode 100644 (file)
index 0000000..778916d
--- /dev/null
@@ -0,0 +1,279 @@
+/*
+ * Allwinner SUNXI "glue layer"
+ *
+ * Copyright © 2015 Hans de Goede <hdegoede@redhat.com>
+ * Copyright © 2013 Jussi Kivilinna <jussi.kivilinna@iki.fi>
+ *
+ * Based on the sw_usb "Allwinner OTG Dual Role Controller" code.
+ *  Copyright 2007-2012 (C) Allwinner Technology Co., Ltd.
+ *  javen <javen@allwinnertech.com>
+ *
+ * Based on the DA8xx "glue layer" code.
+ *  Copyright (c) 2008-2009 MontaVista Software, Inc. <source@mvista.com>
+ *  Copyright (C) 2005-2006 by Texas Instruments
+ *
+ * This file is part of the Inventra Controller Driver for Linux.
+ *
+ * The Inventra Controller Driver for Linux is free software; you
+ * can redistribute it and/or modify it under the terms of the GNU
+ * General Public License version 2 as published by the Free Software
+ * Foundation.
+ *
+ */
+#include <common.h>
+#include <asm/arch/cpu.h>
+#include <asm/arch/usbc.h>
+#include "linux-compat.h"
+#include "musb_core.h"
+
+/******************************************************************************
+ ******************************************************************************
+ * From the Allwinner driver
+ ******************************************************************************
+ ******************************************************************************/
+
+/******************************************************************************
+ * From include/sunxi_usb_bsp.h
+ ******************************************************************************/
+
+/* reg offsets */
+#define  USBC_REG_o_ISCR       0x0400
+#define  USBC_REG_o_PHYCTL     0x0404
+#define  USBC_REG_o_PHYBIST    0x0408
+#define  USBC_REG_o_PHYTUNE    0x040c
+
+#define  USBC_REG_o_VEND0      0x0043
+
+/* Interface Status and Control */
+#define  USBC_BP_ISCR_VBUS_VALID_FROM_DATA     30
+#define  USBC_BP_ISCR_VBUS_VALID_FROM_VBUS     29
+#define  USBC_BP_ISCR_EXT_ID_STATUS            28
+#define  USBC_BP_ISCR_EXT_DM_STATUS            27
+#define  USBC_BP_ISCR_EXT_DP_STATUS            26
+#define  USBC_BP_ISCR_MERGED_VBUS_STATUS       25
+#define  USBC_BP_ISCR_MERGED_ID_STATUS         24
+
+#define  USBC_BP_ISCR_ID_PULLUP_EN             17
+#define  USBC_BP_ISCR_DPDM_PULLUP_EN           16
+#define  USBC_BP_ISCR_FORCE_ID                 14
+#define  USBC_BP_ISCR_FORCE_VBUS_VALID         12
+#define  USBC_BP_ISCR_VBUS_VALID_SRC           10
+
+#define  USBC_BP_ISCR_HOSC_EN                  7
+#define  USBC_BP_ISCR_VBUS_CHANGE_DETECT       6
+#define  USBC_BP_ISCR_ID_CHANGE_DETECT         5
+#define  USBC_BP_ISCR_DPDM_CHANGE_DETECT       4
+#define  USBC_BP_ISCR_IRQ_ENABLE               3
+#define  USBC_BP_ISCR_VBUS_CHANGE_DETECT_EN    2
+#define  USBC_BP_ISCR_ID_CHANGE_DETECT_EN      1
+#define  USBC_BP_ISCR_DPDM_CHANGE_DETECT_EN    0
+
+/******************************************************************************
+ * From usbc/usbc.c
+ ******************************************************************************/
+
+static u32 USBC_WakeUp_ClearChangeDetect(u32 reg_val)
+{
+       u32 temp = reg_val;
+
+       temp &= ~(1 << USBC_BP_ISCR_VBUS_CHANGE_DETECT);
+       temp &= ~(1 << USBC_BP_ISCR_ID_CHANGE_DETECT);
+       temp &= ~(1 << USBC_BP_ISCR_DPDM_CHANGE_DETECT);
+
+       return temp;
+}
+
+static void USBC_EnableIdPullUp(__iomem void *base)
+{
+       u32 reg_val;
+
+       reg_val = musb_readl(base, USBC_REG_o_ISCR);
+       reg_val |= (1 << USBC_BP_ISCR_ID_PULLUP_EN);
+       reg_val = USBC_WakeUp_ClearChangeDetect(reg_val);
+       musb_writel(base, USBC_REG_o_ISCR, reg_val);
+}
+
+static void USBC_DisableIdPullUp(__iomem void *base)
+{
+       u32 reg_val;
+
+       reg_val = musb_readl(base, USBC_REG_o_ISCR);
+       reg_val &= ~(1 << USBC_BP_ISCR_ID_PULLUP_EN);
+       reg_val = USBC_WakeUp_ClearChangeDetect(reg_val);
+       musb_writel(base, USBC_REG_o_ISCR, reg_val);
+}
+
+static void USBC_EnableDpDmPullUp(__iomem void *base)
+{
+       u32 reg_val;
+
+       reg_val = musb_readl(base, USBC_REG_o_ISCR);
+       reg_val |= (1 << USBC_BP_ISCR_DPDM_PULLUP_EN);
+       reg_val = USBC_WakeUp_ClearChangeDetect(reg_val);
+       musb_writel(base, USBC_REG_o_ISCR, reg_val);
+}
+
+static void USBC_DisableDpDmPullUp(__iomem void *base)
+{
+       u32 reg_val;
+
+       reg_val = musb_readl(base, USBC_REG_o_ISCR);
+       reg_val &= ~(1 << USBC_BP_ISCR_DPDM_PULLUP_EN);
+       reg_val = USBC_WakeUp_ClearChangeDetect(reg_val);
+       musb_writel(base, USBC_REG_o_ISCR, reg_val);
+}
+
+static void USBC_ForceIdToLow(__iomem void *base)
+{
+       u32 reg_val;
+
+       reg_val = musb_readl(base, USBC_REG_o_ISCR);
+       reg_val &= ~(0x03 << USBC_BP_ISCR_FORCE_ID);
+       reg_val |= (0x02 << USBC_BP_ISCR_FORCE_ID);
+       reg_val = USBC_WakeUp_ClearChangeDetect(reg_val);
+       musb_writel(base, USBC_REG_o_ISCR, reg_val);
+}
+
+static void USBC_ForceIdToHigh(__iomem void *base)
+{
+       u32 reg_val;
+
+       reg_val = musb_readl(base, USBC_REG_o_ISCR);
+       reg_val &= ~(0x03 << USBC_BP_ISCR_FORCE_ID);
+       reg_val |= (0x03 << USBC_BP_ISCR_FORCE_ID);
+       reg_val = USBC_WakeUp_ClearChangeDetect(reg_val);
+       musb_writel(base, USBC_REG_o_ISCR, reg_val);
+}
+
+static void USBC_ForceVbusValidDisable(__iomem void *base)
+{
+       u32 reg_val;
+
+       reg_val = musb_readl(base, USBC_REG_o_ISCR);
+       reg_val &= ~(0x03 << USBC_BP_ISCR_FORCE_VBUS_VALID);
+       reg_val = USBC_WakeUp_ClearChangeDetect(reg_val);
+       musb_writel(base, USBC_REG_o_ISCR, reg_val);
+}
+
+static void USBC_ForceVbusValidToHigh(__iomem void *base)
+{
+       u32 reg_val;
+
+       reg_val = musb_readl(base, USBC_REG_o_ISCR);
+       reg_val &= ~(0x03 << USBC_BP_ISCR_FORCE_VBUS_VALID);
+       reg_val |= (0x03 << USBC_BP_ISCR_FORCE_VBUS_VALID);
+       reg_val = USBC_WakeUp_ClearChangeDetect(reg_val);
+       musb_writel(base, USBC_REG_o_ISCR, reg_val);
+}
+
+static void USBC_ConfigFIFO_Base(void)
+{
+       u32 reg_value;
+
+       /* config usb fifo, 8kb mode */
+       reg_value = readl(SUNXI_SRAMC_BASE + 0x04);
+       reg_value &= ~(0x03 << 0);
+       reg_value |= (1 << 0);
+       writel(reg_value, SUNXI_SRAMC_BASE + 0x04);
+}
+
+/******************************************************************************
+ * MUSB Glue code
+ ******************************************************************************/
+
+static irqreturn_t sunxi_musb_interrupt(int irq, void *__hci)
+{
+       struct musb             *musb = __hci;
+       irqreturn_t             retval = IRQ_NONE;
+
+       /* read and flush interrupts */
+       musb->int_usb = musb_readb(musb->mregs, MUSB_INTRUSB);
+       if (musb->int_usb)
+               musb_writeb(musb->mregs, MUSB_INTRUSB, musb->int_usb);
+       musb->int_tx = musb_readw(musb->mregs, MUSB_INTRTX);
+       if (musb->int_tx)
+               musb_writew(musb->mregs, MUSB_INTRTX, musb->int_tx);
+       musb->int_rx = musb_readw(musb->mregs, MUSB_INTRRX);
+       if (musb->int_rx)
+               musb_writew(musb->mregs, MUSB_INTRRX, musb->int_rx);
+
+       if (musb->int_usb || musb->int_tx || musb->int_rx)
+               retval |= musb_interrupt(musb);
+
+       return retval;
+}
+
+static void sunxi_musb_enable(struct musb *musb)
+{
+       pr_debug("%s():\n", __func__);
+
+       /* select PIO mode */
+       musb_writeb(musb->mregs, USBC_REG_o_VEND0, 0);
+
+       if (is_host_enabled(musb)) {
+               /* port power on */
+               sunxi_usbc_vbus_enable(0);
+       }
+}
+
+static void sunxi_musb_disable(struct musb *musb)
+{
+       pr_debug("%s():\n", __func__);
+
+       /* Put the controller back in a pristane state for "usb reset" */
+       if (musb->is_active) {
+               sunxi_usbc_disable(0);
+               sunxi_usbc_enable(0);
+               musb->is_active = 0;
+       }
+}
+
+static int sunxi_musb_init(struct musb *musb)
+{
+       int err;
+
+       pr_debug("%s():\n", __func__);
+
+       err = sunxi_usbc_request_resources(0);
+       if (err)
+               return err;
+
+       musb->isr = sunxi_musb_interrupt;
+       sunxi_usbc_enable(0);
+
+       USBC_ConfigFIFO_Base();
+       USBC_EnableDpDmPullUp(musb->mregs);
+       USBC_EnableIdPullUp(musb->mregs);
+
+       if (is_host_enabled(musb)) {
+               /* Host mode */
+               USBC_ForceIdToLow(musb->mregs);
+               USBC_ForceVbusValidToHigh(musb->mregs);
+       } else {
+               /* Peripheral mode */
+               USBC_ForceIdToHigh(musb->mregs);
+               USBC_ForceVbusValidDisable(musb->mregs);
+       }
+
+       return 0;
+}
+
+static int sunxi_musb_exit(struct musb *musb)
+{
+       pr_debug("%s():\n", __func__);
+
+       USBC_DisableDpDmPullUp(musb->mregs);
+       USBC_DisableIdPullUp(musb->mregs);
+       sunxi_usbc_vbus_disable(0);
+       sunxi_usbc_disable(0);
+
+       return sunxi_usbc_free_resources(0);
+}
+
+const struct musb_platform_ops sunxi_musb_ops = {
+       .init           = sunxi_musb_init,
+       .exit           = sunxi_musb_exit,
+
+       .enable         = sunxi_musb_enable,
+       .disable        = sunxi_musb_disable,
+};
index 27f656f0ce518149dddcaae86d63ddc0e9d2f0f4..50bad378c5de95c6527cc1016021a790d4daa087 100644 (file)
@@ -48,6 +48,7 @@ struct urb {
        list_add_tail(&urb->urb_list, &urb->ep->urb_list);      \
        ret; })
 #define usb_hcd_unlink_urb_from_ep(hcd, urb)   list_del_init(&urb->urb_list)
+#define usb_hcd_check_unlink_urb(hdc, urb, status)     0
 
 static inline void usb_hcd_giveback_urb(struct usb_hcd *hcd,
                                        struct urb *urb,
index fdbf3f64f28fee2479ab7dca441508858b430f1e..51728b366f007529c2335dd929becaa30b3fcfd4 100644 (file)
@@ -1,8 +1,90 @@
-config VIDEO_X86
-       bool "Enable x86 video driver support"
+config VIDEO_VESA
+       bool "Enable VESA video driver support"
        depends on X86
        default n
        help
          Turn on this option to enable a very simple driver which uses vesa
          to discover the video mode and then provides a frame buffer for use
-         by U-Boot.
+         by U-Boot. This can in principle be used with any platform that
+         supports PCI and video cards that support VESA BIOS Extension (VBE).
+
+config VIDEO_LCD_SSD2828
+       bool "SSD2828 bridge chip"
+       default n
+       ---help---
+       Support for the SSD2828 bridge chip, which can take pixel data coming
+       from a parallel LCD interface and translate it on the fly into MIPI DSI
+       interface for driving a MIPI compatible LCD panel. It uses SPI for
+       configuration.
+
+config VIDEO_LCD_SSD2828_TX_CLK
+       int "SSD2828 TX_CLK frequency (in MHz)"
+       depends on VIDEO_LCD_SSD2828
+       default 0
+       ---help---
+       The frequency of the crystal, which is clocking SSD2828. It may be
+       anything in the 8MHz-30MHz range and the exact value should be
+       retrieved from the board schematics. Or in the case of Allwinner
+       hardware, it can be usually found as 'lcd_xtal_freq' variable in
+       FEX files. It can be also set to 0 for selecting PCLK from the
+       parallel LCD interface instead of TX_CLK as the PLL clock source.
+
+config VIDEO_LCD_SSD2828_RESET
+       string "RESET pin of SSD2828"
+       depends on VIDEO_LCD_SSD2828
+       default ""
+       ---help---
+       The reset pin of SSD2828 chip. This takes a string in the format
+       understood by 'name_to_gpio' function, e.g. PH1 for pin 1 of port H.
+
+config VIDEO_LCD_HITACHI_TX18D42VM
+       bool "Hitachi tx18d42vm LVDS LCD panel support"
+       depends on VIDEO
+       default n
+       ---help---
+       Support for Hitachi tx18d42vm LVDS LCD panels, these panels have a
+       lcd controller which needs to be initialized over SPI, once that is
+       done they work like a regular LVDS panel.
+
+config VIDEO_LCD_SPI_CS
+       string "SPI CS pin for LCD related config job"
+       depends on VIDEO_LCD_SSD2828 || VIDEO_LCD_HITACHI_TX18D42VM
+       default ""
+       ---help---
+       This is one of the SPI communication pins, involved in setting up a
+       working LCD configuration. The exact role of SPI may differ for
+       different hardware setups. The option takes a string in the format
+       understood by 'name_to_gpio' function, e.g. PH1 for pin 1 of port H.
+
+config VIDEO_LCD_SPI_SCLK
+       string "SPI SCLK pin for LCD related config job"
+       depends on VIDEO_LCD_SSD2828 || VIDEO_LCD_HITACHI_TX18D42VM
+       default ""
+       ---help---
+       This is one of the SPI communication pins, involved in setting up a
+       working LCD configuration. The exact role of SPI may differ for
+       different hardware setups. The option takes a string in the format
+       understood by 'name_to_gpio' function, e.g. PH1 for pin 1 of port H.
+
+config VIDEO_LCD_SPI_MOSI
+       string "SPI MOSI pin for LCD related config job"
+       depends on VIDEO_LCD_SSD2828 || VIDEO_LCD_HITACHI_TX18D42VM
+       default ""
+       ---help---
+       This is one of the SPI communication pins, involved in setting up a
+       working LCD configuration. The exact role of SPI may differ for
+       different hardware setups. The option takes a string in the format
+       understood by 'name_to_gpio' function, e.g. PH1 for pin 1 of port H.
+
+config VIDEO_LCD_SPI_MISO
+       string "SPI MISO pin for LCD related config job (optional)"
+       depends on VIDEO_LCD_SSD2828
+       default ""
+       ---help---
+       This is one of the SPI communication pins, involved in setting up a
+       working LCD configuration. The exact role of SPI may differ for
+       different hardware setups. If wired up, this pin may provide additional
+       useful functionality. Such as bi-directional communication with the
+       hardware and LCD panel id retrieval (if the panel can report it). The
+       option takes a string in the format understood by 'name_to_gpio'
+       function, e.g. PH1 for pin 1 of port H.
index 42b1eaaf760c9323210dfabf2a0ca939d3c04e28..af2d47bd75f63bde957bb4667916c1fbc64021fa 100644 (file)
@@ -29,6 +29,8 @@ obj-$(CONFIG_VIDEO_COREBOOT) += coreboot_fb.o
 obj-$(CONFIG_VIDEO_CT69000) += ct69000.o videomodes.o
 obj-$(CONFIG_VIDEO_DA8XX) += da8xx-fb.o videomodes.o
 obj-$(CONFIG_VIDEO_IMX25LCDC) += imx25lcdc.o videomodes.o
+obj-$(CONFIG_VIDEO_LCD_HITACHI_TX18D42VM) += hitachi_tx18d42vm_lcd.o
+obj-$(CONFIG_VIDEO_LCD_SSD2828) += ssd2828.o
 obj-$(CONFIG_VIDEO_MB862xx) += mb862xx.o videomodes.o
 obj-$(CONFIG_VIDEO_MB86R0xGDC) += mb86r0xgdc.o videomodes.o
 obj-$(CONFIG_VIDEO_MX3) += mx3fb.o videomodes.o
@@ -42,7 +44,7 @@ obj-$(CONFIG_VIDEO_SMI_LYNXEM) += smiLynxEM.o videomodes.o
 obj-$(CONFIG_VIDEO_SUNXI) += sunxi_display.o videomodes.o
 obj-$(CONFIG_VIDEO_TEGRA) += tegra.o
 obj-$(CONFIG_VIDEO_VCXK) += bus_vcxk.o
-obj-$(CONFIG_VIDEO_X86) += x86_fb.o
+obj-$(CONFIG_VIDEO_VESA) += vesa_fb.o
 obj-$(CONFIG_FORMIKE) += formike.o
 obj-$(CONFIG_AM335X_LCD) += am335x-fb.o
 obj-$(CONFIG_VIDEO_PARADE) += parade.o
index cbe6b9fc6d39bea5c1f35db75995647a047c9c63..a81affa3333f743ed6e56e8758a6fab98addf003 100644 (file)
  * Defines for the SED13806 driver
  */
 #ifdef CONFIG_VIDEO_SED13806
-
-#ifndef CONFIG_TOTAL5200
 #define VIDEO_FB_LITTLE_ENDIAN
-#endif
 #define VIDEO_HW_RECTFILL
 #define VIDEO_HW_BITBLT
 #endif
@@ -302,7 +299,11 @@ void console_cursor(int state);
 #define CONSOLE_ROW_SECOND     (video_console_address + CONSOLE_ROW_SIZE)
 #define CONSOLE_ROW_LAST       (video_console_address + CONSOLE_SIZE - CONSOLE_ROW_SIZE)
 #define CONSOLE_SIZE           (CONSOLE_ROW_SIZE * CONSOLE_ROWS)
-#define CONSOLE_SCROLL_SIZE    (CONSOLE_SIZE - CONSOLE_ROW_SIZE)
+
+/* By default we scroll by a single line */
+#ifndef CONFIG_CONSOLE_SCROLL_LINES
+#define CONFIG_CONSOLE_SCROLL_LINES 1
+#endif
 
 /* Macros */
 #ifdef VIDEO_FB_LITTLE_ENDIAN
@@ -743,26 +744,33 @@ static void console_clear_line(int line, int begin, int end)
 
 static void console_scrollup(void)
 {
+       const int rows = CONFIG_CONSOLE_SCROLL_LINES;
+       int i;
+
        /* copy up rows ignoring the first one */
 
 #ifdef VIDEO_HW_BITBLT
        video_hw_bitblt(VIDEO_PIXEL_SIZE,       /* bytes per pixel */
                        0,                      /* source pos x */
                        video_logo_height +
-                               VIDEO_FONT_HEIGHT, /* source pos y */
+                               VIDEO_FONT_HEIGHT * rows, /* source pos y */
                        0,                      /* dest pos x */
                        video_logo_height,      /* dest pos y */
                        VIDEO_VISIBLE_COLS,     /* frame width */
                        VIDEO_VISIBLE_ROWS
                        - video_logo_height
-                       - VIDEO_FONT_HEIGHT     /* frame height */
+                       - VIDEO_FONT_HEIGHT * rows      /* frame height */
                );
 #else
-       memcpyl(CONSOLE_ROW_FIRST, CONSOLE_ROW_SECOND,
-               CONSOLE_SCROLL_SIZE >> 2);
+       memcpyl(CONSOLE_ROW_FIRST, CONSOLE_ROW_FIRST + rows * CONSOLE_ROW_SIZE,
+               (CONSOLE_SIZE - CONSOLE_ROW_SIZE * rows) >> 2);
 #endif
        /* clear the last one */
-       console_clear_line(CONSOLE_ROWS - 1, 0, CONSOLE_COLS - 1);
+       for (i = 1; i <= rows; i++)
+               console_clear_line(CONSOLE_ROWS - i, 0, CONSOLE_COLS - 1);
+
+       /* Decrement row number */
+       console_row -= rows;
 }
 
 static void console_back(void)
@@ -874,9 +882,6 @@ static void console_newline(int n)
        if (console_row >= CONSOLE_ROWS) {
                /* Scroll everything up */
                console_scrollup();
-
-               /* Decrement row number */
-               console_row = CONSOLE_ROWS - 1;
        }
 }
 
diff --git a/drivers/video/hitachi_tx18d42vm_lcd.c b/drivers/video/hitachi_tx18d42vm_lcd.c
new file mode 100644 (file)
index 0000000..1ce4a8c
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * Hitachi tx18d42vm LVDS LCD panel driver
+ *
+ * (C) Copyright 2015 Hans de Goede <hdegoede@redhat.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <common.h>
+
+#include <asm/gpio.h>
+#include <errno.h>
+
+/*
+ * Very simple write only SPI support, this does not use the generic SPI infra
+ * because that assumes R/W SPI, requiring a MISO pin. Also the necessary glue
+ * code alone would be larger then this minimal version.
+ */
+static void lcd_panel_spi_write(int cs, int clk, int mosi,
+                               unsigned int data, int bits)
+{
+       int i, offset;
+
+       gpio_direction_output(cs, 0);
+       for (i = 0; i < bits; i++) {
+               gpio_direction_output(clk, 0);
+               offset = (bits - 1) - i;
+               gpio_direction_output(mosi, (data >> offset) & 1);
+               udelay(2);
+               gpio_direction_output(clk, 1);
+               udelay(2);
+       }
+       gpio_direction_output(cs, 1);
+       udelay(2);
+}
+
+int hitachi_tx18d42vm_init(void)
+{
+       const u16 init_data[] = {
+               0x0029,         /* reset */
+               0x0025,         /* standby */
+               0x0840,         /* enable normally black */
+               0x0430,         /* enable FRC/dither */
+               0x385f,         /* enter test mode(1) */
+               0x3ca4,         /* enter test mode(2) */
+               0x3409,         /* enable SDRRS, enlarge OE width */
+               0x4041,         /* adopt 2 line / 1 dot */
+       };
+       int i, cs, clk, mosi, ret = 0;
+
+       cs = name_to_gpio(CONFIG_VIDEO_LCD_SPI_CS);
+       clk = name_to_gpio(CONFIG_VIDEO_LCD_SPI_SCLK);
+       mosi = name_to_gpio(CONFIG_VIDEO_LCD_SPI_MOSI);
+
+       if (cs == -1 || clk == -1 || mosi == 1) {
+               printf("Error tx18d42vm spi gpio config is invalid\n");
+               return -EINVAL;
+       }
+
+       if (gpio_request(cs, "tx18d42vm-spi-cs") != 0 ||
+           gpio_request(clk, "tx18d42vm-spi-clk") != 0 ||
+           gpio_request(mosi, "tx18d42vm-spi-mosi") != 0) {
+               printf("Error cannot request tx18d42vm spi gpios\n");
+               ret = -EBUSY;
+               goto out;
+       }
+
+       for (i = 0; i < ARRAY_SIZE(init_data); i++)
+               lcd_panel_spi_write(cs, clk, mosi, init_data[i], 16);
+
+       mdelay(50); /* All the tx18d42vm drivers have a delay here ? */
+
+       lcd_panel_spi_write(cs, clk, mosi, 0x00ad, 16); /* display on */
+
+out:
+       gpio_free(mosi);
+       gpio_free(clk);
+       gpio_free(cs);
+
+       return ret;
+}
diff --git a/drivers/video/hitachi_tx18d42vm_lcd.h b/drivers/video/hitachi_tx18d42vm_lcd.h
new file mode 100644 (file)
index 0000000..1b72800
--- /dev/null
@@ -0,0 +1,9 @@
+/*
+ * Hitachi tx18d42vm LVDS LCD panel driver
+ *
+ * (C) Copyright 2015 Hans de Goede <hdegoede@redhat.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+void hitachi_tx18d42vm_init(void);
index da653c0f51673a162e287e9c2b3d23244949aeda..cd7fac6f970603f8f111e47d4d06b9a61759fd50 100644 (file)
 #define writeByte(ptrReg,value) \
     *(volatile unsigned char *)(sed13806.isaBase + ptrReg) = value
 
-#ifdef CONFIG_TOTAL5200
-#define writeWord(ptrReg,value) \
-    (*(volatile unsigned short *)(sed13806.isaBase + ptrReg) = value)
-#else
 #define writeWord(ptrReg,value) \
     (*(volatile unsigned short *)(sed13806.isaBase + ptrReg) = ((value >> 8 ) & 0xff) | ((value << 8) & 0xff00))
-#endif
 
 GraphicDevice sed13806;
 
diff --git a/drivers/video/ssd2828.c b/drivers/video/ssd2828.c
new file mode 100644 (file)
index 0000000..8b09082
--- /dev/null
@@ -0,0 +1,436 @@
+/*
+ * (C) 2015 Siarhei Siamashka <siarhei.siamashka@gmail.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+/*
+ * Support for the SSD2828 bridge chip, which can take pixel data coming
+ * from a parallel LCD interface and translate it on the flight into MIPI DSI
+ * interface for driving a MIPI compatible TFT display.
+ */
+
+#include <common.h>
+#include <mipi_display.h>
+#include <asm/arch/gpio.h>
+#include <asm/gpio.h>
+
+#include "videomodes.h"
+#include "ssd2828.h"
+
+#define                SSD2828_DIR     0xB0
+#define                SSD2828_VICR1   0xB1
+#define                SSD2828_VICR2   0xB2
+#define                SSD2828_VICR3   0xB3
+#define                SSD2828_VICR4   0xB4
+#define                SSD2828_VICR5   0xB5
+#define                SSD2828_VICR6   0xB6
+#define                SSD2828_CFGR    0xB7
+#define                SSD2828_VCR     0xB8
+#define                SSD2828_PCR     0xB9
+#define                SSD2828_PLCR    0xBA
+#define                SSD2828_CCR     0xBB
+#define                SSD2828_PSCR1   0xBC
+#define                SSD2828_PSCR2   0xBD
+#define                SSD2828_PSCR3   0xBE
+#define                SSD2828_PDR     0xBF
+#define                SSD2828_OCR     0xC0
+#define                SSD2828_MRSR    0xC1
+#define                SSD2828_RDCR    0xC2
+#define                SSD2828_ARSR    0xC3
+#define                SSD2828_LCR     0xC4
+#define                SSD2828_ICR     0xC5
+#define                SSD2828_ISR     0xC6
+#define                SSD2828_ESR     0xC7
+#define                SSD2828_DAR1    0xC9
+#define                SSD2828_DAR2    0xCA
+#define                SSD2828_DAR3    0xCB
+#define                SSD2828_DAR4    0xCC
+#define                SSD2828_DAR5    0xCD
+#define                SSD2828_DAR6    0xCE
+#define                SSD2828_HTTR1   0xCF
+#define                SSD2828_HTTR2   0xD0
+#define                SSD2828_LRTR1   0xD1
+#define                SSD2828_LRTR2   0xD2
+#define                SSD2828_TSR     0xD3
+#define                SSD2828_LRR     0xD4
+#define                SSD2828_PLLR    0xD5
+#define                SSD2828_TR      0xD6
+#define                SSD2828_TECR    0xD7
+#define                SSD2828_ACR1    0xD8
+#define                SSD2828_ACR2    0xD9
+#define                SSD2828_ACR3    0xDA
+#define                SSD2828_ACR4    0xDB
+#define                SSD2828_IOCR    0xDC
+#define                SSD2828_VICR7   0xDD
+#define                SSD2828_LCFR    0xDE
+#define                SSD2828_DAR7    0xDF
+#define                SSD2828_PUCR1   0xE0
+#define                SSD2828_PUCR2   0xE1
+#define                SSD2828_PUCR3   0xE2
+#define                SSD2828_CBCR1   0xE9
+#define                SSD2828_CBCR2   0xEA
+#define                SSD2828_CBSR    0xEB
+#define                SSD2828_ECR     0xEC
+#define                SSD2828_VSDR    0xED
+#define                SSD2828_TMR     0xEE
+#define                SSD2828_GPIO1   0xEF
+#define                SSD2828_GPIO2   0xF0
+#define                SSD2828_DLYA01  0xF1
+#define                SSD2828_DLYA23  0xF2
+#define                SSD2828_DLYB01  0xF3
+#define                SSD2828_DLYB23  0xF4
+#define                SSD2828_DLYC01  0xF5
+#define                SSD2828_DLYC23  0xF6
+#define                SSD2828_ACR5    0xF7
+#define                SSD2828_RR      0xFF
+
+#define        SSD2828_CFGR_HS                                 (1 << 0)
+#define        SSD2828_CFGR_CKE                                (1 << 1)
+#define        SSD2828_CFGR_SLP                                (1 << 2)
+#define        SSD2828_CFGR_VEN                                (1 << 3)
+#define        SSD2828_CFGR_HCLK                               (1 << 4)
+#define        SSD2828_CFGR_CSS                                (1 << 5)
+#define        SSD2828_CFGR_DCS                                (1 << 6)
+#define        SSD2828_CFGR_REN                                (1 << 7)
+#define        SSD2828_CFGR_ECD                                (1 << 8)
+#define        SSD2828_CFGR_EOT                                (1 << 9)
+#define        SSD2828_CFGR_LPE                                (1 << 10)
+#define        SSD2828_CFGR_TXD                                (1 << 11)
+
+#define        SSD2828_VIDEO_MODE_NON_BURST_WITH_SYNC_PULSES   (0 << 2)
+#define        SSD2828_VIDEO_MODE_NON_BURST_WITH_SYNC_EVENTS   (1 << 2)
+#define        SSD2828_VIDEO_MODE_BURST                        (2 << 2)
+
+#define        SSD2828_VIDEO_PIXEL_FORMAT_16BPP                0
+#define        SSD2828_VIDEO_PIXEL_FORMAT_18BPP_PACKED         1
+#define        SSD2828_VIDEO_PIXEL_FORMAT_18BPP_LOOSELY_PACKED 2
+#define        SSD2828_VIDEO_PIXEL_FORMAT_24BPP                3
+
+#define        SSD2828_LP_CLOCK_DIVIDER(n)                     (((n) - 1) & 0x3F)
+
+/*
+ * SPI transfer, using the "24-bit 3 wire" mode (that's how it is called in
+ * the SSD2828 documentation). The 'dout' input parameter specifies 24-bits
+ * of data to be written to SSD2828. Returns the lowest 16-bits of data,
+ * that is received back.
+ */
+static u32 soft_spi_xfer_24bit_3wire(const struct ssd2828_config *drv, u32 dout)
+{
+       int j, bitlen = 24;
+       u32 tmpdin = 0;
+       /*
+        * According to the "24 Bit 3 Wire SPI Interface Timing Characteristics"
+        * and "TX_CLK Timing Characteristics" tables in the SSD2828 datasheet,
+        * the lowest possible 'tx_clk' clock frequency is 8MHz, and SPI runs
+        * at 1/8 of that after reset. So using 1 microsecond delays is safe in
+        * the main loop. But the delays around chip select pin manipulations
+        * need to be longer (up to 16 'tx_clk' cycles, or 2 microseconds in
+        * the worst case).
+        */
+       const int spi_delay_us = 1;
+       const int spi_cs_delay_us = 2;
+
+       gpio_set_value(drv->csx_pin, 0);
+       udelay(spi_cs_delay_us);
+       for (j = bitlen - 1; j >= 0; j--) {
+               gpio_set_value(drv->sck_pin, 0);
+               gpio_set_value(drv->sdi_pin, (dout & (1 << j)) != 0);
+               udelay(spi_delay_us);
+               if (drv->sdo_pin != -1)
+                       tmpdin = (tmpdin << 1) | gpio_get_value(drv->sdo_pin);
+               gpio_set_value(drv->sck_pin, 1);
+               udelay(spi_delay_us);
+       }
+       udelay(spi_cs_delay_us);
+       gpio_set_value(drv->csx_pin, 1);
+       udelay(spi_cs_delay_us);
+       return tmpdin & 0xFFFF;
+}
+
+/*
+ * Read from a SSD2828 hardware register (regnum >= 0xB0)
+ */
+static u32 read_hw_register(const struct ssd2828_config *cfg, u8 regnum)
+{
+       soft_spi_xfer_24bit_3wire(cfg, 0x700000 | regnum);
+       return soft_spi_xfer_24bit_3wire(cfg, 0x730000);
+}
+
+/*
+ * Write to a SSD2828 hardware register (regnum >= 0xB0)
+ */
+static void write_hw_register(const struct ssd2828_config *cfg, u8 regnum,
+                             u16 val)
+{
+       soft_spi_xfer_24bit_3wire(cfg, 0x700000 | regnum);
+       soft_spi_xfer_24bit_3wire(cfg, 0x720000 | val);
+}
+
+/*
+ * Send MIPI command to the LCD panel (cmdnum < 0xB0)
+ */
+static void send_mipi_dcs_command(const struct ssd2828_config *cfg, u8 cmdnum)
+{
+       /* Set packet size to 1 (a single command with no parameters) */
+       write_hw_register(cfg, SSD2828_PSCR1, 1);
+       /* Send the command */
+       write_hw_register(cfg, SSD2828_PDR, cmdnum);
+}
+
+/*
+ * Reset SSD2828
+ */
+static void ssd2828_reset(const struct ssd2828_config *cfg)
+{
+       /* RESET needs 10 milliseconds according to the datasheet */
+       gpio_set_value(cfg->reset_pin, 0);
+       mdelay(10);
+       gpio_set_value(cfg->reset_pin, 1);
+       mdelay(10);
+}
+
+static int ssd2828_enable_gpio(const struct ssd2828_config *cfg)
+{
+       if (gpio_request(cfg->csx_pin, "ssd2828_csx")) {
+               printf("SSD2828: request for 'ssd2828_csx' pin failed\n");
+               return 1;
+       }
+       if (gpio_request(cfg->sck_pin, "ssd2828_sck")) {
+               gpio_free(cfg->csx_pin);
+               printf("SSD2828: request for 'ssd2828_sck' pin failed\n");
+               return 1;
+       }
+       if (gpio_request(cfg->sdi_pin, "ssd2828_sdi")) {
+               gpio_free(cfg->csx_pin);
+               gpio_free(cfg->sck_pin);
+               printf("SSD2828: request for 'ssd2828_sdi' pin failed\n");
+               return 1;
+       }
+       if (gpio_request(cfg->reset_pin, "ssd2828_reset")) {
+               gpio_free(cfg->csx_pin);
+               gpio_free(cfg->sck_pin);
+               gpio_free(cfg->sdi_pin);
+               printf("SSD2828: request for 'ssd2828_reset' pin failed\n");
+               return 1;
+       }
+       if (cfg->sdo_pin != -1 && gpio_request(cfg->sdo_pin, "ssd2828_sdo")) {
+               gpio_free(cfg->csx_pin);
+               gpio_free(cfg->sck_pin);
+               gpio_free(cfg->sdi_pin);
+               gpio_free(cfg->reset_pin);
+               printf("SSD2828: request for 'ssd2828_sdo' pin failed\n");
+               return 1;
+       }
+       gpio_direction_output(cfg->reset_pin, 0);
+       gpio_direction_output(cfg->csx_pin, 1);
+       gpio_direction_output(cfg->sck_pin, 1);
+       gpio_direction_output(cfg->sdi_pin, 1);
+       if (cfg->sdo_pin != -1)
+               gpio_direction_input(cfg->sdo_pin);
+
+       return 0;
+}
+
+static int ssd2828_free_gpio(const struct ssd2828_config *cfg)
+{
+       gpio_free(cfg->csx_pin);
+       gpio_free(cfg->sck_pin);
+       gpio_free(cfg->sdi_pin);
+       gpio_free(cfg->reset_pin);
+       if (cfg->sdo_pin != -1)
+               gpio_free(cfg->sdo_pin);
+       return 1;
+}
+
+/*
+ * PLL configuration register settings.
+ *
+ * See the "PLL Configuration Register Description" in the SSD2828 datasheet.
+ */
+static u32 construct_pll_config(u32 desired_pll_freq_kbps,
+                               u32 reference_freq_khz)
+{
+       u32 div_factor = 1, mul_factor, fr = 0;
+       u32 output_freq_kbps;
+
+       /* The intermediate clock after division can't be less than 5MHz */
+       while (reference_freq_khz / (div_factor + 1) >= 5000)
+               div_factor++;
+       if (div_factor > 31)
+               div_factor = 31;
+
+       mul_factor = DIV_ROUND_UP(desired_pll_freq_kbps * div_factor,
+                                 reference_freq_khz);
+
+       output_freq_kbps = reference_freq_khz * mul_factor / div_factor;
+
+       if (output_freq_kbps >= 501000)
+               fr = 3;
+       else if (output_freq_kbps >= 251000)
+               fr = 2;
+       else if (output_freq_kbps >= 126000)
+               fr = 1;
+
+       return (fr << 14) | (div_factor << 8) | mul_factor;
+}
+
+static u32 decode_pll_config(u32 pll_config, u32 reference_freq_khz)
+{
+       u32 mul_factor = pll_config & 0xFF;
+       u32 div_factor = (pll_config >> 8) & 0x1F;
+       if (mul_factor == 0)
+               mul_factor = 1;
+       if (div_factor == 0)
+               div_factor = 1;
+       return reference_freq_khz * mul_factor / div_factor;
+}
+
+static int ssd2828_configure_video_interface(const struct ssd2828_config *cfg,
+                                            const struct ctfb_res_modes *mode)
+{
+       u32 val;
+
+       /* RGB Interface Control Register 1 */
+       write_hw_register(cfg, SSD2828_VICR1, (mode->vsync_len << 8) |
+                                             (mode->hsync_len));
+
+       /* RGB Interface Control Register 2 */
+       u32 vbp = mode->vsync_len + mode->upper_margin;
+       u32 hbp = mode->hsync_len + mode->left_margin;
+       write_hw_register(cfg, SSD2828_VICR2, (vbp << 8) | hbp);
+
+       /* RGB Interface Control Register 3 */
+       write_hw_register(cfg, SSD2828_VICR3, (mode->lower_margin << 8) |
+                                             (mode->right_margin));
+
+       /* RGB Interface Control Register 4 */
+       write_hw_register(cfg, SSD2828_VICR4, mode->xres);
+
+       /* RGB Interface Control Register 5 */
+       write_hw_register(cfg, SSD2828_VICR5, mode->yres);
+
+       /* RGB Interface Control Register 6 */
+       val = SSD2828_VIDEO_MODE_BURST;
+       switch (cfg->ssd2828_color_depth) {
+       case 16:
+               val |= SSD2828_VIDEO_PIXEL_FORMAT_16BPP;
+               break;
+       case 18:
+               val |= cfg->mipi_dsi_loosely_packed_pixel_format ?
+                       SSD2828_VIDEO_PIXEL_FORMAT_18BPP_LOOSELY_PACKED :
+                       SSD2828_VIDEO_PIXEL_FORMAT_18BPP_PACKED;
+               break;
+       case 24:
+               val |= SSD2828_VIDEO_PIXEL_FORMAT_24BPP;
+               break;
+       default:
+               printf("SSD2828: unsupported color depth\n");
+               return 1;
+       }
+       write_hw_register(cfg, SSD2828_VICR6, val);
+
+       /* Lane Configuration Register */
+       write_hw_register(cfg, SSD2828_LCFR,
+                         cfg->mipi_dsi_number_of_data_lanes - 1);
+
+       return 0;
+}
+
+int ssd2828_init(const struct ssd2828_config *cfg,
+                const struct ctfb_res_modes *mode)
+{
+       u32 lp_div, pll_freq_kbps, reference_freq_khz, pll_config;
+       /* The LP clock speed is limited by 10MHz */
+       const u32 mipi_dsi_low_power_clk_khz = 10000;
+       /*
+        * This is just the reset default value of CFGR register (0x301).
+        * Because we are not always able to read back from SPI, have
+        * it initialized here.
+        */
+       u32 cfgr_reg = SSD2828_CFGR_EOT | /* EOT Packet Enable */
+                      SSD2828_CFGR_ECD | /* Disable ECC and CRC */
+                      SSD2828_CFGR_HS;   /* Data lanes are in HS mode */
+
+       /* Initialize the pins */
+       if (ssd2828_enable_gpio(cfg) != 0)
+               return 1;
+
+       /* Reset the chip */
+       ssd2828_reset(cfg);
+
+       /*
+        * If there is a pin to read data back from SPI, then we are lucky. Try
+        * to check if SPI is configured correctly and SSD2828 is actually able
+        * to talk back.
+        */
+       if (cfg->sdo_pin != -1) {
+               if (read_hw_register(cfg, SSD2828_DIR) != 0x2828 ||
+                   read_hw_register(cfg, SSD2828_CFGR) != cfgr_reg) {
+                       printf("SSD2828: SPI communication failed.\n");
+                       ssd2828_free_gpio(cfg);
+                       return 1;
+               }
+       }
+
+       /*
+        * Pick the reference clock for PLL. If we know the exact 'tx_clk'
+        * clock speed, then everything is good. If not, then we can fallback
+        * to 'pclk' (pixel clock from the parallel LCD interface). In the
+        * case of using this fallback, it is necessary to have parallel LCD
+        * already initialized and running at this point.
+        */
+       reference_freq_khz = cfg->ssd2828_tx_clk_khz;
+       if (reference_freq_khz  == 0) {
+               reference_freq_khz = mode->pixclock_khz;
+               /* Use 'pclk' as the reference clock for PLL */
+               cfgr_reg |= SSD2828_CFGR_CSS;
+       }
+
+       /*
+        * Setup the parallel LCD timings in the appropriate registers.
+        */
+       if (ssd2828_configure_video_interface(cfg, mode) != 0) {
+               ssd2828_free_gpio(cfg);
+               return 1;
+       }
+
+       /* Configuration Register */
+       cfgr_reg &= ~SSD2828_CFGR_HS;  /* Data lanes are in LP mode */
+       cfgr_reg |= SSD2828_CFGR_CKE;  /* Clock lane is in HS mode */
+       cfgr_reg |= SSD2828_CFGR_DCS;  /* Only use DCS packets */
+       write_hw_register(cfg, SSD2828_CFGR, cfgr_reg);
+
+       /* PLL Configuration Register */
+       pll_config = construct_pll_config(
+                               cfg->mipi_dsi_bitrate_per_data_lane_mbps * 1000,
+                               reference_freq_khz);
+       write_hw_register(cfg, SSD2828_PLCR, pll_config);
+
+       pll_freq_kbps = decode_pll_config(pll_config, reference_freq_khz);
+       lp_div = DIV_ROUND_UP(pll_freq_kbps, mipi_dsi_low_power_clk_khz * 8);
+
+       /* VC Control Register */
+       write_hw_register(cfg, SSD2828_VCR, 0);
+
+       /* Clock Control Register */
+       write_hw_register(cfg, SSD2828_CCR, SSD2828_LP_CLOCK_DIVIDER(lp_div));
+
+       /* PLL Control Register */
+       write_hw_register(cfg, SSD2828_PCR, 1); /* Enable PLL */
+
+       /* Wait for PLL lock */
+       udelay(500);
+
+       send_mipi_dcs_command(cfg, MIPI_DCS_EXIT_SLEEP_MODE);
+       mdelay(cfg->mipi_dsi_delay_after_exit_sleep_mode_ms);
+
+       send_mipi_dcs_command(cfg, MIPI_DCS_SET_DISPLAY_ON);
+       mdelay(cfg->mipi_dsi_delay_after_set_display_on_ms);
+
+       cfgr_reg |= SSD2828_CFGR_HS;    /* Enable HS mode for data lanes */
+       cfgr_reg |= SSD2828_CFGR_VEN;   /* Enable video pipeline */
+       write_hw_register(cfg, SSD2828_CFGR, cfgr_reg);
+
+       return 0;
+}
diff --git a/drivers/video/ssd2828.h b/drivers/video/ssd2828.h
new file mode 100644 (file)
index 0000000..1af6fa4
--- /dev/null
@@ -0,0 +1,128 @@
+/*
+ * (C) 2015 Siarhei Siamashka <siarhei.siamashka@gmail.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+/*
+ * Support for the SSD2828 bridge chip, which can take pixel data coming
+ * from a parallel LCD interface and translate it on the flight into MIPI DSI
+ * interface for driving a MIPI compatible TFT display.
+ *
+ * Implemented as a utility function. To be used from display drivers, which are
+ * responsible for driving parallel LCD hardware in front of the video pipeline.
+ */
+
+#ifndef _SSD2828_H
+#define _SSD2828_H
+
+struct ctfb_res_modes;
+
+struct ssd2828_config {
+       /*********************************************************************/
+       /* SSD2828 configuration                                             */
+       /*********************************************************************/
+
+       /*
+        * The pins, which are used for SPI communication. This is only used
+        * for configuring SSD2828, so the performance is irrelevant (only
+        * around a hundred of bytes is moved). Also these can be any arbitrary
+        * GPIO pins (not necessarily the pins having hardware SPI function).
+        * Moreover, the 'sdo' pin may be even not wired up in some devices.
+        *
+        * These configuration variables need to be set as pin numbers for
+        * the standard u-boot GPIO interface (gpio_get_value/gpio_set_value
+        * functions). Note that -1 value can be used for the pins, which are
+        * not really wired up.
+        */
+       int csx_pin;
+       int sck_pin;
+       int sdi_pin;
+       int sdo_pin;
+       /* SSD2828 reset pin (shared with LCD panel reset) */
+       int reset_pin;
+
+       /*
+        * The SSD2828 has its own dedicated clock source 'tx_clk' (connected
+        * to TX_CLK_XIO/TX_CLK_XIN pins), which is necessary at least for
+        * clocking SPI after reset. The exact clock speed is not strictly,
+        * defined, but the datasheet says that it must be somewhere in the
+        * 8MHz - 30MHz range (see "TX_CLK Timing" section). It can be also
+        * used as a reference clock for PLL. If the exact clock frequency
+        * is known, then it can be specified here. If it is unknown, or the
+        * information is not trustworthy, then it can be set to 0.
+        *
+        * If unsure, set to 0.
+        */
+       int ssd2828_tx_clk_khz;
+
+       /*
+        * This is not a property of the used LCD panel, but more like a
+        * property of the SSD2828 wiring. See the "SSD2828QN4 RGB data
+        * arrangement" table in the datasheet. The SSD2828 pins are arranged
+        * in such a way that 18bpp and 24bpp configurations are completely
+        * incompatible with each other.
+        *
+        * Depending on the color depth, this must be set to 16, 18 or 24.
+        */
+       int ssd2828_color_depth;
+
+       /*********************************************************************/
+       /* LCD panel configuration                                           */
+       /*********************************************************************/
+
+       /*
+        * The number of lanes in the MIPI DSI interface. May vary from 1 to 4.
+        *
+        * This information can be found in the LCD panel datasheet.
+        */
+       int mipi_dsi_number_of_data_lanes;
+
+       /*
+        * Data transfer bit rate per lane. Please note that it is expected
+        * to be higher than the pixel clock rate of the used video mode when
+        * multiplied by the number of lanes. This is perfectly normal because
+        * MIPI DSI handles data transfers in periodic bursts, and uses the
+        * idle time between bursts for sending configuration information and
+        * commands. Or just for saving power.
+        *
+        * The necessary Mbps/lane information can be found in the LCD panel
+        * datasheet. Note that the transfer rate can't be always set precisely
+        * and it may be rounded *up* (introducing no more than 10Mbps error).
+        */
+       int mipi_dsi_bitrate_per_data_lane_mbps;
+
+       /*
+        * Setting this to 1 enforces packing of 18bpp pixel data in 24bpp
+        * envelope when sending it over the MIPI DSI link.
+        *
+        * If unsure, set to 0.
+        */
+       int mipi_dsi_loosely_packed_pixel_format;
+
+       /*
+        * According to the "Example for system sleep in and out" section in
+        * the SSD2828 datasheet, some LCD panel specific delays are necessary
+        * after MIPI DCS commands EXIT_SLEEP_MODE and SET_DISPLAY_ON.
+        *
+        * For example, Allwinner uses 100 milliseconds delay after
+        * EXIT_SLEEP_MODE and 200 milliseconds delay after SET_DISPLAY_ON.
+        */
+       int mipi_dsi_delay_after_exit_sleep_mode_ms;
+       int mipi_dsi_delay_after_set_display_on_ms;
+};
+
+/*
+ * Initialize the SSD2828 chip. It needs the 'ssd2828_config' structure
+ * and also the video mode timings.
+ *
+ * The right place to insert this function call is after the parallel LCD
+ * interface is initialized and before turning on the backlight. This is
+ * advised in the "Example for system sleep in and out" section of the
+ * SSD2828 datasheet. And also SS2828 may use 'pclk' as the clock source
+ * for PLL, which means that the input signal must be already there.
+ */
+int ssd2828_init(const struct ssd2828_config *cfg,
+                const struct ctfb_res_modes *mode);
+
+#endif
index d92dfa88635260560c871c92536209f18e27c194..f5f24fc020bd793d2e1de7914f99d032e55a5743 100644 (file)
 #include <fdt_support.h>
 #include <video_fb.h>
 #include "videomodes.h"
+#include "hitachi_tx18d42vm_lcd.h"
+#include "ssd2828.h"
+
+#ifdef CONFIG_VIDEO_LCD_BL_PWM_ACTIVE_LOW
+#define PWM_ON 0
+#define PWM_OFF 1
+#else
+#define PWM_ON 1
+#define PWM_OFF 0
+#endif
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -270,6 +280,114 @@ static int sunxi_hdmi_edid_get_mode(struct ctfb_res_modes *mode)
 
 #endif /* CONFIG_VIDEO_HDMI */
 
+#ifdef CONFIG_MACH_SUN4I
+/*
+ * Testing has shown that on sun4i the display backend engine does not have
+ * deep enough fifo-s causing flickering / tearing in full-hd mode due to
+ * fifo underruns. So on sun4i we use the display frontend engine to do the
+ * dma from memory, as the frontend does have deep enough fifo-s.
+ */
+
+static const u32 sun4i_vert_coef[32] = {
+       0x00004000, 0x000140ff, 0x00033ffe, 0x00043ffd,
+       0x00063efc, 0xff083dfc, 0x000a3bfb, 0xff0d39fb,
+       0xff0f37fb, 0xff1136fa, 0xfe1433fb, 0xfe1631fb,
+       0xfd192ffb, 0xfd1c2cfb, 0xfd1f29fb, 0xfc2127fc,
+       0xfc2424fc, 0xfc2721fc, 0xfb291ffd, 0xfb2c1cfd,
+       0xfb2f19fd, 0xfb3116fe, 0xfb3314fe, 0xfa3611ff,
+       0xfb370fff, 0xfb390dff, 0xfb3b0a00, 0xfc3d08ff,
+       0xfc3e0600, 0xfd3f0400, 0xfe3f0300, 0xff400100,
+};
+
+static const u32 sun4i_horz_coef[64] = {
+       0x40000000, 0x00000000, 0x40fe0000, 0x0000ff03,
+       0x3ffd0000, 0x0000ff05, 0x3ffc0000, 0x0000ff06,
+       0x3efb0000, 0x0000ff08, 0x3dfb0000, 0x0000ff09,
+       0x3bfa0000, 0x0000fe0d, 0x39fa0000, 0x0000fe0f,
+       0x38fa0000, 0x0000fe10, 0x36fa0000, 0x0000fe12,
+       0x33fa0000, 0x0000fd16, 0x31fa0000, 0x0000fd18,
+       0x2ffa0000, 0x0000fd1a, 0x2cfa0000, 0x0000fc1e,
+       0x29fa0000, 0x0000fc21, 0x27fb0000, 0x0000fb23,
+       0x24fb0000, 0x0000fb26, 0x21fb0000, 0x0000fb29,
+       0x1ffc0000, 0x0000fa2b, 0x1cfc0000, 0x0000fa2e,
+       0x19fd0000, 0x0000fa30, 0x16fd0000, 0x0000fa33,
+       0x14fd0000, 0x0000fa35, 0x11fe0000, 0x0000fa37,
+       0x0ffe0000, 0x0000fa39, 0x0dfe0000, 0x0000fa3b,
+       0x0afe0000, 0x0000fa3e, 0x08ff0000, 0x0000fb3e,
+       0x06ff0000, 0x0000fb40, 0x05ff0000, 0x0000fc40,
+       0x03ff0000, 0x0000fd41, 0x01ff0000, 0x0000fe42,
+};
+
+static void sunxi_frontend_init(void)
+{
+       struct sunxi_ccm_reg * const ccm =
+               (struct sunxi_ccm_reg *)SUNXI_CCM_BASE;
+       struct sunxi_de_fe_reg * const de_fe =
+               (struct sunxi_de_fe_reg *)SUNXI_DE_FE0_BASE;
+       int i;
+
+       /* Clocks on */
+       setbits_le32(&ccm->ahb_gate1, 1 << AHB_GATE_OFFSET_DE_FE0);
+       setbits_le32(&ccm->dram_clk_gate, 1 << CCM_DRAM_GATE_OFFSET_DE_FE0);
+       clock_set_de_mod_clock(&ccm->fe0_clk_cfg, 300000000);
+
+       setbits_le32(&de_fe->enable, SUNXI_DE_FE_ENABLE_EN);
+
+       for (i = 0; i < 32; i++) {
+               writel(sun4i_horz_coef[2 * i], &de_fe->ch0_horzcoef0[i]);
+               writel(sun4i_horz_coef[2 * i + 1], &de_fe->ch0_horzcoef1[i]);
+               writel(sun4i_vert_coef[i], &de_fe->ch0_vertcoef[i]);
+               writel(sun4i_horz_coef[2 * i], &de_fe->ch1_horzcoef0[i]);
+               writel(sun4i_horz_coef[2 * i + 1], &de_fe->ch1_horzcoef1[i]);
+               writel(sun4i_vert_coef[i], &de_fe->ch1_vertcoef[i]);
+       }
+
+       setbits_le32(&de_fe->frame_ctrl, SUNXI_DE_FE_FRAME_CTRL_COEF_RDY);
+}
+
+static void sunxi_frontend_mode_set(const struct ctfb_res_modes *mode,
+                                   unsigned int address)
+{
+       struct sunxi_de_fe_reg * const de_fe =
+               (struct sunxi_de_fe_reg *)SUNXI_DE_FE0_BASE;
+
+       setbits_le32(&de_fe->bypass, SUNXI_DE_FE_BYPASS_CSC_BYPASS);
+       writel(CONFIG_SYS_SDRAM_BASE + address, &de_fe->ch0_addr);
+       writel(mode->xres * 4, &de_fe->ch0_stride);
+       writel(SUNXI_DE_FE_INPUT_FMT_ARGB8888, &de_fe->input_fmt);
+       writel(SUNXI_DE_FE_OUTPUT_FMT_ARGB8888, &de_fe->output_fmt);
+
+       writel(SUNXI_DE_FE_HEIGHT(mode->yres) | SUNXI_DE_FE_WIDTH(mode->xres),
+              &de_fe->ch0_insize);
+       writel(SUNXI_DE_FE_HEIGHT(mode->yres) | SUNXI_DE_FE_WIDTH(mode->xres),
+              &de_fe->ch0_outsize);
+       writel(SUNXI_DE_FE_FACTOR_INT(1), &de_fe->ch0_horzfact);
+       writel(SUNXI_DE_FE_FACTOR_INT(1), &de_fe->ch0_vertfact);
+
+       writel(SUNXI_DE_FE_HEIGHT(mode->yres) | SUNXI_DE_FE_WIDTH(mode->xres),
+              &de_fe->ch1_insize);
+       writel(SUNXI_DE_FE_HEIGHT(mode->yres) | SUNXI_DE_FE_WIDTH(mode->xres),
+              &de_fe->ch1_outsize);
+       writel(SUNXI_DE_FE_FACTOR_INT(1), &de_fe->ch1_horzfact);
+       writel(SUNXI_DE_FE_FACTOR_INT(1), &de_fe->ch1_vertfact);
+
+       setbits_le32(&de_fe->frame_ctrl, SUNXI_DE_FE_FRAME_CTRL_REG_RDY);
+}
+
+static void sunxi_frontend_enable(void)
+{
+       struct sunxi_de_fe_reg * const de_fe =
+               (struct sunxi_de_fe_reg *)SUNXI_DE_FE0_BASE;
+
+       setbits_le32(&de_fe->frame_ctrl, SUNXI_DE_FE_FRAME_CTRL_FRM_START);
+}
+#else
+static void sunxi_frontend_init(void) {}
+static void sunxi_frontend_mode_set(const struct ctfb_res_modes *mode,
+                                   unsigned int address) {}
+static void sunxi_frontend_enable(void) {}
+#endif
+
 /*
  * This is the entity that mixes and matches the different layers and inputs.
  * Allwinner calls it the back-end, but i like composer better.
@@ -282,6 +400,8 @@ static void sunxi_composer_init(void)
                (struct sunxi_de_be_reg *)SUNXI_DE_BE0_BASE;
        int i;
 
+       sunxi_frontend_init();
+
 #if defined CONFIG_MACH_SUN6I || defined CONFIG_MACH_SUN8I
        /* Reset off */
        setbits_le32(&ccm->ahb_reset1_cfg, 1 << AHB_RESET_OFFSET_DE_BE0);
@@ -289,7 +409,9 @@ static void sunxi_composer_init(void)
 
        /* Clocks on */
        setbits_le32(&ccm->ahb_gate1, 1 << AHB_GATE_OFFSET_DE_BE0);
+#ifndef CONFIG_MACH_SUN4I /* On sun4i the frontend does the dma */
        setbits_le32(&ccm->dram_clk_gate, 1 << CCM_DRAM_GATE_OFFSET_DE_BE0);
+#endif
        clock_set_de_mod_clock(&ccm->be0_clk_cfg, 300000000);
 
        /* Engine bug, clear registers after reset */
@@ -305,13 +427,19 @@ static void sunxi_composer_mode_set(const struct ctfb_res_modes *mode,
        struct sunxi_de_be_reg * const de_be =
                (struct sunxi_de_be_reg *)SUNXI_DE_BE0_BASE;
 
+       sunxi_frontend_mode_set(mode, address);
+
        writel(SUNXI_DE_BE_HEIGHT(mode->yres) | SUNXI_DE_BE_WIDTH(mode->xres),
               &de_be->disp_size);
        writel(SUNXI_DE_BE_HEIGHT(mode->yres) | SUNXI_DE_BE_WIDTH(mode->xres),
               &de_be->layer0_size);
+#ifndef CONFIG_MACH_SUN4I /* On sun4i the frontend does the dma */
        writel(SUNXI_DE_BE_LAYER_STRIDE(mode->xres), &de_be->layer0_stride);
        writel(address << 3, &de_be->layer0_addr_low32b);
        writel(address >> 29, &de_be->layer0_addr_high4b);
+#else
+       writel(SUNXI_DE_BE_LAYER_ATTR0_SRC_FE0, &de_be->layer0_attr0_ctrl);
+#endif
        writel(SUNXI_DE_BE_LAYER_ATTR1_FMT_XRGB8888, &de_be->layer0_attr1_ctrl);
 
        setbits_le32(&de_be->mode, SUNXI_DE_BE_MODE_LAYER0_ENABLE);
@@ -322,6 +450,8 @@ static void sunxi_composer_enable(void)
        struct sunxi_de_be_reg * const de_be =
                (struct sunxi_de_be_reg *)SUNXI_DE_BE0_BASE;
 
+       sunxi_frontend_enable();
+
        setbits_le32(&de_be->reg_ctrl, SUNXI_DE_BE_REG_CTRL_LOAD_REGS);
        setbits_le32(&de_be->mode, SUNXI_DE_BE_MODE_START);
 }
@@ -476,8 +606,7 @@ static void sunxi_lcdc_panel_enable(void)
        pin = sunxi_name_to_gpio(CONFIG_VIDEO_LCD_BL_PWM);
        if (pin != -1) {
                gpio_request(pin, "lcd_backlight_pwm");
-               /* backlight pwm is inverted, set to 1 to disable backlight */
-               gpio_direction_output(pin, 1);
+               gpio_direction_output(pin, PWM_OFF);
        }
 
        /* Give the backlight some time to turn off and power up the panel. */
@@ -504,10 +633,8 @@ static void sunxi_lcdc_backlight_enable(void)
                gpio_direction_output(pin, 1);
 
        pin = sunxi_name_to_gpio(CONFIG_VIDEO_LCD_BL_PWM);
-       if (pin != -1) {
-               /* backlight pwm is inverted, set to 0 to enable backlight */
-               gpio_direction_output(pin, 0);
-       }
+       if (pin != -1)
+               gpio_direction_output(pin, PWM_ON);
 }
 
 static int sunxi_lcdc_get_clk_delay(const struct ctfb_res_modes *mode)
@@ -518,7 +645,8 @@ static int sunxi_lcdc_get_clk_delay(const struct ctfb_res_modes *mode)
        return (delay > 30) ? 30 : delay;
 }
 
-static void sunxi_lcdc_tcon0_mode_set(const struct ctfb_res_modes *mode)
+static void sunxi_lcdc_tcon0_mode_set(const struct ctfb_res_modes *mode,
+                                     bool for_ext_vga_dac)
 {
        struct sunxi_lcdc_reg * const lcdc =
                (struct sunxi_lcdc_reg *)SUNXI_LCD0_BASE;
@@ -587,16 +715,16 @@ static void sunxi_lcdc_tcon0_mode_set(const struct ctfb_res_modes *mode)
                       &lcdc->tcon0_frm_ctrl);
        }
 
-#ifdef CONFIG_VIDEO_LCD_IF_PARALLEL
-       val = SUNXI_LCDC_TCON0_IO_POL_DCLK_PHASE0;
-#endif
-#ifdef CONFIG_VIDEO_LCD_IF_LVDS
-       val = SUNXI_LCDC_TCON0_IO_POL_DCLK_PHASE60;
-#endif
+       val = SUNXI_LCDC_TCON0_IO_POL_DCLK_PHASE(CONFIG_VIDEO_LCD_DCLK_PHASE);
        if (!(mode->sync & FB_SYNC_HOR_HIGH_ACT))
                val |= SUNXI_LCDC_TCON_HSYNC_MASK;
        if (!(mode->sync & FB_SYNC_VERT_HIGH_ACT))
                val |= SUNXI_LCDC_TCON_VSYNC_MASK;
+
+#ifdef CONFIG_VIDEO_VGA_VIA_LCD_FORCE_SYNC_ACTIVE_HIGH
+       if (for_ext_vga_dac)
+               val = 0;
+#endif
        writel(val, &lcdc->tcon0_io_polarity);
 
        writel(0, &lcdc->tcon0_io_tristate);
@@ -826,6 +954,40 @@ static void sunxi_vga_external_dac_enable(void)
 }
 #endif /* CONFIG_VIDEO_VGA_VIA_LCD */
 
+#ifdef CONFIG_VIDEO_LCD_SSD2828
+static int sunxi_ssd2828_init(const struct ctfb_res_modes *mode)
+{
+       struct ssd2828_config cfg = {
+               .csx_pin = name_to_gpio(CONFIG_VIDEO_LCD_SPI_CS),
+               .sck_pin = name_to_gpio(CONFIG_VIDEO_LCD_SPI_SCLK),
+               .sdi_pin = name_to_gpio(CONFIG_VIDEO_LCD_SPI_MOSI),
+               .sdo_pin = name_to_gpio(CONFIG_VIDEO_LCD_SPI_MISO),
+               .reset_pin = name_to_gpio(CONFIG_VIDEO_LCD_SSD2828_RESET),
+               .ssd2828_tx_clk_khz  = CONFIG_VIDEO_LCD_SSD2828_TX_CLK * 1000,
+               .ssd2828_color_depth = 24,
+#ifdef CONFIG_VIDEO_LCD_PANEL_MIPI_4_LANE_513_MBPS_VIA_SSD2828
+               .mipi_dsi_number_of_data_lanes           = 4,
+               .mipi_dsi_bitrate_per_data_lane_mbps     = 513,
+               .mipi_dsi_delay_after_exit_sleep_mode_ms = 100,
+               .mipi_dsi_delay_after_set_display_on_ms  = 200
+#else
+#error MIPI LCD panel needs configuration parameters
+#endif
+       };
+
+       if (cfg.csx_pin == -1 || cfg.sck_pin == -1 || cfg.sdi_pin == -1) {
+               printf("SSD2828: SPI pins are not properly configured\n");
+               return 1;
+       }
+       if (cfg.reset_pin == -1) {
+               printf("SSD2828: Reset pin is not properly configured\n");
+               return 1;
+       }
+
+       return ssd2828_init(&cfg, mode);
+}
+#endif /* CONFIG_VIDEO_LCD_SSD2828 */
+
 static void sunxi_engines_init(void)
 {
        sunxi_composer_init();
@@ -854,10 +1016,17 @@ static void sunxi_mode_set(const struct ctfb_res_modes *mode,
                break;
        case sunxi_monitor_lcd:
                sunxi_lcdc_panel_enable();
+               if (IS_ENABLED(CONFIG_VIDEO_LCD_HITACHI_TX18D42VM)) {
+                       mdelay(50); /* Wait for lcd controller power on */
+                       hitachi_tx18d42vm_init();
+               }
                sunxi_composer_mode_set(mode, address);
-               sunxi_lcdc_tcon0_mode_set(mode);
+               sunxi_lcdc_tcon0_mode_set(mode, false);
                sunxi_composer_enable();
                sunxi_lcdc_enable();
+#ifdef CONFIG_VIDEO_LCD_SSD2828
+               sunxi_ssd2828_init(mode);
+#endif
                sunxi_lcdc_backlight_enable();
                break;
        case sunxi_monitor_vga:
@@ -870,7 +1039,7 @@ static void sunxi_mode_set(const struct ctfb_res_modes *mode,
                sunxi_vga_enable();
 #elif defined CONFIG_VIDEO_VGA_VIA_LCD
                sunxi_composer_mode_set(mode, address);
-               sunxi_lcdc_tcon0_mode_set(mode);
+               sunxi_lcdc_tcon0_mode_set(mode, true);
                sunxi_composer_enable();
                sunxi_lcdc_enable();
                sunxi_vga_external_dac_enable();
@@ -1027,21 +1196,27 @@ int sunxi_simplefb_setup(void *blob)
        int offset, ret;
        const char *pipeline = NULL;
 
+#ifdef CONFIG_MACH_SUN4I
+#define PIPELINE_PREFIX "de_fe0-"
+#else
+#define PIPELINE_PREFIX
+#endif
+
        switch (sunxi_display.monitor) {
        case sunxi_monitor_none:
                return 0;
        case sunxi_monitor_dvi:
        case sunxi_monitor_hdmi:
-               pipeline = "de_be0-lcd0-hdmi";
+               pipeline = PIPELINE_PREFIX "de_be0-lcd0-hdmi";
                break;
        case sunxi_monitor_lcd:
-               pipeline = "de_be0-lcd0";
+               pipeline = PIPELINE_PREFIX "de_be0-lcd0";
                break;
        case sunxi_monitor_vga:
 #ifdef CONFIG_VIDEO_VGA
-               pipeline = "de_be0-lcd0-tve0";
+               pipeline = PIPELINE_PREFIX "de_be0-lcd0-tve0";
 #elif defined CONFIG_VIDEO_VGA_VIA_LCD
-               pipeline = "de_be0-lcd0";
+               pipeline = PIPELINE_PREFIX "de_be0-lcd0";
 #endif
                break;
        }
index 57cb0074e277f97e35e40d78e889c31437cd156b..b8f3431f242339c96cd0a9e28fffa435b4aef0fa 100644 (file)
@@ -149,14 +149,18 @@ static int fdt_decode_lcd(const void *blob, struct fdt_panel_config *config)
                                            FDT_LCD_CACHE_WRITE_BACK_FLUSH);
 
        /* These GPIOs are all optional */
-       fdtdec_decode_gpio(blob, display_node, "nvidia,backlight-enable-gpios",
-                           &config->backlight_en);
-       fdtdec_decode_gpio(blob, display_node, "nvidia,lvds-shutdown-gpios",
-                          &config->lvds_shutdown);
-       fdtdec_decode_gpio(blob, display_node, "nvidia,backlight-vdd-gpios",
-                          &config->backlight_vdd);
-       fdtdec_decode_gpio(blob, display_node, "nvidia,panel-vdd-gpios",
-                          &config->panel_vdd);
+       gpio_request_by_name_nodev(blob, display_node,
+                                  "nvidia,backlight-enable-gpios", 0,
+                                  &config->backlight_en, GPIOD_IS_OUT);
+       gpio_request_by_name_nodev(blob, display_node,
+                                  "nvidia,lvds-shutdown-gpios", 0,
+                                  &config->lvds_shutdown, GPIOD_IS_OUT);
+       gpio_request_by_name_nodev(blob, display_node,
+                                  "nvidia,backlight-vdd-gpios", 0,
+                                  &config->backlight_vdd, GPIOD_IS_OUT);
+       gpio_request_by_name_nodev(blob, display_node,
+                                  "nvidia,panel-vdd-gpios", 0,
+                                  &config->panel_vdd, GPIOD_IS_OUT);
 
        return fdtdec_get_int_array(blob, display_node, "nvidia,panel-timings",
                        config->panel_timings, FDT_LCD_TIMINGS);
@@ -196,36 +200,18 @@ static int handle_stage(const void *blob)
                 */
 
                funcmux_select(PERIPH_ID_DISP1, FUNCMUX_DEFAULT);
-
-               fdtdec_setup_gpio(&config.panel_vdd);
-               fdtdec_setup_gpio(&config.lvds_shutdown);
-               fdtdec_setup_gpio(&config.backlight_vdd);
-               fdtdec_setup_gpio(&config.backlight_en);
-
-               /*
-                * TODO: If fdt includes output flag we can omit this code
-                * since fdtdec_setup_gpio will do it for us.
-                */
-               if (fdt_gpio_isvalid(&config.panel_vdd))
-                       gpio_direction_output(config.panel_vdd.gpio, 0);
-               if (fdt_gpio_isvalid(&config.lvds_shutdown))
-                       gpio_direction_output(config.lvds_shutdown.gpio, 0);
-               if (fdt_gpio_isvalid(&config.backlight_vdd))
-                       gpio_direction_output(config.backlight_vdd.gpio, 0);
-               if (fdt_gpio_isvalid(&config.backlight_en))
-                       gpio_direction_output(config.backlight_en.gpio, 0);
                break;
        case STAGE_PANEL_VDD:
-               if (fdt_gpio_isvalid(&config.panel_vdd))
-                       gpio_direction_output(config.panel_vdd.gpio, 1);
+               if (dm_gpio_is_valid(&config.panel_vdd))
+                       dm_gpio_set_value(&config.panel_vdd, 1);
                break;
        case STAGE_LVDS:
-               if (fdt_gpio_isvalid(&config.lvds_shutdown))
-                       gpio_set_value(config.lvds_shutdown.gpio, 1);
+               if (dm_gpio_is_valid(&config.lvds_shutdown))
+                       dm_gpio_set_value(&config.lvds_shutdown, 1);
                break;
        case STAGE_BACKLIGHT_VDD:
-               if (fdt_gpio_isvalid(&config.backlight_vdd))
-                       gpio_set_value(config.backlight_vdd.gpio, 1);
+               if (dm_gpio_is_valid(&config.backlight_vdd))
+                       dm_gpio_set_value(&config.backlight_vdd, 1);
                break;
        case STAGE_PWM:
                /* Enable PWM at 15/16 high, 32768 Hz with divider 1 */
@@ -235,8 +221,8 @@ static int handle_stage(const void *blob)
                pwm_enable(config.pwm_channel, 32768, 0xdf, 1);
                break;
        case STAGE_BACKLIGHT_EN:
-               if (fdt_gpio_isvalid(&config.backlight_en))
-                       gpio_set_value(config.backlight_en.gpio, 1);
+               if (dm_gpio_is_valid(&config.backlight_en))
+                       dm_gpio_set_value(&config.backlight_en, 1);
                break;
        case STAGE_DONE:
                break;
diff --git a/drivers/video/vesa_fb.c b/drivers/video/vesa_fb.c
new file mode 100644 (file)
index 0000000..3dacafd
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ *
+ * Vesa frame buffer driver for x86
+ *
+ * Copyright (C) 2014 Google, Inc
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <common.h>
+#include <pci_rom.h>
+#include <video_fb.h>
+#include <vbe.h>
+
+/*
+ * The Graphic Device
+ */
+GraphicDevice ctfb;
+
+/* Devices to allow - only the last one works fully */
+struct pci_device_id vesa_video_ids[] = {
+       { .vendor = 0x102b, .device = 0x0525 },
+       { .vendor = 0x1002, .device = 0x5159 },
+       { .vendor = 0x1002, .device = 0x4752 },
+       { .vendor = 0x1002, .device = 0x5452 },
+       {},
+};
+
+void *video_hw_init(void)
+{
+       GraphicDevice *gdev = &ctfb;
+       int bits_per_pixel;
+       pci_dev_t dev;
+       int ret;
+
+       printf("Video: ");
+       if (vbe_get_video_info(gdev)) {
+               /* TODO: Should we look these up by class? */
+               dev = pci_find_devices(vesa_video_ids, 0);
+               if (dev == -1) {
+                       printf("no card detected\n");
+                       return NULL;
+               }
+               printf("bdf %x\n", dev);
+               ret = pci_run_vga_bios(dev, NULL, true);
+               if (ret) {
+                       printf("failed to run video BIOS: %d\n", ret);
+                       return NULL;
+               }
+       }
+
+       if (vbe_get_video_info(gdev)) {
+               printf("No video mode configured\n");
+               return NULL;
+       }
+
+       bits_per_pixel = gdev->gdfBytesPP * 8;
+       sprintf(gdev->modeIdent, "%dx%dx%d", gdev->winSizeX, gdev->winSizeY,
+               bits_per_pixel);
+       printf("%s\n", gdev->modeIdent);
+       debug("Framex buffer at %x\n", gdev->pciBase);
+
+       return (void *)gdev;
+}
diff --git a/drivers/video/x86_fb.c b/drivers/video/x86_fb.c
deleted file mode 100644 (file)
index 6641033..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- *
- * Vesa frame buffer driver for x86
- *
- * Copyright (C) 2014 Google, Inc
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#include <common.h>
-#include <video_fb.h>
-#include <vbe.h>
-#include "videomodes.h"
-
-/*
- * The Graphic Device
- */
-GraphicDevice ctfb;
-
-void *video_hw_init(void)
-{
-       GraphicDevice *gdev = &ctfb;
-       int bits_per_pixel;
-
-       printf("Video: ");
-       if (vbe_get_video_info(gdev)) {
-               printf("No video mode configured\n");
-               return NULL;
-       }
-
-       bits_per_pixel = gdev->gdfBytesPP * 8;
-       sprintf(gdev->modeIdent, "%dx%dx%d", gdev->winSizeX, gdev->winSizeY,
-               bits_per_pixel);
-       printf("%s\n", gdev->modeIdent);
-       debug("Frame buffer at %x\n", gdev->frameAdrs);
-
-       return (void *)gdev;
-}
index 0bf690e73d157fffa65d423060227aced9865fe3..920a0a9cf3b4ae96c2ba3aa21394dde4fd50318b 100644 (file)
@@ -2,6 +2,8 @@
 #include <exports.h>
 #include <linux/compiler.h>
 
+#define FO(x) offsetof(struct jt_funcs, x)
+
 #if defined(CONFIG_X86)
 /*
  * x86 does not have a dedicated register to store the pointer to
  * from flash memory. The global_data address is passed as argv[-1]
  * to the application program.
  */
-static void **jt;
+static struct jt_funcs *jt;
 gd_t *global_data;
 
-#define EXPORT_FUNC(x) \
+#define EXPORT_FUNC(f, a, x, ...) \
        asm volatile (                  \
 "      .globl " #x "\n"                \
 #x ":\n"                               \
 "      movl    %0, %%eax\n"            \
 "      movl    jt, %%ecx\n"            \
 "      jmp     *(%%ecx, %%eax)\n"      \
-       : : "i"(XF_ ## x * sizeof(void *)) : "eax", "ecx");
+       : : "i"(FO(x)) : "eax", "ecx");
 #elif defined(CONFIG_PPC)
 /*
  * r2 holds the pointer to the global_data, r11 is a call-clobbered
  * register
  */
-#define EXPORT_FUNC(x) \
+#define EXPORT_FUNC(f, a, x, ...) \
        asm volatile (                  \
 "      .globl " #x "\n"                \
 #x ":\n"                               \
@@ -34,33 +36,33 @@ gd_t *global_data;
 "      lwz     %%r11, %1(%%r11)\n"     \
 "      mtctr   %%r11\n"                \
 "      bctr\n"                         \
-       : : "i"(offsetof(gd_t, jt)), "i"(XF_ ## x * sizeof(void *)) : "r11");
+       : : "i"(offsetof(gd_t, jt)), "i"(FO(x)) : "r11");
 #elif defined(CONFIG_ARM)
 #ifdef CONFIG_ARM64
 /*
  * x18 holds the pointer to the global_data, x9 is a call-clobbered
  * register
  */
-#define EXPORT_FUNC(x) \
+#define EXPORT_FUNC(f, a, x, ...) \
        asm volatile (                  \
 "      .globl " #x "\n"                \
 #x ":\n"                               \
 "      ldr     x9, [x18, %0]\n"                \
 "      ldr     x9, [x9, %1]\n"         \
 "      br      x9\n"           \
-       : : "i"(offsetof(gd_t, jt)), "i"(XF_ ## x * sizeof(void *)) : "x9");
+       : : "i"(offsetof(gd_t, jt)), "i"(FO(x)) : "x9");
 #else
 /*
  * r9 holds the pointer to the global_data, ip is a call-clobbered
  * register
  */
-#define EXPORT_FUNC(x) \
+#define EXPORT_FUNC(f, a, x, ...) \
        asm volatile (                  \
 "      .globl " #x "\n"                \
 #x ":\n"                               \
 "      ldr     ip, [r9, %0]\n"         \
 "      ldr     pc, [ip, %1]\n"         \
-       : : "i"(offsetof(gd_t, jt)), "i"(XF_ ## x * sizeof(void *)) : "ip");
+       : : "i"(offsetof(gd_t, jt)), "i"(FO(x)) : "ip");
 #endif
 #elif defined(CONFIG_MIPS)
 /*
@@ -70,19 +72,19 @@ gd_t *global_data;
  * it; however, GCC/mips generates an additional `nop' after each asm
  * statement
  */
-#define EXPORT_FUNC(x) \
+#define EXPORT_FUNC(f, a, x, ...) \
        asm volatile (                  \
 "      .globl " #x "\n"                \
 #x ":\n"                               \
 "      lw      $25, %0($26)\n"         \
 "      lw      $25, %1($25)\n"         \
 "      jr      $25\n"                  \
-       : : "i"(offsetof(gd_t, jt)), "i"(XF_ ## x * sizeof(void *)) : "t9");
+       : : "i"(offsetof(gd_t, jt)), "i"(FO(x)) : "t9");
 #elif defined(CONFIG_NIOS2)
 /*
  * gp holds the pointer to the global_data, r8 is call-clobbered
  */
-#define EXPORT_FUNC(x) \
+#define EXPORT_FUNC(f, a, x, ...) \
        asm volatile (                  \
 "      .globl " #x "\n"                \
 #x ":\n"                               \
@@ -92,13 +94,13 @@ gd_t *global_data;
 "      ldw     r8, 0(r8)\n"            \
 "      ldw     r8, %1(r8)\n"           \
 "      jmp     r8\n"                   \
-       : : "i"(offsetof(gd_t, jt)), "i"(XF_ ## x * sizeof(void *)) : "gp");
+       : : "i"(offsetof(gd_t, jt)), "i"(FO(x)) : "gp");
 #elif defined(CONFIG_M68K)
 /*
  * d7 holds the pointer to the global_data, a0 is a call-clobbered
  * register
  */
-#define EXPORT_FUNC(x) \
+#define EXPORT_FUNC(f, a, x, ...) \
        asm volatile (                  \
 "      .globl " #x "\n"                \
 #x ":\n"                               \
@@ -108,50 +110,50 @@ gd_t *global_data;
 "      adda.l  %1, %%a0\n"             \
 "      move.l  (%%a0), %%a0\n"         \
 "      jmp     (%%a0)\n"                       \
-       : : "i"(offsetof(gd_t, jt)), "i"(XF_ ## x * sizeof(void *)) : "a0");
+       : : "i"(offsetof(gd_t, jt)), "i"(FO(x)) : "a0");
 #elif defined(CONFIG_MICROBLAZE)
 /*
  * r31 holds the pointer to the global_data. r5 is a call-clobbered.
  */
-#define EXPORT_FUNC(x)                         \
+#define EXPORT_FUNC(f, a, x, ...)                              \
        asm volatile (                          \
 "      .globl " #x "\n"                        \
 #x ":\n"                                       \
 "      lwi     r5, r31, %0\n"                  \
 "      lwi     r5, r5, %1\n"                   \
 "      bra     r5\n"                           \
-       : : "i"(offsetof(gd_t, jt)), "i"(XF_ ## x * sizeof(void *)) : "r5");
+       : : "i"(offsetof(gd_t, jt)), "i"(FO(x)) : "r5");
 #elif defined(CONFIG_BLACKFIN)
 /*
  * P3 holds the pointer to the global_data, P0 is a call-clobbered
  * register
  */
-#define EXPORT_FUNC(x)                 \
+#define EXPORT_FUNC(f, a, x, ...)                      \
        asm volatile (                  \
 "      .globl _" #x "\n_"              \
 #x ":\n"                               \
 "      P0 = [P3 + %0]\n"               \
 "      P0 = [P0 + %1]\n"               \
 "      JUMP (P0)\n"                    \
-       : : "i"(offsetof(gd_t, jt)), "i"(XF_ ## x * sizeof(void *)) : "P0");
+       : : "i"(offsetof(gd_t, jt)), "i"(FO(x)) : "P0");
 #elif defined(CONFIG_AVR32)
 /*
  * r6 holds the pointer to the global_data. r8 is call clobbered.
  */
-#define EXPORT_FUNC(x)                                 \
+#define EXPORT_FUNC(f, a, x, ...)                                      \
        asm volatile(                                   \
                "       .globl\t" #x "\n"               \
                #x ":\n"                                \
                "       ld.w    r8, r6[%0]\n"           \
                "       ld.w    pc, r8[%1]\n"           \
                :                                       \
-               : "i"(offsetof(gd_t, jt)), "i"(XF_ ##x) \
+               : "i"(offsetof(gd_t, jt)), "i"(FO(x))   \
                : "r8");
 #elif defined(CONFIG_SH)
 /*
  * r13 holds the pointer to the global_data. r1 is a call clobbered.
  */
-#define EXPORT_FUNC(x)                                 \
+#define EXPORT_FUNC(f, a, x, ...)                                      \
        asm volatile (                                  \
                "       .align  2\n"                    \
                "       .globl " #x "\n"                \
@@ -164,12 +166,12 @@ gd_t *global_data;
                "       jmp     @r1\n"                  \
                "       nop\n"                          \
                "       nop\n"                          \
-               : : "i"(offsetof(gd_t, jt)), "i"(XF_ ## x * sizeof(void *)) : "r1", "r2");
+               : : "i"(offsetof(gd_t, jt)), "i"(FO(x)) : "r1", "r2");
 #elif defined(CONFIG_SPARC)
 /*
  * g7 holds the pointer to the global_data. g1 is call clobbered.
  */
-#define EXPORT_FUNC(x)                                 \
+#define EXPORT_FUNC(f, a, x, ...)                                      \
        asm volatile(                                   \
 "      .globl\t" #x "\n"                               \
 #x ":\n"                                               \
@@ -179,26 +181,26 @@ gd_t *global_data;
 "      ld [%%g1 + %1], %%g1\n"                         \
 "      jmp %%g1\n"                                     \
 "      nop\n"                                          \
-       : : "i"(offsetof(gd_t, jt)), "i"(XF_ ## x * sizeof(void *)) : "g1" );
+       : : "i"(offsetof(gd_t, jt)), "i"(FO(x)) : "g1");
 #elif defined(CONFIG_NDS32)
 /*
  * r16 holds the pointer to the global_data. gp is call clobbered.
  * not support reduced register (16 GPR).
  */
-#define EXPORT_FUNC(x) \
+#define EXPORT_FUNC(f, a, x, ...) \
        asm volatile (                  \
 "      .globl " #x "\n"                \
 #x ":\n"                               \
 "      lwi     $r16, [$gp + (%0)]\n"   \
 "      lwi     $r16, [$r16 + (%1)]\n"  \
 "      jr      $r16\n"                 \
-       : : "i"(offsetof(gd_t, jt)), "i"(XF_ ## x * sizeof(void *)) : "$r16");
+       : : "i"(offsetof(gd_t, jt)), "i"(FO(x)) : "$r16");
 #elif defined(CONFIG_OPENRISC)
 /*
  * r10 holds the pointer to the global_data, r13 is a call-clobbered
  * register
  */
-#define EXPORT_FUNC(x) \
+#define EXPORT_FUNC(f, a, x, ...) \
        asm volatile (                  \
 "      .globl " #x "\n"                \
 #x ":\n"                               \
@@ -206,12 +208,12 @@ gd_t *global_data;
 "      l.lwz   r13, %1(r13)\n" \
 "      l.jr    r13\n"          \
 "      l.nop\n"                                \
-       : : "i"(offsetof(gd_t, jt)), "i"(XF_ ## x * sizeof(void *)) : "r13");
+       : : "i"(offsetof(gd_t, jt)), "i"(FO(x)) : "r13");
 #elif defined(CONFIG_ARC)
 /*
  * r25 holds the pointer to the global_data. r10 is call clobbered.
   */
-#define EXPORT_FUNC(x) \
+#define EXPORT_FUNC(f, a, x, ...) \
        asm volatile( \
 "      .align 4\n" \
 "      .globl " #x "\n" \
@@ -219,7 +221,7 @@ gd_t *global_data;
 "      ld      r10, [r25, %0]\n" \
 "      ld      r10, [r10, %1]\n" \
 "      j       [r10]\n" \
-       : : "i"(offsetof(gd_t, jt)), "i"(XF_ ## x * sizeof(void *)) : "r10");
+       : : "i"(offsetof(gd_t, jt)), "i"(FO(x)) : "r10");
 #else
 /*"    addi    $sp, $sp, -24\n"        \
 "      br      $r16\n"                 \*/
diff --git a/fs/fs.c b/fs/fs.c
index ddd751c9cccc1d4c30ed6d29bf1d55581e208ab7..483273fe20b8212075f74526cb86aa2ae3e36988 100644 (file)
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -79,6 +79,7 @@ static inline int fs_uuid_unsupported(char *uuid_str)
 
 struct fstype_info {
        int fstype;
+       char *name;
        /*
         * Is it legal to pass NULL as .probe()'s  fs_dev_desc parameter? This
         * should be false in most cases. For "virtual" filesystems which
@@ -105,6 +106,7 @@ static struct fstype_info fstypes[] = {
 #ifdef CONFIG_FS_FAT
        {
                .fstype = FS_TYPE_FAT,
+               .name = "fat",
                .null_dev_desc_ok = false,
                .probe = fat_set_blk_dev,
                .close = fat_close,
@@ -123,6 +125,7 @@ static struct fstype_info fstypes[] = {
 #ifdef CONFIG_FS_EXT4
        {
                .fstype = FS_TYPE_EXT,
+               .name = "ext4",
                .null_dev_desc_ok = false,
                .probe = ext4fs_probe,
                .close = ext4fs_close,
@@ -141,6 +144,7 @@ static struct fstype_info fstypes[] = {
 #ifdef CONFIG_SANDBOX
        {
                .fstype = FS_TYPE_SANDBOX,
+               .name = "sandbox",
                .null_dev_desc_ok = true,
                .probe = sandbox_fs_set_blk_dev,
                .close = sandbox_fs_close,
@@ -154,6 +158,7 @@ static struct fstype_info fstypes[] = {
 #endif
        {
                .fstype = FS_TYPE_ANY,
+               .name = "unsupported",
                .null_dev_desc_ok = true,
                .probe = fs_probe_unsupported,
                .close = fs_close_unsupported,
@@ -190,6 +195,7 @@ int fs_set_blk_dev(const char *ifname, const char *dev_part_str, int fstype)
        if (!relocated) {
                for (i = 0, info = fstypes; i < ARRAY_SIZE(fstypes);
                                i++, info++) {
+                       info->name += gd->reloc_off;
                        info->probe += gd->reloc_off;
                        info->close += gd->reloc_off;
                        info->ls += gd->reloc_off;
@@ -503,3 +509,24 @@ int do_fs_uuid(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[],
 
        return CMD_RET_SUCCESS;
 }
+
+int do_fs_type(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+       struct fstype_info *info;
+
+       if (argc < 3 || argc > 4)
+               return CMD_RET_USAGE;
+
+       if (fs_set_blk_dev(argv[1], argv[2], FS_TYPE_ANY))
+               return 1;
+
+       info = fs_get_info(fs_type);
+
+       if (argc == 4)
+               setenv(argv[3], info->name);
+       else
+               printf("%s\n", info->name);
+
+       return CMD_RET_SUCCESS;
+}
+
index 8c8c6ac683e71186f464451e88dea814b24e6278..5efb349d0762a93903635a272eae2eb33d4e3417 100644 (file)
@@ -12,4 +12,4 @@
 obj-y := ubifs.o io.o super.o sb.o master.o lpt.o
 obj-y += lpt_commit.o scan.o lprops.o
 obj-y += tnc.o tnc_misc.o debug.o crc16.o budget.o
-obj-y += log.o orphan.o recovery.o replay.o
+obj-y += log.o orphan.o recovery.o replay.o gc.o
diff --git a/fs/ubifs/gc.c b/fs/ubifs/gc.c
new file mode 100644 (file)
index 0000000..c6657a2
--- /dev/null
@@ -0,0 +1,976 @@
+/*
+ * This file is part of UBIFS.
+ *
+ * Copyright (C) 2006-2008 Nokia Corporation.
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ *
+ * Authors: Adrian Hunter
+ *          Artem Bityutskiy (Битюцкий Артём)
+ */
+
+/*
+ * This file implements garbage collection. The procedure for garbage collection
+ * is different depending on whether a LEB as an index LEB (contains index
+ * nodes) or not. For non-index LEBs, garbage collection finds a LEB which
+ * contains a lot of dirty space (obsolete nodes), and copies the non-obsolete
+ * nodes to the journal, at which point the garbage-collected LEB is free to be
+ * reused. For index LEBs, garbage collection marks the non-obsolete index nodes
+ * dirty in the TNC, and after the next commit, the garbage-collected LEB is
+ * to be reused. Garbage collection will cause the number of dirty index nodes
+ * to grow, however sufficient space is reserved for the index to ensure the
+ * commit will never run out of space.
+ *
+ * Notes about dead watermark. At current UBIFS implementation we assume that
+ * LEBs which have less than @c->dead_wm bytes of free + dirty space are full
+ * and not worth garbage-collecting. The dead watermark is one min. I/O unit
+ * size, or min. UBIFS node size, depending on what is greater. Indeed, UBIFS
+ * Garbage Collector has to synchronize the GC head's write buffer before
+ * returning, so this is about wasting one min. I/O unit. However, UBIFS GC can
+ * actually reclaim even very small pieces of dirty space by garbage collecting
+ * enough dirty LEBs, but we do not bother doing this at this implementation.
+ *
+ * Notes about dark watermark. The results of GC work depends on how big are
+ * the UBIFS nodes GC deals with. Large nodes make GC waste more space. Indeed,
+ * if GC move data from LEB A to LEB B and nodes in LEB A are large, GC would
+ * have to waste large pieces of free space at the end of LEB B, because nodes
+ * from LEB A would not fit. And the worst situation is when all nodes are of
+ * maximum size. So dark watermark is the amount of free + dirty space in LEB
+ * which are guaranteed to be reclaimable. If LEB has less space, the GC might
+ * be unable to reclaim it. So, LEBs with free + dirty greater than dark
+ * watermark are "good" LEBs from GC's point of few. The other LEBs are not so
+ * good, and GC takes extra care when moving them.
+ */
+#ifndef __UBOOT__
+#include <linux/slab.h>
+#include <linux/pagemap.h>
+#include <linux/list_sort.h>
+#endif
+#include "ubifs.h"
+
+#ifndef __UBOOT__
+/*
+ * GC may need to move more than one LEB to make progress. The below constants
+ * define "soft" and "hard" limits on the number of LEBs the garbage collector
+ * may move.
+ */
+#define SOFT_LEBS_LIMIT 4
+#define HARD_LEBS_LIMIT 32
+
+/**
+ * switch_gc_head - switch the garbage collection journal head.
+ * @c: UBIFS file-system description object
+ * @buf: buffer to write
+ * @len: length of the buffer to write
+ * @lnum: LEB number written is returned here
+ * @offs: offset written is returned here
+ *
+ * This function switch the GC head to the next LEB which is reserved in
+ * @c->gc_lnum. Returns %0 in case of success, %-EAGAIN if commit is required,
+ * and other negative error code in case of failures.
+ */
+static int switch_gc_head(struct ubifs_info *c)
+{
+       int err, gc_lnum = c->gc_lnum;
+       struct ubifs_wbuf *wbuf = &c->jheads[GCHD].wbuf;
+
+       ubifs_assert(gc_lnum != -1);
+       dbg_gc("switch GC head from LEB %d:%d to LEB %d (waste %d bytes)",
+              wbuf->lnum, wbuf->offs + wbuf->used, gc_lnum,
+              c->leb_size - wbuf->offs - wbuf->used);
+
+       err = ubifs_wbuf_sync_nolock(wbuf);
+       if (err)
+               return err;
+
+       /*
+        * The GC write-buffer was synchronized, we may safely unmap
+        * 'c->gc_lnum'.
+        */
+       err = ubifs_leb_unmap(c, gc_lnum);
+       if (err)
+               return err;
+
+       err = ubifs_wbuf_sync_nolock(wbuf);
+       if (err)
+               return err;
+
+       err = ubifs_add_bud_to_log(c, GCHD, gc_lnum, 0);
+       if (err)
+               return err;
+
+       c->gc_lnum = -1;
+       err = ubifs_wbuf_seek_nolock(wbuf, gc_lnum, 0);
+       return err;
+}
+
+/**
+ * data_nodes_cmp - compare 2 data nodes.
+ * @priv: UBIFS file-system description object
+ * @a: first data node
+ * @a: second data node
+ *
+ * This function compares data nodes @a and @b. Returns %1 if @a has greater
+ * inode or block number, and %-1 otherwise.
+ */
+static int data_nodes_cmp(void *priv, struct list_head *a, struct list_head *b)
+{
+       ino_t inuma, inumb;
+       struct ubifs_info *c = priv;
+       struct ubifs_scan_node *sa, *sb;
+
+       cond_resched();
+       if (a == b)
+               return 0;
+
+       sa = list_entry(a, struct ubifs_scan_node, list);
+       sb = list_entry(b, struct ubifs_scan_node, list);
+
+       ubifs_assert(key_type(c, &sa->key) == UBIFS_DATA_KEY);
+       ubifs_assert(key_type(c, &sb->key) == UBIFS_DATA_KEY);
+       ubifs_assert(sa->type == UBIFS_DATA_NODE);
+       ubifs_assert(sb->type == UBIFS_DATA_NODE);
+
+       inuma = key_inum(c, &sa->key);
+       inumb = key_inum(c, &sb->key);
+
+       if (inuma == inumb) {
+               unsigned int blka = key_block(c, &sa->key);
+               unsigned int blkb = key_block(c, &sb->key);
+
+               if (blka <= blkb)
+                       return -1;
+       } else if (inuma <= inumb)
+               return -1;
+
+       return 1;
+}
+
+/*
+ * nondata_nodes_cmp - compare 2 non-data nodes.
+ * @priv: UBIFS file-system description object
+ * @a: first node
+ * @a: second node
+ *
+ * This function compares nodes @a and @b. It makes sure that inode nodes go
+ * first and sorted by length in descending order. Directory entry nodes go
+ * after inode nodes and are sorted in ascending hash valuer order.
+ */
+static int nondata_nodes_cmp(void *priv, struct list_head *a,
+                            struct list_head *b)
+{
+       ino_t inuma, inumb;
+       struct ubifs_info *c = priv;
+       struct ubifs_scan_node *sa, *sb;
+
+       cond_resched();
+       if (a == b)
+               return 0;
+
+       sa = list_entry(a, struct ubifs_scan_node, list);
+       sb = list_entry(b, struct ubifs_scan_node, list);
+
+       ubifs_assert(key_type(c, &sa->key) != UBIFS_DATA_KEY &&
+                    key_type(c, &sb->key) != UBIFS_DATA_KEY);
+       ubifs_assert(sa->type != UBIFS_DATA_NODE &&
+                    sb->type != UBIFS_DATA_NODE);
+
+       /* Inodes go before directory entries */
+       if (sa->type == UBIFS_INO_NODE) {
+               if (sb->type == UBIFS_INO_NODE)
+                       return sb->len - sa->len;
+               return -1;
+       }
+       if (sb->type == UBIFS_INO_NODE)
+               return 1;
+
+       ubifs_assert(key_type(c, &sa->key) == UBIFS_DENT_KEY ||
+                    key_type(c, &sa->key) == UBIFS_XENT_KEY);
+       ubifs_assert(key_type(c, &sb->key) == UBIFS_DENT_KEY ||
+                    key_type(c, &sb->key) == UBIFS_XENT_KEY);
+       ubifs_assert(sa->type == UBIFS_DENT_NODE ||
+                    sa->type == UBIFS_XENT_NODE);
+       ubifs_assert(sb->type == UBIFS_DENT_NODE ||
+                    sb->type == UBIFS_XENT_NODE);
+
+       inuma = key_inum(c, &sa->key);
+       inumb = key_inum(c, &sb->key);
+
+       if (inuma == inumb) {
+               uint32_t hasha = key_hash(c, &sa->key);
+               uint32_t hashb = key_hash(c, &sb->key);
+
+               if (hasha <= hashb)
+                       return -1;
+       } else if (inuma <= inumb)
+               return -1;
+
+       return 1;
+}
+
+/**
+ * sort_nodes - sort nodes for GC.
+ * @c: UBIFS file-system description object
+ * @sleb: describes nodes to sort and contains the result on exit
+ * @nondata: contains non-data nodes on exit
+ * @min: minimum node size is returned here
+ *
+ * This function sorts the list of inodes to garbage collect. First of all, it
+ * kills obsolete nodes and separates data and non-data nodes to the
+ * @sleb->nodes and @nondata lists correspondingly.
+ *
+ * Data nodes are then sorted in block number order - this is important for
+ * bulk-read; data nodes with lower inode number go before data nodes with
+ * higher inode number, and data nodes with lower block number go before data
+ * nodes with higher block number;
+ *
+ * Non-data nodes are sorted as follows.
+ *   o First go inode nodes - they are sorted in descending length order.
+ *   o Then go directory entry nodes - they are sorted in hash order, which
+ *     should supposedly optimize 'readdir()'. Direntry nodes with lower parent
+ *     inode number go before direntry nodes with higher parent inode number,
+ *     and direntry nodes with lower name hash values go before direntry nodes
+ *     with higher name hash values.
+ *
+ * This function returns zero in case of success and a negative error code in
+ * case of failure.
+ */
+static int sort_nodes(struct ubifs_info *c, struct ubifs_scan_leb *sleb,
+                     struct list_head *nondata, int *min)
+{
+       int err;
+       struct ubifs_scan_node *snod, *tmp;
+
+       *min = INT_MAX;
+
+       /* Separate data nodes and non-data nodes */
+       list_for_each_entry_safe(snod, tmp, &sleb->nodes, list) {
+               ubifs_assert(snod->type == UBIFS_INO_NODE  ||
+                            snod->type == UBIFS_DATA_NODE ||
+                            snod->type == UBIFS_DENT_NODE ||
+                            snod->type == UBIFS_XENT_NODE ||
+                            snod->type == UBIFS_TRUN_NODE);
+
+               if (snod->type != UBIFS_INO_NODE  &&
+                   snod->type != UBIFS_DATA_NODE &&
+                   snod->type != UBIFS_DENT_NODE &&
+                   snod->type != UBIFS_XENT_NODE) {
+                       /* Probably truncation node, zap it */
+                       list_del(&snod->list);
+                       kfree(snod);
+                       continue;
+               }
+
+               ubifs_assert(key_type(c, &snod->key) == UBIFS_DATA_KEY ||
+                            key_type(c, &snod->key) == UBIFS_INO_KEY  ||
+                            key_type(c, &snod->key) == UBIFS_DENT_KEY ||
+                            key_type(c, &snod->key) == UBIFS_XENT_KEY);
+
+               err = ubifs_tnc_has_node(c, &snod->key, 0, sleb->lnum,
+                                        snod->offs, 0);
+               if (err < 0)
+                       return err;
+
+               if (!err) {
+                       /* The node is obsolete, remove it from the list */
+                       list_del(&snod->list);
+                       kfree(snod);
+                       continue;
+               }
+
+               if (snod->len < *min)
+                       *min = snod->len;
+
+               if (key_type(c, &snod->key) != UBIFS_DATA_KEY)
+                       list_move_tail(&snod->list, nondata);
+       }
+
+       /* Sort data and non-data nodes */
+       list_sort(c, &sleb->nodes, &data_nodes_cmp);
+       list_sort(c, nondata, &nondata_nodes_cmp);
+
+       err = dbg_check_data_nodes_order(c, &sleb->nodes);
+       if (err)
+               return err;
+       err = dbg_check_nondata_nodes_order(c, nondata);
+       if (err)
+               return err;
+       return 0;
+}
+
+/**
+ * move_node - move a node.
+ * @c: UBIFS file-system description object
+ * @sleb: describes the LEB to move nodes from
+ * @snod: the mode to move
+ * @wbuf: write-buffer to move node to
+ *
+ * This function moves node @snod to @wbuf, changes TNC correspondingly, and
+ * destroys @snod. Returns zero in case of success and a negative error code in
+ * case of failure.
+ */
+static int move_node(struct ubifs_info *c, struct ubifs_scan_leb *sleb,
+                    struct ubifs_scan_node *snod, struct ubifs_wbuf *wbuf)
+{
+       int err, new_lnum = wbuf->lnum, new_offs = wbuf->offs + wbuf->used;
+
+       cond_resched();
+       err = ubifs_wbuf_write_nolock(wbuf, snod->node, snod->len);
+       if (err)
+               return err;
+
+       err = ubifs_tnc_replace(c, &snod->key, sleb->lnum,
+                               snod->offs, new_lnum, new_offs,
+                               snod->len);
+       list_del(&snod->list);
+       kfree(snod);
+       return err;
+}
+
+/**
+ * move_nodes - move nodes.
+ * @c: UBIFS file-system description object
+ * @sleb: describes the LEB to move nodes from
+ *
+ * This function moves valid nodes from data LEB described by @sleb to the GC
+ * journal head. This function returns zero in case of success, %-EAGAIN if
+ * commit is required, and other negative error codes in case of other
+ * failures.
+ */
+static int move_nodes(struct ubifs_info *c, struct ubifs_scan_leb *sleb)
+{
+       int err, min;
+       LIST_HEAD(nondata);
+       struct ubifs_wbuf *wbuf = &c->jheads[GCHD].wbuf;
+
+       if (wbuf->lnum == -1) {
+               /*
+                * The GC journal head is not set, because it is the first GC
+                * invocation since mount.
+                */
+               err = switch_gc_head(c);
+               if (err)
+                       return err;
+       }
+
+       err = sort_nodes(c, sleb, &nondata, &min);
+       if (err)
+               goto out;
+
+       /* Write nodes to their new location. Use the first-fit strategy */
+       while (1) {
+               int avail;
+               struct ubifs_scan_node *snod, *tmp;
+
+               /* Move data nodes */
+               list_for_each_entry_safe(snod, tmp, &sleb->nodes, list) {
+                       avail = c->leb_size - wbuf->offs - wbuf->used;
+                       if  (snod->len > avail)
+                               /*
+                                * Do not skip data nodes in order to optimize
+                                * bulk-read.
+                                */
+                               break;
+
+                       err = move_node(c, sleb, snod, wbuf);
+                       if (err)
+                               goto out;
+               }
+
+               /* Move non-data nodes */
+               list_for_each_entry_safe(snod, tmp, &nondata, list) {
+                       avail = c->leb_size - wbuf->offs - wbuf->used;
+                       if (avail < min)
+                               break;
+
+                       if  (snod->len > avail) {
+                               /*
+                                * Keep going only if this is an inode with
+                                * some data. Otherwise stop and switch the GC
+                                * head. IOW, we assume that data-less inode
+                                * nodes and direntry nodes are roughly of the
+                                * same size.
+                                */
+                               if (key_type(c, &snod->key) == UBIFS_DENT_KEY ||
+                                   snod->len == UBIFS_INO_NODE_SZ)
+                                       break;
+                               continue;
+                       }
+
+                       err = move_node(c, sleb, snod, wbuf);
+                       if (err)
+                               goto out;
+               }
+
+               if (list_empty(&sleb->nodes) && list_empty(&nondata))
+                       break;
+
+               /*
+                * Waste the rest of the space in the LEB and switch to the
+                * next LEB.
+                */
+               err = switch_gc_head(c);
+               if (err)
+                       goto out;
+       }
+
+       return 0;
+
+out:
+       list_splice_tail(&nondata, &sleb->nodes);
+       return err;
+}
+
+/**
+ * gc_sync_wbufs - sync write-buffers for GC.
+ * @c: UBIFS file-system description object
+ *
+ * We must guarantee that obsoleting nodes are on flash. Unfortunately they may
+ * be in a write-buffer instead. That is, a node could be written to a
+ * write-buffer, obsoleting another node in a LEB that is GC'd. If that LEB is
+ * erased before the write-buffer is sync'd and then there is an unclean
+ * unmount, then an existing node is lost. To avoid this, we sync all
+ * write-buffers.
+ *
+ * This function returns %0 on success or a negative error code on failure.
+ */
+static int gc_sync_wbufs(struct ubifs_info *c)
+{
+       int err, i;
+
+       for (i = 0; i < c->jhead_cnt; i++) {
+               if (i == GCHD)
+                       continue;
+               err = ubifs_wbuf_sync(&c->jheads[i].wbuf);
+               if (err)
+                       return err;
+       }
+       return 0;
+}
+
+/**
+ * ubifs_garbage_collect_leb - garbage-collect a logical eraseblock.
+ * @c: UBIFS file-system description object
+ * @lp: describes the LEB to garbage collect
+ *
+ * This function garbage-collects an LEB and returns one of the @LEB_FREED,
+ * @LEB_RETAINED, etc positive codes in case of success, %-EAGAIN if commit is
+ * required, and other negative error codes in case of failures.
+ */
+int ubifs_garbage_collect_leb(struct ubifs_info *c, struct ubifs_lprops *lp)
+{
+       struct ubifs_scan_leb *sleb;
+       struct ubifs_scan_node *snod;
+       struct ubifs_wbuf *wbuf = &c->jheads[GCHD].wbuf;
+       int err = 0, lnum = lp->lnum;
+
+       ubifs_assert(c->gc_lnum != -1 || wbuf->offs + wbuf->used == 0 ||
+                    c->need_recovery);
+       ubifs_assert(c->gc_lnum != lnum);
+       ubifs_assert(wbuf->lnum != lnum);
+
+       if (lp->free + lp->dirty == c->leb_size) {
+               /* Special case - a free LEB  */
+               dbg_gc("LEB %d is free, return it", lp->lnum);
+               ubifs_assert(!(lp->flags & LPROPS_INDEX));
+
+               if (lp->free != c->leb_size) {
+                       /*
+                        * Write buffers must be sync'd before unmapping
+                        * freeable LEBs, because one of them may contain data
+                        * which obsoletes something in 'lp->pnum'.
+                        */
+                       err = gc_sync_wbufs(c);
+                       if (err)
+                               return err;
+                       err = ubifs_change_one_lp(c, lp->lnum, c->leb_size,
+                                                 0, 0, 0, 0);
+                       if (err)
+                               return err;
+               }
+               err = ubifs_leb_unmap(c, lp->lnum);
+               if (err)
+                       return err;
+
+               if (c->gc_lnum == -1) {
+                       c->gc_lnum = lnum;
+                       return LEB_RETAINED;
+               }
+
+               return LEB_FREED;
+       }
+
+       /*
+        * We scan the entire LEB even though we only really need to scan up to
+        * (c->leb_size - lp->free).
+        */
+       sleb = ubifs_scan(c, lnum, 0, c->sbuf, 0);
+       if (IS_ERR(sleb))
+               return PTR_ERR(sleb);
+
+       ubifs_assert(!list_empty(&sleb->nodes));
+       snod = list_entry(sleb->nodes.next, struct ubifs_scan_node, list);
+
+       if (snod->type == UBIFS_IDX_NODE) {
+               struct ubifs_gced_idx_leb *idx_gc;
+
+               dbg_gc("indexing LEB %d (free %d, dirty %d)",
+                      lnum, lp->free, lp->dirty);
+               list_for_each_entry(snod, &sleb->nodes, list) {
+                       struct ubifs_idx_node *idx = snod->node;
+                       int level = le16_to_cpu(idx->level);
+
+                       ubifs_assert(snod->type == UBIFS_IDX_NODE);
+                       key_read(c, ubifs_idx_key(c, idx), &snod->key);
+                       err = ubifs_dirty_idx_node(c, &snod->key, level, lnum,
+                                                  snod->offs);
+                       if (err)
+                               goto out;
+               }
+
+               idx_gc = kmalloc(sizeof(struct ubifs_gced_idx_leb), GFP_NOFS);
+               if (!idx_gc) {
+                       err = -ENOMEM;
+                       goto out;
+               }
+
+               idx_gc->lnum = lnum;
+               idx_gc->unmap = 0;
+               list_add(&idx_gc->list, &c->idx_gc);
+
+               /*
+                * Don't release the LEB until after the next commit, because
+                * it may contain data which is needed for recovery. So
+                * although we freed this LEB, it will become usable only after
+                * the commit.
+                */
+               err = ubifs_change_one_lp(c, lnum, c->leb_size, 0, 0,
+                                         LPROPS_INDEX, 1);
+               if (err)
+                       goto out;
+               err = LEB_FREED_IDX;
+       } else {
+               dbg_gc("data LEB %d (free %d, dirty %d)",
+                      lnum, lp->free, lp->dirty);
+
+               err = move_nodes(c, sleb);
+               if (err)
+                       goto out_inc_seq;
+
+               err = gc_sync_wbufs(c);
+               if (err)
+                       goto out_inc_seq;
+
+               err = ubifs_change_one_lp(c, lnum, c->leb_size, 0, 0, 0, 0);
+               if (err)
+                       goto out_inc_seq;
+
+               /* Allow for races with TNC */
+               c->gced_lnum = lnum;
+               smp_wmb();
+               c->gc_seq += 1;
+               smp_wmb();
+
+               if (c->gc_lnum == -1) {
+                       c->gc_lnum = lnum;
+                       err = LEB_RETAINED;
+               } else {
+                       err = ubifs_wbuf_sync_nolock(wbuf);
+                       if (err)
+                               goto out;
+
+                       err = ubifs_leb_unmap(c, lnum);
+                       if (err)
+                               goto out;
+
+                       err = LEB_FREED;
+               }
+       }
+
+out:
+       ubifs_scan_destroy(sleb);
+       return err;
+
+out_inc_seq:
+       /* We may have moved at least some nodes so allow for races with TNC */
+       c->gced_lnum = lnum;
+       smp_wmb();
+       c->gc_seq += 1;
+       smp_wmb();
+       goto out;
+}
+
+/**
+ * ubifs_garbage_collect - UBIFS garbage collector.
+ * @c: UBIFS file-system description object
+ * @anyway: do GC even if there are free LEBs
+ *
+ * This function does out-of-place garbage collection. The return codes are:
+ *   o positive LEB number if the LEB has been freed and may be used;
+ *   o %-EAGAIN if the caller has to run commit;
+ *   o %-ENOSPC if GC failed to make any progress;
+ *   o other negative error codes in case of other errors.
+ *
+ * Garbage collector writes data to the journal when GC'ing data LEBs, and just
+ * marking indexing nodes dirty when GC'ing indexing LEBs. Thus, at some point
+ * commit may be required. But commit cannot be run from inside GC, because the
+ * caller might be holding the commit lock, so %-EAGAIN is returned instead;
+ * And this error code means that the caller has to run commit, and re-run GC
+ * if there is still no free space.
+ *
+ * There are many reasons why this function may return %-EAGAIN:
+ * o the log is full and there is no space to write an LEB reference for
+ *   @c->gc_lnum;
+ * o the journal is too large and exceeds size limitations;
+ * o GC moved indexing LEBs, but they can be used only after the commit;
+ * o the shrinker fails to find clean znodes to free and requests the commit;
+ * o etc.
+ *
+ * Note, if the file-system is close to be full, this function may return
+ * %-EAGAIN infinitely, so the caller has to limit amount of re-invocations of
+ * the function. E.g., this happens if the limits on the journal size are too
+ * tough and GC writes too much to the journal before an LEB is freed. This
+ * might also mean that the journal is too large, and the TNC becomes to big,
+ * so that the shrinker is constantly called, finds not clean znodes to free,
+ * and requests commit. Well, this may also happen if the journal is all right,
+ * but another kernel process consumes too much memory. Anyway, infinite
+ * %-EAGAIN may happen, but in some extreme/misconfiguration cases.
+ */
+int ubifs_garbage_collect(struct ubifs_info *c, int anyway)
+{
+       int i, err, ret, min_space = c->dead_wm;
+       struct ubifs_lprops lp;
+       struct ubifs_wbuf *wbuf = &c->jheads[GCHD].wbuf;
+
+       ubifs_assert_cmt_locked(c);
+       ubifs_assert(!c->ro_media && !c->ro_mount);
+
+       if (ubifs_gc_should_commit(c))
+               return -EAGAIN;
+
+       mutex_lock_nested(&wbuf->io_mutex, wbuf->jhead);
+
+       if (c->ro_error) {
+               ret = -EROFS;
+               goto out_unlock;
+       }
+
+       /* We expect the write-buffer to be empty on entry */
+       ubifs_assert(!wbuf->used);
+
+       for (i = 0; ; i++) {
+               int space_before, space_after;
+
+               cond_resched();
+
+               /* Give the commit an opportunity to run */
+               if (ubifs_gc_should_commit(c)) {
+                       ret = -EAGAIN;
+                       break;
+               }
+
+               if (i > SOFT_LEBS_LIMIT && !list_empty(&c->idx_gc)) {
+                       /*
+                        * We've done enough iterations. Indexing LEBs were
+                        * moved and will be available after the commit.
+                        */
+                       dbg_gc("soft limit, some index LEBs GC'ed, -EAGAIN");
+                       ubifs_commit_required(c);
+                       ret = -EAGAIN;
+                       break;
+               }
+
+               if (i > HARD_LEBS_LIMIT) {
+                       /*
+                        * We've moved too many LEBs and have not made
+                        * progress, give up.
+                        */
+                       dbg_gc("hard limit, -ENOSPC");
+                       ret = -ENOSPC;
+                       break;
+               }
+
+               /*
+                * Empty and freeable LEBs can turn up while we waited for
+                * the wbuf lock, or while we have been running GC. In that
+                * case, we should just return one of those instead of
+                * continuing to GC dirty LEBs. Hence we request
+                * 'ubifs_find_dirty_leb()' to return an empty LEB if it can.
+                */
+               ret = ubifs_find_dirty_leb(c, &lp, min_space, anyway ? 0 : 1);
+               if (ret) {
+                       if (ret == -ENOSPC)
+                               dbg_gc("no more dirty LEBs");
+                       break;
+               }
+
+               dbg_gc("found LEB %d: free %d, dirty %d, sum %d (min. space %d)",
+                      lp.lnum, lp.free, lp.dirty, lp.free + lp.dirty,
+                      min_space);
+
+               space_before = c->leb_size - wbuf->offs - wbuf->used;
+               if (wbuf->lnum == -1)
+                       space_before = 0;
+
+               ret = ubifs_garbage_collect_leb(c, &lp);
+               if (ret < 0) {
+                       if (ret == -EAGAIN) {
+                               /*
+                                * This is not error, so we have to return the
+                                * LEB to lprops. But if 'ubifs_return_leb()'
+                                * fails, its failure code is propagated to the
+                                * caller instead of the original '-EAGAIN'.
+                                */
+                               err = ubifs_return_leb(c, lp.lnum);
+                               if (err)
+                                       ret = err;
+                               break;
+                       }
+                       goto out;
+               }
+
+               if (ret == LEB_FREED) {
+                       /* An LEB has been freed and is ready for use */
+                       dbg_gc("LEB %d freed, return", lp.lnum);
+                       ret = lp.lnum;
+                       break;
+               }
+
+               if (ret == LEB_FREED_IDX) {
+                       /*
+                        * This was an indexing LEB and it cannot be
+                        * immediately used. And instead of requesting the
+                        * commit straight away, we try to garbage collect some
+                        * more.
+                        */
+                       dbg_gc("indexing LEB %d freed, continue", lp.lnum);
+                       continue;
+               }
+
+               ubifs_assert(ret == LEB_RETAINED);
+               space_after = c->leb_size - wbuf->offs - wbuf->used;
+               dbg_gc("LEB %d retained, freed %d bytes", lp.lnum,
+                      space_after - space_before);
+
+               if (space_after > space_before) {
+                       /* GC makes progress, keep working */
+                       min_space >>= 1;
+                       if (min_space < c->dead_wm)
+                               min_space = c->dead_wm;
+                       continue;
+               }
+
+               dbg_gc("did not make progress");
+
+               /*
+                * GC moved an LEB bud have not done any progress. This means
+                * that the previous GC head LEB contained too few free space
+                * and the LEB which was GC'ed contained only large nodes which
+                * did not fit that space.
+                *
+                * We can do 2 things:
+                * 1. pick another LEB in a hope it'll contain a small node
+                *    which will fit the space we have at the end of current GC
+                *    head LEB, but there is no guarantee, so we try this out
+                *    unless we have already been working for too long;
+                * 2. request an LEB with more dirty space, which will force
+                *    'ubifs_find_dirty_leb()' to start scanning the lprops
+                *    table, instead of just picking one from the heap
+                *    (previously it already picked the dirtiest LEB).
+                */
+               if (i < SOFT_LEBS_LIMIT) {
+                       dbg_gc("try again");
+                       continue;
+               }
+
+               min_space <<= 1;
+               if (min_space > c->dark_wm)
+                       min_space = c->dark_wm;
+               dbg_gc("set min. space to %d", min_space);
+       }
+
+       if (ret == -ENOSPC && !list_empty(&c->idx_gc)) {
+               dbg_gc("no space, some index LEBs GC'ed, -EAGAIN");
+               ubifs_commit_required(c);
+               ret = -EAGAIN;
+       }
+
+       err = ubifs_wbuf_sync_nolock(wbuf);
+       if (!err)
+               err = ubifs_leb_unmap(c, c->gc_lnum);
+       if (err) {
+               ret = err;
+               goto out;
+       }
+out_unlock:
+       mutex_unlock(&wbuf->io_mutex);
+       return ret;
+
+out:
+       ubifs_assert(ret < 0);
+       ubifs_assert(ret != -ENOSPC && ret != -EAGAIN);
+       ubifs_wbuf_sync_nolock(wbuf);
+       ubifs_ro_mode(c, ret);
+       mutex_unlock(&wbuf->io_mutex);
+       ubifs_return_leb(c, lp.lnum);
+       return ret;
+}
+
+/**
+ * ubifs_gc_start_commit - garbage collection at start of commit.
+ * @c: UBIFS file-system description object
+ *
+ * If a LEB has only dirty and free space, then we may safely unmap it and make
+ * it free.  Note, we cannot do this with indexing LEBs because dirty space may
+ * correspond index nodes that are required for recovery.  In that case, the
+ * LEB cannot be unmapped until after the next commit.
+ *
+ * This function returns %0 upon success and a negative error code upon failure.
+ */
+int ubifs_gc_start_commit(struct ubifs_info *c)
+{
+       struct ubifs_gced_idx_leb *idx_gc;
+       const struct ubifs_lprops *lp;
+       int err = 0, flags;
+
+       ubifs_get_lprops(c);
+
+       /*
+        * Unmap (non-index) freeable LEBs. Note that recovery requires that all
+        * wbufs are sync'd before this, which is done in 'do_commit()'.
+        */
+       while (1) {
+               lp = ubifs_fast_find_freeable(c);
+               if (IS_ERR(lp)) {
+                       err = PTR_ERR(lp);
+                       goto out;
+               }
+               if (!lp)
+                       break;
+               ubifs_assert(!(lp->flags & LPROPS_TAKEN));
+               ubifs_assert(!(lp->flags & LPROPS_INDEX));
+               err = ubifs_leb_unmap(c, lp->lnum);
+               if (err)
+                       goto out;
+               lp = ubifs_change_lp(c, lp, c->leb_size, 0, lp->flags, 0);
+               if (IS_ERR(lp)) {
+                       err = PTR_ERR(lp);
+                       goto out;
+               }
+               ubifs_assert(!(lp->flags & LPROPS_TAKEN));
+               ubifs_assert(!(lp->flags & LPROPS_INDEX));
+       }
+
+       /* Mark GC'd index LEBs OK to unmap after this commit finishes */
+       list_for_each_entry(idx_gc, &c->idx_gc, list)
+               idx_gc->unmap = 1;
+
+       /* Record index freeable LEBs for unmapping after commit */
+       while (1) {
+               lp = ubifs_fast_find_frdi_idx(c);
+               if (IS_ERR(lp)) {
+                       err = PTR_ERR(lp);
+                       goto out;
+               }
+               if (!lp)
+                       break;
+               idx_gc = kmalloc(sizeof(struct ubifs_gced_idx_leb), GFP_NOFS);
+               if (!idx_gc) {
+                       err = -ENOMEM;
+                       goto out;
+               }
+               ubifs_assert(!(lp->flags & LPROPS_TAKEN));
+               ubifs_assert(lp->flags & LPROPS_INDEX);
+               /* Don't release the LEB until after the next commit */
+               flags = (lp->flags | LPROPS_TAKEN) ^ LPROPS_INDEX;
+               lp = ubifs_change_lp(c, lp, c->leb_size, 0, flags, 1);
+               if (IS_ERR(lp)) {
+                       err = PTR_ERR(lp);
+                       kfree(idx_gc);
+                       goto out;
+               }
+               ubifs_assert(lp->flags & LPROPS_TAKEN);
+               ubifs_assert(!(lp->flags & LPROPS_INDEX));
+               idx_gc->lnum = lp->lnum;
+               idx_gc->unmap = 1;
+               list_add(&idx_gc->list, &c->idx_gc);
+       }
+out:
+       ubifs_release_lprops(c);
+       return err;
+}
+
+/**
+ * ubifs_gc_end_commit - garbage collection at end of commit.
+ * @c: UBIFS file-system description object
+ *
+ * This function completes out-of-place garbage collection of index LEBs.
+ */
+int ubifs_gc_end_commit(struct ubifs_info *c)
+{
+       struct ubifs_gced_idx_leb *idx_gc, *tmp;
+       struct ubifs_wbuf *wbuf;
+       int err = 0;
+
+       wbuf = &c->jheads[GCHD].wbuf;
+       mutex_lock_nested(&wbuf->io_mutex, wbuf->jhead);
+       list_for_each_entry_safe(idx_gc, tmp, &c->idx_gc, list)
+               if (idx_gc->unmap) {
+                       dbg_gc("LEB %d", idx_gc->lnum);
+                       err = ubifs_leb_unmap(c, idx_gc->lnum);
+                       if (err)
+                               goto out;
+                       err = ubifs_change_one_lp(c, idx_gc->lnum, LPROPS_NC,
+                                         LPROPS_NC, 0, LPROPS_TAKEN, -1);
+                       if (err)
+                               goto out;
+                       list_del(&idx_gc->list);
+                       kfree(idx_gc);
+               }
+out:
+       mutex_unlock(&wbuf->io_mutex);
+       return err;
+}
+#endif
+/**
+ * ubifs_destroy_idx_gc - destroy idx_gc list.
+ * @c: UBIFS file-system description object
+ *
+ * This function destroys the @c->idx_gc list. It is called when unmounting
+ * so locks are not needed. Returns zero in case of success and a negative
+ * error code in case of failure.
+ */
+void ubifs_destroy_idx_gc(struct ubifs_info *c)
+{
+       while (!list_empty(&c->idx_gc)) {
+               struct ubifs_gced_idx_leb *idx_gc;
+
+               idx_gc = list_entry(c->idx_gc.next, struct ubifs_gced_idx_leb,
+                                   list);
+               c->idx_gc_cnt -= 1;
+               list_del(&idx_gc->list);
+               kfree(idx_gc);
+       }
+}
+#ifndef __UBOOT__
+/**
+ * ubifs_get_idx_gc_leb - get a LEB from GC'd index LEB list.
+ * @c: UBIFS file-system description object
+ *
+ * Called during start commit so locks are not needed.
+ */
+int ubifs_get_idx_gc_leb(struct ubifs_info *c)
+{
+       struct ubifs_gced_idx_leb *idx_gc;
+       int lnum;
+
+       if (list_empty(&c->idx_gc))
+               return -ENOSPC;
+       idx_gc = list_entry(c->idx_gc.next, struct ubifs_gced_idx_leb, list);
+       lnum = idx_gc->lnum;
+       /* c->idx_gc_cnt is updated by the caller when lprops are updated */
+       list_del(&idx_gc->list);
+       kfree(idx_gc);
+       return lnum;
+}
+#endif
index 7268b37a49c8b0a13a3e223fab6aa2a3624e0a86..1064cb29ba8828e0b0347d6665d1c0a9b897b368 100644 (file)
@@ -78,7 +78,6 @@ struct bud_entry {
        int dirty;
 };
 
-#ifndef __UBOOT__
 /**
  * set_bud_lprops - set free and dirty space used by a bud.
  * @c: UBIFS file-system description object
@@ -432,7 +431,6 @@ static int insert_dent(struct ubifs_info *c, int lnum, int offs, int len,
        list_add_tail(&r->list, &c->replay_list);
        return 0;
 }
-#endif
 
 /**
  * ubifs_validate_entry - validate directory or extended attribute entry node.
@@ -466,7 +464,6 @@ int ubifs_validate_entry(struct ubifs_info *c,
        return 0;
 }
 
-#ifndef __UBOOT__
 /**
  * is_last_bud - check if the bud is the last in the journal head.
  * @c: UBIFS file-system description object
@@ -1063,4 +1060,3 @@ out:
        c->replaying = 0;
        return err;
 }
-#endif
index 01d449a7afa4f95185e777f06db9e4f47c01d0a4..10f8fff0be6f7c1cb4bbecdfc673174901c72e28 100644 (file)
@@ -1049,7 +1049,6 @@ static void free_orphans(struct ubifs_info *c)
        c->orph_buf = NULL;
 }
 
-#ifndef __UBOOT__
 /**
  * free_buds - free per-bud objects.
  * @c: UBIFS file-system description object
@@ -1061,7 +1060,6 @@ static void free_buds(struct ubifs_info *c)
        rbtree_postorder_for_each_entry_safe(bud, n, &c->buds, rb)
                kfree(bud);
 }
-#endif
 
 /**
  * check_volume_empty - check if the UBI volume is empty.
@@ -1242,6 +1240,7 @@ static int ubifs_parse_options(struct ubifs_info *c, char *options,
 
        return 0;
 }
+#endif
 
 /**
  * destroy_journal - destroy journal data structures.
@@ -1272,7 +1271,6 @@ static void destroy_journal(struct ubifs_info *c)
        ubifs_tnc_close(c);
        free_buds(c);
 }
-#endif
 
 /**
  * bu_init - initialize bulk-read information.
@@ -1502,11 +1500,9 @@ static int mount_ubifs(struct ubifs_info *c)
        if (err)
                goto out_lpt;
 
-#ifndef __UBOOT__
        err = ubifs_replay_journal(c);
        if (err)
                goto out_journal;
-#endif
 
        /* Calculate 'min_idx_lebs' after journal replay */
        c->bi.min_idx_lebs = ubifs_calc_min_idx_lebs(c);
@@ -1678,10 +1674,8 @@ out_infos:
        spin_unlock(&ubifs_infos_lock);
 out_orphans:
        free_orphans(c);
-#ifndef __UBOOT__
 out_journal:
        destroy_journal(c);
-#endif
 out_lpt:
        ubifs_lpt_free(c, 0);
 out_master:
index 95cae548bf2cf4a2ef2ee7cdfa693f8221a59bec..e20cedda575dd27de30e7ce91ff47db3f7b6cd16 100644 (file)
@@ -2827,7 +2827,6 @@ out_unlock:
        return ERR_PTR(err);
 }
 
-#ifndef __UBOOT__
 /**
  * tnc_destroy_cnext - destroy left-over obsolete znodes from a failed commit.
  * @c: UBIFS file-system description object
@@ -2869,7 +2868,6 @@ void ubifs_tnc_close(struct ubifs_info *c)
        kfree(c->ilebs);
        destroy_old_idx(c);
 }
-#endif
 
 /**
  * left_znode - get the znode to the left.
index 49e6f469ca6c47d3b515dc2ad7308008c045ab39..6dd617426ad35dfdb28da648db8361f6e00a7c02 100644 (file)
@@ -150,6 +150,12 @@ static inline int crypto_comp_decompress(struct crypto_comp *tfm,
 
        return 0;
 }
+
+/* from shrinker.c */
+
+/* Global clean znode counter (for all mounted UBIFS instances) */
+atomic_long_t ubifs_clean_zn_cnt;
+
 #endif
 
 /**
index c12026147fc5635512482a8814abc43e17448d78..a51b2376d22839cee21d5566ff4628063e1b3acc 100644 (file)
@@ -31,6 +31,8 @@
 #include <linux/backing-dev.h>
 #include "ubifs-media.h"
 #else
+#include <asm/atomic.h>
+#include <asm-generic/atomic-long.h>
 #include <ubi_uboot.h>
 
 #include <linux/ctype.h>
@@ -63,16 +65,6 @@ struct page {
 
 void iput(struct inode *inode);
 
-/*
- * The atomic operations are used for budgeting etc which is not
- * needed for the read-only U-Boot implementation:
- */
-#define atomic_long_inc(a)
-#define atomic_long_dec(a)
-#define        atomic_long_sub(a, b)
-
-typedef unsigned long atomic_long_t;
-
 /* linux/include/time.h */
 #define NSEC_PER_SEC   1000000000L
 #define get_seconds()  0
index 349a3c5522ff876f5fba77731a53a56a15371e84..594470328ea8a7aca5b83e359457410806eaf2c3 100644 (file)
@@ -1,32 +1,73 @@
 /*
- * You do not need to use #ifdef around functions that may not exist
+ * You need to use #ifdef around functions that may not exist
  * in the final configuration (such as i2c).
+ * use a dummyfunction as first parameter to EXPORT_FUNC.
+ * As an example see the CONFIG_CMD_I2C section below
  */
-EXPORT_FUNC(get_version)
-EXPORT_FUNC(getc)
-EXPORT_FUNC(tstc)
-EXPORT_FUNC(putc)
-EXPORT_FUNC(puts)
-EXPORT_FUNC(printf)
-EXPORT_FUNC(install_hdlr)
-EXPORT_FUNC(free_hdlr)
-EXPORT_FUNC(malloc)
-EXPORT_FUNC(free)
-EXPORT_FUNC(udelay)
-EXPORT_FUNC(get_timer)
-EXPORT_FUNC(vprintf)
-EXPORT_FUNC(do_reset)
-EXPORT_FUNC(getenv)
-EXPORT_FUNC(setenv)
-EXPORT_FUNC(simple_strtoul)
-EXPORT_FUNC(strict_strtoul)
-EXPORT_FUNC(simple_strtol)
-EXPORT_FUNC(strcmp)
-EXPORT_FUNC(i2c_write)
-EXPORT_FUNC(i2c_read)
-EXPORT_FUNC(spi_init)
-EXPORT_FUNC(spi_setup_slave)
-EXPORT_FUNC(spi_free_slave)
-EXPORT_FUNC(spi_claim_bus)
-EXPORT_FUNC(spi_release_bus)
-EXPORT_FUNC(spi_xfer)
+#ifndef EXPORT_FUNC
+#define EXPORT_FUNC(a, b, c, ...)
+#endif
+       EXPORT_FUNC(get_version, unsigned long, get_version, void)
+       EXPORT_FUNC(getc, int, getc, void)
+       EXPORT_FUNC(tstc, int, tstc, void)
+       EXPORT_FUNC(putc, void, putc, const char)
+       EXPORT_FUNC(puts, void, puts, const char *)
+       EXPORT_FUNC(printf, int, printf, const char*, ...)
+#if defined(CONFIG_X86) || defined(CONFIG_PPC)
+       EXPORT_FUNC(irq_install_handler, void, install_hdlr,
+                   int, interrupt_handler_t, void*)
+
+       EXPORT_FUNC(irq_free_handler, void, free_hdlr, int)
+#else
+       EXPORT_FUNC(dummy, void, install_hdlr, void)
+       EXPORT_FUNC(dummy, void, free_hdlr, void)
+#endif
+       EXPORT_FUNC(malloc, void *, malloc, size_t)
+       EXPORT_FUNC(free, void, free, void *)
+       EXPORT_FUNC(udelay, void, udelay, unsigned long)
+       EXPORT_FUNC(get_timer, unsigned long, get_timer, unsigned long)
+       EXPORT_FUNC(vprintf, int, vprintf, const char *, va_list)
+       EXPORT_FUNC(do_reset, int, do_reset, cmd_tbl_t *,
+                   int , int , char * const [])
+       EXPORT_FUNC(getenv, char  *, getenv, const char*)
+       EXPORT_FUNC(setenv, int, setenv, const char *, const char *)
+       EXPORT_FUNC(simple_strtoul, unsigned long, simple_strtoul,
+                   const char *, char **, unsigned int)
+       EXPORT_FUNC(strict_strtoul, int, strict_strtoul,
+                   const char *, unsigned int , unsigned long *)
+       EXPORT_FUNC(simple_strtol, long, simple_strtol,
+                   const char *, char **, unsigned int)
+       EXPORT_FUNC(strcmp, int, strcmp, const char *cs, const char *ct)
+#if defined(CONFIG_CMD_I2C) && \
+               (!defined(CONFIG_DM_I2C) || defined(CONFIG_DM_I2C_COMPAT))
+       EXPORT_FUNC(i2c_write, int, i2c_write, uchar, uint, int , uchar * , int)
+       EXPORT_FUNC(i2c_read, int, i2c_read, uchar, uint, int , uchar * , int)
+#else
+       EXPORT_FUNC(dummy, void, i2c_write, void)
+       EXPORT_FUNC(dummy, void, i2c_read, void)
+#endif
+
+#if !defined(CONFIG_CMD_SPI) || defined(CONFIG_DM_SPI)
+       EXPORT_FUNC(dummy, void, spi_init, void)
+       EXPORT_FUNC(dummy, void, spi_setup_slave, void)
+       EXPORT_FUNC(dummy, void, spi_free_slave, void)
+#else
+       EXPORT_FUNC(spi_init, void, spi_init, void)
+       EXPORT_FUNC(spi_setup_slave, struct spi_slave *, spi_setup_slave,
+                   unsigned int, unsigned int, unsigned int, unsigned int)
+       EXPORT_FUNC(spi_free_slave, void, spi_free_slave, struct spi_slave *)
+#endif
+#ifndef CONFIG_CMD_SPI
+       EXPORT_FUNC(dummy, void, spi_claim_bus, void)
+       EXPORT_FUNC(dummy, void, spi_release_bus, void)
+       EXPORT_FUNC(dummy, void, spi_xfer, void)
+#else
+       EXPORT_FUNC(spi_claim_bus, int, spi_claim_bus, struct spi_slave *)
+       EXPORT_FUNC(spi_release_bus, void, spi_release_bus, struct spi_slave *)
+       EXPORT_FUNC(spi_xfer, int, spi_xfer, struct spi_slave *,
+                   unsigned int, const void *, void *, unsigned long)
+#endif
+       EXPORT_FUNC(ustrtoul, unsigned long, ustrtoul,
+                   const char *, char **, unsigned int)
+       EXPORT_FUNC(ustrtoull, unsigned long long, ustrtoull,
+                   const char *, char **, unsigned int)
diff --git a/include/asm-generic/atomic-long.h b/include/asm-generic/atomic-long.h
new file mode 100644 (file)
index 0000000..d0469ef
--- /dev/null
@@ -0,0 +1,260 @@
+#ifndef _ASM_GENERIC_ATOMIC_LONG_H
+#define _ASM_GENERIC_ATOMIC_LONG_H
+/*
+ * Copyright (C) 2005 Silicon Graphics, Inc.
+ *     Christoph Lameter
+ *
+ * Allows to provide arch independent atomic definitions without the need to
+ * edit all arch specific atomic.h files.
+ */
+
+#include <asm/types.h>
+
+/*
+ * Suppport for atomic_long_t
+ *
+ * Casts for parameters are avoided for existing atomic functions in order to
+ * avoid issues with cast-as-lval under gcc 4.x and other limitations that the
+ * macros of a platform may have.
+ */
+
+#if BITS_PER_LONG == 64
+
+typedef atomic64_t atomic_long_t;
+
+#define ATOMIC_LONG_INIT(i)    ATOMIC64_INIT(i)
+
+static inline long atomic_long_read(atomic_long_t *l)
+{
+       atomic64_t *v = (atomic64_t *)l;
+
+       return (long)atomic64_read(v);
+}
+
+static inline void atomic_long_set(atomic_long_t *l, long i)
+{
+       atomic64_t *v = (atomic64_t *)l;
+
+       atomic64_set(v, i);
+}
+
+static inline void atomic_long_inc(atomic_long_t *l)
+{
+       atomic64_t *v = (atomic64_t *)l;
+
+       atomic64_inc(v);
+}
+
+static inline void atomic_long_dec(atomic_long_t *l)
+{
+       atomic64_t *v = (atomic64_t *)l;
+
+       atomic64_dec(v);
+}
+
+static inline void atomic_long_add(long i, atomic_long_t *l)
+{
+       atomic64_t *v = (atomic64_t *)l;
+
+       atomic64_add(i, v);
+}
+
+static inline void atomic_long_sub(long i, atomic_long_t *l)
+{
+       atomic64_t *v = (atomic64_t *)l;
+
+       atomic64_sub(i, v);
+}
+
+static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
+{
+       atomic64_t *v = (atomic64_t *)l;
+
+       return atomic64_sub_and_test(i, v);
+}
+
+static inline int atomic_long_dec_and_test(atomic_long_t *l)
+{
+       atomic64_t *v = (atomic64_t *)l;
+
+       return atomic64_dec_and_test(v);
+}
+
+static inline int atomic_long_inc_and_test(atomic_long_t *l)
+{
+       atomic64_t *v = (atomic64_t *)l;
+
+       return atomic64_inc_and_test(v);
+}
+
+static inline int atomic_long_add_negative(long i, atomic_long_t *l)
+{
+       atomic64_t *v = (atomic64_t *)l;
+
+       return atomic64_add_negative(i, v);
+}
+
+static inline long atomic_long_add_return(long i, atomic_long_t *l)
+{
+       atomic64_t *v = (atomic64_t *)l;
+
+       return (long)atomic64_add_return(i, v);
+}
+
+static inline long atomic_long_sub_return(long i, atomic_long_t *l)
+{
+       atomic64_t *v = (atomic64_t *)l;
+
+       return (long)atomic64_sub_return(i, v);
+}
+
+static inline long atomic_long_inc_return(atomic_long_t *l)
+{
+       atomic64_t *v = (atomic64_t *)l;
+
+       return (long)atomic64_inc_return(v);
+}
+
+static inline long atomic_long_dec_return(atomic_long_t *l)
+{
+       atomic64_t *v = (atomic64_t *)l;
+
+       return (long)atomic64_dec_return(v);
+}
+
+static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
+{
+       atomic64_t *v = (atomic64_t *)l;
+
+       return (long)atomic64_add_unless(v, a, u);
+}
+
+#define atomic_long_inc_not_zero(l) atomic64_inc_not_zero((atomic64_t *)(l))
+
+#define atomic_long_cmpxchg(l, old, new) \
+       (atomic64_cmpxchg((atomic64_t *)(l), (old), (new)))
+#define atomic_long_xchg(v, new) \
+       (atomic64_xchg((atomic64_t *)(v), (new)))
+
+#else  /*  BITS_PER_LONG == 64  */
+
+typedef atomic_t atomic_long_t;
+
+#define ATOMIC_LONG_INIT(i)    ATOMIC_INIT(i)
+static inline long atomic_long_read(atomic_long_t *l)
+{
+       atomic_t *v = (atomic_t *)l;
+
+       return (long)atomic_read(v);
+}
+
+static inline void atomic_long_set(atomic_long_t *l, long i)
+{
+       atomic_t *v = (atomic_t *)l;
+
+       atomic_set(v, i);
+}
+
+static inline void atomic_long_inc(atomic_long_t *l)
+{
+       atomic_t *v = (atomic_t *)l;
+
+       atomic_inc(v);
+}
+
+static inline void atomic_long_dec(atomic_long_t *l)
+{
+       atomic_t *v = (atomic_t *)l;
+
+       atomic_dec(v);
+}
+
+static inline void atomic_long_add(long i, atomic_long_t *l)
+{
+       atomic_t *v = (atomic_t *)l;
+
+       atomic_add(i, v);
+}
+
+static inline void atomic_long_sub(long i, atomic_long_t *l)
+{
+       atomic_t *v = (atomic_t *)l;
+
+       atomic_sub(i, v);
+}
+
+#ifndef __UBOOT__
+static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
+{
+       atomic_t *v = (atomic_t *)l;
+
+       return atomic_sub_and_test(i, v);
+}
+
+static inline int atomic_long_dec_and_test(atomic_long_t *l)
+{
+       atomic_t *v = (atomic_t *)l;
+
+       return atomic_dec_and_test(v);
+}
+
+static inline int atomic_long_inc_and_test(atomic_long_t *l)
+{
+       atomic_t *v = (atomic_t *)l;
+
+       return atomic_inc_and_test(v);
+}
+
+static inline int atomic_long_add_negative(long i, atomic_long_t *l)
+{
+       atomic_t *v = (atomic_t *)l;
+
+       return atomic_add_negative(i, v);
+}
+
+static inline long atomic_long_add_return(long i, atomic_long_t *l)
+{
+       atomic_t *v = (atomic_t *)l;
+
+       return (long)atomic_add_return(i, v);
+}
+
+static inline long atomic_long_sub_return(long i, atomic_long_t *l)
+{
+       atomic_t *v = (atomic_t *)l;
+
+       return (long)atomic_sub_return(i, v);
+}
+
+static inline long atomic_long_inc_return(atomic_long_t *l)
+{
+       atomic_t *v = (atomic_t *)l;
+
+       return (long)atomic_inc_return(v);
+}
+
+static inline long atomic_long_dec_return(atomic_long_t *l)
+{
+       atomic_t *v = (atomic_t *)l;
+
+       return (long)atomic_dec_return(v);
+}
+
+static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
+{
+       atomic_t *v = (atomic_t *)l;
+
+       return (long)atomic_add_unless(v, a, u);
+}
+
+#define atomic_long_inc_not_zero(l) atomic_inc_not_zero((atomic_t *)(l))
+
+#define atomic_long_cmpxchg(l, old, new) \
+       (atomic_cmpxchg((atomic_t *)(l), (old), (new)))
+#define atomic_long_xchg(v, new) \
+       (atomic_xchg((atomic_t *)(v), (new)))
+#endif  /*  __UBOOT__ */
+
+#endif  /*  BITS_PER_LONG == 64  */
+
+#endif  /*  _ASM_GENERIC_ATOMIC_LONG_H  */
index 3d14d5f11746680256ffbfb053da8d4c2bbcb3d6..6747619b1c7868ce946660619e4bbe694bcae577 100644 (file)
@@ -73,7 +73,7 @@ typedef struct global_data {
        const void *fdt_blob;   /* Our device tree, NULL if none */
        void *new_fdt;          /* Relocated FDT */
        unsigned long fdt_size; /* Space reserved for relocated FDT */
-       void **jt;              /* jump table */
+       struct jt_funcs *jt;            /* jump table */
        char env_buf[32];       /* buffer for getenv() before reloc. */
 #ifdef CONFIG_TRACE
        void            *trace_buff;    /* The trace buffer */
index 36a36c64b8a6a19879e5236eb85af2fd5960a43d..3b96b8209a10b09d2cdcdf1f559c5fa2787831d7 100644 (file)
 /*
  * Generic GPIO API for U-Boot
  *
+ * --
+ * NB: This is deprecated. Please use the driver model functions instead:
+ *
+ *    - gpio_request_by_name()
+ *    - dm_gpio_get_value() etc.
+ *
+ * For now we need a dm_ prefix on some functions to avoid name collision.
+ * --
+ *
  * GPIOs are numbered from 0 to GPIO_COUNT-1 which value is defined
  * by the SOC/architecture.
  *
@@ -26,6 +35,7 @@
  */
 
 /**
+ * @deprecated Please use driver model instead
  * Request a GPIO. This should be called before any of the other functions
  * are used on this GPIO.
  *
@@ -39,6 +49,7 @@
 int gpio_request(unsigned gpio, const char *label);
 
 /**
+ * @deprecated Please use driver model instead
  * Stop using the GPIO.  This function should not alter pin configuration.
  *
  * @param gpio GPIO number
@@ -47,6 +58,7 @@ int gpio_request(unsigned gpio, const char *label);
 int gpio_free(unsigned gpio);
 
 /**
+ * @deprecated Please use driver model instead
  * Make a GPIO an input.
  *
  * @param gpio GPIO number
@@ -55,6 +67,7 @@ int gpio_free(unsigned gpio);
 int gpio_direction_input(unsigned gpio);
 
 /**
+ * @deprecated Please use driver model instead
  * Make a GPIO an output, and set its value.
  *
  * @param gpio GPIO number
@@ -64,6 +77,7 @@ int gpio_direction_input(unsigned gpio);
 int gpio_direction_output(unsigned gpio, int value);
 
 /**
+ * @deprecated Please use driver model instead
  * Get a GPIO's value. This will work whether the GPIO is an input
  * or an output.
  *
@@ -73,6 +87,7 @@ int gpio_direction_output(unsigned gpio, int value);
 int gpio_get_value(unsigned gpio);
 
 /**
+ * @deprecated Please use driver model instead
  * Set an output GPIO's value. The GPIO must already be an output or
  * this function may have no effect.
  *
@@ -95,6 +110,34 @@ enum gpio_func_t {
 
 struct udevice;
 
+struct gpio_desc {
+       struct udevice *dev;    /* Device, NULL for invalid GPIO */
+       unsigned long flags;
+#define GPIOD_REQUESTED                (1 << 0)        /* Requested/claimed */
+#define GPIOD_IS_OUT           (1 << 1)        /* GPIO is an output */
+#define GPIOD_IS_IN            (1 << 2)        /* GPIO is an output */
+#define GPIOD_ACTIVE_LOW       (1 << 3)        /* value has active low */
+#define GPIOD_IS_OUT_ACTIVE    (1 << 4)        /* set output active */
+
+       uint offset;            /* GPIO offset within the device */
+       /*
+        * We could consider adding the GPIO label in here. Possibly we could
+        * use this structure for internal GPIO information.
+        */
+};
+
+/**
+ * dm_gpio_is_valid() - Check if a GPIO is gpio_is_valie
+ *
+ * @desc:      GPIO description containing device, offset and flags,
+ *             previously returned by gpio_request_by_name()
+ * @return true if valid, false if not
+ */
+static inline bool dm_gpio_is_valid(struct gpio_desc *desc)
+{
+       return desc->dev != NULL;
+}
+
 /**
  * gpio_get_status() - get the current GPIO status as a string
  *
@@ -106,6 +149,8 @@ struct udevice;
  * which means this is GPIO bank b, offset 4, currently set to input, current
  * value 1, [x] means that it is requested and the owner is 'sdmmc_cd'
  *
+ * TODO(sjg@chromium.org): This should use struct gpio_desc
+ *
  * @dev:       Device to check
  * @offset:    Offset of device GPIO to check
  * @buf:       Place to put string
@@ -118,6 +163,8 @@ int gpio_get_status(struct udevice *dev, int offset, char *buf, int buffsize);
  *
  * Note this returns GPIOF_UNUSED if the GPIO is not requested.
  *
+ * TODO(sjg@chromium.org): This should use struct gpio_desc
+ *
  * @dev:       Device to check
  * @offset:    Offset of device GPIO to check
  * @namep:     If non-NULL, this is set to the nane given when the GPIO
@@ -135,6 +182,8 @@ int gpio_get_function(struct udevice *dev, int offset, const char **namep);
  * Note this does not return GPIOF_UNUSED - it will always return the GPIO
  * driver's view of a pin function, even if it is not correctly set up.
  *
+ * TODO(sjg@chromium.org): This should use struct gpio_desc
+ *
  * @dev:       Device to check
  * @offset:    Offset of device GPIO to check
  * @namep:     If non-NULL, this is set to the nane given when the GPIO
@@ -155,6 +204,8 @@ int gpio_get_raw_function(struct udevice *dev, int offset, const char **namep);
 int gpio_requestf(unsigned gpio, const char *fmt, ...)
                __attribute__ ((format (__printf__, 2, 3)));
 
+struct fdtdec_phandle_args;
+
 /**
  * struct struct dm_gpio_ops - Driver model GPIO operations
  *
@@ -198,6 +249,33 @@ struct dm_gpio_ops {
         * @return current function - GPIOF_...
         */
        int (*get_function)(struct udevice *dev, unsigned offset);
+
+       /**
+        * xlate() - Translate phandle arguments into a GPIO description
+        *
+        * This function should set up the fields in desc according to the
+        * information in the arguments. The uclass will have set up:
+        *
+        *   @desc->dev to @dev
+        *   @desc->flags to 0
+        *   @desc->offset to the value of the first argument in args, if any,
+        *              otherwise -1 (which is invalid)
+        *
+        * This method is optional so if the above defaults suit it can be
+        * omitted. Typical behaviour is to set up the GPIOD_ACTIVE_LOW flag
+        * in desc->flags.
+        *
+        * Note that @dev is passed in as a parameter to follow driver model
+        * uclass conventions, even though it is already available as
+        * desc->dev.
+        *
+        * @dev:        GPIO device
+        * @desc:       Place to put GPIO description
+        * @args:       Arguments provided in descripion
+        * @return 0 if OK, -ve on error
+        */
+       int (*xlate)(struct udevice *dev, struct gpio_desc *desc,
+                    struct fdtdec_phandle_args *args);
 };
 
 /**
@@ -268,4 +346,191 @@ int gpio_lookup_name(const char *name, struct udevice **devp,
  */
 unsigned gpio_get_values_as_int(const int *gpio_list);
 
+/**
+ * gpio_request_by_name() - Locate and request a GPIO by name
+ *
+ * This operates by looking up the given list name in the device (device
+ * tree property) and requesting the GPIO for use. The property must exist
+ * in @dev's node.
+ *
+ * Use @flags to specify whether the GPIO should be an input or output. In
+ * principle this can also come from the device tree binding but most
+ * bindings don't provide this information. Specifically, when the GPIO uclass
+ * calls the xlate() method, it can return default flags, which are then
+ * ORed with this @flags.
+ *
+ * If we find that requesting the GPIO is not always needed we could add a
+ * new function or a new GPIOD_NO_REQUEST flag.
+ *
+ * At present driver model has no reference counting so if one device
+ * requests a GPIO which subsequently is unbound, the @desc->dev pointer
+ * will be invalid. However this will only happen if the GPIO device is
+ * unbound, not if it is removed, so this seems like a reasonable limitation
+ * for now. There is no real use case for unbinding drivers in normal
+ * operation.
+ *
+ * The device tree binding is doc/device-tree-bindings/gpio/gpio.txt in
+ * generate terms and each specific device may add additional details in
+ * a binding file in the same directory.
+ *
+ * @dev:       Device requesting the GPIO
+ * @list_name: Name of GPIO list (e.g. "board-id-gpios")
+ * @index:     Index number of the GPIO in that list use request (0=first)
+ * @desc:      Returns GPIO description information. If there is no such
+ *             GPIO, dev->dev will be NULL.
+ * @flags:     Indicates the GPIO input/output settings (GPIOD_...)
+ * @return 0 if OK, -ENOENT if the GPIO does not exist, -EINVAL if there is
+ * something wrong with the list, or other -ve for another error (e.g.
+ * -EBUSY if a GPIO was already requested)
+ */
+int gpio_request_by_name(struct udevice *dev, const char *list_name,
+                        int index, struct gpio_desc *desc, int flags);
+
+/**
+ * gpio_request_list_by_name() - Request a list of GPIOs
+ *
+ * Reads all the GPIOs from a list and requetss them. See
+ * gpio_request_by_name() for additional details. Lists should not be
+ * misused to hold unrelated or optional GPIOs. They should only be used
+ * for things like parallel data lines. A zero phandle terminates the list
+ * the list.
+ *
+ * This function will either succeed, and request all GPIOs in the list, or
+ * fail and request none (it will free already-requested GPIOs in case of
+ * an error part-way through).
+ *
+ * @dev:       Device requesting the GPIO
+ * @list_name: Name of GPIO list (e.g. "board-id-gpios")
+ * @desc_list: Returns a list of GPIO description information
+ * @max_count: Maximum number of GPIOs to return (@desc_list must be at least
+ *             this big)
+ * @flags:     Indicates the GPIO input/output settings (GPIOD_...)
+ * @return number of GPIOs requested, or -ve on error
+ */
+int gpio_request_list_by_name(struct udevice *dev, const char *list_name,
+                             struct gpio_desc *desc_list, int max_count,
+                             int flags);
+
+/**
+ * gpio_get_list_count() - Returns the number of GPIOs in a list
+ *
+ * Counts the GPIOs in a list. See gpio_request_by_name() for additional
+ * details.
+ *
+ * @dev:       Device requesting the GPIO
+ * @list_name: Name of GPIO list (e.g. "board-id-gpios")
+ * @return number of GPIOs (0 for an empty property) or -ENOENT if the list
+ * does not exist
+ */
+int gpio_get_list_count(struct udevice *dev, const char *list_name);
+
+/**
+ * gpio_request_by_name_nodev() - request GPIOs without a device
+ *
+ * This is a version of gpio_request_list_by_name() that does not use a
+ * device. Avoid it unless the caller is not yet using driver model
+ */
+int gpio_request_by_name_nodev(const void *blob, int node,
+                              const char *list_name,
+                              int index, struct gpio_desc *desc, int flags);
+
+/**
+ * gpio_request_list_by_name_nodev() - request GPIOs without a device
+ *
+ * This is a version of gpio_request_list_by_name() that does not use a
+ * device. Avoid it unless the caller is not yet using driver model
+ */
+int gpio_request_list_by_name_nodev(const void *blob, int node,
+                                   const char *list_name,
+                                   struct gpio_desc *desc_list, int max_count,
+                                   int flags);
+
+/**
+ * dm_gpio_free() - Free a single GPIO
+ *
+ * This frees a single GPIOs previously returned from gpio_request_by_name().
+ *
+ * @dev:       Device which requested the GPIO
+ * @desc:      GPIO to free
+ * @return 0 if OK, -ve on error
+ */
+int dm_gpio_free(struct udevice *dev, struct gpio_desc *desc);
+
+/**
+ * gpio_free_list() - Free a list of GPIOs
+ *
+ * This frees a list of GPIOs previously returned from
+ * gpio_request_list_by_name().
+ *
+ * @dev:       Device which requested the GPIOs
+ * @desc:      List of GPIOs to free
+ * @count:     Number of GPIOs in the list
+ * @return 0 if OK, -ve on error
+ */
+int gpio_free_list(struct udevice *dev, struct gpio_desc *desc, int count);
+
+/**
+ * gpio_free_list_nodev() - free GPIOs without a device
+ *
+ * This is a version of gpio_free_list() that does not use a
+ * device. Avoid it unless the caller is not yet using driver model
+ */
+int gpio_free_list_nodev(struct gpio_desc *desc, int count);
+
+/**
+ * dm_gpio_get_value() - Get the value of a GPIO
+ *
+ * This is the driver model version of the existing gpio_get_value() function
+ * and should be used instead of that.
+ *
+ * For now, these functions have a dm_ prefix since they conflict with
+ * existing names.
+ *
+ * @desc:      GPIO description containing device, offset and flags,
+ *             previously returned by gpio_request_by_name()
+ * @return GPIO value (0 for inactive, 1 for active) or -ve on error
+ */
+int dm_gpio_get_value(struct gpio_desc *desc);
+
+int dm_gpio_set_value(struct gpio_desc *desc, int value);
+
+/**
+ * dm_gpio_set_dir() - Set the direction for a GPIO
+ *
+ * This sets up the direction according tot the provided flags. It will do
+ * nothing unless the direction is actually specified.
+ *
+ * @desc:      GPIO description containing device, offset and flags,
+ *             previously returned by gpio_request_by_name()
+ * @return 0 if OK, -ve on error
+ */
+int dm_gpio_set_dir(struct gpio_desc *desc);
+
+/**
+ * dm_gpio_set_dir_flags() - Set direction using specific flags
+ *
+ * This is like dm_gpio_set_dir() except that the flags value is provided
+ * instead of being used from desc->flags. This is needed because in many
+ * cases the GPIO description does not include direction information.
+ * Note that desc->flags is updated by this function.
+ *
+ * @desc:      GPIO description containing device, offset and flags,
+ *             previously returned by gpio_request_by_name()
+ * @flags:     New flags to use
+ * @return 0 if OK, -ve on error, in which case desc->flags is not updated
+ */
+int dm_gpio_set_dir_flags(struct gpio_desc *desc, ulong flags);
+
+/**
+ * gpio_get_number() - Get the global GPIO number of a GPIO
+ *
+ * This should only be used for debugging or interest. It returns the nummber
+ * that should be used for gpio_get_value() etc. to access this GPIO.
+ *
+ * @desc:      GPIO description containing device, offset and flags,
+ *             previously returned by gpio_request_by_name()
+ * @return GPIO number, or -ve if not found
+ */
+int gpio_get_number(struct gpio_desc *desc);
+
 #endif /* _ASM_GENERIC_GPIO_H_ */
index e6639f1ffe694b12b9dbf79f0a7f9b57102c2185..a20e25c2f82740249c9333a7d49657d55ea2550c 100644 (file)
@@ -12,7 +12,6 @@
 
 #define AXP223_DEVICE_ADDR 0x3a3
 #define AXP223_RUNTIME_ADDR 0x2d
-#define AXP223_DEVICE_MODE_DATA 0x7c3e00
 
 /* Page 0 addresses */
 #define AXP221_CHIP_ID         0x03
@@ -26,6 +25,9 @@
 #define AXP221_OUTPUT_CTRL1_ALDO1_EN   (1 << 6)
 #define AXP221_OUTPUT_CTRL1_ALDO2_EN   (1 << 7)
 #define AXP221_OUTPUT_CTRL2    0x12
+#define AXP221_OUTPUT_CTRL2_ELDO1_EN   (1 << 0)
+#define AXP221_OUTPUT_CTRL2_ELDO2_EN   (1 << 1)
+#define AXP221_OUTPUT_CTRL2_ELDO3_EN   (1 << 2)
 #define AXP221_OUTPUT_CTRL2_DLDO1_EN   (1 << 3)
 #define AXP221_OUTPUT_CTRL2_DLDO2_EN   (1 << 4)
 #define AXP221_OUTPUT_CTRL2_DLDO3_EN   (1 << 5)
@@ -37,6 +39,9 @@
 #define AXP221_DLDO2_CTRL      0x16
 #define AXP221_DLDO3_CTRL      0x17
 #define AXP221_DLDO4_CTRL      0x18
+#define AXP221_ELDO1_CTRL      0x19
+#define AXP221_ELDO2_CTRL      0x1a
+#define AXP221_ELDO3_CTRL      0x1b
 #define AXP221_DCDC1_CTRL      0x21
 #define AXP221_DCDC2_CTRL      0x22
 #define AXP221_DCDC3_CTRL      0x23
@@ -69,6 +74,7 @@ int axp221_set_dldo4(unsigned int mvolt);
 int axp221_set_aldo1(unsigned int mvolt);
 int axp221_set_aldo2(unsigned int mvolt);
 int axp221_set_aldo3(unsigned int mvolt);
+int axp221_set_eldo(int eldo_num, unsigned int mvolt);
 int axp221_init(void);
 int axp221_get_sid(unsigned int *sid);
 int axp_drivebus_enable(void);
index 4b3e0d3bbd75adb6fe1a78e3ff1710de5df08297..91294547f5cfe1314067a4e1dd8ffa394d0b6b29 100644 (file)
@@ -183,6 +183,7 @@ typedef void (interrupt_handler_t)(void *);
 /*
  * Function Prototypes
  */
+int dram_init(void);
 
 void   hang            (void) __attribute__ ((noreturn));
 
@@ -228,12 +229,13 @@ int run_command_list(const char *cmd, int len, int flag);
 extern char console_buffer[];
 
 /* arch/$(ARCH)/lib/board.c */
-void   board_init_f(ulong);
-void   board_init_r  (gd_t *, ulong) __attribute__ ((noreturn));
-int    checkboard    (void);
-int    checkflash    (void);
-int    checkdram     (void);
-int    last_stage_init(void);
+void board_init_f(ulong);
+void board_init_r(gd_t *, ulong) __attribute__ ((noreturn));
+int checkboard(void);
+int show_board_info(void);
+int checkflash(void);
+int checkdram(void);
+int last_stage_init(void);
 extern ulong monitor_flash_len;
 int mac_read_from_eeprom(void);
 extern u8 __dtb_dt_begin[];    /* embedded device tree blob */
index be616e8bfd0e0578d54c0414e29599885ada17e8..49674f4537541c6014cb2259976c21ee36dab2d3 100644 (file)
@@ -13,7 +13,7 @@
 #define BOOTENV_SHARED_BLKDEV_BODY(devtypel) \
                "if " #devtypel " dev ${devnum}; then " \
                        "setenv devtype " #devtypel "; " \
-                       "run scan_dev_for_boot; " \
+                       "run scan_dev_for_boot_part; " \
                "fi\0"
 
 #define BOOTENV_SHARED_BLKDEV(devtypel) \
 #endif
 
 #ifdef CONFIG_CMD_USB
-#define BOOTENV_RUN_USB_INIT "run usb_init; "
-#define BOOTENV_SET_USB_NEED_INIT "setenv usb_need_init; "
+#define BOOTENV_RUN_USB_INIT "usb start; "
 #define BOOTENV_SHARED_USB \
-       "usb_init=" \
-               "if ${usb_need_init}; then " \
-                       "setenv usb_need_init false; " \
-                       "usb start 0; " \
-               "fi\0" \
-       \
        "usb_boot=" \
                BOOTENV_RUN_USB_INIT \
                BOOTENV_SHARED_BLKDEV_BODY(usb)
 #define BOOTENV_DEV_NAME_USB   BOOTENV_DEV_NAME_BLKDEV
 #else
 #define BOOTENV_RUN_USB_INIT
-#define BOOTENV_SET_USB_NEED_INIT
 #define BOOTENV_SHARED_USB
 #define BOOTENV_DEV_USB \
        BOOT_TARGET_DEVICES_references_USB_without_CONFIG_CMD_USB
 #define BOOTENV_DEV_DHCP(devtypeu, devtypel, instance) \
        "bootcmd_dhcp=" \
                BOOTENV_RUN_USB_INIT \
-               "if dhcp ${scriptaddr} boot.scr.uimg; then " \
+               "if dhcp ${scriptaddr} ${boot_script_dhcp}; then " \
                        "source ${scriptaddr}; " \
                "fi\0"
 #define BOOTENV_DEV_NAME_DHCP(devtypeu, devtypel, instance) \
        BOOTENV_SHARED_IDE \
        "boot_prefixes=/ /boot/\0" \
        "boot_scripts=boot.scr.uimg boot.scr\0" \
+       "boot_script_dhcp=boot.scr.uimg\0" \
        BOOTENV_BOOT_TARGETS \
-       "bootpart=1\0" \
        \
        "boot_extlinux="                                                  \
                "sysboot ${devtype} ${devnum}:${bootpart} any "           \
                "done\0"                                                  \
        \
        "scan_dev_for_boot="                                              \
-               "echo Scanning ${devtype} ${devnum}...; "                 \
+               "echo Scanning ${devtype} ${devnum}:${bootpart}...; "     \
                "for prefix in ${boot_prefixes}; do "                     \
                        "run scan_dev_for_extlinux; "                     \
                        "run scan_dev_for_scripts; "                      \
                "done\0"                                                  \
        \
+       "scan_dev_for_boot_part="                                         \
+               "part list ${devtype} ${devnum} devplist; "               \
+               "for bootpart in ${devplist}; do "                        \
+                       "if fstype ${devtype} ${devnum}:${bootpart} "     \
+                                       "bootfstype; then "               \
+                               "run scan_dev_for_boot; "                 \
+                       "fi; "                                            \
+               "done\0"                                                  \
+       \
        BOOT_TARGET_DEVICES(BOOTENV_DEV)                                  \
        \
-       "bootcmd=" BOOTENV_SET_USB_NEED_INIT BOOTENV_SET_SCSI_NEED_INIT   \
+       "distro_bootcmd=" BOOTENV_SET_SCSI_NEED_INIT                      \
                "for target in ${boot_targets}; do "                      \
                        "run bootcmd_${target}; "                         \
                "done\0"
 
+#ifndef CONFIG_BOOTCOMMAND
+#define CONFIG_BOOTCOMMAND "run distro_bootcmd"
+#endif
+
 #endif  /* _CONFIG_CMD_DISTRO_BOOTCMD_H */
index eeb0671ddb310df1c24414579200b51af395cee1..6aaaaa43f0f69d413058d5693f0186e319b10b48 100644 (file)
@@ -433,6 +433,7 @@ extern unsigned long get_sdram_size(void);
 #define CONFIG_UBOOTPATH       "u-boot.bin" /* U-Boot image on TFTP server */
 
 #define CONFIG_BAUDRATE                115200
+#define CONFIG_BOOTDELAY       10 /* -1 disable auto-boot */
 
 #define        CONFIG_EXTRA_ENV_SETTINGS                               \
        "netdev=eth0\0"                                         \
index e8a8d299cd9d4c8d0c9e17e79ba6ff17e315406e..59a8d1b5d17dc406ba6db3dc30e621655f214a19 100644 (file)
@@ -675,6 +675,7 @@ combinations. this should be removed later
 #define CONFIG_UBOOTPATH       "u-boot.bin"
 
 #define CONFIG_BAUDRATE                115200
+#define CONFIG_BOOTDELAY       10 /* -1 disable auto-boot */
 
 #ifdef CONFIG_SDCARD
 #define CONFIG_DEF_HWCONFIG    "hwconfig=usb1:dr_mode=host,phy_type=ulpi\0"
index ecb3d7b25fd710f6ac8d4abfeb24af901987a11c..e24b9233687eef4dcccd8c3c8a842e95b25d22b2 100644 (file)
 
 #define CONFIG_BOOTCOMMAND CONFIG_RAMBOOTCOMMAND
 
+#include <asm/fsl_secure_boot.h>
+
 #endif /* __CONFIG_H */
diff --git a/include/configs/CATcenter.h b/include/configs/CATcenter.h
deleted file mode 100644 (file)
index 27539d2..0000000
+++ /dev/null
@@ -1,750 +0,0 @@
-/*
- * ueberarbeitet durch Christoph Seyfert
- *
- * (C) Copyright 2004-2005 DENX Software Engineering,
- *     Wolfgang Grandegger <wg@denx.de>
- * (C) Copyright 2003
- *     DAVE Srl
- *
- * http://www.dave-tech.it
- * http://www.wawnet.biz
- * mailto:info@wawnet.biz
- *
- * Credits: Stefan Roese, Wolfgang Denk
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-/*
- * board/config.h - configuration options, board specific
- */
-
-#ifndef __CONFIG_H
-#define __CONFIG_H
-
-#define CONFIG_PPCHAMELEON_MODULE_BA   0       /* Basic    Model */
-#define CONFIG_PPCHAMELEON_MODULE_ME   1       /* Medium   Model */
-#define CONFIG_PPCHAMELEON_MODULE_HI   2       /* High-End Model */
-#ifndef CONFIG_PPCHAMELEON_MODULE_MODEL
-#define CONFIG_PPCHAMELEON_MODULE_MODEL CONFIG_PPCHAMELEON_MODULE_BA
-#endif
-
-/* Only one of the following two symbols must be defined (default is 25 MHz)
- * CONFIG_PPCHAMELEON_CLK_25
- * CONFIG_PPCHAMELEON_CLK_33
- */
-#if (!defined(CONFIG_PPCHAMELEON_CLK_25) && !defined(CONFIG_PPCHAMELEON_CLK_33))
-#define CONFIG_PPCHAMELEON_CLK_25
-#endif
-
-#if (defined(CONFIG_PPCHAMELEON_CLK_25) && defined(CONFIG_PPCHAMELEON_CLK_33))
-#error "* Two external frequencies (SysClk) are defined! *"
-#endif
-
-#undef CONFIG_PPCHAMELEON_SMI712
-
-/*
- * Debug stuff
- */
-#undef __DEBUG_START_FROM_SRAM__
-#define __DISABLE_MACHINE_EXCEPTION__
-
-#ifdef __DEBUG_START_FROM_SRAM__
-#define CONFIG_SYS_DUMMY_FLASH_SIZE            1024*1024*4
-#endif
-
-/*
- * High Level Configuration Options
- * (easy to change)
- */
-
-#define CONFIG_405EP           1       /* This is a PPC405 CPU         */
-#define CONFIG_PPCHAMELEONEVB  1       /* ...on a PPChameleonEVB board */
-
-#define        CONFIG_SYS_TEXT_BASE    0xFFFB0000      /* Reserve 320 kB for Monitor */
-#define CONFIG_SYS_LDSCRIPT    "board/dave/PPChameleonEVB/u-boot.lds"
-
-#define CONFIG_BOARD_EARLY_INIT_F 1    /* call board_early_init_f()    */
-#define CONFIG_MISC_INIT_R     1       /* call misc_init_r()           */
-
-#ifdef CONFIG_PPCHAMELEON_CLK_25
-# define CONFIG_SYS_CLK_FREQ   25000000 /* external frequency to pll   */
-#elif (defined (CONFIG_PPCHAMELEON_CLK_33))
-#define CONFIG_SYS_CLK_FREQ    33333333 /* external frequency to pll   */
-#else
-# error "* External frequency (SysClk) not defined! *"
-#endif
-
-#define CONFIG_CONS_INDEX      2       /* Use UART1                    */
-#define CONFIG_SYS_NS16550
-#define CONFIG_SYS_NS16550_SERIAL
-#define CONFIG_SYS_NS16550_REG_SIZE    1
-#define CONFIG_SYS_NS16550_CLK         get_serial_clock()
-#define CONFIG_BAUDRATE                115200
-#define CONFIG_BOOTDELAY       5       /* autoboot after 5 seconds     */
-
-#define CONFIG_VERSION_VARIABLE        1       /* add version variable         */
-#define CONFIG_IDENT_STRING    "1"
-
-#undef CONFIG_BOOTARGS
-
-/* Ethernet stuff */
-#define CONFIG_ENV_OVERWRITE /* Let the user to change the Ethernet MAC addresses */
-#define CONFIG_ETHADDR 00:50:C2:1E:AF:FE
-#define CONFIG_HAS_ETH1
-#define CONFIG_ETH1ADDR 00:50:C2:1E:AF:FD
-
-#define CONFIG_LOADS_ECHO      1       /* echo on for serial download  */
-#define CONFIG_SYS_LOADS_BAUD_CHANGE   1       /* allow baudrate change        */
-
-
-#define CONFIG_PPC4xx_EMAC
-#undef CONFIG_EXT_PHY
-
-#define CONFIG_MII             1       /* MII PHY management           */
-#ifndef         CONFIG_EXT_PHY
-#define CONFIG_PHY_ADDR                1       /* EMAC0 PHY address            */
-#define CONFIG_PHY1_ADDR       16      /* EMAC1 PHY address            */
-#else
-#define CONFIG_PHY_ADDR                2       /* PHY address                  */
-#endif
-#define CONFIG_PHY_CLK_FREQ    EMAC_STACR_CLK_66MHZ
-
-#define        CONFIG_TIMESTAMP                /* Print image info with timestamp */
-
-
-/*
- * BOOTP options
- */
-#define CONFIG_BOOTP_BOOTFILESIZE
-#define CONFIG_BOOTP_BOOTPATH
-#define CONFIG_BOOTP_GATEWAY
-#define CONFIG_BOOTP_HOSTNAME
-
-
-/*
- * Command line configuration.
- */
-#include <config_cmd_default.h>
-
-#define CONFIG_CMD_DHCP
-#define CONFIG_CMD_ELF
-#define CONFIG_CMD_EEPROM
-#define CONFIG_CMD_I2C
-#define CONFIG_CMD_IRQ
-#define CONFIG_CMD_JFFS2
-#define CONFIG_CMD_MII
-#define CONFIG_CMD_NAND
-#define CONFIG_CMD_NFS
-#define CONFIG_CMD_SNTP
-
-
-#define CONFIG_MAC_PARTITION
-#define CONFIG_DOS_PARTITION
-
-#undef CONFIG_WATCHDOG                 /* watchdog disabled            */
-
-#define CONFIG_RTC_MC146818            /* DS1685 is MC146818 compatible*/
-#define CONFIG_SYS_RTC_REG_BASE_ADDR    0xF0000500 /* RTC Base Address         */
-
-#define CONFIG_SDRAM_BANK0     1       /* init onboard SDRAM bank 0    */
-
-/*
- * Miscellaneous configurable options
- */
-#define CONFIG_SYS_LONGHELP                    /* undef to save memory         */
-
-#define        CONFIG_SYS_HUSH_PARSER                  /* use "hush" command parser    */
-
-#if defined(CONFIG_CMD_KGDB)
-#define CONFIG_SYS_CBSIZE      1024            /* Console I/O Buffer Size      */
-#else
-#define CONFIG_SYS_CBSIZE      256             /* Console I/O Buffer Size      */
-#endif
-#define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE+sizeof(CONFIG_SYS_PROMPT)+16) /* Print Buffer Size */
-#define CONFIG_SYS_MAXARGS     16              /* max number of command args   */
-#define CONFIG_SYS_BARGSIZE    CONFIG_SYS_CBSIZE       /* Boot Argument Buffer Size    */
-
-#define CONFIG_SYS_DEVICE_NULLDEV      1       /* include nulldev device       */
-
-#define CONFIG_SYS_CONSOLE_INFO_QUIET  1       /* don't print console @ startup*/
-
-#define CONFIG_SYS_MEMTEST_START       0x0400000       /* memtest works on     */
-#define CONFIG_SYS_MEMTEST_END         0x0C00000       /* 4 ... 12 MB in DRAM  */
-
-#undef CONFIG_SYS_EXT_SERIAL_CLOCK             /* no external serial clock used */
-#define CONFIG_SYS_BASE_BAUD           691200
-
-/* The following table includes the supported baudrates */
-#define CONFIG_SYS_BAUDRATE_TABLE      \
-       { 300, 600, 1200, 2400, 4800, 9600, 19200, 38400,     \
-        57600, 115200, 230400, 460800, 921600 }
-
-#define CONFIG_SYS_LOAD_ADDR   0x100000        /* default load address */
-#define CONFIG_SYS_EXTBDINFO   1               /* To use extended board_into (bd_t) */
-
-#define CONFIG_ZERO_BOOTDELAY_CHECK    /* check for keypress on bootdelay==0 */
-
-/*-----------------------------------------------------------------------
- * NAND-FLASH stuff
- *-----------------------------------------------------------------------
- */
-#define CONFIG_SYS_NAND0_BASE 0xFF400000
-#define CONFIG_SYS_NAND1_BASE 0xFF000000
-#define CONFIG_SYS_NAND_BASE_LIST      { CONFIG_SYS_NAND0_BASE }
-#define NAND_BIG_DELAY_US      25
-
-/* For CATcenter there is only NAND on the module */
-#define CONFIG_SYS_MAX_NAND_DEVICE     1       /* Max number of NAND devices           */
-#define NAND_NO_RB
-
-#define CONFIG_SYS_NAND0_CE  (0x80000000 >> 1)  /* our CE is GPIO1 */
-#define CONFIG_SYS_NAND0_CLE (0x80000000 >> 2)  /* our CLE is GPIO2 */
-#define CONFIG_SYS_NAND0_ALE (0x80000000 >> 3)  /* our ALE is GPIO3 */
-#define CONFIG_SYS_NAND0_RDY (0x80000000 >> 4)  /* our RDY is GPIO4 */
-
-#define CONFIG_SYS_NAND1_CE  (0x80000000 >> 14)  /* our CE is GPIO14 */
-#define CONFIG_SYS_NAND1_CLE (0x80000000 >> 15)  /* our CLE is GPIO15 */
-#define CONFIG_SYS_NAND1_ALE (0x80000000 >> 16)  /* our ALE is GPIO16 */
-#define CONFIG_SYS_NAND1_RDY (0x80000000 >> 31)  /* our RDY is GPIO31 */
-
-
-#define MACRO_NAND_DISABLE_CE(nandptr) do \
-{ \
-       switch((unsigned long)nandptr) \
-       { \
-           case CONFIG_SYS_NAND0_BASE: \
-               out32(GPIO0_OR, in32(GPIO0_OR) | CONFIG_SYS_NAND0_CE); \
-               break; \
-           case CONFIG_SYS_NAND1_BASE: \
-               out32(GPIO0_OR, in32(GPIO0_OR) | CONFIG_SYS_NAND1_CE); \
-               break; \
-       } \
-} while(0)
-
-#define MACRO_NAND_ENABLE_CE(nandptr) do \
-{ \
-       switch((unsigned long)nandptr) \
-       { \
-           case CONFIG_SYS_NAND0_BASE: \
-               out32(GPIO0_OR, in32(GPIO0_OR) & ~CONFIG_SYS_NAND0_CE); \
-               break; \
-           case CONFIG_SYS_NAND1_BASE: \
-               out32(GPIO0_OR, in32(GPIO0_OR) & ~CONFIG_SYS_NAND1_CE); \
-               break; \
-       } \
-} while(0)
-
-#define MACRO_NAND_CTL_CLRALE(nandptr) do \
-{ \
-       switch((unsigned long)nandptr) \
-       { \
-           case CONFIG_SYS_NAND0_BASE: \
-               out32(GPIO0_OR, in32(GPIO0_OR) & ~CONFIG_SYS_NAND0_ALE); \
-               break; \
-           case CONFIG_SYS_NAND1_BASE: \
-               out32(GPIO0_OR, in32(GPIO0_OR) & ~CONFIG_SYS_NAND1_ALE); \
-               break; \
-       } \
-} while(0)
-
-#define MACRO_NAND_CTL_SETALE(nandptr) do \
-{ \
-       switch((unsigned long)nandptr) \
-       { \
-           case CONFIG_SYS_NAND0_BASE: \
-               out32(GPIO0_OR, in32(GPIO0_OR) | CONFIG_SYS_NAND0_ALE); \
-               break; \
-           case CONFIG_SYS_NAND1_BASE: \
-               out32(GPIO0_OR, in32(GPIO0_OR) | CONFIG_SYS_NAND1_ALE); \
-               break; \
-       } \
-} while(0)
-
-#define MACRO_NAND_CTL_CLRCLE(nandptr) do \
-{ \
-       switch((unsigned long)nandptr) \
-       { \
-           case CONFIG_SYS_NAND0_BASE: \
-               out32(GPIO0_OR, in32(GPIO0_OR) & ~CONFIG_SYS_NAND0_CLE); \
-               break; \
-           case CONFIG_SYS_NAND1_BASE: \
-               out32(GPIO0_OR, in32(GPIO0_OR) & ~CONFIG_SYS_NAND1_CLE); \
-               break; \
-       } \
-} while(0)
-
-#define MACRO_NAND_CTL_SETCLE(nandptr) do { \
-       switch((unsigned long)nandptr) { \
-       case CONFIG_SYS_NAND0_BASE: \
-               out32(GPIO0_OR, in32(GPIO0_OR) | CONFIG_SYS_NAND0_CLE); \
-               break; \
-       case CONFIG_SYS_NAND1_BASE: \
-               out32(GPIO0_OR, in32(GPIO0_OR) | CONFIG_SYS_NAND1_CLE); \
-               break; \
-       } \
-} while(0)
-
-#ifdef NAND_NO_RB
-/* constant delay (see also tR in the datasheet) */
-#define NAND_WAIT_READY(nand) do { \
-       udelay(12); \
-} while (0)
-#else
-/* use the R/B pin */
-/* TBD */
-#endif
-
-#define WRITE_NAND_COMMAND(d, adr) do{ *(volatile __u8 *)((unsigned long)adr) = (__u8)(d); } while(0)
-#define WRITE_NAND_ADDRESS(d, adr) do{ *(volatile __u8 *)((unsigned long)adr) = (__u8)(d); } while(0)
-#define WRITE_NAND(d, adr) do{ *(volatile __u8 *)((unsigned long)adr) = (__u8)d; } while(0)
-#define READ_NAND(adr) ((volatile unsigned char)(*(volatile __u8 *)(unsigned long)adr))
-
-/*-----------------------------------------------------------------------
- * PCI stuff
- *-----------------------------------------------------------------------
- */
-#if 0  /* No PCI on CATcenter */
-#define PCI_HOST_ADAPTER 0             /* configure as pci adapter     */
-#define PCI_HOST_FORCE 1               /* configure as pci host        */
-#define PCI_HOST_AUTO  2               /* detected via arbiter enable  */
-
-#define CONFIG_PCI                     /* include pci support          */
-#define CONFIG_PCI_INDIRECT_BRIDGE     /* indirect PCI bridge support */
-#define CONFIG_PCI_HOST PCI_HOST_FORCE  /* select pci host function     */
-#undef CONFIG_PCI_PNP                  /* do pci plug-and-play         */
-                                       /* resource configuration       */
-
-#define CONFIG_PCI_SCAN_SHOW           /* print pci devices @ startup  */
-
-#define CONFIG_SYS_PCI_SUBSYS_VENDORID 0x1014  /* PCI Vendor ID: IBM   */
-#define CONFIG_SYS_PCI_SUBSYS_DEVICEID 0x0000  /* PCI Device ID: ---   */
-#define CONFIG_SYS_PCI_CLASSCODE       0x0b20  /* PCI Class Code: Processor/PPC*/
-
-#define CONFIG_SYS_PCI_PTM1LA  0x00000000      /* point to sdram               */
-#define CONFIG_SYS_PCI_PTM1MS  0xfc000001      /* 64MB, enable hard-wired to 1 */
-#define CONFIG_SYS_PCI_PTM1PCI 0x00000000      /* Host: use this pci address   */
-#define CONFIG_SYS_PCI_PTM2LA  0xffc00000      /* point to flash               */
-#define CONFIG_SYS_PCI_PTM2MS  0xffc00001      /* 4MB, enable                  */
-#define CONFIG_SYS_PCI_PTM2PCI 0x04000000      /* Host: use this pci address   */
-#endif /* No PCI */
-
-/*-----------------------------------------------------------------------
- * 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          0xFFFC0000
-#define CONFIG_SYS_MONITOR_BASE        CONFIG_SYS_FLASH_BASE
-#define CONFIG_SYS_MONITOR_LEN         (256 * 1024)    /* Reserve 256 kB for Monitor   */
-#define CONFIG_SYS_MALLOC_LEN          (256 * 1024)    /* Reserve 256 kB for malloc()  */
-
-/*
- * 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.
- */
-#define CONFIG_SYS_BOOTMAPSZ           (8 << 20)       /* Initial Memory map for Linux */
-/*-----------------------------------------------------------------------
- * FLASH organization
- */
-#define CONFIG_SYS_MAX_FLASH_BANKS     1       /* max number of memory banks           */
-#define CONFIG_SYS_MAX_FLASH_SECT      256     /* max number of sectors on one chip    */
-
-#define CONFIG_SYS_FLASH_ERASE_TOUT    120000  /* Timeout for Flash Erase (in ms)      */
-#define CONFIG_SYS_FLASH_WRITE_TOUT    1000    /* Timeout for Flash Write (in ms)      */
-
-#define CONFIG_SYS_FLASH_WORD_SIZE     unsigned short  /* flash word size (width)      */
-#define CONFIG_SYS_FLASH_ADDR0         0x5555  /* 1st address for flash config cycles  */
-#define CONFIG_SYS_FLASH_ADDR1         0x2AAA  /* 2nd address for flash config cycles  */
-/*
- * The following defines are added for buggy IOP480 byte interface.
- * All other boards should use the standard values (CPCI405 etc.)
- */
-#define CONFIG_SYS_FLASH_READ0         0x0000  /* 0 is standard                        */
-#define CONFIG_SYS_FLASH_READ1         0x0001  /* 1 is standard                        */
-#define CONFIG_SYS_FLASH_READ2         0x0002  /* 2 is standard                        */
-
-#define CONFIG_SYS_FLASH_EMPTY_INFO            /* print 'E' for empty sector on flinfo */
-
-/*-----------------------------------------------------------------------
- * Environment Variable setup
- */
-#define CONFIG_ENV_IS_IN_FLASH 1       /* use FLASH for environment vars */
-#define CONFIG_ENV_ADDR                0xFFFF8000      /* environment starts at the first small sector */
-#define CONFIG_ENV_SECT_SIZE   0x2000  /* 8196 bytes may be used for env vars*/
-#define CONFIG_ENV_ADDR_REDUND 0xFFFFA000
-#define CONFIG_ENV_SIZE_REDUND 0x2000
-
-#define        CONFIG_SYS_USE_PPCENV                   /* Environment embedded in sect .ppcenv */
-
-#define CONFIG_SYS_NVRAM_BASE_ADDR     0xF0000500              /* NVRAM base address   */
-#define CONFIG_SYS_NVRAM_SIZE          242                     /* NVRAM size           */
-
-/*-----------------------------------------------------------------------
- * I2C EEPROM (CAT24WC16) for environment
- */
-#define CONFIG_SYS_I2C
-#define CONFIG_SYS_I2C_PPC4XX
-#define CONFIG_SYS_I2C_PPC4XX_CH0
-#define CONFIG_SYS_I2C_PPC4XX_SPEED_0          400000
-#define CONFIG_SYS_I2C_PPC4XX_SLAVE_0          0x7F
-
-#define CONFIG_SYS_I2C_EEPROM_ADDR     0x50    /* EEPROM CAT28WC08             */
-#define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1       /* Bytes of address             */
-/* mask of address bits that overflow into the "EEPROM chip address"   */
-/*#define CONFIG_SYS_I2C_EEPROM_ADDR_OVERFLOW  0x07*/
-#define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS 4    /* The Catalyst CAT24WC08 has   */
-                                       /* 16 byte page write mode using*/
-                                       /* last 4 bits of the address   */
-#define CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS  10   /* and takes up to 10 msec */
-
-/*
- * Init Memory Controller:
- *
- * BR0/1 and OR0/1 (FLASH)
- */
-
-#define FLASH_BASE0_PRELIM     0xFFC00000      /* FLASH bank #0        */
-
-/*-----------------------------------------------------------------------
- * External Bus Controller (EBC) Setup
- */
-
-/* Memory Bank 0 (Flash Bank 0, NOR-FLASH) initialization                      */
-#define CONFIG_SYS_EBC_PB0AP           0x92015480
-#define CONFIG_SYS_EBC_PB0CR           0xFFC5A000  /* BAS=0xFFC,BS=4MB,BU=R/W,BW=16bit */
-
-/* Memory Bank 1 (External SRAM) initialization                                        */
-/* Since this must replace NOR Flash, we use the same settings for CS0         */
-#define CONFIG_SYS_EBC_PB1AP           0x92015480
-#define CONFIG_SYS_EBC_PB1CR           0xFF85A000  /* BAS=0xFF8,BS=4MB,BU=R/W,BW=8bit  */
-
-/* Memory Bank 2 (Flash Bank 1, NAND-FLASH) initialization                     */
-#define CONFIG_SYS_EBC_PB2AP           0x92015480
-#define CONFIG_SYS_EBC_PB2CR           0xFF458000  /* BAS=0xFF4,BS=4MB,BU=R/W,BW=8bit  */
-
-/* Memory Bank 3 (Flash Bank 2, NAND-FLASH) initialization                     */
-#define CONFIG_SYS_EBC_PB3AP           0x92015480
-#define CONFIG_SYS_EBC_PB3CR           0xFF058000  /* BAS=0xFF0,BS=4MB,BU=R/W,BW=8bit  */
-
-#ifdef CONFIG_PPCHAMELEON_SMI712
-/*
- * Video console (graphic: SMI LynxEM)
- */
-#define CONFIG_VIDEO
-#define CONFIG_CFB_CONSOLE
-#define CONFIG_VIDEO_SMI_LYNXEM
-#define CONFIG_VIDEO_LOGO
-/*#define CONFIG_VIDEO_BMP_LOGO*/
-#define CONFIG_CONSOLE_EXTRA_INFO
-#define CONFIG_VGA_AS_SINGLE_DEVICE
-/* This is the base address (on 405EP-side) used to generate I/O accesses on PCI bus */
-#define CONFIG_SYS_ISA_IO 0xE8000000
-/* see also drivers/video/videomodes.c */
-#define CONFIG_SYS_DEFAULT_VIDEO_MODE 0x303
-#endif
-
-/*-----------------------------------------------------------------------
- * FPGA stuff
- */
-/* FPGA internal regs */
-#define CONFIG_SYS_FPGA_MODE           0x00
-#define CONFIG_SYS_FPGA_STATUS         0x02
-#define CONFIG_SYS_FPGA_TS             0x04
-#define CONFIG_SYS_FPGA_TS_LOW         0x06
-#define CONFIG_SYS_FPGA_TS_CAP0        0x10
-#define CONFIG_SYS_FPGA_TS_CAP0_LOW    0x12
-#define CONFIG_SYS_FPGA_TS_CAP1        0x14
-#define CONFIG_SYS_FPGA_TS_CAP1_LOW    0x16
-#define CONFIG_SYS_FPGA_TS_CAP2        0x18
-#define CONFIG_SYS_FPGA_TS_CAP2_LOW    0x1a
-#define CONFIG_SYS_FPGA_TS_CAP3        0x1c
-#define CONFIG_SYS_FPGA_TS_CAP3_LOW    0x1e
-
-/* FPGA Mode Reg */
-#define CONFIG_SYS_FPGA_MODE_CF_RESET  0x0001
-#define CONFIG_SYS_FPGA_MODE_TS_IRQ_ENABLE 0x0100
-#define CONFIG_SYS_FPGA_MODE_TS_IRQ_CLEAR  0x1000
-#define CONFIG_SYS_FPGA_MODE_TS_CLEAR  0x2000
-
-/* FPGA Status Reg */
-#define CONFIG_SYS_FPGA_STATUS_DIP0    0x0001
-#define CONFIG_SYS_FPGA_STATUS_DIP1    0x0002
-#define CONFIG_SYS_FPGA_STATUS_DIP2    0x0004
-#define CONFIG_SYS_FPGA_STATUS_FLASH   0x0008
-#define CONFIG_SYS_FPGA_STATUS_TS_IRQ  0x1000
-
-#define CONFIG_SYS_FPGA_SPARTAN2       1               /* using Xilinx Spartan 2 now   */
-#define CONFIG_SYS_FPGA_MAX_SIZE       128*1024        /* 128kByte is enough for XC2S50E*/
-
-/* FPGA program pin configuration */
-#define CONFIG_SYS_FPGA_PRG            0x04000000      /* FPGA program pin (ppc output) */
-#define CONFIG_SYS_FPGA_CLK            0x02000000      /* FPGA clk pin (ppc output)    */
-#define CONFIG_SYS_FPGA_DATA           0x01000000      /* FPGA data pin (ppc output)   */
-#define CONFIG_SYS_FPGA_INIT           0x00010000      /* FPGA init pin (ppc input)    */
-#define CONFIG_SYS_FPGA_DONE           0x00008000      /* FPGA done pin (ppc input)    */
-
-/*-----------------------------------------------------------------------
- * Definitions for initial stack pointer and data area (in data cache)
- */
-/* use on chip memory ( OCM ) for temperary stack until sdram is tested */
-#define CONFIG_SYS_TEMP_STACK_OCM      1
-
-/* On Chip Memory location */
-#define CONFIG_SYS_OCM_DATA_ADDR       0xF8000000
-#define CONFIG_SYS_OCM_DATA_SIZE       0x1000
-#define CONFIG_SYS_INIT_RAM_ADDR       CONFIG_SYS_OCM_DATA_ADDR /* inside of SDRAM             */
-#define CONFIG_SYS_INIT_RAM_SIZE       CONFIG_SYS_OCM_DATA_SIZE /* Size of used area in RAM    */
-
-#define CONFIG_SYS_GBL_DATA_OFFSET    (CONFIG_SYS_INIT_RAM_SIZE - GENERATED_GBL_DATA_SIZE)
-#define CONFIG_SYS_INIT_SP_OFFSET      CONFIG_SYS_GBL_DATA_OFFSET
-
-/*-----------------------------------------------------------------------
- * Definitions for GPIO setup (PPC405EP specific)
- *
- * GPIO0[0]    - External Bus Controller BLAST output
- * GPIO0[1-9]  - Instruction trace outputs -> GPIO
- * GPIO0[10-13] - External Bus Controller CS_1 - CS_4 outputs
- * GPIO0[14-16] - External Bus Controller ABUS3-ABUS5 outputs -> GPIO
- * GPIO0[17-23] - External Interrupts IRQ0 - IRQ6 inputs
- * GPIO0[24-27] - UART0 control signal inputs/outputs
- * GPIO0[28-29] - UART1 data signal input/output
- * GPIO0[30]   - EMAC0 input
- * GPIO0[31]   - EMAC1 reject packet as output
- */
-#define CONFIG_SYS_GPIO0_OSRL          0x40000550
-#define CONFIG_SYS_GPIO0_OSRH          0x00000110
-#define CONFIG_SYS_GPIO0_ISR1L         0x00000000
-/*#define CONFIG_SYS_GPIO0_ISR1H       0x15555445*/
-#define CONFIG_SYS_GPIO0_ISR1H         0x15555444
-#define CONFIG_SYS_GPIO0_TSRL          0x00000000
-#define CONFIG_SYS_GPIO0_TSRH          0x00000000
-#define CONFIG_SYS_GPIO0_TCR           0xF7FF8014
-
-#define CONFIG_NO_SERIAL_EEPROM
-
-/*--------------------------------------------------------------------*/
-
-#ifdef CONFIG_NO_SERIAL_EEPROM
-
-/*
-!-----------------------------------------------------------------------
-! Defines for entry options.
-! Note: Because the 405EP SDRAM controller does not support ECC, ECC DIMMs that
-!      are plugged in the board will be utilized as non-ECC DIMMs.
-!-----------------------------------------------------------------------
-*/
-#undef         AUTO_MEMORY_CONFIG
-#define                DIMM_READ_ADDR 0xAB
-#define                DIMM_WRITE_ADDR 0xAA
-
-/* Defines for CPC0_PLLMR1 Register fields */
-#define PLL_ACTIVE             0x80000000
-#define CPC0_PLLMR1_SSCS       0x80000000
-#define PLL_RESET              0x40000000
-#define CPC0_PLLMR1_PLLR       0x40000000
-    /* Feedback multiplier */
-#define PLL_FBKDIV             0x00F00000
-#define CPC0_PLLMR1_FBDV       0x00F00000
-#define PLL_FBKDIV_16          0x00000000
-#define PLL_FBKDIV_1           0x00100000
-#define PLL_FBKDIV_2           0x00200000
-#define PLL_FBKDIV_3           0x00300000
-#define PLL_FBKDIV_4           0x00400000
-#define PLL_FBKDIV_5           0x00500000
-#define PLL_FBKDIV_6           0x00600000
-#define PLL_FBKDIV_7           0x00700000
-#define PLL_FBKDIV_8           0x00800000
-#define PLL_FBKDIV_9           0x00900000
-#define PLL_FBKDIV_10          0x00A00000
-#define PLL_FBKDIV_11          0x00B00000
-#define PLL_FBKDIV_12          0x00C00000
-#define PLL_FBKDIV_13          0x00D00000
-#define PLL_FBKDIV_14          0x00E00000
-#define PLL_FBKDIV_15          0x00F00000
-    /* Forward A divisor */
-#define PLL_FWDDIVA            0x00070000
-#define CPC0_PLLMR1_FWDVA      0x00070000
-#define PLL_FWDDIVA_8          0x00000000
-#define PLL_FWDDIVA_7          0x00010000
-#define PLL_FWDDIVA_6          0x00020000
-#define PLL_FWDDIVA_5          0x00030000
-#define PLL_FWDDIVA_4          0x00040000
-#define PLL_FWDDIVA_3          0x00050000
-#define PLL_FWDDIVA_2          0x00060000
-#define PLL_FWDDIVA_1          0x00070000
-    /* Forward B divisor */
-#define PLL_FWDDIVB            0x00007000
-#define CPC0_PLLMR1_FWDVB      0x00007000
-#define PLL_FWDDIVB_8          0x00000000
-#define PLL_FWDDIVB_7          0x00001000
-#define PLL_FWDDIVB_6          0x00002000
-#define PLL_FWDDIVB_5          0x00003000
-#define PLL_FWDDIVB_4          0x00004000
-#define PLL_FWDDIVB_3          0x00005000
-#define PLL_FWDDIVB_2          0x00006000
-#define PLL_FWDDIVB_1          0x00007000
-    /* PLL tune bits */
-#define PLL_TUNE_MASK          0x000003FF
-#define PLL_TUNE_2_M_3         0x00000133      /*  2 <= M <= 3                 */
-#define PLL_TUNE_4_M_6         0x00000134      /*  3 <  M <= 6                 */
-#define PLL_TUNE_7_M_10                0x00000138      /*  6 <  M <= 10                */
-#define PLL_TUNE_11_M_14       0x0000013C      /* 10 <  M <= 14                */
-#define PLL_TUNE_15_M_40       0x0000023E      /* 14 <  M <= 40                */
-#define PLL_TUNE_VCO_LOW       0x00000000      /* 500MHz <= VCO <=  800MHz     */
-#define PLL_TUNE_VCO_HI                0x00000080      /* 800MHz <  VCO <= 1000MHz     */
-
-/* Defines for CPC0_PLLMR0 Register fields */
-    /* CPU divisor */
-#define PLL_CPUDIV             0x00300000
-#define CPC0_PLLMR0_CCDV       0x00300000
-#define PLL_CPUDIV_1           0x00000000
-#define PLL_CPUDIV_2           0x00100000
-#define PLL_CPUDIV_3           0x00200000
-#define PLL_CPUDIV_4           0x00300000
-    /* PLB divisor */
-#define PLL_PLBDIV             0x00030000
-#define CPC0_PLLMR0_CBDV       0x00030000
-#define PLL_PLBDIV_1           0x00000000
-#define PLL_PLBDIV_2           0x00010000
-#define PLL_PLBDIV_3           0x00020000
-#define PLL_PLBDIV_4           0x00030000
-    /* OPB divisor */
-#define PLL_OPBDIV             0x00003000
-#define CPC0_PLLMR0_OPDV       0x00003000
-#define PLL_OPBDIV_1           0x00000000
-#define PLL_OPBDIV_2           0x00001000
-#define PLL_OPBDIV_3           0x00002000
-#define PLL_OPBDIV_4           0x00003000
-    /* EBC divisor */
-#define PLL_EXTBUSDIV          0x00000300
-#define CPC0_PLLMR0_EPDV       0x00000300
-#define PLL_EXTBUSDIV_2                0x00000000
-#define PLL_EXTBUSDIV_3                0x00000100
-#define PLL_EXTBUSDIV_4                0x00000200
-#define PLL_EXTBUSDIV_5                0x00000300
-    /* MAL divisor */
-#define PLL_MALDIV             0x00000030
-#define CPC0_PLLMR0_MPDV       0x00000030
-#define PLL_MALDIV_1           0x00000000
-#define PLL_MALDIV_2           0x00000010
-#define PLL_MALDIV_3           0x00000020
-#define PLL_MALDIV_4           0x00000030
-    /* PCI divisor */
-#define PLL_PCIDIV             0x00000003
-#define CPC0_PLLMR0_PPFD       0x00000003
-#define PLL_PCIDIV_1           0x00000000
-#define PLL_PCIDIV_2           0x00000001
-#define PLL_PCIDIV_3           0x00000002
-#define PLL_PCIDIV_4           0x00000003
-
-#ifdef CONFIG_PPCHAMELEON_CLK_25
-/* CPU - PLB/SDRAM - EBC - OPB - PCI (assuming a 25.0 MHz input clock to the 405EP) */
-#define PPCHAMELEON_PLLMR0_133_133_33_66_33     (PLL_CPUDIV_1 | PLL_PLBDIV_1 |  \
-                             PLL_OPBDIV_2 | PLL_EXTBUSDIV_4 |  \
-                             PLL_MALDIV_1 | PLL_PCIDIV_4)
-#define PPCHAMELEON_PLLMR1_133_133_33_66_33     (PLL_FBKDIV_8  |  \
-                             PLL_FWDDIVA_6 | PLL_FWDDIVB_4 |  \
-                             PLL_TUNE_15_M_40 | PLL_TUNE_VCO_LOW)
-
-#define PPCHAMELEON_PLLMR0_200_100_50_33 (PLL_CPUDIV_1 | PLL_PLBDIV_2 |  \
-                             PLL_OPBDIV_2 | PLL_EXTBUSDIV_3 |  \
-                             PLL_MALDIV_1 | PLL_PCIDIV_4)
-#define PPCHAMELEON_PLLMR1_200_100_50_33 (PLL_FBKDIV_8  |  \
-                             PLL_FWDDIVA_4 | PLL_FWDDIVB_4 |  \
-                             PLL_TUNE_15_M_40 | PLL_TUNE_VCO_LOW)
-
-#define PPCHAMELEON_PLLMR0_266_133_33_66_33 (PLL_CPUDIV_1 | PLL_PLBDIV_2 |     \
-                             PLL_OPBDIV_2 | PLL_EXTBUSDIV_4 |  \
-                             PLL_MALDIV_1 | PLL_PCIDIV_4)
-#define PPCHAMELEON_PLLMR1_266_133_33_66_33 (PLL_FBKDIV_8  |  \
-                             PLL_FWDDIVA_3 | PLL_FWDDIVB_4 |  \
-                             PLL_TUNE_15_M_40 | PLL_TUNE_VCO_LOW)
-
-#define PPCHAMELEON_PLLMR0_333_111_37_55_55 (PLL_CPUDIV_1 | PLL_PLBDIV_3 |     \
-                             PLL_OPBDIV_2 | PLL_EXTBUSDIV_3 |  \
-                             PLL_MALDIV_1 | PLL_PCIDIV_2)
-#define PPCHAMELEON_PLLMR1_333_111_37_55_55 (PLL_FBKDIV_10     |  \
-                             PLL_FWDDIVA_3 | PLL_FWDDIVB_4 |  \
-                             PLL_TUNE_15_M_40 | PLL_TUNE_VCO_HI)
-
-#elif (defined (CONFIG_PPCHAMELEON_CLK_33))
-
-/* CPU - PLB/SDRAM - EBC - OPB - PCI (assuming a 33.3MHz input clock to the 405EP) */
-#define PPCHAMELEON_PLLMR0_133_133_33_66_33     (PLL_CPUDIV_1 | PLL_PLBDIV_1 |  \
-                                 PLL_OPBDIV_2 | PLL_EXTBUSDIV_4 |      \
-                                 PLL_MALDIV_1 | PLL_PCIDIV_4)
-#define PPCHAMELEON_PLLMR1_133_133_33_66_33     (PLL_FBKDIV_4  |  \
-                                 PLL_FWDDIVA_6 | PLL_FWDDIVB_6 |  \
-                                 PLL_TUNE_15_M_40 | PLL_TUNE_VCO_LOW)
-
-#define PPCHAMELEON_PLLMR0_200_100_50_33 (PLL_CPUDIV_1 | PLL_PLBDIV_2 |  \
-                                 PLL_OPBDIV_2 | PLL_EXTBUSDIV_3 |      \
-                                 PLL_MALDIV_1 | PLL_PCIDIV_4)
-#define PPCHAMELEON_PLLMR1_200_100_50_33 (PLL_FBKDIV_6  |  \
-                                 PLL_FWDDIVA_4 | PLL_FWDDIVB_4 |  \
-                                 PLL_TUNE_15_M_40 | PLL_TUNE_VCO_LOW)
-
-#define PPCHAMELEON_PLLMR0_266_133_33_66_33 (PLL_CPUDIV_1 | PLL_PLBDIV_2 |     \
-                                 PLL_OPBDIV_2 | PLL_EXTBUSDIV_4 |      \
-                                 PLL_MALDIV_1 | PLL_PCIDIV_4)
-#define PPCHAMELEON_PLLMR1_266_133_33_66_33 (PLL_FBKDIV_8  |  \
-                                 PLL_FWDDIVA_3 | PLL_FWDDIVB_3 |  \
-                                 PLL_TUNE_15_M_40 | PLL_TUNE_VCO_LOW)
-
-#define PPCHAMELEON_PLLMR0_333_111_37_55_55 (PLL_CPUDIV_1 | PLL_PLBDIV_3 |     \
-                                 PLL_OPBDIV_2 | PLL_EXTBUSDIV_3 |      \
-                                 PLL_MALDIV_1 | PLL_PCIDIV_2)
-#define PPCHAMELEON_PLLMR1_333_111_37_55_55 (PLL_FBKDIV_10     |  \
-                                 PLL_FWDDIVA_3 | PLL_FWDDIVB_3 |  \
-                                 PLL_TUNE_15_M_40 | PLL_TUNE_VCO_HI)
-
-#else
-#error "* External frequency (SysClk) not defined! *"
-#endif
-
-#if   (CONFIG_PPCHAMELEON_MODULE_MODEL == CONFIG_PPCHAMELEON_MODULE_HI)
-/* Model HI */
-#define PLLMR0_DEFAULT PPCHAMELEON_PLLMR0_333_111_37_55_55
-#define PLLMR1_DEFAULT PPCHAMELEON_PLLMR1_333_111_37_55_55
-#define CONFIG_SYS_OPB_FREQ    55555555
-/* Model ME */
-#elif (CONFIG_PPCHAMELEON_MODULE_MODEL == CONFIG_PPCHAMELEON_MODULE_ME)
-#define PLLMR0_DEFAULT PPCHAMELEON_PLLMR0_266_133_33_66_33
-#define PLLMR1_DEFAULT PPCHAMELEON_PLLMR1_266_133_33_66_33
-#define CONFIG_SYS_OPB_FREQ    66666666
-#else
-/* Model BA (default) */
-#define PLLMR0_DEFAULT PPCHAMELEON_PLLMR0_133_133_33_66_33
-#define PLLMR1_DEFAULT PPCHAMELEON_PLLMR1_133_133_33_66_33
-#define CONFIG_SYS_OPB_FREQ    66666666
-#endif
-
-#endif /* CONFIG_NO_SERIAL_EEPROM */
-
-#define CONFIG_JFFS2_NAND 1                    /* jffs2 on nand support */
-#define NAND_CACHE_PAGES 16                    /* size of nand cache in 512 bytes pages */
-
-/*
- * JFFS2 partitions
- *
- */
-/* No command line, one static partition */
-#undef CONFIG_CMD_MTDPARTS
-#define CONFIG_JFFS2_DEV               "nand"
-#define CONFIG_JFFS2_PART_SIZE         0x00200000
-#define CONFIG_JFFS2_PART_OFFSET       0x00000000
-
-/* mtdparts command line support
- *
- * Note: fake mtd_id used, no linux mtd map file
- */
-/*
-#define CONFIG_CMD_MTDPARTS
-#define MTDIDS_DEFAULT         "nand0=catcenter"
-#define MTDPARTS_DEFAULT       "mtdparts=catcenter:2m(nand)"
-*/
-
-#endif /* __CONFIG_H */
diff --git a/include/configs/IceCube.h b/include/configs/IceCube.h
deleted file mode 100644 (file)
index 1861aa8..0000000
+++ /dev/null
@@ -1,403 +0,0 @@
-/*
- * (C) Copyright 2003-2005
- * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#ifndef __CONFIG_H
-#define __CONFIG_H
-
-/*
- * High Level Configuration Options
- * (easy to change)
- */
-
-#define CONFIG_MPC5200         1       /* This is a MPC5200 CPU */
-#define CONFIG_ICECUBE         1       /* ... on IceCube board */
-
-/*
- * Valid values for CONFIG_SYS_TEXT_BASE are:
- * 0xFFF00000  boot high (standard configuration)
- * 0xFF000000  boot low for 16 MiB boards
- * 0xFF800000  boot low for  8 MiB boards
- * 0x00100000  boot from RAM (for testing only)
- */
-#ifndef CONFIG_SYS_TEXT_BASE
-#define        CONFIG_SYS_TEXT_BASE    0xFFF00000
-#endif
-
-#define CONFIG_SYS_MPC5XXX_CLKIN       33000000 /* ... running at 33.000000MHz */
-
-#define CONFIG_HIGH_BATS       1       /* High BATs supported */
-
-/*
- * Serial console configuration
- */
-#define CONFIG_PSC_CONSOLE     1       /* console is on PSC1 */
-#define CONFIG_BAUDRATE                115200  /* ... at 115200 bps */
-#define CONFIG_SYS_BAUDRATE_TABLE      { 9600, 19200, 38400, 57600, 115200, 230400 }
-
-
-/*
- * PCI Mapping:
- * 0x40000000 - 0x4fffffff - PCI Memory
- * 0x50000000 - 0x50ffffff - PCI IO Space
- */
-#define CONFIG_PCI
-
-#if defined(CONFIG_PCI)
-#define CONFIG_PCI_PNP         1
-#define CONFIG_PCI_SCAN_SHOW   1
-#define CONFIG_PCIAUTO_SKIP_HOST_BRIDGE        1
-
-#define CONFIG_PCI_MEM_BUS     0x40000000
-#define CONFIG_PCI_MEM_PHYS    CONFIG_PCI_MEM_BUS
-#define CONFIG_PCI_MEM_SIZE    0x10000000
-
-#define CONFIG_PCI_IO_BUS      0x50000000
-#define CONFIG_PCI_IO_PHYS     CONFIG_PCI_IO_BUS
-#define CONFIG_PCI_IO_SIZE     0x01000000
-#endif
-
-#define CONFIG_SYS_XLB_PIPELINING      1
-
-#define CONFIG_MII             1
-#define CONFIG_EEPRO100                1
-#define CONFIG_SYS_RX_ETH_BUFFER       8  /* use 8 rx buffer on eepro100  */
-#define CONFIG_NS8382X         1
-
-/* Partitions */
-#define CONFIG_MAC_PARTITION
-#define CONFIG_DOS_PARTITION
-#define CONFIG_ISO_PARTITION
-
-/* USB */
-#define CONFIG_USB_OHCI_NEW
-#define CONFIG_USB_STORAGE
-#define CONFIG_SYS_OHCI_BE_CONTROLLER
-#undef CONFIG_SYS_USB_OHCI_BOARD_INIT
-#define CONFIG_SYS_USB_OHCI_CPU_INIT   1
-#define CONFIG_SYS_USB_OHCI_REGS_BASE  MPC5XXX_USB
-#define CONFIG_SYS_USB_OHCI_SLOT_NAME  "mpc5200"
-#define CONFIG_SYS_USB_OHCI_MAX_ROOT_PORTS     15
-
-#define        CONFIG_TIMESTAMP                /* Print image info with timestamp */
-
-
-/*
- * BOOTP options
- */
-#define CONFIG_BOOTP_BOOTFILESIZE
-#define CONFIG_BOOTP_BOOTPATH
-#define CONFIG_BOOTP_GATEWAY
-#define CONFIG_BOOTP_HOSTNAME
-
-
-/*
- * Command line configuration.
- */
-#include <config_cmd_default.h>
-
-#define CONFIG_CMD_EEPROM
-#define CONFIG_CMD_FAT
-#define CONFIG_CMD_I2C
-#define CONFIG_CMD_IDE
-#define CONFIG_CMD_NFS
-#define CONFIG_CMD_SNTP
-#define CONFIG_CMD_USB
-
-#if defined(CONFIG_PCI)
-#define CONFIG_CMD_PCI
-#endif
-
-
-#if (CONFIG_SYS_TEXT_BASE == 0xFF000000)               /* Boot low with 16 MB Flash */
-#   define CONFIG_SYS_LOWBOOT          1
-#   define CONFIG_SYS_LOWBOOT16        1
-#endif
-#if (CONFIG_SYS_TEXT_BASE == 0xFF800000)               /* Boot low with  8 MB Flash */
-#if defined(CONFIG_LITE5200B)
-#   error CONFIG_SYS_LOWBOOT08 is incompatible with the Lite5200B
-#else
-#   define CONFIG_SYS_LOWBOOT          1
-#   define CONFIG_SYS_LOWBOOT08        1
-#endif
-#endif
-
-/*
- * Autobooting
- */
-#define CONFIG_BOOTDELAY       5       /* autoboot after 5 seconds */
-
-#define CONFIG_PREBOOT "echo;" \
-       "echo Type \\\"run flash_nfs\\\" to mount root filesystem over NFS;" \
-       "echo"
-
-#undef CONFIG_BOOTARGS
-
-#define        CONFIG_EXTRA_ENV_SETTINGS                                       \
-       "netdev=eth0\0"                                                 \
-       "nfsargs=setenv bootargs root=/dev/nfs rw "                     \
-               "nfsroot=${serverip}:${rootpath}\0"                     \
-       "ramargs=setenv bootargs root=/dev/ram rw\0"                    \
-       "addip=setenv bootargs ${bootargs} "                            \
-               "ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}"      \
-               ":${hostname}:${netdev}:off panic=1\0"                  \
-       "flash_nfs=run nfsargs addip;"                                  \
-               "bootm ${kernel_addr}\0"                                \
-       "flash_self=run ramargs addip;"                                 \
-               "bootm ${kernel_addr} ${ramdisk_addr}\0"                \
-       "net_nfs=tftp 200000 ${bootfile};run nfsargs addip;bootm\0"     \
-       "rootpath=/opt/eldk/ppc_82xx\0"                                 \
-       "bootfile=/tftpboot/MPC5200/uImage\0"                           \
-       ""
-
-#define CONFIG_BOOTCOMMAND     "run flash_self"
-
-/*
- * IPB Bus clocking configuration.
- */
-#if defined(CONFIG_LITE5200B)
-#define CONFIG_SYS_IPBCLK_EQUALS_XLBCLK        /* define for 133MHz speed */
-#else
-#undef CONFIG_SYS_IPBCLK_EQUALS_XLBCLK         /* define for 133MHz speed */
-#endif
-
-/* pass open firmware flat tree */
-#define CONFIG_OF_LIBFDT       1
-#define CONFIG_OF_BOARD_SETUP  1
-
-#define OF_CPU                 "PowerPC,5200@0"
-#define OF_SOC                 "soc5200@f0000000"
-#define OF_TBCLK               (bd->bi_busfreq / 4)
-#define OF_STDOUT_PATH         "/soc5200@f0000000/serial@2000"
-
-/*
- * I2C configuration
- */
-#define CONFIG_HARD_I2C                1       /* I2C with hardware support */
-#define CONFIG_SYS_I2C_MODULE          2       /* Select I2C module #1 or #2 */
-
-#define CONFIG_SYS_I2C_SPEED           100000 /* 100 kHz */
-#define CONFIG_SYS_I2C_SLAVE           0x7F
-
-/*
- * EEPROM configuration
- */
-#define CONFIG_SYS_I2C_EEPROM_ADDR             0x50    /* 1010000x */
-#define CONFIG_SYS_I2C_EEPROM_ADDR_LEN         1
-#define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS      3
-#define CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS  70
-
-/*
- * Flash configuration
- */
-#if defined(CONFIG_LITE5200B)
-#define CONFIG_SYS_FLASH_BASE          0xFE000000
-#define CONFIG_SYS_FLASH_SIZE          0x01000000
-#if !defined(CONFIG_SYS_LOWBOOT)
-#define CONFIG_ENV_ADDR                (CONFIG_SYS_FLASH_BASE + 0x01760000 + 0x00800000)
-#else  /* CONFIG_SYS_LOWBOOT */
-#if defined(CONFIG_SYS_LOWBOOT08)
-# error CONFIG_SYS_LOWBOOT08 is incompatible with the Lite5200B
-#endif
-#if defined(CONFIG_SYS_LOWBOOT16)
-#define CONFIG_ENV_ADDR                (CONFIG_SYS_FLASH_BASE + 0x01060000)
-#endif
-#endif /* CONFIG_SYS_LOWBOOT */
-#else /* !CONFIG_LITE5200B (IceCube)*/
-#define CONFIG_SYS_FLASH_BASE          0xFF000000
-#define CONFIG_SYS_FLASH_SIZE          0x01000000
-#if !defined(CONFIG_SYS_LOWBOOT)
-#define CONFIG_ENV_ADDR                (CONFIG_SYS_FLASH_BASE + 0x00740000 + 0x00800000)
-#else  /* CONFIG_SYS_LOWBOOT */
-#if defined(CONFIG_SYS_LOWBOOT08)
-#define CONFIG_ENV_ADDR                (CONFIG_SYS_FLASH_BASE + 0x00040000 + 0x00800000)
-#endif
-#if defined(CONFIG_SYS_LOWBOOT16)
-#define CONFIG_ENV_ADDR                (CONFIG_SYS_FLASH_BASE + 0x00040000)
-#endif
-#endif /* CONFIG_SYS_LOWBOOT */
-#endif /* CONFIG_LITE5200B */
-#define CONFIG_SYS_MAX_FLASH_BANKS     2       /* max num of memory banks      */
-
-#define CONFIG_SYS_MAX_FLASH_SECT      128     /* max num of sects on one chip */
-
-#define CONFIG_SYS_FLASH_ERASE_TOUT    240000  /* Flash Erase Timeout (in ms)  */
-#define CONFIG_SYS_FLASH_WRITE_TOUT    500     /* Flash Write Timeout (in ms)  */
-
-#undef CONFIG_FLASH_16BIT      /* Flash is 8-bit */
-
-#if defined(CONFIG_LITE5200B)
-#define CONFIG_FLASH_CFI_DRIVER
-#define CONFIG_SYS_FLASH_CFI
-#define CONFIG_SYS_FLASH_BANKS_LIST    {CONFIG_SYS_CS1_START,CONFIG_SYS_CS0_START}
-#endif
-
-
-/*
- * Environment settings
- */
-#define CONFIG_ENV_IS_IN_FLASH 1
-#define CONFIG_ENV_SIZE                0x10000
-#if defined(CONFIG_LITE5200B)
-#define CONFIG_ENV_SECT_SIZE   0x20000
-#else
-#define CONFIG_ENV_SECT_SIZE   0x10000
-#endif
-#define CONFIG_ENV_OVERWRITE   1
-
-/*
- * Memory map
- */
-#define CONFIG_SYS_MBAR                0xF0000000
-#define CONFIG_SYS_SDRAM_BASE          0x00000000
-#define CONFIG_SYS_DEFAULT_MBAR        0x80000000
-
-/* Use SRAM until RAM will be available */
-#define CONFIG_SYS_INIT_RAM_ADDR       MPC5XXX_SRAM
-#define CONFIG_SYS_INIT_RAM_SIZE       MPC5XXX_SRAM_SIZE       /* Size of used area in DPRAM */
-
-
-#define CONFIG_SYS_GBL_DATA_OFFSET     (CONFIG_SYS_INIT_RAM_SIZE - GENERATED_GBL_DATA_SIZE)
-#define CONFIG_SYS_INIT_SP_OFFSET      CONFIG_SYS_GBL_DATA_OFFSET
-
-#define CONFIG_SYS_MONITOR_BASE    CONFIG_SYS_TEXT_BASE
-#if (CONFIG_SYS_MONITOR_BASE < CONFIG_SYS_FLASH_BASE)
-#   define CONFIG_SYS_RAMBOOT          1
-#endif
-
-#define CONFIG_SYS_MONITOR_LEN         (192 << 10)     /* Reserve 192 kB for Monitor   */
-#define CONFIG_SYS_MALLOC_LEN          (512 << 10)     /* Reserve 512 kB for malloc()  */
-#define CONFIG_SYS_BOOTMAPSZ           (8 << 20)       /* Initial Memory map for Linux */
-
-/*
- * Ethernet configuration
- */
-#define CONFIG_MPC5xxx_FEC     1
-#define CONFIG_MPC5xxx_FEC_MII100
-/*
- * Define CONFIG_MPC5xxx_FEC_MII10 to force FEC at 10Mb
- */
-/* #define CONFIG_MPC5xxx_FEC_MII10 */
-#define CONFIG_PHY_ADDR                0x00
-
-/*
- * GPIO configuration
- */
-#ifdef CONFIG_MPC5200_DDR
-#define CONFIG_SYS_GPS_PORT_CONFIG     0x90000004
-#else
-#define CONFIG_SYS_GPS_PORT_CONFIG     0x10000004
-#endif
-
-/*
- * Miscellaneous configurable options
- */
-#define CONFIG_SYS_LONGHELP                    /* undef to save memory     */
-#if defined(CONFIG_CMD_KGDB)
-#define CONFIG_SYS_CBSIZE              1024    /* Console I/O Buffer Size  */
-#else
-#define CONFIG_SYS_CBSIZE              256     /* Console I/O Buffer Size  */
-#endif
-#define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE+sizeof(CONFIG_SYS_PROMPT)+16)     /* Print Buffer Size */
-#define CONFIG_SYS_MAXARGS             16              /* max number of command args   */
-#define CONFIG_SYS_BARGSIZE            CONFIG_SYS_CBSIZE       /* Boot Argument Buffer Size    */
-
-#define CONFIG_CMDLINE_EDITING 1       /* add command line history     */
-#define CONFIG_SYS_HUSH_PARSER         1       /* use "hush" command parser    */
-
-#define CONFIG_SYS_MEMTEST_START       0x00100000      /* memtest works on */
-#define CONFIG_SYS_MEMTEST_END         0x00f00000      /* 1 ... 15 MB in DRAM  */
-
-#define CONFIG_SYS_LOAD_ADDR           0x100000        /* default load address */
-
-#define CONFIG_SYS_CACHELINE_SIZE      32      /* For MPC5xxx CPUs */
-#if defined(CONFIG_CMD_KGDB)
-#  define CONFIG_SYS_CACHELINE_SHIFT   5       /* log base 2 of the above value */
-#endif
-
-/*
- * Various low-level settings
- */
-#define CONFIG_SYS_HID0_INIT           HID0_ICE | HID0_ICFI
-#define CONFIG_SYS_HID0_FINAL          HID0_ICE
-
-#if defined(CONFIG_LITE5200B)
-#define CONFIG_SYS_CS1_START           CONFIG_SYS_FLASH_BASE
-#define CONFIG_SYS_CS1_SIZE            CONFIG_SYS_FLASH_SIZE
-#define CONFIG_SYS_CS1_CFG             0x00047800
-#define CONFIG_SYS_CS0_START           (CONFIG_SYS_FLASH_BASE + CONFIG_SYS_FLASH_SIZE)
-#define CONFIG_SYS_CS0_SIZE            CONFIG_SYS_FLASH_SIZE
-#define CONFIG_SYS_BOOTCS_START        CONFIG_SYS_CS0_START
-#define CONFIG_SYS_BOOTCS_SIZE         CONFIG_SYS_FLASH_SIZE
-#define CONFIG_SYS_BOOTCS_CFG          0x00047800
-#else /* IceCube aka Lite5200 */
-#ifdef CONFIG_MPC5200_DDR
-
-#define CONFIG_SYS_BOOTCS_START        (CONFIG_SYS_CS1_START + CONFIG_SYS_CS1_SIZE)
-#define CONFIG_SYS_BOOTCS_SIZE         0x00800000
-#define CONFIG_SYS_BOOTCS_CFG          0x00047801
-#define CONFIG_SYS_CS1_START           CONFIG_SYS_FLASH_BASE
-#define CONFIG_SYS_CS1_SIZE            0x00800000
-#define CONFIG_SYS_CS1_CFG             0x00047800
-
-#else /* !CONFIG_MPC5200_DDR */
-
-#define CONFIG_SYS_BOOTCS_START        CONFIG_SYS_FLASH_BASE
-#define CONFIG_SYS_BOOTCS_SIZE         CONFIG_SYS_FLASH_SIZE
-#define CONFIG_SYS_BOOTCS_CFG          0x00047801
-#define CONFIG_SYS_CS0_START           CONFIG_SYS_FLASH_BASE
-#define CONFIG_SYS_CS0_SIZE            CONFIG_SYS_FLASH_SIZE
-
-#endif /* CONFIG_MPC5200_DDR */
-#endif /*CONFIG_LITE5200B */
-
-#define CONFIG_SYS_CS_BURST            0x00000000
-#define CONFIG_SYS_CS_DEADCYCLE        0x33333333
-
-#define CONFIG_SYS_RESET_ADDRESS       0xff000000
-
-/*-----------------------------------------------------------------------
- * USB stuff
- *-----------------------------------------------------------------------
- */
-#define CONFIG_USB_CLOCK       0x0001BBBB
-#define CONFIG_USB_CONFIG      0x00001000
-
-/*-----------------------------------------------------------------------
- * IDE/ATA stuff Supports IDE harddisk
- *-----------------------------------------------------------------------
- */
-
-#undef  CONFIG_IDE_8xx_PCCARD          /* Use IDE with PC Card Adapter */
-
-#undef CONFIG_IDE_8xx_DIRECT           /* Direct IDE    not supported  */
-#undef CONFIG_IDE_LED                  /* LED   for ide not supported  */
-
-#define        CONFIG_IDE_RESET                /* reset for ide supported      */
-#define CONFIG_IDE_PREINIT
-
-#define CONFIG_SYS_IDE_MAXBUS          1       /* max. 1 IDE bus               */
-#define CONFIG_SYS_IDE_MAXDEVICE       2       /* max. 1 drive per IDE bus     */
-
-#define CONFIG_SYS_ATA_IDE0_OFFSET     0x0000
-
-#define CONFIG_SYS_ATA_BASE_ADDR       MPC5XXX_ATA
-
-/* Offset for data I/O                 */
-#define CONFIG_SYS_ATA_DATA_OFFSET     (0x0060)
-
-/* Offset for normal register accesses */
-#define CONFIG_SYS_ATA_REG_OFFSET      (CONFIG_SYS_ATA_DATA_OFFSET)
-
-/* Offset for alternate registers      */
-#define CONFIG_SYS_ATA_ALT_OFFSET      (0x005C)
-
-/* Interval between registers                                                */
-#define CONFIG_SYS_ATA_STRIDE          4
-
-#define CONFIG_ATAPI            1
-
-#endif /* __CONFIG_H */
diff --git a/include/configs/MPC8360EMDS.h b/include/configs/MPC8360EMDS.h
deleted file mode 100644 (file)
index aefde74..0000000
+++ /dev/null
@@ -1,735 +0,0 @@
-/*
- * Copyright (C) 2006,2011 Freescale Semiconductor, Inc.
- *
- * Dave Liu <daveliu@freescale.com>
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#ifndef __CONFIG_H
-#define __CONFIG_H
-
-/*
- * High Level Configuration Options
- */
-#define CONFIG_E300            1 /* E300 family */
-#define CONFIG_QE              1 /* Has QE */
-#define CONFIG_MPC8360         1 /* MPC8360 CPU specific */
-#define CONFIG_MPC8360EMDS     1 /* MPC8360EMDS board specific */
-
-#define        CONFIG_SYS_TEXT_BASE    0xFE000000
-
-#undef CONFIG_PQ_MDS_PIB /* POWERQUICC MDS Platform IO Board */
-#undef CONFIG_PQ_MDS_PIB_ATM /* QOC3 ATM card */
-
-/*
- * System Clock Setup
- */
-#ifdef CONFIG_CLKIN_33MHZ
-#ifdef CONFIG_PCISLAVE
-#define CONFIG_83XX_PCICLK     33330000 /* in HZ */
-#else
-#define CONFIG_83XX_CLKIN      33330000 /* in Hz */
-#endif
-
-#ifndef CONFIG_SYS_CLK_FREQ
-#define CONFIG_SYS_CLK_FREQ    33330000
-#endif
-
-#elif defined(CONFIG_CLKIN_66MHZ)
-#ifdef CONFIG_PCISLAVE
-#define CONFIG_83XX_PCICLK     66000000 /* in HZ */
-#else
-#define CONFIG_83XX_CLKIN      66000000 /* in Hz */
-#endif
-
-#ifndef CONFIG_SYS_CLK_FREQ
-#define CONFIG_SYS_CLK_FREQ    66000000
-#endif
-#else
-#error Unknown oscillator frequency.
-#endif
-
-/*
- * Hardware Reset Configuration Word
- */
-#ifdef CONFIG_CLKIN_33MHZ
-#define CONFIG_SYS_HRCW_LOW (\
-       HRCWL_LCL_BUS_TO_SCB_CLK_1X1 |\
-       HRCWL_DDR_TO_SCB_CLK_1X1 |\
-       HRCWL_CSB_TO_CLKIN_8X1 |\
-       HRCWL_VCO_1X2 |\
-       HRCWL_CE_PLL_VCO_DIV_4 |\
-       HRCWL_CE_PLL_DIV_1X1 |\
-       HRCWL_CE_TO_PLL_1X15 |\
-       HRCWL_CORE_TO_CSB_2X1)
-#elif defined(CONFIG_CLKIN_66MHZ)
-#define CONFIG_SYS_HRCW_LOW (\
-       HRCWL_LCL_BUS_TO_SCB_CLK_1X1 |\
-       HRCWL_DDR_TO_SCB_CLK_1X1 |\
-       HRCWL_CSB_TO_CLKIN_4X1 |\
-       HRCWL_VCO_1X2 |\
-       HRCWL_CE_PLL_VCO_DIV_4 |\
-       HRCWL_CE_PLL_DIV_1X1 |\
-       HRCWL_CE_TO_PLL_1X6 |\
-       HRCWL_CORE_TO_CSB_2X1)
-#endif
-
-#ifdef CONFIG_PCISLAVE
-#define CONFIG_SYS_HRCW_HIGH (\
-       HRCWH_PCI_AGENT |\
-       HRCWH_PCI1_ARBITER_DISABLE |\
-       HRCWH_PCICKDRV_DISABLE |\
-       HRCWH_CORE_ENABLE |\
-       HRCWH_FROM_0XFFF00100 |\
-       HRCWH_BOOTSEQ_DISABLE |\
-       HRCWH_SW_WATCHDOG_DISABLE |\
-       HRCWH_ROM_LOC_LOCAL_16BIT)
-#else
-#define CONFIG_SYS_HRCW_HIGH (\
-       HRCWH_PCI_HOST |\
-       HRCWH_PCI1_ARBITER_ENABLE |\
-       HRCWH_PCICKDRV_ENABLE |\
-       HRCWH_CORE_ENABLE |\
-       HRCWH_FROM_0X00000100 |\
-       HRCWH_BOOTSEQ_DISABLE |\
-       HRCWH_SW_WATCHDOG_DISABLE |\
-       HRCWH_ROM_LOC_LOCAL_16BIT)
-#endif
-
-/*
- * System IO Config
- */
-#define CONFIG_SYS_SICRH               0x00000000
-#define CONFIG_SYS_SICRL               0x40000000
-
-#define CONFIG_BOARD_EARLY_INIT_F /* call board_pre_init */
-#define CONFIG_BOARD_EARLY_INIT_R
-
-/*
- * IMMR new address
- */
-#define CONFIG_SYS_IMMR                0xE0000000
-
-/*
- * DDR Setup
- */
-#define CONFIG_SYS_DDR_BASE    0x00000000 /* DDR is system memory */
-#define CONFIG_SYS_SDRAM_BASE  CONFIG_SYS_DDR_BASE
-                               /* + 256M */
-#define CONFIG_SYS_SDRAM_BASE2 (CONFIG_SYS_SDRAM_BASE + 0x10000000)
-#define CONFIG_SYS_DDR_SDRAM_BASE      CONFIG_SYS_DDR_BASE
-#define CONFIG_SYS_DDR_SDRAM_CLK_CNTL  (DDR_SDRAM_CLK_CNTL_SS_EN \
-                                       | DDR_SDRAM_CLK_CNTL_CLK_ADJUST_05)
-
-#define CONFIG_SYS_83XX_DDR_USES_CS0
-
-#define CONFIG_DDR_ECC         /* support DDR ECC function */
-#define CONFIG_DDR_ECC_CMD     /* Use DDR ECC user commands */
-
-/*
- * DDRCDR - DDR Control Driver Register
- */
-#define CONFIG_SYS_DDRCDR_VALUE        0x80080001
-
-#define CONFIG_SPD_EEPROM      /* Use SPD EEPROM for DDR setup */
-#if defined(CONFIG_SPD_EEPROM)
-/*
- * Determine DDR configuration from I2C interface.
- */
-#define SPD_EEPROM_ADDRESS     0x52 /* DDR SODIMM */
-#else
-/*
- * Manually set up DDR parameters
- */
-#define CONFIG_SYS_DDR_SIZE            256 /* MB */
-#if defined(CONFIG_DDR_II)
-#define CONFIG_SYS_DDRCDR              0x80080001
-#define CONFIG_SYS_DDR_CS0_BNDS                0x0000000f
-#define CONFIG_SYS_DDR_CS0_CONFIG      0x80330102
-#define CONFIG_SYS_DDR_TIMING_0                0x00220802
-#define CONFIG_SYS_DDR_TIMING_1                0x38357322
-#define CONFIG_SYS_DDR_TIMING_2                0x2f9048c8
-#define CONFIG_SYS_DDR_TIMING_3                0x00000000
-#define CONFIG_SYS_DDR_CLK_CNTL                0x02000000
-#define CONFIG_SYS_DDR_MODE            0x47d00432
-#define CONFIG_SYS_DDR_MODE2           0x8000c000
-#define CONFIG_SYS_DDR_INTERVAL                0x03cf0080
-#define CONFIG_SYS_DDR_SDRAM_CFG       0x43000000
-#define CONFIG_SYS_DDR_SDRAM_CFG2      0x00401000
-#else
-#define CONFIG_SYS_DDR_CS0_CONFIG      (CSCONFIG_EN \
-                                       | CSCONFIG_ROW_BIT_13 \
-                                       | CSCONFIG_COL_BIT_9)
-#define CONFIG_SYS_DDR_CS1_CONFIG      CONFIG_SYS_DDR_CS0_CONFIG
-#define CONFIG_SYS_DDR_TIMING_1        0x37344321 /* tCL-tRCD-tRP-tRAS=2.5-3-3-7 */
-#define CONFIG_SYS_DDR_TIMING_2        0x00000800 /* may need tuning */
-#define CONFIG_SYS_DDR_CONTROL 0x42008000 /* Self refresh,2T timing */
-#define CONFIG_SYS_DDR_MODE    0x20000162 /* DLL,normal,seq,4/2.5 */
-#define CONFIG_SYS_DDR_INTERVAL        0x045b0100 /* page mode */
-#endif
-#endif
-
-/*
- * Memory test
- */
-#undef CONFIG_SYS_DRAM_TEST            /* memory test, takes time */
-#define CONFIG_SYS_MEMTEST_START       0x00000000 /* memtest region */
-#define CONFIG_SYS_MEMTEST_END         0x00100000
-
-/*
- * The reserved memory
- */
-
-#define CONFIG_SYS_MONITOR_BASE        CONFIG_SYS_TEXT_BASE /* start of monitor */
-
-#if (CONFIG_SYS_MONITOR_BASE < CONFIG_SYS_FLASH_BASE)
-#define CONFIG_SYS_RAMBOOT
-#else
-#undef CONFIG_SYS_RAMBOOT
-#endif
-
-/* CONFIG_SYS_MONITOR_LEN must be a multiple of CONFIG_ENV_SECT_SIZE */
-#define CONFIG_SYS_MONITOR_LEN (384 * 1024) /* Reserve 384 kB for Mon */
-#define CONFIG_SYS_MALLOC_LEN  (256 * 1024) /* Reserved for malloc */
-
-/*
- * Initial RAM Base Address Setup
- */
-#define CONFIG_SYS_INIT_RAM_LOCK       1
-#define CONFIG_SYS_INIT_RAM_ADDR       0xE6000000 /* Initial RAM address */
-#define CONFIG_SYS_INIT_RAM_SIZE       0x1000 /* Size of used area in RAM */
-#define CONFIG_SYS_GBL_DATA_OFFSET     \
-                       (CONFIG_SYS_INIT_RAM_SIZE - GENERATED_GBL_DATA_SIZE)
-
-/*
- * Local Bus Configuration & Clock Setup
- */
-#define CONFIG_SYS_LCRR_DBYP   LCRR_DBYP
-#define CONFIG_SYS_LCRR_CLKDIV LCRR_CLKDIV_4
-#define CONFIG_SYS_LBC_LBCR    0x00000000
-
-/*
- * FLASH on the Local Bus
- */
-#define CONFIG_SYS_FLASH_CFI           /* use the Common Flash Interface */
-#define CONFIG_FLASH_CFI_DRIVER                /* use the CFI driver */
-#define CONFIG_SYS_FLASH_BASE          0xFE000000 /* FLASH base address */
-#define CONFIG_SYS_FLASH_SIZE          32 /* max FLASH size is 32M */
-#define CONFIG_SYS_FLASH_PROTECTION    1 /* Use h/w Flash protection. */
-#define CONFIG_FLASH_SHOW_PROGRESS     45 /* count down from 45/5: 9..1 */
-
-                                       /* Window base at flash base */
-#define CONFIG_SYS_LBLAWBAR0_PRELIM    CONFIG_SYS_FLASH_BASE
-#define CONFIG_SYS_LBLAWAR0_PRELIM     (LBLAWAR_EN | LBLAWAR_32MB)
-
-#define CONFIG_SYS_BR0_PRELIM  (CONFIG_SYS_FLASH_BASE \
-                               | BR_PS_16      /* 16 bit port */ \
-                               | BR_MS_GPCM    /* MSEL = GPCM */ \
-                               | BR_V)         /* valid */
-#define CONFIG_SYS_OR0_PRELIM  (MEG_TO_AM(CONFIG_SYS_FLASH_SIZE) \
-                               | OR_GPCM_XAM \
-                               | OR_GPCM_CSNT \
-                               | OR_GPCM_ACS_DIV2 \
-                               | OR_GPCM_XACS \
-                               | OR_GPCM_SCY_15 \
-                               | OR_GPCM_TRLX_SET \
-                               | OR_GPCM_EHTR_SET \
-                               | OR_GPCM_EAD)
-
-#define CONFIG_SYS_MAX_FLASH_BANKS     1 /* number of banks */
-#define CONFIG_SYS_MAX_FLASH_SECT      256 /* max sectors per device */
-
-#undef CONFIG_SYS_FLASH_CHECKSUM
-
-/*
- * BCSR on the Local Bus
- */
-#define CONFIG_SYS_BCSR                        0xF8000000
-                                       /* Access window base at BCSR base */
-#define CONFIG_SYS_LBLAWBAR1_PRELIM    CONFIG_SYS_BCSR
-#define CONFIG_SYS_LBLAWAR1_PRELIM     (LBLAWAR_EN | LBLAWAR_64KB)
-
-#define CONFIG_SYS_BR1_PRELIM  (CONFIG_SYS_BCSR \
-                               | BR_PS_8 \
-                               | BR_MS_GPCM \
-                               | BR_V)
-#define CONFIG_SYS_OR1_PRELIM  (OR_AM_32KB \
-                               | OR_GPCM_XAM \
-                               | OR_GPCM_CSNT \
-                               | OR_GPCM_XACS \
-                               | OR_GPCM_SCY_15 \
-                               | OR_GPCM_TRLX_SET \
-                               | OR_GPCM_EHTR_SET \
-                               | OR_GPCM_EAD)
-                               /* 0xFFFFE9F7 */
-
-/*
- * SDRAM on the Local Bus
- */
-#define CONFIG_SYS_LBC_SDRAM_BASE      0xF0000000      /* SDRAM base address */
-#define CONFIG_SYS_LBC_SDRAM_SIZE      64              /* LBC SDRAM is 64MB */
-
-#define CONFIG_SYS_LB_SDRAM            /* if board has SRDAM on local bus */
-
-#ifdef CONFIG_SYS_LB_SDRAM
-#define CONFIG_SYS_LBLAWBAR2           0
-#define CONFIG_SYS_LBLAWAR2            (LBLAWAR_EN | LBLAWAR_64MB)
-
-/*local bus BR2, OR2 definition for SDRAM if soldered on the EPB board */
-/*
- * Base Register 2 and Option Register 2 configure SDRAM.
- *
- * For BR2, need:
- *    Base address = BR[0:16] = dynamic
- *    port size = 32-bits = BR2[19:20] = 11
- *    no parity checking = BR2[21:22] = 00
- *    SDRAM for MSEL = BR2[24:26] = 011
- *    Valid = BR[31] = 1
- *
- * 0   4    8    12   16   20   24   28
- * xxxx xxxx xxxx xxxx x001 1000 0110 0001 = 00001861
- */
-
-/* Port size=32bit, MSEL=DRAM */
-#define CONFIG_SYS_BR2 (BR_PS_32 | BR_MS_SDRAM | BR_V) /* 0xF0001861 */
-
-/*
- * The SDRAM size in MB, CONFIG_SYS_LBC_SDRAM_SIZE, is 64.
- *
- * For OR2, need:
- *    64MB mask for AM, OR2[0:7] = 1111 1100
- *                XAM, OR2[17:18] = 11
- *    9 columns OR2[19-21] = 010
- *    13 rows  OR2[23-25] = 100
- *    EAD set for extra time OR[31] = 1
- *
- * 0   4    8    12   16   20   24   28
- * 1111 1100 0000 0000 0110 1001 0000 0001 = fc006901
- */
-
-#define CONFIG_SYS_OR2 (MEG_TO_AM(CONFIG_SYS_LBC_SDRAM_SIZE) \
-                       | OR_SDRAM_XAM \
-                       | ((9 - OR_SDRAM_MIN_COLS) << OR_SDRAM_COLS_SHIFT) \
-                       | ((13 - OR_SDRAM_MIN_ROWS) << OR_SDRAM_ROWS_SHIFT) \
-                       | OR_SDRAM_EAD)
-                       /* 0xFC006901 */
-
-                               /* LB sdram refresh timer, about 6us */
-#define CONFIG_SYS_LBC_LSRT    0x32000000
-                               /* LB refresh timer prescal, 266MHz/32 */
-#define CONFIG_SYS_LBC_MRTPR   0x20000000
-
-#define CONFIG_SYS_LBC_LSDMR_COMMON    0x0063b723
-
-/*
- * SDRAM Controller configuration sequence.
- */
-#define CONFIG_SYS_LBC_LSDMR_1 (CONFIG_SYS_LBC_LSDMR_COMMON | LSDMR_OP_PCHALL)
-#define CONFIG_SYS_LBC_LSDMR_2 (CONFIG_SYS_LBC_LSDMR_COMMON | LSDMR_OP_ARFRSH)
-#define CONFIG_SYS_LBC_LSDMR_3 (CONFIG_SYS_LBC_LSDMR_COMMON | LSDMR_OP_ARFRSH)
-#define CONFIG_SYS_LBC_LSDMR_4 (CONFIG_SYS_LBC_LSDMR_COMMON | LSDMR_OP_MRW)
-#define CONFIG_SYS_LBC_LSDMR_5 (CONFIG_SYS_LBC_LSDMR_COMMON | LSDMR_OP_NORMAL)
-
-#endif
-
-/*
- * Windows to access Platform I/O Boards (PIB) via local bus
- */
-#define CONFIG_SYS_PIB_BASE            0xF8008000
-#define CONFIG_SYS_PIB_WINDOW_SIZE     (32 * 1024)
-
-/* [RFC] This LBLAW only covers the 2nd window (CS5) */
-#define CONFIG_SYS_LBLAWBAR3_PRELIM    \
-                       CONFIG_SYS_PIB_BASE + CONFIG_SYS_PIB_WINDOW_SIZE
-#define CONFIG_SYS_LBLAWAR3_PRELIM     (LBLAWAR_EN | LBLAWAR_32KB)
-
-/*
- * CS4 on Local Bus, to PIB
- */
-                               /* CS4 base address at 0xf8008000 */
-#define CONFIG_SYS_BR4_PRELIM  (CONFIG_SYS_PIB_BASE \
-                               | BR_PS_8 \
-                               | BR_MS_GPCM \
-                               | BR_V)
-                               /* 0xF8008801 */
-#define CONFIG_SYS_OR4_PRELIM  (OR_AM_32KB \
-                               | OR_GPCM_XAM \
-                               | OR_GPCM_CSNT \
-                               | OR_GPCM_XACS \
-                               | OR_GPCM_SCY_15 \
-                               | OR_GPCM_TRLX_SET \
-                               | OR_GPCM_EHTR_SET \
-                               | OR_GPCM_EAD)
-                               /* 0xffffe9f7 */
-
-/*
- * CS5 on Local Bus, to PIB
- */
-                               /* CS5 base address at 0xf8010000 */
-#define CONFIG_SYS_BR5_PRELIM  ((CONFIG_SYS_PIB_BASE + \
-                                               CONFIG_SYS_PIB_WINDOW_SIZE) \
-                               | BR_PS_8 \
-                               | BR_MS_GPCM \
-                               | BR_V)
-                               /* 0xF8010801 */
-#define CONFIG_SYS_OR5_PRELIM  (CONFIG_SYS_PIB_BASE \
-                               | OR_GPCM_XAM \
-                               | OR_GPCM_CSNT \
-                               | OR_GPCM_XACS \
-                               | OR_GPCM_SCY_15 \
-                               | OR_GPCM_TRLX_SET \
-                               | OR_GPCM_EHTR_SET \
-                               | OR_GPCM_EAD)
-                               /* 0xffffe9f7 */
-
-/*
- * Serial Port
- */
-#define CONFIG_CONS_INDEX      1
-#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_BAUDRATE_TABLE  \
-               {300, 600, 1200, 2400, 4800, 9600, 19200, 38400, 115200}
-
-#define CONFIG_SYS_NS16550_COM1        (CONFIG_SYS_IMMR+0x4500)
-#define CONFIG_SYS_NS16550_COM2        (CONFIG_SYS_IMMR+0x4600)
-
-#define CONFIG_CMDLINE_EDITING 1       /* add command line history     */
-#define CONFIG_AUTO_COMPLETE           /* add autocompletion support   */
-/* Use the HUSH parser */
-#define CONFIG_SYS_HUSH_PARSER
-
-/* pass open firmware flat tree */
-#define CONFIG_OF_LIBFDT       1
-#define CONFIG_OF_BOARD_SETUP  1
-#define CONFIG_OF_STDOUT_VIA_ALIAS     1
-
-/* I2C */
-#define CONFIG_SYS_I2C
-#define CONFIG_SYS_I2C_FSL
-#define CONFIG_SYS_FSL_I2C_SPEED       400000
-#define CONFIG_SYS_FSL_I2C_SLAVE       0x7F
-#define CONFIG_SYS_FSL_I2C_OFFSET      0x3000
-#define CONFIG_SYS_I2C_NOPROBES                { {0, 0x52} }
-
-/*
- * Config on-board RTC
- */
-#define CONFIG_RTC_DS1374              /* use ds1374 rtc via i2c */
-#define CONFIG_SYS_I2C_RTC_ADDR        0x68    /* at address 0x68 */
-
-/*
- * General PCI
- * Addresses are mapped 1-1.
- */
-#define CONFIG_SYS_PCI1_MEM_BASE       0x80000000
-#define CONFIG_SYS_PCI1_MEM_PHYS       CONFIG_SYS_PCI1_MEM_BASE
-#define CONFIG_SYS_PCI1_MEM_SIZE       0x10000000 /* 256M */
-#define CONFIG_SYS_PCI1_MMIO_BASE      0x90000000
-#define CONFIG_SYS_PCI1_MMIO_PHYS      CONFIG_SYS_PCI1_MMIO_BASE
-#define CONFIG_SYS_PCI1_MMIO_SIZE      0x10000000 /* 256M */
-#define CONFIG_SYS_PCI1_IO_BASE                0x00000000
-#define CONFIG_SYS_PCI1_IO_PHYS                0xE0300000
-#define CONFIG_SYS_PCI1_IO_SIZE                0x100000 /* 1M */
-
-#define CONFIG_SYS_PCI_SLV_MEM_LOCAL   CONFIG_SYS_SDRAM_BASE
-#define CONFIG_SYS_PCI_SLV_MEM_BUS     0x00000000
-#define CONFIG_SYS_PCI_SLV_MEM_SIZE    0x80000000
-
-
-#ifdef CONFIG_PCI
-#define CONFIG_PCI_INDIRECT_BRIDGE
-
-#define CONFIG_PCI_PNP         /* do pci plug-and-play */
-#define CONFIG_83XX_PCI_STREAMING
-
-#undef CONFIG_EEPRO100
-#undef CONFIG_PCI_SCAN_SHOW    /* show pci devices on startup */
-#define CONFIG_SYS_PCI_SUBSYS_VENDORID 0x1957  /* Freescale */
-
-#endif /* CONFIG_PCI */
-
-
-#define CONFIG_HWCONFIG                1
-
-/*
- * QE UEC ethernet configuration
- */
-#define CONFIG_UEC_ETH
-#define CONFIG_ETHPRIME                "UEC0"
-#define CONFIG_PHY_MODE_NEED_CHANGE
-
-#define CONFIG_UEC_ETH1                /* GETH1 */
-
-#ifdef CONFIG_UEC_ETH1
-#define CONFIG_SYS_UEC1_UCC_NUM        0       /* UCC1 */
-#define CONFIG_SYS_UEC1_RX_CLK         QE_CLK_NONE
-#define CONFIG_SYS_UEC1_TX_CLK         QE_CLK9
-#define CONFIG_SYS_UEC1_ETH_TYPE       GIGA_ETH
-#define CONFIG_SYS_UEC1_PHY_ADDR       0
-#define CONFIG_SYS_UEC1_INTERFACE_TYPE PHY_INTERFACE_MODE_RGMII_ID
-#define CONFIG_SYS_UEC1_INTERFACE_SPEED 1000
-#endif
-
-#define CONFIG_UEC_ETH2                /* GETH2 */
-
-#ifdef CONFIG_UEC_ETH2
-#define CONFIG_SYS_UEC2_UCC_NUM        1       /* UCC2 */
-#define CONFIG_SYS_UEC2_RX_CLK         QE_CLK_NONE
-#define CONFIG_SYS_UEC2_TX_CLK         QE_CLK4
-#define CONFIG_SYS_UEC2_ETH_TYPE       GIGA_ETH
-#define CONFIG_SYS_UEC2_PHY_ADDR       1
-#define CONFIG_SYS_UEC2_INTERFACE_TYPE PHY_INTERFACE_MODE_RGMII_ID
-#define CONFIG_SYS_UEC2_INTERFACE_SPEED 1000
-#endif
-
-/*
- * Environment
- */
-
-#ifndef CONFIG_SYS_RAMBOOT
-       #define CONFIG_ENV_IS_IN_FLASH  1
-       #define CONFIG_ENV_ADDR         \
-                       (CONFIG_SYS_MONITOR_BASE + CONFIG_SYS_MONITOR_LEN)
-       #define CONFIG_ENV_SECT_SIZE    0x20000
-       #define CONFIG_ENV_SIZE         0x2000
-#else
-       #define CONFIG_SYS_NO_FLASH     1       /* Flash is not usable now */
-       #define CONFIG_ENV_IS_NOWHERE   1       /* Store ENV in memory only */
-       #define CONFIG_ENV_ADDR         (CONFIG_SYS_MONITOR_BASE - 0x1000)
-       #define CONFIG_ENV_SIZE         0x2000
-#endif
-
-#define CONFIG_LOADS_ECHO      1       /* echo on for serial download */
-#define CONFIG_SYS_LOADS_BAUD_CHANGE   1       /* allow baudrate change */
-
-/*
- * BOOTP options
- */
-#define CONFIG_BOOTP_BOOTFILESIZE
-#define CONFIG_BOOTP_BOOTPATH
-#define CONFIG_BOOTP_GATEWAY
-#define CONFIG_BOOTP_HOSTNAME
-
-
-/*
- * Command line configuration.
- */
-#include <config_cmd_default.h>
-
-#define CONFIG_CMD_PING
-#define CONFIG_CMD_I2C
-#define CONFIG_CMD_ASKENV
-#define CONFIG_CMD_SDRAM
-
-#if defined(CONFIG_PCI)
-    #define CONFIG_CMD_PCI
-#endif
-
-#if defined(CONFIG_SYS_RAMBOOT)
-    #undef CONFIG_CMD_SAVEENV
-    #undef CONFIG_CMD_LOADS
-#endif
-
-
-#undef CONFIG_WATCHDOG         /* watchdog disabled */
-
-/*
- * Miscellaneous configurable options
- */
-#define CONFIG_SYS_LONGHELP            /* undef to save memory */
-#define CONFIG_SYS_LOAD_ADDR           0x2000000 /* default load address */
-
-#if defined(CONFIG_CMD_KGDB)
-       #define CONFIG_SYS_CBSIZE       1024 /* Console I/O Buffer Size */
-#else
-       #define CONFIG_SYS_CBSIZE       256 /* Console I/O Buffer Size */
-#endif
-
-                               /* Print Buffer Size */
-#define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE+sizeof(CONFIG_SYS_PROMPT)+16)
-#define CONFIG_SYS_MAXARGS     16      /* max number of command args */
-                               /* Boot Argument Buffer Size */
-#define CONFIG_SYS_BARGSIZE    CONFIG_SYS_CBSIZE
-
-/*
- * For booting Linux, the board info and command line data
- * have to be in the first 256 MB of memory, since this is
- * the maximum mapped by the Linux kernel during initialization.
- */
-#define CONFIG_SYS_BOOTMAPSZ   (256 << 20) /* Initial Memory map for Linux */
-
-/*
- * Core HID Setup
- */
-#define CONFIG_SYS_HID0_INIT   0x000000000
-#define CONFIG_SYS_HID0_FINAL  (HID0_ENABLE_MACHINE_CHECK | \
-                                HID0_ENABLE_INSTRUCTION_CACHE)
-#define CONFIG_SYS_HID2                HID2_HBE
-
-/*
- * MMU Setup
- */
-
-#define CONFIG_HIGH_BATS       1       /* High BATs supported */
-#define CONFIG_BAT_RW
-
-/* DDR/LBC SDRAM: cacheable */
-#define CONFIG_SYS_IBAT0L      (CONFIG_SYS_SDRAM_BASE \
-                               | BATL_PP_RW \
-                               | BATL_MEMCOHERENCE)
-#define CONFIG_SYS_IBAT0U      (CONFIG_SYS_SDRAM_BASE \
-                               | BATU_BL_256M \
-                               | BATU_VS \
-                               | BATU_VP)
-#define CONFIG_SYS_DBAT0L      CONFIG_SYS_IBAT0L
-#define CONFIG_SYS_DBAT0U      CONFIG_SYS_IBAT0U
-
-/* IMMRBAR & PCI IO: cache-inhibit and guarded */
-#define CONFIG_SYS_IBAT1L      (CONFIG_SYS_IMMR \
-                               | BATL_PP_RW \
-                               | BATL_CACHEINHIBIT \
-                               | BATL_GUARDEDSTORAGE)
-#define CONFIG_SYS_IBAT1U      (CONFIG_SYS_IMMR \
-                               | BATU_BL_4M \
-                               | BATU_VS \
-                               | BATU_VP)
-#define CONFIG_SYS_DBAT1L      CONFIG_SYS_IBAT1L
-#define CONFIG_SYS_DBAT1U      CONFIG_SYS_IBAT1U
-
-/* BCSR: cache-inhibit and guarded */
-#define CONFIG_SYS_IBAT2L      (CONFIG_SYS_BCSR \
-                               | BATL_PP_RW \
-                               | BATL_CACHEINHIBIT \
-                               | BATL_GUARDEDSTORAGE)
-#define CONFIG_SYS_IBAT2U      (CONFIG_SYS_BCSR \
-                               | BATU_BL_128K \
-                               | BATU_VS \
-                               | BATU_VP)
-#define CONFIG_SYS_DBAT2L      CONFIG_SYS_IBAT2L
-#define CONFIG_SYS_DBAT2U      CONFIG_SYS_IBAT2U
-
-/* FLASH: icache cacheable, but dcache-inhibit and guarded */
-#define CONFIG_SYS_IBAT3L      (CONFIG_SYS_FLASH_BASE \
-                               | BATL_PP_RW \
-                               | BATL_MEMCOHERENCE)
-#define CONFIG_SYS_IBAT3U      (CONFIG_SYS_FLASH_BASE \
-                               | BATU_BL_32M \
-                               | BATU_VS \
-                               | BATU_VP)
-#define CONFIG_SYS_DBAT3L      (CONFIG_SYS_FLASH_BASE \
-                               | BATL_PP_RW \
-                               | BATL_CACHEINHIBIT \
-                               | BATL_GUARDEDSTORAGE)
-#define CONFIG_SYS_DBAT3U      CONFIG_SYS_IBAT3U
-
-/* DDR/LBC SDRAM next 256M: cacheable */
-#define CONFIG_SYS_IBAT4L      (CONFIG_SYS_SDRAM_BASE2 \
-                               | BATL_PP_RW \
-                               | BATL_MEMCOHERENCE)
-#define CONFIG_SYS_IBAT4U      (CONFIG_SYS_SDRAM_BASE2 \
-                               | BATU_BL_256M \
-                               | BATU_VS \
-                               | BATU_VP)
-#define CONFIG_SYS_DBAT4L      CONFIG_SYS_IBAT4L
-#define CONFIG_SYS_DBAT4U      CONFIG_SYS_IBAT4U
-
-/* Stack in dcache: cacheable, no memory coherence */
-#define CONFIG_SYS_IBAT5L      (CONFIG_SYS_INIT_RAM_ADDR | BATL_PP_RW)
-#define CONFIG_SYS_IBAT5U      (CONFIG_SYS_INIT_RAM_ADDR \
-                               | BATU_BL_128K \
-                               | BATU_VS \
-                               | BATU_VP)
-#define CONFIG_SYS_DBAT5L      CONFIG_SYS_IBAT5L
-#define CONFIG_SYS_DBAT5U      CONFIG_SYS_IBAT5U
-
-#ifdef CONFIG_PCI
-/* PCI MEM space: cacheable */
-#define CONFIG_SYS_IBAT6L      (CONFIG_SYS_PCI1_MEM_PHYS \
-                               | BATL_PP_RW \
-                               | BATL_MEMCOHERENCE)
-#define CONFIG_SYS_IBAT6U      (CONFIG_SYS_PCI1_MEM_PHYS \
-                               | BATU_BL_256M \
-                               | BATU_VS \
-                               | BATU_VP)
-#define CONFIG_SYS_DBAT6L      CONFIG_SYS_IBAT6L
-#define CONFIG_SYS_DBAT6U      CONFIG_SYS_IBAT6U
-/* PCI MMIO space: cache-inhibit and guarded */
-#define CONFIG_SYS_IBAT7L      (CONFIG_SYS_PCI1_MMIO_PHYS \
-                               | BATL_PP_RW \
-                               | BATL_CACHEINHIBIT \
-                               | BATL_GUARDEDSTORAGE)
-#define CONFIG_SYS_IBAT7U      (CONFIG_SYS_PCI1_MMIO_PHYS \
-                               | BATU_BL_256M \
-                               | BATU_VS \
-                               | BATU_VP)
-#define CONFIG_SYS_DBAT7L      CONFIG_SYS_IBAT7L
-#define CONFIG_SYS_DBAT7U      CONFIG_SYS_IBAT7U
-#else
-#define CONFIG_SYS_IBAT6L      (0)
-#define CONFIG_SYS_IBAT6U      (0)
-#define CONFIG_SYS_IBAT7L      (0)
-#define CONFIG_SYS_IBAT7U      (0)
-#define CONFIG_SYS_DBAT6L      CONFIG_SYS_IBAT6L
-#define CONFIG_SYS_DBAT6U      CONFIG_SYS_IBAT6U
-#define CONFIG_SYS_DBAT7L      CONFIG_SYS_IBAT7L
-#define CONFIG_SYS_DBAT7U      CONFIG_SYS_IBAT7U
-#endif
-
-#if defined(CONFIG_CMD_KGDB)
-#define CONFIG_KGDB_BAUDRATE   230400  /* speed of kgdb serial port */
-#endif
-
-/*
- * Environment Configuration
- */
-
-#define CONFIG_ENV_OVERWRITE
-
-#if defined(CONFIG_UEC_ETH)
-#define CONFIG_HAS_ETH0
-#define CONFIG_HAS_ETH1
-#endif
-
-#define CONFIG_BAUDRATE 115200
-
-#define CONFIG_LOADADDR 800000 /* default location for tftp and bootm */
-
-#define CONFIG_BOOTDELAY 6     /* -1 disables auto-boot */
-#undef CONFIG_BOOTARGS         /* the boot command will set bootargs */
-
-#define CONFIG_EXTRA_ENV_SETTINGS                                      \
-       "netdev=eth0\0"                                                 \
-       "consoledev=ttyS0\0"                                            \
-       "ramdiskaddr=1000000\0"                                         \
-       "ramdiskfile=ramfs.83xx\0"                                      \
-       "fdtaddr=780000\0"                                              \
-       "fdtfile=mpc836x_mds.dtb\0"                                     \
-       ""
-
-#define CONFIG_NFSBOOTCOMMAND                                          \
-       "setenv bootargs root=/dev/nfs rw "                             \
-               "nfsroot=$serverip:$rootpath "                          \
-               "ip=$ipaddr:$serverip:$gatewayip:$netmask:$hostname:"   \
-                                                       "$netdev:off "  \
-               "console=$consoledev,$baudrate $othbootargs;"           \
-       "tftp $loadaddr $bootfile;"                                     \
-       "tftp $fdtaddr $fdtfile;"                                       \
-       "bootm $loadaddr - $fdtaddr"
-
-#define CONFIG_RAMBOOTCOMMAND                                          \
-       "setenv bootargs root=/dev/ram rw "                             \
-               "console=$consoledev,$baudrate $othbootargs;"           \
-       "tftp $ramdiskaddr $ramdiskfile;"                               \
-       "tftp $loadaddr $bootfile;"                                     \
-       "tftp $fdtaddr $fdtfile;"                                       \
-       "bootm $loadaddr $ramdiskaddr $fdtaddr"
-
-
-#define CONFIG_BOOTCOMMAND CONFIG_NFSBOOTCOMMAND
-
-#endif /* __CONFIG_H */
diff --git a/include/configs/MPC8360ERDK.h b/include/configs/MPC8360ERDK.h
deleted file mode 100644 (file)
index 1b8bad1..0000000
+++ /dev/null
@@ -1,620 +0,0 @@
-/*
- * Copyright (C) 2006 Freescale Semiconductor, Inc.
- *                    Dave Liu <daveliu@freescale.com>
- *
- * Copyright (C) 2007 Logic Product Development, Inc.
- *                    Peter Barada <peterb@logicpd.com>
- *
- * Copyright (C) 2007 MontaVista Software, Inc.
- *                    Anton Vorontsov <avorontsov@ru.mvista.com>
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#ifndef __CONFIG_H
-#define __CONFIG_H
-
-/*
- * High Level Configuration Options
- */
-#define CONFIG_E300            1 /* E300 family */
-#define CONFIG_QE              1 /* Has QE */
-#define CONFIG_MPC8360         1 /* MPC8360 CPU specific */
-#define CONFIG_MPC8360ERDK     1 /* MPC8360ERDK board specific */
-
-#define        CONFIG_SYS_TEXT_BASE    0xFF800000
-
-/*
- * System Clock Setup
- */
-#ifdef CONFIG_CLKIN_33MHZ
-#define CONFIG_83XX_CLKIN              33333333
-#define CONFIG_SYS_CLK_FREQ            33333333
-#define CONFIG_PCI_33M                         1
-#define HRCWL_CSB_TO_CLKIN_MPC8360ERDK HRCWL_CSB_TO_CLKIN_10X1
-#else
-#define CONFIG_83XX_CLKIN              66000000
-#define CONFIG_SYS_CLK_FREQ            66000000
-#define CONFIG_PCI_66M                         1
-#define HRCWL_CSB_TO_CLKIN_MPC8360ERDK HRCWL_CSB_TO_CLKIN_5X1
-#endif /* CONFIG_CLKIN_33MHZ */
-
-/*
- * Hardware Reset Configuration Word
- */
-#define CONFIG_SYS_HRCW_LOW (\
-       HRCWL_LCL_BUS_TO_SCB_CLK_1X1 |\
-       HRCWL_DDR_TO_SCB_CLK_1X1 |\
-       HRCWL_CSB_TO_CLKIN_MPC8360ERDK |\
-       HRCWL_CORE_TO_CSB_2X1 |\
-       HRCWL_CE_TO_PLL_1X15)
-
-#define CONFIG_SYS_HRCW_HIGH (\
-       HRCWH_PCI_HOST |\
-       HRCWH_PCI1_ARBITER_ENABLE |\
-       HRCWH_PCICKDRV_ENABLE |\
-       HRCWH_CORE_ENABLE |\
-       HRCWH_FROM_0X00000100 |\
-       HRCWH_BOOTSEQ_DISABLE |\
-       HRCWH_SW_WATCHDOG_DISABLE |\
-       HRCWH_ROM_LOC_LOCAL_16BIT |\
-       HRCWH_SECONDARY_DDR_DISABLE |\
-       HRCWH_BIG_ENDIAN |\
-       HRCWH_LALE_EARLY)
-
-/*
- * System IO Config
- */
-#define CONFIG_SYS_SICRH               0x00000000
-#define CONFIG_SYS_SICRL               0x40000000
-
-#define CONFIG_BOARD_EARLY_INIT_R
-
-/*
- * IMMR new address
- */
-#define CONFIG_SYS_IMMR                0xE0000000
-
-/*
- * DDR Setup
- */
-#define CONFIG_SYS_DDR_BASE            0x00000000 /* DDR is system memory */
-#define CONFIG_SYS_SDRAM_BASE          CONFIG_SYS_DDR_BASE
-#define CONFIG_SYS_DDR_SDRAM_BASE      CONFIG_SYS_DDR_BASE
-#define CONFIG_SYS_DDR_SDRAM_CLK_CNTL  (DDR_SDRAM_CLK_CNTL_SS_EN \
-                                       | DDR_SDRAM_CLK_CNTL_CLK_ADJUST_05)
-
-#define CONFIG_SYS_83XX_DDR_USES_CS0
-
-#define CONFIG_DDR_ECC         /* support DDR ECC function */
-#define CONFIG_DDR_ECC_CMD     /* Use DDR ECC user commands */
-
-/*
- * DDRCDR - DDR Control Driver Register
- */
-#define CONFIG_SYS_DDRCDR_VALUE        (DDRCDR_DHC_EN \
-                               | DDRCDR_ODT \
-                               | DDRCDR_Q_DRN)
-                               /* 0x80080001 */
-
-#undef CONFIG_SPD_EEPROM       /* Do not use SPD EEPROM for DDR setup */
-
-/*
- * Manually set up DDR parameters
- */
-#define CONFIG_DDR_II
-#define CONFIG_SYS_DDR_SIZE            256 /* MB */
-#define CONFIG_SYS_DDR_CS0_BNDS                0x0000000f
-#define CONFIG_SYS_DDR_CS0_CONFIG      (CSCONFIG_EN \
-                                       | CSCONFIG_ROW_BIT_13 \
-                                       | CSCONFIG_COL_BIT_10 \
-                                       | CSCONFIG_ODT_WR_ONLY_CURRENT)
-#define CONFIG_SYS_DDR_SDRAM_CFG       (SDRAM_CFG_SDRAM_TYPE_DDR2 \
-                                       | SDRAM_CFG_ECC_EN)
-#define CONFIG_SYS_DDR_SDRAM_CFG2      0x00001000
-#define CONFIG_SYS_DDR_CLK_CNTL                (DDR_SDRAM_CLK_CNTL_CLK_ADJUST_05)
-#define CONFIG_SYS_DDR_INTERVAL                ((256 << SDRAM_INTERVAL_BSTOPRE_SHIFT) \
-                                       | (1115 << SDRAM_INTERVAL_REFINT_SHIFT))
-#define CONFIG_SYS_DDR_MODE            0x47800432
-#define CONFIG_SYS_DDR_MODE2           0x8000c000
-
-#define CONFIG_SYS_DDR_TIMING_0        ((2 << TIMING_CFG0_MRS_CYC_SHIFT) | \
-                                (9 << TIMING_CFG0_ODT_PD_EXIT_SHIFT) | \
-                                (3 << TIMING_CFG0_PRE_PD_EXIT_SHIFT) | \
-                                (3 << TIMING_CFG0_ACT_PD_EXIT_SHIFT) | \
-                                (0 << TIMING_CFG0_WWT_SHIFT) | \
-                                (0 << TIMING_CFG0_RRT_SHIFT) | \
-                                (0 << TIMING_CFG0_WRT_SHIFT) | \
-                                (0 << TIMING_CFG0_RWT_SHIFT))
-
-#define CONFIG_SYS_DDR_TIMING_1        ((TIMING_CFG1_CASLAT_30) | \
-                                (2 << TIMING_CFG1_WRTORD_SHIFT) | \
-                                (2 << TIMING_CFG1_ACTTOACT_SHIFT) | \
-                                (3 << TIMING_CFG1_WRREC_SHIFT) | \
-                                (10 << TIMING_CFG1_REFREC_SHIFT) | \
-                                (3 << TIMING_CFG1_ACTTORW_SHIFT) | \
-                                (8 << TIMING_CFG1_ACTTOPRE_SHIFT) | \
-                                (3 << TIMING_CFG1_PRETOACT_SHIFT))
-
-#define CONFIG_SYS_DDR_TIMING_2        ((9 << TIMING_CFG2_FOUR_ACT_SHIFT) | \
-                                (4 << TIMING_CFG2_CKE_PLS_SHIFT) | \
-                                (2 << TIMING_CFG2_WR_DATA_DELAY_SHIFT) | \
-                                (2 << TIMING_CFG2_RD_TO_PRE_SHIFT) | \
-                                (2 << TIMING_CFG2_WR_LAT_DELAY_SHIFT) | \
-                                (0 << TIMING_CFG2_ADD_LAT_SHIFT) | \
-                                (0 << TIMING_CFG2_CPO_SHIFT))
-
-#define CONFIG_SYS_DDR_TIMING_3        0x00000000
-
-/*
- * Memory test
- */
-#undef CONFIG_SYS_DRAM_TEST            /* memory test, takes time */
-#define CONFIG_SYS_MEMTEST_START       0x00000000 /* memtest region */
-#define CONFIG_SYS_MEMTEST_END         0x00100000
-
-/*
- * The reserved memory
- */
-#define CONFIG_SYS_MONITOR_BASE        CONFIG_SYS_TEXT_BASE /* start of monitor */
-#define CONFIG_SYS_FLASH_BASE          0xFF800000 /* FLASH base address */
-
-#if (CONFIG_SYS_MONITOR_BASE < CONFIG_SYS_FLASH_BASE)
-#define CONFIG_SYS_RAMBOOT
-#else
-#undef CONFIG_SYS_RAMBOOT
-#endif
-
-#define CONFIG_SYS_MONITOR_LEN (384 * 1024) /* Reserve 384 kB for Mon */
-#define CONFIG_SYS_MALLOC_LEN  (256 * 1024) /* Reserved for malloc */
-
-/*
- * Initial RAM Base Address Setup
- */
-#define CONFIG_SYS_INIT_RAM_LOCK       1
-#define CONFIG_SYS_INIT_RAM_ADDR       0xE6000000 /* Initial RAM address */
-#define CONFIG_SYS_INIT_RAM_SIZE       0x1000 /* Size of used area in RAM */
-#define CONFIG_SYS_GBL_DATA_OFFSET     \
-                       (CONFIG_SYS_INIT_RAM_SIZE - GENERATED_GBL_DATA_SIZE)
-
-/*
- * Local Bus Configuration & Clock Setup
- */
-#define CONFIG_SYS_LCRR_DBYP   LCRR_DBYP
-#define CONFIG_SYS_LCRR_CLKDIV LCRR_CLKDIV_4
-#define CONFIG_SYS_LBC_LBCR    0x00000000
-
-/*
- * FLASH on the Local Bus
- */
-#define CONFIG_SYS_FLASH_CFI           /* use the Common Flash Interface */
-#define CONFIG_FLASH_CFI_DRIVER                /* use the CFI driver */
-#define CONFIG_SYS_FLASH_SIZE          8 /* max FLASH size is 32M */
-#define CONFIG_SYS_FLASH_PROTECTION    1 /* Use intel Flash protection. */
-
-                                       /* Window base at flash base */
-#define CONFIG_SYS_LBLAWBAR0_PRELIM    CONFIG_SYS_FLASH_BASE
-#define CONFIG_SYS_LBLAWAR0_PRELIM     (LBLAWAR_EN | LBLAWAR_32MB)
-
-#define CONFIG_SYS_BR0_PRELIM  (CONFIG_SYS_FLASH_BASE \
-                               | BR_PS_16      /* 16 bit port */ \
-                               | BR_MS_GPCM    /* MSEL = GPCM */ \
-                               | BR_V)         /* valid */
-#define CONFIG_SYS_OR0_PRELIM  (MEG_TO_AM(CONFIG_SYS_FLASH_SIZE) \
-                               | OR_UPM_XAM \
-                               | OR_GPCM_CSNT \
-                               | OR_GPCM_ACS_DIV2 \
-                               | OR_GPCM_XACS \
-                               | OR_GPCM_SCY_15 \
-                               | OR_GPCM_TRLX_SET \
-                               | OR_GPCM_EHTR_SET \
-                               | OR_GPCM_EAD)
-
-#define CONFIG_SYS_MAX_FLASH_BANKS     1 /* number of banks */
-#define CONFIG_SYS_MAX_FLASH_SECT      256 /* max sectors per device */
-
-#undef CONFIG_SYS_FLASH_CHECKSUM
-
-/*
- * NAND flash on the local bus
- */
-#define CONFIG_SYS_NAND_BASE           0x60000000
-#define CONFIG_CMD_NAND                1
-#define CONFIG_NAND_FSL_UPM    1
-#define CONFIG_SYS_MAX_NAND_DEVICE     1
-#define CONFIG_MTD_NAND_VERIFY_WRITE
-
-#define CONFIG_SYS_LBLAWBAR1_PRELIM    CONFIG_SYS_NAND_BASE
-/*
- * [RFC] Comment said 4KB window; code said 256MB window; OR1 says 64MB
- * ... What's correct?
- */
-#define CONFIG_SYS_LBLAWAR1_PRELIM     (LBLAWAR_EN | LBLAWAR_256MB)
-
-/* Port size 8 bit, UPMA */
-#define CONFIG_SYS_BR1_PRELIM          (CONFIG_SYS_NAND_BASE \
-                                       | BR_PS_8 \
-                                       | BR_MS_UPMA \
-                                       | BR_V)
-                                       /* 0x60000881 */
-#define CONFIG_SYS_OR1_PRELIM          (OR_AM_64MB | OR_UPM_EAD)
-                                       /* 0xFC000001 */
-
-/*
- * Fujitsu MB86277 (MINT) graphics controller
- */
-#define CONFIG_SYS_VIDEO_BASE          0x70000000
-
-#define CONFIG_SYS_LBLAWBAR2_PRELIM    CONFIG_SYS_VIDEO_BASE
-#define CONFIG_SYS_LBLAWAR2_PRELIM     (LBLAWAR_EN | LBLAWAR_64MB)
-
-/* Port size 32 bit, UPMB */
-#define CONFIG_SYS_BR2_PRELIM  (CONFIG_SYS_VIDEO_BASE \
-                               | BR_PS_32 \
-                               | BR_MS_UPMB \
-                               | BR_V)
-                               /* 0x000018a1 */
-#define CONFIG_SYS_OR2_PRELIM  (OR_AM_64MB | OR_UPM_EAD)
-                               /* 0xFC000001 */
-
-/*
- * Serial Port
- */
-#define CONFIG_CONS_INDEX      1
-#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_BAUDRATE_TABLE  \
-               {300, 600, 1200, 2400, 4800, 9600, 19200, 38400, 115200}
-
-#define CONFIG_SYS_NS16550_COM1        (CONFIG_SYS_IMMR+0x4500)
-#define CONFIG_SYS_NS16550_COM2        (CONFIG_SYS_IMMR+0x4600)
-
-#define CONFIG_CMDLINE_EDITING 1       /* add command line history */
-#define CONFIG_AUTO_COMPLETE           /* add autocompletion support */
-/* Use the HUSH parser */
-#define CONFIG_SYS_HUSH_PARSER
-
-/* Pass open firmware flat tree */
-#define CONFIG_OF_LIBFDT       1
-#define CONFIG_OF_BOARD_SETUP  1
-#define CONFIG_OF_STDOUT_VIA_ALIAS
-
-/* I2C */
-#define CONFIG_SYS_I2C
-#define CONFIG_SYS_I2C_FSL
-#define CONFIG_SYS_FSL_I2C_SPEED       400000
-#define CONFIG_SYS_FSL_I2C_SLAVE       0x7F
-#define CONFIG_SYS_FSL_I2C_OFFSET      0x3000
-#define CONFIG_SYS_FSL_I2C2_SPEED      400000
-#define CONFIG_SYS_FSL_I2C2_SLAVE      0x7F
-#define CONFIG_SYS_FSL_I2C2_OFFSET     0x3100
-#define CONFIG_SYS_I2C_NOPROBES                { {0, 0x52} }
-
-/*
- * General PCI
- * Addresses are mapped 1-1.
- */
-#define CONFIG_PCI
-
-#define CONFIG_SYS_PCI1_MEM_BASE       0x80000000
-#define CONFIG_SYS_PCI1_MEM_PHYS       CONFIG_SYS_PCI1_MEM_BASE
-#define CONFIG_SYS_PCI1_MEM_SIZE       0x10000000 /* 256M */
-#define CONFIG_SYS_PCI1_MMIO_BASE      0x90000000
-#define CONFIG_SYS_PCI1_MMIO_PHYS      CONFIG_SYS_PCI1_MMIO_BASE
-#define CONFIG_SYS_PCI1_MMIO_SIZE      0x10000000 /* 256M */
-#define CONFIG_SYS_PCI1_IO_BASE                0xE0300000
-#define CONFIG_SYS_PCI1_IO_PHYS                0xE0300000
-#define CONFIG_SYS_PCI1_IO_SIZE                0x100000 /* 1M */
-
-#ifdef CONFIG_PCI
-#define CONFIG_PCI_INDIRECT_BRIDGE
-
-#define CONFIG_PCI_PNP         /* do pci plug-and-play */
-
-#undef CONFIG_EEPRO100
-#undef CONFIG_PCI_SCAN_SHOW    /* show pci devices on startup */
-#define CONFIG_SYS_PCI_SUBSYS_VENDORID 0x1957  /* Freescale */
-
-#endif /* CONFIG_PCI */
-
-/*
- * QE UEC ethernet configuration
- */
-#define CONFIG_UEC_ETH
-#define CONFIG_ETHPRIME                "UEC0"
-
-#define CONFIG_UEC_ETH1                /* GETH1 */
-
-#ifdef CONFIG_UEC_ETH1
-#define CONFIG_SYS_UEC1_UCC_NUM        0       /* UCC1 */
-#define CONFIG_SYS_UEC1_RX_CLK         QE_CLK_NONE
-#define CONFIG_SYS_UEC1_TX_CLK         QE_CLK9
-#define CONFIG_SYS_UEC1_ETH_TYPE       GIGA_ETH
-#define CONFIG_SYS_UEC1_PHY_ADDR       2
-#define CONFIG_SYS_UEC1_INTERFACE_TYPE PHY_INTERFACE_MODE_RGMII_RXID
-#define CONFIG_SYS_UEC1_INTERFACE_SPEED        1000
-#endif
-
-#define CONFIG_UEC_ETH2                /* GETH2 */
-
-#ifdef CONFIG_UEC_ETH2
-#define CONFIG_SYS_UEC2_UCC_NUM        1       /* UCC2 */
-#define CONFIG_SYS_UEC2_RX_CLK         QE_CLK_NONE
-#define CONFIG_SYS_UEC2_TX_CLK         QE_CLK4
-#define CONFIG_SYS_UEC2_ETH_TYPE       GIGA_ETH
-#define CONFIG_SYS_UEC2_PHY_ADDR       4
-#define CONFIG_SYS_UEC2_INTERFACE_TYPE PHY_INTERFACE_MODE_RGMII_RXID
-#define CONFIG_SYS_UEC2_INTERFACE_SPEED        1000
-#endif
-
-/*
- * Environment
- */
-
-#ifndef CONFIG_SYS_RAMBOOT
-#define CONFIG_ENV_IS_IN_FLASH 1
-#define CONFIG_ENV_ADDR        (CONFIG_SYS_MONITOR_BASE + CONFIG_SYS_MONITOR_LEN)
-#define CONFIG_ENV_SECT_SIZE   0x20000 /* 128K(one sector) for env */
-#define CONFIG_ENV_SIZE                0x20000
-#else /* CONFIG_SYS_RAMBOOT */
-#define CONFIG_SYS_NO_FLASH    1       /* Flash is not usable now */
-#define CONFIG_ENV_IS_NOWHERE  1       /* Store ENV in memory only */
-#define CONFIG_ENV_ADDR                (CONFIG_SYS_MONITOR_BASE - 0x1000)
-#define CONFIG_ENV_SIZE                0x2000
-#endif /* CONFIG_SYS_RAMBOOT */
-
-#define CONFIG_LOADS_ECHO      1       /* echo on for serial download */
-#define CONFIG_SYS_LOADS_BAUD_CHANGE   1       /* allow baudrate change */
-
-/*
- * BOOTP options
- */
-#define CONFIG_BOOTP_BOOTFILESIZE
-#define CONFIG_BOOTP_BOOTPATH
-#define CONFIG_BOOTP_GATEWAY
-#define CONFIG_BOOTP_HOSTNAME
-
-
-/*
- * Command line configuration.
- */
-#include <config_cmd_default.h>
-
-#define CONFIG_CMD_PING
-#define CONFIG_CMD_I2C
-#define CONFIG_CMD_ASKENV
-#define CONFIG_CMD_DHCP
-
-#if defined(CONFIG_PCI)
-#define CONFIG_CMD_PCI
-#endif
-
-#if defined(CONFIG_SYS_RAMBOOT)
-#undef CONFIG_CMD_SAVEENV
-#undef CONFIG_CMD_LOADS
-#endif
-
-#undef CONFIG_WATCHDOG         /* watchdog disabled */
-
-/*
- * Miscellaneous configurable options
- */
-#define CONFIG_SYS_LONGHELP            /* undef to save memory */
-#define CONFIG_SYS_LOAD_ADDR           0x2000000 /* default load address */
-
-#if defined(CONFIG_CMD_KGDB)
-       #define CONFIG_SYS_CBSIZE       1024 /* Console I/O Buffer Size */
-#else
-       #define CONFIG_SYS_CBSIZE       256 /* Console I/O Buffer Size */
-#endif
-
-                               /* Print Buffer Size */
-#define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE+sizeof(CONFIG_SYS_PROMPT)+16)
-#define CONFIG_SYS_MAXARGS     16      /* max number of command args */
-                               /* Boot Argument Buffer Size */
-#define CONFIG_SYS_BARGSIZE    CONFIG_SYS_CBSIZE
-
-/*
- * For booting Linux, the board info and command line data
- * have to be in the first 256 MB of memory, since this is
- * the maximum mapped by the Linux kernel during initialization.
- */
-#define CONFIG_SYS_BOOTMAPSZ   (256 << 20) /* Initial Memory map for Linux */
-
-/*
- * Core HID Setup
- */
-#define CONFIG_SYS_HID0_INIT   0x000000000
-#define CONFIG_SYS_HID0_FINAL  (HID0_ENABLE_MACHINE_CHECK | \
-                                HID0_ENABLE_INSTRUCTION_CACHE)
-#define CONFIG_SYS_HID2                HID2_HBE
-
-/*
- * MMU Setup
- */
-
-#define CONFIG_HIGH_BATS       1       /* High BATs supported */
-
-/* DDR: cache cacheable */
-#define CONFIG_SYS_IBAT0L      (CONFIG_SYS_SDRAM_BASE \
-                               | BATL_PP_RW \
-                               | BATL_MEMCOHERENCE)
-#define CONFIG_SYS_IBAT0U      (CONFIG_SYS_SDRAM_BASE \
-                               | BATU_BL_256M \
-                               | BATU_VS \
-                               | BATU_VP)
-#define CONFIG_SYS_DBAT0L      CONFIG_SYS_IBAT0L
-#define CONFIG_SYS_DBAT0U      CONFIG_SYS_IBAT0U
-
-/* IMMRBAR & PCI IO: cache-inhibit and guarded */
-#define CONFIG_SYS_IBAT1L      (CONFIG_SYS_IMMR \
-                               | BATL_PP_RW \
-                               | BATL_CACHEINHIBIT \
-                               | BATL_GUARDEDSTORAGE)
-#define CONFIG_SYS_IBAT1U      (CONFIG_SYS_IMMR \
-                               | BATU_BL_4M \
-                               | BATU_VS \
-                               | BATU_VP)
-#define CONFIG_SYS_DBAT1L      CONFIG_SYS_IBAT1L
-#define CONFIG_SYS_DBAT1U      CONFIG_SYS_IBAT1U
-
-/* NAND: cache-inhibit and guarded */
-#define CONFIG_SYS_IBAT2L      (CONFIG_SYS_NAND_BASE \
-                               | BATL_PP_RW \
-                               | BATL_CACHEINHIBIT \
-                               | BATL_GUARDEDSTORAGE)
-#define CONFIG_SYS_IBAT2U      (CONFIG_SYS_NAND_BASE \
-                               | BATU_BL_64M \
-                               | BATU_VS \
-                               | BATU_VP)
-#define CONFIG_SYS_DBAT2L      CONFIG_SYS_IBAT2L
-#define CONFIG_SYS_DBAT2U      CONFIG_SYS_IBAT2U
-
-/* FLASH: icache cacheable, but dcache-inhibit and guarded */
-#define CONFIG_SYS_IBAT3L      (CONFIG_SYS_FLASH_BASE \
-                               | BATL_PP_RW \
-                               | BATL_MEMCOHERENCE)
-#define CONFIG_SYS_IBAT3U      (CONFIG_SYS_FLASH_BASE \
-                               | BATU_BL_32M \
-                               | BATU_VS \
-                               | BATU_VP)
-#define CONFIG_SYS_DBAT3L      (CONFIG_SYS_FLASH_BASE \
-                               | BATL_PP_RW \
-                               | BATL_CACHEINHIBIT \
-                               | BATL_GUARDEDSTORAGE)
-#define CONFIG_SYS_DBAT3U      CONFIG_SYS_IBAT3U
-
-/* Stack in dcache: cacheable, no memory coherence */
-#define CONFIG_SYS_IBAT4L      (CONFIG_SYS_INIT_RAM_ADDR \
-                               | BATL_PP_RW)
-#define CONFIG_SYS_IBAT4U      (CONFIG_SYS_INIT_RAM_ADDR \
-                               | BATU_BL_128K \
-                               | BATU_VS \
-                               | BATU_VP)
-#define CONFIG_SYS_DBAT4L      CONFIG_SYS_IBAT4L
-#define CONFIG_SYS_DBAT4U      CONFIG_SYS_IBAT4U
-
-#define CONFIG_SYS_IBAT5L      (CONFIG_SYS_VIDEO_BASE \
-                               | BATL_PP_RW \
-                               | BATL_CACHEINHIBIT \
-                               | BATL_GUARDEDSTORAGE)
-#define CONFIG_SYS_IBAT5U      (CONFIG_SYS_VIDEO_BASE \
-                               | BATU_BL_64M \
-                               | BATU_VS \
-                               | BATU_VP)
-#define CONFIG_SYS_DBAT5L      CONFIG_SYS_IBAT5L
-#define CONFIG_SYS_DBAT5U      CONFIG_SYS_IBAT5U
-
-#ifdef CONFIG_PCI
-/* PCI MEM space: cacheable */
-#define CONFIG_SYS_IBAT6L      (CONFIG_SYS_PCI1_MEM_PHYS \
-                               | BATL_PP_RW \
-                               | BATL_MEMCOHERENCE)
-#define CONFIG_SYS_IBAT6U      (CONFIG_SYS_PCI1_MEM_PHYS \
-                               | BATU_BL_256M \
-                               | BATU_VS \
-                               | BATU_VP)
-#define CONFIG_SYS_DBAT6L      CONFIG_SYS_IBAT6L
-#define CONFIG_SYS_DBAT6U      CONFIG_SYS_IBAT6U
-/* PCI MMIO space: cache-inhibit and guarded */
-#define CONFIG_SYS_IBAT7L      (CONFIG_SYS_PCI1_MMIO_PHYS \
-                               | BATL_PP_RW \
-                               | BATL_CACHEINHIBIT \
-                               | BATL_GUARDEDSTORAGE)
-#define CONFIG_SYS_IBAT7U      (CONFIG_SYS_PCI1_MMIO_PHYS \
-                               | BATU_BL_256M \
-                               | BATU_VS \
-                               | BATU_VP)
-#define CONFIG_SYS_DBAT7L      CONFIG_SYS_IBAT7L
-#define CONFIG_SYS_DBAT7U      CONFIG_SYS_IBAT7U
-#else /* CONFIG_PCI */
-#define CONFIG_SYS_IBAT6L      (0)
-#define CONFIG_SYS_IBAT6U      (0)
-#define CONFIG_SYS_IBAT7L      (0)
-#define CONFIG_SYS_IBAT7U      (0)
-#define CONFIG_SYS_DBAT6L      CONFIG_SYS_IBAT6L
-#define CONFIG_SYS_DBAT6U      CONFIG_SYS_IBAT6U
-#define CONFIG_SYS_DBAT7L      CONFIG_SYS_IBAT7L
-#define CONFIG_SYS_DBAT7U      CONFIG_SYS_IBAT7U
-#endif /* CONFIG_PCI */
-
-#if defined(CONFIG_CMD_KGDB)
-#define CONFIG_KGDB_BAUDRATE   230400  /* speed of kgdb serial port */
-#endif
-
-/*
- * Environment Configuration
- */
-#define CONFIG_ENV_OVERWRITE
-
-#if defined(CONFIG_UEC_ETH)
-#define CONFIG_HAS_ETH0
-#define CONFIG_HAS_ETH1
-#define CONFIG_HAS_ETH2
-#define CONFIG_HAS_ETH3
-#endif
-
-#define CONFIG_BAUDRATE 115200
-
-#define CONFIG_LOADADDR        a00000
-#define CONFIG_HOSTNAME        mpc8360erdk
-#define CONFIG_BOOTFILE        "uImage"
-
-#define CONFIG_ROOTPATH                "/nfsroot/"
-
-#define        CONFIG_BOOTDELAY 2      /* -1 disables auto-boot */
-#undef CONFIG_BOOTARGS         /* the boot command will set bootargs */
-
-#define CONFIG_EXTRA_ENV_SETTINGS \
-       "netdev=eth0\0"                                                 \
-       "consoledev=ttyS0\0"                                            \
-       "loadaddr=a00000\0"                                             \
-       "fdtaddr=900000\0"                                              \
-       "fdtfile=mpc836x_rdk.dtb\0"                                     \
-       "fsfile=fs\0"                                                   \
-       "ubootfile=u-boot.bin\0"                                        \
-       "mtdparts=mtdparts=60000000.nand-flash:4096k(kernel),128k(dtb),"\
-                                                       "-(rootfs)\0"   \
-       "setbootargs=setenv bootargs console=$consoledev,$baudrate "    \
-               "$mtdparts panic=1\0"                                   \
-       "adddhcpargs=setenv bootargs $bootargs ip=on\0"                 \
-       "addnfsargs=setenv bootargs $bootargs ip=$ipaddr:$serverip:"    \
-               "$gatewayip:$netmask:$hostname:$netdev:off "            \
-               "root=/dev/nfs rw nfsroot=$serverip:$rootpath\0"        \
-       "addnandargs=setenv bootargs $bootargs root=/dev/mtdblock3 "    \
-               "rootfstype=jffs2 rw\0"                                 \
-       "tftp_get_uboot=tftp 100000 $ubootfile\0"                       \
-       "tftp_get_kernel=tftp $loadaddr $bootfile\0"                    \
-       "tftp_get_dtb=tftp $fdtaddr $fdtfile\0"                         \
-       "tftp_get_fs=tftp c00000 $fsfile\0"                             \
-       "nand_erase_kernel=nand erase 0 400000\0"                       \
-       "nand_erase_dtb=nand erase 400000 20000\0"                      \
-       "nand_erase_fs=nand erase 420000 3be0000\0"                     \
-       "nand_write_kernel=nand write.jffs2 $loadaddr 0 400000\0"       \
-       "nand_write_dtb=nand write.jffs2 $fdtaddr 400000 20000\0"       \
-       "nand_write_fs=nand write.jffs2 c00000 420000 $filesize\0"      \
-       "nand_read_kernel=nand read.jffs2 $loadaddr 0 400000\0"         \
-       "nand_read_dtb=nand read.jffs2 $fdtaddr 400000 20000\0"         \
-       "nor_reflash=protect off ff800000 ff87ffff ; "                  \
-               "erase ff800000 ff87ffff ; "                            \
-               "cp.b 100000 ff800000 $filesize\0"                      \
-       "nand_reflash_kernel=run tftp_get_kernel nand_erase_kernel "    \
-               "nand_write_kernel\0"                                   \
-       "nand_reflash_dtb=run tftp_get_dtb nand_erase_dtb nand_write_dtb\0"\
-       "nand_reflash_fs=run tftp_get_fs nand_erase_fs nand_write_fs\0" \
-       "nand_reflash=run nand_reflash_kernel nand_reflash_dtb "        \
-               "nand_reflash_fs\0"                                     \
-       "boot_m=bootm $loadaddr - $fdtaddr\0"                           \
-       "dhcpboot=dhcp ; run setbootargs adddhcpargs tftp_get_dtb boot_m\0"\
-       "nfsboot=run setbootargs addnfsargs tftp_get_kernel tftp_get_dtb "\
-               "boot_m\0"                                              \
-       "nandboot=run setbootargs addnandargs nand_read_kernel nand_read_dtb "\
-               "boot_m\0"                                              \
-       ""
-
-#define CONFIG_BOOTCOMMAND "run dhcpboot"
-
-#endif /* __CONFIG_H */
index 8ed0f7c21afee03ee22fb1ab50c4e93860a8cf6e..19e0e30eef1cea5241a9d4c182a44c5ac6d8c4b8 100644 (file)
@@ -15,6 +15,8 @@
 #define CONFIG_E300            1 /* E300 family */
 #define CONFIG_MPC837x         1 /* MPC837x CPU specific */
 #define CONFIG_MPC837XERDB     1
+#define CONFIG_DISPLAY_BOARDINFO
+#define CONFIG_SYS_GENERIC_BOARD
 
 #define        CONFIG_SYS_TEXT_BASE    0xFE000000
 
diff --git a/include/configs/P1_P2_RDB.h b/include/configs/P1_P2_RDB.h
deleted file mode 100644 (file)
index c75638a..0000000
+++ /dev/null
@@ -1,808 +0,0 @@
-/*
- * Copyright 2009-2011 Freescale Semiconductor, Inc.
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-/*
- * P1 P2 RDB board configuration file
- * This file is intended to address a set of Low End and Ultra Low End
- * Freescale SOCs of QorIQ series(RDB platforms).
- * Currently only P2020RDB
- */
-
-#ifndef __CONFIG_H
-#define __CONFIG_H
-
-#ifdef CONFIG_36BIT
-#define CONFIG_PHYS_64BIT
-#endif
-
-#ifdef CONFIG_P1011RDB
-#define CONFIG_P1011
-#define CONFIG_SYS_L2_SIZE     (256 << 10)
-#endif
-#ifdef CONFIG_P1020RDB
-#define CONFIG_P1020
-#define CONFIG_SYS_L2_SIZE     (256 << 10)
-#endif
-#ifdef CONFIG_P2010RDB
-#define CONFIG_P2010
-#define CONFIG_SYS_L2_SIZE     (512 << 10)
-#endif
-#ifdef CONFIG_P2020RDB
-#define CONFIG_P2020
-#define CONFIG_SYS_L2_SIZE     (512 << 10)
-#endif
-
-#ifdef CONFIG_SDCARD
-#define CONFIG_SPL_MPC8XXX_INIT_DDR_SUPPORT
-#define CONFIG_SPL_ENV_SUPPORT
-#define CONFIG_SPL_SERIAL_SUPPORT
-#define CONFIG_SPL_MMC_SUPPORT
-#define CONFIG_SPL_MMC_MINIMAL
-#define CONFIG_SPL_FLUSH_IMAGE
-#define CONFIG_SPL_TARGET              "u-boot-with-spl.bin"
-#define CONFIG_SPL_LIBGENERIC_SUPPORT
-#define CONFIG_SPL_LIBCOMMON_SUPPORT
-#define CONFIG_SPL_I2C_SUPPORT
-#define CONFIG_SYS_TEXT_BASE           0x11001000
-#define CONFIG_SPL_TEXT_BASE           0xf8f81000
-#define CONFIG_SPL_PAD_TO              0x20000
-#define CONFIG_SPL_MAX_SIZE            (128 * 1024)
-#define CONFIG_SYS_MMC_U_BOOT_SIZE     (768 << 10)
-#define CONFIG_SYS_MMC_U_BOOT_DST      (0x11000000)
-#define CONFIG_SYS_MMC_U_BOOT_START    (0x11000000)
-#define CONFIG_SYS_MMC_U_BOOT_OFFS     (129 << 10)
-#define CONFIG_SYS_MPC85XX_NO_RESETVEC
-#define CONFIG_SYS_LDSCRIPT    "arch/powerpc/cpu/mpc85xx/u-boot.lds"
-#define CONFIG_SPL_MMC_BOOT
-#ifdef CONFIG_SPL_BUILD
-#define CONFIG_SPL_COMMON_INIT_DDR
-#endif
-#endif
-
-#ifdef CONFIG_SPIFLASH
-#define CONFIG_SPL_MPC8XXX_INIT_DDR_SUPPORT
-#define CONFIG_SPL_ENV_SUPPORT
-#define CONFIG_SPL_SERIAL_SUPPORT
-#define CONFIG_SPL_SPI_SUPPORT
-#define CONFIG_SPL_SPI_FLASH_SUPPORT
-#define CONFIG_SPL_SPI_FLASH_MINIMAL
-#define CONFIG_SPL_FLUSH_IMAGE
-#define CONFIG_SPL_TARGET              "u-boot-with-spl.bin"
-#define CONFIG_SPL_LIBGENERIC_SUPPORT
-#define CONFIG_SPL_LIBCOMMON_SUPPORT
-#define CONFIG_SPL_I2C_SUPPORT
-#define CONFIG_SYS_TEXT_BASE           0x11001000
-#define CONFIG_SPL_TEXT_BASE           0xf8f81000
-#define CONFIG_SPL_PAD_TO              0x20000
-#define CONFIG_SPL_MAX_SIZE            (128 * 1024)
-#define CONFIG_SYS_SPI_FLASH_U_BOOT_SIZE       (768 << 10)
-#define CONFIG_SYS_SPI_FLASH_U_BOOT_DST                (0x11000000)
-#define CONFIG_SYS_SPI_FLASH_U_BOOT_START      (0x11000000)
-#define CONFIG_SYS_SPI_FLASH_U_BOOT_OFFS       (128 << 10)
-#define CONFIG_SYS_MPC85XX_NO_RESETVEC
-#define CONFIG_SYS_LDSCRIPT    "arch/powerpc/cpu/mpc85xx/u-boot.lds"
-#define CONFIG_SPL_SPI_BOOT
-#ifdef CONFIG_SPL_BUILD
-#define CONFIG_SPL_COMMON_INIT_DDR
-#endif
-#endif
-
-#ifdef CONFIG_NAND
-#ifdef CONFIG_TPL_BUILD
-#define CONFIG_SPL_NAND_BOOT
-#define CONFIG_SPL_FLUSH_IMAGE
-#define CONFIG_SPL_ENV_SUPPORT
-#define CONFIG_SPL_NAND_INIT
-#define CONFIG_SPL_SERIAL_SUPPORT
-#define CONFIG_SPL_LIBGENERIC_SUPPORT
-#define CONFIG_SPL_LIBCOMMON_SUPPORT
-#define CONFIG_SPL_I2C_SUPPORT
-#define CONFIG_SPL_NAND_SUPPORT
-#define CONFIG_SPL_MPC8XXX_INIT_DDR_SUPPORT
-#define CONFIG_SPL_COMMON_INIT_DDR
-#define CONFIG_SPL_MAX_SIZE            (128 << 10)
-#define CONFIG_SPL_TEXT_BASE           0xf8f81000
-#define CONFIG_SYS_MPC85XX_NO_RESETVEC
-#define CONFIG_SYS_NAND_U_BOOT_SIZE    (832 << 10)
-#define CONFIG_SYS_NAND_U_BOOT_DST     (0x11000000)
-#define CONFIG_SYS_NAND_U_BOOT_START   (0x11000000)
-#define CONFIG_SYS_NAND_U_BOOT_OFFS    ((128 + 128) << 10)
-#elif defined(CONFIG_SPL_BUILD)
-#define CONFIG_SPL_INIT_MINIMAL
-#define CONFIG_SPL_SERIAL_SUPPORT
-#define CONFIG_SPL_NAND_SUPPORT
-#define CONFIG_SPL_FLUSH_IMAGE
-#define CONFIG_SPL_TARGET              "u-boot-with-spl.bin"
-#define CONFIG_SPL_TEXT_BASE           0xff800000
-#define CONFIG_SPL_MAX_SIZE            4096
-#define CONFIG_SYS_NAND_U_BOOT_SIZE    (128 << 10)
-#define CONFIG_SYS_NAND_U_BOOT_DST     0xf8f80000
-#define CONFIG_SYS_NAND_U_BOOT_START   0xf8f80000
-#define CONFIG_SYS_NAND_U_BOOT_OFFS    (128 << 10)
-#endif /* not CONFIG_TPL_BUILD */
-
-#define CONFIG_SPL_PAD_TO              0x20000
-#define CONFIG_TPL_PAD_TO              0x20000
-#define CONFIG_SPL_TARGET              "u-boot-with-spl.bin"
-#define CONFIG_SYS_TEXT_BASE           0x11001000
-#define CONFIG_SYS_LDSCRIPT    "arch/powerpc/cpu/mpc85xx/u-boot-nand.lds"
-#endif
-
-#ifndef CONFIG_SYS_TEXT_BASE
-#define CONFIG_SYS_TEXT_BASE           0xeff40000
-#endif
-
-#ifndef CONFIG_RESET_VECTOR_ADDRESS
-#define CONFIG_RESET_VECTOR_ADDRESS    0xeffffffc
-#endif
-
-#ifndef CONFIG_SYS_MONITOR_BASE
-#ifdef CONFIG_SPL_BUILD
-#define CONFIG_SYS_MONITOR_BASE        CONFIG_SPL_TEXT_BASE
-#else
-#define CONFIG_SYS_MONITOR_BASE        CONFIG_SYS_TEXT_BASE    /* start of monitor */
-#endif
-#endif
-
-/* High Level Configuration Options */
-#define CONFIG_BOOKE           1       /* BOOKE */
-#define CONFIG_E500            1       /* BOOKE e500 family */
-#define CONFIG_FSL_ELBC                1       /* Enable eLBC Support */
-
-#define CONFIG_PCI             1       /* Enable PCI/PCIE */
-#if defined(CONFIG_PCI)
-#define CONFIG_PCIE1           1       /* PCIE controler 1 (slot 1) */
-#define CONFIG_PCIE2           1       /* PCIE controler 2 (slot 2) */
-#define CONFIG_FSL_PCI_INIT    1       /* Use common FSL init code */
-#define CONFIG_PCI_INDIRECT_BRIDGE 1   /* indirect PCI bridge support */
-#define CONFIG_FSL_PCIE_RESET  1       /* need PCIe reset errata */
-#define CONFIG_SYS_PCI_64BIT   1       /* enable 64-bit PCI resources */
-#endif /* #if defined(CONFIG_PCI) */
-#define CONFIG_FSL_LAW         1       /* Use common FSL init code */
-#define CONFIG_TSEC_ENET               /* tsec ethernet support */
-#define CONFIG_ENV_OVERWRITE
-
-#if defined(CONFIG_PCI)
-#define CONFIG_E1000           1       /*  E1000 pci Ethernet card*/
-#endif
-
-#ifndef __ASSEMBLY__
-extern unsigned long get_board_sys_clk(unsigned long dummy);
-#endif
-#define CONFIG_DDR_CLK_FREQ    66666666 /* DDRCLK on P1_P2 RDB */
-#define CONFIG_SYS_CLK_FREQ    get_board_sys_clk(0) /*sysclk for P1_P2 RDB */
-
-#if defined(CONFIG_P2020) || defined(CONFIG_P1020)
-#define CONFIG_MP
-#endif
-
-#define CONFIG_HWCONFIG
-
-/*
- * These can be toggled for performance analysis, otherwise use default.
- */
-#define CONFIG_L2_CACHE                        /* toggle L2 cache */
-#define CONFIG_BTB                     /* toggle branch predition */
-
-#define CONFIG_ADDR_STREAMING          /* toggle addr streaming */
-
-#define CONFIG_ENABLE_36BIT_PHYS       1
-
-#ifdef CONFIG_PHYS_64BIT
-#define CONFIG_ADDR_MAP                        1
-#define CONFIG_SYS_NUM_ADDR_MAP                16      /* number of TLB1 entries */
-#endif
-
-#define CONFIG_SYS_MEMTEST_START       0x00000000      /* memtest works on */
-#define CONFIG_SYS_MEMTEST_END         0x1fffffff
-#define CONFIG_PANIC_HANG      /* do not reset board on panic */
-
-/*
- * Config the L2 Cache as L2 SRAM
-*/
-#if defined(CONFIG_SPL_BUILD)
-#if defined(CONFIG_SDCARD) || defined(CONFIG_SPIFLASH)
-#define CONFIG_SYS_INIT_L2_ADDR                0xf8f80000
-#define CONFIG_SYS_INIT_L2_ADDR_PHYS   CONFIG_SYS_INIT_L2_ADDR
-#define CONFIG_SYS_INIT_L2_END (CONFIG_SYS_INIT_L2_ADDR + CONFIG_SYS_L2_SIZE)
-#define CONFIG_SPL_RELOC_TEXT_BASE     0xf8f81000
-#define CONFIG_SPL_GD_ADDR             (CONFIG_SYS_INIT_L2_ADDR + 112 * 1024)
-#define CONFIG_SPL_RELOC_STACK         (CONFIG_SYS_INIT_L2_ADDR + 116 * 1024)
-#define CONFIG_SPL_RELOC_STACK_SIZE    (32 << 10)
-#define CONFIG_SPL_RELOC_MALLOC_ADDR   (CONFIG_SYS_INIT_L2_ADDR + 148 * 1024)
-#if defined(CONFIG_P2020RDB)
-#define CONFIG_SPL_RELOC_MALLOC_SIZE   (364 << 10)
-#else
-#define CONFIG_SPL_RELOC_MALLOC_SIZE   (108 << 10)
-#endif
-#elif defined(CONFIG_NAND)
-#ifdef CONFIG_TPL_BUILD
-#define CONFIG_SYS_INIT_L2_ADDR                0xf8f80000
-#define CONFIG_SYS_INIT_L2_ADDR_PHYS   CONFIG_SYS_INIT_L2_ADDR
-#define CONFIG_SYS_INIT_L2_END (CONFIG_SYS_INIT_L2_ADDR + CONFIG_SYS_L2_SIZE)
-#define CONFIG_SPL_RELOC_TEXT_BASE     0xf8f81000
-#define CONFIG_SPL_RELOC_STACK         (CONFIG_SYS_INIT_L2_ADDR + 192 * 1024)
-#define CONFIG_SPL_RELOC_MALLOC_ADDR   (CONFIG_SYS_INIT_L2_ADDR + 208 * 1024)
-#define CONFIG_SPL_RELOC_MALLOC_SIZE   (48 << 10)
-#define CONFIG_SPL_GD_ADDR             (CONFIG_SYS_INIT_L2_ADDR + 176 * 1024)
-#else
-#define CONFIG_SYS_INIT_L2_ADDR                0xf8f80000
-#define CONFIG_SYS_INIT_L2_ADDR_PHYS   CONFIG_SYS_INIT_L2_ADDR
-#define CONFIG_SYS_INIT_L2_END (CONFIG_SYS_INIT_L2_ADDR + CONFIG_SYS_L2_SIZE)
-#define CONFIG_SPL_RELOC_TEXT_BASE     (CONFIG_SYS_INIT_L2_END - 0x2000)
-#define CONFIG_SPL_RELOC_STACK         ((CONFIG_SYS_INIT_L2_END - 1) & ~0xF)
-#endif /* CONFIG_TPL_BUILD */
-#endif
-#endif
-
-#ifdef CONFIG_SPL_BUILD
-#define CONFIG_SYS_CCSR_DO_NOT_RELOCATE
-#endif
-
-/* DDR Setup */
-#define CONFIG_SYS_FSL_DDR2
-#undef CONFIG_FSL_DDR_INTERACTIVE
-#undef CONFIG_SPD_EEPROM               /* Use SPD EEPROM for DDR setup */
-
-#define CONFIG_MEM_INIT_VALUE  0xDeadBeef
-
-#if defined(CONFIG_P1011RDB) || defined(CONFIG_P1020RDB)
-/*
- * P1020 and it's derivatives support max 32bit DDR width
- * So Reduce available DDR size
-*/
-#define CONFIG_SYS_SDRAM_SIZE  512
-#else
-#define CONFIG_SYS_SDRAM_SIZE  1024
-#endif
-#define CONFIG_SYS_DDR_SDRAM_BASE      0x00000000
-#define CONFIG_SYS_SDRAM_BASE          CONFIG_SYS_DDR_SDRAM_BASE
-
-#define CONFIG_NUM_DDR_CONTROLLERS     1
-#define CONFIG_DIMM_SLOTS_PER_CTLR     1
-#define CONFIG_CHIP_SELECTS_PER_CTRL   1
-
-#define CONFIG_SYS_DDR_ERR_INT_EN      0x0000000d
-#define CONFIG_SYS_DDR_ERR_DIS         0x00000000
-#define CONFIG_SYS_DDR_SBE             0x00FF0000
-
-/*
- * Memory map
- *
- * 0x0000_0000 0x3fff_ffff     DDR                     1G cacheablen
- * 0x8000_0000  0xbfff_ffff    PCI Express Mem         1G non-cacheable
- * 0xffc0_0000  0xffc3_ffff    PCI IO range            256k non-cacheable
- *
- * Localbus cacheable (TBD)
- * 0xXXXX_XXXX 0xXXXX_XXXX     SRAM                    YZ M Cacheable
- *
- * Localbus non-cacheable
- * 0xef00_0000 0xefff_ffff     FLASH                   16M non-cacheable
- * 0xffa0_0000 0xffaf_ffff     NAND                    1M non-cacheable
- * 0xffb0_0000 0xffbf_ffff     VSC7385 switch          1M non-cacheable
- * 0xffd0_0000 0xffd0_3fff     L1 for stack            16K Cacheable TLB0
- * 0xffe0_0000 0xffef_ffff     CCSR                    1M non-cacheable
- */
-
-/*
- * Local Bus Definitions
- */
-#define CONFIG_SYS_FLASH_BASE          0xef000000      /* start of FLASH 16M */
-
-#ifdef CONFIG_PHYS_64BIT
-#define CONFIG_SYS_FLASH_BASE_PHYS     0xfef000000ull
-#else
-#define CONFIG_SYS_FLASH_BASE_PHYS     CONFIG_SYS_FLASH_BASE
-#endif
-
-#define CONFIG_FLASH_BR_PRELIM (BR_PHYS_ADDR(CONFIG_SYS_FLASH_BASE_PHYS) | \
-                                       BR_PS_16 | BR_V)
-#define CONFIG_FLASH_OR_PRELIM         0xff000ff7
-
-#define CONFIG_SYS_FLASH_BANKS_LIST    {CONFIG_SYS_FLASH_BASE_PHYS}
-#define CONFIG_SYS_FLASH_QUIET_TEST
-#define CONFIG_FLASH_SHOW_PROGRESS 45 /* count down from 45/5: 9..1 */
-
-#define CONFIG_SYS_MAX_FLASH_BANKS     1       /* number of banks */
-#define CONFIG_SYS_MAX_FLASH_SECT      128     /* sectors per device */
-#undef CONFIG_SYS_FLASH_CHECKSUM
-#define CONFIG_SYS_FLASH_ERASE_TOUT    60000   /* Flash Erase Timeout (ms) */
-#define CONFIG_SYS_FLASH_WRITE_TOUT    500     /* Flash Write Timeout (ms) */
-
-#define CONFIG_FLASH_CFI_DRIVER
-#define CONFIG_SYS_FLASH_CFI
-#define CONFIG_SYS_FLASH_EMPTY_INFO
-#define CONFIG_SYS_FLASH_AMD_CHECK_DQ7
-
-#define CONFIG_BOARD_EARLY_INIT_R      /* call board_early_init_r function */
-#define CONFIG_MISC_INIT_R
-#define CONFIG_HWCONFIG
-
-#define CONFIG_SYS_INIT_RAM_LOCK       1
-#define CONFIG_SYS_INIT_RAM_ADDR      0xffd00000       /* stack in RAM */
-#ifdef CONFIG_PHYS_64BIT
-#define CONFIG_SYS_INIT_RAM_ADDR_PHYS_HIGH 0xf
-#define CONFIG_SYS_INIT_RAM_ADDR_PHYS_LOW CONFIG_SYS_INIT_RAM_ADDR
-/* The assembler doesn't like typecast */
-#define CONFIG_SYS_INIT_RAM_ADDR_PHYS \
-       ((CONFIG_SYS_INIT_RAM_ADDR_PHYS_HIGH * 1ull << 32) | \
-         CONFIG_SYS_INIT_RAM_ADDR_PHYS_LOW)
-#else
-#define CONFIG_SYS_INIT_RAM_ADDR_PHYS  CONFIG_SYS_INIT_RAM_ADDR /* Initial L1 address */
-#define CONFIG_SYS_INIT_RAM_ADDR_PHYS_HIGH 0
-#define CONFIG_SYS_INIT_RAM_ADDR_PHYS_LOW CONFIG_SYS_INIT_RAM_ADDR_PHYS
-#endif
-#define CONFIG_SYS_INIT_RAM_SIZE       0x00004000      /* Size of used area in RAM */
-
-#define CONFIG_SYS_GBL_DATA_OFFSET     (CONFIG_SYS_INIT_RAM_SIZE \
-                                               - GENERATED_GBL_DATA_SIZE)
-#define CONFIG_SYS_INIT_SP_OFFSET      CONFIG_SYS_GBL_DATA_OFFSET
-
-#define CONFIG_SYS_MONITOR_LEN         (768 * 1024)
-#define CONFIG_SYS_MALLOC_LEN          (1024 * 1024)   /* Reserved for malloc*/
-
-#define CONFIG_SYS_NAND_BASE           0xff800000
-#ifdef CONFIG_PHYS_64BIT
-#define CONFIG_SYS_NAND_BASE_PHYS      0xfff800000ull
-#else
-#define CONFIG_SYS_NAND_BASE_PHYS      CONFIG_SYS_NAND_BASE
-#endif
-
-#define CONFIG_CMD_NAND
-#define CONFIG_SYS_NAND_BASE_LIST      {CONFIG_SYS_NAND_BASE}
-#define CONFIG_SYS_MAX_NAND_DEVICE     1
-#define CONFIG_MTD_NAND_VERIFY_WRITE
-#define CONFIG_NAND_FSL_ELBC           1
-#define CONFIG_SYS_NAND_BLOCK_SIZE     (16 * 1024)
-
-/* NAND flash config */
-#define CONFIG_SYS_NAND_BR_PRELIM (BR_PHYS_ADDR(CONFIG_SYS_NAND_BASE_PHYS) \
-                               | (2<<BR_DECC_SHIFT)    /* Use HW ECC */ \
-                               | BR_PS_8       /* Port Size = 8 bit */ \
-                               | BR_MS_FCM             /* MSEL = FCM */ \
-                               | BR_V)                 /* valid */
-
-#define CONFIG_SYS_NAND_OR_PRELIM      (0xFFF80000     /* length 32K */ \
-                               | OR_FCM_CSCT \
-                               | OR_FCM_CST \
-                               | OR_FCM_CHT \
-                               | OR_FCM_SCY_1 \
-                               | OR_FCM_TRLX \
-                               | OR_FCM_EHTR)
-
-#ifdef CONFIG_NAND
-#define CONFIG_SYS_BR0_PRELIM  CONFIG_SYS_NAND_BR_PRELIM /* NAND Base Address */
-#define CONFIG_SYS_OR0_PRELIM  CONFIG_SYS_NAND_OR_PRELIM /* NAND Options */
-#define CONFIG_SYS_BR1_PRELIM  CONFIG_FLASH_BR_PRELIM  /* NOR Base Address */
-#define CONFIG_SYS_OR1_PRELIM  CONFIG_FLASH_OR_PRELIM  /* NOR Options */
-#else
-#define CONFIG_SYS_BR0_PRELIM  CONFIG_FLASH_BR_PRELIM  /* NOR Base Address */
-#define CONFIG_SYS_OR0_PRELIM  CONFIG_FLASH_OR_PRELIM  /* NOR Options */
-#define CONFIG_SYS_BR1_PRELIM  CONFIG_SYS_NAND_BR_PRELIM /* NAND Base Address */
-#define CONFIG_SYS_OR1_PRELIM  CONFIG_SYS_NAND_OR_PRELIM /* NAND Options */
-#endif
-
-#define CONFIG_SYS_VSC7385_BASE        0xffb00000
-
-#ifdef CONFIG_PHYS_64BIT
-#define CONFIG_SYS_VSC7385_BASE_PHYS   0xfffb00000ull
-#else
-#define CONFIG_SYS_VSC7385_BASE_PHYS   CONFIG_SYS_VSC7385_BASE
-#endif
-
-#define CONFIG_SYS_BR2_PRELIM  (BR_PHYS_ADDR(CONFIG_SYS_VSC7385_BASE) \
-                                                       | BR_PS_8 | BR_V)
-#define CONFIG_SYS_OR2_PRELIM  (OR_AM_128KB | OR_GPCM_CSNT | OR_GPCM_XACS | \
-                               OR_GPCM_SCY_15 | OR_GPCM_SETA | OR_GPCM_TRLX | \
-                               OR_GPCM_EHTR | OR_GPCM_EAD)
-
-/* Serial Port - controlled on board with jumper J8
- * open - index 2
- * shorted - index 1
- */
-#define CONFIG_CONS_INDEX      1
-#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)
-#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_INIT_MINIMAL)
-#define CONFIG_NS16550_MIN_FUNCTIONS
-#endif
-
-#define CONFIG_SYS_CONSOLE_IS_IN_ENV   /* determine from environment */
-
-#define CONFIG_SYS_BAUDRATE_TABLE      \
-       {300, 600, 1200, 2400, 4800, 9600, 19200, 38400,115200}
-
-#define CONFIG_SYS_NS16550_COM1        (CONFIG_SYS_CCSRBAR+0x4500)
-#define CONFIG_SYS_NS16550_COM2        (CONFIG_SYS_CCSRBAR+0x4600)
-
-/* Use the HUSH parser */
-#define CONFIG_SYS_HUSH_PARSER
-
-/*
- * Pass open firmware flat tree
- */
-#define CONFIG_OF_LIBFDT               1
-#define CONFIG_OF_BOARD_SETUP          1
-#define CONFIG_OF_STDOUT_VIA_ALIAS     1
-
-/* new uImage format support */
-#define CONFIG_FIT             1
-#define CONFIG_FIT_VERBOSE     1 /* enable fit_format_{error,warning}() */
-
-/* I2C */
-#define CONFIG_SYS_I2C
-#define CONFIG_SYS_I2C_FSL
-#define CONFIG_SYS_FSL_I2C_OFFSET      0x3000
-#define CONFIG_SYS_FSL_I2C_SPEED       400000
-#define CONFIG_SYS_FSL_I2C_SLAVE       0x7F
-#define CONFIG_SYS_FSL_I2C2_OFFSET     0x3100
-#define CONFIG_SYS_FSL_I2C2_SPEED      400000
-#define CONFIG_SYS_FSL_I2C2_SLAVE      0x7F
-#define CONFIG_SYS_I2C_NOPROBES                { {0, 0x29} }
-
-/*
- * I2C2 EEPROM
- */
-#define CONFIG_ID_EEPROM
-#ifdef CONFIG_ID_EEPROM
-#define CONFIG_SYS_I2C_EEPROM_NXID
-#endif
-#define CONFIG_SYS_I2C_EEPROM_ADDR     0x52
-#define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1
-#define CONFIG_SYS_EEPROM_BUS_NUM      1
-
-#define CONFIG_SYS_I2C_PCA9557_ADDR    0x18
-
-#define CONFIG_RTC_DS1337
-#define CONFIG_SYS_RTC_DS1337_NOOSC
-#define CONFIG_SYS_I2C_RTC_ADDR                0x68
-
-/* eSPI - Enhanced SPI */
-#define CONFIG_FSL_ESPI
-#define CONFIG_SPI_FLASH
-#define CONFIG_SPI_FLASH_SPANSION
-#define CONFIG_CMD_SF
-#define CONFIG_SF_DEFAULT_SPEED                10000000
-#define CONFIG_SF_DEFAULT_MODE         SPI_MODE_0
-
-/*
- * General PCI
- * Memory space is mapped 1-1, but I/O space must start from 0.
- */
-
-#if defined(CONFIG_PCI)
-/* controller 2, Slot 2, tgtid 2, Base address 9000 */
-#define CONFIG_SYS_PCIE2_NAME          "Slot 1"
-#define CONFIG_SYS_PCIE2_MEM_VIRT      0xa0000000
-#ifdef CONFIG_PHYS_64BIT
-#define CONFIG_SYS_PCIE2_MEM_BUS       0xc0000000
-#define CONFIG_SYS_PCIE2_MEM_PHYS      0xc20000000ull
-#else
-#define CONFIG_SYS_PCIE2_MEM_BUS       0xa0000000
-#define CONFIG_SYS_PCIE2_MEM_PHYS      0xa0000000
-#endif
-#define CONFIG_SYS_PCIE2_MEM_SIZE      0x20000000      /* 512M */
-#define CONFIG_SYS_PCIE2_IO_VIRT       0xffc10000
-#define CONFIG_SYS_PCIE2_IO_BUS                0x00000000
-#ifdef CONFIG_PHYS_64BIT
-#define CONFIG_SYS_PCIE2_IO_PHYS       0xfffc10000ull
-#else
-#define CONFIG_SYS_PCIE2_IO_PHYS       0xffc10000
-#endif
-#define CONFIG_SYS_PCIE2_IO_SIZE       0x00010000      /* 64k */
-
-/* controller 1, Slot 1, tgtid 1, Base address a000 */
-#define CONFIG_SYS_PCIE1_NAME          "Slot 2"
-#define CONFIG_SYS_PCIE1_MEM_VIRT      0x80000000
-#ifdef CONFIG_PHYS_64BIT
-#define CONFIG_SYS_PCIE1_MEM_BUS       0x80000000
-#define CONFIG_SYS_PCIE1_MEM_PHYS      0xc00000000ull
-#else
-#define CONFIG_SYS_PCIE1_MEM_BUS       0x80000000
-#define CONFIG_SYS_PCIE1_MEM_PHYS      0x80000000
-#endif
-#define CONFIG_SYS_PCIE1_MEM_SIZE      0x20000000      /* 512M */
-#define CONFIG_SYS_PCIE1_IO_VIRT       0xffc00000
-#define CONFIG_SYS_PCIE1_IO_BUS                0x00000000
-#ifdef CONFIG_PHYS_64BIT
-#define CONFIG_SYS_PCIE1_IO_PHYS       0xfffc00000ull
-#else
-#define CONFIG_SYS_PCIE1_IO_PHYS       0xffc00000
-#endif
-#define CONFIG_SYS_PCIE1_IO_SIZE       0x00010000      /* 64k */
-
-#define CONFIG_PCI_PNP                 /* do pci plug-and-play */
-
-#undef CONFIG_EEPRO100
-#undef CONFIG_TULIP
-#undef CONFIG_RTL8139
-
-#ifdef CONFIG_RTL8139
-/* This macro is used by RTL8139 but not defined in PPC architecture */
-#define KSEG1ADDR(x)           (x)
-#define _IO_BASE       0x00000000
-#endif
-
-
-#define CONFIG_PCI_SCAN_SHOW           /* show pci devices on startup */
-#define CONFIG_DOS_PARTITION
-
-#endif /* CONFIG_PCI */
-
-
-#if defined(CONFIG_TSEC_ENET)
-#define CONFIG_MII             1       /* MII PHY management */
-#define CONFIG_MII_DEFAULT_TSEC        1       /* Allow unregistered phys */
-#define CONFIG_TSEC1   1
-#define CONFIG_TSEC1_NAME      "eTSEC1"
-#define CONFIG_TSEC2   1
-#define CONFIG_TSEC2_NAME      "eTSEC2"
-#define CONFIG_TSEC3   1
-#define CONFIG_TSEC3_NAME      "eTSEC3"
-
-#define TSEC1_PHY_ADDR         2
-#define TSEC2_PHY_ADDR         0
-#define TSEC3_PHY_ADDR         1
-
-#define CONFIG_VSC7385_ENET
-
-#define TSEC1_FLAGS            (TSEC_GIGABIT | TSEC_REDUCED)
-#define TSEC2_FLAGS            (TSEC_GIGABIT | TSEC_REDUCED)
-#define TSEC3_FLAGS            (TSEC_GIGABIT | TSEC_REDUCED)
-
-#define TSEC1_PHYIDX           0
-#define TSEC2_PHYIDX           0
-#define TSEC3_PHYIDX           0
-
-/* Vitesse 7385 */
-
-#ifdef CONFIG_VSC7385_ENET
-/* The size of the VSC7385 firmware image */
-#define CONFIG_VSC7385_IMAGE_SIZE      8192
-#endif
-
-#define CONFIG_ETHPRIME                "eTSEC1"
-
-#define CONFIG_PHY_GIGE                1       /* Include GbE speed/duplex detection */
-
-#endif /* CONFIG_TSEC_ENET */
-
-/*
- * Environment
- */
-#ifdef CONFIG_SPIFLASH
-#define CONFIG_ENV_IS_IN_SPI_FLASH
-#define CONFIG_ENV_SPI_BUS     0
-#define CONFIG_ENV_SPI_CS      0
-#define CONFIG_ENV_SPI_MAX_HZ  10000000
-#define CONFIG_ENV_SPI_MODE    0
-#define CONFIG_ENV_SIZE                0x2000  /* 8KB */
-#define CONFIG_ENV_OFFSET      0x100000        /* 1MB */
-#define CONFIG_ENV_SECT_SIZE   0x10000
-#define CONFIG_ENV_ADDR                (CONFIG_SYS_INIT_L2_ADDR + (160 << 10))
-#elif defined(CONFIG_SDCARD)
-#define CONFIG_ENV_IS_IN_MMC
-#define CONFIG_FSL_FIXED_MMC_LOCATION
-#define CONFIG_ENV_SIZE                0x2000
-#define CONFIG_SYS_MMC_ENV_DEV 0
-#define CONFIG_ENV_OFFSET      (512 * 0x800)
-#define CONFIG_ENV_ADDR                (CONFIG_SYS_INIT_L2_ADDR + (160 << 10))
-#elif defined(CONFIG_NAND)
-#ifdef CONFIG_TPL_BUILD
-#define CONFIG_ENV_SIZE                0x2000
-#define CONFIG_ENV_ADDR                (CONFIG_SYS_INIT_L2_ADDR + (160 << 10))
-#else
-#define CONFIG_ENV_SIZE                CONFIG_SYS_NAND_BLOCK_SIZE
-#endif
-#define CONFIG_ENV_IS_IN_NAND
-#define CONFIG_ENV_OFFSET      (1024 * 1024)
-#define CONFIG_ENV_RANGE       (3 * CONFIG_ENV_SIZE)
-#elif defined(CONFIG_SYS_RAMBOOT)
-#define CONFIG_ENV_IS_NOWHERE  /* Store ENV in memory only */
-#define CONFIG_ENV_ADDR                (CONFIG_SYS_MONITOR_BASE - 0x1000)
-#define CONFIG_ENV_SIZE                0x2000
-#else
-#define CONFIG_ENV_IS_IN_FLASH
-#define CONFIG_ENV_ADDR        (CONFIG_SYS_MONITOR_BASE - CONFIG_ENV_SECT_SIZE)
-#define CONFIG_ENV_SIZE                0x2000
-#define CONFIG_ENV_SECT_SIZE   0x20000 /* 128K (one sector) */
-#endif
-
-
-#define CONFIG_LOADS_ECHO      1       /* echo on for serial download */
-#define CONFIG_SYS_LOADS_BAUD_CHANGE   1       /* allow baudrate change */
-
-/*
- * Command line configuration.
- */
-#include <config_cmd_default.h>
-
-#define CONFIG_CMD_DATE
-#define CONFIG_CMD_ELF
-#define CONFIG_CMD_I2C
-#define CONFIG_CMD_IRQ
-#define CONFIG_CMD_MII
-#define CONFIG_CMD_PING
-#define CONFIG_CMD_SETEXPR
-#define CONFIG_CMD_REGINFO
-
-#if defined(CONFIG_PCI)
-#define CONFIG_CMD_NET
-#define CONFIG_CMD_PCI
-#endif
-
-#undef CONFIG_WATCHDOG                 /* watchdog disabled */
-
-#define CONFIG_MMC     1
-
-#ifdef CONFIG_MMC
-#define CONFIG_BOARD_EARLY_INIT_F      1       /* Call board_pre_init */
-#define CONFIG_CMD_MMC
-#define CONFIG_DOS_PARTITION
-#define CONFIG_FSL_ESDHC
-#define CONFIG_GENERIC_MMC
-#define CONFIG_SYS_FSL_ESDHC_ADDR      CONFIG_SYS_MPC85xx_ESDHC_ADDR
-#ifdef CONFIG_P2020
-#define CONFIG_SYS_FSL_ESDHC_USE_PIO /* P2020 eSDHC DMA is not functional*/
-#endif
-#endif
-
-#define CONFIG_HAS_FSL_DR_USB
-
-#if defined(CONFIG_HAS_FSL_DR_USB)
-#define CONFIG_USB_EHCI
-
-#ifdef CONFIG_USB_EHCI
-#define CONFIG_CMD_USB
-#define CONFIG_EHCI_HCD_INIT_AFTER_RESET
-#define CONFIG_USB_EHCI_FSL
-#define CONFIG_USB_STORAGE
-#endif
-#endif
-
-#if defined(CONFIG_MMC) || defined(CONFIG_USB_EHCI)
-#define CONFIG_CMD_EXT2
-#define CONFIG_CMD_FAT
-#define CONFIG_DOS_PARTITION
-#endif
-
-/*
- * Miscellaneous configurable options
- */
-#define CONFIG_SYS_LONGHELP                    /* undef to save memory */
-#define CONFIG_CMDLINE_EDITING                 /* Command-line editing */
-#define CONFIG_AUTO_COMPLETE                   /* add autocompletion support */
-#define CONFIG_SYS_LOAD_ADDR   0x2000000       /* default load address */
-#if defined(CONFIG_CMD_KGDB)
-#define CONFIG_SYS_CBSIZE      1024            /* Console I/O Buffer Size */
-#else
-#define CONFIG_SYS_CBSIZE      256             /* Console I/O Buffer Size */
-#endif
-#define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE+sizeof(CONFIG_SYS_PROMPT)+16)
-                                               /* Print Buffer Size */
-#define CONFIG_SYS_MAXARGS     16              /* max number of command args */
-#define CONFIG_SYS_BARGSIZE    CONFIG_SYS_CBSIZE/* Boot Argument Buffer Size */
-
-/*
- * For booting Linux, the board info and command line data
- * have to be in the first 64 MB of memory, since this is
- * the maximum mapped by the Linux kernel during initialization.
- */
-#define CONFIG_SYS_BOOTMAPSZ   (64 << 20)/* Initial Memory map for Linux*/
-#define CONFIG_SYS_BOOTM_LEN   (64 << 20)      /* Increase max gunzip size */
-
-#if defined(CONFIG_CMD_KGDB)
-#define CONFIG_KGDB_BAUDRATE   230400  /* speed to run kgdb serial port */
-#endif
-
-/*
- * Environment Configuration
- */
-
-#if defined(CONFIG_TSEC_ENET)
-#define CONFIG_HAS_ETH0
-#define CONFIG_HAS_ETH1
-#define CONFIG_HAS_ETH2
-#endif
-
-#define CONFIG_HOSTNAME                P2020RDB
-#define CONFIG_ROOTPATH                "/opt/nfsroot"
-#define CONFIG_BOOTFILE                "uImage"
-#define CONFIG_UBOOTPATH       u-boot.bin/* U-Boot image on TFTP server */
-
-/* default location for tftp and bootm */
-#define CONFIG_LOADADDR                1000000
-
-#define CONFIG_BOOTDELAY 10    /* -1 disables auto-boot */
-#undef  CONFIG_BOOTARGS                /* the boot command will set bootargs */
-
-#define CONFIG_BAUDRATE        115200
-
-#define        CONFIG_EXTRA_ENV_SETTINGS                               \
-       "netdev=eth0\0"                                         \
-       "uboot=" __stringify(CONFIG_UBOOTPATH) "\0"             \
-       "loadaddr=1000000\0"                                    \
-       "tftpflash=tftpboot $loadaddr $uboot; "                 \
-               "protect off " __stringify(CONFIG_SYS_TEXT_BASE)        \
-                       " +$filesize; " \
-               "erase " __stringify(CONFIG_SYS_TEXT_BASE)              \
-                       " +$filesize; " \
-               "cp.b $loadaddr " __stringify(CONFIG_SYS_TEXT_BASE)     \
-                       " $filesize; "  \
-               "protect on " __stringify(CONFIG_SYS_TEXT_BASE)         \
-                       " +$filesize; " \
-               "cmp.b $loadaddr " __stringify(CONFIG_SYS_TEXT_BASE)    \
-                       " $filesize\0"  \
-       "consoledev=ttyS0\0"                            \
-       "ramdiskaddr=2000000\0"                 \
-       "ramdiskfile=rootfs.ext2.gz.uboot\0"            \
-       "fdtaddr=c00000\0"                              \
-       "fdtfile=p2020rdb.dtb\0"                \
-       "bdev=sda1\0"   \
-       "jffs2nor=mtdblock3\0"  \
-       "norbootaddr=ef080000\0"        \
-       "norfdtaddr=ef040000\0" \
-       "jffs2nand=mtdblock9\0" \
-       "nandbootaddr=100000\0" \
-       "nandfdtaddr=80000\0"           \
-       "nandimgsize=400000\0"          \
-       "nandfdtsize=80000\0"           \
-       "hwconfig=usb1:dr_mode=host,phy_type=ulpi\0"    \
-       "vscfw_addr=ef000000\0" \
-       "othbootargs=ramdisk_size=600000\0" \
-       "usbfatboot=setenv bootargs root=/dev/ram rw "  \
-       "console=$consoledev,$baudrate $othbootargs; "  \
-       "usb start;"                    \
-       "fatload usb 0:2 $loadaddr $bootfile;"          \
-       "fatload usb 0:2 $fdtaddr $fdtfile;"    \
-       "fatload usb 0:2 $ramdiskaddr $ramdiskfile;"    \
-       "bootm $loadaddr $ramdiskaddr $fdtaddr\0"               \
-       "usbext2boot=setenv bootargs root=/dev/ram rw " \
-       "console=$consoledev,$baudrate $othbootargs; "  \
-       "usb start;"                    \
-       "ext2load usb 0:4 $loadaddr $bootfile;"         \
-       "ext2load usb 0:4 $fdtaddr $fdtfile;"   \
-       "ext2load usb 0:4 $ramdiskaddr $ramdiskfile;"   \
-       "bootm $loadaddr $ramdiskaddr $fdtaddr\0"               \
-       "norboot=setenv bootargs root=/dev/$jffs2nor rw "       \
-       "console=$consoledev,$baudrate rootfstype=jffs2 $othbootargs;"  \
-       "bootm $norbootaddr - $norfdtaddr\0"            \
-       "nandboot=setenv bootargs root=/dev/$jffs2nand rw rootfstype=jffs2 " \
-       "console=$consoledev,$baudrate $othbootargs;"   \
-       "nand read 2000000 $nandbootaddr $nandimgsize;" \
-       "nand read 3000000 $nandfdtaddr $nandfdtsize;"  \
-       "bootm 2000000 - 3000000;\0"
-
-#define CONFIG_NFSBOOTCOMMAND          \
-       "setenv bootargs root=/dev/nfs rw "     \
-       "nfsroot=$serverip:$rootpath "          \
-       "ip=$ipaddr:$serverip:$gatewayip:$netmask:$hostname:$netdev:off " \
-       "console=$consoledev,$baudrate $othbootargs;"   \
-       "tftp $loadaddr $bootfile;"             \
-       "tftp $fdtaddr $fdtfile;"               \
-       "bootm $loadaddr - $fdtaddr"
-
-#define CONFIG_HDBOOT                  \
-       "setenv bootargs root=/dev/$bdev rw rootdelay=30 "      \
-       "console=$consoledev,$baudrate $othbootargs;"   \
-       "usb start;"                    \
-       "ext2load usb 0:1 $loadaddr /boot/$bootfile;"           \
-       "ext2load usb 0:1 $fdtaddr /boot/$fdtfile;"     \
-       "bootm $loadaddr - $fdtaddr"
-
-#define CONFIG_RAMBOOTCOMMAND          \
-       "setenv bootargs root=/dev/ram rw "     \
-       "console=$consoledev,$baudrate $othbootargs; "  \
-       "tftp $ramdiskaddr $ramdiskfile;"       \
-       "tftp $loadaddr $bootfile;"             \
-       "tftp $fdtaddr $fdtfile;"               \
-       "bootm $loadaddr $ramdiskaddr $fdtaddr"
-
-#define CONFIG_BOOTCOMMAND             CONFIG_HDBOOT
-
-#endif /* __CONFIG_H */
diff --git a/include/configs/P2020COME.h b/include/configs/P2020COME.h
deleted file mode 100644 (file)
index d414b84..0000000
+++ /dev/null
@@ -1,547 +0,0 @@
-/*
- * Copyright 2009-2010,2012 Freescale Semiconductor, Inc.
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#ifndef __CONFIG_H
-#define __CONFIG_H
-
-/* The P2020COME board is only booted via the Freescale On-Chip ROM */
-#define CONFIG_SYS_RAMBOOT
-#define CONFIG_SYS_EXTRA_ENV_RELOC
-
-#define CONFIG_SYS_TEXT_BASE           0xf8f80000
-#define CONFIG_RESET_VECTOR_ADDRESS    0xf8fffffc
-
-#ifdef CONFIG_SDCARD
-#define CONFIG_RAMBOOT_SDCARD          1
-#endif
-
-#ifdef CONFIG_SPIFLASH
-#define CONFIG_RAMBOOT_SPIFLASH                1
-#endif
-
-#ifndef CONFIG_SYS_MONITOR_BASE
-#define CONFIG_SYS_MONITOR_BASE        CONFIG_SYS_TEXT_BASE    /* start of monitor */
-#endif
-
-/* High Level Configuration Options */
-#define CONFIG_BOOKE           1       /* BOOKE */
-#define CONFIG_E500            1       /* BOOKE e500 family */
-#define CONFIG_P2020           1
-#define CONFIG_P2020COME       1
-#define CONFIG_FSL_ELBC                1       /* Enable eLBC Support */
-#define CONFIG_MP
-
-#define CONFIG_PCI             1       /* Enable PCI/PCIE */
-#if defined(CONFIG_PCI)
-#define CONFIG_PCIE1           1       /* PCIE controller 1 (slot 1) */
-#define CONFIG_PCIE2           1       /* PCIE controller 2 (slot 2) */
-#define CONFIG_PCIE3           1       /* PCIE controller 3 (slot 3) */
-
-#define CONFIG_FSL_PCI_INIT    1       /* Use common FSL init code */
-#define CONFIG_PCI_INDIRECT_BRIDGE 1   /* indirect PCI bridge support */
-#define CONFIG_FSL_PCIE_RESET  1       /* need PCIe reset errata */
-#define CONFIG_SYS_PCI_64BIT   1       /* enable 64-bit PCI resources */
-#endif /* #if defined(CONFIG_PCI) */
-#define CONFIG_FSL_LAW         1       /* Use common FSL init code */
-#define CONFIG_TSEC_ENET               /* tsec ethernet support */
-#define CONFIG_ENV_OVERWRITE
-
-#if defined(CONFIG_PCI)
-#define CONFIG_E1000           1       /* E1000 pci Ethernet card */
-#endif
-
-#ifndef __ASSEMBLY__
-extern unsigned long get_board_ddr_clk(unsigned long dummy);
-extern unsigned long get_board_sys_clk(unsigned long dummy);
-#endif
-
-/*
- * For P2020COME DDRCLK and SYSCLK are from the same oscillator
- * For DA phase the SYSCLK is 66MHz
- * For EA phase the SYSCLK is 100MHz
- */
-#define CONFIG_DDR_CLK_FREQ    get_board_ddr_clk(0)
-#define CONFIG_SYS_CLK_FREQ    get_board_sys_clk(0)
-
-#define CONFIG_HWCONFIG
-
-/*
- * These can be toggled for performance analysis, otherwise use default.
- */
-#define CONFIG_L2_CACHE                        /* toggle L2 cache */
-#define CONFIG_BTB                     /* toggle branch prediction */
-
-#define CONFIG_ADDR_STREAMING          /* toggle addr streaming */
-
-#define CONFIG_ENABLE_36BIT_PHYS       1
-
-#ifdef CONFIG_PHYS_64BIT
-#define CONFIG_ADDR_MAP                        1
-#define CONFIG_SYS_NUM_ADDR_MAP                16      /* number of TLB1 entries */
-#endif
-
-#define CONFIG_SYS_MEMTEST_START       0x00000000      /* memtest works on */
-#define CONFIG_SYS_MEMTEST_END         0x1fffffff
-#define CONFIG_PANIC_HANG      /* do not reset board on panic */
-
- /*
-  * Config the L2 Cache as L2 SRAM
-  */
-#define CONFIG_SYS_INIT_L2_ADDR                0xf8f80000
-#ifdef CONFIG_PHYS_64BIT
-#define CONFIG_SYS_INIT_L2_ADDR_PHYS   0xff8f80000ull
-#else
-#define CONFIG_SYS_INIT_L2_ADDR_PHYS   CONFIG_SYS_INIT_L2_ADDR
-#endif
-#define CONFIG_SYS_L2_SIZE             (512 << 10)
-#define CONFIG_SYS_INIT_L2_END         (CONFIG_SYS_INIT_L2_ADDR \
-                                       + CONFIG_SYS_L2_SIZE)
-
-#define CONFIG_SYS_CCSRBAR             0xffe00000
-#define CONFIG_SYS_CCSRBAR_PHYS_LOW    CONFIG_SYS_CCSRBAR
-
-/* DDR Setup */
-#define CONFIG_SYS_FSL_DDR3
-#define CONFIG_SPD_EEPROM              /* Use SPD EEPROM for DDR setup */
-#define CONFIG_DDR_SPD
-
-#define CONFIG_DDR_ECC
-#define CONFIG_ECC_INIT_VIA_DDRCONTROLLER
-#define CONFIG_MEM_INIT_VALUE          0xdeadbeef
-
-#define CONFIG_SYS_SDRAM_SIZE          2048ULL /* DDR size on P2020COME */
-#define CONFIG_SYS_DDR_SDRAM_BASE      0x00000000
-#define CONFIG_SYS_SDRAM_BASE          CONFIG_SYS_DDR_SDRAM_BASE
-
-#define CONFIG_NUM_DDR_CONTROLLERS     1
-#define CONFIG_DIMM_SLOTS_PER_CTLR     1
-#define CONFIG_CHIP_SELECTS_PER_CTRL   2
-
-#define CONFIG_SYS_DDR_ERR_INT_EN      0x0000000d
-#define CONFIG_SYS_DDR_ERR_DIS         0x00000000
-#define CONFIG_SYS_DDR_SBE             0x00ff0000
-
-#define CONFIG_SYS_SPD_BUS_NUM         1
-#define SPD_EEPROM_ADDRESS             0x53
-
-/*
- * Memory map
- *
- * 0x0000_0000 0x7fff_ffff     DDR3                    2G Cacheable
- * 0x8000_0000 0x9fff_ffff     PCI Express 3 Mem       1G non-cacheable
- * 0xa000_0000 0xbfff_ffff     PCI Express 2 Mem       1G non-cacheable
- * 0xc000_0000 0xdfff_ffff     PCI Express 1 Mem       1G non-cacheable
- * 0xffc1_0000 0xffc1_ffff     PCI Express 3 IO        64K non-cacheable
- * 0xffc2_0000 0xffc2_ffff     PCI Express 2 IO        64K non-cacheable
- * 0xffc3_0000 0xffc3_ffff     PCI Express 1 IO        64K non-cacheable
- *
- * 0xffd0_0000 0xffd0_3fff     L1 for stack            16K Cacheable TLB0
- * 0xffe0_0000 0xffef_ffff     CCSR                    1M non-cacheable
- */
-
-/*
- * Local Bus Definitions
- */
-
-/* There is no NOR Flash on P2020COME */
-#define CONFIG_SYS_NO_FLASH
-
-#define CONFIG_BOARD_EARLY_INIT_R      /* call board_early_init_r function */
-#define CONFIG_HWCONFIG
-
-#define CONFIG_SYS_INIT_RAM_LOCK       1
-#define CONFIG_SYS_INIT_RAM_ADDR       0xffd00000      /* stack in RAM */
-#ifdef CONFIG_PHYS_64BIT
-#define CONFIG_SYS_INIT_RAM_ADDR_PHYS_HIGH     0xf
-#define CONFIG_SYS_INIT_RAM_ADDR_PHYS_LOW      CONFIG_SYS_INIT_RAM_ADDR
-/* the assembler doesn't like typecast */
-#define CONFIG_SYS_INIT_RAM_ADDR_PHYS \
-       ((CONFIG_SYS_INIT_RAM_ADDR_PHYS_HIGH * 1ull << 32) | \
-         CONFIG_SYS_INIT_RAM_ADDR_PHYS_LOW)
-#else
-#define CONFIG_SYS_INIT_RAM_ADDR_PHYS  CONFIG_SYS_INIT_RAM_ADDR
-#define CONFIG_SYS_INIT_RAM_ADDR_PHYS_HIGH 0
-#define CONFIG_SYS_INIT_RAM_ADDR_PHYS_LOW CONFIG_SYS_INIT_RAM_ADDR_PHYS
-#endif
-#define CONFIG_SYS_INIT_RAM_SIZE       0x00004000
-
-#define CONFIG_SYS_GBL_DATA_OFFSET     (CONFIG_SYS_INIT_RAM_SIZE \
-                                               - GENERATED_GBL_DATA_SIZE)
-#define CONFIG_SYS_INIT_SP_OFFSET      CONFIG_SYS_GBL_DATA_OFFSET
-
-#define CONFIG_SYS_MONITOR_LEN         (256 * 1024)
-#define CONFIG_SYS_MALLOC_LEN          (1024 * 1024)
-
-/* Serial Port - controlled on board with jumper J8
- * open - index 2
- * shorted - index 1
- */
-#define CONFIG_CONS_INDEX              1
-#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_CONSOLE_IS_IN_ENV   /* determine from environment */
-
-#define CONFIG_SYS_BAUDRATE_TABLE   \
-       {300, 600, 1200, 2400, 4800, 9600, 19200, 38400, 115200}
-
-#define CONFIG_SYS_NS16550_COM1        (CONFIG_SYS_CCSRBAR+0x4500)
-#define CONFIG_SYS_NS16550_COM2        (CONFIG_SYS_CCSRBAR+0x4600)
-
-/* Use the HUSH parser */
-#define CONFIG_SYS_HUSH_PARSER
-
-/*
- * Pass open firmware flat tree
- */
-#define CONFIG_OF_LIBFDT               1
-#define CONFIG_OF_BOARD_SETUP          1
-#define CONFIG_OF_STDOUT_VIA_ALIAS     1
-
-/* new uImage format support */
-#define CONFIG_FIT                     1
-#define CONFIG_FIT_VERBOSE             1
-
-/* I2C */
-#define CONFIG_SYS_I2C
-#define CONFIG_SYS_I2C_FSL
-#define CONFIG_SYS_FSL_I2C_SPEED       400000
-#define CONFIG_SYS_FSL_I2C_SLAVE       0x7F
-#define CONFIG_SYS_FSL_I2C_OFFSET      0x3000
-#define CONFIG_SYS_FSL_I2C2_SPEED      400000
-#define CONFIG_SYS_FSL_I2C2_SLAVE      0x7F
-#define CONFIG_SYS_FSL_I2C2_OFFSET     0x3100
-#define CONFIG_SYS_I2C_NOPROBES                { {0, 0x29} }
-
-/*
- * I2C2 EEPROM
- */
-#define CONFIG_ID_EEPROM
-#ifdef CONFIG_ID_EEPROM
-#define CONFIG_SYS_I2C_EEPROM_NXID
-#endif
-#define CONFIG_SYS_I2C_EEPROM_ADDR     0x50
-#define CONFIG_SYS_I2C_EEPROM_ADDR2    0x18
-#define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1
-#define CONFIG_SYS_EEPROM_BUS_NUM      0
-#define CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS  10 /* and takes up to 10 msec */
-
-/*
- * eSPI - Enhanced SPI
- */
-#define CONFIG_FSL_ESPI
-#define CONFIG_SPI_FLASH
-#define CONFIG_SPI_FLASH_STMICRO
-#define CONFIG_CMD_SF
-#define CONFIG_SF_DEFAULT_SPEED                10000000
-#define CONFIG_SF_DEFAULT_MODE         SPI_MODE_0
-
-/*
- * General PCI
- * Memory space is mapped 1-1, but I/O space must start from 0.
- */
-#if defined(CONFIG_PCI)
-
-/* controller 3, Slot 3, tgtid 3, Base address 8000 */
-#define CONFIG_SYS_PCIE3_MEM_VIRT      0x80000000
-#define CONFIG_SYS_PCIE3_MEM_BUS       0x80000000
-#define CONFIG_SYS_PCIE3_MEM_PHYS      0x80000000
-#define CONFIG_SYS_PCIE3_MEM_SIZE      0x20000000  /* 512M */
-#define CONFIG_SYS_PCIE3_IO_VIRT       0xffc10000
-#define CONFIG_SYS_PCIE3_IO_BUS                0x00000000
-#define CONFIG_SYS_PCIE3_IO_PHYS       0xffc10000
-#define CONFIG_SYS_PCIE3_IO_SIZE       0x00010000  /* 64k */
-
-/* controller 2, Slot 2, tgtid 2, Base address 9000 */
-#define CONFIG_SYS_PCIE2_MEM_VIRT      0xa0000000
-#define CONFIG_SYS_PCIE2_MEM_BUS       0xa0000000
-#define CONFIG_SYS_PCIE2_MEM_PHYS      0xa0000000
-#define CONFIG_SYS_PCIE2_MEM_SIZE      0x20000000  /* 512M */
-#define CONFIG_SYS_PCIE2_IO_VIRT       0xffc20000
-#define CONFIG_SYS_PCIE2_IO_BUS                0x00000000
-#define CONFIG_SYS_PCIE2_IO_PHYS       0xffc20000
-#define CONFIG_SYS_PCIE2_IO_SIZE       0x00010000  /* 64k */
-
-/* controller 1, Slot 1, tgtid 1, Base address a000 */
-#define CONFIG_SYS_PCIE1_MEM_VIRT      0xc0000000
-#define CONFIG_SYS_PCIE1_MEM_BUS       0xc0000000
-#define CONFIG_SYS_PCIE1_MEM_PHYS      0xc0000000
-#define CONFIG_SYS_PCIE1_MEM_SIZE      0x20000000  /* 512M */
-#define CONFIG_SYS_PCIE1_IO_VIRT       0xffc30000
-#define CONFIG_SYS_PCIE1_IO_BUS                0x00000000
-#define CONFIG_SYS_PCIE1_IO_PHYS       0xffc30000
-#define CONFIG_SYS_PCIE1_IO_SIZE       0x00010000  /* 64k */
-
-#define CONFIG_PCI_PNP                 /* do pci plug-and-play */
-
-#undef CONFIG_EEPRO100
-#undef CONFIG_TULIP
-#undef CONFIG_RTL8139
-
-#ifdef CONFIG_RTL8139
-/* This macro is used by RTL8139 but not defined in PPC architecture */
-#define KSEG1ADDR(x)           (x)
-#define _IO_BASE               0x00000000
-#endif
-
-#define CONFIG_PCI_SCAN_SHOW           /* show pci devices on startup */
-#define CONFIG_DOS_PARTITION
-
-#endif /* CONFIG_PCI */
-
-#if defined(CONFIG_TSEC_ENET)
-#define CONFIG_MII             1       /* MII PHY management */
-#define CONFIG_MII_DEFAULT_TSEC        1       /* Allow unregistered phys */
-#define CONFIG_TSEC1           1
-#define CONFIG_TSEC1_NAME      "eTSEC1"
-#define CONFIG_TSEC2           1
-#define CONFIG_TSEC2_NAME      "eTSEC2"
-#define CONFIG_TSEC3           1
-#define CONFIG_TSEC3_NAME      "eTSEC3"
-
-#define TSEC1_PHY_ADDR         0
-#define TSEC2_PHY_ADDR         2
-#define TSEC3_PHY_ADDR         1
-
-#undef CONFIG_VSC7385_ENET
-
-#define TSEC1_FLAGS            (TSEC_GIGABIT | TSEC_REDUCED)
-#define TSEC2_FLAGS            (TSEC_GIGABIT | TSEC_REDUCED)
-#define TSEC3_FLAGS            (TSEC_GIGABIT | TSEC_REDUCED)
-
-#define TSEC1_PHYIDX           0
-#define TSEC2_PHYIDX           0
-#define TSEC3_PHYIDX           0
-
-#define CONFIG_ETHPRIME                "eTSEC1"
-
-#define CONFIG_PHY_GIGE                1       /* Include GbE speed/duplex detection */
-
-#endif /* CONFIG_TSEC_ENET */
-
-/*
- * Environment
- */
-#if defined(CONFIG_RAMBOOT_SDCARD)
-       #define CONFIG_ENV_IS_IN_MMC    1
-       #define CONFIG_FSL_FIXED_MMC_LOCATION
-       #define CONFIG_ENV_SIZE         0x2000
-       #define CONFIG_SYS_MMC_ENV_DEV  0
-#elif defined(CONFIG_RAMBOOT_SPIFLASH)
-       #define CONFIG_ENV_IS_IN_SPI_FLASH
-       #define CONFIG_ENV_SPI_BUS      0
-       #define CONFIG_ENV_SPI_CS       0
-       #define CONFIG_ENV_SPI_MAX_HZ   10000000
-       #define CONFIG_ENV_SPI_MODE     0
-       #define CONFIG_ENV_OFFSET       0x100000        /* 1MB */
-       #define CONFIG_ENV_SECT_SIZE    0x10000
-       #define CONFIG_ENV_SIZE         0x2000
-#endif
-
-#define CONFIG_LOADS_ECHO              1
-#define CONFIG_SYS_LOADS_BAUD_CHANGE   1
-
-/*
- * Command line configuration.
- */
-#include <config_cmd_default.h>
-
-#define CONFIG_CMD_ELF
-#define CONFIG_CMD_I2C
-#define CONFIG_CMD_IRQ
-#define CONFIG_CMD_MII
-#define CONFIG_CMD_PING
-#define CONFIG_CMD_SETEXPR
-#define CONFIG_CMD_REGINFO
-
-#if defined(CONFIG_PCI)
-#define CONFIG_CMD_NET
-#define CONFIG_CMD_PCI
-#endif
-
-#undef CONFIG_WATCHDOG                 /* watchdog disabled */
-
-#define CONFIG_MMC     1
-
-#ifdef CONFIG_MMC
-#define CONFIG_BOARD_EARLY_INIT_F      1       /* Call board_pre_init */
-#define CONFIG_CMD_MMC
-#define CONFIG_DOS_PARTITION
-#define CONFIG_FSL_ESDHC
-#define CONFIG_GENERIC_MMC
-#define CONFIG_SYS_FSL_ESDHC_ADDR      CONFIG_SYS_MPC85xx_ESDHC_ADDR
-#define CONFIG_SYS_FSL_ESDHC_BROKEN_TIMEOUT
-#endif /* CONFIG_MMC */
-
-#define CONFIG_HAS_FSL_DR_USB
-#ifdef CONFIG_HAS_FSL_DR_USB
-#define CONFIG_USB_EHCI
-
-#ifdef CONFIG_USB_EHCI
-#define CONFIG_CMD_USB
-#define CONFIG_EHCI_HCD_INIT_AFTER_RESET
-#define CONFIG_USB_EHCI_FSL
-#define CONFIG_USB_STORAGE
-#endif
-#endif
-
-#if defined(CONFIG_MMC) || defined(CONFIG_USB_EHCI)
-#define CONFIG_CMD_EXT2
-#define CONFIG_CMD_FAT
-#define CONFIG_DOS_PARTITION
-#endif
-
-/* Misc Extra Settings */
-#define CONFIG_CMD_DHCP                        1
-
-#define CONFIG_CMD_DATE                        1
-#define CONFIG_RTC_M41T62              1
-#define CONFIG_SYS_RTC_BUS_NUM         1
-#define CONFIG_SYS_I2C_RTC_ADDR                0x68
-
-/*
- * Miscellaneous configurable options
- */
-#define CONFIG_SYS_LONGHELP                    /* undef to save memory */
-#define CONFIG_CMDLINE_EDITING                 /* Command-line editing */
-#define CONFIG_AUTO_COMPLETE   1               /* add autocompletion support */
-#define CONFIG_SYS_LOAD_ADDR   0x2000000       /* default load address */
-#if defined(CONFIG_CMD_KGDB)
-#define CONFIG_SYS_CBSIZE      1024            /* Console I/O Buffer Size */
-#else
-#define CONFIG_SYS_CBSIZE      256             /* Console I/O Buffer Size */
-#endif
-#define CONFIG_SYS_PBSIZE      (CONFIG_SYS_CBSIZE+sizeof(CONFIG_SYS_PROMPT)+16)
-                                               /* Print Buffer Size */
-#define CONFIG_SYS_MAXARGS     16              /* max number of command args */
-#define CONFIG_SYS_BARGSIZE    CONFIG_SYS_CBSIZE/* Boot Argument Buffer Size */
-
-/*
- * For booting Linux, the board info and command line data
- * have to be in the first 64 MB of memory, since this is
- * the maximum mapped by the Linux kernel during initialization.
- */
-#define CONFIG_SYS_BOOTMAPSZ   (64 << 20)
-#define CONFIG_SYS_BOOTM_LEN   (64 << 20)
-
-#if defined(CONFIG_CMD_KGDB)
-#define CONFIG_KGDB_BAUDRATE   230400  /* speed to run kgdb serial port */
-#endif
-
-/*
- * Environment Configuration
- */
-
-/* The mac addresses for all ethernet interface */
-#if defined(CONFIG_TSEC_ENET)
-#define CONFIG_HAS_ETH0
-#define CONFIG_HAS_ETH1
-#define CONFIG_HAS_ETH2
-#define CONFIG_HAS_ETH3
-#endif
-
-#define CONFIG_HOSTNAME                unknown
-#define CONFIG_ROOTPATH                "/opt/nfsroot"
-#define CONFIG_BOOTFILE                "uImage"
-#define CONFIG_UBOOTPATH       u-boot.bin
-
-/* default location for tftp and bootm */
-#define CONFIG_LOADADDR                1000000
-
-#define CONFIG_BOOTDELAY       10      /* -1 disables auto-boot */
-#undef  CONFIG_BOOTARGS                        /* the boot command will set bootargs */
-
-#define CONFIG_BAUDRATE                115200
-
-#define CONFIG_EXTRA_ENV_SETTINGS                                      \
-       "hwconfig=fsl_ddr:ecc=on\0"                                     \
-       "bootcmd=run sdboot\0"                                          \
-       "sdboot=setenv bootargs root=/dev/mmcblk0p2 rw "                \
-               "rootdelay=$rootdelaysecond console=$consoledev,$baudrate "\
-               "$othbootargs; mmcinfo; "                               \
-               "ext2load mmc 0:2 $loadaddr /boot/$bootfile; "          \
-               "ext2load mmc 0:2 $fdtaddr /boot/$fdtfile; "            \
-               "bootm $loadaddr - $fdtaddr\0"                          \
-       "sdfatboot=setenv bootargs root=/dev/ram rw "                   \
-               "rootdelay=$rootdelaysecond console=$consoledev,$baudrate "\
-               "$othbootargs; mmcinfo; "                               \
-               "fatload mmc 0:1 $loadaddr $bootfile; "                 \
-               "fatload mmc 0:1 $fdtaddr $fdtfile; "                   \
-               "fatload mmc 0:1 $ramdiskaddr $ramdiskfile; "           \
-               "bootm $loadaddr $ramdiskaddr $fdtaddr\0"               \
-       "usbboot=setenv bootargs root=/dev/sda1 rw "                    \
-               "rootdelay=$rootdelaysecond console=$consoledev,$baudrate "\
-               "$othbootargs; "                                        \
-               "usb start; "                                           \
-               "ext2load usb 0:1 $loadaddr /boot/$bootfile; "          \
-               "ext2load usb 0:1 $fdtaddr /boot/$fdtfile; "            \
-               "bootm $loadaddr - $fdtaddr\0"                          \
-       "usbfatboot=setenv bootargs root=/dev/ram rw "                  \
-               "console=$consoledev,$baudrate $othbootargs; "          \
-               "usb start; "                                           \
-               "fatload usb 0:2 $loadaddr $bootfile; "                 \
-               "fatload usb 0:2 $fdtaddr $fdtfile; "                   \
-               "fatload usb 0:2 $ramdiskaddr $ramdiskfile; "           \
-               "bootm $loadaddr $ramdiskaddr $fdtaddr\0"               \
-       "usbext2boot=setenv bootargs root=/dev/ram rw "                 \
-               "console=$consoledev,$baudrate $othbootargs; "          \
-               "usb start; "                                           \
-               "ext2load usb 0:4 $loadaddr $bootfile; "                \
-               "ext2load usb 0:4 $fdtaddr $fdtfile; "                  \
-               "ext2load usb 0:4 $ramdiskaddr $ramdiskfile; "          \
-               "bootm $loadaddr $ramdiskaddr $fdtaddr\0"               \
-       "upgradespi=sf probe 0; "                                       \
-               "setenv startaddr 0; "                                  \
-               "setenv erasesize a0000; "                              \
-               "tftp 1000000 $tftppath/$uboot_spi; "                   \
-               "sf erase $startaddr $erasesize; "                      \
-               "sf write 1000000 $startaddr $filesize; "               \
-               "sf erase 100000 120000\0"                              \
-       "clearspienv=sf probe 0;sf erase 100000 20000\0"                \
-       "othbootargs=ramdisk_size=700000 cache-sram-size=0x10000\0"     \
-       "netdev=eth0\0"                                                 \
-       "rootdelaysecond=15\0"                                          \
-       "uboot_nor=u-boot-nor.bin\0"                                    \
-       "uboot_spi=u-boot-p2020.spi\0"                                  \
-       "uboot_sd=u-boot-p2020.bin\0"                                   \
-       "consoledev=ttyS0\0"                                            \
-       "ramdiskaddr=2000000\0"                                         \
-       "ramdiskfile=rootfs-dev.ext2.img\0"                             \
-       "fdtaddr=c00000\0"                                              \
-       "fdtfile=uImage-2.6.32-p2020.dtb\0"                             \
-       "tftppath=p2020\0"
-
-#define CONFIG_HDBOOT                                                  \
-       "setenv bootargs root=/dev/$bdev rw rootdelay=30 "              \
-       "console=$consoledev,$baudrate $othbootargs;"                   \
-       "usb start;"                                                    \
-       "ext2load usb 0:1 $loadaddr /boot/$bootfile;"                   \
-       "ext2load usb 0:1 $fdtaddr /boot/$fdtfile;"                     \
-       "bootm $loadaddr - $fdtaddr"
-
-#define CONFIG_NFSBOOTCOMMAND                                          \
-       "setenv bootargs root=/dev/nfs rw "                             \
-       "nfsroot=$serverip:$rootpath "                                  \
-       "ip=$ipaddr:$serverip:$gatewayip:$netmask:$hostname:$netdev:off "\
-       "console=$consoledev,$baudrate $othbootargs;"                   \
-       "tftp $loadaddr $tftppath/$bootfile;"                           \
-       "tftp $fdtaddr $tftppath/$fdtfile;"                             \
-       "bootm $loadaddr - $fdtaddr"
-
-
-#define CONFIG_RAMBOOTCOMMAND                                          \
-       "setenv bootargs root=/dev/ram rw "                             \
-       "console=$consoledev,$baudrate $othbootargs;"                   \
-       "tftp $ramdiskaddr $tftppath/$ramdiskfile;"                     \
-       "tftp $loadaddr $tftppath/$bootfile;"                           \
-       "tftp $fdtaddr $tftppath/$fdtfile;"                             \
-       "bootm $loadaddr $ramdiskaddr $fdtaddr"
-
-#define CONFIG_BOOTCOMMAND             CONFIG_HDBOOT
-
-#endif  /* __CONFIG_H */
diff --git a/include/configs/P2020DS.h b/include/configs/P2020DS.h
deleted file mode 100644 (file)
index 820b633..0000000
+++ /dev/null
@@ -1,751 +0,0 @@
-/*
- * Copyright 2007-2012 Freescale Semiconductor, Inc.
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-/*
- * p2020ds board configuration file
- *
- */
-#ifndef __CONFIG_H
-#define __CONFIG_H
-
-#include "../board/freescale/common/ics307_clk.h"
-
-#ifdef CONFIG_36BIT
-#define CONFIG_PHYS_64BIT
-#endif
-
-#ifdef CONFIG_SDCARD
-#define CONFIG_SYS_RAMBOOT
-#define CONFIG_SYS_EXTRA_ENV_RELOC
-#define CONFIG_SYS_TEXT_BASE           0xf8f40000
-#define CONFIG_RESET_VECTOR_ADDRESS    0xf8fffffc
-#endif
-
-#ifdef CONFIG_SPIFLASH
-#define CONFIG_SYS_RAMBOOT
-#define CONFIG_SYS_EXTRA_ENV_RELOC
-#define CONFIG_SYS_TEXT_BASE           0xf8f40000
-#define CONFIG_RESET_VECTOR_ADDRESS    0xf8fffffc
-#endif
-
-/* High Level Configuration Options */
-#define CONFIG_BOOKE           1       /* BOOKE */
-#define CONFIG_E500            1       /* BOOKE e500 family */
-#define CONFIG_P2020           1
-#define CONFIG_P2020DS         1
-#define CONFIG_MP              1       /* support multiple processors */
-
-#ifndef CONFIG_SYS_TEXT_BASE
-#define CONFIG_SYS_TEXT_BASE   0xeff40000
-#endif
-
-#ifndef CONFIG_RESET_VECTOR_ADDRESS
-#define CONFIG_RESET_VECTOR_ADDRESS    0xeffffffc
-#endif
-
-#define CONFIG_SYS_SRIO
-#define CONFIG_SRIO1                   /* SRIO port 1 */
-#define CONFIG_SRIO2                   /* SRIO port 2 */
-
-#define CONFIG_FSL_ELBC                1       /* Has Enhanced localbus controller */
-#define CONFIG_PCI             1       /* Enable PCI/PCIE */
-#define CONFIG_PCIE1           1       /* PCIE controler 1 (slot 1) */
-#define CONFIG_PCIE2           1       /* PCIE controler 2 (slot 2) */
-#define CONFIG_PCIE3           1       /* PCIE controler 3 (ULI bridge) */
-#define CONFIG_FSL_PCI_INIT    1       /* Use common FSL init code */
-#define CONFIG_PCI_INDIRECT_BRIDGE 1   /* indirect PCI bridge support */
-#define CONFIG_FSL_PCIE_RESET  1       /* need PCIe reset errata */
-#define CONFIG_SYS_PCI_64BIT   1       /* enable 64-bit PCI resources */
-
-#define CONFIG_FSL_LAW         1       /* Use common FSL init code */
-#define CONFIG_E1000           1       /* Defind e1000 pci Ethernet card*/
-
-#define CONFIG_TSEC_ENET               /* tsec ethernet support */
-#define CONFIG_ENV_OVERWRITE
-
-#define CONFIG_SYS_CLK_FREQ    get_board_sys_clk() /* sysclk for MPC85xx */
-#define CONFIG_DDR_CLK_FREQ    get_board_ddr_clk() /* ddrclk for MPC85xx */
-#define CONFIG_ICS307_REFCLK_HZ        33333000  /* ICS307 clock chip ref freq */
-
-/*
- * These can be toggled for performance analysis, otherwise use default.
- */
-#define CONFIG_L2_CACHE                        /* toggle L2 cache */
-#define CONFIG_BTB                     /* toggle branch predition */
-
-#define CONFIG_BOARD_EARLY_INIT_F      /* Call board_pre_init */
-
-#define CONFIG_ENABLE_36BIT_PHYS       1
-
-#ifdef CONFIG_PHYS_64BIT
-#define CONFIG_ADDR_MAP                        1
-#define CONFIG_SYS_NUM_ADDR_MAP                16      /* number of TLB1 entries */
-#endif
-
-#define CONFIG_POST CONFIG_SYS_POST_MEMORY     /* test POST memory test */
-#define CONFIG_SYS_MEMTEST_START       0x00200000      /* memtest works on */
-#define CONFIG_SYS_MEMTEST_END         0x00400000
-#define CONFIG_PANIC_HANG      /* do not reset board on panic */
-
-/*
- * Config the L2 Cache
- */
-#define CONFIG_SYS_INIT_L2_ADDR                0xf8f80000
-#ifdef CONFIG_PHYS_64BIT
-#define CONFIG_SYS_INIT_L2_ADDR_PHYS   0xff8f80000ull
-#else
-#define CONFIG_SYS_INIT_L2_ADDR_PHYS   CONFIG_SYS_INIT_L2_ADDR
-#endif
-#define CONFIG_SYS_L2_SIZE             (512 << 10)
-#define CONFIG_SYS_INIT_L2_END (CONFIG_SYS_INIT_L2_ADDR + CONFIG_SYS_L2_SIZE)
-
-#define CONFIG_SYS_CCSRBAR             0xffe00000
-#define CONFIG_SYS_CCSRBAR_PHYS_LOW    CONFIG_SYS_CCSRBAR
-
-/* DDR Setup */
-#define CONFIG_VERY_BIG_RAM
-#ifdef CONFIG_DDR2
-#define CONFIG_SYS_FSL_DDR2
-#else
-#define CONFIG_SYS_FSL_DDR3            1
-#endif
-
-/* ECC will be enabled based on perf_mode environment variable */
-/* #define     CONFIG_DDR_ECC */
-
-#define CONFIG_ECC_INIT_VIA_DDRCONTROLLER
-#define CONFIG_MEM_INIT_VALUE  0xDeadBeef
-
-#define CONFIG_SYS_DDR_SDRAM_BASE      0x00000000
-#define CONFIG_SYS_SDRAM_BASE          CONFIG_SYS_DDR_SDRAM_BASE
-
-#define CONFIG_NUM_DDR_CONTROLLERS     1
-#define CONFIG_DIMM_SLOTS_PER_CTLR     1
-#define CONFIG_CHIP_SELECTS_PER_CTRL   2
-
-/* I2C addresses of SPD EEPROMs */
-#define CONFIG_DDR_SPD
-#define CONFIG_SYS_SPD_BUS_NUM         0       /* SPD EEPROM located on I2C bus 0 */
-#define SPD_EEPROM_ADDRESS     0x51    /* CTLR 0 DIMM 0 */
-
-/* These are used when DDR doesn't use SPD.  */
-#define CONFIG_SYS_SDRAM_SIZE          1024            /* DDR is 1GB */
-
-/* Default settings for "stable" mode */
-#define CONFIG_SYS_DDR_CS0_BNDS                0x0000003F
-#define CONFIG_SYS_DDR_CS1_BNDS                0x00000000
-#define CONFIG_SYS_DDR_CS0_CONFIG      0x80014202
-#define CONFIG_SYS_DDR_CS1_CONFIG      0x00000000
-#define CONFIG_SYS_DDR_TIMING_3                0x00020000
-#define CONFIG_SYS_DDR_TIMING_0                0x00330804
-#define CONFIG_SYS_DDR_TIMING_1                0x6f6b4846
-#define CONFIG_SYS_DDR_TIMING_2                0x0fa890d4
-#define CONFIG_SYS_DDR_MODE_1          0x00421422
-#define CONFIG_SYS_DDR_MODE_2          0x00000000
-#define CONFIG_SYS_DDR_MODE_CTRL       0x00000000
-#define CONFIG_SYS_DDR_INTERVAL                0x61800100
-#define CONFIG_SYS_DDR_DATA_INIT       0xdeadbeef
-#define CONFIG_SYS_DDR_CLK_CTRL                0x02000000
-#define CONFIG_SYS_DDR_TIMING_4                0x00220001
-#define CONFIG_SYS_DDR_TIMING_5                0x03402400
-#define CONFIG_SYS_DDR_ZQ_CNTL         0x89080600
-#define CONFIG_SYS_DDR_WRLVL_CNTL      0x8655A608
-#define CONFIG_SYS_DDR_CONTROL         0xE7000000 /* Type = DDR3: ECC enabled, No Interleaving */
-#define CONFIG_SYS_DDR_CONTROL2                0x24400011
-#define CONFIG_SYS_DDR_CDR1            0x00040000
-#define CONFIG_SYS_DDR_CDR2            0x00000000
-
-#define CONFIG_SYS_DDR_ERR_INT_EN      0x0000000d
-#define CONFIG_SYS_DDR_ERR_DIS         0x00000000
-#define CONFIG_SYS_DDR_SBE             0x00010000
-
-/* Settings that differ for "performance" mode */
-#define CONFIG_SYS_DDR_CS0_BNDS_PERF           0x0000007F /* Interleaving Enabled */
-#define CONFIG_SYS_DDR_CS1_BNDS_PERF           0x00000000 /* Interleaving Enabled */
-#define CONFIG_SYS_DDR_CS1_CONFIG_PERF 0x80014202
-#define CONFIG_SYS_DDR_TIMING_1_PERF           0x5d5b4543
-#define CONFIG_SYS_DDR_TIMING_2_PERF           0x0fa890ce
-#define CONFIG_SYS_DDR_CONTROL_PERF            0xC7004000 /* Type = DDR3: ECC disabled, cs0-cs1 interleaving */
-
-/*
- * The following set of values were tested for DDR2
- * with a DDR3 to DDR2 interposer
- *
-#define CONFIG_SYS_DDR_TIMING_3                0x00000000
-#define CONFIG_SYS_DDR_TIMING_0                0x00260802
-#define CONFIG_SYS_DDR_TIMING_1                0x3935d322
-#define CONFIG_SYS_DDR_TIMING_2                0x14904cc8
-#define CONFIG_SYS_DDR_MODE_1          0x00480432
-#define CONFIG_SYS_DDR_MODE_2          0x00000000
-#define CONFIG_SYS_DDR_INTERVAL                0x06180100
-#define CONFIG_SYS_DDR_DATA_INIT       0xdeadbeef
-#define CONFIG_SYS_DDR_CLK_CTRL                0x03800000
-#define CONFIG_SYS_DDR_OCD_CTRL                0x00000000
-#define CONFIG_SYS_DDR_OCD_STATUS      0x00000000
-#define CONFIG_SYS_DDR_CONTROL         0xC3008000
-#define CONFIG_SYS_DDR_CONTROL2                0x04400010
- *
- */
-
-/*
- * Memory map
- *
- * 0x0000_0000 0x7fff_ffff     DDR                     2G Cacheable
- * 0x8000_0000 0xbfff_ffff     PCI Express Mem         1G non-cacheable
- * 0xc000_0000 0xdfff_ffff     PCI                     512M non-cacheable
- * 0xe100_0000 0xe3ff_ffff     PCI IO range            4M non-cacheable
- *
- * Localbus cacheable (TBD)
- * 0xXXXX_XXXX 0xXXXX_XXXX     SRAM                    YZ M Cacheable
- *
- * Localbus non-cacheable
- * 0xe000_0000 0xe80f_ffff     Promjet/free            128M non-cacheable
- * 0xe800_0000 0xefff_ffff     FLASH                   128M non-cacheable
- * 0xffa0_0000 0xffaf_ffff     NAND                    1M non-cacheable
- * 0xffdf_0000 0xffdf_7fff     PIXIS                   32K non-cacheable TLB0
- * 0xffd0_0000 0xffd0_3fff     L1 for stack            16K Cacheable TLB0
- * 0xffe0_0000 0xffef_ffff     CCSR                    1M non-cacheable
- */
-
-/*
- * Local Bus Definitions
- */
-#define CONFIG_SYS_FLASH_BASE          0xe0000000      /* start of FLASH 128M */
-#ifdef CONFIG_PHYS_64BIT
-#define CONFIG_SYS_FLASH_BASE_PHYS     0xfe0000000ull
-#else
-#define CONFIG_SYS_FLASH_BASE_PHYS     CONFIG_SYS_FLASH_BASE
-#endif
-
-#define CONFIG_FLASH_BR_PRELIM  \
-       (BR_PHYS_ADDR(CONFIG_SYS_FLASH_BASE_PHYS + 0x8000000) | BR_PS_16 | BR_V)
-#define CONFIG_FLASH_OR_PRELIM 0xf8000ff7
-
-#define CONFIG_SYS_BR1_PRELIM  (BR_PHYS_ADDR(CONFIG_SYS_FLASH_BASE_PHYS) | BR_PS_16 | BR_V)
-#define CONFIG_SYS_OR1_PRELIM  0xf8000ff7
-
-#define CONFIG_SYS_FLASH_BANKS_LIST    {CONFIG_SYS_FLASH_BASE_PHYS + 0x8000000, CONFIG_SYS_FLASH_BASE_PHYS}
-#define CONFIG_SYS_FLASH_QUIET_TEST
-#define CONFIG_FLASH_SHOW_PROGRESS 45 /* count down from 45/5: 9..1 */
-
-#define CONFIG_SYS_MAX_FLASH_BANKS     2               /* number of banks */
-#define CONFIG_SYS_MAX_FLASH_SECT      1024            /* sectors per device */
-#define CONFIG_SYS_FLASH_ERASE_TOUT    60000           /* Flash Erase Timeout (ms) */
-#define CONFIG_SYS_FLASH_WRITE_TOUT    500             /* Flash Write Timeout (ms) */
-
-#define CONFIG_SYS_MONITOR_BASE        CONFIG_SYS_TEXT_BASE    /* start of monitor */
-
-#define CONFIG_FLASH_CFI_DRIVER
-#define CONFIG_SYS_FLASH_CFI
-#define CONFIG_SYS_FLASH_EMPTY_INFO
-#define CONFIG_SYS_FLASH_AMD_CHECK_DQ7
-
-#define CONFIG_BOARD_EARLY_INIT_R      /* call board_early_init_r function */
-
-#define CONFIG_HWCONFIG                        /* enable hwconfig */
-#define CONFIG_FSL_NGPIXIS             /* use common ngPIXIS code */
-
-#ifdef CONFIG_FSL_NGPIXIS
-#define PIXIS_BASE     0xffdf0000      /* PIXIS registers */
-#ifdef CONFIG_PHYS_64BIT
-#define PIXIS_BASE_PHYS        0xfffdf0000ull
-#else
-#define PIXIS_BASE_PHYS        PIXIS_BASE
-#endif
-
-#define CONFIG_SYS_BR3_PRELIM  (BR_PHYS_ADDR(PIXIS_BASE_PHYS) | BR_PS_8 | BR_V)
-#define CONFIG_SYS_OR3_PRELIM          0xffffeff7      /* 32KB but only 4k mapped */
-
-#define PIXIS_LBMAP_SWITCH     7
-#define PIXIS_LBMAP_MASK       0xf0
-#define PIXIS_LBMAP_SHIFT      4
-#define PIXIS_LBMAP_ALTBANK    0x20
-#endif
-
-#define CONFIG_SYS_INIT_RAM_LOCK       1
-#define CONFIG_SYS_INIT_RAM_ADDR       0xffd00000      /* Initial L1 address */
-#ifdef CONFIG_PHYS_64BIT
-#define CONFIG_SYS_INIT_RAM_ADDR_PHYS_HIGH 0xf
-#define CONFIG_SYS_INIT_RAM_ADDR_PHYS_LOW CONFIG_SYS_INIT_RAM_ADDR
-/* The assembler doesn't like typecast */
-#define CONFIG_SYS_INIT_RAM_ADDR_PHYS \
-       ((CONFIG_SYS_INIT_RAM_ADDR_PHYS_HIGH * 1ull << 32) | \
-         CONFIG_SYS_INIT_RAM_ADDR_PHYS_LOW)
-#else
-#define CONFIG_SYS_INIT_RAM_ADDR_PHYS  CONFIG_SYS_INIT_RAM_ADDR /* Initial L1 address */
-#define CONFIG_SYS_INIT_RAM_ADDR_PHYS_HIGH 0
-#define CONFIG_SYS_INIT_RAM_ADDR_PHYS_LOW CONFIG_SYS_INIT_RAM_ADDR_PHYS
-#endif
-#define CONFIG_SYS_INIT_RAM_SIZE       0x00004000      /* Size of used area in RAM */
-
-#define CONFIG_SYS_GBL_DATA_OFFSET     (CONFIG_SYS_INIT_RAM_SIZE - GENERATED_GBL_DATA_SIZE)
-#define CONFIG_SYS_INIT_SP_OFFSET      CONFIG_SYS_GBL_DATA_OFFSET
-
-#define CONFIG_SYS_MONITOR_LEN         (768 * 1024)
-#define CONFIG_SYS_MALLOC_LEN          (1024 * 1024)   /* Reserved for malloc */
-
-#define CONFIG_SYS_NAND_BASE           0xffa00000
-#ifdef CONFIG_PHYS_64BIT
-#define CONFIG_SYS_NAND_BASE_PHYS      0xfffa00000ull
-#else
-#define CONFIG_SYS_NAND_BASE_PHYS      CONFIG_SYS_NAND_BASE
-#endif
-#define CONFIG_SYS_NAND_BASE_LIST      { CONFIG_SYS_NAND_BASE,\
-                               CONFIG_SYS_NAND_BASE + 0x40000, \
-                               CONFIG_SYS_NAND_BASE + 0x80000,\
-                               CONFIG_SYS_NAND_BASE + 0xC0000}
-#define CONFIG_SYS_MAX_NAND_DEVICE     4
-#define CONFIG_MTD_NAND_VERIFY_WRITE
-#define CONFIG_CMD_NAND                        1
-#define CONFIG_NAND_FSL_ELBC           1
-#define CONFIG_SYS_NAND_BLOCK_SIZE     (128 * 1024)
-
-/* NAND flash config */
-#define CONFIG_SYS_NAND_BR_PRELIM  (BR_PHYS_ADDR(CONFIG_SYS_NAND_BASE_PHYS) \
-                               | (2<<BR_DECC_SHIFT)    /* Use HW ECC */ \
-                               | BR_PS_8               /* Port Size = 8bit */ \
-                               | BR_MS_FCM             /* MSEL = FCM */ \
-                               | BR_V)                 /* valid */
-#define CONFIG_SYS_NAND_OR_PRELIM  (0xFFFC0000         /* length 256K */ \
-                               | OR_FCM_PGS            /* Large Page*/ \
-                               | OR_FCM_CSCT \
-                               | OR_FCM_CST \
-                               | OR_FCM_CHT \
-                               | OR_FCM_SCY_1 \
-                               | OR_FCM_TRLX \
-                               | OR_FCM_EHTR)
-
-#define CONFIG_SYS_BR0_PRELIM  CONFIG_FLASH_BR_PRELIM  /* NOR Base Address */
-#define CONFIG_SYS_OR0_PRELIM  CONFIG_FLASH_OR_PRELIM  /* NOR Options */
-#define CONFIG_SYS_BR2_PRELIM  CONFIG_SYS_NAND_BR_PRELIM  /* NAND Base Address */
-#define CONFIG_SYS_OR2_PRELIM  CONFIG_SYS_NAND_OR_PRELIM  /* NAND Options */
-
-#define CONFIG_SYS_BR4_PRELIM  (BR_PHYS_ADDR(CONFIG_SYS_NAND_BASE_PHYS + 0x40000) \
-                               | (2<<BR_DECC_SHIFT)    /* Use HW ECC */ \
-                               | BR_PS_8               /* Port Size = 8bit */ \
-                               | BR_MS_FCM             /* MSEL = FCM */ \
-                               | BR_V)                 /* valid */
-#define CONFIG_SYS_OR4_PRELIM  CONFIG_SYS_NAND_OR_PRELIM       /* NAND Options */
-#define CONFIG_SYS_BR5_PRELIM  (BR_PHYS_ADDR(CONFIG_SYS_NAND_BASE_PHYS + 0x80000) \
-                               | (2<<BR_DECC_SHIFT)    /* Use HW ECC */ \
-                               | BR_PS_8               /* Port Size = 8bit */ \
-                               | BR_MS_FCM             /* MSEL = FCM */ \
-                               | BR_V)                 /* valid */
-#define CONFIG_SYS_OR5_PRELIM  CONFIG_SYS_NAND_OR_PRELIM       /* NAND Options */
-
-#define CONFIG_SYS_BR6_PRELIM  (BR_PHYS_ADDR(CONFIG_SYS_NAND_BASE_PHYS + 0xc0000) \
-                               | (2<<BR_DECC_SHIFT)    /* Use HW ECC */ \
-                               | BR_PS_8               /* Port Size = 8bit */ \
-                               | BR_MS_FCM             /* MSEL = FCM */ \
-                               | BR_V)                 /* valid */
-#define CONFIG_SYS_OR6_PRELIM  CONFIG_SYS_NAND_OR_PRELIM       /* NAND Options */
-
-/* Serial Port - controlled on board with jumper J8
- * open - index 2
- * shorted - index 1
- */
-#define CONFIG_CONS_INDEX      1
-#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_BAUDRATE_TABLE      \
-       {300, 600, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200}
-
-#define CONFIG_SYS_NS16550_COM1        (CONFIG_SYS_CCSRBAR+0x4500)
-#define CONFIG_SYS_NS16550_COM2        (CONFIG_SYS_CCSRBAR+0x4600)
-
-/* Use the HUSH parser */
-#define CONFIG_SYS_HUSH_PARSER
-
-/*
- * Pass open firmware flat tree
- */
-#define CONFIG_OF_LIBFDT               1
-#define CONFIG_OF_BOARD_SETUP          1
-#define CONFIG_OF_STDOUT_VIA_ALIAS     1
-
-/* I2C */
-#define CONFIG_SYS_I2C
-#define CONFIG_SYS_I2C_FSL
-#define CONFIG_SYS_FSL_I2C_OFFSET      0x3000
-#define CONFIG_SYS_FSL_I2C2_OFFSET     0x3100
-#define CONFIG_SYS_FSL_I2C_SPEED       400000
-#define CONFIG_SYS_FSL_I2C_SLAVE       0x7F
-#define CONFIG_SYS_FSL_I2C2_SPEED      400000
-#define CONFIG_SYS_FSL_I2C2_SLAVE      0x7F
-#define CONFIG_SYS_I2C_EEPROM_ADDR     0x57
-#define CONFIG_SYS_I2C_NOPROBES                { {0, 0x29} }
-
-/*
- * I2C2 EEPROM
- */
-#define CONFIG_ID_EEPROM
-#ifdef CONFIG_ID_EEPROM
-#define CONFIG_SYS_I2C_EEPROM_NXID
-#endif
-#define CONFIG_SYS_I2C_EEPROM_ADDR     0x57
-#define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1
-#define CONFIG_SYS_EEPROM_BUS_NUM      0
-
-/*
- * eSPI - Enhanced SPI
- */
-#define CONFIG_FSL_ESPI
-
-#define CONFIG_SPI_FLASH
-#define CONFIG_SPI_FLASH_SPANSION
-
-#define CONFIG_CMD_SF
-#define CONFIG_SF_DEFAULT_SPEED                10000000
-#define CONFIG_SF_DEFAULT_MODE         SPI_MODE_0
-
-/*
- * General PCI
- * Memory space is mapped 1-1, but I/O space must start from 0.
- */
-
-/* controller 3, Slot 1, tgtid 3, Base address b000 */
-#define CONFIG_SYS_PCIE3_NAME          "Slot 1"
-#define CONFIG_SYS_PCIE3_MEM_VIRT      0x80000000
-#ifdef CONFIG_PHYS_64BIT
-#define CONFIG_SYS_PCIE3_MEM_BUS       0xe0000000
-#define CONFIG_SYS_PCIE3_MEM_PHYS      0xc00000000ull
-#else
-#define CONFIG_SYS_PCIE3_MEM_BUS       0x80000000
-#define CONFIG_SYS_PCIE3_MEM_PHYS      0x80000000
-#endif
-#define CONFIG_SYS_PCIE3_MEM_SIZE      0x20000000      /* 512M */
-#define CONFIG_SYS_PCIE3_IO_VIRT       0xffc00000
-#define CONFIG_SYS_PCIE3_IO_BUS                0x00000000
-#ifdef CONFIG_PHYS_64BIT
-#define CONFIG_SYS_PCIE3_IO_PHYS       0xfffc00000ull
-#else
-#define CONFIG_SYS_PCIE3_IO_PHYS       0xffc00000
-#endif
-#define CONFIG_SYS_PCIE3_IO_SIZE       0x00010000      /* 64k */
-
-/* controller 2, direct to uli, tgtid 2, Base address 9000 */
-#define CONFIG_SYS_PCIE2_NAME          "ULI"
-#define CONFIG_SYS_PCIE2_MEM_VIRT      0xa0000000
-#ifdef CONFIG_PHYS_64BIT
-#define CONFIG_SYS_PCIE2_MEM_BUS       0xe0000000
-#define CONFIG_SYS_PCIE2_MEM_PHYS      0xc20000000ull
-#else
-#define CONFIG_SYS_PCIE2_MEM_BUS       0xa0000000
-#define CONFIG_SYS_PCIE2_MEM_PHYS      0xa0000000
-#endif
-#define CONFIG_SYS_PCIE2_MEM_SIZE      0x20000000      /* 512M */
-#define CONFIG_SYS_PCIE2_IO_VIRT       0xffc10000
-#define CONFIG_SYS_PCIE2_IO_BUS                0x00000000
-#ifdef CONFIG_PHYS_64BIT
-#define CONFIG_SYS_PCIE2_IO_PHYS       0xfffc10000ull
-#else
-#define CONFIG_SYS_PCIE2_IO_PHYS       0xffc10000
-#endif
-#define CONFIG_SYS_PCIE2_IO_SIZE       0x00010000      /* 64k */
-
-/* controller 1, Slot 2, tgtid 1, Base address a000 */
-#define CONFIG_SYS_PCIE1_NAME          "Slot 2"
-#define CONFIG_SYS_PCIE1_MEM_VIRT      0xc0000000
-#ifdef CONFIG_PHYS_64BIT
-#define CONFIG_SYS_PCIE1_MEM_BUS       0xe0000000
-#define CONFIG_SYS_PCIE1_MEM_PHYS      0xc40000000ull
-#else
-#define CONFIG_SYS_PCIE1_MEM_BUS       0xc0000000
-#define CONFIG_SYS_PCIE1_MEM_PHYS      0xc0000000
-#endif
-#define CONFIG_SYS_PCIE1_MEM_SIZE      0x20000000      /* 512M */
-#define CONFIG_SYS_PCIE1_IO_VIRT       0xffc20000
-#define CONFIG_SYS_PCIE1_IO_BUS                0x00000000
-#ifdef CONFIG_PHYS_64BIT
-#define CONFIG_SYS_PCIE1_IO_PHYS       0xfffc20000ull
-#else
-#define CONFIG_SYS_PCIE1_IO_PHYS       0xffc20000
-#endif
-#define CONFIG_SYS_PCIE1_IO_SIZE       0x00010000      /* 64k */
-
-#if defined(CONFIG_PCI)
-
-/*PCIE video card used*/
-#define VIDEO_IO_OFFSET                CONFIG_SYS_PCIE1_IO_VIRT
-
-/* video */
-#undef CONFIG_VIDEO
-
-#if defined(CONFIG_VIDEO)
-#define CONFIG_BIOSEMU
-#define CONFIG_CFB_CONSOLE
-#define CONFIG_VIDEO_SW_CURSOR
-#define CONFIG_VGA_AS_SINGLE_DEVICE
-#define CONFIG_ATI_RADEON_FB
-#define CONFIG_VIDEO_LOGO
-/*#define CONFIG_CONSOLE_CURSOR*/
-#define CONFIG_SYS_ISA_IO_BASE_ADDRESS VIDEO_IO_OFFSET
-#endif
-
-/* SRIO1 uses the same window as PCIE2 mem window */
-#define CONFIG_SYS_SRIO1_MEM_VIRT      0xa0000000
-#ifdef CONFIG_PHYS_64BIT
-#define CONFIG_SYS_SRIO1_MEM_PHYS      0xc20000000ull
-#else
-#define CONFIG_SYS_SRIO1_MEM_PHYS      0xa0000000
-#endif
-#define CONFIG_SYS_SRIO1_MEM_SIZE      0x20000000      /* 512M */
-
-/* SRIO2 uses the same window as PCIE1 mem window */
-#define CONFIG_SYS_SRIO2_MEM_VIRT      0xc0000000
-#ifdef CONFIG_PHYS_64BIT
-#define CONFIG_SYS_SRIO2_MEM_PHYS      0xc40000000ull
-#else
-#define CONFIG_SYS_SRIO2_MEM_PHYS      0xc0000000
-#endif
-#define CONFIG_SYS_SRIO2_MEM_SIZE      0x20000000      /* 512M */
-
-#define CONFIG_PCI_PNP                 /* do pci plug-and-play */
-#define CONFIG_PCI_SCAN_SHOW           /* show pci devices on startup */
-#define CONFIG_DOS_PARTITION
-#define CONFIG_SCSI_AHCI
-
-#ifdef CONFIG_SCSI_AHCI
-#define CONFIG_LIBATA
-#define CONFIG_SATA_ULI5288
-#define CONFIG_SYS_SCSI_MAX_SCSI_ID    4
-#define CONFIG_SYS_SCSI_MAX_LUN        1
-#define CONFIG_SYS_SCSI_MAX_DEVICE     (CONFIG_SYS_SCSI_MAX_SCSI_ID * CONFIG_SYS_SCSI_MAX_LUN)
-#define CONFIG_SYS_SCSI_MAXDEVICE      CONFIG_SYS_SCSI_MAX_DEVICE
-#endif /* SCSI */
-
-#endif /* CONFIG_PCI */
-
-
-#if defined(CONFIG_TSEC_ENET)
-
-#define CONFIG_MII             1       /* MII PHY management */
-#define CONFIG_MII_DEFAULT_TSEC        1       /* Allow unregistered phys */
-#define CONFIG_TSEC1   1
-#define CONFIG_TSEC1_NAME      "eTSEC1"
-#define CONFIG_TSEC2   1
-#define CONFIG_TSEC2_NAME      "eTSEC2"
-#define CONFIG_TSEC3   1
-#define CONFIG_TSEC3_NAME      "eTSEC3"
-
-#define CONFIG_FSL_SGMII_RISER 1
-#define SGMII_RISER_PHY_OFFSET 0x1b
-
-#ifdef CONFIG_FSL_SGMII_RISER
-#define CONFIG_SYS_TBIPA_VALUE         0x10 /* avoid conflict with eTSEC4 paddr */
-#endif
-
-#define TSEC1_PHY_ADDR         0
-#define TSEC2_PHY_ADDR         1
-#define TSEC3_PHY_ADDR         2
-
-#define TSEC1_FLAGS            (TSEC_GIGABIT | TSEC_REDUCED)
-#define TSEC2_FLAGS            (TSEC_GIGABIT | TSEC_REDUCED)
-#define TSEC3_FLAGS            (TSEC_GIGABIT | TSEC_REDUCED)
-
-#define TSEC1_PHYIDX           0
-#define TSEC2_PHYIDX           0
-#define TSEC3_PHYIDX           0
-
-#define CONFIG_ETHPRIME                "eTSEC1"
-
-#define CONFIG_PHY_GIGE                1       /* Include GbE speed/duplex detection */
-#endif /* CONFIG_TSEC_ENET */
-
-/*
- * Environment
- */
-#if defined(CONFIG_SDCARD)
-#define CONFIG_ENV_IS_IN_MMC
-#define CONFIG_FSL_FIXED_MMC_LOCATION
-#define CONFIG_ENV_SIZE                        0x2000
-#define CONFIG_SYS_MMC_ENV_DEV         0
-#elif defined(CONFIG_SPIFLASH)
-#define CONFIG_ENV_IS_IN_SPI_FLASH
-#define CONFIG_ENV_SPI_BUS             0
-#define CONFIG_ENV_SPI_CS              0
-#define CONFIG_ENV_SPI_MAX_HZ          10000000
-#define CONFIG_ENV_SPI_MODE            0
-#define CONFIG_ENV_SIZE                        0x2000          /* 8KB */
-#define CONFIG_ENV_OFFSET              0x100000        /* 1MB */
-#define CONFIG_ENV_SECT_SIZE           0x10000
-#else
-#define CONFIG_ENV_IS_IN_FLASH 1
-#define CONFIG_ENV_ADDR                (CONFIG_SYS_MONITOR_BASE - CONFIG_ENV_SECT_SIZE)
-#define CONFIG_ENV_SIZE                0x2000
-#define CONFIG_ENV_SECT_SIZE   0x20000 /* 128K (one sector) */
-#endif
-
-#define CONFIG_LOADS_ECHO      1       /* echo on for serial download */
-#define CONFIG_SYS_LOADS_BAUD_CHANGE   1       /* allow baudrate change */
-
-/*
- * Command line configuration.
- */
-#include <config_cmd_default.h>
-
-#define CONFIG_CMD_IRQ
-#define CONFIG_CMD_PING
-#define CONFIG_CMD_I2C
-#define CONFIG_CMD_MII
-#define CONFIG_CMD_ELF
-#define CONFIG_CMD_IRQ
-#define CONFIG_CMD_SETEXPR
-#define CONFIG_CMD_REGINFO
-
-#if defined(CONFIG_PCI)
-#define CONFIG_CMD_PCI
-#define CONFIG_CMD_NET
-#define CONFIG_CMD_SCSI
-#define CONFIG_CMD_EXT2
-#endif
-
-/*
- * USB
- */
-#define CONFIG_HAS_FSL_DR_USB
-#ifdef CONFIG_HAS_FSL_DR_USB
-#define CONFIG_USB_EHCI
-
-#ifdef CONFIG_USB_EHCI
-#define CONFIG_CMD_USB
-#define CONFIG_USB_STORAGE
-#define CONFIG_USB_EHCI_FSL
-#define CONFIG_EHCI_HCD_INIT_AFTER_RESET
-#endif
-#endif
-
-/*
- * SDHC/MMC
- */
-#define CONFIG_MMC
-
-#ifdef CONFIG_MMC
-#define CONFIG_FSL_ESDHC
-#define CONFIG_SYS_FSL_ESDHC_ADDR      CONFIG_SYS_MPC85xx_ESDHC_ADDR
-#define CONFIG_CMD_MMC
-#define CONFIG_GENERIC_MMC
-#endif
-
-#if defined(CONFIG_MMC) || defined(CONFIG_USB_EHCI)
-#define CONFIG_CMD_EXT2
-#define CONFIG_CMD_FAT
-#define CONFIG_DOS_PARTITION
-#endif
-
-/*
- * Miscellaneous configurable options
- */
-#define CONFIG_SYS_LONGHELP                    /* undef to save memory */
-#define CONFIG_CMDLINE_EDITING                 /* Command-line editing */
-#define CONFIG_AUTO_COMPLETE                   /* add autocompletion support */
-#define CONFIG_SYS_LOAD_ADDR   0x2000000       /* default load address */
-#if defined(CONFIG_CMD_KGDB)
-#define CONFIG_SYS_CBSIZE      1024            /* Console I/O Buffer Size */
-#else
-#define CONFIG_SYS_CBSIZE      256             /* Console I/O Buffer Size */
-#endif
-#define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE+sizeof(CONFIG_SYS_PROMPT)+16) /* Print Buffer Size */
-#define CONFIG_SYS_MAXARGS     16              /* max number of command args */
-#define CONFIG_SYS_BARGSIZE    CONFIG_SYS_CBSIZE       /* Boot Argument Buffer Size */
-
-/*
- * For booting Linux, the board info and command line data
- * have to be in the first 64 MB of memory, since this is
- * the maximum mapped by the Linux kernel during initialization.
- */
-#define CONFIG_SYS_BOOTMAPSZ   (64 << 20)      /* Initial Memory map for Linux*/
-#define CONFIG_SYS_BOOTM_LEN   (64 << 20)      /* Increase max gunzip size */
-
-#if defined(CONFIG_CMD_KGDB)
-#define CONFIG_KGDB_BAUDRATE   230400  /* speed to run kgdb serial port */
-#endif
-
-/*
- * Environment Configuration
- */
-
-/* The mac addresses for all ethernet interface */
-#if defined(CONFIG_TSEC_ENET)
-#define CONFIG_HAS_ETH0
-#define CONFIG_HAS_ETH1
-#define CONFIG_HAS_ETH2
-#endif
-
-#define CONFIG_IPADDR          192.168.1.254
-
-#define CONFIG_HOSTNAME                unknown
-#define CONFIG_ROOTPATH                "/opt/nfsroot"
-#define CONFIG_BOOTFILE                "uImage"
-#define CONFIG_UBOOTPATH       u-boot.bin      /* U-Boot image on TFTP server */
-
-#define CONFIG_SERVERIP                192.168.1.1
-#define CONFIG_GATEWAYIP       192.168.1.1
-#define CONFIG_NETMASK         255.255.255.0
-
-/* default location for tftp and bootm */
-#define CONFIG_LOADADDR                1000000
-
-#define CONFIG_BOOTDELAY 10    /* -1 disables auto-boot */
-
-#define CONFIG_BAUDRATE        115200
-
-#define        CONFIG_EXTRA_ENV_SETTINGS                               \
-"perf_mode=performance\0"                      \
-       "hwconfig=fsl_ddr:ctlr_intlv=bank,bank_intlv=cs0_cs1;"  \
-       "usb1:dr_mode=host,phy_type=ulpi\0"                     \
-"netdev=eth0\0"                                                \
-"uboot=" __stringify(CONFIG_UBOOTPATH) "\0"                    \
-"tftpflash=tftpboot $loadaddr $uboot; "                        \
-       "protect off " __stringify(CONFIG_SYS_TEXT_BASE) " +$filesize; " \
-       "erase " __stringify(CONFIG_SYS_TEXT_BASE) " +$filesize; "      \
-       "cp.b $loadaddr " __stringify(CONFIG_SYS_TEXT_BASE) " $filesize; " \
-       "protect on " __stringify(CONFIG_SYS_TEXT_BASE) " +$filesize; " \
-       "cmp.b $loadaddr " __stringify(CONFIG_SYS_TEXT_BASE) " $filesize\0" \
-"satabootcmd=setenv bootargs root=/dev/$bdev rw "      \
-       "console=$consoledev,$baudrate $othbootargs;"   \
-       "tftp $loadaddr $bootfile;"                     \
-       "tftp $fdtaddr $fdtfile;"                       \
-       "bootm $loadaddr - $fdtaddr"                    \
-"consoledev=ttyS0\0"                           \
-"ramdiskaddr=2000000\0"                        \
-"ramdiskfile=p2020ds/ramdisk.uboot\0"          \
-"fdtaddr=c00000\0"                             \
-"othbootargs=cache-sram-size=0x10000\0"        \
-"fdtfile=p2020ds/p2020ds.dtb\0"                \
-"bdev=sda3\0"                                  \
-"partition=scsi 0:0\0"
-
-#define CONFIG_HDBOOT                          \
- "setenv bootargs root=/dev/$bdev rw "         \
- "console=$consoledev,$baudrate $othbootargs;" \
- "ext2load $partition $loadaddr $bootfile;"    \
- "ext2load $partition $fdtaddr $fdtfile;"      \
- "bootm $loadaddr - $fdtaddr"
-
-#define CONFIG_NFSBOOTCOMMAND          \
- "setenv bootargs root=/dev/nfs rw "   \
- "nfsroot=$serverip:$rootpath "                \
- "ip=$ipaddr:$serverip:$gatewayip:$netmask:$hostname:$netdev:off " \
- "console=$consoledev,$baudrate $othbootargs;" \
- "tftp $loadaddr $bootfile;"           \
- "tftp $fdtaddr $fdtfile;"             \
- "bootm $loadaddr - $fdtaddr"
-
-#define CONFIG_RAMBOOTCOMMAND          \
- "setenv bootargs root=/dev/ram rw "   \
- "console=$consoledev,$baudrate $othbootargs;" \
- "tftp $ramdiskaddr $ramdiskfile;"     \
- "tftp $loadaddr $bootfile;"           \
- "tftp $fdtaddr $fdtfile;"             \
- "bootm $loadaddr $ramdiskaddr $fdtaddr"
-
-#define CONFIG_BOOTCOMMAND             CONFIG_HDBOOT
-
-#endif /* __CONFIG_H */
diff --git a/include/configs/PM520.h b/include/configs/PM520.h
deleted file mode 100644 (file)
index de46216..0000000
+++ /dev/null
@@ -1,342 +0,0 @@
-/*
- * (C) Copyright 2003-2005
- * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#ifndef __CONFIG_H
-#define __CONFIG_H
-
-/*
- * High Level Configuration Options
- * (easy to change)
- */
-
-#define CONFIG_MPC5200
-#define CONFIG_PM520           1       /* PM520 board */
-
-#define        CONFIG_SYS_TEXT_BASE    0xfff00000
-
-#define CONFIG_SYS_MPC5XXX_CLKIN       33000000 /* ... running at 33MHz */
-
-#define CONFIG_MISC_INIT_R
-
-#define CONFIG_HIGH_BATS       1       /* High BATs supported */
-
-/*
- * Serial console configuration
- */
-#define CONFIG_PSC_CONSOLE     1       /* console is on PSC1 */
-#define CONFIG_BAUDRATE                9600    /* ... at 9600 bps */
-#define CONFIG_SYS_BAUDRATE_TABLE      { 9600, 19200, 38400, 57600, 115200, 230400 }
-
-
-/*
- * PCI Mapping:
- * 0x40000000 - 0x4fffffff - PCI Memory
- * 0x50000000 - 0x50ffffff - PCI IO Space
- */
-#define CONFIG_PCI             1
-#define CONFIG_PCI_PNP         1
-#define CONFIG_PCI_SCAN_SHOW   1
-#define CONFIG_PCIAUTO_SKIP_HOST_BRIDGE        1
-
-#define CONFIG_PCI_MEM_BUS     0x40000000
-#define CONFIG_PCI_MEM_PHYS    CONFIG_PCI_MEM_BUS
-#define CONFIG_PCI_MEM_SIZE    0x10000000
-
-#define CONFIG_PCI_IO_BUS      0x50000000
-#define CONFIG_PCI_IO_PHYS     CONFIG_PCI_IO_BUS
-#define CONFIG_PCI_IO_SIZE     0x01000000
-
-#define CONFIG_MII             1
-#define CONFIG_EEPRO100                1
-#define CONFIG_SYS_RX_ETH_BUFFER       8  /* use 8 rx buffer on eepro100  */
-#undef  CONFIG_NS8382X
-
-
-/* Partitions */
-#define CONFIG_DOS_PARTITION
-
-/* USB */
-#if 1
-#define CONFIG_USB_OHCI
-#define CONFIG_USB_STORAGE
-#endif
-
-/*
- * BOOTP options
- */
-#define CONFIG_BOOTP_BOOTFILESIZE
-#define CONFIG_BOOTP_BOOTPATH
-#define CONFIG_BOOTP_GATEWAY
-#define CONFIG_BOOTP_HOSTNAME
-
-
-/*
- * Command line configuration.
- */
-#include <config_cmd_default.h>
-
-#define CONFIG_CMD_BEDBUG
-#define CONFIG_CMD_DATE
-#define CONFIG_CMD_DHCP
-#define CONFIG_CMD_EEPROM
-#define CONFIG_CMD_FAT
-#define CONFIG_CMD_I2C
-#define CONFIG_CMD_IDE
-#define CONFIG_CMD_NFS
-#define CONFIG_CMD_SNTP
-#define CONFIG_CMD_USB
-
-#define CONFIG_CMD_PCI
-
-
-/*
- * Autobooting
- */
-#define CONFIG_BOOTDELAY       5       /* autoboot after 5 seconds */
-
-#define CONFIG_PREBOOT "echo;" \
-       "echo Type \\\"run flash_nfs\\\" to mount root filesystem over NFS;" \
-       "echo"
-
-#undef CONFIG_BOOTARGS
-
-#define        CONFIG_EXTRA_ENV_SETTINGS                                       \
-       "netdev=eth0\0"                                                 \
-       "hostname=pm520\0"                                                      \
-       "nfsargs=setenv bootargs root=/dev/nfs rw "                     \
-               "nfsroot=${serverip}:${rootpath}\0"                     \
-       "ramargs=setenv bootargs root=/dev/ram rw\0"                    \
-       "addip=setenv bootargs ${bootargs} "                            \
-               "ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}"      \
-               ":${hostname}:${netdev}:off panic=1\0"                  \
-       "flash_nfs=run nfsargs addip;"                                  \
-               "bootm ${kernel_addr}\0"                                \
-       "flash_self=run ramargs addip;"                                 \
-               "bootm ${kernel_addr} ${ramdisk_addr}\0"                \
-       "net_nfs=tftp 200000 ${bootfile};run nfsargs addip;bootm\0"     \
-       "rootpath=/opt/eldk30/ppc_82xx\0"                                       \
-       "bootfile=/tftpboot/PM520/uImage\0"                             \
-       ""
-
-#define CONFIG_BOOTCOMMAND     "run flash_self"
-
-/*
- * IPB Bus clocking configuration.
- */
-#undef CONFIG_SYS_IPBCLK_EQUALS_XLBCLK         /* define for 133MHz speed */
-/*
- * I2C configuration
- */
-#define CONFIG_HARD_I2C                1       /* I2C with hardware support */
-#define CONFIG_SYS_I2C_MODULE          2       /* Select I2C module #1 or #2 */
-
-#define CONFIG_SYS_I2C_SPEED           100000 /* 100 kHz */
-#define CONFIG_SYS_I2C_SLAVE           0x7F
-
-/*
- * EEPROM configuration
- */
-#define CONFIG_SYS_I2C_EEPROM_ADDR             0x58
-#define CONFIG_SYS_I2C_EEPROM_ADDR_LEN         1
-#define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS      4
-#define CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS  10
-
-/*
- * RTC configuration
- */
-#define CONFIG_RTC_PCF8563
-#define CONFIG_SYS_I2C_RTC_ADDR                0x51
-
-#define CONFIG_SYS_DOC_BASE            0xE0000000
-#define CONFIG_SYS_DOC_SIZE            0x00100000
-
-#if defined(CONFIG_BOOT_ROM)
-/*
- * Flash configuration (8,16 or 32 MB)
- * TEXT base always at 0xFFF00000
- * ENV_ADDR always at  0xFFF40000
- * FLASH_BASE at 0xFA000000 for 64 MB
- *               0xFC000000 for 32 MB
- *               0xFD000000 for 16 MB
- *               0xFD800000 for  8 MB
- */
-#define CONFIG_SYS_FLASH_BASE          0xFA000000
-#define CONFIG_SYS_FLASH_SIZE          0x04000000
-#define CONFIG_SYS_BOOTROM_BASE        0xFFF00000
-#define CONFIG_SYS_BOOTROM_SIZE        0x00080000
-#define CONFIG_ENV_ADDR                (0xFDF00000 + 0x40000)
-#else
-/*
- * Flash configuration (8,16 or 32 MB)
- * TEXT base always at 0xFFF00000
- * ENV_ADDR always at  0xFFF40000
- * FLASH_BASE at 0xFC000000 for 64 MB
- *               0xFE000000 for 32 MB
- *               0xFF000000 for 16 MB
- *               0xFF800000 for  8 MB
- */
-#define CONFIG_SYS_FLASH_BASE          0xFC000000
-#define CONFIG_SYS_FLASH_SIZE          0x04000000
-#define CONFIG_ENV_ADDR                (0xFFF00000 + 0x40000)
-#endif
-#define CONFIG_SYS_MAX_FLASH_BANKS     1       /* max num of memory banks      */
-
-#define CONFIG_SYS_MAX_FLASH_SECT      256     /* max num of sects on one chip */
-
-#define CONFIG_SYS_FLASH_ERASE_TOUT    240000  /* Flash Erase Timeout (in ms)  */
-#define CONFIG_SYS_FLASH_WRITE_TOUT    500     /* Flash Write Timeout (in ms)  */
-#define CONFIG_SYS_FLASH_LOCK_TOUT     5       /* Timeout for Flash Set Lock Bit (in ms) */
-#define CONFIG_SYS_FLASH_UNLOCK_TOUT   10000   /* Timeout for Flash Clear Lock Bits (in ms) */
-#define CONFIG_SYS_FLASH_PROTECTION            /* "Real" (hardware) sectors protection */
-
-#define PHYS_FLASH_SECT_SIZE   0x00040000 /* 256 KB sectors (x2) */
-
-#undef CONFIG_FLASH_16BIT      /* Flash is 32-bit */
-
-
-/*
- * Environment settings
- */
-#define CONFIG_ENV_IS_IN_FLASH 1
-#define CONFIG_ENV_SIZE                0x10000
-#define CONFIG_ENV_SECT_SIZE   0x40000
-#define CONFIG_ENV_OVERWRITE   1
-
-/*
- * Memory map
- */
-#define CONFIG_SYS_MBAR                0xf0000000
-#define CONFIG_SYS_SDRAM_BASE          0x00000000
-#define CONFIG_SYS_DEFAULT_MBAR        0x80000000
-
-/* Use SRAM until RAM will be available */
-#define CONFIG_SYS_INIT_RAM_ADDR       MPC5XXX_SRAM
-#define CONFIG_SYS_INIT_RAM_SIZE       MPC5XXX_SRAM_SIZE       /* Size of used area in DPRAM */
-
-
-#define CONFIG_SYS_GBL_DATA_OFFSET     (CONFIG_SYS_INIT_RAM_SIZE - GENERATED_GBL_DATA_SIZE)
-#define CONFIG_SYS_INIT_SP_OFFSET      CONFIG_SYS_GBL_DATA_OFFSET
-
-#define CONFIG_SYS_MONITOR_BASE    CONFIG_SYS_TEXT_BASE
-#if (CONFIG_SYS_MONITOR_BASE < CONFIG_SYS_FLASH_BASE)
-#   define CONFIG_SYS_RAMBOOT          1
-#endif
-
-#define CONFIG_SYS_MONITOR_LEN         (256 << 10)     /* Reserve 256 kB for Monitor   */
-#define CONFIG_SYS_MALLOC_LEN          (128 << 10)     /* Reserve 128 kB for malloc()  */
-#define CONFIG_SYS_BOOTMAPSZ           (8 << 20)       /* Initial Memory map for Linux */
-
-/*
- * Ethernet configuration
- */
-#define CONFIG_MPC5xxx_FEC     1
-#define CONFIG_MPC5xxx_FEC_MII100
-/*
- * Define CONFIG_MPC5xxx_FEC_MII10 to force FEC at 10Mb
- */
-/* #define CONFIG_MPC5xxx_FEC_MII10 */
-#define CONFIG_PHY_ADDR                0x00
-
-/*
- * GPIO configuration
- */
-#define CONFIG_SYS_GPS_PORT_CONFIG     0x10000004
-
-/*
- * Miscellaneous configurable options
- */
-#define CONFIG_SYS_LONGHELP                    /* undef to save memory     */
-#if defined(CONFIG_CMD_KGDB)
-#define CONFIG_SYS_CBSIZE              1024    /* Console I/O Buffer Size  */
-#else
-#define CONFIG_SYS_CBSIZE              256     /* Console I/O Buffer Size  */
-#endif
-#define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE+sizeof(CONFIG_SYS_PROMPT)+16)     /* Print Buffer Size */
-#define CONFIG_SYS_MAXARGS             16              /* max number of command args   */
-#define CONFIG_SYS_BARGSIZE            CONFIG_SYS_CBSIZE       /* Boot Argument Buffer Size    */
-
-#define CONFIG_SYS_MEMTEST_START       0x00100000      /* memtest works on */
-#define CONFIG_SYS_MEMTEST_END         0x00f00000      /* 1 ... 15 MB in DRAM  */
-
-#define CONFIG_SYS_LOAD_ADDR           0x100000        /* default load address */
-
-#define CONFIG_SYS_CACHELINE_SIZE      32      /* For MPC5xxx CPUs */
-#if defined(CONFIG_CMD_KGDB)
-#  define CONFIG_SYS_CACHELINE_SHIFT   5       /* log base 2 of the above value */
-#endif
-
-/*
- * Various low-level settings
- */
-#define CONFIG_SYS_HID0_INIT           HID0_ICE | HID0_ICFI
-#define CONFIG_SYS_HID0_FINAL          HID0_ICE
-
-#if defined(CONFIG_BOOT_ROM)
-#define CONFIG_SYS_BOOTCS_START        CONFIG_SYS_BOOTROM_BASE
-#define CONFIG_SYS_BOOTCS_SIZE         CONFIG_SYS_BOOTROM_SIZE
-#define CONFIG_SYS_BOOTCS_CFG          0x00047800
-#define CONFIG_SYS_CS0_START           CONFIG_SYS_BOOTROM_BASE
-#define CONFIG_SYS_CS0_SIZE            CONFIG_SYS_BOOTROM_SIZE
-#define CONFIG_SYS_CS1_START           CONFIG_SYS_FLASH_BASE
-#define CONFIG_SYS_CS1_SIZE            CONFIG_SYS_FLASH_SIZE
-#define CONFIG_SYS_CS1_CFG             0x0004FF00
-#else
-#define CONFIG_SYS_BOOTCS_START        CONFIG_SYS_FLASH_BASE
-#define CONFIG_SYS_BOOTCS_SIZE         CONFIG_SYS_FLASH_SIZE
-#define CONFIG_SYS_BOOTCS_CFG          0x0004FF00
-#define CONFIG_SYS_CS0_START           CONFIG_SYS_FLASH_BASE
-#define CONFIG_SYS_CS0_SIZE            CONFIG_SYS_FLASH_SIZE
-#define CONFIG_SYS_CS1_START           CONFIG_SYS_DOC_BASE
-#define CONFIG_SYS_CS1_SIZE            CONFIG_SYS_DOC_SIZE
-#define CONFIG_SYS_CS1_CFG             0x00047800
-#endif
-
-#define CONFIG_SYS_CS_BURST            0x00000000
-#define CONFIG_SYS_CS_DEADCYCLE        0x33333333
-
-#define CONFIG_SYS_RESET_ADDRESS       0xff000000
-
-/*-----------------------------------------------------------------------
- * USB stuff
- *-----------------------------------------------------------------------
- */
-#define CONFIG_USB_CLOCK       0x0001BBBB
-#define CONFIG_USB_CONFIG      0x00005000
-
-/*-----------------------------------------------------------------------
- * IDE/ATA stuff Supports IDE harddisk
- *-----------------------------------------------------------------------
- */
-
-#undef  CONFIG_IDE_8xx_PCCARD          /* Use IDE with PC Card Adapter */
-
-#undef CONFIG_IDE_8xx_DIRECT           /* Direct IDE    not supported  */
-#undef CONFIG_IDE_LED                  /* LED   for ide not supported  */
-
-#undef CONFIG_IDE_RESET                /* reset for ide supported      */
-#define CONFIG_IDE_PREINIT
-
-#define CONFIG_SYS_IDE_MAXBUS          1       /* max. 1 IDE bus               */
-#define CONFIG_SYS_IDE_MAXDEVICE       2       /* max. 2 drive per IDE bus     */
-
-#define CONFIG_SYS_ATA_IDE0_OFFSET     0x0000
-
-#define CONFIG_SYS_ATA_BASE_ADDR       MPC5XXX_ATA
-
-/* Offset for data I/O                 */
-#define CONFIG_SYS_ATA_DATA_OFFSET     (0x0060)
-
-/* Offset for normal register accesses */
-#define CONFIG_SYS_ATA_REG_OFFSET      (CONFIG_SYS_ATA_DATA_OFFSET)
-
-/* Offset for alternate registers      */
-#define CONFIG_SYS_ATA_ALT_OFFSET      (0x005C)
-
-/* Interval between registers                                                */
-#define CONFIG_SYS_ATA_STRIDE          4
-
-#endif /* __CONFIG_H */
diff --git a/include/configs/PPChameleonEVB.h b/include/configs/PPChameleonEVB.h
deleted file mode 100644 (file)
index e277d0d..0000000
+++ /dev/null
@@ -1,777 +0,0 @@
-/*
- * (C) Copyright 2003-2005
- * Wolfgang Denk, DENX Software Engineering, <wd@denx.de>
- *
- * (C) Copyright 2003
- * DAVE Srl
- *
- * http://www.dave-tech.it
- * http://www.wawnet.biz
- * mailto:info@wawnet.biz
- *
- * Credits: Stefan Roese, Wolfgang Denk
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-/*
- * board/config.h - configuration options, board specific
- */
-
-#ifndef __CONFIG_H
-#define __CONFIG_H
-
-#define CONFIG_PPCHAMELEON_MODULE_BA   0       /* Basic    Model */
-#define CONFIG_PPCHAMELEON_MODULE_ME   1       /* Medium   Model */
-#define CONFIG_PPCHAMELEON_MODULE_HI   2       /* High-End Model */
-#ifndef CONFIG_PPCHAMELEON_MODULE_MODEL
-#define CONFIG_PPCHAMELEON_MODULE_MODEL CONFIG_PPCHAMELEON_MODULE_BA
-#endif
-
-
-/* Only one of the following two symbols must be defined (default is 25 MHz)
- * CONFIG_PPCHAMELEON_CLK_25
- * CONFIG_PPCHAMELEON_CLK_33
- */
-#if (!defined(CONFIG_PPCHAMELEON_CLK_25) && !defined(CONFIG_PPCHAMELEON_CLK_33))
-#define CONFIG_PPCHAMELEON_CLK_25
-#endif
-
-#if (defined(CONFIG_PPCHAMELEON_CLK_25) && defined(CONFIG_PPCHAMELEON_CLK_33))
-#error "* Two external frequencies (SysClk) are defined! *"
-#endif
-
-#undef CONFIG_PPCHAMELEON_SMI712
-
-/*
- * Debug stuff
- */
-#undef __DEBUG_START_FROM_SRAM__
-#define __DISABLE_MACHINE_EXCEPTION__
-
-#ifdef __DEBUG_START_FROM_SRAM__
-#define CONFIG_SYS_DUMMY_FLASH_SIZE            1024*1024*4
-#endif
-
-/*
- * High Level Configuration Options
- * (easy to change)
- */
-
-#define CONFIG_405EP           1       /* This is a PPC405 CPU         */
-#define CONFIG_PPCHAMELEONEVB  1       /* ...on a PPChameleonEVB board */
-
-#define        CONFIG_SYS_TEXT_BASE    0xFFFB0000      /* Reserve 320 kB for Monitor */
-#define CONFIG_SYS_LDSCRIPT    "board/dave/PPChameleonEVB/u-boot.lds"
-
-#define CONFIG_BOARD_EARLY_INIT_F 1    /* call board_early_init_f()    */
-#define CONFIG_MISC_INIT_R     1       /* call misc_init_r()           */
-
-
-#ifdef CONFIG_PPCHAMELEON_CLK_25
-# define CONFIG_SYS_CLK_FREQ   25000000 /* external frequency to pll   */
-#elif (defined (CONFIG_PPCHAMELEON_CLK_33))
-# define CONFIG_SYS_CLK_FREQ   33333333 /* external frequency to pll   */
-#else
-# error "* External frequency (SysClk) not defined! *"
-#endif
-
-#define CONFIG_BAUDRATE                115200
-#define CONFIG_BOOTDELAY       5       /* autoboot after 5 seconds     */
-
-#undef CONFIG_BOOTARGS
-
-/* Ethernet stuff */
-#define CONFIG_ENV_OVERWRITE /* Let the user to change the Ethernet MAC addresses */
-#define CONFIG_ETHADDR 00:50:c2:1e:af:fe
-#define CONFIG_HAS_ETH1
-#define CONFIG_ETH1ADDR 00:50:c2:1e:af:fd
-
-#define CONFIG_LOADS_ECHO      1       /* echo on for serial download  */
-#define CONFIG_SYS_LOADS_BAUD_CHANGE   1       /* allow baudrate change        */
-
-#undef CONFIG_EXT_PHY
-
-#define CONFIG_PPC4xx_EMAC
-#define CONFIG_MII             1       /* MII PHY management           */
-#ifndef         CONFIG_EXT_PHY
-#define CONFIG_PHY_ADDR                1       /* EMAC0 PHY address            */
-#define CONFIG_PHY1_ADDR       2       /* EMAC1 PHY address            */
-#else
-#define CONFIG_PHY_ADDR                2       /* PHY address                  */
-#endif
-#define CONFIG_PHY_CLK_FREQ    EMAC_STACR_CLK_66MHZ
-
-
-/*
- * BOOTP options
- */
-#define CONFIG_BOOTP_BOOTFILESIZE
-#define CONFIG_BOOTP_BOOTPATH
-#define CONFIG_BOOTP_GATEWAY
-#define CONFIG_BOOTP_HOSTNAME
-
-
-/*
- * Command line configuration.
- */
-#include <config_cmd_default.h>
-
-#define CONFIG_CMD_DATE
-#define CONFIG_CMD_DHCP
-#define CONFIG_CMD_ELF
-#define CONFIG_CMD_EEPROM
-#define CONFIG_CMD_I2C
-#define CONFIG_CMD_IRQ
-#define CONFIG_CMD_JFFS2
-#define CONFIG_CMD_MII
-#define CONFIG_CMD_NAND
-#define CONFIG_CMD_NFS
-#define CONFIG_CMD_PCI
-#define CONFIG_CMD_SNTP
-
-
-#define CONFIG_MAC_PARTITION
-#define CONFIG_DOS_PARTITION
-
-#undef CONFIG_WATCHDOG                 /* watchdog disabled            */
-
-#define CONFIG_RTC_M41T11      1       /* uses a M41T00 RTC            */
-#define CONFIG_SYS_I2C_RTC_ADDR        0x68
-#define CONFIG_SYS_M41T11_BASE_YEAR    1900
-
-/*
- * SDRAM configuration (please see cpu/ppc/sdram.[ch])
- */
-#define CONFIG_SDRAM_BANK0     1       /* init onboard SDRAM bank 0    */
-
-/* SDRAM timings used in datasheet */
-#define CONFIG_SYS_SDRAM_CL            2
-#define CONFIG_SYS_SDRAM_tRP           20
-#define CONFIG_SYS_SDRAM_tRC           65
-#define CONFIG_SYS_SDRAM_tRCD          20
-#undef  CONFIG_SYS_SDRAM_tRFC
-
-/*
- * Miscellaneous configurable options
- */
-#define CONFIG_SYS_LONGHELP                    /* undef to save memory         */
-
-#undef CONFIG_SYS_HUSH_PARSER                  /* use "hush" command parser    */
-
-#if defined(CONFIG_CMD_KGDB)
-#define CONFIG_SYS_CBSIZE      1024            /* Console I/O Buffer Size      */
-#else
-#define CONFIG_SYS_CBSIZE      256             /* Console I/O Buffer Size      */
-#endif
-#define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE+sizeof(CONFIG_SYS_PROMPT)+16) /* Print Buffer Size */
-#define CONFIG_SYS_MAXARGS     16              /* max number of command args   */
-#define CONFIG_SYS_BARGSIZE    CONFIG_SYS_CBSIZE       /* Boot Argument Buffer Size    */
-
-#define CONFIG_SYS_DEVICE_NULLDEV      1       /* include nulldev device       */
-
-#define CONFIG_SYS_CONSOLE_INFO_QUIET  1       /* don't print console @ startup*/
-
-#define CONFIG_SYS_MEMTEST_START       0x0400000       /* memtest works on     */
-#define CONFIG_SYS_MEMTEST_END         0x0C00000       /* 4 ... 12 MB in DRAM  */
-
-#define CONFIG_CONS_INDEX      1       /* Use UART0                    */
-#define CONFIG_SYS_NS16550
-#define CONFIG_SYS_NS16550_SERIAL
-#define CONFIG_SYS_NS16550_REG_SIZE    1
-#define CONFIG_SYS_NS16550_CLK         get_serial_clock()
-
-#undef CONFIG_SYS_EXT_SERIAL_CLOCK             /* no external serial clock used */
-#define CONFIG_SYS_BASE_BAUD           691200
-
-/* The following table includes the supported baudrates */
-#define CONFIG_SYS_BAUDRATE_TABLE      \
-       { 300, 600, 1200, 2400, 4800, 9600, 19200, 38400,     \
-        57600, 115200, 230400, 460800, 921600 }
-
-#define CONFIG_SYS_LOAD_ADDR   0x100000        /* default load address */
-#define CONFIG_SYS_EXTBDINFO   1               /* To use extended board_into (bd_t) */
-
-#define CONFIG_ZERO_BOOTDELAY_CHECK    /* check for keypress on bootdelay==0 */
-
-/*-----------------------------------------------------------------------
- * NAND-FLASH stuff
- *-----------------------------------------------------------------------
- */
-
-/*
- * nand device 1 on dave (PPChameleonEVB) needs more time,
- * so we just introduce additional wait in nand_wait(),
- * effectively for both devices.
- */
-#define PPCHAMELON_NAND_TIMER_HACK
-
-#define CONFIG_SYS_NAND0_BASE 0xFF400000
-#define CONFIG_SYS_NAND1_BASE 0xFF000000
-#define CONFIG_SYS_NAND_BASE_LIST      { CONFIG_SYS_NAND0_BASE, CONFIG_SYS_NAND1_BASE }
-#define NAND_BIG_DELAY_US      25
-#define CONFIG_SYS_MAX_NAND_DEVICE     2       /* Max number of NAND devices */
-
-#define CONFIG_SYS_NAND0_CE  (0x80000000 >> 1)  /* our CE is GPIO1 */
-#define CONFIG_SYS_NAND0_RDY (0x80000000 >> 4)  /* our RDY is GPIO4 */
-#define CONFIG_SYS_NAND0_CLE (0x80000000 >> 2)  /* our CLE is GPIO2 */
-#define CONFIG_SYS_NAND0_ALE (0x80000000 >> 3)  /* our ALE is GPIO3 */
-
-#define CONFIG_SYS_NAND1_CE  (0x80000000 >> 14)  /* our CE is GPIO14 */
-#define CONFIG_SYS_NAND1_RDY (0x80000000 >> 31)  /* our RDY is GPIO31 */
-#define CONFIG_SYS_NAND1_CLE (0x80000000 >> 15)  /* our CLE is GPIO15 */
-#define CONFIG_SYS_NAND1_ALE (0x80000000 >> 16)  /* our ALE is GPIO16 */
-
-#define MACRO_NAND_DISABLE_CE(nandptr) do \
-{ \
-       switch((unsigned long)nandptr) \
-       { \
-           case CONFIG_SYS_NAND0_BASE: \
-               out32(GPIO0_OR, in32(GPIO0_OR) | CONFIG_SYS_NAND0_CE); \
-               break; \
-           case CONFIG_SYS_NAND1_BASE: \
-               out32(GPIO0_OR, in32(GPIO0_OR) | CONFIG_SYS_NAND1_CE); \
-               break; \
-       } \
-} while(0)
-
-#define MACRO_NAND_ENABLE_CE(nandptr) do \
-{ \
-       switch((unsigned long)nandptr) \
-       { \
-           case CONFIG_SYS_NAND0_BASE: \
-               out32(GPIO0_OR, in32(GPIO0_OR) & ~CONFIG_SYS_NAND0_CE); \
-               break; \
-           case CONFIG_SYS_NAND1_BASE: \
-               out32(GPIO0_OR, in32(GPIO0_OR) & ~CONFIG_SYS_NAND1_CE); \
-               break; \
-       } \
-} while(0)
-
-#define MACRO_NAND_CTL_CLRALE(nandptr) do \
-{ \
-       switch((unsigned long)nandptr) \
-       { \
-           case CONFIG_SYS_NAND0_BASE: \
-               out32(GPIO0_OR, in32(GPIO0_OR) & ~CONFIG_SYS_NAND0_ALE); \
-               break; \
-           case CONFIG_SYS_NAND1_BASE: \
-               out32(GPIO0_OR, in32(GPIO0_OR) & ~CONFIG_SYS_NAND1_ALE); \
-               break; \
-       } \
-} while(0)
-
-#define MACRO_NAND_CTL_SETALE(nandptr) do \
-{ \
-       switch((unsigned long)nandptr) \
-       { \
-           case CONFIG_SYS_NAND0_BASE: \
-               out32(GPIO0_OR, in32(GPIO0_OR) | CONFIG_SYS_NAND0_ALE); \
-               break; \
-           case CONFIG_SYS_NAND1_BASE: \
-               out32(GPIO0_OR, in32(GPIO0_OR) | CONFIG_SYS_NAND1_ALE); \
-               break; \
-       } \
-} while(0)
-
-#define MACRO_NAND_CTL_CLRCLE(nandptr) do \
-{ \
-       switch((unsigned long)nandptr) \
-       { \
-           case CONFIG_SYS_NAND0_BASE: \
-               out32(GPIO0_OR, in32(GPIO0_OR) & ~CONFIG_SYS_NAND0_CLE); \
-               break; \
-           case CONFIG_SYS_NAND1_BASE: \
-               out32(GPIO0_OR, in32(GPIO0_OR) & ~CONFIG_SYS_NAND1_CLE); \
-               break; \
-       } \
-} while(0)
-
-#define MACRO_NAND_CTL_SETCLE(nandptr) do { \
-       switch((unsigned long)nandptr) { \
-       case CONFIG_SYS_NAND0_BASE: \
-               out32(GPIO0_OR, in32(GPIO0_OR) | CONFIG_SYS_NAND0_CLE); \
-               break; \
-       case CONFIG_SYS_NAND1_BASE: \
-               out32(GPIO0_OR, in32(GPIO0_OR) | CONFIG_SYS_NAND1_CLE); \
-               break; \
-       } \
-} while(0)
-
-/*-----------------------------------------------------------------------
- * PCI stuff
- *-----------------------------------------------------------------------
- */
-#define PCI_HOST_ADAPTER 0             /* configure as pci adapter     */
-#define PCI_HOST_FORCE 1               /* configure as pci host        */
-#define PCI_HOST_AUTO  2               /* detected via arbiter enable  */
-
-#define CONFIG_PCI                     /* include pci support          */
-#define CONFIG_PCI_INDIRECT_BRIDGE     /* indirect PCI bridge support */
-#define CONFIG_PCI_HOST PCI_HOST_FORCE  /* select pci host function     */
-#undef CONFIG_PCI_PNP                  /* do pci plug-and-play         */
-                                       /* resource configuration       */
-
-#define CONFIG_PCI_SCAN_SHOW           /* print pci devices @ startup  */
-
-#define CONFIG_SYS_PCI_SUBSYS_VENDORID 0x1014  /* PCI Vendor ID: IBM   */
-#define CONFIG_SYS_PCI_SUBSYS_DEVICEID 0x0000  /* PCI Device ID: ---   */
-#define CONFIG_SYS_PCI_CLASSCODE       0x0b20  /* PCI Class Code: Processor/PPC*/
-
-#define CONFIG_SYS_PCI_PTM1LA  0x00000000      /* point to sdram               */
-#define CONFIG_SYS_PCI_PTM1MS  0xfc000001      /* 64MB, enable hard-wired to 1 */
-#define CONFIG_SYS_PCI_PTM1PCI 0x00000000      /* Host: use this pci address   */
-#define CONFIG_SYS_PCI_PTM2LA  0xffc00000      /* point to flash               */
-#define CONFIG_SYS_PCI_PTM2MS  0xffc00001      /* 4MB, enable                  */
-#define CONFIG_SYS_PCI_PTM2PCI 0x04000000      /* Host: use this pci address   */
-
-/*-----------------------------------------------------------------------
- * 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
-
-/* Reserve 256 kB for Monitor  */
-/*
-#define CONFIG_SYS_FLASH_BASE          0xFFFC0000
-#define CONFIG_SYS_MONITOR_BASE        CONFIG_SYS_FLASH_BASE
-#define CONFIG_SYS_MONITOR_LEN         (256 * 1024)
-*/
-
-/* Reserve 320 kB for Monitor  */
-#define CONFIG_SYS_FLASH_BASE          0xFFFB0000
-#define CONFIG_SYS_MONITOR_BASE        CONFIG_SYS_FLASH_BASE
-#define CONFIG_SYS_MONITOR_LEN         (320 * 1024)
-
-#define CONFIG_SYS_MALLOC_LEN          (256 * 1024)    /* Reserve 256 kB for malloc()  */
-
-/*
- * 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.
- */
-#define CONFIG_SYS_BOOTMAPSZ           (8 << 20)       /* Initial Memory map for Linux */
-/*-----------------------------------------------------------------------
- * FLASH organization
- */
-#define CONFIG_SYS_MAX_FLASH_BANKS     1       /* max number of memory banks           */
-#define CONFIG_SYS_MAX_FLASH_SECT      256     /* max number of sectors on one chip    */
-
-#define CONFIG_SYS_FLASH_ERASE_TOUT    120000  /* Timeout for Flash Erase (in ms)      */
-#define CONFIG_SYS_FLASH_WRITE_TOUT    1000    /* Timeout for Flash Write (in ms)      */
-
-#define CONFIG_SYS_FLASH_WORD_SIZE     unsigned short  /* flash word size (width)      */
-#define CONFIG_SYS_FLASH_ADDR0         0x5555  /* 1st address for flash config cycles  */
-#define CONFIG_SYS_FLASH_ADDR1         0x2AAA  /* 2nd address for flash config cycles  */
-/*
- * The following defines are added for buggy IOP480 byte interface.
- * All other boards should use the standard values (CPCI405 etc.)
- */
-#define CONFIG_SYS_FLASH_READ0         0x0000  /* 0 is standard                        */
-#define CONFIG_SYS_FLASH_READ1         0x0001  /* 1 is standard                        */
-#define CONFIG_SYS_FLASH_READ2         0x0002  /* 2 is standard                        */
-
-#define CONFIG_SYS_FLASH_EMPTY_INFO            /* print 'E' for empty sector on flinfo */
-
-/*-----------------------------------------------------------------------
- * Environment Variable setup
- */
-#ifdef ENVIRONMENT_IN_EEPROM
-
-#define CONFIG_ENV_IS_IN_EEPROM        1       /* use EEPROM for environment vars */
-#define CONFIG_ENV_OFFSET              0x100   /* environment starts at the beginning of the EEPROM */
-#define CONFIG_ENV_SIZE                0x700   /* 2048-256 bytes may be used for env vars (total size of a CAT24WC16 is 2048 bytes)*/
-
-#else  /* DEFAULT: environment in flash, using redundand flash sectors */
-
-#define CONFIG_ENV_IS_IN_FLASH 1       /* use FLASH for environment vars */
-#define CONFIG_ENV_ADDR                0xFFFF8000      /* environment starts at the first small sector */
-#define CONFIG_ENV_SECT_SIZE   0x2000  /* 8196 bytes may be used for env vars*/
-#define CONFIG_ENV_ADDR_REDUND 0xFFFFA000
-#define CONFIG_ENV_SIZE_REDUND 0x2000
-
-#define        CONFIG_SYS_USE_PPCENV                   /* Environment embedded in sect .ppcenv */
-
-#endif /* ENVIRONMENT_IN_EEPROM */
-
-
-#define CONFIG_SYS_NVRAM_BASE_ADDR     0xF0000500              /* NVRAM base address   */
-#define CONFIG_SYS_NVRAM_SIZE          242                     /* NVRAM size           */
-
-/*-----------------------------------------------------------------------
- * I2C EEPROM (CAT24WC16) for environment
- */
-#define CONFIG_SYS_I2C
-#define CONFIG_SYS_I2C_PPC4XX
-#define CONFIG_SYS_I2C_PPC4XX_CH0
-#define CONFIG_SYS_I2C_PPC4XX_SPEED_0          400000
-#define CONFIG_SYS_I2C_PPC4XX_SLAVE_0          0x7F
-
-#define CONFIG_SYS_I2C_EEPROM_ADDR     0x50    /* EEPROM CAT28WC08             */
-#define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1       /* Bytes of address             */
-/* mask of address bits that overflow into the "EEPROM chip address"   */
-/*#define CONFIG_SYS_I2C_EEPROM_ADDR_OVERFLOW  0x07*/
-#define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS 4    /* The Catalyst CAT24WC08 has   */
-                                       /* 16 byte page write mode using*/
-                                       /* last 4 bits of the address   */
-#define CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS  10   /* and takes up to 10 msec */
-
-/*
- * Init Memory Controller:
- *
- * BR0/1 and OR0/1 (FLASH)
- */
-
-#define FLASH_BASE0_PRELIM     0xFFC00000      /* FLASH bank #0        */
-
-/*-----------------------------------------------------------------------
- * External Bus Controller (EBC) Setup
- */
-
-/* Memory Bank 0 (Flash Bank 0, NOR-FLASH) initialization                      */
-#define CONFIG_SYS_EBC_PB0AP           0x92015480
-#define CONFIG_SYS_EBC_PB0CR           0xFFC5A000  /* BAS=0xFFC,BS=4MB,BU=R/W,BW=16bit */
-
-/* Memory Bank 1 (External SRAM) initialization                                        */
-/* Since this must replace NOR Flash, we use the same settings for CS0         */
-#define CONFIG_SYS_EBC_PB1AP           0x92015480
-#define CONFIG_SYS_EBC_PB1CR           0xFF85A000  /* BAS=0xFF8,BS=4MB,BU=R/W,BW=8bit  */
-
-/* Memory Bank 2 (Flash Bank 1, NAND-FLASH) initialization                     */
-#define CONFIG_SYS_EBC_PB2AP           0x92015480
-#define CONFIG_SYS_EBC_PB2CR           0xFF458000  /* BAS=0xFF4,BS=4MB,BU=R/W,BW=8bit  */
-
-/* Memory Bank 3 (Flash Bank 2, NAND-FLASH) initialization                     */
-#define CONFIG_SYS_EBC_PB3AP           0x92015480
-#define CONFIG_SYS_EBC_PB3CR           0xFF058000  /* BAS=0xFF0,BS=4MB,BU=R/W,BW=8bit  */
-
-#ifdef CONFIG_PPCHAMELEON_SMI712
-/*
- * Video console (graphic: SMI LynxEM)
- */
-#define CONFIG_VIDEO
-#define CONFIG_CFB_CONSOLE
-#define CONFIG_VIDEO_SMI_LYNXEM
-#define CONFIG_VIDEO_LOGO
-/*#define CONFIG_VIDEO_BMP_LOGO*/
-#define CONFIG_CONSOLE_EXTRA_INFO
-#define CONFIG_VGA_AS_SINGLE_DEVICE
-/* This is the base address (on 405EP-side) used to generate I/O accesses on PCI bus */
-#define CONFIG_SYS_ISA_IO 0xE8000000
-/* see also drivers/video/videomodes.c */
-#define CONFIG_SYS_DEFAULT_VIDEO_MODE 0x303
-#endif
-
-/*-----------------------------------------------------------------------
- * FPGA stuff
- */
-/* FPGA internal regs */
-#define CONFIG_SYS_FPGA_MODE           0x00
-#define CONFIG_SYS_FPGA_STATUS         0x02
-#define CONFIG_SYS_FPGA_TS             0x04
-#define CONFIG_SYS_FPGA_TS_LOW         0x06
-#define CONFIG_SYS_FPGA_TS_CAP0        0x10
-#define CONFIG_SYS_FPGA_TS_CAP0_LOW    0x12
-#define CONFIG_SYS_FPGA_TS_CAP1        0x14
-#define CONFIG_SYS_FPGA_TS_CAP1_LOW    0x16
-#define CONFIG_SYS_FPGA_TS_CAP2        0x18
-#define CONFIG_SYS_FPGA_TS_CAP2_LOW    0x1a
-#define CONFIG_SYS_FPGA_TS_CAP3        0x1c
-#define CONFIG_SYS_FPGA_TS_CAP3_LOW    0x1e
-
-/* FPGA Mode Reg */
-#define CONFIG_SYS_FPGA_MODE_CF_RESET  0x0001
-#define CONFIG_SYS_FPGA_MODE_TS_IRQ_ENABLE 0x0100
-#define CONFIG_SYS_FPGA_MODE_TS_IRQ_CLEAR  0x1000
-#define CONFIG_SYS_FPGA_MODE_TS_CLEAR  0x2000
-
-/* FPGA Status Reg */
-#define CONFIG_SYS_FPGA_STATUS_DIP0    0x0001
-#define CONFIG_SYS_FPGA_STATUS_DIP1    0x0002
-#define CONFIG_SYS_FPGA_STATUS_DIP2    0x0004
-#define CONFIG_SYS_FPGA_STATUS_FLASH   0x0008
-#define CONFIG_SYS_FPGA_STATUS_TS_IRQ  0x1000
-
-#define CONFIG_SYS_FPGA_SPARTAN2       1               /* using Xilinx Spartan 2 now    */
-#define CONFIG_SYS_FPGA_MAX_SIZE       128*1024        /* 128kByte is enough for XC2S50E*/
-
-/* FPGA program pin configuration */
-#define CONFIG_SYS_FPGA_PRG            0x04000000      /* FPGA program pin (ppc output) */
-#define CONFIG_SYS_FPGA_CLK            0x02000000      /* FPGA clk pin (ppc output)     */
-#define CONFIG_SYS_FPGA_DATA           0x01000000      /* FPGA data pin (ppc output)    */
-#define CONFIG_SYS_FPGA_INIT           0x00010000      /* FPGA init pin (ppc input)     */
-#define CONFIG_SYS_FPGA_DONE           0x00008000      /* FPGA done pin (ppc input)     */
-
-/*-----------------------------------------------------------------------
- * Definitions for initial stack pointer and data area (in data cache)
- */
-/* use on chip memory ( OCM ) for temperary stack until sdram is tested */
-#define CONFIG_SYS_TEMP_STACK_OCM      1
-
-/* On Chip Memory location */
-#define CONFIG_SYS_OCM_DATA_ADDR       0xF8000000
-#define CONFIG_SYS_OCM_DATA_SIZE       0x1000
-#define CONFIG_SYS_INIT_RAM_ADDR       CONFIG_SYS_OCM_DATA_ADDR /* inside of SDRAM             */
-#define CONFIG_SYS_INIT_RAM_SIZE       CONFIG_SYS_OCM_DATA_SIZE /* Size of used area in RAM    */
-
-#define CONFIG_SYS_GBL_DATA_OFFSET    (CONFIG_SYS_INIT_RAM_SIZE - GENERATED_GBL_DATA_SIZE)
-#define CONFIG_SYS_INIT_SP_OFFSET      CONFIG_SYS_GBL_DATA_OFFSET
-
-/*-----------------------------------------------------------------------
- * Definitions for GPIO setup (PPC405EP specific)
- *
- * GPIO0[0]    - External Bus Controller BLAST output
- * GPIO0[1-9]  - Instruction trace outputs -> GPIO
- * GPIO0[10-13] - External Bus Controller CS_1 - CS_4 outputs
- * GPIO0[14-16] - External Bus Controller ABUS3-ABUS5 outputs -> GPIO
- * GPIO0[17-23] - External Interrupts IRQ0 - IRQ6 inputs
- * GPIO0[24-27] - UART0 control signal inputs/outputs
- * GPIO0[28-29] - UART1 data signal input/output
- * GPIO0[30]   - EMAC0 input
- * GPIO0[31]   - EMAC1 reject packet as output
- */
-#define CONFIG_SYS_GPIO0_OSRL          0x40000550
-#define CONFIG_SYS_GPIO0_OSRH          0x00000110
-#define CONFIG_SYS_GPIO0_ISR1L         0x00000000
-/*#define CONFIG_SYS_GPIO0_ISR1H       0x15555445*/
-#define CONFIG_SYS_GPIO0_ISR1H         0x15555444
-#define CONFIG_SYS_GPIO0_TSRL          0x00000000
-#define CONFIG_SYS_GPIO0_TSRH          0x00000000
-#define CONFIG_SYS_GPIO0_TCR           0xF7FF8014
-
-#define CONFIG_NO_SERIAL_EEPROM
-
-/*--------------------------------------------------------------------*/
-
-#ifdef CONFIG_NO_SERIAL_EEPROM
-
-/*
-!-----------------------------------------------------------------------
-! Defines for entry options.
-! Note: Because the 405EP SDRAM controller does not support ECC, ECC DIMMs that
-!      are plugged in the board will be utilized as non-ECC DIMMs.
-!-----------------------------------------------------------------------
-*/
-#undef         AUTO_MEMORY_CONFIG
-#define                DIMM_READ_ADDR 0xAB
-#define                DIMM_WRITE_ADDR 0xAA
-
-/* Defines for CPC0_PLLMR1 Register fields */
-#define PLL_ACTIVE             0x80000000
-#define CPC0_PLLMR1_SSCS       0x80000000
-#define PLL_RESET              0x40000000
-#define CPC0_PLLMR1_PLLR       0x40000000
-    /* Feedback multiplier */
-#define PLL_FBKDIV             0x00F00000
-#define CPC0_PLLMR1_FBDV       0x00F00000
-#define PLL_FBKDIV_16          0x00000000
-#define PLL_FBKDIV_1           0x00100000
-#define PLL_FBKDIV_2           0x00200000
-#define PLL_FBKDIV_3           0x00300000
-#define PLL_FBKDIV_4           0x00400000
-#define PLL_FBKDIV_5           0x00500000
-#define PLL_FBKDIV_6           0x00600000
-#define PLL_FBKDIV_7           0x00700000
-#define PLL_FBKDIV_8           0x00800000
-#define PLL_FBKDIV_9           0x00900000
-#define PLL_FBKDIV_10          0x00A00000
-#define PLL_FBKDIV_11          0x00B00000
-#define PLL_FBKDIV_12          0x00C00000
-#define PLL_FBKDIV_13          0x00D00000
-#define PLL_FBKDIV_14          0x00E00000
-#define PLL_FBKDIV_15          0x00F00000
-    /* Forward A divisor */
-#define PLL_FWDDIVA            0x00070000
-#define CPC0_PLLMR1_FWDVA      0x00070000
-#define PLL_FWDDIVA_8          0x00000000
-#define PLL_FWDDIVA_7          0x00010000
-#define PLL_FWDDIVA_6          0x00020000
-#define PLL_FWDDIVA_5          0x00030000
-#define PLL_FWDDIVA_4          0x00040000
-#define PLL_FWDDIVA_3          0x00050000
-#define PLL_FWDDIVA_2          0x00060000
-#define PLL_FWDDIVA_1          0x00070000
-    /* Forward B divisor */
-#define PLL_FWDDIVB            0x00007000
-#define CPC0_PLLMR1_FWDVB      0x00007000
-#define PLL_FWDDIVB_8          0x00000000
-#define PLL_FWDDIVB_7          0x00001000
-#define PLL_FWDDIVB_6          0x00002000
-#define PLL_FWDDIVB_5          0x00003000
-#define PLL_FWDDIVB_4          0x00004000
-#define PLL_FWDDIVB_3          0x00005000
-#define PLL_FWDDIVB_2          0x00006000
-#define PLL_FWDDIVB_1          0x00007000
-    /* PLL tune bits */
-#define PLL_TUNE_MASK          0x000003FF
-#define PLL_TUNE_2_M_3         0x00000133      /*  2 <= M <= 3                 */
-#define PLL_TUNE_4_M_6         0x00000134      /*  3 <  M <= 6                 */
-#define PLL_TUNE_7_M_10                0x00000138      /*  6 <  M <= 10                */
-#define PLL_TUNE_11_M_14       0x0000013C      /* 10 <  M <= 14                */
-#define PLL_TUNE_15_M_40       0x0000023E      /* 14 <  M <= 40                */
-#define PLL_TUNE_VCO_LOW       0x00000000      /* 500MHz <= VCO <=  800MHz     */
-#define PLL_TUNE_VCO_HI                0x00000080      /* 800MHz <  VCO <= 1000MHz     */
-
-/* Defines for CPC0_PLLMR0 Register fields */
-    /* CPU divisor */
-#define PLL_CPUDIV             0x00300000
-#define CPC0_PLLMR0_CCDV       0x00300000
-#define PLL_CPUDIV_1           0x00000000
-#define PLL_CPUDIV_2           0x00100000
-#define PLL_CPUDIV_3           0x00200000
-#define PLL_CPUDIV_4           0x00300000
-    /* PLB divisor */
-#define PLL_PLBDIV             0x00030000
-#define CPC0_PLLMR0_CBDV       0x00030000
-#define PLL_PLBDIV_1           0x00000000
-#define PLL_PLBDIV_2           0x00010000
-#define PLL_PLBDIV_3           0x00020000
-#define PLL_PLBDIV_4           0x00030000
-    /* OPB divisor */
-#define PLL_OPBDIV             0x00003000
-#define CPC0_PLLMR0_OPDV       0x00003000
-#define PLL_OPBDIV_1           0x00000000
-#define PLL_OPBDIV_2           0x00001000
-#define PLL_OPBDIV_3           0x00002000
-#define PLL_OPBDIV_4           0x00003000
-    /* EBC divisor */
-#define PLL_EXTBUSDIV          0x00000300
-#define CPC0_PLLMR0_EPDV       0x00000300
-#define PLL_EXTBUSDIV_2                0x00000000
-#define PLL_EXTBUSDIV_3                0x00000100
-#define PLL_EXTBUSDIV_4                0x00000200
-#define PLL_EXTBUSDIV_5                0x00000300
-    /* MAL divisor */
-#define PLL_MALDIV             0x00000030
-#define CPC0_PLLMR0_MPDV       0x00000030
-#define PLL_MALDIV_1           0x00000000
-#define PLL_MALDIV_2           0x00000010
-#define PLL_MALDIV_3           0x00000020
-#define PLL_MALDIV_4           0x00000030
-    /* PCI divisor */
-#define PLL_PCIDIV             0x00000003
-#define CPC0_PLLMR0_PPFD       0x00000003
-#define PLL_PCIDIV_1           0x00000000
-#define PLL_PCIDIV_2           0x00000001
-#define PLL_PCIDIV_3           0x00000002
-#define PLL_PCIDIV_4           0x00000003
-
-#ifdef CONFIG_PPCHAMELEON_CLK_25
-/* CPU - PLB/SDRAM - EBC - OPB - PCI (assuming a 25.0 MHz input clock to the 405EP) */
-#define PPCHAMELEON_PLLMR0_133_133_33_66_33     (PLL_CPUDIV_1 | PLL_PLBDIV_1 |  \
-                             PLL_OPBDIV_2 | PLL_EXTBUSDIV_4 |  \
-                             PLL_MALDIV_1 | PLL_PCIDIV_4)
-#define PPCHAMELEON_PLLMR1_133_133_33_66_33     (PLL_FBKDIV_8  |  \
-                             PLL_FWDDIVA_6 | PLL_FWDDIVB_4 |  \
-                             PLL_TUNE_15_M_40 | PLL_TUNE_VCO_LOW)
-
-#define PPCHAMELEON_PLLMR0_200_100_50_33 (PLL_CPUDIV_1 | PLL_PLBDIV_2 |  \
-                             PLL_OPBDIV_2 | PLL_EXTBUSDIV_3 |  \
-                             PLL_MALDIV_1 | PLL_PCIDIV_4)
-#define PPCHAMELEON_PLLMR1_200_100_50_33 (PLL_FBKDIV_8  |  \
-                             PLL_FWDDIVA_4 | PLL_FWDDIVB_4 |  \
-                             PLL_TUNE_15_M_40 | PLL_TUNE_VCO_LOW)
-
-#define PPCHAMELEON_PLLMR0_266_133_33_66_33 (PLL_CPUDIV_1 | PLL_PLBDIV_2 |     \
-                             PLL_OPBDIV_2 | PLL_EXTBUSDIV_4 |  \
-                             PLL_MALDIV_1 | PLL_PCIDIV_4)
-#define PPCHAMELEON_PLLMR1_266_133_33_66_33 (PLL_FBKDIV_8  |  \
-                             PLL_FWDDIVA_3 | PLL_FWDDIVB_4 |  \
-                             PLL_TUNE_15_M_40 | PLL_TUNE_VCO_LOW)
-
-#define PPCHAMELEON_PLLMR0_333_111_37_55_55 (PLL_CPUDIV_1 | PLL_PLBDIV_3 |     \
-                             PLL_OPBDIV_2 | PLL_EXTBUSDIV_3 |  \
-                             PLL_MALDIV_1 | PLL_PCIDIV_2)
-#define PPCHAMELEON_PLLMR1_333_111_37_55_55 (PLL_FBKDIV_10     |  \
-                             PLL_FWDDIVA_3 | PLL_FWDDIVB_4 |  \
-                             PLL_TUNE_15_M_40 | PLL_TUNE_VCO_HI)
-
-#elif (defined (CONFIG_PPCHAMELEON_CLK_33))
-
-/* CPU - PLB/SDRAM - EBC - OPB - PCI (assuming a 33.3MHz input clock to the 405EP) */
-#define PPCHAMELEON_PLLMR0_133_133_33_66_33     (PLL_CPUDIV_1 | PLL_PLBDIV_1 |  \
-                                 PLL_OPBDIV_2 | PLL_EXTBUSDIV_4 |      \
-                                 PLL_MALDIV_1 | PLL_PCIDIV_4)
-#define PPCHAMELEON_PLLMR1_133_133_33_66_33     (PLL_FBKDIV_4  |  \
-                                 PLL_FWDDIVA_6 | PLL_FWDDIVB_6 |  \
-                                 PLL_TUNE_15_M_40 | PLL_TUNE_VCO_LOW)
-
-#define PPCHAMELEON_PLLMR0_200_100_50_33 (PLL_CPUDIV_1 | PLL_PLBDIV_2 |  \
-                                 PLL_OPBDIV_2 | PLL_EXTBUSDIV_3 |      \
-                                 PLL_MALDIV_1 | PLL_PCIDIV_4)
-#define PPCHAMELEON_PLLMR1_200_100_50_33 (PLL_FBKDIV_6  |  \
-                                 PLL_FWDDIVA_4 | PLL_FWDDIVB_4 |  \
-                                 PLL_TUNE_15_M_40 | PLL_TUNE_VCO_LOW)
-
-#define PPCHAMELEON_PLLMR0_266_133_33_66_33 (PLL_CPUDIV_1 | PLL_PLBDIV_2 |     \
-                                 PLL_OPBDIV_2 | PLL_EXTBUSDIV_4 |      \
-                                 PLL_MALDIV_1 | PLL_PCIDIV_4)
-#define PPCHAMELEON_PLLMR1_266_133_33_66_33 (PLL_FBKDIV_8  |  \
-                                 PLL_FWDDIVA_3 | PLL_FWDDIVB_3 |  \
-                                 PLL_TUNE_15_M_40 | PLL_TUNE_VCO_LOW)
-
-#define PPCHAMELEON_PLLMR0_333_111_37_55_55 (PLL_CPUDIV_1 | PLL_PLBDIV_3 |     \
-                                 PLL_OPBDIV_2 | PLL_EXTBUSDIV_3 |      \
-                                 PLL_MALDIV_1 | PLL_PCIDIV_2)
-#define PPCHAMELEON_PLLMR1_333_111_37_55_55 (PLL_FBKDIV_10     |  \
-                                 PLL_FWDDIVA_3 | PLL_FWDDIVB_3 |  \
-                                 PLL_TUNE_15_M_40 | PLL_TUNE_VCO_HI)
-
-#else
-#error "* External frequency (SysClk) not defined! *"
-#endif
-
-#if   (CONFIG_PPCHAMELEON_MODULE_MODEL == CONFIG_PPCHAMELEON_MODULE_HI)
-/* Model HI */
-#define PLLMR0_DEFAULT PPCHAMELEON_PLLMR0_333_111_37_55_55
-#define PLLMR1_DEFAULT PPCHAMELEON_PLLMR1_333_111_37_55_55
-#define CONFIG_SYS_OPB_FREQ    55555555
-/* Model ME */
-#elif (CONFIG_PPCHAMELEON_MODULE_MODEL == CONFIG_PPCHAMELEON_MODULE_ME)
-#define PLLMR0_DEFAULT PPCHAMELEON_PLLMR0_266_133_33_66_33
-#define PLLMR1_DEFAULT PPCHAMELEON_PLLMR1_266_133_33_66_33
-#define CONFIG_SYS_OPB_FREQ    66666666
-#else
-/* Model BA (default) */
-#define PLLMR0_DEFAULT PPCHAMELEON_PLLMR0_133_133_33_66_33
-#define PLLMR1_DEFAULT PPCHAMELEON_PLLMR1_133_133_33_66_33
-#define CONFIG_SYS_OPB_FREQ    66666666
-#endif
-
-#endif /* CONFIG_NO_SERIAL_EEPROM */
-
-#define CONFIG_JFFS2_NAND 1                    /* jffs2 on nand support */
-#define NAND_CACHE_PAGES 16                    /* size of nand cache in 512 bytes pages */
-
-/*
- * JFFS2 partitions
- */
-
-/* No command line, one static partition */
-#undef CONFIG_CMD_MTDPARTS
-#define CONFIG_JFFS2_DEV               "nand0"
-#define CONFIG_JFFS2_PART_SIZE         0x00400000
-#define CONFIG_JFFS2_PART_OFFSET       0x00000000
-
-/* mtdparts command line support */
-/*
-#define CONFIG_CMD_MTDPARTS
-#define MTDIDS_DEFAULT         "nor0=PPChameleon-0,nand0=ppchameleonevb-nand"
-*/
-
-/* 256 kB U-boot image */
-/*
-#define MTDPARTS_DEFAULT       "mtdparts=PPChameleon-0:1m(kernel1),1m(kernel2)," \
-                                       "1792k(user),256k(u-boot);" \
-                               "ppchameleonevb-nand:-(nand)"
-*/
-
-/* 320 kB U-boot image */
-/*
-#define MTDPARTS_DEFAULT       "mtdparts=PPChameleon-0:1m(kernel1),1m(kernel2)," \
-                                       "1728k(user),320k(u-boot);" \
-                               "ppchameleonevb-nand:-(nand)"
-*/
-
-#endif /* __CONFIG_H */
index c2bdbb99eda9d28b46422672707179f627a33265..3f02cede3201f0d021aab3d35caf8fa632400fa2 100644 (file)
 #define CONFIG_ENV_OVERWRITE
 
 #define CONFIG_DEEP_SLEEP
+#if defined(CONFIG_DEEP_SLEEP)
 #define CONFIG_SILENT_CONSOLE
+#define CONFIG_BOARD_EARLY_INIT_F
+#endif
 
 #ifdef CONFIG_RAMBOOT_PBL
 #define CONFIG_SYS_FSL_PBL_PBI board/freescale/t102xqds/t1024_pbi.cfg
index 82b669ba6ed94ddca249e2b3f43f2dcb1916eeae..bd40d6ac93c82186e5b50cbb3120a02415c75be9 100644 (file)
 
 /* support deep sleep */
 #define CONFIG_DEEP_SLEEP
+#if defined(CONFIG_DEEP_SLEEP)
 #define CONFIG_SILENT_CONSOLE
+#define CONFIG_BOARD_EARLY_INIT_F
+#endif
 
 #ifdef CONFIG_RAMBOOT_PBL
 #define CONFIG_SYS_FSL_PBL_PBI board/freescale/t102xrdb/t1024_pbi.cfg
@@ -51,7 +54,7 @@
 #define CONFIG_SPL_I2C_SUPPORT
 #define CONFIG_SPL_DRIVERS_MISC_SUPPORT
 #define CONFIG_FSL_LAW                 /* Use common FSL init code */
-#define CONFIG_SYS_TEXT_BASE           0x00201000
+#define CONFIG_SYS_TEXT_BASE           0x30001000
 #define CONFIG_SPL_TEXT_BASE           0xFFFD8000
 #define CONFIG_SPL_PAD_TO              0x40000
 #define CONFIG_SPL_MAX_SIZE            0x28000
 #ifdef CONFIG_NAND
 #define CONFIG_SPL_NAND_SUPPORT
 #define CONFIG_SYS_NAND_U_BOOT_SIZE    (768 << 10)
-#define CONFIG_SYS_NAND_U_BOOT_DST     0x00200000
-#define CONFIG_SYS_NAND_U_BOOT_START   0x00200000
+#define CONFIG_SYS_NAND_U_BOOT_DST     0x30000000
+#define CONFIG_SYS_NAND_U_BOOT_START   0x30000000
 #define CONFIG_SYS_NAND_U_BOOT_OFFS    (256 << 10)
 #define CONFIG_SYS_LDSCRIPT    "arch/powerpc/cpu/mpc85xx/u-boot-nand.lds"
 #define CONFIG_SPL_NAND_BOOT
 #endif
 
 #ifdef CONFIG_SPIFLASH
-#define CONFIG_RESET_VECTOR_ADDRESS            0x200FFC
+#define CONFIG_RESET_VECTOR_ADDRESS            0x30000FFC
 #define CONFIG_SPL_SPI_SUPPORT
 #define CONFIG_SPL_SPI_FLASH_SUPPORT
 #define CONFIG_SPL_SPI_FLASH_MINIMAL
 #define CONFIG_SYS_SPI_FLASH_U_BOOT_SIZE       (768 << 10)
-#define CONFIG_SYS_SPI_FLASH_U_BOOT_DST                (0x00200000)
-#define CONFIG_SYS_SPI_FLASH_U_BOOT_START      (0x00200000)
+#define CONFIG_SYS_SPI_FLASH_U_BOOT_DST                (0x30000000)
+#define CONFIG_SYS_SPI_FLASH_U_BOOT_START      (0x30000000)
 #define CONFIG_SYS_SPI_FLASH_U_BOOT_OFFS       (256 << 10)
 #define CONFIG_SYS_LDSCRIPT            "arch/powerpc/cpu/mpc85xx/u-boot.lds"
 #ifndef CONFIG_SPL_BUILD
 #endif
 
 #ifdef CONFIG_SDCARD
-#define CONFIG_RESET_VECTOR_ADDRESS    0x200FFC
+#define CONFIG_RESET_VECTOR_ADDRESS    0x30000FFC
 #define CONFIG_SPL_MMC_SUPPORT
 #define CONFIG_SPL_MMC_MINIMAL
 #define CONFIG_SYS_MMC_U_BOOT_SIZE     (768 << 10)
-#define CONFIG_SYS_MMC_U_BOOT_DST      (0x00200000)
-#define CONFIG_SYS_MMC_U_BOOT_START    (0x00200000)
+#define CONFIG_SYS_MMC_U_BOOT_DST      (0x30000000)
+#define CONFIG_SYS_MMC_U_BOOT_START    (0x30000000)
 #define CONFIG_SYS_MMC_U_BOOT_OFFS     (260 << 10)
 #define CONFIG_SYS_LDSCRIPT            "arch/powerpc/cpu/mpc85xx/u-boot.lds"
 #ifndef CONFIG_SPL_BUILD
@@ -759,8 +762,10 @@ unsigned long get_board_ddr_clk(void);
 #define CONFIG_FMAN_ENET
 #define CONFIG_PHYLIB_10G
 #define CONFIG_PHY_REALTEK
+#define CONFIG_PHY_AQUANTIA
 #define RGMII_PHY1_ADDR                0x2
 #define RGMII_PHY2_ADDR                0x6
+#define SGMII_PHY1_ADDR                0x2
 #define FM1_10GEC1_PHY_ADDR    0x1
 #endif
 
index b70bdfe5e79f63dcd371a1b7fe314c9498c3188a..92f5f56718cb310da2ddd949aa25cb0e72a5fd2a 100644 (file)
 
 /* support deep sleep */
 #define CONFIG_DEEP_SLEEP
+#if defined(CONFIG_DEEP_SLEEP)
 #define CONFIG_SILENT_CONSOLE
+#define CONFIG_BOARD_EARLY_INIT_F
+#endif
 
 #ifndef CONFIG_SYS_TEXT_BASE
 #define CONFIG_SYS_TEXT_BASE   0xeff40000
@@ -689,6 +692,12 @@ unsigned long get_board_ddr_clk(void);
 #define CONFIG_PHY_GIGE                /* Include GbE speed/duplex detection */
 #endif
 
+/* Enable VSC9953 L2 Switch driver */
+#define CONFIG_VSC9953
+#define CONFIG_VSC9953_CMD
+#define CONFIG_SYS_FM1_QSGMII11_PHY_ADDR       0x14
+#define CONFIG_SYS_FM1_QSGMII21_PHY_ADDR       0x18
+
 /*
  * Dynamic MTD Partition support with mtdparts
  */
index 57cdf7213c4c6b3fa4233f36e02eb9ac50ebef23..d47f1be6851188650e1d315e586905ed1fcdf5f3 100644 (file)
 #define CONFIG_SYS_RGMII1_PHY_ADDR             0x01
 #define CONFIG_SYS_RGMII2_PHY_ADDR             0x02
 
+/* Enable VSC9953 L2 Switch driver on T1040 SoC */
+#ifdef CONFIG_T1040RDB
+#define CONFIG_VSC9953
+#define CONFIG_VSC9953_CMD
+#define CONFIG_SYS_FM1_QSGMII11_PHY_ADDR       0x04
+#define CONFIG_SYS_FM1_QSGMII21_PHY_ADDR       0x08
+#endif
+
 #define CONFIG_MII             /* MII PHY management */
 #define CONFIG_ETHPRIME                "FM1@DTSEC4"
 #define CONFIG_PHY_GIGE                /* Include GbE speed/duplex detection */
diff --git a/include/configs/Total5200.h b/include/configs/Total5200.h
deleted file mode 100644 (file)
index a58eeca..0000000
+++ /dev/null
@@ -1,386 +0,0 @@
-/*
- * (C) Copyright 2003-2004
- * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
- *
- * (C) Copyright 2004
- * Mark Jonas, Freescale Semiconductor, mark.jonas@freescale.com.
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#ifndef __CONFIG_H
-#define __CONFIG_H
-
-/*
- * Check valid setting of revision define.
- * Total5100 and Total5200 Rev.1 are identical except for the processor.
- */
-#if (CONFIG_TOTAL5200_REV!=1 && CONFIG_TOTAL5200_REV!=2)
-#error CONFIG_TOTAL5200_REV must be 1 or 2
-#endif
-
-/*
- * High Level Configuration Options
- * (easy to change)
- */
-
-#define CONFIG_MPC5200         1       /* This is a MPC5200 CPU */
-#define CONFIG_TOTAL5200       1       /* ... on Total5200 board */
-
-/*
- * Valid values for CONFIG_SYS_TEXT_BASE are:
- * 0xFFF00000  boot high (standard configuration)
- * 0xFE000000  boot low
- * 0x00100000  boot from RAM (for testing only)
- */
-#ifndef CONFIG_SYS_TEXT_BASE
-#define        CONFIG_SYS_TEXT_BASE    0xFFF00000
-#endif
-
-#define CONFIG_SYS_MPC5XXX_CLKIN       33000000 /* ... running at 33.000000MHz */
-
-#define CONFIG_HIGH_BATS       1       /* High BATs supported */
-
-/*
- * Serial console configuration
- */
-#define CONFIG_PSC_CONSOLE     3       /* console is on PSC3 */
-#define CONFIG_BAUDRATE                115200  /* ... at 115200 bps */
-#define CONFIG_SYS_BAUDRATE_TABLE      { 9600, 19200, 38400, 57600, 115200, 230400 }
-
-/*
- * Video console
- */
-#define CONFIG_VIDEO
-#define CONFIG_VIDEO_SED13806
-#define CONFIG_VIDEO_SED13806_16BPP
-
-#define CONFIG_CFB_CONSOLE
-#define CONFIG_VIDEO_LOGO
-/* #define CONFIG_VIDEO_BMP_LOGO */
-#define CONFIG_CONSOLE_EXTRA_INFO
-#define CONFIG_VGA_AS_SINGLE_DEVICE
-#define CONFIG_VIDEO_SW_CURSOR
-#define CONFIG_SPLASH_SCREEN
-
-
-/*
- * PCI Mapping:
- * 0x40000000 - 0x4fffffff - PCI Memory
- * 0x50000000 - 0x50ffffff - PCI IO Space
- */
-#define CONFIG_PCI             1
-#define CONFIG_PCI_PNP         1
-#define CONFIG_PCI_SCAN_SHOW   1
-#define CONFIG_PCIAUTO_SKIP_HOST_BRIDGE        1
-
-#define CONFIG_PCI_MEM_BUS     0x40000000
-#define CONFIG_PCI_MEM_PHYS    CONFIG_PCI_MEM_BUS
-#define CONFIG_PCI_MEM_SIZE    0x10000000
-
-#define CONFIG_PCI_IO_BUS      0x50000000
-#define CONFIG_PCI_IO_PHYS     CONFIG_PCI_IO_BUS
-#define CONFIG_PCI_IO_SIZE     0x01000000
-
-#define CONFIG_MII             1
-#define CONFIG_EEPRO100                1
-#define CONFIG_SYS_RX_ETH_BUFFER       8  /* use 8 rx buffer on eepro100  */
-#define CONFIG_NS8382X         1
-
-/* Partitions */
-#define CONFIG_MAC_PARTITION
-#define CONFIG_DOS_PARTITION
-
-/* USB */
-#define CONFIG_USB_OHCI
-#define CONFIG_USB_STORAGE
-
-
-/*
- * BOOTP options
- */
-#define CONFIG_BOOTP_BOOTFILESIZE
-#define CONFIG_BOOTP_BOOTPATH
-#define CONFIG_BOOTP_GATEWAY
-#define CONFIG_BOOTP_HOSTNAME
-
-
-/*
- * Command line configuration.
- */
-#include <config_cmd_default.h>
-
-#define CONFIG_CMD_PCI
-
-#define CONFIG_CMD_BMP
-#define CONFIG_CMD_EEPROM
-#define CONFIG_CMD_FAT
-#define CONFIG_CMD_I2C
-#define CONFIG_CMD_IDE
-#define CONFIG_CMD_PING
-#define CONFIG_CMD_USB
-
-
-#if (CONFIG_SYS_TEXT_BASE == 0xFE000000)               /* Boot low */
-#   define CONFIG_SYS_LOWBOOT          1
-#endif
-
-/*
- * Autobooting
- */
-#define CONFIG_BOOTDELAY       5       /* autoboot after 5 seconds */
-
-#define CONFIG_PREBOOT \
-       "setenv stdout serial;setenv stderr serial;" \
-       "echo;" \
-       "echo Type \\\"run flash_nfs\\\" to mount root filesystem over NFS;" \
-       "echo"
-
-#undef CONFIG_BOOTARGS
-
-#define        CONFIG_EXTRA_ENV_SETTINGS                                       \
-       "netdev=eth0\0"                                                 \
-       "nfsargs=setenv bootargs root=/dev/nfs rw "                     \
-               "nfsroot=${serverip}:${rootpath}\0"                     \
-       "ramargs=setenv bootargs root=/dev/ram rw\0"                    \
-       "addip=setenv bootargs ${bootargs} "                            \
-               "ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}"      \
-               ":${hostname}:${netdev}:off panic=1\0"                  \
-       "flash_nfs=run nfsargs addip;"                                  \
-               "bootm ${kernel_addr}\0"                                \
-       "flash_self=run ramargs addip;"                                 \
-               "bootm ${kernel_addr} ${ramdisk_addr}\0"                \
-       "net_nfs=tftp 200000 ${bootfile};run nfsargs addip;bootm\0"     \
-       "rootpath=/opt/eldk/ppc_82xx\0"                                 \
-       "bootfile=/tftpboot/MPC5200/uImage\0"                           \
-       ""
-
-#define CONFIG_BOOTCOMMAND     "run flash_self"
-
-/*
- * IPB Bus clocking configuration.
- */
-#undef CONFIG_SYS_IPBCLK_EQUALS_XLBCLK         /* define for 133MHz speed */
-
-/*
- * I2C configuration
- */
-#define CONFIG_HARD_I2C                1       /* I2C with hardware support */
-#define CONFIG_SYS_I2C_MODULE          1       /* Select I2C module #1 or #2 */
-
-#define CONFIG_SYS_I2C_SPEED           100000 /* 100 kHz */
-#define CONFIG_SYS_I2C_SLAVE           0x7F
-
-/*
- * EEPROM configuration
- */
-#define CONFIG_SYS_I2C_EEPROM_ADDR             0x50    /* 1010000x */
-#define CONFIG_SYS_I2C_EEPROM_ADDR_LEN         1
-#define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS      3
-#define CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS  70
-
-/*
- * Flash configuration
- */
-#define CONFIG_SYS_FLASH_CFI           1       /* Flash is CFI conformant */
-#define CONFIG_FLASH_CFI_DRIVER        1       /* Use the common driver */
-#if CONFIG_TOTAL5200_REV==2
-#   define CONFIG_SYS_MAX_FLASH_BANKS  3       /* max num of flash banks */
-#   define CONFIG_SYS_FLASH_BANKS_LIST { CONFIG_SYS_CS5_START, CONFIG_SYS_CS4_START, CONFIG_SYS_BOOTCS_START }
-#else
-#   define CONFIG_SYS_MAX_FLASH_BANKS  1       /* max num of flash banks  */
-#   define CONFIG_SYS_FLASH_BANKS_LIST { CONFIG_SYS_BOOTCS_START }
-#endif
-#define CONFIG_SYS_FLASH_EMPTY_INFO
-#define CONFIG_SYS_MAX_FLASH_SECT      128     /* max num of sects on one chip */
-
-#if CONFIG_TOTAL5200_REV==1
-#   define CONFIG_SYS_FLASH_BASE       0xFE000000
-#   define CONFIG_SYS_FLASH_SIZE       0x02000000
-#elif CONFIG_TOTAL5200_REV==2
-#   define CONFIG_SYS_FLASH_BASE       0xFA000000
-#   define CONFIG_SYS_FLASH_SIZE       0x06000000
-#endif /* CONFIG_TOTAL5200_REV */
-
-#if defined(CONFIG_SYS_LOWBOOT)
-#   define CONFIG_ENV_ADDR             0xFE040000
-#else  /* CONFIG_SYS_LOWBOOT */
-#   define CONFIG_ENV_ADDR             0xFFF40000
-#endif /* CONFIG_SYS_LOWBOOT */
-
-/*
- * Environment settings
- */
-#define CONFIG_ENV_IS_IN_FLASH 1
-#define CONFIG_ENV_SIZE                0x40000
-#define CONFIG_ENV_SECT_SIZE   0x40000
-#define CONFIG_ENV_OVERWRITE   1
-
-/*
- * Memory map
- */
-#define CONFIG_SYS_SDRAM_BASE          0x00000000
-#define CONFIG_SYS_DEFAULT_MBAR        0x80000000
-#define CONFIG_SYS_MBAR                0xF0000000      /*   64 kB */
-#define CONFIG_SYS_FPGA_BASE           0xF0010000      /*   64 kB */
-#define CONFIG_SYS_CPLD_BASE           0xF0020000      /*   64 kB */
-#define CONFIG_SYS_LCD_BASE            0xF1000000      /* 4096 kB */
-
-/* Use SRAM until RAM will be available */
-#define CONFIG_SYS_INIT_RAM_ADDR       MPC5XXX_SRAM
-#define CONFIG_SYS_INIT_RAM_SIZE       MPC5XXX_SRAM_SIZE       /* Size of used area in DPRAM */
-
-#define CONFIG_SYS_GBL_DATA_OFFSET     (CONFIG_SYS_INIT_RAM_SIZE - GENERATED_GBL_DATA_SIZE)
-#define CONFIG_SYS_INIT_SP_OFFSET      CONFIG_SYS_GBL_DATA_OFFSET
-
-#define CONFIG_SYS_MONITOR_BASE    CONFIG_SYS_TEXT_BASE
-#if (CONFIG_SYS_MONITOR_BASE < CONFIG_SYS_FLASH_BASE)
-#   define CONFIG_SYS_RAMBOOT          1
-#endif
-
-#define CONFIG_SYS_MONITOR_LEN         (192 << 10)     /* Reserve 192 kB for Monitor   */
-#define CONFIG_SYS_MALLOC_LEN          (128 << 10)     /* Reserve 128 kB for malloc()  */
-#define CONFIG_SYS_BOOTMAPSZ           (8 << 20)       /* Initial Memory map for Linux */
-
-/*
- * Ethernet configuration
- */
-#define CONFIG_MPC5xxx_FEC     1
-#define CONFIG_MPC5xxx_FEC_SEVENWIRE
-/* dummy, 7-wire FEC does not have phy address */
-#define CONFIG_PHY_ADDR                0x00
-
-/*
- * GPIO configuration
- *
- * CS1:   SDRAM CS1 disabled, gpio_wkup_6 enabled                0
- * Reserved                                                      0
- * ALTs:  CAN1/2 on PSC2, SPI on PSC3                            00
- * CS7:   Interrupt GPIO on PSC3_5                               0
- * CS8:   Interrupt GPIO on PSC3_4                               0
- * ATA:   reset default, changed in ATA driver                   00
- * IR_USB_CLK: IrDA/USB 48MHz clock gen. int., pin is GPIO       0
- * IRDA:  reset default, changed in IrDA driver                  000
- * ETHER: reset default, changed in Ethernet driver              0000
- * PCI_DIS: reset default, changed in PCI driver                 0
- * USB_SE: reset default, changed in USB driver                  0
- * USB:   reset default, changed in USB driver                   00
- * PSC3:  SPI and UART functionality without CD                  1100
- * Reserved                                                      0
- * PSC2:  CAN1/2                                                 001
- * Reserved                                                      0
- * PSC1:  reset default, changed in AC'97 driver                 000
- *
- */
-#define CONFIG_SYS_GPS_PORT_CONFIG     0x00000C10
-
-/*
- * Miscellaneous configurable options
- */
-#define CONFIG_SYS_LONGHELP                    /* undef to save memory     */
-#if defined(CONFIG_CMD_KGDB)
-#define CONFIG_SYS_CBSIZE              1024    /* Console I/O Buffer Size  */
-#else
-#define CONFIG_SYS_CBSIZE              256     /* Console I/O Buffer Size  */
-#endif
-#define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE+sizeof(CONFIG_SYS_PROMPT)+16)     /* Print Buffer Size */
-#define CONFIG_SYS_MAXARGS             16              /* max number of command args   */
-#define CONFIG_SYS_BARGSIZE            CONFIG_SYS_CBSIZE       /* Boot Argument Buffer Size    */
-
-#define CONFIG_SYS_MEMTEST_START       0x00100000      /* memtest works on */
-#define CONFIG_SYS_MEMTEST_END         0x00f00000      /* 1 ... 15 MB in DRAM  */
-
-#define CONFIG_SYS_LOAD_ADDR           0x100000        /* default load address */
-
-#define CONFIG_SYS_CACHELINE_SIZE      32      /* For MPC5xxx CPUs */
-#if defined(CONFIG_CMD_KGDB)
-#  define CONFIG_SYS_CACHELINE_SHIFT   5       /* log base 2 of the above value */
-#endif
-
-
-/*
- * Various low-level settings
- */
-#define CONFIG_SYS_HID0_INIT           HID0_ICE | HID0_ICFI
-#define CONFIG_SYS_HID0_FINAL          HID0_ICE
-
-#if CONFIG_TOTAL5200_REV==1
-#   define CONFIG_SYS_BOOTCS_START     CONFIG_SYS_FLASH_BASE
-#   define CONFIG_SYS_BOOTCS_SIZE      0x02000000      /* 32 MB */
-#   define CONFIG_SYS_BOOTCS_CFG       0x0004DF00      /* 4WS, MX, AL, CE, AS_25, DS_32 */
-#   define CONFIG_SYS_CS0_START        CONFIG_SYS_FLASH_BASE
-#   define CONFIG_SYS_CS0_SIZE         0x02000000      /* 32 MB */
-#else
-#   define CONFIG_SYS_BOOTCS_START     (CONFIG_SYS_CS4_START + CONFIG_SYS_CS4_SIZE)
-#   define CONFIG_SYS_BOOTCS_SIZE      0x02000000      /* 32 MB */
-#   define CONFIG_SYS_BOOTCS_CFG       0x0004DF00      /* 4WS, MX, AL, CE, AS_25, DS_32 */
-#   define CONFIG_SYS_CS4_START        (CONFIG_SYS_CS5_START + CONFIG_SYS_CS5_SIZE)
-#   define CONFIG_SYS_CS4_SIZE         0x02000000      /* 32 MB */
-#   define CONFIG_SYS_CS4_CFG          0x0004DF00      /* 4WS, MX, AL, CE, AS_25, DS_32 */
-#   define CONFIG_SYS_CS5_START        CONFIG_SYS_FLASH_BASE
-#   define CONFIG_SYS_CS5_SIZE         0x02000000      /* 32 MB */
-#   define CONFIG_SYS_CS5_CFG          0x0004DF00      /* 4WS, MX, AL, CE, AS_25, DS_32 */
-#endif
-
-#define CONFIG_SYS_CS1_START           CONFIG_SYS_FPGA_BASE
-#define CONFIG_SYS_CS1_SIZE            0x00010000      /* 64 kB */
-#define CONFIG_SYS_CS1_CFG             0x0019FF00      /* 25WS, MX, AL, AA, CE, AS_25, DS_32 */
-
-#define CONFIG_SYS_CS2_START           CONFIG_SYS_LCD_BASE
-#define CONFIG_SYS_CS2_SIZE            0x00400000      /* 4096 kB */
-#define CONFIG_SYS_CS2_CFG             0x0032FD0C      /* 50WS, MX, AL, AA, CE, AS_25, DS_16, endian swapping */
-
-#if CONFIG_TOTAL5200_REV==1
-#   define CONFIG_SYS_CS3_START        CONFIG_SYS_CPLD_BASE
-#   define CONFIG_SYS_CS3_SIZE         0x00010000      /* 64 kB */
-#   define CONFIG_SYS_CS3_CFG          0x000ADF00      /* 10WS, MX, AL, CE, AS_25, DS_32 */
-#else
-#   define CONFIG_SYS_CS3_START        CONFIG_SYS_CPLD_BASE
-#   define CONFIG_SYS_CS3_SIZE         0x00010000      /* 64 kB */
-#   define CONFIG_SYS_CS3_CFG          0x000AD800      /* 10WS, MX, AL, CE, AS_24, DS_8 */
-#endif
-
-#define CONFIG_SYS_CS_BURST            0x00000000
-#define CONFIG_SYS_CS_DEADCYCLE        0x33333333
-
-/*-----------------------------------------------------------------------
- * USB stuff
- *-----------------------------------------------------------------------
- */
-#define CONFIG_USB_CLOCK       0x0001BBBB
-#define CONFIG_USB_CONFIG      0x00001000
-
-/*-----------------------------------------------------------------------
- * IDE/ATA stuff Supports IDE harddisk
- *-----------------------------------------------------------------------
- */
-
-#undef  CONFIG_IDE_8xx_PCCARD          /* Use IDE with PC Card Adapter */
-
-#undef CONFIG_IDE_8xx_DIRECT           /* Direct IDE    not supported  */
-#undef CONFIG_IDE_LED                  /* LED   for ide not supported  */
-
-#define        CONFIG_IDE_RESET                /* reset for ide supported      */
-#define CONFIG_IDE_PREINIT
-
-#define CONFIG_SYS_ATA_CS_ON_I2C2
-#define CONFIG_SYS_IDE_MAXBUS          1       /* max. 1 IDE bus               */
-#define CONFIG_SYS_IDE_MAXDEVICE       1       /* max. 1 drive per IDE bus     */
-
-#define CONFIG_SYS_ATA_IDE0_OFFSET     0x0000
-
-#define CONFIG_SYS_ATA_BASE_ADDR       MPC5XXX_ATA
-
-/* Offset for data I/O                 */
-#define CONFIG_SYS_ATA_DATA_OFFSET     (0x0060)
-
-/* Offset for normal register accesses */
-#define CONFIG_SYS_ATA_REG_OFFSET      (CONFIG_SYS_ATA_DATA_OFFSET)
-
-/* Offset for alternate registers      */
-#define CONFIG_SYS_ATA_ALT_OFFSET      (0x005C)
-
-/* Interval between registers                                                */
-#define CONFIG_SYS_ATA_STRIDE          4
-
-#endif /* __CONFIG_H */
index 000475051812a2846bfd8b0625945cabfd315168..f1c270c939093583a8d7b8acdfb26e9125ddd202 100644 (file)
 #include <configs/ti_am335x_common.h>
 
 #ifndef CONFIG_SPL_BUILD
+#ifndef CONFIG_FIT
 # define CONFIG_FIT
+#endif
 # define CONFIG_TIMESTAMP
 # define CONFIG_LZO
-# ifdef CONFIG_ENABLE_VBOOT
-#  define CONFIG_FIT_SIGNATURE
-#  define CONFIG_RSA
-# endif
 #endif
 
 #define CONFIG_SYS_BOOTM_LEN           (16 << 20)
 #define CONFIG_SYS_NAND_BLOCK_SIZE     (128*1024)
 /* NAND: driver related configs */
 #define CONFIG_NAND_OMAP_GPMC
+#define CONFIG_NAND_OMAP_GPMC_PREFETCH
 #define CONFIG_NAND_OMAP_ELM
 #define CONFIG_SYS_NAND_BAD_BLOCK_POS  NAND_LARGE_BADBLOCK_POS
 #define CONFIG_SYS_NAND_ECCPOS         { 2, 3, 4, 5, 6, 7, 8, 9, \
diff --git a/include/configs/arcangel4-be.h b/include/configs/arcangel4-be.h
deleted file mode 100644 (file)
index 76163ab..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (C) 2013-2014 Synopsys, Inc. All rights reserved.
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#ifndef _CONFIG_ARCANGEL4_H_
-#define _CONFIG_ARCANGEL4_H_
-
-/*
- *  CPU configuration
- */
-#define CONFIG_SYS_BIG_ENDIAN
-#define CONFIG_ARC700
-#define CONFIG_ARC_MMU_VER             3
-#define CONFIG_SYS_CACHELINE_SIZE      64
-#define CONFIG_SYS_TIMER_RATE          CONFIG_SYS_CLK_FREQ
-
-/*
- * Board configuration
- */
-#define CONFIG_SYS_GENERIC_BOARD
-#define CONFIG_SKIP_LOWLEVEL_INIT      /* U-Boot is in RAM already */
-
-#define CONFIG_ARCH_EARLY_INIT_R
-
-/*
- * Memory configuration
- */
-#define CONFIG_SYS_TEXT_BASE           0x81000000
-#define CONFIG_SYS_MONITOR_BASE                CONFIG_SYS_TEXT_BASE
-
-#define CONFIG_SYS_DDR_SDRAM_BASE      0x80000000
-#define CONFIG_SYS_SDRAM_BASE          CONFIG_SYS_DDR_SDRAM_BASE
-#define CONFIG_SYS_SDRAM_SIZE          0x10000000      /* 256 Mb */
-
-#define CONFIG_SYS_INIT_SP_ADDR                \
-       (CONFIG_SYS_SDRAM_BASE + 0x1000 - GENERATED_GBL_DATA_SIZE)
-
-#define CONFIG_SYS_MALLOC_LEN          0x200000        /* 2 MB */
-#define CONFIG_SYS_BOOTM_LEN           0x2000000       /* 32 MB */
-#define CONFIG_SYS_LOAD_ADDR           0x82000000
-
-#define CONFIG_SYS_NO_FLASH
-
-/*
- * UART configuration
- *
- */
-#define CONFIG_ARC_SERIAL
-#define CONFIG_ARC_UART_BASE           0xC0FC1000
-#define CONFIG_BAUDRATE                        115200
-
-/*
- * Command line configuration
- */
-#include <config_cmd_default.h>
-
-#define CONFIG_CMD_ELF
-
-#define CONFIG_OF_LIBFDT
-
-#define CONFIG_AUTO_COMPLETE
-#define CONFIG_SYS_MAXARGS             16
-
-/*
- * Environment settings
- */
-#define CONFIG_ENV_IS_NOWHERE
-#define CONFIG_ENV_SIZE                        0x00200         /* 512 bytes */
-#define CONFIG_ENV_OFFSET              0
-
-/*
- * Environment configuration
- */
-#define CONFIG_BOOTDELAY               3
-#define CONFIG_BOOTFILE                        "uImage"
-#define CONFIG_BOOTARGS                        "console=ttyARC0,115200n8"
-#define CONFIG_LOADADDR                        CONFIG_SYS_LOAD_ADDR
-
-/*
- * Console configuration
- */
-#define CONFIG_SYS_LONGHELP
-#define CONFIG_SYS_PROMPT              "arcangel4# "
-#define CONFIG_SYS_CBSIZE              256
-#define CONFIG_SYS_BARGSIZE            CONFIG_SYS_CBSIZE
-#define CONFIG_SYS_PBSIZE              (CONFIG_SYS_CBSIZE + \
-                                               sizeof(CONFIG_SYS_PROMPT) + 16)
-
-#endif /* _CONFIG_ARCANGEL4_H_ */
index 81934a45a8852282d20d653f826a528633e35450..5e4097fb82e1c9fcf665058c52f8f673e2237338 100644 (file)
 /*
  *  CPU configuration
  */
-#define CONFIG_ARC700
-#define CONFIG_ARC_MMU_VER             3
-#define CONFIG_SYS_CACHELINE_SIZE      64
 #define CONFIG_SYS_TIMER_RATE          CONFIG_SYS_CLK_FREQ
 
-/*
- * Board configuration
- */
-#define CONFIG_SYS_GENERIC_BOARD
-#define CONFIG_SKIP_LOWLEVEL_INIT      /* U-Boot is in RAM already */
-
-#define CONFIG_ARCH_EARLY_INIT_R
-
 /*
  * Memory configuration
  */
-#define CONFIG_SYS_TEXT_BASE           0x81000000
 #define CONFIG_SYS_MONITOR_BASE                CONFIG_SYS_TEXT_BASE
 
 #define CONFIG_SYS_DDR_SDRAM_BASE      0x80000000
index d68993bb1f7301c1384caaed9185524f7a2e3ea6..3ad4a9ba91f6eaa7da5d465b9584308561cbd9f3 100644 (file)
@@ -51,8 +51,6 @@
 /* PMIC */
 #define CONFIG_PMIC
 #define CONFIG_POWER_I2C
-#define CONFIG_POWER_MAX77686
-
 
 #define CONFIG_PREBOOT
 
index c61ddd6fb77c46560d82dc6a1a1e4b9216fab1d8..5fb8aca4bca95f3fa307407649e2d084b65ff2af 100644 (file)
 /*
  *  CPU configuration
  */
-#define CONFIG_ARC700
-#define CONFIG_ARC_MMU_VER             3
-#define CONFIG_SYS_CACHELINE_SIZE      32
 #define CONFIG_SYS_TIMER_RATE          CONFIG_SYS_CLK_FREQ
 
-/* NAND controller DMA doesn't work correctly with D$ enabled */
-#define CONFIG_SYS_DCACHE_OFF
-
-/*
- * Board configuration
- */
-#define CONFIG_SYS_GENERIC_BOARD
-#define CONFIG_SKIP_LOWLEVEL_INIT      /* U-Boot is in RAM already */
-
-#define CONFIG_ARCH_EARLY_INIT_R
-
 #define ARC_FPGA_PERIPHERAL_BASE       0xE0000000
 #define ARC_APB_PERIPHERAL_BASE                0xF0000000
 #define ARC_DWMMC_BASE                 (ARC_FPGA_PERIPHERAL_BASE + 0x15000)
@@ -34,7 +20,6 @@
 /*
  * Memory configuration
  */
-#define CONFIG_SYS_TEXT_BASE           0x81000000
 #define CONFIG_SYS_MONITOR_BASE                CONFIG_SYS_TEXT_BASE
 
 #define CONFIG_SYS_DDR_SDRAM_BASE      0x80000000
index 39982ef72cf1c6fc25a6d24c96f178da8d624700..2e0e9224cfa04407a00b0275bea5fef431694076 100644 (file)
@@ -97,7 +97,7 @@
 #define CONFIG_ENV_IS_IN_FLASH 1
 #define CONFIG_ENV_OFFSET      0x4000
 #define CONFIG_ENV_SIZE                0x2000
-#define CONFIG_ENV_SECT_SIZE   0x10000
+#define CONFIG_ENV_SECT_SIZE   0x12000
 
 #if (CONFIG_BFIN_BOOT_MODE == BFIN_BOOT_BYPASS)
 #define ENV_IS_EMBEDDED
index 7e6d239d13d207c334da837485fc906ecf4ac792..7b460e83c45726004a605b9ef3a5775e6cc000c5 100644 (file)
@@ -20,6 +20,7 @@
 
 #define CONFIG_DCACHE_RAM_MRC_VAR_SIZE         0x4000
 #define CONFIG_BOARD_EARLY_INIT_F
+#define CONFIG_MISC_INIT_R
 
 #define CONFIG_NR_DRAM_BANKS                   8
 #define CONFIG_X86_MRC_ADDR                    0xfffa0000
 #define CONFIG_CMD_CROS_EC
 #define CONFIG_ARCH_EARLY_INIT_R
 
+#undef CONFIG_ENV_IS_NOWHERE
+#undef CONFIG_ENV_SIZE
+#define CONFIG_ENV_SIZE                        0x1000
+#define CONFIG_ENV_SECT_SIZE           0x1000
+#define CONFIG_ENV_IS_IN_SPI_FLASH
+#define CONFIG_ENV_OFFSET              0x003f8000
+
 #define CONFIG_STD_DEVICES_SETTINGS     "stdin=usbkbd,vga,serial\0" \
                                        "stdout=vga,serial\0" \
                                        "stderr=vga,serial\0"
index 5b50c1d6dd5c459b0328da23eec806fd09342461..ace511f76534bc9188a2222eee32a0f15cb2bc0f 100644 (file)
@@ -18,6 +18,7 @@
 
 #define MACH_TYPE_CORVUS               2066
 
+#define CONFIG_MACH_TYPE               MACH_TYPE_CORVUS
 #define CONFIG_SYS_GENERIC_BOARD
 /*
  * Warning: changing CONFIG_SYS_TEXT_BASE requires
 /* our CLE is AD22 */
 #define CONFIG_SYS_NAND_MASK_CLE               (1 << 22)
 #define CONFIG_SYS_NAND_ENABLE_PIN             AT91_PIN_PC14
+#define CONFIG_SYS_NAND_READY_PIN              AT91_PIN_PC8
 #endif
 
 /* Ethernet */
 
 #define CONFIG_SPL_BOARD_INIT
 #define CONFIG_SPL_GPIO_SUPPORT
-#define CONFIG_SYS_NAND_ENABLE_PIN_SPL (2*32 + 14)
 #define CONFIG_SPL_NAND_SUPPORT
 #define CONFIG_SPL_NAND_DRIVERS
 #define CONFIG_SPL_NAND_BASE
 #define CONFIG_SYS_NAND_U_BOOT_DST     CONFIG_SYS_TEXT_BASE
 #define CONFIG_SYS_NAND_5_ADDR_CYCLE
 
-#define CONFIG_SYS_NAND_SIZE           (256*1024*1024)
 #define CONFIG_SYS_NAND_PAGE_SIZE      2048
 #define CONFIG_SYS_NAND_BLOCK_SIZE     (128*1024)
 #define CONFIG_SYS_NAND_PAGE_COUNT     (CONFIG_SYS_NAND_BLOCK_SIZE / \
diff --git a/include/configs/cpci5200.h b/include/configs/cpci5200.h
deleted file mode 100644 (file)
index ec926fd..0000000
+++ /dev/null
@@ -1,390 +0,0 @@
-/*
- * (C) Copyright 2003-2004
- * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
- *
- * SPDX-License-Identifier:    GPL-2.0+
-
- */
-
-/*************************************************************************
- * (c) 2005 esd gmbh Hannover
- *
- *
- * from IceCube.h file
- * by Reinhard Arlt reinhard.arlt@esd-electronics.com
- *
- *************************************************************************/
-
-#ifndef __CONFIG_H
-#define __CONFIG_H
-
-/*
- * High Level Configuration Options
- * (easy to change)
- */
-
-#define CONFIG_MPC5200         1       /* This is an MPC5200 CPU */
-#define CONFIG_ICECUBE         1       /* ... on IceCube board   */
-#define CONFIG_CPCI5200                1       /* ... on CPCI5200  board */
-#define CONFIG_MPC5200_DDR     1       /* ... use DDR RAM        */
-
-#ifndef CONFIG_SYS_TEXT_BASE
-#define CONFIG_SYS_TEXT_BASE   0xFFF00000      /* Standard: boot high */
-#endif
-
-#define CONFIG_SYS_MPC5XXX_CLKIN       33000000        /* ... running at 33.000000MHz */
-
-#define CONFIG_HIGH_BATS       1       /* High BATs supported    */
-
-/*
- * Serial console configuration
- */
-#define CONFIG_PSC_CONSOLE     1       /* console is on PSC1 */
-#define CONFIG_BAUDRATE                9600    /* ... at 115200 bps */
-#define CONFIG_SYS_BAUDRATE_TABLE      { 9600, 19200, 38400, 57600, 115200, 230400 }
-
-/*
- * PCI Mapping:
- * 0x40000000 - 0x4fffffff - PCI Memory
- * 0x50000000 - 0x50ffffff - PCI IO Space
- */
-#if 1
-#define CONFIG_PCI             1
-#if 1
-#define CONFIG_PCI_PNP         1
-#endif
-#define CONFIG_PCI_SCAN_SHOW   1
-#define CONFIG_PCIAUTO_SKIP_HOST_BRIDGE        1
-
-#define CONFIG_PCI_MEM_BUS     0x40000000
-#define CONFIG_PCI_MEM_PHYS    CONFIG_PCI_MEM_BUS
-#define CONFIG_PCI_MEM_SIZE    0x10000000
-
-#define CONFIG_PCI_IO_BUS      0x50000000
-#define CONFIG_PCI_IO_PHYS     CONFIG_PCI_IO_BUS
-#define CONFIG_PCI_IO_SIZE     0x01000000
-#endif
-
-#define CONFIG_MII
-#if 0                          /* test-only !!! */
-#define CONFIG_EEPRO100                1
-#define CONFIG_SYS_RX_ETH_BUFFER       8       /* use 8 rx buffer on eepro100  */
-#define CONFIG_NS8382X         1
-#endif
-
-/* Partitions */
-#define CONFIG_MAC_PARTITION
-#define CONFIG_DOS_PARTITION
-
-/* USB */
-#if 0
-#define CONFIG_USB_OHCI
-#define CONFIG_USB_STORAGE
-#endif
-
-/*
- * BOOTP options
- */
-#define CONFIG_BOOTP_BOOTFILESIZE
-#define CONFIG_BOOTP_BOOTPATH
-#define CONFIG_BOOTP_GATEWAY
-#define CONFIG_BOOTP_HOSTNAME
-
-
-/*
- * Command line configuration.
- */
-#include <config_cmd_default.h>
-
-#if defined(CONFIG_PCI)
-#define CONFIG_CMD_PCI
-#endif
-
-#define CONFIG_CMD_EEPROM
-#define CONFIG_CMD_FAT
-#define CONFIG_CMD_IDE
-#define CONFIG_CMD_I2C
-#define CONFIG_CMD_BSP
-#define CONFIG_CMD_ELF
-#define CONFIG_CMD_EXT2
-#define CONFIG_CMD_DATE
-
-#if (CONFIG_SYS_TEXT_BASE == 0xFF000000)       /* Boot low with 16 MB Flash */
-#   define CONFIG_SYS_LOWBOOT          1
-#   define CONFIG_SYS_LOWBOOT16        1
-#endif
-#if (CONFIG_SYS_TEXT_BASE == 0xFF800000)       /* Boot low with  8 MB Flash */
-#   define CONFIG_SYS_LOWBOOT          1
-#   define CONFIG_SYS_LOWBOOT08        1
-#endif
-
-/*
- * Autobooting
- */
-#define CONFIG_BOOTDELAY       3       /* autoboot after 5 seconds */
-
-#define CONFIG_PREBOOT "echo;" \
-       "echo Welcome to esd CPU CPCI/5200;" \
-       "echo"
-
-#undef CONFIG_BOOTARGS
-
-#define        CONFIG_EXTRA_ENV_SETTINGS \
-       "netdev=eth0\0" \
-       "flash_vxworks0=run ata_vxworks_args;setenv loadaddr ff000000;bootvx\0" \
-       "flash_vxworks1=run ata_vxworks_args;setenv loadaddr ff200000:bootvx\0" \
-       "net_vxworks=phypower 1;sleep 2;tftp ${loadaddr} ${image};run vxworks_args;bootvx\0" \
-       "vxworks_args=setenv bootargs fec(0,0)${host}:${image} h=${serverip} e=${ipaddr} g=${gatewayip} u=${user} ${pass} tn=${target} s=${script}\0" \
-       "ata_vxworks_args=setenv bootargs /ata0/vxWorks h=${serverip} e=${ipaddr} g=${gatewayip} u=${user} ${pass} tn=${target} s=${script} o=fec0 \0" \
-       "loadaddr=01000000\0" \
-       "serverip=192.168.2.99\0" \
-       "gatewayip=10.0.0.79\0" \
-       "user=mu\0" \
-       "target=cpci5200.esd\0" \
-       "script=cpci5200.bat\0" \
-       "image=/tftpboot/vxWorks_cpci5200\0" \
-       "ipaddr=10.0.13.196\0" \
-       "netmask=255.255.0.0\0" \
-       ""
-
-#define CONFIG_BOOTCOMMAND     "run flash_vxworks0"
-
-#define CONFIG_RTC_M48T35A     1       /* ST Electronics M48 timekeeper */
-#define CONFIG_SYS_NVRAM_BASE_ADDR     0xfd010000
-#define CONFIG_SYS_NVRAM_SIZE          32*1024
-
-/*
- * IPB Bus clocking configuration.
- */
-#undef CONFIG_SYS_IPBCLK_EQUALS_XLBCLK         /* define for 133MHz speed */
-/*
- * I2C configuration
- */
-#define CONFIG_HARD_I2C                1       /* I2C with hardware support */
-#define CONFIG_SYS_I2C_MODULE          1       /* Select I2C module #1 or #2 */
-
-#define CONFIG_SYS_I2C_SPEED           86000   /* 100 kHz */
-#define CONFIG_SYS_I2C_SLAVE           0x7F
-
-/*
- * EEPROM configuration
- */
-#define CONFIG_SYS_I2C_EEPROM_ADDR             0x50    /* 1010000x */
-#define CONFIG_SYS_I2C_EEPROM_ADDR_LEN         2
-#define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS      5
-#define CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS  20
-#define CONFIG_SYS_I2C_MULTI_EEPROMS           1
-/*
- * Flash configuration
- */
-
-#define CONFIG_SYS_FLASH_CFI           1       /* Flash is CFI conformant           */
-#define CONFIG_SYS_FLASH_BASE          0xFE000000
-#define CONFIG_SYS_FLASH_SIZE          0x02000000
-#define CONFIG_SYS_FLASH_INCREMENT     0x01000000
-#define CONFIG_ENV_ADDR                (CONFIG_SYS_FLASH_BASE + 0x00000000)
-#define CONFIG_SYS_MAX_FLASH_BANKS     2       /* max num of memory banks      */
-#define CONFIG_SYS_MAX_FLASH_SECT      128
-
-#define CONFIG_SYS_FLASH_PROTECTION    1       /* use hardware protection           */
-#define CONFIG_SYS_FLASH_USE_BUFFER_WRITE 1    /* use buffered writes (20x faster)  */
-
-#define CONFIG_SYS_FLASH_ERASE_TOUT    240000  /* Flash Erase Timeout (in ms)  */
-#define CONFIG_SYS_FLASH_WRITE_TOUT    500     /* Flash Write Timeout (in ms)  */
-
-/*
- * Environment settings
- */
-#if 1                          /* test-only */
-#define CONFIG_ENV_IS_IN_FLASH 1
-#define CONFIG_ENV_SIZE                0x20000
-#define CONFIG_ENV_SECT_SIZE   0x20000
-#define CONFIG_ENV_OVERWRITE   1
-#else
-#define CONFIG_ENV_IS_IN_EEPROM        1       /* use EEPROM for environment vars */
-#define CONFIG_ENV_OFFSET              0x0000  /* environment starts at the beginning of the EEPROM */
-#define CONFIG_ENV_SIZE                0x0400  /* 8192 bytes may be used for env vars */
-                                  /* total size of a CAT24WC32 is 8192 bytes */
-#define CONFIG_ENV_OVERWRITE   1
-#endif
-
-/*
- * Memory map
- */
-#define CONFIG_SYS_MBAR                0xF0000000
-#define CONFIG_SYS_SDRAM_BASE          0x00000000
-#define CONFIG_SYS_DEFAULT_MBAR        0x80000000
-
-/* Use SRAM until RAM will be available */
-#define CONFIG_SYS_INIT_RAM_ADDR       MPC5XXX_SRAM
-#define CONFIG_SYS_INIT_RAM_SIZE       MPC5XXX_SRAM_SIZE       /* Size of used area in DPRAM */
-
-#define CONFIG_SYS_GBL_DATA_OFFSET     (CONFIG_SYS_INIT_RAM_SIZE - GENERATED_GBL_DATA_SIZE)
-#define CONFIG_SYS_INIT_SP_OFFSET      CONFIG_SYS_GBL_DATA_OFFSET
-
-#define CONFIG_SYS_MONITOR_BASE    CONFIG_SYS_TEXT_BASE
-#if (CONFIG_SYS_MONITOR_BASE < CONFIG_SYS_FLASH_BASE)
-#   define CONFIG_SYS_RAMBOOT          1
-#endif
-
-#define CONFIG_SYS_MONITOR_LEN         (192 << 10)     /* Reserve 192 kB for Monitor   */
-#define CONFIG_SYS_MALLOC_LEN          (128 << 10)     /* Reserve 128 kB for malloc()  */
-#define CONFIG_SYS_BOOTMAPSZ           (8 << 20)       /* Initial Memory map for Linux */
-
-/*
- * Ethernet configuration
- */
-#define CONFIG_MPC5xxx_FEC     1
-#define CONFIG_MPC5xxx_FEC_MII100
-/*
- * Define CONFIG_FEC_10MBIT to force FEC at 10Mb
- */
-/* #define CONFIG_FEC_10MBIT 1 */
-#define CONFIG_PHY_ADDR                0x00
-#define CONFIG_UDP_CHECKSUM    1
-
-/*
- * GPIO configuration
- */
-#define CONFIG_SYS_GPS_PORT_CONFIG     0x01052444
-
-/*
- * Miscellaneous configurable options
- */
-#define CONFIG_SYS_LONGHELP            /* undef to save memory     */
-#if defined(CONFIG_CMD_KGDB)
-#define CONFIG_SYS_CBSIZE              1024    /* Console I/O Buffer Size  */
-#else
-#define CONFIG_SYS_CBSIZE              256     /* Console I/O Buffer Size  */
-#endif
-#define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE+sizeof(CONFIG_SYS_PROMPT)+16)     /* Print Buffer Size */
-#define CONFIG_SYS_MAXARGS             16      /* max number of command args   */
-#define CONFIG_SYS_BARGSIZE            CONFIG_SYS_CBSIZE       /* Boot Argument Buffer Size    */
-
-#define CONFIG_SYS_MEMTEST_START       0x00100000      /* memtest works on */
-#define CONFIG_SYS_MEMTEST_END         0x00f00000      /* 1 ... 15 MB in DRAM  */
-
-#define CONFIG_SYS_LOAD_ADDR           0x100000        /* default load address */
-
-#define CONFIG_SYS_VXWORKS_MAC_PTR     0x00000000      /* Pass Ethernet MAC to VxWorks */
-
-#define CONFIG_SYS_CACHELINE_SIZE      32      /* For MPC5xxx CPUs */
-#if defined(CONFIG_CMD_KGDB)
-#  define CONFIG_SYS_CACHELINE_SHIFT   5       /* log base 2 of the above value */
-#endif
-
-/*
- * Various low-level settings
- */
-#define CONFIG_SYS_HID0_INIT           HID0_ICE | HID0_ICFI
-#define CONFIG_SYS_HID0_FINAL          HID0_ICE
-
-#define CONFIG_SYS_BOOTCS_START        CONFIG_SYS_FLASH_BASE
-#define CONFIG_SYS_BOOTCS_SIZE         CONFIG_SYS_FLASH_SIZE
-#define CONFIG_SYS_BOOTCS_CFG          0x0004DD00
-
-#define CONFIG_SYS_CS0_START           CONFIG_SYS_FLASH_BASE
-#define CONFIG_SYS_CS0_SIZE            CONFIG_SYS_FLASH_SIZE
-
-#define CONFIG_SYS_CS1_START           0xfd000000
-#define CONFIG_SYS_CS1_SIZE            0x00010000
-#define CONFIG_SYS_CS1_CFG             0x10101410
-
-#define CONFIG_SYS_CS3_START           0xfd010000
-#define CONFIG_SYS_CS3_SIZE            0x00010000
-#define CONFIG_SYS_CS3_CFG             0x10109410
-
-#define CONFIG_SYS_CS_BURST            0x00000000
-#define CONFIG_SYS_CS_DEADCYCLE        0x33333333
-
-#define CONFIG_SYS_RESET_ADDRESS       0xff000000
-
-/*-----------------------------------------------------------------------
- * USB stuff
- *-----------------------------------------------------------------------
- */
-#define CONFIG_USB_CLOCK       0x0001BBBB
-#define CONFIG_USB_CONFIG      0x00001000
-
-/*-----------------------------------------------------------------------
- * IDE/ATA stuff Supports IDE harddisk
- *-----------------------------------------------------------------------
- */
-
-#undef CONFIG_IDE_8xx_PCCARD   /* Use IDE with PC Card Adapter */
-
-#undef CONFIG_IDE_8xx_DIRECT   /* Direct IDE    not supported  */
-#undef CONFIG_IDE_LED          /* LED   for ide not supported  */
-
-#define        CONFIG_IDE_RESET        /* reset for ide supported      */
-#define CONFIG_IDE_PREINIT
-
-#define CONFIG_SYS_IDE_MAXBUS          1       /* max. 1 IDE bus               */
-#define CONFIG_SYS_IDE_MAXDEVICE       1       /* max. 1 drive per IDE bus     */
-
-#define CONFIG_SYS_ATA_IDE0_OFFSET     0x0000
-
-#define CONFIG_SYS_ATA_BASE_ADDR       MPC5XXX_ATA
-
-/* Offset for data I/O                 */
-#define CONFIG_SYS_ATA_DATA_OFFSET     (0x0060)
-
-/* Offset for normal register accesses */
-#define CONFIG_SYS_ATA_REG_OFFSET      (CONFIG_SYS_ATA_DATA_OFFSET)
-
-/* Offset for alternate registers      */
-#define CONFIG_SYS_ATA_ALT_OFFSET      (0x005C)
-
-/* Interval between registers                                               */
-#define CONFIG_SYS_ATA_STRIDE          4
-
-/*-----------------------------------------------------------------------
- * CPLD stuff
- */
-#define CONFIG_SYS_FPGA_XC95XL         1       /* using Xilinx XC95XL CPLD      */
-#define CONFIG_SYS_FPGA_MAX_SIZE       32*1024 /* 32kByte is enough for CPLD    */
-
-/* CPLD program pin configuration */
-#define CONFIG_SYS_FPGA_PRG            0x20000000      /* JTAG TMS pin (ppc output)           */
-#define CONFIG_SYS_FPGA_CLK            0x10000000      /* JTAG TCK pin (ppc output)           */
-#define CONFIG_SYS_FPGA_DATA           0x20000000      /* JTAG TDO->TDI data pin (ppc output) */
-#define CONFIG_SYS_FPGA_DONE           0x10000000      /* JTAG TDI->TDO pin (ppc input)       */
-
-#define JTAG_GPIO_ADDR_TMS     (CONFIG_SYS_MBAR + 0xB10)       /* JTAG TMS pin (GPS data out value reg.)      */
-#define JTAG_GPIO_ADDR_TCK     (CONFIG_SYS_MBAR + 0xC0C)       /* JTAG TCK pin (GPW data out value reg.)      */
-#define JTAG_GPIO_ADDR_TDI     (CONFIG_SYS_MBAR + 0xC0C)       /* JTAG TDO->TDI pin (GPW data out value reg.) */
-#define JTAG_GPIO_ADDR_TDO     (CONFIG_SYS_MBAR + 0xB14)       /* JTAG TDI->TDO pin (GPS data in value reg.)  */
-
-#define JTAG_GPIO_ADDR_CFG     (CONFIG_SYS_MBAR + 0xB00)
-#define JTAG_GPIO_CFG_SET      0x00000000
-#define JTAG_GPIO_CFG_RESET    0x00F00000
-
-#define JTAG_GPIO_ADDR_EN_TMS  (CONFIG_SYS_MBAR + 0xB04)
-#define JTAG_GPIO_TMS_EN_SET   0x20000000      /* Enable for GPIO */
-#define JTAG_GPIO_TMS_EN_RESET 0x00000000
-#define JTAG_GPIO_ADDR_DDR_TMS (CONFIG_SYS_MBAR + 0xB0C)
-#define JTAG_GPIO_TMS_DDR_SET  0x20000000      /* Set as output   */
-#define JTAG_GPIO_TMS_DDR_RESET 0x00000000
-
-#define JTAG_GPIO_ADDR_EN_TCK  (CONFIG_SYS_MBAR + 0xC00)
-#define JTAG_GPIO_TCK_EN_SET   0x20000000      /* Enable for GPIO */
-#define JTAG_GPIO_TCK_EN_RESET 0x00000000
-#define JTAG_GPIO_ADDR_DDR_TCK (CONFIG_SYS_MBAR + 0xC08)
-#define JTAG_GPIO_TCK_DDR_SET  0x20000000      /* Set as output   */
-#define JTAG_GPIO_TCK_DDR_RESET 0x00000000
-
-#define JTAG_GPIO_ADDR_EN_TDI  (CONFIG_SYS_MBAR + 0xC00)
-#define JTAG_GPIO_TDI_EN_SET   0x10000000      /* Enable as GPIO  */
-#define JTAG_GPIO_TDI_EN_RESET 0x00000000
-#define JTAG_GPIO_ADDR_DDR_TDI (CONFIG_SYS_MBAR + 0xC08)
-#define JTAG_GPIO_TDI_DDR_SET  0x10000000      /* Set as output   */
-#define JTAG_GPIO_TDI_DDR_RESET 0x00000000
-
-#define JTAG_GPIO_ADDR_EN_TDO  (CONFIG_SYS_MBAR + 0xB04)
-#define JTAG_GPIO_TDO_EN_SET   0x10000000      /* Enable as GPIO  */
-#define JTAG_GPIO_TDO_EN_RESET 0x00000000
-#define JTAG_GPIO_ADDR_DDR_TDO (CONFIG_SYS_MBAR + 0xB0C)
-#define JTAG_GPIO_TDO_DDR_SET  0x00000000
-#define JTAG_GPIO_TDO_DDR_RESET 0x10000000     /* Set as input    */
-
-#endif                         /* __CONFIG_H */
index cb03e33b6e133a71f6b5d962dae32abeaf981bdf..1683a1582f4e0dd7ea4299ef8f67bfc937d54fb5 100644 (file)
@@ -11,6 +11,8 @@
  * High Level Configuration Options (easy to change)
  */
 #define CONFIG_ARMADA_XP               /* SOC Family Name */
+#define CONFIG_DB_784MP_GP             /* Board target name for DDR training */
+
 #define CONFIG_SKIP_LOWLEVEL_INIT      /* disable board lowlevel_init */
 #define CONFIG_SYS_GENERIC_BOARD
 #define CONFIG_DISPLAY_BOARDINFO_LATE
  */
 #include "mv-common.h"
 
+/*
+ * Memory layout while starting into the bin_hdr via the
+ * BootROM:
+ *
+ * 0x4000.4000 - 0x4003.4000   headers space (192KiB)
+ * 0x4000.4030                 bin_hdr start address
+ * 0x4003.4000 - 0x4004.7c00   BootROM memory allocations (15KiB)
+ * 0x4007.fffc                 BootROM stack top
+ *
+ * The address space between 0x4007.fffc and 0x400f.fff is not locked in
+ * L2 cache thus cannot be used.
+ */
+
+/* SPL */
+/* Defines for SPL */
+#define CONFIG_SPL_FRAMEWORK
+#define CONFIG_SPL_TEXT_BASE           0x40004030
+#define CONFIG_SPL_MAX_SIZE            ((128 << 10) - 0x4030)
+
+#define CONFIG_SPL_BSS_START_ADDR      (0x40000000 + (128 << 10))
+#define CONFIG_SPL_BSS_MAX_SIZE                (16 << 10)
+
+#define CONFIG_SYS_SPL_MALLOC_START    (CONFIG_SPL_BSS_START_ADDR + \
+                                        CONFIG_SPL_BSS_MAX_SIZE)
+#define CONFIG_SYS_SPL_MALLOC_SIZE     (16 << 10)
+
+#define CONFIG_SPL_STACK               (0x40000000 + ((192 - 16) << 10))
+#define CONFIG_SPL_BOOTROM_SAVE                (CONFIG_SPL_STACK + 4)
+
+#define CONFIG_SPL_LIBCOMMON_SUPPORT
+#define CONFIG_SPL_LIBGENERIC_SUPPORT
+#define CONFIG_SPL_SERIAL_SUPPORT
+#define CONFIG_SPL_I2C_SUPPORT
+#define CONFIG_SPL_LDSCRIPT            "arch/arm/mvebu-common/u-boot-spl.lds"
+
+/* SPL related SPI defines */
+#define CONFIG_SPL_SPI_SUPPORT
+#define CONFIG_SPL_SPI_FLASH_SUPPORT
+#define CONFIG_SPL_SPI_LOAD
+#define CONFIG_SPL_SPI_BUS             0
+#define CONFIG_SPL_SPI_CS              0
+#define CONFIG_SYS_SPI_U_BOOT_OFFS     0x20000
+
+/* Enable DDR support in SPL (DDR3 training from Marvell bin_hdr) */
+#define CONFIG_SYS_MVEBU_DDR
+#define CONFIG_SPD_EEPROM              0x4e
+
 #endif /* _CONFIG_DB_MV7846MP_GP_H */
index 46a42b30874492f970aabf6b0420ea11d57d7dbc..ec7f721ff3736e3f571b3a567d3b09bf9cbba487 100644 (file)
@@ -12,6 +12,8 @@
 #ifndef _CONFIG_DOCKSTAR_H
 #define _CONFIG_DOCKSTAR_H
 
+#define CONFIG_SYS_GENERIC_BOARD
+
 /*
  * Version number information
  */
index ad63f3c5496d39e0be23c35d2a1d29c92edf8c11..0ba39a23dd03d4fcf71d3bed7815e8149cc7019d 100644 (file)
 #define SPI_FLASH_UBOOT_POS    (CONFIG_SEC_FW_SIZE + CONFIG_BL1_SIZE)
 
 /* I2C */
-#define CONFIG_SYS_I2C_INIT_BOARD
-#define CONFIG_SYS_I2C
+#define CONFIG_DM_I2C
+#define CONFIG_DM_I2C_COMPAT
 #define CONFIG_CMD_I2C
-#define CONFIG_SYS_I2C_S3C24X0_SPEED   100000          /* 100 Kbps */
 #define CONFIG_SYS_I2C_S3C24X0
-#define CONFIG_I2C_MULTI_BUS
+#define CONFIG_SYS_I2C_S3C24X0_SPEED   100000          /* 100 Kbps */
 #define CONFIG_SYS_I2C_S3C24X0_SLAVE    0x0
 #define CONFIG_I2C_EDID
 
index 671431397fc02598316a9da65e170cd9196c5df8..ae0e5ff47b096a48f2a1a798070a80a06ad52f52 100644 (file)
@@ -28,9 +28,6 @@
 
 #define CONFIG_SYS_INIT_SP_ADDR        CONFIG_IRAM_STACK
 
-/* PMIC */
-#define CONFIG_POWER_MAX77686
-
 /* Sound */
 #define CONFIG_CMD_SOUND
 #ifdef CONFIG_CMD_SOUND
index 5ed949791f642a5e0a901d7838c0f2595e7fecd1..836515d17820f581fcc2b708c7cf7961d1f3efca 100644 (file)
@@ -15,6 +15,8 @@
 #ifndef _CONFIG_GOFLEXHOME_H
 #define _CONFIG_GOFLEXHOME_H
 
+#define CONFIG_SYS_GENERIC_BOARD
+
 /*
  * Version number information
  */
index a56a4cb98271c558bcd4a3654b686c448ebdd06c..8e53af8c04bb47d3c3ced3d807ddd9fb1537f735 100644 (file)
@@ -1,5 +1,6 @@
 /*
- * (C) Copyright 2009
+ * (C) Copyright 2009-2014
+ * Gerald Kerma <dreagle@doukki.net>
  * Marvell Semiconductor <www.marvell.com>
  * Written-by: Siddarth Gore <gores@marvell.com>
  *
@@ -9,6 +10,8 @@
 #ifndef _CONFIG_GURUPLUG_H
 #define _CONFIG_GURUPLUG_H
 
+#define CONFIG_SYS_GENERIC_BOARD
+
 /*
  * Version number information
  */
 #define CONFIG_MACH_GURUPLUG   /* Machine type */
 #define CONFIG_SKIP_LOWLEVEL_INIT      /* disable board lowlevel_init */
 
+/*
+ * Compression configuration
+ */
+#define CONFIG_BZIP2
+#define CONFIG_LZMA
+#define CONFIG_LZO
+
+/*
+ * Enable device tree support
+ */
+#define CONFIG_OF_LIBFDT
+
+/*
+ * Miscellaneous configurable options
+ */
+#define CONFIG_SYS_HUSH_PARSER         /* use "hush" command parser */
+
 /*
  * Commands configuration
  */
 #define CONFIG_SYS_NO_FLASH            /* Declare no flash (NOR/SPI) */
 #include <config_cmd_default.h>
+#define CONFIG_CMD_BOOTZ
 #define CONFIG_CMD_DHCP
 #define CONFIG_CMD_ENV
-#define CONFIG_CMD_FAT
+#define CONFIG_CMD_IDE
+#define CONFIG_CMD_MII
 #define CONFIG_CMD_NAND
 #define CONFIG_CMD_PING
 #define CONFIG_CMD_USB
-#define CONFIG_CMD_IDE
+#define CONFIG_CMD_FAT
 
 /*
  * mv-common.h should be defined after CMD configs since it used them
  * it has to be rounded to sector size
  */
 #define CONFIG_ENV_SIZE                        0x20000 /* 128k */
-#define CONFIG_ENV_ADDR                        0x60000
-#define CONFIG_ENV_OFFSET              0x60000 /* env starts here */
+#define CONFIG_ENV_OFFSET              0xE0000 /* env starts here */
 
 /*
  * Default environment variables
  */
-#define CONFIG_BOOTCOMMAND             "setenv ethact egiga0; " \
-       "${x_bootcmd_ethernet}; setenv ethact egiga1; " \
-       "${x_bootcmd_ethernet}; ${x_bootcmd_usb}; ${x_bootcmd_kernel}; "\
-       "setenv bootargs ${x_bootargs} ${x_bootargs_root}; "    \
-       "bootm 0x6400000;"
-
-#define CONFIG_EXTRA_ENV_SETTINGS      \
-       "x_bootcmd_ethernet=ping 192.168.2.1\0" \
-       "x_bootcmd_usb=usb start\0"     \
-       "x_bootcmd_kernel=nand read.e 0x6400000 0x100000 0x400000\0" \
-       "x_bootargs=console=ttyS0,115200\0"     \
-       "x_bootargs_root=ubi.mtd=2 root=ubi0:rootfs rootfstype=ubifs\0"
+#define CONFIG_BOOTCOMMAND \
+       "setenv bootargs ${console} ${mtdparts} ${bootargs_root}; "     \
+       "ubi part root; "                                               \
+       "ubifsmount ubi:rootfs; "                                       \
+       "ubifsload 0x800000 ${kernel}; "                                \
+       "ubifsload 0x700000 ${fdt}; "                                   \
+       "ubifsumount; "                                                 \
+       "fdt addr 0x700000; fdt resize; fdt chosen; "                   \
+       "bootz 0x800000 - 0x700000"
+
+#define CONFIG_MTDPARTS        \
+       "mtdparts=orion_nand:"                                          \
+       "896K(uboot),128K(uboot_env),"                                  \
+       "-@1M(root)\0"
+
+#define CONFIG_EXTRA_ENV_SETTINGS \
+       "console=console=ttyS0,115200\0"                                \
+       "mtdids=nand0=orion_nand\0"                                     \
+       "mtdparts="CONFIG_MTDPARTS                                      \
+       "kernel=/boot/zImage\0"                                         \
+       "fdt=/boot/guruplug-server-plus.dtb\0"                          \
+       "bootargs_root=ubi.mtd=2 root=ubi0:rootfs rootfstype=ubifs rw\0"
+
+#define MTDIDS_DEFAULT "nand0=orion_nand"
+
+#define MTDPARTS_DEFAULT       \
+       "mtdparts="CONFIG_MTDPARTS
 
 /*
  * Ethernet Driver configuration
 #define CONFIG_SYS_ATA_IDE0_OFFSET     MV_SATA_PORT0_OFFSET
 #endif /*CONFIG_MVSATA_IDE*/
 
+/*
+ * File system
+ */
+#define CONFIG_CMD_EXT2
+#define CONFIG_CMD_EXT4
+#define CONFIG_CMD_FAT
+#define CONFIG_CMD_JFFS2
+#define CONFIG_CMD_UBI
+#define CONFIG_CMD_UBIFS
+#define CONFIG_RBTREE
+#define CONFIG_MTD_DEVICE
+#define CONFIG_MTD_PARTITIONS
+#define CONFIG_CMD_MTDPARTS
+
 #define CONFIG_SYS_ALT_MEMTEST
 
 #endif /* _CONFIG_GURUPLUG_H */
index f4c748a91d1f0d94190046545fcf73fd5b9946d5..f1ddf21580da19fd0e12f4d3ffa4b49cb47834c3 100644 (file)
@@ -9,6 +9,8 @@
 #ifndef _CONFIG_IB62x0_H
 #define _CONFIG_IB62x0_H
 
+#define CONFIG_SYS_GENERIC_BOARD
+
 /*
  * Version number information
  */
index ac5ca9af37b839385a891f03aa3f86f066f5993f..2a937c6a2212fea8565261a919163a20222a9d40 100644 (file)
@@ -82,7 +82,7 @@
 #define CONFIG_ENV_OFFSET              0x4000
 #define CONFIG_ENV_ADDR                (CONFIG_SYS_FLASH_BASE + CONFIG_ENV_OFFSET)
 #define CONFIG_ENV_SIZE                0x2000
-#define CONFIG_ENV_SECT_SIZE   0x10000 /* Total Size of Environment Sector */
+#define CONFIG_ENV_SECT_SIZE   0x12000 /* Total Size of Environment Sector */
 #if (CONFIG_BFIN_BOOT_MODE == BFIN_BOOT_BYPASS)
 #define ENV_IS_EMBEDDED
 #else
index 9f4a4b83a32a7927f6a4f6b2ac168b30a614cb97..2baf50cc4e1df6ec7229becfb8322ed25f4a0b8c 100644 (file)
@@ -9,6 +9,8 @@
 #ifndef _CONFIG_ICONNECT_H
 #define _CONFIG_ICONNECT_H
 
+#define CONFIG_SYS_GENERIC_BOARD
+
 /*
  * Version number information
  */
index f08483487d9fc7dc7533076cfa6527127d7d8570..2384864eb025fc979288bec16e3a2e2aca709f01 100644 (file)
 
 #define CONFIG_VERSION_VARIABLE
 
-#define CONFIG_FIT
-#define CONFIG_FIT_SIGNATURE
 #define CONFIG_IMAGE_FORMAT_LEGACY
 #define CONFIG_CMD_FDT
 #define CONFIG_CMD_HASH
-#define CONFIG_RSA
 #define CONFIG_SHA1
 #define CONFIG_SHA256
 
index ec510bdac421757a54086fc1e6892ca166d31212..2ee215f70614dfb44b7179e8247dc2936329e768 100644 (file)
@@ -61,7 +61,7 @@
 #define CONFIG_EBIU_AMBCTL0_VAL        0xffc2ffc2
 #define CONFIG_EBIU_AMBCTL1_VAL        0xffc2ffc2
 
-#define CONFIG_SYS_MONITOR_LEN         (256 * 1024)
+#define CONFIG_SYS_MONITOR_LEN         (384 * 1024)
 #define CONFIG_SYS_MALLOC_LEN          (128 * 1024)
 
 
index 8dc04f2e574bd40eee24a31605a245b0373a4a16..2874ccc6fadd2847b98fe5018fb3c6f16479fae7 100644 (file)
 #define CONFIG_SKIP_LOWLEVEL_INIT
 #define CONFIG_BOARD_EARLY_INIT_F
 
+#define CONFIG_DEEP_SLEEP
+#if defined(CONFIG_DEEP_SLEEP)
+#define CONFIG_SILENT_CONSOLE
+#endif
+
 /*
  * Size of malloc() pool
  */
@@ -72,7 +77,8 @@ unsigned long get_board_ddr_clk(void);
 #define CONFIG_SPL_PAD_TO              0x1c000
 #define CONFIG_SYS_TEXT_BASE           0x82000000
 
-#define CONFIG_SYS_SPL_MALLOC_START    0x80200000
+#define CONFIG_SYS_SPL_MALLOC_START    (CONFIG_SYS_TEXT_BASE + \
+               CONFIG_SYS_MONITOR_LEN)
 #define CONFIG_SYS_SPL_MALLOC_SIZE     0x100000
 #define CONFIG_SPL_BSS_START_ADDR      0x80100000
 #define CONFIG_SPL_BSS_MAX_SIZE                0x80000
@@ -365,11 +371,16 @@ unsigned long get_board_ddr_clk(void);
 /*
  * Serial Port
  */
+#ifdef CONFIG_LPUART
+#define CONFIG_FSL_LPUART
+#define CONFIG_LPUART_32B_REG
+#else
 #define CONFIG_CONS_INDEX              1
 #define CONFIG_SYS_NS16550
 #define CONFIG_SYS_NS16550_SERIAL
 #define CONFIG_SYS_NS16550_REG_SIZE    1
 #define CONFIG_SYS_NS16550_CLK         get_serial_clock()
+#endif
 
 #define CONFIG_BAUDRATE                        115200
 
@@ -385,6 +396,7 @@ unsigned long get_board_ddr_clk(void);
  */
 #define I2C_MUX_PCA_ADDR_PRI           0x77
 #define I2C_MUX_CH_DEFAULT             0x8
+#define I2C_MUX_CH_CH7301              0xC
 
 /*
  * MMC
@@ -426,6 +438,25 @@ unsigned long get_board_ddr_clk(void);
 #endif
 #endif
 
+/*
+ * Video
+ */
+#define CONFIG_FSL_DCU_FB
+
+#ifdef CONFIG_FSL_DCU_FB
+#define CONFIG_VIDEO
+#define CONFIG_CMD_BMP
+#define CONFIG_CFB_CONSOLE
+#define CONFIG_VGA_AS_SINGLE_DEVICE
+#define CONFIG_VIDEO_LOGO
+#define CONFIG_VIDEO_BMP_LOGO
+
+#define CONFIG_FSL_DIU_CH7301
+#define CONFIG_SYS_I2C_DVI_BUS_NUM     0
+#define CONFIG_SYS_I2C_QIXIS_ADDR      0x66
+#define CONFIG_SYS_I2C_DVI_ADDR                0x75
+#endif
+
 /*
  * eTSEC
  */
@@ -508,11 +539,19 @@ unsigned long get_board_ddr_clk(void);
 
 #define CONFIG_SYS_QE_FW_ADDR     0x67f40000
 
+#ifdef CONFIG_LPUART
+#define CONFIG_EXTRA_ENV_SETTINGS       \
+       "bootargs=root=/dev/ram0 rw console=ttyLP0,115200\0" \
+       "fdt_high=0xcfffffff\0"         \
+       "initrd_high=0xcfffffff\0"      \
+       "hwconfig=fsl_ddr:ctlr_intlv=null,bank_intlv=null\0"
+#else
 #define CONFIG_EXTRA_ENV_SETTINGS      \
        "bootargs=root=/dev/ram0 rw console=ttyS0,115200\0" \
        "fdt_high=0xcfffffff\0"         \
        "initrd_high=0xcfffffff\0"      \
        "hwconfig=fsl_ddr:ctlr_intlv=null,bank_intlv=null\0"
+#endif
 
 /*
  * Miscellaneous configurable options
index 66954d0a401aee4e97be648cd5566c4c6b9d6194..0a0bb5f1099ea789b8da6dabe00778745527ecf0 100644 (file)
 /*
  * Serial Port
  */
+#ifdef CONFIG_LPUART
+#define CONFIG_FSL_LPUART
+#define CONFIG_LPUART_32B_REG
+#else
 #define CONFIG_CONS_INDEX              1
 #define CONFIG_SYS_NS16550
 #define CONFIG_SYS_NS16550_SERIAL
 #define CONFIG_SYS_NS16550_REG_SIZE    1
 #define CONFIG_SYS_NS16550_CLK         get_serial_clock()
+#endif
 
 #define CONFIG_BAUDRATE                        115200
 
 
 #define CONFIG_BOOTDELAY               3
 
+#ifdef CONFIG_LPUART
+#define CONFIG_EXTRA_ENV_SETTINGS       \
+       "bootargs=root=/dev/ram0 rw console=ttyLP0,115200\0" \
+       "initrd_high=0xcfffffff\0"      \
+       "fdt_high=0xcfffffff\0"
+#else
 #define CONFIG_EXTRA_ENV_SETTINGS      \
        "bootargs=root=/dev/ram0 rw console=ttyS0,115200\0" \
        "initrd_high=0xcfffffff\0"      \
        "fdt_high=0xcfffffff\0"
+#endif
 
 /*
  * Miscellaneous configurable options
index a29b86b4f63c95fe5110f901ca52891c315fa4a2..354672ecf8735e9240b119a801df2ffba0b91ab1 100644 (file)
@@ -38,8 +38,6 @@
 #define CONFIG_SYS_MHZ                 250     /* arbitrary value */
 #define CONFIG_SYS_MIPS_TIMER_FREQ     (CONFIG_SYS_MHZ * 1000000)
 
-#define CONFIG_SWAP_IO_SPACE
-
 /*
  * Memory map
  */
@@ -73,6 +71,7 @@
                                         sizeof(CONFIG_SYS_PROMPT) + 16)
 #define CONFIG_SYS_MAXARGS             16
 
+#define CONFIG_SYS_HUSH_PARSER
 #define CONFIG_AUTO_COMPLETE
 #define CONFIG_CMDLINE_EDITING
 
 #define CONFIG_ENV_ADDR \
        (CONFIG_SYS_FLASH_BASE + (4 << 20) - CONFIG_ENV_SIZE)
 
+/*
+ * IDE/ATA
+ */
+#define CONFIG_SYS_IDE_MAXBUS          1
+#define CONFIG_SYS_IDE_MAXDEVICE       2
+#define CONFIG_SYS_ATA_BASE_ADDR       CONFIG_SYS_ISA_IO_BASE_ADDRESS
+#define CONFIG_SYS_ATA_IDE0_OFFSET     0x01f0
+#define CONFIG_SYS_ATA_DATA_OFFSET     0
+#define CONFIG_SYS_ATA_REG_OFFSET      0
+
 /*
  * Commands
  */
 
 #define CONFIG_CMD_DATE
 #define CONFIG_CMD_DHCP
+#define CONFIG_CMD_ELF
+#define CONFIG_CMD_IDE
 #define CONFIG_CMD_PCI
 #define CONFIG_CMD_PING
 
index 72217bdb574b8c7f71206cb206abb36305414387..5999d6014678afe35743118a91238ed89db5b48b 100644 (file)
@@ -43,6 +43,8 @@
 #define CONFIG_SF_DEFAULT_SPEED                1000000
 #define CONFIG_SF_DEFAULT_MODE         SPI_MODE_3
 #define CONFIG_SPI_FLASH_STMICRO
+#define CONFIG_SPI_FLASH_SPANSION
+#define CONFIG_SPI_FLASH_BAR
 
 /* Environment in SPI NOR flash */
 #define CONFIG_ENV_IS_IN_SPI_FLASH
  */
 #include "mv-common.h"
 
+/*
+ * Memory layout while starting into the bin_hdr via the
+ * BootROM:
+ *
+ * 0x4000.4000 - 0x4003.4000   headers space (192KiB)
+ * 0x4000.4030                 bin_hdr start address
+ * 0x4003.4000 - 0x4004.7c00   BootROM memory allocations (15KiB)
+ * 0x4007.fffc                 BootROM stack top
+ *
+ * The address space between 0x4007.fffc and 0x400f.fff is not locked in
+ * L2 cache thus cannot be used.
+ */
+
+/* SPL */
+/* Defines for SPL */
+#define CONFIG_SPL_FRAMEWORK
+#define CONFIG_SPL_TEXT_BASE           0x40004030
+#define CONFIG_SPL_MAX_SIZE            ((128 << 10) - 0x4030)
+
+#define CONFIG_SPL_BSS_START_ADDR      (0x40000000 + (128 << 10))
+#define CONFIG_SPL_BSS_MAX_SIZE                (16 << 10)
+
+#define CONFIG_SYS_SPL_MALLOC_START    (CONFIG_SPL_BSS_START_ADDR + \
+                                        CONFIG_SPL_BSS_MAX_SIZE)
+#define CONFIG_SYS_SPL_MALLOC_SIZE     (16 << 10)
+
+#define CONFIG_SPL_STACK               (0x40000000 + ((192 - 16) << 10))
+#define CONFIG_SPL_BOOTROM_SAVE                (CONFIG_SPL_STACK + 4)
+
+#define CONFIG_SPL_LIBCOMMON_SUPPORT
+#define CONFIG_SPL_LIBGENERIC_SUPPORT
+#define CONFIG_SPL_SERIAL_SUPPORT
+#define CONFIG_SPL_I2C_SUPPORT
+#define CONFIG_SPL_LDSCRIPT            "arch/arm/mvebu-common/u-boot-spl.lds"
+
+/* SPL related SPI defines */
+#define CONFIG_SPL_SPI_SUPPORT
+#define CONFIG_SPL_SPI_FLASH_SUPPORT
+#define CONFIG_SPL_SPI_LOAD
+#define CONFIG_SPL_SPI_BUS             0
+#define CONFIG_SPL_SPI_CS              0
+#define CONFIG_SYS_SPI_U_BOOT_OFFS     0x20000
+
+/* Enable DDR support in SPL (DDR3 training from Marvell bin_hdr) */
+#define CONFIG_SYS_MVEBU_DDR
+#define CONFIG_DDR_FIXED_SIZE          (1 << 20)       /* 1GiB */
+
 #endif /* _CONFIG_DB_MV7846MP_GP_H */
diff --git a/include/configs/mecp5200.h b/include/configs/mecp5200.h
deleted file mode 100644 (file)
index b270429..0000000
+++ /dev/null
@@ -1,319 +0,0 @@
-/*
- * (C) Copyright 2003-2004
- * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-
-/*************************************************************************
- * (c) 2005 esd gmbh Hannover
- *
- *
- * from IceCube.h file
- * by Reinhard Arlt reinhard.arlt@esd-electronics.com
- *
- *************************************************************************/
-
-#ifndef __CONFIG_H
-#define __CONFIG_H
-
-/*
- * High Level Configuration Options
- * (easy to change)
- */
-
-#define CONFIG_MPC5200         1       /* This is an MPC5200 CPU */
-#define CONFIG_ICECUBE         1       /* ... on IceCube board */
-#define CONFIG_MECP5200                1       /* ... on MECP5200  board */
-#define CONFIG_MPC5200_DDR      1       /* ... use DDR RAM      */
-
-#ifndef CONFIG_SYS_TEXT_BASE
-#define CONFIG_SYS_TEXT_BASE   0xFFF00000
-#endif
-
-#define CONFIG_SYS_MPC5XXX_CLKIN       33000000 /* ... running at 33.000000MHz */
-
-#define CONFIG_HIGH_BATS       1       /* High BATs supported */
-
-/*
- * Serial console configuration
- */
-#define CONFIG_PSC_CONSOLE     1       /* console is on PSC1 */
-#if 0 /* test-only */
-#define CONFIG_BAUDRATE                115200  /* ... at 115200 bps */
-#else
-#define CONFIG_BAUDRATE                9600    /* ... at 115200 bps */
-#endif
-#define CONFIG_SYS_BAUDRATE_TABLE      { 9600, 19200, 38400, 57600, 115200, 230400 }
-
-#define CONFIG_MII
-#if 0 /* test-only !!! */
-#define CONFIG_EEPRO100                1
-#define CONFIG_SYS_RX_ETH_BUFFER       8  /* use 8 rx buffer on eepro100  */
-#define CONFIG_NS8382X         1
-#endif
-
-/* Partitions */
-#define CONFIG_MAC_PARTITION
-#define CONFIG_DOS_PARTITION
-
-/* USB */
-#if 0
-#define CONFIG_USB_OHCI
-#define CONFIG_USB_STORAGE
-#endif
-
-
-/*
- * BOOTP options
- */
-#define CONFIG_BOOTP_BOOTFILESIZE
-#define CONFIG_BOOTP_BOOTPATH
-#define CONFIG_BOOTP_GATEWAY
-#define CONFIG_BOOTP_HOSTNAME
-
-
-/*
- * Command line configuration.
- */
-#include <config_cmd_default.h>
-
-#define CONFIG_CMD_EEPROM
-#define CONFIG_CMD_FAT
-#define CONFIG_CMD_EXT2
-#define CONFIG_CMD_I2C
-#define CONFIG_CMD_IDE
-#define CONFIG_CMD_BSP
-#define CONFIG_CMD_ELF
-
-
-#if (CONFIG_SYS_TEXT_BASE == 0xFF000000)               /* Boot low with 16 MB Flash */
-#   define CONFIG_SYS_LOWBOOT          1
-#   define CONFIG_SYS_LOWBOOT16        1
-#endif
-#if (CONFIG_SYS_TEXT_BASE == 0xFF800000)               /* Boot low with  8 MB Flash */
-#   define CONFIG_SYS_LOWBOOT          1
-#   define CONFIG_SYS_LOWBOOT08        1
-#endif
-
-/*
- * Autobooting
- */
-#define CONFIG_BOOTDELAY       3       /* autoboot after 5 seconds */
-
-#define CONFIG_PREBOOT "echo;" \
-       "echo Welcome to CBX-CPU5200 (mecp5200);" \
-       "echo"
-
-#undef CONFIG_BOOTARGS
-
-#define        CONFIG_EXTRA_ENV_SETTINGS \
-       "netdev=eth0\0" \
-       "flash_vxworks0=run ata_vxworks_args;setenv loadaddr ff000000;bootvx\0" \
-       "flash_vxworks1=run ata_vxworks_args;setenv loadaddr ff200000:bootvx\0" \
-       "net_vxworks=tftp $(loadaddr) $(image);run vxworks_args;bootvx\0" \
-       "vxworks_args=setenv bootargs fec(0,0)$(host):$(image) h=$(serverip) e=$(ipaddr) g=$(gatewayip) u=$(user) $(pass) tn=$(target) s=$(script)\0" \
-       "ata_vxworks_args=setenv bootargs /ata0/vxWorks h=$(serverip) e=$(ipaddr) g=$(gatewayip) u=$(user) $(pass) tn=$(target) s=$(script) o=fec0 \0" \
-       "loadaddr=01000000\0" \
-       "serverip=192.168.2.99\0" \
-       "gatewayip=10.0.0.79\0" \
-       "user=mu\0" \
-       "target=mecp5200.esd\0" \
-       "script=mecp5200.bat\0" \
-       "image=/tftpboot/vxWorks_mecp5200\0" \
-       "ipaddr=10.0.13.196\0" \
-       "netmask=255.255.0.0\0" \
-       ""
-
-#define CONFIG_BOOTCOMMAND     "run flash_vxworks0"
-
-/*
- * IPB Bus clocking configuration.
- */
-#undef CONFIG_SYS_IPBSPEED_133                 /* define for 133MHz speed */
-/*
- * I2C configuration
- */
-#define CONFIG_HARD_I2C                1       /* I2C with hardware support */
-#define CONFIG_SYS_I2C_MODULE          2       /* Select I2C module #1 or #2 */
-
-#define CONFIG_SYS_I2C_SPEED           86000 /* 100 kHz */
-#define CONFIG_SYS_I2C_SLAVE           0x7F
-
-/*
- * EEPROM configuration
- */
-#define CONFIG_SYS_I2C_EEPROM_ADDR             0x50    /* 1010000x */
-#define CONFIG_SYS_I2C_EEPROM_ADDR_LEN         2
-#define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS      5
-#define CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS  20
-#define CONFIG_SYS_I2C_MULTI_EEPROMS           1
-/*
- * Flash configuration
- */
-#define CONFIG_SYS_FLASH_BASE          0xFFC00000
-#define CONFIG_SYS_FLASH_SIZE          0x00400000
-#define CONFIG_ENV_ADDR                (CONFIG_SYS_FLASH_BASE + 0x003E0000)
-#define CONFIG_SYS_MAX_FLASH_BANKS     1       /* max num of memory banks      */
-#define CONFIG_SYS_MAX_FLASH_SECT      512
-
-#define CONFIG_SYS_FLASH_ERASE_TOUT    240000  /* Flash Erase Timeout (in ms)  */
-#define CONFIG_SYS_FLASH_WRITE_TOUT    500     /* Flash Write Timeout (in ms)  */
-
-/*
- * Environment settings
- */
-#if 1 /* test-only */
-#define CONFIG_ENV_IS_IN_FLASH 1
-#define CONFIG_ENV_SIZE                0x10000
-#define CONFIG_ENV_SECT_SIZE   0x10000
-#define CONFIG_ENV_OVERWRITE   1
-#else
-#define CONFIG_ENV_IS_IN_EEPROM        1       /* use EEPROM for environment vars */
-#define CONFIG_ENV_OFFSET              0x0000  /* environment starts at the beginning of the EEPROM */
-#define CONFIG_ENV_SIZE                0x0400  /* 8192 bytes may be used for env vars*/
-                                  /* total size of a CAT24WC32 is 8192 bytes */
-#define CONFIG_ENV_OVERWRITE   1
-#endif
-
-#define CONFIG_FLASH_CFI_DRIVER        1          /* Flash is CFI conformant           */
-#define CONFIG_SYS_FLASH_CFI           1          /* Flash is CFI conformant           */
-#define CONFIG_SYS_FLASH_PROTECTION    1          /* use hardware protection           */
-#if 0
-#define CONFIG_SYS_FLASH_USE_BUFFER_WRITE 1       /* use buffered writes (20x faster)  */
-#endif
-#define CONFIG_SYS_FLASH_INCREMENT     0x00400000 /* size of  flash bank               */
-#define CONFIG_SYS_FLASH_BANKS_LIST  { CONFIG_SYS_FLASH_BASE }
-#define CONFIG_SYS_FLASH_EMPTY_INFO    1          /* show if bank is empty             */
-
-
-/*
- * Memory map
- */
-#define CONFIG_SYS_MBAR                0xF0000000
-#define CONFIG_SYS_SDRAM_BASE          0x00000000
-#define CONFIG_SYS_DEFAULT_MBAR        0x80000000
-
-/* Use SRAM until RAM will be available */
-#define CONFIG_SYS_INIT_RAM_ADDR       MPC5XXX_SRAM
-#define CONFIG_SYS_INIT_RAM_SIZE       MPC5XXX_SRAM_SIZE       /* Size of used area in DPRAM */
-
-
-#define CONFIG_SYS_GBL_DATA_OFFSET     (CONFIG_SYS_INIT_RAM_SIZE - GENERATED_GBL_DATA_SIZE)
-#define CONFIG_SYS_INIT_SP_OFFSET      CONFIG_SYS_GBL_DATA_OFFSET
-
-#define CONFIG_SYS_MONITOR_BASE    CONFIG_SYS_TEXT_BASE
-#if (CONFIG_SYS_MONITOR_BASE < CONFIG_SYS_FLASH_BASE)
-#   define CONFIG_SYS_RAMBOOT          1
-#endif
-
-#define CONFIG_SYS_MONITOR_LEN         (192 << 10)     /* Reserve 192 kB for Monitor   */
-#define CONFIG_SYS_MALLOC_LEN          (128 << 10)     /* Reserve 128 kB for malloc()  */
-#define CONFIG_SYS_BOOTMAPSZ           (8 << 20)       /* Initial Memory map for Linux */
-
-/*
- * Ethernet configuration
- */
-#define CONFIG_MPC5xxx_FEC     1
-#define CONFIG_MPC5xxx_FEC_MII100
-/*
- * Define CONFIG_MPC5xxx_FEC_MII10 to force FEC at 10Mb
- */
-/* #define CONFIG_MPC5xxx_FEC_MII10 */
-#define CONFIG_PHY_ADDR                0x00
-#define CONFIG_UDP_CHECKSUM     1
-
-
-/*
- * GPIO configuration
- */
-#define CONFIG_SYS_GPS_PORT_CONFIG     0x01052444
-
-/*
- * Miscellaneous configurable options
- */
-#define CONFIG_SYS_LONGHELP                    /* undef to save memory     */
-#if defined(CONFIG_CMD_KGDB)
-#define CONFIG_SYS_CBSIZE              1024    /* Console I/O Buffer Size  */
-#else
-#define CONFIG_SYS_CBSIZE              256     /* Console I/O Buffer Size  */
-#endif
-#define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE+sizeof(CONFIG_SYS_PROMPT)+16)     /* Print Buffer Size */
-#define CONFIG_SYS_MAXARGS             16              /* max number of command args   */
-#define CONFIG_SYS_BARGSIZE            CONFIG_SYS_CBSIZE       /* Boot Argument Buffer Size    */
-
-#define CONFIG_SYS_MEMTEST_START       0x00100000      /* memtest works on */
-#define CONFIG_SYS_MEMTEST_END         0x00f00000      /* 1 ... 15 MB in DRAM  */
-
-#define CONFIG_SYS_LOAD_ADDR           0x100000        /* default load address */
-
-#define CONFIG_SYS_VXWORKS_MAC_PTR     0x00000000      /* Pass Ethernet MAC to VxWorks */
-
-#define CONFIG_SYS_CACHELINE_SIZE      32      /* For MPC5xxx CPUs */
-#if defined(CONFIG_CMD_KGDB)
-#  define CONFIG_SYS_CACHELINE_SHIFT   5       /* log base 2 of the above value */
-#endif
-
-/*
- * Various low-level settings
- */
-#define CONFIG_SYS_HID0_INIT           HID0_ICE | HID0_ICFI
-#define CONFIG_SYS_HID0_FINAL          HID0_ICE
-
-#define CONFIG_SYS_BOOTCS_START        CONFIG_SYS_FLASH_BASE
-#define CONFIG_SYS_BOOTCS_SIZE         CONFIG_SYS_FLASH_SIZE
-#define CONFIG_SYS_BOOTCS_CFG          0x00085d00
-
-#define CONFIG_SYS_CS0_START           CONFIG_SYS_FLASH_BASE
-#define CONFIG_SYS_CS0_SIZE            CONFIG_SYS_FLASH_SIZE
-
-#define CONFIG_SYS_CS1_START           0xfd000000
-#define CONFIG_SYS_CS1_SIZE            0x00010000
-#define CONFIG_SYS_CS1_CFG             0x10101410
-
-#define CONFIG_SYS_CS_BURST            0x00000000
-#define CONFIG_SYS_CS_DEADCYCLE        0x33333333
-
-#define CONFIG_SYS_RESET_ADDRESS       0xff000000
-
-/*-----------------------------------------------------------------------
- * USB stuff
- *-----------------------------------------------------------------------
- */
-#define CONFIG_USB_CLOCK       0x0001BBBB
-#define CONFIG_USB_CONFIG      0x00001000
-
-/*-----------------------------------------------------------------------
- * IDE/ATA stuff Supports IDE harddisk
- *-----------------------------------------------------------------------
- */
-
-#undef  CONFIG_IDE_8xx_PCCARD          /* Use IDE with PC Card Adapter */
-
-#undef CONFIG_IDE_8xx_DIRECT           /* Direct IDE    not supported  */
-#undef CONFIG_IDE_LED                  /* LED   for ide not supported  */
-
-#define        CONFIG_IDE_RESET                /* reset for ide supported      */
-#define CONFIG_IDE_PREINIT
-
-#define CONFIG_SYS_IDE_MAXBUS          1       /* max. 1 IDE bus               */
-#define CONFIG_SYS_IDE_MAXDEVICE       1       /* max. 1 drive per IDE bus     */
-
-#define CONFIG_SYS_ATA_IDE0_OFFSET     0x0000
-
-#define CONFIG_SYS_ATA_BASE_ADDR       MPC5XXX_ATA
-
-/* Offset for data I/O                 */
-#define CONFIG_SYS_ATA_DATA_OFFSET     (0x0060)
-
-/* Offset for normal register accesses */
-#define CONFIG_SYS_ATA_REG_OFFSET      (CONFIG_SYS_ATA_DATA_OFFSET)
-
-/* Offset for alternate registers      */
-#define CONFIG_SYS_ATA_ALT_OFFSET      (0x005C)
-
-/* Interval between registers          */
-#define CONFIG_SYS_ATA_STRIDE          4
-
-#endif /* __CONFIG_H */
index bb070600021b4a7da9728aaaafd3c9ba132ddf5c..166ab4f05654e9e1a1a970989cb0be808c7e4c68 100644 (file)
 # define CONFIG_XILINX_TB_WATCHDOG
 #endif
 
-/*
- * memory layout - Example
- * CONFIG_SYS_TEXT_BASE = 0x1200_0000; defined in config.mk
- * CONFIG_SYS_SRAM_BASE = 0x1000_0000;
- * CONFIG_SYS_SRAM_SIZE = 0x0400_0000; 64MB
- *
- * CONFIG_SYS_MONITOR_LEN = 0x40000
- * CONFIG_SYS_MALLOC_LEN = 3 * CONFIG_SYS_MONITOR_LEN = 0xC0000
- *
- * CONFIG_SYS_GBL_DATA_OFFSET = 0x1000_0000 + 0x0400_0000 - 0x1000 = 0x13FF_F000
- * CONFIG_SYS_MONITOR_BASE = 0x13FF_F000 - CONFIG_SYS_MONITOR_LEN = 0x13FB_F000
- * CONFIG_SYS_MALLOC_BASE = 0x13FB_F000 - CONFIG_SYS_MALLOC_LEN = 0x13EF_F000
- *
- * 0x1000_0000 CONFIG_SYS_SDRAM_BASE
- *                                     MEMTEST_AREA     64kB
- *                                     FREE
- * 0x1200_0000 CONFIG_SYS_TEXT_BASE
- *             U-BOOT code
- * 0x1202_0000
- *                                     FREE
- *
- *                                     STACK
- * 0x13EF_F000 CONFIG_SYS_MALLOC_BASE
- *                                     MALLOC_AREA     768kB   Alloc
- * 0x13FB_F000 CONFIG_SYS_MONITOR_BASE
- *                                     MONITOR_CODE    256kB   Env
- * 0x13FF_F000 CONFIG_SYS_GBL_DATA_OFFSET
- *                                     GLOBAL_DATA     4kB     bd, gd
- * 0x1400_0000 CONFIG_SYS_SDRAM_BASE + CONFIG_SYS_SDRAM_SIZE
- */
-
+#ifndef CONFIG_OF_CONTROL
 /* ddr sdram - main memory */
-#define        CONFIG_SYS_SDRAM_BASE           XILINX_RAM_START
-#define        CONFIG_SYS_SDRAM_SIZE           XILINX_RAM_SIZE
-#define        CONFIG_SYS_MEMTEST_START        CONFIG_SYS_SDRAM_BASE
-#define        CONFIG_SYS_MEMTEST_END          (CONFIG_SYS_SDRAM_BASE + 0x1000)
-
-/* global pointer */
-/* start of global data */
-#define        CONFIG_SYS_GBL_DATA_OFFSET \
-               (CONFIG_SYS_SDRAM_SIZE - GENERATED_GBL_DATA_SIZE)
-
-/* monitor code */
-#define        SIZE                            0x40000
-#define        CONFIG_SYS_MONITOR_LEN          SIZE
-#define        CONFIG_SYS_MONITOR_BASE \
-               (CONFIG_SYS_SDRAM_BASE + CONFIG_SYS_GBL_DATA_OFFSET \
-                       - CONFIG_SYS_MONITOR_LEN - GENERATED_BD_INFO_SIZE)
-#define        CONFIG_SYS_MONITOR_END \
-                       (CONFIG_SYS_MONITOR_BASE + CONFIG_SYS_MONITOR_LEN)
-#define        CONFIG_SYS_MALLOC_LEN           (SIZE * 3)
-#define        CONFIG_SYS_MALLOC_BASE \
-                       (CONFIG_SYS_MONITOR_BASE - CONFIG_SYS_MALLOC_LEN)
-
-/* stack */
-#define        CONFIG_SYS_INIT_SP_OFFSET       CONFIG_SYS_MALLOC_BASE
+# define CONFIG_SYS_SDRAM_BASE XILINX_RAM_START
+# define CONFIG_SYS_SDRAM_SIZE XILINX_RAM_SIZE
+#endif
+
+#define CONFIG_SYS_MALLOC_LEN  0xC0000
+#ifndef CONFIG_SPL_BUILD
+# define CONFIG_SYS_MALLOC_F_LEN       1024
+#else
+# define CONFIG_SYS_MALLOC_SIMPLE
+# define CONFIG_SYS_MALLOC_F_LEN       0x150
+#endif
+
+/* Stack location before relocation */
+#define CONFIG_SYS_INIT_SP_OFFSET      CONFIG_SYS_TEXT_BASE
 
 /*
  * CFI flash memory layout - Example
 #define CONFIG_SPL_LDSCRIPT    "arch/microblaze/cpu/u-boot-spl.lds"
 
 #define CONFIG_SPL_RAM_DEVICE
-#define CONFIG_SPL_NOR_SUPPORT
+#ifdef CONFIG_SYS_FLASH_BASE
+# define CONFIG_SPL_NOR_SUPPORT
+# define CONFIG_SYS_UBOOT_BASE         CONFIG_SYS_FLASH_BASE
+#endif
 
 /* for booting directly linux */
 #define CONFIG_SPL_OS_BOOT
 /* BRAM start */
 #define CONFIG_SYS_INIT_RAM_ADDR       0x0
 /* BRAM size - will be generated */
-#define CONFIG_SYS_INIT_RAM_SIZE       0x10000
-/* Stack pointer prior relocation, must situated at on-chip RAM */
-#define CONFIG_SYS_SPL_MALLOC_END      (CONFIG_SYS_INIT_RAM_ADDR + \
-                                        CONFIG_SYS_INIT_RAM_SIZE - \
-                                        GENERATED_GBL_DATA_SIZE)
-
-#define CONFIG_SYS_SPL_MALLOC_SIZE     0x100
+#define CONFIG_SYS_INIT_RAM_SIZE       0x100000
 
-/*
- * The main reason to do it in this way is that MALLOC_START
- * can't be defined - common/spl/spl.c
- */
-#if (CONFIG_SYS_SPL_MALLOC_SIZE != 0)
-# define CONFIG_SYS_SPL_MALLOC_START   (CONFIG_SYS_SPL_MALLOC_END - \
-                                        CONFIG_SYS_SPL_MALLOC_SIZE)
-# define CONFIG_SPL_STACK_ADDR         CONFIG_SYS_SPL_MALLOC_START
-#else
-# define CONFIG_SPL_STACK_ADDR         CONFIG_SYS_SPL_MALLOC_END
-#endif
+# define CONFIG_SPL_STACK_ADDR         (CONFIG_SYS_INIT_RAM_ADDR + \
+                                        CONFIG_SYS_INIT_RAM_SIZE - \
+                                        CONFIG_SYS_MALLOC_F_LEN)
 
 /* Just for sure that there is a space for stack */
 #define CONFIG_SPL_STACK_SIZE          0x100
 
-#define CONFIG_SYS_UBOOT_BASE          CONFIG_SYS_FLASH_BASE
 #define CONFIG_SYS_UBOOT_START         CONFIG_SYS_TEXT_BASE
 
 #define CONFIG_SPL_MAX_FOOTPRINT       (CONFIG_SYS_INIT_RAM_SIZE - \
                                         CONFIG_SYS_INIT_RAM_ADDR - \
-                                        GENERATED_GBL_DATA_SIZE - \
-                                        CONFIG_SYS_SPL_MALLOC_SIZE - \
+                                        CONFIG_SYS_MALLOC_F_LEN - \
                                         CONFIG_SPL_STACK_SIZE)
 
 #endif /* __CONFIG_H */
index 982b689f3cb481b65691db743f9d388dbc7379ac..46fc91e5e197bb4428c8b75c619c84ac2e3e3a9d 100644 (file)
@@ -28,6 +28,7 @@
 #define CONFIG_OMAP3_RX51              /* working with RX51 */
 #define CONFIG_SYS_L2CACHE_OFF         /* pretend there is no L2 CACHE */
 #define CONFIG_OMAP_COMMON
+#define CONFIG_SYS_GENERIC_BOARD
 
 #define CONFIG_MACH_TYPE               MACH_TYPE_NOKIA_RX51
 
index 807e96bbaab9f676bb13f4cacb38ddb5a1af05b0..9d5dbdce369381588f67a13e2e5cb44673d2dab4 100644 (file)
 
 /* I2C */
 #define CONFIG_CMD_I2C
-#define CONFIG_SYS_I2C
+#define CONFIG_DM_I2C
+#define CONFIG_DM_I2C_COMPAT
 #define CONFIG_SYS_I2C_S3C24X0
 #define CONFIG_SYS_I2C_S3C24X0_SPEED   100000
 #define CONFIG_SYS_I2C_S3C24X0_SLAVE   0
-#define CONFIG_MAX_I2C_NUM             8
-#define CONFIG_SYS_I2C_INIT_BOARD
 
 /* POWER */
 #define CONFIG_POWER
index b2b3750c1eb3c4faaee98be9ac63f57b43c8cbe4..6295ec505f8dbfdc4cd9aa8aae953751892f2c59 100644 (file)
 
 #define CONFIG_REVISION_TAG            1
 
-/* define to enable boot progress via leds */
-#if (CONFIG_MACH_TYPE == MACH_TYPE_IGEP0020) || \
-    (CONFIG_MACH_TYPE == MACH_TYPE_IGEP0030)
-#define CONFIG_SHOW_BOOT_PROGRESS
+/* Status LED */
+#define CONFIG_STATUS_LED
+#define CONFIG_BOARD_SPECIFIC_LED
+#define CONFIG_GPIO_LED
+#if (CONFIG_MACH_TYPE == MACH_TYPE_IGEP0020)
+#define RED_LED_GPIO 27
+#endif
+#if (CONFIG_MACH_TYPE == MACH_TYPE_IGEP0030)
+#define RED_LED_GPIO 16
 #endif
+#define RED_LED_DEV                            0
+#define STATUS_LED_BIT                 RED_LED_GPIO
+#define STATUS_LED_STATE               STATUS_LED_ON
+#define STATUS_LED_PERIOD              (CONFIG_SYS_HZ / 2)
+#define STATUS_LED_BOOT                        RED_LED_DEV
 
 /* GPIO banks */
 #define CONFIG_OMAP3_GPIO_3            /* GPIO64 .. 95 is in GPIO bank 3 */
diff --git a/include/configs/pf5200.h b/include/configs/pf5200.h
deleted file mode 100644 (file)
index be76478..0000000
+++ /dev/null
@@ -1,372 +0,0 @@
-/*
- * (C) Copyright 2003-2004
- * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-/*************************************************************************
- * (c) 2005 esd gmbh Hannover
- *
- *
- * from IceCube.h file
- * by Reinhard Arlt reinhard.arlt@esd-electronics.com
- *
- *************************************************************************/
-
-#ifndef __CONFIG_H
-#define __CONFIG_H
-
-/*
- * High Level Configuration Options
- * (easy to change)
- */
-
-#define CONFIG_MPC5200         1       /* This is an MPC5200 CPU */
-#define CONFIG_ICECUBE         1       /* ... on IceCube board */
-#define CONFIG_PF5200          1       /* ... on PF5200  board */
-#define CONFIG_MPC5200_DDR     1       /* ... use DDR RAM      */
-
-#ifndef CONFIG_SYS_TEXT_BASE
-#define CONFIG_SYS_TEXT_BASE   0xFFF00000
-#endif
-
-#define CONFIG_SYS_MPC5XXX_CLKIN       33000000        /* ... running at 33.000000MHz */
-
-#define CONFIG_HIGH_BATS       1       /* High BATs supported */
-/*
- * Serial console configuration
- */
-#define CONFIG_PSC_CONSOLE     1       /* console is on PSC1 */
-#if 0                          /* test-only */
-#define CONFIG_BAUDRATE                115200  /* ... at 115200 bps */
-#else
-#define CONFIG_BAUDRATE                9600    /* ... at 115200 bps */
-#endif
-#define CONFIG_SYS_BAUDRATE_TABLE      { 9600, 19200, 38400, 57600, 115200, 230400 }
-
-/*
- * PCI Mapping:
- * 0x40000000 - 0x4fffffff - PCI Memory
- * 0x50000000 - 0x50ffffff - PCI IO Space
- */
-#define CONFIG_PCI             1
-#define CONFIG_PCI_PNP         1
-#define CONFIG_PCI_SCAN_SHOW   1
-#define CONFIG_PCIAUTO_SKIP_HOST_BRIDGE        1
-
-#define CONFIG_PCI_MEM_BUS     0x40000000
-#define CONFIG_PCI_MEM_PHYS    CONFIG_PCI_MEM_BUS
-#define CONFIG_PCI_MEM_SIZE    0x10000000
-
-#define CONFIG_PCI_IO_BUS      0x50000000
-#define CONFIG_PCI_IO_PHYS     CONFIG_PCI_IO_BUS
-#define CONFIG_PCI_IO_SIZE     0x01000000
-
-#define CONFIG_MII             1
-#if 0                          /* test-only !!! */
-#define CONFIG_EEPRO100                1
-#define CONFIG_SYS_RX_ETH_BUFFER       8       /* use 8 rx buffer on eepro100  */
-#define CONFIG_NS8382X         1
-#endif
-
-/* Partitions */
-#define CONFIG_MAC_PARTITION
-#define CONFIG_DOS_PARTITION
-
-/* USB */
-#if 0
-#define CONFIG_USB_OHCI
-#define CONFIG_USB_STORAGE
-#endif
-
-
-/*
- * BOOTP options
- */
-#define CONFIG_BOOTP_BOOTFILESIZE
-#define CONFIG_BOOTP_BOOTPATH
-#define CONFIG_BOOTP_GATEWAY
-#define CONFIG_BOOTP_HOSTNAME
-
-
-/*
- * Command line configuration.
- */
-#include <config_cmd_default.h>
-
-#define CONFIG_CMD_BSP
-#define CONFIG_CMD_EEPROM
-#define CONFIG_CMD_ELF
-#define CONFIG_CMD_FAT
-#define CONFIG_CMD_I2C
-#define CONFIG_CMD_IDE
-
-#define CONFIG_CMD_PCI
-
-
-#if (CONFIG_SYS_TEXT_BASE == 0xFF000000)       /* Boot low with 16 MB Flash */
-#   define CONFIG_SYS_LOWBOOT          1
-#   define CONFIG_SYS_LOWBOOT16        1
-#endif
-#if (CONFIG_SYS_TEXT_BASE == 0xFF800000)       /* Boot low with  8 MB Flash */
-#   define CONFIG_SYS_LOWBOOT          1
-#   define CONFIG_SYS_LOWBOOT08        1
-#endif
-
-/*
- * Autobooting
- */
-#define CONFIG_BOOTDELAY       3       /* autoboot after 5 seconds */
-
-#define CONFIG_PREBOOT "echo;" \
-       "echo Welcome to ParaFinder pf5200;" \
-       "echo"
-
-#undef CONFIG_BOOTARGS
-
-#define        CONFIG_EXTRA_ENV_SETTINGS \
-       "netdev=eth0\0" \
-       "flash_vxworks0=run ata_vxworks_args;setenv loadaddr ff000000;bootvx\0" \
-       "flash_vxworks1=run ata_vxworks_args;setenv loadaddr ff200000:bootvx\0" \
-       "net_vxworks=phypower 1;sleep 2;tftp ${loadaddr} ${image};run vxworks_args;bootvx\0" \
-       "vxworks_args=setenv bootargs fec(0,0)${host}:${image} h=${serverip} e=${ipaddr} g=${gatewayip} u=${user} ${pass} tn=${target} s=${script}\0" \
-       "ata_vxworks_args=setenv bootargs /ata0/vxWorks h=${serverip} e=${ipaddr} g=${gatewayip} u=${user} ${pass} tn=${target} s=${script} o=fec0 \0" \
-       "loadaddr=01000000\0" \
-       "serverip=192.168.2.99\0" \
-       "gatewayip=10.0.0.79\0" \
-       "user=mu\0" \
-       "target=pf5200.esd\0" \
-       "script=pf5200.bat\0" \
-       "image=/tftpboot/vxWorks_pf5200\0" \
-       "ipaddr=10.0.13.196\0" \
-       "netmask=255.255.0.0\0" \
-       ""
-
-#define CONFIG_BOOTCOMMAND     "run flash_vxworks0"
-
-/*
- * IPB Bus clocking configuration.
- */
-#undef CONFIG_SYS_IPBCLK_EQUALS_XLBCLK         /* define for 133MHz speed */
-/*
- * I2C configuration
- */
-#define CONFIG_HARD_I2C                1       /* I2C with hardware support */
-#define CONFIG_SYS_I2C_MODULE          2       /* Select I2C module #1 or #2 */
-
-#define CONFIG_SYS_I2C_SPEED           86000   /* 100 kHz */
-#define CONFIG_SYS_I2C_SLAVE           0x7F
-
-/*
- * EEPROM configuration
- */
-#define CONFIG_SYS_I2C_EEPROM_ADDR             0x50    /* 1010000x */
-#define CONFIG_SYS_I2C_EEPROM_ADDR_LEN         2
-#define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS      5
-#define CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS  20
-#define CONFIG_SYS_I2C_MULTI_EEPROMS           1
-/*
- * Flash configuration
- */
-#define CONFIG_SYS_FLASH_BASE          0xFE000000
-#define CONFIG_SYS_FLASH_SIZE          0x02000000
-#define CONFIG_ENV_ADDR                (CONFIG_SYS_FLASH_BASE + 0x00000000)
-#define CONFIG_SYS_MAX_FLASH_BANKS     1       /* max num of memory banks      */
-#define CONFIG_SYS_MAX_FLASH_SECT      512
-
-#define CONFIG_SYS_FLASH_ERASE_TOUT    240000  /* Flash Erase Timeout (in ms)  */
-#define CONFIG_SYS_FLASH_WRITE_TOUT    500     /* Flash Write Timeout (in ms)  */
-
-/*
- * Environment settings
- */
-#if 1                          /* test-only */
-#define CONFIG_ENV_IS_IN_FLASH
-#define CONFIG_ENV_SIZE                0x10000
-#define CONFIG_ENV_SECT_SIZE   0x10000
-#define CONFIG_ENV_OVERWRITE   1
-#else
-#define CONFIG_ENV_IS_IN_EEPROM        1       /* use EEPROM for environment vars */
-#define CONFIG_ENV_OFFSET              0x0000  /* environment starts at the beginning of the EEPROM */
-#define CONFIG_ENV_SIZE                0x0400  /* 8192 bytes may be used for env vars */
-                                  /* total size of a CAT24WC32 is 8192 bytes */
-#define CONFIG_ENV_OVERWRITE   1
-#endif
-
-/*
- * Memory map
- */
-#define CONFIG_SYS_MBAR                0xF0000000
-#define CONFIG_SYS_SDRAM_BASE          0x00000000
-#define CONFIG_SYS_DEFAULT_MBAR        0x80000000
-
-/* Use SRAM until RAM will be available */
-#define CONFIG_SYS_INIT_RAM_ADDR       MPC5XXX_SRAM
-#define CONFIG_SYS_INIT_RAM_SIZE       MPC5XXX_SRAM_SIZE       /* Size of used area in DPRAM */
-
-#define CONFIG_SYS_GBL_DATA_OFFSET     (CONFIG_SYS_INIT_RAM_SIZE - GENERATED_GBL_DATA_SIZE)
-#define CONFIG_SYS_INIT_SP_OFFSET      CONFIG_SYS_GBL_DATA_OFFSET
-
-#define CONFIG_SYS_MONITOR_BASE    CONFIG_SYS_TEXT_BASE
-#if (CONFIG_SYS_MONITOR_BASE < CONFIG_SYS_FLASH_BASE)
-#   define CONFIG_SYS_RAMBOOT          1
-#endif
-
-#define CONFIG_SYS_MONITOR_LEN         (192 << 10)     /* Reserve 192 kB for Monitor   */
-#define CONFIG_SYS_MALLOC_LEN          (128 << 10)     /* Reserve 128 kB for malloc()  */
-#define CONFIG_SYS_BOOTMAPSZ           (8 << 20)       /* Initial Memory map for Linux */
-
-/*
- * Ethernet configuration
- */
-#define CONFIG_MPC5xxx_FEC     1
-#define CONFIG_MPC5xxx_FEC_MII100
-/*
- * Define CONFIG_MPC5xxx_FEC_MII10 to force FEC at 10Mb
- */
-/* #define CONFIG_MPC5xxx_FEC_MII10 */
-#define CONFIG_PHY_ADDR                0x00
-#define CONFIG_UDP_CHECKSUM    1
-
-/*
- * GPIO configuration
- */
-#define CONFIG_SYS_GPS_PORT_CONFIG     0x01052444
-
-/*
- * Miscellaneous configurable options
- */
-#define CONFIG_SYS_LONGHELP            /* undef to save memory     */
-#if defined(CONFIG_CMD_KGDB)
-#define CONFIG_SYS_CBSIZE              1024    /* Console I/O Buffer Size  */
-#else
-#define CONFIG_SYS_CBSIZE              256     /* Console I/O Buffer Size  */
-#endif
-#define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE+sizeof(CONFIG_SYS_PROMPT)+16)     /* Print Buffer Size */
-#define CONFIG_SYS_MAXARGS             16      /* max number of command args   */
-#define CONFIG_SYS_BARGSIZE            CONFIG_SYS_CBSIZE       /* Boot Argument Buffer Size    */
-
-#define CONFIG_SYS_MEMTEST_START       0x00100000      /* memtest works on */
-#define CONFIG_SYS_MEMTEST_END         0x00f00000      /* 1 ... 15 MB in DRAM  */
-
-#define CONFIG_SYS_LOAD_ADDR           0x100000        /* default load address */
-
-#define CONFIG_SYS_VXWORKS_MAC_PTR     0x00000000      /* Pass Ethernet MAC to VxWorks */
-
-#define CONFIG_SYS_CACHELINE_SIZE      32      /* For MPC5xxx CPUs */
-#if defined(CONFIG_CMD_KGDB)
-#  define CONFIG_SYS_CACHELINE_SHIFT   5       /* log base 2 of the above value */
-#endif
-
-/*
- * Various low-level settings
- */
-#define CONFIG_SYS_HID0_INIT           HID0_ICE | HID0_ICFI
-#define CONFIG_SYS_HID0_FINAL          HID0_ICE
-
-#define CONFIG_SYS_BOOTCS_START        CONFIG_SYS_FLASH_BASE
-#define CONFIG_SYS_BOOTCS_SIZE         CONFIG_SYS_FLASH_SIZE
-#define CONFIG_SYS_BOOTCS_CFG          0x0004DD00
-
-#define CONFIG_SYS_CS0_START           CONFIG_SYS_FLASH_BASE
-#define CONFIG_SYS_CS0_SIZE            CONFIG_SYS_FLASH_SIZE
-
-#define CONFIG_SYS_CS1_START           0xfd000000
-#define CONFIG_SYS_CS1_SIZE            0x00010000
-#define CONFIG_SYS_CS1_CFG             0x10101410
-
-#define CONFIG_SYS_CS_BURST            0x00000000
-#define CONFIG_SYS_CS_DEADCYCLE        0x33333333
-
-#define CONFIG_SYS_RESET_ADDRESS       0xff000000
-
-/*-----------------------------------------------------------------------
- * USB stuff
- *-----------------------------------------------------------------------
- */
-#define CONFIG_USB_CLOCK       0x0001BBBB
-#define CONFIG_USB_CONFIG      0x00001000
-
-/*-----------------------------------------------------------------------
- * IDE/ATA stuff Supports IDE harddisk
- *-----------------------------------------------------------------------
- */
-
-#undef CONFIG_IDE_8xx_PCCARD   /* Use IDE with PC Card Adapter */
-
-#undef CONFIG_IDE_8xx_DIRECT   /* Direct IDE    not supported  */
-#undef CONFIG_IDE_LED          /* LED   for ide not supported  */
-
-#define        CONFIG_IDE_RESET        /* reset for ide supported      */
-#define CONFIG_IDE_PREINIT
-
-#define CONFIG_SYS_IDE_MAXBUS          1       /* max. 1 IDE bus               */
-#define CONFIG_SYS_IDE_MAXDEVICE       1       /* max. 1 drive per IDE bus     */
-
-#define CONFIG_SYS_ATA_IDE0_OFFSET     0x0000
-
-#define CONFIG_SYS_ATA_BASE_ADDR       MPC5XXX_ATA
-
-/* Offset for data I/O                 */
-#define CONFIG_SYS_ATA_DATA_OFFSET     (0x0060)
-
-/* Offset for normal register accesses */
-#define CONFIG_SYS_ATA_REG_OFFSET      (CONFIG_SYS_ATA_DATA_OFFSET)
-
-/* Offset for alternate registers      */
-#define CONFIG_SYS_ATA_ALT_OFFSET      (0x005C)
-
-/* Interval between registers                                               */
-#define CONFIG_SYS_ATA_STRIDE          4
-
-/*-----------------------------------------------------------------------
- * CPLD stuff
- */
-#define CONFIG_SYS_FPGA_XC95XL         1       /* using Xilinx XC95XL CPLD      */
-#define CONFIG_SYS_FPGA_MAX_SIZE       32*1024 /* 32kByte is enough for CPLD    */
-
-/* CPLD program pin configuration */
-#define CONFIG_SYS_FPGA_PRG            0x20000000      /* JTAG TMS pin (ppc output)           */
-#define CONFIG_SYS_FPGA_CLK            0x10000000      /* JTAG TCK pin (ppc output)           */
-#define CONFIG_SYS_FPGA_DATA           0x20000000      /* JTAG TDO->TDI data pin (ppc output) */
-#define CONFIG_SYS_FPGA_DONE           0x10000000      /* JTAG TDI->TDO pin (ppc input)       */
-
-#define JTAG_GPIO_ADDR_TMS     (CONFIG_SYS_MBAR + 0xB10)       /* JTAG TMS pin (GPS data out value reg.)      */
-#define JTAG_GPIO_ADDR_TCK     (CONFIG_SYS_MBAR + 0xC0C)       /* JTAG TCK pin (GPW data out value reg.)      */
-#define JTAG_GPIO_ADDR_TDI     (CONFIG_SYS_MBAR + 0xC0C)       /* JTAG TDO->TDI pin (GPW data out value reg.) */
-#define JTAG_GPIO_ADDR_TDO     (CONFIG_SYS_MBAR + 0xB14)       /* JTAG TDI->TDO pin (GPS data in value reg.)  */
-
-#define JTAG_GPIO_ADDR_CFG     (CONFIG_SYS_MBAR + 0xB00)
-#define JTAG_GPIO_CFG_SET      0x00000000
-#define JTAG_GPIO_CFG_RESET    0x00F00000
-
-#define JTAG_GPIO_ADDR_EN_TMS  (CONFIG_SYS_MBAR + 0xB04)
-#define JTAG_GPIO_TMS_EN_SET   0x20000000      /* Enable for GPIO */
-#define JTAG_GPIO_TMS_EN_RESET 0x00000000
-#define JTAG_GPIO_ADDR_DDR_TMS (CONFIG_SYS_MBAR + 0xB0C)
-#define JTAG_GPIO_TMS_DDR_SET  0x20000000      /* Set as output   */
-#define JTAG_GPIO_TMS_DDR_RESET 0x00000000
-
-#define JTAG_GPIO_ADDR_EN_TCK  (CONFIG_SYS_MBAR + 0xC00)
-#define JTAG_GPIO_TCK_EN_SET   0x20000000      /* Enable for GPIO */
-#define JTAG_GPIO_TCK_EN_RESET 0x00000000
-#define JTAG_GPIO_ADDR_DDR_TCK (CONFIG_SYS_MBAR + 0xC08)
-#define JTAG_GPIO_TCK_DDR_SET  0x20000000      /* Set as output   */
-#define JTAG_GPIO_TCK_DDR_RESET 0x00000000
-
-#define JTAG_GPIO_ADDR_EN_TDI  (CONFIG_SYS_MBAR + 0xC00)
-#define JTAG_GPIO_TDI_EN_SET   0x10000000      /* Enable as GPIO  */
-#define JTAG_GPIO_TDI_EN_RESET 0x00000000
-#define JTAG_GPIO_ADDR_DDR_TDI (CONFIG_SYS_MBAR + 0xC08)
-#define JTAG_GPIO_TDI_DDR_SET  0x10000000      /* Set as output   */
-#define JTAG_GPIO_TDI_DDR_RESET 0x00000000
-
-#define JTAG_GPIO_ADDR_EN_TDO  (CONFIG_SYS_MBAR + 0xB04)
-#define JTAG_GPIO_TDO_EN_SET   0x10000000      /* Enable as GPIO  */
-#define JTAG_GPIO_TDO_EN_RESET 0x00000000
-#define JTAG_GPIO_ADDR_DDR_TDO (CONFIG_SYS_MBAR + 0xB0C)
-#define JTAG_GPIO_TDO_DDR_SET  0x00000000
-#define JTAG_GPIO_TDO_DDR_RESET 0x10000000     /* Set as input    */
-
-#endif                         /* __CONFIG_H */
index 7594bdb4123a514c8704e829c2ec21090ec17456..89560ad1c5b5f38fd067ff6e6f64e69a10c1edb6 100644 (file)
@@ -13,6 +13,8 @@
 #ifndef _CONFIG_POGO_E02_H
 #define _CONFIG_POGO_E02_H
 
+#define CONFIG_SYS_GENERIC_BOARD
+
 /*
  * Machine type definition and ID
  */
index d5588b12414c54c3dadba4d86ecc450223169695..9458047c06e0077851947ba4e37488a0e20cc051 100644 (file)
 #define CONFIG_SYS_NAND_OOBSIZE                64
 #define CONFIG_SYS_NAND_BLOCK_SIZE     0x20000
 #define CONFIG_SYS_NAND_BAD_BLOCK_POS  0x0
+#define CONFIG_SPL_GENERATE_ATMEL_PMECC_HEADER
 
 #endif
 
index 104edef1026e5b8568dbf970878ca0a094b12366..996973d99b6cb236f848c7d12ad63f61069878f5 100644 (file)
 #define CONFIG_USB_STORAGE
 #endif
 
+/* USB device */
+#define CONFIG_USB_GADGET
+#define CONFIG_USB_GADGET_DUALSPEED
+#define CONFIG_USB_GADGET_ATMEL_USBA
+#define CONFIG_USB_ETHER
+#define CONFIG_USB_ETH_RNDIS
+#define CONFIG_USBNET_MANUFACTURER      "Atmel SAMA5D4EK"
+
 #if defined(CONFIG_CMD_USB) || defined(CONFIG_CMD_MMC)
 #define CONFIG_CMD_FAT
 #define CONFIG_DOS_PARTITION
index cbdb3a2943f93bd44209a7b54174713c9d02daa8..09ab4d7f256b514ad33ee8c6b6d433a0a52a3423 100644 (file)
 #define CONFIG_USB_STORAGE
 #endif
 
+/* USB device */
+#define CONFIG_USB_GADGET
+#define CONFIG_USB_GADGET_DUALSPEED
+#define CONFIG_USB_GADGET_ATMEL_USBA
+#define CONFIG_USB_ETHER
+#define CONFIG_USB_ETH_RNDIS
+#define CONFIG_USBNET_MANUFACTURER      "Atmel SAMA5D4EK"
+
 #if defined(CONFIG_CMD_USB) || defined(CONFIG_CMD_MMC)
 #define CONFIG_CMD_FAT
 #define CONFIG_DOS_PARTITION
index 657f751f3c21bb9c4de81c996695a7371fd3427d..e9d3f3226b373f078faaa2c6c5e34932a3729ee1 100644 (file)
@@ -23,7 +23,6 @@
 
 #define CONFIG_BOOTSTAGE
 #define CONFIG_BOOTSTAGE_REPORT
-#define CONFIG_DM
 #define CONFIG_CMD_DEMO
 #define CONFIG_CMD_DM
 #define CONFIG_DM_DEMO
@@ -41,9 +40,6 @@
 
 #define CONFIG_OF_LIBFDT
 #define CONFIG_LMB
-#define CONFIG_FIT
-#define CONFIG_FIT_SIGNATURE
-#define CONFIG_RSA
 #define CONFIG_CMD_FDT
 #define CONFIG_ANDROID_BOOT_IMAGE
 
index 71be8238998b7a077bfa32d42e4f6922d8c230ef..84029cb39927779cf49a8acfaaa3025a48112499 100644 (file)
@@ -10,6 +10,8 @@
 #ifndef _CONFIG_SHEEVAPLUG_H
 #define _CONFIG_SHEEVAPLUG_H
 
+#define CONFIG_SYS_GENERIC_BOARD
+
 /*
  * Version number information
  */
 #define CONFIG_LZMA
 #define CONFIG_LZO
 
+/*
+ * Enable device tree support
+ */
+#define CONFIG_OF_LIBFDT
+
 /*
  * Miscellaneous configurable options
  */
@@ -49,6 +56,7 @@
 #define CONFIG_CMD_NAND
 #define CONFIG_CMD_PING
 #define CONFIG_CMD_USB
+
 /*
  * mv-common.h should be defined after CMD configs since it used them
  * to enable certain macros
 #define CONFIG_MTD_DEVICE               /* needed for mtdparts commands */
 #define CONFIG_MTD_PARTITIONS
 #define CONFIG_CMD_MTDPARTS
-#define CONFIG_LZO
 
 #endif /* _CONFIG_SHEEVAPLUG_H */
index 83953728dd29b818ad9aae658b209f1e46a92fbf..3b06d305db50221f8ec445d27673cd970c12719b 100644 (file)
@@ -18,6 +18,8 @@
 
 #include <configs/exynos5250-common.h>
 
+/* PMIC */
+#define CONFIG_POWER_MAX77686
 
 #define CONFIG_BOARD_COMMON
 #define CONFIG_ARCH_EARLY_INIT_R
index 942af2e7f6244a59c2f3463b8d24dd539ea5baa7..9fa644f7c288201c1eced5e9d17f84b6b2b7464d 100644 (file)
@@ -34,7 +34,6 @@
 #define CONFIG_SETUP_MEMORY_TAGS
 #define CONFIG_INITRD_TAG
 #define CONFIG_SKIP_LOWLEVEL_INIT
-#define CONFIG_SKIP_RELOCATE_UBOOT
 #define CONFIG_DISPLAY_CPUINFO
 #define CONFIG_FIT
 
index 7eaa58697e44f6cfeab3d2480eada7afb67aa636..ce6676eae7f71c95a32a98d0681584ba6ca15902 100644 (file)
@@ -22,6 +22,7 @@
 
 #define CONFIG_CROS_EC_I2C             /* Support CROS_EC over I2C */
 #define CONFIG_POWER_TPS65090_I2C
+#define CONFIG_DM_CROS_EC
 
 #define CONFIG_BOARD_COMMON
 #define CONFIG_ARCH_EARLY_INIT_R
index 7b857405e9e7839a27a7905b136a5677ec535b08..87d269b041c00f60d3085d842598c38a89e778b7 100644 (file)
@@ -13,7 +13,6 @@
  */
 #define CONFIG_CLK_FULL_SPEED          1008000000
 
-#define CONFIG_SYS_PROMPT              "sun4i# "
 #define CONFIG_MACH_TYPE               4104
 
 #ifdef CONFIG_USB_EHCI
index 09f7533575c83518c43c040ecf944a787aab4fba..52e3a6ff01b3d6ef94400e05ca63e0a9c2ab40d8 100644 (file)
@@ -13,7 +13,6 @@
  */
 #define CONFIG_CLK_FULL_SPEED          1008000000
 
-#define CONFIG_SYS_PROMPT              "sun5i# "
 #define CONFIG_MACH_TYPE               4138
 
 #ifdef CONFIG_USB_EHCI
index 1b738527990972e112a487e9e02ab3031625a6ae..f5e11ddb691f113c32943033592133e01653a72a 100644 (file)
@@ -16,8 +16,6 @@
  */
 #define CONFIG_CLK_FULL_SPEED          1008000000
 
-#define CONFIG_SYS_PROMPT              "sun6i# "
-
 #ifdef CONFIG_USB_EHCI
 #define CONFIG_USB_EHCI_SUNXI
 #define CONFIG_USB_MAX_CONTROLLER_COUNT        2
index ccec50c328171d9fe4f11a1a1c3f67a287f52267..7cd78903412626622713cad62b4a663ec78250bf 100644 (file)
@@ -14,7 +14,6 @@
  */
 #define CONFIG_CLK_FULL_SPEED          912000000
 
-#define CONFIG_SYS_PROMPT              "sun7i# "
 #define CONFIG_MACH_TYPE               4283
 
 #ifdef CONFIG_USB_EHCI
index f16e60b576427574eff1e2f7f26595a0912a9e18..3bdedb390c119f6cc515e6342990fbfb258c77a9 100644 (file)
@@ -14,8 +14,6 @@
  */
 #define CONFIG_CLK_FULL_SPEED  1008000000
 
-#define CONFIG_SYS_PROMPT      "sun8i# "
-
 #ifdef CONFIG_USB_EHCI
 #define CONFIG_USB_EHCI_SUNXI
 #define CONFIG_USB_MAX_CONTROLLER_COUNT        1
index e839053e2ba995ca3388f251fdb6e0f8bf886a9f..6cfd7e1489001f248af66001420d88e11400ea71 100644 (file)
@@ -40,6 +40,8 @@
  */
 #define CONFIG_DISPLAY_CPUINFO
 
+#define CONFIG_SYS_PROMPT      "sunxi# "
+
 /* Serial & console */
 #define CONFIG_SYS_NS16550
 #define CONFIG_SYS_NS16550_SERIAL
 #define CONFIG_SYS_SPL_MALLOC_SIZE     0x00080000      /* 512 KiB */
 
 /* I2C */
+#if defined CONFIG_AXP152_POWER || defined CONFIG_AXP209_POWER
 #define CONFIG_SPL_I2C_SUPPORT
+#endif
+
 #define CONFIG_SYS_I2C
 #define CONFIG_SYS_I2C_MVTWSI
 #define CONFIG_SYS_I2C_SPEED           400000
 #endif
 
 #ifdef CONFIG_USB_EHCI
-#define CONFIG_CMD_USB
 #define CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS 1
+#endif
+
+#ifdef CONFIG_USB_MUSB_SUNXI
+#define CONFIG_MUSB_HOST
+#define CONFIG_MUSB_PIO_ONLY
+#endif
+
+#if defined CONFIG_USB_EHCI || defined CONFIG_USB_MUSB_SUNXI
+#define CONFIG_CMD_USB
 #define CONFIG_USB_STORAGE
 #endif
 
index 20194aebb504d215b6aad4d336eb83c9a7406eae..65468ad1656dad3bbd66fea5fcc8b9b7d6590201 100644 (file)
 
 #define CONFIG_SYS_GENERIC_BOARD
 
+#if defined(CONFIG_SPL_BUILD)
+#define CONFIG_SYS_THUMB_BUILD
+#define CONFIG_SYS_ICACHE_OFF
+#define CONFIG_SYS_DCACHE_OFF
+#endif
 /*
  * Warning: changing CONFIG_SYS_TEXT_BASE requires
  * adapting the initial boot program.
 #define TAURUS_SPI_MASK (1 << 4)
 #define TAURUS_SPI_CS_PIN      AT91_PIN_PA3
 
+#if defined(CONFIG_SPL_BUILD)
+/* SPL related */
+#undef CONFIG_SPL_OS_BOOT              /* Not supported by existing map */
+#define CONFIG_SPL_SPI_SUPPORT
+#define CONFIG_SPL_SPI_FLASH_SUPPORT
+#define CONFIG_SPL_SPI_LOAD
+#define CONFIG_SYS_SPI_U_BOOT_OFFS     0x20000
+
+#define CONFIG_SF_DEFAULT_BUS 0
+#define CONFIG_SF_DEFAULT_SPEED 10000000
+#define CONFIG_SF_DEFAULT_MODE SPI_MODE_0
+#endif
+
 /* load address */
 #define CONFIG_SYS_LOAD_ADDR                   0x22000000
 
 /* Defines for SPL */
 #define CONFIG_SPL_FRAMEWORK
 #define CONFIG_SPL_TEXT_BASE           0x0
-#define CONFIG_SPL_MAX_SIZE            (11 * 1024)
+#define CONFIG_SPL_MAX_SIZE            (14 * 1024)
 #define CONFIG_SPL_STACK               (16 * 1024)
+#define CONFIG_SYS_SPL_MALLOC_START     (CONFIG_SYS_TEXT_BASE - \
+                                       CONFIG_SYS_MALLOC_LEN)
+#define CONFIG_SYS_SPL_MALLOC_SIZE      CONFIG_SYS_MALLOC_LEN
 
 #define CONFIG_SPL_BSS_START_ADDR      CONFIG_SPL_MAX_SIZE
 #define CONFIG_SPL_BSS_MAX_SIZE                (3 * 1024)
index e9218f7d819ef88b9b2f57feac83f85e89933323..46df40661da631bbabb3d629982daf6cb0f7f0f5 100644 (file)
 /*
  *  CPU configuration
  */
-#define CONFIG_ARC700
-#define CONFIG_ARC_MMU_VER             3
-#define CONFIG_SYS_CACHELINE_SIZE      32
 #define CONFIG_SYS_TIMER_RATE          CONFIG_SYS_CLK_FREQ
 
-/*
- * Board configuration
- */
-#define CONFIG_SYS_GENERIC_BOARD
-#define CONFIG_ARCH_EARLY_INIT_R
-
 /*
  * Memory configuration
  */
-#define CONFIG_SYS_TEXT_BASE           0x84000000
 #define CONFIG_SYS_MONITOR_BASE                CONFIG_SYS_TEXT_BASE
 
 #define CONFIG_SYS_DDR_SDRAM_BASE      0x80000000
index 5ed86d9365cd08aee392bbe77e7c7bf84e5c9ad6..598526bf95feb0709fdef7ad179838b0aabdf2a7 100644 (file)
@@ -20,7 +20,9 @@
 #define CONFIG_SPL_AM33XX_ENABLE_RTC32K_OSC
 
 #ifndef CONFIG_SPL_BUILD
+#ifndef CONFIG_DM
 # define CONFIG_DM
+#endif
 # define CONFIG_CMD_DM
 # define CONFIG_DM_GPIO
 # define CONFIG_DM_SERIAL
index 5a53c506c35f50be969b4e5188d002206910ccfc..9420e6b48b80911f5e044bc4593af4054be40afd 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012-2014 Panasonic Corporation
+ * Copyright (C) 2012-2015 Panasonic Corporation
  *   Author: Masahiro Yamada <yamada.m@jp.panasonic.com>
  *
  * SPDX-License-Identifier:    GPL-2.0+
@@ -43,6 +43,9 @@
 #define CONFIG_SDRAM1_SIZE     0x10000000
 #endif
 
+#define CONFIG_I2C_EEPROM
+#define CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS  10
+
 /*
  * Support card address map
  */
@@ -92,6 +95,8 @@
 
 #define CONFIG_DISPLAY_CPUINFO
 #define CONFIG_DISPLAY_BOARDINFO
+#define CONFIG_MISC_INIT_F
+#define CONFIG_BOARD_EARLY_INIT_F
 #define CONFIG_BOARD_EARLY_INIT_R
 #define CONFIG_BOARD_LATE_INIT
 
        "image_offset=0x00080000\0"             \
        "image_size=0x00f00000\0"               \
        "verify=n\0"                            \
-       "norboot=run add_default_bootargs;"                             \
+       "nandupdate=nand erase 0 0x100000 &&"                           \
+                  "tftpboot u-boot-spl.bin &&"                         \
+                  "nand write $loadaddr 0 0x10000 &&"                  \
+                  "tftpboot u-boot-dtb.img &&"                         \
+                  "nand write $loadaddr 0x10000 0xf0000\0"             \
+       "norboot=run add_default_bootargs &&"                           \
                "bootm $image_offset\0"                                 \
-       "nandboot=run add_default_bootargs;"                            \
-               "nand read $loadaddr $image_offset $image_size;"        \
-               "bootm\0"                                               \
+       "nandboot=run add_default_bootargs &&"                          \
+                "nand read $loadaddr $image_offset $image_size &&"     \
+                "bootm\0"                                              \
        "add_default_bootargs=setenv bootargs $bootargs"                \
                " console=ttyS0,$baudrate\0"                            \
 
 #define CONFIG_SPL_TEXT_BASE           0x00100000
 #endif
 
-#define CONFIG_BOARD_POSTCLK_INIT
-
 #ifndef CONFIG_SPL_BUILD
 #define CONFIG_SKIP_LOWLEVEL_INIT
 #endif
index 027d78b59171901274da4e46c0da576c128c6415..7fb28a54ba175f5bba12a4c7e6a20ea304202577 100644 (file)
@@ -11,9 +11,9 @@
 /* We use generic board for v8 Versatile Express */
 #define CONFIG_SYS_GENERIC_BOARD
 
-#ifdef CONFIG_BASE_FVP
+#ifdef CONFIG_TARGET_VEXPRESS64_BASE_FVP
 #ifndef CONFIG_SEMIHOSTING
-#error CONFIG_BASE_FVP requires CONFIG_SEMIHOSTING
+#error CONFIG_TARGET_VEXPRESS64_BASE_FVP requires CONFIG_SEMIHOSTING
 #endif
 #define CONFIG_BOARD_LATE_INIT
 #define CONFIG_ARMV8_SWITCH_TO_EL1
@@ -21,8 +21,9 @@
 
 #define CONFIG_REMAKE_ELF
 
-#ifndef CONFIG_BASE_FVP
-/* Base FVP not using GICv3 yet */
+#if !defined(CONFIG_TARGET_VEXPRESS64_BASE_FVP) && \
+    !defined(CONFIG_TARGET_VEXPRESS64_JUNO)
+/* Base FVP and Juno not using GICv3 yet */
 #define CONFIG_GICV3
 #endif
 
 #define CONFIG_BOOTP_VCI_STRING                "U-boot.armv8.vexpress_aemv8a"
 
 /* Link Definitions */
-#ifdef CONFIG_BASE_FVP
+#ifdef CONFIG_TARGET_VEXPRESS64_BASE_FVP
 /* ATF loads u-boot here for BASE_FVP model */
 #define CONFIG_SYS_TEXT_BASE           0x88000000
 #define CONFIG_SYS_INIT_SP_ADDR         (CONFIG_SYS_SDRAM_BASE + 0x03f00000)
+#elif CONFIG_TARGET_VEXPRESS64_JUNO
+#define CONFIG_SYS_TEXT_BASE           0xe0000000
+#define CONFIG_SYS_INIT_SP_ADDR         (CONFIG_SYS_SDRAM_BASE + 0x7fff0)
 #else
 #define CONFIG_SYS_TEXT_BASE           0x80000000
 #define CONFIG_SYS_INIT_SP_ADDR         (CONFIG_SYS_SDRAM_BASE + 0x7fff0)
@@ -54,7 +58,7 @@
 
 
 /* SMP Spin Table Definitions */
-#ifdef CONFIG_BASE_FVP
+#ifdef CONFIG_TARGET_VEXPRESS64_BASE_FVP
 #define CPU_RELEASE_ADDR               (CONFIG_SYS_SDRAM_BASE + 0x03f00000)
 #else
 #define CPU_RELEASE_ADDR               (CONFIG_SYS_SDRAM_BASE + 0x7fff0)
 #define V2M_KMI0                       (V2M_PA_CS3 + V2M_PERIPH_OFFSET(6))
 #define V2M_KMI1                       (V2M_PA_CS3 + V2M_PERIPH_OFFSET(7))
 
+#ifdef CONFIG_TARGET_VEXPRESS64_JUNO
+#define V2M_UART0                      0x7ff80000
+#define V2M_UART1                      0x7ff70000
+#else /* Not Juno */
 #define V2M_UART0                      (V2M_PA_CS3 + V2M_PERIPH_OFFSET(9))
 #define V2M_UART1                      (V2M_PA_CS3 + V2M_PERIPH_OFFSET(10))
 #define V2M_UART2                      (V2M_PA_CS3 + V2M_PERIPH_OFFSET(11))
 #define V2M_UART3                      (V2M_PA_CS3 + V2M_PERIPH_OFFSET(12))
+#endif
 
 #define V2M_WDT                                (V2M_PA_CS3 + V2M_PERIPH_OFFSET(15))
 
 #define GICR_BASE                      (0x2f100000)
 #else
 
-#ifdef CONFIG_BASE_FVP
+#ifdef CONFIG_TARGET_VEXPRESS64_BASE_FVP
 #define GICD_BASE                      (0x2f000000)
 #define GICC_BASE                      (0x2c000000)
+#elif CONFIG_TARGET_VEXPRESS64_JUNO
+#define GICD_BASE                      (0x2C010000)
+#define GICC_BASE                      (0x2C02f000)
 #else
 #define GICD_BASE                      (0x2C001000)
 #define GICC_BASE                      (0x2C002000)
 
 /* PL011 Serial Configuration */
 #define CONFIG_PL011_SERIAL
+#ifdef CONFIG_TARGET_VEXPRESS64_JUNO
+#define CONFIG_PL011_CLOCK             7273800
+#else
 #define CONFIG_PL011_CLOCK             24000000
+#endif
 #define CONFIG_PL01x_PORTS             {(void *)CONFIG_SYS_SERIAL0, \
                                         (void *)CONFIG_SYS_SERIAL1}
 #define CONFIG_CONS_INDEX              0
 #define CONFIG_CMD_ENV
 #define CONFIG_CMD_FLASH
 #define CONFIG_CMD_IMI
+#define CONFIG_CMD_LOADB
 #define CONFIG_CMD_MEMORY
 #define CONFIG_CMD_MII
 #define CONFIG_CMD_NET
 #define CONFIG_SYS_SDRAM_BASE          PHYS_SDRAM_1
 
 /* Initial environment variables */
-#ifdef CONFIG_BASE_FVP
+#ifdef CONFIG_TARGET_VEXPRESS64_BASE_FVP
 #define CONFIG_EXTRA_ENV_SETTINGS      \
                                "kernel_name=uImage\0"  \
                                "kernel_addr_r=0x80000000\0"    \
index 7e78f8ac8fcc60acf2b728626904d5b70aa29fe4..2dea9210454a7b6dd7cf824aea89295d84864e22 100644 (file)
 #define CONFIG_SETUP_MEMORY_TAGS       1
 #define CONFIG_SYS_L2CACHE_OFF         1
 #define CONFIG_INITRD_TAG              1
-
+#define CONFIG_SYS_GENERIC_BOARD
 #define CONFIG_OF_LIBFDT               1
 
 /* Size of malloc() pool */
index f16ae3291323887671945745dd7cf954c9073ee1..ecedfc3ab16ecc00d3f12af3118120ef255ee9c5 100644 (file)
 #define VIDEO_FB_16BPP_WORD_SWAP
 #define CONFIG_I8042_KBD
 #define CONFIG_CFB_CONSOLE
+#define CONFIG_CONSOLE_SCROLL_LINES 5
 
 /*-----------------------------------------------------------------------
  * CPU Features
 #define CONFIG_CMD_SF_TEST
 #define CONFIG_CMD_SPI
 #define CONFIG_SPI
+#define CONFIG_OF_SPI_FLASH
 
 /*-----------------------------------------------------------------------
  * Environment configuration
index 87b4fffeb9fb262143edaae2599220c04255a959..864528a5ea1b39e8b39e089b45837812bc731a82 100644 (file)
 # define CONFIG_SYS_FAULT_ECHO_LINK_DOWN
 # define CONFIG_PHYLIB
 # define CONFIG_PHY_MARVELL
+# define CONFIG_BOOTP_SERVERIP
+# define CONFIG_BOOTP_BOOTPATH
+# define CONFIG_BOOTP_GATEWAY
+# define CONFIG_BOOTP_HOSTNAME
+# define CONFIG_BOOTP_MAY_FAIL
+# if !defined(CONFIG_ZYNQ_GEM_EMIO0)
+#  define CONFIG_ZYNQ_GEM_EMIO0        0
+# endif
+# if !defined(CONFIG_ZYNQ_GEM_EMIO1)
+#  define CONFIG_ZYNQ_GEM_EMIO1        0
+# endif
 #endif
 
 /* SPI */
 # define CONFIG_USB_ULPI
 # define CONFIG_EHCI_IS_TDI
 # define CONFIG_USB_MAX_CONTROLLER_COUNT       2
+
+# define CONFIG_CI_UDC           /* ChipIdea CI13xxx UDC */
+# define CONFIG_USB_GADGET
+# define CONFIG_USB_GADGET_DUALSPEED
+# define CONFIG_USBDOWNLOAD_GADGET
+# define CONFIG_SYS_DFU_DATA_BUF_SIZE  0x600000
+# define DFU_DEFAULT_POLL_TIMEOUT      300
+# define CONFIG_DFU_FUNCTION
+# define CONFIG_DFU_RAM
+# define CONFIG_USB_GADGET_VBUS_DRAW   2
+# define CONFIG_G_DNL_VENDOR_NUM       0x03FD
+# define CONFIG_G_DNL_PRODUCT_NUM      0x0300
+# define CONFIG_G_DNL_MANUFACTURER     "Xilinx"
+# define CONFIG_USB_GADGET
+# define CONFIG_USB_CABLE_CHECK
+# define CONFIG_CMD_DFU
+# define CONFIG_CMD_THOR_DOWNLOAD
+# define CONFIG_THOR_FUNCTION
+# define DFU_ALT_INFO_RAM \
+       "dfu_ram_info=" \
+       "set dfu_alt_info " \
+       "${kernel_image} ram 0x3000000 0x500000\\\\;" \
+       "${devicetree_image} ram 0x2A00000 0x20000\\\\;" \
+       "${ramdisk_image} ram 0x2000000 0x600000\0" \
+       "dfu_ram=run dfu_ram_info && dfu 0 ram 0\0" \
+       "thor_ram=run dfu_ram_info && thordown 0 ram 0\0"
+
+# if defined(CONFIG_ZYNQ_SDHCI0) || defined(CONFIG_ZYNQ_SDHCI1)
+#  define CONFIG_DFU_MMC
+#  define DFU_ALT_INFO_MMC \
+       "dfu_mmc_info=" \
+       "set dfu_alt_info " \
+       "${kernel_image} fat 0 1\\\\;" \
+       "${devicetree_image} fat 0 1\\\\;" \
+       "${ramdisk_image} fat 0 1\0" \
+       "dfu_mmc=run dfu_mmc_info && dfu 0 mmc 0\0" \
+       "thor_mmc=run dfu_mmc_info && thordown 0 mmc 0\0"
+
+#  define DFU_ALT_INFO \
+       DFU_ALT_INFO_RAM \
+       DFU_ALT_INFO_MMC
+# else
+#  define DFU_ALT_INFO \
+       DFU_ALT_INFO_RAM
+# endif
+#endif
+
+#if !defined(DFU_ALT_INFO)
+# define DFU_ALT_INFO
 #endif
 
 #if defined(CONFIG_ZYNQ_SDHCI) || defined(CONFIG_ZYNQ_USB)
 # define CONFIG_DOS_PARTITION
 # define CONFIG_CMD_EXT4
 # define CONFIG_CMD_EXT4_WRITE
+# define CONFIG_CMD_FS_GENERIC
 #endif
 
 #define CONFIG_SYS_I2C_ZYNQ
 # define CONFIG_SYS_EEPROM_SIZE                        1024 /* Bytes */
 #endif
 
-#define CONFIG_BOOTP_SERVERIP
-#define CONFIG_BOOTP_BOOTPATH
-#define CONFIG_BOOTP_GATEWAY
-#define CONFIG_BOOTP_HOSTNAME
-#define CONFIG_BOOTP_MAY_FAIL
-
 /* Total Size of Environment Sector */
 #define CONFIG_ENV_SIZE                        (128 << 10)
 
                "cp.b ${nor_flash_off} ${load_addr} ${fit_size} && " \
                "bootm ${load_addr}\0" \
        "sdboot=echo Copying FIT from SD to RAM... && " \
-               "fatload mmc 0 ${load_addr} ${fit_image} && " \
+               "load mmc 0 ${load_addr} ${fit_image} && " \
                "bootm ${load_addr}\0" \
        "jtagboot=echo TFTPing FIT to RAM... && " \
                "tftpboot ${load_addr} ${fit_image} && " \
                "bootm ${load_addr}\0" \
        "usbboot=if usb start; then " \
                        "echo Copying FIT from USB to RAM... && " \
-                       "fatload usb 0 ${load_addr} ${fit_image} && " \
+                       "load usb 0 ${load_addr} ${fit_image} && " \
                        "bootm ${load_addr}\0" \
-               "fi\0"
+               "fi\0" \
+               DFU_ALT_INFO
 
 #define CONFIG_BOOTCOMMAND             "run $modeboot"
 #define CONFIG_BOOTDELAY               3 /* -1 to Disable autoboot */
 #define CONFIG_CMDLINE_EDITING
 #define CONFIG_AUTO_COMPLETE
 #define CONFIG_BOARD_LATE_INIT
+#define CONFIG_DISPLAY_BOARDINFO
 #define CONFIG_SYS_LONGHELP
 #define CONFIG_CLOCKS
 #define CONFIG_CMD_CLK
 #define CONFIG_SYS_MEMTEST_START       CONFIG_SYS_SDRAM_BASE
 #define CONFIG_SYS_MEMTEST_END         (CONFIG_SYS_SDRAM_BASE + 0x1000)
 
-#define CONFIG_SYS_MALLOC_LEN          0x400000
+#define CONFIG_SYS_MALLOC_LEN          0xC00000
 #define CONFIG_SYS_INIT_RAM_ADDR       CONFIG_SYS_SDRAM_BASE
 #define CONFIG_SYS_INIT_RAM_SIZE       CONFIG_SYS_MALLOC_LEN
 #define CONFIG_SYS_INIT_SP_ADDR                (CONFIG_SYS_INIT_RAM_ADDR + \
 #define CONFIG_OF_LIBFDT
 
 /* FIT support */
-#define CONFIG_FIT
-#define CONFIG_FIT_VERBOSE     1 /* enable fit_format_{error,warning}() */
 #define CONFIG_IMAGE_FORMAT_LEGACY /* enable also legacy image format */
 
 /* FDT support */
 #define CONFIG_DISPLAY_BOARDINFO_LATE
 
-/* RSA support */
-#define CONFIG_FIT_SIGNATURE
-#define CONFIG_RSA
-
 /* Extend size of kernel image for uncompression */
 #define CONFIG_SYS_BOOTM_LEN   (60 * 1024 * 1024)
 
index 9e13146ecbb266a5b73dbb9b93b1e90317c79a06..8457c80c5efd4264e5943255dc35b83fd520581b 100644 (file)
@@ -13,6 +13,7 @@
 #include <ec_commands.h>
 #include <fdtdec.h>
 #include <cros_ec_message.h>
+#include <asm/gpio.h>
 
 #ifndef CONFIG_DM_CROS_EC
 /* Which interface is the device on? */
@@ -39,7 +40,7 @@ struct cros_ec_dev {
        unsigned int bus_num;           /* Bus number (for I2C) */
        unsigned int max_frequency;     /* Maximum interface frequency */
 #endif
-       struct fdt_gpio_state ec_int;   /* GPIO used as EC interrupt line */
+       struct gpio_desc ec_int;        /* GPIO used as EC interrupt line */
        int protocol_version;           /* Protocol version to use */
        int optimise_flash_write;       /* Don't write erased flash blocks */
 
index a24fec6658e8e9bb1df82235222befc404411b32..03722d0c14dc14de253bc203185da4c59503cd99 100644 (file)
@@ -25,10 +25,14 @@ struct dm_demo_pdata {
 struct demo_ops {
        int (*hello)(struct udevice *dev, int ch);
        int (*status)(struct udevice *dev, int *status);
+       int (*set_light)(struct udevice *dev, int light);
+       int (*get_light)(struct udevice *dev);
 };
 
 int demo_hello(struct udevice *dev, int ch);
 int demo_status(struct udevice *dev, int *status);
+int demo_set_light(struct udevice *dev, int light);
+int demo_get_light(struct udevice *dev);
 int demo_list(void);
 
 int demo_parse_dt(struct udevice *dev);
index 13598a15b68684ee81b023c30d8ec42e21941c2b..81afa8c6281f8f9c55dbd968bfd4b344f8cf872a 100644 (file)
@@ -26,6 +26,9 @@ struct driver_info;
 /* DM should init this device prior to relocation */
 #define DM_FLAG_PRE_RELOC      (1 << 2)
 
+/* DM is responsible for allocating and freeing parent_platdata */
+#define DM_FLAG_ALLOC_PARENT_PDATA     (1 << 3)
+
 /**
  * struct udevice - An instance of a driver
  *
@@ -46,6 +49,7 @@ struct driver_info;
  * @driver: The driver used by this device
  * @name: Name of device, typically the FDT node name
  * @platdata: Configuration data for this device
+ * @parent_platdata: The parent bus's configuration data for this device
  * @of_offset: Device tree node offset for this device (- for none)
  * @of_id: Pointer to the udevice_id structure which created the device
  * @parent: Parent of this device, or NULL for the top level device
@@ -65,6 +69,7 @@ struct udevice {
        struct driver *driver;
        const char *name;
        void *platdata;
+       void *parent_platdata;
        int of_offset;
        const struct udevice_id *of_id;
        struct udevice *parent;
@@ -127,6 +132,7 @@ struct udevice_id {
  * @remove: Called to remove a device, i.e. de-activate it
  * @unbind: Called to unbind a device from its driver
  * @ofdata_to_platdata: Called before probe to decode device tree data
+ * @child_post_bind: Called after a new child has been bound
  * @child_pre_probe: Called before a child device is probed. The device has
  * memory allocated but it has not yet been probed.
  * @child_post_remove: Called after a child device is removed. The device
@@ -146,6 +152,9 @@ struct udevice_id {
  * device_probe_child() pass it in. So far the use case for allocating it
  * is SPI, but I found that unsatisfactory. Since it is here I will leave it
  * until things are clearer.
+ * @per_child_platdata_auto_alloc_size: A bus likes to store information about
+ * its children. If non-zero this is the size of this data, to be allocated
+ * in the child's parent_platdata pointer.
  * @ops: Driver-specific operations. This is typically a list of function
  * pointers defined by the driver, to implement driver functions required by
  * the uclass.
@@ -160,11 +169,13 @@ struct driver {
        int (*remove)(struct udevice *dev);
        int (*unbind)(struct udevice *dev);
        int (*ofdata_to_platdata)(struct udevice *dev);
+       int (*child_post_bind)(struct udevice *dev);
        int (*child_pre_probe)(struct udevice *dev);
        int (*child_post_remove)(struct udevice *dev);
        int priv_auto_alloc_size;
        int platdata_auto_alloc_size;
        int per_child_auto_alloc_size;
+       int per_child_platdata_auto_alloc_size;
        const void *ops;        /* driver-specific operations */
        uint32_t flags;
 };
@@ -183,6 +194,16 @@ struct driver {
  */
 void *dev_get_platdata(struct udevice *dev);
 
+/**
+ * dev_get_parent_platdata() - Get the parent platform data for a device
+ *
+ * This checks that dev is not NULL, but no other checks for now
+ *
+ * @dev                Device to check
+ * @return parent's platform data, or NULL if none
+ */
+void *dev_get_parent_platdata(struct udevice *dev);
+
 /**
  * dev_get_parentdata() - Get the parent data for a device
  *
@@ -224,6 +245,14 @@ struct udevice *dev_get_parent(struct udevice *child);
  */
 ulong dev_get_of_data(struct udevice *dev);
 
+/*
+ * device_get_uclass_id() - return the uclass ID of a device
+ *
+ * @dev:       Device to check
+ * @return uclass ID for the device
+ */
+enum uclass_id device_get_uclass_id(struct udevice *dev);
+
 /**
  * device_get_child() - Get the child of a device by index
  *
index f08c05da8147725f87900da81bf8944ff1c46ebc..707c69e07f02c488f10de559185769829534e689 100644 (file)
@@ -67,6 +67,8 @@ enum {
 struct dm_test_priv {
        int ping_total;
        int op_count[DM_TEST_OP_COUNT];
+       int uclass_flag;
+       int uclass_total;
 };
 
 /**
@@ -88,6 +90,7 @@ struct dm_test_uclass_priv {
  *
  * @sum: Test value used to check parent data works correctly
  * @flag: Used to track calling of parent operations
+ * @uclass_flag: Used to track calling of parent operations by uclass
  */
 struct dm_test_parent_data {
        int sum;
index f17c3c2b384dfc8aa782583fa0734cb31a77d222..91bb90dcfb3044196907da15b3b83efb2c2dd07c 100644 (file)
@@ -33,6 +33,7 @@ enum uclass_id {
        UCLASS_I2C,             /* I2C bus */
        UCLASS_I2C_GENERIC,     /* Generic I2C device */
        UCLASS_I2C_EEPROM,      /* I2C EEPROM device */
+       UCLASS_MOD_EXP,         /* RSA Mod Exp device */
 
        UCLASS_COUNT,
        UCLASS_INVALID = -1,
index f718f37affba344713f7599692f9fa79b2286652..f2f254a8259736f9d24ba18ad95ba9e126eb53c2 100644 (file)
@@ -43,6 +43,17 @@ int uclass_bind_device(struct udevice *dev);
  */
 int uclass_unbind_device(struct udevice *dev);
 
+/**
+ * uclass_pre_probe_child() - Deal with a child that is about to be probed
+ *
+ * Perform any pre-processing that is needed by the uclass before it can be
+ * probed.
+ *
+ * @dev:       Pointer to the device
+ * #return 0 on success, -ve on error
+ */
+int uclass_pre_probe_child(struct udevice *dev);
+
 /**
  * uclass_post_probe_device() - Deal with a device that has just been probed
  *
index f6ec6d7e9f62f7551b869f1eb7b188e8587b44ee..d6c40c60dda0913c27c46ffb8538176a7d595210 100644 (file)
@@ -40,6 +40,9 @@ struct uclass {
 
 struct udevice;
 
+/* Members of this uclass sequence themselves with aliases */
+#define DM_UC_FLAG_SEQ_ALIAS                   (1 << 0)
+
 /**
  * struct uclass_driver - Driver for the uclass
  *
@@ -52,6 +55,7 @@ struct udevice;
  * @pre_unbind: Called before a device is unbound from this uclass
  * @post_probe: Called after a new device is probed
  * @pre_remove: Called before a device is removed
+ * @child_post_bind: Called after a child is bound to a device in this uclass
  * @init: Called to set up the uclass
  * @destroy: Called to destroy the uclass
  * @priv_auto_alloc_size: If non-zero this is the size of the private data
@@ -60,8 +64,16 @@ struct udevice;
  * @per_device_auto_alloc_size: Each device can hold private data owned
  * by the uclass. If required this will be automatically allocated if this
  * value is non-zero.
+ * @per_child_auto_alloc_size: Each child device (of a parent in this
+ * uclass) can hold parent data for the device/uclass. This value is only
+ * used as a falback if this member is 0 in the driver.
+ * @per_child_platdata_auto_alloc_size: A bus likes to store information about
+ * its children. If non-zero this is the size of this data, to be allocated
+ * in the child device's parent_platdata pointer. This value is only used as
+ * a falback if this member is 0 in the driver.
  * @ops: Uclass operations, providing the consistent interface to devices
  * within the uclass.
+ * @flags: Flags for this uclass (DM_UC_...)
  */
 struct uclass_driver {
        const char *name;
@@ -70,11 +82,16 @@ struct uclass_driver {
        int (*pre_unbind)(struct udevice *dev);
        int (*post_probe)(struct udevice *dev);
        int (*pre_remove)(struct udevice *dev);
+       int (*child_post_bind)(struct udevice *dev);
+       int (*child_pre_probe)(struct udevice *dev);
        int (*init)(struct uclass *class);
        int (*destroy)(struct uclass *class);
        int priv_auto_alloc_size;
        int per_device_auto_alloc_size;
+       int per_child_auto_alloc_size;
+       int per_child_platdata_auto_alloc_size;
        const void *ops;
+       uint32_t flags;
 };
 
 /* Declare a new uclass_driver */
@@ -141,6 +158,8 @@ int uclass_get_device_by_of_offset(enum uclass_id id, int node,
 /**
  * uclass_first_device() - Get the first device in a uclass
  *
+ * The device returned is probed if necessary, and ready for use
+ *
  * @id: Uclass ID to look up
  * @devp: Returns pointer to the first device in that uclass, or NULL if none
  * @return 0 if OK (found or not found), -1 on error
@@ -150,6 +169,8 @@ int uclass_first_device(enum uclass_id id, struct udevice **devp);
 /**
  * uclass_next_device() - Get the next device in a uclass
  *
+ * The device returned is probed if necessary, and ready for use
+ *
  * @devp: On entry, pointer to device to lookup. On exit, returns pointer
  * to the next device in the same uclass, or NULL if none
  * @return 0 if OK (found or not found), -1 on error
index 41d5085e16c27017d7e02540c3aacfa2090e994a..205affe72d701d087107b21a818daf974422d8f8 100644 (file)
@@ -3,6 +3,8 @@
 
 #ifndef __ASSEMBLY__
 
+struct spi_slave;
+
 /* These are declarations of exported functions available in C code */
 unsigned long get_version(void);
 int  getc(void);
@@ -10,22 +12,23 @@ int  tstc(void);
 void putc(const char);
 void puts(const char*);
 int printf(const char* fmt, ...);
-void install_hdlr(int, void (*interrupt_handler_t)(void *), void*);
+void install_hdlr(int, interrupt_handler_t, void*);
 void free_hdlr(int);
 void *malloc(size_t);
 void free(void*);
 void __udelay(unsigned long);
 unsigned long get_timer(unsigned long);
 int vprintf(const char *, va_list);
-unsigned long simple_strtoul(const char *cp,char **endp,unsigned int base);
+unsigned long simple_strtoul(const char *cp, char **endp, unsigned int base);
 int strict_strtoul(const char *cp, unsigned int base, unsigned long *res);
 char *getenv (const char *name);
 int setenv (const char *varname, const char *varvalue);
-long simple_strtol(const char *cp,char **endp,unsigned int base);
-int strcmp(const char * cs,const char * ct);
+long simple_strtol(const char *cp, char **endp, unsigned int base);
+int strcmp(const char *cs, const char *ct);
 unsigned long ustrtoul(const char *cp, char **endp, unsigned int base);
 unsigned long long ustrtoull(const char *cp, char **endp, unsigned int base);
-#if defined(CONFIG_CMD_I2C)
+#if defined(CONFIG_CMD_I2C) && \
+               (!defined(CONFIG_DM_I2C) || defined(CONFIG_DM_I2C_COMPAT))
 int i2c_write (uchar, uint, int , uchar* , int);
 int i2c_read (uchar, uint, int , uchar* , int);
 #endif
@@ -34,15 +37,14 @@ void app_startup(char * const *);
 
 #endif    /* ifndef __ASSEMBLY__ */
 
-enum {
-#define EXPORT_FUNC(x) XF_ ## x ,
+struct jt_funcs {
+#define EXPORT_FUNC(impl, res, func, ...) res(*func)(__VA_ARGS__);
 #include <_exports.h>
 #undef EXPORT_FUNC
-
-       XF_MAX
 };
 
-#define XF_VERSION     6
+
+#define XF_VERSION     7
 
 #if defined(CONFIG_X86)
 extern gd_t *global_data;
index 75af750ee576174a1e135952cae09e6ed4f3e1ca..231eed789273800fb3daf14913ae84b07d65a6c9 100644 (file)
@@ -115,9 +115,6 @@ enum fdt_compat_id {
        COMPAT_NVIDIA_TEGRA20_USB,      /* Tegra20 USB port */
        COMPAT_NVIDIA_TEGRA30_USB,      /* Tegra30 USB port */
        COMPAT_NVIDIA_TEGRA114_USB,     /* Tegra114 USB port */
-       COMPAT_NVIDIA_TEGRA114_I2C,     /* Tegra114 I2C w/single clock source */
-       COMPAT_NVIDIA_TEGRA20_I2C,      /* Tegra20 i2c */
-       COMPAT_NVIDIA_TEGRA20_DVC,      /* Tegra20 dvc (really just i2c) */
        COMPAT_NVIDIA_TEGRA20_EMC,      /* Tegra20 memory controller */
        COMPAT_NVIDIA_TEGRA20_EMC_TABLE, /* Tegra20 memory timing table */
        COMPAT_NVIDIA_TEGRA20_KBC,      /* Tegra20 Keyboard */
@@ -127,9 +124,6 @@ enum fdt_compat_id {
        COMPAT_NVIDIA_TEGRA124_SDMMC,   /* Tegra124 SDMMC controller */
        COMPAT_NVIDIA_TEGRA30_SDMMC,    /* Tegra30 SDMMC controller */
        COMPAT_NVIDIA_TEGRA20_SDMMC,    /* Tegra20 SDMMC controller */
-       COMPAT_NVIDIA_TEGRA20_SFLASH,   /* Tegra 2 SPI flash controller */
-       COMPAT_NVIDIA_TEGRA20_SLINK,    /* Tegra 2 SPI SLINK controller */
-       COMPAT_NVIDIA_TEGRA114_SPI,     /* Tegra 114 SPI controller */
        COMPAT_NVIDIA_TEGRA124_PCIE,    /* Tegra 124 PCIe controller */
        COMPAT_NVIDIA_TEGRA30_PCIE,     /* Tegra 30 PCIe controller */
        COMPAT_NVIDIA_TEGRA20_PCIE,     /* Tegra 20 PCIe controller */
@@ -140,7 +134,6 @@ enum fdt_compat_id {
        COMPAT_SAMSUNG_S3C2440_I2C,     /* Exynos I2C Controller */
        COMPAT_SAMSUNG_EXYNOS5_SOUND,   /* Exynos Sound */
        COMPAT_WOLFSON_WM8994_CODEC,    /* Wolfson WM8994 Sound Codec */
-       COMPAT_SAMSUNG_EXYNOS_SPI,      /* Exynos SPI */
        COMPAT_GOOGLE_CROS_EC,          /* Google CROS_EC Protocol */
        COMPAT_GOOGLE_CROS_EC_KEYB,     /* Google CROS_EC Keyboard */
        COMPAT_SAMSUNG_EXYNOS_EHCI,     /* Exynos EHCI controller */
@@ -173,42 +166,63 @@ enum fdt_compat_id {
        COMPAT_INTEL_MODEL_206AX,       /* Intel Model 206AX CPU */
        COMPAT_INTEL_GMA,               /* Intel Graphics Media Accelerator */
        COMPAT_AMS_AS3722,              /* AMS AS3722 PMIC */
+       COMPAT_INTEL_ICH_SPI,           /* Intel ICH7/9 SPI controller */
 
        COMPAT_COUNT,
 };
 
-/* GPIOs are numbered from 0 */
-enum {
-       FDT_GPIO_NONE = -1U,    /* an invalid GPIO used to end our list */
-
-       FDT_GPIO_ACTIVE_LOW = 1 << 0,   /* input is active low (else high) */
-};
-
-/* This is the state of a GPIO pin as defined by the fdt */
-struct fdt_gpio_state {
-       const char *name;       /* name of the fdt property defining this */
-       uint gpio;              /* GPIO number, or FDT_GPIO_NONE if none */
-       u8 flags;               /* FDT_GPIO_... flags */
+#define MAX_PHANDLE_ARGS 16
+struct fdtdec_phandle_args {
+       int node;
+       int args_count;
+       uint32_t args[MAX_PHANDLE_ARGS];
 };
 
-/* This tells us whether a fdt_gpio_state record is valid or not */
-#define fdt_gpio_isvalid(x) ((x)->gpio != FDT_GPIO_NONE)
-
 /**
- * Read the GPIO taking into account the polarity of the pin.
+ * fdtdec_parse_phandle_with_args() - Find a node pointed by phandle in a list
  *
- * @param gpio         pointer to the decoded gpio
- * @return value of the gpio if successful, < 0 if unsuccessful
- */
-int fdtdec_get_gpio(struct fdt_gpio_state *gpio);
-
-/**
- * Write the GPIO taking into account the polarity of the pin.
+ * This function is useful to parse lists of phandles and their arguments.
+ *
+ * Example:
+ *
+ * phandle1: node1 {
+ *     #list-cells = <2>;
+ * }
+ *
+ * phandle2: node2 {
+ *     #list-cells = <1>;
+ * }
+ *
+ * node3 {
+ *     list = <&phandle1 1 2 &phandle2 3>;
+ * }
+ *
+ * To get a device_node of the `node2' node you may call this:
+ * fdtdec_parse_phandle_with_args(blob, node3, "list", "#list-cells", 0, 1,
+ *                               &args);
+ *
+ * (This function is a modified version of __of_parse_phandle_with_args() from
+ * Linux 3.18)
+ *
+ * @blob:      Pointer to device tree
+ * @src_node:  Offset of device tree node containing a list
+ * @list_name: property name that contains a list
+ * @cells_name:        property name that specifies the phandles' arguments count,
+ *             or NULL to use @cells_count
+ * @cells_count: Cell count to use if @cells_name is NULL
+ * @index:     index of a phandle to parse out
+ * @out_args:  optional pointer to output arguments structure (will be filled)
+ * @return 0 on success (with @out_args filled out if not NULL), -ENOENT if
+ *     @list_name does not exist, a phandle was not found, @cells_name
+ *     could not be found, the arguments were truncated or there were too
+ *     many arguments.
  *
- * @param gpio         pointer to the decoded gpio
- * @return 0 if successful
  */
-int fdtdec_set_gpio(struct fdt_gpio_state *gpio, int val);
+int fdtdec_parse_phandle_with_args(const void *blob, int src_node,
+                                  const char *list_name,
+                                  const char *cells_name,
+                                  int cell_count, int index,
+                                  struct fdtdec_phandle_args *out_args);
 
 /**
  * Find the next numbered alias for a peripheral. This is used to enumerate
@@ -590,50 +604,6 @@ const u32 *fdtdec_locate_array(const void *blob, int node,
  */
 int fdtdec_get_bool(const void *blob, int node, const char *prop_name);
 
-/**
- * Decode a single GPIOs from an FDT.
- *
- * If the property is not found, then the GPIO structure will still be
- * initialised, with gpio set to FDT_GPIO_NONE. This makes it easy to
- * provide optional GPIOs.
- *
- * @param blob         FDT blob to use
- * @param node         Node to look at
- * @param prop_name    Node property name
- * @param gpio         gpio elements to fill from FDT
- * @return 0 if ok, -FDT_ERR_NOTFOUND if the property is missing.
- */
-int fdtdec_decode_gpio(const void *blob, int node, const char *prop_name,
-               struct fdt_gpio_state *gpio);
-
-/**
- * Decode a list of GPIOs from an FDT. This creates a list of GPIOs with no
- * terminating item.
- *
- * @param blob         FDT blob to use
- * @param node         Node to look at
- * @param prop_name    Node property name
- * @param gpio         Array of gpio elements to fill from FDT. This will be
- *                     untouched if either 0 or an error is returned
- * @param max_count    Maximum number of elements allowed
- * @return number of GPIOs read if ok, -FDT_ERR_BADLAYOUT if max_count would
- * be exceeded, or -FDT_ERR_NOTFOUND if the property is missing.
- */
-int fdtdec_decode_gpios(const void *blob, int node, const char *prop_name,
-               struct fdt_gpio_state *gpio, int max_count);
-
-/**
- * Set up a GPIO pin according to the provided gpio information. At present this
- * just requests the GPIO.
- *
- * If the gpio is FDT_GPIO_NONE, no action is taken. This makes it easy to
- * deal with optional GPIOs.
- *
- * @param gpio         GPIO info to use for set up
- * @return 0 if all ok or gpio was FDT_GPIO_NONE; -1 on error
- */
-int fdtdec_setup_gpio(struct fdt_gpio_state *gpio);
-
 /**
  * Look in the FDT for a config item with the given name and return its value
  * as a 32-bit integer. The property must have at least 4 bytes of data. The
index 914024c17cb8841578ea622e112bb7aaf7fccb68..e0d12981b283ea93f9e4ef9fcf66076e4cc5bbda 100644 (file)
@@ -49,18 +49,19 @@ typedef enum {
 } bitstream_type;
 
 /* root function definitions */
-extern void fpga_init(void);
-extern int fpga_add(fpga_type devtype, void *desc);
-extern int fpga_count(void);
-extern int fpga_load(int devnum, const void *buf, size_t bsize,
-                    bitstream_type bstype);
-extern int fpga_fsload(int devnum, const void *buf, size_t size,
-                      fpga_fs_info *fpga_fsinfo);
-extern int fpga_loadbitstream(int devnum, char *fpgadata, size_t size,
-                             bitstream_type bstype);
-extern int fpga_dump(int devnum, const void *buf, size_t bsize);
-extern int fpga_info(int devnum);
-extern const fpga_desc *const fpga_validate(int devnum, const void *buf,
-                                           size_t bsize, char *fn);
+void fpga_init(void);
+int fpga_add(fpga_type devtype, void *desc);
+int fpga_count(void);
+const fpga_desc *const fpga_get_desc(int devnum);
+int fpga_load(int devnum, const void *buf, size_t bsize,
+             bitstream_type bstype);
+int fpga_fsload(int devnum, const void *buf, size_t size,
+               fpga_fs_info *fpga_fsinfo);
+int fpga_loadbitstream(int devnum, char *fpgadata, size_t size,
+                      bitstream_type bstype);
+int fpga_dump(int devnum, const void *buf, size_t bsize);
+int fpga_info(int devnum);
+const fpga_desc *const fpga_validate(int devnum, const void *buf,
+                                    size_t bsize, char *fn);
 
 #endif /* _FPGA_H_ */
index ffb6ce7ada64f0498b46eac89d6a335bea83c488..fd1e4ab1c0f3880e0a4a9fdfd8e2be5df42fd4ca 100644 (file)
@@ -109,4 +109,10 @@ int do_save(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[],
 int do_fs_uuid(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[],
                int fstype);
 
+/*
+ * Determine the type of the specified filesystem and print it. Optionally it is
+ * possible to store the type directly in env.
+ */
+int do_fs_type(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
+
 #endif /* _FS_H */
index 675557ad1fd3605f07fab75477f8c61f6cd58fae..3286c95907c2419e3ccdc6cdc05a8245357459a5 100644 (file)
 #ifdef CONFIG_SYS_FSL_DDR_LE
 #define ddr_in32(a)    in_le32(a)
 #define ddr_out32(a, v)        out_le32(a, v)
+#define ddr_setbits32(a, v)    setbits_le32(a, v)
+#define ddr_clrbits32(a, v)    clrbits_le32(a, v)
+#define ddr_clrsetbits32(a, clear, set)        clrsetbits_le32(a, clear, set)
 #else
 #define ddr_in32(a)    in_be32(a)
 #define ddr_out32(a, v)        out_be32(a, v)
+#define ddr_setbits32(a, v)    setbits_be32(a, v)
+#define ddr_clrbits32(a, v)    clrbits_be32(a, v)
+#define ddr_clrsetbits32(a, clear, set)        clrsetbits_be32(a, clear, set)
 #endif
 
 #define _DDR_ADDR CONFIG_SYS_FSL_DDR_ADDR
index d8ec4f08e166702d6a33b145f82eee3c78f6a6a3..f4eb100de05f1279e82930f30e3586d319a453ca 100644 (file)
@@ -17,7 +17,6 @@ enum {
        HASH_FLAG_ENV           = 1 << 1,       /* Allow env vars */
 };
 
-#ifndef USE_HOSTCC
 #if defined(CONFIG_SHA1SUM_VERIFY) || defined(CONFIG_CRC32_VERIFY)
 #define CONFIG_HASH_VERIFY
 #endif
@@ -77,6 +76,7 @@ struct hash_algo {
                           int size);
 };
 
+#ifndef USE_HOSTCC
 /**
  * hash_command: Process a hash command for a particular algorithm
  *
@@ -114,6 +114,23 @@ int hash_command(const char *algo_name, int flags, cmd_tbl_t *cmdtp, int flag,
 int hash_block(const char *algo_name, const void *data, unsigned int len,
               uint8_t *output, int *output_size);
 
+/**
+ * hash_show() - Print out a hash algorithm and value
+ *
+ * You will get a message like this (without a newline at the end):
+ *
+ * "sha1 for 9eb3337c ... 9eb3338f ==> 7942ef1df479fd3130f716eb9613d107dab7e257"
+ *
+ * @algo:              Algorithm used for hash
+ * @addr:              Address of data that was hashed
+ * @len:               Length of data that was hashed
+ * @output:            Hash value to display
+ */
+void hash_show(struct hash_algo *algo, ulong addr, ulong len,
+              uint8_t *output);
+
+#endif /* !USE_HOSTCC */
+
 /**
  * hash_lookup_algo() - Look up the hash_algo struct for an algorithm
  *
@@ -128,18 +145,17 @@ int hash_block(const char *algo_name, const void *data, unsigned int len,
 int hash_lookup_algo(const char *algo_name, struct hash_algo **algop);
 
 /**
- * hash_show() - Print out a hash algorithm and value
+ * hash_progressive_lookup_algo() - Look up hash_algo for prog. hash support
  *
- * You will get a message like this (without a newline at the end):
+ * The function returns the pointer to the struct or -EPROTONOSUPPORT if the
+ * algorithm is not available with progressive hash support.
  *
- * "sha1 for 9eb3337c ... 9eb3338f ==> 7942ef1df479fd3130f716eb9613d107dab7e257"
+ * @algo_name: Hash algorithm to look up
+ * @algop: Pointer to the hash_algo struct if found
  *
- * @algo:              Algorithm used for hash
- * @addr:              Address of data that was hashed
- * @len:               Length of data that was hashed
- * @output:            Hash value to display
+ * @return 0 if ok, -EPROTONOSUPPORT for an unknown algorithm.
  */
-void hash_show(struct hash_algo *algo, ulong addr, ulong len,
-              uint8_t *output);
-#endif /* !USE_HOSTCC */
+int hash_progressive_lookup_algo(const char *algo_name,
+                                struct hash_algo **algop);
+
 #endif
index 9c6a60cf9ae89e50e2a4d2dfaa94874a56774e1f..27fe00f17361763a42bc13f59e378d464c484dc6 100644 (file)
@@ -39,8 +39,8 @@ enum dm_i2c_chip_flags {
  * An I2C chip is a device on the I2C bus. It sits at a particular address
  * and normally supports 7-bit or 10-bit addressing.
  *
- * To obtain this structure, use dev_get_parentdata(dev) where dev is the
- * chip to examine.
+ * To obtain this structure, use dev_get_parent_platdata(dev) where dev is
+ * the chip to examine.
  *
  * @chip_addr: Chip address on bus
  * @offset_len: Length of offset in bytes. A single byte offset can
@@ -75,7 +75,7 @@ struct dm_i2c_bus {
 };
 
 /**
- * i2c_read() - read bytes from an I2C chip
+ * dm_i2c_read() - read bytes from an I2C chip
  *
  * To obtain an I2C device (called a 'chip') given the I2C bus address you
  * can use i2c_get_chip(). To obtain a bus by bus number use
@@ -91,13 +91,12 @@ struct dm_i2c_bus {
  *
  * @return 0 on success, -ve on failure
  */
-int i2c_read(struct udevice *dev, uint offset, uint8_t *buffer,
-            int len);
+int dm_i2c_read(struct udevice *dev, uint offset, uint8_t *buffer, int len);
 
 /**
- * i2c_write() - write bytes to an I2C chip
+ * dm_i2c_write() - write bytes to an I2C chip
  *
- * See notes for i2c_read() above.
+ * See notes for dm_i2c_read() above.
  *
  * @dev:       Chip to write to
  * @offset:    Offset within chip to start writing
@@ -106,11 +105,11 @@ int i2c_read(struct udevice *dev, uint offset, uint8_t *buffer,
  *
  * @return 0 on success, -ve on failure
  */
-int i2c_write(struct udevice *dev, uint offset, const uint8_t *buffer,
-             int len);
+int dm_i2c_write(struct udevice *dev, uint offset, const uint8_t *buffer,
+                int len);
 
 /**
- * i2c_probe() - probe a particular chip address
+ * dm_i2c_probe() - probe a particular chip address
  *
  * This can be useful to check for the existence of a chip on the bus.
  * It is typically implemented by writing the chip address to the bus
@@ -122,8 +121,8 @@ int i2c_write(struct udevice *dev, uint offset, const uint8_t *buffer,
  * @devp:      Returns the device found, or NULL if none
  * @return 0 if a chip was found at that address, -ve if not
  */
-int i2c_probe(struct udevice *bus, uint chip_addr, uint chip_flags,
-             struct udevice **devp);
+int dm_i2c_probe(struct udevice *bus, uint chip_addr, uint chip_flags,
+                struct udevice **devp);
 
 /**
  * i2c_set_bus_speed() - set the speed of a bus
@@ -185,6 +184,80 @@ int i2c_set_chip_offset_len(struct udevice *dev, uint offset_len);
  */
 int i2c_deblock(struct udevice *bus);
 
+#ifdef CONFIG_DM_I2C_COMPAT
+/**
+ * i2c_probe() - Compatibility function for driver model
+ *
+ * Calls dm_i2c_probe() on the current bus
+ */
+int i2c_probe(uint8_t chip_addr);
+
+/**
+ * i2c_read() - Compatibility function for driver model
+ *
+ * Calls dm_i2c_read() with the device corresponding to @chip_addr, and offset
+ * set to @addr. @alen must match the current setting for the device.
+ */
+int i2c_read(uint8_t chip_addr, unsigned int addr, int alen, uint8_t *buffer,
+            int len);
+
+/**
+ * i2c_write() - Compatibility function for driver model
+ *
+ * Calls dm_i2c_write() with the device corresponding to @chip_addr, and offset
+ * set to @addr. @alen must match the current setting for the device.
+ */
+int i2c_write(uint8_t chip_addr, unsigned int addr, int alen, uint8_t *buffer,
+             int len);
+
+/**
+ * i2c_get_bus_num_fdt() - Compatibility function for driver model
+ *
+ * @return the bus number associated with the given device tree node
+ */
+int i2c_get_bus_num_fdt(int node);
+
+/**
+ * i2c_get_bus_num() - Compatibility function for driver model
+ *
+ * @return the 'current' bus number
+ */
+unsigned int i2c_get_bus_num(void);
+
+/**
+ * i2c_set_bus_num() - Compatibility function for driver model
+ *
+ * Sets the 'current' bus
+ */
+int i2c_set_bus_num(unsigned int bus);
+
+static inline void I2C_SET_BUS(unsigned int bus)
+{
+       i2c_set_bus_num(bus);
+}
+
+static inline unsigned int I2C_GET_BUS(void)
+{
+       return i2c_get_bus_num();
+}
+
+/**
+ * i2c_init() - Compatibility function for driver model
+ *
+ * This function does nothing.
+ */
+void i2c_init(int speed, int slaveaddr);
+
+/**
+ * board_i2c_init() - Compatibility function for driver model
+ *
+ * @param blob  Device tree blbo
+ * @return the number of I2C bus
+ */
+void board_i2c_init(const void *blob);
+
+#endif
+
 /*
  * Not all of these flags are implemented in the U-Boot API
  */
@@ -330,10 +403,12 @@ struct dm_i2c_ops {
  *
  * @bus:       Bus to examine
  * @chip_addr: Chip address for the new device
+ * @offset_len:        Length of a register offset in bytes (normally 1)
  * @devp:      Returns pointer to new device if found or -ENODEV if not
  *             found
  */
-int i2c_get_chip(struct udevice *bus, uint chip_addr, struct udevice **devp);
+int i2c_get_chip(struct udevice *bus, uint chip_addr, uint offset_len,
+                struct udevice **devp);
 
 /**
  * i2c_get_chip() - get a device to use to access a chip on a bus number
@@ -343,10 +418,12 @@ int i2c_get_chip(struct udevice *bus, uint chip_addr, struct udevice **devp);
  *
  * @busnum:    Bus number to examine
  * @chip_addr: Chip address for the new device
+ * @offset_len:        Length of a register offset in bytes (normally 1)
  * @devp:      Returns pointer to new device if found or -ENODEV if not
  *             found
  */
-int i2c_get_chip_for_busnum(int busnum, int chip_addr, struct udevice **devp);
+int i2c_get_chip_for_busnum(int busnum, int chip_addr, uint offset_len,
+                           struct udevice **devp);
 
 /**
  * i2c_chip_ofdata_to_platdata() - Decode standard I2C platform data
index ee3afe35670a9b460921ba0b2f5218df5a76b0c0..0e6af00c16bbab07a7c1284bca9963b0a4f2155c 100644 (file)
@@ -751,6 +751,7 @@ int fit_parse_conf(const char *spec, ulong addr_curr,
 int fit_parse_subimage(const char *spec, ulong addr_curr,
                ulong *addr, const char **image_name);
 
+int fit_get_subimage_count(const void *fit, int images_noffset);
 void fit_print_contents(const void *fit);
 void fit_image_print(const void *fit, int noffset, const char *p);
 
@@ -927,8 +928,9 @@ struct checksum_algo {
 #if IMAGE_ENABLE_SIGN
        const EVP_MD *(*calculate_sign)(void);
 #endif
-       void (*calculate)(const struct image_region region[],
-                         int region_count, uint8_t *checksum);
+       int (*calculate)(const char *name,
+                        const struct image_region region[],
+                        int region_count, uint8_t *checksum);
        const uint8_t *rsa_padding;
 };
 
index d37fba44dcafc6b1ce6813cca4e8f3d6999e95d5..940c87128194b654c364c477fc3ba864a523ffc0 100644 (file)
@@ -23,7 +23,7 @@
 
 /**
  * A linker list is constructed by grouping together linker input
- * sections, each containning one entry of the list. Each input section
+ * sections, each containing one entry of the list. Each input section
  * contains a constant initialized variable which holds the entry's
  * content. Linker list input sections are constructed from the list
  * and entry names, plus a prefix which allows grouping all lists
@@ -39,7 +39,7 @@
  * This ensures uniqueness for both input section and C variable name.
  *
  * Note that the names differ only in the first character, "." for the
- * setion and "_" for the variable, so that the linker cannot confuse
+ * section and "_" for the variable, so that the linker cannot confuse
  * section and symbol names. From now on, both names will be referred
  * to as
  *
index b40133cb3cd160e66ca66516e1c47e49300a9aff..6eac17f0b64da075201b976c48a7ac2a29e056e9 100644 (file)
@@ -262,7 +262,6 @@ typedef struct {
 
 /* from include/linux/types.h */
 
-typedef int    atomic_t;
 /**
  * struct callback_head - callback structure for use with RCU and task_work
  * @next: next update requests in a list
diff --git a/include/mipi_display.h b/include/mipi_display.h
new file mode 100644 (file)
index 0000000..ddcc8ca
--- /dev/null
@@ -0,0 +1,130 @@
+/*
+ * Defines for Mobile Industry Processor Interface (MIPI(R))
+ * Display Working Group standards: DSI, DCS, DBI, DPI
+ *
+ * Copyright (C) 2010 Guennadi Liakhovetski <g.liakhovetski@gmx.de>
+ * Copyright (C) 2006 Nokia Corporation
+ * Author: Imre Deak <imre.deak@nokia.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+#ifndef MIPI_DISPLAY_H
+#define MIPI_DISPLAY_H
+
+/* MIPI DSI Processor-to-Peripheral transaction types */
+enum {
+       MIPI_DSI_V_SYNC_START                           = 0x01,
+       MIPI_DSI_V_SYNC_END                             = 0x11,
+       MIPI_DSI_H_SYNC_START                           = 0x21,
+       MIPI_DSI_H_SYNC_END                             = 0x31,
+
+       MIPI_DSI_COLOR_MODE_OFF                         = 0x02,
+       MIPI_DSI_COLOR_MODE_ON                          = 0x12,
+       MIPI_DSI_SHUTDOWN_PERIPHERAL                    = 0x22,
+       MIPI_DSI_TURN_ON_PERIPHERAL                     = 0x32,
+
+       MIPI_DSI_GENERIC_SHORT_WRITE_0_PARAM            = 0x03,
+       MIPI_DSI_GENERIC_SHORT_WRITE_1_PARAM            = 0x13,
+       MIPI_DSI_GENERIC_SHORT_WRITE_2_PARAM            = 0x23,
+
+       MIPI_DSI_GENERIC_READ_REQUEST_0_PARAM           = 0x04,
+       MIPI_DSI_GENERIC_READ_REQUEST_1_PARAM           = 0x14,
+       MIPI_DSI_GENERIC_READ_REQUEST_2_PARAM           = 0x24,
+
+       MIPI_DSI_DCS_SHORT_WRITE                        = 0x05,
+       MIPI_DSI_DCS_SHORT_WRITE_PARAM                  = 0x15,
+
+       MIPI_DSI_DCS_READ                               = 0x06,
+
+       MIPI_DSI_SET_MAXIMUM_RETURN_PACKET_SIZE         = 0x37,
+
+       MIPI_DSI_END_OF_TRANSMISSION                    = 0x08,
+
+       MIPI_DSI_NULL_PACKET                            = 0x09,
+       MIPI_DSI_BLANKING_PACKET                        = 0x19,
+       MIPI_DSI_GENERIC_LONG_WRITE                     = 0x29,
+       MIPI_DSI_DCS_LONG_WRITE                         = 0x39,
+
+       MIPI_DSI_LOOSELY_PACKED_PIXEL_STREAM_YCBCR20    = 0x0c,
+       MIPI_DSI_PACKED_PIXEL_STREAM_YCBCR24            = 0x1c,
+       MIPI_DSI_PACKED_PIXEL_STREAM_YCBCR16            = 0x2c,
+
+       MIPI_DSI_PACKED_PIXEL_STREAM_30                 = 0x0d,
+       MIPI_DSI_PACKED_PIXEL_STREAM_36                 = 0x1d,
+       MIPI_DSI_PACKED_PIXEL_STREAM_YCBCR12            = 0x3d,
+
+       MIPI_DSI_PACKED_PIXEL_STREAM_16                 = 0x0e,
+       MIPI_DSI_PACKED_PIXEL_STREAM_18                 = 0x1e,
+       MIPI_DSI_PIXEL_STREAM_3BYTE_18                  = 0x2e,
+       MIPI_DSI_PACKED_PIXEL_STREAM_24                 = 0x3e,
+};
+
+/* MIPI DSI Peripheral-to-Processor transaction types */
+enum {
+       MIPI_DSI_RX_ACKNOWLEDGE_AND_ERROR_REPORT        = 0x02,
+       MIPI_DSI_RX_END_OF_TRANSMISSION                 = 0x08,
+       MIPI_DSI_RX_GENERIC_SHORT_READ_RESPONSE_1BYTE   = 0x11,
+       MIPI_DSI_RX_GENERIC_SHORT_READ_RESPONSE_2BYTE   = 0x12,
+       MIPI_DSI_RX_GENERIC_LONG_READ_RESPONSE          = 0x1a,
+       MIPI_DSI_RX_DCS_LONG_READ_RESPONSE              = 0x1c,
+       MIPI_DSI_RX_DCS_SHORT_READ_RESPONSE_1BYTE       = 0x21,
+       MIPI_DSI_RX_DCS_SHORT_READ_RESPONSE_2BYTE       = 0x22,
+};
+
+/* MIPI DCS commands */
+enum {
+       MIPI_DCS_NOP                    = 0x00,
+       MIPI_DCS_SOFT_RESET             = 0x01,
+       MIPI_DCS_GET_DISPLAY_ID         = 0x04,
+       MIPI_DCS_GET_RED_CHANNEL        = 0x06,
+       MIPI_DCS_GET_GREEN_CHANNEL      = 0x07,
+       MIPI_DCS_GET_BLUE_CHANNEL       = 0x08,
+       MIPI_DCS_GET_DISPLAY_STATUS     = 0x09,
+       MIPI_DCS_GET_POWER_MODE         = 0x0A,
+       MIPI_DCS_GET_ADDRESS_MODE       = 0x0B,
+       MIPI_DCS_GET_PIXEL_FORMAT       = 0x0C,
+       MIPI_DCS_GET_DISPLAY_MODE       = 0x0D,
+       MIPI_DCS_GET_SIGNAL_MODE        = 0x0E,
+       MIPI_DCS_GET_DIAGNOSTIC_RESULT  = 0x0F,
+       MIPI_DCS_ENTER_SLEEP_MODE       = 0x10,
+       MIPI_DCS_EXIT_SLEEP_MODE        = 0x11,
+       MIPI_DCS_ENTER_PARTIAL_MODE     = 0x12,
+       MIPI_DCS_ENTER_NORMAL_MODE      = 0x13,
+       MIPI_DCS_EXIT_INVERT_MODE       = 0x20,
+       MIPI_DCS_ENTER_INVERT_MODE      = 0x21,
+       MIPI_DCS_SET_GAMMA_CURVE        = 0x26,
+       MIPI_DCS_SET_DISPLAY_OFF        = 0x28,
+       MIPI_DCS_SET_DISPLAY_ON         = 0x29,
+       MIPI_DCS_SET_COLUMN_ADDRESS     = 0x2A,
+       MIPI_DCS_SET_PAGE_ADDRESS       = 0x2B,
+       MIPI_DCS_WRITE_MEMORY_START     = 0x2C,
+       MIPI_DCS_WRITE_LUT              = 0x2D,
+       MIPI_DCS_READ_MEMORY_START      = 0x2E,
+       MIPI_DCS_SET_PARTIAL_AREA       = 0x30,
+       MIPI_DCS_SET_SCROLL_AREA        = 0x33,
+       MIPI_DCS_SET_TEAR_OFF           = 0x34,
+       MIPI_DCS_SET_TEAR_ON            = 0x35,
+       MIPI_DCS_SET_ADDRESS_MODE       = 0x36,
+       MIPI_DCS_SET_SCROLL_START       = 0x37,
+       MIPI_DCS_EXIT_IDLE_MODE         = 0x38,
+       MIPI_DCS_ENTER_IDLE_MODE        = 0x39,
+       MIPI_DCS_SET_PIXEL_FORMAT       = 0x3A,
+       MIPI_DCS_WRITE_MEMORY_CONTINUE  = 0x3C,
+       MIPI_DCS_READ_MEMORY_CONTINUE   = 0x3E,
+       MIPI_DCS_SET_TEAR_SCANLINE      = 0x44,
+       MIPI_DCS_GET_SCANLINE           = 0x45,
+       MIPI_DCS_READ_DDB_START         = 0xA1,
+       MIPI_DCS_READ_DDB_CONTINUE      = 0xA8,
+};
+
+/* MIPI DCS pixel formats */
+#define MIPI_DCS_PIXEL_FMT_24BIT       7
+#define MIPI_DCS_PIXEL_FMT_18BIT       6
+#define MIPI_DCS_PIXEL_FMT_16BIT       5
+#define MIPI_DCS_PIXEL_FMT_12BIT       3
+#define MIPI_DCS_PIXEL_FMT_8BIT                2
+#define MIPI_DCS_PIXEL_FMT_3BIT                1
+
+#endif
index 7ec255d882199c88dc7bf79f52857c87a796a46c..09101e2c87a11cfa76c0412c92dd5e9b6eb5ab00 100644 (file)
 /*
  * EXT_CSD fields
  */
+#define EXT_CSD_ENH_START_ADDR         136     /* R/W */
+#define EXT_CSD_ENH_SIZE_MULT          140     /* R/W */
 #define EXT_CSD_GP_SIZE_MULT           143     /* R/W */
 #define EXT_CSD_PARTITION_SETTING      155     /* R/W */
 #define EXT_CSD_PARTITIONS_ATTRIBUTE   156     /* R/W */
+#define EXT_CSD_MAX_ENH_SIZE_MULT      157     /* R */
 #define EXT_CSD_PARTITIONING_SUPPORT   160     /* RO */
 #define EXT_CSD_RST_N_FUNCTION         162     /* R/W */
+#define EXT_CSD_WR_REL_PARAM           166     /* R */
+#define EXT_CSD_WR_REL_SET             167     /* R/W */
 #define EXT_CSD_RPMB_MULT              168     /* RO */
 #define EXT_CSD_ERASE_GROUP_DEF                175     /* R/W */
 #define EXT_CSD_BOOT_BUS_WIDTH         177
 
 #define EXT_CSD_PARTITION_SETTING_COMPLETED    (1 << 0)
 
+#define EXT_CSD_ENH_USR                (1 << 0)        /* user data area is enhanced */
+#define EXT_CSD_ENH_GP(x)      (1 << ((x)+1))  /* GP part (x+1) is enhanced */
+
+#define EXT_CSD_HS_CTRL_REL    (1 << 0)        /* host controlled WR_REL_SET */
+
+#define EXT_CSD_WR_DATA_REL_USR                (1 << 0)        /* user data area WR_REL */
+#define EXT_CSD_WR_DATA_REL_GP(x)      (1 << ((x)+1))  /* GP part (x+1) WR_REL */
+
 #define R1_ILLEGAL_COMMAND             (1 << 22)
 #define R1_APP_CMD                     (1 << 5)
 
 #define MMCPART_NOAVAILABLE    (0xff)
 #define PART_ACCESS_MASK       (0x7)
 #define PART_SUPPORT           (0x1)
+#define ENHNCD_SUPPORT         (0x2)
 #define PART_ENH_ATTRIB                (0x1f)
 
 /* Maximum block size for MMC */
@@ -302,17 +316,23 @@ struct mmc {
        uint csd[4];
        uint cid[4];
        ushort rca;
+       u8 part_support;
+       u8 part_attr;
+       u8 wr_rel_set;
        char part_config;
        char part_num;
        uint tran_speed;
        uint read_bl_len;
        uint write_bl_len;
-       uint erase_grp_size;
+       uint erase_grp_size;    /* in 512-byte sectors */
+       uint hc_wp_grp_size;    /* in 512-byte sectors */
        u64 capacity;
        u64 capacity_user;
        u64 capacity_boot;
        u64 capacity_rpmb;
        u64 capacity_gp[4];
+       u64 enh_user_start;
+       u64 enh_user_size;
        block_dev_desc_t block_dev;
        char op_cond_pending;   /* 1 if we are waiting on an op_cond command */
        char init_in_progress;  /* 1 if we have done mmc_start_init() */
@@ -321,6 +341,27 @@ struct mmc {
        int ddr_mode;
 };
 
+struct mmc_hwpart_conf {
+       struct {
+               uint enh_start; /* in 512-byte sectors */
+               uint enh_size;  /* in 512-byte sectors, if 0 no enh area */
+               unsigned wr_rel_change : 1;
+               unsigned wr_rel_set : 1;
+       } user;
+       struct {
+               uint size;      /* in 512-byte sectors */
+               unsigned enhanced : 1;
+               unsigned wr_rel_change : 1;
+               unsigned wr_rel_set : 1;
+       } gp_part[4];
+};
+
+enum mmc_hwpart_conf_mode {
+       MMC_HWPART_CONF_CHECK,
+       MMC_HWPART_CONF_SET,
+       MMC_HWPART_CONF_COMPLETE,
+};
+
 int mmc_register(struct mmc *mmc);
 struct mmc *mmc_create(const struct mmc_config *cfg, void *priv);
 void mmc_destroy(struct mmc *mmc);
@@ -333,6 +374,8 @@ int mmc_set_dev(int dev_num);
 void print_mmc_devices(char separator);
 int get_mmc_num(void);
 int mmc_switch_part(int dev_num, unsigned int part_num);
+int mmc_hwpart_config(struct mmc *mmc, const struct mmc_hwpart_conf *conf,
+                     enum mmc_hwpart_conf_mode mode);
 int mmc_getcd(struct mmc *mmc);
 int board_mmc_getcd(struct mmc *mmc);
 int mmc_getwp(struct mmc *mmc);
index 3da35fe981880500b9025ca813164c27a2aa8bdb..73ea88b42d7defb35ddea2da2d0ff30684c26b30 100644 (file)
@@ -482,6 +482,36 @@ extern void net_set_ip_header(uchar *pkt, IPaddr_t dest, IPaddr_t source);
 extern void net_set_udp_header(uchar *pkt, IPaddr_t dest, int dport,
                                int sport, int len);
 
+/**
+ * compute_ip_checksum() - Compute IP checksum
+ *
+ * @addr:      Address to check (must be 16-bit aligned)
+ * @nbytes:    Number of bytes to check (normally a multiple of 2)
+ * @return 16-bit IP checksum
+ */
+unsigned compute_ip_checksum(const void *addr, unsigned nbytes);
+
+/**
+ * add_ip_checksums() - add two IP checksums
+ *
+ * @offset:    Offset of first sum (if odd we do a byte-swap)
+ * @sum:       First checksum
+ * @new_sum:   New checksum to add
+ * @return updated 16-bit IP checksum
+ */
+unsigned add_ip_checksums(unsigned offset, unsigned sum, unsigned new_sum);
+
+/**
+ * ip_checksum_ok() - check if a checksum is correct
+ *
+ * This works by making sure the checksum sums to 0
+ *
+ * @addr:      Address to check (must be 16-bit aligned)
+ * @nbytes:    Number of bytes to check (normally a multiple of 2)
+ * @return true if the checksum matches, false if not
+ */
+int ip_checksum_ok(const void *addr, unsigned nbytes);
+
 /* Checksum */
 extern int     NetCksumOk(uchar *, int);       /* Return true if cksum OK */
 extern uint    NetCksum(uchar *, int);         /* Calculate the checksum */
index 34651ab3779014ce6ec96a83b41acc0a96e60c00..daffc1222d60afba54d8ad9dc5dba7d84d284fe0 100644 (file)
@@ -93,7 +93,8 @@ int xilinx_emaclite_initialize(bd_t *bis, unsigned long base_addr,
 int xilinx_ll_temac_eth_init(bd_t *bis, unsigned long base_addr, int flags,
                                                unsigned long ctrl_addr);
 int zynq_gem_of_init(const void *blob);
-int zynq_gem_initialize(bd_t *bis, int base_addr, int phy_addr, u32 emio);
+int zynq_gem_initialize(bd_t *bis, phys_addr_t base_addr,
+                       int phy_addr, u32 emio);
 /*
  * As long as the Xilinx xps_ll_temac ethernet driver has not its own interface
  * exported by a public hader file, we need a global definition at this point.
index 7f67ca6542652cfdab8beff36494b404d6a211f6..4fbb8f6729f2e33d7f313427af31100b618d5a00 100644 (file)
@@ -697,5 +697,14 @@ void pci_write_bar32(struct pci_controller *hose, pci_dev_t dev, int barnum,
  * */
 u32 pci_read_bar32(struct pci_controller *hose, pci_dev_t dev, int barnum);
 
+/**
+ * pciauto_setup_rom() - Set up access to a device ROM
+ *
+ * @hose:      PCI hose to use
+ * @dev:       PCI device to adjust
+ * @return 0 if done, -ve on error
+ */
+int pciauto_setup_rom(struct pci_controller *hose, pci_dev_t dev);
+
 #endif /* __ASSEMBLY__ */
 #endif /* _PCI_H */
index 8b2674cf87940fbcdd79b456695718a1f822b178..4ba36eb1b7bd079311d59523d14ad41f4d0962fc 100644 (file)
@@ -8,7 +8,6 @@
 #define _PCI_ROM_H
 
 #define PCI_ROM_HDR                    0xaa55
-#define PCI_VGA_RAM_IMAGE_START                0xc0000
 
 struct pci_rom_header {
        uint16_t signature;
index 1e282e2964ec44e5b24fd22b0febd5200dc0df88..d117fc1634b071a6da4bd90206619840618c0dcf 100644 (file)
@@ -225,6 +225,7 @@ int gen10g_startup(struct phy_device *phydev);
 int gen10g_shutdown(struct phy_device *phydev);
 int gen10g_discover_mmds(struct phy_device *phydev);
 
+int phy_aquantia_init(void);
 int phy_atheros_init(void);
 int phy_broadcom_init(void);
 int phy_cortina_init(void);
index d11aa8baf91b7370bf40a18f5785522448933386..54e361ea5e83ee28593dddd8178a361b5e1b53f2 100644 (file)
@@ -50,6 +50,38 @@ void to_tm (int, struct rtc_time *);
 unsigned long mktime (unsigned int, unsigned int, unsigned int,
                      unsigned int, unsigned int, unsigned int);
 
+/**
+ * rtc_read8() - Read an 8-bit register
+ *
+ * @reg:       Register to read
+ * @return value read
+ */
+int rtc_read8(int reg);
+
+/**
+ * rtc_write8() - Write an 8-bit register
+ *
+ * @reg:       Register to write
+ * @value:     Value to write
+ */
+void rtc_write8(int reg, uchar val);
+
+/**
+ * rtc_read32() - Read a 32-bit value from the RTC
+ *
+ * @reg:       Offset to start reading from
+ * @return value read
+ */
+u32 rtc_read32(int reg);
+
+/**
+ * rtc_write32() - Write a 32-bit value to the RTC
+ *
+ * @reg:       Register to start writing to
+ * @value:     Value to write
+ */
+void rtc_write32(int reg, u32 value);
+
 /**
  * rtc_init() - Set up the real time clock ready for use
  */
index aa4a0e9654dd6262839aec65df1d8fab08e16076..23893b57408056ea3cd077af2923a300e53c36fb 100644 (file)
@@ -12,7 +12,7 @@
 
 #include <asm/io.h>
 #include <mmc.h>
-#include <fdtdec.h>
+#include <asm/gpio.h>
 
 /*
  * Controller registers
@@ -246,8 +246,8 @@ struct sdhci_host {
        int index;
 
        int bus_width;
-       struct fdt_gpio_state pwr_gpio; /* Power GPIO */
-       struct fdt_gpio_state cd_gpio;          /* Card Detect GPIO */
+       struct gpio_desc pwr_gpio;      /* Power GPIO */
+       struct gpio_desc cd_gpio;               /* Card Detect GPIO */
 
        void (*set_control_reg)(struct sdhci_host *host);
        void (*set_clock)(int dev_index, unsigned int div);
index 2aca954e73ab108dbd0f20fa84648d64e44fe1bb..14606c303180a43a551977caf2d13a41ca187c87 100644 (file)
@@ -38,7 +38,12 @@ typedef struct {
        xilinx_post_fn  post;
 } xilinx_spartan2_slave_serial_fns;
 
+#if defined(CONFIG_FPGA_SPARTAN2)
 extern struct xilinx_fpga_op spartan2_op;
+# define FPGA_SPARTAN2_OPS     &spartan2_op
+#else
+# define FPGA_SPARTAN2_OPS     NULL
+#endif
 
 /* Device Image Sizes
  *********************************************************************/
@@ -61,36 +66,47 @@ extern struct xilinx_fpga_op spartan2_op;
  *********************************************************************/
 /* Spartan-II devices */
 #define XILINX_XC2S15_DESC(iface, fn_table, cookie) \
-{ xilinx_spartan2, iface, XILINX_XC2S15_SIZE, fn_table, cookie, &spartan2_op }
+{ xilinx_spartan2, iface, XILINX_XC2S15_SIZE, fn_table, cookie, \
+       FPGA_SPARTAN2_OPS }
 
 #define XILINX_XC2S30_DESC(iface, fn_table, cookie) \
-{ xilinx_spartan2, iface, XILINX_XC2S30_SIZE, fn_table, cookie, &spartan2_op }
+{ xilinx_spartan2, iface, XILINX_XC2S30_SIZE, fn_table, cookie, \
+       FPGA_SPARTAN2_OPS }
 
 #define XILINX_XC2S50_DESC(iface, fn_table, cookie) \
-{ xilinx_spartan2, iface, XILINX_XC2S50_SIZE, fn_table, cookie, &spartan2_op }
+{ xilinx_spartan2, iface, XILINX_XC2S50_SIZE, fn_table, cookie, \
+       FPGA_SPARTAN2_OPS }
 
 #define XILINX_XC2S100_DESC(iface, fn_table, cookie) \
-{ xilinx_spartan2, iface, XILINX_XC2S100_SIZE, fn_table, cookie, &spartan2_op }
+{ xilinx_spartan2, iface, XILINX_XC2S100_SIZE, fn_table, cookie, \
+       FPGA_SPARTAN2_OPS }
 
 #define XILINX_XC2S150_DESC(iface, fn_table, cookie) \
-{ xilinx_spartan2, iface, XILINX_XC2S150_SIZE, fn_table, cookie, &spartan2_op }
+{ xilinx_spartan2, iface, XILINX_XC2S150_SIZE, fn_table, cookie, \
+       FPGA_SPARTAN2_OPS }
 
 #define XILINX_XC2S200_DESC(iface, fn_table, cookie) \
-{ xilinx_spartan2, iface, XILINX_XC2S200_SIZE, fn_table, cookie, &spartan2_op }
+{ xilinx_spartan2, iface, XILINX_XC2S200_SIZE, fn_table, cookie, \
+       FPGA_SPARTAN2_OPS }
 
 #define XILINX_XC2S50E_DESC(iface, fn_table, cookie) \
-{ xilinx_spartan2, iface, XILINX_XC2S50E_SIZE, fn_table, cookie, &spartan2_op }
+{ xilinx_spartan2, iface, XILINX_XC2S50E_SIZE, fn_table, cookie, \
+       FPGA_SPARTAN2_OPS }
 
 #define XILINX_XC2S100E_DESC(iface, fn_table, cookie) \
-{ xilinx_spartan2, iface, XILINX_XC2S100E_SIZE, fn_table, cookie, &spartan2_op }
+{ xilinx_spartan2, iface, XILINX_XC2S100E_SIZE, fn_table, cookie, \
+       FPGA_SPARTAN2_OPS }
 
 #define XILINX_XC2S150E_DESC(iface, fn_table, cookie) \
-{ xilinx_spartan2, iface, XILINX_XC2S150E_SIZE, fn_table, cookie, &spartan2_op }
+{ xilinx_spartan2, iface, XILINX_XC2S150E_SIZE, fn_table, cookie, \
+       FPGA_SPARTAN2_OPS }
 
 #define XILINX_XC2S200E_DESC(iface, fn_table, cookie) \
-{ xilinx_spartan2, iface, XILINX_XC2S200E_SIZE, fn_table, cookie, &spartan2_op }
+{ xilinx_spartan2, iface, XILINX_XC2S200E_SIZE, fn_table, cookie, \
+       FPGA_SPARTAN2_OPS }
 
 #define XILINX_XC2S300E_DESC(iface, fn_table, cookie) \
-{ xilinx_spartan2, iface, XILINX_XC2S300E_SIZE, fn_table, cookie, &spartan2_op }
+{ xilinx_spartan2, iface, XILINX_XC2S300E_SIZE, fn_table, cookie, \
+       FPGA_SPARTAN2_OPS }
 
 #endif /* _SPARTAN2_H_ */
index d6d67a6e560cf4ad45d043a44b4be5fa277118e8..fcb27b01e4a7ea261b2126abe4a5d2c56371c556 100644 (file)
@@ -40,7 +40,12 @@ typedef struct {
        xilinx_abort_fn abort;
 } xilinx_spartan3_slave_serial_fns;
 
+#if defined(CONFIG_FPGA_SPARTAN3)
 extern struct xilinx_fpga_op spartan3_op;
+# define FPGA_SPARTAN3_OPS     &spartan3_op
+#else
+# define FPGA_SPARTAN3_OPS     NULL
+#endif
 
 /* Device Image Sizes
  *********************************************************************/
@@ -71,48 +76,60 @@ extern struct xilinx_fpga_op spartan3_op;
  *********************************************************************/
 /* Spartan-III devices */
 #define XILINX_XC3S50_DESC(iface, fn_table, cookie) \
-{ xilinx_spartan3, iface, XILINX_XC3S50_SIZE, fn_table, cookie, &spartan3_op }
+{ xilinx_spartan3, iface, XILINX_XC3S50_SIZE, fn_table, cookie, \
+       FPGA_SPARTAN3_OPS }
 
 #define XILINX_XC3S200_DESC(iface, fn_table, cookie) \
-{ xilinx_spartan3, iface, XILINX_XC3S200_SIZE, fn_table, cookie, &spartan3_op }
+{ xilinx_spartan3, iface, XILINX_XC3S200_SIZE, fn_table, cookie, \
+       FPGA_SPARTAN3_OPS }
 
 #define XILINX_XC3S400_DESC(iface, fn_table, cookie) \
-{ xilinx_spartan3, iface, XILINX_XC3S400_SIZE, fn_table, cookie, &spartan3_op }
+{ xilinx_spartan3, iface, XILINX_XC3S400_SIZE, fn_table, cookie, \
+       FPGA_SPARTAN3_OPS }
 
 #define XILINX_XC3S1000_DESC(iface, fn_table, cookie) \
-{ xilinx_spartan3, iface, XILINX_XC3S1000_SIZE, fn_table, cookie, &spartan3_op }
+{ xilinx_spartan3, iface, XILINX_XC3S1000_SIZE, fn_table, cookie, \
+       FPGA_SPARTAN3_OPS }
 
 #define XILINX_XC3S1500_DESC(iface, fn_table, cookie) \
-{ xilinx_spartan3, iface, XILINX_XC3S1500_SIZE, fn_table, cookie, &spartan3_op }
+{ xilinx_spartan3, iface, XILINX_XC3S1500_SIZE, fn_table, cookie, \
+       FPGA_SPARTAN3_OPS }
 
 #define XILINX_XC3S2000_DESC(iface, fn_table, cookie) \
-{ xilinx_spartan3, iface, XILINX_XC3S2000_SIZE, fn_table, cookie, &spartan3_op }
+{ xilinx_spartan3, iface, XILINX_XC3S2000_SIZE, fn_table, cookie, \
+       FPGA_SPARTAN3_OPS }
 
 #define XILINX_XC3S4000_DESC(iface, fn_table, cookie) \
-{ xilinx_spartan3, iface, XILINX_XC3S4000_SIZE, fn_table, cookie, &spartan3_op }
+{ xilinx_spartan3, iface, XILINX_XC3S4000_SIZE, fn_table, cookie, \
+       FPGA_SPARTAN3_OPS }
 
 #define XILINX_XC3S5000_DESC(iface, fn_table, cookie) \
-{ xilinx_spartan3, iface, XILINX_XC3S5000_SIZE, fn_table, cookie, &spartan3_op }
+{ xilinx_spartan3, iface, XILINX_XC3S5000_SIZE, fn_table, cookie, \
+       FPGA_SPARTAN3_OPS }
 
 /* Spartan-3E devices */
 #define XILINX_XC3S100E_DESC(iface, fn_table, cookie) \
-{ xilinx_spartan3, iface, XILINX_XC3S100E_SIZE, fn_table, cookie, &spartan3_op }
+{ xilinx_spartan3, iface, XILINX_XC3S100E_SIZE, fn_table, cookie, \
+       FPGA_SPARTAN3_OPS }
 
 #define XILINX_XC3S250E_DESC(iface, fn_table, cookie) \
-{ xilinx_spartan3, iface, XILINX_XC3S250E_SIZE, fn_table, cookie, &spartan3_op }
+{ xilinx_spartan3, iface, XILINX_XC3S250E_SIZE, fn_table, cookie, \
+       FPGA_SPARTAN3_OPS }
 
 #define XILINX_XC3S500E_DESC(iface, fn_table, cookie) \
-{ xilinx_spartan3, iface, XILINX_XC3S500E_SIZE, fn_table, cookie, &spartan3_op }
+{ xilinx_spartan3, iface, XILINX_XC3S500E_SIZE, fn_table, cookie, \
+       FPGA_SPARTAN3_OPS }
 
 #define XILINX_XC3S1200E_DESC(iface, fn_table, cookie) \
 { xilinx_spartan3, iface, XILINX_XC3S1200E_SIZE, fn_table, cookie, \
-       &spartan3_op }
+       FPGA_SPARTAN3_OPS }
 
 #define XILINX_XC3S1600E_DESC(iface, fn_table, cookie) \
 { xilinx_spartan3, iface, XILINX_XC3S1600E_SIZE, fn_table, cookie, \
-       &spartan3_op }
+       FPGA_SPARTAN3_OPS }
 
 #define XILINX_XC6SLX4_DESC(iface, fn_table, cookie) \
-{ xilinx_spartan3, iface, XILINK_XC6SLX4_SIZE, fn_table, cookie, &spartan3_op }
+{ xilinx_spartan3, iface, XILINK_XC6SLX4_SIZE, fn_table, cookie, \
+       FPGA_SPARTAN3_OPS }
 
 #endif /* _SPARTAN3_H_ */
index ec17bd0bcc8963e4c4e402e57c0003d3b839b568..c58e453559616eb1cbbca36ee20704afcd4ebecc 100644 (file)
 #define SPI_DEFAULT_WORDLEN 8
 
 #ifdef CONFIG_DM_SPI
+/* TODO(sjg@chromium.org): Remove this and use max_hz from struct spi_slave */
 struct dm_spi_bus {
        uint max_hz;
 };
 
+/**
+ * struct dm_spi_platdata - platform data for all SPI slaves
+ *
+ * This describes a SPI slave, a child device of the SPI bus. To obtain this
+ * struct from a spi_slave, use dev_get_parent_platdata(dev) or
+ * dev_get_parent_platdata(slave->dev).
+ *
+ * This data is immuatable. Each time the device is probed, @max_hz and @mode
+ * will be copied to struct spi_slave.
+ *
+ * @cs:                Chip select number (0..n-1)
+ * @max_hz:    Maximum bus speed that this slave can tolerate
+ * @mode:      SPI mode to use for this device (see SPI mode flags)
+ */
+struct dm_spi_slave_platdata {
+       unsigned int cs;
+       uint max_hz;
+       uint mode;
+};
+
 #endif /* CONFIG_DM_SPI */
 
 /**
  * struct spi_slave - Representation of a SPI slave
  *
  * For driver model this is the per-child data used by the SPI bus. It can
- * be accessed using dev_get_parentdata() on the slave device. Each SPI
- * driver should define this child data in its U_BOOT_DRIVER() definition:
- *
- *     .per_child_auto_alloc_size      = sizeof(struct spi_slave),
+ * be accessed using dev_get_parentdata() on the slave device. The SPI uclass
+ * sets uip per_child_auto_alloc_size to sizeof(struct spi_slave), and the
+ * driver should not override it. Two platform data fields (max_hz and mode)
+ * are copied into this structure to provide an initial value. This allows
+ * them to be changed, since we should never change platform data in drivers.
  *
  * If not using driver model, drivers are expected to extend this with
  * controller-specific data.
@@ -97,8 +119,8 @@ struct spi_slave {
        uint mode;
 #else
        unsigned int bus;
-#endif
        unsigned int cs;
+#endif
        u8 op_mode_rx;
        u8 op_mode_tx;
        unsigned int wordlen;
@@ -545,16 +567,16 @@ int spi_chip_select(struct udevice *slave);
 int spi_find_chip_select(struct udevice *bus, int cs, struct udevice **devp);
 
 /**
- * spi_ofdata_to_platdata() - decode standard SPI platform data
+ * spi_slave_ofdata_to_platdata() - decode standard SPI platform data
  *
- * This decodes the speed and mode from a device tree node and puts it into
- * the spi_slave structure.
+ * This decodes the speed and mode for a slave from a device tree node
  *
  * @blob:      Device tree blob
  * @node:      Node offset to read from
- * @spi:       Place to put the decoded information
+ * @plat:      Place to put the decoded information
  */
-int spi_ofdata_to_platdata(const void *blob, int node, struct spi_slave *spi);
+int spi_slave_ofdata_to_platdata(const void *blob, int node,
+                                struct dm_spi_slave_platdata *plat);
 
 /**
  * spi_cs_info() - Check information on a chip select
index c996fb3e4c10eaf7c73451bbc8e7cf420b96d3d3..3c69d85ecbac7956a525b2e188943b46193259a3 100644 (file)
@@ -16,9 +16,18 @@ extern const uint8_t padding_sha256_rsa4096[];
 extern const uint8_t padding_sha256_rsa2048[];
 extern const uint8_t padding_sha1_rsa2048[];
 
-void sha256_calculate(const struct image_region region[], int region_count,
-                     uint8_t *checksum);
-void sha1_calculate(const struct image_region region[], int region_count,
-                   uint8_t *checksum);
+/**
+ * hash_calculate() - Calculate hash over the data
+ *
+ * @name:  Name of algorithm to be used for hash calculation
+ * @region: Array having info of regions over which hash needs to be calculated
+ * @region_count: Number of regions in the region array
+ * @checksum: Buffer contanining the output hash
+ *
+ * @return 0 if OK, < 0 if error
+ */
+int hash_calculate(const char *name,
+                  const struct image_region region[], int region_count,
+                  uint8_t *checksum);
 
 #endif
diff --git a/include/u-boot/rsa-mod-exp.h b/include/u-boot/rsa-mod-exp.h
new file mode 100644 (file)
index 0000000..fce445a
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2014, Ruchika Gupta.
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+*/
+
+#ifndef _RSA_MOD_EXP_H
+#define _RSA_MOD_EXP_H
+
+#include <errno.h>
+#include <image.h>
+
+/**
+ * struct key_prop - holder for a public key properties
+ *
+ * The struct has pointers to modulus (Typically called N),
+ * The inverse, R^2, exponent. These can be typecasted and
+ * used as byte arrays or converted to the required format
+ * as per requirement of RSA implementation.
+ */
+struct key_prop {
+       const void *rr;         /* R^2 can be treated as byte array */
+       const void *modulus;    /* modulus as byte array */
+       const void *public_exponent; /* public exponent as byte array */
+       uint32_t n0inv;         /* -1 / modulus[0] mod 2^32 */
+       int num_bits;           /* Key length in bits */
+       uint32_t exp_len;       /* Exponent length in number of uint8_t */
+};
+
+/**
+ * rsa_mod_exp_sw() - Perform RSA Modular Exponentiation in sw
+ *
+ * Operation: out[] = sig ^ exponent % modulus
+ *
+ * @sig:       RSA PKCS1.5 signature
+ * @sig_len:   Length of signature in number of bytes
+ * @node:      Node with RSA key elements like modulus, exponent, R^2, n0inv
+ * @out:       Result in form of byte array of len equal to sig_len
+ */
+int rsa_mod_exp_sw(const uint8_t *sig, uint32_t sig_len,
+               struct key_prop *node, uint8_t *out);
+
+int rsa_mod_exp(struct udevice *dev, const uint8_t *sig, uint32_t sig_len,
+               struct key_prop *node, uint8_t *out);
+
+/**
+ * struct struct mod_exp_ops - Driver model for RSA Modular Exponentiation
+ *                             operations
+ *
+ * The uclass interface is implemented by all crypto devices which use
+ * driver model.
+ */
+struct mod_exp_ops {
+       /**
+        * Perform Modular Exponentiation
+        *
+        * Operation: out[] = sig ^ exponent % modulus
+        *
+        * @dev:        RSA Device
+        * @sig:        RSA PKCS1.5 signature
+        * @sig_len:    Length of signature in number of bytes
+        * @node:       Node with RSA key elements like modulus, exponent,
+        *              R^2, n0inv
+        * @out:        Result in form of byte array of len equal to sig_len
+        *
+        * This function computes exponentiation over the signature.
+        * Returns: 0 if exponentiation is successful, or a negative value
+        * if it wasn't.
+        */
+       int (*mod_exp)(struct udevice *dev, const uint8_t *sig,
+                          uint32_t sig_len, struct key_prop *node,
+                          uint8_t *outp);
+};
+
+#endif
index d3c741597c64f64c06281f3d3ce807769d91f4e9..a8fee0bdb76f59a30e478286d06abb1d8201ce8a 100644 (file)
@@ -120,6 +120,7 @@ struct usb_device {
         * Each instance needs its own set of data structures.
         */
        unsigned long status;
+       unsigned long int_pending;      /* 1 bit per ep, used by int_queue */
        int act_len;                    /* transfered bytes */
        int maxchild;                   /* Number of ports if hub */
        int portnr;
@@ -154,11 +155,16 @@ enum usb_init_type {
        defined(CONFIG_USB_OMAP3) || defined(CONFIG_USB_DA8XX) || \
        defined(CONFIG_USB_BLACKFIN) || defined(CONFIG_USB_AM35X) || \
        defined(CONFIG_USB_MUSB_DSPS) || defined(CONFIG_USB_MUSB_AM35X) || \
-       defined(CONFIG_USB_MUSB_OMAP2PLUS) || defined(CONFIG_USB_XHCI) || \
-       defined(CONFIG_USB_DWC2)
+       defined(CONFIG_USB_MUSB_OMAP2PLUS) || defined(CONFIG_USB_MUSB_SUNXI) || \
+       defined(CONFIG_USB_XHCI) || defined(CONFIG_USB_DWC2)
 
 int usb_lowlevel_init(int index, enum usb_init_type init, void **controller);
 int usb_lowlevel_stop(int index);
+#ifdef CONFIG_MUSB_HOST
+void usb_reset_root_port(void);
+#else
+#define usb_reset_root_port()
+#endif
 
 int submit_bulk_msg(struct usb_device *dev, unsigned long pipe,
                        void *buffer, int transfer_len);
@@ -167,9 +173,9 @@ int submit_control_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
 int submit_int_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
                        int transfer_len, int interval);
 
-#ifdef CONFIG_USB_EHCI /* Only the ehci code has pollable int support */
+#if defined CONFIG_USB_EHCI || defined CONFIG_MUSB_HOST
 struct int_queue *create_int_queue(struct usb_device *dev, unsigned long pipe,
-       int queuesize, int elementsize, void *buffer);
+       int queuesize, int elementsize, void *buffer, int interval);
 int destroy_int_queue(struct usb_device *dev, struct int_queue *queue);
 void *poll_int_queue(struct usb_device *dev, struct int_queue *queue);
 #endif
index d4056914c4eb106b431be60828b311846c4aded6..c5deee9eca9d6e4c6997e6422c6d8cff802a3033 100644 (file)
@@ -35,10 +35,14 @@ struct __packed screen_info_input {
 struct __packed vbe_info {
        char signature[4];
        u16 version;
-       u8 *oem_string_ptr;
+       u32 oem_string_ptr;
        u32 capabilities;
-       u16 video_mode_list[256];
+       u32 modes_ptr;
        u16 total_memory;
+       u16 oem_version;
+       u32 vendor_name_ptr;
+       u32 product_name_ptr;
+       u32 product_rev_ptr;
 };
 
 struct __packed vesa_mode_info {
@@ -96,6 +100,7 @@ struct vbe_ddc_info {
 #define VESA_GET_INFO          0x4f00
 #define VESA_GET_MODE_INFO     0x4f01
 #define VESA_SET_MODE          0x4f02
+#define VESA_GET_CUR_MODE      0x4f03
 
 struct graphic_device;
 int vbe_get_video_info(struct graphic_device *gdev);
index 7b7825f513e358be83dbbbb753bd75569892d007..503df9abaeaa2cc9e2769ecb6c776393d356d9fc 100644 (file)
@@ -11,8 +11,6 @@
 
 #include <xilinx.h>
 
-extern struct xilinx_fpga_op virtex2_op;
-
 /*
  * Slave SelectMap Implementation function table.
  */
@@ -40,12 +38,19 @@ typedef struct {
        xilinx_wdata_fn wdata;
 } xilinx_virtex2_slave_serial_fns;
 
+#if defined(CONFIG_FPGA_VIRTEX2)
+extern struct xilinx_fpga_op virtex2_op;
+# define FPGA_VIRTEX2_OPS      &virtex2_op
+#else
+# define FPGA_VIRTEX2_OPS      NULL
+#endif
+
 /* Device Image Sizes (in bytes)
  *********************************************************************/
-#define XILINX_XC2V40_SIZE             (338208 / 8)
-#define XILINX_XC2V80_SIZE             (597408 / 8)
-#define XILINX_XC2V250_SIZE            (1591584 / 8)
-#define XILINX_XC2V500_SIZE            (2557857 / 8)
+#define XILINX_XC2V40_SIZE     (338208 / 8)
+#define XILINX_XC2V80_SIZE     (597408 / 8)
+#define XILINX_XC2V250_SIZE    (1591584 / 8)
+#define XILINX_XC2V500_SIZE    (2557857 / 8)
 #define XILINX_XC2V1000_SIZE   (3749408 / 8)
 #define XILINX_XC2V1500_SIZE   (5166240 / 8)
 #define XILINX_XC2V2000_SIZE   (6808352 / 8)
@@ -58,39 +63,51 @@ typedef struct {
 /* Descriptor Macros
  *********************************************************************/
 #define XILINX_XC2V40_DESC(iface, fn_table, cookie)    \
-{ xilinx_virtex2, iface, XILINX_XC2V40_SIZE, fn_table, cookie, &virtex2_op }
+{ xilinx_virtex2, iface, XILINX_XC2V40_SIZE, fn_table, cookie, \
+       FPGA_VIRTEX2_OPS }
 
 #define XILINX_XC2V80_DESC(iface, fn_table, cookie) \
-{ xilinx_virtex2, iface, XILINX_XC2V80_SIZE, fn_table, cookie, &virtex2_op }
+{ xilinx_virtex2, iface, XILINX_XC2V80_SIZE, fn_table, cookie, \
+       FPGA_VIRTEX2_OPS }
 
 #define XILINX_XC2V250_DESC(iface, fn_table, cookie) \
-{ xilinx_virtex2, iface, XILINX_XC2V250_SIZE, fn_table, cookie, &virtex2_op }
+{ xilinx_virtex2, iface, XILINX_XC2V250_SIZE, fn_table, cookie, \
+       FPGA_VIRTEX2_OPS }
 
 #define XILINX_XC2V500_DESC(iface, fn_table, cookie) \
-{ xilinx_virtex2, iface, XILINX_XC2V500_SIZE, fn_table, cookie, &virtex2_op }
+{ xilinx_virtex2, iface, XILINX_XC2V500_SIZE, fn_table, cookie, \
+       FPGA_VIRTEX2_OPS }
 
 #define XILINX_XC2V1000_DESC(iface, fn_table, cookie) \
-{ xilinx_virtex2, iface, XILINX_XC2V1000_SIZE, fn_table, cookie, &virtex2_op }
+{ xilinx_virtex2, iface, XILINX_XC2V1000_SIZE, fn_table, cookie, \
+       FPGA_VIRTEX2_OPS }
 
 #define XILINX_XC2V1500_DESC(iface, fn_table, cookie) \
-{ xilinx_virtex2, iface, XILINX_XC2V1500_SIZE, fn_table, cookie, &virtex2_op }
+{ xilinx_virtex2, iface, XILINX_XC2V1500_SIZE, fn_table, cookie, \
+       FPGA_VIRTEX2_OPS }
 
 #define XILINX_XC2V2000_DESC(iface, fn_table, cookie) \
-{ xilinx_virtex2, iface, XILINX_XC2V2000_SIZE, fn_table, cookie, &virtex2_op }
+{ xilinx_virtex2, iface, XILINX_XC2V2000_SIZE, fn_table, cookie, \
+       FPGA_VIRTEX2_OPS }
 
 #define XILINX_XC2V3000_DESC(iface, fn_table, cookie) \
-{ xilinx_virtex2, iface, XILINX_XC2V3000_SIZE, fn_table, cookie, &virtex2_op }
+{ xilinx_virtex2, iface, XILINX_XC2V3000_SIZE, fn_table, cookie, \
+       FPGA_VIRTEX2_OPS }
 
 #define XILINX_XC2V4000_DESC(iface, fn_table, cookie) \
-{ xilinx_virtex2, iface, XILINX_XC2V4000_SIZE, fn_table, cookie, &virtex2_op }
+{ xilinx_virtex2, iface, XILINX_XC2V4000_SIZE, fn_table, cookie, \
+       FPGA_VIRTEX2_OPS }
 
 #define XILINX_XC2V6000_DESC(iface, fn_table, cookie) \
-{ xilinx_virtex2, iface, XILINX_XC2V6000_SIZE, fn_table, cookie, &virtex2_op }
+{ xilinx_virtex2, iface, XILINX_XC2V6000_SIZE, fn_table, cookie, \
+       FPGA_VIRTEX2_OPS }
 
 #define XILINX_XC2V8000_DESC(iface, fn_table, cookie) \
-{ xilinx_virtex2, iface, XILINX_XC2V8000_SIZE, fn_table, cookie, &virtex2_op }
+{ xilinx_virtex2, iface, XILINX_XC2V8000_SIZE, fn_table, cookie, \
+       FPGA_VIRTEX2_OPS }
 
 #define XILINX_XC2V10000_DESC(iface, fn_table, cookie) \
-{ xilinx_virtex2, iface, XILINX_XC2V10000_SIZE, fn_table, cookie, &virtex2_op }
+{ xilinx_virtex2, iface, XILINX_XC2V10000_SIZE, fn_table, cookie, \
+       FPGA_VIRTEX2_OPS }
 
 #endif /* _VIRTEX2_H_ */
diff --git a/include/vsc9953.h b/include/vsc9953.h
new file mode 100644 (file)
index 0000000..3d11b87
--- /dev/null
@@ -0,0 +1,402 @@
+/*
+ *  vsc9953.h
+ *
+ *  Driver for the Vitesse VSC9953 L2 Switch
+ *
+ *  This software may be used and distributed according to the
+ *  terms of the GNU Public License, Version 2, incorporated
+ *  herein by reference.
+ *
+ * Copyright 2013  Freescale Semiconductor, Inc.
+ *
+ */
+
+#ifndef _VSC9953_H_
+#define _VSC9953_H_
+
+#include <config.h>
+#include <miiphy.h>
+#include <asm/types.h>
+#include <malloc.h>
+
+#define VSC9953_OFFSET                 (CONFIG_SYS_CCSRBAR_DEFAULT + 0x800000)
+
+#define VSC9953_SYS_OFFSET             0x010000
+#define VSC9953_DEV_GMII_OFFSET                0x100000
+#define VSC9953_QSYS_OFFSET            0x200000
+#define VSC9953_ANA_OFFSET             0x280000
+#define VSC9953_DEVCPU_GCB             0x070000
+#define VSC9953_ES0                    0x040000
+#define VSC9953_IS1                    0x050000
+#define VSC9953_IS2                    0x060000
+
+#define T1040_SWITCH_GMII_DEV_OFFSET   0x010000
+#define VSC9953_PHY_REGS_OFFST         0x0000AC
+
+#define CONFIG_VSC9953_SOFT_SWC_RST_ENA        0x00000001
+#define CONFIG_VSC9953_CORE_ENABLE     0x80
+#define CONFIG_VSC9953_MEM_ENABLE      0x40
+#define CONFIG_VSC9953_MEM_INIT                0x20
+
+#define CONFIG_VSC9953_PORT_ENA                0x00003a00
+#define CONFIG_VSC9953_MAC_ENA_CFG     0x00000011
+#define CONFIG_VSC9953_MAC_MODE_CFG    0x00000011
+#define CONFIG_VSC9953_MAC_IFG_CFG     0x00000515
+#define CONFIG_VSC9953_MAC_HDX_CFG     0x00001043
+#define CONFIG_VSC9953_CLOCK_CFG       0x00000001
+#define CONFIG_VSC9953_CLOCK_CFG_1000M 0x00000001
+#define CONFIG_VSC9953_PFC_FC          0x00000001
+#define CONFIG_VSC9953_PFC_FC_QSGMII   0x00000000
+#define CONFIG_VSC9953_MAC_FC_CFG      0x04700000
+#define CONFIG_VSC9953_MAC_FC_CFG_QSGMII       0x00700000
+#define CONFIG_VSC9953_PAUSE_CFG       0x001ffffe
+#define CONFIG_VSC9953_TOT_TAIL_DROP_LVL       0x000003ff
+#define CONFIG_VSC9953_FRONT_PORT_MODE 0x00000000
+#define CONFIG_VSC9953_MAC_MAX_LEN     0x000005ee
+
+#define        CONFIG_VSC9953_VCAP_MV_CFG      0x0000ffff
+#define        CONFIG_VSC9953_VCAP_UPDATE_CTRL 0x01000004
+#define VSC9953_MAX_PORTS              10
+#define VSC9953_PORT_CHECK(port)       \
+       (((port) < 0 || (port) >= VSC9953_MAX_PORTS) ? 0 : 1)
+#define VSC9953_INTERNAL_PORT_CHECK(port) ( \
+       ( \
+               (port) < VSC9953_MAX_PORTS - 2 || (port) >= VSC9953_MAX_PORTS \
+       ) ? 0 : 1 \
+)
+
+#define DEFAULT_VSC9953_MDIO_NAME      "VSC9953_MDIO0"
+
+#define MIIMIND_OPR_PEND               0x00000004
+
+struct vsc9953_mdio_info {
+       struct vsc9953_mii_mng  *regs;
+       char    *name;
+};
+
+/* VSC9953 ANA structure for T1040 U-boot*/
+
+struct vsc9953_ana_port {
+       u32     vlan_cfg;
+       u32     drop_cfg;
+       u32     qos_cfg;
+       u32     vcap_cfg;
+       u32     vcap_s1_key_cfg[3];
+       u32     vcap_s2_cfg;
+       u32     qos_pcp_dei_map_cfg[16];
+       u32     cpu_fwd_cfg;
+       u32     cpu_fwd_bpdu_cfg;
+       u32     cpu_fwd_garp_cfg;
+       u32     cpu_fwd_ccm_cfg;
+       u32     port_cfg;
+       u32     pol_cfg;
+       u32     reserved[34];
+};
+
+struct vsc9953_ana_pol {
+       u32     pol_pir_cfg;
+       u32     pol_cir_cfg;
+       u32     pol_mode_cfg;
+       u32     pol_pir_state;
+       u32     pol_cir_state;
+       u32     reserved1[3];
+};
+
+struct vsc9953_ana_ana_tables {
+       u32     entry_lim[11];
+       u32     an_moved;
+       u32     mach_data;
+       u32     macl_data;
+       u32     mac_access;
+       u32     mact_indx;
+       u32     vlan_access;
+       u32     vlan_tidx;
+};
+
+struct vsc9953_ana_ana {
+       u32     adv_learn;
+       u32     vlan_mask;
+       u32     anag_efil;
+       u32     an_events;
+       u32     storm_limit_burst;
+       u32     storm_limit_cfg[4];
+       u32     isolated_prts;
+       u32     community_ports;
+       u32     auto_age;
+       u32     mac_options;
+       u32     learn_disc;
+       u32     agen_ctrl;
+       u32     mirror_ports;
+       u32     emirror_ports;
+       u32     flooding;
+       u32     flooding_ipmc;
+       u32     sflow_cfg[11];
+       u32     port_mode[12];
+};
+
+struct vsc9953_ana_pgid {
+       u32     port_grp_id[91];
+};
+
+struct vsc9953_ana_pfc {
+       u32     pfc_cfg;
+       u32     reserved1[15];
+};
+
+struct vsc9953_ana_pol_misc {
+       u32     pol_flowc[10];
+       u32     reserved1[17];
+       u32     pol_hyst;
+};
+
+struct vsc9953_ana_common {
+       u32     aggr_cfg;
+       u32     cpuq_cfg;
+       u32     cpuq_8021_cfg;
+       u32     dscp_cfg;
+       u32     dscp_rewr_cfg;
+       u32     vcap_rng_type_cfg;
+       u32     vcap_rng_val_cfg;
+       u32     discard_cfg;
+       u32     fid_cfg;
+};
+
+struct vsc9953_analyzer {
+       struct vsc9953_ana_port port[11];
+       u32     reserved1[9536];
+       struct vsc9953_ana_pol  pol[164];
+       struct vsc9953_ana_ana_tables   ana_tables;
+       u32     reserved2[14];
+       struct vsc9953_ana_ana  ana;
+       u32     reserved3[22];
+       struct vsc9953_ana_pgid port_id_tbl;
+       u32     reserved4[549];
+       struct vsc9953_ana_pfc  pfc[10];
+       struct vsc9953_ana_pol_misc     pol_misc;
+       u32     reserved5[196];
+       struct vsc9953_ana_common       common;
+};
+/* END VSC9953 ANA structure for T1040 U-boot*/
+
+/* VSC9953 DEV_GMII structure for T1040 U-boot*/
+
+struct vsc9953_dev_gmii_port_mode {
+       u32     clock_cfg;
+       u32     port_misc;
+       u32     reserved1;
+       u32     eee_cfg;
+};
+
+struct vsc9953_dev_gmii_mac_cfg_status {
+       u32     mac_ena_cfg;
+       u32     mac_mode_cfg;
+       u32     mac_maxlen_cfg;
+       u32     mac_tags_cfg;
+       u32     mac_adv_chk_cfg;
+       u32     mac_ifg_cfg;
+       u32     mac_hdx_cfg;
+       u32     mac_fc_mac_low_cfg;
+       u32     mac_fc_mac_high_cfg;
+       u32     mac_sticky;
+};
+
+struct vsc9953_dev_gmii {
+       struct vsc9953_dev_gmii_port_mode       port_mode;
+       struct vsc9953_dev_gmii_mac_cfg_status  mac_cfg_status;
+};
+
+/* END VSC9953 DEV_GMII structure for T1040 U-boot*/
+
+/* VSC9953 QSYS structure for T1040 U-boot*/
+
+struct vsc9953_qsys_hsch {
+       u32     cir_cfg;
+       u32     reserved1;
+       u32     se_cfg;
+       u32     se_dwrr_cfg[8];
+       u32     cir_state;
+       u32     reserved2[20];
+};
+
+struct vsc9953_qsys_sys {
+       u32     port_mode[12];
+       u32     switch_port_mode[11];
+       u32     stat_cnt_cfg;
+       u32     eee_cfg[10];
+       u32     eee_thrs;
+       u32     igr_no_sharing;
+       u32     egr_no_sharing;
+       u32     sw_status[11];
+       u32     ext_cpu_cfg;
+       u32     cpu_group_map;
+       u32     reserved1[23];
+};
+
+struct vsc9953_qsys_qos_cfg {
+       u32     red_profile[16];
+       u32     res_qos_mode;
+};
+
+struct vsc9953_qsys_drop_cfg {
+       u32     egr_drop_mode;
+};
+
+struct vsc9953_qsys_mmgt {
+       u32     eq_cntrl;
+       u32     reserved1;
+};
+
+struct vsc9953_qsys_hsch_misc {
+       u32     hsch_misc_cfg;
+       u32     reserved1[546];
+};
+
+struct vsc9953_qsys_res_ctrl {
+       u32     res_cfg;
+       u32     res_stat;
+
+};
+
+struct vsc9953_qsys_reg {
+       struct vsc9953_qsys_hsch        hsch[108];
+       struct vsc9953_qsys_sys sys;
+       struct vsc9953_qsys_qos_cfg     qos_cfg;
+       struct vsc9953_qsys_drop_cfg    drop_cfg;
+       struct vsc9953_qsys_mmgt        mmgt;
+       struct vsc9953_qsys_hsch_misc   hsch_misc;
+       struct vsc9953_qsys_res_ctrl    res_ctrl[1024];
+};
+
+/* END VSC9953 QSYS structure for T1040 U-boot*/
+
+/* VSC9953 SYS structure for T1040 U-boot*/
+
+struct vsc9953_sys_stat {
+       u32     rx_cntrs[64];
+       u32     tx_cntrs[64];
+       u32     drop_cntrs[64];
+       u32     reserved1[6];
+};
+
+struct vsc9953_sys_sys {
+       u32     reset_cfg;
+       u32     reserved1;
+       u32     vlan_etype_cfg;
+       u32     port_mode[12];
+       u32     front_port_mode[10];
+       u32     frame_aging;
+       u32     stat_cfg;
+       u32     reserved2[50];
+};
+
+struct vsc9953_sys_pause_cfg {
+       u32     pause_cfg[11];
+       u32     pause_tot_cfg;
+       u32     tail_drop_level[11];
+       u32     tot_tail_drop_lvl;
+       u32     mac_fc_cfg[10];
+};
+
+struct vsc9953_sys_mmgt {
+       u16     free_cnt;
+};
+
+struct vsc9953_system_reg {
+       struct vsc9953_sys_stat stat;
+       struct vsc9953_sys_sys  sys;
+       struct vsc9953_sys_pause_cfg    pause_cfg;
+       struct vsc9953_sys_mmgt mmgt;
+};
+
+/* END VSC9953 SYS structure for T1040 U-boot*/
+
+
+/* VSC9953 DEVCPU_GCB structure for T1040 U-boot*/
+
+struct vsc9953_chip_regs {
+       u32     chipd_id;
+       u32     gpr;
+       u32     soft_rst;
+};
+
+struct vsc9953_gpio {
+       u32     gpio_out_set[10];
+       u32     gpio_out_clr[10];
+       u32     gpio_out[10];
+       u32     gpio_in[10];
+};
+
+struct vsc9953_mii_mng {
+       u32     miimstatus;
+       u32     reserved1;
+       u32     miimcmd;
+       u32     miimdata;
+       u32     miimcfg;
+       u32     miimscan_0;
+       u32     miimscan_1;
+       u32     miiscan_lst_rslts;
+       u32     miiscan_lst_rslts_valid;
+};
+
+struct vsc9953_mii_read_scan {
+       u32     mii_scan_results_sticky[2];
+};
+
+struct vsc9953_devcpu_gcb {
+       struct vsc9953_chip_regs        chip_regs;
+       struct vsc9953_gpio             gpio;
+       struct vsc9953_mii_mng  mii_mng[2];
+       struct vsc9953_mii_read_scan    mii_read_scan;
+};
+
+/* END VSC9953 DEVCPU_GCB structure for T1040 U-boot*/
+
+/* VSC9953 IS* structure for T1040 U-boot*/
+
+struct vsc9953_vcap_core_cfg   {
+       u32     vcap_update_ctrl;
+       u32     vcap_mv_cfg;
+};
+
+struct vsc9953_vcap {
+struct vsc9953_vcap_core_cfg   vcap_core_cfg;
+};
+
+/* END VSC9953 IS* structure for T1040 U-boot*/
+
+#define VSC9953_PORT_INFO_INITIALIZER(idx) \
+{                                                                      \
+       .enabled        = 0,                                            \
+       .phyaddr        = 0,                                            \
+       .index          = idx,                                          \
+       .phy_regs       = NULL,                                         \
+       .enet_if        = PHY_INTERFACE_MODE_NONE,                      \
+       .bus            = NULL,                                         \
+       .phydev         = NULL,                                         \
+}
+
+/* Structure to describe a VSC9953 port */
+struct vsc9953_port_info {
+       u8      enabled;
+       u8      phyaddr;
+       int     index;
+       void    *phy_regs;
+       phy_interface_t enet_if;
+       struct mii_dev  *bus;
+       struct phy_device       *phydev;
+};
+
+/* Structure to describe a VSC9953 switch */
+struct vsc9953_info {
+       struct  vsc9953_port_info       port[VSC9953_MAX_PORTS];
+};
+
+void vsc9953_init(bd_t *bis);
+
+void vsc9953_port_info_set_mdio(int port, struct mii_dev *bus);
+void vsc9953_port_info_set_phy_address(int port, int address);
+void vsc9953_port_enable(int port);
+void vsc9953_port_disable(int port);
+void vsc9953_port_info_set_phy_int(int port, phy_interface_t phy_int);
+
+#endif /* _VSC9953_H_ */
index 8a9ec3297fbe5b576f434cf4812d736cf88baf49..1d37a51a04ef8e3f65f6cbddd166f7b27e227d55 100644 (file)
 
 #include <xilinx.h>
 
+#if defined(CONFIG_FPGA_ZYNQPL)
 extern struct xilinx_fpga_op zynq_op;
+# define FPGA_ZYNQPL_OPS       &zynq_op
+#else
+# define FPGA_ZYNQPL_OPS       NULL
+#endif
 
 #define XILINX_ZYNQ_7010       0x2
 #define XILINX_ZYNQ_7015       0x1b
 #define XILINX_ZYNQ_7020       0x7
 #define XILINX_ZYNQ_7030       0xc
+#define XILINX_ZYNQ_7035       0x12
 #define XILINX_ZYNQ_7045       0x11
 #define XILINX_ZYNQ_7100       0x16
 
@@ -26,26 +32,37 @@ extern struct xilinx_fpga_op zynq_op;
 #define XILINX_XC7Z015_SIZE    28085344/8
 #define XILINX_XC7Z020_SIZE    32364512/8
 #define XILINX_XC7Z030_SIZE    47839328/8
+#define XILINX_XC7Z035_SIZE    106571232/8
 #define XILINX_XC7Z045_SIZE    106571232/8
 #define XILINX_XC7Z100_SIZE    139330784/8
 
 /* Descriptor Macros */
 #define XILINX_XC7Z010_DESC(cookie) \
-{ xilinx_zynq, devcfg, XILINX_XC7Z010_SIZE, NULL, cookie, &zynq_op, "7z010" }
+{ xilinx_zynq, devcfg, XILINX_XC7Z010_SIZE, NULL, cookie, FPGA_ZYNQPL_OPS, \
+       "7z010" }
 
 #define XILINX_XC7Z015_DESC(cookie) \
-{ xilinx_zynq, devcfg, XILINX_XC7Z015_SIZE, NULL, cookie, &zynq_op, "7z015" }
+{ xilinx_zynq, devcfg, XILINX_XC7Z015_SIZE, NULL, cookie, FPGA_ZYNQPL_OPS, \
+       "7z015" }
 
 #define XILINX_XC7Z020_DESC(cookie) \
-{ xilinx_zynq, devcfg, XILINX_XC7Z020_SIZE, NULL, cookie, &zynq_op, "7z020" }
+{ xilinx_zynq, devcfg, XILINX_XC7Z020_SIZE, NULL, cookie, FPGA_ZYNQPL_OPS, \
+       "7z020" }
 
 #define XILINX_XC7Z030_DESC(cookie) \
-{ xilinx_zynq, devcfg, XILINX_XC7Z030_SIZE, NULL, cookie, &zynq_op, "7z030" }
+{ xilinx_zynq, devcfg, XILINX_XC7Z030_SIZE, NULL, cookie, FPGA_ZYNQPL_OPS, \
+       "7z030" }
+
+#define XILINX_XC7Z035_DESC(cookie) \
+{ xilinx_zynq, devcfg, XILINX_XC7Z035_SIZE, NULL, cookie, FPGA_ZYNQPL_OPS, \
+       "7z035" }
 
 #define XILINX_XC7Z045_DESC(cookie) \
-{ xilinx_zynq, devcfg, XILINX_XC7Z045_SIZE, NULL, cookie, &zynq_op, "7z045" }
+{ xilinx_zynq, devcfg, XILINX_XC7Z045_SIZE, NULL, cookie, FPGA_ZYNQPL_OPS, \
+       "7z045" }
 
 #define XILINX_XC7Z100_DESC(cookie) \
-{ xilinx_zynq, devcfg, XILINX_XC7Z100_SIZE, NULL, cookie, &zynq_op, "7z100" }
+{ xilinx_zynq, devcfg, XILINX_XC7Z100_SIZE, NULL, cookie, FPGA_ZYNQPL_OPS, \
+       "7z100" }
 
 #endif /* _ZYNQPL_H_ */
index 8460439d8e772d4126b78ad616059dd38a7dabff..a1f30a2c4ef0931483cf80010ef0674ea5dbbb58 100644 (file)
@@ -27,4 +27,6 @@ config SYS_HZ
          get_timer() must operate in milliseconds and this option must be
          set to 1000.
 
+source lib/rsa/Kconfig
+
 endmenu
index 487122eebcf64c9129abb60c91e91d328f207f29..5bf8f29b13e92fbfcb9f0d83132e0e6ac987d0e2 100644 (file)
@@ -11,8 +11,6 @@
 #include <fdtdec.h>
 #include <linux/ctype.h>
 
-#include <asm/gpio.h>
-
 DECLARE_GLOBAL_DATA_PTR;
 
 /*
@@ -26,9 +24,6 @@ static const char * const compat_names[COMPAT_COUNT] = {
        COMPAT(NVIDIA_TEGRA20_USB, "nvidia,tegra20-ehci"),
        COMPAT(NVIDIA_TEGRA30_USB, "nvidia,tegra30-ehci"),
        COMPAT(NVIDIA_TEGRA114_USB, "nvidia,tegra114-ehci"),
-       COMPAT(NVIDIA_TEGRA114_I2C, "nvidia,tegra114-i2c"),
-       COMPAT(NVIDIA_TEGRA20_I2C, "nvidia,tegra20-i2c"),
-       COMPAT(NVIDIA_TEGRA20_DVC, "nvidia,tegra20-i2c-dvc"),
        COMPAT(NVIDIA_TEGRA20_EMC, "nvidia,tegra20-emc"),
        COMPAT(NVIDIA_TEGRA20_EMC_TABLE, "nvidia,tegra20-emc-table"),
        COMPAT(NVIDIA_TEGRA20_KBC, "nvidia,tegra20-kbc"),
@@ -38,9 +33,6 @@ static const char * const compat_names[COMPAT_COUNT] = {
        COMPAT(NVIDIA_TEGRA124_SDMMC, "nvidia,tegra124-sdhci"),
        COMPAT(NVIDIA_TEGRA30_SDMMC, "nvidia,tegra30-sdhci"),
        COMPAT(NVIDIA_TEGRA20_SDMMC, "nvidia,tegra20-sdhci"),
-       COMPAT(NVIDIA_TEGRA20_SFLASH, "nvidia,tegra20-sflash"),
-       COMPAT(NVIDIA_TEGRA20_SLINK, "nvidia,tegra20-slink"),
-       COMPAT(NVIDIA_TEGRA114_SPI, "nvidia,tegra114-spi"),
        COMPAT(NVIDIA_TEGRA124_PCIE, "nvidia,tegra124-pcie"),
        COMPAT(NVIDIA_TEGRA30_PCIE, "nvidia,tegra30-pcie"),
        COMPAT(NVIDIA_TEGRA20_PCIE, "nvidia,tegra20-pcie"),
@@ -50,7 +42,6 @@ static const char * const compat_names[COMPAT_COUNT] = {
        COMPAT(SAMSUNG_S3C2440_I2C, "samsung,s3c2440-i2c"),
        COMPAT(SAMSUNG_EXYNOS5_SOUND, "samsung,exynos-sound"),
        COMPAT(WOLFSON_WM8994_CODEC, "wolfson,wm8994-codec"),
-       COMPAT(SAMSUNG_EXYNOS_SPI, "samsung,exynos-spi"),
        COMPAT(GOOGLE_CROS_EC, "google,cros-ec"),
        COMPAT(GOOGLE_CROS_EC_KEYB, "google,cros-ec-keyb"),
        COMPAT(SAMSUNG_EXYNOS_EHCI, "samsung,exynos-ehci"),
@@ -83,6 +74,7 @@ static const char * const compat_names[COMPAT_COUNT] = {
        COMPAT(INTEL_MODEL_206AX, "intel,model-206ax"),
        COMPAT(INTEL_GMA, "intel,gma"),
        COMPAT(AMS_AS3722, "ams,as3722"),
+       COMPAT(INTEL_ICH_SPI, "intel,ich-spi"),
 };
 
 const char *fdtdec_get_compatible(enum fdt_compat_id id)
@@ -678,99 +670,128 @@ int fdtdec_get_bool(const void *blob, int node, const char *prop_name)
        return cell != NULL;
 }
 
-/**
- * Decode a list of GPIOs from an FDT. This creates a list of GPIOs with no
- * terminating item.
- *
- * @param blob         FDT blob to use
- * @param node         Node to look at
- * @param prop_name    Node property name
- * @param gpio         Array of gpio elements to fill from FDT. This will be
- *                     untouched if either 0 or an error is returned
- * @param max_count    Maximum number of elements allowed
- * @return number of GPIOs read if ok, -FDT_ERR_BADLAYOUT if max_count would
- * be exceeded, or -FDT_ERR_NOTFOUND if the property is missing.
- */
-int fdtdec_decode_gpios(const void *blob, int node, const char *prop_name,
-               struct fdt_gpio_state *gpio, int max_count)
+int fdtdec_parse_phandle_with_args(const void *blob, int src_node,
+                                  const char *list_name,
+                                  const char *cells_name,
+                                  int cell_count, int index,
+                                  struct fdtdec_phandle_args *out_args)
 {
-       const struct fdt_property *prop;
-       const u32 *cell;
-       const char *name;
-       int len, i;
-
-       debug("%s: %s\n", __func__, prop_name);
-       assert(max_count > 0);
-       prop = fdt_get_property(blob, node, prop_name, &len);
-       if (!prop) {
-               debug("%s: property '%s' missing\n", __func__, prop_name);
-               return -FDT_ERR_NOTFOUND;
-       }
-
-       /* We will use the name to tag the GPIO */
-       name = fdt_string(blob, fdt32_to_cpu(prop->nameoff));
-       cell = (u32 *)prop->data;
-       len /= sizeof(u32) * 3;         /* 3 cells per GPIO record */
-       if (len > max_count) {
-               debug(" %s: too many GPIOs / cells for "
-                       "property '%s'\n", __func__, prop_name);
-               return -FDT_ERR_BADLAYOUT;
-       }
-
-       /* Read out the GPIO data from the cells */
-       for (i = 0; i < len; i++, cell += 3) {
-               gpio[i].gpio = fdt32_to_cpu(cell[1]);
-               gpio[i].flags = fdt32_to_cpu(cell[2]);
-               gpio[i].name = name;
-       }
-
-       return len;
-}
+       const __be32 *list, *list_end;
+       int rc = 0, size, cur_index = 0;
+       uint32_t count = 0;
+       int node = -1;
+       int phandle;
+
+       /* Retrieve the phandle list property */
+       list = fdt_getprop(blob, src_node, list_name, &size);
+       if (!list)
+               return -ENOENT;
+       list_end = list + size / sizeof(*list);
 
-int fdtdec_decode_gpio(const void *blob, int node, const char *prop_name,
-               struct fdt_gpio_state *gpio)
-{
-       int err;
+       /* Loop over the phandles until all the requested entry is found */
+       while (list < list_end) {
+               rc = -EINVAL;
+               count = 0;
 
-       debug("%s: %s\n", __func__, prop_name);
-       gpio->gpio = FDT_GPIO_NONE;
-       gpio->name = NULL;
-       err = fdtdec_decode_gpios(blob, node, prop_name, gpio, 1);
-       return err == 1 ? 0 : err;
-}
+               /*
+                * If phandle is 0, then it is an empty entry with no
+                * arguments.  Skip forward to the next entry.
+                */
+               phandle = be32_to_cpup(list++);
+               if (phandle) {
+                       /*
+                        * Find the provider node and parse the #*-cells
+                        * property to determine the argument length.
+                        *
+                        * This is not needed if the cell count is hard-coded
+                        * (i.e. cells_name not set, but cell_count is set),
+                        * except when we're going to return the found node
+                        * below.
+                        */
+                       if (cells_name || cur_index == index) {
+                               node = fdt_node_offset_by_phandle(blob,
+                                                                 phandle);
+                               if (!node) {
+                                       debug("%s: could not find phandle\n",
+                                             fdt_get_name(blob, src_node,
+                                                          NULL));
+                                       goto err;
+                               }
+                       }
 
-int fdtdec_get_gpio(struct fdt_gpio_state *gpio)
-{
-       int val;
+                       if (cells_name) {
+                               count = fdtdec_get_int(blob, node, cells_name,
+                                                      -1);
+                               if (count == -1) {
+                                       debug("%s: could not get %s for %s\n",
+                                             fdt_get_name(blob, src_node,
+                                                          NULL),
+                                             cells_name,
+                                             fdt_get_name(blob, node,
+                                                          NULL));
+                                       goto err;
+                               }
+                       } else {
+                               count = cell_count;
+                       }
 
-       if (!fdt_gpio_isvalid(gpio))
-               return -1;
+                       /*
+                        * Make sure that the arguments actually fit in the
+                        * remaining property data length
+                        */
+                       if (list + count > list_end) {
+                               debug("%s: arguments longer than property\n",
+                                     fdt_get_name(blob, src_node, NULL));
+                               goto err;
+                       }
+               }
 
-       val = gpio_get_value(gpio->gpio);
-       return gpio->flags & FDT_GPIO_ACTIVE_LOW ? val ^ 1 : val;
-}
+               /*
+                * All of the error cases above bail out of the loop, so at
+                * this point, the parsing is successful. If the requested
+                * index matches, then fill the out_args structure and return,
+                * or return -ENOENT for an empty entry.
+                */
+               rc = -ENOENT;
+               if (cur_index == index) {
+                       if (!phandle)
+                               goto err;
+
+                       if (out_args) {
+                               int i;
+
+                               if (count > MAX_PHANDLE_ARGS) {
+                                       debug("%s: too many arguments %d\n",
+                                             fdt_get_name(blob, src_node,
+                                                          NULL), count);
+                                       count = MAX_PHANDLE_ARGS;
+                               }
+                               out_args->node = node;
+                               out_args->args_count = count;
+                               for (i = 0; i < count; i++) {
+                                       out_args->args[i] =
+                                                       be32_to_cpup(list++);
+                               }
+                       }
 
-int fdtdec_set_gpio(struct fdt_gpio_state *gpio, int val)
-{
-       if (!fdt_gpio_isvalid(gpio))
-               return -1;
+                       /* Found it! return success */
+                       return 0;
+               }
 
-       val = gpio->flags & FDT_GPIO_ACTIVE_LOW ? val ^ 1 : val;
-       return gpio_set_value(gpio->gpio, val);
-}
+               node = -1;
+               list += count;
+               cur_index++;
+       }
 
-int fdtdec_setup_gpio(struct fdt_gpio_state *gpio)
-{
        /*
-        * Return success if there is no GPIO defined. This is used for
-        * optional GPIOs)
+        * Result will be one of:
+        * -ENOENT : index is for empty phandle
+        * -EINVAL : parsing error on data
+        * [1..n]  : Number of phandle (count mode; when index = -1)
         */
-       if (!fdt_gpio_isvalid(gpio))
-               return 0;
-
-       if (gpio_request(gpio->gpio, gpio->name))
-               return -1;
-       return 0;
+       rc = index < 0 ? cur_index : -ENOENT;
+ err:
+       return rc;
 }
 
 int fdtdec_get_byte_array(const void *blob, int node, const char *prop_name,
diff --git a/lib/rsa/Kconfig b/lib/rsa/Kconfig
new file mode 100644 (file)
index 0000000..1268a1b
--- /dev/null
@@ -0,0 +1,27 @@
+config RSA
+       bool "Use RSA Library"
+       select RSA_FREESCALE_EXP if FSL_CAAM
+       select RSA_SOFTWARE_EXP if !RSA_FREESCALE_EXP
+       help
+         RSA support. This enables the RSA algorithm used for FIT image
+         verification in U-Boot.
+         See doc/uImage.FIT/signature.txt for more details.
+
+if RSA
+config RSA_SOFTWARE_EXP
+       bool "Enable driver for RSA Modular Exponentiation in software"
+       depends on DM && RSA
+       help
+         Enables driver for modular exponentiation in software. This is a RSA
+         algorithm used in FIT image verification. It required RSA Key as
+         input.
+         See doc/uImage.FIT/signature.txt for more details.
+
+config RSA_FREESCALE_EXP
+       bool "Enable RSA Modular Exponentiation with FSL crypto accelerator"
+       depends on DM && RSA && FSL_CAAM
+       help
+       Enables driver for RSA modular exponentiation using Freescale cryptographic
+       accelerator - CAAM.
+
+endif
index a5a96cb680d16d1cea1f88375f2ca1ec7bfc1776..cc25b3ce6d9232c60ff0b848632265b8a2788626 100644 (file)
@@ -7,4 +7,4 @@
 # SPDX-License-Identifier:     GPL-2.0+
 #
 
-obj-$(CONFIG_FIT_SIGNATURE) += rsa-verify.o rsa-checksum.o
+obj-$(CONFIG_FIT_SIGNATURE) += rsa-verify.o rsa-checksum.o rsa-mod-exp.o
index 8d8b59f779a2bd7d5d9eeb413706c86b5307d9ff..68d9d651b02860ab6cf422be4be62565834370c6 100644 (file)
 #include <asm/byteorder.h>
 #include <asm/errno.h>
 #include <asm/unaligned.h>
+#include <hash.h>
 #else
 #include "fdt_host.h"
-#endif
-#include <u-boot/rsa.h>
 #include <u-boot/sha1.h>
 #include <u-boot/sha256.h>
+#endif
+#include <u-boot/rsa.h>
 
 /* PKCS 1.5 paddings as described in the RSA PKCS#1 v2.1 standard. */
 
@@ -136,28 +137,37 @@ const uint8_t padding_sha256_rsa4096[RSA4096_BYTES - SHA256_SUM_LEN] = {
        0x03, 0x04, 0x02, 0x01, 0x05, 0x00, 0x04, 0x20
 };
 
-void sha1_calculate(const struct image_region region[], int region_count,
-                   uint8_t *checksum)
+int hash_calculate(const char *name,
+                   const struct image_region region[],
+                   int region_count, uint8_t *checksum)
 {
-       sha1_context ctx;
+       struct hash_algo *algo;
+       int ret = 0;
+       void *ctx;
        uint32_t i;
        i = 0;
 
-       sha1_starts(&ctx);
-       for (i = 0; i < region_count; i++)
-               sha1_update(&ctx, region[i].data, region[i].size);
-       sha1_finish(&ctx, checksum);
-}
+       ret = hash_progressive_lookup_algo(name, &algo);
+       if (ret)
+               return ret;
 
-void sha256_calculate(const struct image_region region[], int region_count,
-                     uint8_t *checksum)
-{
-       sha256_context ctx;
-       uint32_t i;
-       i = 0;
+       ret = algo->hash_init(algo, &ctx);
+       if (ret)
+               return ret;
+
+       for (i = 0; i < region_count - 1; i++) {
+               ret = algo->hash_update(algo, ctx, region[i].data,
+                                       region[i].size, 0);
+               if (ret)
+                       return ret;
+       }
+
+       ret = algo->hash_update(algo, ctx, region[i].data, region[i].size, 1);
+       if (ret)
+               return ret;
+       ret = algo->hash_finish(algo, ctx, checksum, algo->digest_size);
+       if (ret)
+               return ret;
 
-       sha256_starts(&ctx);
-       for (i = 0; i < region_count; i++)
-               sha256_update(&ctx, region[i].data, region[i].size);
-       sha256_finish(&ctx, checksum);
+       return 0;
 }
diff --git a/lib/rsa/rsa-mod-exp.c b/lib/rsa/rsa-mod-exp.c
new file mode 100644 (file)
index 0000000..4a6de2b
--- /dev/null
@@ -0,0 +1,303 @@
+/*
+ * Copyright (c) 2013, Google Inc.
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#ifndef USE_HOSTCC
+#include <common.h>
+#include <fdtdec.h>
+#include <asm/types.h>
+#include <asm/byteorder.h>
+#include <asm/errno.h>
+#include <asm/types.h>
+#include <asm/unaligned.h>
+#else
+#include "fdt_host.h"
+#include "mkimage.h"
+#include <fdt_support.h>
+#endif
+#include <u-boot/rsa.h>
+#include <u-boot/rsa-mod-exp.h>
+
+#define UINT64_MULT32(v, multby)  (((uint64_t)(v)) * ((uint32_t)(multby)))
+
+#define get_unaligned_be32(a) fdt32_to_cpu(*(uint32_t *)a)
+#define put_unaligned_be32(a, b) (*(uint32_t *)(b) = cpu_to_fdt32(a))
+
+/* Default public exponent for backward compatibility */
+#define RSA_DEFAULT_PUBEXP     65537
+
+/**
+ * subtract_modulus() - subtract modulus from the given value
+ *
+ * @key:       Key containing modulus to subtract
+ * @num:       Number to subtract modulus from, as little endian word array
+ */
+static void subtract_modulus(const struct rsa_public_key *key, uint32_t num[])
+{
+       int64_t acc = 0;
+       uint i;
+
+       for (i = 0; i < key->len; i++) {
+               acc += (uint64_t)num[i] - key->modulus[i];
+               num[i] = (uint32_t)acc;
+               acc >>= 32;
+       }
+}
+
+/**
+ * greater_equal_modulus() - check if a value is >= modulus
+ *
+ * @key:       Key containing modulus to check
+ * @num:       Number to check against modulus, as little endian word array
+ * @return 0 if num < modulus, 1 if num >= modulus
+ */
+static int greater_equal_modulus(const struct rsa_public_key *key,
+                                uint32_t num[])
+{
+       int i;
+
+       for (i = (int)key->len - 1; i >= 0; i--) {
+               if (num[i] < key->modulus[i])
+                       return 0;
+               if (num[i] > key->modulus[i])
+                       return 1;
+       }
+
+       return 1;  /* equal */
+}
+
+/**
+ * montgomery_mul_add_step() - Perform montgomery multiply-add step
+ *
+ * Operation: montgomery result[] += a * b[] / n0inv % modulus
+ *
+ * @key:       RSA key
+ * @result:    Place to put result, as little endian word array
+ * @a:         Multiplier
+ * @b:         Multiplicand, as little endian word array
+ */
+static void montgomery_mul_add_step(const struct rsa_public_key *key,
+               uint32_t result[], const uint32_t a, const uint32_t b[])
+{
+       uint64_t acc_a, acc_b;
+       uint32_t d0;
+       uint i;
+
+       acc_a = (uint64_t)a * b[0] + result[0];
+       d0 = (uint32_t)acc_a * key->n0inv;
+       acc_b = (uint64_t)d0 * key->modulus[0] + (uint32_t)acc_a;
+       for (i = 1; i < key->len; i++) {
+               acc_a = (acc_a >> 32) + (uint64_t)a * b[i] + result[i];
+               acc_b = (acc_b >> 32) + (uint64_t)d0 * key->modulus[i] +
+                               (uint32_t)acc_a;
+               result[i - 1] = (uint32_t)acc_b;
+       }
+
+       acc_a = (acc_a >> 32) + (acc_b >> 32);
+
+       result[i - 1] = (uint32_t)acc_a;
+
+       if (acc_a >> 32)
+               subtract_modulus(key, result);
+}
+
+/**
+ * montgomery_mul() - Perform montgomery mutitply
+ *
+ * Operation: montgomery result[] = a[] * b[] / n0inv % modulus
+ *
+ * @key:       RSA key
+ * @result:    Place to put result, as little endian word array
+ * @a:         Multiplier, as little endian word array
+ * @b:         Multiplicand, as little endian word array
+ */
+static void montgomery_mul(const struct rsa_public_key *key,
+               uint32_t result[], uint32_t a[], const uint32_t b[])
+{
+       uint i;
+
+       for (i = 0; i < key->len; ++i)
+               result[i] = 0;
+       for (i = 0; i < key->len; ++i)
+               montgomery_mul_add_step(key, result, a[i], b);
+}
+
+/**
+ * num_pub_exponent_bits() - Number of bits in the public exponent
+ *
+ * @key:       RSA key
+ * @num_bits:  Storage for the number of public exponent bits
+ */
+static int num_public_exponent_bits(const struct rsa_public_key *key,
+               int *num_bits)
+{
+       uint64_t exponent;
+       int exponent_bits;
+       const uint max_bits = (sizeof(exponent) * 8);
+
+       exponent = key->exponent;
+       exponent_bits = 0;
+
+       if (!exponent) {
+               *num_bits = exponent_bits;
+               return 0;
+       }
+
+       for (exponent_bits = 1; exponent_bits < max_bits + 1; ++exponent_bits)
+               if (!(exponent >>= 1)) {
+                       *num_bits = exponent_bits;
+                       return 0;
+               }
+
+       return -EINVAL;
+}
+
+/**
+ * is_public_exponent_bit_set() - Check if a bit in the public exponent is set
+ *
+ * @key:       RSA key
+ * @pos:       The bit position to check
+ */
+static int is_public_exponent_bit_set(const struct rsa_public_key *key,
+               int pos)
+{
+       return key->exponent & (1ULL << pos);
+}
+
+/**
+ * pow_mod() - in-place public exponentiation
+ *
+ * @key:       RSA key
+ * @inout:     Big-endian word array containing value and result
+ */
+static int pow_mod(const struct rsa_public_key *key, uint32_t *inout)
+{
+       uint32_t *result, *ptr;
+       uint i;
+       int j, k;
+
+       /* Sanity check for stack size - key->len is in 32-bit words */
+       if (key->len > RSA_MAX_KEY_BITS / 32) {
+               debug("RSA key words %u exceeds maximum %d\n", key->len,
+                     RSA_MAX_KEY_BITS / 32);
+               return -EINVAL;
+       }
+
+       uint32_t val[key->len], acc[key->len], tmp[key->len];
+       uint32_t a_scaled[key->len];
+       result = tmp;  /* Re-use location. */
+
+       /* Convert from big endian byte array to little endian word array. */
+       for (i = 0, ptr = inout + key->len - 1; i < key->len; i++, ptr--)
+               val[i] = get_unaligned_be32(ptr);
+
+       if (0 != num_public_exponent_bits(key, &k))
+               return -EINVAL;
+
+       if (k < 2) {
+               debug("Public exponent is too short (%d bits, minimum 2)\n",
+                     k);
+               return -EINVAL;
+       }
+
+       if (!is_public_exponent_bit_set(key, 0)) {
+               debug("LSB of RSA public exponent must be set.\n");
+               return -EINVAL;
+       }
+
+       /* the bit at e[k-1] is 1 by definition, so start with: C := M */
+       montgomery_mul(key, acc, val, key->rr); /* acc = a * RR / R mod n */
+       /* retain scaled version for intermediate use */
+       memcpy(a_scaled, acc, key->len * sizeof(a_scaled[0]));
+
+       for (j = k - 2; j > 0; --j) {
+               montgomery_mul(key, tmp, acc, acc); /* tmp = acc^2 / R mod n */
+
+               if (is_public_exponent_bit_set(key, j)) {
+                       /* acc = tmp * val / R mod n */
+                       montgomery_mul(key, acc, tmp, a_scaled);
+               } else {
+                       /* e[j] == 0, copy tmp back to acc for next operation */
+                       memcpy(acc, tmp, key->len * sizeof(acc[0]));
+               }
+       }
+
+       /* the bit at e[0] is always 1 */
+       montgomery_mul(key, tmp, acc, acc); /* tmp = acc^2 / R mod n */
+       montgomery_mul(key, acc, tmp, val); /* acc = tmp * a / R mod M */
+       memcpy(result, acc, key->len * sizeof(result[0]));
+
+       /* Make sure result < mod; result is at most 1x mod too large. */
+       if (greater_equal_modulus(key, result))
+               subtract_modulus(key, result);
+
+       /* Convert to bigendian byte array */
+       for (i = key->len - 1, ptr = inout; (int)i >= 0; i--, ptr++)
+               put_unaligned_be32(result[i], ptr);
+       return 0;
+}
+
+static void rsa_convert_big_endian(uint32_t *dst, const uint32_t *src, int len)
+{
+       int i;
+
+       for (i = 0; i < len; i++)
+               dst[i] = fdt32_to_cpu(src[len - 1 - i]);
+}
+
+int rsa_mod_exp_sw(const uint8_t *sig, uint32_t sig_len,
+               struct key_prop *prop, uint8_t *out)
+{
+       struct rsa_public_key key;
+       int ret;
+
+       if (!prop) {
+               debug("%s: Skipping invalid prop", __func__);
+               return -EBADF;
+       }
+       key.n0inv = prop->n0inv;
+       key.len = prop->num_bits;
+
+       if (!prop->public_exponent)
+               key.exponent = RSA_DEFAULT_PUBEXP;
+       else
+               key.exponent =
+                       fdt64_to_cpu(*((uint64_t *)(prop->public_exponent)));
+
+       if (!key.len || !prop->modulus || !prop->rr) {
+               debug("%s: Missing RSA key info", __func__);
+               return -EFAULT;
+       }
+
+       /* Sanity check for stack size */
+       if (key.len > RSA_MAX_KEY_BITS || key.len < RSA_MIN_KEY_BITS) {
+               debug("RSA key bits %u outside allowed range %d..%d\n",
+                     key.len, RSA_MIN_KEY_BITS, RSA_MAX_KEY_BITS);
+               return -EFAULT;
+       }
+       key.len /= sizeof(uint32_t) * 8;
+       uint32_t key1[key.len], key2[key.len];
+
+       key.modulus = key1;
+       key.rr = key2;
+       rsa_convert_big_endian(key.modulus, (uint32_t *)prop->modulus, key.len);
+       rsa_convert_big_endian(key.rr, (uint32_t *)prop->rr, key.len);
+       if (!key.modulus || !key.rr) {
+               debug("%s: Out of memory", __func__);
+               return -ENOMEM;
+       }
+
+       uint32_t buf[sig_len / sizeof(uint32_t)];
+
+       memcpy(buf, sig, sig_len);
+
+       ret = pow_mod(&key, buf);
+       if (ret)
+               return ret;
+
+       memcpy(out, buf, sig_len);
+
+       return 0;
+}
index 4ef19b66f4b12588f2bbe0a978500a0718177336..60126d22884b6e29dd18887ee7fbad90869ed049 100644 (file)
 #include <asm/errno.h>
 #include <asm/types.h>
 #include <asm/unaligned.h>
+#include <dm.h>
 #else
 #include "fdt_host.h"
 #include "mkimage.h"
 #include <fdt_support.h>
 #endif
+#include <u-boot/rsa-mod-exp.h>
 #include <u-boot/rsa.h>
-#include <u-boot/sha1.h>
-#include <u-boot/sha256.h>
-
-#define UINT64_MULT32(v, multby)  (((uint64_t)(v)) * ((uint32_t)(multby)))
-
-#define get_unaligned_be32(a) fdt32_to_cpu(*(uint32_t *)a)
-#define put_unaligned_be32(a, b) (*(uint32_t *)(b) = cpu_to_fdt32(a))
 
 /* Default public exponent for backward compatibility */
 #define RSA_DEFAULT_PUBEXP     65537
 
 /**
- * subtract_modulus() - subtract modulus from the given value
- *
- * @key:       Key containing modulus to subtract
- * @num:       Number to subtract modulus from, as little endian word array
- */
-static void subtract_modulus(const struct rsa_public_key *key, uint32_t num[])
-{
-       int64_t acc = 0;
-       uint i;
-
-       for (i = 0; i < key->len; i++) {
-               acc += (uint64_t)num[i] - key->modulus[i];
-               num[i] = (uint32_t)acc;
-               acc >>= 32;
-       }
-}
-
-/**
- * greater_equal_modulus() - check if a value is >= modulus
- *
- * @key:       Key containing modulus to check
- * @num:       Number to check against modulus, as little endian word array
- * @return 0 if num < modulus, 1 if num >= modulus
- */
-static int greater_equal_modulus(const struct rsa_public_key *key,
-                                uint32_t num[])
-{
-       int i;
-
-       for (i = (int)key->len - 1; i >= 0; i--) {
-               if (num[i] < key->modulus[i])
-                       return 0;
-               if (num[i] > key->modulus[i])
-                       return 1;
-       }
-
-       return 1;  /* equal */
-}
-
-/**
- * montgomery_mul_add_step() - Perform montgomery multiply-add step
- *
- * Operation: montgomery result[] += a * b[] / n0inv % modulus
- *
- * @key:       RSA key
- * @result:    Place to put result, as little endian word array
- * @a:         Multiplier
- * @b:         Multiplicand, as little endian word array
- */
-static void montgomery_mul_add_step(const struct rsa_public_key *key,
-               uint32_t result[], const uint32_t a, const uint32_t b[])
-{
-       uint64_t acc_a, acc_b;
-       uint32_t d0;
-       uint i;
-
-       acc_a = (uint64_t)a * b[0] + result[0];
-       d0 = (uint32_t)acc_a * key->n0inv;
-       acc_b = (uint64_t)d0 * key->modulus[0] + (uint32_t)acc_a;
-       for (i = 1; i < key->len; i++) {
-               acc_a = (acc_a >> 32) + (uint64_t)a * b[i] + result[i];
-               acc_b = (acc_b >> 32) + (uint64_t)d0 * key->modulus[i] +
-                               (uint32_t)acc_a;
-               result[i - 1] = (uint32_t)acc_b;
-       }
-
-       acc_a = (acc_a >> 32) + (acc_b >> 32);
-
-       result[i - 1] = (uint32_t)acc_a;
-
-       if (acc_a >> 32)
-               subtract_modulus(key, result);
-}
-
-/**
- * montgomery_mul() - Perform montgomery mutitply
+ * rsa_verify_key() - Verify a signature against some data using RSA Key
  *
- * Operation: montgomery result[] = a[] * b[] / n0inv % modulus
+ * Verify a RSA PKCS1.5 signature against an expected hash using
+ * the RSA Key properties in prop structure.
  *
- * @key:       RSA key
- * @result:    Place to put result, as little endian word array
- * @a:         Multiplier, as little endian word array
- * @b:         Multiplicand, as little endian word array
+ * @prop:      Specifies key
+ * @sig:       Signature
+ * @sig_len:   Number of bytes in signature
+ * @hash:      Pointer to the expected hash
+ * @algo:      Checksum algo structure having information on RSA padding etc.
+ * @return 0 if verified, -ve on error
  */
-static void montgomery_mul(const struct rsa_public_key *key,
-               uint32_t result[], uint32_t a[], const uint32_t b[])
-{
-       uint i;
-
-       for (i = 0; i < key->len; ++i)
-               result[i] = 0;
-       for (i = 0; i < key->len; ++i)
-               montgomery_mul_add_step(key, result, a[i], b);
-}
-
-/**
- * num_pub_exponent_bits() - Number of bits in the public exponent
- *
- * @key:       RSA key
- * @num_bits:  Storage for the number of public exponent bits
- */
-static int num_public_exponent_bits(const struct rsa_public_key *key,
-               int *num_bits)
-{
-       uint64_t exponent;
-       int exponent_bits;
-       const uint max_bits = (sizeof(exponent) * 8);
-
-       exponent = key->exponent;
-       exponent_bits = 0;
-
-       if (!exponent) {
-               *num_bits = exponent_bits;
-               return 0;
-       }
-
-       for (exponent_bits = 1; exponent_bits < max_bits + 1; ++exponent_bits)
-               if (!(exponent >>= 1)) {
-                       *num_bits = exponent_bits;
-                       return 0;
-               }
-
-       return -EINVAL;
-}
-
-/**
- * is_public_exponent_bit_set() - Check if a bit in the public exponent is set
- *
- * @key:       RSA key
- * @pos:       The bit position to check
- */
-static int is_public_exponent_bit_set(const struct rsa_public_key *key,
-               int pos)
-{
-       return key->exponent & (1ULL << pos);
-}
-
-/**
- * pow_mod() - in-place public exponentiation
- *
- * @key:       RSA key
- * @inout:     Big-endian word array containing value and result
- */
-static int pow_mod(const struct rsa_public_key *key, uint32_t *inout)
-{
-       uint32_t *result, *ptr;
-       uint i;
-       int j, k;
-
-       /* Sanity check for stack size - key->len is in 32-bit words */
-       if (key->len > RSA_MAX_KEY_BITS / 32) {
-               debug("RSA key words %u exceeds maximum %d\n", key->len,
-                     RSA_MAX_KEY_BITS / 32);
-               return -EINVAL;
-       }
-
-       uint32_t val[key->len], acc[key->len], tmp[key->len];
-       uint32_t a_scaled[key->len];
-       result = tmp;  /* Re-use location. */
-
-       /* Convert from big endian byte array to little endian word array. */
-       for (i = 0, ptr = inout + key->len - 1; i < key->len; i++, ptr--)
-               val[i] = get_unaligned_be32(ptr);
-
-       if (0 != num_public_exponent_bits(key, &k))
-               return -EINVAL;
-
-       if (k < 2) {
-               debug("Public exponent is too short (%d bits, minimum 2)\n",
-                     k);
-               return -EINVAL;
-       }
-
-       if (!is_public_exponent_bit_set(key, 0)) {
-               debug("LSB of RSA public exponent must be set.\n");
-               return -EINVAL;
-       }
-
-       /* the bit at e[k-1] is 1 by definition, so start with: C := M */
-       montgomery_mul(key, acc, val, key->rr); /* acc = a * RR / R mod n */
-       /* retain scaled version for intermediate use */
-       memcpy(a_scaled, acc, key->len * sizeof(a_scaled[0]));
-
-       for (j = k - 2; j > 0; --j) {
-               montgomery_mul(key, tmp, acc, acc); /* tmp = acc^2 / R mod n */
-
-               if (is_public_exponent_bit_set(key, j)) {
-                       /* acc = tmp * val / R mod n */
-                       montgomery_mul(key, acc, tmp, a_scaled);
-               } else {
-                       /* e[j] == 0, copy tmp back to acc for next operation */
-                       memcpy(acc, tmp, key->len * sizeof(acc[0]));
-               }
-       }
-
-       /* the bit at e[0] is always 1 */
-       montgomery_mul(key, tmp, acc, acc); /* tmp = acc^2 / R mod n */
-       montgomery_mul(key, acc, tmp, val); /* acc = tmp * a / R mod M */
-       memcpy(result, acc, key->len * sizeof(result[0]));
-
-       /* Make sure result < mod; result is at most 1x mod too large. */
-       if (greater_equal_modulus(key, result))
-               subtract_modulus(key, result);
-
-       /* Convert to bigendian byte array */
-       for (i = key->len - 1, ptr = inout; (int)i >= 0; i--, ptr++)
-               put_unaligned_be32(result[i], ptr);
-       return 0;
-}
-
-static int rsa_verify_key(const struct rsa_public_key *key, const uint8_t *sig,
+static int rsa_verify_key(struct key_prop *prop, const uint8_t *sig,
                          const uint32_t sig_len, const uint8_t *hash,
                          struct checksum_algo *algo)
 {
        const uint8_t *padding;
        int pad_len;
        int ret;
+#if !defined(USE_HOSTCC)
+       struct udevice *mod_exp_dev;
+#endif
 
-       if (!key || !sig || !hash || !algo)
+       if (!prop || !sig || !hash || !algo)
                return -EIO;
 
-       if (sig_len != (key->len * sizeof(uint32_t))) {
+       if (sig_len != (prop->num_bits / 8)) {
                debug("Signature is of incorrect length %d\n", sig_len);
                return -EINVAL;
        }
@@ -265,13 +65,23 @@ static int rsa_verify_key(const struct rsa_public_key *key, const uint8_t *sig,
                return -EINVAL;
        }
 
-       uint32_t buf[sig_len / sizeof(uint32_t)];
+       uint8_t buf[sig_len];
 
-       memcpy(buf, sig, sig_len);
+#if !defined(USE_HOSTCC)
+       ret = uclass_get_device(UCLASS_MOD_EXP, 0, &mod_exp_dev);
+       if (ret) {
+               printf("RSA: Can't find Modular Exp implementation\n");
+               return -EINVAL;
+       }
 
-       ret = pow_mod(key, buf);
-       if (ret)
+       ret = rsa_mod_exp(mod_exp_dev, sig, sig_len, prop, buf);
+#else
+       ret = rsa_mod_exp_sw(sig, sig_len, prop, buf);
+#endif
+       if (ret) {
+               debug("Error in Modular exponentation\n");
                return ret;
+       }
 
        padding = algo->rsa_padding;
        pad_len = algo->pad_len - algo->checksum_len;
@@ -291,72 +101,57 @@ static int rsa_verify_key(const struct rsa_public_key *key, const uint8_t *sig,
        return 0;
 }
 
-static void rsa_convert_big_endian(uint32_t *dst, const uint32_t *src, int len)
-{
-       int i;
-
-       for (i = 0; i < len; i++)
-               dst[i] = fdt32_to_cpu(src[len - 1 - i]);
-}
-
+/**
+ * rsa_verify_with_keynode() - Verify a signature against some data using
+ * information in node with prperties of RSA Key like modulus, exponent etc.
+ *
+ * Parse sign-node and fill a key_prop structure with properties of the
+ * key.  Verify a RSA PKCS1.5 signature against an expected hash using
+ * the properties parsed
+ *
+ * @info:      Specifies key and FIT information
+ * @hash:      Pointer to the expected hash
+ * @sig:       Signature
+ * @sig_len:   Number of bytes in signature
+ * @node:      Node having the RSA Key properties
+ * @return 0 if verified, -ve on error
+ */
 static int rsa_verify_with_keynode(struct image_sign_info *info,
-               const void *hash, uint8_t *sig, uint sig_len, int node)
+                                  const void *hash, uint8_t *sig,
+                                  uint sig_len, int node)
 {
        const void *blob = info->fdt_blob;
-       struct rsa_public_key key;
-       const void *modulus, *rr;
-       const uint64_t *public_exponent;
+       struct key_prop prop;
        int length;
-       int ret;
+       int ret = 0;
 
        if (node < 0) {
                debug("%s: Skipping invalid node", __func__);
                return -EBADF;
        }
-       if (!fdt_getprop(blob, node, "rsa,n0-inverse", NULL)) {
-               debug("%s: Missing rsa,n0-inverse", __func__);
-               return -EFAULT;
-       }
-       key.len = fdtdec_get_int(blob, node, "rsa,num-bits", 0);
-       key.n0inv = fdtdec_get_int(blob, node, "rsa,n0-inverse", 0);
-       public_exponent = fdt_getprop(blob, node, "rsa,exponent", &length);
-       if (!public_exponent || length < sizeof(*public_exponent))
-               key.exponent = RSA_DEFAULT_PUBEXP;
-       else
-               key.exponent = fdt64_to_cpu(*public_exponent);
-       modulus = fdt_getprop(blob, node, "rsa,modulus", NULL);
-       rr = fdt_getprop(blob, node, "rsa,r-squared", NULL);
-       if (!key.len || !modulus || !rr) {
-               debug("%s: Missing RSA key info", __func__);
-               return -EFAULT;
-       }
 
-       /* Sanity check for stack size */
-       if (key.len > RSA_MAX_KEY_BITS || key.len < RSA_MIN_KEY_BITS) {
-               debug("RSA key bits %u outside allowed range %d..%d\n",
-                     key.len, RSA_MIN_KEY_BITS, RSA_MAX_KEY_BITS);
+       prop.num_bits = fdtdec_get_int(blob, node, "rsa,num-bits", 0);
+
+       prop.n0inv = fdtdec_get_int(blob, node, "rsa,n0-inverse", 0);
+
+       prop.public_exponent = fdt_getprop(blob, node, "rsa,exponent", &length);
+       if (!prop.public_exponent || length < sizeof(uint64_t))
+               prop.public_exponent = NULL;
+
+       prop.exp_len = sizeof(uint64_t);
+
+       prop.modulus = fdt_getprop(blob, node, "rsa,modulus", NULL);
+
+       prop.rr = fdt_getprop(blob, node, "rsa,r-squared", NULL);
+
+       if (!prop.num_bits || !prop.modulus) {
+               debug("%s: Missing RSA key info", __func__);
                return -EFAULT;
        }
-       key.len /= sizeof(uint32_t) * 8;
-       uint32_t key1[key.len], key2[key.len];
-
-       key.modulus = key1;
-       key.rr = key2;
-       rsa_convert_big_endian(key.modulus, modulus, key.len);
-       rsa_convert_big_endian(key.rr, rr, key.len);
-       if (!key.modulus || !key.rr) {
-               debug("%s: Out of memory", __func__);
-               return -ENOMEM;
-       }
 
-       debug("key length %d\n", key.len);
-       ret = rsa_verify_key(&key, sig, sig_len, hash, info->algo->checksum);
-       if (ret) {
-               printf("%s: RSA failed to verify: %d\n", __func__, ret);
-               return ret;
-       }
+       ret = rsa_verify_key(&prop, sig, sig_len, hash, info->algo->checksum);
 
-       return 0;
+       return ret;
 }
 
 int rsa_verify(struct image_sign_info *info,
@@ -389,7 +184,12 @@ int rsa_verify(struct image_sign_info *info,
        }
 
        /* Calculate checksum with checksum-algorithm */
-       info->algo->checksum->calculate(region, region_count, hash);
+       ret = info->algo->checksum->calculate(info->algo->checksum->name,
+                                       region, region_count, hash);
+       if (ret < 0) {
+               debug("%s: Error in checksum calculation\n", __func__);
+               return -EINVAL;
+       }
 
        /* See if we must use a particular key */
        if (info->required_keynode != -1) {
index 942595021dad1cf3fccb27531bde72e20e0acd88..e9cc8ada96a783ae18444c9f68a107bede6e0054 100644 (file)
@@ -7,6 +7,7 @@
 
 #ccflags-y += -DDEBUG
 
+obj-y += checksum.o
 obj-$(CONFIG_CMD_NET)  += arp.o
 obj-$(CONFIG_CMD_NET)  += bootp.o
 obj-$(CONFIG_CMD_CDP)  += cdp.o
diff --git a/net/checksum.c b/net/checksum.c
new file mode 100644 (file)
index 0000000..a8c9ff5
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * This file was originally taken from the FreeBSD project.
+ *
+ * Copyright (c) 2001 Charles Mott <cm@linktel.net>
+ * Copyright (c) 2008 coresystems GmbH
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier:    BSD-2-Clause
+ */
+
+#include <common.h>
+#include <net.h>
+
+unsigned compute_ip_checksum(const void *vptr, unsigned nbytes)
+{
+       int sum, oddbyte;
+       const unsigned short *ptr = vptr;
+
+       sum = 0;
+       while (nbytes > 1) {
+               sum += *ptr++;
+               nbytes -= 2;
+       }
+       if (nbytes == 1) {
+               oddbyte = 0;
+               ((u8 *)&oddbyte)[0] = *(u8 *)ptr;
+               ((u8 *)&oddbyte)[1] = 0;
+               sum += oddbyte;
+       }
+       sum = (sum >> 16) + (sum & 0xffff);
+       sum += (sum >> 16);
+       sum = ~sum & 0xffff;
+
+       return sum;
+}
+
+unsigned add_ip_checksums(unsigned offset, unsigned sum, unsigned new)
+{
+       unsigned long checksum;
+
+       sum = ~sum & 0xffff;
+       new = ~new & 0xffff;
+       if (offset & 1) {
+               /*
+                * byte-swap the sum if it came from an odd offset; since the
+                * computation is endian independant this works.
+                */
+               new = ((new >> 8) & 0xff) | ((new << 8) & 0xff00);
+       }
+       checksum = sum + new;
+       if (checksum > 0xffff)
+               checksum -= 0xffff;
+
+       return (~checksum) & 0xffff;
+}
+
+int ip_checksum_ok(const void *addr, unsigned nbytes)
+{
+       return !(compute_ip_checksum(addr, nbytes) & 0xfffe);
+}
index ecf3037cb89b032712f6ba9c9bf673664ed4fa96..e4b98811867da5d6ce753cbe578d187caaaf60b5 100644 (file)
@@ -57,6 +57,7 @@ libs-$(CONFIG_SPL_I2C_SUPPORT) += drivers/i2c/
 libs-$(CONFIG_SPL_GPIO_SUPPORT) += drivers/gpio/
 libs-$(CONFIG_SPL_MMC_SUPPORT) += drivers/mmc/
 libs-$(CONFIG_SPL_MPC8XXX_INIT_DDR_SUPPORT) += drivers/ddr/fsl/
+libs-$(CONFIG_SYS_MVEBU_DDR) += drivers/ddr/mvebu/
 libs-$(CONFIG_SPL_SERIAL_SUPPORT) += drivers/serial/
 libs-$(CONFIG_SPL_SPI_FLASH_SUPPORT) += drivers/mtd/spi/
 libs-$(CONFIG_SPL_SPI_SUPPORT) += drivers/spi/
index abbaccff509ce09374f30e88983252672d3c4e62..faffe6a385b6f8ef9ee066ac705d959993232226 100644 (file)
@@ -9,11 +9,18 @@
 #include <dm/device-internal.h>
 #include <dm/root.h>
 #include <dm/test.h>
+#include <dm/uclass-internal.h>
 #include <dm/ut.h>
 #include <dm/util.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
+struct dm_test_parent_platdata {
+       int count;
+       int bind_flag;
+       int uclass_bind_flag;
+};
+
 enum {
        FLAG_CHILD_PROBED       = 10,
        FLAG_CHILD_REMOVED      = -7,
@@ -26,6 +33,17 @@ static int testbus_drv_probe(struct udevice *dev)
        return dm_scan_fdt_node(dev, gd->fdt_blob, dev->of_offset, false);
 }
 
+static int testbus_child_post_bind(struct udevice *dev)
+{
+       struct dm_test_parent_platdata *plat;
+
+       plat = dev_get_parent_platdata(dev);
+       plat->bind_flag = 1;
+       plat->uclass_bind_flag = 2;
+
+       return 0;
+}
+
 static int testbus_child_pre_probe(struct udevice *dev)
 {
        struct dm_test_parent_data *parent_data = dev_get_parentdata(dev);
@@ -35,6 +53,15 @@ static int testbus_child_pre_probe(struct udevice *dev)
        return 0;
 }
 
+static int testbus_child_pre_probe_uclass(struct udevice *dev)
+{
+       struct dm_test_priv *priv = dev_get_priv(dev);
+
+       priv->uclass_flag++;
+
+       return 0;
+}
+
 static int testbus_child_post_remove(struct udevice *dev)
 {
        struct dm_test_parent_data *parent_data = dev_get_parentdata(dev);
@@ -59,9 +86,12 @@ U_BOOT_DRIVER(testbus_drv) = {
        .of_match       = testbus_ids,
        .id     = UCLASS_TEST_BUS,
        .probe  = testbus_drv_probe,
+       .child_post_bind = testbus_child_post_bind,
        .priv_auto_alloc_size = sizeof(struct dm_test_priv),
        .platdata_auto_alloc_size = sizeof(struct dm_test_pdata),
        .per_child_auto_alloc_size = sizeof(struct dm_test_parent_data),
+       .per_child_platdata_auto_alloc_size =
+                       sizeof(struct dm_test_parent_platdata),
        .child_pre_probe = testbus_child_pre_probe,
        .child_post_remove = testbus_child_post_remove,
 };
@@ -69,12 +99,14 @@ U_BOOT_DRIVER(testbus_drv) = {
 UCLASS_DRIVER(testbus) = {
        .name           = "testbus",
        .id             = UCLASS_TEST_BUS,
+       .flags          = DM_UC_FLAG_SEQ_ALIAS,
+       .child_pre_probe = testbus_child_pre_probe_uclass,
 };
 
 /* Test that we can probe for children */
 static int dm_test_bus_children(struct dm_test_state *dms)
 {
-       int num_devices = 4;
+       int num_devices = 6;
        struct udevice *bus;
        struct uclass *uc;
 
@@ -172,7 +204,7 @@ DM_TEST(dm_test_bus_children_iterators,
        DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
 
 /* Test that the bus can store data about each child */
-static int dm_test_bus_parent_data(struct dm_test_state *dms)
+static int test_bus_parent_data(struct dm_test_state *dms)
 {
        struct dm_test_parent_data *parent_data;
        struct udevice *bus, *dev;
@@ -231,9 +263,36 @@ static int dm_test_bus_parent_data(struct dm_test_state *dms)
 
        return 0;
 }
-
+/* Test that the bus can store data about each child */
+static int dm_test_bus_parent_data(struct dm_test_state *dms)
+{
+       return test_bus_parent_data(dms);
+}
 DM_TEST(dm_test_bus_parent_data, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
 
+/* As above but the size is controlled by the uclass */
+static int dm_test_bus_parent_data_uclass(struct dm_test_state *dms)
+{
+       struct udevice *bus;
+       int size;
+       int ret;
+
+       /* Set the driver size to 0 so that the uclass size is used */
+       ut_assertok(uclass_find_device(UCLASS_TEST_BUS, 0, &bus));
+       size = bus->driver->per_child_auto_alloc_size;
+       bus->uclass->uc_drv->per_child_auto_alloc_size = size;
+       bus->driver->per_child_auto_alloc_size = 0;
+       ret = test_bus_parent_data(dms);
+       if (ret)
+               return ret;
+       bus->uclass->uc_drv->per_child_auto_alloc_size = 0;
+       bus->driver->per_child_auto_alloc_size = size;
+
+       return 0;
+}
+DM_TEST(dm_test_bus_parent_data_uclass,
+       DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+
 /* Test that the bus ops are called when a child is probed/removed */
 static int dm_test_bus_parent_ops(struct dm_test_state *dms)
 {
@@ -271,3 +330,188 @@ static int dm_test_bus_parent_ops(struct dm_test_state *dms)
        return 0;
 }
 DM_TEST(dm_test_bus_parent_ops, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+
+static int test_bus_parent_platdata(struct dm_test_state *dms)
+{
+       struct dm_test_parent_platdata *plat;
+       struct udevice *bus, *dev;
+       int child_count;
+
+       /* Check that the bus has no children */
+       ut_assertok(uclass_find_device(UCLASS_TEST_BUS, 0, &bus));
+       device_find_first_child(bus, &dev);
+       ut_asserteq_ptr(NULL, dev);
+
+       ut_assertok(uclass_get_device(UCLASS_TEST_BUS, 0, &bus));
+
+       for (device_find_first_child(bus, &dev), child_count = 0;
+            dev;
+            device_find_next_child(&dev)) {
+               /* Check that platform data is allocated */
+               plat = dev_get_parent_platdata(dev);
+               ut_assert(plat != NULL);
+
+               /*
+                * Check that it is not affected by the device being
+                * probed/removed
+                */
+               plat->count++;
+               ut_asserteq(1, plat->count);
+               device_probe(dev);
+               device_remove(dev);
+
+               ut_asserteq_ptr(plat, dev_get_parent_platdata(dev));
+               ut_asserteq(1, plat->count);
+               ut_assertok(device_probe(dev));
+               child_count++;
+       }
+       ut_asserteq(3, child_count);
+
+       /* Removing the bus should also have no effect (it is still bound) */
+       device_remove(bus);
+       for (device_find_first_child(bus, &dev), child_count = 0;
+            dev;
+            device_find_next_child(&dev)) {
+               /* Check that platform data is allocated */
+               plat = dev_get_parent_platdata(dev);
+               ut_assert(plat != NULL);
+               ut_asserteq(1, plat->count);
+               child_count++;
+       }
+       ut_asserteq(3, child_count);
+
+       /* Unbind all the children */
+       do {
+               device_find_first_child(bus, &dev);
+               if (dev)
+                       device_unbind(dev);
+       } while (dev);
+
+       /* Now the child platdata should be removed and re-added */
+       device_probe(bus);
+       for (device_find_first_child(bus, &dev), child_count = 0;
+            dev;
+            device_find_next_child(&dev)) {
+               /* Check that platform data is allocated */
+               plat = dev_get_parent_platdata(dev);
+               ut_assert(plat != NULL);
+               ut_asserteq(0, plat->count);
+               child_count++;
+       }
+       ut_asserteq(3, child_count);
+
+       return 0;
+}
+
+/* Test that the bus can store platform data about each child */
+static int dm_test_bus_parent_platdata(struct dm_test_state *dms)
+{
+       return test_bus_parent_platdata(dms);
+}
+DM_TEST(dm_test_bus_parent_platdata, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+
+/* As above but the size is controlled by the uclass */
+static int dm_test_bus_parent_platdata_uclass(struct dm_test_state *dms)
+{
+       struct udevice *bus;
+       int size;
+       int ret;
+
+       /* Set the driver size to 0 so that the uclass size is used */
+       ut_assertok(uclass_find_device(UCLASS_TEST_BUS, 0, &bus));
+       size = bus->driver->per_child_platdata_auto_alloc_size;
+       bus->uclass->uc_drv->per_child_platdata_auto_alloc_size = size;
+       bus->driver->per_child_platdata_auto_alloc_size = 0;
+       ret = test_bus_parent_platdata(dms);
+       if (ret)
+               return ret;
+       bus->uclass->uc_drv->per_child_platdata_auto_alloc_size = 0;
+       bus->driver->per_child_platdata_auto_alloc_size = size;
+
+       return 0;
+}
+DM_TEST(dm_test_bus_parent_platdata_uclass,
+       DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+
+/* Test that the child post_bind method is called */
+static int dm_test_bus_child_post_bind(struct dm_test_state *dms)
+{
+       struct dm_test_parent_platdata *plat;
+       struct udevice *bus, *dev;
+       int child_count;
+
+       ut_assertok(uclass_get_device(UCLASS_TEST_BUS, 0, &bus));
+       for (device_find_first_child(bus, &dev), child_count = 0;
+            dev;
+            device_find_next_child(&dev)) {
+               /* Check that platform data is allocated */
+               plat = dev_get_parent_platdata(dev);
+               ut_assert(plat != NULL);
+               ut_asserteq(1, plat->bind_flag);
+               child_count++;
+       }
+       ut_asserteq(3, child_count);
+
+       return 0;
+}
+DM_TEST(dm_test_bus_child_post_bind, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+
+/* Test that the child post_bind method is called */
+static int dm_test_bus_child_post_bind_uclass(struct dm_test_state *dms)
+{
+       struct dm_test_parent_platdata *plat;
+       struct udevice *bus, *dev;
+       int child_count;
+
+       ut_assertok(uclass_get_device(UCLASS_TEST_BUS, 0, &bus));
+       for (device_find_first_child(bus, &dev), child_count = 0;
+            dev;
+            device_find_next_child(&dev)) {
+               /* Check that platform data is allocated */
+               plat = dev_get_parent_platdata(dev);
+               ut_assert(plat != NULL);
+               ut_asserteq(2, plat->uclass_bind_flag);
+               child_count++;
+       }
+       ut_asserteq(3, child_count);
+
+       return 0;
+}
+DM_TEST(dm_test_bus_child_post_bind_uclass,
+       DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+
+/*
+ * Test that the bus' uclass' child_pre_probe() is called before the
+ * device's probe() method
+ */
+static int dm_test_bus_child_pre_probe_uclass(struct dm_test_state *dms)
+{
+       struct udevice *bus, *dev;
+       int child_count;
+
+       /*
+        * See testfdt_drv_probe() which effectively checks that the uclass
+        * flag is set before that method is called
+        */
+       ut_assertok(uclass_get_device(UCLASS_TEST_BUS, 0, &bus));
+       for (device_find_first_child(bus, &dev), child_count = 0;
+            dev;
+            device_find_next_child(&dev)) {
+               struct dm_test_priv *priv = dev_get_priv(dev);
+
+               /* Check that things happened in the right order */
+               ut_asserteq_ptr(NULL, priv);
+               ut_assertok(device_probe(dev));
+
+               priv = dev_get_priv(dev);
+               ut_assert(priv != NULL);
+               ut_asserteq(1, priv->uclass_flag);
+               ut_asserteq(1, priv->uclass_total);
+               child_count++;
+       }
+       ut_asserteq(3, child_count);
+
+       return 0;
+}
+DM_TEST(dm_test_bus_child_pre_probe_uclass,
+       DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
index ff5c2a749c5e37dbbcca5340dabdf18374a8e5c2..eccda0974da6d6effbdd931c75dff71f36bdaaf6 100644 (file)
@@ -598,3 +598,14 @@ static int dm_test_uclass_before_ready(struct dm_test_state *dms)
 }
 
 DM_TEST(dm_test_uclass_before_ready, 0);
+
+static int dm_test_device_get_uclass_id(struct dm_test_state *dms)
+{
+       struct udevice *dev;
+
+       ut_assertok(uclass_get_device(UCLASS_TEST, 0, &dev));
+       ut_asserteq(UCLASS_TEST, device_get_uclass_id(dev));
+
+       return 0;
+}
+DM_TEST(dm_test_device_get_uclass_id, DM_TESTF_SCAN_PDATA);
index 94bd0d99dc0bc1fa9b5c7033690ab6de7cc29b41..b29daf1af4e238e6d3952f3058191bce3c5a1bb8 100644 (file)
@@ -174,5 +174,72 @@ static int dm_test_gpio_leak(struct dm_test_state *dms)
 
        return 0;
 }
-
 DM_TEST(dm_test_gpio_leak, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+
+/* Test that we can find GPIOs using phandles */
+static int dm_test_gpio_phandles(struct dm_test_state *dms)
+{
+       struct gpio_desc desc, desc_list[8], desc_list2[8];
+       struct udevice *dev, *gpio_a, *gpio_b;
+
+       ut_assertok(uclass_get_device(UCLASS_TEST_FDT, 0, &dev));
+       ut_asserteq_str("a-test", dev->name);
+
+       ut_assertok(gpio_request_by_name(dev, "test-gpios", 1, &desc, 0));
+       ut_assertok(uclass_get_device(UCLASS_GPIO, 1, &gpio_a));
+       ut_assertok(uclass_get_device(UCLASS_GPIO, 2, &gpio_b));
+       ut_asserteq_str("base-gpios", gpio_a->name);
+       ut_asserteq(true, !!device_active(gpio_a));
+       ut_asserteq_ptr(gpio_a, desc.dev);
+       ut_asserteq(4, desc.offset);
+       /* GPIOF_INPUT is the sandbox GPIO driver default */
+       ut_asserteq(GPIOF_INPUT, gpio_get_function(gpio_a, 4, NULL));
+       ut_assertok(dm_gpio_free(dev, &desc));
+
+       ut_asserteq(-ENOENT, gpio_request_by_name(dev, "test-gpios", 3, &desc,
+                                                 0));
+       ut_asserteq_ptr(NULL, desc.dev);
+       ut_asserteq(desc.offset, 0);
+       ut_asserteq(-ENOENT, gpio_request_by_name(dev, "test-gpios", 5, &desc,
+                                                 0));
+
+       /* Last GPIO is ignord as it comes after <0> */
+       ut_asserteq(3, gpio_request_list_by_name(dev, "test-gpios", desc_list,
+                                                ARRAY_SIZE(desc_list), 0));
+       ut_asserteq(-EBUSY, gpio_request_list_by_name(dev, "test-gpios",
+                                                     desc_list2,
+                                                     ARRAY_SIZE(desc_list2),
+                                                     0));
+       ut_assertok(gpio_free_list(dev, desc_list, 3));
+       ut_asserteq(3, gpio_request_list_by_name(dev,  "test-gpios", desc_list,
+                                                ARRAY_SIZE(desc_list),
+                                                GPIOD_IS_OUT |
+                                                GPIOD_IS_OUT_ACTIVE));
+       ut_asserteq_ptr(gpio_a, desc_list[0].dev);
+       ut_asserteq(1, desc_list[0].offset);
+       ut_asserteq_ptr(gpio_a, desc_list[1].dev);
+       ut_asserteq(4, desc_list[1].offset);
+       ut_asserteq_ptr(gpio_b, desc_list[2].dev);
+       ut_asserteq(5, desc_list[2].offset);
+       ut_asserteq(1, dm_gpio_get_value(desc_list));
+       ut_assertok(gpio_free_list(dev, desc_list, 3));
+
+       ut_asserteq(6, gpio_request_list_by_name(dev, "test2-gpios", desc_list,
+                                                ARRAY_SIZE(desc_list), 0));
+       /* This was set to output previously, so still will be */
+       ut_asserteq(GPIOF_OUTPUT, gpio_get_function(gpio_a, 1, NULL));
+
+       /* Active low should invert the input value */
+       ut_asserteq(GPIOF_INPUT, gpio_get_function(gpio_b, 6, NULL));
+       ut_asserteq(1, dm_gpio_get_value(&desc_list[2]));
+
+       ut_asserteq(GPIOF_INPUT, gpio_get_function(gpio_b, 7, NULL));
+       ut_asserteq(GPIOF_OUTPUT, gpio_get_function(gpio_b, 8, NULL));
+       ut_asserteq(0, dm_gpio_get_value(&desc_list[4]));
+       ut_asserteq(GPIOF_OUTPUT, gpio_get_function(gpio_b, 9, NULL));
+       ut_asserteq(1, dm_gpio_get_value(&desc_list[5]));
+
+
+       return 0;
+}
+DM_TEST(dm_test_gpio_phandles, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
index a53e28dbe5dc528172811f24bb9dce3909365860..ef88372d56361ab40186a34787cc6c7a8e0c40d4 100644 (file)
@@ -35,8 +35,8 @@ static int dm_test_i2c_find(struct dm_test_state *dms)
         * remove the emulation and the slave device.
         */
        ut_assertok(uclass_get_device_by_seq(UCLASS_I2C, busnum, &bus));
-       ut_assertok(i2c_probe(bus, chip, 0, &dev));
-       ut_asserteq(-ENODEV, i2c_probe(bus, no_chip, 0, &dev));
+       ut_assertok(dm_i2c_probe(bus, chip, 0, &dev));
+       ut_asserteq(-ENODEV, dm_i2c_probe(bus, no_chip, 0, &dev));
        ut_asserteq(-ENODEV, uclass_get_device_by_seq(UCLASS_I2C, 1, &bus));
 
        return 0;
@@ -49,11 +49,11 @@ static int dm_test_i2c_read_write(struct dm_test_state *dms)
        uint8_t buf[5];
 
        ut_assertok(uclass_get_device_by_seq(UCLASS_I2C, busnum, &bus));
-       ut_assertok(i2c_get_chip(bus, chip, &dev));
-       ut_assertok(i2c_read(dev, 0, buf, 5));
+       ut_assertok(i2c_get_chip(bus, chip, 1, &dev));
+       ut_assertok(dm_i2c_read(dev, 0, buf, 5));
        ut_assertok(memcmp(buf, "\0\0\0\0\0", sizeof(buf)));
-       ut_assertok(i2c_write(dev, 2, (uint8_t *)"AB", 2));
-       ut_assertok(i2c_read(dev, 0, buf, 5));
+       ut_assertok(dm_i2c_write(dev, 2, (uint8_t *)"AB", 2));
+       ut_assertok(dm_i2c_read(dev, 0, buf, 5));
        ut_assertok(memcmp(buf, "\0\0AB\0", sizeof(buf)));
 
        return 0;
@@ -66,13 +66,13 @@ static int dm_test_i2c_speed(struct dm_test_state *dms)
        uint8_t buf[5];
 
        ut_assertok(uclass_get_device_by_seq(UCLASS_I2C, busnum, &bus));
-       ut_assertok(i2c_get_chip(bus, chip, &dev));
+       ut_assertok(i2c_get_chip(bus, chip, 1, &dev));
        ut_assertok(i2c_set_bus_speed(bus, 100000));
-       ut_assertok(i2c_read(dev, 0, buf, 5));
+       ut_assertok(dm_i2c_read(dev, 0, buf, 5));
        ut_assertok(i2c_set_bus_speed(bus, 400000));
        ut_asserteq(400000, i2c_get_bus_speed(bus));
-       ut_assertok(i2c_read(dev, 0, buf, 5));
-       ut_asserteq(-EINVAL, i2c_write(dev, 0, buf, 5));
+       ut_assertok(dm_i2c_read(dev, 0, buf, 5));
+       ut_asserteq(-EINVAL, dm_i2c_write(dev, 0, buf, 5));
 
        return 0;
 }
@@ -84,9 +84,9 @@ static int dm_test_i2c_offset_len(struct dm_test_state *dms)
        uint8_t buf[5];
 
        ut_assertok(uclass_get_device_by_seq(UCLASS_I2C, busnum, &bus));
-       ut_assertok(i2c_get_chip(bus, chip, &dev));
+       ut_assertok(i2c_get_chip(bus, chip, 1, &dev));
        ut_assertok(i2c_set_chip_offset_len(dev, 1));
-       ut_assertok(i2c_read(dev, 0, buf, 5));
+       ut_assertok(dm_i2c_read(dev, 0, buf, 5));
 
        /* This is not supported by the uclass */
        ut_asserteq(-EINVAL, i2c_set_chip_offset_len(dev, 5));
@@ -100,7 +100,7 @@ static int dm_test_i2c_probe_empty(struct dm_test_state *dms)
        struct udevice *bus, *dev;
 
        ut_assertok(uclass_get_device_by_seq(UCLASS_I2C, busnum, &bus));
-       ut_assertok(i2c_probe(bus, SANDBOX_I2C_TEST_ADDR, 0, &dev));
+       ut_assertok(dm_i2c_probe(bus, SANDBOX_I2C_TEST_ADDR, 0, &dev));
 
        return 0;
 }
@@ -113,8 +113,8 @@ static int dm_test_i2c_bytewise(struct dm_test_state *dms)
        uint8_t buf[5];
 
        ut_assertok(uclass_get_device_by_seq(UCLASS_I2C, busnum, &bus));
-       ut_assertok(i2c_get_chip(bus, chip, &dev));
-       ut_assertok(i2c_read(dev, 0, buf, 5));
+       ut_assertok(i2c_get_chip(bus, chip, 1, &dev));
+       ut_assertok(dm_i2c_read(dev, 0, buf, 5));
        ut_assertok(memcmp(buf, "\0\0\0\0\0", sizeof(buf)));
 
        /* Tell the EEPROM to only read/write one register at a time */
@@ -123,34 +123,34 @@ static int dm_test_i2c_bytewise(struct dm_test_state *dms)
        sandbox_i2c_eeprom_set_test_mode(eeprom, SIE_TEST_MODE_SINGLE_BYTE);
 
        /* Now we only get the first byte - the rest will be 0xff */
-       ut_assertok(i2c_read(dev, 0, buf, 5));
+       ut_assertok(dm_i2c_read(dev, 0, buf, 5));
        ut_assertok(memcmp(buf, "\0\xff\xff\xff\xff", sizeof(buf)));
 
        /* If we do a separate transaction for each byte, it works */
        ut_assertok(i2c_set_chip_flags(dev, DM_I2C_CHIP_RD_ADDRESS));
-       ut_assertok(i2c_read(dev, 0, buf, 5));
+       ut_assertok(dm_i2c_read(dev, 0, buf, 5));
        ut_assertok(memcmp(buf, "\0\0\0\0\0", sizeof(buf)));
 
        /* This will only write A */
        ut_assertok(i2c_set_chip_flags(dev, 0));
-       ut_assertok(i2c_write(dev, 2, (uint8_t *)"AB", 2));
-       ut_assertok(i2c_read(dev, 0, buf, 5));
+       ut_assertok(dm_i2c_write(dev, 2, (uint8_t *)"AB", 2));
+       ut_assertok(dm_i2c_read(dev, 0, buf, 5));
        ut_assertok(memcmp(buf, "\0\xff\xff\xff\xff", sizeof(buf)));
 
        /* Check that the B was ignored */
        ut_assertok(i2c_set_chip_flags(dev, DM_I2C_CHIP_RD_ADDRESS));
-       ut_assertok(i2c_read(dev, 0, buf, 5));
+       ut_assertok(dm_i2c_read(dev, 0, buf, 5));
        ut_assertok(memcmp(buf, "\0\0A\0\0\0", sizeof(buf)));
 
        /* Now write it again with the new flags, it should work */
        ut_assertok(i2c_set_chip_flags(dev, DM_I2C_CHIP_WR_ADDRESS));
-       ut_assertok(i2c_write(dev, 2, (uint8_t *)"AB", 2));
-       ut_assertok(i2c_read(dev, 0, buf, 5));
+       ut_assertok(dm_i2c_write(dev, 2, (uint8_t *)"AB", 2));
+       ut_assertok(dm_i2c_read(dev, 0, buf, 5));
        ut_assertok(memcmp(buf, "\0\xff\xff\xff\xff", sizeof(buf)));
 
        ut_assertok(i2c_set_chip_flags(dev, DM_I2C_CHIP_WR_ADDRESS |
                                                DM_I2C_CHIP_RD_ADDRESS));
-       ut_assertok(i2c_read(dev, 0, buf, 5));
+       ut_assertok(dm_i2c_read(dev, 0, buf, 5));
        ut_assertok(memcmp(buf, "\0\0AB\0\0", sizeof(buf)));
 
        /* Restore defaults */
@@ -167,45 +167,45 @@ static int dm_test_i2c_offset(struct dm_test_state *dms)
        struct udevice *dev;
        uint8_t buf[5];
 
-       ut_assertok(i2c_get_chip_for_busnum(busnum, chip, &dev));
+       ut_assertok(i2c_get_chip_for_busnum(busnum, chip, 1, &dev));
 
        /* Do a transfer so we can find the emulator */
-       ut_assertok(i2c_read(dev, 0, buf, 5));
+       ut_assertok(dm_i2c_read(dev, 0, buf, 5));
        ut_assertok(uclass_first_device(UCLASS_I2C_EMUL, &eeprom));
 
        /* Offset length 0 */
        sandbox_i2c_eeprom_set_offset_len(eeprom, 0);
        ut_assertok(i2c_set_chip_offset_len(dev, 0));
-       ut_assertok(i2c_write(dev, 10 /* ignored */, (uint8_t *)"AB", 2));
-       ut_assertok(i2c_read(dev, 0, buf, 5));
+       ut_assertok(dm_i2c_write(dev, 10 /* ignored */, (uint8_t *)"AB", 2));
+       ut_assertok(dm_i2c_read(dev, 0, buf, 5));
        ut_assertok(memcmp(buf, "AB\0\0\0\0", sizeof(buf)));
 
        /* Offset length 1 */
        sandbox_i2c_eeprom_set_offset_len(eeprom, 1);
        ut_assertok(i2c_set_chip_offset_len(dev, 1));
-       ut_assertok(i2c_write(dev, 2, (uint8_t *)"AB", 2));
-       ut_assertok(i2c_read(dev, 0, buf, 5));
+       ut_assertok(dm_i2c_write(dev, 2, (uint8_t *)"AB", 2));
+       ut_assertok(dm_i2c_read(dev, 0, buf, 5));
        ut_assertok(memcmp(buf, "ABAB\0", sizeof(buf)));
 
        /* Offset length 2 */
        sandbox_i2c_eeprom_set_offset_len(eeprom, 2);
        ut_assertok(i2c_set_chip_offset_len(dev, 2));
-       ut_assertok(i2c_write(dev, 0x210, (uint8_t *)"AB", 2));
-       ut_assertok(i2c_read(dev, 0x210, buf, 5));
+       ut_assertok(dm_i2c_write(dev, 0x210, (uint8_t *)"AB", 2));
+       ut_assertok(dm_i2c_read(dev, 0x210, buf, 5));
        ut_assertok(memcmp(buf, "AB\0\0\0", sizeof(buf)));
 
        /* Offset length 3 */
        sandbox_i2c_eeprom_set_offset_len(eeprom, 2);
        ut_assertok(i2c_set_chip_offset_len(dev, 2));
-       ut_assertok(i2c_write(dev, 0x410, (uint8_t *)"AB", 2));
-       ut_assertok(i2c_read(dev, 0x410, buf, 5));
+       ut_assertok(dm_i2c_write(dev, 0x410, (uint8_t *)"AB", 2));
+       ut_assertok(dm_i2c_read(dev, 0x410, buf, 5));
        ut_assertok(memcmp(buf, "AB\0\0\0", sizeof(buf)));
 
        /* Offset length 4 */
        sandbox_i2c_eeprom_set_offset_len(eeprom, 2);
        ut_assertok(i2c_set_chip_offset_len(dev, 2));
-       ut_assertok(i2c_write(dev, 0x420, (uint8_t *)"AB", 2));
-       ut_assertok(i2c_read(dev, 0x420, buf, 5));
+       ut_assertok(dm_i2c_write(dev, 0x420, (uint8_t *)"AB", 2));
+       ut_assertok(dm_i2c_read(dev, 0x420, buf, 5));
        ut_assertok(memcmp(buf, "AB\0\0\0", sizeof(buf)));
 
        /* Restore defaults */
index 61b5b2548c42e4e9895ef95345b5e9e99bc9c52a..c7ee65207b0472d3d360e26a7a87629849544c29 100644 (file)
@@ -36,7 +36,6 @@ static int dm_test_spi_find(struct dm_test_state *dms)
        ut_asserteq(0, uclass_get_device_by_seq(UCLASS_SPI, busnum, &bus));
        ut_assertok(spi_cs_info(bus, cs, &info));
        of_offset = info.dev->of_offset;
-       sandbox_sf_unbind_emul(state_get_current(), busnum, cs);
        device_remove(info.dev);
        device_unbind(info.dev);
 
@@ -45,7 +44,7 @@ static int dm_test_spi_find(struct dm_test_state *dms)
         * reports that CS 0 is present
         */
        ut_assertok(spi_cs_info(bus, cs, &info));
-       ut_asserteq_ptr(info.dev, NULL);
+       ut_asserteq_ptr(NULL, info.dev);
 
        /* This finds nothing because we removed the device */
        ut_asserteq(-ENODEV, spi_find_bus_and_cs(busnum, cs, &bus, &dev));
@@ -62,8 +61,9 @@ static int dm_test_spi_find(struct dm_test_state *dms)
        ut_asserteq(-ENOENT, spi_get_bus_and_cs(busnum, cs, speed, mode,
                                                "spi_flash_std", "name", &bus,
                                                &slave));
+       sandbox_sf_unbind_emul(state_get_current(), busnum, cs);
        ut_assertok(spi_cs_info(bus, cs, &info));
-       ut_asserteq_ptr(info.dev, NULL);
+       ut_asserteq_ptr(NULL, info.dev);
 
        /* Add the emulation and try again */
        ut_assertok(sandbox_sf_bind_emul(state, busnum, cs, bus, of_offset,
index bb99677ece9462604e4362fc514030291e30862d..8ebc39297cb53ec315c828a4d0429e8c7ae46dc7 100755 (executable)
@@ -1,9 +1,14 @@
 #!/bin/sh
 
+die() {
+       echo $1
+       exit 1
+}
+
 NUM_CPUS=$(cat /proc/cpuinfo |grep -c processor)
 dtc -I dts -O dtb test/dm/test.dts -o test/dm/test.dtb
-make O=sandbox sandbox_config
-make O=sandbox -s -j${NUM_CPUS}
+make O=sandbox sandbox_config || die "Cannot configure U-Boot"
+make O=sandbox -s -j${NUM_CPUS} || die "Cannot build U-Boot"
 dd if=/dev/zero of=spi.bin bs=1M count=2
 ./sandbox/u-boot -d test/dm/test.dtb -c "dm test"
 rm spi.bin
index cd2c38995e936246a5b8643f04c91b218d454ff0..b8ee9599a22a67c999bb8cd066226cf63237f324 100644 (file)
@@ -51,6 +51,13 @@ static int testfdt_drv_probe(struct udevice *dev)
 
        priv->ping_total += DM_TEST_START_TOTAL;
 
+       /*
+        * If this device is on a bus, the uclass_flag will be set before
+        * calling this function. This is used by
+        * dm_test_bus_child_pre_probe_uclass().
+        */
+       priv->uclass_total += priv->uclass_flag;
+
        return 0;
 }
 
@@ -89,6 +96,7 @@ int testfdt_ping(struct udevice *dev, int pingval, int *pingret)
 UCLASS_DRIVER(testfdt) = {
        .name           = "testfdt",
        .id             = UCLASS_TEST_FDT,
+       .flags          = DM_UC_FLAG_SEQ_ALIAS,
 };
 
 int dm_check_devices(struct dm_test_state *dms, int num_devices)
@@ -128,7 +136,7 @@ int dm_check_devices(struct dm_test_state *dms, int num_devices)
 /* Test that FDT-based binding works correctly */
 static int dm_test_fdt(struct dm_test_state *dms)
 {
-       const int num_devices = 4;
+       const int num_devices = 6;
        struct udevice *dev;
        struct uclass *uc;
        int ret;
@@ -143,12 +151,12 @@ static int dm_test_fdt(struct dm_test_state *dms)
        /* These are num_devices compatible root-level device tree nodes */
        ut_asserteq(num_devices, list_count_items(&uc->dev_head));
 
-       /* Each should have no platdata / priv */
+       /* Each should have platform data but no private data */
        for (i = 0; i < num_devices; i++) {
                ret = uclass_find_device(UCLASS_TEST_FDT, i, &dev);
                ut_assert(!ret);
                ut_assert(!dev_get_priv(dev));
-               ut_assert(!dev->platdata);
+               ut_assert(dev->platdata);
        }
 
        ut_assertok(dm_check_devices(dms, num_devices));
@@ -184,7 +192,7 @@ static int dm_test_fdt_uclass_seq(struct dm_test_state *dms)
        ut_assertok(uclass_find_device_by_seq(UCLASS_TEST_FDT, 3, true, &dev));
        ut_asserteq_str("b-test", dev->name);
 
-       ut_assertok(uclass_find_device_by_seq(UCLASS_TEST_FDT, 0, true, &dev));
+       ut_assertok(uclass_find_device_by_seq(UCLASS_TEST_FDT, 8, true, &dev));
        ut_asserteq_str("a-test", dev->name);
 
        ut_asserteq(-ENODEV, uclass_find_device_by_seq(UCLASS_TEST_FDT, 5,
@@ -220,11 +228,11 @@ static int dm_test_fdt_uclass_seq(struct dm_test_state *dms)
        ut_asserteq(-ENODEV, uclass_get_device_by_seq(UCLASS_TEST_FDT, 1,
                                                      &dev));
        ut_assertok(uclass_get_device(UCLASS_TEST_FDT, 0, &dev));
-       ut_assertok(uclass_get_device(UCLASS_TEST_FDT, 1, &dev));
+       ut_assertok(uclass_get_device(UCLASS_TEST_FDT, 4, &dev));
 
        /* But now that it is probed, we can find it */
        ut_assertok(uclass_get_device_by_seq(UCLASS_TEST_FDT, 1, &dev));
-       ut_asserteq_str("a-test", dev->name);
+       ut_asserteq_str("f-test", dev->name);
 
        return 0;
 }
index fb0272a59cd25472b4e733afbe832a35c607d1d8..84024a44a3f0368c5cea2e983a02d25465969482 100644 (file)
@@ -8,7 +8,15 @@
 
        aliases {
                console = &uart0;
+               i2c0 = "/i2c@0";
+               spi0 = "/spi@0";
                testfdt6 = "/e-test";
+               testbus3 = "/some-bus";
+               testfdt0 = "/some-bus/c-test@0";
+               testfdt1 = "/some-bus/c-test@1";
+               testfdt3 = "/b-test";
+               testfdt5 = "/some-bus/c-test@5";
+               testfdt8 = "/a-test";
        };
 
        uart0: serial {
                ping-expect = <0>;
                ping-add = <0>;
                u-boot,dm-pre-reloc;
+               test-gpios = <&gpio_a 1>, <&gpio_a 4>, <&gpio_b 5 0 3 2 1>,
+                       <0>, <&gpio_a 12>;
+               test2-gpios = <&gpio_a 1>, <&gpio_a 4>, <&gpio_b 6 1 3 2 1>,
+                       <&gpio_b 7 2 3 2 1>, <&gpio_b 8 4 3 2 1>,
+                       <&gpio_b 9 0xc 3 2 1>;
        };
 
        junk {
                compatible = "google,another-fdt-test";
        };
 
+       f-test {
+               compatible = "denx,u-boot-fdt-test";
+       };
+
+       g-test {
+               compatible = "denx,u-boot-fdt-test";
+       };
+
        gpio_a: base-gpios {
                compatible = "sandbox,gpio";
+               gpio-controller;
+               #gpio-cells = <1>;
                gpio-bank-name = "a";
                num-gpios = <20>;
        };
 
-       extra-gpios {
+       gpio_b: extra-gpios {
                compatible = "sandbox,gpio";
+               gpio-controller;
+               #gpio-cells = <5>;
                gpio-bank-name = "b";
                num-gpios = <10>;
        };
index 9e299e1e57aa40f88f373008293900b7ca4281ef..952f975af11ec9eeb5ff30c63381b80fc8fc7d77 100755 (executable)
 # ./test/image/test-imagetools.sh
 
 BASEDIR=sandbox
-SRCDIR=sandbox/boot
+SRCDIR=${BASEDIR}/boot
 IMAGE_NAME="v1.0-test"
-IMAGE=linux.img
+IMAGE_MULTI=linux.img
+IMAGE_FIT_ITS=linux.its
+IMAGE_FIT_ITB=linux.itb
 DATAFILE0=vmlinuz
 DATAFILE1=initrd.img
 DATAFILE2=System.map
@@ -34,14 +36,17 @@ cleanup()
        for file in ${DATAFILES}; do
                rm -f ${file} ${SRCDIR}/${file}
        done
-       rm -f ${IMAGE} ${DUMPIMAGE_LIST} ${MKIMAGE_LIST} ${TEST_OUT}
+       rm -f ${IMAGE_MULTI}
+       rm -f ${DUMPIMAGE_LIST}
+       rm -f ${MKIMAGE_LIST}
+       rm -f ${TEST_OUT}
        rmdir ${SRCDIR}
 }
 
 # Check that two files are the same
 assert_equal()
 {
-       if ! diff $1 $2; then
+       if ! diff -u $1 $2; then
                echo "Failed."
                cleanup
                exit 1
@@ -82,35 +87,103 @@ do_cmd_redir()
        ${cmd} >${redir}
 }
 
-# Write files into an image
-create_image()
+# Write files into an multi-file image
+create_multi_image()
 {
        local files="${SRCDIR}/${DATAFILE0}:${SRCDIR}/${DATAFILE1}"
        files+=":${SRCDIR}/${DATAFILE2}"
 
-       echo -e "\nBuilding image..."
+       echo -e "\nBuilding multi-file image..."
        do_cmd ${MKIMAGE} -A x86 -O linux -T multi -n \"${IMAGE_NAME}\" \
-               -d ${files} ${IMAGE}
+               -d ${files} ${IMAGE_MULTI}
        echo "done."
 }
 
-# Extract files from an image
-extract_image()
+# Extract files from an multi-file image
+extract_multi_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 -e "\nExtracting multi-file image contents..."
+       do_cmd ${DUMPIMAGE} -T multi -i ${IMAGE_MULTI} -p 0 ${DATAFILE0}
+       do_cmd ${DUMPIMAGE} -T multi -i ${IMAGE_MULTI} -p 1 ${DATAFILE1}
+       do_cmd ${DUMPIMAGE} -T multi -i ${IMAGE_MULTI} -p 2 ${DATAFILE2}
+       do_cmd ${DUMPIMAGE} -T multi -i ${IMAGE_MULTI} -p 2 ${DATAFILE2} -o ${TEST_OUT}
+       echo "done."
+}
+
+# Write files into a FIT image
+create_fit_image()
+{
+       echo " \
+       /dts-v1/; \
+       / { \
+           description = \"FIT image\"; \
+           #address-cells = <1>; \
+       \
+           images { \
+               kernel@1 { \
+                   description = \"kernel\"; \
+                   data = /incbin/(\"${DATAFILE0}\"); \
+                   type = \"kernel\"; \
+                   arch = \"sandbox\"; \
+                   os = \"linux\"; \
+                   compression = \"gzip\"; \
+                   load = <0x40000>; \
+                   entry = <0x8>; \
+               }; \
+               ramdisk@1 { \
+                   description = \"filesystem\"; \
+                   data = /incbin/(\"${DATAFILE1}\"); \
+                   type = \"ramdisk\"; \
+                   arch = \"sandbox\"; \
+                   os = \"linux\"; \
+                   compression = \"none\"; \
+                   load = <0x80000>; \
+                   entry = <0x16>; \
+               }; \
+               fdt@1 { \
+                   description = \"device tree\"; \
+                   data = /incbin/(\"${DATAFILE2}\"); \
+                   type = \"flat_dt\"; \
+                   arch = \"sandbox\"; \
+                   compression = \"none\"; \
+               }; \
+           }; \
+           configurations { \
+               default = \"conf@1\"; \
+               conf@1 { \
+                   kernel = \"kernel@1\"; \
+                   fdt = \"fdt@1\"; \
+               }; \
+           }; \
+       }; \
+       " > ${IMAGE_FIT_ITS}
+
+       echo -e "\nBuilding FIT image..."
+       do_cmd ${MKIMAGE} -f ${IMAGE_FIT_ITS} ${IMAGE_FIT_ITB}
+       echo "done."
+}
+
+# Extract files from a FIT image
+extract_fit_image()
+{
+       echo -e "\nExtracting FIT image contents..."
+       do_cmd ${DUMPIMAGE} -T flat_dt -i ${IMAGE_FIT_ITB} -p 0 ${DATAFILE0}
+       do_cmd ${DUMPIMAGE} -T flat_dt -i ${IMAGE_FIT_ITB} -p 1 ${DATAFILE1}
+       do_cmd ${DUMPIMAGE} -T flat_dt -i ${IMAGE_FIT_ITB} -p 2 ${DATAFILE2}
+       do_cmd ${DUMPIMAGE} -T flat_dt -i ${IMAGE_FIT_ITB} -p 2 ${DATAFILE2} -o ${TEST_OUT}
        echo "done."
 }
 
 # List the contents of a file
+# Args:
+#    image filename
 list_image()
 {
+       local image="$1"
+
        echo -e "\nListing image contents..."
-       do_cmd_redir ${MKIMAGE_LIST} ${MKIMAGE} -l ${IMAGE}
-       do_cmd_redir ${DUMPIMAGE_LIST} ${DUMPIMAGE} -l ${IMAGE}
+       do_cmd_redir ${MKIMAGE_LIST} ${MKIMAGE} -l ${image}
+       do_cmd_redir ${DUMPIMAGE_LIST} ${DUMPIMAGE} -l ${image}
        echo "done."
 }
 
@@ -120,16 +193,28 @@ main()
 
        create_files
 
-       # Compress and extract multifile images, compare the result
-       create_image
-       extract_image
+       # Compress and extract multi-file images, compare the result
+       create_multi_image
+       extract_multi_image
+       for file in ${DATAFILES}; do
+               assert_equal ${file} ${SRCDIR}/${file}
+       done
+       assert_equal ${TEST_OUT} ${DATAFILE2}
+
+       # List contents of multi-file image and compares output from tools
+       list_image ${IMAGE_MULTI}
+       assert_equal ${DUMPIMAGE_LIST} ${MKIMAGE_LIST}
+
+       # Compress and extract FIT images, compare the result
+       create_fit_image
+       extract_fit_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
+       # List contents of FIT image and compares output from tools
+       list_image ${IMAGE_FIT_ITB}
        assert_equal ${DUMPIMAGE_LIST} ${MKIMAGE_LIST}
 
        # Remove files created
index e549f8e63c9cbe0b1066a659efb16bd641601601..e4b23eb5b814c12a3cca4ecb5da978d682ebd77b 100644 (file)
@@ -60,7 +60,8 @@ FIT_SIG_OBJS-$(CONFIG_FIT_SIGNATURE) := common/image-sig.o
 LIBFDT_OBJS := $(addprefix lib/libfdt/, \
                        fdt.o fdt_ro.o fdt_rw.o fdt_strerror.o fdt_wip.o)
 RSA_OBJS-$(CONFIG_FIT_SIGNATURE) := $(addprefix lib/rsa/, \
-                                       rsa-sign.o rsa-verify.o rsa-checksum.o)
+                                       rsa-sign.o rsa-verify.o rsa-checksum.o \
+                                       rsa-mod-exp.o)
 
 # common objs for dumpimage and mkimage
 dumpimage-mkimage-objs := aisimage.o \
@@ -90,6 +91,7 @@ dumpimage-mkimage-objs := aisimage.o \
                        socfpgaimage.o \
                        lib/sha1.o \
                        lib/sha256.o \
+                       common/hash.o \
                        ublimage.o \
                        $(LIBFDT_OBJS) \
                        $(RSA_OBJS-y)
@@ -113,6 +115,10 @@ ifdef CONFIG_FIT_SIGNATURE
 HOST_EXTRACFLAGS       += -DCONFIG_FIT_SIGNATURE
 endif
 
+ifdef CONFIG_SYS_SPI_U_BOOT_OFFS
+HOSTCFLAGS_kwbimage.o += -DCONFIG_SYS_SPI_U_BOOT_OFFS=$(CONFIG_SYS_SPI_U_BOOT_OFFS)
+endif
+
 # MXSImage needs LibSSL
 ifneq ($(CONFIG_MX23)$(CONFIG_MX28)$(CONFIG_FIT_SIGNATURE),)
 HOSTLOADLIBES_mkimage += -lssl -lcrypto
@@ -122,6 +128,8 @@ HOSTLOADLIBES_dumpimage := $(HOSTLOADLIBES_mkimage)
 HOSTLOADLIBES_fit_info := $(HOSTLOADLIBES_mkimage)
 HOSTLOADLIBES_fit_check_sign := $(HOSTLOADLIBES_mkimage)
 
+HOSTLDFLAGS += -T $(srctree)/tools/imagetool.lds
+
 hostprogs-$(CONFIG_EXYNOS5250) += mkexynosspl
 hostprogs-$(CONFIG_EXYNOS5420) += mkexynosspl
 HOSTCFLAGS_mkexynosspl.o := -pedantic
index 8de370a2e08d4cb7deff61f333c5986c722b77f9..9338342cb36c28022c780eb60b2494baf0f08914 100644 (file)
@@ -413,19 +413,17 @@ int aisimage_check_params(struct image_tool_params *params)
 /*
  * aisimage parameters
  */
-static struct image_type_params aisimage_params = {
-       .name           = "TI Davinci AIS Boot Image support",
-       .header_size    = 0,
-       .hdr            = NULL,
-       .check_image_type = aisimage_check_image_types,
-       .verify_header  = aisimage_verify_header,
-       .print_header   = aisimage_print_header,
-       .set_header     = aisimage_set_header,
-       .check_params   = aisimage_check_params,
-       .vrec_header    = aisimage_generate,
-};
-
-void init_ais_image_type(void)
-{
-       register_image_type(&aisimage_params);
-}
+U_BOOT_IMAGE_TYPE(
+       aisimage,
+       "TI Davinci AIS Boot Image support",
+       0,
+       NULL,
+       aisimage_check_params,
+       aisimage_verify_header,
+       aisimage_print_header,
+       aisimage_set_header,
+       NULL,
+       aisimage_check_image_types,
+       NULL,
+       aisimage_generate
+);
index c8101d2ddc221803c2e07f1991be35abcc69d055..5b72ac54a6d35442232a49780287d83134bdf12b 100644 (file)
@@ -324,19 +324,17 @@ static int atmel_vrec_header(struct image_tool_params *params,
        return EXIT_SUCCESS;
 }
 
-static struct image_type_params atmelimage_params = {
-       .name           = "ATMEL ROM-Boot Image support",
-       .header_size    = 0,
-       .hdr            = NULL,
-       .check_image_type = atmel_check_image_type,
-       .verify_header  = atmel_verify_header,
-       .print_header   = atmel_print_header,
-       .set_header     = atmel_set_header,
-       .check_params   = atmel_check_params,
-       .vrec_header    = atmel_vrec_header,
-};
-
-void init_atmel_image_type(void)
-{
-       register_image_type(&atmelimage_params);
-}
+U_BOOT_IMAGE_TYPE(
+       atmelimage,
+       "ATMEL ROM-Boot Image support",
+       0,
+       NULL,
+       atmel_check_params,
+       atmel_verify_header,
+       atmel_print_header,
+       atmel_set_header,
+       NULL,
+       atmel_check_image_type,
+       NULL,
+       atmel_vrec_header
+);
index 0a0792e503eadefe058f51db90c5fe98fcc2e1e2..cf5c0d4393b0937b55bb684023a43a2c0d62f9cd 100644 (file)
@@ -15,6 +15,8 @@
  */
 
 #include "imagetool.h"
+#include "mkimage.h"
+
 #include <image.h>
 #include <u-boot/crc.h>
 
@@ -53,9 +55,8 @@ static int image_verify_header(unsigned char *ptr, int image_size,
        memcpy(hdr, ptr, sizeof(image_header_t));
 
        if (be32_to_cpu(hdr->ih_magic) != IH_MAGIC) {
-               fprintf(stderr,
-                       "%s: Bad Magic Number: \"%s\" is no valid image\n",
-                       params->cmdname, params->imagefile);
+               debug("%s: Bad Magic Number: \"%s\" is no valid image\n",
+                     params->cmdname, params->imagefile);
                return -FDT_ERR_BADMAGIC;
        }
 
@@ -66,9 +67,8 @@ static int image_verify_header(unsigned char *ptr, int image_size,
        hdr->ih_hcrc = cpu_to_be32(0);  /* clear for re-calculation */
 
        if (crc32(0, data, len) != checksum) {
-               fprintf(stderr,
-                       "%s: ERROR: \"%s\" has bad header checksum!\n",
-                       params->cmdname, params->imagefile);
+               debug("%s: ERROR: \"%s\" has bad header checksum!\n",
+                     params->cmdname, params->imagefile);
                return -FDT_ERR_BADSTATE;
        }
 
@@ -77,9 +77,8 @@ static int image_verify_header(unsigned char *ptr, int image_size,
 
        checksum = be32_to_cpu(hdr->ih_dcrc);
        if (crc32(0, data, len) != checksum) {
-               fprintf(stderr,
-                       "%s: ERROR: \"%s\" has corrupted data!\n",
-                       params->cmdname, params->imagefile);
+               debug("%s: ERROR: \"%s\" has corrupted data!\n",
+                     params->cmdname, params->imagefile);
                return -FDT_ERR_BADSTRUCTURE;
        }
        return 0;
@@ -117,33 +116,7 @@ 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)
+static int image_extract_subimage(void *ptr, struct image_tool_params *params)
 {
        const image_header_t *hdr = (const image_header_t *)ptr;
        ulong file_data;
@@ -170,25 +143,23 @@ static int image_extract_datafile(void *ptr, struct image_tool_params *params)
        }
 
        /* save the "data file" into the file system */
-       return image_save_datafile(params, file_data, file_len);
+       return imagetool_save_subimage(params->outfile, file_data, file_len);
 }
 
 /*
  * Default image type parameters definition
  */
-static struct image_type_params defimage_params = {
-       .name = "Default Image support",
-       .header_size = sizeof(image_header_t),
-       .hdr = (void*)&header,
-       .check_image_type = image_check_image_types,
-       .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)
-{
-       register_image_type(&defimage_params);
-}
+U_BOOT_IMAGE_TYPE(
+       defimage,
+       "Default Image support",
+       sizeof(image_header_t),
+       (void *)&header,
+       image_check_params,
+       image_verify_header,
+       image_print_contents,
+       image_set_header,
+       image_extract_subimage,
+       image_check_image_types,
+       NULL,
+       NULL
+);
index 542ee2821096fd41614dc05de3f5ab789840e374..75a5d4762cda6b1e31432a1e419b3d8400e7751e 100644 (file)
 
 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 -
+ * dumpimage_extract_subimage -
  *
  * It scans all registered image types,
  * verifies image_header for each supported image type
@@ -127,29 +28,27 @@ static int dumpimage_verify_print_header(void *ptr, struct stat *sbuf)
  * 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)
+static int dumpimage_extract_subimage(struct image_type_params *tparams,
+               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;
-                       }
+       if (tparams->verify_header) {
+               retval = tparams->verify_header((unsigned char *)ptr,
+                               sbuf->st_size, &params);
+               if (retval != 0)
+                       return -1;
+               /*
+                * Extract the file from the image
+                * if verify is successful
+                */
+               if (tparams->extract_subimage) {
+                       retval = tparams->extract_subimage(ptr, &params);
+               } else {
+                       fprintf(stderr,
+                               "%s: extract_subimage undefined for %s\n",
+                               params.cmdname, tparams->name);
+                       return -2;
                }
        }
 
@@ -165,12 +64,9 @@ int main(int argc, char **argv)
        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) {
+       while ((opt = getopt(argc, argv, "li:o:T:p:V")) != -1) {
                switch (opt) {
                case 'l':
                        params.lflag = 1;
@@ -182,6 +78,12 @@ int main(int argc, char **argv)
                case 'o':
                        params.outfile = optarg;
                        break;
+               case 'T':
+                       params.type = genimg_get_type_id(optarg);
+                       if (params.type < 0) {
+                               usage();
+                       }
+                       break;
                case 'p':
                        params.pflag = strtoul(optarg, &ptr, 10);
                        if (*ptr) {
@@ -196,6 +98,7 @@ int main(int argc, char **argv)
                        exit(EXIT_SUCCESS);
                default:
                        usage();
+                       break;
                }
        }
 
@@ -203,9 +106,9 @@ int main(int argc, char **argv)
                usage();
 
        /* set tparams as per input type_id */
-       tparams = dumpimage_get_type(params.type);
+       tparams = imagetool_get_type(params.type);
        if (tparams == NULL) {
-               fprintf(stderr, "%s: unsupported type %s\n",
+               fprintf(stderr, "%s: unsupported type: %s\n",
                        params.cmdname, genimg_get_type_name(params.type));
                exit(EXIT_FAILURE);
        }
@@ -242,7 +145,7 @@ int main(int argc, char **argv)
                        exit(EXIT_FAILURE);
                }
 
-               if ((unsigned)sbuf.st_size < tparams->header_size) {
+               if ((uint32_t)sbuf.st_size < tparams->header_size) {
                        fprintf(stderr,
                                "%s: Bad size: \"%s\" is not valid image\n",
                                params.cmdname, params.imagefile);
@@ -267,13 +170,15 @@ int main(int argc, char **argv)
                         * Extract the data files from within the matched
                         * image type. Returns the error code if not matched
                         */
-                       retval = dumpimage_extract_datafile(ptr, &sbuf);
+                       retval = dumpimage_extract_subimage(tparams, 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);
+                       retval = imagetool_verify_print_header(ptr, &sbuf,
+                                       tparams, &params);
                }
 
                (void)munmap((void *)ptr, sbuf.st_size);
@@ -293,9 +198,10 @@ static void usage(void)
                "          -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",
+               "       %s -i image -T type [-p position] [-o outfile] data_file\n"
+               "          -i ==> extract from the 'image' a specific 'data_file'\n"
+               "          -T ==> set image type to 'type'\n"
+               "          -p ==> 'position' (starting at 0) of the 'data_file' inside the 'image'\n",
                params.cmdname);
        fprintf(stderr,
                "       %s -V ==> print version information and exit\n",
index 3ececf913ff4c4fe2c1c2457f3f5b5ccbfa195fb..eb2a25eeac6aebcd7ae764ff8a593d18cc482528 100644 (file)
@@ -155,6 +155,97 @@ err_system:
        return -1;
 }
 
+/**
+ * fit_image_extract - extract a FIT component image
+ * @fit: pointer to the FIT format image header
+ * @image_noffset: offset of the component image node
+ * @file_name: name of the file to store the FIT sub-image
+ *
+ * returns:
+ *     zero in case of success or a negative value if fail.
+ */
+static int fit_image_extract(
+       const void *fit,
+       int image_noffset,
+       const char *file_name)
+{
+       const void *file_data;
+       size_t file_size = 0;
+
+       /* get the "data" property of component at offset "image_noffset" */
+       fit_image_get_data(fit, image_noffset, &file_data, &file_size);
+
+       /* save the "file_data" into the file specified by "file_name" */
+       return imagetool_save_subimage(file_name, (ulong) file_data, file_size);
+}
+
+/**
+ * fit_extract_contents - retrieve a sub-image component from the FIT image
+ * @ptr: pointer to the FIT format image header
+ * @params: command line parameters
+ *
+ * returns:
+ *     zero in case of success or a negative value if fail.
+ */
+static int fit_extract_contents(void *ptr, struct image_tool_params *params)
+{
+       int images_noffset;
+       int noffset;
+       int ndepth;
+       const void *fit = ptr;
+       int count = 0;
+       const char *p;
+
+       /* Indent string is defined in header image.h */
+       p = IMAGE_INDENT_STRING;
+
+       if (!fit_check_format(fit)) {
+               printf("Bad FIT image format\n");
+               return -1;
+       }
+
+       /* Find images parent node offset */
+       images_noffset = fdt_path_offset(fit, FIT_IMAGES_PATH);
+       if (images_noffset < 0) {
+               printf("Can't find images parent node '%s' (%s)\n",
+                      FIT_IMAGES_PATH, fdt_strerror(images_noffset));
+               return -1;
+       }
+
+       /* Avoid any overrun */
+       count = fit_get_subimage_count(fit, images_noffset);
+       if ((params->pflag < 0) || (count <= params->pflag)) {
+               printf("No such component at '%d'\n", params->pflag);
+               return -1;
+       }
+
+       /* Process its subnodes, extract the desired component from image */
+       for (ndepth = 0, count = 0,
+               noffset = fdt_next_node(fit, images_noffset, &ndepth);
+               (noffset >= 0) && (ndepth > 0);
+               noffset = fdt_next_node(fit, noffset, &ndepth)) {
+               if (ndepth == 1) {
+                       /*
+                        * Direct child node of the images parent node,
+                        * i.e. component image node.
+                        */
+                       if (params->pflag == count) {
+                               printf("Extracted:\n%s Image %u (%s)\n", p,
+                                      count, fit_get_name(fit, noffset, NULL));
+
+                               fit_image_print(fit, noffset, p);
+
+                               return fit_image_extract(fit, noffset,
+                                               params->outfile);
+                       }
+
+                       count++;
+               }
+       }
+
+       return 0;
+}
+
 static int fit_check_params(struct image_tool_params *params)
 {
        return  ((params->dflag && (params->fflag || params->lflag)) ||
@@ -162,19 +253,17 @@ static int fit_check_params(struct image_tool_params *params)
                (params->lflag && (params->dflag || params->fflag)));
 }
 
-static struct image_type_params fitimage_params = {
-       .name = "FIT Image support",
-       .header_size = sizeof(image_header_t),
-       .hdr = (void*)&header,
-       .verify_header = fit_verify_header,
-       .print_header = fit_print_contents,
-       .check_image_type = fit_check_image_types,
-       .fflag_handle = fit_handle_file,
-       .set_header = NULL,     /* FIT images use DTB header */
-       .check_params = fit_check_params,
-};
-
-void init_fit_image_type (void)
-{
-       register_image_type(&fitimage_params);
-}
+U_BOOT_IMAGE_TYPE(
+       fitimage,
+       "FIT Image support",
+       sizeof(image_header_t),
+       (void *)&header,
+       fit_check_params,
+       fit_verify_header,
+       fit_print_contents,
+       NULL,
+       fit_extract_contents,
+       fit_check_image_types,
+       fit_handle_file,
+       NULL /* FIT images use DTB header */
+);
index b343a3aa8b7c2964eb58d5098149504f947344af..5ad52be4377467614c36a2de18d94c9c0c6f5351 100644 (file)
@@ -32,7 +32,8 @@ void to_be32(uint32_t *gph_size, uint32_t *gph_load_addr)
 
 int gph_verify_header(struct gp_header *gph, int be)
 {
-       uint32_t gph_size = gph->size, gph_load_addr = gph->load_addr;
+       uint32_t gph_size = gph->size;
+       uint32_t gph_load_addr = gph->load_addr;
 
        if (be)
                to_be32(&gph_size, &gph_load_addr);
index 1cabb5b612e2a485662e6d5c411e5851c12efd06..1adc55c5fca9effb91eeb8f8541282abd8ba7839 100644 (file)
@@ -60,18 +60,17 @@ static void gpimage_set_header(void *ptr, struct stat *sbuf, int ifd,
 /*
  * gpimage parameters
  */
-static struct image_type_params gpimage_params = {
-       .name           = "TI KeyStone GP Image support",
-       .header_size    = GPIMAGE_HDR_SIZE,
-       .hdr            = (void *)&gpimage_header,
-       .check_image_type = gpimage_check_image_types,
-       .verify_header  = gpimage_verify_header,
-       .print_header   = gpimage_print_header,
-       .set_header     = gpimage_set_header,
-       .check_params   = gpimage_check_params,
-};
-
-void init_gpimage_type(void)
-{
-       register_image_type(&gpimage_params);
-}
+U_BOOT_IMAGE_TYPE(
+       gpimage,
+       "TI KeyStone GP Image support",
+       GPIMAGE_HDR_SIZE,
+       (void *)&gpimage_header,
+       gpimage_check_params,
+       gpimage_verify_header,
+       gpimage_print_header,
+       gpimage_set_header,
+       NULL,
+       gpimage_check_image_types,
+       NULL,
+       NULL
+);
index 98717bdeddcf39fe9988e6f14ab6b35d8ed6f2b0..148e4662b7b366e2b2400639aa733b59e747865f 100644 (file)
@@ -8,57 +8,87 @@
 
 #include "imagetool.h"
 
-/*
- * Callback function to register a image type within a tool
- */
-static imagetool_register_t register_func;
+#include <image.h>
 
-/*
- * 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)
+struct image_type_params *imagetool_get_type(int type)
 {
-       /*
-        * Save the image tool callback function. It will be used to register
-        * image types within that tool
-        */
-       register_func = image_register;
+       struct image_type_params *curr;
+       struct image_type_params *start = ll_entry_start(
+                       struct image_type_params, image_type);
+       struct image_type_params *end = ll_entry_end(
+                       struct image_type_params, image_type);
 
-       /* Init ATMEL ROM Boot Image generation/list support */
-       init_atmel_image_type();
-       /* 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 Altera SOCFPGA support */
-       init_socfpga_image_type();
-       /* Init TI Keystone boot image generation/list support */
-       init_gpimage_type();
+       for (curr = start; curr != end; curr++) {
+               if (curr->check_image_type) {
+                       if (!curr->check_image_type(type))
+                               return curr;
+               }
+       }
+       return NULL;
 }
 
-/*
- * register_image_type -
- *
- * Register a image type within a tool
- */
-void register_image_type(struct image_type_params *tparams)
+int imagetool_verify_print_header(
+       void *ptr,
+       struct stat *sbuf,
+       struct image_type_params *tparams,
+       struct image_tool_params *params)
 {
-       register_func(tparams);
+       int retval = -1;
+       struct image_type_params *curr;
+
+       struct image_type_params *start = ll_entry_start(
+                       struct image_type_params, image_type);
+       struct image_type_params *end = ll_entry_end(
+                       struct image_type_params, image_type);
+
+       for (curr = start; curr != end; curr++) {
+               if (curr->verify_header) {
+                       retval = curr->verify_header((unsigned char *)ptr,
+                                                    sbuf->st_size, params);
+
+                       if (retval == 0) {
+                               /*
+                                * 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;
+}
+
+int imagetool_save_subimage(
+       const char *file_name,
+       ulong file_data,
+       ulong file_len)
+{
+       int dfd;
+
+       dfd = open(file_name, O_RDWR | O_CREAT | O_TRUNC | O_BINARY,
+                  S_IRUSR | S_IWUSR);
+       if (dfd < 0) {
+               fprintf(stderr, "Can't open \"%s\": %s\n",
+                       file_name, strerror(errno));
+               return -1;
+       }
+
+       if (write(dfd, (void *)file_data, file_len) != (ssize_t)file_len) {
+               fprintf(stderr, "Write error on \"%s\": %s\n",
+                       file_name, strerror(errno));
+               close(dfd);
+               return -1;
+       }
+
+       close(dfd);
+
+       return 0;
 }
index 8bce059482737bb5030ed36d68cafc28838a4084..f35dec71c7190a4b82e817315e998c561f5e064a 100644 (file)
 #include <time.h>
 #include <unistd.h>
 #include <u-boot/sha1.h>
+
+/* define __KERNEL__ in order to get the definitions
+ * required by the linker list. This is probably not
+ * the best way to do this */
+#ifndef __KERNEL__
+#define __KERNEL__
+#include <linker_lists.h>
+#undef __KERNEL__
+#endif /* __KERNEL__ */
+
 #include "fdt_host.h"
 
 #define ARRAY_SIZE(x)          (sizeof(x) / sizeof((x)[0]))
@@ -100,14 +110,15 @@ struct image_type_params {
        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>).
+        * This function is used by the command to retrieve a component
+        * (sub-image) from the image (i.e. dumpimage -i <image> -p <position>
+        * <sub-image-name>).
         * 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 *);
+       int (*extract_subimage)(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
@@ -127,50 +138,88 @@ struct image_type_params {
         */
        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.
+/**
+ * imagetool_get_type() - find the image type params for a given image type
+ *
+ * It scans all registers image type supports
+ * checks the input type for each supported image type
+ *
+ * if successful,
+ *     returns respective image_type_params pointer if success
+ * if input type_id is not supported by any of image_type_support
+ *     returns NULL
  */
-typedef void (*imagetool_register_t)(struct image_type_params *);
+struct image_type_params *imagetool_get_type(int type);
 
 /*
- * Initializes all image types with the given registration callback
- * function.
- * An image tool uses this function to initialize all image types.
+ * imagetool_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
  */
-void register_image_tool(imagetool_register_t image_register);
+int imagetool_verify_print_header(
+       void *ptr,
+       struct stat *sbuf,
+       struct image_type_params *tparams,
+       struct image_tool_params *params);
 
-/*
- * Register a image type within a tool.
- * An image type uses this function to register itself within
- * all tools.
+/**
+ * imagetool_save_subimage - store data into a file
+ * @file_name: name of the destination file
+ * @file_data: data to be written
+ * @file_len: the amount of data to store
+ *
+ * imagetool_save_subimage() store file_len bytes of data pointed by file_data
+ * into the file name by file_name.
+ *
+ * returns:
+ *     zero in case of success or a negative value if fail.
  */
-void register_image_type(struct image_type_params *tparams);
+int imagetool_save_subimage(
+       const char *file_name,
+       ulong file_data,
+       ulong file_len);
 
 /*
  * 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_atmel_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 init_socfpga_image_type(void);
-void init_gpimage_type(void);
+
 
 void pbl_load_uboot(int fd, struct image_tool_params *mparams);
 
+#define U_BOOT_IMAGE_TYPE( \
+               _id, \
+               _name, \
+               _header_size, \
+               _header, \
+               _check_params, \
+               _verify_header, \
+               _print_header, \
+               _set_header, \
+               _extract_subimage, \
+               _check_image_type, \
+               _fflag_handle, \
+               _vrec_header \
+       ) \
+       ll_entry_declare(struct image_type_params, _id, image_type) = { \
+               .name = _name, \
+               .header_size = _header_size, \
+               .hdr = _header, \
+               .check_params = _check_params, \
+               .verify_header = _verify_header, \
+               .print_header = _print_header, \
+               .set_header = _set_header, \
+               .extract_subimage = _extract_subimage, \
+               .check_image_type = _check_image_type, \
+               .fflag_handle = _fflag_handle, \
+               .vrec_header = _vrec_header \
+       }
+
 #endif /* _IMAGETOOL_H_ */
diff --git a/tools/imagetool.lds b/tools/imagetool.lds
new file mode 100644 (file)
index 0000000..7e92b4a
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2011-2012 The Chromium OS Authors.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+SECTIONS
+{
+
+       . = ALIGN(4);
+       .u_boot_list : {
+               KEEP(*(SORT(.u_boot_list*)));
+       }
+
+       __u_boot_sandbox_option_start = .;
+       _u_boot_sandbox_getopt : { *(.u_boot_sandbox_getopt) }
+       __u_boot_sandbox_option_end = .;
+
+       __bss_start = .;
+}
+
+INSERT BEFORE .data;
index f880edd96b560ebc656a8cc282c4de25b08a4c6d..6f469ae6336c064cd0ceb2534929b6396f22f1c1 100644 (file)
@@ -696,19 +696,17 @@ static int imximage_generate(struct image_tool_params *params,
 /*
  * imximage parameters
  */
-static struct image_type_params imximage_params = {
-       .name           = "Freescale i.MX Boot Image support",
-       .header_size    = 0,
-       .hdr            = NULL,
-       .check_image_type = imximage_check_image_types,
-       .verify_header  = imximage_verify_header,
-       .print_header   = imximage_print_header,
-       .set_header     = imximage_set_header,
-       .check_params   = imximage_check_params,
-       .vrec_header    = imximage_generate,
-};
-
-void init_imx_image_type(void)
-{
-       register_image_type(&imximage_params);
-}
+U_BOOT_IMAGE_TYPE(
+       imximage,
+       "Freescale i.MX Boot Image support",
+       0,
+       NULL,
+       imximage_check_params,
+       imximage_verify_header,
+       imximage_print_header,
+       imximage_set_header,
+       NULL,
+       imximage_check_image_types,
+       NULL,
+       imximage_generate
+);
index 807d46668be78ee90b1103b2e5b56460dbc6afe0..de5c80847e3f8d2ee4c8a9aeda595d0c3b1adb56 100644 (file)
@@ -868,6 +868,16 @@ static int kwbimage_generate(struct image_tool_params *params,
                        sizeof(struct ext_hdr_v0);
        } else {
                alloc_len = image_headersz_v1(params, NULL);
+#if defined(CONFIG_SYS_SPI_U_BOOT_OFFS)
+               if (alloc_len > CONFIG_SYS_SPI_U_BOOT_OFFS) {
+                       fprintf(stderr, "Error: Image header (incl. SPL image) too big!\n");
+                       fprintf(stderr, "header=0x%x CONFIG_SYS_SPI_U_BOOT_OFFS=0x%x!\n",
+                               alloc_len, CONFIG_SYS_SPI_U_BOOT_OFFS);
+                       fprintf(stderr, "Increase CONFIG_SYS_SPI_U_BOOT_OFFS!\n");
+               } else {
+                       alloc_len = CONFIG_SYS_SPI_U_BOOT_OFFS;
+               }
+#endif
        }
 
        hdr = malloc(alloc_len);
@@ -905,19 +915,17 @@ static int kwbimage_check_params(struct image_tool_params *params)
 /*
  * kwbimage type parameters definition
  */
-static struct image_type_params kwbimage_params = {
-       .name           = "Marvell MVEBU Boot Image support",
-       .header_size    = 0,            /* no fixed header size */
-       .hdr            = NULL,
-       .vrec_header    = kwbimage_generate,
-       .check_image_type = kwbimage_check_image_types,
-       .verify_header  = kwbimage_verify_header,
-       .print_header   = kwbimage_print_header,
-       .set_header     = kwbimage_set_header,
-       .check_params   = kwbimage_check_params,
-};
-
-void init_kwb_image_type (void)
-{
-       register_image_type(&kwbimage_params);
-}
+U_BOOT_IMAGE_TYPE(
+       kwbimage,
+       "Marvell MVEBU Boot Image support",
+       0,
+       NULL,
+       kwbimage_check_params,
+       kwbimage_verify_header,
+       kwbimage_print_header,
+       kwbimage_set_header,
+       NULL,
+       kwbimage_check_image_types,
+       NULL,
+       kwbimage_generate
+);
index c70408c9ba02375ae959e20d438e4e65acfd75b0..5ccd951048cef587686d264575aae6ea7623e90f 100644 (file)
@@ -15,9 +15,6 @@
 static void copy_file(int, const char *, int);
 static void usage(void);
 
-/* image_type_params link list to maintain registered image type supports */
-struct image_type_params *mkimage_tparams = NULL;
-
 /* parameters initialized by core will be used by the image type code */
 struct image_tool_params params = {
        .os = IH_OS_LINUX,
@@ -29,106 +26,6 @@ struct image_tool_params params = {
        .imagename2 = "",
 };
 
-/*
- * mkimage_register -
- *
- * It is used to register respective image generation/list support to the
- * mkimage core
- *
- * the input struct image_type_params is checked and appended to the link
- * list, if the input structure is already registered, error
- */
-void mkimage_register (struct image_type_params *tparams)
-{
-       struct image_type_params **tp;
-
-       if (!tparams) {
-               fprintf (stderr, "%s: %s: Null input\n",
-                       params.cmdname, __FUNCTION__);
-               exit (EXIT_FAILURE);
-       }
-
-       /* scan the linked list, check for registry and point the last one */
-       for (tp = &mkimage_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);
-}
-
-/*
- * mkimage_get_type -
- *
- * It scans all registers image type supports
- * checks the input type_id for each supported image type
- *
- * if successful,
- *     returns respective image_type_params pointer if success
- * if input type_id is not supported by any of image_type_support
- *     returns NULL
- */
-struct image_type_params *mkimage_get_type(int type)
-{
-       struct image_type_params *curr;
-
-       for (curr = mkimage_tparams; curr != NULL; curr = curr->next) {
-               if (curr->check_image_type) {
-                       if (!curr->check_image_type (type))
-                               return curr;
-               }
-       }
-       return NULL;
-}
-
-/*
- * mkimage_verify_print_header -
- *
- * It scans mkimage_tparams link list,
- * verifies image_header for each supported image type
- * if verification is successful, prints respective header
- *
- * returns negative if input image format does not match with any of
- * supported image types
- */
-int mkimage_verify_print_header (void *ptr, struct stat *sbuf)
-{
-       int retval = -1;
-       struct image_type_params *curr;
-
-       for (curr = mkimage_tparams; curr != NULL; curr = curr->next ) {
-               if (curr->verify_header) {
-                       retval = curr->verify_header (
-                               (unsigned char *)ptr, sbuf->st_size,
-                               &params);
-
-                       if (retval == 0) {
-                               /*
-                                * 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;
-}
-
 int
 main (int argc, char **argv)
 {
@@ -139,9 +36,6 @@ main (int argc, char **argv)
        struct image_type_params *tparams = NULL;
        int pad_len = 0;
 
-       /* Init all image generation/list support */
-       register_image_tool(mkimage_register);
-
        params.cmdname = *argv;
        params.addr = params.ep = 0;
 
@@ -279,7 +173,7 @@ NXTARG:             ;
                usage ();
 
        /* set tparams as per input type_id */
-       tparams = mkimage_get_type(params.type);
+       tparams = imagetool_get_type(params.type);
        if (tparams == NULL) {
                fprintf (stderr, "%s: unsupported type %s\n",
                        params.cmdname, genimg_get_type_name(params.type));
@@ -363,7 +257,8 @@ NXTARG:             ;
                 * Print the image information for matched image type
                 * Returns the error code if not matched
                 */
-               retval = mkimage_verify_print_header (ptr, &sbuf);
+               retval = imagetool_verify_print_header(ptr, &sbuf,
+                               tparams, &params);
 
                (void) munmap((void *)ptr, sbuf.st_size);
                (void) close (ifd);
@@ -529,7 +424,7 @@ copy_file (int ifd, const char *datafile, int pad)
        uint8_t zeros[4096];
        int offset = 0;
        int size;
-       struct image_type_params *tparams = mkimage_get_type (params.type);
+       struct image_type_params *tparams = imagetool_get_type(params.type);
 
        if (pad >= sizeof(zeros)) {
                fprintf(stderr, "%s: Can't pad to %d\n",
index 04beefe05cbfd87575b9e23816a69034742b505c..98fc64491c7d9f56591858f075020eed7d911ca2 100644 (file)
@@ -2312,25 +2312,18 @@ fail:
 /*
  * mxsimage parameters
  */
-static struct image_type_params mxsimage_params = {
-       .name           = "Freescale MXS Boot Image support",
-       .header_size    = 0,
-       .hdr            = NULL,
-       .check_image_type = mxsimage_check_image_types,
-       .verify_header  = mxsimage_verify_header,
-       .print_header   = mxsimage_print_header,
-       .set_header     = mxsimage_set_header,
-       .check_params   = mxsimage_check_params,
-       .vrec_header    = mxsimage_generate,
-};
-
-void init_mxs_image_type(void)
-{
-       register_image_type(&mxsimage_params);
-}
-
-#else
-void init_mxs_image_type(void)
-{
-}
+U_BOOT_IMAGE_TYPE(
+       mxsimage,
+       "Freescale MXS Boot Image support",
+       0,
+       NULL,
+       mxsimage_check_params,
+       mxsimage_verify_header,
+       mxsimage_print_header,
+       mxsimage_set_header,
+       NULL,
+       mxsimage_check_image_types,
+       NULL,
+       mxsimage_generate
+);
 #endif
index 1e0c16479681aec2d8621eabd953ff9a8cdb203c..7198b3330d6d6a62a8d3064643bfe1fe191cec33 100644 (file)
@@ -162,18 +162,17 @@ static void omapimage_set_header(void *ptr, struct stat *sbuf, int ifd,
 /*
  * omapimage parameters
  */
-static struct image_type_params omapimage_params = {
-       .name           = "TI OMAP CH/GP Boot Image support",
-       .header_size    = OMAP_FILE_HDR_SIZE,
-       .hdr            = (void *)&omapimage_header,
-       .check_image_type = omapimage_check_image_types,
-       .verify_header  = omapimage_verify_header,
-       .print_header   = omapimage_print_header,
-       .set_header     = omapimage_set_header,
-       .check_params   = gpimage_check_params,
-};
-
-void init_omap_image_type(void)
-{
-       register_image_type(&omapimage_params);
-}
+U_BOOT_IMAGE_TYPE(
+       omapimage,
+       "TI OMAP CH/GP Boot Image support",
+       OMAP_FILE_HDR_SIZE,
+       (void *)&omapimage_header,
+       gpimage_check_params,
+       omapimage_verify_header,
+       omapimage_print_header,
+       omapimage_set_header,
+       NULL,
+       omapimage_check_image_types,
+       NULL,
+       NULL
+);
index e466886ed2428416824e40f8d0faa529248ff4e4..7d039e82bc2781bc6624bb423f5d8f4ef302232d 100644 (file)
@@ -52,12 +52,15 @@ will get a consistent result each time.
 How to configure it
 ===================
 
-For most cases of using patman for U-Boot development, patman will
-locate and use the file 'doc/git-mailrc' in your U-Boot directory.
-This contains most of the aliases you will need.
+For most cases of using patman for U-Boot development, patman can use the
+file 'doc/git-mailrc' in your U-Boot directory to supply the email aliases
+you need. To make this work, tell git where to find the file by typing
+this once:
 
-For Linux the 'scripts/get_maintainer.pl' handles figuring out where
-to send patches pretty well.
+    git config sendemail.aliasesfile doc/git-mailrc
+
+For both Linux and U-Boot the 'scripts/get_maintainer.pl' handles figuring
+out where to send patches pretty well.
 
 During the first run patman creates a config file for you by taking the default
 user name and email address from the global .gitconfig file.
index cc5a55ab3ffefd7fce9c0107c9470bbd0d05ed2e..c593070d67ef24800462543c0a1774a33515c6bf 100644 (file)
@@ -392,7 +392,8 @@ def EmailPatches(series, cover_fname, args, dry_run, raise_on_error, cc_fname,
                    "Or do something like this\n"
                    "git config sendemail.to u-boot@lists.denx.de")
             return
-    cc = BuildEmailList(series.get('cc'), '--cc', alias, raise_on_error)
+    cc = BuildEmailList(list(set(series.get('cc')) - set(series.get('to'))),
+                        '--cc', alias, raise_on_error)
     if self_only:
         to = BuildEmailList([os.getenv('USER')], '--to', alias, raise_on_error)
         cc = []
index da0488337b29a5fd4db542b58892a14c4e637ee9..8c3a0ec9eee5e7af6bc0ef0820a069e0f74c78aa 100644 (file)
@@ -139,6 +139,9 @@ class PatchStream:
         # Initially we have no output. Prepare the input line string
         out = []
         line = line.rstrip('\n')
+
+        commit_match = re_commit.match(line) if self.is_log else None
+
         if self.is_log:
             if line[:4] == '    ':
                 line = line[4:]
@@ -146,7 +149,6 @@ class PatchStream:
         # Handle state transition and skipping blank lines
         series_tag_match = re_series_tag.match(line)
         commit_tag_match = re_commit_tag.match(line)
-        commit_match = re_commit.match(line) if self.is_log else None
         cover_cc_match = re_cover_cc.match(line)
         signoff_match = re_signoff.match(line)
         tag_match = None
index b67f870b7e21518fa51e97040470658979094b5b..60ebc766f7e956f959e6577c833ec9c68dc5d848 100644 (file)
@@ -94,6 +94,9 @@ class Series(dict):
             cmd: The git command we would have run
             process_tags: Process tags as if they were aliases
         """
+        to_set = set(gitutil.BuildEmailList(self.to));
+        cc_set = set(gitutil.BuildEmailList(self.cc));
+
         col = terminal.Color()
         print 'Dry run, so not doing much. But I would do this:'
         print
@@ -106,24 +109,16 @@ class Series(dict):
             commit = self.commits[upto]
             print col.Color(col.GREEN, '   %s' % args[upto])
             cc_list = list(self._generated_cc[commit.patch])
-
-            # Skip items in To list
-            if 'to' in self:
-                try:
-                    map(cc_list.remove, gitutil.BuildEmailList(self.to))
-                except ValueError:
-                    pass
-
-            for email in cc_list:
+            for email in set(cc_list) - to_set - cc_set:
                 if email == None:
                     email = col.Color(col.YELLOW, "<alias '%s' not found>"
                             % tag)
                 if email:
                     print '      Cc: ',email
         print
-        for item in gitutil.BuildEmailList(self.get('to', '<none>')):
+        for item in to_set:
             print 'To:\t ', item
-        for item in gitutil.BuildEmailList(self.cc):
+        for item in cc_set - to_set:
             print 'Cc:\t ', item
         print 'Version: ', self.get('version')
         print 'Prefix:\t ', self.get('prefix')
@@ -131,7 +126,7 @@ class Series(dict):
             print 'Cover: %d lines' % len(self.cover)
             cover_cc = gitutil.BuildEmailList(self.get('cover_cc', ''))
             all_ccs = itertools.chain(cover_cc, *self._generated_cc.values())
-            for email in set(all_ccs):
+            for email in set(all_ccs) - to_set - cc_set:
                     print '      Cc: ',email
         if cmd:
             print 'Git command: %s' % cmd
@@ -230,7 +225,7 @@ class Series(dict):
            if add_maintainers:
                 list += get_maintainer.GetMaintainer(commit.patch)
             all_ccs += list
-            print >>fd, commit.patch, ', '.join(list)
+            print >>fd, commit.patch, ', '.join(set(list))
             self._generated_cc[commit.patch] = list
 
         if cover_fname:
index 2a799ab4b64eb9214c1a38b317d782cd5fe1e0ea..d74fde9a4415df6e12548a72f1b4b7a9e2ea1d6a 100644 (file)
@@ -308,19 +308,17 @@ int pblimage_check_params(struct image_tool_params *params)
 };
 
 /* pblimage parameters */
-static struct image_type_params pblimage_params = {
-       .name           = "Freescale PBL Boot Image support",
-       .header_size    = sizeof(struct pbl_header),
-       .hdr            = (void *)&pblimage_header,
-       .check_image_type = pblimage_check_image_types,
-       .check_params   = pblimage_check_params,
-       .verify_header  = pblimage_verify_header,
-       .print_header   = pblimage_print_header,
-       .set_header     = pblimage_set_header,
-};
-
-void init_pbl_image_type(void)
-{
-       pbl_size = 0;
-       register_image_type(&pblimage_params);
-}
+U_BOOT_IMAGE_TYPE(
+       pblimage,
+       "Freescale PBL Boot Image support",
+       sizeof(struct pbl_header),
+       (void *)&pblimage_header,
+       pblimage_check_params,
+       pblimage_verify_header,
+       pblimage_print_header,
+       pblimage_set_header,
+       NULL,
+       pblimage_check_image_types,
+       NULL,
+       NULL
+);
index 917873e7b3ce83487cb16a9a9d577f495192f5f6..8fe91fe80ee9ac9ab5c2c0f7af25705f212bd486 100644 (file)
@@ -33,6 +33,8 @@
 
 #include "pbl_crc32.h"
 #include "imagetool.h"
+#include "mkimage.h"
+
 #include <image.h>
 
 #define HEADER_OFFSET  0x40
@@ -133,12 +135,12 @@ static int verify_buffer(const uint8_t *buf)
 
        len = verify_header(buf + HEADER_OFFSET);
        if (len < 0) {
-               fprintf(stderr, "Invalid header\n");
+               debug("Invalid header\n");
                return -1;
        }
 
        if (len < HEADER_OFFSET || len > PADDED_SIZE) {
-               fprintf(stderr, "Invalid header length (%i)\n", len);
+               debug("Invalid header length (%i)\n", len);
                return -1;
        }
 
@@ -241,19 +243,17 @@ static void socfpgaimage_set_header(void *ptr, struct stat *sbuf, int ifd,
        sign_buffer(buf, 0, 0, data_size, 0);
 }
 
-static struct image_type_params socfpgaimage_params = {
-       .name           = "Altera SOCFPGA preloader support",
-       .vrec_header    = socfpgaimage_vrec_header,
-       .header_size    = 0, /* This will be modified by vrec_header() */
-       .hdr            = (void *)buffer,
-       .check_image_type = socfpgaimage_check_image_types,
-       .verify_header  = socfpgaimage_verify_header,
-       .print_header   = socfpgaimage_print_header,
-       .set_header     = socfpgaimage_set_header,
-       .check_params   = socfpgaimage_check_params,
-};
-
-void init_socfpga_image_type(void)
-{
-       register_image_type(&socfpgaimage_params);
-}
+U_BOOT_IMAGE_TYPE(
+       socfpgaimage,
+       "Altera SOCFPGA preloader support",
+       0, /* This will be modified by vrec_header() */
+       (void *)buffer,
+       socfpgaimage_check_params,
+       socfpgaimage_verify_header,
+       socfpgaimage_print_header,
+       socfpgaimage_set_header,
+       NULL,
+       socfpgaimage_check_image_types,
+       NULL,
+       socfpgaimage_vrec_header
+);
index cbbbe205dadf4d168ca5c71b2d6b2aedcf3ffb75..6ed1eef29c95e38bf78658131a9548217059f197 100644 (file)
@@ -244,18 +244,17 @@ int ublimage_check_params(struct image_tool_params *params)
 /*
  * ublimage parameters
  */
-static struct image_type_params ublimage_params = {
-       .name           = "Davinci UBL boot support",
-       .header_size    = sizeof(struct ubl_header),
-       .hdr            = (void *)&ublimage_header,
-       .check_image_type = ublimage_check_image_types,
-       .verify_header  = ublimage_verify_header,
-       .print_header   = ublimage_print_header,
-       .set_header     = ublimage_set_header,
-       .check_params   = ublimage_check_params,
-};
-
-void init_ubl_image_type(void)
-{
-       register_image_type(&ublimage_params);
-}
+U_BOOT_IMAGE_TYPE(
+       ublimage,
+       "Davinci UBL boot support",
+       sizeof(struct ubl_header),
+       (void *)&ublimage_header,
+       ublimage_check_params,
+       ublimage_verify_header,
+       ublimage_print_header,
+       ublimage_set_header,
+       NULL,
+       ublimage_check_image_types,
+       NULL,
+       NULL
+);