diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile index 86808dc22e..02de856efc 100644 --- a/arch/arm/dts/Makefile +++ b/arch/arm/dts/Makefile @@ -646,7 +646,8 @@ dtb-$(CONFIG_MACH_SUN50I_H6) += \ sun50i-h6-pine-h64-model-b.dtb \ sun50i-h6-tanix-tx6.dtb dtb-$(CONFIG_MACH_SUN50I_H616) += \ - sun50i-h616-bananapi-m4berry.dtb \ + sun50i-h618-bananapi-m4berry.dtb \ + sun50i-h618-bananapi-m4zero.dtb \ sun50i-h616-orangepi-zero2.dtb \ sun50i-h616-orangepi-zero2-b.dtb \ sun50i-h616-orangepi-zero2-lts.dtb \ diff --git a/arch/arm/dts/sun50i-h616-bananapi-m4berry.dts b/arch/arm/dts/sun50i-h618-bananapi-m4berry.dts similarity index 87% rename from arch/arm/dts/sun50i-h616-bananapi-m4berry.dts rename to arch/arm/dts/sun50i-h618-bananapi-m4berry.dts index 253fa620c1..288c0141c2 100644 --- a/arch/arm/dts/sun50i-h616-bananapi-m4berry.dts +++ b/arch/arm/dts/sun50i-h618-bananapi-m4berry.dts @@ -6,7 +6,7 @@ /dts-v1/; #include "sun50i-h616.dtsi" -#include "sunxi-common-regulators.dtsi" + #include #include #include @@ -28,9 +28,9 @@ compatible = "gpio-leds"; led-0 { - function = LED_FUNCTION_POWER; - color = ; - gpios = <&pio 2 12 GPIO_ACTIVE_HIGH>; /* PC12 */ + function = LED_FUNCTION_STATUS; + color = ; + gpios = <&pio 2 12 GPIO_ACTIVE_LOW>; /* PC12 */ default-state = "on"; }; @@ -45,6 +45,16 @@ regulator-always-on; }; + reg_usb1_vbus: usb1-vbus { + compatible = "regulator-fixed"; + regulator-name = "usb1-vbus"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + vin-supply = <®_vcc5v>; + regulator-always-on; + + status = "okay"; + }; }; &ehci0 { @@ -75,7 +85,7 @@ }; &mmc0 { - vmmc-supply = <®_vcc3v3>; + cd-gpios = <&pio 5 6 GPIO_ACTIVE_LOW>; /* PF6 */ bus-width = <4>; status = "okay"; @@ -85,8 +95,7 @@ &mmc2 { pinctrl-names = "default"; pinctrl-0 = <&mmc2_pins>; - vmmc-supply = <®_vcc3v3>; - vqmmc-supply = <®_vcc3v3>; + bus-width = <8>; non-removable; status = "okay"; @@ -174,3 +183,7 @@ status = "okay"; }; +&usbphy { + usb1_vbus-supply = <®_usb1_vbus>; + status = "okay"; +}; \ No newline at end of file diff --git a/arch/arm/dts/sun50i-h618-bananapi-m4zero.dts b/arch/arm/dts/sun50i-h618-bananapi-m4zero.dts new file mode 100644 index 0000000000..dc0a9f8fb0 --- /dev/null +++ b/arch/arm/dts/sun50i-h618-bananapi-m4zero.dts @@ -0,0 +1,190 @@ +// SPDX-License-Identifier: (GPL-2.0+ or MIT) +/* + * Copyright (C) 2020 Arm Ltd. + */ + +/dts-v1/; + +#include "sun50i-h616.dtsi" + +#include +#include +#include + +/ { + model = "Banana Pi M4 Zero"; + compatible = "bananapi,bananapi-m4zero", "allwinner,sun50i-h616"; + + aliases { + ethernet0 = &emac0; + serial0 = &uart0; + }; + + chosen { + stdout-path = "serial0:115200n8"; + }; + + leds { + compatible = "gpio-leds"; + + led-0 { + function = LED_FUNCTION_STATUS; + color = ; + gpios = <&pio 2 12 GPIO_ACTIVE_LOW>; /* PC12 */ + default-state = "on"; + }; + + }; + + reg_vcc5v: vcc5v { + /* board wide 5V supply directly from the USB-C socket */ + compatible = "regulator-fixed"; + regulator-name = "vcc-5v"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + regulator-always-on; + }; + + reg_usb1_vbus: usb1-vbus { + compatible = "regulator-fixed"; + regulator-name = "usb1-vbus"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + vin-supply = <®_vcc5v>; + regulator-always-on; + + status = "okay"; + }; +}; + +&ehci0 { + status = "okay"; +}; + +&ehci1 { + status = "okay"; +}; + +/* USB 2 & 3 are on headers only. */ + +&emac0 { + pinctrl-names = "default"; + pinctrl-0 = <&ext_rgmii_pins>; + phy-mode = "rgmii"; + phy-handle = <&ext_rgmii_phy>; + allwinner,rx-delay-ps = <3100>; + allwinner,tx-delay-ps = <700>; + status = "okay"; +}; + +&mdio0 { + ext_rgmii_phy: ethernet-phy@1 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <1>; + }; +}; + +&mmc0 { + + cd-gpios = <&pio 5 6 GPIO_ACTIVE_HIGH>; /* PF6 */ + bus-width = <4>; + non-removable; + status = "okay"; +}; + + +&mmc2 { + pinctrl-names = "default"; + pinctrl-0 = <&mmc2_pins>; + + bus-width = <8>; + non-removable; + status = "okay"; +}; + +&ohci0 { + status = "okay"; +}; + +&ohci1 { + status = "okay"; +}; + +&r_i2c { + status = "okay"; + + axp313a: pmic@36 { + compatible = "x-powers,axp313a"; + status = "okay"; + reg = <0x36>; + wakeup-source; + + standby_param: standby_param { + vcc-dram = <0x4>; + }; + + regulators{ + reg_dcdc1: dcdc1 { + regulator-name = "axp313a-dcdc1"; + regulator-min-microvolt = <500000>; + regulator-max-microvolt = <3400000>; + regulator-step-delay-us = <25>; + regulator-final-delay-us = <50>; + regulator-always-on; + }; + + reg_dcdc2: dcdc2 { + regulator-name = "axp313a-dcdc2"; + regulator-min-microvolt = <500000>; + regulator-max-microvolt = <1540000>; + regulator-step-delay-us = <25>; + regulator-final-delay-us = <50>; + regulator-ramp-delay = <200>; + regulator-always-on; + }; + + reg_dcdc3: dcdc3 { + regulator-name = "axp313a-dcdc3"; + regulator-min-microvolt = <1100000>; + regulator-max-microvolt = <1100000>; + regulator-step-delay-us = <25>; + regulator-final-delay-us = <50>; + regulator-always-on; + }; + + reg_aldo1: aldo1 { + regulator-name = "axp313a-aldo1"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + regulator-step-delay-us = <25>; + regulator-final-delay-us = <50>; + regulator-always-on; + }; + + reg_dldo1: dldo1 { + regulator-name = "axp313a-dldo1"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + regulator-step-delay-us = <25>; + regulator-final-delay-us = <50>; + regulator-always-on; + }; + }; + }; +}; + +&uart0 { + pinctrl-names = "default"; + pinctrl-0 = <&uart0_ph_pins>; + status = "okay"; +}; + +&usbotg { + dr_mode = "peripheral"; + status = "okay"; +}; + +&usbphy { + usb1_vbus-supply = <®_usb1_vbus>; + status = "okay"; +}; \ No newline at end of file diff --git a/arch/arm/include/asm/arch-sunxi/mmc.h b/arch/arm/include/asm/arch-sunxi/mmc.h index 340e25b04d..55ec9a212e 100644 --- a/arch/arm/include/asm/arch-sunxi/mmc.h +++ b/arch/arm/include/asm/arch-sunxi/mmc.h @@ -119,6 +119,7 @@ struct sunxi_mmc { #define SUNXI_MMC_STATUS_CARD_PRESENT (0x1 << 8) #define SUNXI_MMC_STATUS_CARD_DATA_BUSY (0x1 << 9) #define SUNXI_MMC_STATUS_DATA_FSM_BUSY (0x1 << 10) +#define SUNXI_MMC_STATUS_FIFO_LEVEL(reg) (((reg) >> 17) & 0x3fff) #define SUNXI_MMC_NTSR_MODE_SEL_NEW (0x1 << 31) @@ -135,4 +136,4 @@ struct sunxi_mmc { #define SUNXI_MMC_CAL_DL_SW_EN (0x1 << 7) struct mmc *sunxi_mmc_init(int sdc_no); -#endif /* _SUNXI_MMC_H */ +#endif /* _SUNXI_MMC_H */ \ No newline at end of file diff --git a/board/sunxi/board.c b/board/sunxi/board.c index 87f1ffe154..211628132b 100644 --- a/board/sunxi/board.c +++ b/board/sunxi/board.c @@ -582,7 +582,7 @@ static void mmc_pinmux_setup(int sdc) continue; sunxi_gpio_set_cfgpin(pin, SUNXI_GPC_SDC2); sunxi_gpio_set_pull(pin, SUNXI_GPIO_PULL_UP); - sunxi_gpio_set_drv(pin, 2); + sunxi_gpio_set_drv(pin, 3); } #elif defined(CONFIG_MACH_SUN9I) /* SDC2: PC6-PC16 */ @@ -1168,4 +1168,4 @@ int board_fit_config_name_match(const char *name) return ret; } -#endif +#endif \ No newline at end of file diff --git a/configs/bananapi_m4berry_defconfig b/configs/bananapi_m4berry_defconfig index 804eae0515..71dee15fb0 100644 --- a/configs/bananapi_m4berry_defconfig +++ b/configs/bananapi_m4berry_defconfig @@ -1,6 +1,6 @@ CONFIG_ARM=y CONFIG_ARCH_SUNXI=y -CONFIG_DEFAULT_DEVICE_TREE="sun50i-h616-bananapi-m4berry" +CONFIG_DEFAULT_DEVICE_TREE="sun50i-h618-bananapi-m4berry" CONFIG_SPL=y CONFIG_DRAM_CLK=792 CONFIG_SUNXI_DRAM_H616_LPDDR4=y diff --git a/configs/bananapi_m4zero_defconfig b/configs/bananapi_m4zero_defconfig new file mode 100644 index 0000000000..8857b0aed2 --- /dev/null +++ b/configs/bananapi_m4zero_defconfig @@ -0,0 +1,18 @@ +CONFIG_ARM=y +CONFIG_ARCH_SUNXI=y +CONFIG_DEFAULT_DEVICE_TREE="sun50i-h618-bananapi-m4zero" +CONFIG_SPL=y +CONFIG_DRAM_CLK=792 +CONFIG_SUNXI_DRAM_H616_LPDDR4=y +CONFIG_DRAM_SUN50I_H616_READ_CALIBRATION=y +CONFIG_DRAM_SUN50I_H616_UNKNOWN_FEATURE=y +CONFIG_DRAM_SUN50I_H616_BIT_DELAY_COMPENSATION=y +# CONFIG_DRAM_SUN50I_H616_TRIM_SIZE is not set +CONFIG_MACH_SUN50I_H616=y +CONFIG_MMC0_CD_PIN="PF6" +CONFIG_MMC_SUNXI_SLOT_EXTRA=2 +CONFIG_R_I2C_ENABLE=y +# CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set +CONFIG_AXP_DCDC3_VOLT=1100 +CONFIG_SPL_I2C_SUPPORT=y +CONFIG_AXP313A_POWER=y \ No newline at end of file diff --git a/drivers/mmc/sunxi_mmc.c b/drivers/mmc/sunxi_mmc.c index 3503ccdb2e..b9529e86fd 100644 --- a/drivers/mmc/sunxi_mmc.c +++ b/drivers/mmc/sunxi_mmc.c @@ -86,6 +86,7 @@ static int mmc_resource_init(int sdc_no) } priv->mmc_no = sdc_no; +#ifdef BPI cd_pin = sunxi_mmc_getcd_gpio(sdc_no); if (cd_pin >= 0) { ret = gpio_request(cd_pin, "mmc_cd"); @@ -94,6 +95,12 @@ static int mmc_resource_init(int sdc_no) ret = gpio_direction_input(cd_pin); } } +#else + if(1) { + printf("BPI: skip sunxi_mmc_getcd_gpio %d\n", sdc_no); + ret=0; + } +#endif return ret; } @@ -303,8 +310,9 @@ static int mmc_trans_data_by_cpu(struct sunxi_mmc_priv *priv, struct mmc *mmc, SUNXI_MMC_STATUS_FIFO_FULL; unsigned i; unsigned *buff = (unsigned int *)(reading ? data->dest : data->src); - unsigned byte_cnt = data->blocksize * data->blocks; - unsigned timeout_msecs = byte_cnt >> 8; + unsigned word_cnt = (data->blocksize * data->blocks) >> 2; + unsigned timeout_msecs = word_cnt >> 6; + uint32_t status; unsigned long start; if (timeout_msecs < 2000) @@ -315,16 +323,42 @@ static int mmc_trans_data_by_cpu(struct sunxi_mmc_priv *priv, struct mmc *mmc, start = get_timer(0); - for (i = 0; i < (byte_cnt >> 2); i++) { - while (readl(&priv->reg->status) & status_bit) { + for (i = 0; i < word_cnt;) { + unsigned int in_fifo; + + while ((status = readl(&priv->reg->status)) & status_bit) { if (get_timer(start) > timeout_msecs) return -1; } - if (reading) - buff[i] = readl(&priv->reg->fifo); - else - writel(buff[i], &priv->reg->fifo); + /* + * For writing we do not easily know the FIFO size, so have + * to check the FIFO status after every word written. + * TODO: For optimisation we could work out a minimum FIFO + * size across all SoCs, and use that together with the current + * fill level to write chunks of words. + */ + if (!reading) { + writel(buff[i++], &priv->reg->fifo); + continue; + } + + /* + * The status register holds the current FIFO level, so we + * can be sure to collect as many words from the FIFO + * register without checking the status register after every + * read. That saves half of the costly MMIO reads, effectively + * doubling the read performance. + * Some SoCs (A20) report a level of 0 if the FIFO is + * completely full (value masked out?). Use a safe minimal + * FIFO size in this case. + */ + in_fifo = SUNXI_MMC_STATUS_FIFO_LEVEL(status); + if (in_fifo == 0 && (status & SUNXI_MMC_STATUS_FIFO_FULL)) + in_fifo = 32; + for (; in_fifo > 0; in_fifo--) + buff[i++] = readl_relaxed(&priv->reg->fifo); + dmb(); } return 0; @@ -531,6 +565,17 @@ struct mmc *sunxi_mmc_init(int sdc_no) cfg->f_min = 400000; cfg->f_max = 52000000; +#ifdef BPI +#else + printf("BPI: init mmc %d clock(%d) and io\n", sdc_no, cfg->f_max); + if(sdc_no==2) { + cfg->f_max = 2000000; + cfg->f_max = 12000000; + cfg->f_max = 8000000; + printf("BPI: init mmc %d clock(%d) and io\n", sdc_no, cfg->f_max); + } +#endif + if (mmc_resource_init(sdc_no) != 0) return NULL; @@ -633,6 +678,15 @@ static int sunxi_mmc_probe(struct udevice *dev) cfg->f_min = 400000; cfg->f_max = 52000000; +#ifdef BPI +else + if (bus_width == 8) { + cfg->f_max = 2000000; + cfg->f_max = 12000000; + cfg->f_max = 8000000; + printf("BPI: init mmc %d clock(%d) and io\n", 2, cfg->f_max); + } +#endif priv->reg = (void *)dev_read_addr(dev); @@ -711,4 +765,4 @@ U_BOOT_DRIVER(sunxi_mmc_drv) = { .plat_auto = sizeof(struct sunxi_mmc_plat), .priv_auto = sizeof(struct sunxi_mmc_priv), }; -#endif +#endif \ No newline at end of file