From aec9a0f19f64f83090198966aeb4f91702ae3c33 Mon Sep 17 00:00:00 2001 From: Jagan Teki Date: Thu, 13 Oct 2016 14:19:35 +0530 Subject: [PATCH 1/6] sunxi: Rename CONFIG_SUNXI to CONFIG_ARCH_SUNXI CONFIG_SUNXI -> CONFIG_ARCH_SUNXI and removed CONFIG_SUNIX from config_whitelist.txt Cc: Simon Glass Cc: Ian Campbell Cc: Hans de Goede Signed-off-by: Jagan Teki Reviewed-by: Hans de Goede Signed-off-by: Hans de Goede --- Makefile | 2 +- arch/arm/cpu/armv7/Makefile | 2 +- drivers/i2c/mvtwsi.c | 6 +++--- include/configs/sunxi-common.h | 1 - scripts/Makefile.spl | 2 +- scripts/config_whitelist.txt | 1 - tools/Makefile | 2 +- 7 files changed, 7 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 8d1692663c..75afbfc236 100644 --- a/Makefile +++ b/Makefile @@ -1096,7 +1096,7 @@ u-boot-x86-16bit.bin: u-boot FORCE $(call if_changed,objcopy) endif -ifneq ($(CONFIG_SUNXI),) +ifneq ($(CONFIG_ARCH_SUNXI),) OBJCOPYFLAGS_u-boot-sunxi-with-spl.bin = -I binary -O binary \ --pad-to=$(CONFIG_SPL_PAD_TO) --gap-fill=0xff u-boot-sunxi-with-spl.bin: spl/sunxi-spl.bin u-boot.img FORCE diff --git a/arch/arm/cpu/armv7/Makefile b/arch/arm/cpu/armv7/Makefile index c1eeefd5dd..4d3bc9440f 100644 --- a/arch/arm/cpu/armv7/Makefile +++ b/arch/arm/cpu/armv7/Makefile @@ -12,7 +12,7 @@ obj-y += cache_v7.o cache_v7_asm.o obj-y += cpu.o cp15.o obj-y += syslib.o -ifneq ($(CONFIG_AM43XX)$(CONFIG_AM33XX)$(CONFIG_OMAP44XX)$(CONFIG_OMAP54XX)$(CONFIG_TEGRA)$(CONFIG_MX6)$(CONFIG_MX7)$(CONFIG_TI81XX)$(CONFIG_AT91FAMILY)$(CONFIG_SUNXI)$(CONFIG_ARCH_SOCFPGA)$(CONFIG_LS102XA),) +ifneq ($(CONFIG_AM43XX)$(CONFIG_AM33XX)$(CONFIG_OMAP44XX)$(CONFIG_OMAP54XX)$(CONFIG_TEGRA)$(CONFIG_MX6)$(CONFIG_MX7)$(CONFIG_TI81XX)$(CONFIG_AT91FAMILY)$(CONFIG_ARCH_SUNXI)$(CONFIG_ARCH_SOCFPGA)$(CONFIG_LS102XA),) ifneq ($(CONFIG_SKIP_LOWLEVEL_INIT),y) obj-y += lowlevel_init.o endif diff --git a/drivers/i2c/mvtwsi.c b/drivers/i2c/mvtwsi.c index 60c8ea1914..cea3da0b27 100644 --- a/drivers/i2c/mvtwsi.c +++ b/drivers/i2c/mvtwsi.c @@ -29,7 +29,7 @@ DECLARE_GLOBAL_DATA_PTR; #include #elif (defined(CONFIG_KIRKWOOD) || defined(CONFIG_ARCH_MVEBU)) #include -#elif defined(CONFIG_SUNXI) +#elif defined(CONFIG_ARCH_SUNXI) #include #else #error Driver mvtwsi not supported by SoC or board @@ -40,7 +40,7 @@ DECLARE_GLOBAL_DATA_PTR; * TWSI register structure */ -#ifdef CONFIG_SUNXI +#ifdef CONFIG_ARCH_SUNXI struct mvtwsi_registers { u32 slave_address; @@ -399,7 +399,7 @@ static int twsi_stop(struct mvtwsi_registers *twsi, uint tick) */ static uint twsi_calc_freq(const int n, const int m) { -#ifdef CONFIG_SUNXI +#ifdef CONFIG_ARCH_SUNXI return CONFIG_SYS_TCLK / (10 * (m + 1) * (1 << n)); #else return CONFIG_SYS_TCLK / (10 * (m + 1) * (2 << n)); diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h index e0464df038..8363414828 100644 --- a/include/configs/sunxi-common.h +++ b/include/configs/sunxi-common.h @@ -35,7 +35,6 @@ /* * High Level Configuration Options */ -#define CONFIG_SUNXI /* sunxi family */ #ifdef CONFIG_SPL_BUILD #define CONFIG_SYS_THUMB_BUILD /* Thumbs mode to save space in SPL */ #endif diff --git a/scripts/Makefile.spl b/scripts/Makefile.spl index e8cf9f3865..e0b0117dc9 100644 --- a/scripts/Makefile.spl +++ b/scripts/Makefile.spl @@ -166,7 +166,7 @@ ifdef CONFIG_ARCH_SOCFPGA ALL-y += $(obj)/$(SPL_BIN).sfp endif -ifdef CONFIG_SUNXI +ifdef CONFIG_ARCH_SUNXI ALL-y += $(obj)/sunxi-spl.bin endif diff --git a/scripts/config_whitelist.txt b/scripts/config_whitelist.txt index 11b5a221ee..d476367088 100644 --- a/scripts/config_whitelist.txt +++ b/scripts/config_whitelist.txt @@ -4355,7 +4355,6 @@ CONFIG_STV0991_HZ CONFIG_STV0991_HZ_CLOCK CONFIG_ST_SMI CONFIG_SUN4 -CONFIG_SUNXI CONFIG_SUNXI_AHCI CONFIG_SUNXI_EMAC CONFIG_SUNXI_GMAC diff --git a/tools/Makefile b/tools/Makefile index e6f7993f99..556f397bb8 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -169,7 +169,7 @@ hostprogs-$(CONFIG_MX23) += mxsboot hostprogs-$(CONFIG_MX28) += mxsboot HOSTCFLAGS_mxsboot.o := -pedantic -hostprogs-$(CONFIG_SUNXI) += mksunxiboot +hostprogs-$(CONFIG_ARCH_SUNXI) += mksunxiboot hostprogs-$(CONFIG_NETCONSOLE) += ncb hostprogs-$(CONFIG_SHA1_CHECK_UB_IMG) += ubsha1 From 6ab224da57363a80e9f95b79ae1c208b0d8d2f4f Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Fri, 14 Oct 2016 00:40:01 +0900 Subject: [PATCH 2/6] sunxi: remove unneeded CONFIG_USB_MAX_CONTROLLER_COUNT defines ARCH_SUNXI selects DM_USB, where CONFIG_USB_MAX_CONTROLLER_COUNT is not used. Signed-off-by: Masahiro Yamada Reviewed-by: Hans de Goede Signed-off-by: Hans de Goede --- include/configs/sun4i.h | 1 - include/configs/sun5i.h | 1 - include/configs/sun6i.h | 1 - include/configs/sun7i.h | 1 - include/configs/sun8i.h | 1 - 5 files changed, 5 deletions(-) diff --git a/include/configs/sun4i.h b/include/configs/sun4i.h index ea079eb5f7..3dfd95ad77 100644 --- a/include/configs/sun4i.h +++ b/include/configs/sun4i.h @@ -14,7 +14,6 @@ #ifdef CONFIG_USB_EHCI #define CONFIG_USB_EHCI_SUNXI -#define CONFIG_USB_MAX_CONTROLLER_COUNT 2 #endif #define CONFIG_SUNXI_USB_PHYS 3 diff --git a/include/configs/sun5i.h b/include/configs/sun5i.h index d257659903..ec8f3199ba 100644 --- a/include/configs/sun5i.h +++ b/include/configs/sun5i.h @@ -14,7 +14,6 @@ #ifdef CONFIG_USB_EHCI #define CONFIG_USB_EHCI_SUNXI -#define CONFIG_USB_MAX_CONTROLLER_COUNT 1 #endif #define CONFIG_SUNXI_USB_PHYS 2 diff --git a/include/configs/sun6i.h b/include/configs/sun6i.h index 67a26c2e45..6c1eca4d26 100644 --- a/include/configs/sun6i.h +++ b/include/configs/sun6i.h @@ -17,7 +17,6 @@ #ifdef CONFIG_USB_EHCI #define CONFIG_USB_EHCI_SUNXI -#define CONFIG_USB_MAX_CONTROLLER_COUNT 2 #endif #define CONFIG_SUNXI_USB_PHYS 3 diff --git a/include/configs/sun7i.h b/include/configs/sun7i.h index d8e6e20795..5455901efe 100644 --- a/include/configs/sun7i.h +++ b/include/configs/sun7i.h @@ -15,7 +15,6 @@ #ifdef CONFIG_USB_EHCI #define CONFIG_USB_EHCI_SUNXI -#define CONFIG_USB_MAX_CONTROLLER_COUNT 2 #endif #define CONFIG_SUNXI_USB_PHYS 3 diff --git a/include/configs/sun8i.h b/include/configs/sun8i.h index 011d70f367..a4c3fb69e4 100644 --- a/include/configs/sun8i.h +++ b/include/configs/sun8i.h @@ -15,7 +15,6 @@ #ifdef CONFIG_USB_EHCI #define CONFIG_USB_EHCI_SUNXI -#define CONFIG_USB_MAX_CONTROLLER_COUNT 1 #endif #ifdef CONFIG_MACH_SUN8I_H3 From 6301e80ccfdf8b8daf921c67ffb5c5a17960f895 Mon Sep 17 00:00:00 2001 From: Andre Przywara Date: Fri, 21 Oct 2016 01:11:46 +0100 Subject: [PATCH 3/6] sunxi: dts: Pine64: add Ethernet alias The sun8i-emac driver works fine with the A64 Ethernet IP, but we are missing an alias entry to trigger the driver instantiation by U-Boot. Add the line to point U-Boot to the Ethernet DT node. This enables TFTP boot on the Pine64. Signed-off-by: Andre Przywara Reviewed-by: Hans de Goede Signed-off-by: Hans de Goede --- arch/arm/dts/sun50i-a64-pine64-common.dtsi | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm/dts/sun50i-a64-pine64-common.dtsi b/arch/arm/dts/sun50i-a64-pine64-common.dtsi index d5a7249464..c0fde440f5 100644 --- a/arch/arm/dts/sun50i-a64-pine64-common.dtsi +++ b/arch/arm/dts/sun50i-a64-pine64-common.dtsi @@ -46,6 +46,7 @@ aliases { serial0 = &uart0; + ethernet0 = &emac; }; soc { From 06de0701302488b4ac08f6e6d7bb9b8fcc92f5c2 Mon Sep 17 00:00:00 2001 From: Stefan Mavrodiev Date: Sat, 29 Oct 2016 14:34:07 +0200 Subject: [PATCH 4/6] sunxi: Update DRAM clock for Olimex A20 boards Originally dram clock was set to 480MHz, but this behaves unstable. To improve stability the clock is reduced to 384MHz Signed-off-by: Stefan Mavrodiev Reviewed-by: Hans de Goede Signed-off-by: Hans de Goede --- configs/A20-Olimex-SOM-EVB_defconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configs/A20-Olimex-SOM-EVB_defconfig b/configs/A20-Olimex-SOM-EVB_defconfig index 7a14a7b9b2..3f4e90db4a 100644 --- a/configs/A20-Olimex-SOM-EVB_defconfig +++ b/configs/A20-Olimex-SOM-EVB_defconfig @@ -2,7 +2,7 @@ CONFIG_ARM=y CONFIG_ARCH_SUNXI=y CONFIG_SPL_I2C_SUPPORT=y CONFIG_MACH_SUN7I=y -CONFIG_DRAM_CLK=480 +CONFIG_DRAM_CLK=384 CONFIG_MMC0_CD_PIN="PH1" CONFIG_MMC3_CD_PIN="PH0" CONFIG_MMC3_PINS="PH" From 9d6c9d988f0cd2fae095f1c76dc6b786a890108b Mon Sep 17 00:00:00 2001 From: Amit Singh Tomar Date: Fri, 21 Oct 2016 02:24:30 +0100 Subject: [PATCH 5/6] sunxi: A64: enable USB support Mostly by adding MACH_SUN50I to some existing #ifdefs enable support for the the HCI0 USB host controller on the A64. Fix up some minor 64-bit hiccups on the way. Add the bare minimum DT bits to the A64 .dtsi and enable the controllers and the PHY on the Pine64. This is limited to the first USB controller at the moment, which is connected to the lower USB socket on the Pine64 board. [Andre: remove unneeded defines, enable OHCI, add commit message] Signed-off-by: Amit Singh Tomar Signed-off-by: Andre Przywara Reviewed-by: Hans de Goede Signed-off-by: Hans de Goede --- arch/arm/dts/sun50i-a64-pine64-common.dtsi | 12 +++++++++ arch/arm/dts/sun50i-a64.dtsi | 29 +++++++++++++++++++++ arch/arm/include/asm/arch-sunxi/cpu_sun4i.h | 2 +- arch/arm/mach-sunxi/usb_phy.c | 5 ++-- configs/pine64_plus_defconfig | 1 + drivers/usb/host/ehci-sunxi.c | 7 ++--- drivers/usb/host/ohci-sunxi.c | 1 + include/configs/sun50i.h | 5 ++++ 8 files changed, 56 insertions(+), 6 deletions(-) diff --git a/arch/arm/dts/sun50i-a64-pine64-common.dtsi b/arch/arm/dts/sun50i-a64-pine64-common.dtsi index c0fde440f5..9ec81c65e7 100644 --- a/arch/arm/dts/sun50i-a64-pine64-common.dtsi +++ b/arch/arm/dts/sun50i-a64-pine64-common.dtsi @@ -79,3 +79,15 @@ pinctrl-0 = <&i2c1_pins>; status = "okay"; }; + +&usbphy { + status = "okay"; +}; + +&ohci1 { + status = "okay"; +}; + +&ehci1 { + status = "okay"; +}; diff --git a/arch/arm/dts/sun50i-a64.dtsi b/arch/arm/dts/sun50i-a64.dtsi index 7d0dc76a11..bef0d00be8 100644 --- a/arch/arm/dts/sun50i-a64.dtsi +++ b/arch/arm/dts/sun50i-a64.dtsi @@ -653,5 +653,34 @@ #address-cells = <1>; #size-cells = <0>; }; + + usbphy: phy@1c1b810 { + compatible = "allwinner,sun50i-a64-usb-phy", + "allwinner,sun8i-a33-usb-phy"; + reg = <0x01c1b810 0x14>, <0x01c1b800 0x4>; + reg-names = "phy_ctrl", "pmu1"; + status = "disabled"; + #phy-cells = <1>; + }; + + ehci1: usb@01c1b000 { + compatible = "allwinner,sun50i-a64-ehci", + "generic-ehci"; + reg = <0x01c1b000 0x100>; + interrupts = ; + phys = <&usbphy 1>; + phy-names = "usb"; + status = "disabled"; + }; + + ohci1: usb@01c1b400 { + compatible = "allwinner,sun50i-a64-ohci", + "generic-ohci"; + reg = <0x01c1b400 0x100>; + interrupts = ; + phys = <&usbphy 1>; + phy-names = "usb"; + status = "enabled"; + }; }; }; diff --git a/arch/arm/include/asm/arch-sunxi/cpu_sun4i.h b/arch/arm/include/asm/arch-sunxi/cpu_sun4i.h index 5f93830915..7232f6d927 100644 --- a/arch/arm/include/asm/arch-sunxi/cpu_sun4i.h +++ b/arch/arm/include/asm/arch-sunxi/cpu_sun4i.h @@ -56,7 +56,7 @@ #define SUNXI_USB2_BASE 0x01c1c000 #endif #ifdef CONFIG_SUNXI_GEN_SUN6I -#ifdef CONFIG_MACH_SUN8I_H3 +#if defined(CONFIG_MACH_SUN8I_H3) || defined(CONFIG_MACH_SUN50I) #define SUNXI_USBPHY_BASE 0x01c19000 #define SUNXI_USB0_BASE 0x01c1a000 #define SUNXI_USB1_BASE 0x01c1b000 diff --git a/arch/arm/mach-sunxi/usb_phy.c b/arch/arm/mach-sunxi/usb_phy.c index bd1bbee410..278587b493 100644 --- a/arch/arm/mach-sunxi/usb_phy.c +++ b/arch/arm/mach-sunxi/usb_phy.c @@ -146,12 +146,13 @@ __maybe_unused static void usb_phy_write(struct sunxi_usb_phy *phy, int addr, } } -#if defined CONFIG_MACH_SUN8I_H3 +#if defined(CONFIG_MACH_SUN8I_H3) || defined(CONFIG_MACH_SUN50I) static void sunxi_usb_phy_config(struct sunxi_usb_phy *phy) { +#if defined CONFIG_MACH_SUN8I_H3 if (phy->id == 0) clrbits_le32(SUNXI_USBPHY_BASE + REG_PHY_UNK_H3, 0x01); - +#endif clrbits_le32(phy->base + REG_PMU_UNK_H3, 0x02); } #elif defined CONFIG_MACH_SUN8I_A83T diff --git a/configs/pine64_plus_defconfig b/configs/pine64_plus_defconfig index 348cbd4841..6d0198f02c 100644 --- a/configs/pine64_plus_defconfig +++ b/configs/pine64_plus_defconfig @@ -11,3 +11,4 @@ CONFIG_CONSOLE_MUX=y # CONFIG_CMD_FLASH is not set # CONFIG_CMD_FPGA is not set CONFIG_SUN8I_EMAC=y +CONFIG_USB_EHCI_HCD=y diff --git a/drivers/usb/host/ehci-sunxi.c b/drivers/usb/host/ehci-sunxi.c index f2d83e34bc..5bb97ff45b 100644 --- a/drivers/usb/host/ehci-sunxi.c +++ b/drivers/usb/host/ehci-sunxi.c @@ -45,10 +45,10 @@ static int ehci_usb_probe(struct udevice *dev) * clocks resp. phys. */ priv->ahb_gate_mask = 1 << AHB_GATE_OFFSET_USB_EHCI0; -#ifdef CONFIG_MACH_SUN8I_H3 +#if defined(CONFIG_MACH_SUN8I_H3) || defined(CONFIG_MACH_SUN50I) extra_ahb_gate_mask = 1 << AHB_GATE_OFFSET_USB_OHCI0; #endif - priv->phy_index = ((u32)hccr - SUNXI_USB1_BASE) / BASE_DIST; + priv->phy_index = ((uintptr_t)hccr - SUNXI_USB1_BASE) / BASE_DIST; priv->ahb_gate_mask <<= priv->phy_index * AHB_CLK_DIST; extra_ahb_gate_mask <<= priv->phy_index * AHB_CLK_DIST; priv->phy_index++; /* Non otg phys start at 1 */ @@ -63,7 +63,7 @@ static int ehci_usb_probe(struct udevice *dev) sunxi_usb_phy_init(priv->phy_index); sunxi_usb_phy_power_on(priv->phy_index); - hcor = (struct ehci_hcor *)((uint32_t)hccr + + hcor = (struct ehci_hcor *)((uintptr_t)hccr + HC_LENGTH(ehci_readl(&hccr->cr_capbase))); return ehci_register(dev, hccr, hcor, NULL, 0, plat->init_type); @@ -98,6 +98,7 @@ static const struct udevice_id ehci_usb_ids[] = { { .compatible = "allwinner,sun8i-a83t-ehci", }, { .compatible = "allwinner,sun8i-h3-ehci", }, { .compatible = "allwinner,sun9i-a80-ehci", }, + { .compatible = "allwinner,sun50i-a64-ehci", }, { } }; diff --git a/drivers/usb/host/ohci-sunxi.c b/drivers/usb/host/ohci-sunxi.c index 2a1e8bf1e8..a44656e3c7 100644 --- a/drivers/usb/host/ohci-sunxi.c +++ b/drivers/usb/host/ohci-sunxi.c @@ -101,6 +101,7 @@ static const struct udevice_id ohci_usb_ids[] = { { .compatible = "allwinner,sun8i-a83t-ohci", }, { .compatible = "allwinner,sun8i-h3-ohci", }, { .compatible = "allwinner,sun9i-a80-ohci", }, + { .compatible = "allwinner,sun50i-a64-ohci", }, { } }; diff --git a/include/configs/sun50i.h b/include/configs/sun50i.h index 0fdb4c7b99..3e5708b493 100644 --- a/include/configs/sun50i.h +++ b/include/configs/sun50i.h @@ -11,6 +11,11 @@ * A64 specific configuration */ +#ifdef CONFIG_USB_EHCI +#define CONFIG_USB_EHCI_SUNXI +#define CONFIG_USB_MAX_CONTROLLER_COUNT 1 +#endif + #define CONFIG_SUNXI_USB_PHYS 1 #define COUNTER_FREQUENCY CONFIG_TIMER_CLK_FREQ From fed329aebe3aaac0928c73547ac6316af2adf0cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Br=C3=BCns?= Date: Sat, 29 Oct 2016 12:23:18 +0200 Subject: [PATCH 6/6] tools: add mksunxiboot to tools-all target MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit mksunxiboot is useful outside of u-boot, it is e.g. used by sunxi-tools. Signed-off-by: Stefan BrĂ¼ns Signed-off-by: Hans de Goede --- tools/Makefile | 1 + tools/mksunxiboot.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/Makefile b/tools/Makefile index 556f397bb8..400588cf0f 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -13,6 +13,7 @@ CONFIG_CMD_NET = y CONFIG_XWAY_SWAP_BYTES = y CONFIG_NETCONSOLE = y CONFIG_SHA1_CHECK_UB_IMG = y +CONFIG_SUNXI = y endif subdir-$(HOST_TOOLS_ALL) += easylogo diff --git a/tools/mksunxiboot.c b/tools/mksunxiboot.c index 9c1c5b7cee..0f0b003a83 100644 --- a/tools/mksunxiboot.c +++ b/tools/mksunxiboot.c @@ -15,7 +15,7 @@ #include #include #include -#include "asm/arch/spl.h" +#include "../arch/arm/include/asm/arch-sunxi/spl.h" #define STAMP_VALUE 0x5F0A6C39