]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
Merge branch 'master' of git://git.denx.de/u-boot-ti
authorTom Rini <trini@ti.com>
Mon, 27 Oct 2014 13:05:43 +0000 (09:05 -0400)
committerTom Rini <trini@ti.com>
Mon, 27 Oct 2014 13:05:43 +0000 (09:05 -0400)
308 files changed:
Makefile
README
arch/Kconfig
arch/arm/Kconfig
arch/arm/cpu/arm926ejs/at91/led.c
arch/arm/cpu/arm926ejs/kirkwood/Makefile
arch/arm/cpu/arm926ejs/kirkwood/cpu.c
arch/arm/cpu/arm926ejs/kirkwood/mpp.c
arch/arm/cpu/armv7/am33xx/board.c
arch/arm/cpu/armv7/armada-xp/Makefile [new file with mode: 0644]
arch/arm/cpu/armv7/armada-xp/cpu.c [new file with mode: 0644]
arch/arm/cpu/armv7/mx6/soc.c
arch/arm/cpu/armv7/omap3/board.c
arch/arm/cpu/armv7/omap3/emif4.c
arch/arm/cpu/armv7/omap3/sys_info.c
arch/arm/cpu/armv7/socfpga/misc.c
arch/arm/cpu/armv7/socfpga/u-boot-spl.lds
arch/arm/cpu/armv7/sunxi/Makefile
arch/arm/cpu/armv7/sunxi/board.c
arch/arm/cpu/armv7/sunxi/clock_sun4i.c
arch/arm/cpu/armv7/sunxi/clock_sun6i.c [new file with mode: 0644]
arch/arm/cpu/armv7/sunxi/cpu_info.c
arch/arm/cpu/armv7/sunxi/dram.c
arch/arm/cpu/armv7/sunxi/prcm.c [new file with mode: 0644]
arch/arm/cpu/armv7/tegra-common/Kconfig
arch/arm/cpu/armv7/tegra20/display.c
arch/arm/cpu/armv7/tegra30/Kconfig
arch/arm/cpu/armv7/uniphier/ph1-ld4/Makefile
arch/arm/cpu/armv7/uniphier/ph1-ld4/platdevice.c [new file with mode: 0644]
arch/arm/cpu/armv7/uniphier/ph1-pro4/Makefile
arch/arm/cpu/armv7/uniphier/ph1-pro4/platdevice.c [new file with mode: 0644]
arch/arm/cpu/armv7/uniphier/ph1-sld8/Makefile
arch/arm/cpu/armv7/uniphier/ph1-sld8/platdevice.c [new file with mode: 0644]
arch/arm/cpu/tegra-common/board.c
arch/arm/cpu/tegra-common/sys_info.c
arch/arm/dts/Makefile
arch/arm/dts/am335x-bone-common.dtsi
arch/arm/dts/dt-bindings/gpio/gpio.h [deleted file]
arch/arm/dts/tegra30-apalis.dts [new file with mode: 0644]
arch/arm/dts/tegra30-colibri.dts
arch/arm/imx-common/cpu.c
arch/arm/imx-common/misc.c
arch/arm/include/asm/arch-armada-xp/config.h [new file with mode: 0644]
arch/arm/include/asm/arch-armada-xp/cpu.h [new file with mode: 0644]
arch/arm/include/asm/arch-armada-xp/soc.h [new file with mode: 0644]
arch/arm/include/asm/arch-bcm2835/mbox.h
arch/arm/include/asm/arch-kirkwood/config.h
arch/arm/include/asm/arch-kirkwood/cpu.h
arch/arm/include/asm/arch-kirkwood/gpio.h
arch/arm/include/asm/arch-kirkwood/soc.h [moved from arch/arm/include/asm/arch-kirkwood/kirkwood.h with 90% similarity]
arch/arm/include/asm/arch-mvebu/spi.h [moved from arch/arm/include/asm/arch-kirkwood/spi.h with 100% similarity]
arch/arm/include/asm/arch-mxs/sys_proto.h
arch/arm/include/asm/arch-omap3/sys_proto.h
arch/arm/include/asm/arch-socfpga/spl.h [deleted file]
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 [new file with mode: 0644]
arch/arm/include/asm/arch-sunxi/cpu.h
arch/arm/include/asm/arch-sunxi/gpio.h
arch/arm/include/asm/arch-sunxi/mmc.h
arch/arm/include/asm/arch-sunxi/prcm.h [new file with mode: 0644]
arch/arm/include/asm/arch-sunxi/timer.h
arch/arm/include/asm/arch-sunxi/watchdog.h [new file with mode: 0644]
arch/arm/include/asm/arch-tegra/board.h
arch/arm/include/asm/arch-tegra114/mc.h [new file with mode: 0644]
arch/arm/include/asm/arch-tegra114/tegra.h
arch/arm/include/asm/arch-tegra20/mc.h [new file with mode: 0644]
arch/arm/include/asm/arch-tegra20/tegra.h
arch/arm/include/asm/arch-tegra30/mc.h [new file with mode: 0644]
arch/arm/include/asm/arch-tegra30/tegra.h
arch/arm/include/asm/arch-uniphier/platdevice.h [new file with mode: 0644]
arch/arm/include/asm/mach-types.h
arch/arm/include/asm/omap_gpio.h
arch/arm/include/asm/spl.h
arch/arm/include/asm/u-boot-arm.h
arch/arm/lib/board.c
arch/arm/lib/bootm.c
arch/arm/lib/interrupts.c
arch/arm/mvebu-common/Makefile [new file with mode: 0644]
arch/arm/mvebu-common/dram.c [moved from arch/arm/cpu/arm926ejs/kirkwood/dram.c with 57% similarity]
arch/arm/mvebu-common/gpio.c [new file with mode: 0644]
arch/arm/mvebu-common/mbus.c [new file with mode: 0644]
arch/arm/mvebu-common/timer.c [moved from arch/arm/cpu/arm926ejs/kirkwood/timer.c with 63% similarity]
arch/mips/Kconfig
arch/x86/Kconfig
arch/x86/config.mk
arch/x86/cpu/start.S
arch/x86/dts/coreboot.dtsi
arch/x86/dts/link.dts
arch/x86/include/asm/arch-coreboot/gpio.h [new file with mode: 0644]
arch/x86/include/asm/gpio.h
arch/x86/include/asm/ibmpc.h
arch/x86/lib/Makefile
arch/x86/lib/zimage.c
board/LaCie/net2big_v2/net2big_v2.c
board/LaCie/netspace_v2/netspace_v2.c
board/LaCie/wireless_space/wireless_space.c
board/Marvell/db-mv784mp-gp/Kconfig [new file with mode: 0644]
board/Marvell/db-mv784mp-gp/MAINTAINERS [new file with mode: 0644]
board/Marvell/db-mv784mp-gp/Makefile [new file with mode: 0644]
board/Marvell/db-mv784mp-gp/db-mv784mp-gp.c [new file with mode: 0644]
board/Marvell/db-mv784mp-gp/kwbimage.cfg [new file with mode: 0644]
board/Marvell/dreamplug/dreamplug.c
board/Marvell/guruplug/guruplug.c
board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c
board/Marvell/openrd/openrd.c
board/Marvell/rd6281a/rd6281a.c
board/Marvell/sheevaplug/sheevaplug.c
board/Seagate/dockstar/dockstar.c
board/Seagate/goflexhome/goflexhome.c
board/atmel/at91rm9200ek/led.c
board/atmel/at91sam9260ek/led.c
board/buffalo/lsxl/lsxl.c
board/chromebook-x86/coreboot/Makefile
board/chromebook-x86/coreboot/coreboot.c [new file with mode: 0644]
board/cloudengines/pogo_e02/pogo_e02.c
board/compulab/cm_fx6/cm_fx6.c
board/d-link/dns325/dns325.c
board/iomega/iconnect/iconnect.c
board/isee/igep00x0/igep00x0.c
board/karo/tk71/tk71.c
board/keymile/km_arm/km_arm.c
board/logicpd/zoom1/zoom1.c
board/maxbcm/Kconfig [new file with mode: 0644]
board/maxbcm/MAINTAINERS [new file with mode: 0644]
board/maxbcm/Makefile [new file with mode: 0644]
board/maxbcm/kwbimage.cfg [new file with mode: 0644]
board/maxbcm/maxbcm.c [new file with mode: 0644]
board/nvidia/common/board.c
board/nvidia/common/emc.c
board/nvidia/jetson-tk1/pinmux-config-jetson-tk1.h
board/nvidia/seaboard/seaboard.c
board/overo/overo.c
board/raidsonic/ib62x0/ib62x0.c
board/raspberrypi/rpi_b/rpi_b.c
board/samsung/common/board.c
board/sunxi/Kconfig
board/sunxi/MAINTAINERS
board/sunxi/Makefile
board/sunxi/board.c
board/sunxi/dram_a20_olinuxino_l2.c [new file with mode: 0644]
board/technexion/twister/twister.c
board/ti/beagle/beagle.c
board/ti/beagle/led.c
board/toradex/apalis_t30/Kconfig [new file with mode: 0644]
board/toradex/apalis_t30/MAINTAINERS [new file with mode: 0644]
board/toradex/apalis_t30/Makefile [new file with mode: 0644]
board/toradex/apalis_t30/apalis_t30.c [new file with mode: 0644]
board/toradex/apalis_t30/pinmux-config-apalis_t30.h [new file with mode: 0644]
board/toradex/colibri_t30/colibri_t30.c
board/w7o/fsboot.c
common/board_f.c
common/board_r.c
common/cmd_elf.c
common/cmd_gpio.c
common/console.c
common/env_nand.c
common/image-fit.c
common/menu.c
common/modem.c
common/stdio.c
config.mk
configs/A10s-OLinuXino-M_defconfig
configs/A20-OLinuXino-Lime2_defconfig [new file with mode: 0644]
configs/A20-OLinuXino_MICRO_defconfig
configs/Colombus_defconfig [new file with mode: 0644]
configs/Ippo_q8h_defconfig [new file with mode: 0644]
configs/Mele_M3_defconfig [new file with mode: 0644]
configs/am335x_boneblack_defconfig
configs/am335x_boneblack_vboot_defconfig
configs/apalis_t30_defconfig [new file with mode: 0644]
configs/db-mv784mp-gp_defconfig [new file with mode: 0644]
configs/maxbcm_defconfig [new file with mode: 0644]
configs/ph1_ld4_defconfig
configs/ph1_pro4_defconfig
configs/ph1_sld8_defconfig
disk/part.c
doc/driver-model/README.txt
drivers/block/mvsata_ide.c
drivers/core/Kconfig
drivers/gpio/Kconfig
drivers/gpio/bcm2835_gpio.c
drivers/gpio/gpio-uclass.c
drivers/gpio/intel_ich6_gpio.c
drivers/gpio/kw_gpio.c
drivers/gpio/mxc_gpio.c
drivers/gpio/omap_gpio.c
drivers/gpio/s5p_gpio.c
drivers/gpio/sandbox.c
drivers/gpio/tegra_gpio.c
drivers/i2c/designware_i2c.c
drivers/i2c/mvtwsi.c
drivers/i2c/tegra_i2c.c
drivers/input/tegra-kbc.c
drivers/misc/cros_ec_lpc.c
drivers/mmc/bcm2835_sdhci.c
drivers/mmc/mvebu_mmc.c
drivers/mmc/omap_hsmmc.c
drivers/mmc/sdhci.c
drivers/mmc/sunxi_mmc.c
drivers/mmc/tegra_mmc.c
drivers/mtd/cfi_flash.c
drivers/mtd/nand/kirkwood_nand.c
drivers/mtd/nand/omap_gpmc.c
drivers/net/Makefile
drivers/net/davinci_emac.c
drivers/net/fec_mxc.c
drivers/net/mvgbe.c
drivers/net/mvneta.c [new file with mode: 0644]
drivers/net/phy/phy.c
drivers/pci/pci.c
drivers/rtc/mvrtc.h
drivers/serial/Kconfig
drivers/serial/Makefile
drivers/serial/ns16550.c
drivers/serial/serial-uclass.c
drivers/serial/serial.c
drivers/serial/serial_coreboot.c [new file with mode: 0644]
drivers/serial/serial_mxc.c
drivers/serial/serial_ns16550.c
drivers/serial/serial_omap.c [new file with mode: 0644]
drivers/serial/serial_pl01x.c
drivers/serial/serial_s3c24x0.c
drivers/serial/serial_sh.c
drivers/serial/serial_uniphier.c
drivers/spi/Kconfig
drivers/spi/kirkwood_spi.c
drivers/usb/eth/asix.c
drivers/usb/host/Makefile
drivers/usb/host/dwc2.c [new file with mode: 0644]
drivers/usb/host/dwc2.h [new file with mode: 0644]
drivers/usb/host/ehci-hcd.c
drivers/usb/host/ehci-marvell.c
drivers/video/cfb_console.c
drivers/video/exynos_fb.c
drivers/video/ipu_common.c
drivers/video/ipu_disp.c
drivers/video/mxc_ipuv3_fb.c
include/asm-generic/gpio.h
include/bootm.h
include/common.h
include/config_fallbacks.h
include/configs/apalis_t30.h [new file with mode: 0644]
include/configs/cm_fx6.h
include/configs/colibri_t30.h
include/configs/coreboot.h
include/configs/db-mv784mp-gp.h [new file with mode: 0644]
include/configs/edb93xx.h
include/configs/ks2_evm.h
include/configs/ls1021aqds.h
include/configs/ls1021atwr.h
include/configs/ls2085a_common.h
include/configs/maxbcm.h [new file with mode: 0644]
include/configs/ph1_ld4.h
include/configs/ph1_pro4.h
include/configs/ph1_sld8.h
include/configs/rpi_b.h
include/configs/socfpga_common.h
include/configs/socfpga_cyclone5.h
include/configs/sun4i.h
include/configs/sun5i.h
include/configs/sun6i.h [new file with mode: 0644]
include/configs/sun7i.h
include/configs/sun8i.h [new file with mode: 0644]
include/configs/sunxi-common.h
include/configs/tegra-common-post.h
include/configs/tegra-common.h
include/configs/ti_am335x_common.h
include/configs/ti_omap3_common.h
include/configs/tqma6.h
include/configs/uniphier-common.h
include/dm/platform_data/serial-uniphier.h [new file with mode: 0644]
include/dm/platform_data/serial_mxc.h [moved from include/serial_mxc.h with 100% similarity]
include/dm/platform_data/serial_pl01x.h [moved from include/serial_pl01x.h with 100% similarity]
include/dm/test.h
include/dt-bindings/pinctrl/am33xx.h [moved from arch/arm/dts/dt-bindings/pinctrl/am33xx.h with 100% similarity]
include/dt-bindings/pinctrl/omap.h [moved from arch/arm/dts/dt-bindings/pinctrl/omap.h with 100% similarity]
include/elf.h
include/fdt_support.h
include/fdtdec.h
include/ide.h
include/libfdt.h
include/linux/mbus.h [new file with mode: 0644]
include/linux/string.h
include/linux/usb/musb.h
include/mmc.h
include/netdev.h
include/ns16550.h
include/phy.h
include/spl.h
include/usb.h
lib/Kconfig
lib/fdtdec.c
lib/libfdt/fdt_ro.c
lib/lmb.c
lib/time.c
net/eth.c
net/tftp.c
post/post.c
scripts/Makefile.spl
scripts/multiconfig.sh
test/dm/core.c
test/dm/gpio.c
test/dm/test-main.c
tools/Makefile
tools/kwbimage.c
tools/kwboot.c
tools/socfpgaimage.c

index 99097e1e57288ebab699a4678f3635f36f67837c..26dacee98e07d0c203e0156bae557ea95a006d29 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -652,6 +652,10 @@ ifneq (,$(filter $(SOC), mx25 mx27 mx5 mx6 mx31 mx35 mxs vf610))
 libs-y += arch/$(ARCH)/imx-common/
 endif
 
+ifneq (,$(filter $(SOC), armada-xp kirkwood))
+libs-y += arch/$(ARCH)/mvebu-common/
+endif
+
 libs-$(CONFIG_ARM) += arch/arm/cpu/
 libs-$(CONFIG_PPC) += arch/powerpc/cpu/
 
@@ -670,13 +674,9 @@ u-boot-main := $(libs-y)
 
 
 # Add GCC lib
-ifdef CONFIG_USE_PRIVATE_LIBGCC
 ifeq ($(CONFIG_USE_PRIVATE_LIBGCC),y)
 PLATFORM_LIBGCC = arch/$(ARCH)/lib/lib.a
 else
-PLATFORM_LIBGCC = -L $(CONFIG_USE_PRIVATE_LIBGCC) -lgcc
-endif
-else
 PLATFORM_LIBGCC := -L $(shell dirname `$(CC) $(c_flags) -print-libgcc-file-name`) -lgcc
 endif
 PLATFORM_LIBS += $(PLATFORM_LIBGCC)
@@ -754,6 +754,11 @@ endif
 endif
 endif
 
+# Add optional build target if defined in board/cpu/soc headers
+ifneq ($(CONFIG_BUILD_TARGET),)
+ALL-y += $(CONFIG_BUILD_TARGET:"%"=%)
+endif
+
 LDFLAGS_u-boot += $(LDFLAGS_FINAL)
 ifneq ($(CONFIG_SYS_TEXT_BASE),)
 LDFLAGS_u-boot += -Ttext $(CONFIG_SYS_TEXT_BASE)
diff --git a/README b/README
index 19abe20035394d07d1191b434f89124ecee8f6ea..2808dd1eb9a27cdacadb86f1a2dd9eb26121ec29 100644 (file)
--- a/README
+++ b/README
@@ -623,13 +623,6 @@ The following options need to be configured:
                exists, unlike the similar options in the Linux kernel. Do not
                set these options unless they apply!
 
-- CPU timer options:
-               CONFIG_SYS_HZ
-
-               The frequency of the timer returned by get_timer().
-               get_timer() must operate in milliseconds and this CONFIG
-               option must be set to 1000.
-
 - Linux Kernel Interface:
                CONFIG_CLOCKS_IN_MHZ
 
@@ -1465,6 +1458,9 @@ The following options need to be configured:
                CONFIG_USB_EHCI_TXFIFO_THRESH enables setting of the
                txfilltuning field in the EHCI controller on reset.
 
+               CONFIG_USB_DWC2_REG_ADDR the physical CPU address of the DWC2
+               HW module registers.
+
 - USB Device:
                Define the below if you wish to use the USB console.
                Once firmware is rebuilt from a serial console issue the
@@ -2722,6 +2718,14 @@ CBFS (Coreboot Filesystem) support
                200 ms.
 
 - Configuration Management:
+               CONFIG_BUILD_TARGET
+
+               Some SoCs need special image types (e.g. U-Boot binary
+               with a special header) as build targets. By defining
+               CONFIG_BUILD_TARGET in the SoC / board header, this
+               special image will be automatically built upon calling
+               make / MAKEALL.
+
                CONFIG_IDENT_STRING
 
                If defined, this string will be added to the U-Boot
@@ -2830,10 +2834,6 @@ CBFS (Coreboot Filesystem) support
 
                Enable auto completion of commands using TAB.
 
-               Note that this feature has NOT been implemented yet
-               for the "hush" shell.
-
-
                CONFIG_SYS_HUSH_PARSER
 
                Define this variable to enable the "hush" shell (from
index bf2676469c7131dd924139cf42dd392b0902bbc3..f63cc5a7e9440416c351e612eb5c8615693aa037 100644 (file)
@@ -7,6 +7,7 @@ config ARC
 
 config ARM
        bool "ARM architecture"
+       select HAVE_PRIVATE_LIBGCC
        select SUPPORT_OF_CONTROL
 
 config AVR32
@@ -24,6 +25,7 @@ config MICROBLAZE
 
 config MIPS
        bool "MIPS architecture"
+       select HAVE_PRIVATE_LIBGCC
 
 config NDS32
        bool "NDS32 architecture"
@@ -36,6 +38,7 @@ config OPENRISC
 
 config PPC
        bool "PowerPC architecture"
+       select HAVE_PRIVATE_LIBGCC
 
 config SANDBOX
        bool "Sandbox"
@@ -43,12 +46,14 @@ config SANDBOX
 
 config SH
        bool "SuperH architecture"
+       select HAVE_PRIVATE_LIBGCC
 
 config SPARC
        bool "SPARC architecture"
 
 config X86
        bool "x86 architecture"
+       select HAVE_PRIVATE_LIBGCC
        select SUPPORT_OF_CONTROL
 
 endchoice
index 72558b85620a638c2945a58ccb3ebbc1faea06b6..8f910f39a37ec5350d094070fdfdd6a2986519b8 100644 (file)
@@ -141,6 +141,12 @@ config ARCH_DAVINCI
 config KIRKWOOD
        bool "Marvell Kirkwood"
 
+config TARGET_DB_MV784MP_GP
+       bool "Support db-mv784mp-gp"
+
+config TARGET_MAXBCM
+       bool "Support maxbcm"
+
 config TARGET_DEVKIT3250
        bool "Support devkit3250"
 
@@ -444,9 +450,15 @@ config TARGET_SUN4I
 config TARGET_SUN5I
        bool "Support sun5i"
 
+config TARGET_SUN6I
+       bool "Support sun6i"
+
 config TARGET_SUN7I
        bool "Support sun7i"
 
+config TARGET_SUN8I
+       bool "Support sun8i"
+
 config TARGET_SNOWBALL
        bool "Support snowball"
 
@@ -567,6 +579,7 @@ source "board/BuS/eb_cpux9k2/Kconfig"
 source "board/BuS/vl_ma2sc/Kconfig"
 source "board/CarMediaLab/flea3/Kconfig"
 source "board/Marvell/aspenite/Kconfig"
+source "board/Marvell/db-mv784mp-gp/Kconfig"
 source "board/Marvell/dkb/Kconfig"
 source "board/Marvell/gplugd/Kconfig"
 source "board/afeb9260/Kconfig"
@@ -648,6 +661,7 @@ source "board/jornada/Kconfig"
 source "board/karo/tx25/Kconfig"
 source "board/logicpd/imx27lite/Kconfig"
 source "board/logicpd/imx31_litekit/Kconfig"
+source "board/maxbcm/Kconfig"
 source "board/mpl/vcma9/Kconfig"
 source "board/olimex/mx23_olinuxino/Kconfig"
 source "board/palmld/Kconfig"
index 46ed055023978aee455ccfdb74155c31705ebb41..b8d5c785df4d36557168e3f178738fdc9f717006 100644 (file)
@@ -9,6 +9,7 @@
 #include <common.h>
 #include <asm/gpio.h>
 #include <asm/arch/gpio.h>
+#include <status_led.h>
 
 #ifdef CONFIG_RED_LED
 void red_led_on(void)
index c230ce8994e7f5ec3e0b069758f5982d89190cd1..df4756e4bdb1fd072e5356a65e9d4ec7e51b54fa 100644 (file)
@@ -7,7 +7,5 @@
 #
 
 obj-y  = cpu.o
-obj-y  += dram.o
-obj-y  += mpp.o
-obj-y  += timer.o
 obj-y  += cache.o
+obj-y  += mpp.o
index 881e2de81b328ca71d106a0bdd8630202537268d..9e412bbb04d585c949f321ddd04032a652a92e00 100644 (file)
@@ -9,14 +9,11 @@
 #include <common.h>
 #include <netdev.h>
 #include <asm/cache.h>
-#include <u-boot/md5.h>
 #include <asm/io.h>
 #include <asm/arch/cpu.h>
-#include <asm/arch/kirkwood.h>
+#include <asm/arch/soc.h>
 #include <mvebu_mmc.h>
 
-#define BUFLEN 16
-
 void reset_cpu(unsigned long ignored)
 {
        struct kwcpu_registers *cpureg =
@@ -29,31 +26,6 @@ void reset_cpu(unsigned long ignored)
        while (1) ;
 }
 
-/*
- * Generates Ramdom hex number reading some time varient system registers
- * and using md5 algorithm
- */
-unsigned char get_random_hex(void)
-{
-       int i;
-       u32 inbuf[BUFLEN];
-       u8 outbuf[BUFLEN];
-
-       /*
-        * in case of 88F6281/88F6282/88F6192 A0,
-        * Bit7 need to reset to generate random values in KW_REG_UNDOC_0x1470
-        * Soc reg offsets KW_REG_UNDOC_0x1470 and KW_REG_UNDOC_0x1478 are
-        * reserved regs and does not have names at this moment
-        * (no errata available)
-        */
-       writel(readl(KW_REG_UNDOC_0x1478) & ~(1 << 7), KW_REG_UNDOC_0x1478);
-       for (i = 0; i < BUFLEN; i++) {
-               inbuf[i] = readl(KW_REG_UNDOC_0x1470);
-       }
-       md5((u8 *) inbuf, (BUFLEN * sizeof(u32)), outbuf);
-       return outbuf[outbuf[7] % 0x0f];
-}
-
 /*
  * Window Size
  * Used with the Base register to set the address window size and location.
@@ -139,50 +111,6 @@ int kw_config_adr_windows(void)
        return 0;
 }
 
-/*
- * kw_config_gpio - GPIO configuration
- */
-void kw_config_gpio(u32 gpp0_oe_val, u32 gpp1_oe_val, u32 gpp0_oe, u32 gpp1_oe)
-{
-       struct kwgpio_registers *gpio0reg =
-               (struct kwgpio_registers *)KW_GPIO0_BASE;
-       struct kwgpio_registers *gpio1reg =
-               (struct kwgpio_registers *)KW_GPIO1_BASE;
-
-       /* Init GPIOS to default values as per board requirement */
-       writel(gpp0_oe_val, &gpio0reg->dout);
-       writel(gpp1_oe_val, &gpio1reg->dout);
-       writel(gpp0_oe, &gpio0reg->oe);
-       writel(gpp1_oe, &gpio1reg->oe);
-}
-
-/*
- * kw_config_mpp - Multi-Purpose Pins Functionality configuration
- *
- * Each MPP can be configured to different functionality through
- * MPP control register, ref (sec 6.1 of kirkwood h/w specification)
- *
- * There are maximum 64 Multi-Pourpose Pins on Kirkwood
- * Each MPP functionality can be configuration by a 4bit value
- * of MPP control reg, the value and associated functionality depends
- * upon used SoC varient
- */
-int kw_config_mpp(u32 mpp0_7, u32 mpp8_15, u32 mpp16_23, u32 mpp24_31,
-               u32 mpp32_39, u32 mpp40_47, u32 mpp48_55)
-{
-       u32 *mppreg = (u32 *) KW_MPP_BASE;
-
-       /* program mpp registers */
-       writel(mpp0_7, &mppreg[0]);
-       writel(mpp8_15, &mppreg[1]);
-       writel(mpp16_23, &mppreg[2]);
-       writel(mpp24_31, &mppreg[3]);
-       writel(mpp32_39, &mppreg[4]);
-       writel(mpp40_47, &mppreg[5]);
-       writel(mpp48_55, &mppreg[6]);
-       return 0;
-}
-
 /*
  * SYSRSTn Duration Counter Support
  *
index 0ba6f098cb6b2c6486dc1a79375a6482634327f9..7222504ed3a43033d93959af3c9857f310642865 100644 (file)
@@ -12,7 +12,7 @@
 #include <common.h>
 #include <asm/io.h>
 #include <asm/arch/cpu.h>
-#include <asm/arch/kirkwood.h>
+#include <asm/arch/soc.h>
 #include <asm/arch/mpp.h>
 
 static u32 kirkwood_variant(void)
index 828d10bb5a4e59bf9aaa1a0ddf0775af22749dc3..29b1d734382a3c8a83a41cad409a8b5b6e217d7e 100644 (file)
@@ -9,7 +9,9 @@
  */
 
 #include <common.h>
+#include <dm.h>
 #include <errno.h>
+#include <ns16550.h>
 #include <spl.h>
 #include <asm/arch/cpu.h>
 #include <asm/arch/hardware.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
+#ifdef CONFIG_DM_GPIO
+static const struct omap_gpio_platdata am33xx_gpio[] = {
+       { 0, AM33XX_GPIO0_BASE, METHOD_GPIO_24XX },
+       { 1, AM33XX_GPIO1_BASE, METHOD_GPIO_24XX },
+       { 2, AM33XX_GPIO2_BASE, METHOD_GPIO_24XX },
+       { 3, AM33XX_GPIO3_BASE, METHOD_GPIO_24XX },
+#ifdef CONFIG_AM43XX
+       { 4, AM33XX_GPIO4_BASE, METHOD_GPIO_24XX },
+       { 5, AM33XX_GPIO5_BASE, METHOD_GPIO_24XX },
+#endif
+};
+
+U_BOOT_DEVICES(am33xx_gpios) = {
+       { "gpio_omap", &am33xx_gpio[0] },
+       { "gpio_omap", &am33xx_gpio[1] },
+       { "gpio_omap", &am33xx_gpio[2] },
+       { "gpio_omap", &am33xx_gpio[3] },
+#ifdef CONFIG_AM43XX
+       { "gpio_omap", &am33xx_gpio[4] },
+       { "gpio_omap", &am33xx_gpio[5] },
+#endif
+};
+
+# ifndef CONFIG_OF_CONTROL
+/*
+ * TODO(sjg@chromium.org): When we can move SPL serial to DM, we can remove
+ * the CONFIGs. At the same time, we should move this to the board files.
+ */
+static const struct ns16550_platdata am33xx_serial[] = {
+       { CONFIG_SYS_NS16550_COM1, 2, CONFIG_SYS_NS16550_CLK },
+#  ifdef CONFIG_SYS_NS16550_COM2
+       { CONFIG_SYS_NS16550_COM2, 2, CONFIG_SYS_NS16550_CLK },
+#   ifdef CONFIG_SYS_NS16550_COM3
+       { CONFIG_SYS_NS16550_COM3, 2, CONFIG_SYS_NS16550_CLK },
+       { CONFIG_SYS_NS16550_COM4, 2, CONFIG_SYS_NS16550_CLK },
+       { CONFIG_SYS_NS16550_COM5, 2, CONFIG_SYS_NS16550_CLK },
+       { CONFIG_SYS_NS16550_COM6, 2, CONFIG_SYS_NS16550_CLK },
+#   endif
+#  endif
+};
+
+U_BOOT_DEVICES(am33xx_uarts) = {
+       { "serial_omap", &am33xx_serial[0] },
+#  ifdef CONFIG_SYS_NS16550_COM2
+       { "serial_omap", &am33xx_serial[1] },
+#   ifdef CONFIG_SYS_NS16550_COM3
+       { "serial_omap", &am33xx_serial[2] },
+       { "serial_omap", &am33xx_serial[3] },
+       { "serial_omap", &am33xx_serial[4] },
+       { "serial_omap", &am33xx_serial[5] },
+#   endif
+#  endif
+};
+# endif
+
+#else
+
 static const struct gpio_bank gpio_bank_am33xx[] = {
        { (void *)AM33XX_GPIO0_BASE, METHOD_GPIO_24XX },
        { (void *)AM33XX_GPIO1_BASE, METHOD_GPIO_24XX },
@@ -49,6 +108,8 @@ static const struct gpio_bank gpio_bank_am33xx[] = {
 
 const struct gpio_bank *const omap_gpio_bank = gpio_bank_am33xx;
 
+#endif
+
 #if defined(CONFIG_OMAP_HSMMC) && !defined(CONFIG_SPL_BUILD)
 int cpu_mmc_init(bd_t *bis)
 {
diff --git a/arch/arm/cpu/armv7/armada-xp/Makefile b/arch/arm/cpu/armv7/armada-xp/Makefile
new file mode 100644 (file)
index 0000000..885dcee
--- /dev/null
@@ -0,0 +1,7 @@
+#
+# Copyright (C) 2014 Stefan Roese <sr@denx.de>
+#
+# SPDX-License-Identifier:     GPL-2.0+
+#
+
+obj-y  = cpu.o
diff --git a/arch/arm/cpu/armv7/armada-xp/cpu.c b/arch/arm/cpu/armv7/armada-xp/cpu.c
new file mode 100644 (file)
index 0000000..1cf70a9
--- /dev/null
@@ -0,0 +1,193 @@
+/*
+ * Copyright (C) 2014 Stefan Roese <sr@denx.de>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <common.h>
+#include <netdev.h>
+#include <asm/io.h>
+#include <asm/arch/cpu.h>
+#include <asm/arch/soc.h>
+
+#define DDR_BASE_CS_OFF(n)     (0x0000 + ((n) << 3))
+#define DDR_SIZE_CS_OFF(n)     (0x0004 + ((n) << 3))
+
+static struct mbus_win windows[] = {
+       /* PCIE MEM address space */
+       { DEFADR_PCI_MEM, 256 << 20, CPU_TARGET_PCIE13, CPU_ATTR_PCIE_MEM },
+
+       /* PCIE IO address space */
+       { DEFADR_PCI_IO, 64 << 10, CPU_TARGET_PCIE13, CPU_ATTR_PCIE_IO },
+
+       /* SPI */
+       { DEFADR_SPIF, 8 << 20, CPU_TARGET_DEVICEBUS_BOOTROM_SPI,
+         CPU_ATTR_SPIFLASH },
+
+       /* NOR */
+       { DEFADR_BOOTROM, 8 << 20, CPU_TARGET_DEVICEBUS_BOOTROM_SPI,
+         CPU_ATTR_BOOTROM },
+};
+
+void reset_cpu(unsigned long ignored)
+{
+       struct mvebu_system_registers *reg =
+               (struct mvebu_system_registers *)MVEBU_SYSTEM_REG_BASE;
+
+       writel(readl(&reg->rstoutn_mask) | 1, &reg->rstoutn_mask);
+       writel(readl(&reg->sys_soft_rst) | 1, &reg->sys_soft_rst);
+       while (1)
+               ;
+}
+
+#if defined(CONFIG_DISPLAY_CPUINFO)
+int print_cpuinfo(void)
+{
+       u16 devid = (readl(MVEBU_REG_PCIE_DEVID) >> 16) & 0xffff;
+       u8 revid = readl(MVEBU_REG_PCIE_REVID) & 0xff;
+
+       puts("SoC:   ");
+
+       switch (devid) {
+       case SOC_MV78460_ID:
+               puts("MV78460-");
+               break;
+       default:
+               puts("Unknown-");
+               break;
+       }
+
+       switch (revid) {
+       case 1:
+               puts("A0\n");
+               break;
+       case 2:
+               puts("B0\n");
+               break;
+       default:
+               puts("??\n");
+               break;
+       }
+
+       return 0;
+}
+#endif /* CONFIG_DISPLAY_CPUINFO */
+
+/*
+ * This function initialize Controller DRAM Fastpath windows.
+ * It takes the CS size information from the 0x1500 scratch registers
+ * and sets the correct windows sizes and base addresses accordingly.
+ *
+ * These values are set in the scratch registers by the Marvell
+ * DDR3 training code, which is executed by the BootROM before the
+ * main payload (U-Boot) is executed. This training code is currently
+ * only available in the Marvell U-Boot version. It needs to be
+ * ported to mainline U-Boot SPL at some point.
+ */
+static void update_sdram_window_sizes(void)
+{
+       u64 base = 0;
+       u32 size, temp;
+       int i;
+
+       for (i = 0; i < SDRAM_MAX_CS; i++) {
+               size = readl((MVEBU_SDRAM_SCRATCH + (i * 8))) & SDRAM_ADDR_MASK;
+               if (size != 0) {
+                       size |= ~(SDRAM_ADDR_MASK);
+
+                       /* Set Base Address */
+                       temp = (base & 0xFF000000ll) | ((base >> 32) & 0xF);
+                       writel(temp, MVEBU_SDRAM_BASE + DDR_BASE_CS_OFF(i));
+
+                       /*
+                        * Check if out of max window size and resize
+                        * the window
+                        */
+                       temp = (readl(MVEBU_SDRAM_BASE + DDR_SIZE_CS_OFF(i)) &
+                               ~(SDRAM_ADDR_MASK)) | 1;
+                       temp |= (size & SDRAM_ADDR_MASK);
+                       writel(temp, MVEBU_SDRAM_BASE + DDR_SIZE_CS_OFF(i));
+
+                       base += ((u64)size + 1);
+               } else {
+                       /*
+                        * Disable window if not used, otherwise this
+                        * leads to overlapping enabled windows with
+                        * pretty strange results
+                        */
+                       clrbits_le32(MVEBU_SDRAM_BASE + DDR_SIZE_CS_OFF(i), 1);
+               }
+       }
+}
+
+#ifdef CONFIG_ARCH_CPU_INIT
+int arch_cpu_init(void)
+{
+       /* Linux expects the internal registers to be at 0xf1000000 */
+       writel(SOC_REGS_PHY_BASE, INTREG_BASE_ADDR_REG);
+
+       /*
+        * We need to call mvebu_mbus_probe() before calling
+        * update_sdram_window_sizes() as it disables all previously
+        * configured mbus windows and then configures them as
+        * required for U-Boot. Calling update_sdram_window_sizes()
+        * without this configuration will not work, as the internal
+        * registers can't be accessed reliably because of potenial
+        * double mapping.
+        * After updating the SDRAM access windows we need to call
+        * mvebu_mbus_probe() again, as this now correctly configures
+        * the SDRAM areas that are later used by the MVEBU drivers
+        * (e.g. USB, NETA).
+        */
+
+       /*
+        * First disable all windows
+        */
+       mvebu_mbus_probe(NULL, 0);
+
+       /*
+        * Now the SDRAM access windows can be reconfigured using
+        * the information in the SDRAM scratch pad registers
+        */
+       update_sdram_window_sizes();
+
+       /*
+        * Finally the mbus windows can be configured with the
+        * updated SDRAM sizes
+        */
+       mvebu_mbus_probe(windows, ARRAY_SIZE(windows));
+
+       return 0;
+}
+#endif /* CONFIG_ARCH_CPU_INIT */
+
+/*
+ * SOC specific misc init
+ */
+#if defined(CONFIG_ARCH_MISC_INIT)
+int arch_misc_init(void)
+{
+       /* Nothing yet, perhaps we need something here later */
+       return 0;
+}
+#endif /* CONFIG_ARCH_MISC_INIT */
+
+#ifdef CONFIG_MVNETA
+int cpu_eth_init(bd_t *bis)
+{
+       mvneta_initialize(bis, MVEBU_EGIGA0_BASE, 0, CONFIG_PHY_BASE_ADDR + 0);
+       mvneta_initialize(bis, MVEBU_EGIGA1_BASE, 1, CONFIG_PHY_BASE_ADDR + 1);
+       mvneta_initialize(bis, MVEBU_EGIGA2_BASE, 2, CONFIG_PHY_BASE_ADDR + 2);
+       mvneta_initialize(bis, MVEBU_EGIGA3_BASE, 3, CONFIG_PHY_BASE_ADDR + 3);
+
+       return 0;
+}
+#endif
+
+#ifndef CONFIG_SYS_DCACHE_OFF
+void enable_caches(void)
+{
+       /* Enable D-cache. I-cache is already enabled in start.S */
+       dcache_enable();
+}
+#endif
index 63524222539134df5c69c6b2179a334850199ec4..a202b0318e0659e02551027c6de9e6fa9e56b095 100644 (file)
@@ -9,6 +9,7 @@
 
 #include <common.h>
 #include <asm/armv7.h>
+#include <asm/bootm.h>
 #include <asm/pl310.h>
 #include <asm/errno.h>
 #include <asm/io.h>
index 667e77ff05ba22429fdf101e0884856e5eb54e62..c942fe67eeb2148c0dcce6abbaea21d3193653c2 100644 (file)
  * SPDX-License-Identifier:    GPL-2.0+
  */
 #include <common.h>
+#include <dm.h>
+#include <mmc.h>
 #include <spl.h>
 #include <asm/io.h>
 #include <asm/arch/sys_proto.h>
 #include <asm/arch/mem.h>
 #include <asm/cache.h>
 #include <asm/armv7.h>
-#include <asm/arch/gpio.h>
+#include <asm/gpio.h>
 #include <asm/omap_common.h>
 #include <asm/arch/mmc_host_def.h>
 #include <i2c.h>
@@ -38,6 +40,27 @@ static void omap3_setup_aux_cr(void);
 static void omap3_invalidate_l2_cache_secure(void);
 #endif
 
+#ifdef CONFIG_DM_GPIO
+static const struct omap_gpio_platdata omap34xx_gpio[] = {
+       { 0, OMAP34XX_GPIO1_BASE, METHOD_GPIO_24XX },
+       { 1, OMAP34XX_GPIO2_BASE, METHOD_GPIO_24XX },
+       { 2, OMAP34XX_GPIO3_BASE, METHOD_GPIO_24XX },
+       { 3, OMAP34XX_GPIO4_BASE, METHOD_GPIO_24XX },
+       { 4, OMAP34XX_GPIO5_BASE, METHOD_GPIO_24XX },
+       { 5, OMAP34XX_GPIO6_BASE, METHOD_GPIO_24XX },
+};
+
+U_BOOT_DEVICES(am33xx_gpios) = {
+       { "gpio_omap", &omap34xx_gpio[0] },
+       { "gpio_omap", &omap34xx_gpio[1] },
+       { "gpio_omap", &omap34xx_gpio[2] },
+       { "gpio_omap", &omap34xx_gpio[3] },
+       { "gpio_omap", &omap34xx_gpio[4] },
+       { "gpio_omap", &omap34xx_gpio[5] },
+};
+
+#else
+
 static const struct gpio_bank gpio_bank_34xx[6] = {
        { (void *)OMAP34XX_GPIO1_BASE, METHOD_GPIO_24XX },
        { (void *)OMAP34XX_GPIO2_BASE, METHOD_GPIO_24XX },
@@ -49,6 +72,8 @@ static const struct gpio_bank gpio_bank_34xx[6] = {
 
 const struct gpio_bank *const omap_gpio_bank = gpio_bank_34xx;
 
+#endif
+
 #ifdef CONFIG_SPL_BUILD
 /*
 * We use static variables because global data is not ready yet.
@@ -266,7 +291,7 @@ int __weak misc_init_r(void)
  * Routine: wait_for_command_complete
  * Description: Wait for posting to finish on watchdog
  *****************************************************************************/
-void wait_for_command_complete(struct watchdog *wd_base)
+static void wait_for_command_complete(struct watchdog *wd_base)
 {
        int pending = 1;
        do {
index 6c7330a0cabdec269698bad41aa2cf0e3a733fdb..a2aadc9816975e7ec00da1a8874ce4ebf414a188 100644 (file)
@@ -61,7 +61,7 @@ u32 get_sdr_cs_offset(u32 cs)
  *  - Init the emif4 module for DDR access
  *  - Early init routines, called from flash or SRAM.
  */
-void do_emif4_init(void)
+static void do_emif4_init(void)
 {
        unsigned int regval;
        /* Set the DDR PHY parameters in PHY ctrl registers */
index bef5f05eaa71e36e0323f12e82c2377435c2421e..bbb65bbe7263674c2b47b97ee05a9f588ed1c58f 100644 (file)
@@ -16,6 +16,8 @@
 #include <asm/io.h>
 #include <asm/arch/mem.h>      /* get mem tables */
 #include <asm/arch/sys_proto.h>
+#include <asm/bootm.h>
+
 #include <i2c.h>
 #include <linux/compiler.h>
 
@@ -202,7 +204,7 @@ u32 __weak get_board_rev(void)
 /********************************************************
  *  get_base(); get upper addr of current execution
  *******************************************************/
-u32 get_base(void)
+static u32 get_base(void)
 {
        u32 val;
 
index 0eab264668c8502b775b219fffea48797a9f7447..8c3e5f7cd423c608ade2409fc233c0c706251b9d 100644 (file)
@@ -176,7 +176,7 @@ static void socfpga_nic301_slave_ns(void)
 
 static uint32_t iswgrp_handoff[8];
 
-int misc_init_r(void)
+int arch_early_init_r(void)
 {
        int i;
        for (i = 0; i < 8; i++) /* Cache initial SW setting regs */
index db9bdad7d6c94e62308b89574719c75d17ed5054..569fa418f465683a1d40d553d3921728b99b2b77 100644 (file)
@@ -42,13 +42,4 @@ SECTIONS
                . = ALIGN(4);
                __bss_end = .;
        } >.sdram
-
-       . = ALIGN(8);
-       __malloc_start = .;
-       . = . + CONFIG_SPL_MALLOC_SIZE;
-       __malloc_end = .;
-
-       . = . + CONFIG_SPL_STACK_SIZE;
-       . = ALIGN(8);
-       __stack_start = .;
 }
index e9721b27b64595d27918a396954329ae68acc44c..24f1daee64766d1631122a65dcb13dcb88dbc8ea 100644 (file)
@@ -11,9 +11,13 @@ obj-y        += timer.o
 obj-y  += board.o
 obj-y  += clock.o
 obj-y  += pinmux.o
+obj-$(CONFIG_SUN6I)    += prcm.o
+obj-$(CONFIG_SUN8I)    += prcm.o
 obj-$(CONFIG_SUN4I)    += clock_sun4i.o
 obj-$(CONFIG_SUN5I)    += clock_sun4i.o
+obj-$(CONFIG_SUN6I)    += clock_sun6i.o
 obj-$(CONFIG_SUN7I)    += clock_sun4i.o
+obj-$(CONFIG_SUN8I)    += clock_sun6i.o
 
 ifndef CONFIG_SPL_BUILD
 obj-y  += cpu_info.o
index f2cedbb1568a8eaf5dd7c8a3c6ef4acc085286a1..06eb6768e8f2b58ddbe1b2408157f8e4e89ccaab 100644 (file)
@@ -50,18 +50,35 @@ u32 spl_boot_mode(void)
 
 int gpio_init(void)
 {
-#if CONFIG_CONS_INDEX == 1 && (defined(CONFIG_SUN4I) || defined(CONFIG_SUN7I))
+#if CONFIG_CONS_INDEX == 1 && defined(CONFIG_UART0_PORT_F)
+#if defined(CONFIG_SUN4I) || defined(CONFIG_SUN7I)
+       /* disable GPB22,23 as uart0 tx,rx to avoid conflict */
+       sunxi_gpio_set_cfgpin(SUNXI_GPB(22), SUNXI_GPIO_INPUT);
+       sunxi_gpio_set_cfgpin(SUNXI_GPB(23), SUNXI_GPIO_INPUT);
+#endif
+       sunxi_gpio_set_cfgpin(SUNXI_GPF(2), SUNXI_GPF2_UART0_TX);
+       sunxi_gpio_set_cfgpin(SUNXI_GPF(4), SUNXI_GPF4_UART0_RX);
+       sunxi_gpio_set_pull(SUNXI_GPF(4), 1);
+#elif CONFIG_CONS_INDEX == 1 && (defined(CONFIG_SUN4I) || defined(CONFIG_SUN7I))
        sunxi_gpio_set_cfgpin(SUNXI_GPB(22), SUN4I_GPB22_UART0_TX);
        sunxi_gpio_set_cfgpin(SUNXI_GPB(23), SUN4I_GPB23_UART0_RX);
-       sunxi_gpio_set_pull(SUNXI_GPB(23), 1);
+       sunxi_gpio_set_pull(SUNXI_GPB(23), SUNXI_GPIO_PULL_UP);
 #elif CONFIG_CONS_INDEX == 1 && defined(CONFIG_SUN5I)
        sunxi_gpio_set_cfgpin(SUNXI_GPB(19), SUN5I_GPB19_UART0_TX);
        sunxi_gpio_set_cfgpin(SUNXI_GPB(20), SUN5I_GPB20_UART0_RX);
-       sunxi_gpio_set_pull(SUNXI_GPB(20), 1);
+       sunxi_gpio_set_pull(SUNXI_GPB(20), SUNXI_GPIO_PULL_UP);
+#elif CONFIG_CONS_INDEX == 1 && defined(CONFIG_SUN6I)
+       sunxi_gpio_set_cfgpin(SUNXI_GPH(20), SUN6I_GPH20_UART0_TX);
+       sunxi_gpio_set_cfgpin(SUNXI_GPH(21), SUN6I_GPH21_UART0_RX);
+       sunxi_gpio_set_pull(SUNXI_GPH(21), SUNXI_GPIO_PULL_UP);
 #elif CONFIG_CONS_INDEX == 2 && defined(CONFIG_SUN5I)
        sunxi_gpio_set_cfgpin(SUNXI_GPG(3), SUN5I_GPG3_UART1_TX);
        sunxi_gpio_set_cfgpin(SUNXI_GPG(4), SUN5I_GPG4_UART1_RX);
-       sunxi_gpio_set_pull(SUNXI_GPG(4), 1);
+       sunxi_gpio_set_pull(SUNXI_GPG(4), SUNXI_GPIO_PULL_UP);
+#elif CONFIG_CONS_INDEX == 5 && defined(CONFIG_SUN8I)
+       sunxi_gpio_set_cfgpin(SUNXI_GPL(2), SUN8I_GPL2_R_UART_TX);
+       sunxi_gpio_set_cfgpin(SUNXI_GPL(3), SUN8I_GPL3_R_UART_RX);
+       sunxi_gpio_set_pull(SUNXI_GPL(3), SUNXI_GPIO_PULL_UP);
 #else
 #error Unsupported console port number. Please fix pin mux settings in board.c
 #endif
@@ -71,6 +88,7 @@ int gpio_init(void)
 
 void reset_cpu(ulong addr)
 {
+#if defined(CONFIG_SUN4I) || defined(CONFIG_SUN5I) || defined(CONFIG_SUN7I)
        static const struct sunxi_wdog *wdog =
                 &((struct sunxi_timer_reg *)SUNXI_TIMER_BASE)->wdog;
 
@@ -82,12 +100,22 @@ void reset_cpu(ulong addr)
                /* sun5i sometimes gets stuck without this */
                writel(WDT_MODE_RESET_EN | WDT_MODE_EN, &wdog->mode);
        }
+#else /* CONFIG_SUN6I || CONFIG_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_SUN7I || defined CONFIG_SUN6I)
+#if !defined CONFIG_SPL_BUILD && (defined CONFIG_SUN7I || \
+               defined CONFIG_SUN6I || defined CONFIG_SUN8I)
        /* Enable SMP mode for CPU0, by setting bit 6 of Auxiliary Ctl reg */
        asm volatile(
                "mrc p15, 0, r0, c1, c0, 1\n"
index ecbdb0162b2efcd17f6c6ee2a357543e2a71cab2..4a0d64fb30e64db6b996d35e4134469a0ccfd385 100644 (file)
@@ -180,6 +180,17 @@ void clock_set_pll1(unsigned int hz)
 }
 #endif
 
+unsigned int clock_get_pll5p(void)
+{
+       struct sunxi_ccm_reg *const ccm =
+               (struct sunxi_ccm_reg *)SUNXI_CCM_BASE;
+       uint32_t rval = readl(&ccm->pll5_cfg);
+       int n = ((rval & CCM_PLL5_CTRL_N_MASK) >> CCM_PLL5_CTRL_N_SHIFT);
+       int k = ((rval & CCM_PLL5_CTRL_K_MASK) >> CCM_PLL5_CTRL_K_SHIFT) + 1;
+       int p = ((rval & CCM_PLL5_CTRL_P_MASK) >> CCM_PLL5_CTRL_P_SHIFT);
+       return (24000000 * n * k) >> p;
+}
+
 unsigned int clock_get_pll6(void)
 {
        struct sunxi_ccm_reg *const ccm =
diff --git a/arch/arm/cpu/armv7/sunxi/clock_sun6i.c b/arch/arm/cpu/armv7/sunxi/clock_sun6i.c
new file mode 100644 (file)
index 0000000..1eae976
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * sun6i specific clock code
+ *
+ * (C) Copyright 2007-2012
+ * Allwinner Technology Co., Ltd. <www.allwinnertech.com>
+ * Tom Cubie <tangliang@allwinnertech.com>
+ *
+ * (C) Copyright 2013 Luke Kenneth Casson Leighton <lkcl@lkcl.net>
+ *
+ * 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;
+
+#if CONFIG_CONS_INDEX < 5
+       /* uart clock source is apb2 */
+       writel(APB2_CLK_SRC_OSC24M|
+              APB2_CLK_RATE_N_1|
+              APB2_CLK_RATE_M(1),
+              &ccm->apb2_div);
+
+       /* open the clock for uart */
+       setbits_le32(&ccm->apb2_gate,
+                    CLK_GATE_OPEN << (APB2_GATE_UART_SHIFT +
+                                      CONFIG_CONS_INDEX - 1));
+
+       /* deassert uart reset */
+       setbits_le32(&ccm->apb2_reset_cfg,
+                    1 << (APB2_RESET_UART_SHIFT +
+                          CONFIG_CONS_INDEX - 1));
+#else
+       /* 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)
+{
+       struct sunxi_ccm_reg *const ccm =
+               (struct sunxi_ccm_reg *)SUNXI_CCM_BASE;
+
+       if (port > 3)
+               return -1;
+
+       /* set the apb clock gate for twi */
+       if (state)
+               setbits_le32(&ccm->apb2_gate,
+                            CLK_GATE_OPEN << (APB2_GATE_TWI_SHIFT+port));
+       else
+               clrbits_le32(&ccm->apb2_gate,
+                            CLK_GATE_OPEN << (APB2_GATE_TWI_SHIFT+port));
+
+       return 0;
+}
+
+unsigned int clock_get_pll6(void)
+{
+       struct sunxi_ccm_reg *const ccm =
+               (struct sunxi_ccm_reg *)SUNXI_CCM_BASE;
+       uint32_t rval = readl(&ccm->pll6_cfg);
+       int n = ((rval & CCM_PLL6_CTRL_N_MASK) >> CCM_PLL6_CTRL_N_SHIFT) + 1;
+       int k = ((rval & CCM_PLL6_CTRL_K_MASK) >> CCM_PLL6_CTRL_K_SHIFT) + 1;
+       return 24000000 * n * k / 2;
+}
index 5cf35acc1e60127df04bc9b2c178ed5f46d8671c..4f2a09cd2e28cbd69a498bab61c06341f4235473 100644 (file)
@@ -23,8 +23,12 @@ int print_cpuinfo(void)
        case 7: puts("CPU:   Allwinner A10s (SUN5I)\n"); break;
        default: puts("CPU:   Allwinner A1X (SUN5I)\n");
        }
+#elif defined CONFIG_SUN6I
+       puts("CPU:   Allwinner A31 (SUN6I)\n");
 #elif defined CONFIG_SUN7I
        puts("CPU:   Allwinner A20 (SUN7I)\n");
+#elif defined CONFIG_SUN8I
+       puts("CPU:   Allwinner A23 (SUN8I)\n");
 #else
 #warning Please update cpu_info.c with correct CPU information
        puts("CPU:   SUNXI Family\n");
index 584f7420d7d239098e8924db9185fd2a7f24c5a3..3cf3cbf19adb25fce553a4f88a8d35ca6909999a 100644 (file)
@@ -252,15 +252,9 @@ static void mctl_setup_dram_clock(u32 clk, u32 mbus_clk)
 {
        u32 reg_val;
        struct sunxi_ccm_reg *ccm = (struct sunxi_ccm_reg *)SUNXI_CCM_BASE;
-
-       /* PLL5P and PLL6 are the potential clock sources for MBUS */
-       u32 pll6x_div, pll5p_div;
-       u32 pll6x_clk = clock_get_pll6() / 1000000;
-       u32 pll5p_clk = clk / 24 * 48;
+       u32 pll5p_clk, pll6x_clk;
+       u32 pll5p_div, pll6x_div;
        u32 pll5p_rate, pll6x_rate;
-#ifdef CONFIG_SUN7I
-       pll6x_clk *= 2; /* sun7i uses PLL6*2, sun5i uses just PLL6 */
-#endif
 
        /* setup DRAM PLL */
        reg_val = readl(&ccm->pll5_cfg);
@@ -268,33 +262,32 @@ static void mctl_setup_dram_clock(u32 clk, u32 mbus_clk)
        reg_val &= ~CCM_PLL5_CTRL_K_MASK;               /* set K to 0 (x1) */
        reg_val &= ~CCM_PLL5_CTRL_N_MASK;               /* set N to 0 (x0) */
        reg_val &= ~CCM_PLL5_CTRL_P_MASK;               /* set P to 0 (x1) */
+#ifdef CONFIG_OLD_SUNXI_KERNEL_COMPAT
+       /* Old kernels are hardcoded to P=1 (divide by 2) */
+       reg_val |= CCM_PLL5_CTRL_P(1);
+#endif
        if (clk >= 540 && clk < 552) {
-               /* dram = 540MHz, pll5p = 1080MHz */
-               pll5p_clk = 1080;
+               /* dram = 540MHz */
                reg_val |= CCM_PLL5_CTRL_M(CCM_PLL5_CTRL_M_X(2));
                reg_val |= CCM_PLL5_CTRL_K(CCM_PLL5_CTRL_K_X(3));
                reg_val |= CCM_PLL5_CTRL_N(CCM_PLL5_CTRL_N_X(15));
        } else if (clk >= 512 && clk < 528) {
-               /* dram = 512MHz, pll5p = 1536MHz */
-               pll5p_clk = 1536;
+               /* dram = 512MHz */
                reg_val |= CCM_PLL5_CTRL_M(CCM_PLL5_CTRL_M_X(3));
                reg_val |= CCM_PLL5_CTRL_K(CCM_PLL5_CTRL_K_X(4));
                reg_val |= CCM_PLL5_CTRL_N(CCM_PLL5_CTRL_N_X(16));
        } else if (clk >= 496 && clk < 504) {
-               /* dram = 496MHz, pll5p = 1488MHz */
-               pll5p_clk = 1488;
+               /* dram = 496MHz */
                reg_val |= CCM_PLL5_CTRL_M(CCM_PLL5_CTRL_M_X(3));
                reg_val |= CCM_PLL5_CTRL_K(CCM_PLL5_CTRL_K_X(2));
                reg_val |= CCM_PLL5_CTRL_N(CCM_PLL5_CTRL_N_X(31));
        } else if (clk >= 468 && clk < 480) {
-               /* dram = 468MHz, pll5p = 936MHz */
-               pll5p_clk = 936;
+               /* dram = 468MHz */
                reg_val |= CCM_PLL5_CTRL_M(CCM_PLL5_CTRL_M_X(2));
                reg_val |= CCM_PLL5_CTRL_K(CCM_PLL5_CTRL_K_X(3));
                reg_val |= CCM_PLL5_CTRL_N(CCM_PLL5_CTRL_N_X(13));
        } else if (clk >= 396 && clk < 408) {
-               /* dram = 396MHz, pll5p = 792MHz */
-               pll5p_clk = 792;
+               /* dram = 396MHz */
                reg_val |= CCM_PLL5_CTRL_M(CCM_PLL5_CTRL_M_X(2));
                reg_val |= CCM_PLL5_CTRL_K(CCM_PLL5_CTRL_K_X(3));
                reg_val |= CCM_PLL5_CTRL_N(CCM_PLL5_CTRL_N_X(11));
@@ -322,6 +315,13 @@ static void mctl_setup_dram_clock(u32 clk, u32 mbus_clk)
        /* setup MBUS clock */
        if (!mbus_clk)
                mbus_clk = 300;
+
+       /* PLL5P and PLL6 are the potential clock sources for MBUS */
+       pll6x_clk = clock_get_pll6() / 1000000;
+#ifdef CONFIG_SUN7I
+       pll6x_clk *= 2; /* sun7i uses PLL6*2, sun5i uses just PLL6 */
+#endif
+       pll5p_clk = clock_get_pll5p() / 1000000;
        pll6x_div = DIV_ROUND_UP(pll6x_clk, mbus_clk);
        pll5p_div = DIV_ROUND_UP(pll5p_clk, mbus_clk);
        pll6x_rate = pll6x_clk / pll6x_div;
diff --git a/arch/arm/cpu/armv7/sunxi/prcm.c b/arch/arm/cpu/armv7/sunxi/prcm.c
new file mode 100644 (file)
index 0000000..19b4938
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Sunxi A31 Power Management Unit
+ *
+ * (C) Copyright 2013 Oliver Schinagl <oliver@schinagl.nl>
+ * http://linux-sunxi.org
+ *
+ * Based on sun6i sources and earlier U-Boot Allwinner A10 SPL work
+ *
+ * (C) Copyright 2006-2013
+ * Allwinner Technology Co., Ltd. <www.allwinnertech.com>
+ * Berg Xing <bergxing@allwinnertech.com>
+ * Tom Cubie <tangliang@allwinnertech.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <common.h>
+#include <errno.h>
+#include <asm/io.h>
+#include <asm/arch/cpu.h>
+#include <asm/arch/prcm.h>
+#include <asm/arch/sys_proto.h>
+
+/* APB0 clock gate and reset bit offsets are the same. */
+void prcm_apb0_enable(u32 flags)
+{
+       struct sunxi_prcm_reg *prcm =
+               (struct sunxi_prcm_reg *)SUNXI_PRCM_BASE;
+
+       /* open the clock for module */
+       setbits_le32(&prcm->apb0_gate, flags);
+
+       /* deassert reset for module */
+       setbits_le32(&prcm->apb0_reset, flags);
+}
index bcae2d60334c9f6999073ce96dc1c74b35a1cb6a..3ea6d7651cb7fd87af753248aa91465a8e95863a 100644 (file)
@@ -17,6 +17,9 @@ config TEGRA124
 
 endchoice
 
+config USE_PRIVATE_LIBGCC
+       default y if SPL_BUILD
+
 config SYS_CPU
        default "arm720t" if SPL_BUILD
        default "armv7" if !SPL_BUILD
index fd77f3f0eff368e5a0a83762390826b79f3eada3..d98cec90180f5d133432d57c68bf6759649c0c0c 100644 (file)
@@ -194,7 +194,8 @@ static void rgb_enable(struct dc_com_reg *com)
                writel(rgb_sel_tab[i], &com->pin_output_sel[i]);
 }
 
-int setup_window(struct disp_ctl_win *win, struct fdt_disp_config *config)
+static int setup_window(struct disp_ctl_win *win,
+                       struct fdt_disp_config *config)
 {
        win->x = 0;
        win->y = 0;
index 54aec4ed509ecae278a83c69d397272b21ce03e7..3abdc7ba17392a702a5c30a3fc6ade7beaba3e52 100644 (file)
@@ -3,6 +3,9 @@ if TEGRA30
 choice
        prompt "Tegra30 board select"
 
+config TARGET_APALIS_T30
+       bool "Toradex Apalis T30 board"
+
 config TARGET_BEAVER
        bool "NVIDIA Tegra30 Beaver evaluation board"
 
@@ -20,6 +23,7 @@ endchoice
 config SYS_SOC
        default "tegra30"
 
+source "board/toradex/apalis_t30/Kconfig"
 source "board/nvidia/beaver/Kconfig"
 source "board/nvidia/cardhu/Kconfig"
 source "board/toradex/colibri_t30/Kconfig"
index b385e195447a71b3de2a762228458248999ce5b2..781b511a97b499090b4485f78a57d60070b10673 100644 (file)
@@ -3,6 +3,7 @@
 #
 
 obj-$(CONFIG_DISPLAY_BOARDINFO) += board_info.o
+obj-y += platdevice.o
 obj-y += boot-mode.o
 obj-$(CONFIG_BOARD_POSTCLK_INIT) += board_postclk_init.o bcu_init.o \
                sbc_init.o sg_init.o pll_init.o clkrst_init.o pinctrl.o
diff --git a/arch/arm/cpu/armv7/uniphier/ph1-ld4/platdevice.c b/arch/arm/cpu/armv7/uniphier/ph1-ld4/platdevice.c
new file mode 100644 (file)
index 0000000..0047223
--- /dev/null
@@ -0,0 +1,15 @@
+/*
+ * Copyright (C) 2014 Panasonic Corporation
+ *   Author: Masahiro Yamada <yamada.m@jp.panasonic.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <asm/arch/platdevice.h>
+
+#define UART_MASTER_CLK                36864000
+
+SERIAL_DEVICE(0, 0x54006800, UART_MASTER_CLK)
+SERIAL_DEVICE(1, 0x54006900, UART_MASTER_CLK)
+SERIAL_DEVICE(2, 0x54006a00, UART_MASTER_CLK)
+SERIAL_DEVICE(3, 0x54006b00, UART_MASTER_CLK)
index 712afd1beebe74f0163041ee0adf517c68acd12c..e11f4f6d8b3f36c44d340f5bafdf9d8fd4858b12 100644 (file)
@@ -3,6 +3,7 @@
 #
 
 obj-$(CONFIG_DISPLAY_BOARDINFO) += board_info.o
+obj-y += platdevice.o
 obj-y += boot-mode.o
 obj-$(CONFIG_BOARD_POSTCLK_INIT) += board_postclk_init.o sbc_init.o \
                                sg_init.o pll_init.o clkrst_init.o pinctrl.o
diff --git a/arch/arm/cpu/armv7/uniphier/ph1-pro4/platdevice.c b/arch/arm/cpu/armv7/uniphier/ph1-pro4/platdevice.c
new file mode 100644 (file)
index 0000000..6da921e
--- /dev/null
@@ -0,0 +1,15 @@
+/*
+ * Copyright (C) 2014 Panasonic Corporation
+ *   Author: Masahiro Yamada <yamada.m@jp.panasonic.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <asm/arch/platdevice.h>
+
+#define UART_MASTER_CLK                73728000
+
+SERIAL_DEVICE(0, 0x54006800, UART_MASTER_CLK)
+SERIAL_DEVICE(1, 0x54006900, UART_MASTER_CLK)
+SERIAL_DEVICE(2, 0x54006a00, UART_MASTER_CLK)
+SERIAL_DEVICE(3, 0x54006b00, UART_MASTER_CLK)
index b385e195447a71b3de2a762228458248999ce5b2..781b511a97b499090b4485f78a57d60070b10673 100644 (file)
@@ -3,6 +3,7 @@
 #
 
 obj-$(CONFIG_DISPLAY_BOARDINFO) += board_info.o
+obj-y += platdevice.o
 obj-y += boot-mode.o
 obj-$(CONFIG_BOARD_POSTCLK_INIT) += board_postclk_init.o bcu_init.o \
                sbc_init.o sg_init.o pll_init.o clkrst_init.o pinctrl.o
diff --git a/arch/arm/cpu/armv7/uniphier/ph1-sld8/platdevice.c b/arch/arm/cpu/armv7/uniphier/ph1-sld8/platdevice.c
new file mode 100644 (file)
index 0000000..59d054a
--- /dev/null
@@ -0,0 +1,15 @@
+/*
+ * Copyright (C) 2014 Panasonic Corporation
+ *   Author: Masahiro Yamada <yamada.m@jp.panasonic.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <asm/arch/platdevice.h>
+
+#define UART_MASTER_CLK                80000000
+
+SERIAL_DEVICE(0, 0x54006800, UART_MASTER_CLK)
+SERIAL_DEVICE(1, 0x54006900, UART_MASTER_CLK)
+SERIAL_DEVICE(2, 0x54006a00, UART_MASTER_CLK)
+SERIAL_DEVICE(3, 0x54006b00, UART_MASTER_CLK)
index 433da09d10c2ad59efa3fb2db9c8bf971951039c..b6a84a577478a11374ad3e46ed75bc2c437f59ea 100644 (file)
@@ -9,6 +9,7 @@
 #include <asm/io.h>
 #include <asm/arch/clock.h>
 #include <asm/arch/funcmux.h>
+#include <asm/arch/mc.h>
 #include <asm/arch/tegra.h>
 #include <asm/arch-tegra/board.h>
 #include <asm/arch-tegra/pmc.h>
@@ -27,55 +28,6 @@ enum {
        UART_COUNT = 5,
 };
 
-#if defined(CONFIG_TEGRA20) || defined(CONFIG_TEGRA30) || \
-       defined(CONFIG_TEGRA114)
-/*
- * Boot ROM initializes the odmdata in APBDEV_PMC_SCRATCH20_0,
- * so we are using this value to identify memory size.
- */
-unsigned int query_sdram_size(void)
-{
-       struct pmc_ctlr *const pmc = (struct pmc_ctlr *)NV_PA_PMC_BASE;
-       u32 reg;
-
-       reg = readl(&pmc->pmc_scratch20);
-       debug("pmc->pmc_scratch20 (ODMData) = 0x%08x\n", reg);
-
-#if defined(CONFIG_TEGRA20)
-       /* bits 30:28 in OdmData are used for RAM size on T20  */
-       reg &= 0x70000000;
-
-       switch ((reg) >> 28) {
-       case 1:
-               return 0x10000000;      /* 256 MB */
-       case 0:
-       case 2:
-       default:
-               return 0x20000000;      /* 512 MB */
-       case 3:
-               return 0x40000000;      /* 1GB */
-       }
-#else  /* Tegra30/Tegra114 */
-       /* bits 31:28 in OdmData are used for RAM size on T30  */
-       switch ((reg) >> 28) {
-       case 0:
-       case 1:
-       default:
-               return 0x10000000;      /* 256 MB */
-       case 2:
-               return 0x20000000;      /* 512 MB */
-       case 3:
-               return 0x30000000;      /* 768 MB */
-       case 4:
-               return 0x40000000;      /* 1GB */
-       case 8:
-               return 0x7ff00000;      /* 2GB - 1MB */
-       }
-#endif
-}
-#else
-#include <asm/arch/mc.h>
-
 /* Read the RAM size directly from the memory controller */
 unsigned int query_sdram_size(void)
 {
@@ -83,12 +35,22 @@ unsigned int query_sdram_size(void)
        u32 size_mb;
 
        size_mb = readl(&mc->mc_emem_cfg);
+#if defined(CONFIG_TEGRA20)
+       debug("mc->mc_emem_cfg (MEM_SIZE_KB) = 0x%08x\n", size_mb);
+       size_mb = get_ram_size((void *)PHYS_SDRAM_1, size_mb * 1024);
+#else
        debug("mc->mc_emem_cfg (MEM_SIZE_MB) = 0x%08x\n", size_mb);
+       size_mb = get_ram_size((void *)PHYS_SDRAM_1, size_mb * 1024 * 1024);
+#endif
 
-       return size_mb * 1024 * 1024;
-}
+#if defined(CONFIG_TEGRA30) || defined(CONFIG_TEGRA114)
+       /* External memory limited to 2047 MB due to IROM/HI-VEC */
+       if (size_mb == SZ_2G) size_mb -= SZ_1M;
 #endif
 
+       return size_mb;
+}
+
 int dram_init(void)
 {
        /* We do not initialise DRAM here. We just query the size */
index de20325ecf3239666e5da6e5d23cbcba5811108c..5933c35ddd43e9b4242f33fc3d9952404d82088a 100644 (file)
@@ -8,7 +8,7 @@
 #include <common.h>
 #include <linux/ctype.h>
 
-void upstring(char *s)
+static void upstring(char *s)
 {
        while (*s) {
                *s = toupper(*s);
index c37580ed842e6fddb459efb631b2e4796afbff04..c34606334dbea34363aba579097eed3bc8a20200 100644 (file)
@@ -22,6 +22,7 @@ dtb-$(CONFIG_TEGRA) += tegra20-harmony.dtb \
        tegra20-ventana.dtb \
        tegra20-whistler.dtb \
        tegra20-colibri_t20_iris.dtb \
+       tegra30-apalis.dtb \
        tegra30-beaver.dtb \
        tegra30-cardhu.dtb \
        tegra30-colibri.dtb \
index 2f66deda9f5c171b4394046e14dba7b4814588df..e70b4d1f1facc8fa8d8fa520dc8996c4a6348eb7 100644 (file)
        model = "TI AM335x BeagleBone";
        compatible = "ti,am335x-bone", "ti,am33xx";
 
+       chosen {
+               stdout-path = &uart0;
+       };
+
        cpus {
                cpu@0 {
                        cpu0-supply = <&dcdc2_reg>;
diff --git a/arch/arm/dts/dt-bindings/gpio/gpio.h b/arch/arm/dts/dt-bindings/gpio/gpio.h
deleted file mode 100644 (file)
index e6b1e0a..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * This header provides constants for most GPIO bindings.
- *
- * Most GPIO bindings include a flags cell as part of the GPIO specifier.
- * In most cases, the format of the flags cell uses the standard values
- * defined in this header.
- */
-
-#ifndef _DT_BINDINGS_GPIO_GPIO_H
-#define _DT_BINDINGS_GPIO_GPIO_H
-
-#define GPIO_ACTIVE_HIGH 0
-#define GPIO_ACTIVE_LOW 1
-
-#endif
diff --git a/arch/arm/dts/tegra30-apalis.dts b/arch/arm/dts/tegra30-apalis.dts
new file mode 100644 (file)
index 0000000..5bad3e7
--- /dev/null
@@ -0,0 +1,304 @@
+/dts-v1/;
+
+#include "tegra30.dtsi"
+
+/ {
+       model = "Toradex Apalis T30";
+       compatible = "toradex,apalis_t30", "nvidia,tegra30";
+
+       chosen {
+               stdout-path = &uarta;
+       };
+
+       aliases {
+               i2c0 = "/i2c@7000d000";
+               i2c1 = "/i2c@7000c000";
+               i2c2 = "/i2c@7000c500";
+               i2c3 = "/i2c@7000c700";
+               sdhci0 = "/sdhci@78000600";
+               sdhci1 = "/sdhci@78000400";
+               sdhci2 = "/sdhci@78000000";
+               usb0 = "/usb@7d000000";
+               usb1 = "/usb@7d004000";
+               usb2 = "/usb@7d008000";
+       };
+
+       memory {
+               device_type = "memory";
+               reg = <0x80000000 0x40000000>;
+       };
+
+       pcie-controller@00003000 {
+               status = "okay";
+               avdd-pexa-supply = <&vdd2_reg>;
+               vdd-pexa-supply = <&vdd2_reg>;
+               avdd-pexb-supply = <&vdd2_reg>;
+               vdd-pexb-supply = <&vdd2_reg>;
+               avdd-pex-pll-supply = <&vdd2_reg>;
+               avdd-plle-supply = <&ldo6_reg>;
+               vddio-pex-ctl-supply = <&sys_3v3_reg>;
+               hvdd-pex-supply = <&sys_3v3_reg>;
+
+               pci@1,0 {
+                       nvidia,num-lanes = <4>;
+               };
+
+               pci@2,0 {
+                       nvidia,num-lanes = <1>;
+               };
+
+               pci@3,0 {
+                       status = "okay";
+                       nvidia,num-lanes = <1>;
+               };
+       };
+
+       /*
+        * GEN1_I2C: I2C1_SDA/SCL on MXM3 pin 209/211 (e.g. RTC on carrier
+        * board)
+        */
+       i2c@7000c000 {
+               status = "okay";
+               clock-frequency = <100000>;
+       };
+
+       /* GEN2_I2C: unused */
+
+       /*
+        * CAM_I2C: I2C3_SDA/SCL on MXM3 pin 201/203 (e.g. camera sensor on
+        * carrier board)
+        */
+       i2c@7000c500 {
+               status = "okay";
+               clock-frequency = <100000>;
+       };
+
+       /* DDC: I2C2_SDA/SCL on MXM3 pin 205/207 (e.g. display EDID) */
+       i2c@7000c700 {
+               status = "okay";
+               clock-frequency = <100000>;
+       };
+
+       /*
+        * PWR_I2C: power I2C to audio codec, PMIC, temperature sensor and
+        * touch screen controller
+        */
+       i2c@7000d000 {
+               status = "okay";
+               clock-frequency = <100000>;
+
+               pmic: tps65911@2d {
+                       compatible = "ti,tps65911";
+                       reg = <0x2d>;
+
+                       interrupts = <GIC_SPI 86 IRQ_TYPE_LEVEL_HIGH>;
+                       #interrupt-cells = <2>;
+                       interrupt-controller;
+
+                       ti,system-power-controller;
+
+                       #gpio-cells = <2>;
+                       gpio-controller;
+
+                       vcc1-supply = <&sys_3v3_reg>;
+                       vcc2-supply = <&sys_3v3_reg>;
+                       vcc3-supply = <&vio_reg>;
+                       vcc4-supply = <&sys_3v3_reg>;
+                       vcc5-supply = <&sys_3v3_reg>;
+                       vcc6-supply = <&vio_reg>;
+                       vcc7-supply = <&charge_pump_5v0_reg>;
+                       vccio-supply = <&sys_3v3_reg>;
+
+                       regulators {
+                               #address-cells = <1>;
+                               #size-cells = <0>;
+
+                               /* SW1: +V1.35_VDDIO_DDR */
+                               vdd1_reg: vdd1 {
+                                       regulator-name = "vddio_ddr_1v35";
+                                       regulator-min-microvolt = <1350000>;
+                                       regulator-max-microvolt = <1350000>;
+                                       regulator-always-on;
+                               };
+
+                               /* SW2: +V1.05 */
+                               vdd2_reg: vdd2 {
+                                       regulator-name =
+                                               "vdd_pexa,vdd_pexb,vdd_sata";
+                                       regulator-min-microvolt = <1050000>;
+                                       regulator-max-microvolt = <1050000>;
+                               };
+
+                               /* SW CTRL: +V1.0_VDD_CPU */
+                               vddctrl_reg: vddctrl {
+                                       regulator-name = "vdd_cpu,vdd_sys";
+                                       regulator-min-microvolt = <1150000>;
+                                       regulator-max-microvolt = <1150000>;
+                                       regulator-always-on;
+                               };
+
+                               /* SWIO: +V1.8 */
+                               vio_reg: vio {
+                                       regulator-name = "vdd_1v8_gen";
+                                       regulator-min-microvolt = <1800000>;
+                                       regulator-max-microvolt = <1800000>;
+                                       regulator-always-on;
+                               };
+
+                               /* LDO1: unused */
+
+                               /*
+                                * EN_+V3.3 switching via FET:
+                                * +V3.3_AUDIO_AVDD_S, +V3.3 and +V1.8_VDD_LAN
+                                * see also v3_3 fixed supply
+                                */
+                               ldo2_reg: ldo2 {
+                                       regulator-name = "en_3v3";
+                                       regulator-min-microvolt = <3300000>;
+                                       regulator-max-microvolt = <3300000>;
+                                       regulator-always-on;
+                               };
+
+                               /* +V1.2_CSI */
+                               ldo3_reg: ldo3 {
+                                       regulator-name =
+                                               "avdd_dsi_csi,pwrdet_mipi";
+                                       regulator-min-microvolt = <1200000>;
+                                       regulator-max-microvolt = <1200000>;
+                               };
+
+                               /* +V1.2_VDD_RTC */
+                               ldo4_reg: ldo4 {
+                                       regulator-name = "vdd_rtc";
+                                       regulator-min-microvolt = <1200000>;
+                                       regulator-max-microvolt = <1200000>;
+                                       regulator-always-on;
+                               };
+
+                               /*
+                                * +V2.8_AVDD_VDAC:
+                                * only required for analog RGB
+                                */
+                               ldo5_reg: ldo5 {
+                                       regulator-name = "avdd_vdac";
+                                       regulator-min-microvolt = <2800000>;
+                                       regulator-max-microvolt = <2800000>;
+                                       regulator-always-on;
+                               };
+
+                               /*
+                                * +V1.05_AVDD_PLLE: avdd_plle should be 1.05V
+                                * but LDO6 can't set voltage in 50mV
+                                * granularity
+                                */
+                               ldo6_reg: ldo6 {
+                                       regulator-name = "avdd_plle";
+                                       regulator-min-microvolt = <1100000>;
+                                       regulator-max-microvolt = <1100000>;
+                               };
+
+                               /* +V1.2_AVDD_PLL */
+                               ldo7_reg: ldo7 {
+                                       regulator-name = "avdd_pll";
+                                       regulator-min-microvolt = <1200000>;
+                                       regulator-max-microvolt = <1200000>;
+                                       regulator-always-on;
+                               };
+
+                               /* +V1.0_VDD_DDR_HS */
+                               ldo8_reg: ldo8 {
+                                       regulator-name = "vdd_ddr_hs";
+                                       regulator-min-microvolt = <1000000>;
+                                       regulator-max-microvolt = <1000000>;
+                                       regulator-always-on;
+                               };
+                       };
+               };
+       };
+
+       /* SPI1: Apalis SPI1 */
+       spi@7000d400 {
+               status = "okay";
+               spi-max-frequency = <25000000>;
+       };
+
+       /* SPI4: CAN2 */
+       spi@7000da00 {
+               status = "okay";
+               spi-max-frequency = <25000000>;
+       };
+
+       /* SPI5: Apalis SPI2 */
+       spi@7000dc00 {
+               status = "okay";
+               spi-max-frequency = <25000000>;
+       };
+
+       /* SPI6: CAN1 */
+       spi@7000de00 {
+               status = "okay";
+               spi-max-frequency = <25000000>;
+       };
+
+       sdhci@78000000 {
+               status = "okay";
+               bus-width = <4>;
+               cd-gpios = <&gpio 229 1>; /* PCC5, SD1_CD# */
+       };
+
+       sdhci@78000400 {
+               status = "okay";
+               bus-width = <8>;
+               cd-gpios = <&gpio 171 1>; /* PV3, MMC1_CD# */
+       };
+
+       sdhci@78000600 {
+               status = "okay";
+               bus-width = <8>;
+               non-removable;
+       };
+
+       /* EHCI instance 0: USB1_DP/N -> USBO1_DP/N */
+       usb@7d000000 {
+               status = "okay";
+               dr_mode = "peripheral";
+               nvidia,vbus-gpio = <&gpio 157 0>;       /* PT5, USBO1_EN */
+       };
+
+       /* EHCI instance 1: USB2_DP/N -> USBH2_DP/N */
+       usb@7d004000 {
+               status = "okay";
+               nvidia,vbus-gpio = <&gpio 233 0>;       /* PDD1, USBH_EN */
+               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 */
+       };
+
+       regulators {
+               compatible = "simple-bus";
+               #address-cells = <1>;
+               #size-cells = <0>;
+
+               sys_3v3_reg: regulator@100 {
+                       compatible = "regulator-fixed";
+                       reg = <100>;
+                       regulator-name = "3v3";
+                       regulator-min-microvolt = <3300000>;
+                       regulator-max-microvolt = <3300000>;
+                       regulator-always-on;
+               };
+
+               charge_pump_5v0_reg: regulator@101 {
+                       compatible = "regulator-fixed";
+                       reg = <101>;
+                       regulator-name = "5v0";
+                       regulator-min-microvolt = <5000000>;
+                       regulator-max-microvolt = <5000000>;
+                       regulator-always-on;
+               };
+       };
+};
index df79c26a45898ee5a89b348950db872918e7f405..572520a00ec5e330d5bbacd4b187967d45db8ec8 100644 (file)
@@ -6,6 +6,10 @@
        model = "Toradex Colibri T30";
        compatible = "toradex,colibri_t30", "nvidia,tegra30";
 
+       chosen {
+               stdout-path = &uarta;
+       };
+
        aliases {
                i2c0 = "/i2c@7000d000";
                i2c1 = "/i2c@7000c000";
index ed826a0e19c99b8cd76337aa46440a831e2b477a..09fc22760d0c6e973359f121f92c63feed26793d 100644 (file)
@@ -7,7 +7,9 @@
  * SPDX-License-Identifier:    GPL-2.0+
  */
 
+#include <bootm.h>
 #include <common.h>
+#include <netdev.h>
 #include <asm/errno.h>
 #include <asm/io.h>
 #include <asm/arch/imx-regs.h>
index dbecf4e4348e776d4f62ee77b4dc581d7629b656..12256a38eb97a5803071ff526f4fd2ad3b81fb9b 100644 (file)
@@ -5,6 +5,7 @@
  */
 
 #include <common.h>
+#include <asm/arch/sys_proto.h>
 #include <asm/errno.h>
 #include <asm/io.h>
 #include <asm/imx-common/regs-common.h>
diff --git a/arch/arm/include/asm/arch-armada-xp/config.h b/arch/arm/include/asm/arch-armada-xp/config.h
new file mode 100644 (file)
index 0000000..00ee775
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * (C) Copyright 2011
+ * Marvell Semiconductor <www.marvell.com>
+ * Written-by: Lei Wen <leiwen@marvell.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+/*
+ * This file should be included in board config header file.
+ *
+ * It supports common definitions for Armada XP platforms
+ */
+
+#ifndef _ARMADA_XP_CONFIG_H
+#define _ARMADA_XP_CONFIG_H
+
+#include <asm/arch/soc.h>
+
+#define MV88F78X60 /* for the DDR training bin_hdr code */
+
+#define CONFIG_SYS_CACHELINE_SIZE      32
+
+/*
+ * By default kwbimage.cfg from board specific folder is used
+ * If for some board, different configuration file need to be used,
+ * CONFIG_SYS_KWD_CONFIG should be defined in board specific header file
+ */
+#ifndef CONFIG_SYS_KWD_CONFIG
+#define        CONFIG_SYS_KWD_CONFIG   $(CONFIG_BOARDDIR)/kwbimage.cfg
+#endif /* CONFIG_SYS_KWD_CONFIG */
+
+/* Add target to build it automatically upon "make" */
+#define CONFIG_BUILD_TARGET    "u-boot.kwb"
+
+/* end of 16M scrubbed by training in bootrom */
+#define CONFIG_SYS_INIT_SP_ADDR                0x00FF0000
+#define CONFIG_NR_DRAM_BANKS_MAX       2
+
+#define MV_UART_CONSOLE_BASE           MVEBU_UART0_BASE
+
+/*
+ * SPI Flash configuration
+ */
+#ifdef CONFIG_CMD_SF
+#define CONFIG_HARD_SPI                        1
+#define CONFIG_KIRKWOOD_SPI            1
+#ifndef CONFIG_ENV_SPI_BUS
+# define CONFIG_ENV_SPI_BUS            0
+#endif
+#ifndef CONFIG_ENV_SPI_CS
+# define CONFIG_ENV_SPI_CS             0
+#endif
+#ifndef CONFIG_ENV_SPI_MAX_HZ
+# define CONFIG_ENV_SPI_MAX_HZ         50000000
+#endif
+#endif
+
+/*
+ * Ethernet Driver configuration
+ */
+#ifdef CONFIG_CMD_NET
+#define CONFIG_CMD_MII
+#define CONFIG_MII             /* expose smi ove miiphy interface */
+#define CONFIG_MVNETA          /* Enable Marvell Gbe Controller Driver */
+#define CONFIG_PHYLIB
+#define CONFIG_ENV_OVERWRITE   /* ethaddr can be reprogrammed */
+#define CONFIG_PHY_GIGE                /* GbE speed/duplex detect */
+#endif /* CONFIG_CMD_NET */
+
+/*
+ * I2C related stuff
+ */
+#ifdef CONFIG_CMD_I2C
+#ifndef CONFIG_SYS_I2C_SOFT
+#define CONFIG_I2C_MVTWSI
+#endif
+#define CONFIG_SYS_I2C_SLAVE           0x0
+#define CONFIG_SYS_I2C_SPEED           100000
+#endif
+
+#endif /* _ARMADA_XP_CONFIG_H */
diff --git a/arch/arm/include/asm/arch-armada-xp/cpu.h b/arch/arm/include/asm/arch-armada-xp/cpu.h
new file mode 100644 (file)
index 0000000..6b60c21
--- /dev/null
@@ -0,0 +1,107 @@
+/*
+ * (C) Copyright 2009
+ * Marvell Semiconductor <www.marvell.com>
+ * Written-by: Prafulla Wadaskar <prafulla@marvell.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#ifndef _ARMADA_XP_CPU_H
+#define _ARMADA_XP_CPU_H
+
+#include <asm/system.h>
+
+#ifndef __ASSEMBLY__
+
+#define MVEBU_REG_PCIE_DEVID           (MVEBU_REG_PCIE_BASE + 0x00)
+#define MVEBU_REG_PCIE_REVID           (MVEBU_REG_PCIE_BASE + 0x08)
+
+enum memory_bank {
+       BANK0,
+       BANK1,
+       BANK2,
+       BANK3
+};
+
+enum cpu_winen {
+       CPU_WIN_DISABLE,
+       CPU_WIN_ENABLE
+};
+
+enum cpu_target {
+       CPU_TARGET_DRAM = 0x0,
+       CPU_TARGET_DEVICEBUS_BOOTROM_SPI = 0x1,
+       CPU_TARGET_ETH23 = 0x3,
+       CPU_TARGET_PCIE02 = 0x4,
+       CPU_TARGET_ETH01 = 0x7,
+       CPU_TARGET_PCIE13 = 0x8,
+       CPU_TARGET_SASRAM = 0x9,
+       CPU_TARGET_NAND = 0xd,
+};
+
+enum cpu_attrib {
+       CPU_ATTR_SASRAM = 0x01,
+       CPU_ATTR_DRAM_CS0 = 0x0e,
+       CPU_ATTR_DRAM_CS1 = 0x0d,
+       CPU_ATTR_DRAM_CS2 = 0x0b,
+       CPU_ATTR_DRAM_CS3 = 0x07,
+       CPU_ATTR_NANDFLASH = 0x2f,
+       CPU_ATTR_SPIFLASH = 0x1e,
+       CPU_ATTR_BOOTROM = 0x1d,
+       CPU_ATTR_PCIE_IO = 0xe0,
+       CPU_ATTR_PCIE_MEM = 0xe8,
+       CPU_ATTR_DEV_CS0 = 0x3e,
+       CPU_ATTR_DEV_CS1 = 0x3d,
+       CPU_ATTR_DEV_CS2 = 0x3b,
+       CPU_ATTR_DEV_CS3 = 0x37,
+};
+
+/*
+ * Default Device Address MAP BAR values
+ */
+#define DEFADR_PCI_MEM         0x90000000
+#define DEFADR_PCI_IO          0xC0000000
+#define DEFADR_SPIF            0xF4000000
+#define DEFADR_BOOTROM         0xF8000000
+
+struct mbus_win {
+       u32 base;
+       u32 size;
+       u8 target;
+       u8 attr;
+};
+
+/*
+ * System registers
+ * Ref: Datasheet sec:A.28
+ */
+struct mvebu_system_registers {
+       u8 pad1[0x60];
+       u32 rstoutn_mask; /* 0x60 */
+       u32 sys_soft_rst; /* 0x64 */
+};
+
+/*
+ * GPIO Registers
+ * Ref: Datasheet sec:A.19
+ */
+struct kwgpio_registers {
+       u32 dout;
+       u32 oe;
+       u32 blink_en;
+       u32 din_pol;
+       u32 din;
+       u32 irq_cause;
+       u32 irq_mask;
+       u32 irq_level;
+};
+
+/*
+ * functions
+ */
+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);
+#endif /* __ASSEMBLY__ */
+#endif /* _ARMADA_XP_CPU_H */
diff --git a/arch/arm/include/asm/arch-armada-xp/soc.h b/arch/arm/include/asm/arch-armada-xp/soc.h
new file mode 100644 (file)
index 0000000..963e7ac
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * (C) Copyright 2009
+ * Marvell Semiconductor <www.marvell.com>
+ * Written-by: Prafulla Wadaskar <prafulla@marvell.com>
+ *
+ * Header file for the Marvell's Feroceon CPU core.
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#ifndef _ASM_ARCH_ARMADA_XP_H
+#define _ASM_ARCH_ARMADA_XP_H
+
+#define SOC_MV78460_ID         0x7846
+
+/* TCLK Core Clock definition */
+#ifndef CONFIG_SYS_TCLK
+#define CONFIG_SYS_TCLK                250000000       /* 250MHz */
+#endif
+
+/* SOC specific definations */
+#define INTREG_BASE            0xd0000000
+#define INTREG_BASE_ADDR_REG   (INTREG_BASE + 0x20080)
+#define SOC_REGS_PHY_BASE      0xf1000000
+#define MVEBU_REGISTER(x)      (SOC_REGS_PHY_BASE + x)
+
+#define MVEBU_SDRAM_SCRATCH    (MVEBU_REGISTER(0x01504))
+#define MVEBU_SPI_BASE         (MVEBU_REGISTER(0x10600))
+#define MVEBU_TWSI_BASE                (MVEBU_REGISTER(0x11000))
+#define MVEBU_UART0_BASE       (MVEBU_REGISTER(0x12000))
+#define MVEBU_UART1_BASE       (MVEBU_REGISTER(0x12100))
+#define MVEBU_MPP_BASE         (MVEBU_REGISTER(0x18000))
+#define MVEBU_GPIO0_BASE       (MVEBU_REGISTER(0x18100))
+#define MVEBU_GPIO1_BASE       (MVEBU_REGISTER(0x18140))
+#define MVEBU_GPIO2_BASE       (MVEBU_REGISTER(0x18180))
+#define MVEBU_SYSTEM_REG_BASE  (MVEBU_REGISTER(0x18200))
+#define MVEBU_CPU_WIN_BASE     (MVEBU_REGISTER(0x20000))
+#define MVEBU_SDRAM_BASE       (MVEBU_REGISTER(0x20180))
+#define MVEBU_TIMER_BASE       (MVEBU_REGISTER(0x20300))
+#define MVEBU_EGIGA2_BASE      (MVEBU_REGISTER(0x30000))
+#define MVEBU_EGIGA3_BASE      (MVEBU_REGISTER(0x34000))
+#define MVEBU_REG_PCIE_BASE    (MVEBU_REGISTER(0x40000))
+#define MVEBU_EGIGA0_BASE      (MVEBU_REGISTER(0x70000))
+#define MVEBU_EGIGA1_BASE      (MVEBU_REGISTER(0x74000))
+
+#define SDRAM_MAX_CS           4
+#define SDRAM_ADDR_MASK                0xFF000000
+
+/* Armada XP GbE controller has 4 ports */
+#define MAX_MVNETA_DEVS                4
+
+/* Kirkwood CPU memory windows */
+#define MVCPU_WIN_CTRL_DATA    CPU_WIN_CTRL_DATA
+#define MVCPU_WIN_ENABLE       CPU_WIN_ENABLE
+#define MVCPU_WIN_DISABLE      CPU_WIN_DISABLE
+
+#endif /* _ASM_ARCH_ARMADA_XP_H */
index dded857c3ad50abbe650f12a1ebb435e6f8d7614..61f427d914cd939386806a2c45f263d397a11058 100644 (file)
@@ -119,6 +119,20 @@ struct bcm2835_mbox_tag_hdr {
  * };
  */
 
+#define BCM2835_MBOX_TAG_GET_MAC_ADDRESS       0x00010003
+
+struct bcm2835_mbox_tag_get_mac_address {
+       struct bcm2835_mbox_tag_hdr tag_hdr;
+       union {
+               struct {
+               } req;
+               struct {
+                       u8 mac[6];
+                       u8 pad[2];
+               } resp;
+       } body;
+};
+
 #define BCM2835_MBOX_TAG_GET_ARM_MEMORY                0x00010005
 
 struct bcm2835_mbox_tag_get_arm_mem {
index f7bfa0e74d7f68864a8ee090f77d5e2f4d025574..ccc8e4e7d64b57bc9d1e94587b5e8d0e42d3d690 100644 (file)
@@ -23,7 +23,7 @@
 #error "SOC Name not defined"
 #endif /* CONFIG_KW88F6281 */
 
-#include <asm/arch/kirkwood.h>
+#include <asm/arch/soc.h>
 #define CONFIG_ARM926EJS       1       /* Basic Architecture */
 #define CONFIG_SYS_CACHELINE_SIZE      32
                                /* default Dcache Line length for kirkwood */
index 97daa403ce7f294400f90dde720de8a5720f24e0..926d347110f8265680171cd12f6bdc1302404b52 100644 (file)
@@ -140,11 +140,11 @@ struct kwgpio_registers {
  * functions
  */
 unsigned char get_random_hex(void);
-unsigned int kw_sdram_bar(enum memory_bank bank);
-unsigned int kw_sdram_bs(enum memory_bank bank);
-void kw_sdram_size_adjust(enum memory_bank bank);
+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 kw_config_adr_windows(void);
-void kw_config_gpio(unsigned int gpp0_oe_val, unsigned int gpp1_oe_val,
+void mvebu_config_gpio(unsigned int gpp0_oe_val, unsigned int gpp1_oe_val,
                unsigned int gpp0_oe, unsigned int gpp1_oe);
 int kw_config_mpp(unsigned int mpp0_7, unsigned int mpp8_15,
                unsigned int mpp16_23, unsigned int mpp24_31,
index 5f4d78608559dd60f7babb5f70090429e3a56d43..aa8c5da36d35c4b3102083b1f8f9c916f0e0f622 100644 (file)
 
 #define GPIO_MAX               50
 #define GPIO_OFF(pin)          (((pin) >> 5) ? 0x0040 : 0x0000)
-#define GPIO_OUT(pin)          (KW_GPIO0_BASE + GPIO_OFF(pin) + 0x00)
-#define GPIO_IO_CONF(pin)      (KW_GPIO0_BASE + GPIO_OFF(pin) + 0x04)
-#define GPIO_BLINK_EN(pin)     (KW_GPIO0_BASE + GPIO_OFF(pin) + 0x08)
-#define GPIO_IN_POL(pin)       (KW_GPIO0_BASE + GPIO_OFF(pin) + 0x0c)
-#define GPIO_DATA_IN(pin)      (KW_GPIO0_BASE + GPIO_OFF(pin) + 0x10)
-#define GPIO_EDGE_CAUSE(pin)   (KW_GPIO0_BASE + GPIO_OFF(pin) + 0x14)
-#define GPIO_EDGE_MASK(pin)    (KW_GPIO0_BASE + GPIO_OFF(pin) + 0x18)
-#define GPIO_LEVEL_MASK(pin)   (KW_GPIO0_BASE + GPIO_OFF(pin) + 0x1c)
+#define GPIO_OUT(pin)          (MVEBU_GPIO0_BASE + GPIO_OFF(pin) + 0x00)
+#define GPIO_IO_CONF(pin)      (MVEBU_GPIO0_BASE + GPIO_OFF(pin) + 0x04)
+#define GPIO_BLINK_EN(pin)     (MVEBU_GPIO0_BASE + GPIO_OFF(pin) + 0x08)
+#define GPIO_IN_POL(pin)       (MVEBU_GPIO0_BASE + GPIO_OFF(pin) + 0x0c)
+#define GPIO_DATA_IN(pin)      (MVEBU_GPIO0_BASE + GPIO_OFF(pin) + 0x10)
+#define GPIO_EDGE_CAUSE(pin)   (MVEBU_GPIO0_BASE + GPIO_OFF(pin) + 0x14)
+#define GPIO_EDGE_MASK(pin)    (MVEBU_GPIO0_BASE + GPIO_OFF(pin) + 0x18)
+#define GPIO_LEVEL_MASK(pin)   (MVEBU_GPIO0_BASE + GPIO_OFF(pin) + 0x1c)
 
 /*
  * Kirkwood-specific GPIO API
similarity index 90%
rename from arch/arm/include/asm/arch-kirkwood/kirkwood.h
rename to arch/arm/include/asm/arch-kirkwood/soc.h
index 3ea51d7848c5f21bd93baef774b22e692f4eb2c0..58ed71b186413c4c014ca672a3af8ab29246928c 100644 (file)
 #define KW_REG_UNDOC_0x1470            (KW_REGISTER(0x1470))
 #define KW_REG_UNDOC_0x1478            (KW_REGISTER(0x1478))
 
+#define MVEBU_SDRAM_BASE               (KW_REGISTER(0x1500))
 #define KW_TWSI_BASE                   (KW_REGISTER(0x11000))
 #define KW_UART0_BASE                  (KW_REGISTER(0x12000))
 #define KW_UART1_BASE                  (KW_REGISTER(0x12100))
 #define KW_MPP_BASE                    (KW_REGISTER(0x10000))
-#define KW_GPIO0_BASE                  (KW_REGISTER(0x10100))
-#define KW_GPIO1_BASE                  (KW_REGISTER(0x10140))
+#define MVEBU_GPIO0_BASE                       (KW_REGISTER(0x10100))
+#define MVEBU_GPIO1_BASE                       (KW_REGISTER(0x10140))
 #define KW_RTC_BASE                    (KW_REGISTER(0x10300))
 #define KW_NANDF_BASE                  (KW_REGISTER(0x10418))
-#define KW_SPI_BASE                    (KW_REGISTER(0x10600))
+#define MVEBU_SPI_BASE                 (KW_REGISTER(0x10600))
 #define KW_CPU_WIN_BASE                        (KW_REGISTER(0x20000))
 #define KW_CPU_REG_BASE                        (KW_REGISTER(0x20100))
-#define KW_TIMER_BASE                  (KW_REGISTER(0x20300))
+#define MVEBU_TIMER_BASE                       (KW_REGISTER(0x20300))
 #define KW_REG_PCIE_BASE               (KW_REGISTER(0x40000))
 #define KW_USB20_BASE                  (KW_REGISTER(0x50000))
 #define KW_EGIGA0_BASE                 (KW_REGISTER(0x72000))
index 09dfc90a9b0391c7c092285886b1c3fe164daab6..062f3de1d05bfd4de1011762b55fbb6311c84fc9 100644 (file)
@@ -10,6 +10,8 @@
 #ifndef __SYS_PROTO_H__
 #define __SYS_PROTO_H__
 
+#include <asm/imx-common/regs-common.h>
+
 int mxs_reset_block(struct mxs_register_32 *reg);
 int mxs_wait_mask_set(struct mxs_register_32 *reg,
                       uint32_t mask,
index 5866bf23e8d2a003515cf0e1637c1c27e2e66a40..34bd8c509aac924b6886b4a34fe0fe36cba38427 100644 (file)
@@ -64,6 +64,7 @@ void try_unlock_memory(void);
 u32 get_boot_type(void);
 void invalidate_dcache(u32);
 u32 wait_on_value(u32, u32, void *, u32);
+void cancel_out(u32 *num, u32 *den, u32 den_limit);
 void sdelay(unsigned long);
 void make_cs1_contiguous(void);
 void omap_nand_switch_ecc(uint32_t, uint32_t);
diff --git a/arch/arm/include/asm/arch-socfpga/spl.h b/arch/arm/include/asm/arch-socfpga/spl.h
deleted file mode 100644 (file)
index 7e310d5..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- *  Copyright (C) 2012 Pavel Machek <pavel@denx.de>
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#ifndef _SOCFPGA_SPL_H_
-#define _SOCFPGA_SPL_H_
-
-/* Symbols from linker script */
-extern char __malloc_start, __malloc_end, __stack_start;
-
-#define BOOT_DEVICE_RAM 1
-
-#endif
index 5669f392fab7a38e56558cc2f74ea5c903009b30..c562f621c22624ddf8589afb3e2cc3090eac8b1c 100644 (file)
 #define CLK_GATE_CLOSE                 0x0
 
 /* clock control module regs definition */
+#if defined(CONFIG_SUN6I) || defined(CONFIG_SUN8I)
+#include <asm/arch/clock_sun6i.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);
+unsigned int clock_get_pll5p(void);
 unsigned int clock_get_pll6(void);
 void clock_init_safe(void);
 void clock_init_uart(void);
index 1ba997adf9f8b4bf1f2b71c71bc5f1816e308794..90af8e250699b835bbf94c080e798d9eaa575121 100644 (file)
@@ -199,13 +199,16 @@ struct sunxi_ccm_reg {
 #define CCM_PLL5_CTRL_M1_MASK CCM_PLL5_CTRL_M1(0x3)
 #define CCM_PLL5_CTRL_M1_X(n) ((n) - 1)
 #define CCM_PLL5_CTRL_K(n) (((n) & 0x3) << 4)
+#define CCM_PLL5_CTRL_K_SHIFT 4
 #define CCM_PLL5_CTRL_K_MASK CCM_PLL5_CTRL_K(0x3)
 #define CCM_PLL5_CTRL_K_X(n) ((n) - 1)
 #define CCM_PLL5_CTRL_LDO (0x1 << 7)
 #define CCM_PLL5_CTRL_N(n) (((n) & 0x1f) << 8)
+#define CCM_PLL5_CTRL_N_SHIFT 8
 #define CCM_PLL5_CTRL_N_MASK CCM_PLL5_CTRL_N(0x1f)
 #define CCM_PLL5_CTRL_N_X(n) (n)
 #define CCM_PLL5_CTRL_P(n) (((n) & 0x3) << 16)
+#define CCM_PLL5_CTRL_P_SHIFT 16
 #define CCM_PLL5_CTRL_P_MASK CCM_PLL5_CTRL_P(0x3)
 #define CCM_PLL5_CTRL_P_X(n) ((n) - 1)
 #define CCM_PLL5_CTRL_BW (0x1 << 18)
diff --git a/arch/arm/include/asm/arch-sunxi/clock_sun6i.h b/arch/arm/include/asm/arch-sunxi/clock_sun6i.h
new file mode 100644 (file)
index 0000000..1397b35
--- /dev/null
@@ -0,0 +1,205 @@
+/*
+ * sun6i clock register definitions
+ *
+ * (C) Copyright 2007-2011
+ * Allwinner Technology Co., Ltd. <www.allwinnertech.com>
+ * Tom Cubie <tangliang@allwinnertech.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#ifndef _SUNXI_CLOCK_SUN6I_H
+#define _SUNXI_CLOCK_SUN6I_H
+
+struct sunxi_ccm_reg {
+       u32 pll1_cfg;           /* 0x00 pll1 control */
+       u32 reserved0;
+       u32 pll2_cfg;           /* 0x08 pll2 control */
+       u32 reserved1;
+       u32 pll3_cfg;           /* 0x10 pll3 control */
+       u32 reserved2;
+       u32 pll4_cfg;           /* 0x18 pll4 control */
+       u32 reserved3;
+       u32 pll5_cfg;           /* 0x20 pll5 control */
+       u32 reserved4;
+       u32 pll6_cfg;           /* 0x28 pll6 control */
+       u32 reserved5;
+       u32 pll7_cfg;           /* 0x30 pll7 control */
+       u32 reserved6;
+       u32 pll8_cfg;           /* 0x38 pll8 control */
+       u32 reserved7;
+       u32 mipi_pll_cfg;       /* 0x40 MIPI pll control */
+       u32 pll9_cfg;           /* 0x44 pll9 control */
+       u32 pll10_cfg;          /* 0x48 pll10 control */
+       u32 reserved8;
+       u32 cpu_axi_cfg;        /* 0x50 CPU/AXI divide ratio */
+       u32 ahb1_apb1_div;      /* 0x54 AHB1/APB1 divide ratio */
+       u32 apb2_div;           /* 0x58 APB2 divide ratio */
+       u32 axi_gate;           /* 0x5c axi module clock gating */
+       u32 ahb_gate0;          /* 0x60 ahb module clock gating 0 */
+       u32 ahb_gate1;          /* 0x64 ahb module clock gating 1 */
+       u32 apb1_gate;          /* 0x68 apb1 module clock gating */
+       u32 apb2_gate;          /* 0x6c apb2 module clock gating */
+       u32 reserved9[4];
+       u32 nand0_clk_cfg;      /* 0x80 nand0 clock control */
+       u32 nand1_clk_cfg;      /* 0x84 nand1 clock control */
+       u32 sd0_clk_cfg;        /* 0x88 sd0 clock control */
+       u32 sd1_clk_cfg;        /* 0x8c sd1 clock control */
+       u32 sd2_clk_cfg;        /* 0x90 sd2 clock control */
+       u32 sd3_clk_cfg;        /* 0x94 sd3 clock control */
+       u32 ts_clk_cfg;         /* 0x98 transport stream clock control */
+       u32 ss_clk_cfg;         /* 0x9c security system clock control */
+       u32 spi0_clk_cfg;       /* 0xa0 spi0 clock control */
+       u32 spi1_clk_cfg;       /* 0xa4 spi1 clock control */
+       u32 spi2_clk_cfg;       /* 0xa8 spi2 clock control */
+       u32 spi3_clk_cfg;       /* 0xac spi3 clock control */
+       u32 i2s0_clk_cfg;       /* 0xb0 I2S0 clock control*/
+       u32 i2s1_clk_cfg;       /* 0xb4 I2S1 clock control */
+       u32 reserved10[2];
+       u32 spdif_clk_cfg;      /* 0xc0 SPDIF clock control */
+       u32 reserved11[2];
+       u32 usb_clk_cfg;        /* 0xcc USB clock control */
+       u32 gmac_clk_cfg;       /* 0xd0 GMAC clock control */
+       u32 reserved12[7];
+       u32 mdfs_clk_cfg;       /* 0xf0 MDFS clock control */
+       u32 dram_clk_cfg;       /* 0xf4 DRAM configuration clock control */
+       u32 reserved13[2];
+       u32 dram_clk_gate;      /* 0x100 DRAM module gating */
+       u32 be0_clk_cfg;        /* 0x104 BE0 module clock */
+       u32 be1_clk_cfg;        /* 0x108 BE1 module clock */
+       u32 fe0_clk_cfg;        /* 0x10c FE0 module clock */
+       u32 fe1_clk_cfg;        /* 0x110 FE1 module clock */
+       u32 mp_clk_cfg;         /* 0x114 MP module clock */
+       u32 lcd0_ch0_clk_cfg;   /* 0x118 LCD0 CH0 module clock */
+       u32 lcd1_ch0_clk_cfg;   /* 0x11c LCD1 CH0 module clock */
+       u32 reserved14[3];
+       u32 lcd0_ch1_clk_cfg;   /* 0x12c LCD0 CH1 module clock */
+       u32 lcd1_ch1_clk_cfg;   /* 0x130 LCD1 CH1 module clock */
+       u32 csi0_clk_cfg;       /* 0x134 CSI0 module clock */
+       u32 csi1_clk_cfg;       /* 0x138 CSI1 module clock */
+       u32 ve_clk_cfg;         /* 0x13c VE module clock */
+       u32 adda_clk_cfg;       /* 0x140 ADDA module clock */
+       u32 avs_clk_cfg;        /* 0x144 AVS module clock */
+       u32 dmic_clk_cfg;       /* 0x148 Digital Mic module clock*/
+       u32 reserved15;
+       u32 hdmi_clk_cfg;       /* 0x150 HDMI module clock */
+       u32 ps_clk_cfg;         /* 0x154 PS module clock */
+       u32 mtc_clk_cfg;        /* 0x158 MTC module clock */
+       u32 mbus0_clk_cfg;      /* 0x15c MBUS0 module clock */
+       u32 mbus1_clk_cfg;      /* 0x160 MBUS1 module clock */
+       u32 reserved16;
+       u32 mipi_dsi_clk_cfg;   /* 0x168 MIPI DSI clock control */
+       u32 mipi_csi_clk_cfg;   /* 0x16c MIPI CSI clock control */
+       u32 reserved17[4];
+       u32 iep_drc0_clk_cfg;   /* 0x180 IEP DRC0 module clock */
+       u32 iep_drc1_clk_cfg;   /* 0x184 IEP DRC1 module clock */
+       u32 iep_deu0_clk_cfg;   /* 0x188 IEP DEU0 module clock */
+       u32 iep_deu1_clk_cfg;   /* 0x18c IEP DEU1 module clock */
+       u32 reserved18[4];
+       u32 gpu_core_clk_cfg;   /* 0x1a0 GPU core clock config */
+       u32 gpu_mem_clk_cfg;    /* 0x1a4 GPU memory clock config */
+       u32 gpu_hyd_clk_cfg;    /* 0x1a0 GPU HYD clock config */
+       u32 reserved19[21];
+       u32 pll_lock;           /* 0x200 PLL Lock Time */
+       u32 pll1_lock;          /* 0x204 PLL1 Lock Time */
+       u32 reserved20[6];
+       u32 pll1_bias_cfg;      /* 0x220 PLL1 Bias config */
+       u32 pll2_bias_cfg;      /* 0x224 PLL2 Bias config */
+       u32 pll3_bias_cfg;      /* 0x228 PLL3 Bias config */
+       u32 pll4_bias_cfg;      /* 0x22c PLL4 Bias config */
+       u32 pll5_bias_cfg;      /* 0x230 PLL5 Bias config */
+       u32 pll6_bias_cfg;      /* 0x234 PLL6 Bias config */
+       u32 pll7_bias_cfg;      /* 0x238 PLL7 Bias config */
+       u32 pll8_bias_cfg;      /* 0x23c PLL8 Bias config */
+       u32 mipi_bias_cfg;      /* 0x240 MIPI Bias config */
+       u32 pll9_bias_cfg;      /* 0x244 PLL9 Bias config */
+       u32 pll10_bias_cfg;     /* 0x248 PLL10 Bias config */
+       u32 reserved21[13];
+       u32 pll1_pattern_cfg;   /* 0x280 PLL1 Pattern config */
+       u32 pll2_pattern_cfg;   /* 0x284 PLL2 Pattern config */
+       u32 pll3_pattern_cfg;   /* 0x288 PLL3 Pattern config */
+       u32 pll4_pattern_cfg;   /* 0x28c PLL4 Pattern config */
+       u32 pll5_pattern_cfg;   /* 0x290 PLL5 Pattern config */
+       u32 pll6_pattern_cfg;   /* 0x294 PLL6 Pattern config */
+       u32 pll7_pattern_cfg;   /* 0x298 PLL7 Pattern config */
+       u32 pll8_pattern_cfg;   /* 0x29c PLL8 Pattern config */
+       u32 mipi_pattern_cfg;   /* 0x2a0 MIPI Pattern config */
+       u32 pll9_pattern_cfg;   /* 0x2a4 PLL9 Pattern config */
+       u32 pll10_pattern_cfg;  /* 0x2a8 PLL10 Pattern config */
+       u32 reserved22[5];
+       u32 ahb_reset0_cfg;     /* 0x2c0 AHB1 Reset 0 config */
+       u32 ahb_reset1_cfg;     /* 0x2c4 AHB1 Reset 1 config */
+       u32 ahb_reset2_cfg;     /* 0x2c8 AHB1 Reset 2 config */
+       u32 reserved23;
+       u32 apb1_reset_cfg;     /* 0x2d0 APB1 Reset config */
+       u32 reserved24;
+       u32 apb2_reset_cfg;     /* 0x2d8 APB2 Reset config */
+};
+
+/* apb2 bit field */
+#define APB2_CLK_SRC_LOSC              (0x0 << 24)
+#define APB2_CLK_SRC_OSC24M            (0x1 << 24)
+#define APB2_CLK_SRC_PLL6              (0x2 << 24)
+#define APB2_CLK_SRC_MASK              (0x3 << 24)
+#define APB2_CLK_RATE_N_1              (0x0 << 16)
+#define APB2_CLK_RATE_N_2              (0x1 << 16)
+#define APB2_CLK_RATE_N_4              (0x2 << 16)
+#define APB2_CLK_RATE_N_8              (0x3 << 16)
+#define APB2_CLK_RATE_N_MASK           (3 << 16)
+#define APB2_CLK_RATE_M(m)             (((m)-1) << 0)
+#define APB2_CLK_RATE_M_MASK            (0x1f << 0)
+
+/* apb2 gate field */
+#define APB2_GATE_UART_SHIFT   (16)
+#define APB2_GATE_UART_MASK            (0xff << APB2_GATE_UART_SHIFT)
+#define APB2_GATE_TWI_SHIFT    (0)
+#define APB2_GATE_TWI_MASK             (0xf << APB2_GATE_TWI_SHIFT)
+
+/* cpu_axi_cfg bits */
+#define AXI_DIV_SHIFT                  0
+#define ATB_DIV_SHIFT                  8
+#define CPU_CLK_SRC_SHIFT              16
+
+#define AXI_DIV_1                      0
+#define AXI_DIV_2                      1
+#define AXI_DIV_3                      2
+#define AXI_DIV_4                      3
+#define ATB_DIV_1                      0
+#define ATB_DIV_2                      1
+#define ATB_DIV_4                      2
+#define CPU_CLK_SRC_OSC24M             1
+#define CPU_CLK_SRC_PLL1               2
+
+#define PLL1_CFG_DEFAULT               0x90011b21
+
+#define PLL6_CFG_DEFAULT               0x90041811
+
+#define CCM_PLL6_CTRL_N_SHIFT          8
+#define CCM_PLL6_CTRL_N_MASK           (0x1f << CCM_PLL6_CTRL_N_SHIFT)
+#define CCM_PLL6_CTRL_K_SHIFT          4
+#define CCM_PLL6_CTRL_K_MASK           (0x3 << CCM_PLL6_CTRL_K_SHIFT)
+
+#define AHB_GATE_OFFSET_MMC3           11
+#define AHB_GATE_OFFSET_MMC2           10
+#define AHB_GATE_OFFSET_MMC1           9
+#define AHB_GATE_OFFSET_MMC0           8
+#define AHB_GATE_OFFSET_MMC(n)         (AHB_GATE_OFFSET_MMC0 + (n))
+
+#define CCM_MMC_CTRL_OSCM24 (0x0 << 24)
+#define CCM_MMC_CTRL_PLL6   (0x1 << 24)
+
+#define CCM_MMC_CTRL_ENABLE (0x1 << 31)
+
+#define AHB_RESET_OFFSET_MMC3          11
+#define AHB_RESET_OFFSET_MMC2          10
+#define AHB_RESET_OFFSET_MMC1          9
+#define AHB_RESET_OFFSET_MMC0          8
+#define AHB_RESET_OFFSET_MMC(n)                (AHB_RESET_OFFSET_MMC0 + (n))
+
+/* apb2 reset */
+#define APB2_RESET_UART_SHIFT          (16)
+#define APB2_RESET_UART_MASK           (0xff << APB2_RESET_UART_SHIFT)
+#define APB2_RESET_TWI_SHIFT           (0)
+#define APB2_RESET_TWI_MASK            (0xf << APB2_RESET_TWI_SHIFT)
+
+#endif /* _SUNXI_CLOCK_SUN6I_H */
index a987e51d576902d9ec94c6f4196a97e14e899e7f..0de79a0d50890b8463b59b83169ac0703748aec0 100644 (file)
 #define SUNXI_MALI400_BASE             0x01c40000
 #define SUNXI_GMAC_BASE                        0x01c50000
 
+#define SUNXI_DRAM_COM_BASE            0x01c62000
+#define SUNXI_DRAM_CTL_BASE            0x01c63000
+#define SUNXI_DRAM_PHY_CH1_BASE                0x01c65000
+#define SUNXI_DRAM_PHY_CH2_BASE                0x01c66000
+
 /* module sram */
 #define SUNXI_SRAM_C_BASE              0x01d00000
 
 #define SUNXI_MP_BASE                  0x01e80000
 #define SUNXI_AVG_BASE                 0x01ea0000
 
+#define SUNXI_PRCM_BASE                        0x01f01400
+#define SUNXI_R_UART_BASE              0x01f02800
+#define SUNXI_R_PIO_BASE               0x01f02c00
+#define SUNXI_P2WI_BASE                        0x01f03400
+
 /* CoreSight Debug Module */
 #define SUNXI_CSDM_BASE                        0x3f500000
 
index f7f3d8c41ad4c3cd0f8e5673513b9477f15541dc..7bb649950a982d19d9ea293352a35e82414e06ad 100644 (file)
@@ -10,6 +10,7 @@
 #define _SUNXI_GPIO_H
 
 #include <linux/types.h>
+#include <asm/arch/cpu.h>
 
 /*
  * sunxi has 9 banks of gpio, they are:
 #define SUNXI_GPIO_G   6
 #define SUNXI_GPIO_H   7
 #define SUNXI_GPIO_I   8
+
+/*
+ * This defines the number of GPIO banks for the _main_ GPIO controller.
+ * You should fix up the padding in struct sunxi_gpio_reg below if you
+ * change this.
+ */
 #define SUNXI_GPIO_BANKS 9
 
+/*
+ * sun6i/sun8i and later SoCs have an additional GPIO controller (R_PIO)
+ * at a different register offset.
+ *
+ * sun6i has 2 banks:
+ * PL0 - PL8  | PM0 - PM7
+ *
+ * sun8i has 1 bank:
+ * PL0 - PL11
+ */
+#define SUNXI_GPIO_L   11
+#define SUNXI_GPIO_M   12
+
 struct sunxi_gpio {
        u32 cfg[4];
        u32 dat;
@@ -50,8 +70,9 @@ struct sunxi_gpio_reg {
        struct sunxi_gpio_int gpio_int;
 };
 
-#define BANK_TO_GPIO(bank) \
-       &((struct sunxi_gpio_reg *)SUNXI_PIO_BASE)->gpio_bank[bank]
+#define BANK_TO_GPIO(bank)     (((bank) < SUNXI_GPIO_L) ? \
+       &((struct sunxi_gpio_reg *)SUNXI_PIO_BASE)->gpio_bank[bank] : \
+       &((struct sunxi_gpio_reg *)SUNXI_R_PIO_BASE)->gpio_bank[(bank) - SUNXI_GPIO_L])
 
 #define GPIO_BANK(pin)         ((pin) >> 5)
 #define GPIO_NUM(pin)          ((pin) & 0x1f)
@@ -75,6 +96,8 @@ struct sunxi_gpio_reg {
 #define SUNXI_GPIO_G_NR                32
 #define SUNXI_GPIO_H_NR                32
 #define SUNXI_GPIO_I_NR                32
+#define SUNXI_GPIO_L_NR                32
+#define SUNXI_GPIO_M_NR                32
 
 #define SUNXI_GPIO_NEXT(__gpio) \
        ((__gpio##_START) + (__gpio##_NR) + 0)
@@ -89,6 +112,8 @@ enum sunxi_gpio_number {
        SUNXI_GPIO_G_START = SUNXI_GPIO_NEXT(SUNXI_GPIO_F),
        SUNXI_GPIO_H_START = SUNXI_GPIO_NEXT(SUNXI_GPIO_G),
        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 number definitions */
@@ -101,6 +126,8 @@ enum sunxi_gpio_number {
 #define SUNXI_GPG(_nr) (SUNXI_GPIO_G_START + (_nr))
 #define SUNXI_GPH(_nr) (SUNXI_GPIO_H_START + (_nr))
 #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))
 
 /* GPIO pin function config */
 #define SUNXI_GPIO_INPUT       0
@@ -117,6 +144,8 @@ enum sunxi_gpio_number {
 #define SUN5I_GPB19_UART0_TX   2
 #define SUN5I_GPB20_UART0_RX   2
 
+#define SUN5I_GPG3_SDC1                2
+
 #define SUN5I_GPG3_UART1_TX    4
 #define SUN5I_GPG4_UART1_RX    4
 
@@ -125,15 +154,27 @@ enum sunxi_gpio_number {
 #define SUNXI_GPF0_SDC0                2
 
 #define SUNXI_GPF2_SDC0                2
+
+#ifdef CONFIG_SUN8I
+#define SUNXI_GPF2_UART0_TX    3
+#define SUNXI_GPF4_UART0_RX    3
+#else
 #define SUNXI_GPF2_UART0_TX    4
 #define SUNXI_GPF4_UART0_RX    4
+#endif
 
 #define SUN4I_GPG0_SDC1                4
 
 #define SUN4I_GPH22_SDC1       5
 
+#define SUN6I_GPH20_UART0_TX   2
+#define SUN6I_GPH21_UART0_RX   2
+
 #define SUN4I_GPI4_SDC3                2
 
+#define SUN8I_GPL2_R_UART_TX   2
+#define SUN8I_GPL3_R_UART_RX   2
+
 /* GPIO pin pull-up/down config */
 #define SUNXI_GPIO_PULL_DISABLE        0
 #define SUNXI_GPIO_PULL_UP     1
index 53196e3b024c68f3232a1596f29910f16f2131f0..8a216740a722e4471f4f39680634fe9db861b354 100644 (file)
@@ -43,7 +43,10 @@ struct sunxi_mmc {
        u32 chda;               /* 0x90 */
        u32 cbda;               /* 0x94 */
        u32 res1[26];
-       u32 fifo;               /* 0x100 FIFO access address */
+#if defined(CONFIG_SUN6I) || defined(CONFIG_SUN8I)
+       u32 res2[64];
+#endif
+       u32 fifo;               /* 0x100 (0x200 on sun6i) FIFO access address */
 };
 
 #define SUNXI_MMC_CLK_POWERSAVE                (0x1 << 17)
@@ -120,5 +123,5 @@ struct sunxi_mmc {
 #define SUNXI_MMC_IDIE_TXIRQ           (0x1 << 0)
 #define SUNXI_MMC_IDIE_RXIRQ           (0x1 << 1)
 
-int sunxi_mmc_init(int sdc_no);
+struct mmc *sunxi_mmc_init(int sdc_no);
 #endif /* _SUNXI_MMC_H */
diff --git a/arch/arm/include/asm/arch-sunxi/prcm.h b/arch/arm/include/asm/arch-sunxi/prcm.h
new file mode 100644 (file)
index 0000000..3d3bfa6
--- /dev/null
@@ -0,0 +1,238 @@
+/*
+ * Sunxi A31 Power Management Unit register definition.
+ *
+ * (C) Copyright 2013 Oliver Schinagl <oliver@schinagl.nl>
+ * http://linux-sunxi.org
+ * Allwinner Technology Co., Ltd. <www.allwinnertech.com>
+ * Berg Xing <bergxing@allwinnertech.com>
+ * Tom Cubie <tangliang@allwinnertech.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#ifndef _SUNXI_PRCM_H
+#define _SUNXI_PRCM_H
+
+#define __PRCM_CPUS_CFG_PRE(n) (((n) & 0x3) << 4)
+#define PRCM_CPUS_CFG_PRE_MASK __PRCM_CPUS_CFG_PRE(0x3)
+#define __PRCM_CPUS_CFG_PRE_DIV(n) (((n) >> 1) - 1)
+#define PRCM_CPUS_CFG_PRE_DIV(n) \
+       __PRCM_CPUS_CFG_PRE(__PRCM_CPUS_CFG_CLK_PRE(n))
+#define __PRCM_CPUS_CFG_POST(n) (((n) & 0x1f) << 8)
+#define PRCM_CPUS_CFG_POST_MASK __PRCM_CPUS_CFG_POST(0x1f)
+#define __PRCM_CPUS_CFG_POST_DIV(n) ((n) - 1)
+#define PRCM_CPUS_CFG_POST_DIV(n) \
+       __PRCM_CPUS_CFG_POST_DIV(__PRCM_CPUS_CFG_POST_DIV(n))
+#define __PRCM_CPUS_CFG_CLK_SRC(n) (((n) & 0x3) << 16)
+#define PRCM_CPUS_CFG_CLK_SRC_MASK __PRCM_CPUS_CFG_CLK_SRC(0x3)
+#define __PRCM_CPUS_CFG_CLK_SRC_LOSC 0x0
+#define __PRCM_CPUS_CFG_CLK_SRC_HOSC 0x1
+#define __PRCM_CPUS_CFG_CLK_SRC_PLL6 0x2
+#define __PRCM_CPUS_CFG_CLK_SRC_PDIV 0x3
+#define PRCM_CPUS_CFG_CLK_SRC_LOSC \
+       __PRCM_CPUS_CFG_CLK_SRC(__PRCM_CPUS_CFG_CLK_SRC_LOSC)
+#define PRCM_CPUS_CFG_CLK_SRC_HOSC \
+       __PRCM_CPUS_CFG_CLK_SRC(__PRCM_CPUS_CFG_CLK_SRC_HOSC)
+#define PRCM_CPUS_CFG_CLK_SRC_PLL6 \
+       __PRCM_CPUS_CFG_CLK_SRC(__PRCM_CPUS_CFG_CLK_SRC_PLL6)
+#define PRCM_CPUS_CFG_CLK_SRC_PDIV \
+       __PRCM_CPUS_CFG_CLK_SRC(__PRCM_CPUS_CFG_CLK_SRC_PDIV)
+
+#define __PRCM_APB0_RATIO(n) (((n) & 0x3) << 0)
+#define PRCM_APB0_RATIO_DIV_MASK __PRCM_APB0_RATIO_DIV(0x3)
+#define __PRCM_APB0_RATIO_DIV(n) (((n) >> 1) - 1)
+#define PRCM_APB0_RATIO_DIV(n) \
+       __PRCM_APB0_RATIO(__PRCM_APB0_RATIO_DIV(n))
+
+#define PRCM_CPU_CFG_NEON_CLK_EN (0x1 << 0)
+#define PRCM_CPU_CFG_CPU_CLK_EN (0x1 << 1)
+
+#define PRCM_APB0_GATE_PIO (0x1 << 0)
+#define PRCM_APB0_GATE_IR (0x1 << 1)
+#define PRCM_APB0_GATE_TIMER01 (0x1 << 2)
+#define PRCM_APB0_GATE_P2WI (0x1 << 3)
+#define PRCM_APB0_GATE_UART (0x1 << 4)
+#define PRCM_APB0_GATE_1WIRE (0x1 << 5)
+#define PRCM_APB0_GATE_I2C (0x1 << 6)
+
+#define PRCM_APB0_RESET_PIO (0x1 << 0)
+#define PRCM_APB0_RESET_IR (0x1 << 1)
+#define PRCM_APB0_RESET_TIMER01 (0x1 << 2)
+#define PRCM_APB0_RESET_P2WI (0x1 << 3)
+#define PRCM_APB0_RESET_UART (0x1 << 4)
+#define PRCM_APB0_RESET_1WIRE (0x1 << 5)
+#define PRCM_APB0_RESET_I2C (0x1 << 6)
+
+#define PRCM_PLL_CTRL_PLL_BIAS (0x1 << 0)
+#define PRCM_PLL_CTRL_HOSC_GAIN_ENH (0x1 << 1)
+#define __PRCM_PLL_CTRL_USB_CLK_SRC(n) (((n) & 0x3) << 4)
+#define PRCM_PLL_CTRL_USB_CLK_SRC_MASK \
+       __PRCM_PLL_CTRL_USB_CLK_SRC(0x3)
+#define __PRCM_PLL_CTRL_USB_CLK_0 0x0
+#define __PRCM_PLL_CTRL_USB_CLK_1 0x1
+#define __PRCM_PLL_CTRL_USB_CLK_2 0x2
+#define __PRCM_PLL_CTRL_USB_CLK_3 0x3
+#define PRCM_PLL_CTRL_USB_CLK_0 \
+       __PRCM_PLL_CTRL_USB_CLK_SRC(__PRCM_PLL_CTRL_USB_CLK_0)
+#define PRCM_PLL_CTRL_USB_CLK_1 \
+       __PRCM_PLL_CTRL_USB_CLK_SRC(__PRCM_PLL_CTRL_USB_CLK_1)
+#define PRCM_PLL_CTRL_USB_CLK_2 \
+       __PRCM_PLL_CTRL_USB_CLK_SRC(__PRCM_PLL_CTRL_USB_CLK_2)
+#define PRCM_PLL_CTRL_USB_CLK_3 \
+       __PRCM_PLL_CTRL_USB_CLK_SRC(__PRCM_PLL_CTRL_USB_CLK_3)
+#define __PRCM_PLL_CTRL_INT_PLL_IN_SEL(n) (((n) & 0x3) << 12)
+#define PRCM_PLL_CTRL_INT_PLL_IN_SEL_MASK \
+       __PRCM_PLL_CTRL_INT_PLL_IN_SEL(0x3)
+#define PRCM_PLL_CTRL_INT_PLL_IN_SEL(n) \
+       __PRCM_PLL_CTRL_INT_PLL_IN_SEL(n)
+#define __PRCM_PLL_CTRL_HOSC_CLK_SEL(n) (((n) & 0x3) << 20)
+#define PRCM_PLL_CTRL_HOSC_CLK_SEL_MASK \
+       __PRCM_PLL_CTRL_HOSC_CLK_SEL(0x3)
+#define __PRCM_PLL_CTRL_HOSC_CLK_0 0x0
+#define __PRCM_PLL_CTRL_HOSC_CLK_1 0x1
+#define __PRCM_PLL_CTRL_HOSC_CLK_2 0x2
+#define __PRCM_PLL_CTRL_HOSC_CLK_3 0x3
+#define PRCM_PLL_CTRL_HOSC_CLK_0 \
+       __PRCM_PLL_CTRL_HOSC_CLK_SEL(__PRCM_PLL_CTRL_HOSC_CLK_0)
+#define PRCM_PLL_CTRL_HOSC_CLK_1 \
+       __PRCM_PLL_CTRL_HOSC_CLK_SEL(__PRCM_PLL_CTRL_HOSC_CLK_1)
+#define PRCM_PLL_CTRL_HOSC_CLK_2 \
+       __PRCM_PLL_CTRL_HOSC_CLK_SEL(__PRCM_PLL_CTRL_HOSC_CLK_2)
+#define PRCM_PLL_CTRL_HOSC_CLK_3 \
+       __PRCM_PLL_CTRL_HOSC_CLK_SEL(__PRCM_PLL_CTRL_HOSC_CLK_3)
+#define PRCM_PLL_CTRL_PLL_TST_SRC_EXT (0x1 << 24)
+#define PRCM_PLL_CTRL_LDO_DIGITAL_EN (0x1 << 0)
+#define PRCM_PLL_CTRL_LDO_ANALOG_EN (0x1 << 1)
+#define PRCM_PLL_CTRL_EXT_OSC_EN (0x1 << 2)
+#define PRCM_PLL_CTRL_CLK_TST_EN (0x1 << 3)
+#define PRCM_PLL_CTRL_IN_PWR_HIGH (0x1 << 15) /* 3.3 for hi 2.5 for lo */
+#define __PRCM_PLL_CTRL_VDD_LDO_OUT(n) (((n) & 0x7) << 16)
+#define PRCM_PLL_CTRL_LDO_OUT_MASK \
+       __PRCM_PLL_CTRL_LDO_OUT(0x7)
+/* When using the low voltage 20 mV steps, and high voltage 30 mV steps */
+#define PRCM_PLL_CTRL_LDO_OUT_L(n) \
+       __PRCM_PLL_CTRL_VDD_LDO_OUT((((n) - 1000) / 20) & 0x7)
+#define PRCM_PLL_CTRL_LDO_OUT_H(n) \
+       __PRCM_PLL_CTRL_VDD_LDO_OUT((((n) - 1160) / 30) & 0x7)
+#define PRCM_PLL_CTRL_LDO_OUT_LV(n) \
+       __PRCM_PLL_CTRL_VDD_LDO_OUT((((n) & 0x7) * 20) + 1000)
+#define PRCM_PLL_CTRL_LDO_OUT_HV(n) \
+       __PRCM_PLL_CTRL_VDD_LDO_OUT((((n) & 0x7) * 30) + 1160)
+#define PRCM_PLL_CTRL_LDO_KEY (0xa7 << 24)
+
+#define PRCM_CLK_1WIRE_GATE (0x1 << 31)
+
+#define __PRCM_CLK_MOD0_M(n) (((n) & 0xf) << 0)
+#define PRCM_CLK_MOD0_M_MASK __PRCM_CLK_MOD0_M(0xf)
+#define __PRCM_CLK_MOD0_M_X(n) (n - 1)
+#define PRCM_CLK_MOD0_M(n) __PRCM_CLK_MOD0_M(__PRCM_CLK_MOD0_M_X(n))
+#define PRCM_CLK_MOD0_OUT_PHASE(n) (((n) & 0x7) << 8)
+#define PRCM_CLK_MOD0_OUT_PHASE_MASK(n) PRCM_CLK_MOD0_OUT_PHASE(0x7)
+#define _PRCM_CLK_MOD0_N(n) (((n) & 0x3) << 16)
+#define PRCM_CLK_MOD0_N_MASK __PRCM_CLK_MOD_N(0x3)
+#define __PRCM_CLK_MOD0_N_X(n) (((n) >> 1) - 1)
+#define PRCM_CLK_MOD0_N(n) __PRCM_CLK_MOD0_N(__PRCM_CLK_MOD0_N_X(n))
+#define PRCM_CLK_MOD0_SMPL_PHASE(n) (((n) & 0x7) << 20)
+#define PRCM_CLK_MOD0_SMPL_PHASE_MASK PRCM_CLK_MOD0_SMPL_PHASE(0x7)
+#define PRCM_CLK_MOD0_SRC_SEL(n) (((n) & 0x7) << 24)
+#define PRCM_CLK_MOD0_SRC_SEL_MASK PRCM_CLK_MOD0_SRC_SEL(0x7)
+#define PRCM_CLK_MOD0_GATE_EN (0x1 << 31)
+
+#define PRCM_APB0_RESET_PIO (0x1 << 0)
+#define PRCM_APB0_RESET_IR (0x1 << 1)
+#define PRCM_APB0_RESET_TIMER01 (0x1 << 2)
+#define PRCM_APB0_RESET_P2WI (0x1 << 3)
+#define PRCM_APB0_RESET_UART (0x1 << 4)
+#define PRCM_APB0_RESET_1WIRE (0x1 << 5)
+#define PRCM_APB0_RESET_I2C (0x1 << 6)
+
+#define __PRCM_CLK_OUTD_M(n) (((n) & 0x7) << 8)
+#define PRCM_CLK_OUTD_M_MASK __PRCM_CLK_OUTD_M(0x7)
+#define __PRCM_CLK_OUTD_M_X() ((n) - 1)
+#define PRCM_CLK_OUTD_M(n) __PRCM_CLK_OUTD_M(__PRCM_CLK_OUTD_M_X(n))
+#define __PRCM_CLK_OUTD_N(n) (((n) & 0x7) << 20)
+#define PRCM_CLK_OUTD_N_MASK __PRCM_CLK_OUTD_N(0x7)
+#define __PRCM_CLK_OUTD_N_X(n) (((n) >> 1) - 1)
+#define PRCM_CLK_OUTD_N(n) __PRCM_CLK_OUTD_N(__PRCM_CLK_OUTD_N_X(n)
+#define __PRCM_CLK_OUTD_SRC_SEL(n) (((n) & 0x3) << 24)
+#define PRCM_CLK_OUTD_SRC_SEL_MASK __PRCM_CLK_OUTD_SRC_SEL(0x3)
+#define __PRCM_CLK_OUTD_SRC_LOSC2 0x0
+#define __PRCM_CLK_OUTD_SRC_LOSC 0x1
+#define __PRCM_CLK_OUTD_SRC_HOSC 0x2
+#define __PRCM_CLK_OUTD_SRC_ERR 0x3
+#define PRCM_CLK_OUTD_SRC_LOSC2 \
+#deifne __PRCM_CLK_OUTD_SRC_SEL(__PRCM_CLK_OUTD_SRC_LOSC2)
+#define PRCM_CLK_OUTD_SRC_LOSC \
+#deifne __PRCM_CLK_OUTD_SRC_SEL(__PRCM_CLK_OUTD_SRC_LOSC)
+#define PRCM_CLK_OUTD_SRC_HOSC \
+#deifne __PRCM_CLK_OUTD_SRC_SEL(__PRCM_CLK_OUTD_SRC_HOSC)
+#define PRCM_CLK_OUTD_SRC_ERR \
+#deifne __PRCM_CLK_OUTD_SRC_SEL(__PRCM_CLK_OUTD_SRC_ERR)
+#define PRCM_CLK_OUTD_EN (0x1 << 31)
+
+#define PRCM_CPU0_PWROFF (0x1 << 0)
+#define PRCM_CPU1_PWROFF (0x1 << 1)
+#define PRCM_CPU2_PWROFF (0x1 << 2)
+#define PRCM_CPU3_PWROFF (0x1 << 3)
+#define PRCM_CPU_ALL_PWROFF (0xf << 0)
+
+#define PRCM_VDD_SYS_DRAM_CH0_PAD_HOLD_PWROFF (0x1 << 0)
+#define PRCM_VDD_SYS_DRAM_CH1_PAD_HOLD_PWROFF (0x1 << 1)
+#define PRCM_VDD_SYS_AVCC_A_PWROFF (0x1 << 2)
+#define PRCM_VDD_SYS_CPU0_VDD_PWROFF (0x1 << 3)
+
+#define PRCM_VDD_GPU_PWROFF (0x1 << 0)
+
+#define PRCM_VDD_SYS_RESET (0x1 << 0)
+
+#define PRCM_CPU1_PWR_CLAMP(n) (((n) & 0xff) << 0)
+#define PRCM_CPU1_PWR_CLAMP_MASK PRCM_CPU1_PWR_CLAMP(0xff)
+
+#define PRCM_CPU2_PWR_CLAMP(n) (((n) & 0xff) << 0)
+#define PRCM_CPU2_PWR_CLAMP_MASK PRCM_CPU2_PWR_CLAMP(0xff)
+
+#define PRCM_CPU3_PWR_CLAMP(n) (((n) & 0xff) << 0)
+#define PRCM_CPU3_PWR_CLAMP_MASK PRCM_CPU3_PWR_CLAMP(0xff)
+
+#ifndef __ASSEMBLY__
+struct sunxi_prcm_reg {
+       u32 cpus_cfg;           /* 0x000 */
+       u8 res0[0x8];           /* 0x004 */
+       u32 apb0_ratio;         /* 0x00c */
+       u32 cpu0_cfg;           /* 0x010 */
+       u32 cpu1_cfg;           /* 0x014 */
+       u32 cpu2_cfg;           /* 0x018 */
+       u32 cpu3_cfg;           /* 0x01c */
+       u8 res1[0x8];           /* 0x020 */
+       u32 apb0_gate;          /* 0x028 */
+       u8 res2[0x14];          /* 0x02c */
+       u32 pll_ctrl0;          /* 0x040 */
+       u32 pll_ctrl1;          /* 0x044 */
+       u8 res3[0x8];           /* 0x048 */
+       u32 clk_1wire;          /* 0x050 */
+       u32 clk_ir;             /* 0x054 */
+       u8 res4[0x58];          /* 0x058 */
+       u32 apb0_reset;         /* 0x0b0 */
+       u8 res5[0x3c];          /* 0x0b4 */
+       u32 clk_outd;           /* 0x0f0 */
+       u8 res6[0xc];           /* 0x0f4 */
+       u32 cpu_pwroff;         /* 0x100 */
+       u8 res7[0xc];           /* 0x104 */
+       u32 vdd_sys_pwroff;     /* 0x110 */
+       u8 res8[0x4];           /* 0x114 */
+       u32 gpu_pwroff;         /* 0x118 */
+       u8 res9[0x4];           /* 0x11c */
+       u32 vdd_pwr_reset;      /* 0x120 */
+       u8 res10[0x20];         /* 0x124 */
+       u32 cpu1_pwr_clamp;     /* 0x144 */
+       u32 cpu2_pwr_clamp;     /* 0x148 */
+       u32 cpu3_pwr_clamp;     /* 0x14c */
+       u8 res11[0x30];         /* 0x150 */
+       u32 dram_pwr;           /* 0x180 */
+       u8 res12[0xc];          /* 0x184 */
+       u32 dram_tst;           /* 0x190 */
+};
+
+void prcm_apb0_enable(u32 flags);
+#endif /* __ASSEMBLY__ */
+#endif /* _PRCM_H */
index 58e14fd0f713033aeaa2e2b0976b40444a8e1399..03a0684c797a3c28179886a283ca2382d249b17b 100644 (file)
 #ifndef _SUNXI_TIMER_H_
 #define _SUNXI_TIMER_H_
 
-#define WDT_CTRL_RESTART       (0x1 << 0)
-#define WDT_CTRL_KEY           (0x0a57 << 1)
-#define WDT_MODE_EN            (0x1 << 0)
-#define WDT_MODE_RESET_EN      (0x1 << 1)
-
 #ifndef __ASSEMBLY__
 
 #include <linux/types.h>
+#include <asm/arch/watchdog.h>
 
 /* General purpose timer */
 struct sunxi_timer {
@@ -43,12 +39,6 @@ struct sunxi_64cnt {
        u32 hi;                 /* 0xa8 */
 };
 
-/* Watchdog */
-struct sunxi_wdog {
-       u32 ctl;                /* 0x90 */
-       u32 mode;               /* 0x94 */
-};
-
 /* Rtc */
 struct sunxi_rtc {
        u32 ctl;                /* 0x100 */
@@ -77,15 +67,20 @@ struct sunxi_timer_reg {
        struct sunxi_timer timer[6];    /* We have 6 timers */
        u8 res2[16];
        struct sunxi_avs avs;
-       struct sunxi_wdog wdog;
-       u8 res3[8];
-       struct sunxi_64cnt cnt64;
+#if defined(CONFIG_SUN4I) || defined(CONFIG_SUN5I) || defined(CONFIG_SUN7I)
+       struct sunxi_wdog wdog; /* 0x90 */
+       /* XXX the following is not accurate for sun5i/sun7i */
+       struct sunxi_64cnt cnt64;       /* 0xa0 */
        u8 res4[0x58];
        struct sunxi_rtc rtc;
        struct sunxi_alarm alarm;
        struct sunxi_tgp tgp[4];
        u8 res5[8];
        u32 cpu_cfg;
+#else /* CONFIG_SUN6I || CONFIG_SUN8I || ... */
+       u8 res3[16];
+       struct sunxi_wdog wdog[5];      /* We have 5 watchdogs */
+#endif
 };
 
 #endif /* __ASSEMBLY__ */
diff --git a/arch/arm/include/asm/arch-sunxi/watchdog.h b/arch/arm/include/asm/arch-sunxi/watchdog.h
new file mode 100644 (file)
index 0000000..ccc8fa3
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * (C) Copyright 2014
+ * Chen-Yu Tsai <wens@csie.org>
+ *
+ * Watchdog register definitions
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#ifndef _SUNXI_WATCHDOG_H_
+#define _SUNXI_WATCHDOG_H_
+
+#define WDT_CTRL_RESTART       (0x1 << 0)
+#define WDT_CTRL_KEY           (0x0a57 << 1)
+
+#if defined(CONFIG_SUN4I) || defined(CONFIG_SUN5I) || defined(CONFIG_SUN7I)
+
+#define WDT_MODE_EN            (0x1 << 0)
+#define WDT_MODE_RESET_EN      (0x1 << 1)
+
+struct sunxi_wdog {
+       u32 ctl;                /* 0x00 */
+       u32 mode;               /* 0x04 */
+       u32 res[2];
+};
+
+#else
+
+#define WDT_CFG_RESET          (0x1)
+#define WDT_MODE_EN            (0x1)
+
+struct sunxi_wdog {
+       u32 irq_en;             /* 0x00 */
+       u32 irq_sta;            /* 0x04 */
+       u32 res1[2];
+       u32 ctl;                /* 0x10 */
+       u32 cfg;                /* 0x14 */
+       u32 mode;               /* 0x18 */
+       u32 res2;
+};
+
+#endif
+
+#endif /* _SUNXI_WATCHDOG_H_ */
index ff773646cbec669607d5e03a624d1207b4c65b8b..783bb3c0fa12265901fdd3b99c9f2cc008486a83 100644 (file)
@@ -24,10 +24,11 @@ void gpio_early_init(void);  /* overrideable GPIO config        */
  * an empty stub function will be called.
  */
 
-void pinmux_init(void);      /* overrideable general pinmux setup */
-void pin_mux_usb(void);      /* overrideable USB pinmux setup     */
-void pin_mux_spi(void);      /* overrideable SPI pinmux setup     */
-void pin_mux_nand(void);     /* overrideable NAND pinmux setup    */
-void pin_mux_display(void);  /* overrideable DISPLAY pinmux setup */
+void pinmux_init(void);      /* overridable general pinmux setup */
+void pin_mux_usb(void);      /* overridable USB pinmux setup     */
+void pin_mux_spi(void);      /* overridable SPI pinmux setup     */
+void pin_mux_nand(void);     /* overridable NAND pinmux setup    */
+void pin_mux_mmc(void);      /* overridable mmc pinmux setup     */
+void pin_mux_display(void);  /* overridable DISPLAY pinmux setup */
 
 #endif
diff --git a/arch/arm/include/asm/arch-tegra114/mc.h b/arch/arm/include/asm/arch-tegra114/mc.h
new file mode 100644 (file)
index 0000000..044b1e0
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ *  (C) Copyright 2014
+ *  NVIDIA Corporation <www.nvidia.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#ifndef _TEGRA114_MC_H_
+#define _TEGRA114_MC_H_
+
+/**
+ * Defines the memory controller registers we need/care about
+ */
+struct mc_ctlr {
+       u32 reserved0[4];                       /* offset 0x00 - 0x0C */
+       u32 mc_smmu_config;                     /* offset 0x10 */
+       u32 mc_smmu_tlb_config;                 /* offset 0x14 */
+       u32 mc_smmu_ptc_config;                 /* offset 0x18 */
+       u32 mc_smmu_ptb_asid;                   /* offset 0x1C */
+       u32 mc_smmu_ptb_data;                   /* offset 0x20 */
+       u32 reserved1[3];                       /* offset 0x24 - 0x2C */
+       u32 mc_smmu_tlb_flush;                  /* offset 0x30 */
+       u32 mc_smmu_ptc_flush;                  /* offset 0x34 */
+       u32 reserved2[6];                       /* offset 0x38 - 0x4C */
+       u32 mc_emem_cfg;                        /* offset 0x50 */
+       u32 mc_emem_adr_cfg;                    /* offset 0x54 */
+       u32 mc_emem_adr_cfg_dev0;               /* offset 0x58 */
+       u32 mc_emem_adr_cfg_dev1;               /* offset 0x5C */
+       u32 reserved3[12];                      /* offset 0x60 - 0x8C */
+       u32 mc_emem_arb_reserved[28];           /* offset 0x90 - 0xFC */
+       u32 reserved4[338];                     /* offset 0x100 - 0x644 */
+       u32 mc_video_protect_bom;               /* offset 0x648 */
+       u32 mc_video_protect_size_mb;           /* offset 0x64c */
+       u32 mc_video_protect_reg_ctrl;          /* offset 0x650 */
+};
+
+#endif /* _TEGRA114_MC_H_ */
index 5d426b524a1e10776e73940e16c0be70596a6e2a..c3d061ec5867e389cd6b374d9e151428a8f3f5a8 100644 (file)
@@ -19,6 +19,7 @@
 
 #define NV_PA_SDRAM_BASE       0x80000000      /* 0x80000000 for real T114 */
 #define NV_PA_TSC_BASE         0x700F0000      /* System Counter TSC regs */
+#define NV_PA_MC_BASE          0x70019000
 
 #include <asm/arch-tegra/tegra.h>
 
diff --git a/arch/arm/include/asm/arch-tegra20/mc.h b/arch/arm/include/asm/arch-tegra20/mc.h
new file mode 100644 (file)
index 0000000..9c6e3ff
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ *  (C) Copyright 2014
+ *  NVIDIA Corporation <www.nvidia.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#ifndef _TEGRA20_MC_H_
+#define _TEGRA20_MC_H_
+
+/**
+ * Defines the memory controller registers we need/care about
+ */
+struct mc_ctlr {
+       u32 reserved0[3];                       /* offset 0x00 - 0x08 */
+       u32 mc_emem_cfg;                        /* offset 0x0C */
+       u32 mc_emem_adr_cfg;                    /* offset 0x10 */
+       u32 mc_emem_arb_cfg0;                   /* offset 0x14 */
+       u32 mc_emem_arb_cfg1;                   /* offset 0x18 */
+       u32 mc_emem_arb_cfg2;                   /* offset 0x1C */
+       u32 reserved1;                          /* offset 0x20 */
+       u32 mc_gart_cfg;                        /* offset 0x24 */
+       u32 mc_gart_entry_addr;                 /* offset 0x28 */
+       u32 mc_gart_entry_data;                 /* offset 0x2C */
+       u32 mc_gart_error_req;                  /* offset 0x30 */
+       u32 mc_gart_error_addr;                 /* offset 0x34 */
+       u32 reserved2;                          /* offset 0x38 */
+       u32 mc_timeout_ctrl;                    /* offset 0x3C */
+       u32 reserved3[6];                       /* offset 0x40 - 0x54 */
+       u32 mc_decerr_emem_others_status;       /* offset 0x58 */
+       u32 mc_decerr_emem_others_adr;          /* offset 0x5C */
+       u32 reserved4[40];                      /* offset 0x60 - 0xFC */
+       u32 reserved5[93];                      /* offset 0x100 - 0x270 */
+};
+
+#endif /* _TEGRA20_MC_H_ */
index 18856ac3727d085977a9b5b1b70f9963f33548f4..22774abb936df1f3c0687041f7482e0cfca96a18 100644 (file)
@@ -9,6 +9,7 @@
 #define _TEGRA20_H_
 
 #define NV_PA_SDRAM_BASE       0x00000000
+#define NV_PA_MC_BASE          0x7000F000
 
 #include <asm/arch-tegra/tegra.h>
 
diff --git a/arch/arm/include/asm/arch-tegra30/mc.h b/arch/arm/include/asm/arch-tegra30/mc.h
new file mode 100644 (file)
index 0000000..242a1fc
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ *  (C) Copyright 2014
+ *  NVIDIA Corporation <www.nvidia.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#ifndef _TEGRA30_MC_H_
+#define _TEGRA30_MC_H_
+
+/**
+ * Defines the memory controller registers we need/care about
+ */
+struct mc_ctlr {
+       u32 reserved0[4];                       /* offset 0x00 - 0x0C */
+       u32 mc_smmu_config;                     /* offset 0x10 */
+       u32 mc_smmu_tlb_config;                 /* offset 0x14 */
+       u32 mc_smmu_ptc_config;                 /* offset 0x18 */
+       u32 mc_smmu_ptb_asid;                   /* offset 0x1C */
+       u32 mc_smmu_ptb_data;                   /* offset 0x20 */
+       u32 reserved1[3];                       /* offset 0x24 - 0x2C */
+       u32 mc_smmu_tlb_flush;                  /* offset 0x30 */
+       u32 mc_smmu_ptc_flush;                  /* offset 0x34 */
+       u32 mc_smmu_asid_security;              /* offset 0x38 */
+       u32 reserved2[5];                       /* offset 0x3C - 0x4C */
+       u32 mc_emem_cfg;                        /* offset 0x50 */
+       u32 mc_emem_adr_cfg;                    /* offset 0x54 */
+       u32 mc_emem_adr_cfg_dev0;               /* offset 0x58 */
+       u32 mc_emem_adr_cfg_dev1;               /* offset 0x5C */
+       u32 reserved3[12];                      /* offset 0x60 - 0x8C */
+       u32 mc_emem_arb_reserved[28];           /* offset 0x90 - 0xFC */
+       u32 reserved4[338];                     /* offset 0x100 - 0x644 */
+       u32 mc_video_protect_bom;               /* offset 0x648 */
+       u32 mc_video_protect_size_mb;           /* offset 0x64c */
+       u32 mc_video_protect_reg_ctrl;          /* offset 0x650 */
+};
+
+#endif /* _TEGRA30_MC_H_ */
index c02c5d850037ffb7460b7df3b17f41cbf5c932ca..93671793a9f61d416824115d844ef3d939da17db 100644 (file)
@@ -17,6 +17,7 @@
 #ifndef _TEGRA30_H_
 #define _TEGRA30_H_
 
+#define NV_PA_MC_BASE          0x7000F000
 #define NV_PA_SDRAM_BASE       0x80000000      /* 0x80000000 for real T30 */
 
 #include <asm/arch-tegra/tegra.h>
diff --git a/arch/arm/include/asm/arch-uniphier/platdevice.h b/arch/arm/include/asm/arch-uniphier/platdevice.h
new file mode 100644 (file)
index 0000000..cdf7d13
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2014 Panasonic Corporation
+ *   Author: Masahiro Yamada <yamada.m@jp.panasonic.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#ifndef ARCH_PLATDEVICE_H
+#define ARCH_PLATDEVICE_H
+
+#include <dm/platdata.h>
+#include <dm/platform_data/serial-uniphier.h>
+
+#define SERIAL_DEVICE(n, ba, clk)                                      \
+static struct uniphier_serial_platform_data serial_device##n = {       \
+       .base = ba,                                                     \
+       .uartclk = clk                                                  \
+};                                                                     \
+U_BOOT_DEVICE(serial##n) = {                                           \
+       .name = DRIVER_NAME,                                            \
+       .platdata = &serial_device##n                                   \
+};
+
+#endif /* ARCH_PLATDEVICE_H */
index 560924e83ffdc56ee498a25e9b415c108fe1b3a3..d4a447b2b8a96568307bb907fd012b5da9f99187 100644 (file)
@@ -1107,6 +1107,7 @@ extern unsigned int __machine_arch_type;
 #define MACH_TYPE_ARMADILLO_800EVA     3863
 #define MACH_TYPE_KZM9G                4140
 #define MACH_TYPE_COLIBRI_T30          4493
+#define MACH_TYPE_APALIS_T30           4513
 
 #ifdef CONFIG_ARCH_EBSA110
 # ifdef machine_arch_type
@@ -14248,6 +14249,18 @@ extern unsigned int __machine_arch_type;
 # define machine_is_colibri_t30()      (0)
 #endif
 
+#ifdef CONFIG_MACH_APALIS_T30
+# ifdef machine_arch_type
+#  undef machine_arch_type
+#  define machine_arch_type    __machine_arch_type
+# else
+#  define machine_arch_type    MACH_TYPE_APALIS_T30
+# endif
+# define machine_is_apalis_t30()       (machine_arch_type == MACH_TYPE_APALIS_T30)
+#else
+# define machine_is_apalis_t30()       (0)
+#endif
+
 /*
  * These have not yet been registered
  */
index 5d25d04c3bf68f45560aa120faf4182cefca8930..839af54d482e9fbc9e03c5a777eb9317566681ea 100644 (file)
 
 #include <asm/arch/cpu.h>
 
+enum gpio_method {
+       METHOD_GPIO_24XX        = 4,
+};
+
+#ifdef CONFIG_DM_GPIO
+
+/* Information about a GPIO bank */
+struct omap_gpio_platdata {
+       int bank_index;
+       ulong base;     /* address of registers in physical memory */
+       enum gpio_method method;
+};
+
+#else
+
 struct gpio_bank {
        void *base;
        int method;
@@ -30,8 +45,6 @@ struct gpio_bank {
 
 extern const struct gpio_bank *const omap_gpio_bank;
 
-#define METHOD_GPIO_24XX       4
-
 /**
  * Check if gpio is valid.
  *
@@ -39,4 +52,6 @@ extern const struct gpio_bank *const omap_gpio_bank;
  * @return 1 if ok, 0 on error
  */
 int gpio_is_valid(int gpio);
+#endif
+
 #endif /* _GPIO_H_ */
index e5daf89127125c4d4379ed5b08775c7e4d0cc5ec..8acd7cd1bd5ab539ccef5201607fcfe64aab08a7 100644 (file)
@@ -7,7 +7,7 @@
 #ifndef        _ASM_SPL_H_
 #define        _ASM_SPL_H_
 
-#if defined(CONFIG_OMAP) || defined(CONFIG_SOCFPGA) \
+#if defined(CONFIG_OMAP) \
        || defined(CONFIG_EXYNOS4) || defined(CONFIG_EXYNOS5) \
        || defined(CONFIG_EXYNOS4210)
 /* Platform-specific defines */
index b16694c72f8d6b6f06b2a6efd47cc612c4430ba6..f97f3dd1496aa54f7ca0667d0ebea299c95d50e7 100644 (file)
@@ -45,4 +45,19 @@ void reset_timer_masked      (void);
 ulong  get_timer_masked        (void);
 void   udelay_masked           (unsigned long usec);
 
+/* calls to c from vectors.S */
+void bad_mode(void);
+void do_undefined_instruction(struct pt_regs *pt_regs);
+void do_software_interrupt(struct pt_regs *pt_regs);
+void do_prefetch_abort(struct pt_regs *pt_regs);
+void do_data_abort(struct pt_regs *pt_regs);
+void do_not_used(struct pt_regs *pt_regs);
+#ifdef CONFIG_ARM64
+void do_fiq(struct pt_regs *pt_regs, unsigned int esr);
+void do_irq(struct pt_regs *pt_regs, unsigned int esr);
+#else
+void do_fiq(struct pt_regs *pt_regs);
+void do_irq(struct pt_regs *pt_regswq);
+#endif
+
 #endif /* _U_BOOT_ARM_H_ */
index 76adaf3aa4abf69916155cadd9f1e9e1a5effdb7..f6062557e6677fe0636520f9d7f76a9eedfc8d50 100644 (file)
@@ -34,6 +34,7 @@
 #include <onenand_uboot.h>
 #include <mmc.h>
 #include <scsi.h>
+#include <status_led.h>
 #include <libfdt.h>
 #include <fdtdec.h>
 #include <post.h>
@@ -63,25 +64,15 @@ extern void dataflash_print_info(void);
  ************************************************************************
  * May be supplied by boards if desired
  */
-inline void __coloured_LED_init(void) {}
-void coloured_LED_init(void)
-       __attribute__((weak, alias("__coloured_LED_init")));
-inline void __red_led_on(void) {}
-void red_led_on(void) __attribute__((weak, alias("__red_led_on")));
-inline void __red_led_off(void) {}
-void red_led_off(void) __attribute__((weak, alias("__red_led_off")));
-inline void __green_led_on(void) {}
-void green_led_on(void) __attribute__((weak, alias("__green_led_on")));
-inline void __green_led_off(void) {}
-void green_led_off(void) __attribute__((weak, alias("__green_led_off")));
-inline void __yellow_led_on(void) {}
-void yellow_led_on(void) __attribute__((weak, alias("__yellow_led_on")));
-inline void __yellow_led_off(void) {}
-void yellow_led_off(void) __attribute__((weak, alias("__yellow_led_off")));
-inline void __blue_led_on(void) {}
-void blue_led_on(void) __attribute__((weak, alias("__blue_led_on")));
-inline void __blue_led_off(void) {}
-void blue_led_off(void) __attribute__((weak, alias("__blue_led_off")));
+__weak void coloured_LED_init(void) {}
+__weak void red_led_on(void) {}
+__weak void red_led_off(void) {}
+__weak void green_led_on(void) {}
+__weak void green_led_off(void) {}
+__weak void yellow_led_on(void) {}
+__weak void yellow_led_off(void) {}
+__weak void blue_led_on(void) {}
+__weak void blue_led_off(void) {}
 
 /*
  ************************************************************************
@@ -198,27 +189,21 @@ static int arm_pci_init(void)
  */
 typedef int (init_fnc_t) (void);
 
-void __dram_init_banksize(void)
+__weak void dram_init_banksize(void)
 {
        gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE;
        gd->bd->bi_dram[0].size =  gd->ram_size;
 }
-void dram_init_banksize(void)
-       __attribute__((weak, alias("__dram_init_banksize")));
 
-int __arch_cpu_init(void)
+__weak int arch_cpu_init(void)
 {
        return 0;
 }
-int arch_cpu_init(void)
-       __attribute__((weak, alias("__arch_cpu_init")));
 
-int __power_init_board(void)
+__weak int power_init_board(void)
 {
        return 0;
 }
-int power_init_board(void)
-       __attribute__((weak, alias("__power_init_board")));
 
        /* Record the board_init_f() bootstage (after arch_cpu_init()) */
 static int mark_bootstage(void)
index 39fe7a17fcff439f672331a90138454498755a45..0d19c8ae2366caee800920d36dce8d79f984b6c2 100644 (file)
@@ -15,6 +15,7 @@
 #include <common.h>
 #include <command.h>
 #include <image.h>
+#include <vxworks.h>
 #include <u-boot/zlib.h>
 #include <asm/byteorder.h>
 #include <libfdt.h>
index f6b7c03578b80e24a9a275bc7fe65f64ebe47666..9019736d2c74bec4da3fa4f97752954666a91ec1 100644 (file)
@@ -21,6 +21,7 @@
 
 #include <common.h>
 #include <asm/proc-armv/ptrace.h>
+#include <asm/u-boot-arm.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
diff --git a/arch/arm/mvebu-common/Makefile b/arch/arm/mvebu-common/Makefile
new file mode 100644 (file)
index 0000000..9dcab69
--- /dev/null
@@ -0,0 +1,12 @@
+#
+# (C) Copyright 2009
+# Marvell Semiconductor <www.marvell.com>
+# Written-by: Prafulla Wadaskar <prafulla@marvell.com>
+#
+# SPDX-License-Identifier:     GPL-2.0+
+#
+
+obj-y  = dram.o
+obj-y  += gpio.o
+obj-$(CONFIG_ARMADA_XP) += mbus.o
+obj-y  += timer.o
similarity index 57%
rename from arch/arm/cpu/arm926ejs/kirkwood/dram.c
rename to arch/arm/mvebu-common/dram.c
index d73ae47c34162a4ed3ea46b9e1f95e6c84082cfc..db18791a8627e77f9baba41199a9ba5fba3af37c 100644 (file)
 #include <common.h>
 #include <asm/io.h>
 #include <asm/arch/cpu.h>
-#include <asm/arch/kirkwood.h>
+#include <asm/arch/soc.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
-struct kw_sdram_bank {
+struct sdram_bank {
        u32     win_bar;
        u32     win_sz;
 };
 
-struct kw_sdram_addr_dec {
-       struct kw_sdram_bank    sdram_bank[4];
+struct sdram_addr_dec {
+       struct sdram_bank sdram_bank[4];
 };
 
-#define KW_REG_CPUCS_WIN_ENABLE                (1 << 0)
-#define KW_REG_CPUCS_WIN_WR_PROTECT    (1 << 1)
-#define KW_REG_CPUCS_WIN_WIN0_CS(x)    (((x) & 0x3) << 2)
-#define KW_REG_CPUCS_WIN_SIZE(x)       (((x) & 0xff) << 24)
+#define REG_CPUCS_WIN_ENABLE           (1 << 0)
+#define REG_CPUCS_WIN_WR_PROTECT       (1 << 1)
+#define REG_CPUCS_WIN_WIN0_CS(x)       (((x) & 0x3) << 2)
+#define REG_CPUCS_WIN_SIZE(x)          (((x) & 0xff) << 24)
 
 /*
- * kw_sdram_bar - reads SDRAM Base Address Register
+ * mvebu_sdram_bar - reads SDRAM Base Address Register
  */
-u32 kw_sdram_bar(enum memory_bank bank)
+u32 mvebu_sdram_bar(enum memory_bank bank)
 {
-       struct kw_sdram_addr_dec *base =
-               (struct kw_sdram_addr_dec *)KW_REGISTER(0x1500);
+       struct sdram_addr_dec *base =
+               (struct sdram_addr_dec *)MVEBU_SDRAM_BASE;
        u32 result = 0;
        u32 enable = 0x01 & readl(&base->sdram_bank[bank].win_sz);
 
@@ -46,31 +46,31 @@ u32 kw_sdram_bar(enum memory_bank bank)
 }
 
 /*
- * kw_sdram_bs_set - writes SDRAM Bank size
+ * mvebu_sdram_bs_set - writes SDRAM Bank size
  */
-static void kw_sdram_bs_set(enum memory_bank bank, u32 size)
+static void mvebu_sdram_bs_set(enum memory_bank bank, u32 size)
 {
-       struct kw_sdram_addr_dec *base =
-               (struct kw_sdram_addr_dec *)KW_REGISTER(0x1500);
+       struct sdram_addr_dec *base =
+               (struct sdram_addr_dec *)MVEBU_SDRAM_BASE;
        /* Read current register value */
        u32 reg = readl(&base->sdram_bank[bank].win_sz);
 
        /* Clear window size */
-       reg &= ~KW_REG_CPUCS_WIN_SIZE(0xFF);
+       reg &= ~REG_CPUCS_WIN_SIZE(0xFF);
 
        /* Set new window size */
-       reg |= KW_REG_CPUCS_WIN_SIZE((size - 1) >> 24);
+       reg |= REG_CPUCS_WIN_SIZE((size - 1) >> 24);
 
        writel(reg, &base->sdram_bank[bank].win_sz);
 }
 
 /*
- * kw_sdram_bs - reads SDRAM Bank size
+ * mvebu_sdram_bs - reads SDRAM Bank size
  */
-u32 kw_sdram_bs(enum memory_bank bank)
+u32 mvebu_sdram_bs(enum memory_bank bank)
 {
-       struct kw_sdram_addr_dec *base =
-               (struct kw_sdram_addr_dec *)KW_REGISTER(0x1500);
+       struct sdram_addr_dec *base =
+               (struct sdram_addr_dec *)MVEBU_SDRAM_BASE;
        u32 result = 0;
        u32 enable = 0x01 & readl(&base->sdram_bank[bank].win_sz);
 
@@ -81,15 +81,16 @@ u32 kw_sdram_bs(enum memory_bank bank)
        return result;
 }
 
-void kw_sdram_size_adjust(enum memory_bank bank)
+void mvebu_sdram_size_adjust(enum memory_bank bank)
 {
        u32 size;
 
        /* probe currently equipped RAM size */
-       size = get_ram_size((void *)kw_sdram_bar(bank), kw_sdram_bs(bank));
+       size = get_ram_size((void *)mvebu_sdram_bar(bank),
+                           mvebu_sdram_bs(bank));
 
        /* adjust SDRAM window size accordingly */
-       kw_sdram_bs_set(bank, size);
+       mvebu_sdram_bs_set(bank, size);
 }
 
 #ifndef CONFIG_SYS_BOARD_DRAM_INIT
@@ -99,8 +100,8 @@ int dram_init(void)
 
        gd->ram_size = 0;
        for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
-               gd->bd->bi_dram[i].start = kw_sdram_bar(i);
-               gd->bd->bi_dram[i].size = kw_sdram_bs(i);
+               gd->bd->bi_dram[i].start = mvebu_sdram_bar(i);
+               gd->bd->bi_dram[i].size = mvebu_sdram_bs(i);
                /*
                 * It is assumed that all memory banks are consecutive
                 * and without gaps.
@@ -110,7 +111,13 @@ int dram_init(void)
                if (gd->bd->bi_dram[i].start != gd->ram_size)
                        break;
 
-               gd->ram_size += gd->bd->bi_dram[i].size;
+               /*
+                * Don't report more than 3GiB of SDRAM, otherwise there is no
+                * address space left for the internal registers etc.
+                */
+               if ((gd->ram_size + gd->bd->bi_dram[i].size != 0) &&
+                   (gd->ram_size + gd->bd->bi_dram[i].size <= (3 << 30)))
+                       gd->ram_size += gd->bd->bi_dram[i].size;
 
        }
 
diff --git a/arch/arm/mvebu-common/gpio.c b/arch/arm/mvebu-common/gpio.c
new file mode 100644 (file)
index 0000000..56e54e0
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * (C) Copyright 2009
+ * Marvell Semiconductor <www.marvell.com>
+ * Written-by: Prafulla Wadaskar <prafulla@marvell.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <common.h>
+#include <asm/io.h>
+#include <asm/arch/cpu.h>
+#include <asm/arch/soc.h>
+
+/*
+ * mvebu_config_gpio - GPIO configuration
+ */
+void mvebu_config_gpio(u32 gpp0_oe_val, u32 gpp1_oe_val,
+                      u32 gpp0_oe, u32 gpp1_oe)
+{
+       struct kwgpio_registers *gpio0reg =
+               (struct kwgpio_registers *)MVEBU_GPIO0_BASE;
+       struct kwgpio_registers *gpio1reg =
+               (struct kwgpio_registers *)MVEBU_GPIO1_BASE;
+
+       /* Init GPIOS to default values as per board requirement */
+       writel(gpp0_oe_val, &gpio0reg->dout);
+       writel(gpp1_oe_val, &gpio1reg->dout);
+       writel(gpp0_oe, &gpio0reg->oe);
+       writel(gpp1_oe, &gpio1reg->oe);
+}
diff --git a/arch/arm/mvebu-common/mbus.c b/arch/arm/mvebu-common/mbus.c
new file mode 100644 (file)
index 0000000..05c9ef2
--- /dev/null
@@ -0,0 +1,471 @@
+/*
+ * Address map functions for Marvell EBU SoCs (Kirkwood, Armada
+ * 370/XP, Dove, Orion5x and MV78xx0)
+ *
+ * Ported from the Barebox version to U-Boot by:
+ * Stefan Roese <sr@denx.de>
+ *
+ * The Barebox version is:
+ * Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
+ *
+ * based on mbus driver from Linux
+ *   (C) Copyright 2008 Marvell Semiconductor
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ *
+ * The Marvell EBU SoCs have a configurable physical address space:
+ * the physical address at which certain devices (PCIe, NOR, NAND,
+ * etc.) sit can be configured. The configuration takes place through
+ * two sets of registers:
+ *
+ * - One to configure the access of the CPU to the devices. Depending
+ *   on the families, there are between 8 and 20 configurable windows,
+ *   each can be use to create a physical memory window that maps to a
+ *   specific device. Devices are identified by a tuple (target,
+ *   attribute).
+ *
+ * - One to configure the access to the CPU to the SDRAM. There are
+ *   either 2 (for Dove) or 4 (for other families) windows to map the
+ *   SDRAM into the physical address space.
+ *
+ * This driver:
+ *
+ * - Reads out the SDRAM address decoding windows at initialization
+ *   time, and fills the mbus_dram_info structure with these
+ *   informations. The exported function mv_mbus_dram_info() allow
+ *   device drivers to get those informations related to the SDRAM
+ *   address decoding windows. This is because devices also have their
+ *   own windows (configured through registers that are part of each
+ *   device register space), and therefore the drivers for Marvell
+ *   devices have to configure those device -> SDRAM windows to ensure
+ *   that DMA works properly.
+ *
+ * - Provides an API for platform code or device drivers to
+ *   dynamically add or remove address decoding windows for the CPU ->
+ *   device accesses. This API is mvebu_mbus_add_window_by_id(),
+ *   mvebu_mbus_add_window_remap_by_id() and
+ *   mvebu_mbus_del_window().
+ */
+
+#include <common.h>
+#include <asm/errno.h>
+#include <asm/io.h>
+#include <asm/arch/cpu.h>
+#include <asm/arch/soc.h>
+#include <linux/mbus.h>
+
+#define BIT(nr)                        (1UL << (nr))
+
+/* DDR target is the same on all platforms */
+#define TARGET_DDR             0
+
+/* CPU Address Decode Windows registers */
+#define WIN_CTRL_OFF           0x0000
+#define   WIN_CTRL_ENABLE       BIT(0)
+#define   WIN_CTRL_TGT_MASK     0xf0
+#define   WIN_CTRL_TGT_SHIFT    4
+#define   WIN_CTRL_ATTR_MASK    0xff00
+#define   WIN_CTRL_ATTR_SHIFT   8
+#define   WIN_CTRL_SIZE_MASK    0xffff0000
+#define   WIN_CTRL_SIZE_SHIFT   16
+#define WIN_BASE_OFF           0x0004
+#define   WIN_BASE_LOW          0xffff0000
+#define   WIN_BASE_HIGH         0xf
+#define WIN_REMAP_LO_OFF       0x0008
+#define   WIN_REMAP_LOW         0xffff0000
+#define WIN_REMAP_HI_OFF       0x000c
+
+#define ATTR_HW_COHERENCY      (0x1 << 4)
+
+#define DDR_BASE_CS_OFF(n)     (0x0000 + ((n) << 3))
+#define  DDR_BASE_CS_HIGH_MASK  0xf
+#define  DDR_BASE_CS_LOW_MASK   0xff000000
+#define DDR_SIZE_CS_OFF(n)     (0x0004 + ((n) << 3))
+#define  DDR_SIZE_ENABLED       BIT(0)
+#define  DDR_SIZE_CS_MASK       0x1c
+#define  DDR_SIZE_CS_SHIFT      2
+#define  DDR_SIZE_MASK          0xff000000
+
+#define DOVE_DDR_BASE_CS_OFF(n) ((n) << 4)
+
+struct mvebu_mbus_state;
+
+struct mvebu_mbus_soc_data {
+       unsigned int num_wins;
+       unsigned int num_remappable_wins;
+       unsigned int (*win_cfg_offset)(const int win);
+       void (*setup_cpu_target)(struct mvebu_mbus_state *s);
+};
+
+struct mvebu_mbus_state mbus_state
+       __attribute__ ((section(".data")));
+static struct mbus_dram_target_info mbus_dram_info
+       __attribute__ ((section(".data")));
+
+/*
+ * Functions to manipulate the address decoding windows
+ */
+
+static void mvebu_mbus_read_window(struct mvebu_mbus_state *mbus,
+                                  int win, int *enabled, u64 *base,
+                                  u32 *size, u8 *target, u8 *attr,
+                                  u64 *remap)
+{
+       void __iomem *addr = mbus->mbuswins_base +
+               mbus->soc->win_cfg_offset(win);
+       u32 basereg = readl(addr + WIN_BASE_OFF);
+       u32 ctrlreg = readl(addr + WIN_CTRL_OFF);
+
+       if (!(ctrlreg & WIN_CTRL_ENABLE)) {
+               *enabled = 0;
+               return;
+       }
+
+       *enabled = 1;
+       *base = ((u64)basereg & WIN_BASE_HIGH) << 32;
+       *base |= (basereg & WIN_BASE_LOW);
+       *size = (ctrlreg | ~WIN_CTRL_SIZE_MASK) + 1;
+
+       if (target)
+               *target = (ctrlreg & WIN_CTRL_TGT_MASK) >> WIN_CTRL_TGT_SHIFT;
+
+       if (attr)
+               *attr = (ctrlreg & WIN_CTRL_ATTR_MASK) >> WIN_CTRL_ATTR_SHIFT;
+
+       if (remap) {
+               if (win < mbus->soc->num_remappable_wins) {
+                       u32 remap_low = readl(addr + WIN_REMAP_LO_OFF);
+                       u32 remap_hi  = readl(addr + WIN_REMAP_HI_OFF);
+                       *remap = ((u64)remap_hi << 32) | remap_low;
+               } else {
+                       *remap = 0;
+               }
+       }
+}
+
+static void mvebu_mbus_disable_window(struct mvebu_mbus_state *mbus,
+                                     int win)
+{
+       void __iomem *addr;
+
+       addr = mbus->mbuswins_base + mbus->soc->win_cfg_offset(win);
+
+       writel(0, addr + WIN_BASE_OFF);
+       writel(0, addr + WIN_CTRL_OFF);
+       if (win < mbus->soc->num_remappable_wins) {
+               writel(0, addr + WIN_REMAP_LO_OFF);
+               writel(0, addr + WIN_REMAP_HI_OFF);
+       }
+}
+
+/* Checks whether the given window number is available */
+static int mvebu_mbus_window_is_free(struct mvebu_mbus_state *mbus,
+                                    const int win)
+{
+       void __iomem *addr = mbus->mbuswins_base +
+               mbus->soc->win_cfg_offset(win);
+       u32 ctrl = readl(addr + WIN_CTRL_OFF);
+       return !(ctrl & WIN_CTRL_ENABLE);
+}
+
+/*
+ * Checks whether the given (base, base+size) area doesn't overlap an
+ * existing region
+ */
+static int mvebu_mbus_window_conflicts(struct mvebu_mbus_state *mbus,
+                                      phys_addr_t base, size_t size,
+                                      u8 target, u8 attr)
+{
+       u64 end = (u64)base + size;
+       int win;
+
+       for (win = 0; win < mbus->soc->num_wins; win++) {
+               u64 wbase, wend;
+               u32 wsize;
+               u8 wtarget, wattr;
+               int enabled;
+
+               mvebu_mbus_read_window(mbus, win,
+                                      &enabled, &wbase, &wsize,
+                                      &wtarget, &wattr, NULL);
+
+               if (!enabled)
+                       continue;
+
+               wend = wbase + wsize;
+
+               /*
+                * Check if the current window overlaps with the
+                * proposed physical range
+                */
+               if ((u64)base < wend && end > wbase)
+                       return 0;
+
+               /*
+                * Check if target/attribute conflicts
+                */
+               if (target == wtarget && attr == wattr)
+                       return 0;
+       }
+
+       return 1;
+}
+
+static int mvebu_mbus_find_window(struct mvebu_mbus_state *mbus,
+                                 phys_addr_t base, size_t size)
+{
+       int win;
+
+       for (win = 0; win < mbus->soc->num_wins; win++) {
+               u64 wbase;
+               u32 wsize;
+               int enabled;
+
+               mvebu_mbus_read_window(mbus, win,
+                                      &enabled, &wbase, &wsize,
+                                      NULL, NULL, NULL);
+
+               if (!enabled)
+                       continue;
+
+               if (base == wbase && size == wsize)
+                       return win;
+       }
+
+       return -ENODEV;
+}
+
+static int mvebu_mbus_setup_window(struct mvebu_mbus_state *mbus,
+                                  int win, phys_addr_t base, size_t size,
+                                  phys_addr_t remap, u8 target,
+                                  u8 attr)
+{
+       void __iomem *addr = mbus->mbuswins_base +
+               mbus->soc->win_cfg_offset(win);
+       u32 ctrl, remap_addr;
+
+       ctrl = ((size - 1) & WIN_CTRL_SIZE_MASK) |
+               (attr << WIN_CTRL_ATTR_SHIFT)    |
+               (target << WIN_CTRL_TGT_SHIFT)   |
+               WIN_CTRL_ENABLE;
+
+       writel(base & WIN_BASE_LOW, addr + WIN_BASE_OFF);
+       writel(ctrl, addr + WIN_CTRL_OFF);
+       if (win < mbus->soc->num_remappable_wins) {
+               if (remap == MVEBU_MBUS_NO_REMAP)
+                       remap_addr = base;
+               else
+                       remap_addr = remap;
+               writel(remap_addr & WIN_REMAP_LOW, addr + WIN_REMAP_LO_OFF);
+               writel(0, addr + WIN_REMAP_HI_OFF);
+       }
+
+       return 0;
+}
+
+static int mvebu_mbus_alloc_window(struct mvebu_mbus_state *mbus,
+                                  phys_addr_t base, size_t size,
+                                  phys_addr_t remap, u8 target,
+                                  u8 attr)
+{
+       int win;
+
+       if (remap == MVEBU_MBUS_NO_REMAP) {
+               for (win = mbus->soc->num_remappable_wins;
+                    win < mbus->soc->num_wins; win++)
+                       if (mvebu_mbus_window_is_free(mbus, win))
+                               return mvebu_mbus_setup_window(mbus, win, base,
+                                                              size, remap,
+                                                              target, attr);
+       }
+
+
+       for (win = 0; win < mbus->soc->num_wins; win++)
+               if (mvebu_mbus_window_is_free(mbus, win))
+                       return mvebu_mbus_setup_window(mbus, win, base, size,
+                                                      remap, target, attr);
+
+       return -ENOMEM;
+}
+
+/*
+ * SoC-specific functions and definitions
+ */
+
+static unsigned int armada_370_xp_mbus_win_offset(int win)
+{
+       /* The register layout is a bit annoying and the below code
+        * tries to cope with it.
+        * - At offset 0x0, there are the registers for the first 8
+        *   windows, with 4 registers of 32 bits per window (ctrl,
+        *   base, remap low, remap high)
+        * - Then at offset 0x80, there is a hole of 0x10 bytes for
+        *   the internal registers base address and internal units
+        *   sync barrier register.
+        * - Then at offset 0x90, there the registers for 12
+        *   windows, with only 2 registers of 32 bits per window
+        *   (ctrl, base).
+        */
+       if (win < 8)
+               return win << 4;
+       else
+               return 0x90 + ((win - 8) << 3);
+}
+
+static unsigned int orion5x_mbus_win_offset(int win)
+{
+       return win << 4;
+}
+
+static void mvebu_mbus_default_setup_cpu_target(struct mvebu_mbus_state *mbus)
+{
+       int i;
+       int cs;
+
+       mbus_dram_info.mbus_dram_target_id = TARGET_DDR;
+
+       for (i = 0, cs = 0; i < 4; i++) {
+               u32 base = readl(mbus->sdramwins_base + DDR_BASE_CS_OFF(i));
+               u32 size = readl(mbus->sdramwins_base + DDR_SIZE_CS_OFF(i));
+
+               /*
+                * We only take care of entries for which the chip
+                * select is enabled, and that don't have high base
+                * address bits set (devices can only access the first
+                * 32 bits of the memory).
+                */
+               if ((size & DDR_SIZE_ENABLED) &&
+                   !(base & DDR_BASE_CS_HIGH_MASK)) {
+                       struct mbus_dram_window *w;
+
+                       w = &mbus_dram_info.cs[cs++];
+                       w->cs_index = i;
+                       w->mbus_attr = 0xf & ~(1 << i);
+#if defined(CONFIG_ARMADA_XP)
+                       w->mbus_attr |= ATTR_HW_COHERENCY;
+#endif
+                       w->base = base & DDR_BASE_CS_LOW_MASK;
+                       w->size = (size | ~DDR_SIZE_MASK) + 1;
+               }
+       }
+       mbus_dram_info.num_cs = cs;
+}
+
+static const struct mvebu_mbus_soc_data
+armada_370_xp_mbus_data __maybe_unused = {
+       .num_wins            = 20,
+       .num_remappable_wins = 8,
+       .win_cfg_offset      = armada_370_xp_mbus_win_offset,
+       .setup_cpu_target    = mvebu_mbus_default_setup_cpu_target,
+};
+
+static const struct mvebu_mbus_soc_data
+kirkwood_mbus_data __maybe_unused = {
+       .num_wins            = 8,
+       .num_remappable_wins = 4,
+       .win_cfg_offset      = orion5x_mbus_win_offset,
+       .setup_cpu_target    = mvebu_mbus_default_setup_cpu_target,
+};
+
+/*
+ * Public API of the driver
+ */
+const struct mbus_dram_target_info *mvebu_mbus_dram_info(void)
+{
+       return &mbus_dram_info;
+}
+
+int mvebu_mbus_add_window_remap_by_id(unsigned int target,
+                                     unsigned int attribute,
+                                     phys_addr_t base, size_t size,
+                                     phys_addr_t remap)
+{
+       struct mvebu_mbus_state *s = &mbus_state;
+
+       if (!mvebu_mbus_window_conflicts(s, base, size, target, attribute)) {
+               printf("Cannot add window '%x:%x', conflicts with another window\n",
+                      target, attribute);
+               return -EINVAL;
+       }
+
+       return mvebu_mbus_alloc_window(s, base, size, remap, target, attribute);
+}
+
+int mvebu_mbus_add_window_by_id(unsigned int target, unsigned int attribute,
+                               phys_addr_t base, size_t size)
+{
+       return mvebu_mbus_add_window_remap_by_id(target, attribute, base,
+                                                size, MVEBU_MBUS_NO_REMAP);
+}
+
+int mvebu_mbus_del_window(phys_addr_t base, size_t size)
+{
+       int win;
+
+       win = mvebu_mbus_find_window(&mbus_state, base, size);
+       if (win < 0)
+               return win;
+
+       mvebu_mbus_disable_window(&mbus_state, win);
+       return 0;
+}
+
+int mbus_dt_setup_win(struct mvebu_mbus_state *mbus,
+                     u32 base, u32 size, u8 target, u8 attr)
+{
+       if (!mvebu_mbus_window_conflicts(mbus, base, size, target, attr)) {
+               printf("Cannot add window '%04x:%04x', conflicts with another window\n",
+                      target, attr);
+               return -EBUSY;
+       }
+
+       /*
+        * In U-Boot we first try to add the mbus window to the remap windows.
+        * If this fails, lets try to add the windows to the non-remap windows.
+        */
+       if (mvebu_mbus_alloc_window(mbus, base, size, base, target, attr)) {
+               if (mvebu_mbus_alloc_window(mbus, base, size,
+                                           MVEBU_MBUS_NO_REMAP, target, attr))
+                       return -ENOMEM;
+       }
+
+       return 0;
+}
+
+int mvebu_mbus_probe(struct mbus_win windows[], int count)
+{
+       int win;
+       int ret;
+       int i;
+
+#if defined(CONFIG_KIRKWOOD)
+       mbus_state.soc = &kirkwood_mbus_data;
+#endif
+#if defined(CONFIG_ARMADA_XP)
+       mbus_state.soc = &armada_370_xp_mbus_data;
+#endif
+
+       mbus_state.mbuswins_base = (void __iomem *)MVEBU_CPU_WIN_BASE;
+       mbus_state.sdramwins_base = (void __iomem *)MVEBU_SDRAM_BASE;
+
+       for (win = 0; win < mbus_state.soc->num_wins; win++)
+               mvebu_mbus_disable_window(&mbus_state, win);
+
+       mbus_state.soc->setup_cpu_target(&mbus_state);
+
+       /* Setup statically declared windows in the DT */
+       for (i = 0; i < count; i++) {
+               u32 base, size;
+               u8 target, attr;
+
+               target = windows[i].target;
+               attr = windows[i].attr;
+               base = windows[i].base;
+               size = windows[i].size;
+               ret = mbus_dt_setup_win(&mbus_state, base, size, target, attr);
+               if (ret < 0)
+                       return ret;
+       }
+
+       return 0;
+}
similarity index 63%
rename from arch/arm/cpu/arm926ejs/kirkwood/timer.c
rename to arch/arm/mvebu-common/timer.c
index a08f4a1456cf714341dbc3752eb7f407456150bd..40c4bc2da1b233732f69821dec23ccd90495bba9 100644 (file)
@@ -7,75 +7,68 @@
 
 #include <common.h>
 #include <asm/io.h>
-#include <asm/arch/kirkwood.h>
+#include <asm/arch/soc.h>
 
-#define UBOOT_CNTR     0       /* counter to use for uboot timer */
-
-/* Timer reload and current value registers */
-struct kwtmr_val {
-       u32 reload;     /* Timer reload reg */
-       u32 val;        /* Timer value reg */
-};
-
-/* Timer registers */
-struct kwtmr_registers {
-       u32 ctrl;       /* Timer control reg */
-       u32 pad[3];
-       struct kwtmr_val tmr[2];
-       u32 wdt_reload;
-       u32 wdt_val;
-};
-
-struct kwtmr_registers *kwtmr_regs = (struct kwtmr_registers *)KW_TIMER_BASE;
+#define UBOOT_CNTR     0       /* counter to use for U-Boot timer */
 
 /*
  * ARM Timers Registers Map
  */
-#define CNTMR_CTRL_REG                 &kwtmr_regs->ctrl
-#define CNTMR_RELOAD_REG(tmrnum)       &kwtmr_regs->tmr[tmrnum].reload
-#define CNTMR_VAL_REG(tmrnum)          &kwtmr_regs->tmr[tmrnum].val
+#define CNTMR_CTRL_REG                 &tmr_regs->ctrl
+#define CNTMR_RELOAD_REG(tmrnum)       &tmr_regs->tmr[tmrnum].reload
+#define CNTMR_VAL_REG(tmrnum)          &tmr_regs->tmr[tmrnum].val
 
 /*
  * ARM Timers Control Register
  * CPU_TIMERS_CTRL_REG (CTCR)
  */
 #define CTCR_ARM_TIMER_EN_OFFS(cntr)   (cntr * 2)
-#define CTCR_ARM_TIMER_EN_MASK(cntr)   (1 << CTCR_ARM_TIMER_EN_OFFS)
 #define CTCR_ARM_TIMER_EN(cntr)                (1 << CTCR_ARM_TIMER_EN_OFFS(cntr))
-#define CTCR_ARM_TIMER_DIS(cntr)       (0 << CTCR_ARM_TIMER_EN_OFFS(cntr))
 
 #define CTCR_ARM_TIMER_AUTO_OFFS(cntr) ((cntr * 2) + 1)
-#define CTCR_ARM_TIMER_AUTO_MASK(cntr) (1 << 1)
 #define CTCR_ARM_TIMER_AUTO_EN(cntr)   (1 << CTCR_ARM_TIMER_AUTO_OFFS(cntr))
-#define CTCR_ARM_TIMER_AUTO_DIS(cntr)  (0 << CTCR_ARM_TIMER_AUTO_OFFS(cntr))
 
-/*
- * ARM Timer\Watchdog Reload Register
- * CNTMR_RELOAD_REG (TRR)
- */
-#define TRG_ARM_TIMER_REL_OFFS         0
-#define TRG_ARM_TIMER_REL_MASK         0xffffffff
+/* Only Armada XP have the 25MHz enable bit (Kirkwood doesn't) */
+#if defined(CONFIG_ARMADA_XP)
+#define CTCR_ARM_TIMER_25MHZ_OFFS(cntr)        (cntr + 11)
+#define CTCR_ARM_TIMER_25MHZ(cntr)     (1 << CTCR_ARM_TIMER_25MHZ_OFFS(cntr))
+#else
+#define CTCR_ARM_TIMER_25MHZ(cntr)     0
+#endif
 
-/*
- * ARM Timer\Watchdog Register
- * CNTMR_VAL_REG (TVRG)
- */
-#define TVR_ARM_TIMER_OFFS             0
-#define TVR_ARM_TIMER_MASK             0xffffffff
-#define TVR_ARM_TIMER_MAX              0xffffffff
 #define TIMER_LOAD_VAL                         0xffffffff
 
-#define READ_TIMER                     (readl(CNTMR_VAL_REG(UBOOT_CNTR)) /     \
-                                        (CONFIG_SYS_TCLK / 1000))
+#define timestamp                      gd->arch.tbl
+#define lastdec                                gd->arch.lastinc
+
+/* Timer reload and current value registers */
+struct kwtmr_val {
+       u32 reload;     /* Timer reload reg */
+       u32 val;        /* Timer value reg */
+};
+
+/* Timer registers */
+struct kwtmr_registers {
+       u32 ctrl;       /* Timer control reg */
+       u32 pad[3];
+       struct kwtmr_val tmr[4];
+       u32 wdt_reload;
+       u32 wdt_val;
+};
 
 DECLARE_GLOBAL_DATA_PTR;
 
-#define timestamp gd->arch.tbl
-#define lastdec gd->arch.lastinc
+static struct kwtmr_registers *tmr_regs =
+       (struct kwtmr_registers *)MVEBU_TIMER_BASE;
+
+static inline ulong read_timer(void)
+{
+       return readl(CNTMR_VAL_REG(UBOOT_CNTR)) / (CONFIG_SYS_TCLK / 1000);
+}
 
 ulong get_timer_masked(void)
 {
-       ulong now = READ_TIMER;
+       ulong now = read_timer();
 
        if (lastdec >= now) {
                /* normal mode */
@@ -119,20 +112,17 @@ void __udelay(unsigned long usec)
  */
 int timer_init(void)
 {
-       unsigned int cntmrctrl;
-
        /* load value into timer */
        writel(TIMER_LOAD_VAL, CNTMR_RELOAD_REG(UBOOT_CNTR));
        writel(TIMER_LOAD_VAL, CNTMR_VAL_REG(UBOOT_CNTR));
 
        /* enable timer in auto reload mode */
-       cntmrctrl = readl(CNTMR_CTRL_REG);
-       cntmrctrl |= CTCR_ARM_TIMER_EN(UBOOT_CNTR);
-       cntmrctrl |= CTCR_ARM_TIMER_AUTO_EN(UBOOT_CNTR);
-       writel(cntmrctrl, CNTMR_CTRL_REG);
+       clrsetbits_le32(CNTMR_CTRL_REG, CTCR_ARM_TIMER_25MHZ(UBOOT_CNTR),
+                       CTCR_ARM_TIMER_EN(UBOOT_CNTR) |
+                       CTCR_ARM_TIMER_AUTO_EN(UBOOT_CNTR));
 
        /* init the timestamp and lastdec value */
-       lastdec = READ_TIMER;
+       lastdec = read_timer();
        timestamp = 0;
 
        return 0;
index 7686b779bf7b20dd8bb2df58365314105d5f2b47..9b72bab56b64884543e1527a2186b388f7d460ca 100644 (file)
@@ -4,6 +4,9 @@ menu "MIPS architecture"
 config SYS_ARCH
        default "mips"
 
+config USE_PRIVATE_LIBGCC
+       default y
+
 choice
        prompt "Target select"
 
index ff9935acc4fcbe9522ce3b7bd282baf13880fa88..0dba8acbb2b320671541c939c739b98402f100b9 100644 (file)
@@ -4,6 +4,9 @@ menu "x86 architecture"
 config SYS_ARCH
        default "x86"
 
+config USE_PRIVATE_LIBGCC
+       default y
+
 choice
        prompt "Target select"
 
index 3106079c852c0ca54a4c3609805e3413909be2d4..3e7fedb913bed80965c0ca4e2765a35aaec98017 100644 (file)
@@ -28,6 +28,3 @@ PLATFORM_LDFLAGS += --emit-relocs -Bsymbolic -Bsymbolic-functions -m elf_i386
 LDFLAGS_FINAL += --gc-sections -pie
 LDFLAGS_FINAL += --wrap=__divdi3 --wrap=__udivdi3
 LDFLAGS_FINAL += --wrap=__moddi3 --wrap=__umoddi3
-
-export NORMAL_LIBGCC = $(shell $(CC) $(PLATFORM_CPPFLAGS) -print-libgcc-file-name)
-CONFIG_USE_PRIVATE_LIBGCC := arch/x86/lib
index 329bb3ab35bdce43bc83692c16b60fac04529a8a..338bab19e471fdd3f4ab088aa999afeb2e10145e 100644 (file)
@@ -85,12 +85,25 @@ car_init_ret:
        /* Align global data to 16-byte boundary */
        andl    $0xfffffff0, %esp
 
+       /* Zero the global data since it won't happen later */
+       xorl    %eax, %eax
+       movl    $GENERATED_GBL_DATA_SIZE, %ecx
+       movl    %esp, %edi
+       rep     stosb
+
        /* Setup first parameter to setup_gdt */
        movl    %esp, %eax
 
        /* Reserve space for global descriptor table */
        subl    $X86_GDT_SIZE, %esp
 
+#if defined(CONFIG_SYS_MALLOC_F_LEN)
+       subl    $CONFIG_SYS_MALLOC_F_LEN, %esp
+       movl    %eax, %edx
+       addl    $GD_MALLOC_BASE, %edx
+       movl    %esp, (%edx)
+#endif
+
        /* Align temporary global descriptor table to 16-byte boundary */
        andl    $0xfffffff0, %esp
 
index 4862a59704e0deec573debe84c2c64363c357e95..c8dc4cec3c99aac8edf1cbd9186ca900223bc241 100644 (file)
@@ -1,13 +1,14 @@
 /include/ "skeleton.dtsi"
 
 / {
-       aliases {
-               console = "/serial";
+       chosen {
+               stdout-path = "/serial";
        };
 
        serial {
-               compatible = "ns16550";
-               reg-shift = <1>;
+               compatible = "coreboot-uart";
+               reg = <0x3f8 0x10>;
+               reg-shift = <0>;
                io-mapped = <1>;
                multiplier = <1>;
                baudrate = <115200>;
index 4a37dac4ea9adc470005da949b281f0e18923ef6..f2fcb3927cbbb323f30c69468c8aaf687b390f06 100644 (file)
               silent_console = <0>;
        };
 
-       gpio: gpio {};
+       gpioa {
+               compatible = "intel,ich6-gpio";
+               reg = <0 0x10>;
+               bank-name = "A";
+       };
+
+       gpiob {
+               compatible = "intel,ich6-gpio";
+               reg = <0x30 0x10>;
+               bank-name = "B";
+       };
+
+       gpioc {
+               compatible = "intel,ich6-gpio";
+               reg = <0x40 0x10>;
+               bank-name = "C";
+       };
 
        serial {
                reg = <0x3f8 8>;
                        memory-map = <0xff800000 0x00800000>;
                };
        };
+
+       lpc {
+               compatible = "intel,lpc";
+               #address-cells = <1>;
+               #size-cells = <1>;
+               cros-ec@200 {
+                       compatible = "google,cros-ec";
+                       reg = <0x204 1 0x200 1 0x880 0x80>;
+
+                       /* This describes the flash memory within the EC */
+                       #address-cells = <1>;
+                       #size-cells = <1>;
+                       flash@8000000 {
+                               reg = <0x08000000 0x20000>;
+                               erase-value = <0xff>;
+                       };
+               };
+       };
 };
diff --git a/arch/x86/include/asm/arch-coreboot/gpio.h b/arch/x86/include/asm/arch-coreboot/gpio.h
new file mode 100644 (file)
index 0000000..3ec1816
--- /dev/null
@@ -0,0 +1,15 @@
+/*
+ * Copyright (c) 2014, Google Inc.
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#ifndef _X86_ARCH_GPIO_H_
+#define _X86_ARCH_GPIO_H_
+
+struct ich6_bank_platdata {
+       uint32_t base_addr;
+       const char *bank_name;
+};
+
+#endif /* _X86_ARCH_GPIO_H_ */
index fe09f31515455e12dc8ddcef786db2b76630ee81..8bda414dbd73bdef24c93a816b39a1eb8a6129e6 100644 (file)
@@ -6,6 +6,7 @@
 #ifndef _X86_GPIO_H_
 #define _X86_GPIO_H_
 
+#include <asm/arch/gpio.h>
 #include <asm-generic/gpio.h>
 
 #endif /* _X86_GPIO_H_ */
index 0f9665f5495160353e40f8a9d27af726f17ceb16..e6d183b4796bc8ac951d68d3a9f4a9fdfcccfec5 100644 (file)
 #define SYSCTLA         0x92
 #define SLAVE_PIC       0xa0
 
-#if 1
-#define UART0_BASE     0x3f8
-#define UART1_BASE     0x2f8
-#else
-/* FixMe: uarts swapped */
-#define UART0_BASE     0x2f8
-#define UART1_BASE     0x3f8
-#endif
-
-
 #endif
index f7303abccbd3380384b1fa5624cf305683ddfab8..25b672a0c13d831f0ddf1df0f4c17717dab8c863 100644 (file)
@@ -20,9 +20,9 @@ obj-$(CONFIG_SYS_X86_TSC_TIMER)       += tsc_timer.o
 obj-$(CONFIG_VIDEO_VGA)        += video.o
 obj-$(CONFIG_CMD_ZBOOT)        += zimage.o
 
-LIBGCC := $(notdir $(NORMAL_LIBGCC))
-extra-y := $(LIBGCC)
+extra-$(CONFIG_USE_PRIVATE_LIBGCC) := lib.a
 
+NORMAL_LIBGCC = $(shell $(CC) $(PLATFORM_CPPFLAGS) -print-libgcc-file-name)
 OBJCOPYFLAGS := --prefix-symbols=__normal_
-$(obj)/$(LIBGCC): $(NORMAL_LIBGCC) FORCE
+$(obj)/lib.a: $(NORMAL_LIBGCC) FORCE
        $(call if_changed,objcopy)
index 2f0e92f123a5acaa06a6c2f031cec72766d06099..b1902834e8a9514e5bdcce56b2bccbb03fdc7f7c 100644 (file)
@@ -282,7 +282,6 @@ void boot_zimage(void *setup_base, void *load_address)
        :: [kernel_entry]"a"(load_address),
           [boot_params] "S"(setup_base),
           "b"(0), "D"(0)
-       :  "%ebp"
        );
 }
 
index 4c3a9ba785a3219a55c6800072691c2630fd8f23..263bb5426c0d1a7086b9ed28ea7085e7ee0a96ed 100644 (file)
@@ -13,7 +13,7 @@
 #include <command.h>
 #include <i2c.h>
 #include <asm/arch/cpu.h>
-#include <asm/arch/kirkwood.h>
+#include <asm/arch/soc.h>
 #include <asm/arch/mpp.h>
 #include <asm/arch/gpio.h>
 
@@ -26,8 +26,8 @@ DECLARE_GLOBAL_DATA_PTR;
 int board_early_init_f(void)
 {
        /* GPIO configuration */
-       kw_config_gpio(NET2BIG_V2_OE_VAL_LOW, NET2BIG_V2_OE_VAL_HIGH,
-                       NET2BIG_V2_OE_LOW, NET2BIG_V2_OE_HIGH);
+       mvebu_config_gpio(NET2BIG_V2_OE_VAL_LOW, NET2BIG_V2_OE_VAL_HIGH,
+                         NET2BIG_V2_OE_LOW, NET2BIG_V2_OE_HIGH);
 
        /* Multi-Purpose Pins Functionality configuration */
        static const u32 kwmpp_config[] = {
@@ -77,7 +77,7 @@ int board_init(void)
        gd->bd->bi_arch_number = MACH_TYPE_NET2BIG_V2;
 
        /* Boot parameters address */
-       gd->bd->bi_boot_params = kw_sdram_bar(0) + 0x100;
+       gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
 
        return 0;
 }
index 3773587cc6d1ea9ffb553009b8ff2de0354568ec..17e629622ff733487303611f58730835e1317246 100644 (file)
@@ -12,7 +12,7 @@
 #include <common.h>
 #include <command.h>
 #include <asm/arch/cpu.h>
-#include <asm/arch/kirkwood.h>
+#include <asm/arch/soc.h>
 #include <asm/arch/mpp.h>
 #include <asm/arch/gpio.h>
 
@@ -24,8 +24,8 @@ DECLARE_GLOBAL_DATA_PTR;
 int board_early_init_f(void)
 {
        /* Gpio configuration */
-       kw_config_gpio(NETSPACE_V2_OE_VAL_LOW, NETSPACE_V2_OE_VAL_HIGH,
-                       NETSPACE_V2_OE_LOW, NETSPACE_V2_OE_HIGH);
+       mvebu_config_gpio(NETSPACE_V2_OE_VAL_LOW, NETSPACE_V2_OE_VAL_HIGH,
+                         NETSPACE_V2_OE_LOW, NETSPACE_V2_OE_HIGH);
 
        /* Multi-Purpose Pins Functionality configuration */
        static const u32 kwmpp_config[] = {
@@ -73,7 +73,7 @@ int board_init(void)
        gd->bd->bi_arch_number = CONFIG_MACH_TYPE;
 
        /* Boot parameters address */
-       gd->bd->bi_boot_params = kw_sdram_bar(0) + 0x100;
+       gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
 
        return 0;
 }
index 2dc50185604248475eed34d766bf40396973bd9d..8620e4b5d135fa1022043a4cf53f40b2491dde20 100644 (file)
@@ -12,7 +12,7 @@
 #include <common.h>
 #include <command.h>
 #include <asm/arch/cpu.h>
-#include <asm/arch/kirkwood.h>
+#include <asm/arch/soc.h>
 #include <asm/arch/mpp.h>
 #include <asm/arch/gpio.h>
 
@@ -97,8 +97,8 @@ struct mv88e61xx_config swcfg = {
 int board_early_init_f(void)
 {
        /* Gpio configuration */
-       kw_config_gpio(WIRELESS_SPACE_OE_VAL_LOW, WIRELESS_SPACE_OE_VAL_HIGH,
-                       WIRELESS_SPACE_OE_LOW, WIRELESS_SPACE_OE_HIGH);
+       mvebu_config_gpio(WIRELESS_SPACE_OE_VAL_LOW, WIRELESS_SPACE_OE_VAL_HIGH,
+                         WIRELESS_SPACE_OE_LOW, WIRELESS_SPACE_OE_HIGH);
 
        /* Multi-Purpose Pins Functionality configuration */
        kirkwood_mpp_conf(kwmpp_config, NULL);
@@ -112,7 +112,7 @@ int board_init(void)
        gd->bd->bi_arch_number = CONFIG_MACH_TYPE;
 
        /* Boot parameters address */
-       gd->bd->bi_boot_params = kw_sdram_bar(0) + 0x100;
+       gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
 
        return 0;
 }
diff --git a/board/Marvell/db-mv784mp-gp/Kconfig b/board/Marvell/db-mv784mp-gp/Kconfig
new file mode 100644 (file)
index 0000000..f94a444
--- /dev/null
@@ -0,0 +1,23 @@
+if TARGET_DB_MV784MP_GP
+
+config SYS_CPU
+       string
+       default "armv7"
+
+config SYS_BOARD
+       string
+       default "db-mv784mp-gp"
+
+config SYS_VENDOR
+       string
+       default "Marvell"
+
+config SYS_SOC
+       string
+       default "armada-xp"
+
+config SYS_CONFIG_NAME
+       string
+       default "db-mv784mp-gp"
+
+endif
diff --git a/board/Marvell/db-mv784mp-gp/MAINTAINERS b/board/Marvell/db-mv784mp-gp/MAINTAINERS
new file mode 100644 (file)
index 0000000..a095f89
--- /dev/null
@@ -0,0 +1,6 @@
+DB_MV784MP_GP BOARD
+M:     Stefan Roese <sr@denx.de>
+S:     Maintained
+F:     board/Marvell/db-mv784mp-gp/
+F:     include/configs/db-mv784mp-gp.h
+F:     configs/db-mv784mp-gp_defconfig
diff --git a/board/Marvell/db-mv784mp-gp/Makefile b/board/Marvell/db-mv784mp-gp/Makefile
new file mode 100644 (file)
index 0000000..8f5a7fb
--- /dev/null
@@ -0,0 +1,7 @@
+#
+# Copyright (C) 2014 Stefan Roese <sr@denx.de>
+#
+# SPDX-License-Identifier:     GPL-2.0+
+#
+
+obj-y  := db-mv784mp-gp.o
diff --git a/board/Marvell/db-mv784mp-gp/db-mv784mp-gp.c b/board/Marvell/db-mv784mp-gp/db-mv784mp-gp.c
new file mode 100644 (file)
index 0000000..b3dae89
--- /dev/null
@@ -0,0 +1,120 @@
+/*
+ * Copyright (C) 2014 Stefan Roese <sr@denx.de>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <common.h>
+#include <miiphy.h>
+#include <asm/io.h>
+#include <asm/arch/cpu.h>
+#include <asm/arch/soc.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+#define BIT(nr)                                (1UL << (nr))
+
+#define ETH_PHY_CTRL_REG               0
+#define ETH_PHY_CTRL_POWER_DOWN_BIT    11
+#define ETH_PHY_CTRL_POWER_DOWN_MASK   (1 << ETH_PHY_CTRL_POWER_DOWN_BIT)
+
+/*
+ * Those values and defines are taken from the Marvell U-Boot version
+ * "u-boot-2011.12-2014_T1.0" for the board rd78460gp aka
+ * "RD-AXP-GP rev 1.0".
+ *
+ * GPPs
+ * MPP#                NAME                    IN/OUT
+ * ----------------------------------------------
+ * 21          SW_Reset_               OUT
+ * 25          Phy_Int#                IN
+ * 28          SDI_WP                  IN
+ * 29          SDI_Status              IN
+ * 54-61       On GPP Connector        ?
+ * 62          Switch Interrupt        IN
+ * 63-65       Reserved from SW Board  ?
+ * 66          SW_BRD connected        IN
+ */
+#define RD_78460_GP_GPP_OUT_ENA_LOW    (~(BIT(21) | BIT(20)))
+#define RD_78460_GP_GPP_OUT_ENA_MID    (~(BIT(26) | BIT(27)))
+#define RD_78460_GP_GPP_OUT_ENA_HIGH   (~(0x0))
+
+#define RD_78460_GP_GPP_OUT_VAL_LOW    (BIT(21) | BIT(20))
+#define RD_78460_GP_GPP_OUT_VAL_MID    (BIT(26) | BIT(27))
+#define RD_78460_GP_GPP_OUT_VAL_HIGH   0x0
+
+int board_early_init_f(void)
+{
+       /* Configure MPP */
+       writel(0x00000000, MVEBU_MPP_BASE + 0x00);
+       writel(0x00000000, MVEBU_MPP_BASE + 0x04);
+       writel(0x33000000, MVEBU_MPP_BASE + 0x08);
+       writel(0x11000000, MVEBU_MPP_BASE + 0x0c);
+       writel(0x11111111, MVEBU_MPP_BASE + 0x10);
+       writel(0x00221100, MVEBU_MPP_BASE + 0x14);
+       writel(0x00000003, MVEBU_MPP_BASE + 0x18);
+       writel(0x00000000, MVEBU_MPP_BASE + 0x1c);
+       writel(0x00000000, MVEBU_MPP_BASE + 0x20);
+
+       /* Configure GPIO */
+       writel(RD_78460_GP_GPP_OUT_VAL_LOW, MVEBU_GPIO0_BASE + 0x00);
+       writel(RD_78460_GP_GPP_OUT_ENA_LOW, MVEBU_GPIO0_BASE + 0x04);
+       writel(RD_78460_GP_GPP_OUT_VAL_MID, MVEBU_GPIO1_BASE + 0x00);
+       writel(RD_78460_GP_GPP_OUT_ENA_MID, MVEBU_GPIO1_BASE + 0x04);
+       writel(RD_78460_GP_GPP_OUT_VAL_HIGH, MVEBU_GPIO2_BASE + 0x00);
+       writel(RD_78460_GP_GPP_OUT_ENA_HIGH, MVEBU_GPIO2_BASE + 0x04);
+
+       return 0;
+}
+
+int board_init(void)
+{
+       /* adress of boot parameters */
+       gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
+
+       return 0;
+}
+
+int checkboard(void)
+{
+       puts("Board: Marvell DB-MV784MP-GP\n");
+
+       return 0;
+}
+
+#ifdef CONFIG_RESET_PHY_R
+/* Configure and enable MV88E1545 PHY */
+void reset_phy(void)
+{
+       u16 devadr = CONFIG_PHY_BASE_ADDR;
+       char *name = "neta0";
+       u16 reg;
+
+       if (miiphy_set_current_dev(name))
+               return;
+
+       /* Enable QSGMII AN */
+       /* Set page to 4 */
+       miiphy_write(name, devadr, 0x16, 4);
+       /* Enable AN */
+       miiphy_write(name, devadr, 0x0, 0x1140);
+       /* Set page to 0 */
+       miiphy_write(name, devadr, 0x16, 0);
+
+       /* Phy C_ANEG */
+       miiphy_read(name, devadr, 0x4, &reg);
+       reg |= 0x1E0;
+       miiphy_write(name, devadr, 0x4, reg);
+
+       /* Soft-Reset */
+       miiphy_write(name, devadr, 22, 0x0000);
+       miiphy_write(name, devadr, 0, 0x9140);
+
+       /* Power up the phy */
+       miiphy_read(name, devadr, ETH_PHY_CTRL_REG, &reg);
+       reg &= ~(ETH_PHY_CTRL_POWER_DOWN_MASK);
+       miiphy_write(name, devadr, ETH_PHY_CTRL_REG, reg);
+
+       printf("88E1545 Initialized on %s\n", name);
+}
+#endif /* CONFIG_RESET_PHY_R */
diff --git a/board/Marvell/db-mv784mp-gp/kwbimage.cfg b/board/Marvell/db-mv784mp-gp/kwbimage.cfg
new file mode 100644 (file)
index 0000000..d7ef407
--- /dev/null
@@ -0,0 +1,12 @@
+#
+# Copyright (C) 2014 Stefan Roese <sr@denx.de>
+#
+
+# Armada XP uses version 1 image format
+VERSION                1
+
+# Boot Media configurations
+BOOT_FROM      spi
+
+# Binary Header (bin_hdr) with DDR3 training code
+BINARY board/Marvell/db-mv784mp-gp/binary.0 0000005b 00000068
index b53c81080d10985faeb02992fa62f9f35864d64f..0887d92c2995469cb115c0ef719846b7e2eb7e24 100644 (file)
@@ -12,7 +12,7 @@
 #include <common.h>
 #include <miiphy.h>
 #include <asm/arch/cpu.h>
-#include <asm/arch/kirkwood.h>
+#include <asm/arch/soc.h>
 #include <asm/arch/mpp.h>
 #include "dreamplug.h"
 
@@ -25,9 +25,9 @@ int board_early_init_f(void)
         * There are maximum 64 gpios controlled through 2 sets of registers
         * the  below configuration configures mainly initial LED status
         */
-       kw_config_gpio(DREAMPLUG_OE_VAL_LOW,
-                       DREAMPLUG_OE_VAL_HIGH,
-                       DREAMPLUG_OE_LOW, DREAMPLUG_OE_HIGH);
+       mvebu_config_gpio(DREAMPLUG_OE_VAL_LOW,
+                         DREAMPLUG_OE_VAL_HIGH,
+                         DREAMPLUG_OE_LOW, DREAMPLUG_OE_HIGH);
 
        /* Multi-Purpose Pins Functionality configuration */
        static const u32 kwmpp_config[] = {
@@ -90,7 +90,7 @@ int board_early_init_f(void)
 int board_init(void)
 {
        /* adress of boot parameters */
-       gd->bd->bi_boot_params = kw_sdram_bar(0) + 0x100;
+       gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
 
        return 0;
 }
index 72bccc821ce2cc2b7d9fe21e83382f0546a9663e..b0d5f1e10f4ddf46a4f21371a3f5edaaa22af10f 100644 (file)
@@ -9,7 +9,7 @@
 #include <common.h>
 #include <miiphy.h>
 #include <asm/arch/cpu.h>
-#include <asm/arch/kirkwood.h>
+#include <asm/arch/soc.h>
 #include <asm/arch/mpp.h>
 #include "guruplug.h"
 
@@ -22,9 +22,9 @@ int board_early_init_f(void)
         * There are maximum 64 gpios controlled through 2 sets of registers
         * the  below configuration configures mainly initial LED status
         */
-       kw_config_gpio(GURUPLUG_OE_VAL_LOW,
-                       GURUPLUG_OE_VAL_HIGH,
-                       GURUPLUG_OE_LOW, GURUPLUG_OE_HIGH);
+       mvebu_config_gpio(GURUPLUG_OE_VAL_LOW,
+                         GURUPLUG_OE_VAL_HIGH,
+                         GURUPLUG_OE_LOW, GURUPLUG_OE_HIGH);
 
        /* Multi-Purpose Pins Functionality configuration */
        static const u32 kwmpp_config[] = {
@@ -92,7 +92,7 @@ int board_init(void)
        gd->bd->bi_arch_number = MACH_TYPE_GURUPLUG;
 
        /* adress of boot parameters */
-       gd->bd->bi_boot_params = kw_sdram_bar(0) + 0x100;
+       gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
 
        return 0;
 }
index e1652c08317405ac922f087ec1e2f29b153d6da9..ef08ad8928d04dad71afbebfabd9f80f7943052d 100644 (file)
@@ -11,7 +11,7 @@
 #include <common.h>
 #include <netdev.h>
 #include <asm/arch/cpu.h>
-#include <asm/arch/kirkwood.h>
+#include <asm/arch/soc.h>
 #include <asm/arch/mpp.h>
 #include "mv88f6281gtw_ge.h"
 
@@ -24,9 +24,9 @@ int board_early_init_f(void)
         * There are maximum 64 gpios controlled through 2 sets of registers
         * the  below configuration configures mainly initial LED status
         */
-       kw_config_gpio(MV88F6281GTW_GE_OE_VAL_LOW,
-                       MV88F6281GTW_GE_OE_VAL_HIGH,
-                       MV88F6281GTW_GE_OE_LOW, MV88F6281GTW_GE_OE_HIGH);
+       mvebu_config_gpio(MV88F6281GTW_GE_OE_VAL_LOW,
+                         MV88F6281GTW_GE_OE_VAL_HIGH,
+                         MV88F6281GTW_GE_OE_LOW, MV88F6281GTW_GE_OE_HIGH);
 
        /* Multi-Purpose Pins Functionality configuration */
        static const u32 kwmpp_config[] = {
@@ -94,7 +94,7 @@ int board_init(void)
        gd->bd->bi_arch_number = MACH_TYPE_MV88F6281GTW_GE;
 
        /* adress of boot parameters */
-       gd->bd->bi_boot_params = kw_sdram_bar(0) + 0x100;
+       gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
 
        return 0;
 }
index a005a2f79dd07618e89267bc32906f9a946e6e11..55cf525cf8aa18e7aed9542c2761ddc30d41a959 100644 (file)
@@ -14,7 +14,7 @@
 #include <common.h>
 #include <miiphy.h>
 #include <asm/arch/cpu.h>
-#include <asm/arch/kirkwood.h>
+#include <asm/arch/soc.h>
 #include <asm/arch/mpp.h>
 #include "openrd.h"
 
@@ -27,9 +27,9 @@ int board_early_init_f(void)
         * There are maximum 64 gpios controlled through 2 sets of registers
         * the  below configuration configures mainly initial LED status
         */
-       kw_config_gpio(OPENRD_OE_VAL_LOW,
-                       OPENRD_OE_VAL_HIGH,
-                       OPENRD_OE_LOW, OPENRD_OE_HIGH);
+       mvebu_config_gpio(OPENRD_OE_VAL_LOW,
+                         OPENRD_OE_VAL_HIGH,
+                         OPENRD_OE_LOW, OPENRD_OE_HIGH);
 
        /* Multi-Purpose Pins Functionality configuration */
        static const u32 kwmpp_config[] = {
@@ -104,7 +104,7 @@ int board_init(void)
 #endif
 
        /* adress of boot parameters */
-       gd->bd->bi_boot_params = kw_sdram_bar(0) + 0x100;
+       gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
        return 0;
 }
 
index 33ef0c78e5bba9d18ecb15b57f1a1db567506c42..b0020c95a5bb067ebe2291eb4714981751603edf 100644 (file)
@@ -10,7 +10,7 @@
 #include <miiphy.h>
 #include <netdev.h>
 #include <asm/arch/cpu.h>
-#include <asm/arch/kirkwood.h>
+#include <asm/arch/soc.h>
 #include <asm/arch/mpp.h>
 #include "rd6281a.h"
 
@@ -23,9 +23,9 @@ int board_early_init_f(void)
         * There are maximum 64 gpios controlled through 2 sets of registers
         * the  below configuration configures mainly initial LED status
         */
-       kw_config_gpio(RD6281A_OE_VAL_LOW,
-                       RD6281A_OE_VAL_HIGH,
-                       RD6281A_OE_LOW, RD6281A_OE_HIGH);
+       mvebu_config_gpio(RD6281A_OE_VAL_LOW,
+                         RD6281A_OE_VAL_HIGH,
+                         RD6281A_OE_LOW, RD6281A_OE_HIGH);
 
        /* Multi-Purpose Pins Functionality configuration */
        static const u32 kwmpp_config[] = {
@@ -93,7 +93,7 @@ int board_init(void)
        gd->bd->bi_arch_number = MACH_TYPE_RD88F6281;
 
        /* adress of boot parameters */
-       gd->bd->bi_boot_params = kw_sdram_bar(0) + 0x100;
+       gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
 
        return 0;
 }
index 87e49f417bb7138199fd77d3252c46a200206236..8907fb58ff80f90f48c14545e7bbb04c93ae705f 100644 (file)
@@ -9,7 +9,7 @@
 #include <common.h>
 #include <miiphy.h>
 #include <asm/arch/cpu.h>
-#include <asm/arch/kirkwood.h>
+#include <asm/arch/soc.h>
 #include <asm/arch/mpp.h>
 #include "sheevaplug.h"
 
@@ -22,9 +22,9 @@ int board_early_init_f(void)
         * There are maximum 64 gpios controlled through 2 sets of registers
         * the  below configuration configures mainly initial LED status
         */
-       kw_config_gpio(SHEEVAPLUG_OE_VAL_LOW,
-                       SHEEVAPLUG_OE_VAL_HIGH,
-                       SHEEVAPLUG_OE_LOW, SHEEVAPLUG_OE_HIGH);
+       mvebu_config_gpio(SHEEVAPLUG_OE_VAL_LOW,
+                         SHEEVAPLUG_OE_VAL_HIGH,
+                         SHEEVAPLUG_OE_LOW, SHEEVAPLUG_OE_HIGH);
 
        /* Multi-Purpose Pins Functionality configuration */
        static const u32 kwmpp_config[] = {
@@ -92,7 +92,7 @@ int board_init(void)
        gd->bd->bi_arch_number = MACH_TYPE_SHEEVAPLUG;
 
        /* adress of boot parameters */
-       gd->bd->bi_boot_params = kw_sdram_bar(0) + 0x100;
+       gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
 
        return 0;
 }
index ff6a6a09ed7794f3d398f101cdb369a010da75d3..83ab1bc32d307dc16b3e5017dcb169d31b32b8d2 100644 (file)
@@ -11,7 +11,7 @@
 
 #include <common.h>
 #include <miiphy.h>
-#include <asm/arch/kirkwood.h>
+#include <asm/arch/soc.h>
 #include <asm/arch/mpp.h>
 #include <asm/arch/cpu.h>
 #include <asm/io.h>
@@ -26,9 +26,9 @@ int board_early_init_f(void)
         * There are maximum 64 gpios controlled through 2 sets of registers
         * the  below configuration configures mainly initial LED status
         */
-       kw_config_gpio(DOCKSTAR_OE_VAL_LOW,
-                       DOCKSTAR_OE_VAL_HIGH,
-                       DOCKSTAR_OE_LOW, DOCKSTAR_OE_HIGH);
+       mvebu_config_gpio(DOCKSTAR_OE_VAL_LOW,
+                         DOCKSTAR_OE_VAL_HIGH,
+                         DOCKSTAR_OE_LOW, DOCKSTAR_OE_HIGH);
 
        /* Multi-Purpose Pins Functionality configuration */
        static const u32 kwmpp_config[] = {
@@ -96,7 +96,7 @@ int board_init(void)
        gd->bd->bi_arch_number = MACH_TYPE_DOCKSTAR;
 
        /* address of boot parameters */
-       gd->bd->bi_boot_params = kw_sdram_bar(0) + 0x100;
+       gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
 
        return 0;
 }
@@ -143,7 +143,7 @@ void reset_phy(void)
 
 static void set_leds(u32 leds, u32 blinking)
 {
-       struct kwgpio_registers *r = (struct kwgpio_registers *)KW_GPIO1_BASE;
+       struct kwgpio_registers *r = (struct kwgpio_registers *)MVEBU_GPIO1_BASE;
        u32 oe = readl(&r->oe) | BOTH_LEDS;
        writel(oe & ~leds, &r->oe);     /* active low */
        u32 bl = readl(&r->blink_en) & ~BOTH_LEDS;
index a6598e9c81e607d29a2a568d7738ec07574f1f1d..1f4fb924942a4c65a9833fd660eb6847853b90a7 100644 (file)
@@ -14,7 +14,7 @@
 
 #include <common.h>
 #include <miiphy.h>
-#include <asm/arch/kirkwood.h>
+#include <asm/arch/soc.h>
 #include <asm/arch/mpp.h>
 #include <asm/arch/cpu.h>
 #include <asm/io.h>
@@ -83,9 +83,9 @@ int board_early_init_f(void)
         * There are maximum 64 gpios controlled through 2 sets of registers
         * the  below configuration configures mainly initial LED status
         */
-       kw_config_gpio(GOFLEXHOME_OE_VAL_LOW,
-                      GOFLEXHOME_OE_VAL_HIGH,
-                      GOFLEXHOME_OE_LOW, GOFLEXHOME_OE_HIGH);
+       mvebu_config_gpio(GOFLEXHOME_OE_VAL_LOW,
+                         GOFLEXHOME_OE_VAL_HIGH,
+                         GOFLEXHOME_OE_LOW, GOFLEXHOME_OE_HIGH);
        kirkwood_mpp_conf(kwmpp_config, NULL);
        return 0;
 }
@@ -98,7 +98,7 @@ int board_init(void)
        gd->bd->bi_arch_number = MACH_TYPE_GOFLEXHOME;
 
        /* address of boot parameters */
-       gd->bd->bi_boot_params = kw_sdram_bar(0) + 0x100;
+       gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
 
        return 0;
 }
@@ -149,7 +149,7 @@ static void set_leds(u32 leds, u32 blinking)
        u32 oe;
        u32 bl;
 
-       r = (struct kwgpio_registers *)KW_GPIO1_BASE;
+       r = (struct kwgpio_registers *)MVEBU_GPIO1_BASE;
        oe = readl(&r->oe) | BOTH_LEDS;
        writel(oe & ~leds, &r->oe);     /* active low */
        bl = readl(&r->blink_en) & ~BOTH_LEDS;
index 2298e3619c4ee0d4e2ff9b9aebc4ed7f785ecac5..6761b141fb82fd42a51f5e47896d1b9bfaed1b7d 100644 (file)
@@ -14,6 +14,7 @@
 #include <asm/arch/hardware.h>
 #include <asm/arch/at91_pmc.h>
 #include <asm/arch/at91_pio.h>
+#include <status_led.h>
 
 /* bit mask in PIO port B */
 #define        GREEN_LED       (1<<0)
index 56d811ca42566e8e3409c461c6dffd7ed3a568bb..fbe15afd281b34d59317d3c40d40f35299253df7 100644 (file)
@@ -9,6 +9,7 @@
 #include <common.h>
 #include <asm/io.h>
 #include <asm/arch/gpio.h>
+#include <status_led.h>
 
 void coloured_LED_init(void)
 {
index c1cb07b27829a270cfb40a7e64cbcd03de3b3c47..b0d49c4ee6b8ac266588d63c81b8ef3094097346 100644 (file)
@@ -15,7 +15,7 @@
 #include <miiphy.h>
 #include <spi.h>
 #include <spi_flash.h>
-#include <asm/arch/kirkwood.h>
+#include <asm/arch/soc.h>
 #include <asm/arch/cpu.h>
 #include <asm/arch/mpp.h>
 #include <asm/arch/gpio.h>
@@ -52,9 +52,9 @@ int board_early_init_f(void)
         * There are maximum 64 gpios controlled through 2 sets of registers
         * the below configuration configures mainly initial LED status
         */
-       kw_config_gpio(LSXL_OE_VAL_LOW,
-                       LSXL_OE_VAL_HIGH,
-                       LSXL_OE_LOW, LSXL_OE_HIGH);
+       mvebu_config_gpio(LSXL_OE_VAL_LOW,
+                         LSXL_OE_VAL_HIGH,
+                         LSXL_OE_LOW, LSXL_OE_HIGH);
 
        /*
         * Multi-Purpose Pins Functionality configuration
@@ -168,7 +168,7 @@ static void set_led(int state)
 int board_init(void)
 {
        /* address of boot parameters */
-       gd->bd->bi_boot_params = kw_sdram_bar(0) + 0x100;
+       gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
 
        set_led(LED_POWER_BLINKING);
 
index 4f2ac898ebcf3c52ebcb78aef0345612a5d94e0d..27ebe78eb139184cf3687832d13d467ece6ddb20 100644 (file)
@@ -12,4 +12,4 @@
 # SPDX-License-Identifier:     GPL-2.0+
 #
 
-obj-y  += coreboot_start.o
+obj-y  += coreboot_start.o coreboot.o
diff --git a/board/chromebook-x86/coreboot/coreboot.c b/board/chromebook-x86/coreboot/coreboot.c
new file mode 100644 (file)
index 0000000..0240c34
--- /dev/null
@@ -0,0 +1,16 @@
+/*
+ * Copyright (C) 2013 Google, Inc
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <common.h>
+#include <cros_ec.h>
+
+int arch_early_init_r(void)
+{
+       if (cros_ec_board_init())
+               return -1;
+
+       return 0;
+}
index 0e632582d3dcae7c5a0d36e13fc7cfa15fe5079b..8309d06882e39db567488107608745fd8d694ff7 100644 (file)
@@ -13,7 +13,7 @@
 #include <common.h>
 #include <miiphy.h>
 #include <asm/arch/cpu.h>
-#include <asm/arch/kirkwood.h>
+#include <asm/arch/soc.h>
 #include <asm/arch/mpp.h>
 #include "pogo_e02.h"
 
@@ -26,9 +26,9 @@ int board_early_init_f(void)
         * There are maximum 64 gpios controlled through 2 sets of registers
         * the  below configuration configures mainly initial LED status
         */
-       kw_config_gpio(POGO_E02_OE_VAL_LOW,
-                       POGO_E02_OE_VAL_HIGH,
-                       POGO_E02_OE_LOW, POGO_E02_OE_HIGH);
+       mvebu_config_gpio(POGO_E02_OE_VAL_LOW,
+                         POGO_E02_OE_VAL_HIGH,
+                         POGO_E02_OE_LOW, POGO_E02_OE_HIGH);
 
        /* Multi-Purpose Pins Functionality configuration */
        static const u32 kwmpp_config[] = {
@@ -64,7 +64,7 @@ int board_early_init_f(void)
 int board_init(void)
 {
        /* Boot parameters address */
-       gd->bd->bi_boot_params = kw_sdram_bar(0) + 0x100;
+       gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
 
        return 0;
 }
index f77ff48a1c3fb69f7bc04ec22f8cf95ac291122b..82681b10eb8cef4d92f80a751ad99a2360271a37 100644 (file)
@@ -15,7 +15,6 @@
 #include <netdev.h>
 #include <fdt_support.h>
 #include <sata.h>
-#include <serial_mxc.h>
 #include <asm/arch/crm_regs.h>
 #include <asm/arch/sys_proto.h>
 #include <asm/arch/iomux.h>
@@ -23,6 +22,7 @@
 #include <asm/imx-common/sata.h>
 #include <asm/io.h>
 #include <asm/gpio.h>
+#include <dm/platform_data/serial_mxc.h>
 #include "common.h"
 #include "../common/eeprom.h"
 
index ff70e9415f0900b466c34ec7d76239334f91b3d8..a022daf71e419bc87b707aeaf35ea7813d6e13fe 100644 (file)
@@ -14,7 +14,7 @@
 #include <miiphy.h>
 #include <netdev.h>
 #include <asm/arch/cpu.h>
-#include <asm/arch/kirkwood.h>
+#include <asm/arch/soc.h>
 #include <asm/arch/mpp.h>
 #include <asm/arch/gpio.h>
 #include "dns325.h"
@@ -24,8 +24,8 @@ DECLARE_GLOBAL_DATA_PTR;
 int board_early_init_f(void)
 {
        /* Gpio configuration */
-       kw_config_gpio(DNS325_OE_VAL_LOW, DNS325_OE_VAL_HIGH,
-                       DNS325_OE_LOW, DNS325_OE_HIGH);
+       mvebu_config_gpio(DNS325_OE_VAL_LOW, DNS325_OE_VAL_HIGH,
+                         DNS325_OE_LOW, DNS325_OE_HIGH);
 
        /* Multi-Purpose Pins Functionality configuration */
        static const u32 kwmpp_config[] = {
@@ -92,7 +92,7 @@ int board_early_init_f(void)
 int board_init(void)
 {
        /* Boot parameters address */
-       gd->bd->bi_boot_params = kw_sdram_bar(0) + 0x100;
+       gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
 
        return 0;
 }
index c3443bdc88334f027907010ee63b59da2c97ab48..086a473e8875c98865d9d3dc64d970e93467444b 100644 (file)
@@ -9,7 +9,7 @@
 #include <common.h>
 #include <miiphy.h>
 #include <asm/arch/cpu.h>
-#include <asm/arch/kirkwood.h>
+#include <asm/arch/soc.h>
 #include <asm/arch/mpp.h>
 #include "iconnect.h"
 
@@ -22,9 +22,9 @@ int board_early_init_f(void)
         * There are maximum 64 gpios controlled through 2 sets of registers
         * the below configuration configures mainly initial LED status
         */
-       kw_config_gpio(ICONNECT_OE_VAL_LOW,
-                       ICONNECT_OE_VAL_HIGH,
-                       ICONNECT_OE_LOW, ICONNECT_OE_HIGH);
+       mvebu_config_gpio(ICONNECT_OE_VAL_LOW,
+                         ICONNECT_OE_VAL_HIGH,
+                         ICONNECT_OE_LOW, ICONNECT_OE_HIGH);
 
        /* Multi-Purpose Pins Functionality configuration */
        static const u32 kwmpp_config[] = {
@@ -87,7 +87,7 @@ int board_early_init_f(void)
 int board_init(void)
 {
        /* adress of boot parameters */
-       gd->bd->bi_boot_params = kw_sdram_bar(0) + 0x100;
+       gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
 
        return 0;
 }
index 3b2b1f15b8e9647fe0fc72efee1e8f78fa11b588..7b87cc27c41b4e517753342202f240e7ff5668b4 100644 (file)
@@ -5,6 +5,8 @@
  * SPDX-License-Identifier:    GPL-2.0+
  */
 #include <common.h>
+#include <dm.h>
+#include <ns16550.h>
 #include <twl4030.h>
 #include <netdev.h>
 #include <asm/gpio.h>
@@ -30,6 +32,17 @@ static const u32 gpmc_lan_config[] = {
 };
 #endif
 
+static const struct ns16550_platdata igep_serial = {
+       OMAP34XX_UART3,
+       2,
+       V_NS16550_CLK
+};
+
+U_BOOT_DEVICE(igep_uart) = {
+       "serial_omap",
+       &igep_serial
+};
+
 /*
  * Routine: board_init
  * Description: Early hardware init.
index ed0575cb05a26a6c4a77c6635bdc88ba04f91f9d..35546d24e87560454d3a4a047b76899cd1318413 100644 (file)
@@ -8,7 +8,7 @@
 #include <common.h>
 #include <miiphy.h>
 #include <asm/arch/cpu.h>
-#include <asm/arch/kirkwood.h>
+#include <asm/arch/soc.h>
 #include <asm/arch/mpp.h>
 #include <asm/io.h>
 
@@ -26,9 +26,9 @@ int board_early_init_f(void)
         * There are maximum 64 gpios controlled through 2 sets of registers
         * the  below configuration configures mainly initial LED status
         */
-       kw_config_gpio(TK71_OE_VAL_LOW,
-                       TK71_OE_VAL_HIGH,
-                       TK71_OE_LOW, TK71_OE_HIGH);
+       mvebu_config_gpio(TK71_OE_VAL_LOW,
+                         TK71_OE_VAL_HIGH,
+                         TK71_OE_LOW, TK71_OE_HIGH);
 
        /* Multi-Purpose Pins Functionality configuration */
        static const u32 kwmpp_config[] = {
@@ -97,7 +97,7 @@ int board_init(void)
        gd->bd->bi_arch_number = CONFIG_MACH_TYPE;
 
        /* adress of boot parameters */
-       gd->bd->bi_boot_params = kw_sdram_bar(0) + 0x100;
+       gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
 
        return 0;
 }
index 35402c800bd31df15c7162e03a7c327c50878bb7..1c7c108cb5acd7536e0081a7d2a7f40a7eb23a74 100644 (file)
@@ -20,7 +20,7 @@
 #include <spi.h>
 #include <asm/io.h>
 #include <asm/arch/cpu.h>
-#include <asm/arch/kirkwood.h>
+#include <asm/arch/soc.h>
 #include <asm/arch/mpp.h>
 
 #include "../common/common.h"
@@ -222,11 +222,11 @@ int board_early_init_f(void)
        u32 tmp;
 
        /* set the 2 bitbang i2c pins as output gpios */
-       tmp = readl(KW_GPIO0_BASE + 4);
-       writel(tmp & (~KM_KIRKWOOD_SOFT_I2C_GPIOS) , KW_GPIO0_BASE + 4);
+       tmp = readl(MVEBU_GPIO0_BASE + 4);
+       writel(tmp & (~KM_KIRKWOOD_SOFT_I2C_GPIOS) , MVEBU_GPIO0_BASE + 4);
 #endif
        /* adjust SDRAM size for bank 0 */
-       kw_sdram_size_adjust(0);
+       mvebu_sdram_size_adjust(0);
        kirkwood_mpp_conf(kwmpp_config, NULL);
        return 0;
 }
@@ -234,7 +234,7 @@ int board_early_init_f(void)
 int board_init(void)
 {
        /* address of boot parameters */
-       gd->bd->bi_boot_params = kw_sdram_bar(0) + 0x100;
+       gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
 
        /*
         * The KM_FLASH_GPIO_PIN switches between using a
index 461a852724eb6d7a76dd79d785599a26300a8fcb..9ef002637a665f7e405e5873bddee8f640da49af 100644 (file)
@@ -15,6 +15,8 @@
  * SPDX-License-Identifier:    GPL-2.0+
  */
 #include <common.h>
+#include <dm.h>
+#include <ns16550.h>
 #include <netdev.h>
 #include <twl4030.h>
 #include <asm/io.h>
@@ -41,6 +43,17 @@ static const u32 gpmc_lab_enet[] = {
        /*CONF7- computed as params */
 };
 
+static const struct ns16550_platdata zoom1_serial = {
+       OMAP34XX_UART3,
+       2,
+       V_NS16550_CLK
+};
+
+U_BOOT_DEVICE(zoom1_uart) = {
+       "serial_omap",
+       &zoom1_serial
+};
+
 /*
  * Routine: board_init
  * Description: Early hardware init.
diff --git a/board/maxbcm/Kconfig b/board/maxbcm/Kconfig
new file mode 100644 (file)
index 0000000..d34e2ab
--- /dev/null
@@ -0,0 +1,19 @@
+if TARGET_MAXBCM
+
+config SYS_CPU
+       string
+       default "armv7"
+
+config SYS_BOARD
+       string
+       default "maxbcm"
+
+config SYS_SOC
+       string
+       default "armada-xp"
+
+config SYS_CONFIG_NAME
+       string
+       default "maxbcm"
+
+endif
diff --git a/board/maxbcm/MAINTAINERS b/board/maxbcm/MAINTAINERS
new file mode 100644 (file)
index 0000000..3c8af21
--- /dev/null
@@ -0,0 +1,6 @@
+MAXBCM BOARD
+M:     Stefan Roese <sr@denx.de>
+S:     Maintained
+F:     board/maxbcm/
+F:     include/configs/maxbcm.h
+F:     configs/maxbcm_defconfig
diff --git a/board/maxbcm/Makefile b/board/maxbcm/Makefile
new file mode 100644 (file)
index 0000000..37c17d6
--- /dev/null
@@ -0,0 +1,7 @@
+#
+# Copyright (C) 2014 Stefan Roese <sr@denx.de>
+#
+# SPDX-License-Identifier:     GPL-2.0+
+#
+
+obj-y  := maxbcm.o
diff --git a/board/maxbcm/kwbimage.cfg b/board/maxbcm/kwbimage.cfg
new file mode 100644 (file)
index 0000000..5a3bc67
--- /dev/null
@@ -0,0 +1,12 @@
+#
+# Copyright (C) 2014 Stefan Roese <sr@denx.de>
+#
+
+# Armada XP uses version 1 image format
+VERSION                1
+
+# Boot Media configurations
+BOOT_FROM      spi
+
+# Binary Header (bin_hdr) with DDR3 training code
+BINARY board/maxbcm/binary.0 0000005b 00000068
diff --git a/board/maxbcm/maxbcm.c b/board/maxbcm/maxbcm.c
new file mode 100644 (file)
index 0000000..7fc83ee
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2014 Stefan Roese <sr@denx.de>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <common.h>
+#include <miiphy.h>
+#include <asm/io.h>
+#include <asm/arch/cpu.h>
+#include <asm/arch/soc.h>
+#include <linux/mbus.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+/* Base addresses for the external device chip selects */
+#define DEV_CS0_BASE           0xe0000000
+#define DEV_CS1_BASE           0xe1000000
+#define DEV_CS2_BASE           0xe2000000
+#define DEV_CS3_BASE           0xe3000000
+
+/* Needed for dynamic (board-specific) mbus configuration */
+extern struct mvebu_mbus_state mbus_state;
+
+int board_early_init_f(void)
+{
+       /*
+        * Don't configure MPP (pin multiplexing) and GPIO here,
+        * its already done in bin_hdr
+        */
+
+       /*
+        * Setup some board specific mbus address windows
+        */
+       mbus_dt_setup_win(&mbus_state, DEV_CS0_BASE, 16 << 20,
+                         CPU_TARGET_DEVICEBUS_BOOTROM_SPI, CPU_ATTR_DEV_CS0);
+       mbus_dt_setup_win(&mbus_state, DEV_CS1_BASE, 16 << 20,
+                         CPU_TARGET_DEVICEBUS_BOOTROM_SPI, CPU_ATTR_DEV_CS1);
+       mbus_dt_setup_win(&mbus_state, DEV_CS2_BASE, 16 << 20,
+                         CPU_TARGET_DEVICEBUS_BOOTROM_SPI, CPU_ATTR_DEV_CS2);
+       mbus_dt_setup_win(&mbus_state, DEV_CS3_BASE, 16 << 20,
+                         CPU_TARGET_DEVICEBUS_BOOTROM_SPI, CPU_ATTR_DEV_CS3);
+
+       return 0;
+}
+
+int board_init(void)
+{
+       /* adress of boot parameters */
+       gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
+
+       return 0;
+}
+
+int checkboard(void)
+{
+       puts("Board: maxBCM\n");
+
+       return 0;
+}
+
+#ifdef CONFIG_RESET_PHY_R
+/* 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;
+
+       /* todo: fill this with the real setup / config code */
+
+       printf("88E6185 Initialized on %s\n", name);
+}
+#endif /* CONFIG_RESET_PHY_R */
index 03f055dad2aa4d2ff72b26f36b5a23e01849d6a6..51125df34f018b79a511b44dc49e73a817944a43 100644 (file)
@@ -47,46 +47,19 @@ const struct tegra_sysinfo sysinfo = {
        CONFIG_TEGRA_BOARD_STRING
 };
 
-void __pinmux_init(void)
-{
-}
-
-void pinmux_init(void) __attribute__((weak, alias("__pinmux_init")));
-
-void __pin_mux_usb(void)
-{
-}
-
-void pin_mux_usb(void) __attribute__((weak, alias("__pin_mux_usb")));
-
-void __pin_mux_spi(void)
-{
-}
-
-void pin_mux_spi(void) __attribute__((weak, alias("__pin_mux_spi")));
-
-void __gpio_early_init_uart(void)
-{
-}
-
-void gpio_early_init_uart(void)
-__attribute__((weak, alias("__gpio_early_init_uart")));
+__weak void pinmux_init(void) {}
+__weak void pin_mux_usb(void) {}
+__weak void pin_mux_spi(void) {}
+__weak void gpio_early_init_uart(void) {}
+__weak void pin_mux_display(void) {}
 
 #if defined(CONFIG_TEGRA_NAND)
-void __pin_mux_nand(void)
+__weak void pin_mux_nand(void)
 {
        funcmux_select(PERIPH_ID_NDFLASH, FUNCMUX_DEFAULT);
 }
-
-void pin_mux_nand(void) __attribute__((weak, alias("__pin_mux_nand")));
 #endif
 
-void __pin_mux_display(void)
-{
-}
-
-void pin_mux_display(void) __attribute__((weak, alias("__pin_mux_display")));
-
 /*
  * Routine: power_det_init
  * Description: turn off power detects
@@ -204,12 +177,10 @@ int board_late_init(void)
 }
 
 #if defined(CONFIG_TEGRA_MMC)
-void __pin_mux_mmc(void)
+__weak void pin_mux_mmc(void)
 {
 }
 
-void pin_mux_mmc(void) __attribute__((weak, alias("__pin_mux_mmc")));
-
 /* this is a weak define that we are overriding */
 int board_mmc_init(bd_t *bd)
 {
index 8124f8aafde0671e48d0abe770cedcd6bf868c25..8c62f36a7b04a00b8d05f68405567f9d3e1fd687 100644 (file)
@@ -5,6 +5,7 @@
  */
 
 #include <common.h>
+#include "emc.h"
 #include <asm/io.h>
 #include <asm/arch/clock.h>
 #include <asm/arch/emc.h>
index d338818a64eb898697db9ac014fb392fea858674..de4eb355982cb2b1821849407f635caf65d3759b 100644 (file)
@@ -283,6 +283,11 @@ static const struct pmux_pingrp_config jetson_tk1_pingrps[] = {
        PINCFG(PCC2,                   DEFAULT,      DOWN,   NORMAL,   INPUT,   DEFAULT, DEFAULT),
        PINCFG(SDMMC4_CLK_PCC4,        SDMMC4,       NORMAL, NORMAL,   INPUT,   DEFAULT, DEFAULT),
        PINCFG(CLK2_REQ_PCC5,          DEFAULT,      NORMAL, NORMAL,   OUTPUT,  DEFAULT, DEFAULT),
+       PINCFG(PEX_L0_RST_N_PDD1,      PE0,          NORMAL, NORMAL,   OUTPUT,  DEFAULT, DEFAULT),
+       PINCFG(PEX_L0_CLKREQ_N_PDD2,   PE0,          UP,     NORMAL,   INPUT,   DEFAULT, DEFAULT),
+       PINCFG(PEX_WAKE_N_PDD3,        PE,           UP,     NORMAL,   INPUT,   DEFAULT, DEFAULT),
+       PINCFG(PEX_L1_RST_N_PDD5,      PE1,          NORMAL, NORMAL,   OUTPUT,  DEFAULT, DEFAULT),
+       PINCFG(PEX_L1_CLKREQ_N_PDD6,   PE1,          UP,     NORMAL,   INPUT,   DEFAULT, DEFAULT),
        PINCFG(CLK3_OUT_PEE0,          EXTPERIPH3,   NORMAL, NORMAL,   OUTPUT,  DEFAULT, DEFAULT),
        PINCFG(CLK3_REQ_PEE1,          DEFAULT,      NORMAL, NORMAL,   OUTPUT,  DEFAULT, DEFAULT),
        PINCFG(DAP_MCLK1_REQ_PEE2,     SATA,         NORMAL, NORMAL,   OUTPUT,  DEFAULT, DEFAULT),
index 6a243f0aea98cb42b5fd969b16ecd9a361f2aa54..11472ebaf20d1eb385457cf8745322460e7b94bc 100644 (file)
@@ -8,6 +8,7 @@
 #include <common.h>
 #include <asm/io.h>
 #include <asm/arch/tegra.h>
+#include <asm/arch-tegra/board.h>
 #include <asm/arch/clock.h>
 #include <asm/arch/funcmux.h>
 #include <asm/arch/gpio.h>
index 66146eead5f751650366e14f900a015a6c75c282..dfb8602bafccb8d8c912c58c7d946c06effee2c0 100644 (file)
@@ -13,6 +13,8 @@
  * SPDX-License-Identifier:    GPL-2.0+
  */
 #include <common.h>
+#include <dm.h>
+#include <ns16550.h>
 #include <netdev.h>
 #include <twl4030.h>
 #include <linux/mtd/nand.h>
@@ -65,6 +67,17 @@ static struct {
        char env_setting[64];
 } expansion_config = {0x0};
 
+static const struct ns16550_platdata overo_serial = {
+       OMAP34XX_UART3,
+       2,
+       V_NS16550_CLK
+};
+
+U_BOOT_DEVICE(overo_uart) = {
+       "serial_omap",
+       &overo_serial
+};
+
 /*
  * Routine: board_init
  * Description: Early hardware init.
index 976ba4ce94226c8f464944ca6c456a29d6c52269..f01fb1c6e7624bbe66d9714fc3fbfe0d98db0619 100644 (file)
@@ -11,7 +11,7 @@
 #include <miiphy.h>
 #include <asm/io.h>
 #include <asm/arch/cpu.h>
-#include <asm/arch/kirkwood.h>
+#include <asm/arch/soc.h>
 #include <asm/arch/mpp.h>
 #include "ib62x0.h"
 
@@ -24,9 +24,9 @@ int board_early_init_f(void)
         * There are maximum 64 gpios controlled through 2 sets of registers
         * the below configuration configures mainly initial LED status
         */
-       kw_config_gpio(IB62x0_OE_VAL_LOW,
-                       IB62x0_OE_VAL_HIGH,
-                       IB62x0_OE_LOW, IB62x0_OE_HIGH);
+       mvebu_config_gpio(IB62x0_OE_VAL_LOW,
+                         IB62x0_OE_VAL_HIGH,
+                         IB62x0_OE_LOW, IB62x0_OE_HIGH);
 
        /* Set SATA activity LEDs to default off */
        writel(MVSATAHC_LED_POLARITY_CTRL, MVSATAHC_LED_CONF_REG);
@@ -62,7 +62,7 @@ int board_early_init_f(void)
 int board_init(void)
 {
        /* adress of boot parameters */
-       gd->bd->bi_boot_params = kw_sdram_bar(0) + 0x100;
+       gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
 
        return 0;
 }
index 447c940f63154aa560881046a1d742b6bc1e7d5e..7445f5318ad2ed44525ea8bf8a11cc5ae95cbc42 100644 (file)
@@ -42,6 +42,12 @@ struct msg_get_arm_mem {
        u32 end_tag;
 };
 
+struct msg_get_mac_address {
+       struct bcm2835_mbox_hdr hdr;
+       struct bcm2835_mbox_tag_get_mac_address get_mac_address;
+       u32 end_tag;
+};
+
 struct msg_set_power_state {
        struct bcm2835_mbox_hdr hdr;
        struct bcm2835_mbox_tag_set_power_state set_power_state;
@@ -73,6 +79,29 @@ int dram_init(void)
        return 0;
 }
 
+int misc_init_r(void)
+{
+       ALLOC_ALIGN_BUFFER(struct msg_get_mac_address, msg, 1, 16);
+       int ret;
+
+       if (getenv("usbethaddr"))
+               return 0;
+
+       BCM2835_MBOX_INIT_HDR(msg);
+       BCM2835_MBOX_INIT_TAG(&msg->get_mac_address, GET_MAC_ADDRESS);
+
+       ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN, &msg->hdr);
+       if (ret) {
+               printf("bcm2835: Could not query MAC address\n");
+               /* Ignore error; not critical */
+               return 0;
+       }
+
+       eth_setenv_enetaddr("usbethaddr", msg->get_mac_address.body.resp.mac);
+
+       return 0;
+}
+
 static int power_on_module(u32 module)
 {
        ALLOC_ALIGN_BUFFER(struct msg_set_power_state, msg_pwr, 1, 16);
index e1fc123fcc4ea154cd4e189460a8afb3e1713399..8b4c8e9a9db90f882a1349e1b5c6e1258fc77ce3 100644 (file)
 
 DECLARE_GLOBAL_DATA_PTR;
 
-int __exynos_early_init_f(void)
+__weak int exynos_early_init_f(void)
 {
        return 0;
 }
-int exynos_early_init_f(void)
-       __attribute__((weak, alias("__exynos_early_init_f")));
 
-int __exynos_power_init(void)
+__weak int exynos_power_init(void)
 {
        return 0;
 }
-int exynos_power_init(void)
-       __attribute__((weak, alias("__exynos_power_init")));
 
 #if defined CONFIG_EXYNOS_TMU
 /* Boot Time Thermal Analysis for SoC temperature threshold breach */
index bcd0a55a1e584410e13689b691f9d2d3614cdf67..31a15037d07cf950059f9a23d80e7b8fe6259c6f 100644 (file)
@@ -1,25 +1,12 @@
-if TARGET_SUN4I
+if TARGET_SUN4I || TARGET_SUN5I || TARGET_SUN6I || TARGET_SUN7I || TARGET_SUN8I
 
 config SYS_CONFIG_NAME
-       default "sun4i"
-
-endif
-
-if TARGET_SUN5I
-
-config SYS_CONFIG_NAME
-       default "sun5i"
-
-endif
-
-if TARGET_SUN7I
-
-config SYS_CONFIG_NAME
-       default "sun7i"
-
-endif
-
-if TARGET_SUN4I || TARGET_SUN5I || TARGET_SUN7I
+       string
+       default "sun4i" if TARGET_SUN4I
+       default "sun5i" if TARGET_SUN5I
+       default "sun6i" if TARGET_SUN6I
+       default "sun7i" if TARGET_SUN7I
+       default "sun8i" if TARGET_SUN8I
 
 config SYS_CPU
        default "armv7"
@@ -33,4 +20,45 @@ config SYS_SOC
 config FDTFILE
        string "Default fdtfile env setting for this board"
 
+config OLD_SUNXI_KERNEL_COMPAT
+       boolean "Enable workarounds for booting old kernels"
+       default n
+       ---help---
+       Set this to enable various workarounds for old kernels, this results in
+       sub-optimal settings for newer kernels, only enable if needed.
+
+config MMC0_CD_PIN
+       string "Card detect pin for mmc0"
+       default ""
+       ---help---
+       Set the card detect pin for mmc0, leave empty to not use cd. This
+       takes a string in the format understood by sunxi_name_to_gpio, e.g.
+       PH1 for pin 1 of port H.
+
+config MMC1_CD_PIN
+       string "Card detect pin for mmc1"
+       default ""
+       ---help---
+       See MMC0_CD_PIN help text.
+
+config MMC2_CD_PIN
+       string "Card detect pin for mmc2"
+       default ""
+       ---help---
+       See MMC0_CD_PIN help text.
+
+config MMC3_CD_PIN
+       string "Card detect pin for mmc3"
+       default ""
+       ---help---
+       See MMC0_CD_PIN help text.
+
+config MMC_SUNXI_SLOT_EXTRA
+       int "mmc extra slot number"
+       default -1
+       ---help---
+       sunxi builds always enable mmc0, some boards also have a second sdcard
+       slot or emmc on mmc1 - mmc3. Setting this to 1, 2 or 3 will enable
+       support for this.
+
 endif
index 4f32195dcd92372858a2ff0170f45059531d8adf..febd126cb83bb15518515422ac35e25cba071dfa 100644 (file)
@@ -8,6 +8,7 @@ F:      configs/ba10_tv_box_defconfig
 F:     configs/Cubieboard_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:     include/configs/sun5i.h
@@ -38,3 +39,19 @@ M:   FUKAUMI Naoki <naobsd@gmail.com>
 S:     Maintained
 F:     board/sunxi/dram_a20_olinuxino_l.c
 F:     configs/A20-OLinuXino-Lime_defconfig
+
+A20-OLINUXINO-LIME2 BOARD
+M:     Iain Paton <ipaton0@gmail.com>
+S:     Maintained
+F:     board/sunxi/dram_a20_olinuxino_l2.c
+F:     configs/A20-OLinuXino-Lime2_defconfig
+
+COLOMBUS BOARD
+M:     Maxime Ripard <maxime.ripard@free-electrons.com>
+S:     Maintained
+F:     configs/Colombus_defconfig
+
+IPPO-Q8H-V5 BOARD
+M:     CHen-Yu Tsai <wens@csie.org>
+S:     Maintained
+F:     configs/Ippo_q8h_v5_defconfig
index 56073a024d1a4c58940671b325e7c0ad71d75427..6a2e4c9d5b5553d52a6325277109a201d10a1ca3 100644 (file)
@@ -16,6 +16,7 @@ obj-$(CONFIG_A10S_OLINUXINO_M)        += dram_a10s_olinuxino_m.o
 obj-$(CONFIG_A13_OLINUXINO)    += dram_a13_olinuxino.o
 obj-$(CONFIG_A13_OLINUXINOM)   += dram_a13_oli_micro.o
 obj-$(CONFIG_A20_OLINUXINO_L)  += dram_a20_olinuxino_l.o
+obj-$(CONFIG_A20_OLINUXINO_L2) += dram_a20_olinuxino_l2.o
 obj-$(CONFIG_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_AUXTEK_T004)      += dram_a10s_olinuxino_m.o
@@ -27,6 +28,7 @@ obj-$(CONFIG_CUBIETRUCK)      += dram_cubietruck.o
 obj-$(CONFIG_I12_TVBOX)                += dram_sun7i_384_1024_iow16.o
 obj-$(CONFIG_MELE_A1000)       += dram_sun4i_360_512.o
 obj-$(CONFIG_MELE_A1000G)      += dram_sun4i_360_1024_iow8.o
+obj-$(CONFIG_MELE_M3)          += dram_sun7i_384_1024_iow16.o
 obj-$(CONFIG_MINI_X)           += dram_sun4i_360_512.o
 obj-$(CONFIG_MINI_X_1GB)       += dram_sun4i_360_1024_iow16.o
 obj-$(CONFIG_PCDUINO3)         += dram_linksprite_pcduino3.o
index 2179e234e21d67b0fec064de792fca175db90ca5..03890c8c9ceb62c40279c4fb910a56441858ec8a 100644 (file)
@@ -12,6 +12,7 @@
  */
 
 #include <common.h>
+#include <mmc.h>
 #ifdef CONFIG_AXP152_POWER
 #include <axp152.h>
 #endif
@@ -70,9 +71,9 @@ static void mmc_pinmux_setup(int sdc)
                break;
 
        case 1:
-               /* CMD-PH22, CLK-PH23, D0~D3-PH24~27 : 5 */
-               for (pin = SUNXI_GPH(22); pin <= SUNXI_GPH(27); pin++) {
-                       sunxi_gpio_set_cfgpin(pin, SUN4I_GPH22_SDC1);
+               /* CMD-PG3, CLK-PG4, D0~D3-PG5-8 */
+               for (pin = SUNXI_GPG(3); pin <= SUNXI_GPG(8); pin++) {
+                       sunxi_gpio_set_cfgpin(pin, SUN5I_GPG3_SDC1);
                        sunxi_gpio_set_pull(pin, SUNXI_GPIO_PULL_UP);
                        sunxi_gpio_set_drv(pin, 2);
                }
@@ -104,11 +105,36 @@ static void mmc_pinmux_setup(int sdc)
 
 int board_mmc_init(bd_t *bis)
 {
+       __maybe_unused struct mmc *mmc0, *mmc1;
+       __maybe_unused char buf[512];
+
        mmc_pinmux_setup(CONFIG_MMC_SUNXI_SLOT);
-       sunxi_mmc_init(CONFIG_MMC_SUNXI_SLOT);
-#if !defined (CONFIG_SPL_BUILD) && defined (CONFIG_MMC_SUNXI_SLOT_EXTRA)
+       mmc0 = sunxi_mmc_init(CONFIG_MMC_SUNXI_SLOT);
+       if (!mmc0)
+               return -1;
+
+#if CONFIG_MMC_SUNXI_SLOT_EXTRA != -1
        mmc_pinmux_setup(CONFIG_MMC_SUNXI_SLOT_EXTRA);
-       sunxi_mmc_init(CONFIG_MMC_SUNXI_SLOT_EXTRA);
+       mmc1 = sunxi_mmc_init(CONFIG_MMC_SUNXI_SLOT_EXTRA);
+       if (!mmc1)
+               return -1;
+#endif
+
+#if CONFIG_MMC_SUNXI_SLOT == 0 && CONFIG_MMC_SUNXI_SLOT_EXTRA == 2
+       /*
+        * Both mmc0 and mmc2 are bootable, figure out where we're booting
+        * from. Try mmc0 first, just like the brom does.
+        */
+       if (mmc_getcd(mmc0) && mmc_init(mmc0) == 0 &&
+           mmc0->block_dev.block_read(0, 16, 1, buf) == 1) {
+               buf[12] = 0;
+               if (strcmp(&buf[4], "eGON.BT0") == 0)
+                       return 0;
+       }
+
+       /* no bootable card in mmc0, so we must be booting from mmc2, swap */
+       mmc0->block_dev.dev = 1;
+       mmc1->block_dev.dev = 0;
 #endif
 
        return 0;
diff --git a/board/sunxi/dram_a20_olinuxino_l2.c b/board/sunxi/dram_a20_olinuxino_l2.c
new file mode 100644 (file)
index 0000000..2115d37
--- /dev/null
@@ -0,0 +1,31 @@
+/* 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);
+}
index 054e7ccdedf9bf4f222b22ecaab0fa2805b4d68f..a4aed3ba8baf2d3ce742f7c6967f273e61cc5afb 100644 (file)
@@ -16,6 +16,8 @@
 #include <asm/omap_gpio.h>
 #include <asm/arch/mmc_host_def.h>
 #include <i2c.h>
+#include <spl.h>
+#include <mmc.h>
 #include <asm/gpio.h>
 #ifdef CONFIG_USB_EHCI
 #include <usb.h>
index 94b99bf53762660406c1dd1d87d1b9694d5a5625..4c5e38136fd55c542c52379285d0e42237e2cda2 100644 (file)
@@ -14,6 +14,8 @@
  * SPDX-License-Identifier:    GPL-2.0+
  */
 #include <common.h>
+#include <dm.h>
+#include <ns16550.h>
 #ifdef CONFIG_STATUS_LED
 #include <status_led.h>
 #endif
@@ -70,6 +72,17 @@ static struct {
        char env_setting[64];
 } expansion_config;
 
+static const struct ns16550_platdata beagle_serial = {
+       OMAP34XX_UART3,
+       2,
+       V_NS16550_CLK
+};
+
+U_BOOT_DEVICE(beagle_uart) = {
+       "serial_omap",
+       &beagle_serial
+};
+
 /*
  * Routine: board_init
  * Description: Early hardware init.
@@ -103,22 +116,22 @@ int board_init(void)
  */
 static int get_board_revision(void)
 {
-       int revision;
-
-       if (!gpio_request(171, "") &&
-           !gpio_request(172, "") &&
-           !gpio_request(173, "")) {
-
-               gpio_direction_input(171);
-               gpio_direction_input(172);
-               gpio_direction_input(173);
-
-               revision = gpio_get_value(173) << 2 |
-                          gpio_get_value(172) << 1 |
-                          gpio_get_value(171);
-       } else {
-               printf("Error: unable to acquire board revision GPIOs\n");
-               revision = -1;
+       static int revision = -1;
+
+       if (revision == -1) {
+               if (!gpio_request(171, "rev0") &&
+                   !gpio_request(172, "rev1") &&
+                   !gpio_request(173, "rev2")) {
+                       gpio_direction_input(171);
+                       gpio_direction_input(172);
+                       gpio_direction_input(173);
+
+                       revision = gpio_get_value(173) << 2 |
+                               gpio_get_value(172) << 1 |
+                               gpio_get_value(171);
+               } else {
+                       printf("Error: unable to acquire board revision GPIOs\n");
+               }
        }
 
        return revision;
@@ -258,7 +271,7 @@ static void beagle_dvi_pup(void)
        case REVISION_AXBX:
        case REVISION_CX:
        case REVISION_C4:
-               gpio_request(170, "");
+               gpio_request(170, "dvi");
                gpio_direction_output(170, 0);
                gpio_set_value(170, 1);
                break;
index 89b8dd3c3c1ee015be657b27372bc5c2176cc634..a913a4c84aa624453138ce0ad6fa8180db61fc1b 100644 (file)
@@ -27,47 +27,46 @@ void green_led_on(void)
 }
 #endif
 
+static int get_led_gpio(led_id_t mask)
+{
+#ifdef STATUS_LED_BIT
+       if (STATUS_LED_BIT & mask)
+               return BEAGLE_LED_USR0;
+#endif
+#ifdef STATUS_LED_BIT1
+       if (STATUS_LED_BIT1 & mask)
+               return BEAGLE_LED_USR1;
+#endif
+
+       return 0;
+}
+
 void __led_init (led_id_t mask, int state)
 {
-       __led_set (mask, state);
+       int toggle_gpio;
+
+       toggle_gpio = get_led_gpio(mask);
+
+       if (toggle_gpio && !gpio_request(toggle_gpio, "led"))
+               __led_set(mask, state);
 }
 
 void __led_toggle (led_id_t mask)
 {
-       int state, toggle_gpio = 0;
-#ifdef STATUS_LED_BIT
-       if (!toggle_gpio && STATUS_LED_BIT & mask)
-               toggle_gpio = BEAGLE_LED_USR0;
-#endif
-#ifdef STATUS_LED_BIT1
-       if (!toggle_gpio && STATUS_LED_BIT1 & mask)
-               toggle_gpio = BEAGLE_LED_USR1;
-#endif
+       int state, toggle_gpio;
+
+       toggle_gpio = get_led_gpio(mask);
        if (toggle_gpio) {
-               if (!gpio_request(toggle_gpio, "")) {
-                       gpio_direction_output(toggle_gpio, 0);
-                       state = gpio_get_value(toggle_gpio);
-                       gpio_set_value(toggle_gpio, !state);
-               }
+               state = gpio_get_value(toggle_gpio);
+               gpio_direction_output(toggle_gpio, !state);
        }
 }
 
 void __led_set (led_id_t mask, int state)
 {
-#ifdef STATUS_LED_BIT
-       if (STATUS_LED_BIT & mask) {
-               if (!gpio_request(BEAGLE_LED_USR0, "")) {
-                       gpio_direction_output(BEAGLE_LED_USR0, 0);
-                       gpio_set_value(BEAGLE_LED_USR0, state);
-               }
-       }
-#endif
-#ifdef STATUS_LED_BIT1
-       if (STATUS_LED_BIT1 & mask) {
-               if (!gpio_request(BEAGLE_LED_USR1, "")) {
-                       gpio_direction_output(BEAGLE_LED_USR1, 0);
-                       gpio_set_value(BEAGLE_LED_USR1, state);
-               }
-       }
-#endif
+       int toggle_gpio;
+
+       toggle_gpio = get_led_gpio(mask);
+       if (toggle_gpio)
+               gpio_direction_output(toggle_gpio, state);
 }
diff --git a/board/toradex/apalis_t30/Kconfig b/board/toradex/apalis_t30/Kconfig
new file mode 100644 (file)
index 0000000..f1dcda5
--- /dev/null
@@ -0,0 +1,12 @@
+if TARGET_APALIS_T30
+
+config SYS_BOARD
+       default "apalis_t30"
+
+config SYS_VENDOR
+       default "toradex"
+
+config SYS_CONFIG_NAME
+       default "apalis_t30"
+
+endif
diff --git a/board/toradex/apalis_t30/MAINTAINERS b/board/toradex/apalis_t30/MAINTAINERS
new file mode 100644 (file)
index 0000000..01bc73e
--- /dev/null
@@ -0,0 +1,7 @@
+Apalis T30
+M:     Marcel Ziswiler <marcel.ziswiler@toradex.com>
+S:     Maintained
+F:     board/toradex/apalis_t30/
+F:     include/configs/apalis_t30.h
+F:     configs/apalis_t30_defconfig
+F:     arch/arm/dts/tegra30-apalis.dtb
diff --git a/board/toradex/apalis_t30/Makefile b/board/toradex/apalis_t30/Makefile
new file mode 100644 (file)
index 0000000..a968e6b
--- /dev/null
@@ -0,0 +1,6 @@
+# Copyright (c) 2014 Marcel Ziswiler
+# SPDX-License-Identifier:      GPL-2.0+
+
+include $(srctree)/board/nvidia/common/common.mk
+
+obj-y  += apalis_t30.o
diff --git a/board/toradex/apalis_t30/apalis_t30.c b/board/toradex/apalis_t30/apalis_t30.c
new file mode 100644 (file)
index 0000000..b9d694a
--- /dev/null
@@ -0,0 +1,92 @@
+/*
+ *  (C) Copyright 2014
+ *  Marcel Ziswiler <marcel@ziswiler.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <common.h>
+
+#include <asm/arch/gp_padctrl.h>
+#include <asm/arch/pinmux.h>
+#include <asm/gpio.h>
+#include <i2c.h>
+#include <netdev.h>
+
+#include "pinmux-config-apalis_t30.h"
+
+#define PMU_I2C_ADDRESS                0x2D
+#define MAX_I2C_RETRY          3
+
+/*
+ * Routine: pinmux_init
+ * Description: Do individual peripheral pinmux configs
+ */
+void pinmux_init(void)
+{
+       pinmux_config_pingrp_table(tegra3_pinmux_common,
+                                  ARRAY_SIZE(tegra3_pinmux_common));
+
+       pinmux_config_pingrp_table(unused_pins_lowpower,
+                                  ARRAY_SIZE(unused_pins_lowpower));
+
+       /* Initialize any non-default pad configs (APB_MISC_GP regs) */
+       pinmux_config_drvgrp_table(apalis_t30_padctrl,
+                                  ARRAY_SIZE(apalis_t30_padctrl));
+}
+
+#ifdef CONFIG_PCI_TEGRA
+int tegra_pcie_board_init(void)
+{
+       unsigned int old_bus;
+       u8 addr, data[1];
+       int err;
+
+       old_bus = i2c_get_bus_num();
+
+       err = i2c_set_bus_num(0);
+       if (err) {
+               debug("failed to set I2C bus\n");
+               return err;
+       }
+
+       /* TPS659110: VDD2_OP_REG = 1.05V */
+       data[0] = 0x27;
+       addr = 0x25;
+
+       err = i2c_write(PMU_I2C_ADDRESS, addr, 1, data, 1);
+       if (err) {
+               debug("failed to set VDD supply\n");
+               return err;
+       }
+
+       /* TPS659110: VDD2_REG 7.5 mV/us, ACTIVE */
+       data[0] = 0x0D;
+       addr = 0x24;
+
+       err = i2c_write(PMU_I2C_ADDRESS, addr, 1, data, 1);
+       if (err) {
+               debug("failed to enable VDD supply\n");
+               return err;
+       }
+
+       /* TPS659110: LDO6_REG = 1.1V, ACTIVE */
+       data[0] = 0x0D;
+       addr = 0x35;
+
+       err = i2c_write(PMU_I2C_ADDRESS, addr, 1, data, 1);
+       if (err) {
+               debug("failed to set AVDD supply\n");
+               return err;
+       }
+
+       i2c_set_bus_num(old_bus);
+
+       return 0;
+}
+
+int board_eth_init(bd_t *bis)
+{
+       return pci_eth_init(bis);
+}
+#endif /* CONFIG_PCI_TEGRA */
diff --git a/board/toradex/apalis_t30/pinmux-config-apalis_t30.h b/board/toradex/apalis_t30/pinmux-config-apalis_t30.h
new file mode 100644 (file)
index 0000000..c988d39
--- /dev/null
@@ -0,0 +1,347 @@
+/*
+ * Copyright (c) 2014, Marcel Ziswiler
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _PINMUX_CONFIG_APALIS_T30_H_
+#define _PINMUX_CONFIG_APALIS_T30_H_
+
+#define DEFAULT_PINMUX(_pingrp, _mux, _pull, _tri, _io)                \
+       {                                                       \
+               .pingrp         = PMUX_PINGRP_##_pingrp,        \
+               .func           = PMUX_FUNC_##_mux,             \
+               .pull           = PMUX_PULL_##_pull,            \
+               .tristate       = PMUX_TRI_##_tri,              \
+               .io             = PMUX_PIN_##_io,               \
+               .lock           = PMUX_PIN_LOCK_DEFAULT,        \
+               .od             = PMUX_PIN_OD_DEFAULT,          \
+               .ioreset        = PMUX_PIN_IO_RESET_DEFAULT,    \
+       }
+
+#define I2C_PINMUX(_pingrp, _mux, _pull, _tri, _io, _lock, _od)        \
+       {                                                       \
+               .pingrp         = PMUX_PINGRP_##_pingrp,        \
+               .func           = PMUX_FUNC_##_mux,             \
+               .pull           = PMUX_PULL_##_pull,            \
+               .tristate       = PMUX_TRI_##_tri,              \
+               .io             = PMUX_PIN_##_io,               \
+               .lock           = PMUX_PIN_LOCK_##_lock,        \
+               .od             = PMUX_PIN_OD_##_od,            \
+               .ioreset        = PMUX_PIN_IO_RESET_DEFAULT,    \
+       }
+
+#define LV_PINMUX(_pingrp, _mux, _pull, _tri, _io, _lock, _ioreset) \
+       {                                                       \
+               .pingrp         = PMUX_PINGRP_##_pingrp,        \
+               .func           = PMUX_FUNC_##_mux,             \
+               .pull           = PMUX_PULL_##_pull,            \
+               .tristate       = PMUX_TRI_##_tri,              \
+               .io             = PMUX_PIN_##_io,               \
+               .lock           = PMUX_PIN_LOCK_##_lock,        \
+               .od             = PMUX_PIN_OD_DEFAULT,          \
+               .ioreset        = PMUX_PIN_IO_RESET_##_ioreset  \
+       }
+
+#define DEFAULT_PADCFG(_drvgrp, _slwf, _slwr, _drvup, _drvdn, _lpmd, _schmt, _hsm) \
+       {                                                       \
+               .drvgrp         = PMUX_DRVGRP_##_drvgrp,        \
+               .slwf           = _slwf,                        \
+               .slwr           = _slwr,                        \
+               .drvup          = _drvup,                       \
+               .drvdn          = _drvdn,                       \
+               .lpmd           = PMUX_LPMD_##_lpmd,            \
+               .schmt          = PMUX_SCHMT_##_schmt,          \
+               .hsm            = PMUX_HSM_##_hsm,              \
+       }
+
+static struct pmux_pingrp_config tegra3_pinmux_common[] = {
+       /* SDMMC1 pinmux */
+       DEFAULT_PINMUX(SDMMC1_CLK_PZ0, SDMMC1, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(SDMMC1_CMD_PZ1, SDMMC1, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(SDMMC1_DAT3_PY4, SDMMC1, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(SDMMC1_DAT2_PY5, SDMMC1, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(SDMMC1_DAT1_PY6, SDMMC1, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(SDMMC1_DAT0_PY7, SDMMC1, NORMAL, NORMAL, INPUT),
+
+       /* SDMMC3 pinmux */
+       DEFAULT_PINMUX(SDMMC3_CLK_PA6, SDMMC3, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(SDMMC3_CMD_PA7, SDMMC3, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(SDMMC3_DAT0_PB7, SDMMC3, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(SDMMC3_DAT1_PB6, SDMMC3, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(SDMMC3_DAT2_PB5, SDMMC3, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(SDMMC3_DAT3_PB4, SDMMC3, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(SDMMC3_DAT4_PD1, SDMMC3, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(SDMMC3_DAT5_PD0, SDMMC3, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(SDMMC3_DAT6_PD3, SDMMC3, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(SDMMC3_DAT7_PD4, SDMMC3, NORMAL, NORMAL, INPUT),
+
+       /* SDMMC4 pinmux (eMMC) */
+       LV_PINMUX(SDMMC4_CLK_PCC4, SDMMC4, NORMAL, NORMAL, INPUT, DISABLE, DISABLE),
+       LV_PINMUX(SDMMC4_CMD_PT7, SDMMC4, UP, NORMAL, INPUT, DISABLE, DISABLE),
+       LV_PINMUX(SDMMC4_DAT0_PAA0, SDMMC4, UP, NORMAL, INPUT, DISABLE, DISABLE),
+       LV_PINMUX(SDMMC4_DAT1_PAA1, SDMMC4, UP, NORMAL, INPUT, DISABLE, DISABLE),
+       LV_PINMUX(SDMMC4_DAT2_PAA2, SDMMC4, UP, NORMAL, INPUT, DISABLE, DISABLE),
+       LV_PINMUX(SDMMC4_DAT3_PAA3, SDMMC4, UP, NORMAL, INPUT, DISABLE, DISABLE),
+       LV_PINMUX(SDMMC4_DAT4_PAA4, SDMMC4, UP, NORMAL, INPUT, DISABLE, DISABLE),
+       LV_PINMUX(SDMMC4_DAT5_PAA5, SDMMC4, UP, NORMAL, INPUT, DISABLE, DISABLE),
+       LV_PINMUX(SDMMC4_DAT6_PAA6, SDMMC4, UP, NORMAL, INPUT, DISABLE, DISABLE),
+       LV_PINMUX(SDMMC4_DAT7_PAA7, SDMMC4, UP, NORMAL, INPUT, DISABLE, DISABLE),
+       LV_PINMUX(SDMMC4_RST_N_PCC3, RSVD1, DOWN, NORMAL, INPUT, DISABLE, DISABLE),
+
+       /* I2C1 pinmux */
+       I2C_PINMUX(GEN1_I2C_SCL_PC4, I2C1, NORMAL, NORMAL, INPUT, DISABLE, ENABLE),
+       I2C_PINMUX(GEN1_I2C_SDA_PC5, I2C1, NORMAL, NORMAL, INPUT, DISABLE, ENABLE),
+
+       /* I2C2 pinmux */
+       I2C_PINMUX(GEN2_I2C_SCL_PT5, I2C2, NORMAL, NORMAL, INPUT, DISABLE, ENABLE),
+       I2C_PINMUX(GEN2_I2C_SDA_PT6, I2C2, NORMAL, NORMAL, INPUT, DISABLE, ENABLE),
+
+       /* I2C3 pinmux */
+       I2C_PINMUX(CAM_I2C_SCL_PBB1, I2C3, NORMAL, TRISTATE, INPUT, DISABLE, ENABLE),
+       I2C_PINMUX(CAM_I2C_SDA_PBB2, I2C3, NORMAL, TRISTATE, INPUT, DISABLE, ENABLE),
+
+       /* I2C4 pinmux */
+       I2C_PINMUX(DDC_SCL_PV4, I2C4, NORMAL, NORMAL, INPUT, DISABLE, ENABLE),
+       I2C_PINMUX(DDC_SDA_PV5, I2C4, NORMAL, NORMAL, INPUT, DISABLE, ENABLE),
+
+       /* Power I2C pinmux */
+       I2C_PINMUX(PWR_I2C_SCL_PZ6, I2CPWR, NORMAL, NORMAL, INPUT, DISABLE, ENABLE),
+       I2C_PINMUX(PWR_I2C_SDA_PZ7, I2CPWR, NORMAL, NORMAL, INPUT, DISABLE, ENABLE),
+
+       DEFAULT_PINMUX(ULPI_DATA0_PO1, UARTA, NORMAL, NORMAL, OUTPUT),
+       /* UARTA RX, make sure we don't get input form a floating Pin */
+       DEFAULT_PINMUX(ULPI_DATA1_PO2, UARTA, UP, NORMAL, INPUT),
+       DEFAULT_PINMUX(ULPI_DATA2_PO3, UARTA, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(ULPI_DATA3_PO4, RSVD1, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(ULPI_DATA4_PO5, UARTA, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(ULPI_DATA5_PO6, UARTA, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(ULPI_DATA6_PO7, UARTA, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(ULPI_DATA7_PO0, UARTA, NORMAL, NORMAL, OUTPUT),
+       DEFAULT_PINMUX(ULPI_CLK_PY0, UARTD, NORMAL, NORMAL, OUTPUT),
+       DEFAULT_PINMUX(ULPI_DIR_PY1, UARTD, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(ULPI_NXT_PY2, UARTD, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(ULPI_STP_PY3, UARTD, NORMAL, NORMAL, OUTPUT),
+       DEFAULT_PINMUX(DAP3_FS_PP0, I2S2, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(DAP3_DIN_PP1, I2S2, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(DAP3_DOUT_PP2, I2S2, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(DAP3_SCLK_PP3, I2S2, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(PV2, OWR, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(PV3, RSVD1, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(CLK2_OUT_PW5, EXTPERIPH2, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(CLK2_REQ_PCC5, DAP, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(LCD_PWR1_PC1, DISPLAYA, DOWN, TRISTATE, OUTPUT), /* NC */
+       DEFAULT_PINMUX(LCD_PWR2_PC6, DISPLAYA, DOWN, TRISTATE, OUTPUT), /* NC */
+       DEFAULT_PINMUX(LCD_SDIN_PZ2, SPI5, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(LCD_SDOUT_PN5, SPI5, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(LCD_WR_N_PZ3, DISPLAYA, DOWN, TRISTATE, OUTPUT), /* NC */
+       DEFAULT_PINMUX(LCD_CS0_N_PN4, SPI5, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(LCD_DC0_PN6, DISPLAYA, DOWN, TRISTATE, OUTPUT), /* NC */
+       DEFAULT_PINMUX(LCD_SCK_PZ4, SPI5, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(LCD_PWR0_PB2, DISPLAYA, DOWN, TRISTATE, OUTPUT), /* NC */
+       DEFAULT_PINMUX(LCD_PCLK_PB3, DISPLAYA, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(LCD_DE_PJ1, DISPLAYA, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(LCD_HSYNC_PJ3, DISPLAYA, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(LCD_VSYNC_PJ4, DISPLAYA, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(LCD_D0_PE0, DISPLAYA, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(LCD_D1_PE1, DISPLAYA, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(LCD_D2_PE2, DISPLAYA, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(LCD_D3_PE3, DISPLAYA, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(LCD_D4_PE4, DISPLAYA, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(LCD_D5_PE5, DISPLAYA, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(LCD_D6_PE6, DISPLAYA, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(LCD_D7_PE7, DISPLAYA, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(LCD_D8_PF0, DISPLAYA, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(LCD_D9_PF1, DISPLAYA, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(LCD_D10_PF2, DISPLAYA, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(LCD_D11_PF3, DISPLAYA, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(LCD_D12_PF4, DISPLAYA, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(LCD_D13_PF5, DISPLAYA, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(LCD_D14_PF6, DISPLAYA, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(LCD_D15_PF7, DISPLAYA, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(LCD_D16_PM0, DISPLAYA, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(LCD_D17_PM1, DISPLAYA, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(LCD_D18_PM2, DISPLAYA, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(LCD_D19_PM3, DISPLAYA, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(LCD_D20_PM4, DISPLAYA, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(LCD_D21_PM5, DISPLAYA, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(LCD_D22_PM6, DISPLAYA, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(LCD_D23_PM7, DISPLAYA, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(LCD_CS1_N_PW0, DISPLAYA, DOWN, TRISTATE, OUTPUT), /* NC */
+       DEFAULT_PINMUX(LCD_M1_PW1, DISPLAYA, DOWN, TRISTATE, OUTPUT), /* NC */
+       DEFAULT_PINMUX(LCD_DC1_PD2, DISPLAYA, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(CRT_HSYNC_PV6, CRT, NORMAL, NORMAL, OUTPUT),
+       DEFAULT_PINMUX(CRT_VSYNC_PV7, CRT, NORMAL, NORMAL, OUTPUT),
+       LV_PINMUX(VI_D0_PT4, VI, NORMAL, NORMAL, INPUT, DISABLE, DISABLE),
+       LV_PINMUX(VI_D1_PD5, VI, NORMAL, NORMAL, INPUT, DISABLE, DISABLE),
+       LV_PINMUX(VI_D2_PL0, VI, NORMAL, NORMAL, INPUT, DISABLE, DISABLE),
+       LV_PINMUX(VI_D3_PL1, VI, NORMAL, NORMAL, INPUT, DISABLE, DISABLE),
+       LV_PINMUX(VI_D4_PL2, VI, NORMAL, NORMAL, INPUT, DISABLE, DISABLE),
+       LV_PINMUX(VI_D5_PL3, VI, NORMAL, NORMAL, INPUT, DISABLE, DISABLE),
+       LV_PINMUX(VI_D6_PL4, VI, NORMAL, NORMAL, INPUT, DISABLE, DISABLE),
+       LV_PINMUX(VI_D7_PL5, VI, NORMAL, NORMAL, INPUT, DISABLE, DISABLE),
+       LV_PINMUX(VI_D8_PL6, VI, NORMAL, NORMAL, INPUT, DISABLE, DISABLE),
+       LV_PINMUX(VI_D9_PL7, VI, NORMAL, NORMAL, INPUT, DISABLE, DISABLE),
+       LV_PINMUX(VI_D10_PT2, VI, NORMAL, NORMAL, INPUT, DISABLE, DISABLE),
+       LV_PINMUX(VI_D11_PT3, VI, NORMAL, NORMAL, INPUT, DISABLE, DISABLE),
+       LV_PINMUX(VI_HSYNC_PD7, VI, NORMAL, NORMAL, INPUT, DISABLE, DISABLE),
+       LV_PINMUX(VI_MCLK_PT1, VI, NORMAL, NORMAL, OUTPUT, DISABLE, DISABLE),
+       LV_PINMUX(VI_PCLK_PT0, VI, NORMAL, NORMAL, INPUT, DISABLE, DISABLE),
+       LV_PINMUX(VI_VSYNC_PD6, VI, NORMAL, NORMAL, INPUT, DISABLE, DISABLE),
+       DEFAULT_PINMUX(UART2_RXD_PC3, UARTB, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(UART2_TXD_PC2, UARTB, NORMAL, NORMAL, OUTPUT),
+       DEFAULT_PINMUX(UART2_RTS_N_PJ6, UARTB, DOWN, TRISTATE, OUTPUT), /* NC */
+       DEFAULT_PINMUX(UART2_CTS_N_PJ5, UARTB, DOWN, TRISTATE, OUTPUT), /* NC */
+       DEFAULT_PINMUX(UART3_TXD_PW6, UARTC, NORMAL, NORMAL, OUTPUT),
+       DEFAULT_PINMUX(UART3_RXD_PW7, UARTC, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(UART3_CTS_N_PA1, UARTC, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(UART3_RTS_N_PC0, PWM0, NORMAL, NORMAL, OUTPUT),
+       DEFAULT_PINMUX(PU0, RSVD1, DOWN, TRISTATE, OUTPUT),
+       DEFAULT_PINMUX(PU1, RSVD1, DOWN, TRISTATE, OUTPUT),
+       DEFAULT_PINMUX(PU2, RSVD1, DOWN, TRISTATE, OUTPUT),
+       DEFAULT_PINMUX(PU3, PWM0, NORMAL, NORMAL, OUTPUT),
+       DEFAULT_PINMUX(PU4, PWM1, NORMAL, NORMAL, OUTPUT),
+       DEFAULT_PINMUX(PU5, PWM2, NORMAL, NORMAL, OUTPUT),
+       DEFAULT_PINMUX(PU6, PWM3, NORMAL, NORMAL, OUTPUT),
+       DEFAULT_PINMUX(DAP4_FS_PP4, I2S3, DOWN, TRISTATE, OUTPUT), /* NC */
+       DEFAULT_PINMUX(DAP4_DIN_PP5, I2S3, DOWN, TRISTATE, OUTPUT), /* NC */
+       DEFAULT_PINMUX(DAP4_DOUT_PP6, I2S3, DOWN, TRISTATE, OUTPUT), /* NC */
+       DEFAULT_PINMUX(DAP4_SCLK_PP7, I2S3, DOWN, TRISTATE, OUTPUT), /* NC */
+       DEFAULT_PINMUX(CLK3_OUT_PEE0, EXTPERIPH3, DOWN, TRISTATE, OUTPUT), /* NC */
+       DEFAULT_PINMUX(CLK3_REQ_PEE1, DEV3, DOWN, TRISTATE, OUTPUT), /* NC */
+       DEFAULT_PINMUX(GMI_WP_N_PC7, GMI, DOWN, TRISTATE, OUTPUT), /* NC */
+       DEFAULT_PINMUX(GMI_CS2_N_PK3, RSVD1, DOWN, TRISTATE, OUTPUT), /* NC */
+       DEFAULT_PINMUX(GMI_AD8_PH0, PWM0, DOWN, TRISTATE, OUTPUT), /* NC */
+       DEFAULT_PINMUX(GMI_AD10_PH2, NAND, DOWN, TRISTATE, OUTPUT), /* NC */
+       DEFAULT_PINMUX(GMI_A16_PJ7, UARTD, DOWN, TRISTATE, OUTPUT), /* NC */
+       DEFAULT_PINMUX(GMI_A17_PB0, UARTD, DOWN, TRISTATE, OUTPUT), /* NC */
+       DEFAULT_PINMUX(GMI_A18_PB1, UARTD, DOWN, TRISTATE, OUTPUT), /* NC */
+       DEFAULT_PINMUX(GMI_A19_PK7, UARTD, DOWN, TRISTATE, OUTPUT), /* NC */
+
+       DEFAULT_PINMUX(CAM_MCLK_PCC0, VI_ALT2, NORMAL, NORMAL, OUTPUT),
+       DEFAULT_PINMUX(PBB0, RSVD1, NORMAL, NORMAL, OUTPUT),
+       DEFAULT_PINMUX(PBB3, VGP3, NORMAL, NORMAL, OUTPUT),
+       DEFAULT_PINMUX(PBB4, VGP4, NORMAL, NORMAL, OUTPUT),
+       DEFAULT_PINMUX(PBB5, VGP5, NORMAL, NORMAL, OUTPUT),
+       DEFAULT_PINMUX(PBB6, VGP6, NORMAL, NORMAL, OUTPUT),
+       DEFAULT_PINMUX(PBB7, I2S4, NORMAL, NORMAL, OUTPUT),
+       DEFAULT_PINMUX(PCC1, RSVD1, NORMAL, NORMAL, OUTPUT),
+       DEFAULT_PINMUX(PCC2, I2S4, NORMAL, NORMAL, OUTPUT),
+
+       DEFAULT_PINMUX(JTAG_RTCK_PU7, RTCK, NORMAL, NORMAL, OUTPUT),
+
+       /* multiplexed VI_D2, VI_D3, VI_D4, VI_D5, VI_D6, VI_D7, VI_D8 and VI_D9
+        */
+       DEFAULT_PINMUX(KB_ROW0_PR0, RSVD2, NORMAL, TRISTATE, INPUT),
+       DEFAULT_PINMUX(KB_ROW1_PR1, RSVD2, NORMAL, TRISTATE, INPUT),
+       DEFAULT_PINMUX(KB_ROW2_PR2, RSVD2, NORMAL, TRISTATE, INPUT),
+       DEFAULT_PINMUX(KB_ROW3_PR3, RSVD2, NORMAL, TRISTATE, INPUT),
+       DEFAULT_PINMUX(KB_ROW4_PR4, RSVD3, NORMAL, TRISTATE, INPUT),
+       DEFAULT_PINMUX(KB_ROW5_PR5, KBC, NORMAL, TRISTATE, INPUT),
+       DEFAULT_PINMUX(KB_ROW6_PR6, KBC, NORMAL, TRISTATE, INPUT),
+       DEFAULT_PINMUX(KB_ROW7_PR7, KBC, NORMAL, TRISTATE, INPUT),
+       DEFAULT_PINMUX(KB_ROW8_PS0, KBC, NORMAL, TRISTATE, INPUT),
+       DEFAULT_PINMUX(KB_ROW9_PS1, KBC, NORMAL, TRISTATE, INPUT),
+
+       /* GPIOs */
+       DEFAULT_PINMUX(KB_ROW10_PS2, SDMMC2, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(KB_ROW11_PS3, SDMMC2, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(KB_ROW12_PS4, SDMMC2, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(KB_ROW13_PS5, SDMMC2, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(KB_ROW14_PS6, SDMMC2, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(KB_ROW15_PS7, SDMMC2, NORMAL, NORMAL, INPUT),
+
+       DEFAULT_PINMUX(KB_COL0_PQ0, KBC, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(KB_COL1_PQ1, KBC, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(KB_COL2_PQ2, KBC, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(KB_COL3_PQ3, KBC, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(KB_COL4_PQ4, KBC, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(KB_COL5_PQ5, KBC, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(KB_COL6_PQ6, KBC, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(KB_COL7_PQ7, KBC, NORMAL, NORMAL, INPUT),
+
+       DEFAULT_PINMUX(PV0, RSVD1, NORMAL, NORMAL, INPUT),
+
+       DEFAULT_PINMUX(CLK_32K_OUT_PA0, BLINK, DOWN, TRISTATE, OUTPUT), /* NC */
+       DEFAULT_PINMUX(SYS_CLK_REQ_PZ5, SYSCLK, NORMAL, NORMAL, INPUT),
+       /* multiplexed KB_COL0 */
+       DEFAULT_PINMUX(OWR, OWR, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(DAP1_FS_PN0, I2S0, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(DAP1_DIN_PN1, I2S0, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(DAP1_DOUT_PN2, I2S0, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(DAP1_SCLK_PN3, I2S0, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(CLK1_REQ_PEE2, DAP, NORMAL, NORMAL, OUTPUT),
+       DEFAULT_PINMUX(CLK1_OUT_PW4, EXTPERIPH1, NORMAL, NORMAL, OUTPUT),
+       DEFAULT_PINMUX(SPDIF_IN_PK6, SPDIF, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(SPDIF_OUT_PK5, SPDIF, NORMAL, NORMAL, OUTPUT),
+       DEFAULT_PINMUX(DAP2_FS_PA2, I2S1, NORMAL, TRISTATE, OUTPUT),
+       DEFAULT_PINMUX(DAP2_DIN_PA4, I2S1, NORMAL, TRISTATE, OUTPUT),
+       DEFAULT_PINMUX(DAP2_DOUT_PA5, I2S1, NORMAL, TRISTATE, OUTPUT),
+       DEFAULT_PINMUX(DAP2_SCLK_PA3, I2S1, NORMAL, TRISTATE, OUTPUT),
+
+       DEFAULT_PINMUX(SPI2_CS1_N_PW2, SPI2, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(SPI1_MOSI_PX4, SPI1, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(SPI1_SCK_PX5, SPI1, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(SPI1_CS0_N_PX6, SPI1, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(SPI1_MISO_PX7, SPI1, NORMAL, NORMAL, INPUT),
+
+       DEFAULT_PINMUX(PEX_L0_PRSNT_N_PDD0, PCIE, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(PEX_L0_RST_N_PDD1, PCIE, NORMAL, NORMAL, OUTPUT),
+       DEFAULT_PINMUX(PEX_L0_CLKREQ_N_PDD2, PCIE, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(PEX_WAKE_N_PDD3, PCIE, NORMAL, NORMAL, INPUT),
+
+       DEFAULT_PINMUX(PEX_L1_PRSNT_N_PDD4, PCIE, DOWN, TRISTATE, OUTPUT), /* NC */
+       DEFAULT_PINMUX(PEX_L1_RST_N_PDD5, PCIE, DOWN, TRISTATE, OUTPUT), /* NC */
+       DEFAULT_PINMUX(PEX_L1_CLKREQ_N_PDD6, PCIE, DOWN, TRISTATE, OUTPUT), /* NC */
+       DEFAULT_PINMUX(PEX_L2_PRSNT_N_PDD7, PCIE, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(PEX_L2_RST_N_PCC6, PCIE, NORMAL, NORMAL, OUTPUT),
+       DEFAULT_PINMUX(PEX_L2_CLKREQ_N_PCC7, PCIE, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(HDMI_CEC_PEE3, CEC, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(HDMI_INT_PN7, RSVD1, NORMAL, NORMAL, INPUT),
+
+       DEFAULT_PINMUX(GMI_IORDY_PI5, RSVD1, DOWN, TRISTATE, OUTPUT), /* NC */
+       DEFAULT_PINMUX(GMI_AD12_PH4, NAND, DOWN, TRISTATE, OUTPUT), /* NC */
+       DEFAULT_PINMUX(GMI_AD14_PH6, NAND, DOWN, TRISTATE, OUTPUT), /* NC */
+
+       DEFAULT_PINMUX(SPI2_SCK_PX2, GMI, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(KB_ROW8_PS0, KBC, NORMAL, NORMAL, INPUT),
+};
+
+static struct pmux_pingrp_config unused_pins_lowpower[] = {
+       DEFAULT_PINMUX(GMI_WAIT_PI7, NAND, DOWN, TRISTATE, OUTPUT),
+       DEFAULT_PINMUX(GMI_ADV_N_PK0, NAND, DOWN, TRISTATE, OUTPUT),
+       DEFAULT_PINMUX(GMI_CLK_PK1, NAND, DOWN, TRISTATE, OUTPUT),
+       DEFAULT_PINMUX(GMI_CS3_N_PK4, NAND, DOWN, TRISTATE, OUTPUT),
+       DEFAULT_PINMUX(GMI_CS7_N_PI6, NAND, DOWN, TRISTATE, OUTPUT),
+       DEFAULT_PINMUX(GMI_AD0_PG0, NAND, DOWN, TRISTATE, OUTPUT),
+       DEFAULT_PINMUX(GMI_AD1_PG1, NAND, DOWN, TRISTATE, OUTPUT),
+       DEFAULT_PINMUX(GMI_AD2_PG2, NAND, DOWN, TRISTATE, OUTPUT),
+       DEFAULT_PINMUX(GMI_AD3_PG3, NAND, DOWN, TRISTATE, OUTPUT),
+       DEFAULT_PINMUX(GMI_AD4_PG4, NAND, DOWN, TRISTATE, OUTPUT),
+       DEFAULT_PINMUX(GMI_AD5_PG5, NAND, DOWN, TRISTATE, OUTPUT),
+       DEFAULT_PINMUX(GMI_AD6_PG6, NAND, DOWN, TRISTATE, OUTPUT),
+       DEFAULT_PINMUX(GMI_AD7_PG7, NAND, DOWN, TRISTATE, OUTPUT),
+       DEFAULT_PINMUX(GMI_AD9_PH1, PWM1, DOWN, TRISTATE, OUTPUT),
+       DEFAULT_PINMUX(GMI_AD11_PH3, NAND, DOWN, TRISTATE, OUTPUT),
+       DEFAULT_PINMUX(GMI_AD13_PH5, NAND, DOWN, TRISTATE, OUTPUT),
+       DEFAULT_PINMUX(GMI_WR_N_PI0, NAND, DOWN, TRISTATE, OUTPUT),
+       DEFAULT_PINMUX(GMI_OE_N_PI1, NAND, NORMAL, NORMAL, INPUT),
+       DEFAULT_PINMUX(GMI_DQS_PI2, NAND, DOWN, TRISTATE, OUTPUT),
+};
+
+static struct pmux_drvgrp_config apalis_t30_padctrl[] = {
+       /* (_drvgrp, _slwf, _slwr, _drvup, _drvdn, _lpmd, _schmt, _hsm) */
+       DEFAULT_PADCFG(SDIO1, SDIOCFG_DRVUP_SLWF, SDIOCFG_DRVDN_SLWR, \
+               SDIOCFG_DRVUP, SDIOCFG_DRVDN, NONE, DISABLE, DISABLE),
+};
+#endif /* _PINMUX_CONFIG_APALIS_T30_H_ */
index ed043f49b37d70e2739b1c60ac061862cb70ccbf..f4bc7d8728eeda63a0df9b133c3f9fa5757180ee 100644 (file)
@@ -35,7 +35,7 @@ void pinmux_init(void)
 void pin_mux_usb(void)
 {
        /* Reset ASIX using LAN_RESET */
-       gpio_request(GPIO_PDD0, NULL);
+       gpio_request(GPIO_PDD0, "LAN_RESET");
        gpio_direction_output(GPIO_PDD0, 0);
        udelay(5);
        gpio_set_value(GPIO_PDD0, 1);
index 25fbb55c8e6c126c0ebc0f433f584ccf934aa40b..8f4fe310d7d2b23bef6dd5da1bd2e50c50615d6f 100644 (file)
@@ -8,12 +8,11 @@
 #include <common.h>
 #include <config.h>
 #include <command.h>
+#include <elf.h>
 
 /*
  * FIXME: Add code to test image and it's header.
  */
-extern int valid_elf_image (unsigned long addr);
-
 static int
 image_check(ulong addr)
 {
index e6aa298d5a4e8bc5255f7bcacf2022bc7dbf0f8f..b5bebc9dc862727b7aa2386f64691ace23475cc0 100644 (file)
@@ -128,14 +128,11 @@ int init_func_watchdog_reset(void)
 }
 #endif /* CONFIG_WATCHDOG */
 
-void __board_add_ram_info(int use_default)
+__weak void board_add_ram_info(int use_default)
 {
        /* please define platform specific board_add_ram_info() */
 }
 
-void board_add_ram_info(int)
-       __attribute__ ((weak, alias("__board_add_ram_info")));
-
 static int init_baud_rate(void)
 {
        gd->baudrate = getenv_ulong("baudrate", 10, CONFIG_BAUDRATE);
@@ -221,7 +218,7 @@ static int show_dram_config(void)
        return 0;
 }
 
-void __dram_init_banksize(void)
+__weak void dram_init_banksize(void)
 {
 #if defined(CONFIG_NR_DRAM_BANKS) && defined(CONFIG_SYS_SDRAM_BASE)
        gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE;
@@ -229,9 +226,6 @@ void __dram_init_banksize(void)
 #endif
 }
 
-void dram_init_banksize(void)
-       __attribute__((weak, alias("__dram_init_banksize")));
-
 #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SYS_I2C)
 static int init_func_i2c(void)
 {
index 3affb6362f4531ebd3f313248df1fbd7c588e7bf..7c339008ed2a46b91677d4c4c9e5e97fd58f4a1f 100644 (file)
@@ -60,7 +60,7 @@ DECLARE_GLOBAL_DATA_PTR;
 
 ulong monitor_flash_len;
 
-int __board_flash_wp_on(void)
+__weak int board_flash_wp_on(void)
 {
        /*
         * Most flashes can't be detected when write protection is enabled,
@@ -70,16 +70,10 @@ int __board_flash_wp_on(void)
        return 0;
 }
 
-int board_flash_wp_on(void)
-       __attribute__ ((weak, alias("__board_flash_wp_on")));
-
-void __cpu_secondary_init_r(void)
+__weak void cpu_secondary_init_r(void)
 {
 }
 
-void cpu_secondary_init_r(void)
-       __attribute__ ((weak, alias("__cpu_secondary_init_r")));
-
 static int initr_secondary_cpu(void)
 {
        /*
@@ -370,7 +364,7 @@ static int initr_spi(void)
 
 #ifdef CONFIG_CMD_NAND
 /* go init the NAND */
-int initr_nand(void)
+static int initr_nand(void)
 {
        puts("NAND:  ");
        nand_init();
@@ -380,7 +374,7 @@ int initr_nand(void)
 
 #if defined(CONFIG_CMD_ONENAND)
 /* go init the NAND */
-int initr_onenand(void)
+static int initr_onenand(void)
 {
        puts("NAND:  ");
        onenand_init();
@@ -389,7 +383,7 @@ int initr_onenand(void)
 #endif
 
 #ifdef CONFIG_GENERIC_MMC
-int initr_mmc(void)
+static int initr_mmc(void)
 {
        puts("MMC:   ");
        mmc_initialize(gd->bd);
@@ -398,7 +392,7 @@ int initr_mmc(void)
 #endif
 
 #ifdef CONFIG_HAS_DATAFLASH
-int initr_dataflash(void)
+static int initr_dataflash(void)
 {
        AT91F_DataflashInit();
        dataflash_print_info();
index ab9c7e332d97b200109e09e464b0fb786ac967c6..42a52965c2722282c36e6ebeaa0049c8c21b4c9f 100644 (file)
@@ -14,6 +14,7 @@
  */
 
 #include <common.h>
+#include <bootm.h>
 #include <command.h>
 #include <linux/ctype.h>
 #include <net.h>
@@ -28,8 +29,7 @@ static unsigned long load_elf_image_phdr(unsigned long addr);
 static unsigned long load_elf_image_shdr(unsigned long addr);
 
 /* Allow ports to override the default behavior */
-__attribute__((weak))
-unsigned long do_bootelf_exec(ulong (*entry)(int, char * const[]),
+static unsigned long do_bootelf_exec(ulong (*entry)(int, char * const[]),
                               int argc, char * const argv[])
 {
        unsigned long ret;
index 11f4e4031daddca8570892c53c47e16a198cee8a..65d6df451c6d4f4c5dc9c26a94a02a536b42386e 100644 (file)
@@ -12,7 +12,7 @@
 #include <dm.h>
 #include <asm/gpio.h>
 
-int __weak name_to_gpio(const char *name)
+__weak int name_to_gpio(const char *name)
 {
        return simple_strtoul(name, NULL, 10);
 }
@@ -25,13 +25,6 @@ enum gpio_cmd {
 };
 
 #if defined(CONFIG_DM_GPIO) && !defined(gpio_status)
-static const char * const gpio_function[GPIOF_COUNT] = {
-       "input",
-       "output",
-       "unused",
-       "unknown",
-       "func",
-};
 
 /* A few flags used by show_gpio() */
 enum {
@@ -40,22 +33,16 @@ enum {
        FLAG_SHOW_NEWLINE       = 1 << 2,
 };
 
-static void show_gpio(struct udevice *dev, const char *bank_name, int offset,
-                     int *flagsp)
+static void gpio_get_description(struct udevice *dev, const char *bank_name,
+                                int offset, int *flagsp)
 {
-       struct dm_gpio_ops *ops = gpio_get_ops(dev);
-       int func = GPIOF_UNKNOWN;
        char buf[80];
        int ret;
 
-       BUILD_BUG_ON(GPIOF_COUNT != ARRAY_SIZE(gpio_function));
-
-       if (ops->get_function) {
-               ret = ops->get_function(dev, offset);
-               if (ret >= 0 && ret < ARRAY_SIZE(gpio_function))
-                       func = ret;
-       }
-       if (!(*flagsp & FLAG_SHOW_ALL) && func == GPIOF_UNUSED)
+       ret = gpio_get_function(dev, offset, NULL);
+       if (ret < 0)
+               goto err;
+       if (!(*flagsp & FLAG_SHOW_ALL) && ret == GPIOF_UNUSED)
                return;
        if ((*flagsp & FLAG_SHOW_BANK) && bank_name) {
                if (*flagsp & FLAG_SHOW_NEWLINE) {
@@ -65,20 +52,15 @@ static void show_gpio(struct udevice *dev, const char *bank_name, int offset,
                printf("Bank %s:\n", bank_name);
                *flagsp &= ~FLAG_SHOW_BANK;
        }
-       *buf = '\0';
-       if (ops->get_state) {
-               ret = ops->get_state(dev, offset, buf, sizeof(buf));
-               if (ret) {
-                       puts("<unknown>");
-                       return;
-               }
-       } else {
-               sprintf(buf, "%s%u: %8s %d", bank_name, offset,
-                       gpio_function[func], ops->get_value(dev, offset));
-       }
 
-       puts(buf);
-       puts("\n");
+       ret = gpio_get_status(dev, offset, buf, sizeof(buf));
+       if (ret)
+               goto err;
+
+       printf("%s\n", buf);
+       return;
+err:
+       printf("Error %d\n", ret);
 }
 
 static int do_gpio_status(bool all, const char *gpio_name)
@@ -101,8 +83,10 @@ static int do_gpio_status(bool all, const char *gpio_name)
                if (all)
                        flags |= FLAG_SHOW_ALL;
                bank_name = gpio_get_bank_info(dev, &num_bits);
-               if (!num_bits)
+               if (!num_bits) {
+                       debug("GPIO device %s has no bits\n", dev->name);
                        continue;
+               }
                banklen = bank_name ? strlen(bank_name) : 0;
 
                if (!gpio_name || !bank_name ||
@@ -113,11 +97,12 @@ static int do_gpio_status(bool all, const char *gpio_name)
                        p = gpio_name + banklen;
                        if (gpio_name && *p) {
                                offset = simple_strtoul(p, NULL, 10);
-                               show_gpio(dev, bank_name, offset, &flags);
+                               gpio_get_description(dev, bank_name, offset,
+                                                    &flags);
                        } else {
                                for (offset = 0; offset < num_bits; offset++) {
-                                       show_gpio(dev, bank_name, offset,
-                                                 &flags);
+                                       gpio_get_description(dev, bank_name,
+                                                            offset, &flags);
                                }
                        }
                }
index 5a2f411600280acd5ba435762083f8394da61377..4695386a332ab867c12df32e938d4976ce7f0115 100644 (file)
@@ -7,6 +7,7 @@
 
 #include <common.h>
 #include <stdarg.h>
+#include <iomux.h>
 #include <malloc.h>
 #include <os.h>
 #include <serial.h>
@@ -621,7 +622,7 @@ inline void dbg(const char *fmt, ...)
 
 }
 #else
-inline void dbg(const char *fmt, ...)
+static inline void dbg(const char *fmt, ...)
 {
 }
 #endif
index 5a734a9321a9400a73ee8024f29bcdb17d546ee6..749605fe3fa89ab798a0ebde92f1f90e4a40fb2b 100644 (file)
@@ -124,7 +124,7 @@ int env_init(void)
  * The legacy NAND code saved the environment in the first NAND device i.e.,
  * nand_dev_desc + 0. This is also the behaviour using the new NAND code.
  */
-int writeenv(size_t offset, u_char *buf)
+static int writeenv(size_t offset, u_char *buf)
 {
        size_t end = offset + CONFIG_ENV_RANGE;
        size_t amount_saved = 0;
@@ -233,7 +233,7 @@ int saveenv(void)
 }
 #endif /* CMD_SAVEENV */
 
-int readenv(size_t offset, u_char *buf)
+static int readenv(size_t offset, u_char *buf)
 {
        size_t end = offset + CONFIG_ENV_RANGE;
        size_t amount_loaded = 0;
index 2016d1e7dda85a34c5d1c787015bd309ed6061da..a272ea2e83456d9a50018ffb1752b0e2016ddcf7 100644 (file)
@@ -1434,7 +1434,7 @@ void fit_conf_print(const void *fit, int noffset, const char *p)
                printf("%s  FDT:          %s\n", p, uname);
 }
 
-int fit_image_select(const void *fit, int rd_noffset, int verify)
+static int fit_image_select(const void *fit, int rd_noffset, int verify)
 {
        fit_image_print(fit, rd_noffset, "   ");
 
index 94afeb290098dc4b1356496ade659d1985fcd143..e81c074f36c60a92e8223eed055e5b022c697ad8 100644 (file)
@@ -105,12 +105,9 @@ static inline void *menu_item_destroy(struct menu *m,
        return NULL;
 }
 
-void __menu_display_statusline(struct menu *m)
+__weak void menu_display_statusline(struct menu *m)
 {
-       return;
 }
-void menu_display_statusline(struct menu *m)
-       __attribute__ ((weak, alias("__menu_display_statusline")));
 
 /*
  * Display a menu so the user can make a choice of an item. First display its
index be54b1011018192327fdc0bcfd368d7285e0fd44..96b10648d869620ddb3e15a819528de0d29ab2e0 100644 (file)
@@ -19,7 +19,7 @@ static inline void mdm_readline(char *buf, int bufsiz)
        for(;;) {
                c = serial_getc();
 
-               /*              dbg("(%c)", c); */
+               debug("(%c)", c);
 
                switch(c) {
                case '\r':
@@ -40,7 +40,6 @@ static inline void mdm_readline(char *buf, int bufsiz)
        }
 }
 
-extern void  dbg(const char *fmt, ...);
 int mdm_init (void)
 {
        char env_str[16];
@@ -66,15 +65,15 @@ int mdm_init (void)
                        serial_puts("\n");
                        for(;;) {
                                mdm_readline(console_buffer, CONFIG_SYS_CBSIZE);
-                               dbg("ini%d: [%s]", i, console_buffer);
+                               debug("ini%d: [%s]", i, console_buffer);
 
                                if ((strcmp(console_buffer, "OK") == 0) ||
                                        (strcmp(console_buffer, "ERROR") == 0)) {
-                                       dbg("ini%d: cmd done", i);
+                                       debug("ini%d: cmd done", i);
                                        break;
                                } else /* in case we are originating call ... */
                                        if (strncmp(console_buffer, "CONNECT", 7) == 0) {
-                                               dbg("ini%d: connect", i);
+                                               debug("ini%d: connect", i);
                                                return 0;
                                        }
                        }
@@ -90,9 +89,9 @@ int mdm_init (void)
        for(;i > 1;) { /* if 'i' > 1 - wait for connection
                                  message from modem */
                mdm_readline(console_buffer, CONFIG_SYS_CBSIZE);
-               dbg("ini_f: [%s]", console_buffer);
+               debug("ini_f: [%s]", console_buffer);
                if (strncmp(console_buffer, "CONNECT", 7) == 0) {
-                       dbg("ini_f: connected");
+                       debug("ini_f: connected");
                        return 0;
                }
        }
index 82328150cba17ceb382c1ee111595c41b8fbde00..68c595d2d79c292e3ac9b93ae55b0b22bf0e27f0 100644 (file)
@@ -39,39 +39,39 @@ char *stdio_names[MAX_FILES] = { "stdin", "stdout", "stderr" };
 #endif
 
 #ifdef CONFIG_SYS_DEVICE_NULLDEV
-void nulldev_putc(struct stdio_dev *dev, const char c)
+static void nulldev_putc(struct stdio_dev *dev, const char c)
 {
        /* nulldev is empty! */
 }
 
-void nulldev_puts(struct stdio_dev *dev, const char *s)
+static void nulldev_puts(struct stdio_dev *dev, const char *s)
 {
        /* nulldev is empty! */
 }
 
-int nulldev_input(struct stdio_dev *dev)
+static int nulldev_input(struct stdio_dev *dev)
 {
        /* nulldev is empty! */
        return 0;
 }
 #endif
 
-void stdio_serial_putc(struct stdio_dev *dev, const char c)
+static void stdio_serial_putc(struct stdio_dev *dev, const char c)
 {
        serial_putc(c);
 }
 
-void stdio_serial_puts(struct stdio_dev *dev, const char *s)
+static void stdio_serial_puts(struct stdio_dev *dev, const char *s)
 {
        serial_puts(s);
 }
 
-int stdio_serial_getc(struct stdio_dev *dev)
+static int stdio_serial_getc(struct stdio_dev *dev)
 {
        return serial_getc();
 }
 
-int stdio_serial_tstc(struct stdio_dev *dev)
+static int stdio_serial_tstc(struct stdio_dev *dev)
 {
        return serial_tstc();
 }
index 2157537c823056729fef0aae65cffabfe1588b15..00805bdc5b3d9689b069c86c3bf5e67916e6d35a 100644 (file)
--- a/config.mk
+++ b/config.mk
@@ -18,6 +18,8 @@ PLATFORM_LDFLAGS :=
 LDFLAGS :=
 LDFLAGS_FINAL :=
 OBJCOPYFLAGS :=
+# clear VENDOR for tcsh
+VENDOR :=
 #########################################################################
 
 ARCH := $(CONFIG_SYS_ARCH:"%"=%)
index a578c067d4d0dd5dcb39854a1197abdeb24cb86c..2aad834fa840c5b1390c3621442e9ab444240349 100644 (file)
@@ -1,5 +1,8 @@
 CONFIG_SPL=y
 CONFIG_SYS_EXTRA_OPTIONS="A10S_OLINUXINO_M,AXP152_POWER,SUNXI_EMAC,USB_EHCI,SUNXI_USB_VBUS0_GPIO=SUNXI_GPB(10)"
 CONFIG_FDTFILE="sun5i-a10s-olinuxino-micro.dtb"
+CONFIG_MMC_SUNXI_SLOT_EXTRA=1
++S:CONFIG_MMC0_CD_PIN="PG1"
++S:CONFIG_MMC1_CD_PIN="PG13"
 +S:CONFIG_ARM=y
 +S:CONFIG_TARGET_SUN5I=y
diff --git a/configs/A20-OLinuXino-Lime2_defconfig b/configs/A20-OLinuXino-Lime2_defconfig
new file mode 100644 (file)
index 0000000..75ef872
--- /dev/null
@@ -0,0 +1,5 @@
+CONFIG_SPL=y
+CONFIG_SYS_EXTRA_OPTIONS="A20_OLINUXINO_L2,AXP209_POWER,SUNXI_GMAC,RGMII,AHCI,SATAPWR=SUNXI_GPC(3),USB_EHCI"
+CONFIG_FDTFILE="sun7i-a20-olinuxino-lime2.dtb"
++S:CONFIG_ARM=y
++S:CONFIG_TARGET_SUN7I=y
index 20a947ca723adc5e110437dd47914399930ddc0c..0e0a7def2de600f0fc06aaf6898f3644fdd4243e 100644 (file)
@@ -1,5 +1,8 @@
 CONFIG_SPL=y
 CONFIG_SYS_EXTRA_OPTIONS="A20_OLINUXINO_M,AXP209_POWER,SUNXI_GMAC,AHCI,SATAPWR=SUNXI_GPB(8),USB_EHCI"
 CONFIG_FDTFILE="sun7i-a20-olinuxino-micro.dtb"
+CONFIG_MMC_SUNXI_SLOT_EXTRA=3
++S:CONFIG_MMC0_CD_PIN="PH1"
++S:CONFIG_MMC3_CD_PIN="PH11"
 +S:CONFIG_ARM=y
 +S:CONFIG_TARGET_SUN7I=y
diff --git a/configs/Colombus_defconfig b/configs/Colombus_defconfig
new file mode 100644 (file)
index 0000000..16800de
--- /dev/null
@@ -0,0 +1,4 @@
+CONFIG_SYS_EXTRA_OPTIONS="COLOMBUS"
+CONFIG_ARM=y
+CONFIG_TARGET_SUN6I=y
+CONFIG_FDTFILE="sun6i-a31-colombus.dtb"
diff --git a/configs/Ippo_q8h_defconfig b/configs/Ippo_q8h_defconfig
new file mode 100644 (file)
index 0000000..781f137
--- /dev/null
@@ -0,0 +1,4 @@
+CONFIG_SYS_EXTRA_OPTIONS="IPPO_Q8H_V5,CONS_INDEX=5"
+CONFIG_ARM=y
+CONFIG_TARGET_SUN8I=y
+CONFIG_DEFAULT_DEVICE_TREE="sun8i-a23-ippo-q8h-v5.dtb"
diff --git a/configs/Mele_M3_defconfig b/configs/Mele_M3_defconfig
new file mode 100644 (file)
index 0000000..a043ad2
--- /dev/null
@@ -0,0 +1,7 @@
+CONFIG_SPL=y
+CONFIG_SYS_EXTRA_OPTIONS="MELE_M3,AXP209_POWER,SUNXI_GMAC,USB_EHCI"
+CONFIG_FDTFILE="sun7i-a20-m3.dtb"
++S:CONFIG_MMC_SUNXI_SLOT_EXTRA=2
++S:CONFIG_MMC0_CD_PIN="PH1"
++S:CONFIG_ARM=y
++S:CONFIG_TARGET_SUN7I=y
index 38450c0d615c6bb36cf95d1c31d16a29d61e80f4..b631c410dc73414eb83f99349236a2cd5ac6d89b 100644 (file)
@@ -1,4 +1,4 @@
 CONFIG_SPL=y
-CONFIG_SYS_EXTRA_OPTIONS="SERIAL1,CONS_INDEX=1,EMMC_BOOT"
+CONFIG_SYS_EXTRA_OPTIONS="EMMC_BOOT"
 +S:CONFIG_ARM=y
 +S:CONFIG_TARGET_AM335X_EVM=y
index e25714366be5a5b2a7186a97ef640a05e047c0f8..5837a0a4da75bfb9750fcf416194a58977a5ee90 100644 (file)
@@ -1,5 +1,5 @@
 CONFIG_SPL=y
-CONFIG_SYS_EXTRA_OPTIONS="SERIAL1,CONS_INDEX=1,EMMC_BOOT,ENABLE_VBOOT"
+CONFIG_SYS_EXTRA_OPTIONS="EMMC_BOOT,ENABLE_VBOOT"
 +S:CONFIG_ARM=y
 +S:CONFIG_TARGET_AM335X_EVM=y
 CONFIG_OF_CONTROL=y
diff --git a/configs/apalis_t30_defconfig b/configs/apalis_t30_defconfig
new file mode 100644 (file)
index 0000000..fc5e1e4
--- /dev/null
@@ -0,0 +1,5 @@
++S:CONFIG_ARM=y
++S:CONFIG_TEGRA=y
++S:CONFIG_TEGRA30=y
++S:CONFIG_TARGET_APALIS_T30=y
+CONFIG_DEFAULT_DEVICE_TREE="tegra30-apalis"
diff --git a/configs/db-mv784mp-gp_defconfig b/configs/db-mv784mp-gp_defconfig
new file mode 100644 (file)
index 0000000..7aa216c
--- /dev/null
@@ -0,0 +1,2 @@
+CONFIG_ARM=y
+CONFIG_TARGET_DB_MV784MP_GP=y
diff --git a/configs/maxbcm_defconfig b/configs/maxbcm_defconfig
new file mode 100644 (file)
index 0000000..4bcffd8
--- /dev/null
@@ -0,0 +1,2 @@
+CONFIG_ARM=y
+CONFIG_TARGET_MAXBCM=y
index 53f3126e71e43e453d00815e4222de3204e38016..e6aba422f811940b81784c591201b5e743240d4f 100644 (file)
@@ -2,7 +2,10 @@ CONFIG_SPL=y
 +S:CONFIG_ARM=y
 +S:CONFIG_ARCH_UNIPHIER=y
 +S:CONFIG_MACH_PH1_LD4=y
+CONFIG_DM=y
 CONFIG_NAND_DENALI=y
 CONFIG_SYS_NAND_DENALI_64BIT=y
 CONFIG_NAND_DENALI_SPARE_AREA_SKIP_BYTES=8
+CONFIG_DM_SERIAL=y
+CONFIG_UNIPHIER_SERIAL=y
 S:CONFIG_SPL_NAND_DENALI=y
index 209466ebcb334c900e54692ac75993e7e5dbb00d..334ec4bbdff8ff9af4724770dc19d9a66524a711 100644 (file)
@@ -2,7 +2,10 @@ CONFIG_SPL=y
 +S:CONFIG_ARM=y
 +S:CONFIG_ARCH_UNIPHIER=y
 +S:CONFIG_MACH_PH1_PRO4=y
+CONFIG_DM=y
 CONFIG_NAND_DENALI=y
 CONFIG_SYS_NAND_DENALI_64BIT=y
 CONFIG_NAND_DENALI_SPARE_AREA_SKIP_BYTES=8
+CONFIG_DM_SERIAL=y
+CONFIG_UNIPHIER_SERIAL=y
 S:CONFIG_SPL_NAND_DENALI=y
index 658977bcf6293f8b58e358c1c2bc8d75d0050342..4e8f354c9b596a30fe5eba2429477e1ef0d9b17a 100644 (file)
@@ -2,7 +2,10 @@ CONFIG_SPL=y
 +S:CONFIG_ARM=y
 +S:CONFIG_ARCH_UNIPHIER=y
 +S:CONFIG_MACH_PH1_SLD8=y
+CONFIG_DM=y
 CONFIG_NAND_DENALI=y
 CONFIG_SYS_NAND_DENALI_64BIT=y
 CONFIG_NAND_DENALI_SPARE_AREA_SKIP_BYTES=8
+CONFIG_DM_SERIAL=y
+CONFIG_UNIPHIER_SERIAL=y
 S:CONFIG_SPL_NAND_DENALI=y
index cfd77b0ff567cbacd4f5a3e6223e2edeb28fbd69..43485c9148b0f404e91cb0f45f9a3c76b2267578 100644 (file)
@@ -57,7 +57,7 @@ static const struct block_drvr block_drvr[] = {
 DECLARE_GLOBAL_DATA_PTR;
 
 #ifdef HAVE_BLOCK_DEVICE
-block_dev_desc_t *get_dev_hwpart(const char *ifname, int dev, int hwpart)
+static block_dev_desc_t *get_dev_hwpart(const char *ifname, int dev, int hwpart)
 {
        const struct block_drvr *drvr = block_drvr;
        block_dev_desc_t* (*reloc_get_dev)(int dev);
index 8dfcf75c3d369219b8cbc15782723013b94b0129..0278dda4d77045a7dbcc8400b1d5593252b4f514 100644 (file)
@@ -95,7 +95,7 @@ are provided in test/dm. To run them, try:
 You should see something like this:
 
     <...U-Boot banner...>
-    Running 22 driver model tests
+    Running 29 driver model tests
     Test: dm_test_autobind
     Test: dm_test_autoprobe
     Test: dm_test_bus_children
@@ -115,7 +115,12 @@ You should see something like this:
     Device 'd-test': seq 3 is in use by 'b-test'
     Device 'a-test': seq 0 is in use by 'd-test'
     Test: dm_test_gpio
-    sandbox_gpio: sb_gpio_get_value: error: offset 4 not reserved
+    extra-gpios: get_value: error: gpio b5 not reserved
+    Test: dm_test_gpio_anon
+    Test: dm_test_gpio_copy
+    Test: dm_test_gpio_leak
+    extra-gpios: get_value: error: gpio b5 not reserved
+    Test: dm_test_gpio_requestf
     Test: dm_test_leak
     Test: dm_test_lifecycle
     Test: dm_test_operations
@@ -123,6 +128,26 @@ You should see something like this:
     Test: dm_test_platdata
     Test: dm_test_pre_reloc
     Test: dm_test_remove
+    Test: dm_test_spi_find
+    Invalid chip select 0:0 (err=-19)
+    SF: Failed to get idcodes
+    Device 'name-emul': seq 0 is in use by 'name-emul'
+    SF: Detected M25P16 with page size 256 Bytes, erase size 64 KiB, total 2 MiB
+    Test: dm_test_spi_flash
+    2097152 bytes written in 0 ms
+    SF: Detected M25P16 with page size 256 Bytes, erase size 64 KiB, total 2 MiB
+    SPI flash test:
+    0 erase: 0 ticks, 65536000 KiB/s 524288.000 Mbps
+    1 check: 0 ticks, 65536000 KiB/s 524288.000 Mbps
+    2 write: 0 ticks, 65536000 KiB/s 524288.000 Mbps
+    3 read: 0 ticks, 65536000 KiB/s 524288.000 Mbps
+    Test passed
+    0 erase: 0 ticks, 65536000 KiB/s 524288.000 Mbps
+    1 check: 0 ticks, 65536000 KiB/s 524288.000 Mbps
+    2 write: 0 ticks, 65536000 KiB/s 524288.000 Mbps
+    3 read: 0 ticks, 65536000 KiB/s 524288.000 Mbps
+    Test: dm_test_spi_xfer
+    SF: Detected M25P16 with page size 256 Bytes, erase size 64 KiB, total 2 MiB
     Test: dm_test_uclass
     Test: dm_test_uclass_before_ready
     Failures: 0
index 574bc40b10e138a09200b8e3187d5295696b485f..e54d564bf764d0a6015bf84fc1c6cfd3999eeacd 100644 (file)
@@ -12,7 +12,7 @@
 #if defined(CONFIG_ORION5X)
 #include <asm/arch/orion5x.h>
 #elif defined(CONFIG_KIRKWOOD)
-#include <asm/arch/kirkwood.h>
+#include <asm/arch/soc.h>
 #endif
 
 /* SATA port registers */
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..d2799dc861ff5a661ff6717c985285f263ebd1e9 100644 (file)
@@ -0,0 +1,6 @@
+config DM
+       bool "Enable Driver Model"
+       depends on !SPL_BUILD
+       help
+         This config option enables Driver Model.
+         To use legacy drivers, say N.
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..d21302f8da95316cdf7891556a73bb0de576b8e1 100644 (file)
@@ -0,0 +1,6 @@
+config DM_GPIO
+       bool "Enable Driver Model for GPIO drivers"
+       depends on DM
+       help
+         If you want to use driver model for GPIO drivers, say Y.
+         To use legacy GPIO drivers, say N.
index 332cfc2b231835ca7c4ffd9f0ead44b2a8351730..0244c01882863903596f76f153a11cbbaf98dc3e 100644 (file)
 #include <asm/gpio.h>
 #include <asm/io.h>
 
-#define GPIO_NAME_SIZE         20
-
 struct bcm2835_gpios {
-       char label[BCM2835_GPIO_COUNT][GPIO_NAME_SIZE];
        struct bcm2835_gpio_regs *reg;
 };
 
-/**
- * gpio_is_requested() - check if a GPIO has been requested
- *
- * @bank:      Bank to check
- * @offset:    GPIO offset within bank to check
- * @return true if marked as requested, false if not
- */
-static inline bool gpio_is_requested(struct bcm2835_gpios *gpios, int offset)
-{
-       return *gpios->label[offset] != '\0';
-}
-
-static int check_requested(struct udevice *dev, unsigned offset,
-                          const char *func)
-{
-       struct bcm2835_gpios *gpios = dev_get_priv(dev);
-       struct gpio_dev_priv *uc_priv = dev->uclass_priv;
-
-       if (!gpio_is_requested(gpios, offset)) {
-               printf("omap_gpio: %s: error: gpio %s%d not requested\n",
-                      func, uc_priv->bank_name, offset);
-               return -EPERM;
-       }
-
-       return 0;
-}
-
-static int bcm2835_gpio_request(struct udevice *dev, unsigned offset,
-                               const char *label)
-{
-       struct bcm2835_gpios *gpios = dev_get_priv(dev);
-
-       if (gpio_is_requested(gpios, offset))
-               return -EBUSY;
-
-       strncpy(gpios->label[offset], label, GPIO_NAME_SIZE);
-       gpios->label[offset][GPIO_NAME_SIZE - 1] = '\0';
-
-       return 0;
-}
-
-static int bcm2835_gpio_free(struct udevice *dev, unsigned offset)
-{
-       struct bcm2835_gpios *gpios = dev_get_priv(dev);
-       int ret;
-
-       ret = check_requested(dev, offset, __func__);
-       if (ret)
-               return ret;
-       gpios->label[offset][0] = '\0';
-
-       return 0;
-}
-
 static int bcm2835_gpio_direction_input(struct udevice *dev, unsigned gpio)
 {
        struct bcm2835_gpios *gpios = dev_get_priv(dev);
@@ -142,9 +85,6 @@ static int bcm2835_gpio_get_function(struct udevice *dev, unsigned offset)
 {
        struct bcm2835_gpios *gpios = dev_get_priv(dev);
 
-       if (!gpio_is_requested(gpios, offset))
-               return GPIOF_UNUSED;
-
        /* GPIOF_FUNC is not implemented yet */
        if (bcm2835_gpio_is_output(gpios, offset))
                return GPIOF_OUTPUT;
@@ -152,42 +92,13 @@ static int bcm2835_gpio_get_function(struct udevice *dev, unsigned offset)
                return GPIOF_INPUT;
 }
 
-static int bcm2835_gpio_get_state(struct udevice *dev, unsigned int offset,
-                                 char *buf, int bufsize)
-{
-       struct gpio_dev_priv *uc_priv = dev->uclass_priv;
-       struct bcm2835_gpios *gpios = dev_get_priv(dev);
-       const char *label;
-       bool requested;
-       bool is_output;
-       int size;
-
-       label = gpios->label[offset];
-       is_output = bcm2835_gpio_is_output(gpios, offset);
-       size = snprintf(buf, bufsize, "%s%d: ",
-                       uc_priv->bank_name ? uc_priv->bank_name : "", offset);
-       buf += size;
-       bufsize -= size;
-       requested = gpio_is_requested(gpios, offset);
-       snprintf(buf, bufsize, "%s: %d [%c]%s%s",
-                is_output ? "out" : " in",
-                bcm2835_get_value(gpios, offset),
-                requested ? 'x' : ' ',
-                requested ? " " : "",
-                label);
-
-       return 0;
-}
 
 static const struct dm_gpio_ops gpio_bcm2835_ops = {
-       .request                = bcm2835_gpio_request,
-       .free                   = bcm2835_gpio_free,
        .direction_input        = bcm2835_gpio_direction_input,
        .direction_output       = bcm2835_gpio_direction_output,
        .get_value              = bcm2835_gpio_get_value,
        .set_value              = bcm2835_gpio_set_value,
        .get_function           = bcm2835_gpio_get_function,
-       .get_state              = bcm2835_gpio_get_state,
 };
 
 static int bcm2835_gpio_probe(struct udevice *dev)
index f1bbc587961709dec3922c52c76585227acecd9b..45e9a5ad2278378814b7351c5d70dd5c53fbf287 100644 (file)
@@ -7,7 +7,9 @@
 #include <common.h>
 #include <dm.h>
 #include <errno.h>
+#include <malloc.h>
 #include <asm/gpio.h>
+#include <linux/ctype.h>
 
 /**
  * gpio_to_device() - Convert global GPIO number to device, number
@@ -43,35 +45,47 @@ static int gpio_to_device(unsigned int gpio, struct udevice **devp,
 int gpio_lookup_name(const char *name, struct udevice **devp,
                     unsigned int *offsetp, unsigned int *gpiop)
 {
-       struct gpio_dev_priv *uc_priv;
+       struct gpio_dev_priv *uc_priv = NULL;
        struct udevice *dev;
+       ulong offset;
+       int numeric;
        int ret;
 
        if (devp)
                *devp = NULL;
+       numeric = isdigit(*name) ? simple_strtoul(name, NULL, 10) : -1;
        for (ret = uclass_first_device(UCLASS_GPIO, &dev);
             dev;
             ret = uclass_next_device(&dev)) {
-               ulong offset;
                int len;
 
                uc_priv = dev->uclass_priv;
+               if (numeric != -1) {
+                       offset = numeric - uc_priv->gpio_base;
+                       /* Allow GPIOs to be numbered from 0 */
+                       if (offset >= 0 && offset < uc_priv->gpio_count)
+                               break;
+               }
+
                len = uc_priv->bank_name ? strlen(uc_priv->bank_name) : 0;
 
                if (!strncasecmp(name, uc_priv->bank_name, len)) {
-                       if (strict_strtoul(name + len, 10, &offset))
-                               continue;
-                       if (devp)
-                               *devp = dev;
-                       if (offsetp)
-                               *offsetp = offset;
-                       if (gpiop)
-                               *gpiop = uc_priv->gpio_base + offset;
-                       return 0;
+                       if (!strict_strtoul(name + len, 10, &offset))
+                               break;
                }
        }
 
-       return ret ? ret : -EINVAL;
+       if (!dev)
+               return ret ? ret : -EINVAL;
+
+       if (devp)
+               *devp = dev;
+       if (offsetp)
+               *offsetp = offset;
+       if (gpiop)
+               *gpiop = uc_priv->gpio_base + offset;
+
+       return 0;
 }
 
 /**
@@ -79,24 +93,62 @@ int gpio_lookup_name(const char *name, struct udevice **devp,
  * gpio:       GPIO number
  * label:      Name for the requested GPIO
  *
+ * The label is copied and allocated so the caller does not need to keep
+ * the pointer around.
+ *
  * 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_request(unsigned gpio, const char *label)
 {
+       struct gpio_dev_priv *uc_priv;
        unsigned int offset;
        struct udevice *dev;
+       char *str;
        int ret;
 
        ret = gpio_to_device(gpio, &dev, &offset);
        if (ret)
                return ret;
 
-       if (!gpio_get_ops(dev)->request)
-               return 0;
+       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;
+}
+
+/**
+ * gpio_requestf() - [COMPAT] Request GPIO
+ * @gpio:      GPIO number
+ * @fmt:       Format string for the requested GPIO
+ * @...:       Arguments for the printf() format string
+ *
+ * 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_requestf(unsigned gpio, const char *fmt, ...)
+{
+       va_list args;
+       char buf[40];
 
-       return gpio_get_ops(dev)->request(dev, offset, label);
+       va_start(args, fmt);
+       vscnprintf(buf, sizeof(buf), fmt, args);
+       va_end(args);
+       return gpio_request(gpio, buf);
 }
 
 /**
@@ -109,6 +161,7 @@ int gpio_request(unsigned gpio, const char *label)
  */
 int gpio_free(unsigned gpio)
 {
+       struct gpio_dev_priv *uc_priv;
        unsigned int offset;
        struct udevice *dev;
        int ret;
@@ -117,9 +170,34 @@ int gpio_free(unsigned gpio)
        if (ret)
                return ret;
 
-       if (!gpio_get_ops(dev)->free)
-               return 0;
-       return gpio_get_ops(dev)->free(dev, offset);
+       uc_priv = dev->uclass_priv;
+       if (!uc_priv->name[offset])
+               return -ENXIO;
+       if (gpio_get_ops(dev)->free) {
+               ret = gpio_get_ops(dev)->free(dev, offset);
+               if (ret)
+                       return ret;
+       }
+
+       free(uc_priv->name[offset]);
+       uc_priv->name[offset] = NULL;
+
+       return 0;
+}
+
+static int check_reserved(struct udevice *dev, unsigned offset,
+                         const char *func)
+{
+       struct gpio_dev_priv *uc_priv = dev->uclass_priv;
+
+       if (!uc_priv->name[offset]) {
+               printf("%s: %s: error: gpio %s%d not reserved\n",
+                      dev->name, func,
+                      uc_priv->bank_name ? uc_priv->bank_name : "", offset);
+               return -EBUSY;
+       }
+
+       return 0;
 }
 
 /**
@@ -139,8 +217,9 @@ int gpio_direction_input(unsigned gpio)
        ret = gpio_to_device(gpio, &dev, &offset);
        if (ret)
                return ret;
+       ret = check_reserved(dev, offset, "dir_input");
 
-       return gpio_get_ops(dev)->direction_input(dev, offset);
+       return ret ? ret : gpio_get_ops(dev)->direction_input(dev, offset);
 }
 
 /**
@@ -161,8 +240,10 @@ int gpio_direction_output(unsigned gpio, int value)
        ret = gpio_to_device(gpio, &dev, &offset);
        if (ret)
                return ret;
+       ret = check_reserved(dev, offset, "dir_output");
 
-       return gpio_get_ops(dev)->direction_output(dev, offset, value);
+       return ret ? ret :
+               gpio_get_ops(dev)->direction_output(dev, offset, value);
 }
 
 /**
@@ -183,8 +264,9 @@ int gpio_get_value(unsigned gpio)
        ret = gpio_to_device(gpio, &dev, &offset);
        if (ret)
                return ret;
+       ret = check_reserved(dev, offset, "get_value");
 
-       return gpio_get_ops(dev)->get_value(dev, offset);
+       return ret ? ret : gpio_get_ops(dev)->get_value(dev, offset);
 }
 
 /**
@@ -205,8 +287,9 @@ int gpio_set_value(unsigned gpio, int value)
        ret = gpio_to_device(gpio, &dev, &offset);
        if (ret)
                return ret;
+       ret = check_reserved(dev, offset, "set_value");
 
-       return gpio_get_ops(dev)->set_value(dev, offset, value);
+       return ret ? ret : gpio_get_ops(dev)->set_value(dev, offset, value);
 }
 
 const char *gpio_get_bank_info(struct udevice *dev, int *bit_count)
@@ -221,8 +304,94 @@ const char *gpio_get_bank_info(struct udevice *dev, int *bit_count)
        return priv->bank_name;
 }
 
+static const char * const gpio_function[GPIOF_COUNT] = {
+       "input",
+       "output",
+       "unused",
+       "unknown",
+       "func",
+};
+
+int get_function(struct udevice *dev, int offset, bool skip_unused,
+                const char **namep)
+{
+       struct gpio_dev_priv *uc_priv = dev->uclass_priv;
+       struct dm_gpio_ops *ops = gpio_get_ops(dev);
+
+       BUILD_BUG_ON(GPIOF_COUNT != ARRAY_SIZE(gpio_function));
+       if (!device_active(dev))
+               return -ENODEV;
+       if (offset < 0 || offset >= uc_priv->gpio_count)
+               return -EINVAL;
+       if (namep)
+               *namep = uc_priv->name[offset];
+       if (skip_unused && !uc_priv->name[offset])
+               return GPIOF_UNUSED;
+       if (ops->get_function) {
+               int ret;
+
+               ret = ops->get_function(dev, offset);
+               if (ret < 0)
+                       return ret;
+               if (ret >= ARRAY_SIZE(gpio_function))
+                       return -ENODATA;
+               return ret;
+       }
+
+       return GPIOF_UNKNOWN;
+}
+
+int gpio_get_function(struct udevice *dev, int offset, const char **namep)
+{
+       return get_function(dev, offset, true, namep);
+}
+
+int gpio_get_raw_function(struct udevice *dev, int offset, const char **namep)
+{
+       return get_function(dev, offset, false, namep);
+}
+
+int gpio_get_status(struct udevice *dev, int offset, char *buf, int buffsize)
+{
+       struct dm_gpio_ops *ops = gpio_get_ops(dev);
+       struct gpio_dev_priv *priv;
+       char *str = buf;
+       int func;
+       int ret;
+       int len;
+
+       BUILD_BUG_ON(GPIOF_COUNT != ARRAY_SIZE(gpio_function));
+
+       *buf = 0;
+       priv = dev->uclass_priv;
+       ret = gpio_get_raw_function(dev, offset, NULL);
+       if (ret < 0)
+               return ret;
+       func = ret;
+       len = snprintf(str, buffsize, "%s%d: %s",
+                      priv->bank_name ? priv->bank_name : "",
+                      offset, gpio_function[func]);
+       if (func == GPIOF_INPUT || func == GPIOF_OUTPUT ||
+           func == GPIOF_UNUSED) {
+               const char *label;
+               bool used;
+
+               ret = ops->get_value(dev, offset);
+               if (ret < 0)
+                       return ret;
+               used = gpio_get_function(dev, offset, &label) != GPIOF_UNUSED;
+               snprintf(str + len, buffsize - len, ": %d [%c]%s%s",
+                        ret,
+                        used ? 'x' : ' ',
+                        used ? " " : "",
+                        label ? label : "");
+       }
+
+       return 0;
+}
+
 /* We need to renumber the GPIOs when any driver is probed/removed */
-static int gpio_renumber(void)
+static int gpio_renumber(struct udevice *removed_dev)
 {
        struct gpio_dev_priv *uc_priv;
        struct udevice *dev;
@@ -237,7 +406,7 @@ static int gpio_renumber(void)
        /* Ensure that we have a base for each bank */
        base = 0;
        uclass_foreach_dev(dev, uc) {
-               if (device_active(dev)) {
+               if (device_active(dev) && dev != removed_dev) {
                        uc_priv = dev->uclass_priv;
                        uc_priv->gpio_base = base;
                        base += uc_priv->gpio_count;
@@ -249,12 +418,27 @@ static int gpio_renumber(void)
 
 static int gpio_post_probe(struct udevice *dev)
 {
-       return gpio_renumber();
+       struct gpio_dev_priv *uc_priv = dev->uclass_priv;
+
+       uc_priv->name = calloc(uc_priv->gpio_count, sizeof(char *));
+       if (!uc_priv->name)
+               return -ENOMEM;
+
+       return gpio_renumber(NULL);
 }
 
 static int gpio_pre_remove(struct udevice *dev)
 {
-       return gpio_renumber();
+       struct gpio_dev_priv *uc_priv = dev->uclass_priv;
+       int i;
+
+       for (i = 0; i < uc_priv->gpio_count; i++) {
+               if (uc_priv->name[i])
+                       free(uc_priv->name[i]);
+       }
+       free(uc_priv->name);
+
+       return gpio_renumber(dev);
 }
 
 UCLASS_DRIVER(gpio) = {
index 7d9fac72337fc329ac12d2c80ad21f03b9e8fe7e..d3381b0369c1a4122f30c0e80aecd154d4e4e896 100644 (file)
  */
 
 #include <common.h>
+#include <dm.h>
+#include <errno.h>
+#include <fdtdec.h>
 #include <pci.h>
 #include <asm/gpio.h>
 #include <asm/io.h>
 
+#define GPIO_PER_BANK  32
+
 /* Where in config space is the register that points to the GPIO registers? */
 #define PCI_CFG_GPIOBASE 0x48
 
-#define NUM_BANKS 3
-
-/* Within the I/O space, where are the registers to control the GPIOs? */
-static struct {
-       u8 use_sel;
-       u8 io_sel;
-       u8 lvl;
-} gpio_bank[NUM_BANKS] = {
-       { 0x00, 0x04, 0x0c },           /* Bank 0 */
-       { 0x30, 0x34, 0x38 },           /* Bank 1 */
-       { 0x40, 0x44, 0x48 }            /* Bank 2 */
+struct ich6_bank_priv {
+       /* These are I/O addresses */
+       uint32_t use_sel;
+       uint32_t io_sel;
+       uint32_t lvl;
 };
 
-static pci_dev_t dev;                  /* handle for 0:1f:0 */
-static u32 gpiobase;                   /* offset into I/O space */
-static int found_it_once;              /* valid GPIO device? */
-static u32 lock[NUM_BANKS];            /* "lock" for access to pins */
-
-static int bad_arg(int num, int *bank, int *bitnum)
-{
-       int i = num / 32;
-       int j = num % 32;
-
-       if (num < 0 || i > NUM_BANKS) {
-               debug("%s: bogus gpio num: %d\n", __func__, num);
-               return -1;
-       }
-       *bank = i;
-       *bitnum = j;
-       return 0;
-}
-
-static int mark_gpio(int bank, int bitnum)
-{
-       if (lock[bank] & (1UL << bitnum)) {
-               debug("%s: %d.%d already marked\n", __func__, bank, bitnum);
-               return -1;
-       }
-       lock[bank] |= (1 << bitnum);
-       return 0;
-}
-
-static void clear_gpio(int bank, int bitnum)
-{
-       lock[bank] &= ~(1 << bitnum);
-}
-
-static int notmine(int num, int *bank, int *bitnum)
-{
-       if (bad_arg(num, bank, bitnum))
-               return -1;
-       return !(lock[*bank] & (1UL << *bitnum));
-}
-
-static int gpio_init(void)
+static int gpio_ich6_ofdata_to_platdata(struct udevice *dev)
 {
+       struct ich6_bank_platdata *plat = dev_get_platdata(dev);
+       pci_dev_t pci_dev;                      /* handle for 0:1f:0 */
        u8 tmpbyte;
        u16 tmpword;
        u32 tmplong;
-
-       /* Have we already done this? */
-       if (found_it_once)
-               return 0;
+       u32 gpiobase;
+       int offset;
 
        /* Where should it be? */
-       dev = PCI_BDF(0, 0x1f, 0);
+       pci_dev = PCI_BDF(0, 0x1f, 0);
 
        /* Is the device present? */
-       pci_read_config_word(dev, PCI_VENDOR_ID, &tmpword);
+       pci_read_config_word(pci_dev, PCI_VENDOR_ID, &tmpword);
        if (tmpword != PCI_VENDOR_ID_INTEL) {
                debug("%s: wrong VendorID\n", __func__);
-               return -1;
+               return -ENODEV;
        }
 
-       pci_read_config_word(dev, PCI_DEVICE_ID, &tmpword);
+       pci_read_config_word(pci_dev, PCI_DEVICE_ID, &tmpword);
        debug("Found %04x:%04x\n", PCI_VENDOR_ID_INTEL, tmpword);
        /*
         * We'd like to validate the Device ID too, but pretty much any
@@ -118,37 +76,37 @@ static int gpio_init(void)
         */
 
        /* I/O should already be enabled (it's a RO bit). */
-       pci_read_config_word(dev, PCI_COMMAND, &tmpword);
+       pci_read_config_word(pci_dev, PCI_COMMAND, &tmpword);
        if (!(tmpword & PCI_COMMAND_IO)) {
                debug("%s: device IO not enabled\n", __func__);
-               return -1;
+               return -ENODEV;
        }
 
        /* Header Type must be normal (bits 6-0 only; see spec.) */
-       pci_read_config_byte(dev, PCI_HEADER_TYPE, &tmpbyte);
+       pci_read_config_byte(pci_dev, PCI_HEADER_TYPE, &tmpbyte);
        if ((tmpbyte & 0x7f) != PCI_HEADER_TYPE_NORMAL) {
                debug("%s: invalid Header type\n", __func__);
-               return -1;
+               return -ENODEV;
        }
 
        /* Base Class must be a bridge device */
-       pci_read_config_byte(dev, PCI_CLASS_CODE, &tmpbyte);
+       pci_read_config_byte(pci_dev, PCI_CLASS_CODE, &tmpbyte);
        if (tmpbyte != PCI_CLASS_CODE_BRIDGE) {
                debug("%s: invalid class\n", __func__);
-               return -1;
+               return -ENODEV;
        }
        /* Sub Class must be ISA */
-       pci_read_config_byte(dev, PCI_CLASS_SUB_CODE, &tmpbyte);
+       pci_read_config_byte(pci_dev, PCI_CLASS_SUB_CODE, &tmpbyte);
        if (tmpbyte != PCI_CLASS_SUB_CODE_BRIDGE_ISA) {
                debug("%s: invalid subclass\n", __func__);
-               return -1;
+               return -ENODEV;
        }
 
        /* Programming Interface must be 0x00 (no others exist) */
-       pci_read_config_byte(dev, PCI_CLASS_PROG, &tmpbyte);
+       pci_read_config_byte(pci_dev, PCI_CLASS_PROG, &tmpbyte);
        if (tmpbyte != 0x00) {
                debug("%s: invalid interface type\n", __func__);
-               return -1;
+               return -ENODEV;
        }
 
        /*
@@ -156,11 +114,11 @@ static int gpio_init(void)
         * that it was unused (or undocumented). Check that it looks
         * okay: not all ones or zeros, and mapped to I/O space (bit 0).
         */
-       pci_read_config_dword(dev, PCI_CFG_GPIOBASE, &tmplong);
+       pci_read_config_dword(pci_dev, PCI_CFG_GPIOBASE, &tmplong);
        if (tmplong == 0x00000000 || tmplong == 0xffffffff ||
            !(tmplong & 0x00000001)) {
                debug("%s: unexpected GPIOBASE value\n", __func__);
-               return -1;
+               return -ENODEV;
        }
 
        /*
@@ -170,105 +128,137 @@ static int gpio_init(void)
         * an I/O address, not a memory address, so mask that off.
         */
        gpiobase = tmplong & 0xfffffffe;
+       offset = fdtdec_get_int(gd->fdt_blob, dev->of_offset, "reg", -1);
+       if (offset == -1) {
+               debug("%s: Invalid register offset %d\n", __func__, offset);
+               return -EINVAL;
+       }
+       plat->base_addr = gpiobase + offset;
+       plat->bank_name = fdt_getprop(gd->fdt_blob, dev->of_offset,
+                                     "bank-name", NULL);
 
-       /* Finally. These are the droids we're looking for. */
-       found_it_once = 1;
        return 0;
 }
 
-int gpio_request(unsigned num, const char *label /* UNUSED */)
+int ich6_gpio_probe(struct udevice *dev)
 {
-       u32 tmplong;
-       int i = 0, j = 0;
+       struct ich6_bank_platdata *plat = dev_get_platdata(dev);
+       struct gpio_dev_priv *uc_priv = dev->uclass_priv;
+       struct ich6_bank_priv *bank = dev_get_priv(dev);
+
+       uc_priv->gpio_count = GPIO_PER_BANK;
+       uc_priv->bank_name = plat->bank_name;
+       bank->use_sel = plat->base_addr;
+       bank->io_sel = plat->base_addr + 4;
+       bank->lvl = plat->base_addr + 8;
 
-       /* Is the hardware ready? */
-       if (gpio_init())
-               return -1;
+       return 0;
+}
 
-       if (bad_arg(num, &i, &j))
-               return -1;
+int ich6_gpio_request(struct udevice *dev, unsigned offset, const char *label)
+{
+       struct ich6_bank_priv *bank = dev_get_priv(dev);
+       u32 tmplong;
 
        /*
         * Make sure that the GPIO pin we want isn't already in use for some
         * built-in hardware function. We have to check this for every
         * requested pin.
         */
-       tmplong = inl(gpiobase + gpio_bank[i].use_sel);
-       if (!(tmplong & (1UL << j))) {
+       tmplong = inl(bank->use_sel);
+       if (!(tmplong & (1UL << offset))) {
                debug("%s: gpio %d is reserved for internal use\n", __func__,
-                     num);
-               return -1;
+                     offset);
+               return -EPERM;
        }
 
-       return mark_gpio(i, j);
-}
-
-int gpio_free(unsigned num)
-{
-       int i = 0, j = 0;
-
-       if (notmine(num, &i, &j))
-               return -1;
-
-       clear_gpio(i, j);
        return 0;
 }
 
-int gpio_direction_input(unsigned num)
+static int ich6_gpio_direction_input(struct udevice *dev, unsigned offset)
 {
+       struct ich6_bank_priv *bank = dev_get_priv(dev);
        u32 tmplong;
-       int i = 0, j = 0;
-
-       if (notmine(num, &i, &j))
-               return -1;
 
-       tmplong = inl(gpiobase + gpio_bank[i].io_sel);
-       tmplong |= (1UL << j);
-       outl(gpiobase + gpio_bank[i].io_sel, tmplong);
+       tmplong = inl(bank->io_sel);
+       tmplong |= (1UL << offset);
+       outl(bank->io_sel, tmplong);
        return 0;
 }
 
-int gpio_direction_output(unsigned num, int value)
+static int ich6_gpio_direction_output(struct udevice *dev, unsigned offset,
+                                      int value)
 {
+       struct ich6_bank_priv *bank = dev_get_priv(dev);
        u32 tmplong;
-       int i = 0, j = 0;
 
-       if (notmine(num, &i, &j))
-               return -1;
-
-       tmplong = inl(gpiobase + gpio_bank[i].io_sel);
-       tmplong &= ~(1UL << j);
-       outl(gpiobase + gpio_bank[i].io_sel, tmplong);
+       tmplong = inl(bank->io_sel);
+       tmplong &= ~(1UL << offset);
+       outl(bank->io_sel, tmplong);
        return 0;
 }
 
-int gpio_get_value(unsigned num)
+static int ich6_gpio_get_value(struct udevice *dev, unsigned offset)
+
 {
+       struct ich6_bank_priv *bank = dev_get_priv(dev);
        u32 tmplong;
-       int i = 0, j = 0;
        int r;
 
-       if (notmine(num, &i, &j))
-               return -1;
-
-       tmplong = inl(gpiobase + gpio_bank[i].lvl);
-       r = (tmplong & (1UL << j)) ? 1 : 0;
+       tmplong = inl(bank->lvl);
+       r = (tmplong & (1UL << offset)) ? 1 : 0;
        return r;
 }
 
-int gpio_set_value(unsigned num, int value)
+static int ich6_gpio_set_value(struct udevice *dev, unsigned offset,
+                              int value)
 {
+       struct ich6_bank_priv *bank = dev_get_priv(dev);
        u32 tmplong;
-       int i = 0, j = 0;
 
-       if (notmine(num, &i, &j))
-               return -1;
-
-       tmplong = inl(gpiobase + gpio_bank[i].lvl);
+       tmplong = inl(bank->lvl);
        if (value)
-               tmplong |= (1UL << j);
+               tmplong |= (1UL << offset);
        else
-               tmplong &= ~(1UL << j);
-       outl(gpiobase + gpio_bank[i].lvl, tmplong);
+               tmplong &= ~(1UL << offset);
+       outl(bank->lvl, tmplong);
        return 0;
 }
+
+static int ich6_gpio_get_function(struct udevice *dev, unsigned offset)
+{
+       struct ich6_bank_priv *bank = dev_get_priv(dev);
+       u32 mask = 1UL << offset;
+
+       if (!(inl(bank->use_sel) & mask))
+               return GPIOF_FUNC;
+       if (inl(bank->io_sel) & mask)
+               return GPIOF_INPUT;
+       else
+               return GPIOF_OUTPUT;
+}
+
+static const struct dm_gpio_ops gpio_ich6_ops = {
+       .request                = ich6_gpio_request,
+       .direction_input        = ich6_gpio_direction_input,
+       .direction_output       = ich6_gpio_direction_output,
+       .get_value              = ich6_gpio_get_value,
+       .set_value              = ich6_gpio_set_value,
+       .get_function           = ich6_gpio_get_function,
+};
+
+static const struct udevice_id intel_ich6_gpio_ids[] = {
+       { .compatible = "intel,ich6-gpio" },
+       { }
+};
+
+U_BOOT_DRIVER(gpio_ich6) = {
+       .name   = "gpio_ich6",
+       .id     = UCLASS_GPIO,
+       .of_match = intel_ich6_gpio_ids,
+       .ops    = &gpio_ich6_ops,
+       .ofdata_to_platdata     = gpio_ich6_ofdata_to_platdata,
+       .probe  = ich6_gpio_probe,
+       .priv_auto_alloc_size = sizeof(struct ich6_bank_priv),
+       .platdata_auto_alloc_size = sizeof(struct ich6_bank_platdata),
+};
index 0af75a84ea7ab6ea5251549d43d40bbed96e40f2..43b27e3fea1bc86f5fbef46f969a7f8ff0322286 100644 (file)
@@ -16,7 +16,7 @@
 #include <common.h>
 #include <asm/bitops.h>
 #include <asm/io.h>
-#include <asm/arch/kirkwood.h>
+#include <asm/arch/soc.h>
 #include <asm/arch/gpio.h>
 
 static unsigned long gpio_valid_input[BITS_TO_LONGS(GPIO_MAX)];
@@ -36,7 +36,7 @@ void __set_direction(unsigned pin, int input)
        u = readl(GPIO_IO_CONF(pin));
 }
 
-void __set_level(unsigned pin, int high)
+static void __set_level(unsigned pin, int high)
 {
        u32 u;
 
@@ -48,7 +48,7 @@ void __set_level(unsigned pin, int high)
        writel(u, GPIO_OUT(pin));
 }
 
-void __set_blinking(unsigned pin, int blink)
+static void __set_blinking(unsigned pin, int blink)
 {
        u32 u;
 
index 3f7b7d24416b4bb59b31f9d4a02fe3c41039ac20..8bb9e39b7231e522f87eaf9612ad5abf383931e7 100644 (file)
@@ -20,7 +20,6 @@ enum mxc_gpio_direction {
        MXC_GPIO_DIRECTION_OUT,
 };
 
-#define GPIO_NAME_SIZE                 20
 #define GPIO_PER_BANK                  32
 
 struct mxc_gpio_plat {
@@ -28,7 +27,6 @@ struct mxc_gpio_plat {
 };
 
 struct mxc_bank_info {
-       char label[GPIO_PER_BANK][GPIO_NAME_SIZE];
        struct gpio_regs *regs;
 };
 
@@ -152,18 +150,6 @@ int gpio_direction_output(unsigned gpio, int value)
 #endif
 
 #ifdef CONFIG_DM_GPIO
-/**
- * gpio_is_requested() - check if a GPIO has been requested
- *
- * @bank:      Bank to check
- * @offset:    GPIO offset within bank to check
- * @return true if marked as requested, false if not
- */
-static inline bool gpio_is_requested(struct mxc_bank_info *bank, int offset)
-{
-       return *bank->label[offset] != '\0';
-}
-
 static int mxc_gpio_is_output(struct gpio_regs *regs, int offset)
 {
        u32 val;
@@ -208,35 +194,10 @@ static int mxc_gpio_bank_get_value(struct gpio_regs *regs, int offset)
        return (readl(&regs->gpio_psr) >> offset) & 0x01;
 }
 
-static int mxc_gpio_bank_get_output_value(struct gpio_regs *regs, int offset)
-{
-       return (readl(&regs->gpio_dr) >> offset) & 0x01;
-}
-
-static int check_requested(struct udevice *dev, unsigned offset,
-                          const char *func)
-{
-       struct mxc_bank_info *bank = dev_get_priv(dev);
-       struct gpio_dev_priv *uc_priv = dev->uclass_priv;
-
-       if (!gpio_is_requested(bank, offset)) {
-               printf("mxc_gpio: %s: error: gpio %s%d not requested\n",
-                      func, uc_priv->bank_name, offset);
-               return -EPERM;
-       }
-
-       return 0;
-}
-
 /* set GPIO pin 'gpio' as an input */
 static int mxc_gpio_direction_input(struct udevice *dev, unsigned offset)
 {
        struct mxc_bank_info *bank = dev_get_priv(dev);
-       int ret;
-
-       ret = check_requested(dev, offset, __func__);
-       if (ret)
-               return ret;
 
        /* Configure GPIO direction as input. */
        mxc_gpio_bank_direction(bank->regs, offset, MXC_GPIO_DIRECTION_IN);
@@ -249,11 +210,6 @@ static int mxc_gpio_direction_output(struct udevice *dev, unsigned offset,
                                       int value)
 {
        struct mxc_bank_info *bank = dev_get_priv(dev);
-       int ret;
-
-       ret = check_requested(dev, offset, __func__);
-       if (ret)
-               return ret;
 
        /* Configure GPIO output value. */
        mxc_gpio_bank_set_value(bank->regs, offset, value);
@@ -268,11 +224,6 @@ static int mxc_gpio_direction_output(struct udevice *dev, unsigned offset,
 static int mxc_gpio_get_value(struct udevice *dev, unsigned offset)
 {
        struct mxc_bank_info *bank = dev_get_priv(dev);
-       int ret;
-
-       ret = check_requested(dev, offset, __func__);
-       if (ret)
-               return ret;
 
        return mxc_gpio_bank_get_value(bank->regs, offset);
 }
@@ -282,80 +233,16 @@ static int mxc_gpio_set_value(struct udevice *dev, unsigned offset,
                                 int value)
 {
        struct mxc_bank_info *bank = dev_get_priv(dev);
-       int ret;
-
-       ret = check_requested(dev, offset, __func__);
-       if (ret)
-               return ret;
 
        mxc_gpio_bank_set_value(bank->regs, offset, value);
 
        return 0;
 }
 
-static int mxc_gpio_get_state(struct udevice *dev, unsigned int offset,
-                             char *buf, int bufsize)
-{
-       struct gpio_dev_priv *uc_priv = dev->uclass_priv;
-       struct mxc_bank_info *bank = dev_get_priv(dev);
-       const char *label;
-       bool requested;
-       bool is_output;
-       int size;
-
-       label = bank->label[offset];
-       is_output = mxc_gpio_is_output(bank->regs, offset);
-       size = snprintf(buf, bufsize, "%s%d: ",
-                       uc_priv->bank_name ? uc_priv->bank_name : "", offset);
-       buf += size;
-       bufsize -= size;
-       requested = gpio_is_requested(bank, offset);
-       snprintf(buf, bufsize, "%s: %d [%c]%s%s",
-                is_output ? "out" : " in",
-                is_output ?
-                       mxc_gpio_bank_get_output_value(bank->regs, offset) :
-                       mxc_gpio_bank_get_value(bank->regs, offset),
-                requested ? 'x' : ' ',
-                requested ? " " : "",
-                label);
-
-       return 0;
-}
-
-static int mxc_gpio_request(struct udevice *dev, unsigned offset,
-                             const char *label)
-{
-       struct mxc_bank_info *bank = dev_get_priv(dev);
-
-       if (gpio_is_requested(bank, offset))
-               return -EBUSY;
-
-       strncpy(bank->label[offset], label, GPIO_NAME_SIZE);
-       bank->label[offset][GPIO_NAME_SIZE - 1] = '\0';
-
-       return 0;
-}
-
-static int mxc_gpio_free(struct udevice *dev, unsigned offset)
-{
-       struct mxc_bank_info *bank = dev_get_priv(dev);
-       int ret;
-
-       ret = check_requested(dev, offset, __func__);
-       if (ret)
-               return ret;
-       bank->label[offset][0] = '\0';
-
-       return 0;
-}
-
 static int mxc_gpio_get_function(struct udevice *dev, unsigned offset)
 {
        struct mxc_bank_info *bank = dev_get_priv(dev);
 
-       if (!gpio_is_requested(bank, offset))
-               return GPIOF_UNUSED;
-
        /* GPIOF_FUNC is not implemented yet */
        if (mxc_gpio_is_output(bank->regs, offset))
                return GPIOF_OUTPUT;
@@ -364,14 +251,11 @@ static int mxc_gpio_get_function(struct udevice *dev, unsigned offset)
 }
 
 static const struct dm_gpio_ops gpio_mxc_ops = {
-       .request                = mxc_gpio_request,
-       .free                   = mxc_gpio_free,
        .direction_input        = mxc_gpio_direction_input,
        .direction_output       = mxc_gpio_direction_output,
        .get_value              = mxc_gpio_get_value,
        .set_value              = mxc_gpio_set_value,
        .get_function           = mxc_gpio_get_function,
-       .get_state              = mxc_gpio_get_state,
 };
 
 static const struct mxc_gpio_plat mxc_plat[] = {
index 13dcf798730f4313e6767dc8078b05a454e6adb2..f3a7ccb51e98f28ee1b9dd72906dac4b93e0c407 100644 (file)
@@ -19,6 +19,7 @@
  * Written by Juha Yrjölä <juha.yrjola@nokia.com>
  */
 #include <common.h>
+#include <dm.h>
 #include <asm/gpio.h>
 #include <asm/io.h>
 #include <asm/errno.h>
 #define OMAP_GPIO_DIR_OUT      0
 #define OMAP_GPIO_DIR_IN       1
 
-static inline const struct gpio_bank *get_gpio_bank(int gpio)
-{
-       return &omap_gpio_bank[gpio >> 5];
-}
+#ifdef CONFIG_DM_GPIO
+
+#define GPIO_PER_BANK                  32
+
+struct gpio_bank {
+       /* TODO(sjg@chromium.org): Can we use a struct here? */
+       void *base;     /* address of registers in physical memory */
+       enum gpio_method method;
+};
+
+#endif
 
 static inline int get_gpio_index(int gpio)
 {
@@ -41,15 +49,6 @@ int gpio_is_valid(int gpio)
        return (gpio >= 0) && (gpio < OMAP_MAX_GPIO);
 }
 
-static int check_gpio(int gpio)
-{
-       if (!gpio_is_valid(gpio)) {
-               printf("ERROR : check_gpio: invalid GPIO %d\n", gpio);
-               return -1;
-       }
-       return 0;
-}
-
 static void _set_gpio_direction(const struct gpio_bank *bank, int gpio,
                                int is_input)
 {
@@ -118,6 +117,48 @@ static void _set_gpio_dataout(const struct gpio_bank *bank, int gpio,
        __raw_writel(l, reg);
 }
 
+static int _get_gpio_value(const struct gpio_bank *bank, int gpio)
+{
+       void *reg = bank->base;
+       int input;
+
+       switch (bank->method) {
+       case METHOD_GPIO_24XX:
+               input = _get_gpio_direction(bank, gpio);
+               switch (input) {
+               case OMAP_GPIO_DIR_IN:
+                       reg += OMAP_GPIO_DATAIN;
+                       break;
+               case OMAP_GPIO_DIR_OUT:
+                       reg += OMAP_GPIO_DATAOUT;
+                       break;
+               default:
+                       return -1;
+               }
+               break;
+       default:
+               return -1;
+       }
+
+       return (__raw_readl(reg) & (1 << gpio)) != 0;
+}
+
+#ifndef CONFIG_DM_GPIO
+
+static inline const struct gpio_bank *get_gpio_bank(int gpio)
+{
+       return &omap_gpio_bank[gpio >> 5];
+}
+
+static int check_gpio(int gpio)
+{
+       if (!gpio_is_valid(gpio)) {
+               printf("ERROR : check_gpio: invalid GPIO %d\n", gpio);
+               return -1;
+       }
+       return 0;
+}
+
 /**
  * Set value of the specified gpio
  */
@@ -139,32 +180,12 @@ int gpio_set_value(unsigned gpio, int value)
 int gpio_get_value(unsigned gpio)
 {
        const struct gpio_bank *bank;
-       void *reg;
-       int input;
 
        if (check_gpio(gpio) < 0)
                return -1;
        bank = get_gpio_bank(gpio);
-       reg = bank->base;
-       switch (bank->method) {
-       case METHOD_GPIO_24XX:
-               input = _get_gpio_direction(bank, get_gpio_index(gpio));
-               switch (input) {
-               case OMAP_GPIO_DIR_IN:
-                       reg += OMAP_GPIO_DATAIN;
-                       break;
-               case OMAP_GPIO_DIR_OUT:
-                       reg += OMAP_GPIO_DATAOUT;
-                       break;
-               default:
-                       return -1;
-               }
-               break;
-       default:
-               return -1;
-       }
-       return (__raw_readl(reg)
-                       & (1 << get_gpio_index(gpio))) != 0;
+
+       return _get_gpio_value(bank, get_gpio_index(gpio));
 }
 
 /**
@@ -220,3 +241,95 @@ int gpio_free(unsigned gpio)
 {
        return 0;
 }
+
+#else /* new driver model interface CONFIG_DM_GPIO */
+
+/* set GPIO pin 'gpio' as an input */
+static int omap_gpio_direction_input(struct udevice *dev, unsigned offset)
+{
+       struct gpio_bank *bank = dev_get_priv(dev);
+
+       /* Configure GPIO direction as input. */
+       _set_gpio_direction(bank, offset, 1);
+
+       return 0;
+}
+
+/* set GPIO pin 'gpio' as an output, with polarity 'value' */
+static int omap_gpio_direction_output(struct udevice *dev, unsigned offset,
+                                      int value)
+{
+       struct gpio_bank *bank = dev_get_priv(dev);
+
+       _set_gpio_dataout(bank, offset, value);
+       _set_gpio_direction(bank, offset, 0);
+
+       return 0;
+}
+
+/* read GPIO IN value of pin 'gpio' */
+static int omap_gpio_get_value(struct udevice *dev, unsigned offset)
+{
+       struct gpio_bank *bank = dev_get_priv(dev);
+
+       return _get_gpio_value(bank, offset);
+}
+
+/* write GPIO OUT value to pin 'gpio' */
+static int omap_gpio_set_value(struct udevice *dev, unsigned offset,
+                                int value)
+{
+       struct gpio_bank *bank = dev_get_priv(dev);
+
+       _set_gpio_dataout(bank, offset, value);
+
+       return 0;
+}
+
+static int omap_gpio_get_function(struct udevice *dev, unsigned offset)
+{
+       struct gpio_bank *bank = dev_get_priv(dev);
+
+       /* GPIOF_FUNC is not implemented yet */
+       if (_get_gpio_direction(bank->base, offset) == OMAP_GPIO_DIR_OUT)
+               return GPIOF_OUTPUT;
+       else
+               return GPIOF_INPUT;
+}
+
+static const struct dm_gpio_ops gpio_omap_ops = {
+       .direction_input        = omap_gpio_direction_input,
+       .direction_output       = omap_gpio_direction_output,
+       .get_value              = omap_gpio_get_value,
+       .set_value              = omap_gpio_set_value,
+       .get_function           = omap_gpio_get_function,
+};
+
+static int omap_gpio_probe(struct udevice *dev)
+{
+       struct gpio_bank *bank = dev_get_priv(dev);
+       struct omap_gpio_platdata *plat = dev_get_platdata(dev);
+       struct gpio_dev_priv *uc_priv = dev->uclass_priv;
+       char name[18], *str;
+
+       sprintf(name, "GPIO%d_", plat->bank_index);
+       str = strdup(name);
+       if (!str)
+               return -ENOMEM;
+       uc_priv->bank_name = str;
+       uc_priv->gpio_count = GPIO_PER_BANK;
+       bank->base = (void *)plat->base;
+       bank->method = plat->method;
+
+       return 0;
+}
+
+U_BOOT_DRIVER(gpio_omap) = {
+       .name   = "gpio_omap",
+       .id     = UCLASS_GPIO,
+       .ops    = &gpio_omap_ops,
+       .probe  = omap_gpio_probe,
+       .priv_auto_alloc_size = sizeof(struct gpio_bank),
+};
+
+#endif /* CONFIG_DM_GPIO */
index 13d74eb951bc406a6c3aea51f2548201c16ac258..6c41a42c177351adcd0d6f96ff81ae2a0f1036ee 100644 (file)
@@ -33,8 +33,6 @@ DECLARE_GLOBAL_DATA_PTR;
 #define RATE_MASK(gpio)                (0x1 << (gpio + 16))
 #define RATE_SET(gpio)                 (0x1 << (gpio + 16))
 
-#define GPIO_NAME_SIZE                 20
-
 /* Platform data for each bank */
 struct exynos_gpio_platdata {
        struct s5p_gpio_bank *bank;
@@ -43,7 +41,6 @@ struct exynos_gpio_platdata {
 
 /* Information about each bank at run-time */
 struct exynos_bank_info {
-       char label[GPIO_PER_BANK][GPIO_NAME_SIZE];
        struct s5p_gpio_bank *bank;
 };
 
@@ -189,61 +186,10 @@ int s5p_gpio_get_pin(unsigned gpio)
 
 /* Driver model interface */
 #ifndef CONFIG_SPL_BUILD
-static int exynos_gpio_get_state(struct udevice *dev, unsigned int offset,
-                               char *buf, int bufsize)
-{
-       struct gpio_dev_priv *uc_priv = dev->uclass_priv;
-       struct exynos_bank_info *state = dev_get_priv(dev);
-       const char *label;
-       bool is_output;
-       int size;
-       int cfg;
-
-       label = state->label[offset];
-       cfg = s5p_gpio_get_cfg_pin(state->bank, offset);
-       is_output = cfg == S5P_GPIO_OUTPUT;
-       size = snprintf(buf, bufsize, "%s%d: ",
-                       uc_priv->bank_name ? uc_priv->bank_name : "", offset);
-       buf += size;
-       bufsize -= size;
-       if (is_output || cfg == S5P_GPIO_INPUT) {
-               snprintf(buf, bufsize, "%s: %d [%c]%s%s",
-                        is_output ? "out" : " in",
-                        s5p_gpio_get_value(state->bank, offset),
-                        *label ? 'x' : ' ',
-                        *label ? " " : "",
-                        label);
-       } else {
-               snprintf(buf, bufsize, "sfpio");
-       }
-
-       return 0;
-}
-
-static int check_reserved(struct udevice *dev, unsigned offset,
-                         const char *func)
-{
-       struct exynos_bank_info *state = dev_get_priv(dev);
-       struct gpio_dev_priv *uc_priv = dev->uclass_priv;
-
-       if (!*state->label[offset]) {
-               printf("exynos_gpio: %s: error: gpio %s%d not reserved\n",
-                      func, uc_priv->bank_name, offset);
-               return -EPERM;
-       }
-
-       return 0;
-}
-
 /* set GPIO pin 'gpio' as an input */
 static int exynos_gpio_direction_input(struct udevice *dev, unsigned offset)
 {
        struct exynos_bank_info *state = dev_get_priv(dev);
-       int ret;
-
-       ret = check_reserved(dev, offset, __func__);
-       if (ret)
-               return ret;
 
        /* Configure GPIO direction as input. */
        s5p_gpio_cfg_pin(state->bank, offset, S5P_GPIO_INPUT);
@@ -256,11 +202,6 @@ static int exynos_gpio_direction_output(struct udevice *dev, unsigned offset,
                                       int value)
 {
        struct exynos_bank_info *state = dev_get_priv(dev);
-       int ret;
-
-       ret = check_reserved(dev, offset, __func__);
-       if (ret)
-               return ret;
 
        /* Configure GPIO output value. */
        s5p_gpio_set_value(state->bank, offset, value);
@@ -275,11 +216,6 @@ static int exynos_gpio_direction_output(struct udevice *dev, unsigned offset,
 static int exynos_gpio_get_value(struct udevice *dev, unsigned offset)
 {
        struct exynos_bank_info *state = dev_get_priv(dev);
-       int ret;
-
-       ret = check_reserved(dev, offset, __func__);
-       if (ret)
-               return ret;
 
        return s5p_gpio_get_value(state->bank, offset);
 }
@@ -289,43 +225,11 @@ static int exynos_gpio_set_value(struct udevice *dev, unsigned offset,
                                 int value)
 {
        struct exynos_bank_info *state = dev_get_priv(dev);
-       int ret;
-
-       ret = check_reserved(dev, offset, __func__);
-       if (ret)
-               return ret;
 
        s5p_gpio_set_value(state->bank, offset, value);
 
        return 0;
 }
-
-static int exynos_gpio_request(struct udevice *dev, unsigned offset,
-                             const char *label)
-{
-       struct exynos_bank_info *state = dev_get_priv(dev);
-
-       if (*state->label[offset])
-               return -EBUSY;
-
-       strncpy(state->label[offset], label, GPIO_NAME_SIZE);
-       state->label[offset][GPIO_NAME_SIZE - 1] = '\0';
-
-       return 0;
-}
-
-static int exynos_gpio_free(struct udevice *dev, unsigned offset)
-{
-       struct exynos_bank_info *state = dev_get_priv(dev);
-       int ret;
-
-       ret = check_reserved(dev, offset, __func__);
-       if (ret)
-               return ret;
-       state->label[offset][0] = '\0';
-
-       return 0;
-}
 #endif /* nCONFIG_SPL_BUILD */
 
 /*
@@ -362,8 +266,6 @@ static int exynos_gpio_get_function(struct udevice *dev, unsigned offset)
        struct exynos_bank_info *state = dev_get_priv(dev);
        int cfg;
 
-       if (!*state->label[offset])
-               return GPIOF_UNUSED;
        cfg = s5p_gpio_get_cfg_pin(state->bank, offset);
        if (cfg == S5P_GPIO_OUTPUT)
                return GPIOF_OUTPUT;
@@ -374,14 +276,11 @@ static int exynos_gpio_get_function(struct udevice *dev, unsigned offset)
 }
 
 static const struct dm_gpio_ops gpio_exynos_ops = {
-       .request                = exynos_gpio_request,
-       .free                   = exynos_gpio_free,
        .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,
-       .get_state              = exynos_gpio_get_state,
 };
 
 static int gpio_exynos_probe(struct udevice *dev)
index 75ada5d3871a844935c22b1bb9557f2e3229c84f..53c80d5be65dd85c0dbe20d2e1823e0400a4937f 100644 (file)
@@ -14,7 +14,6 @@ DECLARE_GLOBAL_DATA_PTR;
 /* Flags for each GPIO */
 #define GPIOF_OUTPUT   (1 << 0)        /* Currently set as an output */
 #define GPIOF_HIGH     (1 << 1)        /* Currently set high */
-#define GPIOF_RESERVED (1 << 2)        /* Is in use / requested */
 
 struct gpio_state {
        const char *label;      /* label given by requester */
@@ -54,18 +53,6 @@ static int set_gpio_flag(struct udevice *dev, unsigned offset, int flag,
        return 0;
 }
 
-static int check_reserved(struct udevice *dev, unsigned offset,
-                         const char *func)
-{
-       if (!get_gpio_flag(dev, offset, GPIOF_RESERVED)) {
-               printf("sandbox_gpio: %s: error: offset %u not reserved\n",
-                      func, offset);
-               return -1;
-       }
-
-       return 0;
-}
-
 /*
  * Back-channel sandbox-internal-only access to GPIO state
  */
@@ -101,9 +88,6 @@ static int sb_gpio_direction_input(struct udevice *dev, unsigned offset)
 {
        debug("%s: offset:%u\n", __func__, offset);
 
-       if (check_reserved(dev, offset, __func__))
-               return -1;
-
        return sandbox_gpio_set_direction(dev, offset, 0);
 }
 
@@ -113,9 +97,6 @@ static int sb_gpio_direction_output(struct udevice *dev, unsigned offset,
 {
        debug("%s: offset:%u, value = %d\n", __func__, offset, value);
 
-       if (check_reserved(dev, offset, __func__))
-               return -1;
-
        return sandbox_gpio_set_direction(dev, offset, 1) |
                sandbox_gpio_set_value(dev, offset, value);
 }
@@ -125,9 +106,6 @@ static int sb_gpio_get_value(struct udevice *dev, unsigned offset)
 {
        debug("%s: offset:%u\n", __func__, offset);
 
-       if (check_reserved(dev, offset, __func__))
-               return -1;
-
        return sandbox_gpio_get_value(dev, offset);
 }
 
@@ -136,9 +114,6 @@ static int sb_gpio_set_value(struct udevice *dev, unsigned offset, int value)
 {
        debug("%s: offset:%u, value = %d\n", __func__, offset, value);
 
-       if (check_reserved(dev, offset, __func__))
-               return -1;
-
        if (!sandbox_gpio_get_direction(dev, offset)) {
                printf("sandbox_gpio: error: set_value on input gpio %u\n",
                       offset);
@@ -148,69 +123,19 @@ static int sb_gpio_set_value(struct udevice *dev, unsigned offset, int value)
        return sandbox_gpio_set_value(dev, offset, value);
 }
 
-static int sb_gpio_request(struct udevice *dev, unsigned offset,
-                          const char *label)
+static int sb_gpio_get_function(struct udevice *dev, unsigned offset)
 {
-       struct gpio_dev_priv *uc_priv = dev->uclass_priv;
-       struct gpio_state *state = dev_get_priv(dev);
-
-       debug("%s: offset:%u, label:%s\n", __func__, offset, label);
-
-       if (offset >= uc_priv->gpio_count) {
-               printf("sandbox_gpio: error: invalid gpio %u\n", offset);
-               return -1;
-       }
-
-       if (get_gpio_flag(dev, offset, GPIOF_RESERVED)) {
-               printf("sandbox_gpio: error: gpio %u already reserved\n",
-                      offset);
-               return -1;
-       }
-
-       state[offset].label = label;
-       return set_gpio_flag(dev, offset, GPIOF_RESERVED, 1);
-}
-
-static int sb_gpio_free(struct udevice *dev, unsigned offset)
-{
-       struct gpio_state *state = dev_get_priv(dev);
-
-       debug("%s: offset:%u\n", __func__, offset);
-
-       if (check_reserved(dev, offset, __func__))
-               return -1;
-
-       state[offset].label = NULL;
-       return set_gpio_flag(dev, offset, GPIOF_RESERVED, 0);
-}
-
-static int sb_gpio_get_state(struct udevice *dev, unsigned int offset,
-                            char *buf, int bufsize)
-{
-       struct gpio_dev_priv *uc_priv = dev->uclass_priv;
-       struct gpio_state *state = dev_get_priv(dev);
-       const char *label;
-
-       label = state[offset].label;
-       snprintf(buf, bufsize, "%s%d: %s: %d [%c]%s%s",
-                uc_priv->bank_name ? uc_priv->bank_name : "", offset,
-                sandbox_gpio_get_direction(dev, offset) ? "out" : " in",
-                sandbox_gpio_get_value(dev, offset),
-                get_gpio_flag(dev, offset, GPIOF_RESERVED) ? 'x' : ' ',
-                label ? " " : "",
-                label ? label : "");
-
-       return 0;
+       if (get_gpio_flag(dev, offset, GPIOF_OUTPUT))
+               return GPIOF_OUTPUT;
+       return GPIOF_INPUT;
 }
 
 static const struct dm_gpio_ops gpio_sandbox_ops = {
-       .request                = sb_gpio_request,
-       .free                   = sb_gpio_free,
        .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_state              = sb_gpio_get_state,
+       .get_function           = sb_gpio_get_function,
 };
 
 static int sandbox_gpio_ofdata_to_platdata(struct udevice *dev)
@@ -239,6 +164,13 @@ static int gpio_sandbox_probe(struct udevice *dev)
        return 0;
 }
 
+static int gpio_sandbox_remove(struct udevice *dev)
+{
+       free(dev->priv);
+
+       return 0;
+}
+
 static const struct udevice_id sandbox_gpio_ids[] = {
        { .compatible = "sandbox,gpio" },
        { }
@@ -250,5 +182,6 @@ U_BOOT_DRIVER(gpio_sandbox) = {
        .of_match = sandbox_gpio_ids,
        .ofdata_to_platdata = sandbox_gpio_ofdata_to_platdata,
        .probe  = gpio_sandbox_probe,
+       .remove = gpio_sandbox_remove,
        .ops    = &gpio_sandbox_ops,
 };
index 1cc4abb8a938b16ccc1322a6adcc903bc064b299..88f7ef5bf04d9abce9605cd7e8e161a11b135a8d 100644 (file)
@@ -39,7 +39,6 @@ struct tegra_gpio_platdata {
 
 /* Information about each port at run-time */
 struct tegra_port_info {
-       char label[TEGRA_GPIOS_PER_PORT][GPIO_NAME_SIZE];
        struct gpio_ctlr_bank *bank;
        int base_gpio;          /* Port number for this port (0, 1,.., n-1) */
 };
@@ -132,21 +131,6 @@ static void set_level(unsigned gpio, int high)
        writel(u, &bank->gpio_out[GPIO_PORT(gpio)]);
 }
 
-static int check_reserved(struct udevice *dev, unsigned offset,
-                         const char *func)
-{
-       struct tegra_port_info *state = dev_get_priv(dev);
-       struct gpio_dev_priv *uc_priv = dev->uclass_priv;
-
-       if (!*state->label[offset]) {
-               printf("tegra_gpio: %s: error: gpio %s%d not reserved\n",
-                      func, uc_priv->bank_name, offset);
-               return -EBUSY;
-       }
-
-       return 0;
-}
-
 /* set GPIO pin 'gpio' as an output, with polarity 'value' */
 int tegra_spl_gpio_direction_output(int gpio, int value)
 {
@@ -171,56 +155,16 @@ static int tegra_gpio_request(struct udevice *dev, unsigned offset,
 {
        struct tegra_port_info *state = dev_get_priv(dev);
 
-       if (*state->label[offset])
-               return -EBUSY;
-
-       strncpy(state->label[offset], label, GPIO_NAME_SIZE);
-       state->label[offset][GPIO_NAME_SIZE - 1] = '\0';
-
        /* Configure as a GPIO */
        set_config(state->base_gpio + offset, 1);
 
        return 0;
 }
 
-static int tegra_gpio_free(struct udevice *dev, unsigned offset)
-{
-       struct tegra_port_info *state = dev_get_priv(dev);
-       int ret;
-
-       ret = check_reserved(dev, offset, __func__);
-       if (ret)
-               return ret;
-       state->label[offset][0] = '\0';
-
-       return 0;
-}
-
-/* read GPIO OUT value of pin 'gpio' */
-static int tegra_gpio_get_output_value(unsigned gpio)
-{
-       struct gpio_ctlr *ctlr = (struct gpio_ctlr *)NV_PA_GPIO_BASE;
-       struct gpio_ctlr_bank *bank = &ctlr->gpio_bank[GPIO_BANK(gpio)];
-       int val;
-
-       debug("gpio_get_output_value: pin = %d (port %d:bit %d)\n",
-               gpio, GPIO_FULLPORT(gpio), GPIO_BIT(gpio));
-
-       val = readl(&bank->gpio_out[GPIO_PORT(gpio)]);
-
-       return (val >> GPIO_BIT(gpio)) & 1;
-}
-
-
 /* set GPIO pin 'gpio' as an input */
 static int tegra_gpio_direction_input(struct udevice *dev, unsigned offset)
 {
        struct tegra_port_info *state = dev_get_priv(dev);
-       int ret;
-
-       ret = check_reserved(dev, offset, __func__);
-       if (ret)
-               return ret;
 
        /* Configure GPIO direction as input. */
        set_direction(state->base_gpio + offset, 0);
@@ -234,11 +178,6 @@ static int tegra_gpio_direction_output(struct udevice *dev, unsigned offset,
 {
        struct tegra_port_info *state = dev_get_priv(dev);
        int gpio = state->base_gpio + offset;
-       int ret;
-
-       ret = check_reserved(dev, offset, __func__);
-       if (ret)
-               return ret;
 
        /* Configure GPIO output value. */
        set_level(gpio, value);
@@ -254,13 +193,8 @@ static int tegra_gpio_get_value(struct udevice *dev, unsigned offset)
 {
        struct tegra_port_info *state = dev_get_priv(dev);
        int gpio = state->base_gpio + offset;
-       int ret;
        int val;
 
-       ret = check_reserved(dev, offset, __func__);
-       if (ret)
-               return ret;
-
        debug("%s: pin = %d (port %d:bit %d)\n", __func__,
              gpio, GPIO_FULLPORT(gpio), GPIO_BIT(gpio));
 
@@ -274,11 +208,6 @@ static int tegra_gpio_set_value(struct udevice *dev, unsigned offset, int value)
 {
        struct tegra_port_info *state = dev_get_priv(dev);
        int gpio = state->base_gpio + offset;
-       int ret;
-
-       ret = check_reserved(dev, offset, __func__);
-       if (ret)
-               return ret;
 
        debug("gpio_set_value: pin = %d (port %d:bit %d), value = %d\n",
              gpio, GPIO_FULLPORT(gpio), GPIO_BIT(gpio), value);
@@ -314,8 +243,6 @@ static int tegra_gpio_get_function(struct udevice *dev, unsigned offset)
        struct tegra_port_info *state = dev_get_priv(dev);
        int gpio = state->base_gpio + offset;
 
-       if (!*state->label[offset])
-               return GPIOF_UNUSED;
        if (!get_config(gpio))
                return GPIOF_FUNC;
        else if (get_direction(gpio))
@@ -324,50 +251,13 @@ static int tegra_gpio_get_function(struct udevice *dev, unsigned offset)
                return GPIOF_INPUT;
 }
 
-static int tegra_gpio_get_state(struct udevice *dev, unsigned int offset,
-                               char *buf, int bufsize)
-{
-       struct gpio_dev_priv *uc_priv = dev->uclass_priv;
-       struct tegra_port_info *state = dev_get_priv(dev);
-       int gpio = state->base_gpio + offset;
-       const char *label;
-       int is_output;
-       int is_gpio;
-       int size;
-
-       label = state->label[offset];
-       is_gpio = get_config(gpio); /* GPIO, not SFPIO */
-       size = snprintf(buf, bufsize, "%s%d: ",
-                       uc_priv->bank_name ? uc_priv->bank_name : "", offset);
-       buf += size;
-       bufsize -= size;
-       if (is_gpio) {
-               is_output = get_direction(gpio);
-
-               snprintf(buf, bufsize, "%s: %d [%c]%s%s",
-                        is_output ? "out" : " in",
-                        is_output ?
-                               tegra_gpio_get_output_value(gpio) :
-                               tegra_gpio_get_value(dev, offset),
-                        *label ? 'x' : ' ',
-                        *label ? " " : "",
-                        label);
-       } else {
-               snprintf(buf, bufsize, "sfpio");
-       }
-
-       return 0;
-}
-
 static const struct dm_gpio_ops gpio_tegra_ops = {
        .request                = tegra_gpio_request,
-       .free                   = tegra_gpio_free,
        .direction_input        = tegra_gpio_direction_input,
        .direction_output       = tegra_gpio_direction_output,
        .get_value              = tegra_gpio_get_value,
        .set_value              = tegra_gpio_set_value,
        .get_function           = tegra_gpio_get_function,
-       .get_state              = tegra_gpio_get_state,
 };
 
 /**
index c891ebd39e243ebc5540e7db6291ed88f7e84678..e085a7095eaf55ef62bc9c47283bcfe20636740a 100644 (file)
@@ -8,6 +8,7 @@
 #include <common.h>
 #include <asm/io.h>
 #include "designware_i2c.h"
+#include <i2c.h>
 
 #ifdef CONFIG_I2C_MULTI_BUS
 static unsigned int bus_initialized[CONFIG_SYS_I2C_BUS_MAX];
@@ -76,16 +77,20 @@ static void set_speed(int i2c_spd)
  *
  * Set the i2c speed.
  */
-int i2c_set_bus_speed(int speed)
+int i2c_set_bus_speed(unsigned int speed)
 {
+       int i2c_spd;
+
        if (speed >= I2C_MAX_SPEED)
-               set_speed(IC_SPEED_MODE_MAX);
+               i2c_spd = IC_SPEED_MODE_MAX;
        else if (speed >= I2C_FAST_SPEED)
-               set_speed(IC_SPEED_MODE_FAST);
+               i2c_spd = IC_SPEED_MODE_FAST;
        else
-               set_speed(IC_SPEED_MODE_STANDARD);
+               i2c_spd = IC_SPEED_MODE_STANDARD;
 
-       return 0;
+       set_speed(i2c_spd);
+
+       return i2c_spd;
 }
 
 /*
@@ -93,7 +98,7 @@ int i2c_set_bus_speed(int speed)
  *
  * Gets the i2c speed.
  */
-int i2c_get_bus_speed(void)
+unsigned int i2c_get_bus_speed(void)
 {
        u32 cntl;
 
@@ -429,7 +434,7 @@ int i2c_set_bus_num(unsigned int bus)
        return 0;
 }
 
-int i2c_get_bus_num(void)
+unsigned int i2c_get_bus_num(void)
 {
        return current_bus;
 }
index ab3ffa0fc1535b89101f40877b5e4355b69ea1f2..9b2ca1e81ba33a7f94e539a020336015b30592fa 100644 (file)
@@ -20,8 +20,8 @@
 
 #if defined(CONFIG_ORION5X)
 #include <asm/arch/orion5x.h>
-#elif defined(CONFIG_KIRKWOOD)
-#include <asm/arch/kirkwood.h>
+#elif (defined(CONFIG_KIRKWOOD) || defined(CONFIG_ARMADA_XP))
+#include <asm/arch/soc.h>
 #elif defined(CONFIG_SUNXI)
 #include <asm/arch/i2c.h>
 #else
index 257b72f0f7cdf71b40afc10a2d18a9d48fdf700d..562211e7deb6504b65a0a3a088ea7572e5cc93b0 100644 (file)
@@ -471,8 +471,8 @@ static void tegra_i2c_init(struct i2c_adapter *adap, int speed, int slaveaddr)
 }
 
 /* i2c write version without the register address */
-int i2c_write_data(struct i2c_bus *bus, uchar chip, uchar *buffer, int len,
-                  bool end_with_repeated_start)
+static int i2c_write_data(struct i2c_bus *bus, uchar chip, uchar *buffer,
+                         int len, bool end_with_repeated_start)
 {
        int rc;
 
@@ -493,7 +493,8 @@ int i2c_write_data(struct i2c_bus *bus, uchar chip, uchar *buffer, int len,
 }
 
 /* i2c read version without the register address */
-int i2c_read_data(struct i2c_bus *bus, uchar chip, uchar *buffer, int len)
+static int i2c_read_data(struct i2c_bus *bus, uchar chip, uchar *buffer,
+                               int len)
 {
        int rc;
 
index 7e36db0a71a0b74ffbf2ff4b3fedd1ac99718241..0ef94f7a00bb26c72bfb2d07b60f63dc9030d77b 100644 (file)
@@ -181,7 +181,7 @@ static void kbd_wait_for_fifo_init(struct keyb *config)
  * @param input                Input configuration
  * @return 1, to indicate that we have something to look at
  */
-int tegra_kbc_check(struct input_config *input)
+static int tegra_kbc_check(struct input_config *input)
 {
        kbd_wait_for_fifo_init(&config);
        check_for_keys(&config);
index 0e02671c93d46652864d9e83bf4a7d3d9f658e2e..07624a136fa47def2c330ae229c25a1cd822a3dc 100644 (file)
@@ -54,7 +54,7 @@ int cros_ec_lpc_command(struct cros_ec_dev *dev, uint8_t cmd, int cmd_version,
        int csum;
        int i;
 
-       if (dout_len > EC_HOST_PARAM_SIZE) {
+       if (dout_len > EC_PROTO2_MAX_PARAM_SIZE) {
                debug("%s: Cannot send %d bytes\n", __func__, dout_len);
                return -1;
        }
@@ -159,7 +159,7 @@ int cros_ec_lpc_init(struct cros_ec_dev *dev, const void *blob)
        byte = 0xff;
        byte &= inb(EC_LPC_ADDR_HOST_CMD);
        byte &= inb(EC_LPC_ADDR_HOST_DATA);
-       for (i = 0; i < EC_HOST_PARAM_SIZE && (byte == 0xff); i++)
+       for (i = 0; i < EC_PROTO2_MAX_PARAM_SIZE && (byte == 0xff); i++)
                byte &= inb(EC_LPC_ADDR_HOST_PARAM + i);
        if (byte == 0xff) {
                debug("%s: CROS_EC device not found on LPC bus\n",
index 82079d67cd8fc07565e5b8c57cc7e7c8234793b7..92f7d8942f02d1420e397664afcb99b938a3dafc 100644 (file)
@@ -40,6 +40,7 @@
 #include <malloc.h>
 #include <sdhci.h>
 #include <asm/arch/timer.h>
+#include <asm/arch-bcm2835/sdhci.h>
 
 /* 400KHz is max freq for card ID etc. Use that as min */
 #define MIN_FREQ 400000
index d34e74357f0a4e74055f0280e969b6eda6add4c6..9f98c3f37c9790858a873b90fdcf27845fce15bc 100644 (file)
@@ -14,7 +14,7 @@
 #include <mmc.h>
 #include <asm/io.h>
 #include <asm/arch/cpu.h>
-#include <asm/arch/kirkwood.h>
+#include <asm/arch/soc.h>
 #include <mvebu_mmc.h>
 
 DECLARE_GLOBAL_DATA_PTR;
index 5b0c3020693c325a396b6726fd01d920776122f3..ef2cbf9e2fa574cd2846c280149cca2cf1dbc28b 100644 (file)
@@ -67,14 +67,19 @@ static int mmc_write_data(struct hsmmc *mmc_base, const char *buf,
 #ifdef OMAP_HSMMC_USE_GPIO
 static int omap_mmc_setup_gpio_in(int gpio, const char *label)
 {
-       if (!gpio_is_valid(gpio))
-               return -1;
+       int ret;
 
-       if (gpio_request(gpio, label) < 0)
+#ifndef CONFIG_DM_GPIO
+       if (!gpio_is_valid(gpio))
                return -1;
+#endif
+       ret = gpio_request(gpio, label);
+       if (ret)
+               return ret;
 
-       if (gpio_direction_input(gpio) < 0)
-               return -1;
+       ret = gpio_direction_input(gpio);
+       if (ret)
+               return ret;
 
        return gpio;
 }
index 3125d13ba3ce8e8e2552248e41c059bd31e5fb3c..de88e19609f37aaba48665e9bff60f6a7b63f31b 100644 (file)
@@ -124,7 +124,7 @@ static int sdhci_transfer_data(struct sdhci_host *host, struct mmc_data *data,
 #endif
 #define CONFIG_SDHCI_CMD_DEFAULT_TIMEOUT       100
 
-int sdhci_send_command(struct mmc *mmc, struct mmc_cmd *cmd,
+static int sdhci_send_command(struct mmc *mmc, struct mmc_cmd *cmd,
                       struct mmc_data *data)
 {
        struct sdhci_host *host = mmc->priv;
@@ -355,7 +355,7 @@ static void sdhci_set_power(struct sdhci_host *host, unsigned short power)
        sdhci_writeb(host, pwr, SDHCI_POWER_CONTROL);
 }
 
-void sdhci_set_ios(struct mmc *mmc)
+static void sdhci_set_ios(struct mmc *mmc)
 {
        u32 ctrl;
        struct sdhci_host *host = mmc->priv;
@@ -393,7 +393,7 @@ void sdhci_set_ios(struct mmc *mmc)
        sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL);
 }
 
-int sdhci_init(struct mmc *mmc)
+static int sdhci_init(struct mmc *mmc)
 {
        struct sdhci_host *host = mmc->priv;
 
index d4e574fe191b0e8edd587b733be4b9cf5ec6ee24..16592e3d7cf2454e00013181576dcb0ea437822e 100644 (file)
 #include <asm/io.h>
 #include <asm/arch/clock.h>
 #include <asm/arch/cpu.h>
+#include <asm/arch/gpio.h>
 #include <asm/arch/mmc.h>
+#include <asm-generic/gpio.h>
 
 struct sunxi_mmc_host {
        unsigned mmc_no;
        uint32_t *mclkreg;
-       unsigned database;
        unsigned fatal_err;
        unsigned mod_clk;
        struct sunxi_mmc *reg;
@@ -57,7 +58,6 @@ static int mmc_resource_init(int sdc_no)
                printf("Wrong mmc number %d\n", sdc_no);
                return -1;
        }
-       mmchost->database = (unsigned int)mmchost->reg + 0x100;
        mmchost->mmc_no = sdc_no;
 
        return 0;
@@ -75,6 +75,11 @@ 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_SUN6I) || defined(CONFIG_SUN8I)
+       /* unassert reset */
+       setbits_le32(&ccm->ahb_reset0_cfg, 1 << AHB_RESET_OFFSET_MMC(sdc_no));
+#endif
+
        /* config mod clock */
        pll_clk = clock_get_pll6();
        /* should be close to 100 MHz but no more, so round up */
@@ -194,9 +199,9 @@ static int mmc_trans_data_by_cpu(struct mmc *mmc, struct mmc_data *data)
                }
 
                if (reading)
-                       buff[i] = readl(mmchost->database);
+                       buff[i] = readl(&mmchost->reg->fifo);
                else
-                       writel(buff[i], mmchost->database);
+                       writel(buff[i], &mmchost->reg->fifo);
        }
 
        return 0;
@@ -343,13 +348,32 @@ out:
        return error;
 }
 
+static int sunxi_mmc_getcd(struct mmc *mmc)
+{
+       struct sunxi_mmc_host *mmchost = mmc->priv;
+       int cd_pin = -1;
+
+       switch (mmchost->mmc_no) {
+       case 0: cd_pin = sunxi_name_to_gpio(CONFIG_MMC0_CD_PIN); break;
+       case 1: cd_pin = sunxi_name_to_gpio(CONFIG_MMC1_CD_PIN); break;
+       case 2: cd_pin = sunxi_name_to_gpio(CONFIG_MMC2_CD_PIN); break;
+       case 3: cd_pin = sunxi_name_to_gpio(CONFIG_MMC3_CD_PIN); break;
+       }
+
+       if (cd_pin == -1)
+               return 1;
+
+       return !gpio_direction_input(cd_pin);
+}
+
 static const struct mmc_ops sunxi_mmc_ops = {
        .send_cmd       = mmc_send_cmd,
        .set_ios        = mmc_set_ios,
        .init           = mmc_core_init,
+       .getcd          = sunxi_mmc_getcd,
 };
 
-int sunxi_mmc_init(int sdc_no)
+struct mmc *sunxi_mmc_init(int sdc_no)
 {
        struct mmc_config *cfg = &mmc_host[sdc_no].cfg;
 
@@ -361,6 +385,9 @@ int 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_SUN6I) || defined(CONFIG_SUN7I) || defined(CONFIG_SUN8I)
+       cfg->host_caps |= MMC_MODE_HC;
+#endif
        cfg->b_max = CONFIG_SYS_MMC_MAX_BLK_COUNT;
 
        cfg->f_min = 400000;
@@ -369,8 +396,5 @@ int sunxi_mmc_init(int sdc_no)
        mmc_resource_init(sdc_no);
        mmc_clk_io_on(sdc_no);
 
-       if (mmc_create(cfg, &mmc_host[sdc_no]) == NULL)
-               return -1;
-
-       return 0;
+       return mmc_create(cfg, &mmc_host[sdc_no]);
 }
index ca9c4aa15feea77686f8d5e87b7f24bdb8e1be89..2bd36b0ee704a86308bfa0d3c7faa68cc506249a 100644 (file)
@@ -13,6 +13,7 @@
 #include <asm/io.h>
 #include <asm/arch/clock.h>
 #include <asm/arch-tegra/clk_rst.h>
+#include <asm/arch-tegra/mmc.h>
 #include <asm/arch-tegra/tegra_mmc.h>
 #include <mmc.h>
 
@@ -292,7 +293,7 @@ static int mmc_send_cmd_bounced(struct mmc *mmc, struct mmc_cmd *cmd,
                                /* Transfer Complete */
                                debug("r/w is done\n");
                                break;
-                       } else if (get_timer(start) > 2000UL) {
+                       } else if (get_timer(start) > 8000UL) {
                                writel(mask, &host->reg->norintsts);
                                printf("%s: MMC Timeout\n"
                                       "    Interrupt status        0x%08x\n"
@@ -508,7 +509,7 @@ static int tegra_mmc_core_init(struct mmc *mmc)
        return 0;
 }
 
-int tegra_mmc_getcd(struct mmc *mmc)
+static int tegra_mmc_getcd(struct mmc *mmc)
 {
        struct mmc_host *host = mmc->priv;
 
index 9b3175d87fbdabff14d922ce4c64d620b9aa60f4..50983b837b2238b781477f13b559502047b1ad6e 100644 (file)
@@ -63,6 +63,12 @@ flash_info_t flash_info[CFI_MAX_FLASH_BANKS];        /* FLASH chips info */
 #define CONFIG_SYS_FLASH_CFI_WIDTH     FLASH_CFI_8BIT
 #endif
 
+#ifdef CONFIG_CFI_FLASH_USE_WEAK_ACCESSORS
+#define __maybe_weak __weak
+#else
+#define __maybe_weak static
+#endif
+
 /*
  * 0xffff is an undefined value for the configuration register. When
  * this value is returned, the configuration register shall not be
@@ -81,14 +87,12 @@ static u16 cfi_flash_config_reg(int i)
 int cfi_flash_num_flash_banks = CONFIG_SYS_MAX_FLASH_BANKS_DETECT;
 #endif
 
-static phys_addr_t __cfi_flash_bank_addr(int i)
+__weak phys_addr_t cfi_flash_bank_addr(int i)
 {
        return ((phys_addr_t [])CONFIG_SYS_FLASH_BANKS_LIST)[i];
 }
-phys_addr_t cfi_flash_bank_addr(int i)
-       __attribute__((weak, alias("__cfi_flash_bank_addr")));
 
-static unsigned long __cfi_flash_bank_size(int i)
+__weak unsigned long cfi_flash_bank_size(int i)
 {
 #ifdef CONFIG_SYS_FLASH_BANKS_SIZES
        return ((unsigned long [])CONFIG_SYS_FLASH_BANKS_SIZES)[i];
@@ -96,71 +100,49 @@ static unsigned long __cfi_flash_bank_size(int i)
        return 0;
 #endif
 }
-unsigned long cfi_flash_bank_size(int i)
-       __attribute__((weak, alias("__cfi_flash_bank_size")));
 
-static void __flash_write8(u8 value, void *addr)
+__maybe_weak void flash_write8(u8 value, void *addr)
 {
        __raw_writeb(value, addr);
 }
 
-static void __flash_write16(u16 value, void *addr)
+__maybe_weak void flash_write16(u16 value, void *addr)
 {
        __raw_writew(value, addr);
 }
 
-static void __flash_write32(u32 value, void *addr)
+__maybe_weak void flash_write32(u32 value, void *addr)
 {
        __raw_writel(value, addr);
 }
 
-static void __flash_write64(u64 value, void *addr)
+__maybe_weak void flash_write64(u64 value, void *addr)
 {
        /* No architectures currently implement __raw_writeq() */
        *(volatile u64 *)addr = value;
 }
 
-static u8 __flash_read8(void *addr)
+__maybe_weak u8 flash_read8(void *addr)
 {
        return __raw_readb(addr);
 }
 
-static u16 __flash_read16(void *addr)
+__maybe_weak u16 flash_read16(void *addr)
 {
        return __raw_readw(addr);
 }
 
-static u32 __flash_read32(void *addr)
+__maybe_weak u32 flash_read32(void *addr)
 {
        return __raw_readl(addr);
 }
 
-static u64 __flash_read64(void *addr)
+__maybe_weak u64 flash_read64(void *addr)
 {
        /* No architectures currently implement __raw_readq() */
        return *(volatile u64 *)addr;
 }
 
-#ifdef CONFIG_CFI_FLASH_USE_WEAK_ACCESSORS
-void flash_write8(u8 value, void *addr)__attribute__((weak, alias("__flash_write8")));
-void flash_write16(u16 value, void *addr)__attribute__((weak, alias("__flash_write16")));
-void flash_write32(u32 value, void *addr)__attribute__((weak, alias("__flash_write32")));
-void flash_write64(u64 value, void *addr)__attribute__((weak, alias("__flash_write64")));
-u8 flash_read8(void *addr)__attribute__((weak, alias("__flash_read8")));
-u16 flash_read16(void *addr)__attribute__((weak, alias("__flash_read16")));
-u32 flash_read32(void *addr)__attribute__((weak, alias("__flash_read32")));
-u64 flash_read64(void *addr)__attribute__((weak, alias("__flash_read64")));
-#else
-#define flash_write8   __flash_write8
-#define flash_write16  __flash_write16
-#define flash_write32  __flash_write32
-#define flash_write64  __flash_write64
-#define flash_read8    __flash_read8
-#define flash_read16   __flash_read16
-#define flash_read32   __flash_read32
-#define flash_read64   __flash_read64
-#endif
-
 /*-----------------------------------------------------------------------
  */
 #if defined(CONFIG_ENV_IS_IN_FLASH) || defined(CONFIG_ENV_ADDR_REDUND) || (CONFIG_SYS_MONITOR_BASE >= CONFIG_SYS_FLASH_BASE)
index 3e5fb0cd65a243d77fe2759556bab0f9209beec1..4fc34d6b9fca6d7b41ff44f52912da85532d1b9b 100644 (file)
@@ -8,7 +8,7 @@
 
 #include <common.h>
 #include <asm/io.h>
-#include <asm/arch/kirkwood.h>
+#include <asm/arch/soc.h>
 #include <nand.h>
 
 /* NAND Flash Soc registers */
index db1599e9a641402e811c9e6172e35909098a0769..40d670563c1e447c172f075eabda3d304433f693 100644 (file)
@@ -75,7 +75,7 @@ static void omap_nand_hwcontrol(struct mtd_info *mtd, int32_t cmd,
 
 #ifdef CONFIG_SPL_BUILD
 /* Check wait pin as dev ready indicator */
-int omap_spl_dev_ready(struct mtd_info *mtd)
+static int omap_spl_dev_ready(struct mtd_info *mtd)
 {
        return gpmc_cfg->status & (1 << 8);
 }
@@ -161,23 +161,6 @@ static int __maybe_unused omap_correct_data(struct mtd_info *mtd, uint8_t *dat,
        return 0;
 }
 
-/*
- * omap_reverse_list - re-orders list elements in reverse order [internal]
- * @list:      pointer to start of list
- * @length:    length of list
-*/
-void omap_reverse_list(u8 *list, unsigned int length)
-{
-       unsigned int i, j;
-       unsigned int half_length = length / 2;
-       u8 tmp;
-       for (i = 0, j = length - 1; i < half_length; i++, j--) {
-               tmp = list[i];
-               list[i] = list[j];
-               list[j] = tmp;
-       }
-}
-
 /*
  * omap_enable_hwecc - configures GPMC as per ECC scheme before read/write
  * @mtd:       MTD device structure
@@ -350,6 +333,23 @@ static int omap_calculate_ecc(struct mtd_info *mtd, const uint8_t *dat,
 }
 
 #ifdef CONFIG_NAND_OMAP_ELM
+/*
+ * omap_reverse_list - re-orders list elements in reverse order [internal]
+ * @list:      pointer to start of list
+ * @length:    length of list
+*/
+static void omap_reverse_list(u8 *list, unsigned int length)
+{
+       unsigned int i, j;
+       unsigned int half_length = length / 2;
+       u8 tmp;
+       for (i = 0, j = length - 1; i < half_length; i++, j--) {
+               tmp = list[i];
+               list[i] = list[j];
+               list[j] = tmp;
+       }
+}
+
 /*
  * omap_correct_data_bch - Compares the ecc read from nand spare area
  * with ECC registers values and corrects one bit error if it has occured
index 2c4dd7cb6ad8657a500f7e7247a658591c1dab4b..fb0cf8c1cf172dce03a8dcea02d7522de26793a9 100644 (file)
@@ -41,6 +41,7 @@ obj-$(CONFIG_MCFFEC) += mcffec.o mcfmii.o
 obj-$(CONFIG_MPC5xxx_FEC) += mpc5xxx_fec.o
 obj-$(CONFIG_MPC512x_FEC) += mpc512x_fec.o
 obj-$(CONFIG_MVGBE) += mvgbe.o
+obj-$(CONFIG_MVNETA) += mvneta.o
 obj-$(CONFIG_NATSEMI) += natsemi.o
 obj-$(CONFIG_DRIVER_NE2000) += ne2000.o ne2000_base.o
 obj-$(CONFIG_DRIVER_AX88796L) += ax88796.o ne2000_base.o
index 439f8ae99e364f2082ceaa2ad5f0630c21e0fe9f..08bc1afcf638be1dbde9e1c23662a829c2bfa298 100644 (file)
@@ -27,6 +27,7 @@
 #include <net.h>
 #include <miiphy.h>
 #include <malloc.h>
+#include <netdev.h>
 #include <linux/compiler.h>
 #include <asm/arch/emac_defs.h>
 #include <asm/io.h>
index 549d6486136204ed644a2c2ecba101d25db303ef..b57247032fa85aaa65ec47c9fcf7668a4cd567df 100644 (file)
@@ -11,6 +11,7 @@
 #include <common.h>
 #include <malloc.h>
 #include <net.h>
+#include <netdev.h>
 #include <miiphy.h>
 #include "fec_mxc.h"
 
@@ -179,13 +180,14 @@ static int fec_mdio_write(struct ethernet_regs *eth, uint8_t phyAddr,
        return 0;
 }
 
-int fec_phy_read(struct mii_dev *bus, int phyAddr, int dev_addr, int regAddr)
+static int fec_phy_read(struct mii_dev *bus, int phyAddr, int dev_addr,
+                       int regAddr)
 {
        return fec_mdio_read(bus->priv, phyAddr, regAddr);
 }
 
-int fec_phy_write(struct mii_dev *bus, int phyAddr, int dev_addr, int regAddr,
-               u16 data)
+static int fec_phy_write(struct mii_dev *bus, int phyAddr, int dev_addr,
+                        int regAddr, u16 data)
 {
        return fec_mdio_write(bus->priv, phyAddr, regAddr, data);
 }
index 0cd06b6a69df68aa8e9e1410724d89844b131010..6ef6cacb6b87940421bae8d78085eb0ebb5a6e0d 100644 (file)
@@ -24,7 +24,7 @@
 #include <asm/arch/cpu.h>
 
 #if defined(CONFIG_KIRKWOOD)
-#include <asm/arch/kirkwood.h>
+#include <asm/arch/soc.h>
 #elif defined(CONFIG_ORION5X)
 #include <asm/arch/orion5x.h>
 #elif defined(CONFIG_DOVE)
diff --git a/drivers/net/mvneta.c b/drivers/net/mvneta.c
new file mode 100644 (file)
index 0000000..a2a69b4
--- /dev/null
@@ -0,0 +1,1653 @@
+/*
+ * Driver for Marvell NETA network card for Armada XP and Armada 370 SoCs.
+ *
+ * U-Boot version:
+ * Copyright (C) 2014 Stefan Roese <sr@denx.de>
+ *
+ * Based on the Linux version which is:
+ * Copyright (C) 2012 Marvell
+ *
+ * Rami Rosen <rosenr@marvell.com>
+ * Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#include <common.h>
+#include <net.h>
+#include <netdev.h>
+#include <config.h>
+#include <malloc.h>
+#include <asm/io.h>
+#include <asm/errno.h>
+#include <phy.h>
+#include <miiphy.h>
+#include <watchdog.h>
+#include <asm/arch/cpu.h>
+#include <asm/arch/soc.h>
+#include <linux/compat.h>
+#include <linux/mbus.h>
+
+#if !defined(CONFIG_PHYLIB)
+# error Marvell mvneta requires PHYLIB
+#endif
+
+/* Some linux -> U-Boot compatibility stuff */
+#define netdev_err(dev, fmt, args...)          \
+       printf(fmt, ##args)
+#define netdev_warn(dev, fmt, args...)         \
+       printf(fmt, ##args)
+#define netdev_info(dev, fmt, args...)         \
+       printf(fmt, ##args)
+
+#define CONFIG_NR_CPUS         1
+#define BIT(nr)                        (1UL << (nr))
+#define ETH_HLEN               14      /* Total octets in header */
+
+/* 2(HW hdr) 14(MAC hdr) 4(CRC) 32(extra for cache prefetch) */
+#define WRAP                   (2 + ETH_HLEN + 4 + 32)
+#define MTU                    1500
+#define RX_BUFFER_SIZE         (ALIGN(MTU + WRAP, ARCH_DMA_MINALIGN))
+
+#define MVNETA_SMI_TIMEOUT                     10000
+
+/* Registers */
+#define MVNETA_RXQ_CONFIG_REG(q)                (0x1400 + ((q) << 2))
+#define             MVNETA_RXQ_HW_BUF_ALLOC            BIT(1)
+#define      MVNETA_RXQ_PKT_OFFSET_ALL_MASK     (0xf    << 8)
+#define      MVNETA_RXQ_PKT_OFFSET_MASK(offs)   ((offs) << 8)
+#define MVNETA_RXQ_THRESHOLD_REG(q)             (0x14c0 + ((q) << 2))
+#define      MVNETA_RXQ_NON_OCCUPIED(v)         ((v) << 16)
+#define MVNETA_RXQ_BASE_ADDR_REG(q)             (0x1480 + ((q) << 2))
+#define MVNETA_RXQ_SIZE_REG(q)                  (0x14a0 + ((q) << 2))
+#define      MVNETA_RXQ_BUF_SIZE_SHIFT          19
+#define      MVNETA_RXQ_BUF_SIZE_MASK           (0x1fff << 19)
+#define MVNETA_RXQ_STATUS_REG(q)                (0x14e0 + ((q) << 2))
+#define      MVNETA_RXQ_OCCUPIED_ALL_MASK       0x3fff
+#define MVNETA_RXQ_STATUS_UPDATE_REG(q)         (0x1500 + ((q) << 2))
+#define      MVNETA_RXQ_ADD_NON_OCCUPIED_SHIFT  16
+#define      MVNETA_RXQ_ADD_NON_OCCUPIED_MAX    255
+#define MVNETA_PORT_RX_RESET                    0x1cc0
+#define      MVNETA_PORT_RX_DMA_RESET           BIT(0)
+#define MVNETA_PHY_ADDR                         0x2000
+#define      MVNETA_PHY_ADDR_MASK               0x1f
+#define MVNETA_SMI                              0x2004
+#define      MVNETA_PHY_REG_MASK                0x1f
+/* SMI register fields */
+#define     MVNETA_SMI_DATA_OFFS               0       /* Data */
+#define     MVNETA_SMI_DATA_MASK               (0xffff << MVNETA_SMI_DATA_OFFS)
+#define     MVNETA_SMI_DEV_ADDR_OFFS           16      /* PHY device address */
+#define     MVNETA_SMI_REG_ADDR_OFFS           21      /* PHY device reg addr*/
+#define     MVNETA_SMI_OPCODE_OFFS             26      /* Write/Read opcode */
+#define     MVNETA_SMI_OPCODE_READ             (1 << MVNETA_SMI_OPCODE_OFFS)
+#define     MVNETA_SMI_READ_VALID              (1 << 27)       /* Read Valid */
+#define     MVNETA_SMI_BUSY                    (1 << 28)       /* Busy */
+#define MVNETA_MBUS_RETRY                       0x2010
+#define MVNETA_UNIT_INTR_CAUSE                  0x2080
+#define MVNETA_UNIT_CONTROL                     0x20B0
+#define      MVNETA_PHY_POLLING_ENABLE          BIT(1)
+#define MVNETA_WIN_BASE(w)                      (0x2200 + ((w) << 3))
+#define MVNETA_WIN_SIZE(w)                      (0x2204 + ((w) << 3))
+#define MVNETA_WIN_REMAP(w)                     (0x2280 + ((w) << 2))
+#define MVNETA_BASE_ADDR_ENABLE                 0x2290
+#define MVNETA_PORT_CONFIG                      0x2400
+#define      MVNETA_UNI_PROMISC_MODE            BIT(0)
+#define      MVNETA_DEF_RXQ(q)                  ((q) << 1)
+#define      MVNETA_DEF_RXQ_ARP(q)              ((q) << 4)
+#define      MVNETA_TX_UNSET_ERR_SUM            BIT(12)
+#define      MVNETA_DEF_RXQ_TCP(q)              ((q) << 16)
+#define      MVNETA_DEF_RXQ_UDP(q)              ((q) << 19)
+#define      MVNETA_DEF_RXQ_BPDU(q)             ((q) << 22)
+#define      MVNETA_RX_CSUM_WITH_PSEUDO_HDR     BIT(25)
+#define      MVNETA_PORT_CONFIG_DEFL_VALUE(q)   (MVNETA_DEF_RXQ(q)       | \
+                                                MVNETA_DEF_RXQ_ARP(q)   | \
+                                                MVNETA_DEF_RXQ_TCP(q)   | \
+                                                MVNETA_DEF_RXQ_UDP(q)   | \
+                                                MVNETA_DEF_RXQ_BPDU(q)  | \
+                                                MVNETA_TX_UNSET_ERR_SUM | \
+                                                MVNETA_RX_CSUM_WITH_PSEUDO_HDR)
+#define MVNETA_PORT_CONFIG_EXTEND                0x2404
+#define MVNETA_MAC_ADDR_LOW                      0x2414
+#define MVNETA_MAC_ADDR_HIGH                     0x2418
+#define MVNETA_SDMA_CONFIG                       0x241c
+#define      MVNETA_SDMA_BRST_SIZE_16            4
+#define      MVNETA_RX_BRST_SZ_MASK(burst)       ((burst) << 1)
+#define      MVNETA_RX_NO_DATA_SWAP              BIT(4)
+#define      MVNETA_TX_NO_DATA_SWAP              BIT(5)
+#define      MVNETA_DESC_SWAP                    BIT(6)
+#define      MVNETA_TX_BRST_SZ_MASK(burst)       ((burst) << 22)
+#define MVNETA_PORT_STATUS                       0x2444
+#define      MVNETA_TX_IN_PRGRS                  BIT(1)
+#define      MVNETA_TX_FIFO_EMPTY                BIT(8)
+#define MVNETA_RX_MIN_FRAME_SIZE                 0x247c
+#define MVNETA_SERDES_CFG                       0x24A0
+#define      MVNETA_SGMII_SERDES_PROTO          0x0cc7
+#define      MVNETA_QSGMII_SERDES_PROTO                 0x0667
+#define MVNETA_TYPE_PRIO                         0x24bc
+#define      MVNETA_FORCE_UNI                    BIT(21)
+#define MVNETA_TXQ_CMD_1                         0x24e4
+#define MVNETA_TXQ_CMD                           0x2448
+#define      MVNETA_TXQ_DISABLE_SHIFT            8
+#define      MVNETA_TXQ_ENABLE_MASK              0x000000ff
+#define MVNETA_ACC_MODE                          0x2500
+#define MVNETA_CPU_MAP(cpu)                      (0x2540 + ((cpu) << 2))
+#define      MVNETA_CPU_RXQ_ACCESS_ALL_MASK      0x000000ff
+#define      MVNETA_CPU_TXQ_ACCESS_ALL_MASK      0x0000ff00
+#define MVNETA_RXQ_TIME_COAL_REG(q)              (0x2580 + ((q) << 2))
+
+/* Exception Interrupt Port/Queue Cause register */
+
+#define MVNETA_INTR_NEW_CAUSE                    0x25a0
+#define MVNETA_INTR_NEW_MASK                     0x25a4
+
+/* bits  0..7  = TXQ SENT, one bit per queue.
+ * bits  8..15 = RXQ OCCUP, one bit per queue.
+ * bits 16..23 = RXQ FREE, one bit per queue.
+ * bit  29 = OLD_REG_SUM, see old reg ?
+ * bit  30 = TX_ERR_SUM, one bit for 4 ports
+ * bit  31 = MISC_SUM,   one bit for 4 ports
+ */
+#define      MVNETA_TX_INTR_MASK(nr_txqs)        (((1 << nr_txqs) - 1) << 0)
+#define      MVNETA_TX_INTR_MASK_ALL             (0xff << 0)
+#define      MVNETA_RX_INTR_MASK(nr_rxqs)        (((1 << nr_rxqs) - 1) << 8)
+#define      MVNETA_RX_INTR_MASK_ALL             (0xff << 8)
+
+#define MVNETA_INTR_OLD_CAUSE                    0x25a8
+#define MVNETA_INTR_OLD_MASK                     0x25ac
+
+/* Data Path Port/Queue Cause Register */
+#define MVNETA_INTR_MISC_CAUSE                   0x25b0
+#define MVNETA_INTR_MISC_MASK                    0x25b4
+#define MVNETA_INTR_ENABLE                       0x25b8
+
+#define MVNETA_RXQ_CMD                           0x2680
+#define      MVNETA_RXQ_DISABLE_SHIFT            8
+#define      MVNETA_RXQ_ENABLE_MASK              0x000000ff
+#define MVETH_TXQ_TOKEN_COUNT_REG(q)             (0x2700 + ((q) << 4))
+#define MVETH_TXQ_TOKEN_CFG_REG(q)               (0x2704 + ((q) << 4))
+#define MVNETA_GMAC_CTRL_0                       0x2c00
+#define      MVNETA_GMAC_MAX_RX_SIZE_SHIFT       2
+#define      MVNETA_GMAC_MAX_RX_SIZE_MASK        0x7ffc
+#define      MVNETA_GMAC0_PORT_ENABLE            BIT(0)
+#define MVNETA_GMAC_CTRL_2                       0x2c08
+#define      MVNETA_GMAC2_PCS_ENABLE             BIT(3)
+#define      MVNETA_GMAC2_PORT_RGMII             BIT(4)
+#define      MVNETA_GMAC2_PORT_RESET             BIT(6)
+#define MVNETA_GMAC_STATUS                       0x2c10
+#define      MVNETA_GMAC_LINK_UP                 BIT(0)
+#define      MVNETA_GMAC_SPEED_1000              BIT(1)
+#define      MVNETA_GMAC_SPEED_100               BIT(2)
+#define      MVNETA_GMAC_FULL_DUPLEX             BIT(3)
+#define      MVNETA_GMAC_RX_FLOW_CTRL_ENABLE     BIT(4)
+#define      MVNETA_GMAC_TX_FLOW_CTRL_ENABLE     BIT(5)
+#define      MVNETA_GMAC_RX_FLOW_CTRL_ACTIVE     BIT(6)
+#define      MVNETA_GMAC_TX_FLOW_CTRL_ACTIVE     BIT(7)
+#define MVNETA_GMAC_AUTONEG_CONFIG               0x2c0c
+#define      MVNETA_GMAC_FORCE_LINK_DOWN         BIT(0)
+#define      MVNETA_GMAC_FORCE_LINK_PASS         BIT(1)
+#define      MVNETA_GMAC_CONFIG_MII_SPEED        BIT(5)
+#define      MVNETA_GMAC_CONFIG_GMII_SPEED       BIT(6)
+#define      MVNETA_GMAC_AN_SPEED_EN             BIT(7)
+#define      MVNETA_GMAC_CONFIG_FULL_DUPLEX      BIT(12)
+#define      MVNETA_GMAC_AN_DUPLEX_EN            BIT(13)
+#define MVNETA_MIB_COUNTERS_BASE                 0x3080
+#define      MVNETA_MIB_LATE_COLLISION           0x7c
+#define MVNETA_DA_FILT_SPEC_MCAST                0x3400
+#define MVNETA_DA_FILT_OTH_MCAST                 0x3500
+#define MVNETA_DA_FILT_UCAST_BASE                0x3600
+#define MVNETA_TXQ_BASE_ADDR_REG(q)              (0x3c00 + ((q) << 2))
+#define MVNETA_TXQ_SIZE_REG(q)                   (0x3c20 + ((q) << 2))
+#define      MVNETA_TXQ_SENT_THRESH_ALL_MASK     0x3fff0000
+#define      MVNETA_TXQ_SENT_THRESH_MASK(coal)   ((coal) << 16)
+#define MVNETA_TXQ_UPDATE_REG(q)                 (0x3c60 + ((q) << 2))
+#define      MVNETA_TXQ_DEC_SENT_SHIFT           16
+#define MVNETA_TXQ_STATUS_REG(q)                 (0x3c40 + ((q) << 2))
+#define      MVNETA_TXQ_SENT_DESC_SHIFT          16
+#define      MVNETA_TXQ_SENT_DESC_MASK           0x3fff0000
+#define MVNETA_PORT_TX_RESET                     0x3cf0
+#define      MVNETA_PORT_TX_DMA_RESET            BIT(0)
+#define MVNETA_TX_MTU                            0x3e0c
+#define MVNETA_TX_TOKEN_SIZE                     0x3e14
+#define      MVNETA_TX_TOKEN_SIZE_MAX            0xffffffff
+#define MVNETA_TXQ_TOKEN_SIZE_REG(q)             (0x3e40 + ((q) << 2))
+#define      MVNETA_TXQ_TOKEN_SIZE_MAX           0x7fffffff
+
+/* Descriptor ring Macros */
+#define MVNETA_QUEUE_NEXT_DESC(q, index)       \
+       (((index) < (q)->last_desc) ? ((index) + 1) : 0)
+
+/* Various constants */
+
+/* Coalescing */
+#define MVNETA_TXDONE_COAL_PKTS                16
+#define MVNETA_RX_COAL_PKTS            32
+#define MVNETA_RX_COAL_USEC            100
+
+/* The two bytes Marvell header. Either contains a special value used
+ * by Marvell switches when a specific hardware mode is enabled (not
+ * supported by this driver) or is filled automatically by zeroes on
+ * the RX side. Those two bytes being at the front of the Ethernet
+ * header, they allow to have the IP header aligned on a 4 bytes
+ * boundary automatically: the hardware skips those two bytes on its
+ * own.
+ */
+#define MVNETA_MH_SIZE                 2
+
+#define MVNETA_VLAN_TAG_LEN             4
+
+#define MVNETA_CPU_D_CACHE_LINE_SIZE    32
+#define MVNETA_TX_CSUM_MAX_SIZE                9800
+#define MVNETA_ACC_MODE_EXT            1
+
+/* Timeout constants */
+#define MVNETA_TX_DISABLE_TIMEOUT_MSEC 1000
+#define MVNETA_RX_DISABLE_TIMEOUT_MSEC 1000
+#define MVNETA_TX_FIFO_EMPTY_TIMEOUT   10000
+
+#define MVNETA_TX_MTU_MAX              0x3ffff
+
+/* Max number of Rx descriptors */
+#define MVNETA_MAX_RXD 16
+
+/* Max number of Tx descriptors */
+#define MVNETA_MAX_TXD 16
+
+/* descriptor aligned size */
+#define MVNETA_DESC_ALIGNED_SIZE       32
+
+struct mvneta_port {
+       void __iomem *base;
+       struct mvneta_rx_queue *rxqs;
+       struct mvneta_tx_queue *txqs;
+
+       u8 mcast_count[256];
+       u16 tx_ring_size;
+       u16 rx_ring_size;
+
+       phy_interface_t phy_interface;
+       unsigned int link;
+       unsigned int duplex;
+       unsigned int speed;
+
+       int init;
+       int phyaddr;
+       struct phy_device *phydev;
+       struct mii_dev *bus;
+};
+
+/* The mvneta_tx_desc and mvneta_rx_desc structures describe the
+ * layout of the transmit and reception DMA descriptors, and their
+ * layout is therefore defined by the hardware design
+ */
+
+#define MVNETA_TX_L3_OFF_SHIFT 0
+#define MVNETA_TX_IP_HLEN_SHIFT        8
+#define MVNETA_TX_L4_UDP       BIT(16)
+#define MVNETA_TX_L3_IP6       BIT(17)
+#define MVNETA_TXD_IP_CSUM     BIT(18)
+#define MVNETA_TXD_Z_PAD       BIT(19)
+#define MVNETA_TXD_L_DESC      BIT(20)
+#define MVNETA_TXD_F_DESC      BIT(21)
+#define MVNETA_TXD_FLZ_DESC    (MVNETA_TXD_Z_PAD  | \
+                                MVNETA_TXD_L_DESC | \
+                                MVNETA_TXD_F_DESC)
+#define MVNETA_TX_L4_CSUM_FULL BIT(30)
+#define MVNETA_TX_L4_CSUM_NOT  BIT(31)
+
+#define MVNETA_RXD_ERR_CRC             0x0
+#define MVNETA_RXD_ERR_SUMMARY         BIT(16)
+#define MVNETA_RXD_ERR_OVERRUN         BIT(17)
+#define MVNETA_RXD_ERR_LEN             BIT(18)
+#define MVNETA_RXD_ERR_RESOURCE                (BIT(17) | BIT(18))
+#define MVNETA_RXD_ERR_CODE_MASK       (BIT(17) | BIT(18))
+#define MVNETA_RXD_L3_IP4              BIT(25)
+#define MVNETA_RXD_FIRST_LAST_DESC     (BIT(26) | BIT(27))
+#define MVNETA_RXD_L4_CSUM_OK          BIT(30)
+
+struct mvneta_tx_desc {
+       u32  command;           /* Options used by HW for packet transmitting.*/
+       u16  reserverd1;        /* csum_l4 (for future use)             */
+       u16  data_size;         /* Data size of transmitted packet in bytes */
+       u32  buf_phys_addr;     /* Physical addr of transmitted buffer  */
+       u32  reserved2;         /* hw_cmd - (for future use, PMT)       */
+       u32  reserved3[4];      /* Reserved - (for future use)          */
+};
+
+struct mvneta_rx_desc {
+       u32  status;            /* Info about received packet           */
+       u16  reserved1;         /* pnc_info - (for future use, PnC)     */
+       u16  data_size;         /* Size of received packet in bytes     */
+
+       u32  buf_phys_addr;     /* Physical address of the buffer       */
+       u32  reserved2;         /* pnc_flow_id  (for future use, PnC)   */
+
+       u32  buf_cookie;        /* cookie for access to RX buffer in rx path */
+       u16  reserved3;         /* prefetch_cmd, for future use         */
+       u16  reserved4;         /* csum_l4 - (for future use, PnC)      */
+
+       u32  reserved5;         /* pnc_extra PnC (for future use, PnC)  */
+       u32  reserved6;         /* hw_cmd (for future use, PnC and HWF) */
+};
+
+struct mvneta_tx_queue {
+       /* Number of this TX queue, in the range 0-7 */
+       u8 id;
+
+       /* Number of TX DMA descriptors in the descriptor ring */
+       int size;
+
+       /* Index of last TX DMA descriptor that was inserted */
+       int txq_put_index;
+
+       /* Index of the TX DMA descriptor to be cleaned up */
+       int txq_get_index;
+
+       /* Virtual address of the TX DMA descriptors array */
+       struct mvneta_tx_desc *descs;
+
+       /* DMA address of the TX DMA descriptors array */
+       dma_addr_t descs_phys;
+
+       /* Index of the last TX DMA descriptor */
+       int last_desc;
+
+       /* Index of the next TX DMA descriptor to process */
+       int next_desc_to_proc;
+};
+
+struct mvneta_rx_queue {
+       /* rx queue number, in the range 0-7 */
+       u8 id;
+
+       /* num of rx descriptors in the rx descriptor ring */
+       int size;
+
+       /* Virtual address of the RX DMA descriptors array */
+       struct mvneta_rx_desc *descs;
+
+       /* DMA address of the RX DMA descriptors array */
+       dma_addr_t descs_phys;
+
+       /* Index of the last RX DMA descriptor */
+       int last_desc;
+
+       /* Index of the next RX DMA descriptor to process */
+       int next_desc_to_proc;
+};
+
+/* U-Boot doesn't use the queues, so set the number to 1 */
+static int rxq_number = 1;
+static int txq_number = 1;
+static int rxq_def;
+
+struct buffer_location {
+       struct mvneta_tx_desc *tx_descs;
+       struct mvneta_rx_desc *rx_descs;
+       u32 rx_buffers;
+};
+
+/*
+ * All 4 interfaces use the same global buffer, since only one interface
+ * can be enabled at once
+ */
+static struct buffer_location buffer_loc;
+
+/*
+ * Page table entries are set to 1MB, or multiples of 1MB
+ * (not < 1MB). driver uses less bd's so use 1MB bdspace.
+ */
+#define BD_SPACE       (1 << 20)
+
+/* Utility/helper methods */
+
+/* Write helper method */
+static void mvreg_write(struct mvneta_port *pp, u32 offset, u32 data)
+{
+       writel(data, pp->base + offset);
+}
+
+/* Read helper method */
+static u32 mvreg_read(struct mvneta_port *pp, u32 offset)
+{
+       return readl(pp->base + offset);
+}
+
+/* Clear all MIB counters */
+static void mvneta_mib_counters_clear(struct mvneta_port *pp)
+{
+       int i;
+
+       /* Perform dummy reads from MIB counters */
+       for (i = 0; i < MVNETA_MIB_LATE_COLLISION; i += 4)
+               mvreg_read(pp, (MVNETA_MIB_COUNTERS_BASE + i));
+}
+
+/* Rx descriptors helper methods */
+
+/* Checks whether the RX descriptor having this status is both the first
+ * and the last descriptor for the RX packet. Each RX packet is currently
+ * received through a single RX descriptor, so not having each RX
+ * descriptor with its first and last bits set is an error
+ */
+static int mvneta_rxq_desc_is_first_last(u32 status)
+{
+       return (status & MVNETA_RXD_FIRST_LAST_DESC) ==
+               MVNETA_RXD_FIRST_LAST_DESC;
+}
+
+/* Add number of descriptors ready to receive new packets */
+static void mvneta_rxq_non_occup_desc_add(struct mvneta_port *pp,
+                                         struct mvneta_rx_queue *rxq,
+                                         int ndescs)
+{
+       /* Only MVNETA_RXQ_ADD_NON_OCCUPIED_MAX (255) descriptors can
+        * be added at once
+        */
+       while (ndescs > MVNETA_RXQ_ADD_NON_OCCUPIED_MAX) {
+               mvreg_write(pp, MVNETA_RXQ_STATUS_UPDATE_REG(rxq->id),
+                           (MVNETA_RXQ_ADD_NON_OCCUPIED_MAX <<
+                            MVNETA_RXQ_ADD_NON_OCCUPIED_SHIFT));
+               ndescs -= MVNETA_RXQ_ADD_NON_OCCUPIED_MAX;
+       }
+
+       mvreg_write(pp, MVNETA_RXQ_STATUS_UPDATE_REG(rxq->id),
+                   (ndescs << MVNETA_RXQ_ADD_NON_OCCUPIED_SHIFT));
+}
+
+/* Get number of RX descriptors occupied by received packets */
+static int mvneta_rxq_busy_desc_num_get(struct mvneta_port *pp,
+                                       struct mvneta_rx_queue *rxq)
+{
+       u32 val;
+
+       val = mvreg_read(pp, MVNETA_RXQ_STATUS_REG(rxq->id));
+       return val & MVNETA_RXQ_OCCUPIED_ALL_MASK;
+}
+
+/* Update num of rx desc called upon return from rx path or
+ * from mvneta_rxq_drop_pkts().
+ */
+static void mvneta_rxq_desc_num_update(struct mvneta_port *pp,
+                                      struct mvneta_rx_queue *rxq,
+                                      int rx_done, int rx_filled)
+{
+       u32 val;
+
+       if ((rx_done <= 0xff) && (rx_filled <= 0xff)) {
+               val = rx_done |
+                 (rx_filled << MVNETA_RXQ_ADD_NON_OCCUPIED_SHIFT);
+               mvreg_write(pp, MVNETA_RXQ_STATUS_UPDATE_REG(rxq->id), val);
+               return;
+       }
+
+       /* Only 255 descriptors can be added at once */
+       while ((rx_done > 0) || (rx_filled > 0)) {
+               if (rx_done <= 0xff) {
+                       val = rx_done;
+                       rx_done = 0;
+               } else {
+                       val = 0xff;
+                       rx_done -= 0xff;
+               }
+               if (rx_filled <= 0xff) {
+                       val |= rx_filled << MVNETA_RXQ_ADD_NON_OCCUPIED_SHIFT;
+                       rx_filled = 0;
+               } else {
+                       val |= 0xff << MVNETA_RXQ_ADD_NON_OCCUPIED_SHIFT;
+                       rx_filled -= 0xff;
+               }
+               mvreg_write(pp, MVNETA_RXQ_STATUS_UPDATE_REG(rxq->id), val);
+       }
+}
+
+/* Get pointer to next RX descriptor to be processed by SW */
+static struct mvneta_rx_desc *
+mvneta_rxq_next_desc_get(struct mvneta_rx_queue *rxq)
+{
+       int rx_desc = rxq->next_desc_to_proc;
+
+       rxq->next_desc_to_proc = MVNETA_QUEUE_NEXT_DESC(rxq, rx_desc);
+       return rxq->descs + rx_desc;
+}
+
+/* Tx descriptors helper methods */
+
+/* Update HW with number of TX descriptors to be sent */
+static void mvneta_txq_pend_desc_add(struct mvneta_port *pp,
+                                    struct mvneta_tx_queue *txq,
+                                    int pend_desc)
+{
+       u32 val;
+
+       /* Only 255 descriptors can be added at once ; Assume caller
+        * process TX desriptors in quanta less than 256
+        */
+       val = pend_desc;
+       mvreg_write(pp, MVNETA_TXQ_UPDATE_REG(txq->id), val);
+}
+
+/* Get pointer to next TX descriptor to be processed (send) by HW */
+static struct mvneta_tx_desc *
+mvneta_txq_next_desc_get(struct mvneta_tx_queue *txq)
+{
+       int tx_desc = txq->next_desc_to_proc;
+
+       txq->next_desc_to_proc = MVNETA_QUEUE_NEXT_DESC(txq, tx_desc);
+       return txq->descs + tx_desc;
+}
+
+/* Set rxq buf size */
+static void mvneta_rxq_buf_size_set(struct mvneta_port *pp,
+                                   struct mvneta_rx_queue *rxq,
+                                   int buf_size)
+{
+       u32 val;
+
+       val = mvreg_read(pp, MVNETA_RXQ_SIZE_REG(rxq->id));
+
+       val &= ~MVNETA_RXQ_BUF_SIZE_MASK;
+       val |= ((buf_size >> 3) << MVNETA_RXQ_BUF_SIZE_SHIFT);
+
+       mvreg_write(pp, MVNETA_RXQ_SIZE_REG(rxq->id), val);
+}
+
+/* Start the Ethernet port RX and TX activity */
+static void mvneta_port_up(struct mvneta_port *pp)
+{
+       int queue;
+       u32 q_map;
+
+       /* Enable all initialized TXs. */
+       mvneta_mib_counters_clear(pp);
+       q_map = 0;
+       for (queue = 0; queue < txq_number; queue++) {
+               struct mvneta_tx_queue *txq = &pp->txqs[queue];
+               if (txq->descs != NULL)
+                       q_map |= (1 << queue);
+       }
+       mvreg_write(pp, MVNETA_TXQ_CMD, q_map);
+
+       /* Enable all initialized RXQs. */
+       q_map = 0;
+       for (queue = 0; queue < rxq_number; queue++) {
+               struct mvneta_rx_queue *rxq = &pp->rxqs[queue];
+               if (rxq->descs != NULL)
+                       q_map |= (1 << queue);
+       }
+       mvreg_write(pp, MVNETA_RXQ_CMD, q_map);
+}
+
+/* Stop the Ethernet port activity */
+static void mvneta_port_down(struct mvneta_port *pp)
+{
+       u32 val;
+       int count;
+
+       /* Stop Rx port activity. Check port Rx activity. */
+       val = mvreg_read(pp, MVNETA_RXQ_CMD) & MVNETA_RXQ_ENABLE_MASK;
+
+       /* Issue stop command for active channels only */
+       if (val != 0)
+               mvreg_write(pp, MVNETA_RXQ_CMD,
+                           val << MVNETA_RXQ_DISABLE_SHIFT);
+
+       /* Wait for all Rx activity to terminate. */
+       count = 0;
+       do {
+               if (count++ >= MVNETA_RX_DISABLE_TIMEOUT_MSEC) {
+                       netdev_warn(pp->dev,
+                                   "TIMEOUT for RX stopped ! rx_queue_cmd: 0x08%x\n",
+                                   val);
+                       break;
+               }
+               mdelay(1);
+
+               val = mvreg_read(pp, MVNETA_RXQ_CMD);
+       } while (val & 0xff);
+
+       /* Stop Tx port activity. Check port Tx activity. Issue stop
+        * command for active channels only
+        */
+       val = (mvreg_read(pp, MVNETA_TXQ_CMD)) & MVNETA_TXQ_ENABLE_MASK;
+
+       if (val != 0)
+               mvreg_write(pp, MVNETA_TXQ_CMD,
+                           (val << MVNETA_TXQ_DISABLE_SHIFT));
+
+       /* Wait for all Tx activity to terminate. */
+       count = 0;
+       do {
+               if (count++ >= MVNETA_TX_DISABLE_TIMEOUT_MSEC) {
+                       netdev_warn(pp->dev,
+                                   "TIMEOUT for TX stopped status=0x%08x\n",
+                                   val);
+                       break;
+               }
+               mdelay(1);
+
+               /* Check TX Command reg that all Txqs are stopped */
+               val = mvreg_read(pp, MVNETA_TXQ_CMD);
+
+       } while (val & 0xff);
+
+       /* Double check to verify that TX FIFO is empty */
+       count = 0;
+       do {
+               if (count++ >= MVNETA_TX_FIFO_EMPTY_TIMEOUT) {
+                       netdev_warn(pp->dev,
+                                   "TX FIFO empty timeout status=0x08%x\n",
+                                   val);
+                       break;
+               }
+               mdelay(1);
+
+               val = mvreg_read(pp, MVNETA_PORT_STATUS);
+       } while (!(val & MVNETA_TX_FIFO_EMPTY) &&
+                (val & MVNETA_TX_IN_PRGRS));
+
+       udelay(200);
+}
+
+/* Enable the port by setting the port enable bit of the MAC control register */
+static void mvneta_port_enable(struct mvneta_port *pp)
+{
+       u32 val;
+
+       /* Enable port */
+       val = mvreg_read(pp, MVNETA_GMAC_CTRL_0);
+       val |= MVNETA_GMAC0_PORT_ENABLE;
+       mvreg_write(pp, MVNETA_GMAC_CTRL_0, val);
+}
+
+/* Disable the port and wait for about 200 usec before retuning */
+static void mvneta_port_disable(struct mvneta_port *pp)
+{
+       u32 val;
+
+       /* Reset the Enable bit in the Serial Control Register */
+       val = mvreg_read(pp, MVNETA_GMAC_CTRL_0);
+       val &= ~MVNETA_GMAC0_PORT_ENABLE;
+       mvreg_write(pp, MVNETA_GMAC_CTRL_0, val);
+
+       udelay(200);
+}
+
+/* Multicast tables methods */
+
+/* Set all entries in Unicast MAC Table; queue==-1 means reject all */
+static void mvneta_set_ucast_table(struct mvneta_port *pp, int queue)
+{
+       int offset;
+       u32 val;
+
+       if (queue == -1) {
+               val = 0;
+       } else {
+               val = 0x1 | (queue << 1);
+               val |= (val << 24) | (val << 16) | (val << 8);
+       }
+
+       for (offset = 0; offset <= 0xc; offset += 4)
+               mvreg_write(pp, MVNETA_DA_FILT_UCAST_BASE + offset, val);
+}
+
+/* Set all entries in Special Multicast MAC Table; queue==-1 means reject all */
+static void mvneta_set_special_mcast_table(struct mvneta_port *pp, int queue)
+{
+       int offset;
+       u32 val;
+
+       if (queue == -1) {
+               val = 0;
+       } else {
+               val = 0x1 | (queue << 1);
+               val |= (val << 24) | (val << 16) | (val << 8);
+       }
+
+       for (offset = 0; offset <= 0xfc; offset += 4)
+               mvreg_write(pp, MVNETA_DA_FILT_SPEC_MCAST + offset, val);
+}
+
+/* Set all entries in Other Multicast MAC Table. queue==-1 means reject all */
+static void mvneta_set_other_mcast_table(struct mvneta_port *pp, int queue)
+{
+       int offset;
+       u32 val;
+
+       if (queue == -1) {
+               memset(pp->mcast_count, 0, sizeof(pp->mcast_count));
+               val = 0;
+       } else {
+               memset(pp->mcast_count, 1, sizeof(pp->mcast_count));
+               val = 0x1 | (queue << 1);
+               val |= (val << 24) | (val << 16) | (val << 8);
+       }
+
+       for (offset = 0; offset <= 0xfc; offset += 4)
+               mvreg_write(pp, MVNETA_DA_FILT_OTH_MCAST + offset, val);
+}
+
+/* This method sets defaults to the NETA port:
+ *     Clears interrupt Cause and Mask registers.
+ *     Clears all MAC tables.
+ *     Sets defaults to all registers.
+ *     Resets RX and TX descriptor rings.
+ *     Resets PHY.
+ * This method can be called after mvneta_port_down() to return the port
+ *     settings to defaults.
+ */
+static void mvneta_defaults_set(struct mvneta_port *pp)
+{
+       int cpu;
+       int queue;
+       u32 val;
+
+       /* Clear all Cause registers */
+       mvreg_write(pp, MVNETA_INTR_NEW_CAUSE, 0);
+       mvreg_write(pp, MVNETA_INTR_OLD_CAUSE, 0);
+       mvreg_write(pp, MVNETA_INTR_MISC_CAUSE, 0);
+
+       /* Mask all interrupts */
+       mvreg_write(pp, MVNETA_INTR_NEW_MASK, 0);
+       mvreg_write(pp, MVNETA_INTR_OLD_MASK, 0);
+       mvreg_write(pp, MVNETA_INTR_MISC_MASK, 0);
+       mvreg_write(pp, MVNETA_INTR_ENABLE, 0);
+
+       /* Enable MBUS Retry bit16 */
+       mvreg_write(pp, MVNETA_MBUS_RETRY, 0x20);
+
+       /* Set CPU queue access map - all CPUs have access to all RX
+        * queues and to all TX queues
+        */
+       for (cpu = 0; cpu < CONFIG_NR_CPUS; cpu++)
+               mvreg_write(pp, MVNETA_CPU_MAP(cpu),
+                           (MVNETA_CPU_RXQ_ACCESS_ALL_MASK |
+                            MVNETA_CPU_TXQ_ACCESS_ALL_MASK));
+
+       /* Reset RX and TX DMAs */
+       mvreg_write(pp, MVNETA_PORT_RX_RESET, MVNETA_PORT_RX_DMA_RESET);
+       mvreg_write(pp, MVNETA_PORT_TX_RESET, MVNETA_PORT_TX_DMA_RESET);
+
+       /* Disable Legacy WRR, Disable EJP, Release from reset */
+       mvreg_write(pp, MVNETA_TXQ_CMD_1, 0);
+       for (queue = 0; queue < txq_number; queue++) {
+               mvreg_write(pp, MVETH_TXQ_TOKEN_COUNT_REG(queue), 0);
+               mvreg_write(pp, MVETH_TXQ_TOKEN_CFG_REG(queue), 0);
+       }
+
+       mvreg_write(pp, MVNETA_PORT_TX_RESET, 0);
+       mvreg_write(pp, MVNETA_PORT_RX_RESET, 0);
+
+       /* Set Port Acceleration Mode */
+       val = MVNETA_ACC_MODE_EXT;
+       mvreg_write(pp, MVNETA_ACC_MODE, val);
+
+       /* Update val of portCfg register accordingly with all RxQueue types */
+       val = MVNETA_PORT_CONFIG_DEFL_VALUE(rxq_def);
+       mvreg_write(pp, MVNETA_PORT_CONFIG, val);
+
+       val = 0;
+       mvreg_write(pp, MVNETA_PORT_CONFIG_EXTEND, val);
+       mvreg_write(pp, MVNETA_RX_MIN_FRAME_SIZE, 64);
+
+       /* Build PORT_SDMA_CONFIG_REG */
+       val = 0;
+
+       /* Default burst size */
+       val |= MVNETA_TX_BRST_SZ_MASK(MVNETA_SDMA_BRST_SIZE_16);
+       val |= MVNETA_RX_BRST_SZ_MASK(MVNETA_SDMA_BRST_SIZE_16);
+       val |= MVNETA_RX_NO_DATA_SWAP | MVNETA_TX_NO_DATA_SWAP;
+
+       /* Assign port SDMA configuration */
+       mvreg_write(pp, MVNETA_SDMA_CONFIG, val);
+
+       /* Enable PHY polling in hardware for U-Boot */
+       val = mvreg_read(pp, MVNETA_UNIT_CONTROL);
+       val |= MVNETA_PHY_POLLING_ENABLE;
+       mvreg_write(pp, MVNETA_UNIT_CONTROL, val);
+
+       mvneta_set_ucast_table(pp, -1);
+       mvneta_set_special_mcast_table(pp, -1);
+       mvneta_set_other_mcast_table(pp, -1);
+}
+
+/* Set unicast address */
+static void mvneta_set_ucast_addr(struct mvneta_port *pp, u8 last_nibble,
+                                 int queue)
+{
+       unsigned int unicast_reg;
+       unsigned int tbl_offset;
+       unsigned int reg_offset;
+
+       /* Locate the Unicast table entry */
+       last_nibble = (0xf & last_nibble);
+
+       /* offset from unicast tbl base */
+       tbl_offset = (last_nibble / 4) * 4;
+
+       /* offset within the above reg  */
+       reg_offset = last_nibble % 4;
+
+       unicast_reg = mvreg_read(pp, (MVNETA_DA_FILT_UCAST_BASE + tbl_offset));
+
+       if (queue == -1) {
+               /* Clear accepts frame bit at specified unicast DA tbl entry */
+               unicast_reg &= ~(0xff << (8 * reg_offset));
+       } else {
+               unicast_reg &= ~(0xff << (8 * reg_offset));
+               unicast_reg |= ((0x01 | (queue << 1)) << (8 * reg_offset));
+       }
+
+       mvreg_write(pp, (MVNETA_DA_FILT_UCAST_BASE + tbl_offset), unicast_reg);
+}
+
+/* Set mac address */
+static void mvneta_mac_addr_set(struct mvneta_port *pp, unsigned char *addr,
+                               int queue)
+{
+       unsigned int mac_h;
+       unsigned int mac_l;
+
+       if (queue != -1) {
+               mac_l = (addr[4] << 8) | (addr[5]);
+               mac_h = (addr[0] << 24) | (addr[1] << 16) |
+                       (addr[2] << 8) | (addr[3] << 0);
+
+               mvreg_write(pp, MVNETA_MAC_ADDR_LOW, mac_l);
+               mvreg_write(pp, MVNETA_MAC_ADDR_HIGH, mac_h);
+       }
+
+       /* Accept frames of this address */
+       mvneta_set_ucast_addr(pp, addr[5], queue);
+}
+
+/* Handle rx descriptor fill by setting buf_cookie and buf_phys_addr */
+static void mvneta_rx_desc_fill(struct mvneta_rx_desc *rx_desc,
+                               u32 phys_addr, u32 cookie)
+{
+       rx_desc->buf_cookie = cookie;
+       rx_desc->buf_phys_addr = phys_addr;
+}
+
+/* Decrement sent descriptors counter */
+static void mvneta_txq_sent_desc_dec(struct mvneta_port *pp,
+                                    struct mvneta_tx_queue *txq,
+                                    int sent_desc)
+{
+       u32 val;
+
+       /* Only 255 TX descriptors can be updated at once */
+       while (sent_desc > 0xff) {
+               val = 0xff << MVNETA_TXQ_DEC_SENT_SHIFT;
+               mvreg_write(pp, MVNETA_TXQ_UPDATE_REG(txq->id), val);
+               sent_desc = sent_desc - 0xff;
+       }
+
+       val = sent_desc << MVNETA_TXQ_DEC_SENT_SHIFT;
+       mvreg_write(pp, MVNETA_TXQ_UPDATE_REG(txq->id), val);
+}
+
+/* Get number of TX descriptors already sent by HW */
+static int mvneta_txq_sent_desc_num_get(struct mvneta_port *pp,
+                                       struct mvneta_tx_queue *txq)
+{
+       u32 val;
+       int sent_desc;
+
+       val = mvreg_read(pp, MVNETA_TXQ_STATUS_REG(txq->id));
+       sent_desc = (val & MVNETA_TXQ_SENT_DESC_MASK) >>
+               MVNETA_TXQ_SENT_DESC_SHIFT;
+
+       return sent_desc;
+}
+
+/* Display more error info */
+static void mvneta_rx_error(struct mvneta_port *pp,
+                           struct mvneta_rx_desc *rx_desc)
+{
+       u32 status = rx_desc->status;
+
+       if (!mvneta_rxq_desc_is_first_last(status)) {
+               netdev_err(pp->dev,
+                          "bad rx status %08x (buffer oversize), size=%d\n",
+                          status, rx_desc->data_size);
+               return;
+       }
+
+       switch (status & MVNETA_RXD_ERR_CODE_MASK) {
+       case MVNETA_RXD_ERR_CRC:
+               netdev_err(pp->dev, "bad rx status %08x (crc error), size=%d\n",
+                          status, rx_desc->data_size);
+               break;
+       case MVNETA_RXD_ERR_OVERRUN:
+               netdev_err(pp->dev, "bad rx status %08x (overrun error), size=%d\n",
+                          status, rx_desc->data_size);
+               break;
+       case MVNETA_RXD_ERR_LEN:
+               netdev_err(pp->dev, "bad rx status %08x (max frame length error), size=%d\n",
+                          status, rx_desc->data_size);
+               break;
+       case MVNETA_RXD_ERR_RESOURCE:
+               netdev_err(pp->dev, "bad rx status %08x (resource error), size=%d\n",
+                          status, rx_desc->data_size);
+               break;
+       }
+}
+
+static struct mvneta_rx_queue *mvneta_rxq_handle_get(struct mvneta_port *pp,
+                                                    int rxq)
+{
+       return &pp->rxqs[rxq];
+}
+
+
+/* Drop packets received by the RXQ and free buffers */
+static void mvneta_rxq_drop_pkts(struct mvneta_port *pp,
+                                struct mvneta_rx_queue *rxq)
+{
+       int rx_done;
+
+       rx_done = mvneta_rxq_busy_desc_num_get(pp, rxq);
+       if (rx_done)
+               mvneta_rxq_desc_num_update(pp, rxq, rx_done, rx_done);
+}
+
+/* Handle rxq fill: allocates rxq skbs; called when initializing a port */
+static int mvneta_rxq_fill(struct mvneta_port *pp, struct mvneta_rx_queue *rxq,
+                          int num)
+{
+       int i;
+
+       for (i = 0; i < num; i++) {
+               u32 addr;
+
+               /* U-Boot special: Fill in the rx buffer addresses */
+               addr = buffer_loc.rx_buffers + (i * RX_BUFFER_SIZE);
+               mvneta_rx_desc_fill(rxq->descs + i, addr, addr);
+       }
+
+       /* Add this number of RX descriptors as non occupied (ready to
+        * get packets)
+        */
+       mvneta_rxq_non_occup_desc_add(pp, rxq, i);
+
+       return 0;
+}
+
+/* Rx/Tx queue initialization/cleanup methods */
+
+/* Create a specified RX queue */
+static int mvneta_rxq_init(struct mvneta_port *pp,
+                          struct mvneta_rx_queue *rxq)
+
+{
+       rxq->size = pp->rx_ring_size;
+
+       /* Allocate memory for RX descriptors */
+       rxq->descs_phys = (dma_addr_t)rxq->descs;
+       if (rxq->descs == NULL)
+               return -ENOMEM;
+
+       rxq->last_desc = rxq->size - 1;
+
+       /* Set Rx descriptors queue starting address */
+       mvreg_write(pp, MVNETA_RXQ_BASE_ADDR_REG(rxq->id), rxq->descs_phys);
+       mvreg_write(pp, MVNETA_RXQ_SIZE_REG(rxq->id), rxq->size);
+
+       /* Fill RXQ with buffers from RX pool */
+       mvneta_rxq_buf_size_set(pp, rxq, RX_BUFFER_SIZE);
+       mvneta_rxq_fill(pp, rxq, rxq->size);
+
+       return 0;
+}
+
+/* Cleanup Rx queue */
+static void mvneta_rxq_deinit(struct mvneta_port *pp,
+                             struct mvneta_rx_queue *rxq)
+{
+       mvneta_rxq_drop_pkts(pp, rxq);
+
+       rxq->descs             = NULL;
+       rxq->last_desc         = 0;
+       rxq->next_desc_to_proc = 0;
+       rxq->descs_phys        = 0;
+}
+
+/* Create and initialize a tx queue */
+static int mvneta_txq_init(struct mvneta_port *pp,
+                          struct mvneta_tx_queue *txq)
+{
+       txq->size = pp->tx_ring_size;
+
+       /* Allocate memory for TX descriptors */
+       txq->descs_phys = (u32)txq->descs;
+       if (txq->descs == NULL)
+               return -ENOMEM;
+
+       txq->last_desc = txq->size - 1;
+
+       /* Set maximum bandwidth for enabled TXQs */
+       mvreg_write(pp, MVETH_TXQ_TOKEN_CFG_REG(txq->id), 0x03ffffff);
+       mvreg_write(pp, MVETH_TXQ_TOKEN_COUNT_REG(txq->id), 0x3fffffff);
+
+       /* Set Tx descriptors queue starting address */
+       mvreg_write(pp, MVNETA_TXQ_BASE_ADDR_REG(txq->id), txq->descs_phys);
+       mvreg_write(pp, MVNETA_TXQ_SIZE_REG(txq->id), txq->size);
+
+       return 0;
+}
+
+/* Free allocated resources when mvneta_txq_init() fails to allocate memory*/
+static void mvneta_txq_deinit(struct mvneta_port *pp,
+                             struct mvneta_tx_queue *txq)
+{
+       txq->descs             = NULL;
+       txq->last_desc         = 0;
+       txq->next_desc_to_proc = 0;
+       txq->descs_phys        = 0;
+
+       /* Set minimum bandwidth for disabled TXQs */
+       mvreg_write(pp, MVETH_TXQ_TOKEN_CFG_REG(txq->id), 0);
+       mvreg_write(pp, MVETH_TXQ_TOKEN_COUNT_REG(txq->id), 0);
+
+       /* Set Tx descriptors queue starting address and size */
+       mvreg_write(pp, MVNETA_TXQ_BASE_ADDR_REG(txq->id), 0);
+       mvreg_write(pp, MVNETA_TXQ_SIZE_REG(txq->id), 0);
+}
+
+/* Cleanup all Tx queues */
+static void mvneta_cleanup_txqs(struct mvneta_port *pp)
+{
+       int queue;
+
+       for (queue = 0; queue < txq_number; queue++)
+               mvneta_txq_deinit(pp, &pp->txqs[queue]);
+}
+
+/* Cleanup all Rx queues */
+static void mvneta_cleanup_rxqs(struct mvneta_port *pp)
+{
+       int queue;
+
+       for (queue = 0; queue < rxq_number; queue++)
+               mvneta_rxq_deinit(pp, &pp->rxqs[queue]);
+}
+
+
+/* Init all Rx queues */
+static int mvneta_setup_rxqs(struct mvneta_port *pp)
+{
+       int queue;
+
+       for (queue = 0; queue < rxq_number; queue++) {
+               int err = mvneta_rxq_init(pp, &pp->rxqs[queue]);
+               if (err) {
+                       netdev_err(pp->dev, "%s: can't create rxq=%d\n",
+                                  __func__, queue);
+                       mvneta_cleanup_rxqs(pp);
+                       return err;
+               }
+       }
+
+       return 0;
+}
+
+/* Init all tx queues */
+static int mvneta_setup_txqs(struct mvneta_port *pp)
+{
+       int queue;
+
+       for (queue = 0; queue < txq_number; queue++) {
+               int err = mvneta_txq_init(pp, &pp->txqs[queue]);
+               if (err) {
+                       netdev_err(pp->dev, "%s: can't create txq=%d\n",
+                                  __func__, queue);
+                       mvneta_cleanup_txqs(pp);
+                       return err;
+               }
+       }
+
+       return 0;
+}
+
+static void mvneta_start_dev(struct mvneta_port *pp)
+{
+       /* start the Rx/Tx activity */
+       mvneta_port_enable(pp);
+}
+
+static void mvneta_adjust_link(struct eth_device *dev)
+{
+       struct mvneta_port *pp = dev->priv;
+       struct phy_device *phydev = pp->phydev;
+       int status_change = 0;
+
+       if (phydev->link) {
+               if ((pp->speed != phydev->speed) ||
+                   (pp->duplex != phydev->duplex)) {
+                       u32 val;
+
+                       val = mvreg_read(pp, MVNETA_GMAC_AUTONEG_CONFIG);
+                       val &= ~(MVNETA_GMAC_CONFIG_MII_SPEED |
+                                MVNETA_GMAC_CONFIG_GMII_SPEED |
+                                MVNETA_GMAC_CONFIG_FULL_DUPLEX |
+                                MVNETA_GMAC_AN_SPEED_EN |
+                                MVNETA_GMAC_AN_DUPLEX_EN);
+
+                       if (phydev->duplex)
+                               val |= MVNETA_GMAC_CONFIG_FULL_DUPLEX;
+
+                       if (phydev->speed == SPEED_1000)
+                               val |= MVNETA_GMAC_CONFIG_GMII_SPEED;
+                       else
+                               val |= MVNETA_GMAC_CONFIG_MII_SPEED;
+
+                       mvreg_write(pp, MVNETA_GMAC_AUTONEG_CONFIG, val);
+
+                       pp->duplex = phydev->duplex;
+                       pp->speed  = phydev->speed;
+               }
+       }
+
+       if (phydev->link != pp->link) {
+               if (!phydev->link) {
+                       pp->duplex = -1;
+                       pp->speed = 0;
+               }
+
+               pp->link = phydev->link;
+               status_change = 1;
+       }
+
+       if (status_change) {
+               if (phydev->link) {
+                       u32 val = mvreg_read(pp, MVNETA_GMAC_AUTONEG_CONFIG);
+                       val |= (MVNETA_GMAC_FORCE_LINK_PASS |
+                               MVNETA_GMAC_FORCE_LINK_DOWN);
+                       mvreg_write(pp, MVNETA_GMAC_AUTONEG_CONFIG, val);
+                       mvneta_port_up(pp);
+               } else {
+                       mvneta_port_down(pp);
+               }
+       }
+}
+
+static int mvneta_open(struct eth_device *dev)
+{
+       struct mvneta_port *pp = dev->priv;
+       int ret;
+
+       ret = mvneta_setup_rxqs(pp);
+       if (ret)
+               return ret;
+
+       ret = mvneta_setup_txqs(pp);
+       if (ret)
+               return ret;
+
+       mvneta_adjust_link(dev);
+
+       mvneta_start_dev(pp);
+
+       return 0;
+}
+
+/* Initialize hw */
+static int mvneta_init(struct mvneta_port *pp)
+{
+       int queue;
+
+       /* Disable port */
+       mvneta_port_disable(pp);
+
+       /* Set port default values */
+       mvneta_defaults_set(pp);
+
+       pp->txqs = kzalloc(txq_number * sizeof(struct mvneta_tx_queue),
+                          GFP_KERNEL);
+       if (!pp->txqs)
+               return -ENOMEM;
+
+       /* U-Boot special: use preallocated area */
+       pp->txqs[0].descs = buffer_loc.tx_descs;
+
+       /* Initialize TX descriptor rings */
+       for (queue = 0; queue < txq_number; queue++) {
+               struct mvneta_tx_queue *txq = &pp->txqs[queue];
+               txq->id = queue;
+               txq->size = pp->tx_ring_size;
+       }
+
+       pp->rxqs = kzalloc(rxq_number * sizeof(struct mvneta_rx_queue),
+                          GFP_KERNEL);
+       if (!pp->rxqs) {
+               kfree(pp->txqs);
+               return -ENOMEM;
+       }
+
+       /* U-Boot special: use preallocated area */
+       pp->rxqs[0].descs = buffer_loc.rx_descs;
+
+       /* Create Rx descriptor rings */
+       for (queue = 0; queue < rxq_number; queue++) {
+               struct mvneta_rx_queue *rxq = &pp->rxqs[queue];
+               rxq->id = queue;
+               rxq->size = pp->rx_ring_size;
+       }
+
+       return 0;
+}
+
+/* platform glue : initialize decoding windows */
+static void mvneta_conf_mbus_windows(struct mvneta_port *pp)
+{
+       const struct mbus_dram_target_info *dram;
+       u32 win_enable;
+       u32 win_protect;
+       int i;
+
+       dram = mvebu_mbus_dram_info();
+       for (i = 0; i < 6; i++) {
+               mvreg_write(pp, MVNETA_WIN_BASE(i), 0);
+               mvreg_write(pp, MVNETA_WIN_SIZE(i), 0);
+
+               if (i < 4)
+                       mvreg_write(pp, MVNETA_WIN_REMAP(i), 0);
+       }
+
+       win_enable = 0x3f;
+       win_protect = 0;
+
+       for (i = 0; i < dram->num_cs; i++) {
+               const struct mbus_dram_window *cs = dram->cs + i;
+               mvreg_write(pp, MVNETA_WIN_BASE(i), (cs->base & 0xffff0000) |
+                           (cs->mbus_attr << 8) | dram->mbus_dram_target_id);
+
+               mvreg_write(pp, MVNETA_WIN_SIZE(i),
+                           (cs->size - 1) & 0xffff0000);
+
+               win_enable &= ~(1 << i);
+               win_protect |= 3 << (2 * i);
+       }
+
+       mvreg_write(pp, MVNETA_BASE_ADDR_ENABLE, win_enable);
+}
+
+/* Power up the port */
+static int mvneta_port_power_up(struct mvneta_port *pp, int phy_mode)
+{
+       u32 ctrl;
+
+       /* MAC Cause register should be cleared */
+       mvreg_write(pp, MVNETA_UNIT_INTR_CAUSE, 0);
+
+       ctrl = mvreg_read(pp, MVNETA_GMAC_CTRL_2);
+
+       /* Even though it might look weird, when we're configured in
+        * SGMII or QSGMII mode, the RGMII bit needs to be set.
+        */
+       switch (phy_mode) {
+       case PHY_INTERFACE_MODE_QSGMII:
+               mvreg_write(pp, MVNETA_SERDES_CFG, MVNETA_QSGMII_SERDES_PROTO);
+               ctrl |= MVNETA_GMAC2_PCS_ENABLE | MVNETA_GMAC2_PORT_RGMII;
+               break;
+       case PHY_INTERFACE_MODE_SGMII:
+               mvreg_write(pp, MVNETA_SERDES_CFG, MVNETA_SGMII_SERDES_PROTO);
+               ctrl |= MVNETA_GMAC2_PCS_ENABLE | MVNETA_GMAC2_PORT_RGMII;
+               break;
+       case PHY_INTERFACE_MODE_RGMII:
+       case PHY_INTERFACE_MODE_RGMII_ID:
+               ctrl |= MVNETA_GMAC2_PORT_RGMII;
+               break;
+       default:
+               return -EINVAL;
+       }
+
+       /* Cancel Port Reset */
+       ctrl &= ~MVNETA_GMAC2_PORT_RESET;
+       mvreg_write(pp, MVNETA_GMAC_CTRL_2, ctrl);
+
+       while ((mvreg_read(pp, MVNETA_GMAC_CTRL_2) &
+               MVNETA_GMAC2_PORT_RESET) != 0)
+               continue;
+
+       return 0;
+}
+
+/* Device initialization routine */
+static int mvneta_probe(struct eth_device *dev)
+{
+       struct mvneta_port *pp = dev->priv;
+       int err;
+
+       pp->tx_ring_size = MVNETA_MAX_TXD;
+       pp->rx_ring_size = MVNETA_MAX_RXD;
+
+       err = mvneta_init(pp);
+       if (err < 0) {
+               dev_err(&pdev->dev, "can't init eth hal\n");
+               return err;
+       }
+
+       mvneta_conf_mbus_windows(pp);
+
+       mvneta_mac_addr_set(pp, dev->enetaddr, rxq_def);
+
+       err = mvneta_port_power_up(pp, pp->phy_interface);
+       if (err < 0) {
+               dev_err(&pdev->dev, "can't power up port\n");
+               return err;
+       }
+
+       /* Call open() now as it needs to be done before runing send() */
+       mvneta_open(dev);
+
+       return 0;
+}
+
+/* U-Boot only functions follow here */
+
+/* SMI / MDIO functions */
+
+static int smi_wait_ready(struct mvneta_port *pp)
+{
+       u32 timeout = MVNETA_SMI_TIMEOUT;
+       u32 smi_reg;
+
+       /* wait till the SMI is not busy */
+       do {
+               /* read smi register */
+               smi_reg = mvreg_read(pp, MVNETA_SMI);
+               if (timeout-- == 0) {
+                       printf("Error: SMI busy timeout\n");
+                       return -EFAULT;
+               }
+       } while (smi_reg & MVNETA_SMI_BUSY);
+
+       return 0;
+}
+
+/*
+ * smi_reg_read - miiphy_read callback function.
+ *
+ * Returns 16bit phy register value, or 0xffff on error
+ */
+static int smi_reg_read(const char *devname, u8 phy_adr, u8 reg_ofs, u16 *data)
+{
+       struct eth_device *dev = eth_get_dev_by_name(devname);
+       struct mvneta_port *pp = dev->priv;
+       u32 smi_reg;
+       u32 timeout;
+
+       /* check parameters */
+       if (phy_adr > MVNETA_PHY_ADDR_MASK) {
+               printf("Error: Invalid PHY address %d\n", phy_adr);
+               return -EFAULT;
+       }
+
+       if (reg_ofs > MVNETA_PHY_REG_MASK) {
+               printf("Err: Invalid register offset %d\n", reg_ofs);
+               return -EFAULT;
+       }
+
+       /* wait till the SMI is not busy */
+       if (smi_wait_ready(pp) < 0)
+               return -EFAULT;
+
+       /* fill the phy address and regiser offset and read opcode */
+       smi_reg = (phy_adr << MVNETA_SMI_DEV_ADDR_OFFS)
+               | (reg_ofs << MVNETA_SMI_REG_ADDR_OFFS)
+               | MVNETA_SMI_OPCODE_READ;
+
+       /* write the smi register */
+       mvreg_write(pp, MVNETA_SMI, smi_reg);
+
+       /*wait till read value is ready */
+       timeout = MVNETA_SMI_TIMEOUT;
+
+       do {
+               /* read smi register */
+               smi_reg = mvreg_read(pp, MVNETA_SMI);
+               if (timeout-- == 0) {
+                       printf("Err: SMI read ready timeout\n");
+                       return -EFAULT;
+               }
+       } while (!(smi_reg & MVNETA_SMI_READ_VALID));
+
+       /* Wait for the data to update in the SMI register */
+       for (timeout = 0; timeout < MVNETA_SMI_TIMEOUT; timeout++)
+               ;
+
+       *data = (u16)(mvreg_read(pp, MVNETA_SMI) & MVNETA_SMI_DATA_MASK);
+
+       return 0;
+}
+
+/*
+ * smi_reg_write - imiiphy_write callback function.
+ *
+ * Returns 0 if write succeed, -EINVAL on bad parameters
+ * -ETIME on timeout
+ */
+static int smi_reg_write(const char *devname, u8 phy_adr, u8 reg_ofs, u16 data)
+{
+       struct eth_device *dev = eth_get_dev_by_name(devname);
+       struct mvneta_port *pp = dev->priv;
+       u32 smi_reg;
+
+       /* check parameters */
+       if (phy_adr > MVNETA_PHY_ADDR_MASK) {
+               printf("Error: Invalid PHY address %d\n", phy_adr);
+               return -EFAULT;
+       }
+
+       if (reg_ofs > MVNETA_PHY_REG_MASK) {
+               printf("Err: Invalid register offset %d\n", reg_ofs);
+               return -EFAULT;
+       }
+
+       /* wait till the SMI is not busy */
+       if (smi_wait_ready(pp) < 0)
+               return -EFAULT;
+
+       /* fill the phy addr and reg offset and write opcode and data */
+       smi_reg = (data << MVNETA_SMI_DATA_OFFS);
+       smi_reg |= (phy_adr << MVNETA_SMI_DEV_ADDR_OFFS)
+               | (reg_ofs << MVNETA_SMI_REG_ADDR_OFFS);
+       smi_reg &= ~MVNETA_SMI_OPCODE_READ;
+
+       /* write the smi register */
+       mvreg_write(pp, MVNETA_SMI, smi_reg);
+
+       return 0;
+}
+
+static int mvneta_init_u_boot(struct eth_device *dev, bd_t *bis)
+{
+       struct mvneta_port *pp = dev->priv;
+       struct phy_device *phydev;
+
+       mvneta_port_power_up(pp, pp->phy_interface);
+
+       if (!pp->init || pp->link == 0) {
+               /* Set phy address of the port */
+               mvreg_write(pp, MVNETA_PHY_ADDR, pp->phyaddr);
+               phydev = phy_connect(pp->bus, pp->phyaddr, dev,
+                                    pp->phy_interface);
+
+               pp->phydev = phydev;
+               phy_config(phydev);
+               phy_startup(phydev);
+               if (!phydev->link) {
+                       printf("%s: No link.\n", phydev->dev->name);
+                       return -1;
+               }
+
+               /* Full init on first call */
+               mvneta_probe(dev);
+               pp->init = 1;
+       } else {
+               /* Upon all following calls, this is enough */
+               mvneta_port_up(pp);
+               mvneta_port_enable(pp);
+       }
+
+       return 0;
+}
+
+static int mvneta_send(struct eth_device *dev, void *ptr, int len)
+{
+       struct mvneta_port *pp = dev->priv;
+       struct mvneta_tx_queue *txq = &pp->txqs[0];
+       struct mvneta_tx_desc *tx_desc;
+       int sent_desc;
+       u32 timeout = 0;
+
+       /* Get a descriptor for the first part of the packet */
+       tx_desc = mvneta_txq_next_desc_get(txq);
+
+       tx_desc->buf_phys_addr = (u32)ptr;
+       tx_desc->data_size = len;
+       flush_dcache_range((u32)ptr, (u32)ptr + len);
+
+       /* First and Last descriptor */
+       tx_desc->command = MVNETA_TX_L4_CSUM_NOT | MVNETA_TXD_FLZ_DESC;
+       mvneta_txq_pend_desc_add(pp, txq, 1);
+
+       /* Wait for packet to be sent (queue might help with speed here) */
+       sent_desc = mvneta_txq_sent_desc_num_get(pp, txq);
+       while (!sent_desc) {
+               if (timeout++ > 10000) {
+                       printf("timeout: packet not sent\n");
+                       return -1;
+               }
+               sent_desc = mvneta_txq_sent_desc_num_get(pp, txq);
+       }
+
+       /* txDone has increased - hw sent packet */
+       mvneta_txq_sent_desc_dec(pp, txq, sent_desc);
+       return 0;
+
+       return 0;
+}
+
+static int mvneta_recv(struct eth_device *dev)
+{
+       struct mvneta_port *pp = dev->priv;
+       int rx_done;
+       int packets_done;
+       struct mvneta_rx_queue *rxq;
+
+       /* get rx queue */
+       rxq = mvneta_rxq_handle_get(pp, rxq_def);
+       rx_done = mvneta_rxq_busy_desc_num_get(pp, rxq);
+       packets_done = rx_done;
+
+       while (packets_done--) {
+               struct mvneta_rx_desc *rx_desc;
+               unsigned char *data;
+               u32 rx_status;
+               int rx_bytes;
+
+               /*
+                * No cache invalidation needed here, since the desc's are
+                * located in a uncached memory region
+                */
+               rx_desc = mvneta_rxq_next_desc_get(rxq);
+
+               rx_status = rx_desc->status;
+               if (!mvneta_rxq_desc_is_first_last(rx_status) ||
+                   (rx_status & MVNETA_RXD_ERR_SUMMARY)) {
+                       mvneta_rx_error(pp, rx_desc);
+                       /* leave the descriptor untouched */
+                       continue;
+               }
+
+               /* 2 bytes for marvell header. 4 bytes for crc */
+               rx_bytes = rx_desc->data_size - 6;
+
+               /* give packet to stack - skip on first 2 bytes */
+               data = (u8 *)rx_desc->buf_cookie + 2;
+               /*
+                * No cache invalidation needed here, since the rx_buffer's are
+                * located in a uncached memory region
+                */
+               NetReceive(data, rx_bytes);
+       }
+
+       /* Update rxq management counters */
+       if (rx_done)
+               mvneta_rxq_desc_num_update(pp, rxq, rx_done, rx_done);
+
+       return 0;
+}
+
+static void mvneta_halt(struct eth_device *dev)
+{
+       struct mvneta_port *pp = dev->priv;
+
+       mvneta_port_down(pp);
+       mvneta_port_disable(pp);
+}
+
+int mvneta_initialize(bd_t *bis, int base_addr, int devnum, int phy_addr)
+{
+       struct eth_device *dev;
+       struct mvneta_port *pp;
+       void *bd_space;
+
+       dev = calloc(1, sizeof(*dev));
+       if (dev == NULL)
+               return -ENOMEM;
+
+       pp = calloc(1, sizeof(*pp));
+       if (pp == NULL)
+               return -ENOMEM;
+
+       dev->priv = pp;
+
+       /*
+        * Allocate buffer area for descs and rx_buffers. This is only
+        * done once for all interfaces. As only one interface can
+        * be active. Make this area DMA save by disabling the D-cache
+        */
+       if (!buffer_loc.tx_descs) {
+               /* Align buffer area for descs and rx_buffers to 1MiB */
+               bd_space = memalign(1 << MMU_SECTION_SHIFT, BD_SPACE);
+               mmu_set_region_dcache_behaviour((u32)bd_space, BD_SPACE,
+                                               DCACHE_OFF);
+               buffer_loc.tx_descs = (struct mvneta_tx_desc *)bd_space;
+               buffer_loc.rx_descs = (struct mvneta_rx_desc *)
+                       ((u32)bd_space +
+                        MVNETA_MAX_TXD * sizeof(struct mvneta_tx_desc));
+               buffer_loc.rx_buffers = (u32)
+                       (bd_space +
+                        MVNETA_MAX_TXD * sizeof(struct mvneta_tx_desc) +
+                        MVNETA_MAX_RXD * sizeof(struct mvneta_rx_desc));
+       }
+
+       sprintf(dev->name, "neta%d", devnum);
+
+       pp->base = (void __iomem *)base_addr;
+       dev->iobase = base_addr;
+       dev->init = mvneta_init_u_boot;
+       dev->halt = mvneta_halt;
+       dev->send = mvneta_send;
+       dev->recv = mvneta_recv;
+       dev->write_hwaddr = NULL;
+
+       /*
+        * The PHY interface type is configured via the
+        * board specific CONFIG_SYS_NETA_INTERFACE_TYPE
+        * define.
+        */
+       pp->phy_interface = CONFIG_SYS_NETA_INTERFACE_TYPE;
+
+       eth_register(dev);
+
+       pp->phyaddr = phy_addr;
+       miiphy_register(dev->name, smi_reg_read, smi_reg_write);
+       pp->bus = miiphy_get_dev_by_name(dev->name);
+
+       return 1;
+}
index 99b0b83631875923a87b4c5e1436977411ba9194..467c97224313328e2aa7e2f04edabc15def84792 100644 (file)
@@ -575,7 +575,7 @@ static struct phy_device *phy_device_create(struct mii_dev *bus, int addr,
  * Description: Reads the ID registers of the PHY at @addr on the
  *   @bus, stores it in @phy_id and returns zero on success.
  */
-int __weak get_phy_id(struct mii_dev *bus, int addr, int devad, u32 *phy_id)
+static int get_phy_id(struct mii_dev *bus, int addr, int devad, u32 *phy_id)
 {
        int phy_reg;
 
@@ -785,16 +785,13 @@ int phy_startup(struct phy_device *phydev)
        return 0;
 }
 
-static int __board_phy_config(struct phy_device *phydev)
+__weak int board_phy_config(struct phy_device *phydev)
 {
        if (phydev->drv->config)
                return phydev->drv->config(phydev);
        return 0;
 }
 
-int board_phy_config(struct phy_device *phydev)
-       __attribute__((weak, alias("__board_phy_config")));
-
 int phy_config(struct phy_device *phydev)
 {
        /* Invoke an optional board-specific helper */
index 28859f31612527ccff49ee3fbc69dbbc1caaaa54..60c333e2c0191d5ef8753075669a7edc3af95532 100644 (file)
@@ -572,7 +572,7 @@ const char * pci_class_str(u8 class)
 }
 #endif /* CONFIG_CMD_PCI || CONFIG_PCI_SCAN_SHOW */
 
-int __pci_skip_dev(struct pci_controller *hose, pci_dev_t dev)
+__weak int pci_skip_dev(struct pci_controller *hose, pci_dev_t dev)
 {
        /*
         * Check if pci device should be skipped in configuration
@@ -591,19 +591,15 @@ int __pci_skip_dev(struct pci_controller *hose, pci_dev_t dev)
 
        return 0;
 }
-int pci_skip_dev(struct pci_controller *hose, pci_dev_t dev)
-       __attribute__((weak, alias("__pci_skip_dev")));
 
 #ifdef CONFIG_PCI_SCAN_SHOW
-int __pci_print_dev(struct pci_controller *hose, pci_dev_t dev)
+__weak int pci_print_dev(struct pci_controller *hose, pci_dev_t dev)
 {
        if (dev == PCI_BDF(hose->first_busno, 0, 0))
                return 0;
 
        return 1;
 }
-int pci_print_dev(struct pci_controller *hose, pci_dev_t dev)
-       __attribute__((weak, alias("__pci_print_dev")));
 #endif /* CONFIG_PCI_SCAN_SHOW */
 
 int pci_hose_scan_bus(struct pci_controller *hose, int bus)
index ce7a69bab57048d7f8e1a40a1377de96946d5e5c..ebddc124c3dae96195f31eca4bab99f60bc5204a 100644 (file)
@@ -12,7 +12,7 @@
 #ifndef _MVRTC_H_
 #define _MVRTC_H_
 
-#include <asm/arch/kirkwood.h>
+#include <asm/arch/soc.h>
 #include <compiler.h>
 
 /* RTC registers */
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..a0b6e02b5462e5fc515a28d7f40b04a46c22018d 100644 (file)
@@ -0,0 +1,12 @@
+config DM_SERIAL
+       bool "Enable Driver Model for serial drivers"
+       depends on DM
+       help
+         If you want to use driver model for serial drivers, say Y.
+         To use legacy serial drivers, say N.
+
+config UNIPHIER_SERIAL
+       bool "UniPhier on-chip UART support"
+       depends on ARCH_UNIPHIER && DM_SERIAL
+       help
+         Support for the on-chip UARTs on the Panasonic UniPhier platform.
index 17c56ea66e8e65185110bfa91b20069da675fbfa..2c19ebc2885e90c77b58302e989527a162d9c517 100644 (file)
@@ -41,6 +41,8 @@ obj-$(CONFIG_MXS_AUART) += mxs_auart.o
 obj-$(CONFIG_ARC_SERIAL) += serial_arc.o
 obj-$(CONFIG_TEGRA_SERIAL) += serial_tegra.o
 obj-$(CONFIG_UNIPHIER_SERIAL) += serial_uniphier.o
+obj-$(CONFIG_OMAP_SERIAL) += serial_omap.o
+obj-$(CONFIG_COREBOOT_SERIAL) += serial_coreboot.o
 
 ifndef CONFIG_SPL_BUILD
 obj-$(CONFIG_USB_TTY) += usbtty.o
index 63a9ef68444d3af762213467b1b9e9524aaa4473..8f051914f54a37539d5768dd9d8ed90ff34adcf0 100644 (file)
@@ -61,13 +61,13 @@ static void ns16550_writeb(NS16550_t port, int offset, int value)
        unsigned char *addr;
 
        offset *= 1 << plat->reg_shift;
-       addr = plat->base + offset;
+       addr = map_sysmem(plat->base, 0) + offset;
        /*
         * As far as we know it doesn't make sense to support selection of
         * these options at run-time, so use the existing CONFIG options.
         */
 #ifdef CONFIG_SYS_NS16550_PORT_MAPPED
-       outb(value, addr);
+       outb(value, (ulong)addr);
 #elif defined(CONFIG_SYS_NS16550_MEM32) && !defined(CONFIG_SYS_BIG_ENDIAN)
        out_le32(addr, value);
 #elif defined(CONFIG_SYS_NS16550_MEM32) && defined(CONFIG_SYS_BIG_ENDIAN)
@@ -85,9 +85,9 @@ static int ns16550_readb(NS16550_t port, int offset)
        unsigned char *addr;
 
        offset *= 1 << plat->reg_shift;
-       addr = plat->base + offset;
+       addr = map_sysmem(plat->base, 0) + offset;
 #ifdef CONFIG_SYS_NS16550_PORT_MAPPED
-       return inb(addr);
+       return inb((ulong)addr);
 #elif defined(CONFIG_SYS_NS16550_MEM32) && !defined(CONFIG_SYS_BIG_ENDIAN)
        return in_le32(addr);
 #elif defined(CONFIG_SYS_NS16550_MEM32) && defined(CONFIG_SYS_BIG_ENDIAN)
@@ -253,7 +253,7 @@ static int ns16550_serial_getc(struct udevice *dev)
 {
        struct NS16550 *const com_port = dev_get_priv(dev);
 
-       if (!serial_in(&com_port->lsr) & UART_LSR_DR)
+       if (!(serial_in(&com_port->lsr) & UART_LSR_DR))
                return -EAGAIN;
 
        return serial_in(&com_port->rbr);
@@ -276,14 +276,15 @@ int ns16550_serial_probe(struct udevice *dev)
 {
        struct NS16550 *const com_port = dev_get_priv(dev);
 
+       com_port->plat = dev_get_platdata(dev);
        NS16550_init(com_port, -1);
 
        return 0;
 }
 
+#ifdef CONFIG_OF_CONTROL
 int ns16550_serial_ofdata_to_platdata(struct udevice *dev)
 {
-       struct NS16550 *const com_port = dev_get_priv(dev);
        struct ns16550_platdata *plat = dev->platdata;
        fdt_addr_t addr;
 
@@ -291,13 +292,13 @@ int ns16550_serial_ofdata_to_platdata(struct udevice *dev)
        if (addr == FDT_ADDR_T_NONE)
                return -EINVAL;
 
-       plat->base = (unsigned char *)addr;
+       plat->base = addr;
        plat->reg_shift = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
                                         "reg-shift", 1);
-       com_port->plat = plat;
 
        return 0;
 }
+#endif
 
 const struct dm_serial_ops ns16550_serial_ops = {
        .putc = ns16550_serial_putc,
index 1a75950d19fa4c738f7f5c881da08561d416faf2..71f1a5cb91024e9fc473e2a5e61f0deb82efd3c1 100644 (file)
 #include <os.h>
 #include <serial.h>
 #include <stdio_dev.h>
+#include <watchdog.h>
 #include <dm/lists.h>
 #include <dm/device-internal.h>
 
+#include <ns16550.h>
+
 DECLARE_GLOBAL_DATA_PTR;
 
 /* The currently-selected console serial device */
@@ -47,13 +50,22 @@ static void serial_find_console_or_panic(void)
        }
 #endif
        /*
+        * Try to use CONFIG_CONS_INDEX if available (it is numbered from 1!).
+        *
         * Failing that, get the device with sequence number 0, or in extremis
         * just the first serial device we can find. But we insist on having
         * a console (even if it is silent).
         */
-       if (uclass_get_device_by_seq(UCLASS_SERIAL, 0, &cur_dev) &&
+#ifdef CONFIG_CONS_INDEX
+#define INDEX (CONFIG_CONS_INDEX - 1)
+#else
+#define INDEX 0
+#endif
+       if (uclass_get_device_by_seq(UCLASS_SERIAL, INDEX, &cur_dev) &&
+           uclass_get_device(UCLASS_SERIAL, INDEX, &cur_dev) &&
            (uclass_first_device(UCLASS_SERIAL, &cur_dev) || !cur_dev))
                panic("No serial driver found");
+#undef INDEX
 }
 
 /* Called prior to relocation */
@@ -71,62 +83,74 @@ void serial_initialize(void)
        serial_find_console_or_panic();
 }
 
-static void serial_putc_dev(struct udevice *dev, char ch)
+static void _serial_putc(struct udevice *dev, char ch)
 {
-       struct dm_serial_ops *ops = serial_get_ops(cur_dev);
+       struct dm_serial_ops *ops = serial_get_ops(dev);
        int err;
 
        do {
-               err = ops->putc(cur_dev, ch);
+               err = ops->putc(dev, ch);
        } while (err == -EAGAIN);
        if (ch == '\n')
-               serial_putc('\r');
+               _serial_putc(dev, '\r');
 }
 
-void serial_putc(char ch)
+static void _serial_puts(struct udevice *dev, const char *str)
 {
-       serial_putc_dev(cur_dev, ch);
+       while (*str)
+               _serial_putc(dev, *str++);
 }
 
-void serial_setbrg(void)
+static int _serial_getc(struct udevice *dev)
 {
-       struct dm_serial_ops *ops = serial_get_ops(cur_dev);
+       struct dm_serial_ops *ops = serial_get_ops(dev);
+       int err;
 
-       if (ops->setbrg)
-               ops->setbrg(cur_dev, gd->baudrate);
-}
+       do {
+               err = ops->getc(dev);
+               if (err == -EAGAIN)
+                       WATCHDOG_RESET();
+       } while (err == -EAGAIN);
 
-void serial_puts(const char *str)
-{
-       while (*str)
-               serial_putc(*str++);
+       return err >= 0 ? err : 0;
 }
 
-int serial_tstc(void)
+static int _serial_tstc(struct udevice *dev)
 {
-       struct dm_serial_ops *ops = serial_get_ops(cur_dev);
+       struct dm_serial_ops *ops = serial_get_ops(dev);
 
        if (ops->pending)
-               return ops->pending(cur_dev, true);
+               return ops->pending(dev, true);
 
        return 1;
 }
 
-static int serial_getc_dev(struct udevice *dev)
+void serial_putc(char ch)
 {
-       struct dm_serial_ops *ops = serial_get_ops(dev);
-       int err;
-
-       do {
-               err = ops->getc(dev);
-       } while (err == -EAGAIN);
+       _serial_putc(cur_dev, ch);
+}
 
-       return err >= 0 ? err : 0;
+void serial_puts(const char *str)
+{
+       _serial_puts(cur_dev, str);
 }
 
 int serial_getc(void)
 {
-       return serial_getc_dev(cur_dev);
+       return _serial_getc(cur_dev);
+}
+
+int serial_tstc(void)
+{
+       return _serial_tstc(cur_dev);
+}
+
+void serial_setbrg(void)
+{
+       struct dm_serial_ops *ops = serial_get_ops(cur_dev);
+
+       if (ops->setbrg)
+               ops->setbrg(cur_dev, gd->baudrate);
 }
 
 void serial_stdio_init(void)
@@ -135,33 +159,22 @@ void serial_stdio_init(void)
 
 static void serial_stub_putc(struct stdio_dev *sdev, const char ch)
 {
-       struct udevice *dev = sdev->priv;
-
-       serial_putc_dev(dev, ch);
+       _serial_putc(sdev->priv, ch);
 }
 
 void serial_stub_puts(struct stdio_dev *sdev, const char *str)
 {
-       while (*str)
-               serial_stub_putc(sdev, *str++);
+       _serial_puts(sdev->priv, str);
 }
 
 int serial_stub_getc(struct stdio_dev *sdev)
 {
-       struct udevice *dev = sdev->priv;
-
-       return serial_getc_dev(dev);
+       return _serial_getc(sdev->priv);
 }
 
 int serial_stub_tstc(struct stdio_dev *sdev)
 {
-       struct udevice *dev = sdev->priv;
-       struct dm_serial_ops *ops = serial_get_ops(dev);
-
-       if (ops->pending)
-               return ops->pending(dev, true);
-
-       return 1;
+       return _serial_tstc(sdev->priv);
 }
 
 static int serial_post_probe(struct udevice *dev)
index 82fbbd92e2b259586455484b635338adc5cdf72f..18e41b2302a2181ba6f38c53ecc71c682fb5cad0 100644 (file)
@@ -157,7 +157,6 @@ serial_initfunc(sh_serial_initialize);
 serial_initfunc(arm_dcc_initialize);
 serial_initfunc(mxs_auart_initialize);
 serial_initfunc(arc_serial_initialize);
-serial_initfunc(uniphier_serial_initialize);
 
 /**
  * serial_register() - Register serial driver with serial driver core
@@ -251,33 +250,32 @@ void serial_initialize(void)
        arm_dcc_initialize();
        mxs_auart_initialize();
        arc_serial_initialize();
-       uniphier_serial_initialize();
 
        serial_assign(default_serial_console()->name);
 }
 
-int serial_stub_start(struct stdio_dev *sdev)
+static int serial_stub_start(struct stdio_dev *sdev)
 {
        struct serial_device *dev = sdev->priv;
 
        return dev->start();
 }
 
-int serial_stub_stop(struct stdio_dev *sdev)
+static int serial_stub_stop(struct stdio_dev *sdev)
 {
        struct serial_device *dev = sdev->priv;
 
        return dev->stop();
 }
 
-void serial_stub_putc(struct stdio_dev *sdev, const char ch)
+static void serial_stub_putc(struct stdio_dev *sdev, const char ch)
 {
        struct serial_device *dev = sdev->priv;
 
        dev->putc(ch);
 }
 
-void serial_stub_puts(struct stdio_dev *sdev, const char *str)
+static void serial_stub_puts(struct stdio_dev *sdev, const char *str)
 {
        struct serial_device *dev = sdev->priv;
 
diff --git a/drivers/serial/serial_coreboot.c b/drivers/serial/serial_coreboot.c
new file mode 100644 (file)
index 0000000..5c6a76c
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2014 Google, Inc
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <ns16550.h>
+#include <serial.h>
+
+static const struct udevice_id coreboot_serial_ids[] = {
+       { .compatible = "coreboot-uart" },
+       { }
+};
+
+static int coreboot_serial_ofdata_to_platdata(struct udevice *dev)
+{
+       struct ns16550_platdata *plat = dev_get_platdata(dev);
+       int ret;
+
+       ret = ns16550_serial_ofdata_to_platdata(dev);
+       if (ret)
+               return ret;
+       plat->clock = 1843200;
+
+       return 0;
+}
+U_BOOT_DRIVER(serial_ns16550) = {
+       .name   = "serial_coreboot",
+       .id     = UCLASS_SERIAL,
+       .of_match = coreboot_serial_ids,
+       .ofdata_to_platdata = coreboot_serial_ofdata_to_platdata,
+       .platdata_auto_alloc_size = sizeof(struct ns16550_platdata),
+       .priv_auto_alloc_size = sizeof(struct NS16550),
+       .probe = ns16550_serial_probe,
+       .ops    = &ns16550_serial_ops,
+};
index 9ce24f9f932d932f6244479241809b8858a696a4..d6cf1d874a60c72c747489849bf58cffc915e57c 100644 (file)
@@ -7,10 +7,10 @@
 #include <common.h>
 #include <dm.h>
 #include <errno.h>
-#include <serial_mxc.h>
 #include <watchdog.h>
 #include <asm/arch/imx-regs.h>
 #include <asm/arch/clock.h>
+#include <dm/platform_data/serial_mxc.h>
 #include <serial.h>
 #include <linux/compiler.h>
 
index 632da4cf70bb93c15c2a84a93815b6b6078c06c4..799ef6a667d16a1d38427be6e642633848c9a9c4 100644 (file)
@@ -119,8 +119,7 @@ static NS16550_t serial_ports[6] = {
        .puts   = eserial##port##_puts,         \
 }
 
-void
-_serial_putc(const char c,const int port)
+static void _serial_putc(const char c, const int port)
 {
        if (c == '\n')
                NS16550_putc(PORT, '\r');
@@ -128,35 +127,29 @@ _serial_putc(const char c,const int port)
        NS16550_putc(PORT, c);
 }
 
-void
-_serial_putc_raw(const char c,const int port)
+static void _serial_putc_raw(const char c, const int port)
 {
        NS16550_putc(PORT, c);
 }
 
-void
-_serial_puts (const char *s,const int port)
+static void _serial_puts(const char *s, const int port)
 {
        while (*s) {
-               _serial_putc (*s++,port);
+               _serial_putc(*s++, port);
        }
 }
 
-
-int
-_serial_getc(const int port)
+static int _serial_getc(const int port)
 {
        return NS16550_getc(PORT);
 }
 
-int
-_serial_tstc(const int port)
+static int _serial_tstc(const int port)
 {
        return NS16550_tstc(PORT);
 }
 
-void
-_serial_setbrg (const int port)
+static void _serial_setbrg(const int port)
 {
        int clock_divisor;
 
diff --git a/drivers/serial/serial_omap.c b/drivers/serial/serial_omap.c
new file mode 100644 (file)
index 0000000..265fe00
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2014 Google, Inc
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <fdtdec.h>
+#include <ns16550.h>
+#include <serial.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+#ifdef CONFIG_OF_CONTROL
+static const struct udevice_id omap_serial_ids[] = {
+       { .compatible = "ti,omap3-uart" },
+       { }
+};
+
+static int omap_serial_ofdata_to_platdata(struct udevice *dev)
+{
+       struct ns16550_platdata *plat = dev_get_platdata(dev);
+       int ret;
+
+       ret = ns16550_serial_ofdata_to_platdata(dev);
+       if (ret)
+               return ret;
+       plat->clock = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+                                    "clock-frequency", -1);
+       plat->reg_shift = 2;
+
+       return 0;
+}
+#endif
+
+U_BOOT_DRIVER(serial_omap_ns16550) = {
+       .name   = "serial_omap",
+       .id     = UCLASS_SERIAL,
+       .of_match = of_match_ptr(omap_serial_ids),
+       .ofdata_to_platdata = of_match_ptr(omap_serial_ofdata_to_platdata),
+       .platdata_auto_alloc_size = sizeof(struct ns16550_platdata),
+       .priv_auto_alloc_size = sizeof(struct NS16550),
+       .probe = ns16550_serial_probe,
+       .ops    = &ns16550_serial_ops,
+       .flags  = DM_FLAG_PRE_RELOC,
+};
index e6313ad3d3a8d238a774543bab6777964b04627f..38dda910217652ecf167ad52bbc53af3559e2722 100644 (file)
@@ -17,7 +17,7 @@
 #include <watchdog.h>
 #include <asm/io.h>
 #include <serial.h>
-#include <serial_pl01x.h>
+#include <dm/platform_data/serial_pl01x.h>
 #include <linux/compiler.h>
 #include "serial_pl01x_internal.h"
 
index c07f4c9b4737f5a64ea59e1a570e77c9850e0f7f..7afc5044a8c70f77607a5e1d351b83b2681b012b 100644 (file)
@@ -69,7 +69,7 @@ DECLARE_GLOBAL_DATA_PTR;
 static int hwflow;
 #endif
 
-void _serial_setbrg(const int dev_index)
+static void _serial_setbrg(const int dev_index)
 {
        struct s3c24x0_uart *uart = s3c24x0_get_base_uart(dev_index);
        unsigned int reg = 0;
@@ -131,7 +131,7 @@ static int serial_init_dev(const int dev_index)
  * otherwise. When the function is succesfull, the character read is
  * written into its argument c.
  */
-int _serial_getc(const int dev_index)
+static int _serial_getc(const int dev_index)
 {
        struct s3c24x0_uart *uart = s3c24x0_get_base_uart(dev_index);
 
@@ -181,7 +181,7 @@ void enable_putc(void)
 /*
  * Output a single byte to the serial port.
  */
-void _serial_putc(const char c, const int dev_index)
+static void _serial_putc(const char c, const int dev_index)
 {
        struct s3c24x0_uart *uart = s3c24x0_get_base_uart(dev_index);
 #ifdef CONFIG_MODEM_SUPPORT
@@ -212,7 +212,7 @@ static inline void serial_putc_dev(unsigned int dev_index, const char c)
 /*
  * Test whether a character is in the RX buffer
  */
-int _serial_tstc(const int dev_index)
+static int _serial_tstc(const int dev_index)
 {
        struct s3c24x0_uart *uart = s3c24x0_get_base_uart(dev_index);
 
@@ -224,7 +224,7 @@ static inline int serial_tstc_dev(unsigned int dev_index)
        return _serial_tstc(dev_index);
 }
 
-void _serial_puts(const char *s, const int dev_index)
+static void _serial_puts(const char *s, const int dev_index)
 {
        while (*s) {
                _serial_putc(*s++, dev_index);
index 144a925394513d38b1677030cb97fcc5f96d84cb..7c1f27137615faa4a56f0b40f567c49a0ff73378 100644 (file)
@@ -122,7 +122,7 @@ static void handle_error(void)
        sci_out(&sh_sci, SCLSR, 0x00);
 }
 
-void serial_raw_putc(const char c)
+static void serial_raw_putc(const char c)
 {
        while (1) {
                /* Tx fifo is empty */
@@ -152,7 +152,7 @@ static int sh_serial_tstc(void)
 }
 
 
-int serial_getc_check(void)
+static int serial_getc_check(void)
 {
        unsigned short status;
 
index f8c9d921e283028c5fe199efa7b081bbfc08d09f..9114b3ed6002a1a0d9e3c6303ad07993060b07f9 100644 (file)
@@ -2,14 +2,14 @@
  * Copyright (C) 2012-2014 Panasonic Corporation
  *   Author: Masahiro Yamada <yamada.m@jp.panasonic.com>
  *
- * Based on serial_ns16550.c
- * (C) Copyright 2000
- * Rob Taylor, Flying Pig Systems. robt@flyingpig.com.
- *
  * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <common.h>
+#include <asm/io.h>
+#include <asm/errno.h>
+#include <dm/device.h>
+#include <dm/platform_data/serial-uniphier.h>
 #include <serial.h>
 
 #define UART_REG(x)                                    \
@@ -48,157 +48,104 @@ struct uniphier_serial {
 #define UART_LSR_DR    0x01            /* Data ready */
 #define UART_LSR_THRE  0x20            /* Xmit holding register empty */
 
-DECLARE_GLOBAL_DATA_PTR;
+struct uniphier_serial_private_data {
+       struct uniphier_serial __iomem *membase;
+};
+
+#define uniphier_serial_port(dev)      \
+       ((struct uniphier_serial_private_data *)dev_get_priv(dev))->membase
 
-static void uniphier_serial_init(struct uniphier_serial *port)
+int uniphier_serial_setbrg(struct udevice *dev, int baudrate)
 {
+       struct uniphier_serial_platform_data *plat = dev_get_platdata(dev);
+       struct uniphier_serial __iomem *port = uniphier_serial_port(dev);
        const unsigned int mode_x_div = 16;
        unsigned int divisor;
 
        writeb(UART_LCR_WLS_8, &port->lcr);
 
-       divisor = DIV_ROUND_CLOSEST(CONFIG_SYS_UNIPHIER_UART_CLK,
-                                               mode_x_div * gd->baudrate);
+       divisor = DIV_ROUND_CLOSEST(plat->uartclk, mode_x_div * baudrate);
 
        writew(divisor, &port->dlr);
-}
 
-static void uniphier_serial_setbrg(struct uniphier_serial *port)
-{
-       uniphier_serial_init(port);
+       return 0;
 }
 
-static int uniphier_serial_tstc(struct uniphier_serial *port)
+static int uniphier_serial_getc(struct udevice *dev)
 {
-       return (readb(&port->lsr) & UART_LSR_DR) != 0;
-}
+       struct uniphier_serial __iomem *port = uniphier_serial_port(dev);
 
-static int uniphier_serial_getc(struct uniphier_serial *port)
-{
-       while (!uniphier_serial_tstc(port))
-               ;
+       if (!(readb(&port->lsr) & UART_LSR_DR))
+               return -EAGAIN;
 
        return readb(&port->rbr);
 }
 
-static void uniphier_serial_putc(struct uniphier_serial *port, const char c)
+static int uniphier_serial_putc(struct udevice *dev, const char c)
 {
-       if (c == '\n')
-               uniphier_serial_putc(port, '\r');
+       struct uniphier_serial __iomem *port = uniphier_serial_port(dev);
 
-       while (!(readb(&port->lsr) & UART_LSR_THRE))
-               ;
+       if (!(readb(&port->lsr) & UART_LSR_THRE))
+               return -EAGAIN;
 
        writeb(c, &port->thr);
+
+       return 0;
 }
 
-static struct uniphier_serial *serial_ports[4] = {
-#ifdef CONFIG_SYS_UNIPHIER_SERIAL_BASE0
-       (struct uniphier_serial *)CONFIG_SYS_UNIPHIER_SERIAL_BASE0,
-#else
-       NULL,
-#endif
-#ifdef CONFIG_SYS_UNIPHIER_SERIAL_BASE1
-       (struct uniphier_serial *)CONFIG_SYS_UNIPHIER_SERIAL_BASE1,
-#else
-       NULL,
-#endif
-#ifdef CONFIG_SYS_UNIPHIER_SERIAL_BASE2
-       (struct uniphier_serial *)CONFIG_SYS_UNIPHIER_SERIAL_BASE2,
-#else
-       NULL,
-#endif
-#ifdef CONFIG_SYS_UNIPHIER_SERIAL_BASE3
-       (struct uniphier_serial *)CONFIG_SYS_UNIPHIER_SERIAL_BASE3,
-#else
-       NULL,
-#endif
-};
+int uniphier_serial_probe(struct udevice *dev)
+{
+       struct uniphier_serial_private_data *priv = dev_get_priv(dev);
+       struct uniphier_serial_platform_data *plat = dev_get_platdata(dev);
 
-/* Multi serial device functions */
-#define DECLARE_ESERIAL_FUNCTIONS(port) \
-       static int  eserial##port##_init(void) \
-       { \
-               uniphier_serial_init(serial_ports[port]); \
-               return 0 ; \
-       } \
-       static void eserial##port##_setbrg(void) \
-       { \
-               uniphier_serial_setbrg(serial_ports[port]); \
-       } \
-       static int  eserial##port##_getc(void) \
-       { \
-               return uniphier_serial_getc(serial_ports[port]); \
-       } \
-       static int  eserial##port##_tstc(void) \
-       { \
-               return uniphier_serial_tstc(serial_ports[port]); \
-       } \
-       static void eserial##port##_putc(const char c) \
-       { \
-               uniphier_serial_putc(serial_ports[port], c); \
-       }
-
-/* Serial device descriptor */
-#define INIT_ESERIAL_STRUCTURE(port, __name) { \
-       .name   = __name,                       \
-       .start  = eserial##port##_init,         \
-       .stop   = NULL,                         \
-       .setbrg = eserial##port##_setbrg,       \
-       .getc   = eserial##port##_getc,         \
-       .tstc   = eserial##port##_tstc,         \
-       .putc   = eserial##port##_putc,         \
-       .puts   = default_serial_puts,          \
-}
+       priv->membase = map_sysmem(plat->base, sizeof(struct uniphier_serial));
 
-#if defined(CONFIG_SYS_UNIPHIER_SERIAL_BASE0)
-DECLARE_ESERIAL_FUNCTIONS(0);
-struct serial_device uniphier_serial0_device =
-       INIT_ESERIAL_STRUCTURE(0, "ttyS0");
-#endif
-#if defined(CONFIG_SYS_UNIPHIER_SERIAL_BASE1)
-DECLARE_ESERIAL_FUNCTIONS(1);
-struct serial_device uniphier_serial1_device =
-       INIT_ESERIAL_STRUCTURE(1, "ttyS1");
-#endif
-#if defined(CONFIG_SYS_UNIPHIER_SERIAL_BASE2)
-DECLARE_ESERIAL_FUNCTIONS(2);
-struct serial_device uniphier_serial2_device =
-       INIT_ESERIAL_STRUCTURE(2, "ttyS2");
-#endif
-#if defined(CONFIG_SYS_UNIPHIER_SERIAL_BASE3)
-DECLARE_ESERIAL_FUNCTIONS(3);
-struct serial_device uniphier_serial3_device =
-       INIT_ESERIAL_STRUCTURE(3, "ttyS3");
-#endif
+       if (!priv->membase)
+               return -ENOMEM;
 
-__weak struct serial_device *default_serial_console(void)
+       return 0;
+}
+
+int uniphier_serial_remove(struct udevice *dev)
 {
-#if defined(CONFIG_SYS_UNIPHIER_SERIAL_BASE0)
-       return &uniphier_serial0_device;
-#elif defined(CONFIG_SYS_UNIPHIER_SERIAL_BASE1)
-       return &uniphier_serial1_device;
-#elif defined(CONFIG_SYS_UNIPHIER_SERIAL_BASE2)
-       return &uniphier_serial2_device;
-#elif defined(CONFIG_SYS_UNIPHIER_SERIAL_BASE3)
-       return &uniphier_serial3_device;
-#else
-#error "No uniphier serial ports configured."
-#endif
+       unmap_sysmem(uniphier_serial_port(dev));
+
+       return 0;
 }
 
-void uniphier_serial_initialize(void)
+#ifdef CONFIG_OF_CONTROL
+static const struct udevice_id uniphier_uart_of_match = {
+       { .compatible = "panasonic,uniphier-uart"},
+       {},
+};
+
+static int uniphier_serial_ofdata_to_platdata(struct udevice *dev)
 {
-#if defined(CONFIG_SYS_UNIPHIER_SERIAL_BASE0)
-       serial_register(&uniphier_serial0_device);
-#endif
-#if defined(CONFIG_SYS_UNIPHIER_SERIAL_BASE1)
-       serial_register(&uniphier_serial1_device);
-#endif
-#if defined(CONFIG_SYS_UNIPHIER_SERIAL_BASE2)
-       serial_register(&uniphier_serial2_device);
-#endif
-#if defined(CONFIG_SYS_UNIPHIER_SERIAL_BASE3)
-       serial_register(&uniphier_serial3_device);
-#endif
+       /*
+        * TODO: Masahiro Yamada (yamada.m@jp.panasonic.com)
+        *
+        * Implement conversion code from DTB to platform data
+        * when supporting CONFIG_OF_CONTROL on UniPhir platform.
+        */
 }
+#endif
+
+static const struct dm_serial_ops uniphier_serial_ops = {
+       .setbrg = uniphier_serial_setbrg,
+       .getc = uniphier_serial_getc,
+       .putc = uniphier_serial_putc,
+};
+
+U_BOOT_DRIVER(uniphier_serial) = {
+       .name = DRIVER_NAME,
+       .id = UCLASS_SERIAL,
+       .of_match = of_match_ptr(uniphier_uart_of_match),
+       .ofdata_to_platdata = of_match_ptr(uniphier_serial_ofdata_to_platdata),
+       .probe = uniphier_serial_probe,
+       .remove = uniphier_serial_remove,
+       .priv_auto_alloc_size = sizeof(struct uniphier_serial_private_data),
+       .platdata_auto_alloc_size =
+                               sizeof(struct uniphier_serial_platform_data),
+       .ops = &uniphier_serial_ops,
+       .flags = DM_FLAG_PRE_RELOC,
+};
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..e1678e63e6adf976e4514978a3d2e1a9b6634c42 100644 (file)
@@ -0,0 +1,6 @@
+config DM_SPI
+       bool "Enable Driver Model for SPI drivers"
+       depends on DM
+       help
+         If you want to use driver model for SPI drivers, say Y.
+         To use legacy SPI drivers, say N.
index 3d58bcc1b955d140b8dc4a3937eba4db59dc6d35..e7b0982fb654681e4b9650d7ce8fe9a9c23d8acd 100644 (file)
 #include <malloc.h>
 #include <spi.h>
 #include <asm/io.h>
-#include <asm/arch/kirkwood.h>
-#include <asm/arch/spi.h>
+#include <asm/arch/soc.h>
+#ifdef CONFIG_KIRKWOOD
 #include <asm/arch/mpp.h>
+#endif
+#include <asm/arch-mvebu/spi.h>
 
-static struct kwspi_registers *spireg = (struct kwspi_registers *)KW_SPI_BASE;
+static struct kwspi_registers *spireg =
+       (struct kwspi_registers *)MVEBU_SPI_BASE;
 
+#ifdef CONFIG_KIRKWOOD
 static u32 cs_spi_mpp_back[2];
+#endif
 
 struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
                                unsigned int max_hz, unsigned int mode)
 {
        struct spi_slave *slave;
        u32 data;
+#ifdef CONFIG_KIRKWOOD
        static const u32 kwspi_mpp_config[2][2] = {
                { MPP0_SPI_SCn, 0 }, /* if cs == 0 */
                { MPP7_SPI_SCn, 0 } /* if cs != 0 */
        };
+#endif
 
        if (!spi_cs_is_valid(bus, cs))
                return NULL;
@@ -51,15 +58,19 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
        writel(KWSPI_SMEMRDIRQ, &spireg->irq_cause);
        writel(KWSPI_IRQMASK, &spireg->irq_mask);
 
+#ifdef CONFIG_KIRKWOOD
        /* program mpp registers to select  SPI_CSn */
        kirkwood_mpp_conf(kwspi_mpp_config[cs ? 1 : 0], cs_spi_mpp_back);
+#endif
 
        return slave;
 }
 
 void spi_free_slave(struct spi_slave *slave)
 {
+#ifdef CONFIG_KIRKWOOD
        kirkwood_mpp_conf(cs_spi_mpp_back, NULL);
+#endif
        free(slave);
 }
 
index 6557055e02b8ea130cc592b6425af0e54b0ca8d8..11811094ede8a9381af75bfc4fb0d0f12f6debaa 100644 (file)
@@ -580,6 +580,7 @@ static const struct asix_dongle asix_dongles[] = {
        { 0x2001, 0x3c05, FLAG_TYPE_AX88772 },
        /* ASIX 88772B */
        { 0x0b95, 0x772b, FLAG_TYPE_AX88772B | FLAG_EEPROM_MAC },
+       { 0x0b95, 0x7e2b, FLAG_TYPE_AX88772B },
        { 0x0000, 0x0000, FLAG_NONE }   /* END - Do not remove */
 };
 
index 3d3a0c42a5c3c5f26d16fff70f03f30433a21745..1c3592914dcf363c71de68f05a69cf5b21b5d845 100644 (file)
@@ -46,3 +46,6 @@ obj-$(CONFIG_USB_XHCI) += xhci.o xhci-mem.o xhci-ring.o
 obj-$(CONFIG_USB_XHCI_KEYSTONE) += xhci-keystone.o
 obj-$(CONFIG_USB_XHCI_EXYNOS) += xhci-exynos5.o
 obj-$(CONFIG_USB_XHCI_OMAP) += xhci-omap.o
+
+# designware
+obj-$(CONFIG_USB_DWC2) += dwc2.o
diff --git a/drivers/usb/host/dwc2.c b/drivers/usb/host/dwc2.c
new file mode 100644 (file)
index 0000000..2a5bbf5
--- /dev/null
@@ -0,0 +1,1053 @@
+/*
+ * Copyright (C) 2012 Oleksandr Tymoshenko <gonzo@freebsd.org>
+ * Copyright (C) 2014 Marek Vasut <marex@denx.de>
+ *
+ * SPDX-License-Identifier:     GPL-2.0+
+ */
+
+#include <common.h>
+#include <errno.h>
+#include <usb.h>
+#include <malloc.h>
+#include <usbroothubdes.h>
+#include <asm/io.h>
+
+#include "dwc2.h"
+
+/* Use only HC channel 0. */
+#define DWC2_HC_CHANNEL                        0
+
+#define DWC2_STATUS_BUF_SIZE           64
+#define DWC2_DATA_BUF_SIZE             (64 * 1024)
+
+/* We need doubleword-aligned buffers for DMA transfers */
+DEFINE_ALIGN_BUFFER(uint8_t, aligned_buffer, DWC2_DATA_BUF_SIZE, 8);
+DEFINE_ALIGN_BUFFER(uint8_t, status_buffer, DWC2_STATUS_BUF_SIZE, 8);
+
+#define MAX_DEVICE                     16
+#define MAX_ENDPOINT                   16
+static int bulk_data_toggle[MAX_DEVICE][MAX_ENDPOINT];
+static int control_data_toggle[MAX_DEVICE][MAX_ENDPOINT];
+
+static int root_hub_devnum;
+
+static struct dwc2_core_regs *regs =
+       (struct dwc2_core_regs *)CONFIG_USB_DWC2_REG_ADDR;
+
+/*
+ * DWC2 IP interface
+ */
+static int wait_for_bit(void *reg, const uint32_t mask, bool set)
+{
+       unsigned int timeout = 1000000;
+       uint32_t val;
+
+       while (--timeout) {
+               val = readl(reg);
+               if (!set)
+                       val = ~val;
+
+               if ((val & mask) == mask)
+                       return 0;
+
+               udelay(1);
+       }
+
+       debug("%s: Timeout (reg=%p mask=%08x wait_set=%i)\n",
+             __func__, reg, mask, set);
+
+       return -ETIMEDOUT;
+}
+
+/*
+ * Initializes the FSLSPClkSel field of the HCFG register
+ * depending on the PHY type.
+ */
+static void init_fslspclksel(struct dwc2_core_regs *regs)
+{
+       uint32_t phyclk;
+
+#if (CONFIG_DWC2_PHY_TYPE == DWC2_PHY_TYPE_FS)
+       phyclk = DWC2_HCFG_FSLSPCLKSEL_48_MHZ;  /* Full speed PHY */
+#else
+       /* High speed PHY running at full speed or high speed */
+       phyclk = DWC2_HCFG_FSLSPCLKSEL_30_60_MHZ;
+#endif
+
+#ifdef CONFIG_DWC2_ULPI_FS_LS
+       uint32_t hwcfg2 = readl(&regs->ghwcfg2);
+       uint32_t hval = (ghwcfg2 & DWC2_HWCFG2_HS_PHY_TYPE_MASK) >>
+                       DWC2_HWCFG2_HS_PHY_TYPE_OFFSET;
+       uint32_t fval = (ghwcfg2 & DWC2_HWCFG2_FS_PHY_TYPE_MASK) >>
+                       DWC2_HWCFG2_FS_PHY_TYPE_OFFSET;
+
+       if (hval == 2 && fval == 1)
+               phyclk = DWC2_HCFG_FSLSPCLKSEL_48_MHZ;  /* Full speed PHY */
+#endif
+
+       clrsetbits_le32(&regs->host_regs.hcfg,
+                       DWC2_HCFG_FSLSPCLKSEL_MASK,
+                       phyclk << DWC2_HCFG_FSLSPCLKSEL_OFFSET);
+}
+
+/*
+ * Flush a Tx FIFO.
+ *
+ * @param regs Programming view of DWC_otg controller.
+ * @param num Tx FIFO to flush.
+ */
+static void dwc_otg_flush_tx_fifo(struct dwc2_core_regs *regs, const int num)
+{
+       int ret;
+
+       writel(DWC2_GRSTCTL_TXFFLSH | (num << DWC2_GRSTCTL_TXFNUM_OFFSET),
+              &regs->grstctl);
+       ret = wait_for_bit(&regs->grstctl, DWC2_GRSTCTL_TXFFLSH, 0);
+       if (ret)
+               printf("%s: Timeout!\n", __func__);
+
+       /* Wait for 3 PHY Clocks */
+       udelay(1);
+}
+
+/*
+ * Flush Rx FIFO.
+ *
+ * @param regs Programming view of DWC_otg controller.
+ */
+static void dwc_otg_flush_rx_fifo(struct dwc2_core_regs *regs)
+{
+       int ret;
+
+       writel(DWC2_GRSTCTL_RXFFLSH, &regs->grstctl);
+       ret = wait_for_bit(&regs->grstctl, DWC2_GRSTCTL_RXFFLSH, 0);
+       if (ret)
+               printf("%s: Timeout!\n", __func__);
+
+       /* Wait for 3 PHY Clocks */
+       udelay(1);
+}
+
+/*
+ * Do core a soft reset of the core.  Be careful with this because it
+ * resets all the internal state machines of the core.
+ */
+static void dwc_otg_core_reset(struct dwc2_core_regs *regs)
+{
+       int ret;
+
+       /* Wait for AHB master IDLE state. */
+       ret = wait_for_bit(&regs->grstctl, DWC2_GRSTCTL_AHBIDLE, 1);
+       if (ret)
+               printf("%s: Timeout!\n", __func__);
+
+       /* Core Soft Reset */
+       writel(DWC2_GRSTCTL_CSFTRST, &regs->grstctl);
+       ret = wait_for_bit(&regs->grstctl, DWC2_GRSTCTL_CSFTRST, 0);
+       if (ret)
+               printf("%s: Timeout!\n", __func__);
+
+       /*
+        * Wait for core to come out of reset.
+        * NOTE: This long sleep is _very_ important, otherwise the core will
+        *       not stay in host mode after a connector ID change!
+        */
+       mdelay(100);
+}
+
+/*
+ * This function initializes the DWC_otg controller registers for
+ * host mode.
+ *
+ * This function flushes the Tx and Rx FIFOs and it flushes any entries in the
+ * request queues. Host channels are reset to ensure that they are ready for
+ * performing transfers.
+ *
+ * @param regs Programming view of DWC_otg controller
+ *
+ */
+static void dwc_otg_core_host_init(struct dwc2_core_regs *regs)
+{
+       uint32_t nptxfifosize = 0;
+       uint32_t ptxfifosize = 0;
+       uint32_t hprt0 = 0;
+       int i, ret, num_channels;
+
+       /* Restart the Phy Clock */
+       writel(0, &regs->pcgcctl);
+
+       /* Initialize Host Configuration Register */
+       init_fslspclksel(regs);
+#ifdef CONFIG_DWC2_DFLT_SPEED_FULL
+       setbits_le32(&regs->host_regs.hcfg, DWC2_HCFG_FSLSSUPP);
+#endif
+
+       /* Configure data FIFO sizes */
+#ifdef CONFIG_DWC2_ENABLE_DYNAMIC_FIFO
+       if (readl(&regs->ghwcfg2) & DWC2_HWCFG2_DYNAMIC_FIFO) {
+               /* Rx FIFO */
+               writel(CONFIG_DWC2_HOST_RX_FIFO_SIZE, &regs->grxfsiz);
+
+               /* Non-periodic Tx FIFO */
+               nptxfifosize |= CONFIG_DWC2_HOST_NPERIO_TX_FIFO_SIZE <<
+                               DWC2_FIFOSIZE_DEPTH_OFFSET;
+               nptxfifosize |= CONFIG_DWC2_HOST_RX_FIFO_SIZE <<
+                               DWC2_FIFOSIZE_STARTADDR_OFFSET;
+               writel(nptxfifosize, &regs->gnptxfsiz);
+
+               /* Periodic Tx FIFO */
+               ptxfifosize |= CONFIG_DWC2_HOST_PERIO_TX_FIFO_SIZE <<
+                               DWC2_FIFOSIZE_DEPTH_OFFSET;
+               ptxfifosize |= (CONFIG_DWC2_HOST_RX_FIFO_SIZE +
+                               CONFIG_DWC2_HOST_NPERIO_TX_FIFO_SIZE) <<
+                               DWC2_FIFOSIZE_STARTADDR_OFFSET;
+               writel(ptxfifosize, &regs->hptxfsiz);
+       }
+#endif
+
+       /* Clear Host Set HNP Enable in the OTG Control Register */
+       clrbits_le32(&regs->gotgctl, DWC2_GOTGCTL_HSTSETHNPEN);
+
+       /* Make sure the FIFOs are flushed. */
+       dwc_otg_flush_tx_fifo(regs, 0x10);      /* All Tx FIFOs */
+       dwc_otg_flush_rx_fifo(regs);
+
+       /* Flush out any leftover queued requests. */
+       num_channels = readl(&regs->ghwcfg2);
+       num_channels &= DWC2_HWCFG2_NUM_HOST_CHAN_MASK;
+       num_channels >>= DWC2_HWCFG2_NUM_HOST_CHAN_OFFSET;
+       num_channels += 1;
+
+       for (i = 0; i < num_channels; i++)
+               clrsetbits_le32(&regs->hc_regs[i].hcchar,
+                               DWC2_HCCHAR_CHEN | DWC2_HCCHAR_EPDIR,
+                               DWC2_HCCHAR_CHDIS);
+
+       /* Halt all channels to put them into a known state. */
+       for (i = 0; i < num_channels; i++) {
+               clrsetbits_le32(&regs->hc_regs[i].hcchar,
+                               DWC2_HCCHAR_EPDIR,
+                               DWC2_HCCHAR_CHEN | DWC2_HCCHAR_CHDIS);
+               ret = wait_for_bit(&regs->hc_regs[i].hcchar,
+                                  DWC2_HCCHAR_CHEN, 0);
+               if (ret)
+                       printf("%s: Timeout!\n", __func__);
+       }
+
+       /* Turn on the vbus power. */
+       if (readl(&regs->gintsts) & DWC2_GINTSTS_CURMODE_HOST) {
+               hprt0 = readl(&regs->hprt0);
+               hprt0 &= ~(DWC2_HPRT0_PRTENA | DWC2_HPRT0_PRTCONNDET);
+               hprt0 &= ~(DWC2_HPRT0_PRTENCHNG | DWC2_HPRT0_PRTOVRCURRCHNG);
+               if (!(hprt0 & DWC2_HPRT0_PRTPWR)) {
+                       hprt0 |= DWC2_HPRT0_PRTPWR;
+                       writel(hprt0, &regs->hprt0);
+               }
+       }
+}
+
+/*
+ * This function initializes the DWC_otg controller registers and
+ * prepares the core for device mode or host mode operation.
+ *
+ * @param regs Programming view of the DWC_otg controller
+ */
+static void dwc_otg_core_init(struct dwc2_core_regs *regs)
+{
+       uint32_t ahbcfg = 0;
+       uint32_t usbcfg = 0;
+       uint8_t brst_sz = CONFIG_DWC2_DMA_BURST_SIZE;
+
+       /* Common Initialization */
+       usbcfg = readl(&regs->gusbcfg);
+
+       /* Program the ULPI External VBUS bit if needed */
+#ifdef CONFIG_DWC2_PHY_ULPI_EXT_VBUS
+       usbcfg |= DWC2_GUSBCFG_ULPI_EXT_VBUS_DRV;
+#else
+       usbcfg &= ~DWC2_GUSBCFG_ULPI_EXT_VBUS_DRV;
+#endif
+
+       /* Set external TS Dline pulsing */
+#ifdef CONFIG_DWC2_TS_DLINE
+       usbcfg |= DWC2_GUSBCFG_TERM_SEL_DL_PULSE;
+#else
+       usbcfg &= ~DWC2_GUSBCFG_TERM_SEL_DL_PULSE;
+#endif
+       writel(usbcfg, &regs->gusbcfg);
+
+       /* Reset the Controller */
+       dwc_otg_core_reset(regs);
+
+       /*
+        * This programming sequence needs to happen in FS mode before
+        * any other programming occurs
+        */
+#if defined(CONFIG_DWC2_DFLT_SPEED_FULL) && \
+       (CONFIG_DWC2_PHY_TYPE == DWC2_PHY_TYPE_FS)
+       /* If FS mode with FS PHY */
+       setbits_le32(&regs->gusbcfg, DWC2_GUSBCFG_PHYSEL);
+
+       /* Reset after a PHY select */
+       dwc_otg_core_reset(regs);
+
+       /*
+        * Program DCFG.DevSpd or HCFG.FSLSPclkSel to 48Mhz in FS.
+        * Also do this on HNP Dev/Host mode switches (done in dev_init
+        * and host_init).
+        */
+       if (readl(&regs->gintsts) & DWC2_GINTSTS_CURMODE_HOST)
+               init_fslspclksel(regs);
+
+#ifdef CONFIG_DWC2_I2C_ENABLE
+       /* Program GUSBCFG.OtgUtmifsSel to I2C */
+       setbits_le32(&regs->gusbcfg, DWC2_GUSBCFG_OTGUTMIFSSEL);
+
+       /* Program GI2CCTL.I2CEn */
+       clrsetbits_le32(&regs->gi2cctl, DWC2_GI2CCTL_I2CEN |
+                       DWC2_GI2CCTL_I2CDEVADDR_MASK,
+                       1 << DWC2_GI2CCTL_I2CDEVADDR_OFFSET);
+       setbits_le32(&regs->gi2cctl, DWC2_GI2CCTL_I2CEN);
+#endif
+
+#else
+       /* High speed PHY. */
+
+       /*
+        * HS PHY parameters. These parameters are preserved during
+        * soft reset so only program the first time. Do a soft reset
+        * immediately after setting phyif.
+        */
+       usbcfg &= ~(DWC2_GUSBCFG_ULPI_UTMI_SEL | DWC2_GUSBCFG_PHYIF);
+       usbcfg |= CONFIG_DWC2_PHY_TYPE << DWC2_GUSBCFG_ULPI_UTMI_SEL_OFFSET;
+
+       if (usbcfg & DWC2_GUSBCFG_ULPI_UTMI_SEL) {      /* ULPI interface */
+#ifdef CONFIG_DWC2_PHY_ULPI_DDR
+               usbcfg |= DWC2_GUSBCFG_DDRSEL;
+#else
+               usbcfg &= ~DWC2_GUSBCFG_DDRSEL;
+#endif
+       } else {        /* UTMI+ interface */
+#if (CONFIG_DWC2_UTMI_PHY_WIDTH == 16)
+               usbcfg |= DWC2_GUSBCFG_PHYIF;
+#endif
+       }
+
+       writel(usbcfg, &regs->gusbcfg);
+
+       /* Reset after setting the PHY parameters */
+       dwc_otg_core_reset(regs);
+#endif
+
+       usbcfg = readl(&regs->gusbcfg);
+       usbcfg &= ~(DWC2_GUSBCFG_ULPI_FSLS | DWC2_GUSBCFG_ULPI_CLK_SUS_M);
+#ifdef CONFIG_DWC2_ULPI_FS_LS
+       uint32_t hwcfg2 = readl(&regs->ghwcfg2);
+       uint32_t hval = (ghwcfg2 & DWC2_HWCFG2_HS_PHY_TYPE_MASK) >>
+                       DWC2_HWCFG2_HS_PHY_TYPE_OFFSET;
+       uint32_t fval = (ghwcfg2 & DWC2_HWCFG2_FS_PHY_TYPE_MASK) >>
+                       DWC2_HWCFG2_FS_PHY_TYPE_OFFSET;
+       if (hval == 2 && fval == 1) {
+               usbcfg |= DWC2_GUSBCFG_ULPI_FSLS;
+               usbcfg |= DWC2_GUSBCFG_ULPI_CLK_SUS_M;
+       }
+#endif
+       writel(usbcfg, &regs->gusbcfg);
+
+       /* Program the GAHBCFG Register. */
+       switch (readl(&regs->ghwcfg2) & DWC2_HWCFG2_ARCHITECTURE_MASK) {
+       case DWC2_HWCFG2_ARCHITECTURE_SLAVE_ONLY:
+               break;
+       case DWC2_HWCFG2_ARCHITECTURE_EXT_DMA:
+               while (brst_sz > 1) {
+                       ahbcfg |= ahbcfg + (1 << DWC2_GAHBCFG_HBURSTLEN_OFFSET);
+                       ahbcfg &= DWC2_GAHBCFG_HBURSTLEN_MASK;
+                       brst_sz >>= 1;
+               }
+
+#ifdef CONFIG_DWC2_DMA_ENABLE
+               ahbcfg |= DWC2_GAHBCFG_DMAENABLE;
+#endif
+               break;
+
+       case DWC2_HWCFG2_ARCHITECTURE_INT_DMA:
+               ahbcfg |= DWC2_GAHBCFG_HBURSTLEN_INCR4;
+#ifdef CONFIG_DWC2_DMA_ENABLE
+               ahbcfg |= DWC2_GAHBCFG_DMAENABLE;
+#endif
+               break;
+       }
+
+       writel(ahbcfg, &regs->gahbcfg);
+
+       /* Program the GUSBCFG register for HNP/SRP. */
+       setbits_le32(&regs->gusbcfg, DWC2_GUSBCFG_HNPCAP | DWC2_GUSBCFG_SRPCAP);
+
+#ifdef CONFIG_DWC2_IC_USB_CAP
+       setbits_le32(&regs->gusbcfg, DWC2_GUSBCFG_IC_USB_CAP);
+#endif
+}
+
+/*
+ * Prepares a host channel for transferring packets to/from a specific
+ * endpoint. The HCCHARn register is set up with the characteristics specified
+ * in _hc. Host channel interrupts that may need to be serviced while this
+ * transfer is in progress are enabled.
+ *
+ * @param regs Programming view of DWC_otg controller
+ * @param hc Information needed to initialize the host channel
+ */
+static void dwc_otg_hc_init(struct dwc2_core_regs *regs, uint8_t hc_num,
+               uint8_t dev_addr, uint8_t ep_num, uint8_t ep_is_in,
+               uint8_t ep_type, uint16_t max_packet)
+{
+       struct dwc2_hc_regs *hc_regs = &regs->hc_regs[hc_num];
+       const uint32_t hcchar = (dev_addr << DWC2_HCCHAR_DEVADDR_OFFSET) |
+                               (ep_num << DWC2_HCCHAR_EPNUM_OFFSET) |
+                               (ep_is_in << DWC2_HCCHAR_EPDIR_OFFSET) |
+                               (ep_type << DWC2_HCCHAR_EPTYPE_OFFSET) |
+                               (max_packet << DWC2_HCCHAR_MPS_OFFSET);
+
+       /* Clear old interrupt conditions for this host channel. */
+       writel(0x3fff, &hc_regs->hcint);
+
+       /*
+        * Program the HCCHARn register with the endpoint characteristics
+        * for the current transfer.
+        */
+       writel(hcchar, &hc_regs->hcchar);
+
+       /* Program the HCSPLIT register for SPLITs */
+       writel(0, &hc_regs->hcsplt);
+}
+
+/*
+ * DWC2 to USB API interface
+ */
+/* Direction: In ; Request: Status */
+static int dwc_otg_submit_rh_msg_in_status(struct usb_device *dev, void *buffer,
+                                          int txlen, struct devrequest *cmd)
+{
+       uint32_t hprt0 = 0;
+       uint32_t port_status = 0;
+       uint32_t port_change = 0;
+       int len = 0;
+       int stat = 0;
+
+       switch (cmd->requesttype & ~USB_DIR_IN) {
+       case 0:
+               *(uint16_t *)buffer = cpu_to_le16(1);
+               len = 2;
+               break;
+       case USB_RECIP_INTERFACE:
+       case USB_RECIP_ENDPOINT:
+               *(uint16_t *)buffer = cpu_to_le16(0);
+               len = 2;
+               break;
+       case USB_TYPE_CLASS:
+               *(uint32_t *)buffer = cpu_to_le32(0);
+               len = 4;
+               break;
+       case USB_RECIP_OTHER | USB_TYPE_CLASS:
+               hprt0 = readl(&regs->hprt0);
+               if (hprt0 & DWC2_HPRT0_PRTCONNSTS)
+                       port_status |= USB_PORT_STAT_CONNECTION;
+               if (hprt0 & DWC2_HPRT0_PRTENA)
+                       port_status |= USB_PORT_STAT_ENABLE;
+               if (hprt0 & DWC2_HPRT0_PRTSUSP)
+                       port_status |= USB_PORT_STAT_SUSPEND;
+               if (hprt0 & DWC2_HPRT0_PRTOVRCURRACT)
+                       port_status |= USB_PORT_STAT_OVERCURRENT;
+               if (hprt0 & DWC2_HPRT0_PRTRST)
+                       port_status |= USB_PORT_STAT_RESET;
+               if (hprt0 & DWC2_HPRT0_PRTPWR)
+                       port_status |= USB_PORT_STAT_POWER;
+
+               port_status |= USB_PORT_STAT_HIGH_SPEED;
+
+               if (hprt0 & DWC2_HPRT0_PRTENCHNG)
+                       port_change |= USB_PORT_STAT_C_ENABLE;
+               if (hprt0 & DWC2_HPRT0_PRTCONNDET)
+                       port_change |= USB_PORT_STAT_C_CONNECTION;
+               if (hprt0 & DWC2_HPRT0_PRTOVRCURRCHNG)
+                       port_change |= USB_PORT_STAT_C_OVERCURRENT;
+
+               *(uint32_t *)buffer = cpu_to_le32(port_status |
+                                       (port_change << 16));
+               len = 4;
+               break;
+       default:
+               puts("unsupported root hub command\n");
+               stat = USB_ST_STALLED;
+       }
+
+       dev->act_len = min(len, txlen);
+       dev->status = stat;
+
+       return stat;
+}
+
+/* Direction: In ; Request: Descriptor */
+static int dwc_otg_submit_rh_msg_in_descriptor(struct usb_device *dev,
+                                              void *buffer, int txlen,
+                                              struct devrequest *cmd)
+{
+       unsigned char data[32];
+       uint32_t dsc;
+       int len = 0;
+       int stat = 0;
+       uint16_t wValue = cpu_to_le16(cmd->value);
+       uint16_t wLength = cpu_to_le16(cmd->length);
+
+       switch (cmd->requesttype & ~USB_DIR_IN) {
+       case 0:
+               switch (wValue & 0xff00) {
+               case 0x0100:    /* device descriptor */
+                       len = min3(txlen, sizeof(root_hub_dev_des), wLength);
+                       memcpy(buffer, root_hub_dev_des, len);
+                       break;
+               case 0x0200:    /* configuration descriptor */
+                       len = min3(txlen, sizeof(root_hub_config_des), wLength);
+                       memcpy(buffer, root_hub_config_des, len);
+                       break;
+               case 0x0300:    /* string descriptors */
+                       switch (wValue & 0xff) {
+                       case 0x00:
+                               len = min3(txlen, sizeof(root_hub_str_index0),
+                                          wLength);
+                               memcpy(buffer, root_hub_str_index0, len);
+                               break;
+                       case 0x01:
+                               len = min3(txlen, sizeof(root_hub_str_index1),
+                                          wLength);
+                               memcpy(buffer, root_hub_str_index1, len);
+                               break;
+                       }
+                       break;
+               default:
+                       stat = USB_ST_STALLED;
+               }
+               break;
+
+       case USB_TYPE_CLASS:
+               /* Root port config, set 1 port and nothing else. */
+               dsc = 0x00000001;
+
+               data[0] = 9;            /* min length; */
+               data[1] = 0x29;
+               data[2] = dsc & RH_A_NDP;
+               data[3] = 0;
+               if (dsc & RH_A_PSM)
+                       data[3] |= 0x1;
+               if (dsc & RH_A_NOCP)
+                       data[3] |= 0x10;
+               else if (dsc & RH_A_OCPM)
+                       data[3] |= 0x8;
+
+               /* corresponds to data[4-7] */
+               data[5] = (dsc & RH_A_POTPGT) >> 24;
+               data[7] = dsc & RH_B_DR;
+               if (data[2] < 7) {
+                       data[8] = 0xff;
+               } else {
+                       data[0] += 2;
+                       data[8] = (dsc & RH_B_DR) >> 8;
+                       data[9] = 0xff;
+                       data[10] = data[9];
+               }
+
+               len = min3(txlen, data[0], wLength);
+               memcpy(buffer, data, len);
+               break;
+       default:
+               puts("unsupported root hub command\n");
+               stat = USB_ST_STALLED;
+       }
+
+       dev->act_len = min(len, txlen);
+       dev->status = stat;
+
+       return stat;
+}
+
+/* Direction: In ; Request: Configuration */
+static int dwc_otg_submit_rh_msg_in_configuration(struct usb_device *dev,
+                                                 void *buffer, int txlen,
+                                                 struct devrequest *cmd)
+{
+       int len = 0;
+       int stat = 0;
+
+       switch (cmd->requesttype & ~USB_DIR_IN) {
+       case 0:
+               *(uint8_t *)buffer = 0x01;
+               len = 1;
+               break;
+       default:
+               puts("unsupported root hub command\n");
+               stat = USB_ST_STALLED;
+       }
+
+       dev->act_len = min(len, txlen);
+       dev->status = stat;
+
+       return stat;
+}
+
+/* Direction: In */
+static int dwc_otg_submit_rh_msg_in(struct usb_device *dev,
+                                void *buffer, int txlen,
+                                struct devrequest *cmd)
+{
+       switch (cmd->request) {
+       case USB_REQ_GET_STATUS:
+               return dwc_otg_submit_rh_msg_in_status(dev, buffer,
+                                                      txlen, cmd);
+       case USB_REQ_GET_DESCRIPTOR:
+               return dwc_otg_submit_rh_msg_in_descriptor(dev, buffer,
+                                                          txlen, cmd);
+       case USB_REQ_GET_CONFIGURATION:
+               return dwc_otg_submit_rh_msg_in_configuration(dev, buffer,
+                                                             txlen, cmd);
+       default:
+               puts("unsupported root hub command\n");
+               return USB_ST_STALLED;
+       }
+}
+
+/* Direction: Out */
+static int dwc_otg_submit_rh_msg_out(struct usb_device *dev,
+                                void *buffer, int txlen,
+                                struct devrequest *cmd)
+{
+       int len = 0;
+       int stat = 0;
+       uint16_t bmrtype_breq = cmd->requesttype | (cmd->request << 8);
+       uint16_t wValue = cpu_to_le16(cmd->value);
+
+       switch (bmrtype_breq & ~USB_DIR_IN) {
+       case (USB_REQ_CLEAR_FEATURE << 8) | USB_RECIP_ENDPOINT:
+       case (USB_REQ_CLEAR_FEATURE << 8) | USB_TYPE_CLASS:
+               break;
+
+       case (USB_REQ_CLEAR_FEATURE << 8) | USB_RECIP_OTHER | USB_TYPE_CLASS:
+               switch (wValue) {
+               case USB_PORT_FEAT_C_CONNECTION:
+                       setbits_le32(&regs->hprt0, DWC2_HPRT0_PRTCONNDET);
+                       break;
+               }
+               break;
+
+       case (USB_REQ_SET_FEATURE << 8) | USB_RECIP_OTHER | USB_TYPE_CLASS:
+               switch (wValue) {
+               case USB_PORT_FEAT_SUSPEND:
+                       break;
+
+               case USB_PORT_FEAT_RESET:
+                       clrsetbits_le32(&regs->hprt0, DWC2_HPRT0_PRTENA |
+                                       DWC2_HPRT0_PRTCONNDET |
+                                       DWC2_HPRT0_PRTENCHNG |
+                                       DWC2_HPRT0_PRTOVRCURRCHNG,
+                                       DWC2_HPRT0_PRTRST);
+                       mdelay(50);
+                       clrbits_le32(&regs->hprt0, DWC2_HPRT0_PRTRST);
+                       break;
+
+               case USB_PORT_FEAT_POWER:
+                       clrsetbits_le32(&regs->hprt0, DWC2_HPRT0_PRTENA |
+                                       DWC2_HPRT0_PRTCONNDET |
+                                       DWC2_HPRT0_PRTENCHNG |
+                                       DWC2_HPRT0_PRTOVRCURRCHNG,
+                                       DWC2_HPRT0_PRTRST);
+                       break;
+
+               case USB_PORT_FEAT_ENABLE:
+                       break;
+               }
+               break;
+       case (USB_REQ_SET_ADDRESS << 8):
+               root_hub_devnum = wValue;
+               break;
+       case (USB_REQ_SET_CONFIGURATION << 8):
+               break;
+       default:
+               puts("unsupported root hub command\n");
+               stat = USB_ST_STALLED;
+       }
+
+       len = min(len, txlen);
+
+       dev->act_len = len;
+       dev->status = stat;
+
+       return stat;
+}
+
+static int dwc_otg_submit_rh_msg(struct usb_device *dev, unsigned long pipe,
+                                void *buffer, int txlen,
+                                struct devrequest *cmd)
+{
+       int stat = 0;
+
+       if (usb_pipeint(pipe)) {
+               puts("Root-Hub submit IRQ: NOT implemented\n");
+               return 0;
+       }
+
+       if (cmd->requesttype & USB_DIR_IN)
+               stat = dwc_otg_submit_rh_msg_in(dev, buffer, txlen, cmd);
+       else
+               stat = dwc_otg_submit_rh_msg_out(dev, buffer, txlen, cmd);
+
+       mdelay(1);
+
+       return stat;
+}
+
+/* U-Boot USB transmission interface */
+int submit_bulk_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
+                   int len)
+{
+       int devnum = usb_pipedevice(pipe);
+       int ep = usb_pipeendpoint(pipe);
+       int max = usb_maxpacket(dev, pipe);
+       int done = 0;
+       uint32_t hctsiz, sub, tmp;
+       struct dwc2_hc_regs *hc_regs = &regs->hc_regs[DWC2_HC_CHANNEL];
+       uint32_t hcint;
+       uint32_t xfer_len;
+       uint32_t num_packets;
+       int stop_transfer = 0;
+       unsigned int timeout = 1000000;
+
+       if (devnum == root_hub_devnum) {
+               dev->status = 0;
+               return -EINVAL;
+       }
+
+       if (len > DWC2_DATA_BUF_SIZE) {
+               printf("%s: %d is more then available buffer size (%d)\n",
+                      __func__, len, DWC2_DATA_BUF_SIZE);
+               dev->status = 0;
+               dev->act_len = 0;
+               return -EINVAL;
+       }
+
+       while ((done < len) && !stop_transfer) {
+               /* Initialize channel */
+               dwc_otg_hc_init(regs, DWC2_HC_CHANNEL, devnum, ep,
+                               usb_pipein(pipe), DWC2_HCCHAR_EPTYPE_BULK, max);
+
+               xfer_len = len - done;
+               /* Make sure that xfer_len is a multiple of max packet size. */
+               if (xfer_len > CONFIG_DWC2_MAX_TRANSFER_SIZE)
+                       xfer_len = CONFIG_DWC2_MAX_TRANSFER_SIZE - max + 1;
+
+               if (xfer_len > 0) {
+                       num_packets = (xfer_len + max - 1) / max;
+                       if (num_packets > CONFIG_DWC2_MAX_PACKET_COUNT) {
+                               num_packets = CONFIG_DWC2_MAX_PACKET_COUNT;
+                               xfer_len = num_packets * max;
+                       }
+               } else {
+                       num_packets = 1;
+               }
+
+               if (usb_pipein(pipe))
+                       xfer_len = num_packets * max;
+
+               writel((xfer_len << DWC2_HCTSIZ_XFERSIZE_OFFSET) |
+                      (num_packets << DWC2_HCTSIZ_PKTCNT_OFFSET) |
+                      (bulk_data_toggle[devnum][ep] <<
+                               DWC2_HCTSIZ_PID_OFFSET),
+                      &hc_regs->hctsiz);
+
+               memcpy(aligned_buffer, (char *)buffer + done, len - done);
+               writel((uint32_t)aligned_buffer, &hc_regs->hcdma);
+
+               /* Set host channel enable after all other setup is complete. */
+               clrsetbits_le32(&hc_regs->hcchar, DWC2_HCCHAR_MULTICNT_MASK |
+                               DWC2_HCCHAR_CHEN | DWC2_HCCHAR_CHDIS,
+                               (1 << DWC2_HCCHAR_MULTICNT_OFFSET) |
+                               DWC2_HCCHAR_CHEN);
+
+               while (1) {
+                       hcint = readl(&hc_regs->hcint);
+
+                       if (!(hcint & DWC2_HCINT_CHHLTD))
+                               continue;
+
+                       if (hcint & DWC2_HCINT_XFERCOMP) {
+                               hctsiz = readl(&hc_regs->hctsiz);
+                               done += xfer_len;
+
+                               sub = hctsiz & DWC2_HCTSIZ_XFERSIZE_MASK;
+                               sub >>= DWC2_HCTSIZ_XFERSIZE_OFFSET;
+
+                               if (usb_pipein(pipe)) {
+                                       done -= sub;
+                                       if (hctsiz & DWC2_HCTSIZ_XFERSIZE_MASK)
+                                               stop_transfer = 1;
+                               }
+
+                               tmp = hctsiz & DWC2_HCTSIZ_PID_MASK;
+                               tmp >>= DWC2_HCTSIZ_PID_OFFSET;
+                               if (tmp == DWC2_HC_PID_DATA1) {
+                                       bulk_data_toggle[devnum][ep] =
+                                               DWC2_HC_PID_DATA1;
+                               } else {
+                                       bulk_data_toggle[devnum][ep] =
+                                               DWC2_HC_PID_DATA0;
+                               }
+                               break;
+                       }
+
+                       if (hcint & DWC2_HCINT_STALL) {
+                               puts("DWC OTG: Channel halted\n");
+                               bulk_data_toggle[devnum][ep] =
+                                       DWC2_HC_PID_DATA0;
+
+                               stop_transfer = 1;
+                               break;
+                       }
+
+                       if (!--timeout) {
+                               printf("%s: Timeout!\n", __func__);
+                               break;
+                       }
+               }
+       }
+
+       if (done && usb_pipein(pipe))
+               memcpy(buffer, aligned_buffer, done);
+
+       writel(0, &hc_regs->hcintmsk);
+       writel(0xFFFFFFFF, &hc_regs->hcint);
+
+       dev->status = 0;
+       dev->act_len = done;
+
+       return 0;
+}
+
+int submit_control_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
+                      int len, struct devrequest *setup)
+{
+       struct dwc2_hc_regs *hc_regs = &regs->hc_regs[DWC2_HC_CHANNEL];
+       int done = 0;
+       int devnum = usb_pipedevice(pipe);
+       int ep = usb_pipeendpoint(pipe);
+       int max = usb_maxpacket(dev, pipe);
+       uint32_t hctsiz = 0, sub, tmp, ret;
+       uint32_t hcint;
+       const uint32_t hcint_comp_hlt_ack = DWC2_HCINT_XFERCOMP |
+               DWC2_HCINT_CHHLTD | DWC2_HCINT_ACK;
+       unsigned int timeout = 1000000;
+
+       /* For CONTROL endpoint pid should start with DATA1 */
+       int status_direction;
+
+       if (devnum == root_hub_devnum) {
+               dev->status = 0;
+               dev->speed = USB_SPEED_HIGH;
+               return dwc_otg_submit_rh_msg(dev, pipe, buffer, len, setup);
+       }
+
+       if (len > DWC2_DATA_BUF_SIZE) {
+               printf("%s: %d is more then available buffer size(%d)\n",
+                      __func__, len, DWC2_DATA_BUF_SIZE);
+               dev->status = 0;
+               dev->act_len = 0;
+               return -EINVAL;
+       }
+
+       /* Initialize channel, OUT for setup buffer */
+       dwc_otg_hc_init(regs, DWC2_HC_CHANNEL, devnum, ep, 0,
+                       DWC2_HCCHAR_EPTYPE_CONTROL, max);
+
+       /* SETUP stage  */
+       writel((8 << DWC2_HCTSIZ_XFERSIZE_OFFSET) |
+              (1 << DWC2_HCTSIZ_PKTCNT_OFFSET) |
+              (DWC2_HC_PID_SETUP << DWC2_HCTSIZ_PID_OFFSET),
+              &hc_regs->hctsiz);
+
+       writel((uint32_t)setup, &hc_regs->hcdma);
+
+       /* Set host channel enable after all other setup is complete. */
+       clrsetbits_le32(&hc_regs->hcchar, DWC2_HCCHAR_MULTICNT_MASK |
+                       DWC2_HCCHAR_CHEN | DWC2_HCCHAR_CHDIS,
+                       (1 << DWC2_HCCHAR_MULTICNT_OFFSET) | DWC2_HCCHAR_CHEN);
+
+       ret = wait_for_bit(&hc_regs->hcint, DWC2_HCINT_CHHLTD, 1);
+       if (ret)
+               printf("%s: Timeout!\n", __func__);
+
+       hcint = readl(&hc_regs->hcint);
+
+       if (!(hcint & DWC2_HCINT_CHHLTD) || !(hcint & DWC2_HCINT_XFERCOMP)) {
+               printf("%s: Error (HCINT=%08x)\n", __func__, hcint);
+               dev->status = 0;
+               dev->act_len = 0;
+               return -EINVAL;
+       }
+
+       /* Clear interrupts */
+       writel(0, &hc_regs->hcintmsk);
+       writel(0xFFFFFFFF, &hc_regs->hcint);
+
+       if (buffer) {
+               /* DATA stage */
+               dwc_otg_hc_init(regs, DWC2_HC_CHANNEL, devnum, ep,
+                               usb_pipein(pipe),
+                               DWC2_HCCHAR_EPTYPE_CONTROL, max);
+
+               /* TODO: check if len < 64 */
+               control_data_toggle[devnum][ep] = DWC2_HC_PID_DATA1;
+               writel((len << DWC2_HCTSIZ_XFERSIZE_OFFSET) |
+                      (1 << DWC2_HCTSIZ_PKTCNT_OFFSET) |
+                      (control_data_toggle[devnum][ep] <<
+                               DWC2_HCTSIZ_PID_OFFSET),
+                      &hc_regs->hctsiz);
+
+               writel((uint32_t)buffer, &hc_regs->hcdma);
+
+               /* Set host channel enable after all other setup is complete */
+               clrsetbits_le32(&hc_regs->hcchar, DWC2_HCCHAR_MULTICNT_MASK |
+                               DWC2_HCCHAR_CHEN | DWC2_HCCHAR_CHDIS,
+                               (1 << DWC2_HCCHAR_MULTICNT_OFFSET) |
+                               DWC2_HCCHAR_CHEN);
+
+               while (1) {
+                       hcint = readl(&hc_regs->hcint);
+                       if (!(hcint & DWC2_HCINT_CHHLTD))
+                               continue;
+
+                       if (hcint & DWC2_HCINT_XFERCOMP) {
+                               hctsiz = readl(&hc_regs->hctsiz);
+                               done = len;
+
+                               sub = hctsiz & DWC2_HCTSIZ_XFERSIZE_MASK;
+                               sub >>= DWC2_HCTSIZ_XFERSIZE_OFFSET;
+
+                               if (usb_pipein(pipe))
+                                       done -= sub;
+                       }
+
+                       if (hcint & DWC2_HCINT_ACK) {
+                               tmp = hctsiz & DWC2_HCTSIZ_PID_MASK;
+                               tmp >>= DWC2_HCTSIZ_PID_OFFSET;
+                               if (tmp == DWC2_HC_PID_DATA0) {
+                                       control_data_toggle[devnum][ep] =
+                                               DWC2_HC_PID_DATA0;
+                               } else {
+                                       control_data_toggle[devnum][ep] =
+                                               DWC2_HC_PID_DATA1;
+                               }
+                       }
+
+                       if (hcint != hcint_comp_hlt_ack) {
+                               printf("%s: Error (HCINT=%08x)\n",
+                                      __func__, hcint);
+                               goto out;
+                       }
+
+                       if (!--timeout) {
+                               printf("%s: Timeout!\n", __func__);
+                               goto out;
+                       }
+
+                       break;
+               }
+       } /* End of DATA stage */
+
+       /* STATUS stage */
+       if ((len == 0) || usb_pipeout(pipe))
+               status_direction = 1;
+       else
+               status_direction = 0;
+
+       dwc_otg_hc_init(regs, DWC2_HC_CHANNEL, devnum, ep,
+                       status_direction, DWC2_HCCHAR_EPTYPE_CONTROL, max);
+
+       writel((1 << DWC2_HCTSIZ_PKTCNT_OFFSET) |
+              (DWC2_HC_PID_DATA1 << DWC2_HCTSIZ_PID_OFFSET),
+              &hc_regs->hctsiz);
+
+       writel((uint32_t)status_buffer, &hc_regs->hcdma);
+
+       /* Set host channel enable after all other setup is complete. */
+       clrsetbits_le32(&hc_regs->hcchar, DWC2_HCCHAR_MULTICNT_MASK |
+                       DWC2_HCCHAR_CHEN | DWC2_HCCHAR_CHDIS,
+                       (1 << DWC2_HCCHAR_MULTICNT_OFFSET) | DWC2_HCCHAR_CHEN);
+
+       while (1) {
+               hcint = readl(&hc_regs->hcint);
+               if (hcint & DWC2_HCINT_CHHLTD)
+                       break;
+       }
+
+       if (hcint != hcint_comp_hlt_ack)
+               printf("%s: Error (HCINT=%08x)\n", __func__, hcint);
+
+out:
+       dev->act_len = done;
+       dev->status = 0;
+
+       return done;
+}
+
+int submit_int_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
+                  int len, int interval)
+{
+       printf("dev = %p pipe = %#lx buf = %p size = %d int = %d\n",
+              dev, pipe, buffer, len, interval);
+       return -ENOSYS;
+}
+
+/* U-Boot USB control interface */
+int usb_lowlevel_init(int index, enum usb_init_type init, void **controller)
+{
+       uint32_t snpsid;
+       int i, j;
+
+       root_hub_devnum = 0;
+
+       snpsid = readl(&regs->gsnpsid);
+       printf("Core Release: %x.%03x\n", snpsid >> 12 & 0xf, snpsid & 0xfff);
+
+       if ((snpsid & DWC2_SNPSID_DEVID_MASK) != DWC2_SNPSID_DEVID_VER_2xx) {
+               printf("SNPSID invalid (not DWC2 OTG device): %08x\n", snpsid);
+               return -ENODEV;
+       }
+
+       dwc_otg_core_init(regs);
+       dwc_otg_core_host_init(regs);
+
+       clrsetbits_le32(&regs->hprt0, DWC2_HPRT0_PRTENA |
+                       DWC2_HPRT0_PRTCONNDET | DWC2_HPRT0_PRTENCHNG |
+                       DWC2_HPRT0_PRTOVRCURRCHNG,
+                       DWC2_HPRT0_PRTRST);
+       mdelay(50);
+       clrbits_le32(&regs->hprt0, DWC2_HPRT0_PRTENA | DWC2_HPRT0_PRTCONNDET |
+                    DWC2_HPRT0_PRTENCHNG | DWC2_HPRT0_PRTOVRCURRCHNG |
+                    DWC2_HPRT0_PRTRST);
+
+       for (i = 0; i < MAX_DEVICE; i++) {
+               for (j = 0; j < MAX_ENDPOINT; j++) {
+                       control_data_toggle[i][j] = DWC2_HC_PID_DATA1;
+                       bulk_data_toggle[i][j] = DWC2_HC_PID_DATA0;
+               }
+       }
+
+       return 0;
+}
+
+int usb_lowlevel_stop(int index)
+{
+       /* Put everything in reset. */
+       clrsetbits_le32(&regs->hprt0, DWC2_HPRT0_PRTENA |
+                       DWC2_HPRT0_PRTCONNDET | DWC2_HPRT0_PRTENCHNG |
+                       DWC2_HPRT0_PRTOVRCURRCHNG,
+                       DWC2_HPRT0_PRTRST);
+       return 0;
+}
diff --git a/drivers/usb/host/dwc2.h b/drivers/usb/host/dwc2.h
new file mode 100644 (file)
index 0000000..ba08fd5
--- /dev/null
@@ -0,0 +1,782 @@
+/*
+ * Copyright (C) 2014 Marek Vasut <marex@denx.de>
+ *
+ * SPDX-License-Identifier:     GPL-2.0+
+ */
+
+#ifndef __DWC2_H__
+#define __DWC2_H__
+
+struct dwc2_hc_regs {
+       u32                     hcchar;         /* 0x00 */
+       u32                     hcsplt;
+       u32                     hcint;
+       u32                     hcintmsk;
+       u32                     hctsiz;         /* 0x10 */
+       u32                     hcdma;
+       u32                     reserved;
+       u32                     hcdmab;
+};
+
+struct dwc2_host_regs {
+       u32                     hcfg;           /* 0x00 */
+       u32                     hfir;
+       u32                     hfnum;
+       u32                     _pad_0x40c;
+       u32                     hptxsts;        /* 0x10 */
+       u32                     haint;
+       u32                     haintmsk;
+       u32                     hflbaddr;
+};
+
+struct dwc2_core_regs {
+       u32                     gotgctl;        /* 0x000 */
+       u32                     gotgint;
+       u32                     gahbcfg;
+       u32                     gusbcfg;
+       u32                     grstctl;        /* 0x010 */
+       u32                     gintsts;
+       u32                     gintmsk;
+       u32                     grxstsr;
+       u32                     grxstsp;        /* 0x020 */
+       u32                     grxfsiz;
+       u32                     gnptxfsiz;
+       u32                     gnptxsts;
+       u32                     gi2cctl;        /* 0x030 */
+       u32                     gpvndctl;
+       u32                     ggpio;
+       u32                     guid;
+       u32                     gsnpsid;        /* 0x040 */
+       u32                     ghwcfg1;
+       u32                     ghwcfg2;
+       u32                     ghwcfg3;
+       u32                     ghwcfg4;        /* 0x050 */
+       u32                     glpmcfg;
+       u32                     _pad_0x58_0x9c[42];
+       u32                     hptxfsiz;       /* 0x100 */
+       u32                     dptxfsiz_dieptxf[15];
+       u32                     _pad_0x140_0x3fc[176];
+       struct dwc2_host_regs   host_regs;      /* 0x400 */
+       u32                     _pad_0x420_0x43c[8];
+       u32                     hprt0;          /* 0x440 */
+       u32                     _pad_0x444_0x4fc[47];
+       struct dwc2_hc_regs     hc_regs[16];    /* 0x500 */
+       u32                     _pad_0x700_0xe00[448];
+       u32                     pcgcctl;        /* 0xe00 */
+};
+
+#define DWC2_GOTGCTL_SESREQSCS                         (1 << 0)
+#define DWC2_GOTGCTL_SESREQSCS_OFFSET                  0
+#define DWC2_GOTGCTL_SESREQ                            (1 << 1)
+#define DWC2_GOTGCTL_SESREQ_OFFSET                     1
+#define DWC2_GOTGCTL_HSTNEGSCS                         (1 << 8)
+#define DWC2_GOTGCTL_HSTNEGSCS_OFFSET                  8
+#define DWC2_GOTGCTL_HNPREQ                            (1 << 9)
+#define DWC2_GOTGCTL_HNPREQ_OFFSET                     9
+#define DWC2_GOTGCTL_HSTSETHNPEN                       (1 << 10)
+#define DWC2_GOTGCTL_HSTSETHNPEN_OFFSET                        10
+#define DWC2_GOTGCTL_DEVHNPEN                          (1 << 11)
+#define DWC2_GOTGCTL_DEVHNPEN_OFFSET                   11
+#define DWC2_GOTGCTL_CONIDSTS                          (1 << 16)
+#define DWC2_GOTGCTL_CONIDSTS_OFFSET                   16
+#define DWC2_GOTGCTL_DBNCTIME                          (1 << 17)
+#define DWC2_GOTGCTL_DBNCTIME_OFFSET                   17
+#define DWC2_GOTGCTL_ASESVLD                           (1 << 18)
+#define DWC2_GOTGCTL_ASESVLD_OFFSET                    18
+#define DWC2_GOTGCTL_BSESVLD                           (1 << 19)
+#define DWC2_GOTGCTL_BSESVLD_OFFSET                    19
+#define DWC2_GOTGCTL_OTGVER                            (1 << 20)
+#define DWC2_GOTGCTL_OTGVER_OFFSET                     20
+#define DWC2_GOTGINT_SESENDDET                         (1 << 2)
+#define DWC2_GOTGINT_SESENDDET_OFFSET                  2
+#define DWC2_GOTGINT_SESREQSUCSTSCHNG                  (1 << 8)
+#define DWC2_GOTGINT_SESREQSUCSTSCHNG_OFFSET           8
+#define DWC2_GOTGINT_HSTNEGSUCSTSCHNG                  (1 << 9)
+#define DWC2_GOTGINT_HSTNEGSUCSTSCHNG_OFFSET           9
+#define DWC2_GOTGINT_RESERVER10_16_MASK                        (0x7F << 10)
+#define DWC2_GOTGINT_RESERVER10_16_OFFSET              10
+#define DWC2_GOTGINT_HSTNEGDET                         (1 << 17)
+#define DWC2_GOTGINT_HSTNEGDET_OFFSET                  17
+#define DWC2_GOTGINT_ADEVTOUTCHNG                      (1 << 18)
+#define DWC2_GOTGINT_ADEVTOUTCHNG_OFFSET               18
+#define DWC2_GOTGINT_DEBDONE                           (1 << 19)
+#define DWC2_GOTGINT_DEBDONE_OFFSET                    19
+#define DWC2_GAHBCFG_GLBLINTRMSK                       (1 << 0)
+#define DWC2_GAHBCFG_GLBLINTRMSK_OFFSET                        0
+#define DWC2_GAHBCFG_HBURSTLEN_SINGLE                  (0 << 1)
+#define DWC2_GAHBCFG_HBURSTLEN_INCR                    (1 << 1)
+#define DWC2_GAHBCFG_HBURSTLEN_INCR4                   (3 << 1)
+#define DWC2_GAHBCFG_HBURSTLEN_INCR8                   (5 << 1)
+#define DWC2_GAHBCFG_HBURSTLEN_INCR16                  (7 << 1)
+#define DWC2_GAHBCFG_HBURSTLEN_MASK                    (0xF << 1)
+#define DWC2_GAHBCFG_HBURSTLEN_OFFSET                  1
+#define DWC2_GAHBCFG_DMAENABLE                         (1 << 5)
+#define DWC2_GAHBCFG_DMAENABLE_OFFSET                  5
+#define DWC2_GAHBCFG_NPTXFEMPLVL_TXFEMPLVL             (1 << 7)
+#define DWC2_GAHBCFG_NPTXFEMPLVL_TXFEMPLVL_OFFSET      7
+#define DWC2_GAHBCFG_PTXFEMPLVL                                (1 << 8)
+#define DWC2_GAHBCFG_PTXFEMPLVL_OFFSET                 8
+#define DWC2_GUSBCFG_TOUTCAL_MASK                      (0x7 << 0)
+#define DWC2_GUSBCFG_TOUTCAL_OFFSET                    0
+#define DWC2_GUSBCFG_PHYIF                             (1 << 3)
+#define DWC2_GUSBCFG_PHYIF_OFFSET                      3
+#define DWC2_GUSBCFG_ULPI_UTMI_SEL                     (1 << 4)
+#define DWC2_GUSBCFG_ULPI_UTMI_SEL_OFFSET              4
+#define DWC2_GUSBCFG_FSINTF                            (1 << 5)
+#define DWC2_GUSBCFG_FSINTF_OFFSET                     5
+#define DWC2_GUSBCFG_PHYSEL                            (1 << 6)
+#define DWC2_GUSBCFG_PHYSEL_OFFSET                     6
+#define DWC2_GUSBCFG_DDRSEL                            (1 << 7)
+#define DWC2_GUSBCFG_DDRSEL_OFFSET                     7
+#define DWC2_GUSBCFG_SRPCAP                            (1 << 8)
+#define DWC2_GUSBCFG_SRPCAP_OFFSET                     8
+#define DWC2_GUSBCFG_HNPCAP                            (1 << 9)
+#define DWC2_GUSBCFG_HNPCAP_OFFSET                     9
+#define DWC2_GUSBCFG_USBTRDTIM_MASK                    (0xF << 10)
+#define DWC2_GUSBCFG_USBTRDTIM_OFFSET                  10
+#define DWC2_GUSBCFG_NPTXFRWNDEN                       (1 << 14)
+#define DWC2_GUSBCFG_NPTXFRWNDEN_OFFSET                        14
+#define DWC2_GUSBCFG_PHYLPWRCLKSEL                     (1 << 15)
+#define DWC2_GUSBCFG_PHYLPWRCLKSEL_OFFSET              15
+#define DWC2_GUSBCFG_OTGUTMIFSSEL                      (1 << 16)
+#define DWC2_GUSBCFG_OTGUTMIFSSEL_OFFSET               16
+#define DWC2_GUSBCFG_ULPI_FSLS                         (1 << 17)
+#define DWC2_GUSBCFG_ULPI_FSLS_OFFSET                  17
+#define DWC2_GUSBCFG_ULPI_AUTO_RES                     (1 << 18)
+#define DWC2_GUSBCFG_ULPI_AUTO_RES_OFFSET              18
+#define DWC2_GUSBCFG_ULPI_CLK_SUS_M                    (1 << 19)
+#define DWC2_GUSBCFG_ULPI_CLK_SUS_M_OFFSET             19
+#define DWC2_GUSBCFG_ULPI_EXT_VBUS_DRV                 (1 << 20)
+#define DWC2_GUSBCFG_ULPI_EXT_VBUS_DRV_OFFSET          20
+#define DWC2_GUSBCFG_ULPI_INT_VBUS_INDICATOR           (1 << 21)
+#define DWC2_GUSBCFG_ULPI_INT_VBUS_INDICATOR_OFFSET    21
+#define DWC2_GUSBCFG_TERM_SEL_DL_PULSE                 (1 << 22)
+#define DWC2_GUSBCFG_TERM_SEL_DL_PULSE_OFFSET          22
+#define DWC2_GUSBCFG_IC_USB_CAP                                (1 << 26)
+#define DWC2_GUSBCFG_IC_USB_CAP_OFFSET                 26
+#define DWC2_GUSBCFG_IC_TRAFFIC_PULL_REMOVE            (1 << 27)
+#define DWC2_GUSBCFG_IC_TRAFFIC_PULL_REMOVE_OFFSET     27
+#define DWC2_GUSBCFG_TX_END_DELAY                      (1 << 28)
+#define DWC2_GUSBCFG_TX_END_DELAY_OFFSET               28
+#define DWC2_GUSBCFG_FORCEHOSTMODE                     (1 << 29)
+#define DWC2_GUSBCFG_FORCEHOSTMODE_OFFSET              29
+#define DWC2_GUSBCFG_FORCEDEVMODE                      (1 << 30)
+#define DWC2_GUSBCFG_FORCEDEVMODE_OFFSET               30
+#define DWC2_GLPMCTL_LPM_CAP_EN                                (1 << 0)
+#define DWC2_GLPMCTL_LPM_CAP_EN_OFFSET                 0
+#define DWC2_GLPMCTL_APPL_RESP                         (1 << 1)
+#define DWC2_GLPMCTL_APPL_RESP_OFFSET                  1
+#define DWC2_GLPMCTL_HIRD_MASK                         (0xF << 2)
+#define DWC2_GLPMCTL_HIRD_OFFSET                       2
+#define DWC2_GLPMCTL_REM_WKUP_EN                       (1 << 6)
+#define DWC2_GLPMCTL_REM_WKUP_EN_OFFSET                        6
+#define DWC2_GLPMCTL_EN_UTMI_SLEEP                     (1 << 7)
+#define DWC2_GLPMCTL_EN_UTMI_SLEEP_OFFSET              7
+#define DWC2_GLPMCTL_HIRD_THRES_MASK                   (0x1F << 8)
+#define DWC2_GLPMCTL_HIRD_THRES_OFFSET                 8
+#define DWC2_GLPMCTL_LPM_RESP_MASK                     (0x3 << 13)
+#define DWC2_GLPMCTL_LPM_RESP_OFFSET                   13
+#define DWC2_GLPMCTL_PRT_SLEEP_STS                     (1 << 15)
+#define DWC2_GLPMCTL_PRT_SLEEP_STS_OFFSET              15
+#define DWC2_GLPMCTL_SLEEP_STATE_RESUMEOK              (1 << 16)
+#define DWC2_GLPMCTL_SLEEP_STATE_RESUMEOK_OFFSET       16
+#define DWC2_GLPMCTL_LPM_CHAN_INDEX_MASK               (0xF << 17)
+#define DWC2_GLPMCTL_LPM_CHAN_INDEX_OFFSET             17
+#define DWC2_GLPMCTL_RETRY_COUNT_MASK                  (0x7 << 21)
+#define DWC2_GLPMCTL_RETRY_COUNT_OFFSET                        21
+#define DWC2_GLPMCTL_SEND_LPM                          (1 << 24)
+#define DWC2_GLPMCTL_SEND_LPM_OFFSET                   24
+#define DWC2_GLPMCTL_RETRY_COUNT_STS_MASK              (0x7 << 25)
+#define DWC2_GLPMCTL_RETRY_COUNT_STS_OFFSET            25
+#define DWC2_GLPMCTL_HSIC_CONNECT                      (1 << 30)
+#define DWC2_GLPMCTL_HSIC_CONNECT_OFFSET               30
+#define DWC2_GLPMCTL_INV_SEL_HSIC                      (1 << 31)
+#define DWC2_GLPMCTL_INV_SEL_HSIC_OFFSET               31
+#define DWC2_GRSTCTL_CSFTRST                           (1 << 0)
+#define DWC2_GRSTCTL_CSFTRST_OFFSET                    0
+#define DWC2_GRSTCTL_HSFTRST                           (1 << 1)
+#define DWC2_GRSTCTL_HSFTRST_OFFSET                    1
+#define DWC2_GRSTCTL_HSTFRM                            (1 << 2)
+#define DWC2_GRSTCTL_HSTFRM_OFFSET                     2
+#define DWC2_GRSTCTL_INTKNQFLSH                                (1 << 3)
+#define DWC2_GRSTCTL_INTKNQFLSH_OFFSET                 3
+#define DWC2_GRSTCTL_RXFFLSH                           (1 << 4)
+#define DWC2_GRSTCTL_RXFFLSH_OFFSET                    4
+#define DWC2_GRSTCTL_TXFFLSH                           (1 << 5)
+#define DWC2_GRSTCTL_TXFFLSH_OFFSET                    5
+#define DWC2_GRSTCTL_TXFNUM_MASK                       (0x1F << 6)
+#define DWC2_GRSTCTL_TXFNUM_OFFSET                     6
+#define DWC2_GRSTCTL_DMAREQ                            (1 << 30)
+#define DWC2_GRSTCTL_DMAREQ_OFFSET                     30
+#define DWC2_GRSTCTL_AHBIDLE                           (1 << 31)
+#define DWC2_GRSTCTL_AHBIDLE_OFFSET                    31
+#define DWC2_GINTMSK_MODEMISMATCH                      (1 << 1)
+#define DWC2_GINTMSK_MODEMISMATCH_OFFSET               1
+#define DWC2_GINTMSK_OTGINTR                           (1 << 2)
+#define DWC2_GINTMSK_OTGINTR_OFFSET                    2
+#define DWC2_GINTMSK_SOFINTR                           (1 << 3)
+#define DWC2_GINTMSK_SOFINTR_OFFSET                    3
+#define DWC2_GINTMSK_RXSTSQLVL                         (1 << 4)
+#define DWC2_GINTMSK_RXSTSQLVL_OFFSET                  4
+#define DWC2_GINTMSK_NPTXFEMPTY                                (1 << 5)
+#define DWC2_GINTMSK_NPTXFEMPTY_OFFSET                 5
+#define DWC2_GINTMSK_GINNAKEFF                         (1 << 6)
+#define DWC2_GINTMSK_GINNAKEFF_OFFSET                  6
+#define DWC2_GINTMSK_GOUTNAKEFF                                (1 << 7)
+#define DWC2_GINTMSK_GOUTNAKEFF_OFFSET                 7
+#define DWC2_GINTMSK_I2CINTR                           (1 << 9)
+#define DWC2_GINTMSK_I2CINTR_OFFSET                    9
+#define DWC2_GINTMSK_ERLYSUSPEND                       (1 << 10)
+#define DWC2_GINTMSK_ERLYSUSPEND_OFFSET                        10
+#define DWC2_GINTMSK_USBSUSPEND                                (1 << 11)
+#define DWC2_GINTMSK_USBSUSPEND_OFFSET                 11
+#define DWC2_GINTMSK_USBRESET                          (1 << 12)
+#define DWC2_GINTMSK_USBRESET_OFFSET                   12
+#define DWC2_GINTMSK_ENUMDONE                          (1 << 13)
+#define DWC2_GINTMSK_ENUMDONE_OFFSET                   13
+#define DWC2_GINTMSK_ISOOUTDROP                                (1 << 14)
+#define DWC2_GINTMSK_ISOOUTDROP_OFFSET                 14
+#define DWC2_GINTMSK_EOPFRAME                          (1 << 15)
+#define DWC2_GINTMSK_EOPFRAME_OFFSET                   15
+#define DWC2_GINTMSK_EPMISMATCH                                (1 << 17)
+#define DWC2_GINTMSK_EPMISMATCH_OFFSET                 17
+#define DWC2_GINTMSK_INEPINTR                          (1 << 18)
+#define DWC2_GINTMSK_INEPINTR_OFFSET                   18
+#define DWC2_GINTMSK_OUTEPINTR                         (1 << 19)
+#define DWC2_GINTMSK_OUTEPINTR_OFFSET                  19
+#define DWC2_GINTMSK_INCOMPLISOIN                      (1 << 20)
+#define DWC2_GINTMSK_INCOMPLISOIN_OFFSET               20
+#define DWC2_GINTMSK_INCOMPLISOOUT                     (1 << 21)
+#define DWC2_GINTMSK_INCOMPLISOOUT_OFFSET              21
+#define DWC2_GINTMSK_PORTINTR                          (1 << 24)
+#define DWC2_GINTMSK_PORTINTR_OFFSET                   24
+#define DWC2_GINTMSK_HCINTR                            (1 << 25)
+#define DWC2_GINTMSK_HCINTR_OFFSET                     25
+#define DWC2_GINTMSK_PTXFEMPTY                         (1 << 26)
+#define DWC2_GINTMSK_PTXFEMPTY_OFFSET                  26
+#define DWC2_GINTMSK_LPMTRANRCVD                       (1 << 27)
+#define DWC2_GINTMSK_LPMTRANRCVD_OFFSET                        27
+#define DWC2_GINTMSK_CONIDSTSCHNG                      (1 << 28)
+#define DWC2_GINTMSK_CONIDSTSCHNG_OFFSET               28
+#define DWC2_GINTMSK_DISCONNECT                                (1 << 29)
+#define DWC2_GINTMSK_DISCONNECT_OFFSET                 29
+#define DWC2_GINTMSK_SESSREQINTR                       (1 << 30)
+#define DWC2_GINTMSK_SESSREQINTR_OFFSET                        30
+#define DWC2_GINTMSK_WKUPINTR                          (1 << 31)
+#define DWC2_GINTMSK_WKUPINTR_OFFSET                   31
+#define DWC2_GINTSTS_CURMODE_DEVICE                    (0 << 0)
+#define DWC2_GINTSTS_CURMODE_HOST                      (1 << 0)
+#define DWC2_GINTSTS_CURMODE                           (1 << 0)
+#define DWC2_GINTSTS_CURMODE_OFFSET                    0
+#define DWC2_GINTSTS_MODEMISMATCH                      (1 << 1)
+#define DWC2_GINTSTS_MODEMISMATCH_OFFSET               1
+#define DWC2_GINTSTS_OTGINTR                           (1 << 2)
+#define DWC2_GINTSTS_OTGINTR_OFFSET                    2
+#define DWC2_GINTSTS_SOFINTR                           (1 << 3)
+#define DWC2_GINTSTS_SOFINTR_OFFSET                    3
+#define DWC2_GINTSTS_RXSTSQLVL                         (1 << 4)
+#define DWC2_GINTSTS_RXSTSQLVL_OFFSET                  4
+#define DWC2_GINTSTS_NPTXFEMPTY                                (1 << 5)
+#define DWC2_GINTSTS_NPTXFEMPTY_OFFSET                 5
+#define DWC2_GINTSTS_GINNAKEFF                         (1 << 6)
+#define DWC2_GINTSTS_GINNAKEFF_OFFSET                  6
+#define DWC2_GINTSTS_GOUTNAKEFF                                (1 << 7)
+#define DWC2_GINTSTS_GOUTNAKEFF_OFFSET                 7
+#define DWC2_GINTSTS_I2CINTR                           (1 << 9)
+#define DWC2_GINTSTS_I2CINTR_OFFSET                    9
+#define DWC2_GINTSTS_ERLYSUSPEND                       (1 << 10)
+#define DWC2_GINTSTS_ERLYSUSPEND_OFFSET                        10
+#define DWC2_GINTSTS_USBSUSPEND                                (1 << 11)
+#define DWC2_GINTSTS_USBSUSPEND_OFFSET                 11
+#define DWC2_GINTSTS_USBRESET                          (1 << 12)
+#define DWC2_GINTSTS_USBRESET_OFFSET                   12
+#define DWC2_GINTSTS_ENUMDONE                          (1 << 13)
+#define DWC2_GINTSTS_ENUMDONE_OFFSET                   13
+#define DWC2_GINTSTS_ISOOUTDROP                                (1 << 14)
+#define DWC2_GINTSTS_ISOOUTDROP_OFFSET                 14
+#define DWC2_GINTSTS_EOPFRAME                          (1 << 15)
+#define DWC2_GINTSTS_EOPFRAME_OFFSET                   15
+#define DWC2_GINTSTS_INTOKENRX                         (1 << 16)
+#define DWC2_GINTSTS_INTOKENRX_OFFSET                  16
+#define DWC2_GINTSTS_EPMISMATCH                                (1 << 17)
+#define DWC2_GINTSTS_EPMISMATCH_OFFSET                 17
+#define DWC2_GINTSTS_INEPINT                           (1 << 18)
+#define DWC2_GINTSTS_INEPINT_OFFSET                    18
+#define DWC2_GINTSTS_OUTEPINTR                         (1 << 19)
+#define DWC2_GINTSTS_OUTEPINTR_OFFSET                  19
+#define DWC2_GINTSTS_INCOMPLISOIN                      (1 << 20)
+#define DWC2_GINTSTS_INCOMPLISOIN_OFFSET               20
+#define DWC2_GINTSTS_INCOMPLISOOUT                     (1 << 21)
+#define DWC2_GINTSTS_INCOMPLISOOUT_OFFSET              21
+#define DWC2_GINTSTS_PORTINTR                          (1 << 24)
+#define DWC2_GINTSTS_PORTINTR_OFFSET                   24
+#define DWC2_GINTSTS_HCINTR                            (1 << 25)
+#define DWC2_GINTSTS_HCINTR_OFFSET                     25
+#define DWC2_GINTSTS_PTXFEMPTY                         (1 << 26)
+#define DWC2_GINTSTS_PTXFEMPTY_OFFSET                  26
+#define DWC2_GINTSTS_LPMTRANRCVD                       (1 << 27)
+#define DWC2_GINTSTS_LPMTRANRCVD_OFFSET                        27
+#define DWC2_GINTSTS_CONIDSTSCHNG                      (1 << 28)
+#define DWC2_GINTSTS_CONIDSTSCHNG_OFFSET               28
+#define DWC2_GINTSTS_DISCONNECT                                (1 << 29)
+#define DWC2_GINTSTS_DISCONNECT_OFFSET                 29
+#define DWC2_GINTSTS_SESSREQINTR                       (1 << 30)
+#define DWC2_GINTSTS_SESSREQINTR_OFFSET                        30
+#define DWC2_GINTSTS_WKUPINTR                          (1 << 31)
+#define DWC2_GINTSTS_WKUPINTR_OFFSET                   31
+#define DWC2_GRXSTS_EPNUM_MASK                         (0xF << 0)
+#define DWC2_GRXSTS_EPNUM_OFFSET                       0
+#define DWC2_GRXSTS_BCNT_MASK                          (0x7FF << 4)
+#define DWC2_GRXSTS_BCNT_OFFSET                                4
+#define DWC2_GRXSTS_DPID_MASK                          (0x3 << 15)
+#define DWC2_GRXSTS_DPID_OFFSET                                15
+#define DWC2_GRXSTS_PKTSTS_MASK                                (0xF << 17)
+#define DWC2_GRXSTS_PKTSTS_OFFSET                      17
+#define DWC2_GRXSTS_FN_MASK                            (0xF << 21)
+#define DWC2_GRXSTS_FN_OFFSET                          21
+#define DWC2_FIFOSIZE_STARTADDR_MASK                   (0xFFFF << 0)
+#define DWC2_FIFOSIZE_STARTADDR_OFFSET                 0
+#define DWC2_FIFOSIZE_DEPTH_MASK                       (0xFFFF << 16)
+#define DWC2_FIFOSIZE_DEPTH_OFFSET                     16
+#define DWC2_GNPTXSTS_NPTXFSPCAVAIL_MASK               (0xFFFF << 0)
+#define DWC2_GNPTXSTS_NPTXFSPCAVAIL_OFFSET             0
+#define DWC2_GNPTXSTS_NPTXQSPCAVAIL_MASK               (0xFF << 16)
+#define DWC2_GNPTXSTS_NPTXQSPCAVAIL_OFFSET             16
+#define DWC2_GNPTXSTS_NPTXQTOP_TERMINATE               (1 << 24)
+#define DWC2_GNPTXSTS_NPTXQTOP_TERMINATE_OFFSET                24
+#define DWC2_GNPTXSTS_NPTXQTOP_TOKEN_MASK              (0x3 << 25)
+#define DWC2_GNPTXSTS_NPTXQTOP_TOKEN_OFFSET            25
+#define DWC2_GNPTXSTS_NPTXQTOP_CHNEP_MASK              (0xF << 27)
+#define DWC2_GNPTXSTS_NPTXQTOP_CHNEP_OFFSET            27
+#define DWC2_DTXFSTS_TXFSPCAVAIL_MASK                  (0xFFFF << 0)
+#define DWC2_DTXFSTS_TXFSPCAVAIL_OFFSET                        0
+#define DWC2_GI2CCTL_RWDATA_MASK                       (0xFF << 0)
+#define DWC2_GI2CCTL_RWDATA_OFFSET                     0
+#define DWC2_GI2CCTL_REGADDR_MASK                      (0xFF << 8)
+#define DWC2_GI2CCTL_REGADDR_OFFSET                    8
+#define DWC2_GI2CCTL_ADDR_MASK                         (0x7F << 16)
+#define DWC2_GI2CCTL_ADDR_OFFSET                       16
+#define DWC2_GI2CCTL_I2CEN                             (1 << 23)
+#define DWC2_GI2CCTL_I2CEN_OFFSET                      23
+#define DWC2_GI2CCTL_ACK                               (1 << 24)
+#define DWC2_GI2CCTL_ACK_OFFSET                                24
+#define DWC2_GI2CCTL_I2CSUSPCTL                                (1 << 25)
+#define DWC2_GI2CCTL_I2CSUSPCTL_OFFSET                 25
+#define DWC2_GI2CCTL_I2CDEVADDR_MASK                   (0x3 << 26)
+#define DWC2_GI2CCTL_I2CDEVADDR_OFFSET                 26
+#define DWC2_GI2CCTL_RW                                        (1 << 30)
+#define DWC2_GI2CCTL_RW_OFFSET                         30
+#define DWC2_GI2CCTL_BSYDNE                            (1 << 31)
+#define DWC2_GI2CCTL_BSYDNE_OFFSET                     31
+#define DWC2_HWCFG1_EP_DIR0_MASK                       (0x3 << 0)
+#define DWC2_HWCFG1_EP_DIR0_OFFSET                     0
+#define DWC2_HWCFG1_EP_DIR1_MASK                       (0x3 << 2)
+#define DWC2_HWCFG1_EP_DIR1_OFFSET                     2
+#define DWC2_HWCFG1_EP_DIR2_MASK                       (0x3 << 4)
+#define DWC2_HWCFG1_EP_DIR2_OFFSET                     4
+#define DWC2_HWCFG1_EP_DIR3_MASK                       (0x3 << 6)
+#define DWC2_HWCFG1_EP_DIR3_OFFSET                     6
+#define DWC2_HWCFG1_EP_DIR4_MASK                       (0x3 << 8)
+#define DWC2_HWCFG1_EP_DIR4_OFFSET                     8
+#define DWC2_HWCFG1_EP_DIR5_MASK                       (0x3 << 10)
+#define DWC2_HWCFG1_EP_DIR5_OFFSET                     10
+#define DWC2_HWCFG1_EP_DIR6_MASK                       (0x3 << 12)
+#define DWC2_HWCFG1_EP_DIR6_OFFSET                     12
+#define DWC2_HWCFG1_EP_DIR7_MASK                       (0x3 << 14)
+#define DWC2_HWCFG1_EP_DIR7_OFFSET                     14
+#define DWC2_HWCFG1_EP_DIR8_MASK                       (0x3 << 16)
+#define DWC2_HWCFG1_EP_DIR8_OFFSET                     16
+#define DWC2_HWCFG1_EP_DIR9_MASK                       (0x3 << 18)
+#define DWC2_HWCFG1_EP_DIR9_OFFSET                     18
+#define DWC2_HWCFG1_EP_DIR10_MASK                      (0x3 << 20)
+#define DWC2_HWCFG1_EP_DIR10_OFFSET                    20
+#define DWC2_HWCFG1_EP_DIR11_MASK                      (0x3 << 22)
+#define DWC2_HWCFG1_EP_DIR11_OFFSET                    22
+#define DWC2_HWCFG1_EP_DIR12_MASK                      (0x3 << 24)
+#define DWC2_HWCFG1_EP_DIR12_OFFSET                    24
+#define DWC2_HWCFG1_EP_DIR13_MASK                      (0x3 << 26)
+#define DWC2_HWCFG1_EP_DIR13_OFFSET                    26
+#define DWC2_HWCFG1_EP_DIR14_MASK                      (0x3 << 28)
+#define DWC2_HWCFG1_EP_DIR14_OFFSET                    28
+#define DWC2_HWCFG1_EP_DIR15_MASK                      (0x3 << 30)
+#define DWC2_HWCFG1_EP_DIR15_OFFSET                    30
+#define DWC2_HWCFG2_OP_MODE_MASK                       (0x7 << 0)
+#define DWC2_HWCFG2_OP_MODE_OFFSET                     0
+#define DWC2_HWCFG2_ARCHITECTURE_SLAVE_ONLY            (0x0 << 3)
+#define DWC2_HWCFG2_ARCHITECTURE_EXT_DMA               (0x1 << 3)
+#define DWC2_HWCFG2_ARCHITECTURE_INT_DMA               (0x2 << 3)
+#define DWC2_HWCFG2_ARCHITECTURE_MASK                  (0x3 << 3)
+#define DWC2_HWCFG2_ARCHITECTURE_OFFSET                        3
+#define DWC2_HWCFG2_POINT2POINT                                (1 << 5)
+#define DWC2_HWCFG2_POINT2POINT_OFFSET                 5
+#define DWC2_HWCFG2_HS_PHY_TYPE_MASK                   (0x3 << 6)
+#define DWC2_HWCFG2_HS_PHY_TYPE_OFFSET                 6
+#define DWC2_HWCFG2_FS_PHY_TYPE_MASK                   (0x3 << 8)
+#define DWC2_HWCFG2_FS_PHY_TYPE_OFFSET                 8
+#define DWC2_HWCFG2_NUM_DEV_EP_MASK                    (0xF << 10)
+#define DWC2_HWCFG2_NUM_DEV_EP_OFFSET                  10
+#define DWC2_HWCFG2_NUM_HOST_CHAN_MASK                 (0xF << 14)
+#define DWC2_HWCFG2_NUM_HOST_CHAN_OFFSET               14
+#define DWC2_HWCFG2_PERIO_EP_SUPPORTED                 (1 << 18)
+#define DWC2_HWCFG2_PERIO_EP_SUPPORTED_OFFSET          18
+#define DWC2_HWCFG2_DYNAMIC_FIFO                       (1 << 19)
+#define DWC2_HWCFG2_DYNAMIC_FIFO_OFFSET                        19
+#define DWC2_HWCFG2_MULTI_PROC_INT                     (1 << 20)
+#define DWC2_HWCFG2_MULTI_PROC_INT_OFFSET              20
+#define DWC2_HWCFG2_NONPERIO_TX_Q_DEPTH_MASK           (0x3 << 22)
+#define DWC2_HWCFG2_NONPERIO_TX_Q_DEPTH_OFFSET         22
+#define DWC2_HWCFG2_HOST_PERIO_TX_Q_DEPTH_MASK         (0x3 << 24)
+#define DWC2_HWCFG2_HOST_PERIO_TX_Q_DEPTH_OFFSET       24
+#define DWC2_HWCFG2_DEV_TOKEN_Q_DEPTH_MASK             (0x1F << 26)
+#define DWC2_HWCFG2_DEV_TOKEN_Q_DEPTH_OFFSET           26
+#define DWC2_HWCFG3_XFER_SIZE_CNTR_WIDTH_MASK          (0xF << 0)
+#define DWC2_HWCFG3_XFER_SIZE_CNTR_WIDTH_OFFSET                0
+#define DWC2_HWCFG3_PACKET_SIZE_CNTR_WIDTH_MASK                (0x7 << 4)
+#define DWC2_HWCFG3_PACKET_SIZE_CNTR_WIDTH_OFFSET      4
+#define DWC2_HWCFG3_OTG_FUNC                           (1 << 7)
+#define DWC2_HWCFG3_OTG_FUNC_OFFSET                    7
+#define DWC2_HWCFG3_I2C                                        (1 << 8)
+#define DWC2_HWCFG3_I2C_OFFSET                         8
+#define DWC2_HWCFG3_VENDOR_CTRL_IF                     (1 << 9)
+#define DWC2_HWCFG3_VENDOR_CTRL_IF_OFFSET              9
+#define DWC2_HWCFG3_OPTIONAL_FEATURES                  (1 << 10)
+#define DWC2_HWCFG3_OPTIONAL_FEATURES_OFFSET           10
+#define DWC2_HWCFG3_SYNCH_RESET_TYPE                   (1 << 11)
+#define DWC2_HWCFG3_SYNCH_RESET_TYPE_OFFSET            11
+#define DWC2_HWCFG3_OTG_ENABLE_IC_USB                  (1 << 12)
+#define DWC2_HWCFG3_OTG_ENABLE_IC_USB_OFFSET           12
+#define DWC2_HWCFG3_OTG_ENABLE_HSIC                    (1 << 13)
+#define DWC2_HWCFG3_OTG_ENABLE_HSIC_OFFSET             13
+#define DWC2_HWCFG3_OTG_LPM_EN                         (1 << 15)
+#define DWC2_HWCFG3_OTG_LPM_EN_OFFSET                  15
+#define DWC2_HWCFG3_DFIFO_DEPTH_MASK                   (0xFFFF << 16)
+#define DWC2_HWCFG3_DFIFO_DEPTH_OFFSET                 16
+#define DWC2_HWCFG4_NUM_DEV_PERIO_IN_EP_MASK           (0xF << 0)
+#define DWC2_HWCFG4_NUM_DEV_PERIO_IN_EP_OFFSET         0
+#define DWC2_HWCFG4_POWER_OPTIMIZ                      (1 << 4)
+#define DWC2_HWCFG4_POWER_OPTIMIZ_OFFSET               4
+#define DWC2_HWCFG4_MIN_AHB_FREQ_MASK                  (0x1FF << 5)
+#define DWC2_HWCFG4_MIN_AHB_FREQ_OFFSET                        5
+#define DWC2_HWCFG4_UTMI_PHY_DATA_WIDTH_MASK           (0x3 << 14)
+#define DWC2_HWCFG4_UTMI_PHY_DATA_WIDTH_OFFSET         14
+#define DWC2_HWCFG4_NUM_DEV_MODE_CTRL_EP_MASK          (0xF << 16)
+#define DWC2_HWCFG4_NUM_DEV_MODE_CTRL_EP_OFFSET                16
+#define DWC2_HWCFG4_IDDIG_FILT_EN                      (1 << 20)
+#define DWC2_HWCFG4_IDDIG_FILT_EN_OFFSET               20
+#define DWC2_HWCFG4_VBUS_VALID_FILT_EN                 (1 << 21)
+#define DWC2_HWCFG4_VBUS_VALID_FILT_EN_OFFSET          21
+#define DWC2_HWCFG4_A_VALID_FILT_EN                    (1 << 22)
+#define DWC2_HWCFG4_A_VALID_FILT_EN_OFFSET             22
+#define DWC2_HWCFG4_B_VALID_FILT_EN                    (1 << 23)
+#define DWC2_HWCFG4_B_VALID_FILT_EN_OFFSET             23
+#define DWC2_HWCFG4_SESSION_END_FILT_EN                        (1 << 24)
+#define DWC2_HWCFG4_SESSION_END_FILT_EN_OFFSET         24
+#define DWC2_HWCFG4_DED_FIFO_EN                                (1 << 25)
+#define DWC2_HWCFG4_DED_FIFO_EN_OFFSET                 25
+#define DWC2_HWCFG4_NUM_IN_EPS_MASK                    (0xF << 26)
+#define DWC2_HWCFG4_NUM_IN_EPS_OFFSET                  26
+#define DWC2_HWCFG4_DESC_DMA                           (1 << 30)
+#define DWC2_HWCFG4_DESC_DMA_OFFSET                    30
+#define DWC2_HWCFG4_DESC_DMA_DYN                       (1 << 31)
+#define DWC2_HWCFG4_DESC_DMA_DYN_OFFSET                        31
+#define DWC2_HCFG_FSLSPCLKSEL_30_60_MHZ                        0
+#define DWC2_HCFG_FSLSPCLKSEL_48_MHZ                   1
+#define DWC2_HCFG_FSLSPCLKSEL_6_MHZ                    2
+#define DWC2_HCFG_FSLSPCLKSEL_MASK                     (0x3 << 0)
+#define DWC2_HCFG_FSLSPCLKSEL_OFFSET                   0
+#define DWC2_HCFG_FSLSSUPP                             (1 << 2)
+#define DWC2_HCFG_FSLSSUPP_OFFSET                      2
+#define DWC2_HCFG_DESCDMA                              (1 << 23)
+#define DWC2_HCFG_DESCDMA_OFFSET                       23
+#define DWC2_HCFG_FRLISTEN_MASK                                (0x3 << 24)
+#define DWC2_HCFG_FRLISTEN_OFFSET                      24
+#define DWC2_HCFG_PERSCHEDENA                          (1 << 26)
+#define DWC2_HCFG_PERSCHEDENA_OFFSET                   26
+#define DWC2_HCFG_PERSCHEDSTAT                         (1 << 27)
+#define DWC2_HCFG_PERSCHEDSTAT_OFFSET                  27
+#define DWC2_HFIR_FRINT_MASK                           (0xFFFF << 0)
+#define DWC2_HFIR_FRINT_OFFSET                         0
+#define DWC2_HFNUM_FRNUM_MASK                          (0xFFFF << 0)
+#define DWC2_HFNUM_FRNUM_OFFSET                                0
+#define DWC2_HFNUM_FRREM_MASK                          (0xFFFF << 16)
+#define DWC2_HFNUM_FRREM_OFFSET                                16
+#define DWC2_HPTXSTS_PTXFSPCAVAIL_MASK                 (0xFFFF << 0)
+#define DWC2_HPTXSTS_PTXFSPCAVAIL_OFFSET               0
+#define DWC2_HPTXSTS_PTXQSPCAVAIL_MASK                 (0xFF << 16)
+#define DWC2_HPTXSTS_PTXQSPCAVAIL_OFFSET               16
+#define DWC2_HPTXSTS_PTXQTOP_TERMINATE                 (1 << 24)
+#define DWC2_HPTXSTS_PTXQTOP_TERMINATE_OFFSET          24
+#define DWC2_HPTXSTS_PTXQTOP_TOKEN_MASK                        (0x3 << 25)
+#define DWC2_HPTXSTS_PTXQTOP_TOKEN_OFFSET              25
+#define DWC2_HPTXSTS_PTXQTOP_CHNUM_MASK                        (0xF << 27)
+#define DWC2_HPTXSTS_PTXQTOP_CHNUM_OFFSET              27
+#define DWC2_HPTXSTS_PTXQTOP_ODD                       (1 << 31)
+#define DWC2_HPTXSTS_PTXQTOP_ODD_OFFSET                        31
+#define DWC2_HPRT0_PRTCONNSTS                          (1 << 0)
+#define DWC2_HPRT0_PRTCONNSTS_OFFSET                   0
+#define DWC2_HPRT0_PRTCONNDET                          (1 << 1)
+#define DWC2_HPRT0_PRTCONNDET_OFFSET                   1
+#define DWC2_HPRT0_PRTENA                              (1 << 2)
+#define DWC2_HPRT0_PRTENA_OFFSET                       2
+#define DWC2_HPRT0_PRTENCHNG                           (1 << 3)
+#define DWC2_HPRT0_PRTENCHNG_OFFSET                    3
+#define DWC2_HPRT0_PRTOVRCURRACT                       (1 << 4)
+#define DWC2_HPRT0_PRTOVRCURRACT_OFFSET                        4
+#define DWC2_HPRT0_PRTOVRCURRCHNG                      (1 << 5)
+#define DWC2_HPRT0_PRTOVRCURRCHNG_OFFSET               5
+#define DWC2_HPRT0_PRTRES                              (1 << 6)
+#define DWC2_HPRT0_PRTRES_OFFSET                       6
+#define DWC2_HPRT0_PRTSUSP                             (1 << 7)
+#define DWC2_HPRT0_PRTSUSP_OFFSET                      7
+#define DWC2_HPRT0_PRTRST                              (1 << 8)
+#define DWC2_HPRT0_PRTRST_OFFSET                       8
+#define DWC2_HPRT0_PRTLNSTS_MASK                       (0x3 << 10)
+#define DWC2_HPRT0_PRTLNSTS_OFFSET                     10
+#define DWC2_HPRT0_PRTPWR                              (1 << 12)
+#define DWC2_HPRT0_PRTPWR_OFFSET                       12
+#define DWC2_HPRT0_PRTTSTCTL_MASK                      (0xF << 13)
+#define DWC2_HPRT0_PRTTSTCTL_OFFSET                    13
+#define DWC2_HPRT0_PRTSPD_MASK                         (0x3 << 17)
+#define DWC2_HPRT0_PRTSPD_OFFSET                       17
+#define DWC2_HAINT_CH0                                 (1 << 0)
+#define DWC2_HAINT_CH0_OFFSET                          0
+#define DWC2_HAINT_CH1                                 (1 << 1)
+#define DWC2_HAINT_CH1_OFFSET                          1
+#define DWC2_HAINT_CH2                                 (1 << 2)
+#define DWC2_HAINT_CH2_OFFSET                          2
+#define DWC2_HAINT_CH3                                 (1 << 3)
+#define DWC2_HAINT_CH3_OFFSET                          3
+#define DWC2_HAINT_CH4                                 (1 << 4)
+#define DWC2_HAINT_CH4_OFFSET                          4
+#define DWC2_HAINT_CH5                                 (1 << 5)
+#define DWC2_HAINT_CH5_OFFSET                          5
+#define DWC2_HAINT_CH6                                 (1 << 6)
+#define DWC2_HAINT_CH6_OFFSET                          6
+#define DWC2_HAINT_CH7                                 (1 << 7)
+#define DWC2_HAINT_CH7_OFFSET                          7
+#define DWC2_HAINT_CH8                                 (1 << 8)
+#define DWC2_HAINT_CH8_OFFSET                          8
+#define DWC2_HAINT_CH9                                 (1 << 9)
+#define DWC2_HAINT_CH9_OFFSET                          9
+#define DWC2_HAINT_CH10                                        (1 << 10)
+#define DWC2_HAINT_CH10_OFFSET                         10
+#define DWC2_HAINT_CH11                                        (1 << 11)
+#define DWC2_HAINT_CH11_OFFSET                         11
+#define DWC2_HAINT_CH12                                        (1 << 12)
+#define DWC2_HAINT_CH12_OFFSET                         12
+#define DWC2_HAINT_CH13                                        (1 << 13)
+#define DWC2_HAINT_CH13_OFFSET                         13
+#define DWC2_HAINT_CH14                                        (1 << 14)
+#define DWC2_HAINT_CH14_OFFSET                         14
+#define DWC2_HAINT_CH15                                        (1 << 15)
+#define DWC2_HAINT_CH15_OFFSET                         15
+#define DWC2_HAINT_CHINT_MASK                          0xffff
+#define DWC2_HAINT_CHINT_OFFSET                                0
+#define DWC2_HAINTMSK_CH0                              (1 << 0)
+#define DWC2_HAINTMSK_CH0_OFFSET                       0
+#define DWC2_HAINTMSK_CH1                              (1 << 1)
+#define DWC2_HAINTMSK_CH1_OFFSET                       1
+#define DWC2_HAINTMSK_CH2                              (1 << 2)
+#define DWC2_HAINTMSK_CH2_OFFSET                       2
+#define DWC2_HAINTMSK_CH3                              (1 << 3)
+#define DWC2_HAINTMSK_CH3_OFFSET                       3
+#define DWC2_HAINTMSK_CH4                              (1 << 4)
+#define DWC2_HAINTMSK_CH4_OFFSET                       4
+#define DWC2_HAINTMSK_CH5                              (1 << 5)
+#define DWC2_HAINTMSK_CH5_OFFSET                       5
+#define DWC2_HAINTMSK_CH6                              (1 << 6)
+#define DWC2_HAINTMSK_CH6_OFFSET                       6
+#define DWC2_HAINTMSK_CH7                              (1 << 7)
+#define DWC2_HAINTMSK_CH7_OFFSET                       7
+#define DWC2_HAINTMSK_CH8                              (1 << 8)
+#define DWC2_HAINTMSK_CH8_OFFSET                       8
+#define DWC2_HAINTMSK_CH9                              (1 << 9)
+#define DWC2_HAINTMSK_CH9_OFFSET                       9
+#define DWC2_HAINTMSK_CH10                             (1 << 10)
+#define DWC2_HAINTMSK_CH10_OFFSET                      10
+#define DWC2_HAINTMSK_CH11                             (1 << 11)
+#define DWC2_HAINTMSK_CH11_OFFSET                      11
+#define DWC2_HAINTMSK_CH12                             (1 << 12)
+#define DWC2_HAINTMSK_CH12_OFFSET                      12
+#define DWC2_HAINTMSK_CH13                             (1 << 13)
+#define DWC2_HAINTMSK_CH13_OFFSET                      13
+#define DWC2_HAINTMSK_CH14                             (1 << 14)
+#define DWC2_HAINTMSK_CH14_OFFSET                      14
+#define DWC2_HAINTMSK_CH15                             (1 << 15)
+#define DWC2_HAINTMSK_CH15_OFFSET                      15
+#define DWC2_HAINTMSK_CHINT_MASK                       0xffff
+#define DWC2_HAINTMSK_CHINT_OFFSET                     0
+#define DWC2_HCCHAR_MPS_MASK                           (0x7FF << 0)
+#define DWC2_HCCHAR_MPS_OFFSET                         0
+#define DWC2_HCCHAR_EPNUM_MASK                         (0xF << 11)
+#define DWC2_HCCHAR_EPNUM_OFFSET                       11
+#define DWC2_HCCHAR_EPDIR                              (1 << 15)
+#define DWC2_HCCHAR_EPDIR_OFFSET                       15
+#define DWC2_HCCHAR_LSPDDEV                            (1 << 17)
+#define DWC2_HCCHAR_LSPDDEV_OFFSET                     17
+#define DWC2_HCCHAR_EPTYPE_CONTROL                     0
+#define DWC2_HCCHAR_EPTYPE_ISOC                                1
+#define DWC2_HCCHAR_EPTYPE_BULK                                2
+#define DWC2_HCCHAR_EPTYPE_INTR                                3
+#define DWC2_HCCHAR_EPTYPE_MASK                                (0x3 << 18)
+#define DWC2_HCCHAR_EPTYPE_OFFSET                      18
+#define DWC2_HCCHAR_MULTICNT_MASK                      (0x3 << 20)
+#define DWC2_HCCHAR_MULTICNT_OFFSET                    20
+#define DWC2_HCCHAR_DEVADDR_MASK                       (0x7F << 22)
+#define DWC2_HCCHAR_DEVADDR_OFFSET                     22
+#define DWC2_HCCHAR_ODDFRM                             (1 << 29)
+#define DWC2_HCCHAR_ODDFRM_OFFSET                      29
+#define DWC2_HCCHAR_CHDIS                              (1 << 30)
+#define DWC2_HCCHAR_CHDIS_OFFSET                       30
+#define DWC2_HCCHAR_CHEN                               (1 << 31)
+#define DWC2_HCCHAR_CHEN_OFFSET                                31
+#define DWC2_HCSPLT_PRTADDR_MASK                       (0x7F << 0)
+#define DWC2_HCSPLT_PRTADDR_OFFSET                     0
+#define DWC2_HCSPLT_HUBADDR_MASK                       (0x7F << 7)
+#define DWC2_HCSPLT_HUBADDR_OFFSET                     7
+#define DWC2_HCSPLT_XACTPOS_MASK                       (0x3 << 14)
+#define DWC2_HCSPLT_XACTPOS_OFFSET                     14
+#define DWC2_HCSPLT_COMPSPLT                           (1 << 16)
+#define DWC2_HCSPLT_COMPSPLT_OFFSET                    16
+#define DWC2_HCSPLT_SPLTENA                            (1 << 31)
+#define DWC2_HCSPLT_SPLTENA_OFFSET                     31
+#define DWC2_HCINT_XFERCOMP                            (1 << 0)
+#define DWC2_HCINT_XFERCOMP_OFFSET                     0
+#define DWC2_HCINT_CHHLTD                              (1 << 1)
+#define DWC2_HCINT_CHHLTD_OFFSET                       1
+#define DWC2_HCINT_AHBERR                              (1 << 2)
+#define DWC2_HCINT_AHBERR_OFFSET                       2
+#define DWC2_HCINT_STALL                               (1 << 3)
+#define DWC2_HCINT_STALL_OFFSET                                3
+#define DWC2_HCINT_NAK                                 (1 << 4)
+#define DWC2_HCINT_NAK_OFFSET                          4
+#define DWC2_HCINT_ACK                                 (1 << 5)
+#define DWC2_HCINT_ACK_OFFSET                          5
+#define DWC2_HCINT_NYET                                        (1 << 6)
+#define DWC2_HCINT_NYET_OFFSET                         6
+#define DWC2_HCINT_XACTERR                             (1 << 7)
+#define DWC2_HCINT_XACTERR_OFFSET                      7
+#define DWC2_HCINT_BBLERR                              (1 << 8)
+#define DWC2_HCINT_BBLERR_OFFSET                       8
+#define DWC2_HCINT_FRMOVRUN                            (1 << 9)
+#define DWC2_HCINT_FRMOVRUN_OFFSET                     9
+#define DWC2_HCINT_DATATGLERR                          (1 << 10)
+#define DWC2_HCINT_DATATGLERR_OFFSET                   10
+#define DWC2_HCINT_BNA                                 (1 << 11)
+#define DWC2_HCINT_BNA_OFFSET                          11
+#define DWC2_HCINT_XCS_XACT                            (1 << 12)
+#define DWC2_HCINT_XCS_XACT_OFFSET                     12
+#define DWC2_HCINT_FRM_LIST_ROLL                       (1 << 13)
+#define DWC2_HCINT_FRM_LIST_ROLL_OFFSET                        13
+#define DWC2_HCINTMSK_XFERCOMPL                                (1 << 0)
+#define DWC2_HCINTMSK_XFERCOMPL_OFFSET                 0
+#define DWC2_HCINTMSK_CHHLTD                           (1 << 1)
+#define DWC2_HCINTMSK_CHHLTD_OFFSET                    1
+#define DWC2_HCINTMSK_AHBERR                           (1 << 2)
+#define DWC2_HCINTMSK_AHBERR_OFFSET                    2
+#define DWC2_HCINTMSK_STALL                            (1 << 3)
+#define DWC2_HCINTMSK_STALL_OFFSET                     3
+#define DWC2_HCINTMSK_NAK                              (1 << 4)
+#define DWC2_HCINTMSK_NAK_OFFSET                       4
+#define DWC2_HCINTMSK_ACK                              (1 << 5)
+#define DWC2_HCINTMSK_ACK_OFFSET                       5
+#define DWC2_HCINTMSK_NYET                             (1 << 6)
+#define DWC2_HCINTMSK_NYET_OFFSET                      6
+#define DWC2_HCINTMSK_XACTERR                          (1 << 7)
+#define DWC2_HCINTMSK_XACTERR_OFFSET                   7
+#define DWC2_HCINTMSK_BBLERR                           (1 << 8)
+#define DWC2_HCINTMSK_BBLERR_OFFSET                    8
+#define DWC2_HCINTMSK_FRMOVRUN                         (1 << 9)
+#define DWC2_HCINTMSK_FRMOVRUN_OFFSET                  9
+#define DWC2_HCINTMSK_DATATGLERR                       (1 << 10)
+#define DWC2_HCINTMSK_DATATGLERR_OFFSET                        10
+#define DWC2_HCINTMSK_BNA                              (1 << 11)
+#define DWC2_HCINTMSK_BNA_OFFSET                       11
+#define DWC2_HCINTMSK_XCS_XACT                         (1 << 12)
+#define DWC2_HCINTMSK_XCS_XACT_OFFSET                  12
+#define DWC2_HCINTMSK_FRM_LIST_ROLL                    (1 << 13)
+#define DWC2_HCINTMSK_FRM_LIST_ROLL_OFFSET             13
+#define DWC2_HCTSIZ_XFERSIZE_MASK                      0x7ffff
+#define DWC2_HCTSIZ_XFERSIZE_OFFSET                    0
+#define DWC2_HCTSIZ_SCHINFO_MASK                       0xff
+#define DWC2_HCTSIZ_SCHINFO_OFFSET                     0
+#define DWC2_HCTSIZ_NTD_MASK                           (0xff << 8)
+#define DWC2_HCTSIZ_NTD_OFFSET                         8
+#define DWC2_HCTSIZ_PKTCNT_MASK                                (0x3ff << 19)
+#define DWC2_HCTSIZ_PKTCNT_OFFSET                      19
+#define DWC2_HCTSIZ_PID_MASK                           (0x3 << 29)
+#define DWC2_HCTSIZ_PID_OFFSET                         29
+#define DWC2_HCTSIZ_DOPNG                              (1 << 31)
+#define DWC2_HCTSIZ_DOPNG_OFFSET                       31
+#define DWC2_HCDMA_CTD_MASK                            (0xFF << 3)
+#define DWC2_HCDMA_CTD_OFFSET                          3
+#define DWC2_HCDMA_DMA_ADDR_MASK                       (0x1FFFFF << 11)
+#define DWC2_HCDMA_DMA_ADDR_OFFSET                     11
+#define DWC2_PCGCCTL_STOPPCLK                          (1 << 0)
+#define DWC2_PCGCCTL_STOPPCLK_OFFSET                   0
+#define DWC2_PCGCCTL_GATEHCLK                          (1 << 1)
+#define DWC2_PCGCCTL_GATEHCLK_OFFSET                   1
+#define DWC2_PCGCCTL_PWRCLMP                           (1 << 2)
+#define DWC2_PCGCCTL_PWRCLMP_OFFSET                    2
+#define DWC2_PCGCCTL_RSTPDWNMODULE                     (1 << 3)
+#define DWC2_PCGCCTL_RSTPDWNMODULE_OFFSET              3
+#define DWC2_PCGCCTL_PHYSUSPENDED                      (1 << 4)
+#define DWC2_PCGCCTL_PHYSUSPENDED_OFFSET               4
+#define DWC2_PCGCCTL_ENBL_SLEEP_GATING                 (1 << 5)
+#define DWC2_PCGCCTL_ENBL_SLEEP_GATING_OFFSET          5
+#define DWC2_PCGCCTL_PHY_IN_SLEEP                      (1 << 6)
+#define DWC2_PCGCCTL_PHY_IN_SLEEP_OFFSET               6
+#define DWC2_PCGCCTL_DEEP_SLEEP                                (1 << 7)
+#define DWC2_PCGCCTL_DEEP_SLEEP_OFFSET                 7
+#define DWC2_SNPSID_DEVID_VER_2xx                      (0x4f542 << 12)
+#define DWC2_SNPSID_DEVID_MASK                         (0xfffff << 12)
+#define DWC2_SNPSID_DEVID_OFFSET                       12
+
+/* Host controller specific */
+#define DWC2_HC_PID_DATA0              0
+#define DWC2_HC_PID_DATA2              1
+#define DWC2_HC_PID_DATA1              2
+#define DWC2_HC_PID_MDATA              3
+#define DWC2_HC_PID_SETUP              3
+
+/* 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 */
+
+/* roothub.b masks */
+#define RH_B_DR                0x0000ffff      /* device removable flags */
+#define RH_B_PPCM      0xffff0000      /* port power control mask */
+
+/* Default driver configuration */
+#define CONFIG_DWC2_DMA_ENABLE
+#define CONFIG_DWC2_DMA_BURST_SIZE             32      /* DMA burst len */
+#undef CONFIG_DWC2_DFLT_SPEED_FULL             /* Do not force DWC2 to FS */
+#define CONFIG_DWC2_ENABLE_DYNAMIC_FIFO                /* Runtime FIFO size detect */
+#define CONFIG_DWC2_MAX_CHANNELS               16      /* Max # of EPs */
+#define CONFIG_DWC2_HOST_RX_FIFO_SIZE          (516 + CONFIG_DWC2_MAX_CHANNELS)
+#define CONFIG_DWC2_HOST_NPERIO_TX_FIFO_SIZE   0x100   /* nPeriodic TX FIFO */
+#define CONFIG_DWC2_HOST_PERIO_TX_FIFO_SIZE    0x200   /* Periodic TX FIFO */
+#define CONFIG_DWC2_MAX_TRANSFER_SIZE          65535
+#define CONFIG_DWC2_MAX_PACKET_COUNT           511
+
+#define DWC2_PHY_TYPE_FS               0
+#define DWC2_PHY_TYPE_UTMI             1
+#define DWC2_PHY_TYPE_ULPI             2
+#define CONFIG_DWC2_PHY_TYPE           DWC2_PHY_TYPE_UTMI      /* PHY type */
+#define CONFIG_DWC2_UTMI_WIDTH         8       /* UTMI bus width (8/16) */
+
+#undef CONFIG_DWC2_PHY_ULPI_DDR                        /* ULPI PHY uses DDR mode */
+#define CONFIG_DWC2_PHY_ULPI_EXT_VBUS          /* ULPI PHY controls VBUS */
+#undef CONFIG_DWC2_I2C_ENABLE                  /* Enable I2C */
+#undef CONFIG_DWC2_ULPI_FS_LS                  /* ULPI is FS/LS */
+#undef CONFIG_DWC2_TS_DLINE                    /* External DLine pulsing */
+#undef CONFIG_DWC2_THR_CTL                     /* Threshold control */
+#define CONFIG_DWC2_TX_THR_LENGTH              64
+#undef CONFIG_DWC2_IC_USB_CAP                  /* IC Cap */
+
+#endif /* __DWC2_H__ */
index 6323c508375af8ce3b98009a85bfbc2f5e8a5564..936d006ba414ca2bfea76ac5ab0b0d5dccc944ab 100644 (file)
@@ -119,15 +119,12 @@ static struct descriptor {
 #define ehci_is_TDI()  (0)
 #endif
 
-int __ehci_get_port_speed(struct ehci_hcor *hcor, uint32_t reg)
+__weak int ehci_get_port_speed(struct ehci_hcor *hcor, uint32_t reg)
 {
        return PORTSC_PSPD(reg);
 }
 
-int ehci_get_port_speed(struct ehci_hcor *hcor, uint32_t reg)
-       __attribute__((weak, alias("__ehci_get_port_speed")));
-
-void __ehci_set_usbmode(int index)
+__weak void ehci_set_usbmode(int index)
 {
        uint32_t tmp;
        uint32_t *reg_ptr;
@@ -141,17 +138,11 @@ void __ehci_set_usbmode(int index)
        ehci_writel(reg_ptr, tmp);
 }
 
-void ehci_set_usbmode(int index)
-       __attribute__((weak, alias("__ehci_set_usbmode")));
-
-void __ehci_powerup_fixup(uint32_t *status_reg, uint32_t *reg)
+__weak void ehci_powerup_fixup(uint32_t *status_reg, uint32_t *reg)
 {
        mdelay(50);
 }
 
-void ehci_powerup_fixup(uint32_t *status_reg, uint32_t *reg)
-       __attribute__((weak, alias("__ehci_powerup_fixup")));
-
 static int handshake(uint32_t *ptr, uint32_t mask, uint32_t done, int usec)
 {
        uint32_t result;
@@ -1323,7 +1314,7 @@ void *poll_int_queue(struct usb_device *dev, struct int_queue *queue)
 }
 
 /* Do not free buffers associated with QHs, they're owned by someone else */
-int
+static int
 destroy_int_queue(struct usb_device *dev, struct int_queue *queue)
 {
        struct ehci_ctrl *ctrl = dev->controller;
index 52c43fdc5aaa1fdc2a99ed3177c65c35b3a2c979..1a5fd6eefc296bfee80552530cbb7237dffd3792 100644 (file)
@@ -13,7 +13,7 @@
 #include <asm/arch/cpu.h>
 
 #if defined(CONFIG_KIRKWOOD)
-#include <asm/arch/kirkwood.h>
+#include <asm/arch/soc.h>
 #elif defined(CONFIG_ORION5X)
 #include <asm/arch/orion5x.h>
 #endif
index 923192787996f70942b766c1c9086f787ee04e3a..6aa50cb4f966c70d3495ea5588db8b42bb40bcd7 100644 (file)
@@ -944,7 +944,7 @@ static void parse_putc(const char c)
                CURSOR_SET;
 }
 
-void video_putc(struct stdio_dev *dev, const char c)
+static void video_putc(struct stdio_dev *dev, const char c)
 {
 #ifdef CONFIG_CFB_CONSOLE_ANSI
        int i;
@@ -1158,7 +1158,7 @@ void video_putc(struct stdio_dev *dev, const char c)
                flush_cache(VIDEO_FB_ADRS, VIDEO_SIZE);
 }
 
-void video_puts(struct stdio_dev *dev, const char *s)
+static void video_puts(struct stdio_dev *dev, const char *s)
 {
        int count = strlen(s);
 
@@ -1171,14 +1171,11 @@ void video_puts(struct stdio_dev *dev, const char *s)
  * video_set_lut() if they do not support 8 bpp format.
  * Implement weak default function instead.
  */
-void __video_set_lut(unsigned int index, unsigned char r,
+__weak void video_set_lut(unsigned int index, unsigned char r,
                     unsigned char g, unsigned char b)
 {
 }
 
-void video_set_lut(unsigned int, unsigned char, unsigned char, unsigned char)
-       __attribute__ ((weak, alias("__video_set_lut")));
-
 #if defined(CONFIG_CMD_BMP) || defined(CONFIG_SPLASH_SCREEN)
 
 #define FILL_8BIT_332RGB(r,g,b)        {                       \
@@ -2240,15 +2237,12 @@ static int video_init(void)
  * Implement a weak default function for boards that optionally
  * need to skip the video initialization.
  */
-int __board_video_skip(void)
+__weak int board_video_skip(void)
 {
        /* As default, don't skip test */
        return 0;
 }
 
-int board_video_skip(void)
-       __attribute__ ((weak, alias("__board_video_skip")));
-
 int drv_video_init(void)
 {
        int skip_dev_init;
index 180a3b41499dba25c9815adb57345678772482fa..be35b982acd12f6019281248145a06124a483720 100644 (file)
@@ -58,54 +58,38 @@ static void exynos_lcd_init(vidinfo_t *vid)
        lcd_set_flush_dcache(1);
 }
 
-void __exynos_cfg_lcd_gpio(void)
+__weak void exynos_cfg_lcd_gpio(void)
 {
 }
-void exynos_cfg_lcd_gpio(void)
-       __attribute__((weak, alias("__exynos_cfg_lcd_gpio")));
 
-void __exynos_backlight_on(unsigned int onoff)
+__weak void exynos_backlight_on(unsigned int onoff)
 {
 }
-void exynos_backlight_on(unsigned int onoff)
-       __attribute__((weak, alias("__exynos_cfg_lcd_gpio")));
 
-void __exynos_reset_lcd(void)
+__weak void exynos_reset_lcd(void)
 {
 }
-void exynos_reset_lcd(void)
-       __attribute__((weak, alias("__exynos_reset_lcd")));
 
-void __exynos_lcd_power_on(void)
+__weak void exynos_lcd_power_on(void)
 {
 }
-void exynos_lcd_power_on(void)
-       __attribute__((weak, alias("__exynos_lcd_power_on")));
 
-void __exynos_cfg_ldo(void)
+__weak void exynos_cfg_ldo(void)
 {
 }
-void exynos_cfg_ldo(void)
-       __attribute__((weak, alias("__exynos_cfg_ldo")));
 
-void __exynos_enable_ldo(unsigned int onoff)
+__weak void exynos_enable_ldo(unsigned int onoff)
 {
 }
-void exynos_enable_ldo(unsigned int onoff)
-       __attribute__((weak, alias("__exynos_enable_ldo")));
 
-void __exynos_backlight_reset(void)
+__weak void exynos_backlight_reset(void)
 {
 }
-void exynos_backlight_reset(void)
-       __attribute__((weak, alias("__exynos_backlight_reset")));
 
-int __exynos_lcd_misc_init(vidinfo_t *vid)
+__weak int exynos_lcd_misc_init(vidinfo_t *vid)
 {
        return 0;
 }
-int exynos_lcd_misc_init(vidinfo_t *vid)
-       __attribute__((weak, alias("__exynos_lcd_misc_init")));
 
 static void lcd_panel_on(vidinfo_t *vid)
 {
index 8d4e9254784d8d89050f3b20bbf6ac75486fe66e..5873531953316a25799c020206328bd84280b97d 100644 (file)
@@ -379,7 +379,7 @@ static struct clk pixel_clk[] = {
 /*
  * This function resets IPU
  */
-void ipu_reset(void)
+static void ipu_reset(void)
 {
        u32 *reg;
        u32 value;
index 48fee992a180029b4adbe30e53b9f39491acde79..4faeafb6351d4d3e75376e704b479ebad4a3c6b3 100644 (file)
@@ -377,7 +377,7 @@ static struct dp_csc_param_t dp_csc_array[CSC_NUM][CSC_NUM] = {
 static enum csc_type_t fg_csc_type = CSC_NONE, bg_csc_type = CSC_NONE;
 static int color_key_4rgb = 1;
 
-void ipu_dp_csc_setup(int dp, struct dp_csc_param_t dp_csc_param,
+static void ipu_dp_csc_setup(int dp, struct dp_csc_param_t dp_csc_param,
                        unsigned char srm_mode_update)
 {
        u32 reg;
@@ -605,17 +605,6 @@ void ipu_dc_uninit(int dc_chan)
        }
 }
 
-int ipu_chan_is_interlaced(ipu_channel_t channel)
-{
-       if (channel == MEM_DC_SYNC)
-               return !!(__raw_readl(DC_WR_CH_CONF_1) &
-                         DC_WR_CH_CONF_FIELD_MODE);
-       else if ((channel == MEM_BG_SYNC) || (channel == MEM_FG_SYNC))
-               return !!(__raw_readl(DC_WR_CH_CONF_5) &
-                         DC_WR_CH_CONF_FIELD_MODE);
-       return 0;
-}
-
 void ipu_dp_dc_enable(ipu_channel_t channel)
 {
        int di;
@@ -782,7 +771,7 @@ void ipu_init_dc_mappings(void)
        ipu_dc_map_config(4, 2, 21, 0xFC);
 }
 
-int ipu_pixfmt_to_map(uint32_t fmt)
+static int ipu_pixfmt_to_map(uint32_t fmt)
 {
        switch (fmt) {
        case IPU_PIX_FMT_GENERIC:
index b20c19c426d5cb0e1baaea409cc7c361bac0979c..1fa95314fc4621857114bcef2e98e50a60f163b7 100644 (file)
@@ -36,7 +36,7 @@ static struct fb_videomode const *gmode;
 static uint8_t gdisp;
 static uint32_t gpixfmt;
 
-void fb_videomode_to_var(struct fb_var_screeninfo *var,
+static void fb_videomode_to_var(struct fb_var_screeninfo *var,
                         const struct fb_videomode *mode)
 {
        var->xres = mode->xres;
index 60539d8a9d24fc113e9d8f839a9f84244fbe1a23..f81b51aa301feec3f13dc787c95626c2f84012a8 100644 (file)
  */
 
 /**
- * Request a gpio. This should be called before any of the other functions
- * are used on this gpio.
+ * Request a GPIO. This should be called before any of the other functions
+ * are used on this GPIO.
+ *
+ * Note: With driver model, the label is allocated so there is no need for
+ * the caller to preserve it.
  *
  * @param gp   GPIO number
  * @param label        User label for this GPIO
@@ -80,7 +83,7 @@ int gpio_get_value(unsigned gpio);
 int gpio_set_value(unsigned gpio, int value);
 
 /* State of a GPIO, as reported by get_function() */
-enum {
+enum gpio_func_t {
        GPIOF_INPUT = 0,
        GPIOF_OUTPUT,
        GPIOF_UNUSED,           /* Not claimed */
@@ -92,6 +95,66 @@ enum {
 
 struct udevice;
 
+/**
+ * gpio_get_status() - get the current GPIO status as a string
+ *
+ * Obtain the current GPIO status as a string which can be presented to the
+ * user. A typical string is:
+ *
+ * "b4:  in: 1 [x] sdmmc_cd"
+ *
+ * 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'
+ *
+ * @dev:       Device to check
+ * @offset:    Offset of device GPIO to check
+ * @buf:       Place to put string
+ * @buffsize:  Size of string including \0
+ */
+int gpio_get_status(struct udevice *dev, int offset, char *buf, int buffsize);
+
+/**
+ * gpio_get_function() - get the current function for a GPIO pin
+ *
+ * Note this returns GPIOF_UNUSED if the GPIO is not requested.
+ *
+ * @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
+ *             was requested, or -1 if it has not been requested
+ * @return  -ENODATA if the driver returned an unknown function,
+ * -ENODEV if the device is not active, -EINVAL if the offset is invalid.
+ * GPIOF_UNUSED if the GPIO has not been requested. Otherwise returns the
+ * function from enum gpio_func_t.
+ */
+int gpio_get_function(struct udevice *dev, int offset, const char **namep);
+
+/**
+ * gpio_get_raw_function() - get the current raw function for a GPIO pin
+ *
+ * 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.
+ *
+ * @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
+ *             was requested, or -1 if it has not been requested
+ * @return  -ENODATA if the driver returned an unknown function,
+ * -ENODEV if the device is not active, -EINVAL if the offset is invalid.
+ * Otherwise returns the function from enum gpio_func_t.
+ */
+int gpio_get_raw_function(struct udevice *dev, int offset, const char **namep);
+
+/**
+ * gpio_requestf() - request a GPIO using a format string for the owner
+ *
+ * This is a helper function for gpio_request(). It allows you to provide
+ * a printf()-format string for the GPIO owner. It calls gpio_request() with
+ * the string that is created
+ */
+int gpio_requestf(unsigned gpio, const char *fmt, ...)
+               __attribute__ ((format (__printf__, 2, 3)));
+
 /**
  * struct struct dm_gpio_ops - Driver model GPIO operations
  *
@@ -102,7 +165,7 @@ struct udevice;
  * new DM GPIO API, this should be really easy to flip over to the Linux
  * GPIO API-alike interface.
  *
- * Akso it would be useful to standardise additional functions like
+ * Also it would be useful to standardise additional functions like
  * pullup, slew rate and drive strength.
  *
  * gpio_request)( and gpio_free() are optional - if NULL then they will
@@ -115,7 +178,7 @@ struct udevice;
  * SoCs there may be many banks and therefore many devices all referring
  * to the different IO addresses within the SoC.
  *
- * The uclass combines all GPIO devices togther to provide a consistent
+ * The uclass combines all GPIO devices together to provide a consistent
  * numbering from 0 to n-1, where n is the number of GPIOs in total across
  * all devices. Be careful not to confuse offset with gpio in the parameters.
  */
@@ -135,15 +198,13 @@ struct dm_gpio_ops {
         * @return current function - GPIOF_...
         */
        int (*get_function)(struct udevice *dev, unsigned offset);
-       int (*get_state)(struct udevice *dev, unsigned offset, char *state,
-                        int maxlen);
 };
 
 /**
  * struct gpio_dev_priv - information about a device used by the uclass
  *
  * The uclass combines all active GPIO devices into a unified numbering
- * scheme. To do this it maintains some private information aobut each
+ * scheme. To do this it maintains some private information about each
  * device.
  *
  * To implement driver model support in your GPIO driver, add a probe
@@ -157,11 +218,14 @@ struct dm_gpio_ops {
  * @gpio_base: Base GPIO number for this device. For the first active device
  * this will be 0; the numbering for others will follow sequentially so that
  * @gpio_base for device 1 will equal the number of GPIOs in device 0.
+ * @name: Array of pointers to the name for each GPIO in this bank. The
+ * value of the pointer will be NULL if the GPIO has not been claimed.
  */
 struct gpio_dev_priv {
        const char *bank_name;
        unsigned gpio_count;
        unsigned gpio_base;
+       char **name;
 };
 
 /* Access the GPIO operations for a device */
@@ -193,4 +257,6 @@ const char *gpio_get_bank_info(struct udevice *dev, int *offset_count);
 int gpio_lookup_name(const char *name, struct udevice **devp,
                     unsigned int *offsetp, unsigned int *gpiop);
 
+int name_to_gpio(const char *name);
+
 #endif /* _ASM_GENERIC_GPIO_H_ */
index 694d6fc080fcc5c1b6759f6e74bdf7ba9a328755..b3d1a620daeaf0041679e5caef49adbb0be4e2e8 100644 (file)
@@ -54,4 +54,6 @@ int bootm_find_ramdisk_fdt(int flag, int argc, char * const argv[]);
 int do_bootm_states(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[],
                    int states, bootm_headers_t *images, int boot_progress);
 
+void arch_preboot_os(void);
+
 #endif
index d5020c8c45d1afc515e02433ea2513ab6b99d28e..bcf6c7e9502f479b9fe533765f28efdb97132eda 100644 (file)
@@ -636,13 +636,6 @@ struct stdio_dev;
 int serial_stub_getc(struct stdio_dev *sdev);
 int serial_stub_tstc(struct stdio_dev *sdev);
 
-void   _serial_setbrg (const int);
-void   _serial_putc   (const char, const int);
-void   _serial_putc_raw(const char, const int);
-void   _serial_puts   (const char *, const int);
-int    _serial_getc   (const int);
-int    _serial_tstc   (const int);
-
 /* $(CPU)/speed.c */
 int    get_clocks (void);
 int    get_clocks_866 (void);
index 76818f673f2810c69520067a7a10e2b34ed4515a..7d8daa2b8e5332f421b9bb616812d494927f1c71 100644 (file)
 #define CONFIG_SYS_PROMPT      "=> "
 #endif
 
-#ifndef CONFIG_SYS_HZ
-#define CONFIG_SYS_HZ          1000
-#endif
-
 #ifndef CONFIG_FIT_SIGNATURE
 #define CONFIG_IMAGE_FORMAT_LEGACY
 #endif
diff --git a/include/configs/apalis_t30.h b/include/configs/apalis_t30.h
new file mode 100644 (file)
index 0000000..3cde923
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2014 Marcel Ziswiler
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#ifndef __CONFIG_H
+#define __CONFIG_H
+
+#include <linux/sizes.h>
+
+#include "tegra30-common.h"
+
+/* High-level configuration options */
+#define V_PROMPT                       "Apalis T30 # "
+#define CONFIG_TEGRA_BOARD_STRING      "Toradex Apalis T30"
+
+/* Board-specific serial config */
+#define CONFIG_SERIAL_MULTI
+#define CONFIG_TEGRA_ENABLE_UARTA
+#define CONFIG_SYS_NS16550_COM1                NV_PA_APB_UARTA_BASE
+
+#define CONFIG_MACH_TYPE               MACH_TYPE_APALIS_T30
+
+#define CONFIG_BOARD_EARLY_INIT_F
+
+/* I2C */
+#define CONFIG_SYS_I2C_TEGRA
+#define CONFIG_SYS_I2C_INIT_BOARD
+#define CONFIG_SYS_I2C_SPEED           100000
+#define CONFIG_CMD_I2C
+#define CONFIG_SYS_I2C
+
+/* SD/MMC */
+#define CONFIG_MMC
+#define CONFIG_GENERIC_MMC
+#define CONFIG_TEGRA_MMC
+#define CONFIG_CMD_MMC
+
+/* Environment in eMMC, at the end of 2nd "boot sector" */
+#define CONFIG_ENV_IS_IN_MMC
+#define CONFIG_ENV_OFFSET              (-CONFIG_ENV_SIZE)
+#define CONFIG_SYS_MMC_ENV_DEV         0
+#define CONFIG_SYS_MMC_ENV_PART                2
+
+/* USB Host support */
+#define CONFIG_USB_EHCI
+#define CONFIG_USB_EHCI_TEGRA
+#define CONFIG_USB_MAX_CONTROLLER_COUNT 3
+#define CONFIG_USB_STORAGE
+#define CONFIG_CMD_USB
+
+/* USB networking support */
+#define CONFIG_USB_HOST_ETHER
+#define CONFIG_USB_ETHER_ASIX
+
+/* PCI host support */
+#undef CONFIG_PCI      /* just define once Tegra PCIe support got merged */
+#define CONFIG_PCI_TEGRA
+#define CONFIG_PCI_PNP
+#define CONFIG_CMD_PCI
+#define CONFIG_CMD_PCI_ENUM
+
+/* PCI networking support */
+#define CONFIG_E1000
+#undef CONFIG_E1000_NO_NVM     /* just define once E1000 driver got fixed */
+
+/* General networking support */
+#define CONFIG_CMD_NET
+#define CONFIG_CMD_DHCP
+
+#include "tegra-common-usb-gadget.h"
+#include "tegra-common-post.h"
+
+#endif /* __CONFIG_H */
index a20c3733212ca39d2dc9509a63b703746aad5c0a..f7277eb1d17a0d5f3a4c613d6033bd682c3491dd 100644 (file)
@@ -19,7 +19,6 @@
 #define CONFIG_MX6
 #define CONFIG_SYS_LITTLE_ENDIAN
 #define CONFIG_MACH_TYPE               4273
-#define CONFIG_SYS_HZ                  1000
 
 #ifndef CONFIG_SPL_BUILD
 #define CONFIG_DM
index 782b9d16b7a4f7c8ab1fcf1fa6e9a9647505170e..a582e255169c8188cdcd3aac8416b530191bf2c3 100644 (file)
@@ -11,7 +11,6 @@
 
 #include "tegra30-common.h"
 
-
 #define V_PROMPT                       "Colibri T30 # "
 #define CONFIG_TEGRA_BOARD_STRING      "Toradex Colibri T30"
 
index 936be145119d1e55a810ccc95bb922cb8a9b0f72..4b90dc205de82e4130547d1be44defd1ea8c208f 100644 (file)
 #define CONFIG_ZBOOT_32
 #define CONFIG_PHYSMEM
 #define CONFIG_SYS_EARLY_PCI_INIT
+#define CONFIG_DISPLAY_BOARDINFO_LATE
+
+#define CONFIG_DM
+#define CONFIG_CMD_DM
+#define CONFIG_DM_GPIO
+#define CONFIG_DM_SERIAL
 
 #define CONFIG_LMB
 #define CONFIG_OF_LIBFDT
@@ -39,6 +45,7 @@
 #define CONFIG_BOOTSTAGE_USER_COUNT    60
 
 #define CONFIG_LZO
+#define CONFIG_FIT
 #undef CONFIG_ZLIB
 #undef CONFIG_GZIP
 
 /*-----------------------------------------------------------------------
  * Serial Configuration
  */
-#define CONFIG_CONS_INDEX              1
+#define CONFIG_COREBOOT_SERIAL
 #define CONFIG_SYS_NS16550
-#define CONFIG_SYS_NS16550_SERIAL
-#define CONFIG_SYS_NS16550_REG_SIZE    1
-#define CONFIG_SYS_NS16550_CLK         1843200
-#define CONFIG_BAUDRATE                        9600
+#define CONFIG_BAUDRATE                        115200
 #define CONFIG_SYS_BAUDRATE_TABLE      {300, 600, 1200, 2400, 4800, \
                                         9600, 19200, 38400, 115200}
-#define CONFIG_SYS_NS16550_COM1        UART0_BASE
-#define CONFIG_SYS_NS16550_COM2        UART1_BASE
 #define CONFIG_SYS_NS16550_PORT_MAPPED
 
-#define CONFIG_STD_DEVICES_SETTINGS     "stdin=usbkbd,vga,eserial0\0" \
-                                       "stdout=vga,eserial0,cbmem\0" \
-                                       "stderr=vga,eserial0,cbmem\0"
+#define CONFIG_STD_DEVICES_SETTINGS     "stdin=usbkbd,vga,serial\0" \
+                                       "stdout=vga,serial,cbmem\0" \
+                                       "stderr=vga,serial,cbmem\0"
 
 #define CONFIG_CONSOLE_MUX
 #define CONFIG_SYS_CONSOLE_IS_IN_ENV
 
 #define CONFIG_CMDLINE_EDITING
 #define CONFIG_COMMAND_HISTORY
-#define CONFIG_AUTOCOMPLETE
+#define CONFIG_AUTO_COMPLETE
+#define CONFIG_SYS_HUSH_PARSER
 
 #define CONFIG_SUPPORT_VFAT
 /************************************************************
 #define CONFIG_CMD_EXT2
 
 #define CONFIG_CMD_ZBOOT
+#define CONFIG_CMD_ELF
 
 #define CONFIG_BOOTDELAY       2
 #define CONFIG_BOOTARGS                \
  * Miscellaneous configurable options
  */
 #define CONFIG_SYS_LONGHELP
-#define CONFIG_SYS_PROMPT                      "boot > "
-#define CONFIG_SYS_CBSIZE                      256
+#define CONFIG_SYS_CBSIZE                      512
 #define CONFIG_SYS_PBSIZE                      (CONFIG_SYS_CBSIZE + \
                                                 sizeof(CONFIG_SYS_PROMPT) + \
                                                 16)
 
 #define CONFIG_SYS_MEMTEST_START               0x00100000
 #define CONFIG_SYS_MEMTEST_END                 0x01000000
-#define CONFIG_SYS_LOAD_ADDR                   0x100000
+#define CONFIG_SYS_LOAD_ADDR                   0x02000000
 
 /*-----------------------------------------------------------------------
  * SDRAM Configuration
 #define CONFIG_SYS_MONITOR_BASE                CONFIG_SYS_TEXT_BASE
 #define CONFIG_SYS_MONITOR_LEN                 (256 * 1024)
 #define CONFIG_SYS_MALLOC_LEN                  (0x20000 + 128 * 1024)
-
+#define CONFIG_SYS_MALLOC_F_LEN                        (1 << 10)
 
 /* allow to overwrite serial and ethaddr */
 #define CONFIG_ENV_OVERWRITE
  */
 #define CONFIG_PCI
 
+#define CONFIG_CROS_EC
+#define CONFIG_CROS_EC_LPC
+#define CONFIG_CMD_CROS_EC
+#define CONFIG_ARCH_EARLY_INIT_R
+
 /*-----------------------------------------------------------------------
  * USB configuration
  */
 #define CONFIG_USB_HOST_ETHER
 #define CONFIG_USB_ETHER_ASIX
 #define CONFIG_USB_ETHER_SMSC95XX
+#define CONFIG_TFTP_TSIZE
+#define CONFIG_CMD_DHCP
+#define CONFIG_BOOTP_BOOTFILESIZE
+#define CONFIG_BOOTP_BOOTPATH
+#define CONFIG_BOOTP_GATEWAY
+#define CONFIG_BOOTP_HOSTNAME
 
 #define CONFIG_CMD_USB
 
diff --git a/include/configs/db-mv784mp-gp.h b/include/configs/db-mv784mp-gp.h
new file mode 100644 (file)
index 0000000..cb03e33
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2014 Stefan Roese <sr@denx.de>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#ifndef _CONFIG_DB_MV7846MP_GP_H
+#define _CONFIG_DB_MV7846MP_GP_H
+
+/*
+ * High Level Configuration Options (easy to change)
+ */
+#define CONFIG_ARMADA_XP               /* SOC Family Name */
+#define CONFIG_SKIP_LOWLEVEL_INIT      /* disable board lowlevel_init */
+#define CONFIG_SYS_GENERIC_BOARD
+#define CONFIG_DISPLAY_BOARDINFO_LATE
+
+#define        CONFIG_SYS_TEXT_BASE    0x04000000
+#define CONFIG_SYS_TCLK                250000000       /* 250MHz */
+
+/*
+ * Commands configuration
+ */
+#define CONFIG_SYS_NO_FLASH            /* Declare no flash (NOR/SPI) */
+#include <config_cmd_default.h>
+#define CONFIG_CMD_DHCP
+#define CONFIG_CMD_ENV
+#define CONFIG_CMD_I2C
+#define CONFIG_CMD_PING
+#define CONFIG_CMD_SF
+#define CONFIG_CMD_SPI
+#define CONFIG_CMD_TFTPPUT
+#define CONFIG_CMD_TIME
+
+/* I2C */
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_MVTWSI
+#define CONFIG_I2C_MVTWSI_BASE         MVEBU_TWSI_BASE
+#define CONFIG_SYS_I2C_SLAVE           0x0
+#define CONFIG_SYS_I2C_SPEED           100000
+
+/* SPI NOR flash default params, used by sf commands */
+#define CONFIG_SF_DEFAULT_SPEED                1000000
+#define CONFIG_SF_DEFAULT_MODE         SPI_MODE_3
+#define CONFIG_SPI_FLASH_STMICRO
+
+/* Environment in SPI NOR flash */
+#define CONFIG_ENV_IS_IN_SPI_FLASH
+#define CONFIG_ENV_OFFSET              (1 << 20) /* 1MiB in */
+#define CONFIG_ENV_SIZE                        (64 << 10) /* 64KiB */
+#define CONFIG_ENV_SECT_SIZE           (64 << 10) /* 64KiB sectors */
+
+#define CONFIG_PHY_MARVELL             /* there is a marvell phy */
+#define CONFIG_PHY_BASE_ADDR   0x10
+#define CONFIG_SYS_NETA_INTERFACE_TYPE PHY_INTERFACE_MODE_QSGMII
+#define PHY_ANEG_TIMEOUT       8000    /* PHY needs a longer aneg time */
+#define CONFIG_RESET_PHY_R
+
+#define CONFIG_SYS_CONSOLE_INFO_QUIET  /* don't print console @ startup */
+#define CONFIG_SYS_ALT_MEMTEST
+
+/*
+ * mv-common.h should be defined after CMD configs since it used them
+ * to enable certain macros
+ */
+#include "mv-common.h"
+
+#endif /* _CONFIG_DB_MV7846MP_GP_H */
index 37bdcc0f3320a447b096ec9c553cad579929e1ca..47a8420f42d37cf8a9d9d4614a25b255254e1c82 100644 (file)
@@ -89,7 +89,6 @@
 #define CONFIG_EP93XX          1               /* in a Cirrus Logic 93xx SoC */
 
 #define CONFIG_SYS_CLK_FREQ    14745600        /* EP93xx has a 14.7456 clock */
-#define CONFIG_SYS_HZ          1000            /* decr freq: 1 ms ticks */
 #undef CONFIG_USE_IRQ                          /* Don't need IRQ/FIQ */
 
 /* Monitor configuration */
index 5dae40921c8cd68a457bab118c2f0149977e9097..b0c91d8dcb599a6f91ff0b32ba4b968e68aed0cb 100644 (file)
@@ -23,7 +23,6 @@
 #define CONFIG_ARMV7
 #define CONFIG_ARCH_CPU_INIT
 #define CONFIG_SYS_ARCH_TIMER
-#define CONFIG_SYS_HZ                  1000
 #define CONFIG_SYS_TEXT_BASE           0x0c001000
 #define CONFIG_SPL_TARGET              "u-boot-spi.gph"
 #define CONFIG_SYS_DCACHE_OFF
index 42214262f480fd5ad748a360c2177ce139f8fe9b..d1f6ea7e7b0e6d5f1efcda54eca34af3cd3d3b3c 100644 (file)
@@ -360,7 +360,6 @@ unsigned long get_board_ddr_clk(void);
 #define CONFIG_SYS_MEMTEST_END         0x9fffffff
 
 #define CONFIG_SYS_LOAD_ADDR           0x82000000
-#define CONFIG_SYS_HZ                  1000
 
 /*
  * Stack sizes
index 5868287057399b8c830adfe03124a090493d34d7..3c73af8ac39dc6663fa0db3ed5d91eb9c3601618 100644 (file)
 #define CONFIG_SYS_MEMTEST_END         0x9fffffff
 
 #define CONFIG_SYS_LOAD_ADDR           0x82000000
-#define CONFIG_SYS_HZ                  1000
 
 /*
  * Stack sizes
index a72e1f3567d22144383bf94b306bfb0c5f1112cb..6fe032c9ff64fb6b89f107095af3b9f38ca4998b 100644 (file)
 
 #define CONFIG_NR_DRAM_BANKS           3
 
-#define CONFIG_SYS_HZ                  1000
-
 #define CONFIG_HWCONFIG
 #define HWCONFIG_BUFFER_SIZE           128
 
diff --git a/include/configs/maxbcm.h b/include/configs/maxbcm.h
new file mode 100644 (file)
index 0000000..72217bd
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2014 Stefan Roese <sr@denx.de>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#ifndef _CONFIG_DB_MV7846MP_GP_H
+#define _CONFIG_DB_MV7846MP_GP_H
+
+/*
+ * High Level Configuration Options (easy to change)
+ */
+#define CONFIG_ARMADA_XP               /* SOC Family Name */
+#define CONFIG_SKIP_LOWLEVEL_INIT      /* disable board lowlevel_init */
+#define CONFIG_SYS_GENERIC_BOARD
+#define CONFIG_DISPLAY_BOARDINFO_LATE
+
+#define        CONFIG_SYS_TEXT_BASE    0x04000000
+#define CONFIG_SYS_TCLK                250000000       /* 250MHz */
+
+/*
+ * Commands configuration
+ */
+#define CONFIG_SYS_NO_FLASH            /* Declare no flash (NOR/SPI) */
+#include <config_cmd_default.h>
+#define CONFIG_CMD_DHCP
+#define CONFIG_CMD_ENV
+#define CONFIG_CMD_I2C
+#define CONFIG_CMD_PING
+#define CONFIG_CMD_SF
+#define CONFIG_CMD_SPI
+#define CONFIG_CMD_TFTPPUT
+#define CONFIG_CMD_TIME
+
+/* I2C */
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_MVTWSI
+#define CONFIG_I2C_MVTWSI_BASE         MVEBU_TWSI_BASE
+#define CONFIG_SYS_I2C_SLAVE           0x0
+#define CONFIG_SYS_I2C_SPEED           100000
+
+/* SPI NOR flash default params, used by sf commands */
+#define CONFIG_SF_DEFAULT_SPEED                1000000
+#define CONFIG_SF_DEFAULT_MODE         SPI_MODE_3
+#define CONFIG_SPI_FLASH_STMICRO
+
+/* Environment in SPI NOR flash */
+#define CONFIG_ENV_IS_IN_SPI_FLASH
+#define CONFIG_ENV_OFFSET              (1 << 20) /* 1MiB in */
+#define CONFIG_ENV_SIZE                        (64 << 10) /* 64KiB */
+#define CONFIG_ENV_SECT_SIZE           (64 << 10) /* 64KiB sectors */
+
+#define CONFIG_PHY_MARVELL             /* there is a marvell phy */
+#define CONFIG_PHY_BASE_ADDR   0x0
+#define CONFIG_SYS_NETA_INTERFACE_TYPE PHY_INTERFACE_MODE_SGMII
+#define PHY_ANEG_TIMEOUT       8000    /* PHY needs a longer aneg time */
+#define CONFIG_RESET_PHY_R
+
+#define CONFIG_SYS_CONSOLE_INFO_QUIET  /* don't print console @ startup */
+#define CONFIG_SYS_ALT_MEMTEST
+
+/*
+ * mv-common.h should be defined after CMD configs since it used them
+ * to enable certain macros
+ */
+#include "mv-common.h"
+
+#endif /* _CONFIG_DB_MV7846MP_GP_H */
index a28d7b579a6405a1b7f32e5f9ba7816681a08045..005a853f56822b3d8630cedb51f044c96c81662b 100644 (file)
  *   SoC UART     : enable CONFIG_UNIPHIER_SERIAL
  *   On-board UART: enable CONFIG_SYS_NS16550_SERIAL
  */
-#if 1
-#define CONFIG_UNIPHIER_SERIAL
-#else
+#if 0
 #define CONFIG_SYS_NS16550_SERIAL
 #endif
 
-#define CONFIG_SYS_UNIPHIER_UART_CLK    36864000
-
 #define CONFIG_SMC911X
 
 #define CONFIG_DDR_NUM_CH0 1
index b79967f7da477c351e307f2b1dc879f8932a037e..7dd6fd2a9292d8bdd73c33b5371218f25b07f128 100644 (file)
  *   SoC UART     : enable CONFIG_UNIPHIER_SERIAL
  *   On-board UART: enable CONFIG_SYS_NS16550_SERIAL
  */
-#if 1
-#define CONFIG_UNIPHIER_SERIAL
-#else
+#if 0
 #define CONFIG_SYS_NS16550_SERIAL
 #endif
 
-#define CONFIG_SYS_UNIPHIER_UART_CLK    73728000
-
 #define CONFIG_SMC911X
 
 #define CONFIG_DDR_NUM_CH0 2
index 9d391f1d74a2650b4d53ab5730e55aa7553866cd..1062aace38a7970772e6f16ed68f8a66c664ee10 100644 (file)
  *   SoC UART     : enable CONFIG_UNIPHIER_SERIAL
  *   On-board UART: enable CONFIG_SYS_NS16550_SERIAL
  */
-#if 1
-#define CONFIG_UNIPHIER_SERIAL
-#else
+#if 0
 #define CONFIG_SYS_NS16550_SERIAL
 #endif
 
-#define CONFIG_SYS_UNIPHIER_UART_CLK    80000000
-
 #define CONFIG_SMC911X
 
 #define CONFIG_DDR_NUM_CH0 1
index d9475e950b798188244e15269348c1a79ec5c687..ca27f9ad787008c507241464aadbbf191286a83f 100644 (file)
 #define CONFIG_MMC_SDHCI_IO_ACCESSORS
 #define CONFIG_BCM2835_SDHCI
 
+#define CONFIG_CMD_USB
+#ifdef CONFIG_CMD_USB
+#define CONFIG_USB_DWC2
+#define CONFIG_USB_DWC2_REG_ADDR 0x20980000
+#define CONFIG_USB_STORAGE
+#define CONFIG_USB_HOST_ETHER
+#define CONFIG_USB_ETHER_SMSC95XX
+#define CONFIG_MISC_INIT_R
+#endif
+
 /* Console UART */
 #define CONFIG_PL011_SERIAL
 #define CONFIG_PL011_CLOCK             3000000
 
 /* Some things don't make sense on this HW or yet */
 #undef CONFIG_CMD_FPGA
-#undef CONFIG_CMD_NET
-#undef CONFIG_CMD_NFS
 #undef CONFIG_CMD_SAVEENV
-#undef CONFIG_CMD_DHCP
-#undef CONFIG_CMD_MII
-#undef CONFIG_CMD_NET
-#undef CONFIG_CMD_PING
 
 /* Environment */
 #define ENV_DEVICE_SETTINGS \
        "ramdisk_addr_r=0x02100000\0" \
 
 #define BOOT_TARGET_DEVICES(func) \
-       func(MMC, mmc, 0)
+       func(MMC, mmc, 0) \
+       func(USB, usb, 0) \
+       func(PXE, pxe, na) \
+       func(DHCP, dhcp, na)
 #include <config_distro_bootcmd.h>
 
 #define CONFIG_EXTRA_ENV_SETTINGS \
index 49504dcafbc23278000c965058364b892b59c931..83a1bcdfbe34354980713f7e1c01e2c2ec788c7e 100644 (file)
@@ -22,7 +22,7 @@
 #define CONFIG_DISPLAY_CPUINFO
 #define CONFIG_DISPLAY_BOARDINFO
 #define CONFIG_BOARD_EARLY_INIT_F
-#define CONFIG_MISC_INIT_R
+#define CONFIG_ARCH_EARLY_INIT_R
 #define CONFIG_SYS_NO_FLASH
 #define CONFIG_CLOCKS
 
 #define CONFIG_CONS_INDEX              1
 #define CONFIG_BAUDRATE                        115200
 
+/*
+ * USB
+ */
+#ifdef CONFIG_CMD_USB
+#define CONFIG_USB_DWC2
+#define CONFIG_USB_STORAGE
+/*
+ * NOTE: User must define either of the following to select which
+ *       of the two USB controllers available on SoCFPGA to use.
+ *       The DWC2 driver doesn't support multiple USB controllers.
+ * #define CONFIG_USB_DWC2_REG_ADDR    SOCFPGA_USB0_ADDRESS
+ * #define CONFIG_USB_DWC2_REG_ADDR    SOCFPGA_USB1_ADDRESS
+ */
+#endif
+
 /*
  * U-Boot environment
  */
 
 /*
  * SPL
+ *
+ * SRAM Memory layout:
+ *
+ * 0xFFFF_0000 ...... Start of SRAM
+ * 0xFFFF_xxxx ...... Top of stack (grows down)
+ * 0xFFFF_yyyy ...... Malloc area
+ * 0xFFFF_zzzz ...... Global Data
+ * 0xFFFF_FF00 ...... End of SRAM
  */
 #define CONFIG_SPL_FRAMEWORK
 #define CONFIG_SPL_BOARD_INIT
 #define CONFIG_SPL_RAM_DEVICE
-#define CONFIG_SPL_TEXT_BASE           0xFFFF0000
-#define CONFIG_SPL_STACK               CONFIG_SYS_INIT_SP_ADDR
-#define CONFIG_SPL_STACK_SIZE          (4 * 1024)
-#define CONFIG_SPL_MALLOC_SIZE         (5 * 1024)      /* FIXME */
-#define CONFIG_SYS_SPL_MALLOC_START    ((unsigned long) (&__malloc_start))
-#define CONFIG_SYS_SPL_MALLOC_SIZE     (&__malloc_end - &__malloc_start)
+#define CONFIG_SPL_TEXT_BASE           CONFIG_SYS_INIT_RAM_ADDR
+#define CONFIG_SYS_SPL_MALLOC_START    CONFIG_SYS_INIT_SP_ADDR
+#define CONFIG_SYS_SPL_MALLOC_SIZE     (5 * 1024)
 
 #define CHUNKSZ_CRC32                  (1 * 1024)      /* FIXME: ewww */
 #define CONFIG_CRC32_VERIFY
index 60d7e20e83b2678254e129127f221b5e6a74d0c4..942738c138bef60597e12fcefb5b70c90d18a109 100644 (file)
 #if defined(CONFIG_CMD_NET)
 #define CONFIG_EMAC_BASE               SOCFPGA_EMAC1_ADDRESS
 #define CONFIG_PHY_INTERFACE_MODE      PHY_INTERFACE_MODE_RGMII
-#define CONFIG_EPHY0_PHY_ADDR          0
 
 /* PHY */
-#define CONFIG_EPHY1_PHY_ADDR          4
 #define CONFIG_PHY_MICREL
 #define CONFIG_PHY_MICREL_KSZ9021
 #define CONFIG_KSZ9021_CLK_SKEW_ENV    "micrel-ksz9021-clk-skew"
index 5611ecc85f22bf3f3d949211c54cabc3eb54db92..d0191a32b1a6d99807cf75becf4821f2e6879cfd 100644 (file)
@@ -15,6 +15,7 @@
 #define CONFIG_CLK_FULL_SPEED          1008000000
 
 #define CONFIG_SYS_PROMPT              "sun4i# "
+#define CONFIG_MACH_TYPE               4104
 
 #ifdef CONFIG_USB_EHCI
 #define CONFIG_USB_EHCI_SUNXI
index 6066371a17d8d172c62d00cff4f4a508c5de53ee..7b683e9c8908394e56072d545f873d0e5f798c6a 100644 (file)
@@ -15,6 +15,7 @@
 #define CONFIG_CLK_FULL_SPEED          1008000000
 
 #define CONFIG_SYS_PROMPT              "sun5i# "
+#define CONFIG_MACH_TYPE               4138
 
 #ifdef CONFIG_USB_EHCI
 #define CONFIG_USB_EHCI_SUNXI
diff --git a/include/configs/sun6i.h b/include/configs/sun6i.h
new file mode 100644 (file)
index 0000000..93a1d96
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * (C) Copyright 2012-2013 Henrik Nordstrom <henrik@henriknordstrom.net>
+ * (C) Copyright 2013 Luke Kenneth Casson Leighton <lkcl@lkcl.net>
+ * (C) Copyright 2013 Maxime Ripard <maxime.ripard@free-electrons.com>
+ *
+ * Configuration settings for the Allwinner A31 (sun6i) CPU
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#ifndef __CONFIG_H
+#define __CONFIG_H
+
+/*
+ * A31 specific configuration
+ */
+#define CONFIG_SUN6I           /* sun6i SoC generation */
+
+#define CONFIG_SYS_PROMPT              "sun6i# "
+
+/*
+ * Include common sunxi configuration where most the settings are
+ */
+#include <configs/sunxi-common.h>
+
+#endif /* __CONFIG_H */
index a902b845744707e64fb5a064c6039bc93b0150d9..966cbd8e83f6cb2659f64798cfeb502a1b5e6aa4 100644 (file)
@@ -16,6 +16,7 @@
 #define CONFIG_CLK_FULL_SPEED          912000000
 
 #define CONFIG_SYS_PROMPT              "sun7i# "
+#define CONFIG_MACH_TYPE               4283
 
 #ifdef CONFIG_USB_EHCI
 #define CONFIG_USB_EHCI_SUNXI
diff --git a/include/configs/sun8i.h b/include/configs/sun8i.h
new file mode 100644 (file)
index 0000000..1c1a7cd
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * (C) Copyright 2014 Chen-Yu Tsai <wens@csie.org>
+ *
+ * Configuration settings for the Allwinner A23 (sun8i) CPU
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#ifndef __CONFIG_H
+#define __CONFIG_H
+
+/*
+ * A23 specific configuration
+ */
+#define CONFIG_SUN8I           /* sun8i SoC generation */
+#define CONFIG_SYS_PROMPT      "sun8i# "
+
+/*
+ * Include common sunxi configuration where most the settings are
+ */
+#include <configs/sunxi-common.h>
+
+#endif /* __CONFIG_H */
index 1d947d7d9eab39030964f4d6b1e14e678303e55e..cc450e02e67e041b248a47c84c05aa1a5325c57b 100644 (file)
@@ -42,6 +42,7 @@
 #define CONFIG_SYS_NS16550_COM2                SUNXI_UART1_BASE
 #define CONFIG_SYS_NS16550_COM3                SUNXI_UART2_BASE
 #define CONFIG_SYS_NS16550_COM4                SUNXI_UART3_BASE
+#define CONFIG_SYS_NS16550_COM5                SUNXI_R_UART_BASE
 
 /* DRAM Base */
 #define CONFIG_SYS_SDRAM_BASE          0x40000000
@@ -77,6 +78,7 @@
 #define CONFIG_INITRD_TAG
 
 /* mmc config */
+#if !defined(CONFIG_UART0_PORT_F)
 #define CONFIG_MMC
 #define CONFIG_GENERIC_MMC
 #define CONFIG_CMD_MMC
@@ -84,6 +86,7 @@
 #define CONFIG_MMC_SUNXI_SLOT          0
 #define CONFIG_ENV_IS_IN_MMC
 #define CONFIG_SYS_MMC_ENV_DEV         0       /* first detected MMC controller */
+#endif
 
 /* 4MB of malloc() pool */
 #define CONFIG_SYS_MALLOC_LEN          (CONFIG_ENV_SIZE + (4 << 20))
@@ -92,8 +95,8 @@
  * Miscellaneous configurable options
  */
 #define CONFIG_CMD_ECHO
-#define CONFIG_SYS_CBSIZE      256     /* Console I/O Buffer Size */
-#define CONFIG_SYS_PBSIZE      384     /* Print Buffer Size */
+#define CONFIG_SYS_CBSIZE      1024    /* Console I/O Buffer Size */
+#define CONFIG_SYS_PBSIZE      1024    /* Print Buffer Size */
 #define CONFIG_SYS_MAXARGS     16      /* max number of command args */
 #define CONFIG_SYS_GENERIC_BOARD
 
 /* standalone support */
 #define CONFIG_STANDALONE_LOAD_ADDR    0x42000000
 
-#define CONFIG_SYS_HZ                  1000
-
 /* baudrate */
 #define CONFIG_BAUDRATE                        115200
 
 
 /* GPIO */
 #define CONFIG_SUNXI_GPIO
+#define CONFIG_SPL_GPIO_SUPPORT
 #define CONFIG_CMD_GPIO
 
 /* Ethernet support */
        "pxefile_addr_r=0x43200000\0" \
        "ramdisk_addr_r=0x43300000\0"
 
+#ifdef CONFIG_MMC
+#define BOOT_TARGET_DEVICES_MMC(func) func(MMC, mmc, 0)
+#else
+#define BOOT_TARGET_DEVICES_MMC(func)
+#endif
+
 #ifdef CONFIG_AHCI
 #define BOOT_TARGET_DEVICES_SCSI(func) func(SCSI, scsi, 0)
 #else
 #define BOOT_TARGET_DEVICES_SCSI(func)
 #endif
 
+#ifdef CONFIG_USB_EHCI
+#define BOOT_TARGET_DEVICES_USB(func) func(USB, usb, 0)
+#else
+#define BOOT_TARGET_DEVICES_USB(func)
+#endif
+
 #define BOOT_TARGET_DEVICES(func) \
-       func(MMC, mmc, 0) \
+       BOOT_TARGET_DEVICES_MMC(func) \
        BOOT_TARGET_DEVICES_SCSI(func) \
-       func(USB, usb, 0) \
+       BOOT_TARGET_DEVICES_USB(func) \
        func(PXE, pxe, na) \
        func(DHCP, dhcp, na)
 
index a258699af7ec5fb089c78daf52496a6c919f983f..c3ad8beb903d9e131ae596ee98fbb725297614ec 100644 (file)
 
 #define CONFIG_SKIP_LOWLEVEL_INIT
 
-/* remove devicetree support */
-#ifdef CONFIG_OF_CONTROL
-#endif
-
 /* remove I2C support */
 #ifdef CONFIG_SYS_I2C_TEGRA
 #undef CONFIG_SYS_I2C_TEGRA
index 4719ee10aeeca8810c25bad2392e2dff6875f422..5d2b12a11d1ef1e1494fa76ae14f5eeae8401797 100644 (file)
 #define CONFIG_SYS_MEMTEST_START       (NV_PA_SDRC_CS0 + 0x600000)
 #define CONFIG_SYS_MEMTEST_END         (CONFIG_SYS_MEMTEST_START + 0x100000)
 
+#define CONFIG_USE_ARCH_MEMCPY
+
 /*-----------------------------------------------------------------------
  * Physical Memory Map
  */
 #define CONFIG_SPL_SERIAL_SUPPORT
 #define CONFIG_SPL_GPIO_SUPPORT
 
-#ifdef CONFIG_SPL_BUILD
-# define CONFIG_USE_PRIVATE_LIBGCC
-#endif
-
 #define CONFIG_SYS_GENERIC_BOARD
 
 /* Misc utility code */
index 80976e7e3b84ecddc3ea767f3416763ce37b6eda..5ed86d9365cd08aee392bbe77e7c7bf84e5c9ad6 100644 (file)
 #define CONFIG_SYS_TIMERBASE           0x48040000      /* Use Timer2 */
 #define CONFIG_SPL_AM33XX_ENABLE_RTC32K_OSC
 
+#ifndef CONFIG_SPL_BUILD
+# define CONFIG_DM
+# define CONFIG_CMD_DM
+# define CONFIG_DM_GPIO
+# define CONFIG_DM_SERIAL
+# define CONFIG_OMAP_SERIAL
+# define CONFIG_SYS_MALLOC_F_LEN       (1 << 10)
+#endif
+
 #include <asm/arch/omap.h>
 
 /* NS16550 Configuration */
 #define CONFIG_SYS_NS16550
+#ifdef CONFIG_SPL_BUILD
 #define CONFIG_SYS_NS16550_SERIAL
 #define CONFIG_SYS_NS16550_REG_SIZE    (-4)
+#endif
 #define CONFIG_SYS_NS16550_CLK         48000000
 
 /* Network defines. */
index 3b19d3d6baf4c46f7a930e5c74c7e1afdea1f6a3..3c634ee680d02143b69fa0534143f28705b1a36b 100644 (file)
 #include <asm/arch/cpu.h>
 #include <asm/arch/omap3.h>
 
+#ifndef CONFIG_SPL_BUILD
+# define CONFIG_DM
+# define CONFIG_CMD_DM
+# define CONFIG_DM_GPIO
+# define CONFIG_DM_SERIAL
+# define CONFIG_OMAP_SERIAL
+# define CONFIG_SYS_MALLOC_F_LEN       (1 << 10)
+#endif
+
 /* The chip has SDRC controller */
 #define CONFIG_SDRC
 
 /* NS16550 Configuration */
 #define V_NS16550_CLK                  48000000        /* 48MHz (APLL96/2) */
 #define CONFIG_SYS_NS16550
-#define CONFIG_SYS_NS16550_SERIAL
-#define CONFIG_SYS_NS16550_REG_SIZE    (-4)
-#define CONFIG_SYS_NS16550_CLK         V_NS16550_CLK
+#ifdef CONFIG_SPL_BUILD
+# define CONFIG_SYS_NS16550_SERIAL
+# define CONFIG_SYS_NS16550_REG_SIZE   (-4)
+# define CONFIG_SYS_NS16550_CLK                V_NS16550_CLK
+#endif
 #define CONFIG_SYS_BAUDRATE_TABLE      {4800, 9600, 19200, 38400, 57600, \
                                        115200}
 
 /* Select serial console configuration */
 #define CONFIG_CONS_INDEX              3
+#ifdef CONFIG_SPL_BUILD
 #define CONFIG_SYS_NS16550_COM3                OMAP34XX_UART3
 #define CONFIG_SERIAL3                 3
+#endif
 
 /* Physical Memory Map */
 #define PHYS_SDRAM_1           OMAP34XX_SDRC_CS0
index 2705d2c55febe2b7d7f9b1881ae63af37a8a85ba..d97a9613ae5f3c83f56f246467a51ba1ea767f83 100644 (file)
 #define CONFIG_SYS_BARGSIZE            CONFIG_SYS_CBSIZE
 
 #define CONFIG_SYS_LOAD_ADDR           CONFIG_LOADADDR
-#define CONFIG_SYS_HZ                  1000
 
 #define CONFIG_CMDLINE_EDITING
 #define CONFIG_STACKSIZE               (128u * SZ_1K)
index 18fe277cada77b585012af8d5c0279ea834a7d0e..b18ae6dfaeb3551573ae9810fd4ef817428e209f 100644 (file)
@@ -33,18 +33,17 @@ are defined. Select only one of them."
 # define CONFIG_SUPPORT_CARD_UART_BASE (CONFIG_SUPPORT_CARD_BASE + 0x00200000)
 #endif
 
+#ifdef CONFIG_SYS_NS16550_SERIAL
 #define CONFIG_SYS_NS16550
 #define CONFIG_SYS_NS16550_COM1                CONFIG_SUPPORT_CARD_UART_BASE
 #define CONFIG_SYS_NS16550_CLK         12288000
 #define CONFIG_SYS_NS16550_REG_SIZE    -2
+#endif
 
 #define CONFIG_SMC911X_BASE            CONFIG_SUPPORT_CARD_ETHER_BASE
 #define CONFIG_SMC911X_32_BIT
 
-#define CONFIG_SYS_UNIPHIER_SERIAL_BASE0 0x54006800
-#define CONFIG_SYS_UNIPHIER_SERIAL_BASE1 0x54006900
-#define CONFIG_SYS_UNIPHIER_SERIAL_BASE2 0x54006a00
-#define CONFIG_SYS_UNIPHIER_SERIAL_BASE3 0x54006b00
+#define CONFIG_SYS_MALLOC_F_LEN  0x7000
 
 /*-----------------------------------------------------------------------
  * MMU and Cache Setting
diff --git a/include/dm/platform_data/serial-uniphier.h b/include/dm/platform_data/serial-uniphier.h
new file mode 100644 (file)
index 0000000..52343e3
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+ * Copyright (C) 2014 Panasonic Corporation
+ *   Author: Masahiro Yamada <yamada.m@jp.panasonic.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#ifndef __PLAT_UNIPHIER_SERIAL_H
+#define __PLAT_UNIPHIER_SERIAL_H
+
+#define DRIVER_NAME    "uniphier-uart"
+
+struct uniphier_serial_platform_data {
+       unsigned long base;
+       unsigned int uartclk;
+};
+
+#endif /* __PLAT_UNIPHIER_SERIAL_H */
index 235d728bfbe62ea9af8cc3f6e946a248ce9791cd..f08c05da8147725f87900da81bf8944ff1c46ebc 100644 (file)
@@ -8,6 +8,7 @@
 #define __DM_TEST_H
 
 #include <dm.h>
+#include <malloc.h>
 
 /**
  * struct dm_test_cdata - configuration data for test instance
@@ -120,6 +121,7 @@ struct dm_test_state {
        int force_fail_alloc;
        int skip_post_probe;
        struct udevice *removed;
+       struct mallinfo start;
 };
 
 /* Test flags for each test */
@@ -177,6 +179,27 @@ int dm_check_operations(struct dm_test_state *dms, struct udevice *dev,
  */
 int dm_check_devices(struct dm_test_state *dms, int num_devices);
 
+/**
+ * dm_leak_check_start() - Prepare to check for a memory leak
+ *
+ * Call this before allocating memory to record the amount of memory being
+ * used.
+ *
+ * @dms: Overall test state
+ */
+void dm_leak_check_start(struct dm_test_state *dms);
+
+/**
+ * dm_leak_check_end() - Check that no memory has leaked
+ *
+ * Call this after dm_leak_check_start() and after you have hopefuilly freed
+ * all the memory that was allocated. This function will print an error if
+ * it sees a different amount of total memory allocated than before.
+ *
+ * @dms: Overall test state
+ */int dm_leak_check_end(struct dm_test_state *dms);
+
+
 /**
  * dm_test_main() - Run all the tests
  *
index b8ecc41063b3e5b366f1688d60a32dd4f8e914fa..63d93416a3e1246975bd390b8990b6067c350f97 100644 (file)
@@ -570,4 +570,6 @@ unsigned long elf_hash(const unsigned char *name);
    that may still be in object files.  */
 #define R_PPC_TOC16             255
 
+int valid_elf_image(unsigned long addr);
+
 #endif /* _ELF_H */
index c3d1fbcf3566451419bff1a325a870a945743475..55cef94358bcd9ed1db349493941addc901d1ff4 100644 (file)
@@ -144,6 +144,8 @@ static inline u64 of_read_number(const fdt32_t *cell, int size)
 
 void of_bus_default_count_cells(void *blob, int parentoffset,
                                        int *addrc, int *sizec);
+int ft_verify_fdt(void *fdt);
+int arch_fixup_memory_node(void *blob);
 
 #endif /* ifdef CONFIG_OF_LIBFDT */
 
index 2590d3071fd0353eb7e96f667e74bb089c3a476a..4ae77be9ba7c8bf09860606645db711db0911fb2 100644 (file)
@@ -40,6 +40,27 @@ struct fdt_memory {
        fdt_addr_t end;
 };
 
+/*
+ * Information about a resource. start is the first address of the resource
+ * and end is the last address (inclusive). The length of the resource will
+ * be equal to: end - start + 1.
+ */
+struct fdt_resource {
+       fdt_addr_t start;
+       fdt_addr_t end;
+};
+
+/**
+ * Compute the size of a resource.
+ *
+ * @param res  the resource to operate on
+ * @return the size of the resource
+ */
+static inline fdt_size_t fdt_resource_size(const struct fdt_resource *res)
+{
+       return res->end - res->start + 1;
+}
+
 /**
  * Compat types that we know about and for which we might have drivers.
  * Each is named COMPAT_<dir>_<filename> where <dir> is the directory
@@ -96,6 +117,7 @@ enum fdt_compat_id {
        COMPAT_NXP_PTN3460,             /* NXP PTN3460 DP/LVDS bridge */
        COMPAT_SAMSUNG_EXYNOS_SYSMMU,   /* Exynos sysmmu */
        COMPAT_PARADE_PS8625,           /* Parade PS8622 EDP->LVDS bridge */
+       COMPAT_INTEL_LPC,               /* Intel Low Pin Count I/F */
 
        COMPAT_COUNT,
 };
@@ -597,4 +619,46 @@ struct fmap_entry {
  */
 int fdtdec_read_fmap_entry(const void *blob, int node, const char *name,
                           struct fmap_entry *entry);
+
+/**
+ * Obtain an indexed resource from a device property.
+ *
+ * @param fdt          FDT blob
+ * @param node         node to examine
+ * @param property     name of the property to parse
+ * @param index                index of the resource to retrieve
+ * @param res          returns the resource
+ * @return 0 if ok, negative on error
+ */
+int fdt_get_resource(const void *fdt, int node, const char *property,
+                    unsigned int index, struct fdt_resource *res);
+
+/**
+ * Obtain a named resource from a device property.
+ *
+ * Look up the index of the name in a list of strings and return the resource
+ * at that index.
+ *
+ * @param fdt          FDT blob
+ * @param node         node to examine
+ * @param property     name of the property to parse
+ * @param prop_names   name of the property containing the list of names
+ * @param name         the name of the entry to look up
+ * @param res          returns the resource
+ */
+int fdt_get_named_resource(const void *fdt, int node, const char *property,
+                          const char *prop_names, const char *name,
+                          struct fdt_resource *res);
+
+/**
+ * Look at the reg property of a device node that represents a PCI device
+ * and parse the bus, device and function number from it.
+ *
+ * @param fdt          FDT blob
+ * @param node         node to examine
+ * @param bdf          returns bus, device, function triplet
+ * @return 0 if ok, negative on error
+ */
+int fdtdec_pci_get_bdf(const void *fdt, int node, int *bdf);
+
 #endif
index c2a48e0b37853bedfcf36ed9640bf4d850778084..d5e05e97cb2fb12dc68794a2f1032eb366c79f18 100644 (file)
@@ -23,6 +23,7 @@ extern ulong ide_bus_offset[];
 #define LED_IDE2       0x02
 #define        DEVICE_LED(d)   ((d & 2) | ((d & 2) == 0)) /* depends on bit positions! */
 
+void ide_led(uchar led, uchar status);
 #endif /* CONFIG_IDE_LED */
 
 #ifdef CONFIG_SYS_64BIT_LBA
index a1ef1e15df3ddbd8abec45766b9f9038f334bcc1..f3cbb637be419d16c35e59aec1aaf08f7819e310 100644 (file)
@@ -163,6 +163,31 @@ int fdt_first_subnode(const void *fdt, int offset);
  */
 int fdt_next_subnode(const void *fdt, int offset);
 
+/**
+ * fdt_for_each_subnode - iterate over all subnodes of a parent
+ *
+ * This is actually a wrapper around a for loop and would be used like so:
+ *
+ *     fdt_for_each_subnode(fdt, node, parent) {
+ *             ...
+ *             use node
+ *             ...
+ *     }
+ *
+ * Note that this is implemented as a macro and node is used as iterator in
+ * the loop. It should therefore be a locally allocated variable. The parent
+ * variable on the other hand is never modified, so it can be constant or
+ * even a literal.
+ *
+ * @fdt:       FDT blob (const void *)
+ * @node:      child node (int)
+ * @parent:    parent node (int)
+ */
+#define fdt_for_each_subnode(fdt, node, parent)                \
+       for (node = fdt_first_subnode(fdt, parent);     \
+            node >= 0;                                 \
+            node = fdt_next_subnode(fdt, node))
+
 /**********************************************************************/
 /* General functions                                                  */
 /**********************************************************************/
@@ -857,6 +882,53 @@ int fdt_node_offset_by_compatible(const void *fdt, int startoffset,
  */
 int fdt_stringlist_contains(const char *strlist, int listlen, const char *str);
 
+/**
+ * fdt_count_strings - count the number of strings in a string list
+ * @fdt: pointer to the device tree blob
+ * @node: offset of the node
+ * @property: name of the property containing the string list
+ * @return: the number of strings in the given property
+ */
+int fdt_count_strings(const void *fdt, int node, const char *property);
+
+/**
+ * fdt_find_string - find a string in a string list and return its index
+ * @fdt: pointer to the device tree blob
+ * @node: offset of the node
+ * @property: name of the property containing the string list
+ * @string: string to look up in the string list
+ * @return: the index of the string or negative on error
+ */
+int fdt_find_string(const void *fdt, int node, const char *property,
+                   const char *string);
+
+/**
+ * fdt_get_string_index() - obtain the string at a given index in a string list
+ * @fdt: pointer to the device tree blob
+ * @node: offset of the node
+ * @property: name of the property containing the string list
+ * @index: index of the string to return
+ * @output: return location for the string
+ * @return: 0 if the string was found or a negative error code otherwise
+ */
+int fdt_get_string_index(const void *fdt, int node, const char *property,
+                        int index, const char **output);
+
+/**
+ * fdt_get_string() - obtain the string at a given index in a string list
+ * @fdt: pointer to the device tree blob
+ * @node: offset of the node
+ * @property: name of the property containing the string list
+ * @output: return location for the string
+ * @return: 0 if the string was found or a negative error code otherwise
+ *
+ * This is a shortcut for:
+ *
+ *     fdt_get_string_index(fdt, node, property, 0, output).
+ */
+int fdt_get_string(const void *fdt, int node, const char *property,
+                  const char **output);
+
 /**********************************************************************/
 /* Read-only functions (addressing related)                           */
 /**********************************************************************/
diff --git a/include/linux/mbus.h b/include/linux/mbus.h
new file mode 100644 (file)
index 0000000..717cbea
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * Marvell MBUS common definitions.
+ *
+ * Copyright (C) 2008 Marvell Semiconductor
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2.  This program is licensed "as is" without any
+ * warranty of any kind, whether express or implied.
+ */
+
+#ifndef __LINUX_MBUS_H
+#define __LINUX_MBUS_H
+
+struct resource;
+
+struct mbus_dram_target_info {
+       /*
+        * The 4-bit MBUS target ID of the DRAM controller.
+        */
+       u8              mbus_dram_target_id;
+
+       /*
+        * The base address, size, and MBUS attribute ID for each
+        * of the possible DRAM chip selects.  Peripherals are
+        * required to support at least 4 decode windows.
+        */
+       int             num_cs;
+       struct mbus_dram_window {
+               u8      cs_index;
+               u8      mbus_attr;
+               u32     base;
+               u32     size;
+       } cs[4];
+};
+
+struct mvebu_mbus_state {
+       void __iomem *mbuswins_base;
+       void __iomem *sdramwins_base;
+       struct dentry *debugfs_root;
+       struct dentry *debugfs_sdram;
+       struct dentry *debugfs_devs;
+       const struct mvebu_mbus_soc_data *soc;
+       int hw_io_coherency;
+};
+
+/* Flags for PCI/PCIe address decoding regions */
+#define MVEBU_MBUS_PCI_IO  0x1
+#define MVEBU_MBUS_PCI_MEM 0x2
+#define MVEBU_MBUS_PCI_WA  0x3
+
+/*
+ * Magic value that explicits that we don't need a remapping-capable
+ * address decoding window.
+ */
+#define MVEBU_MBUS_NO_REMAP (0xffffffff)
+
+/* Maximum size of a mbus window name */
+#define MVEBU_MBUS_MAX_WINNAME_SZ 32
+
+const struct mbus_dram_target_info *mvebu_mbus_dram_info(void);
+void mvebu_mbus_get_pcie_mem_aperture(struct resource *res);
+void mvebu_mbus_get_pcie_io_aperture(struct resource *res);
+int mvebu_mbus_add_window_remap_by_id(unsigned int target,
+                                     unsigned int attribute,
+                                     phys_addr_t base, size_t size,
+                                     phys_addr_t remap);
+int mvebu_mbus_add_window_by_id(unsigned int target, unsigned int attribute,
+                               phys_addr_t base, size_t size);
+int mvebu_mbus_del_window(phys_addr_t base, size_t size);
+int mbus_dt_setup_win(struct mvebu_mbus_state *mbus,
+                     u32 base, u32 size, u8 target, u8 attr);
+
+#endif /* __LINUX_MBUS_H */
index 8e44855712c33be990b02ff0db8f70f67110d08d..96348d617fca34c4abfbf00759a84b8178d8aae9 100644 (file)
@@ -20,6 +20,10 @@ extern __kernel_size_t strspn(const char *,const char *);
  */
 #include <asm/string.h>
 
+#ifndef __HAVE_ARCH_BCOPY
+char *bcopy(const char *src, char *dest, int count);
+#endif
+
 #ifndef __HAVE_ARCH_STRCPY
 extern char * strcpy(char *,const char *);
 #endif
@@ -89,6 +93,9 @@ extern void * memchr(const void *,int,__kernel_size_t);
 void *memchr_inv(const void *, int, size_t);
 #endif
 
+unsigned long ustrtoul(const char *cp, char **endp, unsigned int base);
+unsigned long long ustrtoull(const char *cp, char **endp, unsigned int base);
+
 #ifdef __cplusplus
 }
 #endif
index 9f65ef96ac131912f32e49729752f33735dc61dd..075d222195ff25ea6b6addd703764452bd98e9fe 100644 (file)
@@ -14,6 +14,8 @@
 #define __deprecated
 #endif
 
+#include <linux/compat.h>
+
 /* The USB role is defined by the connector used on the board, so long as
  * standards are being followed.  (Developer boards sometimes won't.)
  */
index 7f5f9bc8ca86eb92614c24f951991f05d9dd64e5..d74a190eea066684a072e477a9fe52fb6640b20d 100644 (file)
@@ -387,6 +387,7 @@ int mmc_legacy_init(int verbose);
 
 int board_mmc_init(bd_t *bis);
 int cpu_mmc_init(bd_t *bis);
+int mmc_get_env_addr(struct mmc *mmc, int copy, u32 *env_addr);
 
 /* Set block count limit because of 16 bit register limit on some hardware*/
 #ifndef CONFIG_SYS_MMC_MAX_BLK_COUNT
index a887bfb5f7a0a927f0e86eecc1fd8283f3738140..34651ab3779014ce6ec96a83b41acc0a96e60c00 100644 (file)
@@ -65,6 +65,7 @@ int mpc512x_fec_initialize(bd_t *bis);
 int mpc5xxx_fec_initialize(bd_t *bis);
 int mpc82xx_scc_enet_initialize(bd_t *bis);
 int mvgbe_initialize(bd_t *bis);
+int mvneta_initialize(bd_t *bis, int base_addr, int devnum, int phy_addr);
 int natsemi_initialize(bd_t *bis);
 int ne2k_register(void);
 int npe_initialize(bd_t *bis);
index 5784cfd97b859407c9b32fc3c4246e0674c742fd..0607379537d7ccf1038a0d322fdf29d95fbc0df4 100644 (file)
@@ -53,7 +53,7 @@
  * @clock:             UART base clock speed in Hz
  */
 struct ns16550_platdata {
-       unsigned char *base;
+       unsigned long base;
        int reg_shift;
        int clock;
 };
index 2fcc328d5bcfcbb7eb5bd740ad79b01c52830134..b4950776977e5440a75873065b753c472798a73e 100644 (file)
@@ -32,7 +32,9 @@
 #define PHY_10G_FEATURES       (PHY_GBIT_FEATURES | \
                                SUPPORTED_10000baseT_Full)
 
+#ifndef PHY_ANEG_TIMEOUT
 #define PHY_ANEG_TIMEOUT       4000
+#endif
 
 
 typedef enum {
index a7e41da7fd4980ef2362816a63d8680cc26ef1b9..cee251faf7dcec67794b0d24f3e2b4a9fea514fb 100644 (file)
@@ -72,6 +72,8 @@ void spl_sata_load_image(void);
 int spl_load_image_fat(block_dev_desc_t *block_dev, int partition, const char *filename);
 int spl_load_image_fat_os(block_dev_desc_t *block_dev, int partition);
 
+void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image);
+
 #ifdef CONFIG_SPL_BOARD_INIT
 void spl_board_init(void);
 #endif
index c355fbe4819836a18bcfacd94c592feb612fcdd3..c4a288d5e9f804bbbda4ac9c8c24f13d1bd59c55 100644 (file)
@@ -150,7 +150,8 @@ 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_MUSB_OMAP2PLUS) || 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);
index 88e5da72ecc6ffe619a337b981dcb6c6af206c9a..8460439d8e772d4126b78ad616059dd38a7dabff 100644 (file)
@@ -8,4 +8,23 @@ config CC_OPTIMIZE_LIBS_FOR_SPEED
 
          If unsure, say N.
 
+config HAVE_PRIVATE_LIBGCC
+       bool
+
+config USE_PRIVATE_LIBGCC
+       bool "Use private libgcc"
+       depends on HAVE_PRIVATE_LIBGCC
+       help
+         This option allows you to use the built-in libgcc implementation
+         of U-boot instead of the one privided by the compiler.
+         If unsure, say N.
+
+config SYS_HZ
+       int
+       default 1000
+       help
+         The frequency of the timer returned by get_timer().
+         get_timer() must operate in milliseconds and this option must be
+         set to 1000.
+
 endmenu
index 06d4542029623cb7d84f764c57fb805bc84f5cd6..9714620ab3e211df006d440dc4f1abb6d03bb9b8 100644 (file)
@@ -72,6 +72,7 @@ static const char * const compat_names[COMPAT_COUNT] = {
        COMPAT(COMPAT_NXP_PTN3460, "nxp,ptn3460"),
        COMPAT(SAMSUNG_EXYNOS_SYSMMU, "samsung,sysmmu-v3.3"),
        COMPAT(PARADE_PS8625, "parade,ps8625"),
+       COMPAT(COMPAT_INTEL_LPC, "intel,lpc"),
 };
 
 const char *fdtdec_get_compatible(enum fdt_compat_id id)
@@ -708,4 +709,75 @@ int fdtdec_read_fmap_entry(const void *blob, int node, const char *name,
 
        return 0;
 }
+
+static u64 fdtdec_get_number(const fdt32_t *ptr, unsigned int cells)
+{
+       u64 number = 0;
+
+       while (cells--)
+               number = (number << 32) | fdt32_to_cpu(*ptr++);
+
+       return number;
+}
+
+int fdt_get_resource(const void *fdt, int node, const char *property,
+                    unsigned int index, struct fdt_resource *res)
+{
+       const fdt32_t *ptr, *end;
+       int na, ns, len, parent;
+       unsigned int i = 0;
+
+       parent = fdt_parent_offset(fdt, node);
+       if (parent < 0)
+               return parent;
+
+       na = fdt_address_cells(fdt, parent);
+       ns = fdt_size_cells(fdt, parent);
+
+       ptr = fdt_getprop(fdt, node, property, &len);
+       if (!ptr)
+               return len;
+
+       end = ptr + len / sizeof(*ptr);
+
+       while (ptr + na + ns <= end) {
+               if (i == index) {
+                       res->start = res->end = fdtdec_get_number(ptr, na);
+                       res->end += fdtdec_get_number(&ptr[na], ns) - 1;
+                       return 0;
+               }
+
+               ptr += na + ns;
+               i++;
+       }
+
+       return -FDT_ERR_NOTFOUND;
+}
+
+int fdt_get_named_resource(const void *fdt, int node, const char *property,
+                          const char *prop_names, const char *name,
+                          struct fdt_resource *res)
+{
+       int index;
+
+       index = fdt_find_string(fdt, node, prop_names, name);
+       if (index < 0)
+               return index;
+
+       return fdt_get_resource(fdt, node, property, index, res);
+}
+
+int fdtdec_pci_get_bdf(const void *fdt, int node, int *bdf)
+{
+       const fdt32_t *prop;
+       int len;
+
+       prop = fdt_getprop(fdt, node, "reg", &len);
+       if (!prop)
+               return len;
+
+       *bdf = fdt32_to_cpu(*prop) & 0xffffff;
+
+       return 0;
+}
 #endif
index 36af0435254b47cb0d2599836d1c81638266adf8..03733e574f71db1df2ebec2c08ec66dff95908d0 100644 (file)
@@ -491,6 +491,82 @@ int fdt_stringlist_contains(const char *strlist, int listlen, const char *str)
        return 0;
 }
 
+int fdt_count_strings(const void *fdt, int node, const char *property)
+{
+       int length, i, count = 0;
+       const char *list;
+
+       list = fdt_getprop(fdt, node, property, &length);
+       if (!list)
+               return -length;
+
+       for (i = 0; i < length; i++) {
+               int len = strlen(list);
+
+               list += len + 1;
+               i += len;
+               count++;
+       }
+
+       return count;
+}
+
+int fdt_find_string(const void *fdt, int node, const char *property,
+                   const char *string)
+{
+       const char *list, *end;
+       int len, index = 0;
+
+       list = fdt_getprop(fdt, node, property, &len);
+       if (!list)
+               return len;
+
+       end = list + len;
+       len = strlen(string);
+
+       while (list < end) {
+               int l = strlen(list);
+
+               if (l == len && memcmp(list, string, len) == 0)
+                       return index;
+
+               list += l + 1;
+               index++;
+       }
+
+       return -FDT_ERR_NOTFOUND;
+}
+
+int fdt_get_string_index(const void *fdt, int node, const char *property,
+                        int index, const char **output)
+{
+       const char *list;
+       int length, i;
+
+       list = fdt_getprop(fdt, node, property, &length);
+
+       for (i = 0; i < length; i++) {
+               int len = strlen(list);
+
+               if (index == 0) {
+                       *output = list;
+                       return 0;
+               }
+
+               list += len + 1;
+               i += len;
+               index--;
+       }
+
+       return FDT_ERR_NOTFOUND;
+}
+
+int fdt_get_string(const void *fdt, int node, const char *property,
+                  const char **output)
+{
+       return fdt_get_string_index(fdt, node, property, 0, output);
+}
+
 int fdt_node_check_compatible(const void *fdt, int nodeoffset,
                              const char *compatible)
 {
index 41a2be463565c6b519841902cba45b43839ef69a..031f0e1ac895289f772fb4bf538626ff065d1106 100644 (file)
--- a/lib/lmb.c
+++ b/lib/lmb.c
@@ -236,7 +236,7 @@ long lmb_reserve(struct lmb *lmb, phys_addr_t base, phys_size_t size)
        return lmb_add_region(_rgn, base, size);
 }
 
-long lmb_overlaps_region(struct lmb_region *rgn, phys_addr_t base,
+static long lmb_overlaps_region(struct lmb_region *rgn, phys_addr_t base,
                                phys_size_t size)
 {
        unsigned long i;
index c7b026498be67e28f02cf070acf73a43e3c18ad4..5ebd1be48f324f8e9f21157ddd1b38f2dc85570a 100644 (file)
 #include <div64.h>
 #include <asm/io.h>
 
-#if CONFIG_SYS_HZ != 1000
-#warning "CONFIG_SYS_HZ must be 1000 and should not be defined by platforms"
-#endif
-
 #ifndef CONFIG_WD_PERIOD
 # define CONFIG_WD_PERIOD      (10 * 1000 * 1000)      /* 10 seconds default */
 #endif
index 76ffa05608adcaffb9bf3f888b4983a6a17cfcd4..eac4f7b3d0ed602c852d0f47dd9580670f8292da 100644 (file)
--- a/net/eth.c
+++ b/net/eth.c
@@ -153,7 +153,7 @@ static void eth_current_changed(void)
                setenv("ethact", NULL);
 }
 
-int eth_address_set(unsigned char *addr)
+static int eth_address_set(unsigned char *addr)
 {
        return memcmp(addr, "\0\0\0\0\0\0", 6);
 }
index 966d1cfba360ce7e7505dd5f806ce13543b0654c..0a2c53302cab1edacacd88f439b888f4837e7d4a 100644 (file)
@@ -299,6 +299,8 @@ static void tftp_complete(void)
                putc('#');
                TftpNumchars++;
        }
+       puts("  ");
+       print_size(TftpTsize, "");
 #endif
        time_start = get_timer(time_start);
        if (time_start > 0) {
index 4af5355fa5a20f9c2e763f37b269bea38d43e8ea..4194edb89e86fe2db008767dd33bd7faf4e32b79 100644 (file)
@@ -52,7 +52,7 @@ int post_init_f(void)
  * Boards with hotkey support can override this weak default function
  * by defining one in their board specific code.
  */
-int __post_hotkeys_pressed(void)
+__weak int post_hotkeys_pressed(void)
 {
 #ifdef CONFIG_SYS_POST_HOTKEYS_GPIO
        int ret;
@@ -73,9 +73,6 @@ int __post_hotkeys_pressed(void)
 
        return 0;       /* No hotkeys supported */
 }
-int post_hotkeys_pressed(void)
-       __attribute__((weak, alias("__post_hotkeys_pressed")));
-
 
 void post_bootmode_init(void)
 {
@@ -236,11 +233,9 @@ static void post_get_flags(int *test_flags)
                        test_flags[j] |= POST_SLOWTEST;
 }
 
-void __show_post_progress(unsigned int test_num, int before, int result)
+__weak void show_post_progress(unsigned int test_num, int before, int result)
 {
 }
-void show_post_progress(unsigned int, int, int)
-                       __attribute__((weak, alias("__show_post_progress")));
 
 static int post_run_single(struct post_test *test,
                                int test_flags, int flags, unsigned int i)
index 88c01d18ecf9a94fbee9b6cd273c7b6c3285fe3d..7afe437e62e11b1ed25f13c909fff68263957948 100644 (file)
@@ -216,13 +216,13 @@ $(obj)/sunxi-spl.bin: $(obj)/$(SPL_BIN).bin
 endif
 
 quiet_cmd_u-boot-spl = LD      $@
-      cmd_u-boot-spl = cd $(obj) && $(LD) $(LDFLAGS) $(LDFLAGS_$(@F)) \
+      cmd_u-boot-spl = (cd $(obj) && $(LD) $(LDFLAGS) $(LDFLAGS_$(@F)) \
                       $(patsubst $(obj)/%,%,$(u-boot-spl-init)) --start-group \
                       $(patsubst $(obj)/%,%,$(u-boot-spl-main)) --end-group \
-                      $(PLATFORM_LIBS) -Map $(SPL_BIN).map -o $(SPL_BIN)
+                      $(PLATFORM_LIBS) -Map $(SPL_BIN).map -o $(SPL_BIN))
 
-$(obj)/$(SPL_BIN): $(u-boot-spl-init) $(u-boot-spl-main) $(obj)/u-boot-spl.lds
-       $(call cmd,u-boot-spl)
+$(obj)/$(SPL_BIN): $(u-boot-spl-init) $(u-boot-spl-main) $(obj)/u-boot-spl.lds FORCE
+       $(call if_changed,u-boot-spl)
 
 $(sort $(u-boot-spl-init) $(u-boot-spl-main)): $(u-boot-spl-dirs) ;
 
index 3a963c7973da5da0e37c0ac350ea7e4b1e2d59e1..3e3040b2e2ab9210ebef73859b93e158d2875ecc 100644 (file)
@@ -297,9 +297,24 @@ do_others () {
        else
                objdir=${1%/*}
                check_enabled_subimage $1 $objdir
+
+               if [ -f "$objdir/$KCONFIG_CONFIG" ]; then
+                       timestamp_before=$(stat --printf="%Y" \
+                                               $objdir/$KCONFIG_CONFIG)
+               fi
        fi
 
        run_make_config $target $objdir
+
+       if [ "$timestamp_before" -a -f "$objdir/$KCONFIG_CONFIG" ]; then
+               timestamp_after=$(stat --printf="%Y" $objdir/$KCONFIG_CONFIG)
+
+               if [ "$timestamp_after" -gt "$timestamp_before" ]; then
+                       # $objdir/.config has been updated.
+                       # touch .config to invoke "make silentoldconfig"
+                       touch $KCONFIG_CONFIG
+               fi
+       fi
 }
 
 progname=$(basename $0)
index b0cfb42c85fc692a5d5ffb0ef11d22d5f5bcea90..ff5c2a749c5e37dbbcca5340dabdf18374a8e5c2 100644 (file)
@@ -67,6 +67,34 @@ static struct driver_info driver_info_pre_reloc = {
        .platdata = &test_pdata_manual,
 };
 
+void dm_leak_check_start(struct dm_test_state *dms)
+{
+       dms->start = mallinfo();
+       if (!dms->start.uordblks)
+               puts("Warning: Please add '#define DEBUG' to the top of common/dlmalloc.c\n");
+}
+
+int dm_leak_check_end(struct dm_test_state *dms)
+{
+       struct mallinfo end;
+       int id;
+
+       /* Don't delete the root class, since we started with that */
+       for (id = UCLASS_ROOT + 1; id < UCLASS_COUNT; id++) {
+               struct uclass *uc;
+
+               uc = uclass_find(id);
+               if (!uc)
+                       continue;
+               ut_assertok(uclass_destroy(uc));
+       }
+
+       end = mallinfo();
+       ut_asserteq(dms->start.uordblks, end.uordblks);
+
+       return 0;
+}
+
 /* Test that binding with platdata occurs correctly */
 static int dm_test_autobind(struct dm_test_state *dms)
 {
@@ -377,14 +405,11 @@ static int dm_test_leak(struct dm_test_state *dms)
        int i;
 
        for (i = 0; i < 2; i++) {
-               struct mallinfo start, end;
                struct udevice *dev;
                int ret;
                int id;
 
-               start = mallinfo();
-               if (!start.uordblks)
-                       puts("Warning: Please add '#define DEBUG' to the top of common/dlmalloc.c\n");
+               dm_leak_check_start(dms);
 
                ut_assertok(dm_scan_platdata(false));
                ut_assertok(dm_scan_fdt(gd->fdt_blob, false));
@@ -398,18 +423,7 @@ static int dm_test_leak(struct dm_test_state *dms)
                        ut_assertok(ret);
                }
 
-               /* Don't delete the root class, since we started with that */
-               for (id = UCLASS_ROOT + 1; id < UCLASS_COUNT; id++) {
-                       struct uclass *uc;
-
-                       uc = uclass_find(id);
-                       if (!uc)
-                               continue;
-                       ut_assertok(uclass_destroy(uc));
-               }
-
-               end = mallinfo();
-               ut_asserteq(start.uordblks, end.uordblks);
+               ut_assertok(dm_leak_check_end(dms));
        }
 
        return 0;
index 2b2b0b51fa74571a0e0ca200574bef48c0d7dee7..94bd0d99dc0bc1fa9b5c7033690ab6de7cc29b41 100644 (file)
@@ -7,11 +7,14 @@
 #include <common.h>
 #include <fdtdec.h>
 #include <dm.h>
+#include <dm/root.h>
 #include <dm/ut.h>
 #include <dm/test.h>
 #include <dm/util.h>
 #include <asm/gpio.h>
 
+DECLARE_GLOBAL_DATA_PTR;
+
 /* Test that sandbox GPIOs work correctly */
 static int dm_test_gpio(struct dm_test_state *dms)
 {
@@ -39,52 +42,51 @@ static int dm_test_gpio(struct dm_test_state *dms)
 
        /* Get the operations for this device */
        ops = gpio_get_ops(dev);
-       ut_assert(ops->get_state);
+       ut_assert(ops->get_function);
 
        /* Cannot get a value until it is reserved */
-       ut_asserteq(-1, ops->get_value(dev, offset));
-
+       ut_asserteq(-EBUSY, gpio_get_value(gpio + 1));
        /*
         * Now some tests that use the 'sandbox' back door. All GPIOs
         * should default to input, include b4 that we are using here.
         */
-       ut_assertok(ops->get_state(dev, offset, buf, sizeof(buf)));
-       ut_asserteq_str("b4:  in: 0 [ ]", buf);
+       ut_assertok(gpio_get_status(dev, offset, buf, sizeof(buf)));
+       ut_asserteq_str("b4: input: 0 [ ]", buf);
 
        /* Change it to an output */
        sandbox_gpio_set_direction(dev, offset, 1);
-       ut_assertok(ops->get_state(dev, offset, buf, sizeof(buf)));
-       ut_asserteq_str("b4: out: 0 [ ]", buf);
+       ut_assertok(gpio_get_status(dev, offset, buf, sizeof(buf)));
+       ut_asserteq_str("b4: output: 0 [ ]", buf);
 
        sandbox_gpio_set_value(dev, offset, 1);
-       ut_assertok(ops->get_state(dev, offset, buf, sizeof(buf)));
-       ut_asserteq_str("b4: out: 1 [ ]", buf);
+       ut_assertok(gpio_get_status(dev, offset, buf, sizeof(buf)));
+       ut_asserteq_str("b4: output: 1 [ ]", buf);
 
-       ut_assertok(ops->request(dev, offset, "testing"));
-       ut_assertok(ops->get_state(dev, offset, buf, sizeof(buf)));
-       ut_asserteq_str("b4: out: 1 [x] testing", buf);
+       ut_assertok(gpio_request(gpio, "testing"));
+       ut_assertok(gpio_get_status(dev, offset, buf, sizeof(buf)));
+       ut_asserteq_str("b4: output: 1 [x] testing", buf);
 
        /* Change the value a bit */
        ut_asserteq(1, ops->get_value(dev, offset));
        ut_assertok(ops->set_value(dev, offset, 0));
        ut_asserteq(0, ops->get_value(dev, offset));
-       ut_assertok(ops->get_state(dev, offset, buf, sizeof(buf)));
-       ut_asserteq_str("b4: out: 0 [x] testing", buf);
+       ut_assertok(gpio_get_status(dev, offset, buf, sizeof(buf)));
+       ut_asserteq_str("b4: output: 0 [x] testing", buf);
        ut_assertok(ops->set_value(dev, offset, 1));
        ut_asserteq(1, ops->get_value(dev, offset));
 
        /* Make it an input */
        ut_assertok(ops->direction_input(dev, offset));
-       ut_assertok(ops->get_state(dev, offset, buf, sizeof(buf)));
-       ut_asserteq_str("b4:  in: 1 [x] testing", buf);
+       ut_assertok(gpio_get_status(dev, offset, buf, sizeof(buf)));
+       ut_asserteq_str("b4: input: 1 [x] testing", buf);
        sandbox_gpio_set_value(dev, offset, 0);
        ut_asserteq(0, sandbox_gpio_get_value(dev, offset));
-       ut_assertok(ops->get_state(dev, offset, buf, sizeof(buf)));
-       ut_asserteq_str("b4:  in: 0 [x] testing", buf);
+       ut_assertok(gpio_get_status(dev, offset, buf, sizeof(buf)));
+       ut_asserteq_str("b4: input: 0 [x] testing", buf);
 
-       ut_assertok(ops->free(dev, offset));
-       ut_assertok(ops->get_state(dev, offset, buf, sizeof(buf)));
-       ut_asserteq_str("b4:  in: 0 [ ]", buf);
+       ut_assertok(gpio_free(gpio));
+       ut_assertok(gpio_get_status(dev, offset, buf, sizeof(buf)));
+       ut_asserteq_str("b4: input: 0 [ ]", buf);
 
        /* Check the 'a' bank also */
        ut_assertok(gpio_lookup_name("a15", &dev, &offset, &gpio));
@@ -96,6 +98,18 @@ static int dm_test_gpio(struct dm_test_state *dms)
        ut_asserteq_str("a", name);
        ut_asserteq(20, offset_count);
 
+       return 0;
+}
+DM_TEST(dm_test_gpio, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+
+/* Test that sandbox anonymous GPIOs work correctly */
+static int dm_test_gpio_anon(struct dm_test_state *dms)
+{
+       unsigned int offset, gpio;
+       struct udevice *dev;
+       const char *name;
+       int offset_count;
+
        /* And the anonymous bank */
        ut_assertok(gpio_lookup_name("14", &dev, &offset, &gpio));
        ut_asserteq_str(dev->name, "gpio_sandbox");
@@ -108,4 +122,57 @@ static int dm_test_gpio(struct dm_test_state *dms)
 
        return 0;
 }
-DM_TEST(dm_test_gpio, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_gpio_anon, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+
+/* Test that gpio_requestf() works as expected */
+static int dm_test_gpio_requestf(struct dm_test_state *dms)
+{
+       unsigned int offset, gpio;
+       struct udevice *dev;
+       char buf[80];
+
+       ut_assertok(gpio_lookup_name("b5", &dev, &offset, &gpio));
+       ut_assertok(gpio_requestf(gpio, "testing %d %s", 1, "hi"));
+       sandbox_gpio_set_direction(dev, offset, 1);
+       sandbox_gpio_set_value(dev, offset, 1);
+       ut_assertok(gpio_get_status(dev, offset, buf, sizeof(buf)));
+       ut_asserteq_str("b5: output: 1 [x] testing 1 hi", buf);
+
+       return 0;
+}
+DM_TEST(dm_test_gpio_requestf, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+
+/* Test that gpio_request() copies its string */
+static int dm_test_gpio_copy(struct dm_test_state *dms)
+{
+       unsigned int offset, gpio;
+       struct udevice *dev;
+       char buf[80], name[10];
+
+       ut_assertok(gpio_lookup_name("b6", &dev, &offset, &gpio));
+       strcpy(name, "odd_name");
+       ut_assertok(gpio_request(gpio, name));
+       sandbox_gpio_set_direction(dev, offset, 1);
+       sandbox_gpio_set_value(dev, offset, 1);
+       ut_assertok(gpio_get_status(dev, offset, buf, sizeof(buf)));
+       ut_asserteq_str("b6: output: 1 [x] odd_name", buf);
+       strcpy(name, "nothing");
+       ut_assertok(gpio_get_status(dev, offset, buf, sizeof(buf)));
+       ut_asserteq_str("b6: output: 1 [x] odd_name", buf);
+
+       return 0;
+}
+DM_TEST(dm_test_gpio_copy, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+
+/* Test that we don't leak memory with GPIOs */
+static int dm_test_gpio_leak(struct dm_test_state *dms)
+{
+       ut_assertok(dm_test_gpio(dms));
+       ut_assertok(dm_test_gpio_anon(dms));
+       ut_assertok(dm_test_gpio_requestf(dms));
+       ut_assertok(dm_leak_check_end(dms));
+
+       return 0;
+}
+
+DM_TEST(dm_test_gpio_leak, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
index 94ce72abfd5ced11313480ba736c88d65e01d862..90ca81092f721052df78504e7ffeb0a3a76817ef 100644 (file)
@@ -7,6 +7,7 @@
 #include <common.h>
 #include <dm.h>
 #include <errno.h>
+#include <malloc.h>
 #include <dm/test.h>
 #include <dm/root.h>
 #include <dm/uclass-internal.h>
@@ -88,6 +89,7 @@ int dm_test_main(void)
                printf("Test: %s\n", test->name);
                ut_assertok(dm_test_init(dms));
 
+               dms->start = mallinfo();
                if (test->flags & DM_TESTF_SCAN_PDATA)
                        ut_assertok(dm_scan_platdata(false));
                if (test->flags & DM_TESTF_PROBE_TEST)
index 2b05b202a07276a3581b956e33d00a73a5d6278e..3b95964fd15cb1494c64ea6de43058b87ebaa584 100644 (file)
@@ -140,6 +140,7 @@ ubsha1-objs := os_support.o ubsha1.o lib/sha1.o
 HOSTCFLAGS_ubsha1.o := -pedantic
 
 hostprogs-$(CONFIG_KIRKWOOD) += kwboot
+hostprogs-$(CONFIG_ARMADA_XP) += kwboot
 hostprogs-y += proftool
 hostprogs-$(CONFIG_STATIC_RELA) += relocate-rela
 
index 109d61686ec69fc958bd3b66995c83c412164eaa..1120e9b3729024fc851ddba5a3410dcc92cf29d1 100644 (file)
 /*
- * (C) Copyright 2008
- * Marvell Semiconductor <www.marvell.com>
- * Written-by: Prafulla Wadaskar <prafulla@marvell.com>
+ * Image manipulator for Marvell SoCs
+ *  supports Kirkwood, Dove, Armada 370, and Armada XP
+ *
+ * (C) Copyright 2013 Thomas Petazzoni
+ * <thomas.petazzoni@free-electrons.com>
  *
  * SPDX-License-Identifier:    GPL-2.0+
+ *
+ * Not implemented: support for the register headers and secure
+ * headers in v1 images
  */
 
 #include "imagetool.h"
 #include <image.h>
+#include <stdint.h>
 #include "kwbimage.h"
 
-/*
- * Supported commands for configuration file
- */
-static table_entry_t kwbimage_cmds[] = {
-       {CMD_BOOT_FROM,         "BOOT_FROM",            "boot command", },
-       {CMD_NAND_ECC_MODE,     "NAND_ECC_MODE",        "NAND mode",    },
-       {CMD_NAND_PAGE_SIZE,    "NAND_PAGE_SIZE",       "NAND size",    },
-       {CMD_SATA_PIO_MODE,     "SATA_PIO_MODE",        "SATA mode",    },
-       {CMD_DDR_INIT_DELAY,    "DDR_INIT_DELAY",       "DDR init dly", },
-       {CMD_DATA,              "DATA",                 "Reg Write Data", },
-       {CMD_INVALID,           "",                     "",     },
+#define ALIGN_SUP(x, a) (((x) + (a - 1)) & ~(a - 1))
+
+/* Structure of the main header, version 0 (Kirkwood, Dove) */
+struct main_hdr_v0 {
+       uint8_t  blockid;               /*0     */
+       uint8_t  nandeccmode;           /*1     */
+       uint16_t nandpagesize;          /*2-3   */
+       uint32_t blocksize;             /*4-7   */
+       uint32_t rsvd1;                 /*8-11  */
+       uint32_t srcaddr;               /*12-15 */
+       uint32_t destaddr;              /*16-19 */
+       uint32_t execaddr;              /*20-23 */
+       uint8_t  satapiomode;           /*24    */
+       uint8_t  rsvd3;                 /*25    */
+       uint16_t ddrinitdelay;          /*26-27 */
+       uint16_t rsvd2;                 /*28-29 */
+       uint8_t  ext;                   /*30    */
+       uint8_t  checksum;              /*31    */
+};
+
+struct ext_hdr_v0_reg {
+       uint32_t raddr;
+       uint32_t rdata;
+};
+
+#define EXT_HDR_V0_REG_COUNT ((0x1dc - 0x20) / sizeof(struct ext_hdr_v0_reg))
+
+struct ext_hdr_v0 {
+       uint32_t              offset;
+       uint8_t               reserved[0x20 - sizeof(uint32_t)];
+       struct ext_hdr_v0_reg rcfg[EXT_HDR_V0_REG_COUNT];
+       uint8_t               reserved2[7];
+       uint8_t               checksum;
+};
+
+/* Structure of the main header, version 1 (Armada 370, Armada XP) */
+struct main_hdr_v1 {
+       uint8_t  blockid;               /* 0 */
+       uint8_t  reserved1;             /* 1 */
+       uint16_t reserved2;             /* 2-3 */
+       uint32_t blocksize;             /* 4-7 */
+       uint8_t  version;               /* 8 */
+       uint8_t  headersz_msb;          /* 9 */
+       uint16_t headersz_lsb;          /* A-B */
+       uint32_t srcaddr;               /* C-F */
+       uint32_t destaddr;              /* 10-13 */
+       uint32_t execaddr;              /* 14-17 */
+       uint8_t  reserved3;             /* 18 */
+       uint8_t  nandblocksize;         /* 19 */
+       uint8_t  nandbadblklocation;    /* 1A */
+       uint8_t  reserved4;             /* 1B */
+       uint16_t reserved5;             /* 1C-1D */
+       uint8_t  ext;                   /* 1E */
+       uint8_t  checksum;              /* 1F */
 };
 
 /*
- * Supported Boot options for configuration file
+ * Header for the optional headers, version 1 (Armada 370, Armada XP)
  */
-static table_entry_t kwbimage_bootops[] = {
-       {IBR_HDR_SPI_ID,        "spi",          "SPI Flash",    },
-       {IBR_HDR_NAND_ID,       "nand",         "NAND Flash",   },
-       {IBR_HDR_SATA_ID,       "sata",         "Sata port",    },
-       {IBR_HDR_PEX_ID,        "pex",          "PCIe port",    },
-       {IBR_HDR_UART_ID,       "uart",         "Serial port",  },
-       {-1,                    "",             "Invalid",      },
+struct opt_hdr_v1 {
+       uint8_t  headertype;
+       uint8_t  headersz_msb;
+       uint16_t headersz_lsb;
+       char     data[0];
 };
 
 /*
- * Supported NAND ecc options configuration file
+ * Various values for the opt_hdr_v1->headertype field, describing the
+ * different types of optional headers. The "secure" header contains
+ * informations related to secure boot (encryption keys, etc.). The
+ * "binary" header contains ARM binary code to be executed prior to
+ * executing the main payload (usually the bootloader). This is
+ * typically used to execute DDR3 training code. The "register" header
+ * allows to describe a set of (address, value) tuples that are
+ * generally used to configure the DRAM controller.
  */
-static table_entry_t kwbimage_eccmodes[] = {
-       {IBR_HDR_ECC_DEFAULT,           "default",      "Default mode", },
-       {IBR_HDR_ECC_FORCED_HAMMING,    "hamming",      "Hamming mode", },
-       {IBR_HDR_ECC_FORCED_RS,         "rs",           "RS mode",      },
-       {IBR_HDR_ECC_DISABLED,          "disabled",     "ECC Disabled", },
-       {-1,                            "",             "",     },
+#define OPT_HDR_V1_SECURE_TYPE   0x1
+#define OPT_HDR_V1_BINARY_TYPE   0x2
+#define OPT_HDR_V1_REGISTER_TYPE 0x3
+
+#define KWBHEADER_V1_SIZE(hdr) \
+       (((hdr)->headersz_msb << 16) | (hdr)->headersz_lsb)
+
+static struct image_cfg_element *image_cfg;
+static int cfgn;
+
+struct boot_mode {
+       unsigned int id;
+       const char *name;
+};
+
+struct boot_mode boot_modes[] = {
+       { 0x4D, "i2c"  },
+       { 0x5A, "spi"  },
+       { 0x8B, "nand" },
+       { 0x78, "sata" },
+       { 0x9C, "pex"  },
+       { 0x69, "uart" },
+       {},
 };
 
-static struct kwb_header kwbimage_header;
-static int datacmd_cnt = 0;
-static char * fname = "Unknown";
-static int lineno = -1;
+struct nand_ecc_mode {
+       unsigned int id;
+       const char *name;
+};
+
+struct nand_ecc_mode nand_ecc_modes[] = {
+       { 0x00, "default" },
+       { 0x01, "hamming" },
+       { 0x02, "rs" },
+       { 0x03, "disabled" },
+       {},
+};
+
+/* Used to identify an undefined execution or destination address */
+#define ADDR_INVALID ((uint32_t)-1)
+
+#define BINARY_MAX_ARGS 8
+
+/* In-memory representation of a line of the configuration file */
+struct image_cfg_element {
+       enum {
+               IMAGE_CFG_VERSION = 0x1,
+               IMAGE_CFG_BOOT_FROM,
+               IMAGE_CFG_DEST_ADDR,
+               IMAGE_CFG_EXEC_ADDR,
+               IMAGE_CFG_NAND_BLKSZ,
+               IMAGE_CFG_NAND_BADBLK_LOCATION,
+               IMAGE_CFG_NAND_ECC_MODE,
+               IMAGE_CFG_NAND_PAGESZ,
+               IMAGE_CFG_BINARY,
+               IMAGE_CFG_PAYLOAD,
+               IMAGE_CFG_DATA,
+       } type;
+       union {
+               unsigned int version;
+               unsigned int bootfrom;
+               struct {
+                       const char *file;
+                       unsigned int args[BINARY_MAX_ARGS];
+                       unsigned int nargs;
+               } binary;
+               const char *payload;
+               unsigned int dstaddr;
+               unsigned int execaddr;
+               unsigned int nandblksz;
+               unsigned int nandbadblklocation;
+               unsigned int nandeccmode;
+               unsigned int nandpagesz;
+               struct ext_hdr_v0_reg regdata;
+       };
+};
+
+#define IMAGE_CFG_ELEMENT_MAX 256
 
 /*
- * Report Error if xflag is set in addition to default
+ * Byte 8 of the image header contains the version number. In the v0
+ * header, byte 8 was reserved, and always set to 0. In the v1 header,
+ * byte 8 has been changed to a proper field, set to 1.
  */
-static int kwbimage_check_params(struct image_tool_params *params)
+static unsigned int image_version(void *header)
 {
-       if (!strlen (params->imagename)) {
-               printf ("Error:%s - Configuration file not specified, "
-                       "it is needed for kwbimage generation\n",
-                       params->cmdname);
-               return CFG_INVALID;
-       }
-       return  ((params->dflag && (params->fflag || params->lflag)) ||
-               (params->fflag && (params->dflag || params->lflag)) ||
-               (params->lflag && (params->dflag || params->fflag)) ||
-               (params->xflag) || !(strlen (params->imagename)));
+       unsigned char *ptr = header;
+       return ptr[8];
+}
+
+/*
+ * Utility functions to manipulate boot mode and ecc modes (convert
+ * them back and forth between description strings and the
+ * corresponding numerical identifiers).
+ */
+
+static const char *image_boot_mode_name(unsigned int id)
+{
+       int i;
+       for (i = 0; boot_modes[i].name; i++)
+               if (boot_modes[i].id == id)
+                       return boot_modes[i].name;
+       return NULL;
+}
+
+int image_boot_mode_id(const char *boot_mode_name)
+{
+       int i;
+       for (i = 0; boot_modes[i].name; i++)
+               if (!strcmp(boot_modes[i].name, boot_mode_name))
+                       return boot_modes[i].id;
+
+       return -1;
+}
+
+int image_nand_ecc_mode_id(const char *nand_ecc_mode_name)
+{
+       int i;
+       for (i = 0; nand_ecc_modes[i].name; i++)
+               if (!strcmp(nand_ecc_modes[i].name, nand_ecc_mode_name))
+                       return nand_ecc_modes[i].id;
+       return -1;
 }
 
-static uint32_t check_get_hexval (char *token)
+static struct image_cfg_element *
+image_find_option(unsigned int optiontype)
 {
-       uint32_t hexval;
+       int i;
 
-       if (!sscanf (token, "%x", &hexval)) {
-               printf ("Error:%s[%d] - Invalid hex data(%s)\n", fname,
-                       lineno, token);
-               exit (EXIT_FAILURE);
+       for (i = 0; i < cfgn; i++) {
+               if (image_cfg[i].type == optiontype)
+                       return &image_cfg[i];
        }
-       return hexval;
+
+       return NULL;
+}
+
+static unsigned int
+image_count_options(unsigned int optiontype)
+{
+       int i;
+       unsigned int count = 0;
+
+       for (i = 0; i < cfgn; i++)
+               if (image_cfg[i].type == optiontype)
+                       count++;
+
+       return count;
 }
 
 /*
- * Generates 8 bit checksum
+ * Compute a 8-bit checksum of a memory area. This algorithm follows
+ * the requirements of the Marvell SoC BootROM specifications.
  */
-static uint8_t kwbimage_checksum8 (void *start, uint32_t len, uint8_t csum)
+static uint8_t image_checksum8(void *start, uint32_t len)
 {
-       register uint8_t sum = csum;
-       volatile uint8_t *p = (volatile uint8_t *)start;
+       uint8_t csum = 0;
+       uint8_t *p = start;
 
        /* check len and return zero checksum if invalid */
        if (!len)
                return 0;
 
        do {
-               sum += *p;
+               csum += *p;
                p++;
        } while (--len);
-       return (sum);
+
+       return csum;
 }
 
-/*
- * Generates 32 bit checksum
- */
-static uint32_t kwbimage_checksum32 (uint32_t *start, uint32_t len, uint32_t csum)
+static uint32_t image_checksum32(void *start, uint32_t len)
 {
-       register uint32_t sum = csum;
-       volatile uint32_t *p = start;
+       uint32_t csum = 0;
+       uint32_t *p = start;
 
        /* check len and return zero checksum if invalid */
        if (!len)
                return 0;
 
        if (len % sizeof(uint32_t)) {
-               printf ("Error:%s[%d] - length is not in multiple of %zu\n",
-                       __FUNCTION__, len, sizeof(uint32_t));
+               fprintf(stderr, "Length %d is not in multiple of %zu\n",
+                       len, sizeof(uint32_t));
                return 0;
        }
 
        do {
-               sum += *p;
+               csum += *p;
                p++;
                len -= sizeof(uint32_t);
        } while (len > 0);
-       return (sum);
+
+       return csum;
 }
 
-static void kwbimage_check_cfgdata (char *token, enum kwbimage_cmd cmdsw,
-                                       struct kwb_header *kwbhdr)
+static void *image_create_v0(size_t *imagesz, struct image_tool_params *params,
+                            int payloadsz)
 {
-       bhr_t *mhdr = &kwbhdr->kwb_hdr;
-       extbhr_t *exthdr = &kwbhdr->kwb_exthdr;
-       int i;
+       struct image_cfg_element *e;
+       size_t headersz;
+       struct main_hdr_v0 *main_hdr;
+       struct ext_hdr_v0 *ext_hdr;
+       void *image;
+       int has_ext = 0;
+
+       /*
+        * Calculate the size of the header and the size of the
+        * payload
+        */
+       headersz  = sizeof(struct main_hdr_v0);
+
+       if (image_count_options(IMAGE_CFG_DATA) > 0) {
+               has_ext = 1;
+               headersz += sizeof(struct ext_hdr_v0);
+       }
+
+       if (image_count_options(IMAGE_CFG_PAYLOAD) > 1) {
+               fprintf(stderr, "More than one payload, not possible\n");
+               return NULL;
+       }
 
-       switch (cmdsw) {
-       case CMD_BOOT_FROM:
-               i = get_table_entry_id (kwbimage_bootops,
-                               "Kwbimage boot option", token);
-
-               if (i < 0)
-                       goto INVL_DATA;
-
-               mhdr->blockid = i;
-               printf ("Preparing kirkwood boot image to boot "
-                       "from %s\n", token);
-               break;
-       case CMD_NAND_ECC_MODE:
-               i = get_table_entry_id (kwbimage_eccmodes,
-                       "NAND ecc mode", token);
-
-               if (i < 0)
-                       goto INVL_DATA;
-
-               mhdr->nandeccmode = i;
-               printf ("Nand ECC mode = %s\n", token);
-               break;
-       case CMD_NAND_PAGE_SIZE:
-               mhdr->nandpagesize =
-                       (uint16_t) check_get_hexval (token);
-               printf ("Nand page size = 0x%x\n", mhdr->nandpagesize);
-               break;
-       case CMD_SATA_PIO_MODE:
-               mhdr->satapiomode =
-                       (uint8_t) check_get_hexval (token);
-               printf ("Sata PIO mode = 0x%x\n",
-                               mhdr->satapiomode);
-               break;
-       case CMD_DDR_INIT_DELAY:
-               mhdr->ddrinitdelay =
-                       (uint16_t) check_get_hexval (token);
-               printf ("DDR init delay = %d msec\n", mhdr->ddrinitdelay);
-               break;
-       case CMD_DATA:
-               exthdr->rcfg[datacmd_cnt].raddr =
-                       check_get_hexval (token);
-
-               break;
-       case CMD_INVALID:
-               goto INVL_DATA;
-       default:
-               goto INVL_DATA;
+       image = malloc(headersz);
+       if (!image) {
+               fprintf(stderr, "Cannot allocate memory for image\n");
+               return NULL;
        }
-       return;
 
-INVL_DATA:
-       printf ("Error:%s[%d] - Invalid data\n", fname, lineno);
-       exit (EXIT_FAILURE);
+       memset(image, 0, headersz);
+
+       main_hdr = image;
+
+       /* Fill in the main header */
+       main_hdr->blocksize = payloadsz + sizeof(uint32_t);
+       main_hdr->srcaddr   = headersz;
+       main_hdr->ext       = has_ext;
+       main_hdr->destaddr  = params->addr;
+       main_hdr->execaddr  = params->ep;
+
+       e = image_find_option(IMAGE_CFG_BOOT_FROM);
+       if (e)
+               main_hdr->blockid = e->bootfrom;
+       e = image_find_option(IMAGE_CFG_NAND_ECC_MODE);
+       if (e)
+               main_hdr->nandeccmode = e->nandeccmode;
+       e = image_find_option(IMAGE_CFG_NAND_PAGESZ);
+       if (e)
+               main_hdr->nandpagesize = e->nandpagesz;
+       main_hdr->checksum = image_checksum8(image,
+                                            sizeof(struct main_hdr_v0));
+
+       /* Generate the ext header */
+       if (has_ext) {
+               int cfgi, datai;
+
+               ext_hdr = image + sizeof(struct main_hdr_v0);
+               ext_hdr->offset = 0x40;
+
+               for (cfgi = 0, datai = 0; cfgi < cfgn; cfgi++) {
+                       e = &image_cfg[cfgi];
+                       if (e->type != IMAGE_CFG_DATA)
+                               continue;
+
+                       ext_hdr->rcfg[datai].raddr = e->regdata.raddr;
+                       ext_hdr->rcfg[datai].rdata = e->regdata.rdata;
+                       datai++;
+               }
+
+               ext_hdr->checksum = image_checksum8(ext_hdr,
+                                                   sizeof(struct ext_hdr_v0));
+       }
+
+       *imagesz = headersz;
+       return image;
 }
 
-/*
- * this function sets the kwbimage header by-
- *     1. Abstracting input command line arguments data
- *     2. parses the kwbimage configuration file and update extebded header data
- *     3. calculates header, extended header and image checksums
- */
-static void kwdimage_set_ext_header (struct kwb_header *kwbhdr, char* name) {
-       bhr_t *mhdr = &kwbhdr->kwb_hdr;
-       extbhr_t *exthdr = &kwbhdr->kwb_exthdr;
-       FILE *fd = NULL;
-       int j;
-       char *line = NULL;
-       char * token, *saveptr1, *saveptr2;
-       size_t len = 0;
-       enum kwbimage_cmd cmd;
-
-       fname = name;
-       /* set dram register offset */
-       exthdr->dramregsoffs = (intptr_t)&exthdr->rcfg - (intptr_t)mhdr;
-
-       if ((fd = fopen (name, "r")) == 0) {
-               printf ("Error:%s - Can't open\n", fname);
-               exit (EXIT_FAILURE);
+static size_t image_headersz_v1(struct image_tool_params *params,
+                               int *hasext)
+{
+       struct image_cfg_element *binarye;
+       size_t headersz;
+       int ret;
+
+       /*
+        * Calculate the size of the header and the size of the
+        * payload
+        */
+       headersz = sizeof(struct main_hdr_v1);
+
+       if (image_count_options(IMAGE_CFG_BINARY) > 1) {
+               fprintf(stderr, "More than one binary blob, not supported\n");
+               return 0;
        }
 
-       /* Simple kwimage.cfg file parser */
-       lineno=0;
-       while ((getline (&line, &len, fd)) > 0) {
-               lineno++;
-               token = strtok_r (line, "\r\n", &saveptr1);
-               /* drop all lines with zero tokens (= empty lines) */
-               if (token == NULL)
-                       continue;
+       if (image_count_options(IMAGE_CFG_PAYLOAD) > 1) {
+               fprintf(stderr, "More than one payload, not possible\n");
+               return 0;
+       }
 
-               for (j = 0, cmd = CMD_INVALID, line = token; ; line = NULL) {
-                       token = strtok_r (line, " \t", &saveptr2);
-                       if (token == NULL)
-                       break;
-                       /* Drop all text starting with '#' as comments */
-                       if (token[0] == '#')
-                               break;
+       binarye = image_find_option(IMAGE_CFG_BINARY);
+       if (binarye) {
+               struct stat s;
+
+               ret = stat(binarye->binary.file, &s);
+               if (ret < 0) {
+                       char *cwd = get_current_dir_name();
+                       fprintf(stderr,
+                               "Didn't find the file '%s' in '%s' which is mandatory to generate the image\n"
+                               "This file generally contains the DDR3 training code, and should be extracted from an existing bootable\n"
+                               "image for your board. See 'kwbimage -x' to extract it from an existing image.\n",
+                               binarye->binary.file, cwd);
+                       free(cwd);
+                       return 0;
+               }
 
-                       /* Process rest as valid config command line */
-                       switch (j) {
-                       case CFG_COMMAND:
-                               cmd = get_table_entry_id (kwbimage_cmds,
-                                               "Kwbimage command", token);
+               headersz += s.st_size +
+                       binarye->binary.nargs * sizeof(unsigned int);
+               if (hasext)
+                       *hasext = 1;
+       }
 
-                               if (cmd == CMD_INVALID)
-                                       goto INVL_CMD;
-                               break;
+       /*
+        * The payload should be aligned on some reasonable
+        * boundary
+        */
+       return ALIGN_SUP(headersz, 4096);
+}
 
-                       case CFG_DATA0:
-                               kwbimage_check_cfgdata (token, cmd, kwbhdr);
-                               break;
+static void *image_create_v1(size_t *imagesz, struct image_tool_params *params,
+                            int payloadsz)
+{
+       struct image_cfg_element *e, *binarye;
+       struct main_hdr_v1 *main_hdr;
+       size_t headersz;
+       void *image, *cur;
+       int hasext = 0;
+       int ret;
+
+       /*
+        * Calculate the size of the header and the size of the
+        * payload
+        */
+       headersz = image_headersz_v1(params, &hasext);
+       if (headersz == 0)
+               return NULL;
+
+       image = malloc(headersz);
+       if (!image) {
+               fprintf(stderr, "Cannot allocate memory for image\n");
+               return NULL;
+       }
 
-                       case CFG_DATA1:
-                               if (cmd != CMD_DATA)
-                                       goto INVL_CMD;
-
-                               exthdr->rcfg[datacmd_cnt].rdata =
-                                               check_get_hexval (token);
-
-                               if (datacmd_cnt > KWBIMAGE_MAX_CONFIG ) {
-                                       printf ("Error:%s[%d] - Found more "
-                                               "than max(%zd) allowed "
-                                               "data configurations\n",
-                                               fname, lineno,
-                                               KWBIMAGE_MAX_CONFIG);
-                               exit (EXIT_FAILURE);
-                               } else
-                                       datacmd_cnt++;
-                               break;
+       memset(image, 0, headersz);
+
+       cur = main_hdr = image;
+       cur += sizeof(struct main_hdr_v1);
+
+       /* Fill the main header */
+       main_hdr->blocksize    = payloadsz - headersz + sizeof(uint32_t);
+       main_hdr->headersz_lsb = headersz & 0xFFFF;
+       main_hdr->headersz_msb = (headersz & 0xFFFF0000) >> 16;
+       main_hdr->destaddr     = params->addr;
+       main_hdr->execaddr     = params->ep;
+       main_hdr->srcaddr      = headersz;
+       main_hdr->ext          = hasext;
+       main_hdr->version      = 1;
+       e = image_find_option(IMAGE_CFG_BOOT_FROM);
+       if (e)
+               main_hdr->blockid = e->bootfrom;
+       e = image_find_option(IMAGE_CFG_NAND_BLKSZ);
+       if (e)
+               main_hdr->nandblocksize = e->nandblksz / (64 * 1024);
+       e = image_find_option(IMAGE_CFG_NAND_BADBLK_LOCATION);
+       if (e)
+               main_hdr->nandbadblklocation = e->nandbadblklocation;
+
+       binarye = image_find_option(IMAGE_CFG_BINARY);
+       if (binarye) {
+               struct opt_hdr_v1 *hdr = cur;
+               unsigned int *args;
+               size_t binhdrsz;
+               struct stat s;
+               int argi;
+               FILE *bin;
+
+               hdr->headertype = OPT_HDR_V1_BINARY_TYPE;
+
+               bin = fopen(binarye->binary.file, "r");
+               if (!bin) {
+                       fprintf(stderr, "Cannot open binary file %s\n",
+                               binarye->binary.file);
+                       return NULL;
+               }
+
+               fstat(fileno(bin), &s);
+
+               binhdrsz = sizeof(struct opt_hdr_v1) +
+                       (binarye->binary.nargs + 1) * sizeof(unsigned int) +
+                       s.st_size;
+               hdr->headersz_lsb = binhdrsz & 0xFFFF;
+               hdr->headersz_msb = (binhdrsz & 0xFFFF0000) >> 16;
+
+               cur += sizeof(struct opt_hdr_v1);
+
+               args = cur;
+               *args = binarye->binary.nargs;
+               args++;
+               for (argi = 0; argi < binarye->binary.nargs; argi++)
+                       args[argi] = binarye->binary.args[argi];
+
+               cur += (binarye->binary.nargs + 1) * sizeof(unsigned int);
+
+               ret = fread(cur, s.st_size, 1, bin);
+               if (ret != 1) {
+                       fprintf(stderr,
+                               "Could not read binary image %s\n",
+                               binarye->binary.file);
+                       return NULL;
+               }
+
+               fclose(bin);
 
-                       default:
-                               goto INVL_CMD;
+               cur += s.st_size;
+
+               /*
+                * For now, we don't support more than one binary
+                * header, and no other header types are
+                * supported. So, the binary header is necessarily the
+                * last one
+                */
+               *((unsigned char *)cur) = 0;
+
+               cur += sizeof(uint32_t);
+       }
+
+       /* Calculate and set the header checksum */
+       main_hdr->checksum = image_checksum8(main_hdr, headersz);
+
+       *imagesz = headersz;
+       return image;
+}
+
+static int image_create_config_parse_oneline(char *line,
+                                            struct image_cfg_element *el)
+{
+       char *keyword, *saveptr;
+       char deliminiters[] = " \t";
+
+       keyword = strtok_r(line, deliminiters, &saveptr);
+       if (!strcmp(keyword, "VERSION")) {
+               char *value = strtok_r(NULL, deliminiters, &saveptr);
+               el->type = IMAGE_CFG_VERSION;
+               el->version = atoi(value);
+       } else if (!strcmp(keyword, "BOOT_FROM")) {
+               char *value = strtok_r(NULL, deliminiters, &saveptr);
+               el->type = IMAGE_CFG_BOOT_FROM;
+               el->bootfrom = image_boot_mode_id(value);
+               if (el->bootfrom < 0) {
+                       fprintf(stderr,
+                               "Invalid boot media '%s'\n", value);
+                       return -1;
+               }
+       } else if (!strcmp(keyword, "NAND_BLKSZ")) {
+               char *value = strtok_r(NULL, deliminiters, &saveptr);
+               el->type = IMAGE_CFG_NAND_BLKSZ;
+               el->nandblksz = strtoul(value, NULL, 16);
+       } else if (!strcmp(keyword, "NAND_BADBLK_LOCATION")) {
+               char *value = strtok_r(NULL, deliminiters, &saveptr);
+               el->type = IMAGE_CFG_NAND_BADBLK_LOCATION;
+               el->nandbadblklocation =
+                       strtoul(value, NULL, 16);
+       } else if (!strcmp(keyword, "NAND_ECC_MODE")) {
+               char *value = strtok_r(NULL, deliminiters, &saveptr);
+               el->type = IMAGE_CFG_NAND_ECC_MODE;
+               el->nandeccmode = image_nand_ecc_mode_id(value);
+               if (el->nandeccmode < 0) {
+                       fprintf(stderr,
+                               "Invalid NAND ECC mode '%s'\n", value);
+                       return -1;
+               }
+       } else if (!strcmp(keyword, "NAND_PAGE_SIZE")) {
+               char *value = strtok_r(NULL, deliminiters, &saveptr);
+               el->type = IMAGE_CFG_NAND_PAGESZ;
+               el->nandpagesz = strtoul(value, NULL, 16);
+       } else if (!strcmp(keyword, "BINARY")) {
+               char *value = strtok_r(NULL, deliminiters, &saveptr);
+               int argi = 0;
+
+               el->type = IMAGE_CFG_BINARY;
+               el->binary.file = strdup(value);
+               while (1) {
+                       value = strtok_r(NULL, deliminiters, &saveptr);
+                       if (!value)
+                               break;
+                       el->binary.args[argi] = strtoul(value, NULL, 16);
+                       argi++;
+                       if (argi >= BINARY_MAX_ARGS) {
+                               fprintf(stderr,
+                                       "Too many argument for binary\n");
+                               return -1;
                        }
-                       j++;
                }
+               el->binary.nargs = argi;
+       } else if (!strcmp(keyword, "DATA")) {
+               char *value1 = strtok_r(NULL, deliminiters, &saveptr);
+               char *value2 = strtok_r(NULL, deliminiters, &saveptr);
+
+               if (!value1 || !value2) {
+                       fprintf(stderr,
+                               "Invalid number of arguments for DATA\n");
+                       return -1;
+               }
+
+               el->type = IMAGE_CFG_DATA;
+               el->regdata.raddr = strtoul(value1, NULL, 16);
+               el->regdata.rdata = strtoul(value2, NULL, 16);
+       } else {
+               fprintf(stderr, "Ignoring unknown line '%s'\n", line);
        }
-       if (line)
-               free (line);
 
-       fclose (fd);
-       return;
+       return 0;
+}
 
 /*
- * Invalid Command error reporring
- *
- * command CMD_DATA needs three strings on a line
- * whereas other commands need only two.
- *
- * if more than two/three (as per command type) are observed,
- * then error will be reported
+ * Parse the configuration file 'fcfg' into the array of configuration
+ * elements 'image_cfg', and return the number of configuration
+ * elements in 'cfgn'.
  */
-INVL_CMD:
-       printf ("Error:%s[%d] - Invalid command\n", fname, lineno);
-       exit (EXIT_FAILURE);
+static int image_create_config_parse(FILE *fcfg)
+{
+       int ret;
+       int cfgi = 0;
+
+       /* Parse the configuration file */
+       while (!feof(fcfg)) {
+               char *line;
+               char buf[256];
+
+               /* Read the current line */
+               memset(buf, 0, sizeof(buf));
+               line = fgets(buf, sizeof(buf), fcfg);
+               if (!line)
+                       break;
+
+               /* Ignore useless lines */
+               if (line[0] == '\n' || line[0] == '#')
+                       continue;
+
+               /* Strip final newline */
+               if (line[strlen(line) - 1] == '\n')
+                       line[strlen(line) - 1] = 0;
+
+               /* Parse the current line */
+               ret = image_create_config_parse_oneline(line,
+                                                       &image_cfg[cfgi]);
+               if (ret)
+                       return ret;
+
+               cfgi++;
+
+               if (cfgi >= IMAGE_CFG_ELEMENT_MAX) {
+                       fprintf(stderr,
+                               "Too many configuration elements in .cfg file\n");
+                       return -1;
+               }
+       }
+
+       cfgn = cfgi;
+       return 0;
+}
+
+static int image_get_version(void)
+{
+       struct image_cfg_element *e;
+
+       e = image_find_option(IMAGE_CFG_VERSION);
+       if (!e)
+               return -1;
+
+       return e->version;
+}
+
+static int image_version_file(const char *input)
+{
+       FILE *fcfg;
+       int version;
+       int ret;
+
+       fcfg = fopen(input, "r");
+       if (!fcfg) {
+               fprintf(stderr, "Could not open input file %s\n", input);
+               return -1;
+       }
+
+       image_cfg = malloc(IMAGE_CFG_ELEMENT_MAX *
+                          sizeof(struct image_cfg_element));
+       if (!image_cfg) {
+               fprintf(stderr, "Cannot allocate memory\n");
+               fclose(fcfg);
+               return -1;
+       }
+
+       memset(image_cfg, 0,
+              IMAGE_CFG_ELEMENT_MAX * sizeof(struct image_cfg_element));
+       rewind(fcfg);
+
+       ret = image_create_config_parse(fcfg);
+       fclose(fcfg);
+       if (ret) {
+               free(image_cfg);
+               return -1;
+       }
+
+       version = image_get_version();
+       /* Fallback to version 0 is no version is provided in the cfg file */
+       if (version == -1)
+               version = 0;
+
+       free(image_cfg);
+
+       return version;
 }
 
-static void kwbimage_set_header (void *ptr, struct stat *sbuf, int ifd,
+static void kwbimage_set_header(void *ptr, struct stat *sbuf, int ifd,
                                struct image_tool_params *params)
 {
-       struct kwb_header *hdr = (struct kwb_header *)ptr;
-       bhr_t *mhdr = &hdr->kwb_hdr;
-       extbhr_t *exthdr = &hdr->kwb_exthdr;
+       FILE *fcfg;
+       void *image = NULL;
+       int version;
+       size_t headersz;
        uint32_t checksum;
+       int ret;
        int size;
 
-       /* Build and add image checksum header */
-       checksum = kwbimage_checksum32 ((uint32_t *)ptr, sbuf->st_size, 0);
+       fcfg = fopen(params->imagename, "r");
+       if (!fcfg) {
+               fprintf(stderr, "Could not open input file %s\n",
+                       params->imagename);
+               exit(EXIT_FAILURE);
+       }
+
+       image_cfg = malloc(IMAGE_CFG_ELEMENT_MAX *
+                          sizeof(struct image_cfg_element));
+       if (!image_cfg) {
+               fprintf(stderr, "Cannot allocate memory\n");
+               fclose(fcfg);
+               exit(EXIT_FAILURE);
+       }
+
+       memset(image_cfg, 0,
+              IMAGE_CFG_ELEMENT_MAX * sizeof(struct image_cfg_element));
+       rewind(fcfg);
+
+       ret = image_create_config_parse(fcfg);
+       fclose(fcfg);
+       if (ret) {
+               free(image_cfg);
+               exit(EXIT_FAILURE);
+       }
+
+       version = image_get_version();
+       /* Fallback to version 0 is no version is provided in the cfg file */
+       if (version == -1)
+               version = 0;
+
+       if (version == 0)
+               image = image_create_v0(&headersz, params, sbuf->st_size);
+       else if (version == 1)
+               image = image_create_v1(&headersz, params, sbuf->st_size);
+
+       if (!image) {
+               fprintf(stderr, "Could not create image\n");
+               free(image_cfg);
+               exit(EXIT_FAILURE);
+       }
+
+       free(image_cfg);
 
-       size = write (ifd, &checksum, sizeof(uint32_t));
+       /* Build and add image checksum header */
+       checksum = image_checksum32((uint32_t *)ptr, sbuf->st_size);
+       size = write(ifd, &checksum, sizeof(uint32_t));
        if (size != sizeof(uint32_t)) {
-               printf ("Error:%s - Checksum write %d bytes %s\n",
+               fprintf(stderr, "Error:%s - Checksum write %d bytes %s\n",
                        params->cmdname, size, params->imagefile);
-               exit (EXIT_FAILURE);
+               exit(EXIT_FAILURE);
        }
 
        sbuf->st_size += sizeof(uint32_t);
 
-       mhdr->blocksize = sbuf->st_size - sizeof(struct kwb_header);
-       mhdr->srcaddr = sizeof(struct kwb_header);
-       mhdr->destaddr= params->addr;
-       mhdr->execaddr =params->ep;
-       mhdr->ext = 0x1; /* header extension appended */
-
-       kwdimage_set_ext_header (hdr, params->imagename);
-       /* calculate checksums */
-       mhdr->checkSum = kwbimage_checksum8 ((void *)mhdr, sizeof(bhr_t), 0);
-       exthdr->checkSum = kwbimage_checksum8 ((void *)exthdr,
-                                               sizeof(extbhr_t), 0);
-}
-
-static int kwbimage_verify_header (unsigned char *ptr, int image_size,
-                       struct image_tool_params *params)
-{
-       struct kwb_header *hdr = (struct kwb_header *)ptr;
-       bhr_t *mhdr = &hdr->kwb_hdr;
-       extbhr_t *exthdr = &hdr->kwb_exthdr;
-       uint8_t calc_hdrcsum;
-       uint8_t calc_exthdrcsum;
-
-       calc_hdrcsum = kwbimage_checksum8 ((void *)mhdr,
-                       sizeof(bhr_t) - sizeof(uint8_t), 0);
-       if (calc_hdrcsum != mhdr->checkSum)
-               return -FDT_ERR_BADSTRUCTURE;   /* mhdr csum not matched */
-
-       calc_exthdrcsum = kwbimage_checksum8 ((void *)exthdr,
-                       sizeof(extbhr_t) - sizeof(uint8_t), 0);
-       if (calc_exthdrcsum != exthdr->checkSum)
-               return -FDT_ERR_BADSTRUCTURE; /* exthdr csum not matched */
+       /* Finally copy the header into the image area */
+       memcpy(ptr, image, headersz);
 
-       return 0;
+       free(image);
 }
 
-static void kwbimage_print_header (const void *ptr)
+static void kwbimage_print_header(const void *ptr)
 {
-       struct kwb_header *hdr = (struct kwb_header *) ptr;
-       bhr_t *mhdr = &hdr->kwb_hdr;
-       char *name = get_table_entry_name (kwbimage_bootops,
-                               "Kwbimage boot option",
-                               (int) mhdr->blockid);
-
-       printf ("Image Type:   Kirkwood Boot from %s Image\n", name);
-       printf ("Data Size:    ");
-       genimg_print_size (mhdr->blocksize - sizeof(uint32_t));
-       printf ("Load Address: %08x\n", mhdr->destaddr);
-       printf ("Entry Point:  %08x\n", mhdr->execaddr);
+       struct main_hdr_v0 *mhdr = (struct main_hdr_v0 *)ptr;
+
+       printf("Image Type:   MVEBU Boot from %s Image\n",
+              image_boot_mode_name(mhdr->blockid));
+       printf("Data Size:    ");
+       printf("Image version:%d\n", image_version((void *)ptr));
+       genimg_print_size(mhdr->blocksize - sizeof(uint32_t));
+       printf("Load Address: %08x\n", mhdr->destaddr);
+       printf("Entry Point:  %08x\n", mhdr->execaddr);
 }
 
-static int kwbimage_check_image_types (uint8_t type)
+static int kwbimage_check_image_types(uint8_t type)
 {
        if (type == IH_TYPE_KWBIMAGE)
                return EXIT_SUCCESS;
@@ -366,18 +807,91 @@ static int kwbimage_check_image_types (uint8_t type)
                return EXIT_FAILURE;
 }
 
+static int kwbimage_verify_header(unsigned char *ptr, int image_size,
+                                 struct image_tool_params *params)
+{
+       struct main_hdr_v0 *main_hdr;
+       struct ext_hdr_v0 *ext_hdr;
+       uint8_t checksum;
+
+       main_hdr = (void *)ptr;
+       checksum = image_checksum8(ptr,
+                                  sizeof(struct main_hdr_v0));
+       if (checksum != main_hdr->checksum)
+               return -FDT_ERR_BADSTRUCTURE;
+
+       /* Only version 0 extended header has checksum */
+       if (image_version((void *)ptr) == 0) {
+               ext_hdr = (void *)ptr + sizeof(struct main_hdr_v0);
+               checksum = image_checksum8(ext_hdr,
+                                          sizeof(struct ext_hdr_v0));
+               if (checksum != ext_hdr->checksum)
+                       return -FDT_ERR_BADSTRUCTURE;
+       }
+
+       return 0;
+}
+
+static int kwbimage_generate(struct image_tool_params *params,
+                            struct image_type_params *tparams)
+{
+       int alloc_len;
+       void *hdr;
+       int version = 0;
+
+       version = image_version_file(params->imagename);
+       if (version == 0) {
+               alloc_len = sizeof(struct main_hdr_v0) +
+                       sizeof(struct ext_hdr_v0);
+       } else {
+               alloc_len = image_headersz_v1(params, NULL);
+       }
+
+       hdr = malloc(alloc_len);
+       if (!hdr) {
+               fprintf(stderr, "%s: malloc return failure: %s\n",
+                       params->cmdname, strerror(errno));
+               exit(EXIT_FAILURE);
+       }
+
+       memset(hdr, 0, alloc_len);
+       tparams->header_size = alloc_len;
+       tparams->hdr = hdr;
+
+       return 0;
+}
+
+/*
+ * Report Error if xflag is set in addition to default
+ */
+static int kwbimage_check_params(struct image_tool_params *params)
+{
+       if (!strlen(params->imagename)) {
+               fprintf(stderr, "Error:%s - Configuration file not specified, "
+                       "it is needed for kwbimage generation\n",
+                       params->cmdname);
+               return CFG_INVALID;
+       }
+
+       return (params->dflag && (params->fflag || params->lflag)) ||
+               (params->fflag && (params->dflag || params->lflag)) ||
+               (params->lflag && (params->dflag || params->fflag)) ||
+               (params->xflag) || !(strlen(params->imagename));
+}
+
 /*
  * kwbimage type parameters definition
  */
 static struct image_type_params kwbimage_params = {
-       .name = "Kirkwood Boot Image support",
-       .header_size = sizeof(struct kwb_header),
-       .hdr = (void*)&kwbimage_header,
+       .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,
+       .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)
index e773f01df3f626b337c8c44390303b677feb46d0..1368b4c948ae74e977683880fc8828ea86b95bb7 100644 (file)
@@ -1,5 +1,6 @@
 /*
- * Boot a Marvell Kirkwood SoC, with Xmodem over UART0.
+ * Boot a Marvell SoC, with Xmodem over UART0.
+ *  supports Kirkwood, Dove, Armada 370, Armada XP
  *
  * (c) 2012 Daniel Stodden <daniel.stodden@gmail.com>
  *
@@ -37,9 +38,18 @@ static unsigned char kwboot_msg_boot[] = {
        0xBB, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77
 };
 
+static unsigned char kwboot_msg_debug[] = {
+       0xDD, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77
+};
+
+/* Defines known to work on Kirkwood */
 #define KWBOOT_MSG_REQ_DELAY   10 /* ms */
 #define KWBOOT_MSG_RSP_TIMEO   50 /* ms */
 
+/* Defines known to work on Armada XP */
+#define KWBOOT_MSG_REQ_DELAY_AXP       1000 /* ms */
+#define KWBOOT_MSG_RSP_TIMEO_AXP       1000 /* ms */
+
 /*
  * Xmodem Transfers
  */
@@ -62,6 +72,9 @@ struct kwboot_block {
 
 static int kwboot_verbose;
 
+static int msg_req_delay = KWBOOT_MSG_REQ_DELAY;
+static int msg_rsp_timeo = KWBOOT_MSG_RSP_TIMEO;
+
 static void
 kwboot_printv(const char *fmt, ...)
 {
@@ -184,6 +197,9 @@ kwboot_tty_send(int fd, const void *buf, size_t len)
        int rc;
        ssize_t n;
 
+       if (!buf)
+               return 0;
+
        rc = -1;
 
        do {
@@ -268,7 +284,10 @@ kwboot_bootmsg(int tty, void *msg)
        int rc;
        char c;
 
-       kwboot_printv("Sending boot message. Please reboot the target...");
+       if (msg == NULL)
+               kwboot_printv("Please reboot the target into UART boot mode...");
+       else
+               kwboot_printv("Sending boot message. Please reboot the target...");
 
        do {
                rc = tcflush(tty, TCIOFLUSH);
@@ -277,11 +296,11 @@ kwboot_bootmsg(int tty, void *msg)
 
                rc = kwboot_tty_send(tty, msg, 8);
                if (rc) {
-                       usleep(KWBOOT_MSG_REQ_DELAY * 1000);
+                       usleep(msg_req_delay * 1000);
                        continue;
                }
 
-               rc = kwboot_tty_recv(tty, &c, 1, KWBOOT_MSG_RSP_TIMEO);
+               rc = kwboot_tty_recv(tty, &c, 1, msg_rsp_timeo);
 
                kwboot_spinner();
 
@@ -292,6 +311,37 @@ kwboot_bootmsg(int tty, void *msg)
        return rc;
 }
 
+static int
+kwboot_debugmsg(int tty, void *msg)
+{
+       int rc;
+
+       kwboot_printv("Sending debug message. Please reboot the target...");
+
+       do {
+               char buf[16];
+
+               rc = tcflush(tty, TCIOFLUSH);
+               if (rc)
+                       break;
+
+               rc = kwboot_tty_send(tty, msg, 8);
+               if (rc) {
+                       usleep(msg_req_delay * 1000);
+                       continue;
+               }
+
+               rc = kwboot_tty_recv(tty, buf, 16, msg_rsp_timeo);
+
+               kwboot_spinner();
+
+       } while (rc);
+
+       kwboot_printv("\n");
+
+       return rc;
+}
+
 static int
 kwboot_xm_makeblock(struct kwboot_block *block, const void *data,
                    size_t size, int pnum)
@@ -300,6 +350,7 @@ kwboot_xm_makeblock(struct kwboot_block *block, const void *data,
        size_t n;
        int i;
 
+       block->soh = SOH;
        block->pnum = pnum;
        block->_pnum = ~block->pnum;
 
@@ -326,9 +377,15 @@ kwboot_xm_sendblock(int fd, struct kwboot_block *block)
                if (rc)
                        break;
 
-               rc = kwboot_tty_recv(fd, &c, 1, KWBOOT_BLK_RSP_TIMEO);
-               if (rc)
-                       break;
+               do {
+                       rc = kwboot_tty_recv(fd, &c, 1, KWBOOT_BLK_RSP_TIMEO);
+                       if (rc)
+                               break;
+
+                       if (c != ACK && c != NAK && c != CAN)
+                               printf("%c", c);
+
+               } while (c != ACK && c != NAK && c != CAN);
 
                if (c != ACK)
                        kwboot_progress(-1, '+');
@@ -511,7 +568,6 @@ kwboot_mmap_image(const char *path, size_t *size, int prot)
        void *img;
 
        rc = -1;
-       fd = -1;
        img = NULL;
 
        fd = open(path, O_RDONLY);
@@ -601,11 +657,16 @@ static void
 kwboot_usage(FILE *stream, char *progname)
 {
        fprintf(stream,
-               "Usage: %s -b <image> [ -p ] [ -t ] "
-               "[-B <baud> ] <TTY>\n", progname);
+               "Usage: %s [-d | -a | -b <image> | -D <image> ] [ -t ] [-B <baud> ] <TTY>\n",
+               progname);
        fprintf(stream, "\n");
-       fprintf(stream, "  -b <image>: boot <image>\n");
+       fprintf(stream,
+               "  -b <image>: boot <image> with preamble (Kirkwood, Armada 370/XP)\n");
        fprintf(stream, "  -p: patch <image> to type 0x69 (uart boot)\n");
+       fprintf(stream,
+               "  -D <image>: boot <image> without preamble (Dove)\n");
+       fprintf(stream, "  -d: enter debug mode\n");
+       fprintf(stream, "  -a: use timings for Armada XP\n");
        fprintf(stream, "\n");
        fprintf(stream, "  -t: mini terminal\n");
        fprintf(stream, "\n");
@@ -619,6 +680,7 @@ main(int argc, char **argv)
        const char *ttypath, *imgpath;
        int rv, rc, tty, term, prot, patch;
        void *bootmsg;
+       void *debugmsg;
        void *img;
        size_t size;
        speed_t speed;
@@ -626,6 +688,7 @@ main(int argc, char **argv)
        rv = 1;
        tty = -1;
        bootmsg = NULL;
+       debugmsg = NULL;
        imgpath = NULL;
        img = NULL;
        term = 0;
@@ -636,7 +699,7 @@ main(int argc, char **argv)
        kwboot_verbose = isatty(STDOUT_FILENO);
 
        do {
-               int c = getopt(argc, argv, "hb:ptB:");
+               int c = getopt(argc, argv, "hb:ptaB:dD:");
                if (c < 0)
                        break;
 
@@ -646,6 +709,15 @@ main(int argc, char **argv)
                        imgpath = optarg;
                        break;
 
+               case 'D':
+                       bootmsg = NULL;
+                       imgpath = optarg;
+                       break;
+
+               case 'd':
+                       debugmsg = kwboot_msg_debug;
+                       break;
+
                case 'p':
                        patch = 1;
                        break;
@@ -654,6 +726,11 @@ main(int argc, char **argv)
                        term = 1;
                        break;
 
+               case 'a':
+                       msg_req_delay = KWBOOT_MSG_REQ_DELAY_AXP;
+                       msg_rsp_timeo = KWBOOT_MSG_RSP_TIMEO_AXP;
+                       break;
+
                case 'B':
                        speed = kwboot_tty_speed(atoi(optarg));
                        if (speed == -1)
@@ -667,7 +744,7 @@ main(int argc, char **argv)
                }
        } while (1);
 
-       if (!bootmsg && !term)
+       if (!bootmsg && !term && !debugmsg)
                goto usage;
 
        if (patch && !imgpath)
@@ -702,7 +779,13 @@ main(int argc, char **argv)
                }
        }
 
-       if (bootmsg) {
+       if (debugmsg) {
+               rc = kwboot_debugmsg(tty, debugmsg);
+               if (rc) {
+                       perror("debugmsg");
+                       goto out;
+               }
+       } else {
                rc = kwboot_bootmsg(tty, bootmsg);
                if (rc) {
                        perror("bootmsg");
index 396d8a5472f90ce0981515e26c4ebb9c0d2541e8..917873e7b3ce83487cb16a9a9d577f495192f5f6 100644 (file)
@@ -74,12 +74,12 @@ static uint16_t hdr_checksum(struct socfpga_header *header)
 static void build_header(uint8_t *buf, uint8_t version, uint8_t flags,
                         uint16_t length_bytes)
 {
-       header.validation = htole32(VALIDATION_WORD);
+       header.validation = cpu_to_le32(VALIDATION_WORD);
        header.version = version;
        header.flags = flags;
-       header.length_u32 = htole16(length_bytes/4);
+       header.length_u32 = cpu_to_le16(length_bytes/4);
        header.zero = 0;
-       header.checksum = htole16(hdr_checksum(&header));
+       header.checksum = cpu_to_le16(hdr_checksum(&header));
 
        memcpy(buf, &header, sizeof(header));
 }
@@ -92,12 +92,12 @@ static int verify_header(const uint8_t *buf)
 {
        memcpy(&header, buf, sizeof(header));
 
-       if (le32toh(header.validation) != VALIDATION_WORD)
+       if (le32_to_cpu(header.validation) != VALIDATION_WORD)
                return -1;
-       if (le16toh(header.checksum) != hdr_checksum(&header))
+       if (le16_to_cpu(header.checksum) != hdr_checksum(&header))
                return -1;
 
-       return le16toh(header.length_u32) * 4;
+       return le16_to_cpu(header.length_u32) * 4;
 }
 
 /* Sign the buffer and return the signed buffer size */
@@ -116,7 +116,7 @@ static int sign_buffer(uint8_t *buf,
        /* Calculate and apply the CRC */
        calc_crc = ~pbl_crc32(0, (char *)buf, len);
 
-       *((uint32_t *)(buf + len)) = htole32(calc_crc);
+       *((uint32_t *)(buf + len)) = cpu_to_le32(calc_crc);
 
        if (!pad_64k)
                return len + 4;
@@ -150,7 +150,7 @@ static int verify_buffer(const uint8_t *buf)
 
        calc_crc = ~pbl_crc32(0, (const char *)buf, len);
 
-       buf_crc = le32toh(*((uint32_t *)(buf + len)));
+       buf_crc = le32_to_cpu(*((uint32_t *)(buf + len)));
 
        if (buf_crc != calc_crc) {
                fprintf(stderr, "CRC32 does not match (%08x != %08x)\n",